moralis.js 2.7 MB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495449644974498449945004501450245034504450545064507450845094510451145124513451445154516451745184519452045214522452345244525452645274528452945304531453245334534453545364537453845394540454145424543454445454546454745484549455045514552455345544555455645574558455945604561456245634564456545664567456845694570457145724573457445754576457745784579458045814582458345844585458645874588458945904591459245934594459545964597459845994600460146024603460446054606460746084609461046114612461346144615461646174618461946204621462246234624462546264627462846294630463146324633463446354636463746384639464046414642464346444645464646474648464946504651465246534654465546564657465846594660466146624663466446654666466746684669467046714672467346744675467646774678467946804681468246834684468546864687468846894690469146924693469446954696469746984699470047014702470347044705470647074708470947104711471247134714471547164717471847194720472147224723472447254726472747284729473047314732473347344735473647374738473947404741474247434744474547464747474847494750475147524753475447554756475747584759476047614762476347644765476647674768476947704771477247734774477547764777477847794780478147824783478447854786478747884789479047914792479347944795479647974798479948004801480248034804480548064807480848094810481148124813481448154816481748184819482048214822482348244825482648274828482948304831483248334834483548364837483848394840484148424843484448454846484748484849485048514852485348544855485648574858485948604861486248634864486548664867486848694870487148724873487448754876487748784879488048814882488348844885488648874888488948904891489248934894489548964897489848994900490149024903490449054906490749084909491049114912491349144915491649174918491949204921492249234924492549264927492849294930493149324933493449354936493749384939494049414942494349444945494649474948494949504951495249534954495549564957495849594960496149624963496449654966496749684969497049714972497349744975497649774978497949804981498249834984498549864987498849894990499149924993499449954996499749984999500050015002500350045005500650075008500950105011501250135014501550165017501850195020502150225023502450255026502750285029503050315032503350345035503650375038503950405041504250435044504550465047504850495050505150525053505450555056505750585059506050615062506350645065506650675068506950705071507250735074507550765077507850795080508150825083508450855086508750885089509050915092509350945095509650975098509951005101510251035104510551065107510851095110511151125113511451155116511751185119512051215122512351245125512651275128512951305131513251335134513551365137513851395140514151425143514451455146514751485149515051515152515351545155515651575158515951605161516251635164516551665167516851695170517151725173517451755176517751785179518051815182518351845185518651875188518951905191519251935194519551965197519851995200520152025203520452055206520752085209521052115212521352145215521652175218521952205221522252235224522552265227522852295230523152325233523452355236523752385239524052415242524352445245524652475248524952505251525252535254525552565257525852595260526152625263526452655266526752685269527052715272527352745275527652775278527952805281528252835284528552865287528852895290529152925293529452955296529752985299530053015302530353045305530653075308530953105311531253135314531553165317531853195320532153225323532453255326532753285329533053315332533353345335533653375338533953405341534253435344534553465347534853495350535153525353535453555356535753585359536053615362536353645365536653675368536953705371537253735374537553765377537853795380538153825383538453855386538753885389539053915392539353945395539653975398539954005401540254035404540554065407540854095410541154125413541454155416541754185419542054215422542354245425542654275428542954305431543254335434543554365437543854395440544154425443544454455446544754485449545054515452545354545455545654575458545954605461546254635464546554665467546854695470547154725473547454755476547754785479548054815482548354845485548654875488548954905491549254935494549554965497549854995500550155025503550455055506550755085509551055115512551355145515551655175518551955205521552255235524552555265527552855295530553155325533553455355536553755385539554055415542554355445545554655475548554955505551555255535554555555565557555855595560556155625563556455655566556755685569557055715572557355745575557655775578557955805581558255835584558555865587558855895590559155925593559455955596559755985599560056015602560356045605560656075608560956105611561256135614561556165617561856195620562156225623562456255626562756285629563056315632563356345635563656375638563956405641564256435644564556465647564856495650565156525653565456555656565756585659566056615662566356645665566656675668566956705671567256735674567556765677567856795680568156825683568456855686568756885689569056915692569356945695569656975698569957005701570257035704570557065707570857095710571157125713571457155716571757185719572057215722572357245725572657275728572957305731573257335734573557365737573857395740574157425743574457455746574757485749575057515752575357545755575657575758575957605761576257635764576557665767576857695770577157725773577457755776577757785779578057815782578357845785578657875788578957905791579257935794579557965797579857995800580158025803580458055806580758085809581058115812581358145815581658175818581958205821582258235824582558265827582858295830583158325833583458355836583758385839584058415842584358445845584658475848584958505851585258535854585558565857585858595860586158625863586458655866586758685869587058715872587358745875587658775878587958805881588258835884588558865887588858895890589158925893589458955896589758985899590059015902590359045905590659075908590959105911591259135914591559165917591859195920592159225923592459255926592759285929593059315932593359345935593659375938593959405941594259435944594559465947594859495950595159525953595459555956595759585959596059615962596359645965596659675968596959705971597259735974597559765977597859795980598159825983598459855986598759885989599059915992599359945995599659975998599960006001600260036004600560066007600860096010601160126013601460156016601760186019602060216022602360246025602660276028602960306031603260336034603560366037603860396040604160426043604460456046604760486049605060516052605360546055605660576058605960606061606260636064606560666067606860696070607160726073607460756076607760786079608060816082608360846085608660876088608960906091609260936094609560966097609860996100610161026103610461056106610761086109611061116112611361146115611661176118611961206121612261236124612561266127612861296130613161326133613461356136613761386139614061416142614361446145614661476148614961506151615261536154615561566157615861596160616161626163616461656166616761686169617061716172617361746175617661776178617961806181618261836184618561866187618861896190619161926193619461956196619761986199620062016202620362046205620662076208620962106211621262136214621562166217621862196220622162226223622462256226622762286229623062316232623362346235623662376238623962406241624262436244624562466247624862496250625162526253625462556256625762586259626062616262626362646265626662676268626962706271627262736274627562766277627862796280628162826283628462856286628762886289629062916292629362946295629662976298629963006301630263036304630563066307630863096310631163126313631463156316631763186319632063216322632363246325632663276328632963306331633263336334633563366337633863396340634163426343634463456346634763486349635063516352635363546355635663576358635963606361636263636364636563666367636863696370637163726373637463756376637763786379638063816382638363846385638663876388638963906391639263936394639563966397639863996400640164026403640464056406640764086409641064116412641364146415641664176418641964206421642264236424642564266427642864296430643164326433643464356436643764386439644064416442644364446445644664476448644964506451645264536454645564566457645864596460646164626463646464656466646764686469647064716472647364746475647664776478647964806481648264836484648564866487648864896490649164926493649464956496649764986499650065016502650365046505650665076508650965106511651265136514651565166517651865196520652165226523652465256526652765286529653065316532653365346535653665376538653965406541654265436544654565466547654865496550655165526553655465556556655765586559656065616562656365646565656665676568656965706571657265736574657565766577657865796580658165826583658465856586658765886589659065916592659365946595659665976598659966006601660266036604660566066607660866096610661166126613661466156616661766186619662066216622662366246625662666276628662966306631663266336634663566366637663866396640664166426643664466456646664766486649665066516652665366546655665666576658665966606661666266636664666566666667666866696670667166726673667466756676667766786679668066816682668366846685668666876688668966906691669266936694669566966697669866996700670167026703670467056706670767086709671067116712671367146715671667176718671967206721672267236724672567266727672867296730673167326733673467356736673767386739674067416742674367446745674667476748674967506751675267536754675567566757675867596760676167626763676467656766676767686769677067716772677367746775677667776778677967806781678267836784678567866787678867896790679167926793679467956796679767986799680068016802680368046805680668076808680968106811681268136814681568166817681868196820682168226823682468256826682768286829683068316832683368346835683668376838683968406841684268436844684568466847684868496850685168526853685468556856685768586859686068616862686368646865686668676868686968706871687268736874687568766877687868796880688168826883688468856886688768886889689068916892689368946895689668976898689969006901690269036904690569066907690869096910691169126913691469156916691769186919692069216922692369246925692669276928692969306931693269336934693569366937693869396940694169426943694469456946694769486949695069516952695369546955695669576958695969606961696269636964696569666967696869696970697169726973697469756976697769786979698069816982698369846985698669876988698969906991699269936994699569966997699869997000700170027003700470057006700770087009701070117012701370147015701670177018701970207021702270237024702570267027702870297030703170327033703470357036703770387039704070417042704370447045704670477048704970507051705270537054705570567057705870597060706170627063706470657066706770687069707070717072707370747075707670777078707970807081708270837084708570867087708870897090709170927093709470957096709770987099710071017102710371047105710671077108710971107111711271137114711571167117711871197120712171227123712471257126712771287129713071317132713371347135713671377138713971407141714271437144714571467147714871497150715171527153715471557156715771587159716071617162716371647165716671677168716971707171717271737174717571767177717871797180718171827183718471857186718771887189719071917192719371947195719671977198719972007201720272037204720572067207720872097210721172127213721472157216721772187219722072217222722372247225722672277228722972307231723272337234723572367237723872397240724172427243724472457246724772487249725072517252725372547255725672577258725972607261726272637264726572667267726872697270727172727273727472757276727772787279728072817282728372847285728672877288728972907291729272937294729572967297729872997300730173027303730473057306730773087309731073117312731373147315731673177318731973207321732273237324732573267327732873297330733173327333733473357336733773387339734073417342734373447345734673477348734973507351735273537354735573567357735873597360736173627363736473657366736773687369737073717372737373747375737673777378737973807381738273837384738573867387738873897390739173927393739473957396739773987399740074017402740374047405740674077408740974107411741274137414741574167417741874197420742174227423742474257426742774287429743074317432743374347435743674377438743974407441744274437444744574467447744874497450745174527453745474557456745774587459746074617462746374647465746674677468746974707471747274737474747574767477747874797480748174827483748474857486748774887489749074917492749374947495749674977498749975007501750275037504750575067507750875097510751175127513751475157516751775187519752075217522752375247525752675277528752975307531753275337534753575367537753875397540754175427543754475457546754775487549755075517552755375547555755675577558755975607561756275637564756575667567756875697570757175727573757475757576757775787579758075817582758375847585758675877588758975907591759275937594759575967597759875997600760176027603760476057606760776087609761076117612761376147615761676177618761976207621762276237624762576267627762876297630763176327633763476357636763776387639764076417642764376447645764676477648764976507651765276537654765576567657765876597660766176627663766476657666766776687669767076717672767376747675767676777678767976807681768276837684768576867687768876897690769176927693769476957696769776987699770077017702770377047705770677077708770977107711771277137714771577167717771877197720772177227723772477257726772777287729773077317732773377347735773677377738773977407741774277437744774577467747774877497750775177527753775477557756775777587759776077617762776377647765776677677768776977707771777277737774777577767777777877797780778177827783778477857786778777887789779077917792779377947795779677977798779978007801780278037804780578067807780878097810781178127813781478157816781778187819782078217822782378247825782678277828782978307831783278337834783578367837783878397840784178427843784478457846784778487849785078517852785378547855785678577858785978607861786278637864786578667867786878697870787178727873787478757876787778787879788078817882788378847885788678877888788978907891789278937894789578967897789878997900790179027903790479057906790779087909791079117912791379147915791679177918791979207921792279237924792579267927792879297930793179327933793479357936793779387939794079417942794379447945794679477948794979507951795279537954795579567957795879597960796179627963796479657966796779687969797079717972797379747975797679777978797979807981798279837984798579867987798879897990799179927993799479957996799779987999800080018002800380048005800680078008800980108011801280138014801580168017801880198020802180228023802480258026802780288029803080318032803380348035803680378038803980408041804280438044804580468047804880498050805180528053805480558056805780588059806080618062806380648065806680678068806980708071807280738074807580768077807880798080808180828083808480858086808780888089809080918092809380948095809680978098809981008101810281038104810581068107810881098110811181128113811481158116811781188119812081218122812381248125812681278128812981308131813281338134813581368137813881398140814181428143814481458146814781488149815081518152815381548155815681578158815981608161816281638164816581668167816881698170817181728173817481758176817781788179818081818182818381848185818681878188818981908191819281938194819581968197819881998200820182028203820482058206820782088209821082118212821382148215821682178218821982208221822282238224822582268227822882298230823182328233823482358236823782388239824082418242824382448245824682478248824982508251825282538254825582568257825882598260826182628263826482658266826782688269827082718272827382748275827682778278827982808281828282838284828582868287828882898290829182928293829482958296829782988299830083018302830383048305830683078308830983108311831283138314831583168317831883198320832183228323832483258326832783288329833083318332833383348335833683378338833983408341834283438344834583468347834883498350835183528353835483558356835783588359836083618362836383648365836683678368836983708371837283738374837583768377837883798380838183828383838483858386838783888389839083918392839383948395839683978398839984008401840284038404840584068407840884098410841184128413841484158416841784188419842084218422842384248425842684278428842984308431843284338434843584368437843884398440844184428443844484458446844784488449845084518452845384548455845684578458845984608461846284638464846584668467846884698470847184728473847484758476847784788479848084818482848384848485848684878488848984908491849284938494849584968497849884998500850185028503850485058506850785088509851085118512851385148515851685178518851985208521852285238524852585268527852885298530853185328533853485358536853785388539854085418542854385448545854685478548854985508551855285538554855585568557855885598560856185628563856485658566856785688569857085718572857385748575857685778578857985808581858285838584858585868587858885898590859185928593859485958596859785988599860086018602860386048605860686078608860986108611861286138614861586168617861886198620862186228623862486258626862786288629863086318632863386348635863686378638863986408641864286438644864586468647864886498650865186528653865486558656865786588659866086618662866386648665866686678668866986708671867286738674867586768677867886798680868186828683868486858686868786888689869086918692869386948695869686978698869987008701870287038704870587068707870887098710871187128713871487158716871787188719872087218722872387248725872687278728872987308731873287338734873587368737873887398740874187428743874487458746874787488749875087518752875387548755875687578758875987608761876287638764876587668767876887698770877187728773877487758776877787788779878087818782878387848785878687878788878987908791879287938794879587968797879887998800880188028803880488058806880788088809881088118812881388148815881688178818881988208821882288238824882588268827882888298830883188328833883488358836883788388839884088418842884388448845884688478848884988508851885288538854885588568857885888598860886188628863886488658866886788688869887088718872887388748875887688778878887988808881888288838884888588868887888888898890889188928893889488958896889788988899890089018902890389048905890689078908890989108911891289138914891589168917891889198920892189228923892489258926892789288929893089318932893389348935893689378938893989408941894289438944894589468947894889498950895189528953895489558956895789588959896089618962896389648965896689678968896989708971897289738974897589768977897889798980898189828983898489858986898789888989899089918992899389948995899689978998899990009001900290039004900590069007900890099010901190129013901490159016901790189019902090219022902390249025902690279028902990309031903290339034903590369037903890399040904190429043904490459046904790489049905090519052905390549055905690579058905990609061906290639064906590669067906890699070907190729073907490759076907790789079908090819082908390849085908690879088908990909091909290939094909590969097909890999100910191029103910491059106910791089109911091119112911391149115911691179118911991209121912291239124912591269127912891299130913191329133913491359136913791389139914091419142914391449145914691479148914991509151915291539154915591569157915891599160916191629163916491659166916791689169917091719172917391749175917691779178917991809181918291839184918591869187918891899190919191929193919491959196919791989199920092019202920392049205920692079208920992109211921292139214921592169217921892199220922192229223922492259226922792289229923092319232923392349235923692379238923992409241924292439244924592469247924892499250925192529253925492559256925792589259926092619262926392649265926692679268926992709271927292739274927592769277927892799280928192829283928492859286928792889289929092919292929392949295929692979298929993009301930293039304930593069307930893099310931193129313931493159316931793189319932093219322932393249325932693279328932993309331933293339334933593369337933893399340934193429343934493459346934793489349935093519352935393549355935693579358935993609361936293639364936593669367936893699370937193729373937493759376937793789379938093819382938393849385938693879388938993909391939293939394939593969397939893999400940194029403940494059406940794089409941094119412941394149415941694179418941994209421942294239424942594269427942894299430943194329433943494359436943794389439944094419442944394449445944694479448944994509451945294539454945594569457945894599460946194629463946494659466946794689469947094719472947394749475947694779478947994809481948294839484948594869487948894899490949194929493949494959496949794989499950095019502950395049505950695079508950995109511951295139514951595169517951895199520952195229523952495259526952795289529953095319532953395349535953695379538953995409541954295439544954595469547954895499550955195529553955495559556955795589559956095619562956395649565956695679568956995709571957295739574957595769577957895799580958195829583958495859586958795889589959095919592959395949595959695979598959996009601960296039604960596069607960896099610961196129613961496159616961796189619962096219622962396249625962696279628962996309631963296339634963596369637963896399640964196429643964496459646964796489649965096519652965396549655965696579658965996609661966296639664966596669667966896699670967196729673967496759676967796789679968096819682968396849685968696879688968996909691969296939694969596969697969896999700970197029703970497059706970797089709971097119712971397149715971697179718971997209721972297239724972597269727972897299730973197329733973497359736973797389739974097419742974397449745974697479748974997509751975297539754975597569757975897599760976197629763976497659766976797689769977097719772977397749775977697779778977997809781978297839784978597869787978897899790979197929793979497959796979797989799980098019802980398049805980698079808980998109811981298139814981598169817981898199820982198229823982498259826982798289829983098319832983398349835983698379838983998409841984298439844984598469847984898499850985198529853985498559856985798589859986098619862986398649865986698679868986998709871987298739874987598769877987898799880988198829883988498859886988798889889989098919892989398949895989698979898989999009901990299039904990599069907990899099910991199129913991499159916991799189919992099219922992399249925992699279928992999309931993299339934993599369937993899399940994199429943994499459946994799489949995099519952995399549955995699579958995999609961996299639964996599669967996899699970997199729973997499759976997799789979998099819982998399849985998699879988998999909991999299939994999599969997999899991000010001100021000310004100051000610007100081000910010100111001210013100141001510016100171001810019100201002110022100231002410025100261002710028100291003010031100321003310034100351003610037100381003910040100411004210043100441004510046100471004810049100501005110052100531005410055100561005710058100591006010061100621006310064100651006610067100681006910070100711007210073100741007510076100771007810079100801008110082100831008410085100861008710088100891009010091100921009310094100951009610097100981009910100101011010210103101041010510106101071010810109101101011110112101131011410115101161011710118101191012010121101221012310124101251012610127101281012910130101311013210133101341013510136101371013810139101401014110142101431014410145101461014710148101491015010151101521015310154101551015610157101581015910160101611016210163101641016510166101671016810169101701017110172101731017410175101761017710178101791018010181101821018310184101851018610187101881018910190101911019210193101941019510196101971019810199102001020110202102031020410205102061020710208102091021010211102121021310214102151021610217102181021910220102211022210223102241022510226102271022810229102301023110232102331023410235102361023710238102391024010241102421024310244102451024610247102481024910250102511025210253102541025510256102571025810259102601026110262102631026410265102661026710268102691027010271102721027310274102751027610277102781027910280102811028210283102841028510286102871028810289102901029110292102931029410295102961029710298102991030010301103021030310304103051030610307103081030910310103111031210313103141031510316103171031810319103201032110322103231032410325103261032710328103291033010331103321033310334103351033610337103381033910340103411034210343103441034510346103471034810349103501035110352103531035410355103561035710358103591036010361103621036310364103651036610367103681036910370103711037210373103741037510376103771037810379103801038110382103831038410385103861038710388103891039010391103921039310394103951039610397103981039910400104011040210403104041040510406104071040810409104101041110412104131041410415104161041710418104191042010421104221042310424104251042610427104281042910430104311043210433104341043510436104371043810439104401044110442104431044410445104461044710448104491045010451104521045310454104551045610457104581045910460104611046210463104641046510466104671046810469104701047110472104731047410475104761047710478104791048010481104821048310484104851048610487104881048910490104911049210493104941049510496104971049810499105001050110502105031050410505105061050710508105091051010511105121051310514105151051610517105181051910520105211052210523105241052510526105271052810529105301053110532105331053410535105361053710538105391054010541105421054310544105451054610547105481054910550105511055210553105541055510556105571055810559105601056110562105631056410565105661056710568105691057010571105721057310574105751057610577105781057910580105811058210583105841058510586105871058810589105901059110592105931059410595105961059710598105991060010601106021060310604106051060610607106081060910610106111061210613106141061510616106171061810619106201062110622106231062410625106261062710628106291063010631106321063310634106351063610637106381063910640106411064210643106441064510646106471064810649106501065110652106531065410655106561065710658106591066010661106621066310664106651066610667106681066910670106711067210673106741067510676106771067810679106801068110682106831068410685106861068710688106891069010691106921069310694106951069610697106981069910700107011070210703107041070510706107071070810709107101071110712107131071410715107161071710718107191072010721107221072310724107251072610727107281072910730107311073210733107341073510736107371073810739107401074110742107431074410745107461074710748107491075010751107521075310754107551075610757107581075910760107611076210763107641076510766107671076810769107701077110772107731077410775107761077710778107791078010781107821078310784107851078610787107881078910790107911079210793107941079510796107971079810799108001080110802108031080410805108061080710808108091081010811108121081310814108151081610817108181081910820108211082210823108241082510826108271082810829108301083110832108331083410835108361083710838108391084010841108421084310844108451084610847108481084910850108511085210853108541085510856108571085810859108601086110862108631086410865108661086710868108691087010871108721087310874108751087610877108781087910880108811088210883108841088510886108871088810889108901089110892108931089410895108961089710898108991090010901109021090310904109051090610907109081090910910109111091210913109141091510916109171091810919109201092110922109231092410925109261092710928109291093010931109321093310934109351093610937109381093910940109411094210943109441094510946109471094810949109501095110952109531095410955109561095710958109591096010961109621096310964109651096610967109681096910970109711097210973109741097510976109771097810979109801098110982109831098410985109861098710988109891099010991109921099310994109951099610997109981099911000110011100211003110041100511006110071100811009110101101111012110131101411015110161101711018110191102011021110221102311024110251102611027110281102911030110311103211033110341103511036110371103811039110401104111042110431104411045110461104711048110491105011051110521105311054110551105611057110581105911060110611106211063110641106511066110671106811069110701107111072110731107411075110761107711078110791108011081110821108311084110851108611087110881108911090110911109211093110941109511096110971109811099111001110111102111031110411105111061110711108111091111011111111121111311114111151111611117111181111911120111211112211123111241112511126111271112811129111301113111132111331113411135111361113711138111391114011141111421114311144111451114611147111481114911150111511115211153111541115511156111571115811159111601116111162111631116411165111661116711168111691117011171111721117311174111751117611177111781117911180111811118211183111841118511186111871118811189111901119111192111931119411195111961119711198111991120011201112021120311204112051120611207112081120911210112111121211213112141121511216112171121811219112201122111222112231122411225112261122711228112291123011231112321123311234112351123611237112381123911240112411124211243112441124511246112471124811249112501125111252112531125411255112561125711258112591126011261112621126311264112651126611267112681126911270112711127211273112741127511276112771127811279112801128111282112831128411285112861128711288112891129011291112921129311294112951129611297112981129911300113011130211303113041130511306113071130811309113101131111312113131131411315113161131711318113191132011321113221132311324113251132611327113281132911330113311133211333113341133511336113371133811339113401134111342113431134411345113461134711348113491135011351113521135311354113551135611357113581135911360113611136211363113641136511366113671136811369113701137111372113731137411375113761137711378113791138011381113821138311384113851138611387113881138911390113911139211393113941139511396113971139811399114001140111402114031140411405114061140711408114091141011411114121141311414114151141611417114181141911420114211142211423114241142511426114271142811429114301143111432114331143411435114361143711438114391144011441114421144311444114451144611447114481144911450114511145211453114541145511456114571145811459114601146111462114631146411465114661146711468114691147011471114721147311474114751147611477114781147911480114811148211483114841148511486114871148811489114901149111492114931149411495114961149711498114991150011501115021150311504115051150611507115081150911510115111151211513115141151511516115171151811519115201152111522115231152411525115261152711528115291153011531115321153311534115351153611537115381153911540115411154211543115441154511546115471154811549115501155111552115531155411555115561155711558115591156011561115621156311564115651156611567115681156911570115711157211573115741157511576115771157811579115801158111582115831158411585115861158711588115891159011591115921159311594115951159611597115981159911600116011160211603116041160511606116071160811609116101161111612116131161411615116161161711618116191162011621116221162311624116251162611627116281162911630116311163211633116341163511636116371163811639116401164111642116431164411645116461164711648116491165011651116521165311654116551165611657116581165911660116611166211663116641166511666116671166811669116701167111672116731167411675116761167711678116791168011681116821168311684116851168611687116881168911690116911169211693116941169511696116971169811699117001170111702117031170411705117061170711708117091171011711117121171311714117151171611717117181171911720117211172211723117241172511726117271172811729117301173111732117331173411735117361173711738117391174011741117421174311744117451174611747117481174911750117511175211753117541175511756117571175811759117601176111762117631176411765117661176711768117691177011771117721177311774117751177611777117781177911780117811178211783117841178511786117871178811789117901179111792117931179411795117961179711798117991180011801118021180311804118051180611807118081180911810118111181211813118141181511816118171181811819118201182111822118231182411825118261182711828118291183011831118321183311834118351183611837118381183911840118411184211843118441184511846118471184811849118501185111852118531185411855118561185711858118591186011861118621186311864118651186611867118681186911870118711187211873118741187511876118771187811879118801188111882118831188411885118861188711888118891189011891118921189311894118951189611897118981189911900119011190211903119041190511906119071190811909119101191111912119131191411915119161191711918119191192011921119221192311924119251192611927119281192911930119311193211933119341193511936119371193811939119401194111942119431194411945119461194711948119491195011951119521195311954119551195611957119581195911960119611196211963119641196511966119671196811969119701197111972119731197411975119761197711978119791198011981119821198311984119851198611987119881198911990119911199211993119941199511996119971199811999120001200112002120031200412005120061200712008120091201012011120121201312014120151201612017120181201912020120211202212023120241202512026120271202812029120301203112032120331203412035120361203712038120391204012041120421204312044120451204612047120481204912050120511205212053120541205512056120571205812059120601206112062120631206412065120661206712068120691207012071120721207312074120751207612077120781207912080120811208212083120841208512086120871208812089120901209112092120931209412095120961209712098120991210012101121021210312104121051210612107121081210912110121111211212113121141211512116121171211812119121201212112122121231212412125121261212712128121291213012131121321213312134121351213612137121381213912140121411214212143121441214512146121471214812149121501215112152121531215412155121561215712158121591216012161121621216312164121651216612167121681216912170121711217212173121741217512176121771217812179121801218112182121831218412185121861218712188121891219012191121921219312194121951219612197121981219912200122011220212203122041220512206122071220812209122101221112212122131221412215122161221712218122191222012221122221222312224122251222612227122281222912230122311223212233122341223512236122371223812239122401224112242122431224412245122461224712248122491225012251122521225312254122551225612257122581225912260122611226212263122641226512266122671226812269122701227112272122731227412275122761227712278122791228012281122821228312284122851228612287122881228912290122911229212293122941229512296122971229812299123001230112302123031230412305123061230712308123091231012311123121231312314123151231612317123181231912320123211232212323123241232512326123271232812329123301233112332123331233412335123361233712338123391234012341123421234312344123451234612347123481234912350123511235212353123541235512356123571235812359123601236112362123631236412365123661236712368123691237012371123721237312374123751237612377123781237912380123811238212383123841238512386123871238812389123901239112392123931239412395123961239712398123991240012401124021240312404124051240612407124081240912410124111241212413124141241512416124171241812419124201242112422124231242412425124261242712428124291243012431124321243312434124351243612437124381243912440124411244212443124441244512446124471244812449124501245112452124531245412455124561245712458124591246012461124621246312464124651246612467124681246912470124711247212473124741247512476124771247812479124801248112482124831248412485124861248712488124891249012491124921249312494124951249612497124981249912500125011250212503125041250512506125071250812509125101251112512125131251412515125161251712518125191252012521125221252312524125251252612527125281252912530125311253212533125341253512536125371253812539125401254112542125431254412545125461254712548125491255012551125521255312554125551255612557125581255912560125611256212563125641256512566125671256812569125701257112572125731257412575125761257712578125791258012581125821258312584125851258612587125881258912590125911259212593125941259512596125971259812599126001260112602126031260412605126061260712608126091261012611126121261312614126151261612617126181261912620126211262212623126241262512626126271262812629126301263112632126331263412635126361263712638126391264012641126421264312644126451264612647126481264912650126511265212653126541265512656126571265812659126601266112662126631266412665126661266712668126691267012671126721267312674126751267612677126781267912680126811268212683126841268512686126871268812689126901269112692126931269412695126961269712698126991270012701127021270312704127051270612707127081270912710127111271212713127141271512716127171271812719127201272112722127231272412725127261272712728127291273012731127321273312734127351273612737127381273912740127411274212743127441274512746127471274812749127501275112752127531275412755127561275712758127591276012761127621276312764127651276612767127681276912770127711277212773127741277512776127771277812779127801278112782127831278412785127861278712788127891279012791127921279312794127951279612797127981279912800128011280212803128041280512806128071280812809128101281112812128131281412815128161281712818128191282012821128221282312824128251282612827128281282912830128311283212833128341283512836128371283812839128401284112842128431284412845128461284712848128491285012851128521285312854128551285612857128581285912860128611286212863128641286512866128671286812869128701287112872128731287412875128761287712878128791288012881128821288312884128851288612887128881288912890128911289212893128941289512896128971289812899129001290112902129031290412905129061290712908129091291012911129121291312914129151291612917129181291912920129211292212923129241292512926129271292812929129301293112932129331293412935129361293712938129391294012941129421294312944129451294612947129481294912950129511295212953129541295512956129571295812959129601296112962129631296412965129661296712968129691297012971129721297312974129751297612977129781297912980129811298212983129841298512986129871298812989129901299112992129931299412995129961299712998129991300013001130021300313004130051300613007130081300913010130111301213013130141301513016130171301813019130201302113022130231302413025130261302713028130291303013031130321303313034130351303613037130381303913040130411304213043130441304513046130471304813049130501305113052130531305413055130561305713058130591306013061130621306313064130651306613067130681306913070130711307213073130741307513076130771307813079130801308113082130831308413085130861308713088130891309013091130921309313094130951309613097130981309913100131011310213103131041310513106131071310813109131101311113112131131311413115131161311713118131191312013121131221312313124131251312613127131281312913130131311313213133131341313513136131371313813139131401314113142131431314413145131461314713148131491315013151131521315313154131551315613157131581315913160131611316213163131641316513166131671316813169131701317113172131731317413175131761317713178131791318013181131821318313184131851318613187131881318913190131911319213193131941319513196131971319813199132001320113202132031320413205132061320713208132091321013211132121321313214132151321613217132181321913220132211322213223132241322513226132271322813229132301323113232132331323413235132361323713238132391324013241132421324313244132451324613247132481324913250132511325213253132541325513256132571325813259132601326113262132631326413265132661326713268132691327013271132721327313274132751327613277132781327913280132811328213283132841328513286132871328813289132901329113292132931329413295132961329713298132991330013301133021330313304133051330613307133081330913310133111331213313133141331513316133171331813319133201332113322133231332413325133261332713328133291333013331133321333313334133351333613337133381333913340133411334213343133441334513346133471334813349133501335113352133531335413355133561335713358133591336013361133621336313364133651336613367133681336913370133711337213373133741337513376133771337813379133801338113382133831338413385133861338713388133891339013391133921339313394133951339613397133981339913400134011340213403134041340513406134071340813409134101341113412134131341413415134161341713418134191342013421134221342313424134251342613427134281342913430134311343213433134341343513436134371343813439134401344113442134431344413445134461344713448134491345013451134521345313454134551345613457134581345913460134611346213463134641346513466134671346813469134701347113472134731347413475134761347713478134791348013481134821348313484134851348613487134881348913490134911349213493134941349513496134971349813499135001350113502135031350413505135061350713508135091351013511135121351313514135151351613517135181351913520135211352213523135241352513526135271352813529135301353113532135331353413535135361353713538135391354013541135421354313544135451354613547135481354913550135511355213553135541355513556135571355813559135601356113562135631356413565135661356713568135691357013571135721357313574135751357613577135781357913580135811358213583135841358513586135871358813589135901359113592135931359413595135961359713598135991360013601136021360313604136051360613607136081360913610136111361213613136141361513616136171361813619136201362113622136231362413625136261362713628136291363013631136321363313634136351363613637136381363913640136411364213643136441364513646136471364813649136501365113652136531365413655136561365713658136591366013661136621366313664136651366613667136681366913670136711367213673136741367513676136771367813679136801368113682136831368413685136861368713688136891369013691136921369313694136951369613697136981369913700137011370213703137041370513706137071370813709137101371113712137131371413715137161371713718137191372013721137221372313724137251372613727137281372913730137311373213733137341373513736137371373813739137401374113742137431374413745137461374713748137491375013751137521375313754137551375613757137581375913760137611376213763137641376513766137671376813769137701377113772137731377413775137761377713778137791378013781137821378313784137851378613787137881378913790137911379213793137941379513796137971379813799138001380113802138031380413805138061380713808138091381013811138121381313814138151381613817138181381913820138211382213823138241382513826138271382813829138301383113832138331383413835138361383713838138391384013841138421384313844138451384613847138481384913850138511385213853138541385513856138571385813859138601386113862138631386413865138661386713868138691387013871138721387313874138751387613877138781387913880138811388213883138841388513886138871388813889138901389113892138931389413895138961389713898138991390013901139021390313904139051390613907139081390913910139111391213913139141391513916139171391813919139201392113922139231392413925139261392713928139291393013931139321393313934139351393613937139381393913940139411394213943139441394513946139471394813949139501395113952139531395413955139561395713958139591396013961139621396313964139651396613967139681396913970139711397213973139741397513976139771397813979139801398113982139831398413985139861398713988139891399013991139921399313994139951399613997139981399914000140011400214003140041400514006140071400814009140101401114012140131401414015140161401714018140191402014021140221402314024140251402614027140281402914030140311403214033140341403514036140371403814039140401404114042140431404414045140461404714048140491405014051140521405314054140551405614057140581405914060140611406214063140641406514066140671406814069140701407114072140731407414075140761407714078140791408014081140821408314084140851408614087140881408914090140911409214093140941409514096140971409814099141001410114102141031410414105141061410714108141091411014111141121411314114141151411614117141181411914120141211412214123141241412514126141271412814129141301413114132141331413414135141361413714138141391414014141141421414314144141451414614147141481414914150141511415214153141541415514156141571415814159141601416114162141631416414165141661416714168141691417014171141721417314174141751417614177141781417914180141811418214183141841418514186141871418814189141901419114192141931419414195141961419714198141991420014201142021420314204142051420614207142081420914210142111421214213142141421514216142171421814219142201422114222142231422414225142261422714228142291423014231142321423314234142351423614237142381423914240142411424214243142441424514246142471424814249142501425114252142531425414255142561425714258142591426014261142621426314264142651426614267142681426914270142711427214273142741427514276142771427814279142801428114282142831428414285142861428714288142891429014291142921429314294142951429614297142981429914300143011430214303143041430514306143071430814309143101431114312143131431414315143161431714318143191432014321143221432314324143251432614327143281432914330143311433214333143341433514336143371433814339143401434114342143431434414345143461434714348143491435014351143521435314354143551435614357143581435914360143611436214363143641436514366143671436814369143701437114372143731437414375143761437714378143791438014381143821438314384143851438614387143881438914390143911439214393143941439514396143971439814399144001440114402144031440414405144061440714408144091441014411144121441314414144151441614417144181441914420144211442214423144241442514426144271442814429144301443114432144331443414435144361443714438144391444014441144421444314444144451444614447144481444914450144511445214453144541445514456144571445814459144601446114462144631446414465144661446714468144691447014471144721447314474144751447614477144781447914480144811448214483144841448514486144871448814489144901449114492144931449414495144961449714498144991450014501145021450314504145051450614507145081450914510145111451214513145141451514516145171451814519145201452114522145231452414525145261452714528145291453014531145321453314534145351453614537145381453914540145411454214543145441454514546145471454814549145501455114552145531455414555145561455714558145591456014561145621456314564145651456614567145681456914570145711457214573145741457514576145771457814579145801458114582145831458414585145861458714588145891459014591145921459314594145951459614597145981459914600146011460214603146041460514606146071460814609146101461114612146131461414615146161461714618146191462014621146221462314624146251462614627146281462914630146311463214633146341463514636146371463814639146401464114642146431464414645146461464714648146491465014651146521465314654146551465614657146581465914660146611466214663146641466514666146671466814669146701467114672146731467414675146761467714678146791468014681146821468314684146851468614687146881468914690146911469214693146941469514696146971469814699147001470114702147031470414705147061470714708147091471014711147121471314714147151471614717147181471914720147211472214723147241472514726147271472814729147301473114732147331473414735147361473714738147391474014741147421474314744147451474614747147481474914750147511475214753147541475514756147571475814759147601476114762147631476414765147661476714768147691477014771147721477314774147751477614777147781477914780147811478214783147841478514786147871478814789147901479114792147931479414795147961479714798147991480014801148021480314804148051480614807148081480914810148111481214813148141481514816148171481814819148201482114822148231482414825148261482714828148291483014831148321483314834148351483614837148381483914840148411484214843148441484514846148471484814849148501485114852148531485414855148561485714858148591486014861148621486314864148651486614867148681486914870148711487214873148741487514876148771487814879148801488114882148831488414885148861488714888148891489014891148921489314894148951489614897148981489914900149011490214903149041490514906149071490814909149101491114912149131491414915149161491714918149191492014921149221492314924149251492614927149281492914930149311493214933149341493514936149371493814939149401494114942149431494414945149461494714948149491495014951149521495314954149551495614957149581495914960149611496214963149641496514966149671496814969149701497114972149731497414975149761497714978149791498014981149821498314984149851498614987149881498914990149911499214993149941499514996149971499814999150001500115002150031500415005150061500715008150091501015011150121501315014150151501615017150181501915020150211502215023150241502515026150271502815029150301503115032150331503415035150361503715038150391504015041150421504315044150451504615047150481504915050150511505215053150541505515056150571505815059150601506115062150631506415065150661506715068150691507015071150721507315074150751507615077150781507915080150811508215083150841508515086150871508815089150901509115092150931509415095150961509715098150991510015101151021510315104151051510615107151081510915110151111511215113151141511515116151171511815119151201512115122151231512415125151261512715128151291513015131151321513315134151351513615137151381513915140151411514215143151441514515146151471514815149151501515115152151531515415155151561515715158151591516015161151621516315164151651516615167151681516915170151711517215173151741517515176151771517815179151801518115182151831518415185151861518715188151891519015191151921519315194151951519615197151981519915200152011520215203152041520515206152071520815209152101521115212152131521415215152161521715218152191522015221152221522315224152251522615227152281522915230152311523215233152341523515236152371523815239152401524115242152431524415245152461524715248152491525015251152521525315254152551525615257152581525915260152611526215263152641526515266152671526815269152701527115272152731527415275152761527715278152791528015281152821528315284152851528615287152881528915290152911529215293152941529515296152971529815299153001530115302153031530415305153061530715308153091531015311153121531315314153151531615317153181531915320153211532215323153241532515326153271532815329153301533115332153331533415335153361533715338153391534015341153421534315344153451534615347153481534915350153511535215353153541535515356153571535815359153601536115362153631536415365153661536715368153691537015371153721537315374153751537615377153781537915380153811538215383153841538515386153871538815389153901539115392153931539415395153961539715398153991540015401154021540315404154051540615407154081540915410154111541215413154141541515416154171541815419154201542115422154231542415425154261542715428154291543015431154321543315434154351543615437154381543915440154411544215443154441544515446154471544815449154501545115452154531545415455154561545715458154591546015461154621546315464154651546615467154681546915470154711547215473154741547515476154771547815479154801548115482154831548415485154861548715488154891549015491154921549315494154951549615497154981549915500155011550215503155041550515506155071550815509155101551115512155131551415515155161551715518155191552015521155221552315524155251552615527155281552915530155311553215533155341553515536155371553815539155401554115542155431554415545155461554715548155491555015551155521555315554155551555615557155581555915560155611556215563155641556515566155671556815569155701557115572155731557415575155761557715578155791558015581155821558315584155851558615587155881558915590155911559215593155941559515596155971559815599156001560115602156031560415605156061560715608156091561015611156121561315614156151561615617156181561915620156211562215623156241562515626156271562815629156301563115632156331563415635156361563715638156391564015641156421564315644156451564615647156481564915650156511565215653156541565515656156571565815659156601566115662156631566415665156661566715668156691567015671156721567315674156751567615677156781567915680156811568215683156841568515686156871568815689156901569115692156931569415695156961569715698156991570015701157021570315704157051570615707157081570915710157111571215713157141571515716157171571815719157201572115722157231572415725157261572715728157291573015731157321573315734157351573615737157381573915740157411574215743157441574515746157471574815749157501575115752157531575415755157561575715758157591576015761157621576315764157651576615767157681576915770157711577215773157741577515776157771577815779157801578115782157831578415785157861578715788157891579015791157921579315794157951579615797157981579915800158011580215803158041580515806158071580815809158101581115812158131581415815158161581715818158191582015821158221582315824158251582615827158281582915830158311583215833158341583515836158371583815839158401584115842158431584415845158461584715848158491585015851158521585315854158551585615857158581585915860158611586215863158641586515866158671586815869158701587115872158731587415875158761587715878158791588015881158821588315884158851588615887158881588915890158911589215893158941589515896158971589815899159001590115902159031590415905159061590715908159091591015911159121591315914159151591615917159181591915920159211592215923159241592515926159271592815929159301593115932159331593415935159361593715938159391594015941159421594315944159451594615947159481594915950159511595215953159541595515956159571595815959159601596115962159631596415965159661596715968159691597015971159721597315974159751597615977159781597915980159811598215983159841598515986159871598815989159901599115992159931599415995159961599715998159991600016001160021600316004160051600616007160081600916010160111601216013160141601516016160171601816019160201602116022160231602416025160261602716028160291603016031160321603316034160351603616037160381603916040160411604216043160441604516046160471604816049160501605116052160531605416055160561605716058160591606016061160621606316064160651606616067160681606916070160711607216073160741607516076160771607816079160801608116082160831608416085160861608716088160891609016091160921609316094160951609616097160981609916100161011610216103161041610516106161071610816109161101611116112161131611416115161161611716118161191612016121161221612316124161251612616127161281612916130161311613216133161341613516136161371613816139161401614116142161431614416145161461614716148161491615016151161521615316154161551615616157161581615916160161611616216163161641616516166161671616816169161701617116172161731617416175161761617716178161791618016181161821618316184161851618616187161881618916190161911619216193161941619516196161971619816199162001620116202162031620416205162061620716208162091621016211162121621316214162151621616217162181621916220162211622216223162241622516226162271622816229162301623116232162331623416235162361623716238162391624016241162421624316244162451624616247162481624916250162511625216253162541625516256162571625816259162601626116262162631626416265162661626716268162691627016271162721627316274162751627616277162781627916280162811628216283162841628516286162871628816289162901629116292162931629416295162961629716298162991630016301163021630316304163051630616307163081630916310163111631216313163141631516316163171631816319163201632116322163231632416325163261632716328163291633016331163321633316334163351633616337163381633916340163411634216343163441634516346163471634816349163501635116352163531635416355163561635716358163591636016361163621636316364163651636616367163681636916370163711637216373163741637516376163771637816379163801638116382163831638416385163861638716388163891639016391163921639316394163951639616397163981639916400164011640216403164041640516406164071640816409164101641116412164131641416415164161641716418164191642016421164221642316424164251642616427164281642916430164311643216433164341643516436164371643816439164401644116442164431644416445164461644716448164491645016451164521645316454164551645616457164581645916460164611646216463164641646516466164671646816469164701647116472164731647416475164761647716478164791648016481164821648316484164851648616487164881648916490164911649216493164941649516496164971649816499165001650116502165031650416505165061650716508165091651016511165121651316514165151651616517165181651916520165211652216523165241652516526165271652816529165301653116532165331653416535165361653716538165391654016541165421654316544165451654616547165481654916550165511655216553165541655516556165571655816559165601656116562165631656416565165661656716568165691657016571165721657316574165751657616577165781657916580165811658216583165841658516586165871658816589165901659116592165931659416595165961659716598165991660016601166021660316604166051660616607166081660916610166111661216613166141661516616166171661816619166201662116622166231662416625166261662716628166291663016631166321663316634166351663616637166381663916640166411664216643166441664516646166471664816649166501665116652166531665416655166561665716658166591666016661166621666316664166651666616667166681666916670166711667216673166741667516676166771667816679166801668116682166831668416685166861668716688166891669016691166921669316694166951669616697166981669916700167011670216703167041670516706167071670816709167101671116712167131671416715167161671716718167191672016721167221672316724167251672616727167281672916730167311673216733167341673516736167371673816739167401674116742167431674416745167461674716748167491675016751167521675316754167551675616757167581675916760167611676216763167641676516766167671676816769167701677116772167731677416775167761677716778167791678016781167821678316784167851678616787167881678916790167911679216793167941679516796167971679816799168001680116802168031680416805168061680716808168091681016811168121681316814168151681616817168181681916820168211682216823168241682516826168271682816829168301683116832168331683416835168361683716838168391684016841168421684316844168451684616847168481684916850168511685216853168541685516856168571685816859168601686116862168631686416865168661686716868168691687016871168721687316874168751687616877168781687916880168811688216883168841688516886168871688816889168901689116892168931689416895168961689716898168991690016901169021690316904169051690616907169081690916910169111691216913169141691516916169171691816919169201692116922169231692416925169261692716928169291693016931169321693316934169351693616937169381693916940169411694216943169441694516946169471694816949169501695116952169531695416955169561695716958169591696016961169621696316964169651696616967169681696916970169711697216973169741697516976169771697816979169801698116982169831698416985169861698716988169891699016991169921699316994169951699616997169981699917000170011700217003170041700517006170071700817009170101701117012170131701417015170161701717018170191702017021170221702317024170251702617027170281702917030170311703217033170341703517036170371703817039170401704117042170431704417045170461704717048170491705017051170521705317054170551705617057170581705917060170611706217063170641706517066170671706817069170701707117072170731707417075170761707717078170791708017081170821708317084170851708617087170881708917090170911709217093170941709517096170971709817099171001710117102171031710417105171061710717108171091711017111171121711317114171151711617117171181711917120171211712217123171241712517126171271712817129171301713117132171331713417135171361713717138171391714017141171421714317144171451714617147171481714917150171511715217153171541715517156171571715817159171601716117162171631716417165171661716717168171691717017171171721717317174171751717617177171781717917180171811718217183171841718517186171871718817189171901719117192171931719417195171961719717198171991720017201172021720317204172051720617207172081720917210172111721217213172141721517216172171721817219172201722117222172231722417225172261722717228172291723017231172321723317234172351723617237172381723917240172411724217243172441724517246172471724817249172501725117252172531725417255172561725717258172591726017261172621726317264172651726617267172681726917270172711727217273172741727517276172771727817279172801728117282172831728417285172861728717288172891729017291172921729317294172951729617297172981729917300173011730217303173041730517306173071730817309173101731117312173131731417315173161731717318173191732017321173221732317324173251732617327173281732917330173311733217333173341733517336173371733817339173401734117342173431734417345173461734717348173491735017351173521735317354173551735617357173581735917360173611736217363173641736517366173671736817369173701737117372173731737417375173761737717378173791738017381173821738317384173851738617387173881738917390173911739217393173941739517396173971739817399174001740117402174031740417405174061740717408174091741017411174121741317414174151741617417174181741917420174211742217423174241742517426174271742817429174301743117432174331743417435174361743717438174391744017441174421744317444174451744617447174481744917450174511745217453174541745517456174571745817459174601746117462174631746417465174661746717468174691747017471174721747317474174751747617477174781747917480174811748217483174841748517486174871748817489174901749117492174931749417495174961749717498174991750017501175021750317504175051750617507175081750917510175111751217513175141751517516175171751817519175201752117522175231752417525175261752717528175291753017531175321753317534175351753617537175381753917540175411754217543175441754517546175471754817549175501755117552175531755417555175561755717558175591756017561175621756317564175651756617567175681756917570175711757217573175741757517576175771757817579175801758117582175831758417585175861758717588175891759017591175921759317594175951759617597175981759917600176011760217603176041760517606176071760817609176101761117612176131761417615176161761717618176191762017621176221762317624176251762617627176281762917630176311763217633176341763517636176371763817639176401764117642176431764417645176461764717648176491765017651176521765317654176551765617657176581765917660176611766217663176641766517666176671766817669176701767117672176731767417675176761767717678176791768017681176821768317684176851768617687176881768917690176911769217693176941769517696176971769817699177001770117702177031770417705177061770717708177091771017711177121771317714177151771617717177181771917720177211772217723177241772517726177271772817729177301773117732177331773417735177361773717738177391774017741177421774317744177451774617747177481774917750177511775217753177541775517756177571775817759177601776117762177631776417765177661776717768177691777017771177721777317774177751777617777177781777917780177811778217783177841778517786177871778817789177901779117792177931779417795177961779717798177991780017801178021780317804178051780617807178081780917810178111781217813178141781517816178171781817819178201782117822178231782417825178261782717828178291783017831178321783317834178351783617837178381783917840178411784217843178441784517846178471784817849178501785117852178531785417855178561785717858178591786017861178621786317864178651786617867178681786917870178711787217873178741787517876178771787817879178801788117882178831788417885178861788717888178891789017891178921789317894178951789617897178981789917900179011790217903179041790517906179071790817909179101791117912179131791417915179161791717918179191792017921179221792317924179251792617927179281792917930179311793217933179341793517936179371793817939179401794117942179431794417945179461794717948179491795017951179521795317954179551795617957179581795917960179611796217963179641796517966179671796817969179701797117972179731797417975179761797717978179791798017981179821798317984179851798617987179881798917990179911799217993179941799517996179971799817999180001800118002180031800418005180061800718008180091801018011180121801318014180151801618017180181801918020180211802218023180241802518026180271802818029180301803118032180331803418035180361803718038180391804018041180421804318044180451804618047180481804918050180511805218053180541805518056180571805818059180601806118062180631806418065180661806718068180691807018071180721807318074180751807618077180781807918080180811808218083180841808518086180871808818089180901809118092180931809418095180961809718098180991810018101181021810318104181051810618107181081810918110181111811218113181141811518116181171811818119181201812118122181231812418125181261812718128181291813018131181321813318134181351813618137181381813918140181411814218143181441814518146181471814818149181501815118152181531815418155181561815718158181591816018161181621816318164181651816618167181681816918170181711817218173181741817518176181771817818179181801818118182181831818418185181861818718188181891819018191181921819318194181951819618197181981819918200182011820218203182041820518206182071820818209182101821118212182131821418215182161821718218182191822018221182221822318224182251822618227182281822918230182311823218233182341823518236182371823818239182401824118242182431824418245182461824718248182491825018251182521825318254182551825618257182581825918260182611826218263182641826518266182671826818269182701827118272182731827418275182761827718278182791828018281182821828318284182851828618287182881828918290182911829218293182941829518296182971829818299183001830118302183031830418305183061830718308183091831018311183121831318314183151831618317183181831918320183211832218323183241832518326183271832818329183301833118332183331833418335183361833718338183391834018341183421834318344183451834618347183481834918350183511835218353183541835518356183571835818359183601836118362183631836418365183661836718368183691837018371183721837318374183751837618377183781837918380183811838218383183841838518386183871838818389183901839118392183931839418395183961839718398183991840018401184021840318404184051840618407184081840918410184111841218413184141841518416184171841818419184201842118422184231842418425184261842718428184291843018431184321843318434184351843618437184381843918440184411844218443184441844518446184471844818449184501845118452184531845418455184561845718458184591846018461184621846318464184651846618467184681846918470184711847218473184741847518476184771847818479184801848118482184831848418485184861848718488184891849018491184921849318494184951849618497184981849918500185011850218503185041850518506185071850818509185101851118512185131851418515185161851718518185191852018521185221852318524185251852618527185281852918530185311853218533185341853518536185371853818539185401854118542185431854418545185461854718548185491855018551185521855318554185551855618557185581855918560185611856218563185641856518566185671856818569185701857118572185731857418575185761857718578185791858018581185821858318584185851858618587185881858918590185911859218593185941859518596185971859818599186001860118602186031860418605186061860718608186091861018611186121861318614186151861618617186181861918620186211862218623186241862518626186271862818629186301863118632186331863418635186361863718638186391864018641186421864318644186451864618647186481864918650186511865218653186541865518656186571865818659186601866118662186631866418665186661866718668186691867018671186721867318674186751867618677186781867918680186811868218683186841868518686186871868818689186901869118692186931869418695186961869718698186991870018701187021870318704187051870618707187081870918710187111871218713187141871518716187171871818719187201872118722187231872418725187261872718728187291873018731187321873318734187351873618737187381873918740187411874218743187441874518746187471874818749187501875118752187531875418755187561875718758187591876018761187621876318764187651876618767187681876918770187711877218773187741877518776187771877818779187801878118782187831878418785187861878718788187891879018791187921879318794187951879618797187981879918800188011880218803188041880518806188071880818809188101881118812188131881418815188161881718818188191882018821188221882318824188251882618827188281882918830188311883218833188341883518836188371883818839188401884118842188431884418845188461884718848188491885018851188521885318854188551885618857188581885918860188611886218863188641886518866188671886818869188701887118872188731887418875188761887718878188791888018881188821888318884188851888618887188881888918890188911889218893188941889518896188971889818899189001890118902189031890418905189061890718908189091891018911189121891318914189151891618917189181891918920189211892218923189241892518926189271892818929189301893118932189331893418935189361893718938189391894018941189421894318944189451894618947189481894918950189511895218953189541895518956189571895818959189601896118962189631896418965189661896718968189691897018971189721897318974189751897618977189781897918980189811898218983189841898518986189871898818989189901899118992189931899418995189961899718998189991900019001190021900319004190051900619007190081900919010190111901219013190141901519016190171901819019190201902119022190231902419025190261902719028190291903019031190321903319034190351903619037190381903919040190411904219043190441904519046190471904819049190501905119052190531905419055190561905719058190591906019061190621906319064190651906619067190681906919070190711907219073190741907519076190771907819079190801908119082190831908419085190861908719088190891909019091190921909319094190951909619097190981909919100191011910219103191041910519106191071910819109191101911119112191131911419115191161911719118191191912019121191221912319124191251912619127191281912919130191311913219133191341913519136191371913819139191401914119142191431914419145191461914719148191491915019151191521915319154191551915619157191581915919160191611916219163191641916519166191671916819169191701917119172191731917419175191761917719178191791918019181191821918319184191851918619187191881918919190191911919219193191941919519196191971919819199192001920119202192031920419205192061920719208192091921019211192121921319214192151921619217192181921919220192211922219223192241922519226192271922819229192301923119232192331923419235192361923719238192391924019241192421924319244192451924619247192481924919250192511925219253192541925519256192571925819259192601926119262192631926419265192661926719268192691927019271192721927319274192751927619277192781927919280192811928219283192841928519286192871928819289192901929119292192931929419295192961929719298192991930019301193021930319304193051930619307193081930919310193111931219313193141931519316193171931819319193201932119322193231932419325193261932719328193291933019331193321933319334193351933619337193381933919340193411934219343193441934519346193471934819349193501935119352193531935419355193561935719358193591936019361193621936319364193651936619367193681936919370193711937219373193741937519376193771937819379193801938119382193831938419385193861938719388193891939019391193921939319394193951939619397193981939919400194011940219403194041940519406194071940819409194101941119412194131941419415194161941719418194191942019421194221942319424194251942619427194281942919430194311943219433194341943519436194371943819439194401944119442194431944419445194461944719448194491945019451194521945319454194551945619457194581945919460194611946219463194641946519466194671946819469194701947119472194731947419475194761947719478194791948019481194821948319484194851948619487194881948919490194911949219493194941949519496194971949819499195001950119502195031950419505195061950719508195091951019511195121951319514195151951619517195181951919520195211952219523195241952519526195271952819529195301953119532195331953419535195361953719538195391954019541195421954319544195451954619547195481954919550195511955219553195541955519556195571955819559195601956119562195631956419565195661956719568195691957019571195721957319574195751957619577195781957919580195811958219583195841958519586195871958819589195901959119592195931959419595195961959719598195991960019601196021960319604196051960619607196081960919610196111961219613196141961519616196171961819619196201962119622196231962419625196261962719628196291963019631196321963319634196351963619637196381963919640196411964219643196441964519646196471964819649196501965119652196531965419655196561965719658196591966019661196621966319664196651966619667196681966919670196711967219673196741967519676196771967819679196801968119682196831968419685196861968719688196891969019691196921969319694196951969619697196981969919700197011970219703197041970519706197071970819709197101971119712197131971419715197161971719718197191972019721197221972319724197251972619727197281972919730197311973219733197341973519736197371973819739197401974119742197431974419745197461974719748197491975019751197521975319754197551975619757197581975919760197611976219763197641976519766197671976819769197701977119772197731977419775197761977719778197791978019781197821978319784197851978619787197881978919790197911979219793197941979519796197971979819799198001980119802198031980419805198061980719808198091981019811198121981319814198151981619817198181981919820198211982219823198241982519826198271982819829198301983119832198331983419835198361983719838198391984019841198421984319844198451984619847198481984919850198511985219853198541985519856198571985819859198601986119862198631986419865198661986719868198691987019871198721987319874198751987619877198781987919880198811988219883198841988519886198871988819889198901989119892198931989419895198961989719898198991990019901199021990319904199051990619907199081990919910199111991219913199141991519916199171991819919199201992119922199231992419925199261992719928199291993019931199321993319934199351993619937199381993919940199411994219943199441994519946199471994819949199501995119952199531995419955199561995719958199591996019961199621996319964199651996619967199681996919970199711997219973199741997519976199771997819979199801998119982199831998419985199861998719988199891999019991199921999319994199951999619997199981999920000200012000220003200042000520006200072000820009200102001120012200132001420015200162001720018200192002020021200222002320024200252002620027200282002920030200312003220033200342003520036200372003820039200402004120042200432004420045200462004720048200492005020051200522005320054200552005620057200582005920060200612006220063200642006520066200672006820069200702007120072200732007420075200762007720078200792008020081200822008320084200852008620087200882008920090200912009220093200942009520096200972009820099201002010120102201032010420105201062010720108201092011020111201122011320114201152011620117201182011920120201212012220123201242012520126201272012820129201302013120132201332013420135201362013720138201392014020141201422014320144201452014620147201482014920150201512015220153201542015520156201572015820159201602016120162201632016420165201662016720168201692017020171201722017320174201752017620177201782017920180201812018220183201842018520186201872018820189201902019120192201932019420195201962019720198201992020020201202022020320204202052020620207202082020920210202112021220213202142021520216202172021820219202202022120222202232022420225202262022720228202292023020231202322023320234202352023620237202382023920240202412024220243202442024520246202472024820249202502025120252202532025420255202562025720258202592026020261202622026320264202652026620267202682026920270202712027220273202742027520276202772027820279202802028120282202832028420285202862028720288202892029020291202922029320294202952029620297202982029920300203012030220303203042030520306203072030820309203102031120312203132031420315203162031720318203192032020321203222032320324203252032620327203282032920330203312033220333203342033520336203372033820339203402034120342203432034420345203462034720348203492035020351203522035320354203552035620357203582035920360203612036220363203642036520366203672036820369203702037120372203732037420375203762037720378203792038020381203822038320384203852038620387203882038920390203912039220393203942039520396203972039820399204002040120402204032040420405204062040720408204092041020411204122041320414204152041620417204182041920420204212042220423204242042520426204272042820429204302043120432204332043420435204362043720438204392044020441204422044320444204452044620447204482044920450204512045220453204542045520456204572045820459204602046120462204632046420465204662046720468204692047020471204722047320474204752047620477204782047920480204812048220483204842048520486204872048820489204902049120492204932049420495204962049720498204992050020501205022050320504205052050620507205082050920510205112051220513205142051520516205172051820519205202052120522205232052420525205262052720528205292053020531205322053320534205352053620537205382053920540205412054220543205442054520546205472054820549205502055120552205532055420555205562055720558205592056020561205622056320564205652056620567205682056920570205712057220573205742057520576205772057820579205802058120582205832058420585205862058720588205892059020591205922059320594205952059620597205982059920600206012060220603206042060520606206072060820609206102061120612206132061420615206162061720618206192062020621206222062320624206252062620627206282062920630206312063220633206342063520636206372063820639206402064120642206432064420645206462064720648206492065020651206522065320654206552065620657206582065920660206612066220663206642066520666206672066820669206702067120672206732067420675206762067720678206792068020681206822068320684206852068620687206882068920690206912069220693206942069520696206972069820699207002070120702207032070420705207062070720708207092071020711207122071320714207152071620717207182071920720207212072220723207242072520726207272072820729207302073120732207332073420735207362073720738207392074020741207422074320744207452074620747207482074920750207512075220753207542075520756207572075820759207602076120762207632076420765207662076720768207692077020771207722077320774207752077620777207782077920780207812078220783207842078520786207872078820789207902079120792207932079420795207962079720798207992080020801208022080320804208052080620807208082080920810208112081220813208142081520816208172081820819208202082120822208232082420825208262082720828208292083020831208322083320834208352083620837208382083920840208412084220843208442084520846208472084820849208502085120852208532085420855208562085720858208592086020861208622086320864208652086620867208682086920870208712087220873208742087520876208772087820879208802088120882208832088420885208862088720888208892089020891208922089320894208952089620897208982089920900209012090220903209042090520906209072090820909209102091120912209132091420915209162091720918209192092020921209222092320924209252092620927209282092920930209312093220933209342093520936209372093820939209402094120942209432094420945209462094720948209492095020951209522095320954209552095620957209582095920960209612096220963209642096520966209672096820969209702097120972209732097420975209762097720978209792098020981209822098320984209852098620987209882098920990209912099220993209942099520996209972099820999210002100121002210032100421005210062100721008210092101021011210122101321014210152101621017210182101921020210212102221023210242102521026210272102821029210302103121032210332103421035210362103721038210392104021041210422104321044210452104621047210482104921050210512105221053210542105521056210572105821059210602106121062210632106421065210662106721068210692107021071210722107321074210752107621077210782107921080210812108221083210842108521086210872108821089210902109121092210932109421095210962109721098210992110021101211022110321104211052110621107211082110921110211112111221113211142111521116211172111821119211202112121122211232112421125211262112721128211292113021131211322113321134211352113621137211382113921140211412114221143211442114521146211472114821149211502115121152211532115421155211562115721158211592116021161211622116321164211652116621167211682116921170211712117221173211742117521176211772117821179211802118121182211832118421185211862118721188211892119021191211922119321194211952119621197211982119921200212012120221203212042120521206212072120821209212102121121212212132121421215212162121721218212192122021221212222122321224212252122621227212282122921230212312123221233212342123521236212372123821239212402124121242212432124421245212462124721248212492125021251212522125321254212552125621257212582125921260212612126221263212642126521266212672126821269212702127121272212732127421275212762127721278212792128021281212822128321284212852128621287212882128921290212912129221293212942129521296212972129821299213002130121302213032130421305213062130721308213092131021311213122131321314213152131621317213182131921320213212132221323213242132521326213272132821329213302133121332213332133421335213362133721338213392134021341213422134321344213452134621347213482134921350213512135221353213542135521356213572135821359213602136121362213632136421365213662136721368213692137021371213722137321374213752137621377213782137921380213812138221383213842138521386213872138821389213902139121392213932139421395213962139721398213992140021401214022140321404214052140621407214082140921410214112141221413214142141521416214172141821419214202142121422214232142421425214262142721428214292143021431214322143321434214352143621437214382143921440214412144221443214442144521446214472144821449214502145121452214532145421455214562145721458214592146021461214622146321464214652146621467214682146921470214712147221473214742147521476214772147821479214802148121482214832148421485214862148721488214892149021491214922149321494214952149621497214982149921500215012150221503215042150521506215072150821509215102151121512215132151421515215162151721518215192152021521215222152321524215252152621527215282152921530215312153221533215342153521536215372153821539215402154121542215432154421545215462154721548215492155021551215522155321554215552155621557215582155921560215612156221563215642156521566215672156821569215702157121572215732157421575215762157721578215792158021581215822158321584215852158621587215882158921590215912159221593215942159521596215972159821599216002160121602216032160421605216062160721608216092161021611216122161321614216152161621617216182161921620216212162221623216242162521626216272162821629216302163121632216332163421635216362163721638216392164021641216422164321644216452164621647216482164921650216512165221653216542165521656216572165821659216602166121662216632166421665216662166721668216692167021671216722167321674216752167621677216782167921680216812168221683216842168521686216872168821689216902169121692216932169421695216962169721698216992170021701217022170321704217052170621707217082170921710217112171221713217142171521716217172171821719217202172121722217232172421725217262172721728217292173021731217322173321734217352173621737217382173921740217412174221743217442174521746217472174821749217502175121752217532175421755217562175721758217592176021761217622176321764217652176621767217682176921770217712177221773217742177521776217772177821779217802178121782217832178421785217862178721788217892179021791217922179321794217952179621797217982179921800218012180221803218042180521806218072180821809218102181121812218132181421815218162181721818218192182021821218222182321824218252182621827218282182921830218312183221833218342183521836218372183821839218402184121842218432184421845218462184721848218492185021851218522185321854218552185621857218582185921860218612186221863218642186521866218672186821869218702187121872218732187421875218762187721878218792188021881218822188321884218852188621887218882188921890218912189221893218942189521896218972189821899219002190121902219032190421905219062190721908219092191021911219122191321914219152191621917219182191921920219212192221923219242192521926219272192821929219302193121932219332193421935219362193721938219392194021941219422194321944219452194621947219482194921950219512195221953219542195521956219572195821959219602196121962219632196421965219662196721968219692197021971219722197321974219752197621977219782197921980219812198221983219842198521986219872198821989219902199121992219932199421995219962199721998219992200022001220022200322004220052200622007220082200922010220112201222013220142201522016220172201822019220202202122022220232202422025220262202722028220292203022031220322203322034220352203622037220382203922040220412204222043220442204522046220472204822049220502205122052220532205422055220562205722058220592206022061220622206322064220652206622067220682206922070220712207222073220742207522076220772207822079220802208122082220832208422085220862208722088220892209022091220922209322094220952209622097220982209922100221012210222103221042210522106221072210822109221102211122112221132211422115221162211722118221192212022121221222212322124221252212622127221282212922130221312213222133221342213522136221372213822139221402214122142221432214422145221462214722148221492215022151221522215322154221552215622157221582215922160221612216222163221642216522166221672216822169221702217122172221732217422175221762217722178221792218022181221822218322184221852218622187221882218922190221912219222193221942219522196221972219822199222002220122202222032220422205222062220722208222092221022211222122221322214222152221622217222182221922220222212222222223222242222522226222272222822229222302223122232222332223422235222362223722238222392224022241222422224322244222452224622247222482224922250222512225222253222542225522256222572225822259222602226122262222632226422265222662226722268222692227022271222722227322274222752227622277222782227922280222812228222283222842228522286222872228822289222902229122292222932229422295222962229722298222992230022301223022230322304223052230622307223082230922310223112231222313223142231522316223172231822319223202232122322223232232422325223262232722328223292233022331223322233322334223352233622337223382233922340223412234222343223442234522346223472234822349223502235122352223532235422355223562235722358223592236022361223622236322364223652236622367223682236922370223712237222373223742237522376223772237822379223802238122382223832238422385223862238722388223892239022391223922239322394223952239622397223982239922400224012240222403224042240522406224072240822409224102241122412224132241422415224162241722418224192242022421224222242322424224252242622427224282242922430224312243222433224342243522436224372243822439224402244122442224432244422445224462244722448224492245022451224522245322454224552245622457224582245922460224612246222463224642246522466224672246822469224702247122472224732247422475224762247722478224792248022481224822248322484224852248622487224882248922490224912249222493224942249522496224972249822499225002250122502225032250422505225062250722508225092251022511225122251322514225152251622517225182251922520225212252222523225242252522526225272252822529225302253122532225332253422535225362253722538225392254022541225422254322544225452254622547225482254922550225512255222553225542255522556225572255822559225602256122562225632256422565225662256722568225692257022571225722257322574225752257622577225782257922580225812258222583225842258522586225872258822589225902259122592225932259422595225962259722598225992260022601226022260322604226052260622607226082260922610226112261222613226142261522616226172261822619226202262122622226232262422625226262262722628226292263022631226322263322634226352263622637226382263922640226412264222643226442264522646226472264822649226502265122652226532265422655226562265722658226592266022661226622266322664226652266622667226682266922670226712267222673226742267522676226772267822679226802268122682226832268422685226862268722688226892269022691226922269322694226952269622697226982269922700227012270222703227042270522706227072270822709227102271122712227132271422715227162271722718227192272022721227222272322724227252272622727227282272922730227312273222733227342273522736227372273822739227402274122742227432274422745227462274722748227492275022751227522275322754227552275622757227582275922760227612276222763227642276522766227672276822769227702277122772227732277422775227762277722778227792278022781227822278322784227852278622787227882278922790227912279222793227942279522796227972279822799228002280122802228032280422805228062280722808228092281022811228122281322814228152281622817228182281922820228212282222823228242282522826228272282822829228302283122832228332283422835228362283722838228392284022841228422284322844228452284622847228482284922850228512285222853228542285522856228572285822859228602286122862228632286422865228662286722868228692287022871228722287322874228752287622877228782287922880228812288222883228842288522886228872288822889228902289122892228932289422895228962289722898228992290022901229022290322904229052290622907229082290922910229112291222913229142291522916229172291822919229202292122922229232292422925229262292722928229292293022931229322293322934229352293622937229382293922940229412294222943229442294522946229472294822949229502295122952229532295422955229562295722958229592296022961229622296322964229652296622967229682296922970229712297222973229742297522976229772297822979229802298122982229832298422985229862298722988229892299022991229922299322994229952299622997229982299923000230012300223003230042300523006230072300823009230102301123012230132301423015230162301723018230192302023021230222302323024230252302623027230282302923030230312303223033230342303523036230372303823039230402304123042230432304423045230462304723048230492305023051230522305323054230552305623057230582305923060230612306223063230642306523066230672306823069230702307123072230732307423075230762307723078230792308023081230822308323084230852308623087230882308923090230912309223093230942309523096230972309823099231002310123102231032310423105231062310723108231092311023111231122311323114231152311623117231182311923120231212312223123231242312523126231272312823129231302313123132231332313423135231362313723138231392314023141231422314323144231452314623147231482314923150231512315223153231542315523156231572315823159231602316123162231632316423165231662316723168231692317023171231722317323174231752317623177231782317923180231812318223183231842318523186231872318823189231902319123192231932319423195231962319723198231992320023201232022320323204232052320623207232082320923210232112321223213232142321523216232172321823219232202322123222232232322423225232262322723228232292323023231232322323323234232352323623237232382323923240232412324223243232442324523246232472324823249232502325123252232532325423255232562325723258232592326023261232622326323264232652326623267232682326923270232712327223273232742327523276232772327823279232802328123282232832328423285232862328723288232892329023291232922329323294232952329623297232982329923300233012330223303233042330523306233072330823309233102331123312233132331423315233162331723318233192332023321233222332323324233252332623327233282332923330233312333223333233342333523336233372333823339233402334123342233432334423345233462334723348233492335023351233522335323354233552335623357233582335923360233612336223363233642336523366233672336823369233702337123372233732337423375233762337723378233792338023381233822338323384233852338623387233882338923390233912339223393233942339523396233972339823399234002340123402234032340423405234062340723408234092341023411234122341323414234152341623417234182341923420234212342223423234242342523426234272342823429234302343123432234332343423435234362343723438234392344023441234422344323444234452344623447234482344923450234512345223453234542345523456234572345823459234602346123462234632346423465234662346723468234692347023471234722347323474234752347623477234782347923480234812348223483234842348523486234872348823489234902349123492234932349423495234962349723498234992350023501235022350323504235052350623507235082350923510235112351223513235142351523516235172351823519235202352123522235232352423525235262352723528235292353023531235322353323534235352353623537235382353923540235412354223543235442354523546235472354823549235502355123552235532355423555235562355723558235592356023561235622356323564235652356623567235682356923570235712357223573235742357523576235772357823579235802358123582235832358423585235862358723588235892359023591235922359323594235952359623597235982359923600236012360223603236042360523606236072360823609236102361123612236132361423615236162361723618236192362023621236222362323624236252362623627236282362923630236312363223633236342363523636236372363823639236402364123642236432364423645236462364723648236492365023651236522365323654236552365623657236582365923660236612366223663236642366523666236672366823669236702367123672236732367423675236762367723678236792368023681236822368323684236852368623687236882368923690236912369223693236942369523696236972369823699237002370123702237032370423705237062370723708237092371023711237122371323714237152371623717237182371923720237212372223723237242372523726237272372823729237302373123732237332373423735237362373723738237392374023741237422374323744237452374623747237482374923750237512375223753237542375523756237572375823759237602376123762237632376423765237662376723768237692377023771237722377323774237752377623777237782377923780237812378223783237842378523786237872378823789237902379123792237932379423795237962379723798237992380023801238022380323804238052380623807238082380923810238112381223813238142381523816238172381823819238202382123822238232382423825238262382723828238292383023831238322383323834238352383623837238382383923840238412384223843238442384523846238472384823849238502385123852238532385423855238562385723858238592386023861238622386323864238652386623867238682386923870238712387223873238742387523876238772387823879238802388123882238832388423885238862388723888238892389023891238922389323894238952389623897238982389923900239012390223903239042390523906239072390823909239102391123912239132391423915239162391723918239192392023921239222392323924239252392623927239282392923930239312393223933239342393523936239372393823939239402394123942239432394423945239462394723948239492395023951239522395323954239552395623957239582395923960239612396223963239642396523966239672396823969239702397123972239732397423975239762397723978239792398023981239822398323984239852398623987239882398923990239912399223993239942399523996239972399823999240002400124002240032400424005240062400724008240092401024011240122401324014240152401624017240182401924020240212402224023240242402524026240272402824029240302403124032240332403424035240362403724038240392404024041240422404324044240452404624047240482404924050240512405224053240542405524056240572405824059240602406124062240632406424065240662406724068240692407024071240722407324074240752407624077240782407924080240812408224083240842408524086240872408824089240902409124092240932409424095240962409724098240992410024101241022410324104241052410624107241082410924110241112411224113241142411524116241172411824119241202412124122241232412424125241262412724128241292413024131241322413324134241352413624137241382413924140241412414224143241442414524146241472414824149241502415124152241532415424155241562415724158241592416024161241622416324164241652416624167241682416924170241712417224173241742417524176241772417824179241802418124182241832418424185241862418724188241892419024191241922419324194241952419624197241982419924200242012420224203242042420524206242072420824209242102421124212242132421424215242162421724218242192422024221242222422324224242252422624227242282422924230242312423224233242342423524236242372423824239242402424124242242432424424245242462424724248242492425024251242522425324254242552425624257242582425924260242612426224263242642426524266242672426824269242702427124272242732427424275242762427724278242792428024281242822428324284242852428624287242882428924290242912429224293242942429524296242972429824299243002430124302243032430424305243062430724308243092431024311243122431324314243152431624317243182431924320243212432224323243242432524326243272432824329243302433124332243332433424335243362433724338243392434024341243422434324344243452434624347243482434924350243512435224353243542435524356243572435824359243602436124362243632436424365243662436724368243692437024371243722437324374243752437624377243782437924380243812438224383243842438524386243872438824389243902439124392243932439424395243962439724398243992440024401244022440324404244052440624407244082440924410244112441224413244142441524416244172441824419244202442124422244232442424425244262442724428244292443024431244322443324434244352443624437244382443924440244412444224443244442444524446244472444824449244502445124452244532445424455244562445724458244592446024461244622446324464244652446624467244682446924470244712447224473244742447524476244772447824479244802448124482244832448424485244862448724488244892449024491244922449324494244952449624497244982449924500245012450224503245042450524506245072450824509245102451124512245132451424515245162451724518245192452024521245222452324524245252452624527245282452924530245312453224533245342453524536245372453824539245402454124542245432454424545245462454724548245492455024551245522455324554245552455624557245582455924560245612456224563245642456524566245672456824569245702457124572245732457424575245762457724578245792458024581245822458324584245852458624587245882458924590245912459224593245942459524596245972459824599246002460124602246032460424605246062460724608246092461024611246122461324614246152461624617246182461924620246212462224623246242462524626246272462824629246302463124632246332463424635246362463724638246392464024641246422464324644246452464624647246482464924650246512465224653246542465524656246572465824659246602466124662246632466424665246662466724668246692467024671246722467324674246752467624677246782467924680246812468224683246842468524686246872468824689246902469124692246932469424695246962469724698246992470024701247022470324704247052470624707247082470924710247112471224713247142471524716247172471824719247202472124722247232472424725247262472724728247292473024731247322473324734247352473624737247382473924740247412474224743247442474524746247472474824749247502475124752247532475424755247562475724758247592476024761247622476324764247652476624767247682476924770247712477224773247742477524776247772477824779247802478124782247832478424785247862478724788247892479024791247922479324794247952479624797247982479924800248012480224803248042480524806248072480824809248102481124812248132481424815248162481724818248192482024821248222482324824248252482624827248282482924830248312483224833248342483524836248372483824839248402484124842248432484424845248462484724848248492485024851248522485324854248552485624857248582485924860248612486224863248642486524866248672486824869248702487124872248732487424875248762487724878248792488024881248822488324884248852488624887248882488924890248912489224893248942489524896248972489824899249002490124902249032490424905249062490724908249092491024911249122491324914249152491624917249182491924920249212492224923249242492524926249272492824929249302493124932249332493424935249362493724938249392494024941249422494324944249452494624947249482494924950249512495224953249542495524956249572495824959249602496124962249632496424965249662496724968249692497024971249722497324974249752497624977249782497924980249812498224983249842498524986249872498824989249902499124992249932499424995249962499724998249992500025001250022500325004250052500625007250082500925010250112501225013250142501525016250172501825019250202502125022250232502425025250262502725028250292503025031250322503325034250352503625037250382503925040250412504225043250442504525046250472504825049250502505125052250532505425055250562505725058250592506025061250622506325064250652506625067250682506925070250712507225073250742507525076250772507825079250802508125082250832508425085250862508725088250892509025091250922509325094250952509625097250982509925100251012510225103251042510525106251072510825109251102511125112251132511425115251162511725118251192512025121251222512325124251252512625127251282512925130251312513225133251342513525136251372513825139251402514125142251432514425145251462514725148251492515025151251522515325154251552515625157251582515925160251612516225163251642516525166251672516825169251702517125172251732517425175251762517725178251792518025181251822518325184251852518625187251882518925190251912519225193251942519525196251972519825199252002520125202252032520425205252062520725208252092521025211252122521325214252152521625217252182521925220252212522225223252242522525226252272522825229252302523125232252332523425235252362523725238252392524025241252422524325244252452524625247252482524925250252512525225253252542525525256252572525825259252602526125262252632526425265252662526725268252692527025271252722527325274252752527625277252782527925280252812528225283252842528525286252872528825289252902529125292252932529425295252962529725298252992530025301253022530325304253052530625307253082530925310253112531225313253142531525316253172531825319253202532125322253232532425325253262532725328253292533025331253322533325334253352533625337253382533925340253412534225343253442534525346253472534825349253502535125352253532535425355253562535725358253592536025361253622536325364253652536625367253682536925370253712537225373253742537525376253772537825379253802538125382253832538425385253862538725388253892539025391253922539325394253952539625397253982539925400254012540225403254042540525406254072540825409254102541125412254132541425415254162541725418254192542025421254222542325424254252542625427254282542925430254312543225433254342543525436254372543825439254402544125442254432544425445254462544725448254492545025451254522545325454254552545625457254582545925460254612546225463254642546525466254672546825469254702547125472254732547425475254762547725478254792548025481254822548325484254852548625487254882548925490254912549225493254942549525496254972549825499255002550125502255032550425505255062550725508255092551025511255122551325514255152551625517255182551925520255212552225523255242552525526255272552825529255302553125532255332553425535255362553725538255392554025541255422554325544255452554625547255482554925550255512555225553255542555525556255572555825559255602556125562255632556425565255662556725568255692557025571255722557325574255752557625577255782557925580255812558225583255842558525586255872558825589255902559125592255932559425595255962559725598255992560025601256022560325604256052560625607256082560925610256112561225613256142561525616256172561825619256202562125622256232562425625256262562725628256292563025631256322563325634256352563625637256382563925640256412564225643256442564525646256472564825649256502565125652256532565425655256562565725658256592566025661256622566325664256652566625667256682566925670256712567225673256742567525676256772567825679256802568125682256832568425685256862568725688256892569025691256922569325694256952569625697256982569925700257012570225703257042570525706257072570825709257102571125712257132571425715257162571725718257192572025721257222572325724257252572625727257282572925730257312573225733257342573525736257372573825739257402574125742257432574425745257462574725748257492575025751257522575325754257552575625757257582575925760257612576225763257642576525766257672576825769257702577125772257732577425775257762577725778257792578025781257822578325784257852578625787257882578925790257912579225793257942579525796257972579825799258002580125802258032580425805258062580725808258092581025811258122581325814258152581625817258182581925820258212582225823258242582525826258272582825829258302583125832258332583425835258362583725838258392584025841258422584325844258452584625847258482584925850258512585225853258542585525856258572585825859258602586125862258632586425865258662586725868258692587025871258722587325874258752587625877258782587925880258812588225883258842588525886258872588825889258902589125892258932589425895258962589725898258992590025901259022590325904259052590625907259082590925910259112591225913259142591525916259172591825919259202592125922259232592425925259262592725928259292593025931259322593325934259352593625937259382593925940259412594225943259442594525946259472594825949259502595125952259532595425955259562595725958259592596025961259622596325964259652596625967259682596925970259712597225973259742597525976259772597825979259802598125982259832598425985259862598725988259892599025991259922599325994259952599625997259982599926000260012600226003260042600526006260072600826009260102601126012260132601426015260162601726018260192602026021260222602326024260252602626027260282602926030260312603226033260342603526036260372603826039260402604126042260432604426045260462604726048260492605026051260522605326054260552605626057260582605926060260612606226063260642606526066260672606826069260702607126072260732607426075260762607726078260792608026081260822608326084260852608626087260882608926090260912609226093260942609526096260972609826099261002610126102261032610426105261062610726108261092611026111261122611326114261152611626117261182611926120261212612226123261242612526126261272612826129261302613126132261332613426135261362613726138261392614026141261422614326144261452614626147261482614926150261512615226153261542615526156261572615826159261602616126162261632616426165261662616726168261692617026171261722617326174261752617626177261782617926180261812618226183261842618526186261872618826189261902619126192261932619426195261962619726198261992620026201262022620326204262052620626207262082620926210262112621226213262142621526216262172621826219262202622126222262232622426225262262622726228262292623026231262322623326234262352623626237262382623926240262412624226243262442624526246262472624826249262502625126252262532625426255262562625726258262592626026261262622626326264262652626626267262682626926270262712627226273262742627526276262772627826279262802628126282262832628426285262862628726288262892629026291262922629326294262952629626297262982629926300263012630226303263042630526306263072630826309263102631126312263132631426315263162631726318263192632026321263222632326324263252632626327263282632926330263312633226333263342633526336263372633826339263402634126342263432634426345263462634726348263492635026351263522635326354263552635626357263582635926360263612636226363263642636526366263672636826369263702637126372263732637426375263762637726378263792638026381263822638326384263852638626387263882638926390263912639226393263942639526396263972639826399264002640126402264032640426405264062640726408264092641026411264122641326414264152641626417264182641926420264212642226423264242642526426264272642826429264302643126432264332643426435264362643726438264392644026441264422644326444264452644626447264482644926450264512645226453264542645526456264572645826459264602646126462264632646426465264662646726468264692647026471264722647326474264752647626477264782647926480264812648226483264842648526486264872648826489264902649126492264932649426495264962649726498264992650026501265022650326504265052650626507265082650926510265112651226513265142651526516265172651826519265202652126522265232652426525265262652726528265292653026531265322653326534265352653626537265382653926540265412654226543265442654526546265472654826549265502655126552265532655426555265562655726558265592656026561265622656326564265652656626567265682656926570265712657226573265742657526576265772657826579265802658126582265832658426585265862658726588265892659026591265922659326594265952659626597265982659926600266012660226603266042660526606266072660826609266102661126612266132661426615266162661726618266192662026621266222662326624266252662626627266282662926630266312663226633266342663526636266372663826639266402664126642266432664426645266462664726648266492665026651266522665326654266552665626657266582665926660266612666226663266642666526666266672666826669266702667126672266732667426675266762667726678266792668026681266822668326684266852668626687266882668926690266912669226693266942669526696266972669826699267002670126702267032670426705267062670726708267092671026711267122671326714267152671626717267182671926720267212672226723267242672526726267272672826729267302673126732267332673426735267362673726738267392674026741267422674326744267452674626747267482674926750267512675226753267542675526756267572675826759267602676126762267632676426765267662676726768267692677026771267722677326774267752677626777267782677926780267812678226783267842678526786267872678826789267902679126792267932679426795267962679726798267992680026801268022680326804268052680626807268082680926810268112681226813268142681526816268172681826819268202682126822268232682426825268262682726828268292683026831268322683326834268352683626837268382683926840268412684226843268442684526846268472684826849268502685126852268532685426855268562685726858268592686026861268622686326864268652686626867268682686926870268712687226873268742687526876268772687826879268802688126882268832688426885268862688726888268892689026891268922689326894268952689626897268982689926900269012690226903269042690526906269072690826909269102691126912269132691426915269162691726918269192692026921269222692326924269252692626927269282692926930269312693226933269342693526936269372693826939269402694126942269432694426945269462694726948269492695026951269522695326954269552695626957269582695926960269612696226963269642696526966269672696826969269702697126972269732697426975269762697726978269792698026981269822698326984269852698626987269882698926990269912699226993269942699526996269972699826999270002700127002270032700427005270062700727008270092701027011270122701327014270152701627017270182701927020270212702227023270242702527026270272702827029270302703127032270332703427035270362703727038270392704027041270422704327044270452704627047270482704927050270512705227053270542705527056270572705827059270602706127062270632706427065270662706727068270692707027071270722707327074270752707627077270782707927080270812708227083270842708527086270872708827089270902709127092270932709427095270962709727098270992710027101271022710327104271052710627107271082710927110271112711227113271142711527116271172711827119271202712127122271232712427125271262712727128271292713027131271322713327134271352713627137271382713927140271412714227143271442714527146271472714827149271502715127152271532715427155271562715727158271592716027161271622716327164271652716627167271682716927170271712717227173271742717527176271772717827179271802718127182271832718427185271862718727188271892719027191271922719327194271952719627197271982719927200272012720227203272042720527206272072720827209272102721127212272132721427215272162721727218272192722027221272222722327224272252722627227272282722927230272312723227233272342723527236272372723827239272402724127242272432724427245272462724727248272492725027251272522725327254272552725627257272582725927260272612726227263272642726527266272672726827269272702727127272272732727427275272762727727278272792728027281272822728327284272852728627287272882728927290272912729227293272942729527296272972729827299273002730127302273032730427305273062730727308273092731027311273122731327314273152731627317273182731927320273212732227323273242732527326273272732827329273302733127332273332733427335273362733727338273392734027341273422734327344273452734627347273482734927350273512735227353273542735527356273572735827359273602736127362273632736427365273662736727368273692737027371273722737327374273752737627377273782737927380273812738227383273842738527386273872738827389273902739127392273932739427395273962739727398273992740027401274022740327404274052740627407274082740927410274112741227413274142741527416274172741827419274202742127422274232742427425274262742727428274292743027431274322743327434274352743627437274382743927440274412744227443274442744527446274472744827449274502745127452274532745427455274562745727458274592746027461274622746327464274652746627467274682746927470274712747227473274742747527476274772747827479274802748127482274832748427485274862748727488274892749027491274922749327494274952749627497274982749927500275012750227503275042750527506275072750827509275102751127512275132751427515275162751727518275192752027521275222752327524275252752627527275282752927530275312753227533275342753527536275372753827539275402754127542275432754427545275462754727548275492755027551275522755327554275552755627557275582755927560275612756227563275642756527566275672756827569275702757127572275732757427575275762757727578275792758027581275822758327584275852758627587275882758927590275912759227593275942759527596275972759827599276002760127602276032760427605276062760727608276092761027611276122761327614276152761627617276182761927620276212762227623276242762527626276272762827629276302763127632276332763427635276362763727638276392764027641276422764327644276452764627647276482764927650276512765227653276542765527656276572765827659276602766127662276632766427665276662766727668276692767027671276722767327674276752767627677276782767927680276812768227683276842768527686276872768827689276902769127692276932769427695276962769727698276992770027701277022770327704277052770627707277082770927710277112771227713277142771527716277172771827719277202772127722277232772427725277262772727728277292773027731277322773327734277352773627737277382773927740277412774227743277442774527746277472774827749277502775127752277532775427755277562775727758277592776027761277622776327764277652776627767277682776927770277712777227773277742777527776277772777827779277802778127782277832778427785277862778727788277892779027791277922779327794277952779627797277982779927800278012780227803278042780527806278072780827809278102781127812278132781427815278162781727818278192782027821278222782327824278252782627827278282782927830278312783227833278342783527836278372783827839278402784127842278432784427845278462784727848278492785027851278522785327854278552785627857278582785927860278612786227863278642786527866278672786827869278702787127872278732787427875278762787727878278792788027881278822788327884278852788627887278882788927890278912789227893278942789527896278972789827899279002790127902279032790427905279062790727908279092791027911279122791327914279152791627917279182791927920279212792227923279242792527926279272792827929279302793127932279332793427935279362793727938279392794027941279422794327944279452794627947279482794927950279512795227953279542795527956279572795827959279602796127962279632796427965279662796727968279692797027971279722797327974279752797627977279782797927980279812798227983279842798527986279872798827989279902799127992279932799427995279962799727998279992800028001280022800328004280052800628007280082800928010280112801228013280142801528016280172801828019280202802128022280232802428025280262802728028280292803028031280322803328034280352803628037280382803928040280412804228043280442804528046280472804828049280502805128052280532805428055280562805728058280592806028061280622806328064280652806628067280682806928070280712807228073280742807528076280772807828079280802808128082280832808428085280862808728088280892809028091280922809328094280952809628097280982809928100281012810228103281042810528106281072810828109281102811128112281132811428115281162811728118281192812028121281222812328124281252812628127281282812928130281312813228133281342813528136281372813828139281402814128142281432814428145281462814728148281492815028151281522815328154281552815628157281582815928160281612816228163281642816528166281672816828169281702817128172281732817428175281762817728178281792818028181281822818328184281852818628187281882818928190281912819228193281942819528196281972819828199282002820128202282032820428205282062820728208282092821028211282122821328214282152821628217282182821928220282212822228223282242822528226282272822828229282302823128232282332823428235282362823728238282392824028241282422824328244282452824628247282482824928250282512825228253282542825528256282572825828259282602826128262282632826428265282662826728268282692827028271282722827328274282752827628277282782827928280282812828228283282842828528286282872828828289282902829128292282932829428295282962829728298282992830028301283022830328304283052830628307283082830928310283112831228313283142831528316283172831828319283202832128322283232832428325283262832728328283292833028331283322833328334283352833628337283382833928340283412834228343283442834528346283472834828349283502835128352283532835428355283562835728358283592836028361283622836328364283652836628367283682836928370283712837228373283742837528376283772837828379283802838128382283832838428385283862838728388283892839028391283922839328394283952839628397283982839928400284012840228403284042840528406284072840828409284102841128412284132841428415284162841728418284192842028421284222842328424284252842628427284282842928430284312843228433284342843528436284372843828439284402844128442284432844428445284462844728448284492845028451284522845328454284552845628457284582845928460284612846228463284642846528466284672846828469284702847128472284732847428475284762847728478284792848028481284822848328484284852848628487284882848928490284912849228493284942849528496284972849828499285002850128502285032850428505285062850728508285092851028511285122851328514285152851628517285182851928520285212852228523285242852528526285272852828529285302853128532285332853428535285362853728538285392854028541285422854328544285452854628547285482854928550285512855228553285542855528556285572855828559285602856128562285632856428565285662856728568285692857028571285722857328574285752857628577285782857928580285812858228583285842858528586285872858828589285902859128592285932859428595285962859728598285992860028601286022860328604286052860628607286082860928610286112861228613286142861528616286172861828619286202862128622286232862428625286262862728628286292863028631286322863328634286352863628637286382863928640286412864228643286442864528646286472864828649286502865128652286532865428655286562865728658286592866028661286622866328664286652866628667286682866928670286712867228673286742867528676286772867828679286802868128682286832868428685286862868728688286892869028691286922869328694286952869628697286982869928700287012870228703287042870528706287072870828709287102871128712287132871428715287162871728718287192872028721287222872328724287252872628727287282872928730287312873228733287342873528736287372873828739287402874128742287432874428745287462874728748287492875028751287522875328754287552875628757287582875928760287612876228763287642876528766287672876828769287702877128772287732877428775287762877728778287792878028781287822878328784287852878628787287882878928790287912879228793287942879528796287972879828799288002880128802288032880428805288062880728808288092881028811288122881328814288152881628817288182881928820288212882228823288242882528826288272882828829288302883128832288332883428835288362883728838288392884028841288422884328844288452884628847288482884928850288512885228853288542885528856288572885828859288602886128862288632886428865288662886728868288692887028871288722887328874288752887628877288782887928880288812888228883288842888528886288872888828889288902889128892288932889428895288962889728898288992890028901289022890328904289052890628907289082890928910289112891228913289142891528916289172891828919289202892128922289232892428925289262892728928289292893028931289322893328934289352893628937289382893928940289412894228943289442894528946289472894828949289502895128952289532895428955289562895728958289592896028961289622896328964289652896628967289682896928970289712897228973289742897528976289772897828979289802898128982289832898428985289862898728988289892899028991289922899328994289952899628997289982899929000290012900229003290042900529006290072900829009290102901129012290132901429015290162901729018290192902029021290222902329024290252902629027290282902929030290312903229033290342903529036290372903829039290402904129042290432904429045290462904729048290492905029051290522905329054290552905629057290582905929060290612906229063290642906529066290672906829069290702907129072290732907429075290762907729078290792908029081290822908329084290852908629087290882908929090290912909229093290942909529096290972909829099291002910129102291032910429105291062910729108291092911029111291122911329114291152911629117291182911929120291212912229123291242912529126291272912829129291302913129132291332913429135291362913729138291392914029141291422914329144291452914629147291482914929150291512915229153291542915529156291572915829159291602916129162291632916429165291662916729168291692917029171291722917329174291752917629177291782917929180291812918229183291842918529186291872918829189291902919129192291932919429195291962919729198291992920029201292022920329204292052920629207292082920929210292112921229213292142921529216292172921829219292202922129222292232922429225292262922729228292292923029231292322923329234292352923629237292382923929240292412924229243292442924529246292472924829249292502925129252292532925429255292562925729258292592926029261292622926329264292652926629267292682926929270292712927229273292742927529276292772927829279292802928129282292832928429285292862928729288292892929029291292922929329294292952929629297292982929929300293012930229303293042930529306293072930829309293102931129312293132931429315293162931729318293192932029321293222932329324293252932629327293282932929330293312933229333293342933529336293372933829339293402934129342293432934429345293462934729348293492935029351293522935329354293552935629357293582935929360293612936229363293642936529366293672936829369293702937129372293732937429375293762937729378293792938029381293822938329384293852938629387293882938929390293912939229393293942939529396293972939829399294002940129402294032940429405294062940729408294092941029411294122941329414294152941629417294182941929420294212942229423294242942529426294272942829429294302943129432294332943429435294362943729438294392944029441294422944329444294452944629447294482944929450294512945229453294542945529456294572945829459294602946129462294632946429465294662946729468294692947029471294722947329474294752947629477294782947929480294812948229483294842948529486294872948829489294902949129492294932949429495294962949729498294992950029501295022950329504295052950629507295082950929510295112951229513295142951529516295172951829519295202952129522295232952429525295262952729528295292953029531295322953329534295352953629537295382953929540295412954229543295442954529546295472954829549295502955129552295532955429555295562955729558295592956029561295622956329564295652956629567295682956929570295712957229573295742957529576295772957829579295802958129582295832958429585295862958729588295892959029591295922959329594295952959629597295982959929600296012960229603296042960529606296072960829609296102961129612296132961429615296162961729618296192962029621296222962329624296252962629627296282962929630296312963229633296342963529636296372963829639296402964129642296432964429645296462964729648296492965029651296522965329654296552965629657296582965929660296612966229663296642966529666296672966829669296702967129672296732967429675296762967729678296792968029681296822968329684296852968629687296882968929690296912969229693296942969529696296972969829699297002970129702297032970429705297062970729708297092971029711297122971329714297152971629717297182971929720297212972229723297242972529726297272972829729297302973129732297332973429735297362973729738297392974029741297422974329744297452974629747297482974929750297512975229753297542975529756297572975829759297602976129762297632976429765297662976729768297692977029771297722977329774297752977629777297782977929780297812978229783297842978529786297872978829789297902979129792297932979429795297962979729798297992980029801298022980329804298052980629807298082980929810298112981229813298142981529816298172981829819298202982129822298232982429825298262982729828298292983029831298322983329834298352983629837298382983929840298412984229843298442984529846298472984829849298502985129852298532985429855298562985729858298592986029861298622986329864298652986629867298682986929870298712987229873298742987529876298772987829879298802988129882298832988429885298862988729888298892989029891298922989329894298952989629897298982989929900299012990229903299042990529906299072990829909299102991129912299132991429915299162991729918299192992029921299222992329924299252992629927299282992929930299312993229933299342993529936299372993829939299402994129942299432994429945299462994729948299492995029951299522995329954299552995629957299582995929960299612996229963299642996529966299672996829969299702997129972299732997429975299762997729978299792998029981299822998329984299852998629987299882998929990299912999229993299942999529996299972999829999300003000130002300033000430005300063000730008300093001030011300123001330014300153001630017300183001930020300213002230023300243002530026300273002830029300303003130032300333003430035300363003730038300393004030041300423004330044300453004630047300483004930050300513005230053300543005530056300573005830059300603006130062300633006430065300663006730068300693007030071300723007330074300753007630077300783007930080300813008230083300843008530086300873008830089300903009130092300933009430095300963009730098300993010030101301023010330104301053010630107301083010930110301113011230113301143011530116301173011830119301203012130122301233012430125301263012730128301293013030131301323013330134301353013630137301383013930140301413014230143301443014530146301473014830149301503015130152301533015430155301563015730158301593016030161301623016330164301653016630167301683016930170301713017230173301743017530176301773017830179301803018130182301833018430185301863018730188301893019030191301923019330194301953019630197301983019930200302013020230203302043020530206302073020830209302103021130212302133021430215302163021730218302193022030221302223022330224302253022630227302283022930230302313023230233302343023530236302373023830239302403024130242302433024430245302463024730248302493025030251302523025330254302553025630257302583025930260302613026230263302643026530266302673026830269302703027130272302733027430275302763027730278302793028030281302823028330284302853028630287302883028930290302913029230293302943029530296302973029830299303003030130302303033030430305303063030730308303093031030311303123031330314303153031630317303183031930320303213032230323303243032530326303273032830329303303033130332303333033430335303363033730338303393034030341303423034330344303453034630347303483034930350303513035230353303543035530356303573035830359303603036130362303633036430365303663036730368303693037030371303723037330374303753037630377303783037930380303813038230383303843038530386303873038830389303903039130392303933039430395303963039730398303993040030401304023040330404304053040630407304083040930410304113041230413304143041530416304173041830419304203042130422304233042430425304263042730428304293043030431304323043330434304353043630437304383043930440304413044230443304443044530446304473044830449304503045130452304533045430455304563045730458304593046030461304623046330464304653046630467304683046930470304713047230473304743047530476304773047830479304803048130482304833048430485304863048730488304893049030491304923049330494304953049630497304983049930500305013050230503305043050530506305073050830509305103051130512305133051430515305163051730518305193052030521305223052330524305253052630527305283052930530305313053230533305343053530536305373053830539305403054130542305433054430545305463054730548305493055030551305523055330554305553055630557305583055930560305613056230563305643056530566305673056830569305703057130572305733057430575305763057730578305793058030581305823058330584305853058630587305883058930590305913059230593305943059530596305973059830599306003060130602306033060430605306063060730608306093061030611306123061330614306153061630617306183061930620306213062230623306243062530626306273062830629306303063130632306333063430635306363063730638306393064030641306423064330644306453064630647306483064930650306513065230653306543065530656306573065830659306603066130662306633066430665306663066730668306693067030671306723067330674306753067630677306783067930680306813068230683306843068530686306873068830689306903069130692306933069430695306963069730698306993070030701307023070330704307053070630707307083070930710307113071230713307143071530716307173071830719307203072130722307233072430725307263072730728307293073030731307323073330734307353073630737307383073930740307413074230743307443074530746307473074830749307503075130752307533075430755307563075730758307593076030761307623076330764307653076630767307683076930770307713077230773307743077530776307773077830779307803078130782307833078430785307863078730788307893079030791307923079330794307953079630797307983079930800308013080230803308043080530806308073080830809308103081130812308133081430815308163081730818308193082030821308223082330824308253082630827308283082930830308313083230833308343083530836308373083830839308403084130842308433084430845308463084730848308493085030851308523085330854308553085630857308583085930860308613086230863308643086530866308673086830869308703087130872308733087430875308763087730878308793088030881308823088330884308853088630887308883088930890308913089230893308943089530896308973089830899309003090130902309033090430905309063090730908309093091030911309123091330914309153091630917309183091930920309213092230923309243092530926309273092830929309303093130932309333093430935309363093730938309393094030941309423094330944309453094630947309483094930950309513095230953309543095530956309573095830959309603096130962309633096430965309663096730968309693097030971309723097330974309753097630977309783097930980309813098230983309843098530986309873098830989309903099130992309933099430995309963099730998309993100031001310023100331004310053100631007310083100931010310113101231013310143101531016310173101831019310203102131022310233102431025310263102731028310293103031031310323103331034310353103631037310383103931040310413104231043310443104531046310473104831049310503105131052310533105431055310563105731058310593106031061310623106331064310653106631067310683106931070310713107231073310743107531076310773107831079310803108131082310833108431085310863108731088310893109031091310923109331094310953109631097310983109931100311013110231103311043110531106311073110831109311103111131112311133111431115311163111731118311193112031121311223112331124311253112631127311283112931130311313113231133311343113531136311373113831139311403114131142311433114431145311463114731148311493115031151311523115331154311553115631157311583115931160311613116231163311643116531166311673116831169311703117131172311733117431175311763117731178311793118031181311823118331184311853118631187311883118931190311913119231193311943119531196311973119831199312003120131202312033120431205312063120731208312093121031211312123121331214312153121631217312183121931220312213122231223312243122531226312273122831229312303123131232312333123431235312363123731238312393124031241312423124331244312453124631247312483124931250312513125231253312543125531256312573125831259312603126131262312633126431265312663126731268312693127031271312723127331274312753127631277312783127931280312813128231283312843128531286312873128831289312903129131292312933129431295312963129731298312993130031301313023130331304313053130631307313083130931310313113131231313313143131531316313173131831319313203132131322313233132431325313263132731328313293133031331313323133331334313353133631337313383133931340313413134231343313443134531346313473134831349313503135131352313533135431355313563135731358313593136031361313623136331364313653136631367313683136931370313713137231373313743137531376313773137831379313803138131382313833138431385313863138731388313893139031391313923139331394313953139631397313983139931400314013140231403314043140531406314073140831409314103141131412314133141431415314163141731418314193142031421314223142331424314253142631427314283142931430314313143231433314343143531436314373143831439314403144131442314433144431445314463144731448314493145031451314523145331454314553145631457314583145931460314613146231463314643146531466314673146831469314703147131472314733147431475314763147731478314793148031481314823148331484314853148631487314883148931490314913149231493314943149531496314973149831499315003150131502315033150431505315063150731508315093151031511315123151331514315153151631517315183151931520315213152231523315243152531526315273152831529315303153131532315333153431535315363153731538315393154031541315423154331544315453154631547315483154931550315513155231553315543155531556315573155831559315603156131562315633156431565315663156731568315693157031571315723157331574315753157631577315783157931580315813158231583315843158531586315873158831589315903159131592315933159431595315963159731598315993160031601316023160331604316053160631607316083160931610316113161231613316143161531616316173161831619316203162131622316233162431625316263162731628316293163031631316323163331634316353163631637316383163931640316413164231643316443164531646316473164831649316503165131652316533165431655316563165731658316593166031661316623166331664316653166631667316683166931670316713167231673316743167531676316773167831679316803168131682316833168431685316863168731688316893169031691316923169331694316953169631697316983169931700317013170231703317043170531706317073170831709317103171131712317133171431715317163171731718317193172031721317223172331724317253172631727317283172931730317313173231733317343173531736317373173831739317403174131742317433174431745317463174731748317493175031751317523175331754317553175631757317583175931760317613176231763317643176531766317673176831769317703177131772317733177431775317763177731778317793178031781317823178331784317853178631787317883178931790317913179231793317943179531796317973179831799318003180131802318033180431805318063180731808318093181031811318123181331814318153181631817318183181931820318213182231823318243182531826318273182831829318303183131832318333183431835318363183731838318393184031841318423184331844318453184631847318483184931850318513185231853318543185531856318573185831859318603186131862318633186431865318663186731868318693187031871318723187331874318753187631877318783187931880318813188231883318843188531886318873188831889318903189131892318933189431895318963189731898318993190031901319023190331904319053190631907319083190931910319113191231913319143191531916319173191831919319203192131922319233192431925319263192731928319293193031931319323193331934319353193631937319383193931940319413194231943319443194531946319473194831949319503195131952319533195431955319563195731958319593196031961319623196331964319653196631967319683196931970319713197231973319743197531976319773197831979319803198131982319833198431985319863198731988319893199031991319923199331994319953199631997319983199932000320013200232003320043200532006320073200832009320103201132012320133201432015320163201732018320193202032021320223202332024320253202632027320283202932030320313203232033320343203532036320373203832039320403204132042320433204432045320463204732048320493205032051320523205332054320553205632057320583205932060320613206232063320643206532066320673206832069320703207132072320733207432075320763207732078320793208032081320823208332084320853208632087320883208932090320913209232093320943209532096320973209832099321003210132102321033210432105321063210732108321093211032111321123211332114321153211632117321183211932120321213212232123321243212532126321273212832129321303213132132321333213432135321363213732138321393214032141321423214332144321453214632147321483214932150321513215232153321543215532156321573215832159321603216132162321633216432165321663216732168321693217032171321723217332174321753217632177321783217932180321813218232183321843218532186321873218832189321903219132192321933219432195321963219732198321993220032201322023220332204322053220632207322083220932210322113221232213322143221532216322173221832219322203222132222322233222432225322263222732228322293223032231322323223332234322353223632237322383223932240322413224232243322443224532246322473224832249322503225132252322533225432255322563225732258322593226032261322623226332264322653226632267322683226932270322713227232273322743227532276322773227832279322803228132282322833228432285322863228732288322893229032291322923229332294322953229632297322983229932300323013230232303323043230532306323073230832309323103231132312323133231432315323163231732318323193232032321323223232332324323253232632327323283232932330323313233232333323343233532336323373233832339323403234132342323433234432345323463234732348323493235032351323523235332354323553235632357323583235932360323613236232363323643236532366323673236832369323703237132372323733237432375323763237732378323793238032381323823238332384323853238632387323883238932390323913239232393323943239532396323973239832399324003240132402324033240432405324063240732408324093241032411324123241332414324153241632417324183241932420324213242232423324243242532426324273242832429324303243132432324333243432435324363243732438324393244032441324423244332444324453244632447324483244932450324513245232453324543245532456324573245832459324603246132462324633246432465324663246732468324693247032471324723247332474324753247632477324783247932480324813248232483324843248532486324873248832489324903249132492324933249432495324963249732498324993250032501325023250332504325053250632507325083250932510325113251232513325143251532516325173251832519325203252132522325233252432525325263252732528325293253032531325323253332534325353253632537325383253932540325413254232543325443254532546325473254832549325503255132552325533255432555325563255732558325593256032561325623256332564325653256632567325683256932570325713257232573325743257532576325773257832579325803258132582325833258432585325863258732588325893259032591325923259332594325953259632597325983259932600326013260232603326043260532606326073260832609326103261132612326133261432615326163261732618326193262032621326223262332624326253262632627326283262932630326313263232633326343263532636326373263832639326403264132642326433264432645326463264732648326493265032651326523265332654326553265632657326583265932660326613266232663326643266532666326673266832669326703267132672326733267432675326763267732678326793268032681326823268332684326853268632687326883268932690326913269232693326943269532696326973269832699327003270132702327033270432705327063270732708327093271032711327123271332714327153271632717327183271932720327213272232723327243272532726327273272832729327303273132732327333273432735327363273732738327393274032741327423274332744327453274632747327483274932750327513275232753327543275532756327573275832759327603276132762327633276432765327663276732768327693277032771327723277332774327753277632777327783277932780327813278232783327843278532786327873278832789327903279132792327933279432795327963279732798327993280032801328023280332804328053280632807328083280932810328113281232813328143281532816328173281832819328203282132822328233282432825328263282732828328293283032831328323283332834328353283632837328383283932840328413284232843328443284532846328473284832849328503285132852328533285432855328563285732858328593286032861328623286332864328653286632867328683286932870328713287232873328743287532876328773287832879328803288132882328833288432885328863288732888328893289032891328923289332894328953289632897328983289932900329013290232903329043290532906329073290832909329103291132912329133291432915329163291732918329193292032921329223292332924329253292632927329283292932930329313293232933329343293532936329373293832939329403294132942329433294432945329463294732948329493295032951329523295332954329553295632957329583295932960329613296232963329643296532966329673296832969329703297132972329733297432975329763297732978329793298032981329823298332984329853298632987329883298932990329913299232993329943299532996329973299832999330003300133002330033300433005330063300733008330093301033011330123301333014330153301633017330183301933020330213302233023330243302533026330273302833029330303303133032330333303433035330363303733038330393304033041330423304333044330453304633047330483304933050330513305233053330543305533056330573305833059330603306133062330633306433065330663306733068330693307033071330723307333074330753307633077330783307933080330813308233083330843308533086330873308833089330903309133092330933309433095330963309733098330993310033101331023310333104331053310633107331083310933110331113311233113331143311533116331173311833119331203312133122331233312433125331263312733128331293313033131331323313333134331353313633137331383313933140331413314233143331443314533146331473314833149331503315133152331533315433155331563315733158331593316033161331623316333164331653316633167331683316933170331713317233173331743317533176331773317833179331803318133182331833318433185331863318733188331893319033191331923319333194331953319633197331983319933200332013320233203332043320533206332073320833209332103321133212332133321433215332163321733218332193322033221332223322333224332253322633227332283322933230332313323233233332343323533236332373323833239332403324133242332433324433245332463324733248332493325033251332523325333254332553325633257332583325933260332613326233263332643326533266332673326833269332703327133272332733327433275332763327733278332793328033281332823328333284332853328633287332883328933290332913329233293332943329533296332973329833299333003330133302333033330433305333063330733308333093331033311333123331333314333153331633317333183331933320333213332233323333243332533326333273332833329333303333133332333333333433335333363333733338333393334033341333423334333344333453334633347333483334933350333513335233353333543335533356333573335833359333603336133362333633336433365333663336733368333693337033371333723337333374333753337633377333783337933380333813338233383333843338533386333873338833389333903339133392333933339433395333963339733398333993340033401334023340333404334053340633407334083340933410334113341233413334143341533416334173341833419334203342133422334233342433425334263342733428334293343033431334323343333434334353343633437334383343933440334413344233443334443344533446334473344833449334503345133452334533345433455334563345733458334593346033461334623346333464334653346633467334683346933470334713347233473334743347533476334773347833479334803348133482334833348433485334863348733488334893349033491334923349333494334953349633497334983349933500335013350233503335043350533506335073350833509335103351133512335133351433515335163351733518335193352033521335223352333524335253352633527335283352933530335313353233533335343353533536335373353833539335403354133542335433354433545335463354733548335493355033551335523355333554335553355633557335583355933560335613356233563335643356533566335673356833569335703357133572335733357433575335763357733578335793358033581335823358333584335853358633587335883358933590335913359233593335943359533596335973359833599336003360133602336033360433605336063360733608336093361033611336123361333614336153361633617336183361933620336213362233623336243362533626336273362833629336303363133632336333363433635336363363733638336393364033641336423364333644336453364633647336483364933650336513365233653336543365533656336573365833659336603366133662336633366433665336663366733668336693367033671336723367333674336753367633677336783367933680336813368233683336843368533686336873368833689336903369133692336933369433695336963369733698336993370033701337023370333704337053370633707337083370933710337113371233713337143371533716337173371833719337203372133722337233372433725337263372733728337293373033731337323373333734337353373633737337383373933740337413374233743337443374533746337473374833749337503375133752337533375433755337563375733758337593376033761337623376333764337653376633767337683376933770337713377233773337743377533776337773377833779337803378133782337833378433785337863378733788337893379033791337923379333794337953379633797337983379933800338013380233803338043380533806338073380833809338103381133812338133381433815338163381733818338193382033821338223382333824338253382633827338283382933830338313383233833338343383533836338373383833839338403384133842338433384433845338463384733848338493385033851338523385333854338553385633857338583385933860338613386233863338643386533866338673386833869338703387133872338733387433875338763387733878338793388033881338823388333884338853388633887338883388933890338913389233893338943389533896338973389833899339003390133902339033390433905339063390733908339093391033911339123391333914339153391633917339183391933920339213392233923339243392533926339273392833929339303393133932339333393433935339363393733938339393394033941339423394333944339453394633947339483394933950339513395233953339543395533956339573395833959339603396133962339633396433965339663396733968339693397033971339723397333974339753397633977339783397933980339813398233983339843398533986339873398833989339903399133992339933399433995339963399733998339993400034001340023400334004340053400634007340083400934010340113401234013340143401534016340173401834019340203402134022340233402434025340263402734028340293403034031340323403334034340353403634037340383403934040340413404234043340443404534046340473404834049340503405134052340533405434055340563405734058340593406034061340623406334064340653406634067340683406934070340713407234073340743407534076340773407834079340803408134082340833408434085340863408734088340893409034091340923409334094340953409634097340983409934100341013410234103341043410534106341073410834109341103411134112341133411434115341163411734118341193412034121341223412334124341253412634127341283412934130341313413234133341343413534136341373413834139341403414134142341433414434145341463414734148341493415034151341523415334154341553415634157341583415934160341613416234163341643416534166341673416834169341703417134172341733417434175341763417734178341793418034181341823418334184341853418634187341883418934190341913419234193341943419534196341973419834199342003420134202342033420434205342063420734208342093421034211342123421334214342153421634217342183421934220342213422234223342243422534226342273422834229342303423134232342333423434235342363423734238342393424034241342423424334244342453424634247342483424934250342513425234253342543425534256342573425834259342603426134262342633426434265342663426734268342693427034271342723427334274342753427634277342783427934280342813428234283342843428534286342873428834289342903429134292342933429434295342963429734298342993430034301343023430334304343053430634307343083430934310343113431234313343143431534316343173431834319343203432134322343233432434325343263432734328343293433034331343323433334334343353433634337343383433934340343413434234343343443434534346343473434834349343503435134352343533435434355343563435734358343593436034361343623436334364343653436634367343683436934370343713437234373343743437534376343773437834379343803438134382343833438434385343863438734388343893439034391343923439334394343953439634397343983439934400344013440234403344043440534406344073440834409344103441134412344133441434415344163441734418344193442034421344223442334424344253442634427344283442934430344313443234433344343443534436344373443834439344403444134442344433444434445344463444734448344493445034451344523445334454344553445634457344583445934460344613446234463344643446534466344673446834469344703447134472344733447434475344763447734478344793448034481344823448334484344853448634487344883448934490344913449234493344943449534496344973449834499345003450134502345033450434505345063450734508345093451034511345123451334514345153451634517345183451934520345213452234523345243452534526345273452834529345303453134532345333453434535345363453734538345393454034541345423454334544345453454634547345483454934550345513455234553345543455534556345573455834559345603456134562345633456434565345663456734568345693457034571345723457334574345753457634577345783457934580345813458234583345843458534586345873458834589345903459134592345933459434595345963459734598345993460034601346023460334604346053460634607346083460934610346113461234613346143461534616346173461834619346203462134622346233462434625346263462734628346293463034631346323463334634346353463634637346383463934640346413464234643346443464534646346473464834649346503465134652346533465434655346563465734658346593466034661346623466334664346653466634667346683466934670346713467234673346743467534676346773467834679346803468134682346833468434685346863468734688346893469034691346923469334694346953469634697346983469934700347013470234703347043470534706347073470834709347103471134712347133471434715347163471734718347193472034721347223472334724347253472634727347283472934730347313473234733347343473534736347373473834739347403474134742347433474434745347463474734748347493475034751347523475334754347553475634757347583475934760347613476234763347643476534766347673476834769347703477134772347733477434775347763477734778347793478034781347823478334784347853478634787347883478934790347913479234793347943479534796347973479834799348003480134802348033480434805348063480734808348093481034811348123481334814348153481634817348183481934820348213482234823348243482534826348273482834829348303483134832348333483434835348363483734838348393484034841348423484334844348453484634847348483484934850348513485234853348543485534856348573485834859348603486134862348633486434865348663486734868348693487034871348723487334874348753487634877348783487934880348813488234883348843488534886348873488834889348903489134892348933489434895348963489734898348993490034901349023490334904349053490634907349083490934910349113491234913349143491534916349173491834919349203492134922349233492434925349263492734928349293493034931349323493334934349353493634937349383493934940349413494234943349443494534946349473494834949349503495134952349533495434955349563495734958349593496034961349623496334964349653496634967349683496934970349713497234973349743497534976349773497834979349803498134982349833498434985349863498734988349893499034991349923499334994349953499634997349983499935000350013500235003350043500535006350073500835009350103501135012350133501435015350163501735018350193502035021350223502335024350253502635027350283502935030350313503235033350343503535036350373503835039350403504135042350433504435045350463504735048350493505035051350523505335054350553505635057350583505935060350613506235063350643506535066350673506835069350703507135072350733507435075350763507735078350793508035081350823508335084350853508635087350883508935090350913509235093350943509535096350973509835099351003510135102351033510435105351063510735108351093511035111351123511335114351153511635117351183511935120351213512235123351243512535126351273512835129351303513135132351333513435135351363513735138351393514035141351423514335144351453514635147351483514935150351513515235153351543515535156351573515835159351603516135162351633516435165351663516735168351693517035171351723517335174351753517635177351783517935180351813518235183351843518535186351873518835189351903519135192351933519435195351963519735198351993520035201352023520335204352053520635207352083520935210352113521235213352143521535216352173521835219352203522135222352233522435225352263522735228352293523035231352323523335234352353523635237352383523935240352413524235243352443524535246352473524835249352503525135252352533525435255352563525735258352593526035261352623526335264352653526635267352683526935270352713527235273352743527535276352773527835279352803528135282352833528435285352863528735288352893529035291352923529335294352953529635297352983529935300353013530235303353043530535306353073530835309353103531135312353133531435315353163531735318353193532035321353223532335324353253532635327353283532935330353313533235333353343533535336353373533835339353403534135342353433534435345353463534735348353493535035351353523535335354353553535635357353583535935360353613536235363353643536535366353673536835369353703537135372353733537435375353763537735378353793538035381353823538335384353853538635387353883538935390353913539235393353943539535396353973539835399354003540135402354033540435405354063540735408354093541035411354123541335414354153541635417354183541935420354213542235423354243542535426354273542835429354303543135432354333543435435354363543735438354393544035441354423544335444354453544635447354483544935450354513545235453354543545535456354573545835459354603546135462354633546435465354663546735468354693547035471354723547335474354753547635477354783547935480354813548235483354843548535486354873548835489354903549135492354933549435495354963549735498354993550035501355023550335504355053550635507355083550935510355113551235513355143551535516355173551835519355203552135522355233552435525355263552735528355293553035531355323553335534355353553635537355383553935540355413554235543355443554535546355473554835549355503555135552355533555435555355563555735558355593556035561355623556335564355653556635567355683556935570355713557235573355743557535576355773557835579355803558135582355833558435585355863558735588355893559035591355923559335594355953559635597355983559935600356013560235603356043560535606356073560835609356103561135612356133561435615356163561735618356193562035621356223562335624356253562635627356283562935630356313563235633356343563535636356373563835639356403564135642356433564435645356463564735648356493565035651356523565335654356553565635657356583565935660356613566235663356643566535666356673566835669356703567135672356733567435675356763567735678356793568035681356823568335684356853568635687356883568935690356913569235693356943569535696356973569835699357003570135702357033570435705357063570735708357093571035711357123571335714357153571635717357183571935720357213572235723357243572535726357273572835729357303573135732357333573435735357363573735738357393574035741357423574335744357453574635747357483574935750357513575235753357543575535756357573575835759357603576135762357633576435765357663576735768357693577035771357723577335774357753577635777357783577935780357813578235783357843578535786357873578835789357903579135792357933579435795357963579735798357993580035801358023580335804358053580635807358083580935810358113581235813358143581535816358173581835819358203582135822358233582435825358263582735828358293583035831358323583335834358353583635837358383583935840358413584235843358443584535846358473584835849358503585135852358533585435855358563585735858358593586035861358623586335864358653586635867358683586935870358713587235873358743587535876358773587835879358803588135882358833588435885358863588735888358893589035891358923589335894358953589635897358983589935900359013590235903359043590535906359073590835909359103591135912359133591435915359163591735918359193592035921359223592335924359253592635927359283592935930359313593235933359343593535936359373593835939359403594135942359433594435945359463594735948359493595035951359523595335954359553595635957359583595935960359613596235963359643596535966359673596835969359703597135972359733597435975359763597735978359793598035981359823598335984359853598635987359883598935990359913599235993359943599535996359973599835999360003600136002360033600436005360063600736008360093601036011360123601336014360153601636017360183601936020360213602236023360243602536026360273602836029360303603136032360333603436035360363603736038360393604036041360423604336044360453604636047360483604936050360513605236053360543605536056360573605836059360603606136062360633606436065360663606736068360693607036071360723607336074360753607636077360783607936080360813608236083360843608536086360873608836089360903609136092360933609436095360963609736098360993610036101361023610336104361053610636107361083610936110361113611236113361143611536116361173611836119361203612136122361233612436125361263612736128361293613036131361323613336134361353613636137361383613936140361413614236143361443614536146361473614836149361503615136152361533615436155361563615736158361593616036161361623616336164361653616636167361683616936170361713617236173361743617536176361773617836179361803618136182361833618436185361863618736188361893619036191361923619336194361953619636197361983619936200362013620236203362043620536206362073620836209362103621136212362133621436215362163621736218362193622036221362223622336224362253622636227362283622936230362313623236233362343623536236362373623836239362403624136242362433624436245362463624736248362493625036251362523625336254362553625636257362583625936260362613626236263362643626536266362673626836269362703627136272362733627436275362763627736278362793628036281362823628336284362853628636287362883628936290362913629236293362943629536296362973629836299363003630136302363033630436305363063630736308363093631036311363123631336314363153631636317363183631936320363213632236323363243632536326363273632836329363303633136332363333633436335363363633736338363393634036341363423634336344363453634636347363483634936350363513635236353363543635536356363573635836359363603636136362363633636436365363663636736368363693637036371363723637336374363753637636377363783637936380363813638236383363843638536386363873638836389363903639136392363933639436395363963639736398363993640036401364023640336404364053640636407364083640936410364113641236413364143641536416364173641836419364203642136422364233642436425364263642736428364293643036431364323643336434364353643636437364383643936440364413644236443364443644536446364473644836449364503645136452364533645436455364563645736458364593646036461364623646336464364653646636467364683646936470364713647236473364743647536476364773647836479364803648136482364833648436485364863648736488364893649036491364923649336494364953649636497364983649936500365013650236503365043650536506365073650836509365103651136512365133651436515365163651736518365193652036521365223652336524365253652636527365283652936530365313653236533365343653536536365373653836539365403654136542365433654436545365463654736548365493655036551365523655336554365553655636557365583655936560365613656236563365643656536566365673656836569365703657136572365733657436575365763657736578365793658036581365823658336584365853658636587365883658936590365913659236593365943659536596365973659836599366003660136602366033660436605366063660736608366093661036611366123661336614366153661636617366183661936620366213662236623366243662536626366273662836629366303663136632366333663436635366363663736638366393664036641366423664336644366453664636647366483664936650366513665236653366543665536656366573665836659366603666136662366633666436665366663666736668366693667036671366723667336674366753667636677366783667936680366813668236683366843668536686366873668836689366903669136692366933669436695366963669736698366993670036701367023670336704367053670636707367083670936710367113671236713367143671536716367173671836719367203672136722367233672436725367263672736728367293673036731367323673336734367353673636737367383673936740367413674236743367443674536746367473674836749367503675136752367533675436755367563675736758367593676036761367623676336764367653676636767367683676936770367713677236773367743677536776367773677836779367803678136782367833678436785367863678736788367893679036791367923679336794367953679636797367983679936800368013680236803368043680536806368073680836809368103681136812368133681436815368163681736818368193682036821368223682336824368253682636827368283682936830368313683236833368343683536836368373683836839368403684136842368433684436845368463684736848368493685036851368523685336854368553685636857368583685936860368613686236863368643686536866368673686836869368703687136872368733687436875368763687736878368793688036881368823688336884368853688636887368883688936890368913689236893368943689536896368973689836899369003690136902369033690436905369063690736908369093691036911369123691336914369153691636917369183691936920369213692236923369243692536926369273692836929369303693136932369333693436935369363693736938369393694036941369423694336944369453694636947369483694936950369513695236953369543695536956369573695836959369603696136962369633696436965369663696736968369693697036971369723697336974369753697636977369783697936980369813698236983369843698536986369873698836989369903699136992369933699436995369963699736998369993700037001370023700337004370053700637007370083700937010370113701237013370143701537016370173701837019370203702137022370233702437025370263702737028370293703037031370323703337034370353703637037370383703937040370413704237043370443704537046370473704837049370503705137052370533705437055370563705737058370593706037061370623706337064370653706637067370683706937070370713707237073370743707537076370773707837079370803708137082370833708437085370863708737088370893709037091370923709337094370953709637097370983709937100371013710237103371043710537106371073710837109371103711137112371133711437115371163711737118371193712037121371223712337124371253712637127371283712937130371313713237133371343713537136371373713837139371403714137142371433714437145371463714737148371493715037151371523715337154371553715637157371583715937160371613716237163371643716537166371673716837169371703717137172371733717437175371763717737178371793718037181371823718337184371853718637187371883718937190371913719237193371943719537196371973719837199372003720137202372033720437205372063720737208372093721037211372123721337214372153721637217372183721937220372213722237223372243722537226372273722837229372303723137232372333723437235372363723737238372393724037241372423724337244372453724637247372483724937250372513725237253372543725537256372573725837259372603726137262372633726437265372663726737268372693727037271372723727337274372753727637277372783727937280372813728237283372843728537286372873728837289372903729137292372933729437295372963729737298372993730037301373023730337304373053730637307373083730937310373113731237313373143731537316373173731837319373203732137322373233732437325373263732737328373293733037331373323733337334373353733637337373383733937340373413734237343373443734537346373473734837349373503735137352373533735437355373563735737358373593736037361373623736337364373653736637367373683736937370373713737237373373743737537376373773737837379373803738137382373833738437385373863738737388373893739037391373923739337394373953739637397373983739937400374013740237403374043740537406374073740837409374103741137412374133741437415374163741737418374193742037421374223742337424374253742637427374283742937430374313743237433374343743537436374373743837439374403744137442374433744437445374463744737448374493745037451374523745337454374553745637457374583745937460374613746237463374643746537466374673746837469374703747137472374733747437475374763747737478374793748037481374823748337484374853748637487374883748937490374913749237493374943749537496374973749837499375003750137502375033750437505375063750737508375093751037511375123751337514375153751637517375183751937520375213752237523375243752537526375273752837529375303753137532375333753437535375363753737538375393754037541375423754337544375453754637547375483754937550375513755237553375543755537556375573755837559375603756137562375633756437565375663756737568375693757037571375723757337574375753757637577375783757937580375813758237583375843758537586375873758837589375903759137592375933759437595375963759737598375993760037601376023760337604376053760637607376083760937610376113761237613376143761537616376173761837619376203762137622376233762437625376263762737628376293763037631376323763337634376353763637637376383763937640376413764237643376443764537646376473764837649376503765137652376533765437655376563765737658376593766037661376623766337664376653766637667376683766937670376713767237673376743767537676376773767837679376803768137682376833768437685376863768737688376893769037691376923769337694376953769637697376983769937700377013770237703377043770537706377073770837709377103771137712377133771437715377163771737718377193772037721377223772337724377253772637727377283772937730377313773237733377343773537736377373773837739377403774137742377433774437745377463774737748377493775037751377523775337754377553775637757377583775937760377613776237763377643776537766377673776837769377703777137772377733777437775377763777737778377793778037781377823778337784377853778637787377883778937790377913779237793377943779537796377973779837799378003780137802378033780437805378063780737808378093781037811378123781337814378153781637817378183781937820378213782237823378243782537826378273782837829378303783137832378333783437835378363783737838378393784037841378423784337844378453784637847378483784937850378513785237853378543785537856378573785837859378603786137862378633786437865378663786737868378693787037871378723787337874378753787637877378783787937880378813788237883378843788537886378873788837889378903789137892378933789437895378963789737898378993790037901379023790337904379053790637907379083790937910379113791237913379143791537916379173791837919379203792137922379233792437925379263792737928379293793037931379323793337934379353793637937379383793937940379413794237943379443794537946379473794837949379503795137952379533795437955379563795737958379593796037961379623796337964379653796637967379683796937970379713797237973379743797537976379773797837979379803798137982379833798437985379863798737988379893799037991379923799337994379953799637997379983799938000380013800238003380043800538006380073800838009380103801138012380133801438015380163801738018380193802038021380223802338024380253802638027380283802938030380313803238033380343803538036380373803838039380403804138042380433804438045380463804738048380493805038051380523805338054380553805638057380583805938060380613806238063380643806538066380673806838069380703807138072380733807438075380763807738078380793808038081380823808338084380853808638087380883808938090380913809238093380943809538096380973809838099381003810138102381033810438105381063810738108381093811038111381123811338114381153811638117381183811938120381213812238123381243812538126381273812838129381303813138132381333813438135381363813738138381393814038141381423814338144381453814638147381483814938150381513815238153381543815538156381573815838159381603816138162381633816438165381663816738168381693817038171381723817338174381753817638177381783817938180381813818238183381843818538186381873818838189381903819138192381933819438195381963819738198381993820038201382023820338204382053820638207382083820938210382113821238213382143821538216382173821838219382203822138222382233822438225382263822738228382293823038231382323823338234382353823638237382383823938240382413824238243382443824538246382473824838249382503825138252382533825438255382563825738258382593826038261382623826338264382653826638267382683826938270382713827238273382743827538276382773827838279382803828138282382833828438285382863828738288382893829038291382923829338294382953829638297382983829938300383013830238303383043830538306383073830838309383103831138312383133831438315383163831738318383193832038321383223832338324383253832638327383283832938330383313833238333383343833538336383373833838339383403834138342383433834438345383463834738348383493835038351383523835338354383553835638357383583835938360383613836238363383643836538366383673836838369383703837138372383733837438375383763837738378383793838038381383823838338384383853838638387383883838938390383913839238393383943839538396383973839838399384003840138402384033840438405384063840738408384093841038411384123841338414384153841638417384183841938420384213842238423384243842538426384273842838429384303843138432384333843438435384363843738438384393844038441384423844338444384453844638447384483844938450384513845238453384543845538456384573845838459384603846138462384633846438465384663846738468384693847038471384723847338474384753847638477384783847938480384813848238483384843848538486384873848838489384903849138492384933849438495384963849738498384993850038501385023850338504385053850638507385083850938510385113851238513385143851538516385173851838519385203852138522385233852438525385263852738528385293853038531385323853338534385353853638537385383853938540385413854238543385443854538546385473854838549385503855138552385533855438555385563855738558385593856038561385623856338564385653856638567385683856938570385713857238573385743857538576385773857838579385803858138582385833858438585385863858738588385893859038591385923859338594385953859638597385983859938600386013860238603386043860538606386073860838609386103861138612386133861438615386163861738618386193862038621386223862338624386253862638627386283862938630386313863238633386343863538636386373863838639386403864138642386433864438645386463864738648386493865038651386523865338654386553865638657386583865938660386613866238663386643866538666386673866838669386703867138672386733867438675386763867738678386793868038681386823868338684386853868638687386883868938690386913869238693386943869538696386973869838699387003870138702387033870438705387063870738708387093871038711387123871338714387153871638717387183871938720387213872238723387243872538726387273872838729387303873138732387333873438735387363873738738387393874038741387423874338744387453874638747387483874938750387513875238753387543875538756387573875838759387603876138762387633876438765387663876738768387693877038771387723877338774387753877638777387783877938780387813878238783387843878538786387873878838789387903879138792387933879438795387963879738798387993880038801388023880338804388053880638807388083880938810388113881238813388143881538816388173881838819388203882138822388233882438825388263882738828388293883038831388323883338834388353883638837388383883938840388413884238843388443884538846388473884838849388503885138852388533885438855388563885738858388593886038861388623886338864388653886638867388683886938870388713887238873388743887538876388773887838879388803888138882388833888438885388863888738888388893889038891388923889338894388953889638897388983889938900389013890238903389043890538906389073890838909389103891138912389133891438915389163891738918389193892038921389223892338924389253892638927389283892938930389313893238933389343893538936389373893838939389403894138942389433894438945389463894738948389493895038951389523895338954389553895638957389583895938960389613896238963389643896538966389673896838969389703897138972389733897438975389763897738978389793898038981389823898338984389853898638987389883898938990389913899238993389943899538996389973899838999390003900139002390033900439005390063900739008390093901039011390123901339014390153901639017390183901939020390213902239023390243902539026390273902839029390303903139032390333903439035390363903739038390393904039041390423904339044390453904639047390483904939050390513905239053390543905539056390573905839059390603906139062390633906439065390663906739068390693907039071390723907339074390753907639077390783907939080390813908239083390843908539086390873908839089390903909139092390933909439095390963909739098390993910039101391023910339104391053910639107391083910939110391113911239113391143911539116391173911839119391203912139122391233912439125391263912739128391293913039131391323913339134391353913639137391383913939140391413914239143391443914539146391473914839149391503915139152391533915439155391563915739158391593916039161391623916339164391653916639167391683916939170391713917239173391743917539176391773917839179391803918139182391833918439185391863918739188391893919039191391923919339194391953919639197391983919939200392013920239203392043920539206392073920839209392103921139212392133921439215392163921739218392193922039221392223922339224392253922639227392283922939230392313923239233392343923539236392373923839239392403924139242392433924439245392463924739248392493925039251392523925339254392553925639257392583925939260392613926239263392643926539266392673926839269392703927139272392733927439275392763927739278392793928039281392823928339284392853928639287392883928939290392913929239293392943929539296392973929839299393003930139302393033930439305393063930739308393093931039311393123931339314393153931639317393183931939320393213932239323393243932539326393273932839329393303933139332393333933439335393363933739338393393934039341393423934339344393453934639347393483934939350393513935239353393543935539356393573935839359393603936139362393633936439365393663936739368393693937039371393723937339374393753937639377393783937939380393813938239383393843938539386393873938839389393903939139392393933939439395393963939739398393993940039401394023940339404394053940639407394083940939410394113941239413394143941539416394173941839419394203942139422394233942439425394263942739428394293943039431394323943339434394353943639437394383943939440394413944239443394443944539446394473944839449394503945139452394533945439455394563945739458394593946039461394623946339464394653946639467394683946939470394713947239473394743947539476394773947839479394803948139482394833948439485394863948739488394893949039491394923949339494394953949639497394983949939500395013950239503395043950539506395073950839509395103951139512395133951439515395163951739518395193952039521395223952339524395253952639527395283952939530395313953239533395343953539536395373953839539395403954139542395433954439545395463954739548395493955039551395523955339554395553955639557395583955939560395613956239563395643956539566395673956839569395703957139572395733957439575395763957739578395793958039581395823958339584395853958639587395883958939590395913959239593395943959539596395973959839599396003960139602396033960439605396063960739608396093961039611396123961339614396153961639617396183961939620396213962239623396243962539626396273962839629396303963139632396333963439635396363963739638396393964039641396423964339644396453964639647396483964939650396513965239653396543965539656396573965839659396603966139662396633966439665396663966739668396693967039671396723967339674396753967639677396783967939680396813968239683396843968539686396873968839689396903969139692396933969439695396963969739698396993970039701397023970339704397053970639707397083970939710397113971239713397143971539716397173971839719397203972139722397233972439725397263972739728397293973039731397323973339734397353973639737397383973939740397413974239743397443974539746397473974839749397503975139752397533975439755397563975739758397593976039761397623976339764397653976639767397683976939770397713977239773397743977539776397773977839779397803978139782397833978439785397863978739788397893979039791397923979339794397953979639797397983979939800398013980239803398043980539806398073980839809398103981139812398133981439815398163981739818398193982039821398223982339824398253982639827398283982939830398313983239833398343983539836398373983839839398403984139842398433984439845398463984739848398493985039851398523985339854398553985639857398583985939860398613986239863398643986539866398673986839869398703987139872398733987439875398763987739878398793988039881398823988339884398853988639887398883988939890398913989239893398943989539896398973989839899399003990139902399033990439905399063990739908399093991039911399123991339914399153991639917399183991939920399213992239923399243992539926399273992839929399303993139932399333993439935399363993739938399393994039941399423994339944399453994639947399483994939950399513995239953399543995539956399573995839959399603996139962399633996439965399663996739968399693997039971399723997339974399753997639977399783997939980399813998239983399843998539986399873998839989399903999139992399933999439995399963999739998399994000040001400024000340004400054000640007400084000940010400114001240013400144001540016400174001840019400204002140022400234002440025400264002740028400294003040031400324003340034400354003640037400384003940040400414004240043400444004540046400474004840049400504005140052400534005440055400564005740058400594006040061400624006340064400654006640067400684006940070400714007240073400744007540076400774007840079400804008140082400834008440085400864008740088400894009040091400924009340094400954009640097400984009940100401014010240103401044010540106401074010840109401104011140112401134011440115401164011740118401194012040121401224012340124401254012640127401284012940130401314013240133401344013540136401374013840139401404014140142401434014440145401464014740148401494015040151401524015340154401554015640157401584015940160401614016240163401644016540166401674016840169401704017140172401734017440175401764017740178401794018040181401824018340184401854018640187401884018940190401914019240193401944019540196401974019840199402004020140202402034020440205402064020740208402094021040211402124021340214402154021640217402184021940220402214022240223402244022540226402274022840229402304023140232402334023440235402364023740238402394024040241402424024340244402454024640247402484024940250402514025240253402544025540256402574025840259402604026140262402634026440265402664026740268402694027040271402724027340274402754027640277402784027940280402814028240283402844028540286402874028840289402904029140292402934029440295402964029740298402994030040301403024030340304403054030640307403084030940310403114031240313403144031540316403174031840319403204032140322403234032440325403264032740328403294033040331403324033340334403354033640337403384033940340403414034240343403444034540346403474034840349403504035140352403534035440355403564035740358403594036040361403624036340364403654036640367403684036940370403714037240373403744037540376403774037840379403804038140382403834038440385403864038740388403894039040391403924039340394403954039640397403984039940400404014040240403404044040540406404074040840409404104041140412404134041440415404164041740418404194042040421404224042340424404254042640427404284042940430404314043240433404344043540436404374043840439404404044140442404434044440445404464044740448404494045040451404524045340454404554045640457404584045940460404614046240463404644046540466404674046840469404704047140472404734047440475404764047740478404794048040481404824048340484404854048640487404884048940490404914049240493404944049540496404974049840499405004050140502405034050440505405064050740508405094051040511405124051340514405154051640517405184051940520405214052240523405244052540526405274052840529405304053140532405334053440535405364053740538405394054040541405424054340544405454054640547405484054940550405514055240553405544055540556405574055840559405604056140562405634056440565405664056740568405694057040571405724057340574405754057640577405784057940580405814058240583405844058540586405874058840589405904059140592405934059440595405964059740598405994060040601406024060340604406054060640607406084060940610406114061240613406144061540616406174061840619406204062140622406234062440625406264062740628406294063040631406324063340634406354063640637406384063940640406414064240643406444064540646406474064840649406504065140652406534065440655406564065740658406594066040661406624066340664406654066640667406684066940670406714067240673406744067540676406774067840679406804068140682406834068440685406864068740688406894069040691406924069340694406954069640697406984069940700407014070240703407044070540706407074070840709407104071140712407134071440715407164071740718407194072040721407224072340724407254072640727407284072940730407314073240733407344073540736407374073840739407404074140742407434074440745407464074740748407494075040751407524075340754407554075640757407584075940760407614076240763407644076540766407674076840769407704077140772407734077440775407764077740778407794078040781407824078340784407854078640787407884078940790407914079240793407944079540796407974079840799408004080140802408034080440805408064080740808408094081040811408124081340814408154081640817408184081940820408214082240823408244082540826408274082840829408304083140832408334083440835408364083740838408394084040841408424084340844408454084640847408484084940850408514085240853408544085540856408574085840859408604086140862408634086440865408664086740868408694087040871408724087340874408754087640877408784087940880408814088240883408844088540886408874088840889408904089140892408934089440895408964089740898408994090040901409024090340904409054090640907409084090940910409114091240913409144091540916409174091840919409204092140922409234092440925409264092740928409294093040931409324093340934409354093640937409384093940940409414094240943409444094540946409474094840949409504095140952409534095440955409564095740958409594096040961409624096340964409654096640967409684096940970409714097240973409744097540976409774097840979409804098140982409834098440985409864098740988409894099040991409924099340994409954099640997409984099941000410014100241003410044100541006410074100841009410104101141012410134101441015410164101741018410194102041021410224102341024410254102641027410284102941030410314103241033410344103541036410374103841039410404104141042410434104441045410464104741048410494105041051410524105341054410554105641057410584105941060410614106241063410644106541066410674106841069410704107141072410734107441075410764107741078410794108041081410824108341084410854108641087410884108941090410914109241093410944109541096410974109841099411004110141102411034110441105411064110741108411094111041111411124111341114411154111641117411184111941120411214112241123411244112541126411274112841129411304113141132411334113441135411364113741138411394114041141411424114341144411454114641147411484114941150411514115241153411544115541156411574115841159411604116141162411634116441165411664116741168411694117041171411724117341174411754117641177411784117941180411814118241183411844118541186411874118841189411904119141192411934119441195411964119741198411994120041201412024120341204412054120641207412084120941210412114121241213412144121541216412174121841219412204122141222412234122441225412264122741228412294123041231412324123341234412354123641237412384123941240412414124241243412444124541246412474124841249412504125141252412534125441255412564125741258412594126041261412624126341264412654126641267412684126941270412714127241273412744127541276412774127841279412804128141282412834128441285412864128741288412894129041291412924129341294412954129641297412984129941300413014130241303413044130541306413074130841309413104131141312413134131441315413164131741318413194132041321413224132341324413254132641327413284132941330413314133241333413344133541336413374133841339413404134141342413434134441345413464134741348413494135041351413524135341354413554135641357413584135941360413614136241363413644136541366413674136841369413704137141372413734137441375413764137741378413794138041381413824138341384413854138641387413884138941390413914139241393413944139541396413974139841399414004140141402414034140441405414064140741408414094141041411414124141341414414154141641417414184141941420414214142241423414244142541426414274142841429414304143141432414334143441435414364143741438414394144041441414424144341444414454144641447414484144941450414514145241453414544145541456414574145841459414604146141462414634146441465414664146741468414694147041471414724147341474414754147641477414784147941480414814148241483414844148541486414874148841489414904149141492414934149441495414964149741498414994150041501415024150341504415054150641507415084150941510415114151241513415144151541516415174151841519415204152141522415234152441525415264152741528415294153041531415324153341534415354153641537415384153941540415414154241543415444154541546415474154841549415504155141552415534155441555415564155741558415594156041561415624156341564415654156641567415684156941570415714157241573415744157541576415774157841579415804158141582415834158441585415864158741588415894159041591415924159341594415954159641597415984159941600416014160241603416044160541606416074160841609416104161141612416134161441615416164161741618416194162041621416224162341624416254162641627416284162941630416314163241633416344163541636416374163841639416404164141642416434164441645416464164741648416494165041651416524165341654416554165641657416584165941660416614166241663416644166541666416674166841669416704167141672416734167441675416764167741678416794168041681416824168341684416854168641687416884168941690416914169241693416944169541696416974169841699417004170141702417034170441705417064170741708417094171041711417124171341714417154171641717417184171941720417214172241723417244172541726417274172841729417304173141732417334173441735417364173741738417394174041741417424174341744417454174641747417484174941750417514175241753417544175541756417574175841759417604176141762417634176441765417664176741768417694177041771417724177341774417754177641777417784177941780417814178241783417844178541786417874178841789417904179141792417934179441795417964179741798417994180041801418024180341804418054180641807418084180941810418114181241813418144181541816418174181841819418204182141822418234182441825418264182741828418294183041831418324183341834418354183641837418384183941840418414184241843418444184541846418474184841849418504185141852418534185441855418564185741858418594186041861418624186341864418654186641867418684186941870418714187241873418744187541876418774187841879418804188141882418834188441885418864188741888418894189041891418924189341894418954189641897418984189941900419014190241903419044190541906419074190841909419104191141912419134191441915419164191741918419194192041921419224192341924419254192641927419284192941930419314193241933419344193541936419374193841939419404194141942419434194441945419464194741948419494195041951419524195341954419554195641957419584195941960419614196241963419644196541966419674196841969419704197141972419734197441975419764197741978419794198041981419824198341984419854198641987419884198941990419914199241993419944199541996419974199841999420004200142002420034200442005420064200742008420094201042011420124201342014420154201642017420184201942020420214202242023420244202542026420274202842029420304203142032420334203442035420364203742038420394204042041420424204342044420454204642047420484204942050420514205242053420544205542056420574205842059420604206142062420634206442065420664206742068420694207042071420724207342074420754207642077420784207942080420814208242083420844208542086420874208842089420904209142092420934209442095420964209742098420994210042101421024210342104421054210642107421084210942110421114211242113421144211542116421174211842119421204212142122421234212442125421264212742128421294213042131421324213342134421354213642137421384213942140421414214242143421444214542146421474214842149421504215142152421534215442155421564215742158421594216042161421624216342164421654216642167421684216942170421714217242173421744217542176421774217842179421804218142182421834218442185421864218742188421894219042191421924219342194421954219642197421984219942200422014220242203422044220542206422074220842209422104221142212422134221442215422164221742218422194222042221422224222342224422254222642227422284222942230422314223242233422344223542236422374223842239422404224142242422434224442245422464224742248422494225042251422524225342254422554225642257422584225942260422614226242263422644226542266422674226842269422704227142272422734227442275422764227742278422794228042281422824228342284422854228642287422884228942290422914229242293422944229542296422974229842299423004230142302423034230442305423064230742308423094231042311423124231342314423154231642317423184231942320423214232242323423244232542326423274232842329423304233142332423334233442335423364233742338423394234042341423424234342344423454234642347423484234942350423514235242353423544235542356423574235842359423604236142362423634236442365423664236742368423694237042371423724237342374423754237642377423784237942380423814238242383423844238542386423874238842389423904239142392423934239442395423964239742398423994240042401424024240342404424054240642407424084240942410424114241242413424144241542416424174241842419424204242142422424234242442425424264242742428424294243042431424324243342434424354243642437424384243942440424414244242443424444244542446424474244842449424504245142452424534245442455424564245742458424594246042461424624246342464424654246642467424684246942470424714247242473424744247542476424774247842479424804248142482424834248442485424864248742488424894249042491424924249342494424954249642497424984249942500425014250242503425044250542506425074250842509425104251142512425134251442515425164251742518425194252042521425224252342524425254252642527425284252942530425314253242533425344253542536425374253842539425404254142542425434254442545425464254742548425494255042551425524255342554425554255642557425584255942560425614256242563425644256542566425674256842569425704257142572425734257442575425764257742578425794258042581425824258342584425854258642587425884258942590425914259242593425944259542596425974259842599426004260142602426034260442605426064260742608426094261042611426124261342614426154261642617426184261942620426214262242623426244262542626426274262842629426304263142632426334263442635426364263742638426394264042641426424264342644426454264642647426484264942650426514265242653426544265542656426574265842659426604266142662426634266442665426664266742668426694267042671426724267342674426754267642677426784267942680426814268242683426844268542686426874268842689426904269142692426934269442695426964269742698426994270042701427024270342704427054270642707427084270942710427114271242713427144271542716427174271842719427204272142722427234272442725427264272742728427294273042731427324273342734427354273642737427384273942740427414274242743427444274542746427474274842749427504275142752427534275442755427564275742758427594276042761427624276342764427654276642767427684276942770427714277242773427744277542776427774277842779427804278142782427834278442785427864278742788427894279042791427924279342794427954279642797427984279942800428014280242803428044280542806428074280842809428104281142812428134281442815428164281742818428194282042821428224282342824428254282642827428284282942830428314283242833428344283542836428374283842839428404284142842428434284442845428464284742848428494285042851428524285342854428554285642857428584285942860428614286242863428644286542866428674286842869428704287142872428734287442875428764287742878428794288042881428824288342884428854288642887428884288942890428914289242893428944289542896428974289842899429004290142902429034290442905429064290742908429094291042911429124291342914429154291642917429184291942920429214292242923429244292542926429274292842929429304293142932429334293442935429364293742938429394294042941429424294342944429454294642947429484294942950429514295242953429544295542956429574295842959429604296142962429634296442965429664296742968429694297042971429724297342974429754297642977429784297942980429814298242983429844298542986429874298842989429904299142992429934299442995429964299742998429994300043001430024300343004430054300643007430084300943010430114301243013430144301543016430174301843019430204302143022430234302443025430264302743028430294303043031430324303343034430354303643037430384303943040430414304243043430444304543046430474304843049430504305143052430534305443055430564305743058430594306043061430624306343064430654306643067430684306943070430714307243073430744307543076430774307843079430804308143082430834308443085430864308743088430894309043091430924309343094430954309643097430984309943100431014310243103431044310543106431074310843109431104311143112431134311443115431164311743118431194312043121431224312343124431254312643127431284312943130431314313243133431344313543136431374313843139431404314143142431434314443145431464314743148431494315043151431524315343154431554315643157431584315943160431614316243163431644316543166431674316843169431704317143172431734317443175431764317743178431794318043181431824318343184431854318643187431884318943190431914319243193431944319543196431974319843199432004320143202432034320443205432064320743208432094321043211432124321343214432154321643217432184321943220432214322243223432244322543226432274322843229432304323143232432334323443235432364323743238432394324043241432424324343244432454324643247432484324943250432514325243253432544325543256432574325843259432604326143262432634326443265432664326743268432694327043271432724327343274432754327643277432784327943280432814328243283432844328543286432874328843289432904329143292432934329443295432964329743298432994330043301433024330343304433054330643307433084330943310433114331243313433144331543316433174331843319433204332143322433234332443325433264332743328433294333043331433324333343334433354333643337433384333943340433414334243343433444334543346433474334843349433504335143352433534335443355433564335743358433594336043361433624336343364433654336643367433684336943370433714337243373433744337543376433774337843379433804338143382433834338443385433864338743388433894339043391433924339343394433954339643397433984339943400434014340243403434044340543406434074340843409434104341143412434134341443415434164341743418434194342043421434224342343424434254342643427434284342943430434314343243433434344343543436434374343843439434404344143442434434344443445434464344743448434494345043451434524345343454434554345643457434584345943460434614346243463434644346543466434674346843469434704347143472434734347443475434764347743478434794348043481434824348343484434854348643487434884348943490434914349243493434944349543496434974349843499435004350143502435034350443505435064350743508435094351043511435124351343514435154351643517435184351943520435214352243523435244352543526435274352843529435304353143532435334353443535435364353743538435394354043541435424354343544435454354643547435484354943550435514355243553435544355543556435574355843559435604356143562435634356443565435664356743568435694357043571435724357343574435754357643577435784357943580435814358243583435844358543586435874358843589435904359143592435934359443595435964359743598435994360043601436024360343604436054360643607436084360943610436114361243613436144361543616436174361843619436204362143622436234362443625436264362743628436294363043631436324363343634436354363643637436384363943640436414364243643436444364543646436474364843649436504365143652436534365443655436564365743658436594366043661436624366343664436654366643667436684366943670436714367243673436744367543676436774367843679436804368143682436834368443685436864368743688436894369043691436924369343694436954369643697436984369943700437014370243703437044370543706437074370843709437104371143712437134371443715437164371743718437194372043721437224372343724437254372643727437284372943730437314373243733437344373543736437374373843739437404374143742437434374443745437464374743748437494375043751437524375343754437554375643757437584375943760437614376243763437644376543766437674376843769437704377143772437734377443775437764377743778437794378043781437824378343784437854378643787437884378943790437914379243793437944379543796437974379843799438004380143802438034380443805438064380743808438094381043811438124381343814438154381643817438184381943820438214382243823438244382543826438274382843829438304383143832438334383443835438364383743838438394384043841438424384343844438454384643847438484384943850438514385243853438544385543856438574385843859438604386143862438634386443865438664386743868438694387043871438724387343874438754387643877438784387943880438814388243883438844388543886438874388843889438904389143892438934389443895438964389743898438994390043901439024390343904439054390643907439084390943910439114391243913439144391543916439174391843919439204392143922439234392443925439264392743928439294393043931439324393343934439354393643937439384393943940439414394243943439444394543946439474394843949439504395143952439534395443955439564395743958439594396043961439624396343964439654396643967439684396943970439714397243973439744397543976439774397843979439804398143982439834398443985439864398743988439894399043991439924399343994439954399643997439984399944000440014400244003440044400544006440074400844009440104401144012440134401444015440164401744018440194402044021440224402344024440254402644027440284402944030440314403244033440344403544036440374403844039440404404144042440434404444045440464404744048440494405044051440524405344054440554405644057440584405944060440614406244063440644406544066440674406844069440704407144072440734407444075440764407744078440794408044081440824408344084440854408644087440884408944090440914409244093440944409544096440974409844099441004410144102441034410444105441064410744108441094411044111441124411344114441154411644117441184411944120441214412244123441244412544126441274412844129441304413144132441334413444135441364413744138441394414044141441424414344144441454414644147441484414944150441514415244153441544415544156441574415844159441604416144162441634416444165441664416744168441694417044171441724417344174441754417644177441784417944180441814418244183441844418544186441874418844189441904419144192441934419444195441964419744198441994420044201442024420344204442054420644207442084420944210442114421244213442144421544216442174421844219442204422144222442234422444225442264422744228442294423044231442324423344234442354423644237442384423944240442414424244243442444424544246442474424844249442504425144252442534425444255442564425744258442594426044261442624426344264442654426644267442684426944270442714427244273442744427544276442774427844279442804428144282442834428444285442864428744288442894429044291442924429344294442954429644297442984429944300443014430244303443044430544306443074430844309443104431144312443134431444315443164431744318443194432044321443224432344324443254432644327443284432944330443314433244333443344433544336443374433844339443404434144342443434434444345443464434744348443494435044351443524435344354443554435644357443584435944360443614436244363443644436544366443674436844369443704437144372443734437444375443764437744378443794438044381443824438344384443854438644387443884438944390443914439244393443944439544396443974439844399444004440144402444034440444405444064440744408444094441044411444124441344414444154441644417444184441944420444214442244423444244442544426444274442844429444304443144432444334443444435444364443744438444394444044441444424444344444444454444644447444484444944450444514445244453444544445544456444574445844459444604446144462444634446444465444664446744468444694447044471444724447344474444754447644477444784447944480444814448244483444844448544486444874448844489444904449144492444934449444495444964449744498444994450044501445024450344504445054450644507445084450944510445114451244513445144451544516445174451844519445204452144522445234452444525445264452744528445294453044531445324453344534445354453644537445384453944540445414454244543445444454544546445474454844549445504455144552445534455444555445564455744558445594456044561445624456344564445654456644567445684456944570445714457244573445744457544576445774457844579445804458144582445834458444585445864458744588445894459044591445924459344594445954459644597445984459944600446014460244603446044460544606446074460844609446104461144612446134461444615446164461744618446194462044621446224462344624446254462644627446284462944630446314463244633446344463544636446374463844639446404464144642446434464444645446464464744648446494465044651446524465344654446554465644657446584465944660446614466244663446644466544666446674466844669446704467144672446734467444675446764467744678446794468044681446824468344684446854468644687446884468944690446914469244693446944469544696446974469844699447004470144702447034470444705447064470744708447094471044711447124471344714447154471644717447184471944720447214472244723447244472544726447274472844729447304473144732447334473444735447364473744738447394474044741447424474344744447454474644747447484474944750447514475244753447544475544756447574475844759447604476144762447634476444765447664476744768447694477044771447724477344774447754477644777447784477944780447814478244783447844478544786447874478844789447904479144792447934479444795447964479744798447994480044801448024480344804448054480644807448084480944810448114481244813448144481544816448174481844819448204482144822448234482444825448264482744828448294483044831448324483344834448354483644837448384483944840448414484244843448444484544846448474484844849448504485144852448534485444855448564485744858448594486044861448624486344864448654486644867448684486944870448714487244873448744487544876448774487844879448804488144882448834488444885448864488744888448894489044891448924489344894448954489644897448984489944900449014490244903449044490544906449074490844909449104491144912449134491444915449164491744918449194492044921449224492344924449254492644927449284492944930449314493244933449344493544936449374493844939449404494144942449434494444945449464494744948449494495044951449524495344954449554495644957449584495944960449614496244963449644496544966449674496844969449704497144972449734497444975449764497744978449794498044981449824498344984449854498644987449884498944990449914499244993449944499544996449974499844999450004500145002450034500445005450064500745008450094501045011450124501345014450154501645017450184501945020450214502245023450244502545026450274502845029450304503145032450334503445035450364503745038450394504045041450424504345044450454504645047450484504945050450514505245053450544505545056450574505845059450604506145062450634506445065450664506745068450694507045071450724507345074450754507645077450784507945080450814508245083450844508545086450874508845089450904509145092450934509445095450964509745098450994510045101451024510345104451054510645107451084510945110451114511245113451144511545116451174511845119451204512145122451234512445125451264512745128451294513045131451324513345134451354513645137451384513945140451414514245143451444514545146451474514845149451504515145152451534515445155451564515745158451594516045161451624516345164451654516645167451684516945170451714517245173451744517545176451774517845179451804518145182451834518445185451864518745188451894519045191451924519345194451954519645197451984519945200452014520245203452044520545206452074520845209452104521145212452134521445215452164521745218452194522045221452224522345224452254522645227452284522945230452314523245233452344523545236452374523845239452404524145242452434524445245452464524745248452494525045251452524525345254452554525645257452584525945260452614526245263452644526545266452674526845269452704527145272452734527445275452764527745278452794528045281452824528345284452854528645287452884528945290452914529245293452944529545296452974529845299453004530145302453034530445305453064530745308453094531045311453124531345314453154531645317453184531945320453214532245323453244532545326453274532845329453304533145332453334533445335453364533745338453394534045341453424534345344453454534645347453484534945350453514535245353453544535545356453574535845359453604536145362453634536445365453664536745368453694537045371453724537345374453754537645377453784537945380453814538245383453844538545386453874538845389453904539145392453934539445395453964539745398453994540045401454024540345404454054540645407454084540945410454114541245413454144541545416454174541845419454204542145422454234542445425454264542745428454294543045431454324543345434454354543645437454384543945440454414544245443454444544545446454474544845449454504545145452454534545445455454564545745458454594546045461454624546345464454654546645467454684546945470454714547245473454744547545476454774547845479454804548145482454834548445485454864548745488454894549045491454924549345494454954549645497454984549945500455014550245503455044550545506455074550845509455104551145512455134551445515455164551745518455194552045521455224552345524455254552645527455284552945530455314553245533455344553545536455374553845539455404554145542455434554445545455464554745548455494555045551455524555345554455554555645557455584555945560455614556245563455644556545566455674556845569455704557145572455734557445575455764557745578455794558045581455824558345584455854558645587455884558945590455914559245593455944559545596455974559845599456004560145602456034560445605456064560745608456094561045611456124561345614456154561645617456184561945620456214562245623456244562545626456274562845629456304563145632456334563445635456364563745638456394564045641456424564345644456454564645647456484564945650456514565245653456544565545656456574565845659456604566145662456634566445665456664566745668456694567045671456724567345674456754567645677456784567945680456814568245683456844568545686456874568845689456904569145692456934569445695456964569745698456994570045701457024570345704457054570645707457084570945710457114571245713457144571545716457174571845719457204572145722457234572445725457264572745728457294573045731457324573345734457354573645737457384573945740457414574245743457444574545746457474574845749457504575145752457534575445755457564575745758457594576045761457624576345764457654576645767457684576945770457714577245773457744577545776457774577845779457804578145782457834578445785457864578745788457894579045791457924579345794457954579645797457984579945800458014580245803458044580545806458074580845809458104581145812458134581445815458164581745818458194582045821458224582345824458254582645827458284582945830458314583245833458344583545836458374583845839458404584145842458434584445845458464584745848458494585045851458524585345854458554585645857458584585945860458614586245863458644586545866458674586845869458704587145872458734587445875458764587745878458794588045881458824588345884458854588645887458884588945890458914589245893458944589545896458974589845899459004590145902459034590445905459064590745908459094591045911459124591345914459154591645917459184591945920459214592245923459244592545926459274592845929459304593145932459334593445935459364593745938459394594045941459424594345944459454594645947459484594945950459514595245953459544595545956459574595845959459604596145962459634596445965459664596745968459694597045971459724597345974459754597645977459784597945980459814598245983459844598545986459874598845989459904599145992459934599445995459964599745998459994600046001460024600346004460054600646007460084600946010460114601246013460144601546016460174601846019460204602146022460234602446025460264602746028460294603046031460324603346034460354603646037460384603946040460414604246043460444604546046460474604846049460504605146052460534605446055460564605746058460594606046061460624606346064460654606646067460684606946070460714607246073460744607546076460774607846079460804608146082460834608446085460864608746088460894609046091460924609346094460954609646097460984609946100461014610246103461044610546106461074610846109461104611146112461134611446115461164611746118461194612046121461224612346124461254612646127461284612946130461314613246133461344613546136461374613846139461404614146142461434614446145461464614746148461494615046151461524615346154461554615646157461584615946160461614616246163461644616546166461674616846169461704617146172461734617446175461764617746178461794618046181461824618346184461854618646187461884618946190461914619246193461944619546196461974619846199462004620146202462034620446205462064620746208462094621046211462124621346214462154621646217462184621946220462214622246223462244622546226462274622846229462304623146232462334623446235462364623746238462394624046241462424624346244462454624646247462484624946250462514625246253462544625546256462574625846259462604626146262462634626446265462664626746268462694627046271462724627346274462754627646277462784627946280462814628246283462844628546286462874628846289462904629146292462934629446295462964629746298462994630046301463024630346304463054630646307463084630946310463114631246313463144631546316463174631846319463204632146322463234632446325463264632746328463294633046331463324633346334463354633646337463384633946340463414634246343463444634546346463474634846349463504635146352463534635446355463564635746358463594636046361463624636346364463654636646367463684636946370463714637246373463744637546376463774637846379463804638146382463834638446385463864638746388463894639046391463924639346394463954639646397463984639946400464014640246403464044640546406464074640846409464104641146412464134641446415464164641746418464194642046421464224642346424464254642646427464284642946430464314643246433464344643546436464374643846439464404644146442464434644446445464464644746448464494645046451464524645346454464554645646457464584645946460464614646246463464644646546466464674646846469464704647146472464734647446475464764647746478464794648046481464824648346484464854648646487464884648946490464914649246493464944649546496464974649846499465004650146502465034650446505465064650746508465094651046511465124651346514465154651646517465184651946520465214652246523465244652546526465274652846529465304653146532465334653446535465364653746538465394654046541465424654346544465454654646547465484654946550465514655246553465544655546556465574655846559465604656146562465634656446565465664656746568465694657046571465724657346574465754657646577465784657946580465814658246583465844658546586465874658846589465904659146592465934659446595465964659746598465994660046601466024660346604466054660646607466084660946610466114661246613466144661546616466174661846619466204662146622466234662446625466264662746628466294663046631466324663346634466354663646637466384663946640466414664246643466444664546646466474664846649466504665146652466534665446655466564665746658466594666046661466624666346664466654666646667466684666946670466714667246673466744667546676466774667846679466804668146682466834668446685466864668746688466894669046691466924669346694466954669646697466984669946700467014670246703467044670546706467074670846709467104671146712467134671446715467164671746718467194672046721467224672346724467254672646727467284672946730467314673246733467344673546736467374673846739467404674146742467434674446745467464674746748467494675046751467524675346754467554675646757467584675946760467614676246763467644676546766467674676846769467704677146772467734677446775467764677746778467794678046781467824678346784467854678646787467884678946790467914679246793467944679546796467974679846799468004680146802468034680446805468064680746808468094681046811468124681346814468154681646817468184681946820468214682246823468244682546826468274682846829468304683146832468334683446835468364683746838468394684046841468424684346844468454684646847468484684946850468514685246853468544685546856468574685846859468604686146862468634686446865468664686746868468694687046871468724687346874468754687646877468784687946880468814688246883468844688546886468874688846889468904689146892468934689446895468964689746898468994690046901469024690346904469054690646907469084690946910469114691246913469144691546916469174691846919469204692146922469234692446925469264692746928469294693046931469324693346934469354693646937469384693946940469414694246943469444694546946469474694846949469504695146952469534695446955469564695746958469594696046961469624696346964469654696646967469684696946970469714697246973469744697546976469774697846979469804698146982469834698446985469864698746988469894699046991469924699346994469954699646997469984699947000470014700247003470044700547006470074700847009470104701147012470134701447015470164701747018470194702047021470224702347024470254702647027470284702947030470314703247033470344703547036470374703847039470404704147042470434704447045470464704747048470494705047051470524705347054470554705647057470584705947060470614706247063470644706547066470674706847069470704707147072470734707447075470764707747078470794708047081470824708347084470854708647087470884708947090470914709247093470944709547096470974709847099471004710147102471034710447105471064710747108471094711047111471124711347114471154711647117471184711947120471214712247123471244712547126471274712847129471304713147132471334713447135471364713747138471394714047141471424714347144471454714647147471484714947150471514715247153471544715547156471574715847159471604716147162471634716447165471664716747168471694717047171471724717347174471754717647177471784717947180471814718247183471844718547186471874718847189471904719147192471934719447195471964719747198471994720047201472024720347204472054720647207472084720947210472114721247213472144721547216472174721847219472204722147222472234722447225472264722747228472294723047231472324723347234472354723647237472384723947240472414724247243472444724547246472474724847249472504725147252472534725447255472564725747258472594726047261472624726347264472654726647267472684726947270472714727247273472744727547276472774727847279472804728147282472834728447285472864728747288472894729047291472924729347294472954729647297472984729947300473014730247303473044730547306473074730847309473104731147312473134731447315473164731747318473194732047321473224732347324473254732647327473284732947330473314733247333473344733547336473374733847339473404734147342473434734447345473464734747348473494735047351473524735347354473554735647357473584735947360473614736247363473644736547366473674736847369473704737147372473734737447375473764737747378473794738047381473824738347384473854738647387473884738947390473914739247393473944739547396473974739847399474004740147402474034740447405474064740747408474094741047411474124741347414474154741647417474184741947420474214742247423474244742547426474274742847429474304743147432474334743447435474364743747438474394744047441474424744347444474454744647447474484744947450474514745247453474544745547456474574745847459474604746147462474634746447465474664746747468474694747047471474724747347474474754747647477474784747947480474814748247483474844748547486474874748847489474904749147492474934749447495474964749747498474994750047501475024750347504475054750647507475084750947510475114751247513475144751547516475174751847519475204752147522475234752447525475264752747528475294753047531475324753347534475354753647537475384753947540475414754247543475444754547546475474754847549475504755147552475534755447555475564755747558475594756047561475624756347564475654756647567475684756947570475714757247573475744757547576475774757847579475804758147582475834758447585475864758747588475894759047591475924759347594475954759647597475984759947600476014760247603476044760547606476074760847609476104761147612476134761447615476164761747618476194762047621476224762347624476254762647627476284762947630476314763247633476344763547636476374763847639476404764147642476434764447645476464764747648476494765047651476524765347654476554765647657476584765947660476614766247663476644766547666476674766847669476704767147672476734767447675476764767747678476794768047681476824768347684476854768647687476884768947690476914769247693476944769547696476974769847699477004770147702477034770447705477064770747708477094771047711477124771347714477154771647717477184771947720477214772247723477244772547726477274772847729477304773147732477334773447735477364773747738477394774047741477424774347744477454774647747477484774947750477514775247753477544775547756477574775847759477604776147762477634776447765477664776747768477694777047771477724777347774477754777647777477784777947780477814778247783477844778547786477874778847789477904779147792477934779447795477964779747798477994780047801478024780347804478054780647807478084780947810478114781247813478144781547816478174781847819478204782147822478234782447825478264782747828478294783047831478324783347834478354783647837478384783947840478414784247843478444784547846478474784847849478504785147852478534785447855478564785747858478594786047861478624786347864478654786647867478684786947870478714787247873478744787547876478774787847879478804788147882478834788447885478864788747888478894789047891478924789347894478954789647897478984789947900479014790247903479044790547906479074790847909479104791147912479134791447915479164791747918479194792047921479224792347924479254792647927479284792947930479314793247933479344793547936479374793847939479404794147942479434794447945479464794747948479494795047951479524795347954479554795647957479584795947960479614796247963479644796547966479674796847969479704797147972479734797447975479764797747978479794798047981479824798347984479854798647987479884798947990479914799247993479944799547996479974799847999480004800148002480034800448005480064800748008480094801048011480124801348014480154801648017480184801948020480214802248023480244802548026480274802848029480304803148032480334803448035480364803748038480394804048041480424804348044480454804648047480484804948050480514805248053480544805548056480574805848059480604806148062480634806448065480664806748068480694807048071480724807348074480754807648077480784807948080480814808248083480844808548086480874808848089480904809148092480934809448095480964809748098480994810048101481024810348104481054810648107481084810948110481114811248113481144811548116481174811848119481204812148122481234812448125481264812748128481294813048131481324813348134481354813648137481384813948140481414814248143481444814548146481474814848149481504815148152481534815448155481564815748158481594816048161481624816348164481654816648167481684816948170481714817248173481744817548176481774817848179481804818148182481834818448185481864818748188481894819048191481924819348194481954819648197481984819948200482014820248203482044820548206482074820848209482104821148212482134821448215482164821748218482194822048221482224822348224482254822648227482284822948230482314823248233482344823548236482374823848239482404824148242482434824448245482464824748248482494825048251482524825348254482554825648257482584825948260482614826248263482644826548266482674826848269482704827148272482734827448275482764827748278482794828048281482824828348284482854828648287482884828948290482914829248293482944829548296482974829848299483004830148302483034830448305483064830748308483094831048311483124831348314483154831648317483184831948320483214832248323483244832548326483274832848329483304833148332483334833448335483364833748338483394834048341483424834348344483454834648347483484834948350483514835248353483544835548356483574835848359483604836148362483634836448365483664836748368483694837048371483724837348374483754837648377483784837948380483814838248383483844838548386483874838848389483904839148392483934839448395483964839748398483994840048401484024840348404484054840648407484084840948410484114841248413484144841548416484174841848419484204842148422484234842448425484264842748428484294843048431484324843348434484354843648437484384843948440484414844248443484444844548446484474844848449484504845148452484534845448455484564845748458484594846048461484624846348464484654846648467484684846948470484714847248473484744847548476484774847848479484804848148482484834848448485484864848748488484894849048491484924849348494484954849648497484984849948500485014850248503485044850548506485074850848509485104851148512485134851448515485164851748518485194852048521485224852348524485254852648527485284852948530485314853248533485344853548536485374853848539485404854148542485434854448545485464854748548485494855048551485524855348554485554855648557485584855948560485614856248563485644856548566485674856848569485704857148572485734857448575485764857748578485794858048581485824858348584485854858648587485884858948590485914859248593485944859548596485974859848599486004860148602486034860448605486064860748608486094861048611486124861348614486154861648617486184861948620486214862248623486244862548626486274862848629486304863148632486334863448635486364863748638486394864048641486424864348644486454864648647486484864948650486514865248653486544865548656486574865848659486604866148662486634866448665486664866748668486694867048671486724867348674486754867648677486784867948680486814868248683486844868548686486874868848689486904869148692486934869448695486964869748698486994870048701487024870348704487054870648707487084870948710487114871248713487144871548716487174871848719487204872148722487234872448725487264872748728487294873048731487324873348734487354873648737487384873948740487414874248743487444874548746487474874848749487504875148752487534875448755487564875748758487594876048761487624876348764487654876648767487684876948770487714877248773487744877548776487774877848779487804878148782487834878448785487864878748788487894879048791487924879348794487954879648797487984879948800488014880248803488044880548806488074880848809488104881148812488134881448815488164881748818488194882048821488224882348824488254882648827488284882948830488314883248833488344883548836488374883848839488404884148842488434884448845488464884748848488494885048851488524885348854488554885648857488584885948860488614886248863488644886548866488674886848869488704887148872488734887448875488764887748878488794888048881488824888348884488854888648887488884888948890488914889248893488944889548896488974889848899489004890148902489034890448905489064890748908489094891048911489124891348914489154891648917489184891948920489214892248923489244892548926489274892848929489304893148932489334893448935489364893748938489394894048941489424894348944489454894648947489484894948950489514895248953489544895548956489574895848959489604896148962489634896448965489664896748968489694897048971489724897348974489754897648977489784897948980489814898248983489844898548986489874898848989489904899148992489934899448995489964899748998489994900049001490024900349004490054900649007490084900949010490114901249013490144901549016490174901849019490204902149022490234902449025490264902749028490294903049031490324903349034490354903649037490384903949040490414904249043490444904549046490474904849049490504905149052490534905449055490564905749058490594906049061490624906349064490654906649067490684906949070490714907249073490744907549076490774907849079490804908149082490834908449085490864908749088490894909049091490924909349094490954909649097490984909949100491014910249103491044910549106491074910849109491104911149112491134911449115491164911749118491194912049121491224912349124491254912649127491284912949130491314913249133491344913549136491374913849139491404914149142491434914449145491464914749148491494915049151491524915349154491554915649157491584915949160491614916249163491644916549166491674916849169491704917149172491734917449175491764917749178491794918049181491824918349184491854918649187491884918949190491914919249193491944919549196491974919849199492004920149202492034920449205492064920749208492094921049211492124921349214492154921649217492184921949220492214922249223492244922549226492274922849229492304923149232492334923449235492364923749238492394924049241492424924349244492454924649247492484924949250492514925249253492544925549256492574925849259492604926149262492634926449265492664926749268492694927049271492724927349274492754927649277492784927949280492814928249283492844928549286492874928849289492904929149292492934929449295492964929749298492994930049301493024930349304493054930649307493084930949310493114931249313493144931549316493174931849319493204932149322493234932449325493264932749328493294933049331493324933349334493354933649337493384933949340493414934249343493444934549346493474934849349493504935149352493534935449355493564935749358493594936049361493624936349364493654936649367493684936949370493714937249373493744937549376493774937849379493804938149382493834938449385493864938749388493894939049391493924939349394493954939649397493984939949400494014940249403494044940549406494074940849409494104941149412494134941449415494164941749418494194942049421494224942349424494254942649427494284942949430494314943249433494344943549436494374943849439494404944149442494434944449445494464944749448494494945049451494524945349454494554945649457494584945949460494614946249463494644946549466494674946849469494704947149472494734947449475494764947749478494794948049481494824948349484494854948649487494884948949490494914949249493494944949549496494974949849499495004950149502495034950449505495064950749508495094951049511495124951349514495154951649517495184951949520495214952249523495244952549526495274952849529495304953149532495334953449535495364953749538495394954049541495424954349544495454954649547495484954949550495514955249553495544955549556495574955849559495604956149562495634956449565495664956749568495694957049571495724957349574495754957649577495784957949580495814958249583495844958549586495874958849589495904959149592495934959449595495964959749598495994960049601496024960349604496054960649607496084960949610496114961249613496144961549616496174961849619496204962149622496234962449625496264962749628496294963049631496324963349634496354963649637496384963949640496414964249643496444964549646496474964849649496504965149652496534965449655496564965749658496594966049661496624966349664496654966649667496684966949670496714967249673496744967549676496774967849679496804968149682496834968449685496864968749688496894969049691496924969349694496954969649697496984969949700497014970249703497044970549706497074970849709497104971149712497134971449715497164971749718497194972049721497224972349724497254972649727497284972949730497314973249733497344973549736497374973849739497404974149742497434974449745497464974749748497494975049751497524975349754497554975649757497584975949760497614976249763497644976549766497674976849769497704977149772497734977449775497764977749778497794978049781497824978349784497854978649787497884978949790497914979249793497944979549796497974979849799498004980149802498034980449805498064980749808498094981049811498124981349814498154981649817498184981949820498214982249823498244982549826498274982849829498304983149832498334983449835498364983749838498394984049841498424984349844498454984649847498484984949850498514985249853498544985549856498574985849859498604986149862498634986449865498664986749868498694987049871498724987349874498754987649877498784987949880498814988249883498844988549886498874988849889498904989149892498934989449895498964989749898498994990049901499024990349904499054990649907499084990949910499114991249913499144991549916499174991849919499204992149922499234992449925499264992749928499294993049931499324993349934499354993649937499384993949940499414994249943499444994549946499474994849949499504995149952499534995449955499564995749958499594996049961499624996349964499654996649967499684996949970499714997249973499744997549976499774997849979499804998149982499834998449985499864998749988499894999049991499924999349994499954999649997499984999950000500015000250003500045000550006500075000850009500105001150012500135001450015500165001750018500195002050021500225002350024500255002650027500285002950030500315003250033500345003550036500375003850039500405004150042500435004450045500465004750048500495005050051500525005350054500555005650057500585005950060500615006250063500645006550066500675006850069500705007150072500735007450075500765007750078500795008050081500825008350084500855008650087500885008950090500915009250093500945009550096500975009850099501005010150102501035010450105501065010750108501095011050111501125011350114501155011650117501185011950120501215012250123501245012550126501275012850129501305013150132501335013450135501365013750138501395014050141501425014350144501455014650147501485014950150501515015250153501545015550156501575015850159501605016150162501635016450165501665016750168501695017050171501725017350174501755017650177501785017950180501815018250183501845018550186501875018850189501905019150192501935019450195501965019750198501995020050201502025020350204502055020650207502085020950210502115021250213502145021550216502175021850219502205022150222502235022450225502265022750228502295023050231502325023350234502355023650237502385023950240502415024250243502445024550246502475024850249502505025150252502535025450255502565025750258502595026050261502625026350264502655026650267502685026950270502715027250273502745027550276502775027850279502805028150282502835028450285502865028750288502895029050291502925029350294502955029650297502985029950300503015030250303503045030550306503075030850309503105031150312503135031450315503165031750318503195032050321503225032350324503255032650327503285032950330503315033250333503345033550336503375033850339503405034150342503435034450345503465034750348503495035050351503525035350354503555035650357503585035950360503615036250363503645036550366503675036850369503705037150372503735037450375503765037750378503795038050381503825038350384503855038650387503885038950390503915039250393503945039550396503975039850399504005040150402504035040450405504065040750408504095041050411504125041350414504155041650417504185041950420504215042250423504245042550426504275042850429504305043150432504335043450435504365043750438504395044050441504425044350444504455044650447504485044950450504515045250453504545045550456504575045850459504605046150462504635046450465504665046750468504695047050471504725047350474504755047650477504785047950480504815048250483504845048550486504875048850489504905049150492504935049450495504965049750498504995050050501505025050350504505055050650507505085050950510505115051250513505145051550516505175051850519505205052150522505235052450525505265052750528505295053050531505325053350534505355053650537505385053950540505415054250543505445054550546505475054850549505505055150552505535055450555505565055750558505595056050561505625056350564505655056650567505685056950570505715057250573505745057550576505775057850579505805058150582505835058450585505865058750588505895059050591505925059350594505955059650597505985059950600506015060250603506045060550606506075060850609506105061150612506135061450615506165061750618506195062050621506225062350624506255062650627506285062950630506315063250633506345063550636506375063850639506405064150642506435064450645506465064750648506495065050651506525065350654506555065650657506585065950660506615066250663506645066550666506675066850669506705067150672506735067450675506765067750678506795068050681506825068350684506855068650687506885068950690506915069250693506945069550696506975069850699507005070150702507035070450705507065070750708507095071050711507125071350714507155071650717507185071950720507215072250723507245072550726507275072850729507305073150732507335073450735507365073750738507395074050741507425074350744507455074650747507485074950750507515075250753507545075550756507575075850759507605076150762507635076450765507665076750768507695077050771507725077350774507755077650777507785077950780507815078250783507845078550786507875078850789507905079150792507935079450795507965079750798507995080050801508025080350804508055080650807508085080950810508115081250813508145081550816508175081850819508205082150822508235082450825508265082750828508295083050831508325083350834508355083650837508385083950840508415084250843508445084550846508475084850849508505085150852508535085450855508565085750858508595086050861508625086350864508655086650867508685086950870508715087250873508745087550876508775087850879508805088150882508835088450885508865088750888508895089050891508925089350894508955089650897508985089950900509015090250903509045090550906509075090850909509105091150912509135091450915509165091750918509195092050921509225092350924509255092650927509285092950930509315093250933509345093550936509375093850939509405094150942509435094450945509465094750948509495095050951509525095350954509555095650957509585095950960509615096250963509645096550966509675096850969509705097150972509735097450975509765097750978509795098050981509825098350984509855098650987509885098950990509915099250993509945099550996509975099850999510005100151002510035100451005510065100751008510095101051011510125101351014510155101651017510185101951020510215102251023510245102551026510275102851029510305103151032510335103451035510365103751038510395104051041510425104351044510455104651047510485104951050510515105251053510545105551056510575105851059510605106151062510635106451065510665106751068510695107051071510725107351074510755107651077510785107951080510815108251083510845108551086510875108851089510905109151092510935109451095510965109751098510995110051101511025110351104511055110651107511085110951110511115111251113511145111551116511175111851119511205112151122511235112451125511265112751128511295113051131511325113351134511355113651137511385113951140511415114251143511445114551146511475114851149511505115151152511535115451155511565115751158511595116051161511625116351164511655116651167511685116951170511715117251173511745117551176511775117851179511805118151182511835118451185511865118751188511895119051191511925119351194511955119651197511985119951200512015120251203512045120551206512075120851209512105121151212512135121451215512165121751218512195122051221512225122351224512255122651227512285122951230512315123251233512345123551236512375123851239512405124151242512435124451245512465124751248512495125051251512525125351254512555125651257512585125951260512615126251263512645126551266512675126851269512705127151272512735127451275512765127751278512795128051281512825128351284512855128651287512885128951290512915129251293512945129551296512975129851299513005130151302513035130451305513065130751308513095131051311513125131351314513155131651317513185131951320513215132251323513245132551326513275132851329513305133151332513335133451335513365133751338513395134051341513425134351344513455134651347513485134951350513515135251353513545135551356513575135851359513605136151362513635136451365513665136751368513695137051371513725137351374513755137651377513785137951380513815138251383513845138551386513875138851389513905139151392513935139451395513965139751398513995140051401514025140351404514055140651407514085140951410514115141251413514145141551416514175141851419514205142151422514235142451425514265142751428514295143051431514325143351434514355143651437514385143951440514415144251443514445144551446514475144851449514505145151452514535145451455514565145751458514595146051461514625146351464514655146651467514685146951470514715147251473514745147551476514775147851479514805148151482514835148451485514865148751488514895149051491514925149351494514955149651497514985149951500515015150251503515045150551506515075150851509515105151151512515135151451515515165151751518515195152051521515225152351524515255152651527515285152951530515315153251533515345153551536515375153851539515405154151542515435154451545515465154751548515495155051551515525155351554515555155651557515585155951560515615156251563515645156551566515675156851569515705157151572515735157451575515765157751578515795158051581515825158351584515855158651587515885158951590515915159251593515945159551596515975159851599516005160151602516035160451605516065160751608516095161051611516125161351614516155161651617516185161951620516215162251623516245162551626516275162851629516305163151632516335163451635516365163751638516395164051641516425164351644516455164651647516485164951650516515165251653516545165551656516575165851659516605166151662516635166451665516665166751668516695167051671516725167351674516755167651677516785167951680516815168251683516845168551686516875168851689516905169151692516935169451695516965169751698516995170051701517025170351704517055170651707517085170951710517115171251713517145171551716517175171851719517205172151722517235172451725517265172751728517295173051731517325173351734517355173651737517385173951740517415174251743517445174551746517475174851749517505175151752517535175451755517565175751758517595176051761517625176351764517655176651767517685176951770517715177251773517745177551776517775177851779517805178151782517835178451785517865178751788517895179051791517925179351794517955179651797517985179951800518015180251803518045180551806518075180851809518105181151812518135181451815518165181751818518195182051821518225182351824518255182651827518285182951830518315183251833518345183551836518375183851839518405184151842518435184451845518465184751848518495185051851518525185351854518555185651857518585185951860518615186251863518645186551866518675186851869518705187151872518735187451875518765187751878518795188051881518825188351884518855188651887518885188951890518915189251893518945189551896518975189851899519005190151902519035190451905519065190751908519095191051911519125191351914519155191651917519185191951920519215192251923519245192551926519275192851929519305193151932519335193451935519365193751938519395194051941519425194351944519455194651947519485194951950519515195251953519545195551956519575195851959519605196151962519635196451965519665196751968519695197051971519725197351974519755197651977519785197951980519815198251983519845198551986519875198851989519905199151992519935199451995519965199751998519995200052001520025200352004520055200652007520085200952010520115201252013520145201552016520175201852019520205202152022520235202452025520265202752028520295203052031520325203352034520355203652037520385203952040520415204252043520445204552046520475204852049520505205152052520535205452055520565205752058520595206052061520625206352064520655206652067520685206952070520715207252073520745207552076520775207852079520805208152082520835208452085520865208752088520895209052091520925209352094520955209652097520985209952100521015210252103521045210552106521075210852109521105211152112521135211452115521165211752118521195212052121521225212352124521255212652127521285212952130521315213252133521345213552136521375213852139521405214152142521435214452145521465214752148521495215052151521525215352154521555215652157521585215952160521615216252163521645216552166521675216852169521705217152172521735217452175521765217752178521795218052181521825218352184521855218652187521885218952190521915219252193521945219552196521975219852199522005220152202522035220452205522065220752208522095221052211522125221352214522155221652217522185221952220522215222252223522245222552226522275222852229522305223152232522335223452235522365223752238522395224052241522425224352244522455224652247522485224952250522515225252253522545225552256522575225852259522605226152262522635226452265522665226752268522695227052271522725227352274522755227652277522785227952280522815228252283522845228552286522875228852289522905229152292522935229452295522965229752298522995230052301523025230352304523055230652307523085230952310523115231252313523145231552316523175231852319523205232152322523235232452325523265232752328523295233052331523325233352334523355233652337523385233952340523415234252343523445234552346523475234852349523505235152352523535235452355523565235752358523595236052361523625236352364523655236652367523685236952370523715237252373523745237552376523775237852379523805238152382523835238452385523865238752388523895239052391523925239352394523955239652397523985239952400524015240252403524045240552406524075240852409524105241152412524135241452415524165241752418524195242052421524225242352424524255242652427524285242952430524315243252433524345243552436524375243852439524405244152442524435244452445524465244752448524495245052451524525245352454524555245652457524585245952460524615246252463524645246552466524675246852469524705247152472524735247452475524765247752478524795248052481524825248352484524855248652487524885248952490524915249252493524945249552496524975249852499525005250152502525035250452505525065250752508525095251052511525125251352514525155251652517525185251952520525215252252523525245252552526525275252852529525305253152532525335253452535525365253752538525395254052541525425254352544525455254652547525485254952550525515255252553525545255552556525575255852559525605256152562525635256452565525665256752568525695257052571525725257352574525755257652577525785257952580525815258252583525845258552586525875258852589525905259152592525935259452595525965259752598525995260052601526025260352604526055260652607526085260952610526115261252613526145261552616526175261852619526205262152622526235262452625526265262752628526295263052631526325263352634526355263652637526385263952640526415264252643526445264552646526475264852649526505265152652526535265452655526565265752658526595266052661526625266352664526655266652667526685266952670526715267252673526745267552676526775267852679526805268152682526835268452685526865268752688526895269052691526925269352694526955269652697526985269952700527015270252703527045270552706527075270852709527105271152712527135271452715527165271752718527195272052721527225272352724527255272652727527285272952730527315273252733527345273552736527375273852739527405274152742527435274452745527465274752748527495275052751527525275352754527555275652757527585275952760527615276252763527645276552766527675276852769527705277152772527735277452775527765277752778527795278052781527825278352784527855278652787527885278952790527915279252793527945279552796527975279852799528005280152802528035280452805528065280752808528095281052811528125281352814528155281652817528185281952820528215282252823528245282552826528275282852829528305283152832528335283452835528365283752838528395284052841528425284352844528455284652847528485284952850528515285252853528545285552856528575285852859528605286152862528635286452865528665286752868528695287052871528725287352874528755287652877528785287952880528815288252883528845288552886528875288852889528905289152892528935289452895528965289752898528995290052901529025290352904529055290652907529085290952910529115291252913529145291552916529175291852919529205292152922529235292452925529265292752928529295293052931529325293352934529355293652937529385293952940529415294252943529445294552946529475294852949529505295152952529535295452955529565295752958529595296052961529625296352964529655296652967529685296952970529715297252973529745297552976529775297852979529805298152982529835298452985529865298752988529895299052991529925299352994529955299652997529985299953000530015300253003530045300553006530075300853009530105301153012530135301453015530165301753018530195302053021530225302353024530255302653027530285302953030530315303253033530345303553036530375303853039530405304153042530435304453045530465304753048530495305053051530525305353054530555305653057530585305953060530615306253063530645306553066530675306853069530705307153072530735307453075530765307753078530795308053081530825308353084530855308653087530885308953090530915309253093530945309553096530975309853099531005310153102531035310453105531065310753108531095311053111531125311353114531155311653117531185311953120531215312253123531245312553126531275312853129531305313153132531335313453135531365313753138531395314053141531425314353144531455314653147531485314953150531515315253153531545315553156531575315853159531605316153162531635316453165531665316753168531695317053171531725317353174531755317653177531785317953180531815318253183531845318553186531875318853189531905319153192531935319453195531965319753198531995320053201532025320353204532055320653207532085320953210532115321253213532145321553216532175321853219532205322153222532235322453225532265322753228532295323053231532325323353234532355323653237532385323953240532415324253243532445324553246532475324853249532505325153252532535325453255532565325753258532595326053261532625326353264532655326653267532685326953270532715327253273532745327553276532775327853279532805328153282532835328453285532865328753288532895329053291532925329353294532955329653297532985329953300533015330253303533045330553306533075330853309533105331153312533135331453315533165331753318533195332053321533225332353324533255332653327533285332953330533315333253333533345333553336533375333853339533405334153342533435334453345533465334753348533495335053351533525335353354533555335653357533585335953360533615336253363533645336553366533675336853369533705337153372533735337453375533765337753378533795338053381533825338353384533855338653387533885338953390533915339253393533945339553396533975339853399534005340153402534035340453405534065340753408534095341053411534125341353414534155341653417534185341953420534215342253423534245342553426534275342853429534305343153432534335343453435534365343753438534395344053441534425344353444534455344653447534485344953450534515345253453534545345553456534575345853459534605346153462534635346453465534665346753468534695347053471534725347353474534755347653477534785347953480534815348253483534845348553486534875348853489534905349153492534935349453495534965349753498534995350053501535025350353504535055350653507535085350953510535115351253513535145351553516535175351853519535205352153522535235352453525535265352753528535295353053531535325353353534535355353653537535385353953540535415354253543535445354553546535475354853549535505355153552535535355453555535565355753558535595356053561535625356353564535655356653567535685356953570535715357253573535745357553576535775357853579535805358153582535835358453585535865358753588535895359053591535925359353594535955359653597535985359953600536015360253603536045360553606536075360853609536105361153612536135361453615536165361753618536195362053621536225362353624536255362653627536285362953630536315363253633536345363553636536375363853639536405364153642536435364453645536465364753648536495365053651536525365353654536555365653657536585365953660536615366253663536645366553666536675366853669536705367153672536735367453675536765367753678536795368053681536825368353684536855368653687536885368953690536915369253693536945369553696536975369853699537005370153702537035370453705537065370753708537095371053711537125371353714537155371653717537185371953720537215372253723537245372553726537275372853729537305373153732537335373453735537365373753738537395374053741537425374353744537455374653747537485374953750537515375253753537545375553756537575375853759537605376153762537635376453765537665376753768537695377053771537725377353774537755377653777537785377953780537815378253783537845378553786537875378853789537905379153792537935379453795537965379753798537995380053801538025380353804538055380653807538085380953810538115381253813538145381553816538175381853819538205382153822538235382453825538265382753828538295383053831538325383353834538355383653837538385383953840538415384253843538445384553846538475384853849538505385153852538535385453855538565385753858538595386053861538625386353864538655386653867538685386953870538715387253873538745387553876538775387853879538805388153882538835388453885538865388753888538895389053891538925389353894538955389653897538985389953900539015390253903539045390553906539075390853909539105391153912539135391453915539165391753918539195392053921539225392353924539255392653927539285392953930539315393253933539345393553936539375393853939539405394153942539435394453945539465394753948539495395053951539525395353954539555395653957539585395953960539615396253963539645396553966539675396853969539705397153972539735397453975539765397753978539795398053981539825398353984539855398653987539885398953990539915399253993539945399553996539975399853999540005400154002540035400454005540065400754008540095401054011540125401354014540155401654017540185401954020540215402254023540245402554026540275402854029540305403154032540335403454035540365403754038540395404054041540425404354044540455404654047540485404954050540515405254053540545405554056540575405854059540605406154062540635406454065540665406754068540695407054071540725407354074540755407654077540785407954080540815408254083540845408554086540875408854089540905409154092540935409454095540965409754098540995410054101541025410354104541055410654107541085410954110541115411254113541145411554116541175411854119541205412154122541235412454125541265412754128541295413054131541325413354134541355413654137541385413954140541415414254143541445414554146541475414854149541505415154152541535415454155541565415754158541595416054161541625416354164541655416654167541685416954170541715417254173541745417554176541775417854179541805418154182541835418454185541865418754188541895419054191541925419354194541955419654197541985419954200542015420254203542045420554206542075420854209542105421154212542135421454215542165421754218542195422054221542225422354224542255422654227542285422954230542315423254233542345423554236542375423854239542405424154242542435424454245542465424754248542495425054251542525425354254542555425654257542585425954260542615426254263542645426554266542675426854269542705427154272542735427454275542765427754278542795428054281542825428354284542855428654287542885428954290542915429254293542945429554296542975429854299543005430154302543035430454305543065430754308543095431054311543125431354314543155431654317543185431954320543215432254323543245432554326543275432854329543305433154332543335433454335543365433754338543395434054341543425434354344543455434654347543485434954350543515435254353543545435554356543575435854359543605436154362543635436454365543665436754368543695437054371543725437354374543755437654377543785437954380543815438254383543845438554386543875438854389543905439154392543935439454395543965439754398543995440054401544025440354404544055440654407544085440954410544115441254413544145441554416544175441854419544205442154422544235442454425544265442754428544295443054431544325443354434544355443654437544385443954440544415444254443544445444554446544475444854449544505445154452544535445454455544565445754458544595446054461544625446354464544655446654467544685446954470544715447254473544745447554476544775447854479544805448154482544835448454485544865448754488544895449054491544925449354494544955449654497544985449954500545015450254503545045450554506545075450854509545105451154512545135451454515545165451754518545195452054521545225452354524545255452654527545285452954530545315453254533545345453554536545375453854539545405454154542545435454454545545465454754548545495455054551545525455354554545555455654557545585455954560545615456254563545645456554566545675456854569545705457154572545735457454575545765457754578545795458054581545825458354584545855458654587545885458954590545915459254593545945459554596545975459854599546005460154602546035460454605546065460754608546095461054611546125461354614546155461654617546185461954620546215462254623546245462554626546275462854629546305463154632546335463454635546365463754638546395464054641546425464354644546455464654647546485464954650546515465254653546545465554656546575465854659546605466154662546635466454665546665466754668546695467054671546725467354674546755467654677546785467954680546815468254683546845468554686546875468854689546905469154692546935469454695546965469754698546995470054701547025470354704547055470654707547085470954710547115471254713547145471554716547175471854719547205472154722547235472454725547265472754728547295473054731547325473354734547355473654737547385473954740547415474254743547445474554746547475474854749547505475154752547535475454755547565475754758547595476054761547625476354764547655476654767547685476954770547715477254773547745477554776547775477854779547805478154782547835478454785547865478754788547895479054791547925479354794547955479654797547985479954800548015480254803548045480554806548075480854809548105481154812548135481454815548165481754818548195482054821548225482354824548255482654827548285482954830548315483254833548345483554836548375483854839548405484154842548435484454845548465484754848548495485054851548525485354854548555485654857548585485954860548615486254863548645486554866548675486854869548705487154872548735487454875548765487754878548795488054881548825488354884548855488654887548885488954890548915489254893548945489554896548975489854899549005490154902549035490454905549065490754908549095491054911549125491354914549155491654917549185491954920549215492254923549245492554926549275492854929549305493154932549335493454935549365493754938549395494054941549425494354944549455494654947549485494954950549515495254953549545495554956549575495854959549605496154962549635496454965549665496754968549695497054971549725497354974549755497654977549785497954980549815498254983549845498554986549875498854989549905499154992549935499454995549965499754998549995500055001550025500355004550055500655007550085500955010550115501255013550145501555016550175501855019550205502155022550235502455025550265502755028550295503055031550325503355034550355503655037550385503955040550415504255043550445504555046550475504855049550505505155052550535505455055550565505755058550595506055061550625506355064550655506655067550685506955070550715507255073550745507555076550775507855079550805508155082550835508455085550865508755088550895509055091550925509355094550955509655097550985509955100551015510255103551045510555106551075510855109551105511155112551135511455115551165511755118551195512055121551225512355124551255512655127551285512955130551315513255133551345513555136551375513855139551405514155142551435514455145551465514755148551495515055151551525515355154551555515655157551585515955160551615516255163551645516555166551675516855169551705517155172551735517455175551765517755178551795518055181551825518355184551855518655187551885518955190551915519255193551945519555196551975519855199552005520155202552035520455205552065520755208552095521055211552125521355214552155521655217552185521955220552215522255223552245522555226552275522855229552305523155232552335523455235552365523755238552395524055241552425524355244552455524655247552485524955250552515525255253552545525555256552575525855259552605526155262552635526455265552665526755268552695527055271552725527355274552755527655277552785527955280552815528255283552845528555286552875528855289552905529155292552935529455295552965529755298552995530055301553025530355304553055530655307553085530955310553115531255313553145531555316553175531855319553205532155322553235532455325553265532755328553295533055331553325533355334553355533655337553385533955340553415534255343553445534555346553475534855349553505535155352553535535455355553565535755358553595536055361553625536355364553655536655367553685536955370553715537255373553745537555376553775537855379553805538155382553835538455385553865538755388553895539055391553925539355394553955539655397553985539955400554015540255403554045540555406554075540855409554105541155412554135541455415554165541755418554195542055421554225542355424554255542655427554285542955430554315543255433554345543555436554375543855439554405544155442554435544455445554465544755448554495545055451554525545355454554555545655457554585545955460554615546255463554645546555466554675546855469554705547155472554735547455475554765547755478554795548055481554825548355484554855548655487554885548955490554915549255493554945549555496554975549855499555005550155502555035550455505555065550755508555095551055511555125551355514555155551655517555185551955520555215552255523555245552555526555275552855529555305553155532555335553455535555365553755538555395554055541555425554355544555455554655547555485554955550555515555255553555545555555556555575555855559555605556155562555635556455565555665556755568555695557055571555725557355574555755557655577555785557955580555815558255583555845558555586555875558855589555905559155592555935559455595555965559755598555995560055601556025560355604556055560655607556085560955610556115561255613556145561555616556175561855619556205562155622556235562455625556265562755628556295563055631556325563355634556355563655637556385563955640556415564255643556445564555646556475564855649556505565155652556535565455655556565565755658556595566055661556625566355664556655566655667556685566955670556715567255673556745567555676556775567855679556805568155682556835568455685556865568755688556895569055691556925569355694556955569655697556985569955700557015570255703557045570555706557075570855709557105571155712557135571455715557165571755718557195572055721557225572355724557255572655727557285572955730557315573255733557345573555736557375573855739557405574155742557435574455745557465574755748557495575055751557525575355754557555575655757557585575955760557615576255763557645576555766557675576855769557705577155772557735577455775557765577755778557795578055781557825578355784557855578655787557885578955790557915579255793557945579555796557975579855799558005580155802558035580455805558065580755808558095581055811558125581355814558155581655817558185581955820558215582255823558245582555826558275582855829558305583155832558335583455835558365583755838558395584055841558425584355844558455584655847558485584955850558515585255853558545585555856558575585855859558605586155862558635586455865558665586755868558695587055871558725587355874558755587655877558785587955880558815588255883558845588555886558875588855889558905589155892558935589455895558965589755898558995590055901559025590355904559055590655907559085590955910559115591255913559145591555916559175591855919559205592155922559235592455925559265592755928559295593055931559325593355934559355593655937559385593955940559415594255943559445594555946559475594855949559505595155952559535595455955559565595755958559595596055961559625596355964559655596655967559685596955970559715597255973559745597555976559775597855979559805598155982559835598455985559865598755988559895599055991559925599355994559955599655997559985599956000560015600256003560045600556006560075600856009560105601156012560135601456015560165601756018560195602056021560225602356024560255602656027560285602956030560315603256033560345603556036560375603856039560405604156042560435604456045560465604756048560495605056051560525605356054560555605656057560585605956060560615606256063560645606556066560675606856069560705607156072560735607456075560765607756078560795608056081560825608356084560855608656087560885608956090560915609256093560945609556096560975609856099561005610156102561035610456105561065610756108561095611056111561125611356114561155611656117561185611956120561215612256123561245612556126561275612856129561305613156132561335613456135561365613756138561395614056141561425614356144561455614656147561485614956150561515615256153561545615556156561575615856159561605616156162561635616456165561665616756168561695617056171561725617356174561755617656177561785617956180561815618256183561845618556186561875618856189561905619156192561935619456195561965619756198561995620056201562025620356204562055620656207562085620956210562115621256213562145621556216562175621856219562205622156222562235622456225562265622756228562295623056231562325623356234562355623656237562385623956240562415624256243562445624556246562475624856249562505625156252562535625456255562565625756258562595626056261562625626356264562655626656267562685626956270562715627256273562745627556276562775627856279562805628156282562835628456285562865628756288562895629056291562925629356294562955629656297562985629956300563015630256303563045630556306563075630856309563105631156312563135631456315563165631756318563195632056321563225632356324563255632656327563285632956330563315633256333563345633556336563375633856339563405634156342563435634456345563465634756348563495635056351563525635356354563555635656357563585635956360563615636256363563645636556366563675636856369563705637156372563735637456375563765637756378563795638056381563825638356384563855638656387563885638956390563915639256393563945639556396563975639856399564005640156402564035640456405564065640756408564095641056411564125641356414564155641656417564185641956420564215642256423564245642556426564275642856429564305643156432564335643456435564365643756438564395644056441564425644356444564455644656447564485644956450564515645256453564545645556456564575645856459564605646156462564635646456465564665646756468564695647056471564725647356474564755647656477564785647956480564815648256483564845648556486564875648856489564905649156492564935649456495564965649756498564995650056501565025650356504565055650656507565085650956510565115651256513565145651556516565175651856519565205652156522565235652456525565265652756528565295653056531565325653356534565355653656537565385653956540565415654256543565445654556546565475654856549565505655156552565535655456555565565655756558565595656056561565625656356564565655656656567565685656956570565715657256573565745657556576565775657856579565805658156582565835658456585565865658756588565895659056591565925659356594565955659656597565985659956600566015660256603566045660556606566075660856609566105661156612566135661456615566165661756618566195662056621566225662356624566255662656627566285662956630566315663256633566345663556636566375663856639566405664156642566435664456645566465664756648566495665056651566525665356654566555665656657566585665956660566615666256663566645666556666566675666856669566705667156672566735667456675566765667756678566795668056681566825668356684566855668656687566885668956690566915669256693566945669556696566975669856699567005670156702567035670456705567065670756708567095671056711567125671356714567155671656717567185671956720567215672256723567245672556726567275672856729567305673156732567335673456735567365673756738567395674056741567425674356744567455674656747567485674956750567515675256753567545675556756567575675856759567605676156762567635676456765567665676756768567695677056771567725677356774567755677656777567785677956780567815678256783567845678556786567875678856789567905679156792567935679456795567965679756798567995680056801568025680356804568055680656807568085680956810568115681256813568145681556816568175681856819568205682156822568235682456825568265682756828568295683056831568325683356834568355683656837568385683956840568415684256843568445684556846568475684856849568505685156852568535685456855568565685756858568595686056861568625686356864568655686656867568685686956870568715687256873568745687556876568775687856879568805688156882568835688456885568865688756888568895689056891568925689356894568955689656897568985689956900569015690256903569045690556906569075690856909569105691156912569135691456915569165691756918569195692056921569225692356924569255692656927569285692956930569315693256933569345693556936569375693856939569405694156942569435694456945569465694756948569495695056951569525695356954569555695656957569585695956960569615696256963569645696556966569675696856969569705697156972569735697456975569765697756978569795698056981569825698356984569855698656987569885698956990569915699256993569945699556996569975699856999570005700157002570035700457005570065700757008570095701057011570125701357014570155701657017570185701957020570215702257023570245702557026570275702857029570305703157032570335703457035570365703757038570395704057041570425704357044570455704657047570485704957050570515705257053570545705557056570575705857059570605706157062570635706457065570665706757068570695707057071570725707357074570755707657077570785707957080570815708257083570845708557086570875708857089570905709157092570935709457095570965709757098570995710057101571025710357104571055710657107571085710957110571115711257113571145711557116571175711857119571205712157122571235712457125571265712757128571295713057131571325713357134571355713657137571385713957140571415714257143571445714557146571475714857149571505715157152571535715457155571565715757158571595716057161571625716357164571655716657167571685716957170571715717257173571745717557176571775717857179571805718157182571835718457185571865718757188571895719057191571925719357194571955719657197571985719957200572015720257203572045720557206572075720857209572105721157212572135721457215572165721757218572195722057221572225722357224572255722657227572285722957230572315723257233572345723557236572375723857239572405724157242572435724457245572465724757248572495725057251572525725357254572555725657257572585725957260572615726257263572645726557266572675726857269572705727157272572735727457275572765727757278572795728057281572825728357284572855728657287572885728957290572915729257293572945729557296572975729857299573005730157302573035730457305573065730757308573095731057311573125731357314573155731657317573185731957320573215732257323573245732557326573275732857329573305733157332573335733457335573365733757338573395734057341573425734357344573455734657347573485734957350573515735257353573545735557356573575735857359573605736157362573635736457365573665736757368573695737057371573725737357374573755737657377573785737957380573815738257383573845738557386573875738857389573905739157392573935739457395573965739757398573995740057401574025740357404574055740657407574085740957410574115741257413574145741557416574175741857419574205742157422574235742457425574265742757428574295743057431574325743357434574355743657437574385743957440574415744257443574445744557446574475744857449574505745157452574535745457455574565745757458574595746057461574625746357464574655746657467574685746957470574715747257473574745747557476574775747857479574805748157482574835748457485574865748757488574895749057491574925749357494574955749657497574985749957500575015750257503575045750557506575075750857509575105751157512575135751457515575165751757518575195752057521575225752357524575255752657527575285752957530575315753257533575345753557536575375753857539575405754157542575435754457545575465754757548575495755057551575525755357554575555755657557575585755957560575615756257563575645756557566575675756857569575705757157572575735757457575575765757757578575795758057581575825758357584575855758657587575885758957590575915759257593575945759557596575975759857599576005760157602576035760457605576065760757608576095761057611576125761357614576155761657617576185761957620576215762257623576245762557626576275762857629576305763157632576335763457635576365763757638576395764057641576425764357644576455764657647576485764957650576515765257653576545765557656576575765857659576605766157662576635766457665576665766757668576695767057671576725767357674576755767657677576785767957680576815768257683576845768557686576875768857689576905769157692576935769457695576965769757698576995770057701577025770357704577055770657707577085770957710577115771257713577145771557716577175771857719577205772157722577235772457725577265772757728577295773057731577325773357734577355773657737577385773957740577415774257743577445774557746577475774857749577505775157752577535775457755577565775757758577595776057761577625776357764577655776657767577685776957770577715777257773577745777557776577775777857779577805778157782577835778457785577865778757788577895779057791577925779357794577955779657797577985779957800578015780257803578045780557806578075780857809578105781157812578135781457815578165781757818578195782057821578225782357824578255782657827578285782957830578315783257833578345783557836578375783857839578405784157842578435784457845578465784757848578495785057851578525785357854578555785657857578585785957860578615786257863578645786557866578675786857869578705787157872578735787457875578765787757878578795788057881578825788357884578855788657887578885788957890578915789257893578945789557896578975789857899579005790157902579035790457905579065790757908579095791057911579125791357914579155791657917579185791957920579215792257923579245792557926579275792857929579305793157932579335793457935579365793757938579395794057941579425794357944579455794657947579485794957950579515795257953579545795557956579575795857959579605796157962579635796457965579665796757968579695797057971579725797357974579755797657977579785797957980579815798257983579845798557986579875798857989579905799157992579935799457995579965799757998579995800058001580025800358004580055800658007580085800958010580115801258013580145801558016580175801858019580205802158022580235802458025580265802758028580295803058031580325803358034580355803658037580385803958040580415804258043580445804558046580475804858049580505805158052580535805458055580565805758058580595806058061580625806358064580655806658067580685806958070580715807258073580745807558076580775807858079580805808158082580835808458085580865808758088580895809058091580925809358094580955809658097580985809958100581015810258103581045810558106581075810858109581105811158112581135811458115581165811758118581195812058121581225812358124581255812658127581285812958130581315813258133581345813558136581375813858139581405814158142581435814458145581465814758148581495815058151581525815358154581555815658157581585815958160581615816258163581645816558166581675816858169581705817158172581735817458175581765817758178581795818058181581825818358184581855818658187581885818958190581915819258193581945819558196581975819858199582005820158202582035820458205582065820758208582095821058211582125821358214582155821658217582185821958220582215822258223582245822558226582275822858229582305823158232582335823458235582365823758238582395824058241582425824358244582455824658247582485824958250582515825258253582545825558256582575825858259582605826158262582635826458265582665826758268582695827058271582725827358274582755827658277582785827958280582815828258283582845828558286582875828858289582905829158292582935829458295582965829758298582995830058301583025830358304583055830658307583085830958310583115831258313583145831558316583175831858319583205832158322583235832458325583265832758328583295833058331583325833358334583355833658337583385833958340583415834258343583445834558346583475834858349583505835158352583535835458355583565835758358583595836058361583625836358364583655836658367583685836958370583715837258373583745837558376583775837858379583805838158382583835838458385583865838758388583895839058391583925839358394583955839658397583985839958400584015840258403584045840558406584075840858409584105841158412584135841458415584165841758418584195842058421584225842358424584255842658427584285842958430584315843258433584345843558436584375843858439584405844158442584435844458445584465844758448584495845058451584525845358454584555845658457584585845958460584615846258463584645846558466584675846858469584705847158472584735847458475584765847758478584795848058481584825848358484584855848658487584885848958490584915849258493584945849558496584975849858499585005850158502585035850458505585065850758508585095851058511585125851358514585155851658517585185851958520585215852258523585245852558526585275852858529585305853158532585335853458535585365853758538585395854058541585425854358544585455854658547585485854958550585515855258553585545855558556585575855858559585605856158562585635856458565585665856758568585695857058571585725857358574585755857658577585785857958580585815858258583585845858558586585875858858589585905859158592585935859458595585965859758598585995860058601586025860358604586055860658607586085860958610586115861258613586145861558616586175861858619586205862158622586235862458625586265862758628586295863058631586325863358634586355863658637586385863958640586415864258643586445864558646586475864858649586505865158652586535865458655586565865758658586595866058661586625866358664586655866658667586685866958670586715867258673586745867558676586775867858679586805868158682586835868458685586865868758688586895869058691586925869358694586955869658697586985869958700587015870258703587045870558706587075870858709587105871158712587135871458715587165871758718587195872058721587225872358724587255872658727587285872958730587315873258733587345873558736587375873858739587405874158742587435874458745587465874758748587495875058751587525875358754587555875658757587585875958760587615876258763587645876558766587675876858769587705877158772587735877458775587765877758778587795878058781587825878358784587855878658787587885878958790587915879258793587945879558796587975879858799588005880158802588035880458805588065880758808588095881058811588125881358814588155881658817588185881958820588215882258823588245882558826588275882858829588305883158832588335883458835588365883758838588395884058841588425884358844588455884658847588485884958850588515885258853588545885558856588575885858859588605886158862588635886458865588665886758868588695887058871588725887358874588755887658877588785887958880588815888258883588845888558886588875888858889588905889158892588935889458895588965889758898588995890058901589025890358904589055890658907589085890958910589115891258913589145891558916589175891858919589205892158922589235892458925589265892758928589295893058931589325893358934589355893658937589385893958940589415894258943589445894558946589475894858949589505895158952589535895458955589565895758958589595896058961589625896358964589655896658967589685896958970589715897258973589745897558976589775897858979589805898158982589835898458985589865898758988589895899058991589925899358994589955899658997589985899959000590015900259003590045900559006590075900859009590105901159012590135901459015590165901759018590195902059021590225902359024590255902659027590285902959030590315903259033590345903559036590375903859039590405904159042590435904459045590465904759048590495905059051590525905359054590555905659057590585905959060590615906259063590645906559066590675906859069590705907159072590735907459075590765907759078590795908059081590825908359084590855908659087590885908959090590915909259093590945909559096590975909859099591005910159102591035910459105591065910759108591095911059111591125911359114591155911659117591185911959120591215912259123591245912559126591275912859129591305913159132591335913459135591365913759138591395914059141591425914359144591455914659147591485914959150591515915259153591545915559156591575915859159591605916159162591635916459165591665916759168591695917059171591725917359174591755917659177591785917959180591815918259183591845918559186591875918859189591905919159192591935919459195591965919759198591995920059201592025920359204592055920659207592085920959210592115921259213592145921559216592175921859219592205922159222592235922459225592265922759228592295923059231592325923359234592355923659237592385923959240592415924259243592445924559246592475924859249592505925159252592535925459255592565925759258592595926059261592625926359264592655926659267592685926959270592715927259273592745927559276592775927859279592805928159282592835928459285592865928759288592895929059291592925929359294592955929659297592985929959300593015930259303593045930559306593075930859309593105931159312593135931459315593165931759318593195932059321593225932359324593255932659327593285932959330593315933259333593345933559336593375933859339593405934159342593435934459345593465934759348593495935059351593525935359354593555935659357593585935959360593615936259363593645936559366593675936859369593705937159372593735937459375593765937759378593795938059381593825938359384593855938659387593885938959390593915939259393593945939559396593975939859399594005940159402594035940459405594065940759408594095941059411594125941359414594155941659417594185941959420594215942259423594245942559426594275942859429594305943159432594335943459435594365943759438594395944059441594425944359444594455944659447594485944959450594515945259453594545945559456594575945859459594605946159462594635946459465594665946759468594695947059471594725947359474594755947659477594785947959480594815948259483594845948559486594875948859489594905949159492594935949459495594965949759498594995950059501595025950359504595055950659507595085950959510595115951259513595145951559516595175951859519595205952159522595235952459525595265952759528595295953059531595325953359534595355953659537595385953959540595415954259543595445954559546595475954859549595505955159552595535955459555595565955759558595595956059561595625956359564595655956659567595685956959570595715957259573595745957559576595775957859579595805958159582595835958459585595865958759588595895959059591595925959359594595955959659597595985959959600596015960259603596045960559606596075960859609596105961159612596135961459615596165961759618596195962059621596225962359624596255962659627596285962959630596315963259633596345963559636596375963859639596405964159642596435964459645596465964759648596495965059651596525965359654596555965659657596585965959660596615966259663596645966559666596675966859669596705967159672596735967459675596765967759678596795968059681596825968359684596855968659687596885968959690596915969259693596945969559696596975969859699597005970159702597035970459705597065970759708597095971059711597125971359714597155971659717597185971959720597215972259723597245972559726597275972859729597305973159732597335973459735597365973759738597395974059741597425974359744597455974659747597485974959750597515975259753597545975559756597575975859759597605976159762597635976459765597665976759768597695977059771597725977359774597755977659777597785977959780597815978259783597845978559786597875978859789597905979159792597935979459795597965979759798597995980059801598025980359804598055980659807598085980959810598115981259813598145981559816598175981859819598205982159822598235982459825598265982759828598295983059831598325983359834598355983659837598385983959840598415984259843598445984559846598475984859849598505985159852598535985459855598565985759858598595986059861598625986359864598655986659867598685986959870598715987259873598745987559876598775987859879598805988159882598835988459885598865988759888598895989059891598925989359894598955989659897598985989959900599015990259903599045990559906599075990859909599105991159912599135991459915599165991759918599195992059921599225992359924599255992659927599285992959930599315993259933599345993559936599375993859939599405994159942599435994459945599465994759948599495995059951599525995359954599555995659957599585995959960599615996259963599645996559966599675996859969599705997159972599735997459975599765997759978599795998059981599825998359984599855998659987599885998959990599915999259993599945999559996599975999859999600006000160002600036000460005600066000760008600096001060011600126001360014600156001660017600186001960020600216002260023600246002560026600276002860029600306003160032600336003460035600366003760038600396004060041600426004360044600456004660047600486004960050600516005260053600546005560056600576005860059600606006160062600636006460065600666006760068600696007060071600726007360074600756007660077600786007960080600816008260083600846008560086600876008860089600906009160092600936009460095600966009760098600996010060101601026010360104601056010660107601086010960110601116011260113601146011560116601176011860119601206012160122601236012460125601266012760128601296013060131601326013360134601356013660137601386013960140601416014260143601446014560146601476014860149601506015160152601536015460155601566015760158601596016060161601626016360164601656016660167601686016960170601716017260173601746017560176601776017860179601806018160182601836018460185601866018760188601896019060191601926019360194601956019660197601986019960200602016020260203602046020560206602076020860209602106021160212602136021460215602166021760218602196022060221602226022360224602256022660227602286022960230602316023260233602346023560236602376023860239602406024160242602436024460245602466024760248602496025060251602526025360254602556025660257602586025960260602616026260263602646026560266602676026860269602706027160272602736027460275602766027760278602796028060281602826028360284602856028660287602886028960290602916029260293602946029560296602976029860299603006030160302603036030460305603066030760308603096031060311603126031360314603156031660317603186031960320603216032260323603246032560326603276032860329603306033160332603336033460335603366033760338603396034060341603426034360344603456034660347603486034960350603516035260353603546035560356603576035860359603606036160362603636036460365603666036760368603696037060371603726037360374603756037660377603786037960380603816038260383603846038560386603876038860389603906039160392603936039460395603966039760398603996040060401604026040360404604056040660407604086040960410604116041260413604146041560416604176041860419604206042160422604236042460425604266042760428604296043060431604326043360434604356043660437604386043960440604416044260443604446044560446604476044860449604506045160452604536045460455604566045760458604596046060461604626046360464604656046660467604686046960470604716047260473604746047560476604776047860479604806048160482604836048460485604866048760488604896049060491604926049360494604956049660497604986049960500605016050260503605046050560506605076050860509605106051160512605136051460515605166051760518605196052060521605226052360524605256052660527605286052960530605316053260533605346053560536605376053860539605406054160542605436054460545605466054760548605496055060551605526055360554605556055660557605586055960560605616056260563605646056560566605676056860569605706057160572605736057460575605766057760578605796058060581605826058360584605856058660587605886058960590605916059260593605946059560596605976059860599606006060160602606036060460605606066060760608606096061060611606126061360614606156061660617606186061960620606216062260623606246062560626606276062860629606306063160632606336063460635606366063760638606396064060641606426064360644606456064660647606486064960650606516065260653606546065560656606576065860659606606066160662606636066460665606666066760668606696067060671606726067360674606756067660677606786067960680606816068260683606846068560686606876068860689606906069160692606936069460695606966069760698606996070060701607026070360704607056070660707607086070960710607116071260713607146071560716607176071860719607206072160722607236072460725607266072760728607296073060731607326073360734607356073660737607386073960740607416074260743607446074560746607476074860749607506075160752607536075460755607566075760758607596076060761607626076360764607656076660767607686076960770607716077260773607746077560776607776077860779607806078160782607836078460785607866078760788607896079060791607926079360794607956079660797607986079960800608016080260803608046080560806608076080860809608106081160812608136081460815608166081760818608196082060821608226082360824608256082660827608286082960830608316083260833608346083560836608376083860839608406084160842608436084460845608466084760848608496085060851608526085360854608556085660857608586085960860608616086260863608646086560866608676086860869608706087160872608736087460875608766087760878608796088060881608826088360884608856088660887608886088960890608916089260893608946089560896608976089860899609006090160902609036090460905609066090760908609096091060911609126091360914609156091660917609186091960920609216092260923609246092560926609276092860929609306093160932609336093460935609366093760938609396094060941609426094360944609456094660947609486094960950609516095260953609546095560956609576095860959609606096160962609636096460965609666096760968609696097060971609726097360974609756097660977609786097960980609816098260983609846098560986609876098860989609906099160992609936099460995609966099760998609996100061001610026100361004610056100661007610086100961010610116101261013610146101561016610176101861019610206102161022610236102461025610266102761028610296103061031610326103361034610356103661037610386103961040610416104261043610446104561046610476104861049610506105161052610536105461055610566105761058610596106061061610626106361064610656106661067610686106961070610716107261073610746107561076610776107861079610806108161082610836108461085610866108761088610896109061091610926109361094610956109661097610986109961100611016110261103611046110561106611076110861109611106111161112611136111461115611166111761118611196112061121611226112361124611256112661127611286112961130611316113261133611346113561136611376113861139611406114161142611436114461145611466114761148611496115061151611526115361154611556115661157611586115961160611616116261163611646116561166611676116861169611706117161172611736117461175611766117761178611796118061181611826118361184611856118661187611886118961190611916119261193611946119561196611976119861199612006120161202612036120461205612066120761208612096121061211612126121361214612156121661217612186121961220612216122261223612246122561226612276122861229612306123161232612336123461235612366123761238612396124061241612426124361244612456124661247612486124961250612516125261253612546125561256612576125861259612606126161262612636126461265612666126761268612696127061271612726127361274612756127661277612786127961280612816128261283612846128561286612876128861289612906129161292612936129461295612966129761298612996130061301613026130361304613056130661307613086130961310613116131261313613146131561316613176131861319613206132161322613236132461325613266132761328613296133061331613326133361334613356133661337613386133961340613416134261343613446134561346613476134861349613506135161352613536135461355613566135761358613596136061361613626136361364613656136661367613686136961370613716137261373613746137561376613776137861379613806138161382613836138461385613866138761388613896139061391613926139361394613956139661397613986139961400614016140261403614046140561406614076140861409614106141161412614136141461415614166141761418614196142061421614226142361424614256142661427614286142961430614316143261433614346143561436614376143861439614406144161442614436144461445614466144761448614496145061451614526145361454614556145661457614586145961460614616146261463614646146561466614676146861469614706147161472614736147461475614766147761478614796148061481614826148361484614856148661487614886148961490614916149261493614946149561496614976149861499615006150161502615036150461505615066150761508615096151061511615126151361514615156151661517615186151961520615216152261523615246152561526615276152861529615306153161532615336153461535615366153761538615396154061541615426154361544615456154661547615486154961550615516155261553615546155561556615576155861559615606156161562615636156461565615666156761568615696157061571615726157361574615756157661577615786157961580615816158261583615846158561586615876158861589615906159161592615936159461595615966159761598615996160061601616026160361604616056160661607616086160961610616116161261613616146161561616616176161861619616206162161622616236162461625616266162761628616296163061631616326163361634616356163661637616386163961640616416164261643616446164561646616476164861649616506165161652616536165461655616566165761658616596166061661616626166361664616656166661667616686166961670616716167261673616746167561676616776167861679616806168161682616836168461685616866168761688616896169061691616926169361694616956169661697616986169961700617016170261703617046170561706617076170861709617106171161712617136171461715617166171761718617196172061721617226172361724617256172661727617286172961730617316173261733617346173561736617376173861739617406174161742617436174461745617466174761748617496175061751617526175361754617556175661757617586175961760617616176261763617646176561766617676176861769617706177161772617736177461775617766177761778617796178061781617826178361784617856178661787617886178961790617916179261793617946179561796617976179861799618006180161802618036180461805618066180761808618096181061811618126181361814618156181661817618186181961820618216182261823618246182561826618276182861829618306183161832618336183461835618366183761838618396184061841618426184361844618456184661847618486184961850618516185261853618546185561856618576185861859618606186161862618636186461865618666186761868618696187061871618726187361874618756187661877618786187961880618816188261883618846188561886618876188861889618906189161892618936189461895618966189761898618996190061901619026190361904619056190661907619086190961910619116191261913619146191561916619176191861919619206192161922619236192461925619266192761928619296193061931619326193361934619356193661937619386193961940619416194261943619446194561946619476194861949619506195161952619536195461955619566195761958619596196061961619626196361964619656196661967619686196961970619716197261973619746197561976619776197861979619806198161982619836198461985619866198761988619896199061991619926199361994619956199661997619986199962000620016200262003620046200562006620076200862009620106201162012620136201462015620166201762018620196202062021620226202362024620256202662027620286202962030620316203262033620346203562036620376203862039620406204162042620436204462045620466204762048620496205062051620526205362054620556205662057620586205962060620616206262063620646206562066620676206862069620706207162072620736207462075620766207762078620796208062081620826208362084620856208662087620886208962090620916209262093620946209562096620976209862099621006210162102621036210462105621066210762108621096211062111621126211362114621156211662117621186211962120621216212262123621246212562126621276212862129621306213162132621336213462135621366213762138621396214062141621426214362144621456214662147621486214962150621516215262153621546215562156621576215862159621606216162162621636216462165621666216762168621696217062171621726217362174621756217662177621786217962180621816218262183621846218562186621876218862189621906219162192621936219462195621966219762198621996220062201622026220362204622056220662207622086220962210622116221262213622146221562216622176221862219622206222162222622236222462225622266222762228622296223062231622326223362234622356223662237622386223962240622416224262243622446224562246622476224862249622506225162252622536225462255622566225762258622596226062261622626226362264622656226662267622686226962270622716227262273622746227562276622776227862279622806228162282622836228462285622866228762288622896229062291622926229362294622956229662297622986229962300623016230262303623046230562306623076230862309623106231162312623136231462315623166231762318623196232062321623226232362324623256232662327623286232962330623316233262333623346233562336623376233862339623406234162342623436234462345623466234762348623496235062351623526235362354623556235662357623586235962360623616236262363623646236562366623676236862369623706237162372623736237462375623766237762378623796238062381623826238362384623856238662387623886238962390623916239262393623946239562396623976239862399624006240162402624036240462405624066240762408624096241062411624126241362414624156241662417624186241962420624216242262423624246242562426624276242862429624306243162432624336243462435624366243762438624396244062441624426244362444624456244662447624486244962450624516245262453624546245562456624576245862459624606246162462624636246462465624666246762468624696247062471624726247362474624756247662477624786247962480624816248262483624846248562486624876248862489624906249162492624936249462495624966249762498624996250062501625026250362504625056250662507625086250962510625116251262513625146251562516625176251862519625206252162522625236252462525625266252762528625296253062531625326253362534625356253662537625386253962540625416254262543625446254562546625476254862549625506255162552625536255462555625566255762558625596256062561625626256362564625656256662567625686256962570625716257262573625746257562576625776257862579625806258162582625836258462585625866258762588625896259062591625926259362594625956259662597625986259962600626016260262603626046260562606626076260862609626106261162612626136261462615626166261762618626196262062621626226262362624626256262662627626286262962630626316263262633626346263562636626376263862639626406264162642626436264462645626466264762648626496265062651626526265362654626556265662657626586265962660626616266262663626646266562666626676266862669626706267162672626736267462675626766267762678626796268062681626826268362684626856268662687626886268962690626916269262693626946269562696626976269862699627006270162702627036270462705627066270762708627096271062711627126271362714627156271662717627186271962720627216272262723627246272562726627276272862729627306273162732627336273462735627366273762738627396274062741627426274362744627456274662747627486274962750627516275262753627546275562756627576275862759627606276162762627636276462765627666276762768627696277062771627726277362774627756277662777627786277962780627816278262783627846278562786627876278862789627906279162792627936279462795627966279762798627996280062801628026280362804628056280662807628086280962810628116281262813628146281562816628176281862819628206282162822628236282462825628266282762828628296283062831628326283362834628356283662837628386283962840628416284262843628446284562846628476284862849628506285162852628536285462855628566285762858628596286062861628626286362864628656286662867628686286962870628716287262873628746287562876628776287862879628806288162882628836288462885628866288762888628896289062891628926289362894628956289662897628986289962900629016290262903629046290562906629076290862909629106291162912629136291462915629166291762918629196292062921629226292362924629256292662927629286292962930629316293262933629346293562936629376293862939629406294162942629436294462945629466294762948629496295062951629526295362954629556295662957629586295962960629616296262963629646296562966629676296862969629706297162972629736297462975629766297762978629796298062981629826298362984629856298662987629886298962990629916299262993629946299562996629976299862999630006300163002630036300463005630066300763008630096301063011630126301363014630156301663017630186301963020630216302263023630246302563026630276302863029630306303163032630336303463035630366303763038630396304063041630426304363044630456304663047630486304963050630516305263053630546305563056630576305863059630606306163062630636306463065630666306763068630696307063071630726307363074630756307663077630786307963080630816308263083630846308563086630876308863089630906309163092630936309463095630966309763098630996310063101631026310363104631056310663107631086310963110631116311263113631146311563116631176311863119631206312163122631236312463125631266312763128631296313063131631326313363134631356313663137631386313963140631416314263143631446314563146631476314863149631506315163152631536315463155631566315763158631596316063161631626316363164631656316663167631686316963170631716317263173631746317563176631776317863179631806318163182631836318463185631866318763188631896319063191631926319363194631956319663197631986319963200632016320263203632046320563206632076320863209632106321163212632136321463215632166321763218632196322063221632226322363224632256322663227632286322963230632316323263233632346323563236632376323863239632406324163242632436324463245632466324763248632496325063251632526325363254632556325663257632586325963260632616326263263632646326563266632676326863269632706327163272632736327463275632766327763278632796328063281632826328363284632856328663287632886328963290632916329263293632946329563296632976329863299633006330163302633036330463305633066330763308633096331063311633126331363314633156331663317633186331963320633216332263323633246332563326633276332863329633306333163332633336333463335633366333763338633396334063341633426334363344633456334663347633486334963350633516335263353633546335563356633576335863359633606336163362633636336463365633666336763368633696337063371633726337363374633756337663377633786337963380633816338263383633846338563386633876338863389633906339163392633936339463395633966339763398633996340063401634026340363404634056340663407634086340963410634116341263413634146341563416634176341863419634206342163422634236342463425634266342763428634296343063431634326343363434634356343663437634386343963440634416344263443634446344563446634476344863449634506345163452634536345463455634566345763458634596346063461634626346363464634656346663467634686346963470634716347263473634746347563476634776347863479634806348163482634836348463485634866348763488634896349063491634926349363494634956349663497634986349963500635016350263503635046350563506635076350863509635106351163512635136351463515635166351763518635196352063521635226352363524635256352663527635286352963530635316353263533635346353563536635376353863539635406354163542635436354463545635466354763548635496355063551635526355363554635556355663557635586355963560635616356263563635646356563566635676356863569635706357163572635736357463575635766357763578635796358063581635826358363584635856358663587635886358963590635916359263593635946359563596635976359863599636006360163602636036360463605636066360763608636096361063611636126361363614636156361663617636186361963620636216362263623636246362563626636276362863629636306363163632636336363463635636366363763638636396364063641636426364363644636456364663647636486364963650636516365263653636546365563656636576365863659636606366163662636636366463665636666366763668636696367063671636726367363674636756367663677636786367963680636816368263683636846368563686636876368863689636906369163692636936369463695636966369763698636996370063701637026370363704637056370663707637086370963710637116371263713637146371563716637176371863719637206372163722637236372463725637266372763728637296373063731637326373363734637356373663737637386373963740637416374263743637446374563746637476374863749637506375163752637536375463755637566375763758637596376063761637626376363764637656376663767637686376963770637716377263773637746377563776637776377863779637806378163782637836378463785637866378763788637896379063791637926379363794637956379663797637986379963800638016380263803638046380563806638076380863809638106381163812638136381463815638166381763818638196382063821638226382363824638256382663827638286382963830638316383263833638346383563836638376383863839638406384163842638436384463845638466384763848638496385063851638526385363854638556385663857638586385963860638616386263863638646386563866638676386863869638706387163872638736387463875638766387763878638796388063881638826388363884638856388663887638886388963890638916389263893638946389563896638976389863899639006390163902639036390463905639066390763908639096391063911639126391363914639156391663917639186391963920639216392263923639246392563926639276392863929639306393163932639336393463935639366393763938639396394063941639426394363944639456394663947639486394963950639516395263953639546395563956639576395863959639606396163962639636396463965639666396763968639696397063971639726397363974639756397663977639786397963980639816398263983639846398563986639876398863989639906399163992639936399463995639966399763998639996400064001640026400364004640056400664007640086400964010640116401264013640146401564016640176401864019640206402164022640236402464025640266402764028640296403064031640326403364034640356403664037640386403964040640416404264043640446404564046640476404864049640506405164052640536405464055640566405764058640596406064061640626406364064640656406664067640686406964070640716407264073640746407564076640776407864079640806408164082640836408464085640866408764088640896409064091640926409364094640956409664097640986409964100641016410264103641046410564106641076410864109641106411164112641136411464115641166411764118641196412064121641226412364124641256412664127641286412964130641316413264133641346413564136641376413864139641406414164142641436414464145641466414764148641496415064151641526415364154641556415664157641586415964160641616416264163641646416564166641676416864169641706417164172641736417464175641766417764178641796418064181641826418364184641856418664187641886418964190641916419264193641946419564196641976419864199642006420164202642036420464205642066420764208642096421064211642126421364214642156421664217642186421964220642216422264223642246422564226642276422864229642306423164232642336423464235642366423764238642396424064241642426424364244642456424664247642486424964250642516425264253642546425564256642576425864259642606426164262642636426464265642666426764268642696427064271642726427364274642756427664277642786427964280642816428264283642846428564286642876428864289642906429164292642936429464295642966429764298642996430064301643026430364304643056430664307643086430964310643116431264313643146431564316643176431864319643206432164322643236432464325643266432764328643296433064331643326433364334643356433664337643386433964340643416434264343643446434564346643476434864349643506435164352643536435464355643566435764358643596436064361643626436364364643656436664367643686436964370643716437264373643746437564376643776437864379643806438164382643836438464385643866438764388643896439064391643926439364394643956439664397643986439964400644016440264403644046440564406644076440864409644106441164412644136441464415644166441764418644196442064421644226442364424644256442664427644286442964430644316443264433644346443564436644376443864439644406444164442644436444464445644466444764448644496445064451644526445364454644556445664457644586445964460644616446264463644646446564466644676446864469644706447164472644736447464475644766447764478644796448064481644826448364484644856448664487644886448964490644916449264493644946449564496644976449864499645006450164502645036450464505645066450764508645096451064511645126451364514645156451664517645186451964520645216452264523645246452564526645276452864529645306453164532645336453464535645366453764538645396454064541645426454364544645456454664547645486454964550645516455264553645546455564556645576455864559645606456164562645636456464565645666456764568645696457064571645726457364574645756457664577645786457964580645816458264583645846458564586645876458864589645906459164592645936459464595645966459764598645996460064601646026460364604646056460664607646086460964610646116461264613646146461564616646176461864619646206462164622646236462464625646266462764628646296463064631646326463364634646356463664637646386463964640646416464264643646446464564646646476464864649646506465164652646536465464655646566465764658646596466064661646626466364664646656466664667646686466964670646716467264673646746467564676646776467864679646806468164682646836468464685646866468764688646896469064691646926469364694646956469664697646986469964700647016470264703647046470564706647076470864709647106471164712647136471464715647166471764718647196472064721647226472364724647256472664727647286472964730647316473264733647346473564736647376473864739647406474164742647436474464745647466474764748647496475064751647526475364754647556475664757647586475964760647616476264763647646476564766647676476864769647706477164772647736477464775647766477764778647796478064781647826478364784647856478664787647886478964790647916479264793647946479564796647976479864799648006480164802648036480464805648066480764808648096481064811648126481364814648156481664817648186481964820648216482264823648246482564826648276482864829648306483164832648336483464835648366483764838648396484064841648426484364844648456484664847648486484964850648516485264853648546485564856648576485864859648606486164862648636486464865648666486764868648696487064871648726487364874648756487664877648786487964880648816488264883648846488564886648876488864889648906489164892648936489464895648966489764898648996490064901649026490364904649056490664907649086490964910649116491264913649146491564916649176491864919649206492164922649236492464925649266492764928649296493064931649326493364934649356493664937649386493964940649416494264943649446494564946649476494864949649506495164952649536495464955649566495764958649596496064961649626496364964649656496664967649686496964970649716497264973649746497564976649776497864979649806498164982649836498464985649866498764988649896499064991649926499364994649956499664997649986499965000650016500265003650046500565006650076500865009650106501165012650136501465015650166501765018650196502065021650226502365024650256502665027650286502965030650316503265033650346503565036650376503865039650406504165042650436504465045650466504765048650496505065051650526505365054650556505665057650586505965060650616506265063650646506565066650676506865069650706507165072650736507465075650766507765078650796508065081650826508365084650856508665087650886508965090650916509265093650946509565096650976509865099651006510165102651036510465105651066510765108651096511065111651126511365114651156511665117651186511965120651216512265123651246512565126651276512865129651306513165132651336513465135651366513765138651396514065141651426514365144651456514665147651486514965150651516515265153651546515565156651576515865159651606516165162651636516465165651666516765168651696517065171651726517365174651756517665177651786517965180651816518265183651846518565186651876518865189651906519165192651936519465195651966519765198651996520065201652026520365204652056520665207652086520965210652116521265213652146521565216652176521865219652206522165222652236522465225652266522765228652296523065231652326523365234652356523665237652386523965240652416524265243652446524565246652476524865249652506525165252652536525465255652566525765258652596526065261652626526365264652656526665267652686526965270652716527265273652746527565276652776527865279652806528165282652836528465285652866528765288652896529065291652926529365294652956529665297652986529965300653016530265303653046530565306653076530865309653106531165312653136531465315653166531765318653196532065321653226532365324653256532665327653286532965330653316533265333653346533565336653376533865339653406534165342653436534465345653466534765348653496535065351653526535365354653556535665357653586535965360653616536265363653646536565366653676536865369653706537165372653736537465375653766537765378653796538065381653826538365384653856538665387653886538965390653916539265393653946539565396653976539865399654006540165402654036540465405654066540765408654096541065411654126541365414654156541665417654186541965420654216542265423654246542565426654276542865429654306543165432654336543465435654366543765438654396544065441654426544365444654456544665447654486544965450654516545265453654546545565456654576545865459654606546165462654636546465465654666546765468654696547065471654726547365474654756547665477654786547965480654816548265483654846548565486654876548865489654906549165492654936549465495654966549765498654996550065501655026550365504655056550665507655086550965510655116551265513655146551565516655176551865519655206552165522655236552465525655266552765528655296553065531655326553365534655356553665537655386553965540655416554265543655446554565546655476554865549655506555165552655536555465555655566555765558655596556065561655626556365564655656556665567655686556965570655716557265573655746557565576655776557865579655806558165582655836558465585655866558765588655896559065591655926559365594655956559665597655986559965600656016560265603656046560565606656076560865609656106561165612656136561465615656166561765618656196562065621656226562365624656256562665627656286562965630656316563265633656346563565636656376563865639656406564165642656436564465645656466564765648656496565065651656526565365654656556565665657656586565965660656616566265663656646566565666656676566865669656706567165672656736567465675656766567765678656796568065681656826568365684656856568665687656886568965690656916569265693656946569565696656976569865699657006570165702657036570465705657066570765708657096571065711657126571365714657156571665717657186571965720657216572265723657246572565726657276572865729657306573165732657336573465735657366573765738657396574065741657426574365744657456574665747657486574965750657516575265753657546575565756657576575865759657606576165762657636576465765657666576765768657696577065771657726577365774657756577665777657786577965780657816578265783657846578565786657876578865789657906579165792657936579465795657966579765798657996580065801658026580365804658056580665807658086580965810658116581265813658146581565816658176581865819658206582165822658236582465825658266582765828658296583065831658326583365834658356583665837658386583965840658416584265843658446584565846658476584865849658506585165852658536585465855658566585765858658596586065861658626586365864658656586665867658686586965870658716587265873658746587565876658776587865879658806588165882658836588465885658866588765888658896589065891658926589365894658956589665897658986589965900659016590265903659046590565906659076590865909659106591165912659136591465915659166591765918659196592065921659226592365924659256592665927659286592965930659316593265933659346593565936659376593865939659406594165942659436594465945659466594765948659496595065951659526595365954659556595665957659586595965960659616596265963659646596565966659676596865969659706597165972659736597465975659766597765978659796598065981659826598365984659856598665987659886598965990659916599265993659946599565996659976599865999660006600166002660036600466005660066600766008660096601066011660126601366014660156601666017660186601966020660216602266023660246602566026660276602866029660306603166032660336603466035660366603766038660396604066041660426604366044660456604666047660486604966050660516605266053660546605566056660576605866059660606606166062660636606466065660666606766068660696607066071660726607366074660756607666077660786607966080660816608266083660846608566086660876608866089660906609166092660936609466095660966609766098660996610066101661026610366104661056610666107661086610966110661116611266113661146611566116661176611866119661206612166122661236612466125661266612766128661296613066131661326613366134661356613666137661386613966140661416614266143661446614566146661476614866149661506615166152661536615466155661566615766158661596616066161661626616366164661656616666167661686616966170661716617266173661746617566176661776617866179661806618166182661836618466185661866618766188661896619066191661926619366194661956619666197661986619966200662016620266203662046620566206662076620866209662106621166212662136621466215662166621766218662196622066221662226622366224662256622666227662286622966230662316623266233662346623566236662376623866239662406624166242662436624466245662466624766248662496625066251662526625366254662556625666257662586625966260662616626266263662646626566266662676626866269662706627166272662736627466275662766627766278662796628066281662826628366284662856628666287662886628966290662916629266293662946629566296662976629866299663006630166302663036630466305663066630766308663096631066311663126631366314663156631666317663186631966320663216632266323663246632566326663276632866329663306633166332663336633466335663366633766338663396634066341663426634366344663456634666347663486634966350663516635266353663546635566356663576635866359663606636166362663636636466365663666636766368663696637066371663726637366374663756637666377663786637966380663816638266383663846638566386663876638866389663906639166392663936639466395663966639766398663996640066401664026640366404664056640666407664086640966410664116641266413664146641566416664176641866419664206642166422664236642466425664266642766428664296643066431664326643366434664356643666437664386643966440664416644266443664446644566446664476644866449664506645166452664536645466455664566645766458664596646066461664626646366464664656646666467664686646966470664716647266473664746647566476664776647866479664806648166482664836648466485664866648766488664896649066491664926649366494664956649666497664986649966500665016650266503665046650566506665076650866509665106651166512665136651466515665166651766518665196652066521665226652366524665256652666527665286652966530665316653266533665346653566536665376653866539665406654166542665436654466545665466654766548665496655066551665526655366554665556655666557665586655966560665616656266563665646656566566665676656866569665706657166572665736657466575665766657766578665796658066581665826658366584665856658666587665886658966590665916659266593665946659566596665976659866599666006660166602666036660466605666066660766608666096661066611666126661366614666156661666617666186661966620666216662266623666246662566626666276662866629666306663166632666336663466635666366663766638666396664066641666426664366644666456664666647666486664966650666516665266653666546665566656666576665866659666606666166662666636666466665666666666766668666696667066671666726667366674666756667666677666786667966680666816668266683666846668566686666876668866689666906669166692666936669466695666966669766698666996670066701667026670366704667056670666707667086670966710667116671266713667146671566716667176671866719667206672166722667236672466725667266672766728667296673066731667326673366734667356673666737667386673966740667416674266743667446674566746667476674866749667506675166752667536675466755667566675766758667596676066761667626676366764667656676666767667686676966770667716677266773667746677566776667776677866779667806678166782667836678466785667866678766788667896679066791667926679366794667956679666797667986679966800668016680266803668046680566806668076680866809668106681166812668136681466815668166681766818668196682066821668226682366824668256682666827668286682966830668316683266833668346683566836668376683866839668406684166842668436684466845668466684766848668496685066851668526685366854668556685666857668586685966860668616686266863668646686566866668676686866869668706687166872668736687466875668766687766878668796688066881668826688366884668856688666887668886688966890668916689266893668946689566896668976689866899669006690166902669036690466905669066690766908669096691066911669126691366914669156691666917669186691966920669216692266923669246692566926669276692866929669306693166932669336693466935669366693766938669396694066941669426694366944669456694666947669486694966950669516695266953669546695566956669576695866959669606696166962669636696466965669666696766968669696697066971669726697366974669756697666977669786697966980669816698266983669846698566986669876698866989669906699166992669936699466995669966699766998669996700067001670026700367004670056700667007670086700967010670116701267013670146701567016670176701867019670206702167022670236702467025670266702767028670296703067031670326703367034670356703667037670386703967040670416704267043670446704567046670476704867049670506705167052670536705467055670566705767058670596706067061670626706367064670656706667067670686706967070670716707267073670746707567076670776707867079670806708167082670836708467085670866708767088670896709067091670926709367094670956709667097670986709967100671016710267103671046710567106671076710867109671106711167112671136711467115671166711767118671196712067121671226712367124671256712667127671286712967130671316713267133671346713567136671376713867139671406714167142671436714467145671466714767148671496715067151671526715367154671556715667157671586715967160671616716267163671646716567166671676716867169671706717167172671736717467175671766717767178671796718067181671826718367184671856718667187671886718967190671916719267193671946719567196671976719867199672006720167202672036720467205672066720767208672096721067211672126721367214672156721667217672186721967220672216722267223672246722567226672276722867229672306723167232672336723467235672366723767238672396724067241672426724367244672456724667247672486724967250672516725267253672546725567256672576725867259672606726167262672636726467265672666726767268672696727067271672726727367274672756727667277672786727967280672816728267283672846728567286672876728867289672906729167292672936729467295672966729767298672996730067301673026730367304673056730667307673086730967310673116731267313673146731567316673176731867319673206732167322673236732467325673266732767328673296733067331673326733367334673356733667337673386733967340673416734267343673446734567346673476734867349673506735167352673536735467355673566735767358673596736067361673626736367364673656736667367673686736967370673716737267373673746737567376673776737867379673806738167382673836738467385673866738767388673896739067391673926739367394673956739667397673986739967400674016740267403674046740567406674076740867409674106741167412674136741467415674166741767418674196742067421674226742367424674256742667427674286742967430674316743267433674346743567436674376743867439674406744167442674436744467445674466744767448674496745067451674526745367454674556745667457674586745967460674616746267463674646746567466674676746867469674706747167472674736747467475674766747767478674796748067481674826748367484674856748667487674886748967490674916749267493674946749567496674976749867499675006750167502675036750467505675066750767508675096751067511675126751367514675156751667517675186751967520675216752267523675246752567526675276752867529675306753167532675336753467535675366753767538675396754067541675426754367544675456754667547675486754967550675516755267553675546755567556675576755867559675606756167562675636756467565675666756767568675696757067571675726757367574675756757667577675786757967580675816758267583675846758567586675876758867589675906759167592675936759467595675966759767598675996760067601676026760367604676056760667607676086760967610676116761267613676146761567616676176761867619676206762167622676236762467625676266762767628676296763067631676326763367634676356763667637676386763967640676416764267643676446764567646676476764867649676506765167652676536765467655676566765767658676596766067661676626766367664676656766667667676686766967670676716767267673676746767567676676776767867679676806768167682676836768467685676866768767688676896769067691676926769367694676956769667697676986769967700677016770267703677046770567706677076770867709677106771167712677136771467715677166771767718677196772067721677226772367724677256772667727677286772967730677316773267733677346773567736677376773867739677406774167742677436774467745677466774767748677496775067751677526775367754677556775667757677586775967760677616776267763677646776567766677676776867769677706777167772677736777467775677766777767778677796778067781677826778367784677856778667787677886778967790677916779267793677946779567796677976779867799678006780167802678036780467805678066780767808678096781067811678126781367814678156781667817678186781967820678216782267823678246782567826678276782867829678306783167832678336783467835678366783767838678396784067841678426784367844678456784667847678486784967850678516785267853678546785567856678576785867859678606786167862678636786467865678666786767868678696787067871678726787367874678756787667877678786787967880678816788267883678846788567886678876788867889678906789167892678936789467895678966789767898678996790067901679026790367904679056790667907679086790967910679116791267913679146791567916679176791867919679206792167922679236792467925679266792767928679296793067931679326793367934679356793667937679386793967940679416794267943679446794567946679476794867949679506795167952679536795467955679566795767958679596796067961679626796367964679656796667967679686796967970679716797267973679746797567976679776797867979679806798167982679836798467985679866798767988679896799067991679926799367994679956799667997679986799968000680016800268003680046800568006680076800868009680106801168012680136801468015680166801768018680196802068021680226802368024680256802668027680286802968030680316803268033680346803568036680376803868039680406804168042680436804468045680466804768048680496805068051680526805368054680556805668057680586805968060680616806268063680646806568066680676806868069680706807168072680736807468075680766807768078680796808068081680826808368084680856808668087680886808968090680916809268093680946809568096680976809868099681006810168102681036810468105681066810768108681096811068111681126811368114681156811668117681186811968120681216812268123681246812568126681276812868129681306813168132681336813468135681366813768138681396814068141681426814368144681456814668147681486814968150681516815268153681546815568156681576815868159681606816168162681636816468165681666816768168681696817068171681726817368174681756817668177681786817968180681816818268183681846818568186681876818868189681906819168192681936819468195681966819768198681996820068201682026820368204682056820668207682086820968210682116821268213682146821568216682176821868219682206822168222682236822468225682266822768228682296823068231682326823368234682356823668237682386823968240682416824268243682446824568246682476824868249682506825168252682536825468255682566825768258682596826068261682626826368264682656826668267682686826968270682716827268273682746827568276682776827868279682806828168282682836828468285682866828768288682896829068291682926829368294682956829668297682986829968300683016830268303683046830568306683076830868309683106831168312683136831468315683166831768318683196832068321683226832368324683256832668327683286832968330683316833268333683346833568336683376833868339683406834168342683436834468345683466834768348683496835068351683526835368354683556835668357683586835968360683616836268363683646836568366683676836868369683706837168372683736837468375683766837768378683796838068381683826838368384683856838668387683886838968390683916839268393683946839568396683976839868399684006840168402684036840468405684066840768408684096841068411684126841368414684156841668417684186841968420684216842268423684246842568426684276842868429684306843168432684336843468435684366843768438684396844068441684426844368444684456844668447684486844968450684516845268453684546845568456684576845868459684606846168462684636846468465684666846768468684696847068471684726847368474684756847668477684786847968480684816848268483684846848568486684876848868489684906849168492684936849468495684966849768498684996850068501685026850368504685056850668507685086850968510685116851268513685146851568516685176851868519685206852168522685236852468525685266852768528685296853068531685326853368534685356853668537685386853968540685416854268543685446854568546685476854868549685506855168552685536855468555685566855768558685596856068561685626856368564685656856668567685686856968570685716857268573685746857568576685776857868579685806858168582685836858468585685866858768588685896859068591685926859368594685956859668597685986859968600686016860268603686046860568606686076860868609686106861168612686136861468615686166861768618686196862068621686226862368624686256862668627686286862968630686316863268633686346863568636686376863868639686406864168642686436864468645686466864768648686496865068651686526865368654686556865668657686586865968660686616866268663686646866568666686676866868669686706867168672686736867468675686766867768678686796868068681686826868368684686856868668687686886868968690686916869268693686946869568696686976869868699687006870168702687036870468705687066870768708687096871068711687126871368714687156871668717687186871968720687216872268723687246872568726687276872868729687306873168732687336873468735687366873768738687396874068741687426874368744687456874668747687486874968750687516875268753687546875568756687576875868759687606876168762687636876468765687666876768768687696877068771687726877368774687756877668777687786877968780687816878268783687846878568786687876878868789687906879168792687936879468795687966879768798687996880068801688026880368804688056880668807688086880968810688116881268813688146881568816688176881868819688206882168822688236882468825688266882768828688296883068831688326883368834688356883668837688386883968840688416884268843688446884568846688476884868849688506885168852688536885468855688566885768858688596886068861688626886368864688656886668867688686886968870688716887268873688746887568876688776887868879688806888168882688836888468885688866888768888688896889068891688926889368894688956889668897688986889968900689016890268903689046890568906689076890868909689106891168912689136891468915689166891768918689196892068921689226892368924689256892668927689286892968930689316893268933689346893568936689376893868939689406894168942689436894468945689466894768948689496895068951689526895368954689556895668957689586895968960689616896268963689646896568966689676896868969689706897168972689736897468975689766897768978689796898068981689826898368984689856898668987689886898968990689916899268993689946899568996689976899868999690006900169002690036900469005690066900769008690096901069011690126901369014690156901669017690186901969020690216902269023690246902569026690276902869029690306903169032690336903469035690366903769038690396904069041690426904369044690456904669047690486904969050690516905269053690546905569056690576905869059690606906169062690636906469065690666906769068690696907069071690726907369074690756907669077690786907969080690816908269083690846908569086690876908869089690906909169092690936909469095690966909769098690996910069101691026910369104691056910669107691086910969110691116911269113691146911569116691176911869119691206912169122691236912469125691266912769128691296913069131691326913369134691356913669137691386913969140691416914269143691446914569146691476914869149691506915169152691536915469155691566915769158691596916069161691626916369164691656916669167691686916969170691716917269173691746917569176691776917869179691806918169182691836918469185691866918769188691896919069191691926919369194691956919669197691986919969200692016920269203692046920569206692076920869209692106921169212692136921469215692166921769218692196922069221692226922369224692256922669227692286922969230692316923269233692346923569236692376923869239692406924169242692436924469245692466924769248692496925069251692526925369254692556925669257692586925969260692616926269263692646926569266692676926869269692706927169272692736927469275692766927769278692796928069281692826928369284692856928669287692886928969290692916929269293692946929569296692976929869299693006930169302693036930469305693066930769308693096931069311693126931369314693156931669317693186931969320693216932269323693246932569326693276932869329693306933169332693336933469335693366933769338693396934069341693426934369344693456934669347693486934969350693516935269353693546935569356693576935869359693606936169362693636936469365693666936769368693696937069371693726937369374693756937669377693786937969380693816938269383693846938569386693876938869389693906939169392693936939469395693966939769398693996940069401694026940369404694056940669407694086940969410694116941269413694146941569416694176941869419694206942169422694236942469425694266942769428694296943069431694326943369434694356943669437694386943969440694416944269443694446944569446694476944869449694506945169452694536945469455694566945769458694596946069461694626946369464694656946669467694686946969470694716947269473694746947569476694776947869479694806948169482694836948469485694866948769488694896949069491694926949369494694956949669497694986949969500695016950269503695046950569506695076950869509695106951169512695136951469515695166951769518695196952069521695226952369524695256952669527695286952969530695316953269533695346953569536695376953869539695406954169542695436954469545695466954769548695496955069551695526955369554695556955669557695586955969560695616956269563695646956569566695676956869569695706957169572695736957469575695766957769578695796958069581695826958369584695856958669587695886958969590695916959269593695946959569596695976959869599696006960169602696036960469605696066960769608696096961069611696126961369614696156961669617696186961969620696216962269623696246962569626696276962869629696306963169632696336963469635696366963769638696396964069641696426964369644696456964669647696486964969650696516965269653696546965569656696576965869659696606966169662696636966469665696666966769668696696967069671696726967369674696756967669677696786967969680696816968269683696846968569686696876968869689696906969169692696936969469695696966969769698696996970069701697026970369704697056970669707697086970969710697116971269713697146971569716697176971869719697206972169722697236972469725697266972769728697296973069731697326973369734697356973669737697386973969740697416974269743697446974569746697476974869749697506975169752697536975469755697566975769758697596976069761697626976369764697656976669767697686976969770697716977269773697746977569776697776977869779697806978169782697836978469785697866978769788697896979069791697926979369794697956979669797697986979969800698016980269803698046980569806698076980869809698106981169812698136981469815698166981769818698196982069821698226982369824698256982669827698286982969830698316983269833698346983569836698376983869839698406984169842698436984469845698466984769848698496985069851698526985369854698556985669857698586985969860698616986269863698646986569866698676986869869698706987169872698736987469875698766987769878698796988069881698826988369884698856988669887698886988969890698916989269893698946989569896698976989869899699006990169902699036990469905699066990769908699096991069911699126991369914699156991669917699186991969920699216992269923699246992569926699276992869929699306993169932699336993469935699366993769938699396994069941699426994369944699456994669947699486994969950699516995269953699546995569956699576995869959699606996169962699636996469965699666996769968699696997069971699726997369974699756997669977699786997969980699816998269983699846998569986699876998869989699906999169992699936999469995699966999769998699997000070001700027000370004700057000670007700087000970010700117001270013700147001570016700177001870019700207002170022700237002470025700267002770028700297003070031700327003370034700357003670037700387003970040700417004270043700447004570046700477004870049700507005170052700537005470055700567005770058700597006070061700627006370064700657006670067700687006970070700717007270073700747007570076700777007870079700807008170082700837008470085700867008770088700897009070091700927009370094700957009670097700987009970100701017010270103701047010570106701077010870109701107011170112701137011470115701167011770118701197012070121701227012370124701257012670127701287012970130701317013270133701347013570136701377013870139701407014170142701437014470145701467014770148701497015070151701527015370154701557015670157701587015970160701617016270163701647016570166701677016870169701707017170172701737017470175701767017770178701797018070181701827018370184701857018670187701887018970190701917019270193701947019570196701977019870199702007020170202702037020470205702067020770208702097021070211702127021370214702157021670217702187021970220702217022270223702247022570226702277022870229702307023170232702337023470235702367023770238702397024070241702427024370244702457024670247702487024970250702517025270253702547025570256702577025870259702607026170262702637026470265702667026770268702697027070271702727027370274702757027670277702787027970280702817028270283702847028570286702877028870289702907029170292702937029470295702967029770298702997030070301703027030370304703057030670307703087030970310703117031270313703147031570316703177031870319703207032170322703237032470325703267032770328703297033070331703327033370334703357033670337703387033970340703417034270343703447034570346703477034870349703507035170352703537035470355703567035770358703597036070361703627036370364703657036670367703687036970370703717037270373703747037570376703777037870379703807038170382703837038470385703867038770388703897039070391703927039370394703957039670397703987039970400704017040270403704047040570406704077040870409704107041170412704137041470415704167041770418704197042070421704227042370424704257042670427704287042970430704317043270433704347043570436704377043870439704407044170442704437044470445704467044770448704497045070451704527045370454704557045670457704587045970460704617046270463704647046570466704677046870469704707047170472704737047470475704767047770478704797048070481704827048370484704857048670487704887048970490704917049270493704947049570496704977049870499705007050170502705037050470505705067050770508705097051070511705127051370514705157051670517705187051970520705217052270523705247052570526705277052870529705307053170532705337053470535705367053770538705397054070541705427054370544705457054670547705487054970550705517055270553705547055570556705577055870559705607056170562705637056470565705667056770568705697057070571705727057370574705757057670577705787057970580705817058270583705847058570586705877058870589705907059170592705937059470595705967059770598705997060070601706027060370604706057060670607706087060970610706117061270613706147061570616706177061870619706207062170622706237062470625706267062770628706297063070631706327063370634706357063670637706387063970640706417064270643706447064570646706477064870649706507065170652706537065470655706567065770658706597066070661706627066370664706657066670667706687066970670706717067270673706747067570676706777067870679706807068170682706837068470685706867068770688706897069070691706927069370694706957069670697706987069970700707017070270703707047070570706707077070870709707107071170712707137071470715707167071770718707197072070721707227072370724707257072670727707287072970730707317073270733707347073570736707377073870739707407074170742707437074470745707467074770748707497075070751707527075370754707557075670757707587075970760707617076270763707647076570766707677076870769707707077170772707737077470775707767077770778707797078070781707827078370784707857078670787707887078970790707917079270793707947079570796707977079870799708007080170802708037080470805708067080770808708097081070811708127081370814708157081670817708187081970820708217082270823708247082570826708277082870829708307083170832708337083470835708367083770838708397084070841708427084370844708457084670847708487084970850708517085270853708547085570856708577085870859708607086170862708637086470865708667086770868708697087070871708727087370874708757087670877708787087970880708817088270883708847088570886708877088870889708907089170892708937089470895708967089770898708997090070901709027090370904709057090670907709087090970910709117091270913709147091570916709177091870919709207092170922709237092470925709267092770928709297093070931709327093370934709357093670937709387093970940709417094270943709447094570946709477094870949709507095170952709537095470955709567095770958709597096070961709627096370964709657096670967709687096970970709717097270973709747097570976709777097870979709807098170982709837098470985709867098770988709897099070991709927099370994709957099670997709987099971000710017100271003710047100571006710077100871009710107101171012710137101471015710167101771018710197102071021710227102371024710257102671027710287102971030710317103271033710347103571036710377103871039710407104171042710437104471045710467104771048710497105071051710527105371054710557105671057710587105971060710617106271063710647106571066710677106871069710707107171072710737107471075710767107771078710797108071081710827108371084710857108671087710887108971090710917109271093710947109571096710977109871099711007110171102711037110471105711067110771108711097111071111711127111371114711157111671117711187111971120711217112271123711247112571126711277112871129711307113171132711337113471135711367113771138711397114071141711427114371144711457114671147711487114971150711517115271153711547115571156711577115871159711607116171162711637116471165711667116771168711697117071171711727117371174711757117671177711787117971180711817118271183711847118571186711877118871189711907119171192711937119471195711967119771198711997120071201712027120371204712057120671207712087120971210712117121271213712147121571216712177121871219712207122171222712237122471225712267122771228712297123071231712327123371234712357123671237712387123971240712417124271243712447124571246712477124871249712507125171252712537125471255712567125771258712597126071261712627126371264712657126671267712687126971270712717127271273712747127571276712777127871279712807128171282712837128471285712867128771288712897129071291712927129371294712957129671297712987129971300713017130271303713047130571306713077130871309713107131171312713137131471315713167131771318713197132071321713227132371324713257132671327713287132971330713317133271333713347133571336713377133871339713407134171342713437134471345713467134771348713497135071351713527135371354713557135671357713587135971360713617136271363713647136571366713677136871369713707137171372713737137471375713767137771378713797138071381713827138371384713857138671387713887138971390713917139271393713947139571396713977139871399714007140171402714037140471405714067140771408714097141071411714127141371414714157141671417714187141971420714217142271423714247142571426714277142871429714307143171432714337143471435714367143771438714397144071441714427144371444714457144671447714487144971450714517145271453714547145571456714577145871459714607146171462714637146471465714667146771468714697147071471714727147371474714757147671477714787147971480714817148271483714847148571486714877148871489714907149171492714937149471495714967149771498714997150071501715027150371504715057150671507715087150971510715117151271513715147151571516715177151871519715207152171522715237152471525715267152771528715297153071531715327153371534715357153671537715387153971540715417154271543715447154571546715477154871549715507155171552715537155471555715567155771558715597156071561715627156371564715657156671567715687156971570715717157271573715747157571576715777157871579715807158171582715837158471585715867158771588715897159071591715927159371594715957159671597715987159971600716017160271603716047160571606716077160871609716107161171612716137161471615716167161771618716197162071621716227162371624716257162671627716287162971630716317163271633716347163571636716377163871639716407164171642716437164471645716467164771648716497165071651716527165371654716557165671657716587165971660716617166271663716647166571666716677166871669716707167171672716737167471675716767167771678716797168071681716827168371684716857168671687716887168971690716917169271693716947169571696716977169871699717007170171702717037170471705717067170771708717097171071711717127171371714717157171671717717187171971720717217172271723717247172571726717277172871729717307173171732717337173471735717367173771738717397174071741717427174371744717457174671747717487174971750717517175271753717547175571756717577175871759717607176171762717637176471765717667176771768717697177071771717727177371774717757177671777717787177971780717817178271783717847178571786717877178871789717907179171792717937179471795717967179771798717997180071801718027180371804718057180671807718087180971810718117181271813718147181571816718177181871819718207182171822718237182471825718267182771828718297183071831718327183371834718357183671837718387183971840718417184271843718447184571846718477184871849718507185171852718537185471855718567185771858718597186071861718627186371864718657186671867718687186971870718717187271873718747187571876718777187871879718807188171882718837188471885718867188771888718897189071891718927189371894718957189671897718987189971900719017190271903719047190571906719077190871909719107191171912719137191471915719167191771918719197192071921719227192371924719257192671927719287192971930719317193271933719347193571936719377193871939719407194171942719437194471945719467194771948719497195071951719527195371954719557195671957719587195971960719617196271963719647196571966719677196871969719707197171972719737197471975719767197771978719797198071981719827198371984719857198671987719887198971990719917199271993719947199571996719977199871999720007200172002720037200472005720067200772008720097201072011720127201372014720157201672017720187201972020720217202272023720247202572026720277202872029720307203172032720337203472035720367203772038720397204072041720427204372044720457204672047720487204972050720517205272053720547205572056720577205872059720607206172062720637206472065720667206772068720697207072071720727207372074720757207672077720787207972080720817208272083720847208572086720877208872089720907209172092720937209472095720967209772098720997210072101721027210372104721057210672107721087210972110721117211272113721147211572116721177211872119721207212172122721237212472125721267212772128721297213072131721327213372134721357213672137721387213972140721417214272143721447214572146721477214872149721507215172152721537215472155721567215772158721597216072161721627216372164721657216672167721687216972170721717217272173721747217572176721777217872179721807218172182721837218472185721867218772188721897219072191721927219372194721957219672197721987219972200722017220272203722047220572206722077220872209722107221172212722137221472215722167221772218722197222072221722227222372224722257222672227722287222972230722317223272233722347223572236722377223872239722407224172242722437224472245722467224772248722497225072251722527225372254722557225672257722587225972260722617226272263722647226572266722677226872269722707227172272722737227472275722767227772278722797228072281722827228372284722857228672287722887228972290722917229272293722947229572296722977229872299723007230172302723037230472305723067230772308723097231072311723127231372314723157231672317723187231972320723217232272323723247232572326723277232872329723307233172332723337233472335723367233772338723397234072341723427234372344723457234672347723487234972350723517235272353723547235572356723577235872359723607236172362723637236472365723667236772368723697237072371723727237372374723757237672377723787237972380723817238272383723847238572386723877238872389723907239172392723937239472395723967239772398723997240072401724027240372404724057240672407724087240972410724117241272413724147241572416724177241872419724207242172422724237242472425724267242772428724297243072431724327243372434724357243672437724387243972440724417244272443724447244572446724477244872449724507245172452724537245472455724567245772458724597246072461724627246372464724657246672467724687246972470724717247272473724747247572476724777247872479724807248172482724837248472485724867248772488724897249072491724927249372494724957249672497724987249972500725017250272503725047250572506725077250872509725107251172512725137251472515725167251772518725197252072521725227252372524725257252672527725287252972530725317253272533725347253572536725377253872539725407254172542725437254472545725467254772548725497255072551725527255372554725557255672557725587255972560725617256272563725647256572566725677256872569725707257172572725737257472575725767257772578725797258072581725827258372584725857258672587725887258972590725917259272593725947259572596725977259872599726007260172602726037260472605726067260772608726097261072611726127261372614726157261672617726187261972620726217262272623726247262572626726277262872629726307263172632726337263472635726367263772638726397264072641726427264372644726457264672647726487264972650726517265272653726547265572656726577265872659726607266172662726637266472665726667266772668726697267072671726727267372674726757267672677726787267972680726817268272683726847268572686726877268872689726907269172692726937269472695726967269772698726997270072701727027270372704727057270672707727087270972710727117271272713727147271572716727177271872719727207272172722727237272472725727267272772728727297273072731727327273372734727357273672737727387273972740727417274272743727447274572746727477274872749727507275172752727537275472755727567275772758727597276072761727627276372764727657276672767727687276972770727717277272773727747277572776727777277872779727807278172782727837278472785727867278772788727897279072791727927279372794727957279672797727987279972800728017280272803728047280572806728077280872809728107281172812728137281472815728167281772818728197282072821728227282372824728257282672827728287282972830728317283272833728347283572836728377283872839728407284172842728437284472845728467284772848728497285072851728527285372854728557285672857728587285972860728617286272863728647286572866728677286872869728707287172872728737287472875728767287772878728797288072881728827288372884728857288672887728887288972890728917289272893728947289572896728977289872899729007290172902729037290472905729067290772908729097291072911729127291372914729157291672917729187291972920729217292272923729247292572926729277292872929729307293172932729337293472935729367293772938729397294072941729427294372944729457294672947729487294972950729517295272953729547295572956729577295872959729607296172962729637296472965729667296772968729697297072971729727297372974729757297672977729787297972980729817298272983729847298572986729877298872989729907299172992729937299472995729967299772998729997300073001730027300373004730057300673007730087300973010730117301273013730147301573016730177301873019730207302173022730237302473025730267302773028730297303073031730327303373034730357303673037730387303973040730417304273043730447304573046730477304873049730507305173052730537305473055730567305773058730597306073061730627306373064730657306673067730687306973070730717307273073730747307573076730777307873079730807308173082730837308473085730867308773088730897309073091730927309373094730957309673097730987309973100731017310273103731047310573106731077310873109731107311173112731137311473115731167311773118731197312073121731227312373124731257312673127731287312973130731317313273133731347313573136731377313873139731407314173142731437314473145731467314773148731497315073151731527315373154731557315673157731587315973160731617316273163731647316573166731677316873169731707317173172731737317473175731767317773178731797318073181731827318373184731857318673187731887318973190731917319273193731947319573196731977319873199732007320173202732037320473205732067320773208732097321073211732127321373214732157321673217732187321973220732217322273223732247322573226732277322873229732307323173232732337323473235732367323773238732397324073241732427324373244732457324673247732487324973250732517325273253732547325573256732577325873259732607326173262732637326473265732667326773268732697327073271732727327373274732757327673277732787327973280732817328273283732847328573286732877328873289732907329173292732937329473295732967329773298732997330073301733027330373304733057330673307733087330973310733117331273313733147331573316733177331873319733207332173322733237332473325733267332773328733297333073331733327333373334733357333673337733387333973340733417334273343733447334573346733477334873349733507335173352733537335473355733567335773358733597336073361733627336373364733657336673367733687336973370733717337273373733747337573376733777337873379733807338173382733837338473385733867338773388733897339073391733927339373394733957339673397733987339973400734017340273403734047340573406734077340873409734107341173412734137341473415734167341773418734197342073421734227342373424734257342673427734287342973430734317343273433734347343573436734377343873439734407344173442734437344473445734467344773448734497345073451734527345373454734557345673457734587345973460734617346273463734647346573466734677346873469734707347173472734737347473475734767347773478734797348073481734827348373484734857348673487734887348973490734917349273493734947349573496734977349873499735007350173502735037350473505735067350773508735097351073511735127351373514735157351673517735187351973520735217352273523735247352573526735277352873529735307353173532735337353473535735367353773538735397354073541735427354373544735457354673547735487354973550735517355273553735547355573556735577355873559735607356173562735637356473565735667356773568735697357073571735727357373574735757357673577735787357973580735817358273583735847358573586735877358873589735907359173592735937359473595735967359773598735997360073601736027360373604736057360673607736087360973610736117361273613736147361573616736177361873619736207362173622736237362473625736267362773628736297363073631736327363373634736357363673637736387363973640736417364273643736447364573646736477364873649736507365173652736537365473655736567365773658736597366073661736627366373664736657366673667736687366973670736717367273673736747367573676736777367873679736807368173682736837368473685736867368773688736897369073691736927369373694736957369673697736987369973700737017370273703737047370573706737077370873709737107371173712737137371473715737167371773718737197372073721737227372373724737257372673727737287372973730737317373273733737347373573736737377373873739737407374173742737437374473745737467374773748737497375073751737527375373754737557375673757737587375973760737617376273763737647376573766737677376873769737707377173772737737377473775737767377773778737797378073781737827378373784737857378673787737887378973790737917379273793737947379573796737977379873799738007380173802738037380473805738067380773808738097381073811738127381373814738157381673817738187381973820738217382273823738247382573826738277382873829738307383173832738337383473835738367383773838738397384073841738427384373844738457384673847738487384973850738517385273853738547385573856738577385873859738607386173862738637386473865738667386773868738697387073871738727387373874738757387673877738787387973880738817388273883738847388573886738877388873889738907389173892738937389473895738967389773898738997390073901739027390373904739057390673907739087390973910739117391273913739147391573916739177391873919739207392173922739237392473925739267392773928739297393073931739327393373934739357393673937739387393973940739417394273943739447394573946739477394873949739507395173952739537395473955739567395773958739597396073961739627396373964739657396673967739687396973970739717397273973739747397573976739777397873979739807398173982739837398473985739867398773988739897399073991739927399373994739957399673997739987399974000740017400274003740047400574006740077400874009740107401174012740137401474015740167401774018740197402074021740227402374024740257402674027740287402974030740317403274033740347403574036740377403874039740407404174042740437404474045740467404774048740497405074051740527405374054740557405674057740587405974060740617406274063740647406574066740677406874069740707407174072740737407474075740767407774078740797408074081740827408374084740857408674087740887408974090740917409274093740947409574096740977409874099741007410174102741037410474105741067410774108741097411074111741127411374114741157411674117741187411974120741217412274123741247412574126741277412874129741307413174132741337413474135741367413774138741397414074141741427414374144741457414674147741487414974150741517415274153741547415574156741577415874159741607416174162741637416474165741667416774168741697417074171741727417374174741757417674177741787417974180741817418274183741847418574186741877418874189741907419174192741937419474195741967419774198741997420074201742027420374204742057420674207742087420974210742117421274213742147421574216742177421874219742207422174222742237422474225742267422774228742297423074231742327423374234742357423674237742387423974240742417424274243742447424574246742477424874249742507425174252742537425474255742567425774258742597426074261742627426374264742657426674267742687426974270742717427274273742747427574276742777427874279742807428174282742837428474285742867428774288742897429074291742927429374294742957429674297742987429974300743017430274303743047430574306743077430874309743107431174312743137431474315743167431774318743197432074321743227432374324743257432674327743287432974330743317433274333743347433574336743377433874339743407434174342743437434474345743467434774348743497435074351743527435374354743557435674357743587435974360743617436274363743647436574366743677436874369743707437174372743737437474375743767437774378743797438074381743827438374384743857438674387743887438974390743917439274393743947439574396743977439874399744007440174402744037440474405744067440774408744097441074411744127441374414744157441674417744187441974420744217442274423744247442574426744277442874429744307443174432744337443474435744367443774438744397444074441744427444374444744457444674447744487444974450744517445274453744547445574456744577445874459744607446174462744637446474465744667446774468744697447074471744727447374474744757447674477744787447974480744817448274483744847448574486744877448874489744907449174492744937449474495744967449774498744997450074501745027450374504745057450674507745087450974510745117451274513745147451574516745177451874519745207452174522745237452474525745267452774528745297453074531745327453374534745357453674537745387453974540745417454274543745447454574546745477454874549745507455174552745537455474555745567455774558745597456074561745627456374564745657456674567745687456974570745717457274573745747457574576745777457874579745807458174582745837458474585745867458774588745897459074591745927459374594745957459674597745987459974600746017460274603746047460574606746077460874609746107461174612746137461474615746167461774618746197462074621746227462374624746257462674627746287462974630746317463274633746347463574636746377463874639746407464174642746437464474645746467464774648746497465074651746527465374654746557465674657746587465974660746617466274663746647466574666746677466874669746707467174672746737467474675746767467774678746797468074681746827468374684746857468674687746887468974690746917469274693746947469574696746977469874699747007470174702747037470474705747067470774708747097471074711747127471374714747157471674717747187471974720747217472274723747247472574726747277472874729747307473174732747337473474735747367473774738747397474074741747427474374744747457474674747747487474974750747517475274753747547475574756747577475874759747607476174762747637476474765747667476774768747697477074771747727477374774747757477674777747787477974780747817478274783747847478574786747877478874789747907479174792747937479474795747967479774798747997480074801748027480374804748057480674807748087480974810748117481274813748147481574816748177481874819748207482174822748237482474825748267482774828748297483074831748327483374834748357483674837748387483974840748417484274843748447484574846748477484874849748507485174852748537485474855748567485774858748597486074861748627486374864748657486674867748687486974870748717487274873748747487574876748777487874879748807488174882748837488474885748867488774888748897489074891748927489374894748957489674897748987489974900749017490274903749047490574906749077490874909749107491174912749137491474915749167491774918749197492074921749227492374924749257492674927749287492974930749317493274933749347493574936749377493874939749407494174942749437494474945749467494774948749497495074951749527495374954749557495674957749587495974960749617496274963749647496574966749677496874969749707497174972749737497474975749767497774978749797498074981749827498374984749857498674987749887498974990749917499274993749947499574996749977499874999750007500175002750037500475005750067500775008750097501075011750127501375014750157501675017750187501975020750217502275023750247502575026750277502875029750307503175032750337503475035750367503775038750397504075041750427504375044750457504675047750487504975050750517505275053750547505575056750577505875059750607506175062750637506475065750667506775068750697507075071750727507375074750757507675077750787507975080750817508275083750847508575086750877508875089750907509175092750937509475095750967509775098750997510075101751027510375104751057510675107751087510975110751117511275113751147511575116751177511875119751207512175122751237512475125751267512775128751297513075131751327513375134751357513675137751387513975140751417514275143751447514575146751477514875149751507515175152751537515475155751567515775158751597516075161751627516375164751657516675167751687516975170751717517275173751747517575176751777517875179751807518175182751837518475185751867518775188751897519075191751927519375194751957519675197751987519975200752017520275203752047520575206752077520875209752107521175212752137521475215752167521775218752197522075221752227522375224752257522675227752287522975230752317523275233752347523575236752377523875239752407524175242752437524475245752467524775248752497525075251752527525375254752557525675257752587525975260752617526275263752647526575266752677526875269752707527175272752737527475275752767527775278752797528075281752827528375284752857528675287752887528975290752917529275293752947529575296752977529875299753007530175302753037530475305753067530775308753097531075311753127531375314753157531675317753187531975320753217532275323753247532575326753277532875329753307533175332753337533475335753367533775338753397534075341753427534375344753457534675347753487534975350753517535275353753547535575356753577535875359753607536175362753637536475365753667536775368753697537075371753727537375374753757537675377753787537975380753817538275383753847538575386753877538875389753907539175392753937539475395753967539775398753997540075401754027540375404754057540675407754087540975410754117541275413754147541575416754177541875419754207542175422754237542475425754267542775428754297543075431754327543375434754357543675437754387543975440754417544275443754447544575446754477544875449754507545175452754537545475455754567545775458754597546075461754627546375464754657546675467754687546975470754717547275473754747547575476754777547875479754807548175482754837548475485754867548775488754897549075491754927549375494754957549675497754987549975500755017550275503755047550575506755077550875509755107551175512755137551475515755167551775518755197552075521755227552375524755257552675527755287552975530755317553275533755347553575536755377553875539755407554175542755437554475545755467554775548755497555075551755527555375554755557555675557755587555975560755617556275563755647556575566755677556875569755707557175572755737557475575755767557775578755797558075581755827558375584755857558675587755887558975590755917559275593755947559575596755977559875599756007560175602756037560475605756067560775608756097561075611756127561375614756157561675617756187561975620756217562275623756247562575626756277562875629756307563175632756337563475635756367563775638756397564075641756427564375644756457564675647756487564975650756517565275653756547565575656756577565875659756607566175662756637566475665756667566775668756697567075671756727567375674756757567675677756787567975680756817568275683756847568575686756877568875689756907569175692756937569475695756967569775698756997570075701757027570375704757057570675707757087570975710757117571275713757147571575716757177571875719757207572175722757237572475725757267572775728757297573075731757327573375734757357573675737757387573975740757417574275743757447574575746757477574875749757507575175752757537575475755757567575775758757597576075761757627576375764757657576675767757687576975770757717577275773757747577575776757777577875779757807578175782757837578475785757867578775788757897579075791757927579375794757957579675797757987579975800758017580275803758047580575806758077580875809758107581175812758137581475815758167581775818758197582075821758227582375824758257582675827758287582975830758317583275833758347583575836758377583875839758407584175842758437584475845758467584775848758497585075851758527585375854758557585675857758587585975860758617586275863758647586575866758677586875869758707587175872758737587475875758767587775878758797588075881758827588375884758857588675887758887588975890758917589275893758947589575896758977589875899759007590175902759037590475905759067590775908759097591075911759127591375914759157591675917759187591975920759217592275923759247592575926759277592875929759307593175932759337593475935759367593775938759397594075941759427594375944759457594675947759487594975950759517595275953759547595575956759577595875959759607596175962759637596475965759667596775968759697597075971759727597375974759757597675977759787597975980759817598275983759847598575986759877598875989759907599175992759937599475995759967599775998759997600076001760027600376004760057600676007760087600976010760117601276013760147601576016760177601876019760207602176022760237602476025760267602776028760297603076031760327603376034760357603676037760387603976040760417604276043760447604576046760477604876049760507605176052760537605476055760567605776058760597606076061760627606376064760657606676067760687606976070760717607276073760747607576076760777607876079760807608176082760837608476085760867608776088760897609076091760927609376094760957609676097760987609976100761017610276103761047610576106761077610876109761107611176112761137611476115761167611776118761197612076121761227612376124761257612676127761287612976130761317613276133761347613576136761377613876139761407614176142761437614476145761467614776148761497615076151761527615376154761557615676157761587615976160761617616276163761647616576166761677616876169761707617176172761737617476175761767617776178761797618076181761827618376184761857618676187761887618976190761917619276193761947619576196761977619876199762007620176202762037620476205762067620776208762097621076211762127621376214762157621676217762187621976220762217622276223762247622576226762277622876229762307623176232762337623476235762367623776238762397624076241762427624376244762457624676247762487624976250762517625276253762547625576256762577625876259762607626176262762637626476265762667626776268762697627076271762727627376274762757627676277762787627976280762817628276283762847628576286762877628876289762907629176292762937629476295762967629776298762997630076301763027630376304763057630676307763087630976310763117631276313763147631576316763177631876319763207632176322763237632476325763267632776328763297633076331763327633376334763357633676337763387633976340763417634276343763447634576346763477634876349763507635176352763537635476355763567635776358763597636076361763627636376364763657636676367763687636976370763717637276373763747637576376763777637876379763807638176382763837638476385763867638776388763897639076391763927639376394763957639676397763987639976400764017640276403764047640576406764077640876409764107641176412764137641476415764167641776418764197642076421764227642376424764257642676427764287642976430764317643276433764347643576436764377643876439764407644176442764437644476445764467644776448764497645076451764527645376454764557645676457764587645976460764617646276463764647646576466764677646876469764707647176472764737647476475764767647776478764797648076481764827648376484764857648676487764887648976490764917649276493764947649576496764977649876499765007650176502765037650476505765067650776508765097651076511765127651376514765157651676517765187651976520765217652276523765247652576526765277652876529765307653176532765337653476535765367653776538765397654076541765427654376544765457654676547765487654976550765517655276553765547655576556765577655876559765607656176562765637656476565765667656776568765697657076571765727657376574765757657676577765787657976580765817658276583765847658576586765877658876589765907659176592765937659476595765967659776598765997660076601766027660376604766057660676607766087660976610766117661276613766147661576616766177661876619766207662176622766237662476625766267662776628766297663076631766327663376634766357663676637766387663976640766417664276643766447664576646766477664876649766507665176652766537665476655766567665776658766597666076661766627666376664766657666676667766687666976670766717667276673766747667576676766777667876679766807668176682766837668476685766867668776688766897669076691766927669376694766957669676697766987669976700767017670276703767047670576706767077670876709767107671176712767137671476715767167671776718767197672076721767227672376724767257672676727767287672976730767317673276733767347673576736767377673876739767407674176742767437674476745767467674776748767497675076751767527675376754767557675676757767587675976760767617676276763767647676576766767677676876769767707677176772767737677476775767767677776778767797678076781767827678376784767857678676787767887678976790767917679276793767947679576796767977679876799768007680176802768037680476805768067680776808768097681076811768127681376814768157681676817768187681976820768217682276823
  1. /**
  2. * Moralis JavaScript SDK v1.5.9
  3. *
  4. * The source tree of this library can be found at
  5. * https://github.com/MoralisWeb3/Moralis-JS-SDK
  6. */
  7. (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.Moralis = 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(_dereq_,module,exports){
  8. "use strict";
  9. var _Object$defineProperty = _dereq_("@babel/runtime-corejs3/core-js-stable/object/define-property");
  10. var _interopRequireDefault = _dereq_("@babel/runtime-corejs3/helpers/interopRequireDefault");
  11. _Object$defineProperty(exports, "__esModule", {
  12. value: true
  13. });
  14. exports.track = track;
  15. var _CoreManager = _interopRequireDefault(_dereq_("./CoreManager"));
  16. /**
  17. * Copyright (c) 2015-present, Parse, LLC.
  18. * All rights reserved.
  19. *
  20. * This source code is licensed under the BSD-style license found in the
  21. * LICENSE file in the root directory of this source tree. An additional grant
  22. * of patent rights can be found in the PATENTS file in the same directory.
  23. *
  24. * @flow
  25. */
  26. /**
  27. * Parse.Analytics provides an interface to Parse's logging and analytics
  28. * backend.
  29. *
  30. * @class Parse.Analytics
  31. * @static
  32. * @hideconstructor
  33. */
  34. /**
  35. * Tracks the occurrence of a custom event with additional dimensions.
  36. * Parse will store a data point at the time of invocation with the given
  37. * event name.
  38. *
  39. * Dimensions will allow segmentation of the occurrences of this custom
  40. * event. Keys and values should be {@code String}s, and will throw
  41. * otherwise.
  42. *
  43. * To track a user signup along with additional metadata, consider the
  44. * following:
  45. * <pre>
  46. * var dimensions = {
  47. * gender: 'm',
  48. * source: 'web',
  49. * dayType: 'weekend'
  50. * };
  51. * Parse.Analytics.track('signup', dimensions);
  52. * </pre>
  53. *
  54. * There is a default limit of 8 dimensions per event tracked.
  55. *
  56. * @function track
  57. * @name Parse.Analytics.track
  58. * @param {string} name The name of the custom event to report to Parse as
  59. * having happened.
  60. * @param {object} dimensions The dictionary of information by which to
  61. * segment this event.
  62. * @returns {Promise} A promise that is resolved when the round-trip
  63. * to the server completes.
  64. */
  65. function track(name
  66. /*: string*/
  67. , dimensions
  68. /*: { [key: string]: string }*/
  69. )
  70. /*: Promise*/
  71. {
  72. name = name || '';
  73. name = name.replace(/^\s*/, '');
  74. name = name.replace(/\s*$/, '');
  75. if (name.length === 0) {
  76. throw new TypeError('A name for the custom event must be provided');
  77. }
  78. for (var _key in dimensions) {
  79. if (typeof _key !== 'string' || typeof dimensions[_key] !== 'string') {
  80. throw new TypeError('track() dimensions expects keys and values of type "string".');
  81. }
  82. }
  83. return _CoreManager.default.getAnalyticsController().track(name, dimensions);
  84. }
  85. var DefaultController = {
  86. track: function (name, dimensions) {
  87. var path = "events/".concat(name);
  88. var RESTController = _CoreManager.default.getRESTController();
  89. return RESTController.request('POST', path, {
  90. dimensions: dimensions
  91. });
  92. }
  93. };
  94. _CoreManager.default.setAnalyticsController(DefaultController);
  95. },{"./CoreManager":5,"@babel/runtime-corejs3/core-js-stable/object/define-property":105,"@babel/runtime-corejs3/helpers/interopRequireDefault":152}],2:[function(_dereq_,module,exports){
  96. "use strict";
  97. var _Object$defineProperty = _dereq_("@babel/runtime-corejs3/core-js-stable/object/define-property");
  98. var _interopRequireDefault = _dereq_("@babel/runtime-corejs3/helpers/interopRequireDefault");
  99. _Object$defineProperty(exports, "__esModule", {
  100. value: true
  101. });
  102. exports.default = void 0;
  103. var _ParseUser = _interopRequireDefault(_dereq_("./ParseUser"));
  104. /**
  105. * Copyright (c) 2015-present, Parse, LLC.
  106. * All rights reserved.
  107. *
  108. * This source code is licensed under the BSD-style license found in the
  109. * LICENSE file in the root directory of this source tree. An additional grant
  110. * of patent rights can be found in the PATENTS file in the same directory.
  111. *
  112. * @flow-weak
  113. */
  114. var _require = _dereq_('uuid'),
  115. uuidv4 = _require.v4;
  116. var registered = false;
  117. /**
  118. * Provides utility functions for working with Anonymously logged-in users. <br />
  119. * Anonymous users have some unique characteristics:
  120. * <ul>
  121. * <li>Anonymous users don't need a user name or password.</li>
  122. * <ul>
  123. * <li>Once logged out, an anonymous user cannot be recovered.</li>
  124. * </ul>
  125. * <li>signUp converts an anonymous user to a standard user with the given username and password.</li>
  126. * <ul>
  127. * <li>Data associated with the anonymous user is retained.</li>
  128. * </ul>
  129. * <li>logIn switches users without converting the anonymous user.</li>
  130. * <ul>
  131. * <li>Data associated with the anonymous user will be lost.</li>
  132. * </ul>
  133. * <li>Service logIn (e.g. Facebook, Twitter) will attempt to convert
  134. * the anonymous user into a standard user by linking it to the service.</li>
  135. * <ul>
  136. * <li>If a user already exists that is linked to the service, it will instead switch to the existing user.</li>
  137. * </ul>
  138. * <li>Service linking (e.g. Facebook, Twitter) will convert the anonymous user
  139. * into a standard user by linking it to the service.</li>
  140. * </ul>
  141. *
  142. * @class Parse.AnonymousUtils
  143. * @static
  144. */
  145. var AnonymousUtils = {
  146. /**
  147. * Gets whether the user has their account linked to anonymous user.
  148. *
  149. * @function isLinked
  150. * @name Parse.AnonymousUtils.isLinked
  151. * @param {Parse.User} user User to check for.
  152. * The user must be logged in on this device.
  153. * @returns {boolean} <code>true</code> if the user has their account
  154. * linked to an anonymous user.
  155. * @static
  156. */
  157. isLinked: function (user
  158. /*: ParseUser*/
  159. ) {
  160. var provider = this._getAuthProvider();
  161. return user._isLinked(provider.getAuthType());
  162. },
  163. /**
  164. * Logs in a user Anonymously.
  165. *
  166. * @function logIn
  167. * @name Parse.AnonymousUtils.logIn
  168. * @param {object} options MasterKey / SessionToken.
  169. * @returns {Promise} Logged in user
  170. * @static
  171. */
  172. logIn: function (options
  173. /*:: ?: RequestOptions*/
  174. )
  175. /*: Promise<ParseUser>*/
  176. {
  177. var provider = this._getAuthProvider();
  178. return _ParseUser.default.logInWith(provider.getAuthType(), provider.getAuthData(), options);
  179. },
  180. /**
  181. * Links Anonymous User to an existing PFUser.
  182. *
  183. * @function link
  184. * @name Parse.AnonymousUtils.link
  185. * @param {Parse.User} user User to link. This must be the current user.
  186. * @param {object} options MasterKey / SessionToken.
  187. * @returns {Promise} Linked with User
  188. * @static
  189. */
  190. link: function (user
  191. /*: ParseUser*/
  192. , options
  193. /*:: ?: RequestOptions*/
  194. )
  195. /*: Promise<ParseUser>*/
  196. {
  197. var provider = this._getAuthProvider();
  198. return user.linkWith(provider.getAuthType(), provider.getAuthData(), options);
  199. },
  200. _getAuthProvider: function () {
  201. var provider = {
  202. restoreAuthentication: function () {
  203. return true;
  204. },
  205. getAuthType: function () {
  206. return 'anonymous';
  207. },
  208. getAuthData: function () {
  209. return {
  210. authData: {
  211. id: uuidv4()
  212. }
  213. };
  214. }
  215. };
  216. if (!registered) {
  217. _ParseUser.default._registerAuthenticationProvider(provider);
  218. registered = true;
  219. }
  220. return provider;
  221. }
  222. };
  223. var _default = AnonymousUtils;
  224. exports.default = _default;
  225. },{"./ParseUser":44,"@babel/runtime-corejs3/core-js-stable/object/define-property":105,"@babel/runtime-corejs3/helpers/interopRequireDefault":152,"uuid":797}],3:[function(_dereq_,module,exports){
  226. "use strict";
  227. var _Object$defineProperty = _dereq_("@babel/runtime-corejs3/core-js-stable/object/define-property");
  228. _Object$defineProperty(exports, "__esModule", {
  229. value: true
  230. });
  231. exports.default = void 0;
  232. var Chains = {
  233. ETH_MAINENT: '0x1',
  234. ETH_ROPSTEN: '0x3',
  235. ETH_GOERLI: '0x5',
  236. ETH_KOVAN: '0x2a',
  237. ETH_RINKBEY: '0x4',
  238. ETH_LOCALDEVCHAIN: '0x539',
  239. POLYGON_MAINNET: '0x89',
  240. POLYGON_MUMBAI: '0x13881',
  241. BSC_MAINNET: '0x38',
  242. BSC_TESTNET: '0x61',
  243. AVAX_MAINNET: '0xa86a',
  244. AVAX_TESTNET: '0xa869',
  245. FANTOM_MAINNET: '0xfa'
  246. };
  247. var _default = Chains;
  248. exports.default = _default;
  249. },{"@babel/runtime-corejs3/core-js-stable/object/define-property":105}],4:[function(_dereq_,module,exports){
  250. "use strict";
  251. var _Object$defineProperty = _dereq_("@babel/runtime-corejs3/core-js-stable/object/define-property");
  252. var _interopRequireDefault = _dereq_("@babel/runtime-corejs3/helpers/interopRequireDefault");
  253. _Object$defineProperty(exports, "__esModule", {
  254. value: true
  255. });
  256. exports.getJobStatus = getJobStatus;
  257. exports.getJobsData = getJobsData;
  258. exports.run = run;
  259. exports.startJob = startJob;
  260. var _keys = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/object/keys"));
  261. var _promise = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/promise"));
  262. var _typeof2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/helpers/typeof"));
  263. var _CoreManager = _interopRequireDefault(_dereq_("./CoreManager"));
  264. var _decode = _interopRequireDefault(_dereq_("./decode"));
  265. var _encode = _interopRequireDefault(_dereq_("./encode"));
  266. var _ParseError = _interopRequireDefault(_dereq_("./ParseError"));
  267. var _ParseQuery = _interopRequireDefault(_dereq_("./ParseQuery"));
  268. var _ParseObject = _interopRequireDefault(_dereq_("./ParseObject"));
  269. /**
  270. * Copyright (c) 2015-present, Parse, LLC.
  271. * All rights reserved.
  272. *
  273. * This source code is licensed under the BSD-style license found in the
  274. * LICENSE file in the root directory of this source tree. An additional grant
  275. * of patent rights can be found in the PATENTS file in the same directory.
  276. *
  277. * @flow
  278. */
  279. /**
  280. * Contains functions for calling and declaring
  281. * <a href="/docs/cloud_code_guide#functions">cloud functions</a>.
  282. * <p><strong><em>
  283. * Some functions are only available from Cloud Code.
  284. * </em></strong></p>
  285. *
  286. * @class Parse.Cloud
  287. * @static
  288. * @hideconstructor
  289. */
  290. /**
  291. * Makes a call to a cloud function.
  292. *
  293. * @function run
  294. * @name Parse.Cloud.run
  295. * @param {string} name The function name.
  296. * @param {object} data The parameters to send to the cloud function.
  297. * @param {object} options
  298. * @returns {Promise} A promise that will be resolved with the result
  299. * of the function.
  300. */
  301. function run(name
  302. /*: string*/
  303. , data
  304. /*: mixed*/
  305. , options
  306. /*: RequestOptions*/
  307. )
  308. /*: Promise<mixed>*/
  309. {
  310. options = options || {};
  311. if (typeof name !== 'string' || name.length === 0) {
  312. throw new TypeError('Cloud function name must be a string.');
  313. }
  314. var requestOptions = {};
  315. if (options.useMasterKey) {
  316. requestOptions.useMasterKey = options.useMasterKey;
  317. }
  318. if (options.sessionToken) {
  319. requestOptions.sessionToken = options.sessionToken;
  320. }
  321. if (options.context && (0, _typeof2.default)(options.context) === 'object') {
  322. requestOptions.context = options.context;
  323. }
  324. return _CoreManager.default.getCloudController().run(name, data, requestOptions);
  325. }
  326. /**
  327. * Gets data for the current set of cloud jobs.
  328. *
  329. * @function getJobsData
  330. * @name Parse.Cloud.getJobsData
  331. * @returns {Promise} A promise that will be resolved with the result
  332. * of the function.
  333. */
  334. function getJobsData()
  335. /*: Promise<Object>*/
  336. {
  337. return _CoreManager.default.getCloudController().getJobsData({
  338. useMasterKey: true
  339. });
  340. }
  341. /**
  342. * Starts a given cloud job, which will process asynchronously.
  343. *
  344. * @function startJob
  345. * @name Parse.Cloud.startJob
  346. * @param {string} name The function name.
  347. * @param {object} data The parameters to send to the cloud function.
  348. * @returns {Promise} A promise that will be resolved with the jobStatusId
  349. * of the job.
  350. */
  351. function startJob(name
  352. /*: string*/
  353. , data
  354. /*: mixed*/
  355. )
  356. /*: Promise<string>*/
  357. {
  358. if (typeof name !== 'string' || name.length === 0) {
  359. throw new TypeError('Cloud job name must be a string.');
  360. }
  361. return _CoreManager.default.getCloudController().startJob(name, data, {
  362. useMasterKey: true
  363. });
  364. }
  365. /**
  366. * Gets job status by Id
  367. *
  368. * @function getJobStatus
  369. * @name Parse.Cloud.getJobStatus
  370. * @param {string} jobStatusId The Id of Job Status.
  371. * @returns {Parse.Object} Status of Job.
  372. */
  373. function getJobStatus(jobStatusId
  374. /*: string*/
  375. )
  376. /*: Promise<ParseObject>*/
  377. {
  378. var query = new _ParseQuery.default('_JobStatus');
  379. return query.get(jobStatusId, {
  380. useMasterKey: true
  381. });
  382. }
  383. var DefaultController = {
  384. run: function (name, data, options
  385. /*: RequestOptions*/
  386. ) {
  387. var RESTController = _CoreManager.default.getRESTController();
  388. var payload = (0, _encode.default)(data, true);
  389. var request = RESTController.request('POST', "functions/".concat(name), payload, options);
  390. return request.then(function (res) {
  391. if ((0, _typeof2.default)(res) === 'object' && (0, _keys.default)(res).length > 0 && !res.hasOwnProperty('result')) {
  392. throw new _ParseError.default(_ParseError.default.INVALID_JSON, 'The server returned an invalid response.');
  393. }
  394. var decoded = (0, _decode.default)(res);
  395. if (decoded && decoded.hasOwnProperty('result')) {
  396. return _promise.default.resolve(decoded.result);
  397. }
  398. return _promise.default.resolve(undefined);
  399. });
  400. },
  401. getJobsData: function (options
  402. /*: RequestOptions*/
  403. ) {
  404. var RESTController = _CoreManager.default.getRESTController();
  405. return RESTController.request('GET', 'cloud_code/jobs/data', null, options);
  406. },
  407. startJob: function (name, data, options
  408. /*: RequestOptions*/
  409. ) {
  410. var RESTController = _CoreManager.default.getRESTController();
  411. var payload = (0, _encode.default)(data, true);
  412. return RESTController.request('POST', "jobs/".concat(name), payload, options);
  413. }
  414. };
  415. _CoreManager.default.setCloudController(DefaultController);
  416. },{"./CoreManager":5,"./ParseError":29,"./ParseObject":36,"./ParseQuery":39,"./decode":65,"./encode":66,"@babel/runtime-corejs3/core-js-stable/object/define-property":105,"@babel/runtime-corejs3/core-js-stable/object/keys":112,"@babel/runtime-corejs3/core-js-stable/promise":115,"@babel/runtime-corejs3/helpers/interopRequireDefault":152,"@babel/runtime-corejs3/helpers/typeof":164}],5:[function(_dereq_,module,exports){
  417. (function (process){(function (){
  418. "use strict";
  419. var _interopRequireDefault = _dereq_("@babel/runtime-corejs3/helpers/interopRequireDefault");
  420. var _forEach = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/instance/for-each"));
  421. var _concat = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/instance/concat"));
  422. /*
  423. * Copyright (c) 2015-present, Parse, LLC.
  424. * All rights reserved.
  425. *
  426. * This source code is licensed under the BSD-style license found in the
  427. * LICENSE file in the root directory of this source tree. An additional grant
  428. * of patent rights can be found in the PATENTS file in the same directory.
  429. *
  430. * @flow
  431. */
  432. /*:: import type { AttributeMap, ObjectCache, OpsMap, State } from './ObjectStateMutations';*/
  433. /*:: import type ParseFile from './ParseFile';*/
  434. /*:: import type { FileSource } from './ParseFile';*/
  435. /*:: import type { Op } from './ParseOp';*/
  436. /*:: import type ParseObject from './ParseObject';*/
  437. /*:: import type { QueryJSON } from './ParseQuery';*/
  438. /*:: import type ParseUser from './ParseUser';*/
  439. /*:: import type { AuthData } from './ParseUser';*/
  440. /*:: import type { PushData } from './Push';*/
  441. /*:: import type { RequestOptions, FullOptions } from './RESTController';*/
  442. /*:: type AnalyticsController = {
  443. track: (name: string, dimensions: { [key: string]: string }) => Promise,
  444. };*/
  445. /*:: type CloudController = {
  446. run: (name: string, data: mixed, options: RequestOptions) => Promise,
  447. getJobsData: (options: RequestOptions) => Promise,
  448. startJob: (name: string, data: mixed, options: RequestOptions) => Promise,
  449. };*/
  450. /*:: type ConfigController = {
  451. current: () => Promise,
  452. get: () => Promise,
  453. save: (attrs: { [key: string]: any }) => Promise,
  454. };*/
  455. /*:: type CryptoController = {
  456. encrypt: (obj: any, secretKey: string) => string,
  457. decrypt: (encryptedText: string, secretKey: any) => string,
  458. };*/
  459. /*:: type FileController = {
  460. saveFile: (name: string, source: FileSource, options: FullOptions) => Promise,
  461. saveBase64: (name: string, source: FileSource, options: FullOptions) => Promise,
  462. download: (uri: string) => Promise,
  463. };*/
  464. /*:: type InstallationController = {
  465. currentInstallationId: () => Promise,
  466. };*/
  467. /*:: type ObjectController = {
  468. fetch: (
  469. object: ParseObject | Array<ParseObject>,
  470. forceFetch: boolean,
  471. options: RequestOptions
  472. ) => Promise,
  473. save: (object: ParseObject | Array<ParseObject | ParseFile>, options: RequestOptions) => Promise,
  474. destroy: (object: ParseObject | Array<ParseObject>, options: RequestOptions) => Promise,
  475. };*/
  476. /*:: type ObjectStateController = {
  477. getState: (obj: any) => ?State,
  478. initializeState: (obj: any, initial?: State) => State,
  479. removeState: (obj: any) => ?State,
  480. getServerData: (obj: any) => AttributeMap,
  481. setServerData: (obj: any, attributes: AttributeMap) => void,
  482. getPendingOps: (obj: any) => Array<OpsMap>,
  483. setPendingOp: (obj: any, attr: string, op: ?Op) => void,
  484. pushPendingState: (obj: any) => void,
  485. popPendingState: (obj: any) => OpsMap,
  486. mergeFirstPendingState: (obj: any) => void,
  487. getObjectCache: (obj: any) => ObjectCache,
  488. estimateAttribute: (obj: any, attr: string) => mixed,
  489. estimateAttributes: (obj: any) => AttributeMap,
  490. commitServerChanges: (obj: any, changes: AttributeMap) => void,
  491. enqueueTask: (obj: any, task: () => Promise) => Promise,
  492. clearAllState: () => void,
  493. duplicateState: (source: any, dest: any) => void,
  494. };*/
  495. /*:: type PushController = {
  496. send: (data: PushData) => Promise,
  497. };*/
  498. /*:: type QueryController = {
  499. find: (className: string, params: QueryJSON, options: RequestOptions) => Promise,
  500. aggregate: (className: string, params: any, options: RequestOptions) => Promise,
  501. };*/
  502. /*:: type RESTController = {
  503. request: (method: string, path: string, data: mixed, options: RequestOptions) => Promise,
  504. ajax: (method: string, url: string, data: any, headers?: any, options: FullOptions) => Promise,
  505. };*/
  506. /*:: type SchemaController = {
  507. purge: (className: string) => Promise,
  508. get: (className: string, options: RequestOptions) => Promise,
  509. delete: (className: string, options: RequestOptions) => Promise,
  510. create: (className: string, params: any, options: RequestOptions) => Promise,
  511. update: (className: string, params: any, options: RequestOptions) => Promise,
  512. send(className: string, method: string, params: any, options: RequestOptions): Promise,
  513. };*/
  514. /*:: type SessionController = {
  515. getSession: (token: RequestOptions) => Promise,
  516. };*/
  517. /*:: type StorageController =
  518. | {
  519. async: 0,
  520. getItem: (path: string) => ?string,
  521. setItem: (path: string, value: string) => void,
  522. removeItem: (path: string) => void,
  523. getItemAsync?: (path: string) => Promise,
  524. setItemAsync?: (path: string, value: string) => Promise,
  525. removeItemAsync?: (path: string) => Promise,
  526. clear: () => void,
  527. }
  528. | {
  529. async: 1,
  530. getItem?: (path: string) => ?string,
  531. setItem?: (path: string, value: string) => void,
  532. removeItem?: (path: string) => void,
  533. getItemAsync: (path: string) => Promise,
  534. setItemAsync: (path: string, value: string) => Promise,
  535. removeItemAsync: (path: string) => Promise,
  536. clear: () => void,
  537. };*/
  538. /*:: type LocalDatastoreController = {
  539. fromPinWithName: (name: string) => ?any,
  540. pinWithName: (name: string, objects: any) => void,
  541. unPinWithName: (name: string) => void,
  542. getAllContents: () => ?any,
  543. clear: () => void,
  544. };*/
  545. /*:: type UserController = {
  546. setCurrentUser: (user: ParseUser) => Promise,
  547. currentUser: () => ?ParseUser,
  548. currentUserAsync: () => Promise,
  549. signUp: (user: ParseUser, attrs: AttributeMap, options: RequestOptions) => Promise,
  550. logIn: (user: ParseUser, options: RequestOptions) => Promise,
  551. become: (options: RequestOptions) => Promise,
  552. hydrate: (userJSON: AttributeMap) => Promise,
  553. logOut: (options: RequestOptions) => Promise,
  554. me: (options: RequestOptions) => Promise,
  555. requestPasswordReset: (email: string, options: RequestOptions) => Promise,
  556. updateUserOnDisk: (user: ParseUser) => Promise,
  557. upgradeToRevocableSession: (user: ParseUser, options: RequestOptions) => Promise,
  558. linkWith: (user: ParseUser, authData: AuthData) => Promise,
  559. removeUserFromDisk: () => Promise,
  560. verifyPassword: (username: string, password: string, options: RequestOptions) => Promise,
  561. requestEmailVerification: (email: string, options: RequestOptions) => Promise,
  562. };*/
  563. /*:: type HooksController = {
  564. get: (type: string, functionName?: string, triggerName?: string) => Promise,
  565. create: (hook: mixed) => Promise,
  566. delete: (hook: mixed) => Promise,
  567. update: (hook: mixed) => Promise,
  568. send: (method: string, path: string, body?: mixed) => Promise,
  569. };*/
  570. /*:: type WebSocketController = {
  571. onopen: () => void,
  572. onmessage: (message: any) => void,
  573. onclose: () => void,
  574. onerror: (error: any) => void,
  575. send: (data: any) => void,
  576. close: () => void,
  577. };*/
  578. /*:: type Config = {
  579. AnalyticsController?: AnalyticsController,
  580. CloudController?: CloudController,
  581. ConfigController?: ConfigController,
  582. FileController?: FileController,
  583. InstallationController?: InstallationController,
  584. ObjectController?: ObjectController,
  585. ObjectStateController?: ObjectStateController,
  586. PushController?: PushController,
  587. QueryController?: QueryController,
  588. RESTController?: RESTController,
  589. SchemaController?: SchemaController,
  590. SessionController?: SessionController,
  591. StorageController?: StorageController,
  592. LocalDatastoreController?: LocalDatastoreController,
  593. UserController?: UserController,
  594. HooksController?: HooksController,
  595. WebSocketController?: WebSocketController,
  596. };*/
  597. var config
  598. /*: Config & { [key: string]: mixed }*/
  599. = {
  600. // Defaults
  601. IS_NODE: typeof process !== 'undefined' && !!process.versions && !!process.versions.node && !process.versions.electron,
  602. REQUEST_ATTEMPT_LIMIT: 5,
  603. REQUEST_BATCH_SIZE: 20,
  604. REQUEST_HEADERS: {},
  605. SERVER_URL: 'https://api.parse.com/1',
  606. SERVER_AUTH_TYPE: null,
  607. SERVER_AUTH_TOKEN: null,
  608. LIVEQUERY_SERVER_URL: null,
  609. ENCRYPTED_KEY: null,
  610. VERSION: "js".concat("1.5.9"),
  611. APPLICATION_ID: null,
  612. JAVASCRIPT_KEY: null,
  613. MASTER_KEY: null,
  614. USE_MASTER_KEY: false,
  615. PERFORM_USER_REWRITE: true,
  616. FORCE_REVOCABLE_SESSION: false,
  617. ENCRYPTED_USER: false,
  618. IDEMPOTENCY: false
  619. };
  620. function requireMethods(name
  621. /*: string*/
  622. , methods
  623. /*: Array<string>*/
  624. , controller
  625. /*: any*/
  626. ) {
  627. (0, _forEach.default)(methods).call(methods, function (func) {
  628. if (typeof controller[func] !== 'function') {
  629. var _context;
  630. throw new Error((0, _concat.default)(_context = "".concat(name, " must implement ")).call(_context, func, "()"));
  631. }
  632. });
  633. }
  634. module.exports = {
  635. get: function (key
  636. /*: string*/
  637. )
  638. /*: any*/
  639. {
  640. if (config.hasOwnProperty(key)) {
  641. return config[key];
  642. }
  643. throw new Error("Configuration key not found: ".concat(key));
  644. },
  645. set: function (key
  646. /*: string*/
  647. , value
  648. /*: any*/
  649. )
  650. /*: void*/
  651. {
  652. config[key] = value;
  653. },
  654. /* Specialized Controller Setters/Getters */
  655. setAnalyticsController: function (controller
  656. /*: AnalyticsController*/
  657. ) {
  658. requireMethods('AnalyticsController', ['track'], controller);
  659. config.AnalyticsController = controller;
  660. },
  661. getAnalyticsController: function ()
  662. /*: AnalyticsController*/
  663. {
  664. return config.AnalyticsController;
  665. },
  666. setCloudController: function (controller
  667. /*: CloudController*/
  668. ) {
  669. requireMethods('CloudController', ['run', 'getJobsData', 'startJob'], controller);
  670. config.CloudController = controller;
  671. },
  672. getCloudController: function ()
  673. /*: CloudController*/
  674. {
  675. return config.CloudController;
  676. },
  677. setConfigController: function (controller
  678. /*: ConfigController*/
  679. ) {
  680. requireMethods('ConfigController', ['current', 'get', 'save'], controller);
  681. config.ConfigController = controller;
  682. },
  683. getConfigController: function ()
  684. /*: ConfigController*/
  685. {
  686. return config.ConfigController;
  687. },
  688. setCryptoController: function (controller
  689. /*: CryptoController*/
  690. ) {
  691. requireMethods('CryptoController', ['encrypt', 'decrypt'], controller);
  692. config.CryptoController = controller;
  693. },
  694. getCryptoController: function ()
  695. /*: CryptoController*/
  696. {
  697. return config.CryptoController;
  698. },
  699. setFileController: function (controller
  700. /*: FileController*/
  701. ) {
  702. requireMethods('FileController', ['saveFile', 'saveBase64'], controller);
  703. config.FileController = controller;
  704. },
  705. getFileController: function ()
  706. /*: FileController*/
  707. {
  708. return config.FileController;
  709. },
  710. setInstallationController: function (controller
  711. /*: InstallationController*/
  712. ) {
  713. requireMethods('InstallationController', ['currentInstallationId'], controller);
  714. config.InstallationController = controller;
  715. },
  716. getInstallationController: function ()
  717. /*: InstallationController*/
  718. {
  719. return config.InstallationController;
  720. },
  721. setObjectController: function (controller
  722. /*: ObjectController*/
  723. ) {
  724. requireMethods('ObjectController', ['save', 'fetch', 'destroy'], controller);
  725. config.ObjectController = controller;
  726. },
  727. getObjectController: function ()
  728. /*: ObjectController*/
  729. {
  730. return config.ObjectController;
  731. },
  732. setObjectStateController: function (controller
  733. /*: ObjectStateController*/
  734. ) {
  735. requireMethods('ObjectStateController', ['getState', 'initializeState', 'removeState', 'getServerData', 'setServerData', 'getPendingOps', 'setPendingOp', 'pushPendingState', 'popPendingState', 'mergeFirstPendingState', 'getObjectCache', 'estimateAttribute', 'estimateAttributes', 'commitServerChanges', 'enqueueTask', 'clearAllState'], controller);
  736. config.ObjectStateController = controller;
  737. },
  738. getObjectStateController: function ()
  739. /*: ObjectStateController*/
  740. {
  741. return config.ObjectStateController;
  742. },
  743. setPushController: function (controller
  744. /*: PushController*/
  745. ) {
  746. requireMethods('PushController', ['send'], controller);
  747. config.PushController = controller;
  748. },
  749. getPushController: function ()
  750. /*: PushController*/
  751. {
  752. return config.PushController;
  753. },
  754. setQueryController: function (controller
  755. /*: QueryController*/
  756. ) {
  757. requireMethods('QueryController', ['find', 'aggregate'], controller);
  758. config.QueryController = controller;
  759. },
  760. getQueryController: function ()
  761. /*: QueryController*/
  762. {
  763. return config.QueryController;
  764. },
  765. setRESTController: function (controller
  766. /*: RESTController*/
  767. ) {
  768. requireMethods('RESTController', ['request', 'ajax'], controller);
  769. config.RESTController = controller;
  770. },
  771. getRESTController: function ()
  772. /*: RESTController*/
  773. {
  774. return config.RESTController;
  775. },
  776. setSchemaController: function (controller
  777. /*: SchemaController*/
  778. ) {
  779. requireMethods('SchemaController', ['get', 'create', 'update', 'delete', 'send', 'purge'], controller);
  780. config.SchemaController = controller;
  781. },
  782. getSchemaController: function ()
  783. /*: SchemaController*/
  784. {
  785. return config.SchemaController;
  786. },
  787. setSessionController: function (controller
  788. /*: SessionController*/
  789. ) {
  790. requireMethods('SessionController', ['getSession'], controller);
  791. config.SessionController = controller;
  792. },
  793. getSessionController: function ()
  794. /*: SessionController*/
  795. {
  796. return config.SessionController;
  797. },
  798. setStorageController: function (controller
  799. /*: StorageController*/
  800. ) {
  801. if (controller.async) {
  802. requireMethods('An async StorageController', ['getItemAsync', 'setItemAsync', 'removeItemAsync', 'getAllKeysAsync'], controller);
  803. } else {
  804. requireMethods('A synchronous StorageController', ['getItem', 'setItem', 'removeItem', 'getAllKeys'], controller);
  805. }
  806. config.StorageController = controller;
  807. },
  808. setLocalDatastoreController: function (controller
  809. /*: LocalDatastoreController*/
  810. ) {
  811. requireMethods('LocalDatastoreController', ['pinWithName', 'fromPinWithName', 'unPinWithName', 'getAllContents', 'clear'], controller);
  812. config.LocalDatastoreController = controller;
  813. },
  814. getLocalDatastoreController: function ()
  815. /*: LocalDatastoreController*/
  816. {
  817. return config.LocalDatastoreController;
  818. },
  819. setLocalDatastore: function (store
  820. /*: any*/
  821. ) {
  822. config.LocalDatastore = store;
  823. },
  824. getLocalDatastore: function () {
  825. return config.LocalDatastore;
  826. },
  827. getStorageController: function ()
  828. /*: StorageController*/
  829. {
  830. return config.StorageController;
  831. },
  832. setAsyncStorage: function (storage
  833. /*: any*/
  834. ) {
  835. config.AsyncStorage = storage;
  836. },
  837. getAsyncStorage: function () {
  838. return config.AsyncStorage;
  839. },
  840. setWebSocketController: function (controller
  841. /*: WebSocketController*/
  842. ) {
  843. config.WebSocketController = controller;
  844. },
  845. getWebSocketController: function ()
  846. /*: WebSocketController*/
  847. {
  848. return config.WebSocketController;
  849. },
  850. setUserController: function (controller
  851. /*: UserController*/
  852. ) {
  853. requireMethods('UserController', ['setCurrentUser', 'currentUser', 'currentUserAsync', 'signUp', 'logIn', 'become', 'logOut', 'me', 'requestPasswordReset', 'upgradeToRevocableSession', 'requestEmailVerification', 'verifyPassword', 'linkWith'], controller);
  854. config.UserController = controller;
  855. },
  856. getUserController: function ()
  857. /*: UserController*/
  858. {
  859. return config.UserController;
  860. },
  861. setLiveQueryController: function (controller
  862. /*: any*/
  863. ) {
  864. requireMethods('LiveQueryController', ['setDefaultLiveQueryClient', 'getDefaultLiveQueryClient', '_clearCachedDefaultClient'], controller);
  865. config.LiveQueryController = controller;
  866. },
  867. getLiveQueryController: function ()
  868. /*: any*/
  869. {
  870. return config.LiveQueryController;
  871. },
  872. setHooksController: function (controller
  873. /*: HooksController*/
  874. ) {
  875. requireMethods('HooksController', ['create', 'get', 'update', 'remove'], controller);
  876. config.HooksController = controller;
  877. },
  878. getHooksController: function ()
  879. /*: HooksController*/
  880. {
  881. return config.HooksController;
  882. }
  883. };
  884. }).call(this)}).call(this,_dereq_('_process'))
  885. },{"@babel/runtime-corejs3/core-js-stable/instance/concat":81,"@babel/runtime-corejs3/core-js-stable/instance/for-each":86,"@babel/runtime-corejs3/helpers/interopRequireDefault":152,"_process":323}],6:[function(_dereq_,module,exports){
  886. "use strict";
  887. var _interopRequireDefault = _dereq_("@babel/runtime-corejs3/helpers/interopRequireDefault");
  888. var _stringify = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/json/stringify"));
  889. var AES;
  890. var ENC;
  891. AES = _dereq_('crypto-js/aes');
  892. ENC = _dereq_('crypto-js/enc-utf8');
  893. var CryptoJS;
  894. var CryptoController = {
  895. encrypt: function (obj
  896. /*: any*/
  897. , secretKey
  898. /*: string*/
  899. )
  900. /*: ?string*/
  901. {
  902. var encrypted = AES.encrypt((0, _stringify.default)(obj), secretKey);
  903. return encrypted.toString();
  904. },
  905. decrypt: function (encryptedText
  906. /*: string*/
  907. , secretKey
  908. /*: string*/
  909. )
  910. /*: ?string*/
  911. {
  912. var decryptedStr = AES.decrypt(encryptedText, secretKey).toString(ENC);
  913. return decryptedStr;
  914. }
  915. };
  916. module.exports = CryptoController;
  917. },{"@babel/runtime-corejs3/core-js-stable/json/stringify":99,"@babel/runtime-corejs3/helpers/interopRequireDefault":152,"crypto-js/aes":745,"crypto-js/enc-utf8":749}],7:[function(_dereq_,module,exports){
  918. "use strict";
  919. /**
  920. * Copyright (c) 2015-present, Parse, LLC.
  921. * All rights reserved.
  922. *
  923. * This source code is licensed under the BSD-style license found in the
  924. * LICENSE file in the root directory of this source tree. An additional grant
  925. * of patent rights can be found in the PATENTS file in the same directory.
  926. *
  927. * This is a simple wrapper to unify EventEmitter implementations across platforms.
  928. */
  929. module.exports = _dereq_('events').EventEmitter;
  930. var EventEmitter;
  931. },{"events":775}],8:[function(_dereq_,module,exports){
  932. "use strict";
  933. var _Object$defineProperty = _dereq_("@babel/runtime-corejs3/core-js-stable/object/define-property");
  934. var _interopRequireDefault = _dereq_("@babel/runtime-corejs3/helpers/interopRequireDefault");
  935. _Object$defineProperty(exports, "__esModule", {
  936. value: true
  937. });
  938. exports.default = void 0;
  939. var _ParseUser = _interopRequireDefault(_dereq_("./ParseUser"));
  940. /**
  941. * Copyright (c) 2015-present, Parse, LLC.
  942. * All rights reserved.
  943. *
  944. * This source code is licensed under the BSD-style license found in the
  945. * LICENSE file in the root directory of this source tree. An additional grant
  946. * of patent rights can be found in the PATENTS file in the same directory.
  947. *
  948. * @flow-weak
  949. */
  950. /* global FB */
  951. var initialized = false;
  952. var requestedPermissions;
  953. var initOptions;
  954. var provider = {
  955. authenticate: function (options) {
  956. var _this = this;
  957. if (typeof FB === 'undefined') {
  958. options.error(this, 'Facebook SDK not found.');
  959. }
  960. FB.login(function (response) {
  961. if (response.authResponse) {
  962. if (options.success) {
  963. options.success(_this, {
  964. id: response.authResponse.userID,
  965. access_token: response.authResponse.accessToken,
  966. expiration_date: new Date(response.authResponse.expiresIn * 1000 + new Date().getTime()).toJSON()
  967. });
  968. }
  969. } else {
  970. if (options.error) {
  971. options.error(_this, response);
  972. }
  973. }
  974. }, {
  975. scope: requestedPermissions
  976. });
  977. },
  978. restoreAuthentication: function (authData) {
  979. if (authData) {
  980. var newOptions = {};
  981. if (initOptions) {
  982. for (var key in initOptions) {
  983. newOptions[key] = initOptions[key];
  984. }
  985. } // Suppress checks for login status from the browser.
  986. newOptions.status = false; // If the user doesn't match the one known by the FB SDK, log out.
  987. // Most of the time, the users will match -- it's only in cases where
  988. // the FB SDK knows of a different user than the one being restored
  989. // from a Parse User that logged in with username/password.
  990. var existingResponse = FB.getAuthResponse();
  991. if (existingResponse && existingResponse.userID !== authData.id) {
  992. FB.logout();
  993. }
  994. FB.init(newOptions);
  995. }
  996. return true;
  997. },
  998. getAuthType: function () {
  999. return 'facebook';
  1000. },
  1001. deauthenticate: function () {
  1002. this.restoreAuthentication(null);
  1003. }
  1004. };
  1005. /**
  1006. * Provides a set of utilities for using Parse with Facebook.
  1007. *
  1008. * @class Parse.FacebookUtils
  1009. * @static
  1010. * @hideconstructor
  1011. */
  1012. var FacebookUtils = {
  1013. /**
  1014. * Initializes Parse Facebook integration. Call this function after you
  1015. * have loaded the Facebook Javascript SDK with the same parameters
  1016. * as you would pass to<code>
  1017. * <a href=
  1018. * "https://developers.facebook.com/docs/reference/javascript/FB.init/">
  1019. * FB.init()</a></code>. Parse.FacebookUtils will invoke FB.init() for you
  1020. * with these arguments.
  1021. *
  1022. * @function init
  1023. * @name Parse.FacebookUtils.init
  1024. * @param {object} options Facebook options argument as described here:
  1025. * <a href=
  1026. * "https://developers.facebook.com/docs/reference/javascript/FB.init/">
  1027. * FB.init()</a>. The status flag will be coerced to 'false' because it
  1028. * interferes with Parse Facebook integration. Call FB.getLoginStatus()
  1029. * explicitly if this behavior is required by your application.
  1030. */
  1031. init: function (options) {
  1032. if (typeof FB === 'undefined') {
  1033. throw new Error('The Facebook JavaScript SDK must be loaded before calling init.');
  1034. }
  1035. initOptions = {};
  1036. if (options) {
  1037. for (var key in options) {
  1038. initOptions[key] = options[key];
  1039. }
  1040. }
  1041. if (initOptions.status && typeof console !== 'undefined') {
  1042. var warn = console.warn || console.log || function () {}; // eslint-disable-line no-console
  1043. warn.call(console, 'The "status" flag passed into' + ' FB.init, when set to true, can interfere with Parse Facebook' + ' integration, so it has been suppressed. Please call' + ' FB.getLoginStatus() explicitly if you require this behavior.');
  1044. }
  1045. initOptions.status = false;
  1046. FB.init(initOptions);
  1047. _ParseUser.default._registerAuthenticationProvider(provider);
  1048. initialized = true;
  1049. },
  1050. /**
  1051. * Gets whether the user has their account linked to Facebook.
  1052. *
  1053. * @function isLinked
  1054. * @name Parse.FacebookUtils.isLinked
  1055. * @param {Parse.User} user User to check for a facebook link.
  1056. * The user must be logged in on this device.
  1057. * @returns {boolean} <code>true</code> if the user has their account
  1058. * linked to Facebook.
  1059. */
  1060. isLinked: function (user) {
  1061. return user._isLinked('facebook');
  1062. },
  1063. /**
  1064. * Logs in a user using Facebook. This method delegates to the Facebook
  1065. * SDK to authenticate the user, and then automatically logs in (or
  1066. * creates, in the case where it is a new user) a Parse.User.
  1067. *
  1068. * Standard API:
  1069. *
  1070. * <code>logIn(permission: string, authData: Object);</code>
  1071. *
  1072. * Advanced API: Used for handling your own oAuth tokens
  1073. * {@link https://docs.parseplatform.org/rest/guide/#linking-users}
  1074. *
  1075. * <code>logIn(authData: Object, options?: Object);</code>
  1076. *
  1077. * @function logIn
  1078. * @name Parse.FacebookUtils.logIn
  1079. * @param {(string | object)} permissions The permissions required for Facebook
  1080. * log in. This is a comma-separated string of permissions.
  1081. * Alternatively, supply a Facebook authData object as described in our
  1082. * REST API docs if you want to handle getting facebook auth tokens
  1083. * yourself.
  1084. * @param {object} options MasterKey / SessionToken. Alternatively can be used for authData if permissions is a string
  1085. * @returns {Promise}
  1086. */
  1087. logIn: function (permissions, options) {
  1088. if (!permissions || typeof permissions === 'string') {
  1089. if (!initialized) {
  1090. throw new Error('You must initialize FacebookUtils before calling logIn.');
  1091. }
  1092. requestedPermissions = permissions;
  1093. return _ParseUser.default.logInWith('facebook', options);
  1094. }
  1095. return _ParseUser.default.logInWith('facebook', {
  1096. authData: permissions
  1097. }, options);
  1098. },
  1099. /**
  1100. * Links Facebook to an existing PFUser. This method delegates to the
  1101. * Facebook SDK to authenticate the user, and then automatically links
  1102. * the account to the Parse.User.
  1103. *
  1104. * Standard API:
  1105. *
  1106. * <code>link(user: Parse.User, permission: string, authData?: Object);</code>
  1107. *
  1108. * Advanced API: Used for handling your own oAuth tokens
  1109. * {@link https://docs.parseplatform.org/rest/guide/#linking-users}
  1110. *
  1111. * <code>link(user: Parse.User, authData: Object, options?: FullOptions);</code>
  1112. *
  1113. * @function link
  1114. * @name Parse.FacebookUtils.link
  1115. * @param {Parse.User} user User to link to Facebook. This must be the
  1116. * current user.
  1117. * @param {(string | object)} permissions The permissions required for Facebook
  1118. * log in. This is a comma-separated string of permissions.
  1119. * Alternatively, supply a Facebook authData object as described in our
  1120. * REST API docs if you want to handle getting facebook auth tokens
  1121. * yourself.
  1122. * @param {object} options MasterKey / SessionToken. Alternatively can be used for authData if permissions is a string
  1123. * @returns {Promise}
  1124. */
  1125. link: function (user, permissions, options) {
  1126. if (!permissions || typeof permissions === 'string') {
  1127. if (!initialized) {
  1128. throw new Error('You must initialize FacebookUtils before calling link.');
  1129. }
  1130. requestedPermissions = permissions;
  1131. return user.linkWith('facebook', options);
  1132. }
  1133. return user.linkWith('facebook', {
  1134. authData: permissions
  1135. }, options);
  1136. },
  1137. /**
  1138. * Unlinks the Parse.User from a Facebook account.
  1139. *
  1140. * @function unlink
  1141. * @name Parse.FacebookUtils.unlink
  1142. * @param {Parse.User} user User to unlink from Facebook. This must be the
  1143. * current user.
  1144. * @param {object} options Standard options object with success and error
  1145. * callbacks.
  1146. * @returns {Promise}
  1147. */
  1148. unlink: function (user, options) {
  1149. if (!initialized) {
  1150. throw new Error('You must initialize FacebookUtils before calling unlink.');
  1151. }
  1152. return user._unlinkFrom('facebook', options);
  1153. },
  1154. // Used for testing purposes
  1155. _getAuthProvider: function () {
  1156. return provider;
  1157. }
  1158. };
  1159. var _default = FacebookUtils;
  1160. exports.default = _default;
  1161. },{"./ParseUser":44,"@babel/runtime-corejs3/core-js-stable/object/define-property":105,"@babel/runtime-corejs3/helpers/interopRequireDefault":152}],9:[function(_dereq_,module,exports){
  1162. "use strict";
  1163. var _interopRequireDefault = _dereq_("@babel/runtime-corejs3/helpers/interopRequireDefault");
  1164. var _promise = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/promise"));
  1165. var _Storage = _interopRequireDefault(_dereq_("./Storage"));
  1166. /**
  1167. * Copyright (c) 2015-present, Parse, LLC.
  1168. * All rights reserved.
  1169. *
  1170. * This source code is licensed under the BSD-style license found in the
  1171. * LICENSE file in the root directory of this source tree. An additional grant
  1172. * of patent rights can be found in the PATENTS file in the same directory.
  1173. *
  1174. * @flow
  1175. */
  1176. var _require = _dereq_('uuid'),
  1177. uuidv4 = _require.v4;
  1178. var iidCache = null;
  1179. var InstallationController = {
  1180. currentInstallationId: function ()
  1181. /*: Promise<string>*/
  1182. {
  1183. if (typeof iidCache === 'string') {
  1184. return _promise.default.resolve(iidCache);
  1185. }
  1186. var path = _Storage.default.generatePath('installationId');
  1187. return _Storage.default.getItemAsync(path).then(function (iid) {
  1188. if (!iid) {
  1189. iid = uuidv4();
  1190. return _Storage.default.setItemAsync(path, iid).then(function () {
  1191. iidCache = iid;
  1192. return iid;
  1193. });
  1194. }
  1195. iidCache = iid;
  1196. return iid;
  1197. });
  1198. },
  1199. _clearCache: function () {
  1200. iidCache = null;
  1201. },
  1202. _setInstallationIdCache: function (iid
  1203. /*: string*/
  1204. ) {
  1205. iidCache = iid;
  1206. }
  1207. };
  1208. module.exports = InstallationController;
  1209. },{"./Storage":48,"@babel/runtime-corejs3/core-js-stable/promise":115,"@babel/runtime-corejs3/helpers/interopRequireDefault":152,"uuid":797}],10:[function(_dereq_,module,exports){
  1210. "use strict";
  1211. var _Reflect$construct = _dereq_("@babel/runtime-corejs3/core-js-stable/reflect/construct");
  1212. var _Object$defineProperty = _dereq_("@babel/runtime-corejs3/core-js-stable/object/define-property");
  1213. var _interopRequireDefault = _dereq_("@babel/runtime-corejs3/helpers/interopRequireDefault");
  1214. _Object$defineProperty(exports, "__esModule", {
  1215. value: true
  1216. });
  1217. exports.default = exports.InternalWeb3Events = void 0;
  1218. var _regenerator = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/regenerator"));
  1219. var _asyncToGenerator2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/helpers/asyncToGenerator"));
  1220. var _classCallCheck2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/helpers/classCallCheck"));
  1221. var _createClass2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/helpers/createClass"));
  1222. var _assertThisInitialized2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/helpers/assertThisInitialized"));
  1223. var _inherits2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/helpers/inherits"));
  1224. var _possibleConstructorReturn2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/helpers/possibleConstructorReturn"));
  1225. var _getPrototypeOf2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/helpers/getPrototypeOf"));
  1226. var _freeze = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/object/freeze"));
  1227. var _bind = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/instance/bind"));
  1228. var _events = _interopRequireDefault(_dereq_("events"));
  1229. var _events2 = _dereq_("./Web3Connector/events");
  1230. var _ethers = _dereq_("ethers");
  1231. var _convert = _dereq_("./utils/convert");
  1232. function _createSuper(Derived) {
  1233. var hasNativeReflectConstruct = _isNativeReflectConstruct();
  1234. return function () {
  1235. var Super = (0, _getPrototypeOf2.default)(Derived),
  1236. result;
  1237. if (hasNativeReflectConstruct) {
  1238. var NewTarget = (0, _getPrototypeOf2.default)(this).constructor;
  1239. result = _Reflect$construct(Super, arguments, NewTarget);
  1240. } else {
  1241. result = Super.apply(this, arguments);
  1242. }
  1243. return (0, _possibleConstructorReturn2.default)(this, result);
  1244. };
  1245. }
  1246. function _isNativeReflectConstruct() {
  1247. if (typeof Reflect === "undefined" || !_Reflect$construct) return false;
  1248. if (_Reflect$construct.sham) return false;
  1249. if (typeof Proxy === "function") return true;
  1250. try {
  1251. Boolean.prototype.valueOf.call(_Reflect$construct(Boolean, [], function () {}));
  1252. return true;
  1253. } catch (e) {
  1254. return false;
  1255. }
  1256. } // Events emitted by Moralis
  1257. var InternalWeb3Events = (0, _freeze.default)({
  1258. ACCOUNT_CHANGED: 'accountChanged',
  1259. CHAIN_CHANGED: 'chainChanged',
  1260. PROVIDER_CONNECT: 'provider-connect',
  1261. PROVIDER_DISCONNECT: 'provider-disconnect',
  1262. WEB3_ENABLED: 'web3Enabled',
  1263. WEB3_DEACTIVATED: 'web3Deactivated'
  1264. });
  1265. /**
  1266. * Wrapper for the internal web3 provider,
  1267. * responsible for syncing data when connector connects/deactivates
  1268. * Gives access to ethers functionalities, initialized by the connector
  1269. */
  1270. exports.InternalWeb3Events = InternalWeb3Events;
  1271. var InternalWeb3Provider = /*#__PURE__*/function (_EventEmitter) {
  1272. (0, _inherits2.default)(InternalWeb3Provider, _EventEmitter);
  1273. var _super = _createSuper(InternalWeb3Provider);
  1274. function InternalWeb3Provider(connector) {
  1275. var _context, _context2, _context3, _context4;
  1276. var _this;
  1277. var anyNetwork = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
  1278. var privateKey = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : null;
  1279. (0, _classCallCheck2.default)(this, InternalWeb3Provider);
  1280. _this = _super.call(this);
  1281. if (!connector) {
  1282. throw new Error('Cannot initialize InternalWeb3Provider without a connector');
  1283. }
  1284. _this.connector = connector;
  1285. _this.anyNetwork = anyNetwork;
  1286. _this.privateKey = privateKey;
  1287. _this.handleAccountChanged = (0, _bind.default)(_context = _this.handleAccountChanged).call(_context, (0, _assertThisInitialized2.default)(_this));
  1288. _this.handleChainChanged = (0, _bind.default)(_context2 = _this.handleChainChanged).call(_context2, (0, _assertThisInitialized2.default)(_this));
  1289. _this.handleConnect = (0, _bind.default)(_context3 = _this.handleConnect).call(_context3, (0, _assertThisInitialized2.default)(_this));
  1290. _this.handleDisconnect = (0, _bind.default)(_context4 = _this.handleDisconnect).call(_context4, (0, _assertThisInitialized2.default)(_this));
  1291. return _this;
  1292. }
  1293. (0, _createClass2.default)(InternalWeb3Provider, [{
  1294. key: "activate",
  1295. value: function () {
  1296. var _activate = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee(options) {
  1297. var _yield$this$connector, provider, chainId, account, network;
  1298. return _regenerator.default.wrap(function (_context5) {
  1299. while (1) {
  1300. switch (_context5.prev = _context5.next) {
  1301. case 0:
  1302. if (this.connector) {
  1303. _context5.next = 2;
  1304. break;
  1305. }
  1306. throw new Error('Cannot acticate InternalWeb3Provider without a connector');
  1307. case 2:
  1308. _context5.next = 4;
  1309. return this.connector.activate(options);
  1310. case 4:
  1311. _yield$this$connector = _context5.sent;
  1312. provider = _yield$this$connector.provider;
  1313. chainId = _yield$this$connector.chainId;
  1314. account = _yield$this$connector.account;
  1315. this.provider = provider;
  1316. this.chainId = chainId;
  1317. this.account = account;
  1318. network = this.anyNetwork ? 'any' : (0, _convert.fromHexToDecimal)(chainId);
  1319. this.web3 = new _ethers.ethers.providers.Web3Provider(provider, network);
  1320. if (this.connector.on) {
  1321. this.connector.on(_events2.ConnectorEvents.ACCOUNT_CHANGED, this.handleAccountChanged);
  1322. this.connector.on(_events2.ConnectorEvents.CHAIN_CHANGED, this.handleChainChanged);
  1323. this.connector.on(_events2.ConnectorEvents.CONNECT, this.handleConnect);
  1324. this.connector.on(_events2.ConnectorEvents.DISCONNECT, this.handleDisconnect);
  1325. }
  1326. return _context5.abrupt("return", {
  1327. provider: provider,
  1328. chainId: chainId,
  1329. account: account,
  1330. web3: this.web3
  1331. });
  1332. case 15:
  1333. case "end":
  1334. return _context5.stop();
  1335. }
  1336. }
  1337. }, _callee, this);
  1338. }));
  1339. return function () {
  1340. return _activate.apply(this, arguments);
  1341. };
  1342. }() // Returns a provider (or wallet if a privateKey is provided) that can sign messages (throws if not possible, ie. the account cannot sign)
  1343. }, {
  1344. key: "signer",
  1345. get: function () {
  1346. return this.privateKey != null ? new _ethers.ethers.Wallet(this.privateKey, this.web3) : this.web3.getSigner(this.account);
  1347. } // Returns a provider (or wallet if a privateKey is provided) that can sign messages or the normal web3 provider as fallback
  1348. }, {
  1349. key: "signerOrProvider",
  1350. get: function () {
  1351. try {
  1352. if (this.account) {
  1353. return this.privateKey != null ? new _ethers.ethers.Wallet(this.privateKey, this.web3) : this.web3.getSigner(this.account);
  1354. }
  1355. return this.web3;
  1356. } catch (error) {
  1357. return this.web3;
  1358. }
  1359. }
  1360. }, {
  1361. key: "handleChainChanged",
  1362. value: function (chainId) {
  1363. this.chainId = chainId;
  1364. this.web3 = new _ethers.ethers.providers.Web3Provider(this.provider, (0, _convert.fromHexToDecimal)(chainId));
  1365. this.emit(InternalWeb3Events.CHAIN_CHANGED, chainId);
  1366. }
  1367. }, {
  1368. key: "handleAccountChanged",
  1369. value: function (account) {
  1370. this.account = account;
  1371. this.emit(InternalWeb3Events.ACCOUNT_CHANGED, account);
  1372. } // Handle Connect events fired from connectors
  1373. }, {
  1374. key: "handleConnect",
  1375. value: function (connectInfo) {
  1376. this.emit(InternalWeb3Events.PROVIDER_CONNECT, connectInfo);
  1377. } // Handle Disconnect events fired from connectors
  1378. }, {
  1379. key: "handleDisconnect",
  1380. value: function (error) {
  1381. this.emit(InternalWeb3Events.PROVIDER_DISCONNECT, error);
  1382. }
  1383. }, {
  1384. key: "deactivate",
  1385. value: function () {
  1386. var _deactivate = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee2() {
  1387. return _regenerator.default.wrap(function (_context6) {
  1388. while (1) {
  1389. switch (_context6.prev = _context6.next) {
  1390. case 0:
  1391. this.account = null;
  1392. this.chianId = null;
  1393. this.web3 = null;
  1394. this.provider = null;
  1395. this.privateKey = null;
  1396. if (!this.connector) {
  1397. _context6.next = 10;
  1398. break;
  1399. }
  1400. if (this.connector.removeListener) {
  1401. this.connector.removeListener(InternalWeb3Events.CHAIN_CHANGED, this.handleChainChanged);
  1402. this.connector.removeListener(InternalWeb3Events.ACCOUNT_CHANGED, this.handleAccountChanged);
  1403. this.connector.removeListener(InternalWeb3Events.PROVIDER_CONNECT, this.handleConnect);
  1404. this.connector.removeListener(InternalWeb3Events.PROVIDER_DISCONNECT, this.handleDisconnect);
  1405. }
  1406. if (!this.connector.deactivate) {
  1407. _context6.next = 10;
  1408. break;
  1409. }
  1410. _context6.next = 10;
  1411. return this.connector.deactivate();
  1412. case 10:
  1413. this.connector = null;
  1414. case 11:
  1415. case "end":
  1416. return _context6.stop();
  1417. }
  1418. }
  1419. }, _callee2, this);
  1420. }));
  1421. return function () {
  1422. return _deactivate.apply(this, arguments);
  1423. };
  1424. }()
  1425. }]);
  1426. return InternalWeb3Provider;
  1427. }(_events.default);
  1428. var _default = InternalWeb3Provider;
  1429. exports.default = _default;
  1430. },{"./Web3Connector/events":61,"./utils/convert":76,"@babel/runtime-corejs3/core-js-stable/instance/bind":80,"@babel/runtime-corejs3/core-js-stable/object/define-property":105,"@babel/runtime-corejs3/core-js-stable/object/freeze":107,"@babel/runtime-corejs3/core-js-stable/reflect/construct":116,"@babel/runtime-corejs3/helpers/assertThisInitialized":143,"@babel/runtime-corejs3/helpers/asyncToGenerator":144,"@babel/runtime-corejs3/helpers/classCallCheck":145,"@babel/runtime-corejs3/helpers/createClass":147,"@babel/runtime-corejs3/helpers/getPrototypeOf":150,"@babel/runtime-corejs3/helpers/inherits":151,"@babel/runtime-corejs3/helpers/interopRequireDefault":152,"@babel/runtime-corejs3/helpers/possibleConstructorReturn":159,"@babel/runtime-corejs3/regenerator":167,"ethers":773,"events":775}],11:[function(_dereq_,module,exports){
  1431. "use strict";
  1432. var _Reflect$construct = _dereq_("@babel/runtime-corejs3/core-js-stable/reflect/construct");
  1433. var _sliceInstanceProperty = _dereq_("@babel/runtime-corejs3/core-js-stable/instance/slice");
  1434. var _Array$from = _dereq_("@babel/runtime-corejs3/core-js-stable/array/from");
  1435. var _Symbol = _dereq_("@babel/runtime-corejs3/core-js-stable/symbol");
  1436. var _getIteratorMethod = _dereq_("@babel/runtime-corejs3/core-js/get-iterator-method");
  1437. var _Array$isArray = _dereq_("@babel/runtime-corejs3/core-js-stable/array/is-array");
  1438. var _Object$defineProperty = _dereq_("@babel/runtime-corejs3/core-js-stable/object/define-property");
  1439. var _interopRequireDefault = _dereq_("@babel/runtime-corejs3/helpers/interopRequireDefault");
  1440. _Object$defineProperty(exports, "__esModule", {
  1441. value: true
  1442. });
  1443. exports.default = void 0;
  1444. var _indexOf = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/instance/index-of"));
  1445. var _map = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/map"));
  1446. var _keys = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/instance/keys"));
  1447. var _stringify = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/json/stringify"));
  1448. var _forEach = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/instance/for-each"));
  1449. var _values = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/instance/values"));
  1450. var _setTimeout2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/set-timeout"));
  1451. var _bind = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/instance/bind"));
  1452. var _typeof2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/helpers/typeof"));
  1453. var _classCallCheck2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/helpers/classCallCheck"));
  1454. var _createClass2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/helpers/createClass"));
  1455. var _assertThisInitialized2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/helpers/assertThisInitialized"));
  1456. var _inherits2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/helpers/inherits"));
  1457. var _possibleConstructorReturn2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/helpers/possibleConstructorReturn"));
  1458. var _getPrototypeOf2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/helpers/getPrototypeOf"));
  1459. var _defineProperty2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/helpers/defineProperty"));
  1460. var _CoreManager = _interopRequireDefault(_dereq_("./CoreManager"));
  1461. var _EventEmitter2 = _interopRequireDefault(_dereq_("./EventEmitter"));
  1462. var _ParseObject = _interopRequireDefault(_dereq_("./ParseObject"));
  1463. var _LiveQuerySubscription = _interopRequireDefault(_dereq_("./LiveQuerySubscription"));
  1464. var _promiseUtils = _dereq_("./promiseUtils");
  1465. function _createForOfIteratorHelper(o, allowArrayLike) {
  1466. var it = typeof _Symbol !== "undefined" && _getIteratorMethod(o) || o["@@iterator"];
  1467. if (!it) {
  1468. if (_Array$isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") {
  1469. if (it) o = it;
  1470. var i = 0;
  1471. var F = function () {};
  1472. return {
  1473. s: F,
  1474. n: function () {
  1475. if (i >= o.length) return {
  1476. done: true
  1477. };
  1478. return {
  1479. done: false,
  1480. value: o[i++]
  1481. };
  1482. },
  1483. e: function (_e) {
  1484. throw _e;
  1485. },
  1486. f: F
  1487. };
  1488. }
  1489. throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
  1490. }
  1491. var normalCompletion = true,
  1492. didErr = false,
  1493. err;
  1494. return {
  1495. s: function () {
  1496. it = it.call(o);
  1497. },
  1498. n: function () {
  1499. var step = it.next();
  1500. normalCompletion = step.done;
  1501. return step;
  1502. },
  1503. e: function (_e2) {
  1504. didErr = true;
  1505. err = _e2;
  1506. },
  1507. f: function () {
  1508. try {
  1509. if (!normalCompletion && it.return != null) it.return();
  1510. } finally {
  1511. if (didErr) throw err;
  1512. }
  1513. }
  1514. };
  1515. }
  1516. function _unsupportedIterableToArray(o, minLen) {
  1517. var _context6;
  1518. if (!o) return;
  1519. if (typeof o === "string") return _arrayLikeToArray(o, minLen);
  1520. var n = _sliceInstanceProperty(_context6 = Object.prototype.toString.call(o)).call(_context6, 8, -1);
  1521. if (n === "Object" && o.constructor) n = o.constructor.name;
  1522. if (n === "Map" || n === "Set") return _Array$from(o);
  1523. if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen);
  1524. }
  1525. function _arrayLikeToArray(arr, len) {
  1526. if (len == null || len > arr.length) len = arr.length;
  1527. for (var i = 0, arr2 = new Array(len); i < len; i++) {
  1528. arr2[i] = arr[i];
  1529. }
  1530. return arr2;
  1531. }
  1532. function _createSuper(Derived) {
  1533. var hasNativeReflectConstruct = _isNativeReflectConstruct();
  1534. return function () {
  1535. var Super = (0, _getPrototypeOf2.default)(Derived),
  1536. result;
  1537. if (hasNativeReflectConstruct) {
  1538. var NewTarget = (0, _getPrototypeOf2.default)(this).constructor;
  1539. result = _Reflect$construct(Super, arguments, NewTarget);
  1540. } else {
  1541. result = Super.apply(this, arguments);
  1542. }
  1543. return (0, _possibleConstructorReturn2.default)(this, result);
  1544. };
  1545. }
  1546. function _isNativeReflectConstruct() {
  1547. if (typeof Reflect === "undefined" || !_Reflect$construct) return false;
  1548. if (_Reflect$construct.sham) return false;
  1549. if (typeof Proxy === "function") return true;
  1550. try {
  1551. Boolean.prototype.valueOf.call(_Reflect$construct(Boolean, [], function () {}));
  1552. return true;
  1553. } catch (e) {
  1554. return false;
  1555. }
  1556. } // The LiveQuery client inner state
  1557. var CLIENT_STATE = {
  1558. INITIALIZED: 'initialized',
  1559. CONNECTING: 'connecting',
  1560. CONNECTED: 'connected',
  1561. CLOSED: 'closed',
  1562. RECONNECTING: 'reconnecting',
  1563. DISCONNECTED: 'disconnected'
  1564. }; // The event type the LiveQuery client should sent to server
  1565. var OP_TYPES = {
  1566. CONNECT: 'connect',
  1567. SUBSCRIBE: 'subscribe',
  1568. UNSUBSCRIBE: 'unsubscribe',
  1569. ERROR: 'error'
  1570. }; // The event we get back from LiveQuery server
  1571. var OP_EVENTS = {
  1572. CONNECTED: 'connected',
  1573. SUBSCRIBED: 'subscribed',
  1574. UNSUBSCRIBED: 'unsubscribed',
  1575. ERROR: 'error',
  1576. CREATE: 'create',
  1577. UPDATE: 'update',
  1578. ENTER: 'enter',
  1579. LEAVE: 'leave',
  1580. DELETE: 'delete'
  1581. }; // The event the LiveQuery client should emit
  1582. var CLIENT_EMMITER_TYPES = {
  1583. CLOSE: 'close',
  1584. ERROR: 'error',
  1585. OPEN: 'open'
  1586. }; // The event the LiveQuery subscription should emit
  1587. var SUBSCRIPTION_EMMITER_TYPES = {
  1588. OPEN: 'open',
  1589. CLOSE: 'close',
  1590. ERROR: 'error',
  1591. CREATE: 'create',
  1592. UPDATE: 'update',
  1593. ENTER: 'enter',
  1594. LEAVE: 'leave',
  1595. DELETE: 'delete'
  1596. };
  1597. var generateInterval = function (k) {
  1598. return Math.random() * Math.min(30, Math.pow(2, k) - 1) * 1000;
  1599. };
  1600. /**
  1601. * Creates a new LiveQueryClient.
  1602. * Extends events.EventEmitter
  1603. * <a href="https://nodejs.org/api/events.html#events_class_eventemitter">cloud functions</a>.
  1604. *
  1605. * A wrapper of a standard WebSocket client. We add several useful methods to
  1606. * help you connect/disconnect to LiveQueryServer, subscribe/unsubscribe a ParseQuery easily.
  1607. *
  1608. * javascriptKey and masterKey are used for verifying the LiveQueryClient when it tries
  1609. * to connect to the LiveQuery server
  1610. *
  1611. * We expose three events to help you monitor the status of the LiveQueryClient.
  1612. *
  1613. * <pre>
  1614. * let Parse = require('parse/node');
  1615. * let LiveQueryClient = Parse.LiveQueryClient;
  1616. * let client = new LiveQueryClient({
  1617. * applicationId: '',
  1618. * serverURL: '',
  1619. * javascriptKey: '',
  1620. * masterKey: ''
  1621. * });
  1622. * </pre>
  1623. *
  1624. * Open - When we establish the WebSocket connection to the LiveQuery server, you'll get this event.
  1625. * <pre>
  1626. * client.on('open', () => {
  1627. *
  1628. * });</pre>
  1629. *
  1630. * Close - When we lose the WebSocket connection to the LiveQuery server, you'll get this event.
  1631. * <pre>
  1632. * client.on('close', () => {
  1633. *
  1634. * });</pre>
  1635. *
  1636. * Error - When some network error or LiveQuery server error happens, you'll get this event.
  1637. * <pre>
  1638. * client.on('error', (error) => {
  1639. *
  1640. * });</pre>
  1641. *
  1642. * @alias Parse.LiveQueryClient
  1643. */
  1644. var LiveQueryClient = /*#__PURE__*/function (_EventEmitter) {
  1645. (0, _inherits2.default)(LiveQueryClient, _EventEmitter);
  1646. var _super = _createSuper(LiveQueryClient);
  1647. /**
  1648. * @param {object} options
  1649. * @param {string} options.applicationId - applicationId of your Parse app
  1650. * @param {string} options.serverURL - <b>the URL of your LiveQuery server</b>
  1651. * @param {string} options.javascriptKey (optional)
  1652. * @param {string} options.masterKey (optional) Your Parse Master Key. (Node.js only!)
  1653. * @param {string} options.sessionToken (optional)
  1654. * @param {string} options.installationId (optional)
  1655. */
  1656. function LiveQueryClient(_ref) {
  1657. var _this;
  1658. var applicationId = _ref.applicationId,
  1659. serverURL = _ref.serverURL,
  1660. javascriptKey = _ref.javascriptKey,
  1661. masterKey = _ref.masterKey,
  1662. sessionToken = _ref.sessionToken,
  1663. installationId = _ref.installationId;
  1664. (0, _classCallCheck2.default)(this, LiveQueryClient);
  1665. _this = _super.call(this);
  1666. (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "attempts", void 0);
  1667. (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "id", void 0);
  1668. (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "requestId", void 0);
  1669. (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "applicationId", void 0);
  1670. (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "serverURL", void 0);
  1671. (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "javascriptKey", void 0);
  1672. (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "masterKey", void 0);
  1673. (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "sessionToken", void 0);
  1674. (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "installationId", void 0);
  1675. (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "additionalProperties", void 0);
  1676. (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "connectPromise", void 0);
  1677. (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "subscriptions", void 0);
  1678. (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "socket", void 0);
  1679. (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "state", void 0);
  1680. if (!serverURL || (0, _indexOf.default)(serverURL).call(serverURL, 'ws') !== 0) {
  1681. throw new Error('You need to set a proper Parse LiveQuery server url before using LiveQueryClient');
  1682. }
  1683. _this.reconnectHandle = null;
  1684. _this.attempts = 1;
  1685. _this.id = 0;
  1686. _this.requestId = 1;
  1687. _this.serverURL = serverURL;
  1688. _this.applicationId = applicationId;
  1689. _this.javascriptKey = javascriptKey || undefined;
  1690. _this.masterKey = masterKey || undefined;
  1691. _this.sessionToken = sessionToken || undefined;
  1692. _this.installationId = installationId || undefined;
  1693. _this.additionalProperties = true;
  1694. _this.connectPromise = (0, _promiseUtils.resolvingPromise)();
  1695. _this.subscriptions = new _map.default();
  1696. _this.state = CLIENT_STATE.INITIALIZED; // adding listener so process does not crash
  1697. // best practice is for developer to register their own listener
  1698. _this.on('error', function () {});
  1699. return _this;
  1700. }
  1701. (0, _createClass2.default)(LiveQueryClient, [{
  1702. key: "shouldOpen",
  1703. value: function ()
  1704. /*: any*/
  1705. {
  1706. return this.state === CLIENT_STATE.INITIALIZED || this.state === CLIENT_STATE.DISCONNECTED;
  1707. }
  1708. /**
  1709. * Subscribes to a ParseQuery
  1710. *
  1711. * If you provide the sessionToken, when the LiveQuery server gets ParseObject's
  1712. * updates from parse server, it'll try to check whether the sessionToken fulfills
  1713. * the ParseObject's ACL. The LiveQuery server will only send updates to clients whose
  1714. * sessionToken is fit for the ParseObject's ACL. You can check the LiveQuery protocol
  1715. * <a href="https://github.com/parse-community/parse-server/wiki/Parse-LiveQuery-Protocol-Specification">here</a> for more details. The subscription you get is the same subscription you get
  1716. * from our Standard API.
  1717. *
  1718. * @param {object} query - the ParseQuery you want to subscribe to
  1719. * @param {string} sessionToken (optional)
  1720. * @returns {LiveQuerySubscription} subscription
  1721. */
  1722. }, {
  1723. key: "subscribe",
  1724. value: function (query
  1725. /*: Object*/
  1726. , sessionToken
  1727. /*: ?string*/
  1728. )
  1729. /*: LiveQuerySubscription*/
  1730. {
  1731. var _this2 = this;
  1732. if (!query) {
  1733. return;
  1734. }
  1735. var className = query.className;
  1736. var queryJSON = query.toJSON();
  1737. var where = queryJSON.where;
  1738. var fields = (0, _keys.default)(queryJSON) ? (0, _keys.default)(queryJSON).split(',') : undefined;
  1739. var subscribeRequest = {
  1740. op: OP_TYPES.SUBSCRIBE,
  1741. requestId: this.requestId,
  1742. query: {
  1743. className: className,
  1744. where: where,
  1745. fields: fields
  1746. }
  1747. };
  1748. if (sessionToken) {
  1749. subscribeRequest.sessionToken = sessionToken;
  1750. }
  1751. var subscription = new _LiveQuerySubscription.default(this.requestId, query, sessionToken);
  1752. this.subscriptions.set(this.requestId, subscription);
  1753. this.requestId += 1;
  1754. this.connectPromise.then(function () {
  1755. _this2.socket.send((0, _stringify.default)(subscribeRequest));
  1756. });
  1757. return subscription;
  1758. }
  1759. /**
  1760. * After calling unsubscribe you'll stop receiving events from the subscription object.
  1761. *
  1762. * @param {object} subscription - subscription you would like to unsubscribe from.
  1763. */
  1764. }, {
  1765. key: "unsubscribe",
  1766. value: function (subscription
  1767. /*: Object*/
  1768. ) {
  1769. var _this3 = this;
  1770. if (!subscription) {
  1771. return;
  1772. }
  1773. this.subscriptions.delete(subscription.id);
  1774. var unsubscribeRequest = {
  1775. op: OP_TYPES.UNSUBSCRIBE,
  1776. requestId: subscription.id
  1777. };
  1778. this.connectPromise.then(function () {
  1779. _this3.socket.send((0, _stringify.default)(unsubscribeRequest));
  1780. });
  1781. }
  1782. /**
  1783. * After open is called, the LiveQueryClient will try to send a connect request
  1784. * to the LiveQuery server.
  1785. *
  1786. */
  1787. }, {
  1788. key: "open",
  1789. value: function () {
  1790. var _this4 = this;
  1791. var WebSocketImplementation = _CoreManager.default.getWebSocketController();
  1792. if (!WebSocketImplementation) {
  1793. this.emit(CLIENT_EMMITER_TYPES.ERROR, 'Can not find WebSocket implementation');
  1794. return;
  1795. }
  1796. if (this.state !== CLIENT_STATE.RECONNECTING) {
  1797. this.state = CLIENT_STATE.CONNECTING;
  1798. }
  1799. this.socket = new WebSocketImplementation(this.serverURL); // Bind WebSocket callbacks
  1800. this.socket.onopen = function () {
  1801. _this4._handleWebSocketOpen();
  1802. };
  1803. this.socket.onmessage = function (event) {
  1804. _this4._handleWebSocketMessage(event);
  1805. };
  1806. this.socket.onclose = function () {
  1807. _this4._handleWebSocketClose();
  1808. };
  1809. this.socket.onerror = function (error) {
  1810. _this4._handleWebSocketError(error);
  1811. };
  1812. }
  1813. }, {
  1814. key: "resubscribe",
  1815. value: function () {
  1816. var _context,
  1817. _this5 = this;
  1818. (0, _forEach.default)(_context = this.subscriptions).call(_context, function (subscription, requestId) {
  1819. var query = subscription.query;
  1820. var queryJSON = query.toJSON();
  1821. var where = queryJSON.where;
  1822. var fields = (0, _keys.default)(queryJSON) ? (0, _keys.default)(queryJSON).split(',') : undefined;
  1823. var className = query.className;
  1824. var sessionToken = subscription.sessionToken;
  1825. var subscribeRequest = {
  1826. op: OP_TYPES.SUBSCRIBE,
  1827. requestId: requestId,
  1828. query: {
  1829. className: className,
  1830. where: where,
  1831. fields: fields
  1832. }
  1833. };
  1834. if (sessionToken) {
  1835. subscribeRequest.sessionToken = sessionToken;
  1836. }
  1837. _this5.connectPromise.then(function () {
  1838. _this5.socket.send((0, _stringify.default)(subscribeRequest));
  1839. });
  1840. });
  1841. }
  1842. /**
  1843. * This method will close the WebSocket connection to this LiveQueryClient,
  1844. * cancel the auto reconnect and unsubscribe all subscriptions based on it.
  1845. *
  1846. */
  1847. }, {
  1848. key: "close",
  1849. value: function () {
  1850. var _context2;
  1851. if (this.state === CLIENT_STATE.INITIALIZED || this.state === CLIENT_STATE.DISCONNECTED) {
  1852. return;
  1853. }
  1854. this.state = CLIENT_STATE.DISCONNECTED;
  1855. this.socket.close(); // Notify each subscription about the close
  1856. var _iterator = _createForOfIteratorHelper((0, _values.default)(_context2 = this.subscriptions).call(_context2)),
  1857. _step;
  1858. try {
  1859. for (_iterator.s(); !(_step = _iterator.n()).done;) {
  1860. var subscription = _step.value;
  1861. subscription.subscribed = false;
  1862. subscription.emit(SUBSCRIPTION_EMMITER_TYPES.CLOSE);
  1863. }
  1864. } catch (err) {
  1865. _iterator.e(err);
  1866. } finally {
  1867. _iterator.f();
  1868. }
  1869. this._handleReset();
  1870. this.emit(CLIENT_EMMITER_TYPES.CLOSE);
  1871. } // ensure we start with valid state if connect is called again after close
  1872. }, {
  1873. key: "_handleReset",
  1874. value: function () {
  1875. this.attempts = 1;
  1876. this.id = 0;
  1877. this.requestId = 1;
  1878. this.connectPromise = (0, _promiseUtils.resolvingPromise)();
  1879. this.subscriptions = new _map.default();
  1880. }
  1881. }, {
  1882. key: "_handleWebSocketOpen",
  1883. value: function () {
  1884. this.attempts = 1;
  1885. var connectRequest = {
  1886. op: OP_TYPES.CONNECT,
  1887. applicationId: this.applicationId,
  1888. javascriptKey: this.javascriptKey,
  1889. masterKey: this.masterKey,
  1890. sessionToken: this.sessionToken
  1891. };
  1892. if (this.additionalProperties) {
  1893. connectRequest.installationId = this.installationId;
  1894. }
  1895. this.socket.send((0, _stringify.default)(connectRequest));
  1896. }
  1897. }, {
  1898. key: "_handleWebSocketMessage",
  1899. value: function (event
  1900. /*: any*/
  1901. ) {
  1902. var data = event.data;
  1903. if (typeof data === 'string') {
  1904. data = JSON.parse(data);
  1905. }
  1906. var subscription = null;
  1907. if (data.requestId) {
  1908. subscription = this.subscriptions.get(data.requestId);
  1909. }
  1910. var response = {
  1911. clientId: data.clientId,
  1912. installationId: data.installationId
  1913. };
  1914. switch (data.op) {
  1915. case OP_EVENTS.CONNECTED:
  1916. if (this.state === CLIENT_STATE.RECONNECTING) {
  1917. this.resubscribe();
  1918. }
  1919. this.emit(CLIENT_EMMITER_TYPES.OPEN);
  1920. this.id = data.clientId;
  1921. this.connectPromise.resolve();
  1922. this.state = CLIENT_STATE.CONNECTED;
  1923. break;
  1924. case OP_EVENTS.SUBSCRIBED:
  1925. if (subscription) {
  1926. subscription.subscribed = true;
  1927. subscription.subscribePromise.resolve();
  1928. (0, _setTimeout2.default)(function () {
  1929. return subscription.emit(SUBSCRIPTION_EMMITER_TYPES.OPEN, response);
  1930. }, 200);
  1931. }
  1932. break;
  1933. case OP_EVENTS.ERROR:
  1934. if (data.requestId) {
  1935. if (subscription) {
  1936. subscription.subscribePromise.resolve();
  1937. (0, _setTimeout2.default)(function () {
  1938. return subscription.emit(SUBSCRIPTION_EMMITER_TYPES.ERROR, data.error);
  1939. }, 200);
  1940. }
  1941. } else {
  1942. this.emit(CLIENT_EMMITER_TYPES.ERROR, data.error);
  1943. }
  1944. if (data.error === 'Additional properties not allowed') {
  1945. this.additionalProperties = false;
  1946. }
  1947. if (data.reconnect) {
  1948. this._handleReconnect();
  1949. }
  1950. break;
  1951. case OP_EVENTS.UNSUBSCRIBED:
  1952. // We have already deleted subscription in unsubscribe(), do nothing here
  1953. break;
  1954. default:
  1955. {
  1956. // create, update, enter, leave, delete cases
  1957. if (!subscription) {
  1958. break;
  1959. }
  1960. var override = false;
  1961. if (data.original) {
  1962. override = true;
  1963. delete data.original.__type; // Check for removed fields
  1964. for (var field in data.original) {
  1965. if (!(field in data.object)) {
  1966. data.object[field] = undefined;
  1967. }
  1968. }
  1969. data.original = _ParseObject.default.fromJSON(data.original, false);
  1970. }
  1971. delete data.object.__type;
  1972. var parseObject = _ParseObject.default.fromJSON(data.object, override);
  1973. if (data.original) {
  1974. subscription.emit(data.op, parseObject, data.original, response);
  1975. } else {
  1976. subscription.emit(data.op, parseObject, response);
  1977. }
  1978. var localDatastore = _CoreManager.default.getLocalDatastore();
  1979. if (override && localDatastore.isEnabled) {
  1980. localDatastore._updateObjectIfPinned(parseObject).then(function () {});
  1981. }
  1982. }
  1983. }
  1984. }
  1985. }, {
  1986. key: "_handleWebSocketClose",
  1987. value: function () {
  1988. var _context3;
  1989. if (this.state === CLIENT_STATE.DISCONNECTED) {
  1990. return;
  1991. }
  1992. this.state = CLIENT_STATE.CLOSED;
  1993. this.emit(CLIENT_EMMITER_TYPES.CLOSE); // Notify each subscription about the close
  1994. var _iterator2 = _createForOfIteratorHelper((0, _values.default)(_context3 = this.subscriptions).call(_context3)),
  1995. _step2;
  1996. try {
  1997. for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
  1998. var subscription = _step2.value;
  1999. subscription.emit(SUBSCRIPTION_EMMITER_TYPES.CLOSE);
  2000. }
  2001. } catch (err) {
  2002. _iterator2.e(err);
  2003. } finally {
  2004. _iterator2.f();
  2005. }
  2006. this._handleReconnect();
  2007. }
  2008. }, {
  2009. key: "_handleWebSocketError",
  2010. value: function (error
  2011. /*: any*/
  2012. ) {
  2013. var _context4;
  2014. this.emit(CLIENT_EMMITER_TYPES.ERROR, error);
  2015. var _iterator3 = _createForOfIteratorHelper((0, _values.default)(_context4 = this.subscriptions).call(_context4)),
  2016. _step3;
  2017. try {
  2018. for (_iterator3.s(); !(_step3 = _iterator3.n()).done;) {
  2019. var subscription = _step3.value;
  2020. subscription.emit(SUBSCRIPTION_EMMITER_TYPES.ERROR, error);
  2021. }
  2022. } catch (err) {
  2023. _iterator3.e(err);
  2024. } finally {
  2025. _iterator3.f();
  2026. }
  2027. this._handleReconnect();
  2028. }
  2029. }, {
  2030. key: "_handleReconnect",
  2031. value: function () {
  2032. var _context5,
  2033. _this6 = this; // if closed or currently reconnecting we stop attempting to reconnect
  2034. if (this.state === CLIENT_STATE.DISCONNECTED) {
  2035. return;
  2036. }
  2037. this.state = CLIENT_STATE.RECONNECTING;
  2038. var time = generateInterval(this.attempts); // handle case when both close/error occur at frequent rates we ensure we do not reconnect unnecessarily.
  2039. // we're unable to distinguish different between close/error when we're unable to reconnect therefore
  2040. // we try to reconnect in both cases
  2041. // server side ws and browser WebSocket behave differently in when close/error get triggered
  2042. if (this.reconnectHandle) {
  2043. clearTimeout(this.reconnectHandle);
  2044. }
  2045. this.reconnectHandle = (0, _setTimeout2.default)((0, _bind.default)(_context5 = function () {
  2046. _this6.attempts++;
  2047. _this6.connectPromise = (0, _promiseUtils.resolvingPromise)();
  2048. _this6.open();
  2049. }).call(_context5, this), time);
  2050. }
  2051. }]);
  2052. return LiveQueryClient;
  2053. }(_EventEmitter2.default);
  2054. _CoreManager.default.setWebSocketController(typeof WebSocket === 'function' || (typeof WebSocket === "undefined" ? "undefined" : (0, _typeof2.default)(WebSocket)) === 'object' ? WebSocket : null);
  2055. var _default = LiveQueryClient;
  2056. exports.default = _default;
  2057. },{"./CoreManager":5,"./EventEmitter":7,"./LiveQuerySubscription":12,"./ParseObject":36,"./promiseUtils":72,"@babel/runtime-corejs3/core-js-stable/array/from":78,"@babel/runtime-corejs3/core-js-stable/array/is-array":79,"@babel/runtime-corejs3/core-js-stable/instance/bind":80,"@babel/runtime-corejs3/core-js-stable/instance/for-each":86,"@babel/runtime-corejs3/core-js-stable/instance/index-of":88,"@babel/runtime-corejs3/core-js-stable/instance/keys":89,"@babel/runtime-corejs3/core-js-stable/instance/slice":93,"@babel/runtime-corejs3/core-js-stable/instance/values":98,"@babel/runtime-corejs3/core-js-stable/json/stringify":99,"@babel/runtime-corejs3/core-js-stable/map":100,"@babel/runtime-corejs3/core-js-stable/object/define-property":105,"@babel/runtime-corejs3/core-js-stable/reflect/construct":116,"@babel/runtime-corejs3/core-js-stable/set-timeout":117,"@babel/runtime-corejs3/core-js-stable/symbol":119,"@babel/runtime-corejs3/core-js/get-iterator-method":125,"@babel/runtime-corejs3/helpers/assertThisInitialized":143,"@babel/runtime-corejs3/helpers/classCallCheck":145,"@babel/runtime-corejs3/helpers/createClass":147,"@babel/runtime-corejs3/helpers/defineProperty":148,"@babel/runtime-corejs3/helpers/getPrototypeOf":150,"@babel/runtime-corejs3/helpers/inherits":151,"@babel/runtime-corejs3/helpers/interopRequireDefault":152,"@babel/runtime-corejs3/helpers/possibleConstructorReturn":159,"@babel/runtime-corejs3/helpers/typeof":164}],12:[function(_dereq_,module,exports){
  2058. "use strict";
  2059. var _Reflect$construct = _dereq_("@babel/runtime-corejs3/core-js-stable/reflect/construct");
  2060. var _Object$defineProperty = _dereq_("@babel/runtime-corejs3/core-js-stable/object/define-property");
  2061. var _interopRequireDefault = _dereq_("@babel/runtime-corejs3/helpers/interopRequireDefault");
  2062. _Object$defineProperty(exports, "__esModule", {
  2063. value: true
  2064. });
  2065. exports.default = void 0;
  2066. var _classCallCheck2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/helpers/classCallCheck"));
  2067. var _createClass2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/helpers/createClass"));
  2068. var _inherits2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/helpers/inherits"));
  2069. var _possibleConstructorReturn2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/helpers/possibleConstructorReturn"));
  2070. var _getPrototypeOf2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/helpers/getPrototypeOf"));
  2071. var _EventEmitter2 = _interopRequireDefault(_dereq_("./EventEmitter"));
  2072. var _CoreManager = _interopRequireDefault(_dereq_("./CoreManager"));
  2073. var _promiseUtils = _dereq_("./promiseUtils");
  2074. function _createSuper(Derived) {
  2075. var hasNativeReflectConstruct = _isNativeReflectConstruct();
  2076. return function () {
  2077. var Super = (0, _getPrototypeOf2.default)(Derived),
  2078. result;
  2079. if (hasNativeReflectConstruct) {
  2080. var NewTarget = (0, _getPrototypeOf2.default)(this).constructor;
  2081. result = _Reflect$construct(Super, arguments, NewTarget);
  2082. } else {
  2083. result = Super.apply(this, arguments);
  2084. }
  2085. return (0, _possibleConstructorReturn2.default)(this, result);
  2086. };
  2087. }
  2088. function _isNativeReflectConstruct() {
  2089. if (typeof Reflect === "undefined" || !_Reflect$construct) return false;
  2090. if (_Reflect$construct.sham) return false;
  2091. if (typeof Proxy === "function") return true;
  2092. try {
  2093. Boolean.prototype.valueOf.call(_Reflect$construct(Boolean, [], function () {}));
  2094. return true;
  2095. } catch (e) {
  2096. return false;
  2097. }
  2098. }
  2099. /**
  2100. * Creates a new LiveQuery Subscription.
  2101. * Extends events.EventEmitter
  2102. * <a href="https://nodejs.org/api/events.html#events_class_eventemitter">cloud functions</a>.
  2103. *
  2104. * <p>Response Object - Contains data from the client that made the request
  2105. * <ul>
  2106. * <li>clientId</li>
  2107. * <li>installationId - requires Parse Server 4.0.0+</li>
  2108. * </ul>
  2109. * </p>
  2110. *
  2111. * <p>Open Event - When you call query.subscribe(), we send a subscribe request to
  2112. * the LiveQuery server, when we get the confirmation from the LiveQuery server,
  2113. * this event will be emitted. When the client loses WebSocket connection to the
  2114. * LiveQuery server, we will try to auto reconnect the LiveQuery server. If we
  2115. * reconnect the LiveQuery server and successfully resubscribe the ParseQuery,
  2116. * you'll also get this event.
  2117. *
  2118. * <pre>
  2119. * subscription.on('open', (response) => {
  2120. *
  2121. * });</pre></p>
  2122. *
  2123. * <p>Create Event - When a new ParseObject is created and it fulfills the ParseQuery you subscribe,
  2124. * you'll get this event. The object is the ParseObject which is created.
  2125. *
  2126. * <pre>
  2127. * subscription.on('create', (object, response) => {
  2128. *
  2129. * });</pre></p>
  2130. *
  2131. * <p>Update Event - When an existing ParseObject (original) which fulfills the ParseQuery you subscribe
  2132. * is updated (The ParseObject fulfills the ParseQuery before and after changes),
  2133. * you'll get this event. The object is the ParseObject which is updated.
  2134. * Its content is the latest value of the ParseObject.
  2135. *
  2136. * Parse-Server 3.1.3+ Required for original object parameter
  2137. *
  2138. * <pre>
  2139. * subscription.on('update', (object, original, response) => {
  2140. *
  2141. * });</pre></p>
  2142. *
  2143. * <p>Enter Event - When an existing ParseObject's (original) old value doesn't fulfill the ParseQuery
  2144. * but its new value fulfills the ParseQuery, you'll get this event. The object is the
  2145. * ParseObject which enters the ParseQuery. Its content is the latest value of the ParseObject.
  2146. *
  2147. * Parse-Server 3.1.3+ Required for original object parameter
  2148. *
  2149. * <pre>
  2150. * subscription.on('enter', (object, original, response) => {
  2151. *
  2152. * });</pre></p>
  2153. *
  2154. *
  2155. * <p>Update Event - When an existing ParseObject's old value fulfills the ParseQuery but its new value
  2156. * doesn't fulfill the ParseQuery, you'll get this event. The object is the ParseObject
  2157. * which leaves the ParseQuery. Its content is the latest value of the ParseObject.
  2158. *
  2159. * <pre>
  2160. * subscription.on('leave', (object, response) => {
  2161. *
  2162. * });</pre></p>
  2163. *
  2164. *
  2165. * <p>Delete Event - When an existing ParseObject which fulfills the ParseQuery is deleted, you'll
  2166. * get this event. The object is the ParseObject which is deleted.
  2167. *
  2168. * <pre>
  2169. * subscription.on('delete', (object, response) => {
  2170. *
  2171. * });</pre></p>
  2172. *
  2173. *
  2174. * <p>Close Event - When the client loses the WebSocket connection to the LiveQuery
  2175. * server and we stop receiving events, you'll get this event.
  2176. *
  2177. * <pre>
  2178. * subscription.on('close', () => {
  2179. *
  2180. * });</pre></p>
  2181. *
  2182. * @alias Parse.LiveQuerySubscription
  2183. */
  2184. var Subscription = /*#__PURE__*/function (_EventEmitter) {
  2185. (0, _inherits2.default)(Subscription, _EventEmitter);
  2186. var _super = _createSuper(Subscription);
  2187. /*
  2188. * @param {string} id - subscription id
  2189. * @param {string} query - query to subscribe to
  2190. * @param {string} sessionToken - optional session token
  2191. */
  2192. function Subscription(id, query, sessionToken) {
  2193. var _this;
  2194. (0, _classCallCheck2.default)(this, Subscription);
  2195. _this = _super.call(this);
  2196. _this.id = id;
  2197. _this.query = query;
  2198. _this.sessionToken = sessionToken;
  2199. _this.subscribePromise = (0, _promiseUtils.resolvingPromise)();
  2200. _this.subscribed = false; // adding listener so process does not crash
  2201. // best practice is for developer to register their own listener
  2202. _this.on('error', function () {});
  2203. return _this;
  2204. }
  2205. /**
  2206. * Close the subscription
  2207. *
  2208. * @returns {Promise}
  2209. */
  2210. (0, _createClass2.default)(Subscription, [{
  2211. key: "unsubscribe",
  2212. value: function ()
  2213. /*: Promise*/
  2214. {
  2215. var _this2 = this;
  2216. return _CoreManager.default.getLiveQueryController().getDefaultLiveQueryClient().then(function (liveQueryClient) {
  2217. liveQueryClient.unsubscribe(_this2);
  2218. _this2.emit('close');
  2219. });
  2220. }
  2221. }]);
  2222. return Subscription;
  2223. }(_EventEmitter2.default);
  2224. var _default = Subscription;
  2225. exports.default = _default;
  2226. },{"./CoreManager":5,"./EventEmitter":7,"./promiseUtils":72,"@babel/runtime-corejs3/core-js-stable/object/define-property":105,"@babel/runtime-corejs3/core-js-stable/reflect/construct":116,"@babel/runtime-corejs3/helpers/classCallCheck":145,"@babel/runtime-corejs3/helpers/createClass":147,"@babel/runtime-corejs3/helpers/getPrototypeOf":150,"@babel/runtime-corejs3/helpers/inherits":151,"@babel/runtime-corejs3/helpers/interopRequireDefault":152,"@babel/runtime-corejs3/helpers/possibleConstructorReturn":159}],13:[function(_dereq_,module,exports){
  2227. "use strict";
  2228. var _sliceInstanceProperty = _dereq_("@babel/runtime-corejs3/core-js-stable/instance/slice");
  2229. var _Array$from2 = _dereq_("@babel/runtime-corejs3/core-js-stable/array/from");
  2230. var _Symbol = _dereq_("@babel/runtime-corejs3/core-js-stable/symbol");
  2231. var _getIteratorMethod = _dereq_("@babel/runtime-corejs3/core-js/get-iterator-method");
  2232. var _Array$isArray2 = _dereq_("@babel/runtime-corejs3/core-js-stable/array/is-array");
  2233. var _interopRequireDefault = _dereq_("@babel/runtime-corejs3/helpers/interopRequireDefault");
  2234. var _regenerator = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/regenerator"));
  2235. var _promise = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/promise"));
  2236. var _set = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/set"));
  2237. var _concat = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/instance/concat"));
  2238. var _filter = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/instance/filter"));
  2239. var _includes = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/instance/includes"));
  2240. var _keys2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/object/keys"));
  2241. var _startsWith = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/instance/starts-with"));
  2242. var _keys3 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/instance/keys"));
  2243. var _isArray = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/array/is-array"));
  2244. var _map = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/instance/map"));
  2245. var _from = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/array/from"));
  2246. var _find = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/instance/find"));
  2247. var _toConsumableArray2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/helpers/toConsumableArray"));
  2248. var _slicedToArray2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/helpers/slicedToArray"));
  2249. var _asyncToGenerator2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/helpers/asyncToGenerator"));
  2250. var _CoreManager = _interopRequireDefault(_dereq_("./CoreManager"));
  2251. var _ParseQuery = _interopRequireDefault(_dereq_("./ParseQuery"));
  2252. var _LocalDatastoreUtils = _dereq_("./LocalDatastoreUtils");
  2253. function _createForOfIteratorHelper(o, allowArrayLike) {
  2254. var it = typeof _Symbol !== "undefined" && _getIteratorMethod(o) || o["@@iterator"];
  2255. if (!it) {
  2256. if (_Array$isArray2(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") {
  2257. if (it) o = it;
  2258. var i = 0;
  2259. var F = function () {};
  2260. return {
  2261. s: F,
  2262. n: function () {
  2263. if (i >= o.length) return {
  2264. done: true
  2265. };
  2266. return {
  2267. done: false,
  2268. value: o[i++]
  2269. };
  2270. },
  2271. e: function (_e) {
  2272. throw _e;
  2273. },
  2274. f: F
  2275. };
  2276. }
  2277. throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
  2278. }
  2279. var normalCompletion = true,
  2280. didErr = false,
  2281. err;
  2282. return {
  2283. s: function () {
  2284. it = it.call(o);
  2285. },
  2286. n: function () {
  2287. var step = it.next();
  2288. normalCompletion = step.done;
  2289. return step;
  2290. },
  2291. e: function (_e2) {
  2292. didErr = true;
  2293. err = _e2;
  2294. },
  2295. f: function () {
  2296. try {
  2297. if (!normalCompletion && it.return != null) it.return();
  2298. } finally {
  2299. if (didErr) throw err;
  2300. }
  2301. }
  2302. };
  2303. }
  2304. function _unsupportedIterableToArray(o, minLen) {
  2305. var _context16;
  2306. if (!o) return;
  2307. if (typeof o === "string") return _arrayLikeToArray(o, minLen);
  2308. var n = _sliceInstanceProperty(_context16 = Object.prototype.toString.call(o)).call(_context16, 8, -1);
  2309. if (n === "Object" && o.constructor) n = o.constructor.name;
  2310. if (n === "Map" || n === "Set") return _Array$from2(o);
  2311. if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen);
  2312. }
  2313. function _arrayLikeToArray(arr, len) {
  2314. if (len == null || len > arr.length) len = arr.length;
  2315. for (var i = 0, arr2 = new Array(len); i < len; i++) {
  2316. arr2[i] = arr[i];
  2317. }
  2318. return arr2;
  2319. }
  2320. /**
  2321. * Provides a local datastore which can be used to store and retrieve <code>Parse.Object</code>. <br />
  2322. * To enable this functionality, call <code>Parse.enableLocalDatastore()</code>.
  2323. *
  2324. * Pin object to add to local datastore
  2325. *
  2326. * <pre>await object.pin();</pre>
  2327. * <pre>await object.pinWithName('pinName');</pre>
  2328. *
  2329. * Query pinned objects
  2330. *
  2331. * <pre>query.fromLocalDatastore();</pre>
  2332. * <pre>query.fromPin();</pre>
  2333. * <pre>query.fromPinWithName();</pre>
  2334. *
  2335. * <pre>const localObjects = await query.find();</pre>
  2336. *
  2337. * @class Parse.LocalDatastore
  2338. * @static
  2339. */
  2340. var LocalDatastore = {
  2341. isEnabled: false,
  2342. isSyncing: false,
  2343. fromPinWithName: function (name
  2344. /*: string*/
  2345. )
  2346. /*: Promise<Array<Object>>*/
  2347. {
  2348. var controller = _CoreManager.default.getLocalDatastoreController();
  2349. return controller.fromPinWithName(name);
  2350. },
  2351. pinWithName: function (name
  2352. /*: string*/
  2353. , value
  2354. /*: any*/
  2355. )
  2356. /*: Promise<void>*/
  2357. {
  2358. var controller = _CoreManager.default.getLocalDatastoreController();
  2359. return controller.pinWithName(name, value);
  2360. },
  2361. unPinWithName: function (name
  2362. /*: string*/
  2363. )
  2364. /*: Promise<void>*/
  2365. {
  2366. var controller = _CoreManager.default.getLocalDatastoreController();
  2367. return controller.unPinWithName(name);
  2368. },
  2369. _getAllContents: function ()
  2370. /*: Promise<Object>*/
  2371. {
  2372. var controller = _CoreManager.default.getLocalDatastoreController();
  2373. return controller.getAllContents();
  2374. },
  2375. // Use for testing
  2376. _getRawStorage: function ()
  2377. /*: Promise<Object>*/
  2378. {
  2379. var controller = _CoreManager.default.getLocalDatastoreController();
  2380. return controller.getRawStorage();
  2381. },
  2382. _clear: function ()
  2383. /*: Promise<void>*/
  2384. {
  2385. var controller = _CoreManager.default.getLocalDatastoreController();
  2386. return controller.clear();
  2387. },
  2388. // Pin the object and children recursively
  2389. // Saves the object and children key to Pin Name
  2390. _handlePinAllWithName: function (name
  2391. /*: string*/
  2392. , objects
  2393. /*: Array<ParseObject>*/
  2394. )
  2395. /*: Promise<void>*/
  2396. {
  2397. var _this = this;
  2398. return (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee() {
  2399. var _context;
  2400. var pinName, toPinPromises, objectKeys, _iterator, _step, parent, children, parentKey, json, objectKey, fromPinPromise, _yield$Promise$all, _yield$Promise$all2, pinned, toPin;
  2401. return _regenerator.default.wrap(function (_context2) {
  2402. while (1) {
  2403. switch (_context2.prev = _context2.next) {
  2404. case 0:
  2405. pinName = _this.getPinName(name);
  2406. toPinPromises = [];
  2407. objectKeys = [];
  2408. _iterator = _createForOfIteratorHelper(objects);
  2409. try {
  2410. for (_iterator.s(); !(_step = _iterator.n()).done;) {
  2411. parent = _step.value;
  2412. children = _this._getChildren(parent);
  2413. parentKey = _this.getKeyForObject(parent);
  2414. json = parent._toFullJSON(undefined, true);
  2415. if (parent._localId) {
  2416. json._localId = parent._localId;
  2417. }
  2418. children[parentKey] = json;
  2419. for (objectKey in children) {
  2420. objectKeys.push(objectKey);
  2421. toPinPromises.push(_this.pinWithName(objectKey, [children[objectKey]]));
  2422. }
  2423. }
  2424. } catch (err) {
  2425. _iterator.e(err);
  2426. } finally {
  2427. _iterator.f();
  2428. }
  2429. fromPinPromise = _this.fromPinWithName(pinName);
  2430. _context2.next = 8;
  2431. return _promise.default.all([fromPinPromise, toPinPromises]);
  2432. case 8:
  2433. _yield$Promise$all = _context2.sent;
  2434. _yield$Promise$all2 = (0, _slicedToArray2.default)(_yield$Promise$all, 1);
  2435. pinned = _yield$Promise$all2[0];
  2436. toPin = (0, _toConsumableArray2.default)(new _set.default((0, _concat.default)(_context = []).call(_context, (0, _toConsumableArray2.default)(pinned || []), objectKeys)));
  2437. return _context2.abrupt("return", _this.pinWithName(pinName, toPin));
  2438. case 13:
  2439. case "end":
  2440. return _context2.stop();
  2441. }
  2442. }
  2443. }, _callee);
  2444. }))();
  2445. },
  2446. // Removes object and children keys from pin name
  2447. // Keeps the object and children pinned
  2448. _handleUnPinAllWithName: function (name
  2449. /*: string*/
  2450. , objects
  2451. /*: Array<ParseObject>*/
  2452. ) {
  2453. var _this2 = this;
  2454. return (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee2() {
  2455. var localDatastore, pinName, promises, objectKeys, _iterator2, _step2, _objectKeys, _context3, parent, children, parentKey, pinned, _iterator3, _step3, objectKey, hasReference, key, pinnedObjects;
  2456. return _regenerator.default.wrap(function (_context4) {
  2457. while (1) {
  2458. switch (_context4.prev = _context4.next) {
  2459. case 0:
  2460. _context4.next = 2;
  2461. return _this2._getAllContents();
  2462. case 2:
  2463. localDatastore = _context4.sent;
  2464. pinName = _this2.getPinName(name);
  2465. promises = [];
  2466. objectKeys = [];
  2467. _iterator2 = _createForOfIteratorHelper(objects);
  2468. try {
  2469. for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
  2470. parent = _step2.value;
  2471. children = _this2._getChildren(parent);
  2472. parentKey = _this2.getKeyForObject(parent);
  2473. (_objectKeys = objectKeys).push.apply(_objectKeys, (0, _concat.default)(_context3 = [parentKey]).call(_context3, (0, _toConsumableArray2.default)((0, _keys2.default)(children))));
  2474. }
  2475. } catch (err) {
  2476. _iterator2.e(err);
  2477. } finally {
  2478. _iterator2.f();
  2479. }
  2480. objectKeys = (0, _toConsumableArray2.default)(new _set.default(objectKeys));
  2481. pinned = localDatastore[pinName] || [];
  2482. pinned = (0, _filter.default)(pinned).call(pinned, function (item) {
  2483. return !(0, _includes.default)(objectKeys).call(objectKeys, item);
  2484. });
  2485. if (pinned.length === 0) {
  2486. promises.push(_this2.unPinWithName(pinName));
  2487. delete localDatastore[pinName];
  2488. } else {
  2489. promises.push(_this2.pinWithName(pinName, pinned));
  2490. localDatastore[pinName] = pinned;
  2491. }
  2492. _iterator3 = _createForOfIteratorHelper(objectKeys);
  2493. _context4.prev = 13;
  2494. _iterator3.s();
  2495. case 15:
  2496. if ((_step3 = _iterator3.n()).done) {
  2497. _context4.next = 31;
  2498. break;
  2499. }
  2500. objectKey = _step3.value;
  2501. hasReference = false;
  2502. _context4.t0 = (0, _keys3.default)(_regenerator.default).call(_regenerator.default, localDatastore);
  2503. case 19:
  2504. if ((_context4.t1 = _context4.t0()).done) {
  2505. _context4.next = 28;
  2506. break;
  2507. }
  2508. key = _context4.t1.value;
  2509. if (!(key === _LocalDatastoreUtils.DEFAULT_PIN || (0, _startsWith.default)(key).call(key, _LocalDatastoreUtils.PIN_PREFIX))) {
  2510. _context4.next = 26;
  2511. break;
  2512. }
  2513. pinnedObjects = localDatastore[key] || [];
  2514. if (!(0, _includes.default)(pinnedObjects).call(pinnedObjects, objectKey)) {
  2515. _context4.next = 26;
  2516. break;
  2517. }
  2518. hasReference = true;
  2519. return _context4.abrupt("break", 28);
  2520. case 26:
  2521. _context4.next = 19;
  2522. break;
  2523. case 28:
  2524. if (!hasReference) {
  2525. promises.push(_this2.unPinWithName(objectKey));
  2526. }
  2527. case 29:
  2528. _context4.next = 15;
  2529. break;
  2530. case 31:
  2531. _context4.next = 36;
  2532. break;
  2533. case 33:
  2534. _context4.prev = 33;
  2535. _context4.t2 = _context4["catch"](13);
  2536. _iterator3.e(_context4.t2);
  2537. case 36:
  2538. _context4.prev = 36;
  2539. _iterator3.f();
  2540. return _context4.finish(36);
  2541. case 39:
  2542. return _context4.abrupt("return", _promise.default.all(promises));
  2543. case 40:
  2544. case "end":
  2545. return _context4.stop();
  2546. }
  2547. }
  2548. }, _callee2, null, [[13, 33, 36, 39]]);
  2549. }))();
  2550. },
  2551. // Retrieve all pointer fields from object recursively
  2552. _getChildren: function (object
  2553. /*: ParseObject*/
  2554. ) {
  2555. var encountered = {};
  2556. var json = object._toFullJSON(undefined, true);
  2557. for (var key in json) {
  2558. if (json[key] && json[key].__type && json[key].__type === 'Object') {
  2559. this._traverse(json[key], encountered);
  2560. }
  2561. }
  2562. return encountered;
  2563. },
  2564. _traverse: function (object
  2565. /*: any*/
  2566. , encountered
  2567. /*: any*/
  2568. ) {
  2569. if (!object.objectId) {
  2570. return;
  2571. }
  2572. var objectKey = this.getKeyForObject(object);
  2573. if (encountered[objectKey]) {
  2574. return;
  2575. }
  2576. encountered[objectKey] = object;
  2577. for (var key in object) {
  2578. var json = object[key];
  2579. if (!object[key]) {
  2580. json = object;
  2581. }
  2582. if (json.__type && json.__type === 'Object') {
  2583. this._traverse(json, encountered);
  2584. }
  2585. }
  2586. },
  2587. // Transform keys in pin name to objects
  2588. _serializeObjectsFromPinName: function (name
  2589. /*: string*/
  2590. ) {
  2591. var _this3 = this;
  2592. return (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee3() {
  2593. var _ref;
  2594. var localDatastore, allObjects, key, pinName, pinned, promises, objects;
  2595. return _regenerator.default.wrap(function (_context5) {
  2596. while (1) {
  2597. switch (_context5.prev = _context5.next) {
  2598. case 0:
  2599. _context5.next = 2;
  2600. return _this3._getAllContents();
  2601. case 2:
  2602. localDatastore = _context5.sent;
  2603. allObjects = [];
  2604. for (key in localDatastore) {
  2605. if ((0, _startsWith.default)(key).call(key, _LocalDatastoreUtils.OBJECT_PREFIX)) {
  2606. allObjects.push(localDatastore[key][0]);
  2607. }
  2608. }
  2609. if (name) {
  2610. _context5.next = 7;
  2611. break;
  2612. }
  2613. return _context5.abrupt("return", allObjects);
  2614. case 7:
  2615. pinName = _this3.getPinName(name);
  2616. pinned = localDatastore[pinName];
  2617. if ((0, _isArray.default)(pinned)) {
  2618. _context5.next = 11;
  2619. break;
  2620. }
  2621. return _context5.abrupt("return", []);
  2622. case 11:
  2623. promises = (0, _map.default)(pinned).call(pinned, function (objectKey) {
  2624. return _this3.fromPinWithName(objectKey);
  2625. });
  2626. _context5.next = 14;
  2627. return _promise.default.all(promises);
  2628. case 14:
  2629. objects = _context5.sent;
  2630. objects = (0, _concat.default)(_ref = []).apply(_ref, (0, _toConsumableArray2.default)(objects));
  2631. return _context5.abrupt("return", (0, _filter.default)(objects).call(objects, function (object) {
  2632. return object != null;
  2633. }));
  2634. case 17:
  2635. case "end":
  2636. return _context5.stop();
  2637. }
  2638. }
  2639. }, _callee3);
  2640. }))();
  2641. },
  2642. // Replaces object pointers with pinned pointers
  2643. // The object pointers may contain old data
  2644. // Uses Breadth First Search Algorithm
  2645. _serializeObject: function (objectKey
  2646. /*: string*/
  2647. , localDatastore
  2648. /*: any*/
  2649. ) {
  2650. var _this4 = this;
  2651. return (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee4() {
  2652. var LDS, root, queue, meta, uniqueId, nodeId, subTreeRoot, field, value, key, pointer;
  2653. return _regenerator.default.wrap(function (_context6) {
  2654. while (1) {
  2655. switch (_context6.prev = _context6.next) {
  2656. case 0:
  2657. LDS = localDatastore;
  2658. if (LDS) {
  2659. _context6.next = 5;
  2660. break;
  2661. }
  2662. _context6.next = 4;
  2663. return _this4._getAllContents();
  2664. case 4:
  2665. LDS = _context6.sent;
  2666. case 5:
  2667. if (!(!LDS[objectKey] || LDS[objectKey].length === 0)) {
  2668. _context6.next = 7;
  2669. break;
  2670. }
  2671. return _context6.abrupt("return", null);
  2672. case 7:
  2673. root = LDS[objectKey][0];
  2674. queue = [];
  2675. meta = {};
  2676. uniqueId = 0;
  2677. meta[uniqueId] = root;
  2678. queue.push(uniqueId);
  2679. while (queue.length !== 0) {
  2680. nodeId = queue.shift();
  2681. subTreeRoot = meta[nodeId];
  2682. for (field in subTreeRoot) {
  2683. value = subTreeRoot[field];
  2684. if (value.__type && value.__type === 'Object') {
  2685. key = _this4.getKeyForObject(value);
  2686. if (LDS[key] && LDS[key].length > 0) {
  2687. pointer = LDS[key][0];
  2688. uniqueId++;
  2689. meta[uniqueId] = pointer;
  2690. subTreeRoot[field] = pointer;
  2691. queue.push(uniqueId);
  2692. }
  2693. }
  2694. }
  2695. }
  2696. return _context6.abrupt("return", root);
  2697. case 15:
  2698. case "end":
  2699. return _context6.stop();
  2700. }
  2701. }
  2702. }, _callee4);
  2703. }))();
  2704. },
  2705. // Called when an object is save / fetched
  2706. // Update object pin value
  2707. _updateObjectIfPinned: function (object
  2708. /*: ParseObject*/
  2709. )
  2710. /*: Promise<void>*/
  2711. {
  2712. var _this5 = this;
  2713. return (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee5() {
  2714. var objectKey, pinned;
  2715. return _regenerator.default.wrap(function (_context7) {
  2716. while (1) {
  2717. switch (_context7.prev = _context7.next) {
  2718. case 0:
  2719. if (_this5.isEnabled) {
  2720. _context7.next = 2;
  2721. break;
  2722. }
  2723. return _context7.abrupt("return");
  2724. case 2:
  2725. objectKey = _this5.getKeyForObject(object);
  2726. _context7.next = 5;
  2727. return _this5.fromPinWithName(objectKey);
  2728. case 5:
  2729. pinned = _context7.sent;
  2730. if (!(!pinned || pinned.length === 0)) {
  2731. _context7.next = 8;
  2732. break;
  2733. }
  2734. return _context7.abrupt("return");
  2735. case 8:
  2736. return _context7.abrupt("return", _this5.pinWithName(objectKey, [object._toFullJSON()]));
  2737. case 9:
  2738. case "end":
  2739. return _context7.stop();
  2740. }
  2741. }
  2742. }, _callee5);
  2743. }))();
  2744. },
  2745. // Called when object is destroyed
  2746. // Unpin object and remove all references from pin names
  2747. // TODO: Destroy children?
  2748. _destroyObjectIfPinned: function (object
  2749. /*: ParseObject*/
  2750. ) {
  2751. var _this6 = this;
  2752. return (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee6() {
  2753. var localDatastore, objectKey, pin, promises, key, pinned;
  2754. return _regenerator.default.wrap(function (_context8) {
  2755. while (1) {
  2756. switch (_context8.prev = _context8.next) {
  2757. case 0:
  2758. if (_this6.isEnabled) {
  2759. _context8.next = 2;
  2760. break;
  2761. }
  2762. return _context8.abrupt("return");
  2763. case 2:
  2764. _context8.next = 4;
  2765. return _this6._getAllContents();
  2766. case 4:
  2767. localDatastore = _context8.sent;
  2768. objectKey = _this6.getKeyForObject(object);
  2769. pin = localDatastore[objectKey];
  2770. if (pin) {
  2771. _context8.next = 9;
  2772. break;
  2773. }
  2774. return _context8.abrupt("return");
  2775. case 9:
  2776. promises = [_this6.unPinWithName(objectKey)];
  2777. delete localDatastore[objectKey];
  2778. for (key in localDatastore) {
  2779. if (key === _LocalDatastoreUtils.DEFAULT_PIN || (0, _startsWith.default)(key).call(key, _LocalDatastoreUtils.PIN_PREFIX)) {
  2780. pinned = localDatastore[key] || [];
  2781. if ((0, _includes.default)(pinned).call(pinned, objectKey)) {
  2782. pinned = (0, _filter.default)(pinned).call(pinned, function (item) {
  2783. return item !== objectKey;
  2784. });
  2785. if (pinned.length === 0) {
  2786. promises.push(_this6.unPinWithName(key));
  2787. delete localDatastore[key];
  2788. } else {
  2789. promises.push(_this6.pinWithName(key, pinned));
  2790. localDatastore[key] = pinned;
  2791. }
  2792. }
  2793. }
  2794. }
  2795. return _context8.abrupt("return", _promise.default.all(promises));
  2796. case 13:
  2797. case "end":
  2798. return _context8.stop();
  2799. }
  2800. }
  2801. }, _callee6);
  2802. }))();
  2803. },
  2804. // Update pin and references of the unsaved object
  2805. _updateLocalIdForObject: function (localId
  2806. /*: string*/
  2807. , object
  2808. /*: ParseObject*/
  2809. ) {
  2810. var _this7 = this;
  2811. return (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee7() {
  2812. var _context9, _context10;
  2813. var localKey, objectKey, unsaved, promises, localDatastore, key, pinned;
  2814. return _regenerator.default.wrap(function (_context11) {
  2815. while (1) {
  2816. switch (_context11.prev = _context11.next) {
  2817. case 0:
  2818. if (_this7.isEnabled) {
  2819. _context11.next = 2;
  2820. break;
  2821. }
  2822. return _context11.abrupt("return");
  2823. case 2:
  2824. localKey = (0, _concat.default)(_context9 = (0, _concat.default)(_context10 = "".concat(_LocalDatastoreUtils.OBJECT_PREFIX)).call(_context10, object.className, "_")).call(_context9, localId);
  2825. objectKey = _this7.getKeyForObject(object);
  2826. _context11.next = 6;
  2827. return _this7.fromPinWithName(localKey);
  2828. case 6:
  2829. unsaved = _context11.sent;
  2830. if (!(!unsaved || unsaved.length === 0)) {
  2831. _context11.next = 9;
  2832. break;
  2833. }
  2834. return _context11.abrupt("return");
  2835. case 9:
  2836. promises = [_this7.unPinWithName(localKey), _this7.pinWithName(objectKey, unsaved)];
  2837. _context11.next = 12;
  2838. return _this7._getAllContents();
  2839. case 12:
  2840. localDatastore = _context11.sent;
  2841. for (key in localDatastore) {
  2842. if (key === _LocalDatastoreUtils.DEFAULT_PIN || (0, _startsWith.default)(key).call(key, _LocalDatastoreUtils.PIN_PREFIX)) {
  2843. pinned = localDatastore[key] || [];
  2844. if ((0, _includes.default)(pinned).call(pinned, localKey)) {
  2845. pinned = (0, _filter.default)(pinned).call(pinned, function (item) {
  2846. return item !== localKey;
  2847. });
  2848. pinned.push(objectKey);
  2849. promises.push(_this7.pinWithName(key, pinned));
  2850. localDatastore[key] = pinned;
  2851. }
  2852. }
  2853. }
  2854. return _context11.abrupt("return", _promise.default.all(promises));
  2855. case 15:
  2856. case "end":
  2857. return _context11.stop();
  2858. }
  2859. }
  2860. }, _callee7);
  2861. }))();
  2862. },
  2863. /**
  2864. * Updates Local Datastore from Server
  2865. *
  2866. * <pre>
  2867. * await Parse.LocalDatastore.updateFromServer();
  2868. * </pre>
  2869. *
  2870. * @function updateFromServer
  2871. * @name Parse.LocalDatastore.updateFromServer
  2872. * @static
  2873. */
  2874. updateFromServer: function () {
  2875. var _this8 = this;
  2876. return (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee8() {
  2877. var _context12;
  2878. var localDatastore, keys, key, pointersHash, _i, _keys, _key, _key$split, _key$split2, className, objectId, queryPromises, responses, objects, pinPromises;
  2879. return _regenerator.default.wrap(function (_context13) {
  2880. while (1) {
  2881. switch (_context13.prev = _context13.next) {
  2882. case 0:
  2883. if (!(!_this8.checkIfEnabled() || _this8.isSyncing)) {
  2884. _context13.next = 2;
  2885. break;
  2886. }
  2887. return _context13.abrupt("return");
  2888. case 2:
  2889. _context13.next = 4;
  2890. return _this8._getAllContents();
  2891. case 4:
  2892. localDatastore = _context13.sent;
  2893. keys = [];
  2894. for (key in localDatastore) {
  2895. if ((0, _startsWith.default)(key).call(key, _LocalDatastoreUtils.OBJECT_PREFIX)) {
  2896. keys.push(key);
  2897. }
  2898. }
  2899. if (!(keys.length === 0)) {
  2900. _context13.next = 9;
  2901. break;
  2902. }
  2903. return _context13.abrupt("return");
  2904. case 9:
  2905. _this8.isSyncing = true;
  2906. pointersHash = {};
  2907. _i = 0, _keys = keys;
  2908. case 12:
  2909. if (!(_i < _keys.length)) {
  2910. _context13.next = 23;
  2911. break;
  2912. }
  2913. _key = _keys[_i]; // Ignore the OBJECT_PREFIX
  2914. _key$split = _key.split('_'), _key$split2 = (0, _slicedToArray2.default)(_key$split, 4), className = _key$split2[2], objectId = _key$split2[3]; // User key is split into [ 'Parse', 'LDS', '', 'User', 'objectId' ]
  2915. if (_key.split('_').length === 5 && _key.split('_')[3] === 'User') {
  2916. className = '_User';
  2917. objectId = _key.split('_')[4];
  2918. }
  2919. if (!(0, _startsWith.default)(objectId).call(objectId, 'local')) {
  2920. _context13.next = 18;
  2921. break;
  2922. }
  2923. return _context13.abrupt("continue", 20);
  2924. case 18:
  2925. if (!(className in pointersHash)) {
  2926. pointersHash[className] = new _set.default();
  2927. }
  2928. pointersHash[className].add(objectId);
  2929. case 20:
  2930. _i++;
  2931. _context13.next = 12;
  2932. break;
  2933. case 23:
  2934. queryPromises = (0, _map.default)(_context12 = (0, _keys2.default)(pointersHash)).call(_context12, function (className) {
  2935. var objectIds = (0, _from.default)(pointersHash[className]);
  2936. var query = new _ParseQuery.default(className);
  2937. query.limit(objectIds.length);
  2938. if (objectIds.length === 1) {
  2939. query.equalTo('objectId', objectIds[0]);
  2940. } else {
  2941. query.containedIn('objectId', objectIds);
  2942. }
  2943. return (0, _find.default)(query).call(query);
  2944. });
  2945. _context13.prev = 24;
  2946. _context13.next = 27;
  2947. return _promise.default.all(queryPromises);
  2948. case 27:
  2949. responses = _context13.sent;
  2950. objects = (0, _concat.default)([]).apply([], responses);
  2951. pinPromises = (0, _map.default)(objects).call(objects, function (object) {
  2952. var objectKey = _this8.getKeyForObject(object);
  2953. return _this8.pinWithName(objectKey, object._toFullJSON());
  2954. });
  2955. _context13.next = 32;
  2956. return _promise.default.all(pinPromises);
  2957. case 32:
  2958. _this8.isSyncing = false;
  2959. _context13.next = 39;
  2960. break;
  2961. case 35:
  2962. _context13.prev = 35;
  2963. _context13.t0 = _context13["catch"](24); // eslint-disable-next-line no-console
  2964. console.error('Error syncing LocalDatastore: ', _context13.t0);
  2965. _this8.isSyncing = false;
  2966. case 39:
  2967. case "end":
  2968. return _context13.stop();
  2969. }
  2970. }
  2971. }, _callee8, null, [[24, 35]]);
  2972. }))();
  2973. },
  2974. getKeyForObject: function (object
  2975. /*: any*/
  2976. ) {
  2977. var _context14, _context15;
  2978. var objectId = object.objectId || object._getId();
  2979. return (0, _concat.default)(_context14 = (0, _concat.default)(_context15 = "".concat(_LocalDatastoreUtils.OBJECT_PREFIX)).call(_context15, object.className, "_")).call(_context14, objectId);
  2980. },
  2981. getPinName: function (pinName
  2982. /*: ?string*/
  2983. ) {
  2984. if (!pinName || pinName === _LocalDatastoreUtils.DEFAULT_PIN) {
  2985. return _LocalDatastoreUtils.DEFAULT_PIN;
  2986. }
  2987. return _LocalDatastoreUtils.PIN_PREFIX + pinName;
  2988. },
  2989. checkIfEnabled: function () {
  2990. if (!this.isEnabled) {
  2991. // eslint-disable-next-line no-console
  2992. console.error('Parse.enableLocalDatastore() must be called first');
  2993. }
  2994. return this.isEnabled;
  2995. }
  2996. };
  2997. module.exports = LocalDatastore;
  2998. _CoreManager.default.setLocalDatastoreController(_dereq_('./LocalDatastoreController'));
  2999. _CoreManager.default.setLocalDatastore(LocalDatastore);
  3000. },{"./CoreManager":5,"./LocalDatastoreController":14,"./LocalDatastoreUtils":15,"./ParseQuery":39,"@babel/runtime-corejs3/core-js-stable/array/from":78,"@babel/runtime-corejs3/core-js-stable/array/is-array":79,"@babel/runtime-corejs3/core-js-stable/instance/concat":81,"@babel/runtime-corejs3/core-js-stable/instance/filter":84,"@babel/runtime-corejs3/core-js-stable/instance/find":85,"@babel/runtime-corejs3/core-js-stable/instance/includes":87,"@babel/runtime-corejs3/core-js-stable/instance/keys":89,"@babel/runtime-corejs3/core-js-stable/instance/map":90,"@babel/runtime-corejs3/core-js-stable/instance/slice":93,"@babel/runtime-corejs3/core-js-stable/instance/starts-with":96,"@babel/runtime-corejs3/core-js-stable/object/keys":112,"@babel/runtime-corejs3/core-js-stable/promise":115,"@babel/runtime-corejs3/core-js-stable/set":118,"@babel/runtime-corejs3/core-js-stable/symbol":119,"@babel/runtime-corejs3/core-js/get-iterator-method":125,"@babel/runtime-corejs3/helpers/asyncToGenerator":144,"@babel/runtime-corejs3/helpers/interopRequireDefault":152,"@babel/runtime-corejs3/helpers/slicedToArray":161,"@babel/runtime-corejs3/helpers/toConsumableArray":163,"@babel/runtime-corejs3/regenerator":167}],14:[function(_dereq_,module,exports){
  3001. "use strict";
  3002. var _sliceInstanceProperty = _dereq_("@babel/runtime-corejs3/core-js-stable/instance/slice");
  3003. var _Array$from = _dereq_("@babel/runtime-corejs3/core-js-stable/array/from");
  3004. var _Symbol = _dereq_("@babel/runtime-corejs3/core-js-stable/symbol");
  3005. var _getIteratorMethod = _dereq_("@babel/runtime-corejs3/core-js/get-iterator-method");
  3006. var _Array$isArray = _dereq_("@babel/runtime-corejs3/core-js-stable/array/is-array");
  3007. var _interopRequireDefault = _dereq_("@babel/runtime-corejs3/helpers/interopRequireDefault");
  3008. var _stringify = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/json/stringify"));
  3009. var _reduce = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/instance/reduce"));
  3010. var _promise = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/promise"));
  3011. var _map = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/instance/map"));
  3012. var _regenerator = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/regenerator"));
  3013. var _asyncToGenerator2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/helpers/asyncToGenerator"));
  3014. var _LocalDatastoreUtils = _dereq_("./LocalDatastoreUtils");
  3015. var _Storage = _interopRequireDefault(_dereq_("./Storage"));
  3016. function _createForOfIteratorHelper(o, allowArrayLike) {
  3017. var it = typeof _Symbol !== "undefined" && _getIteratorMethod(o) || o["@@iterator"];
  3018. if (!it) {
  3019. if (_Array$isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") {
  3020. if (it) o = it;
  3021. var i = 0;
  3022. var F = function () {};
  3023. return {
  3024. s: F,
  3025. n: function () {
  3026. if (i >= o.length) return {
  3027. done: true
  3028. };
  3029. return {
  3030. done: false,
  3031. value: o[i++]
  3032. };
  3033. },
  3034. e: function (_e) {
  3035. throw _e;
  3036. },
  3037. f: F
  3038. };
  3039. }
  3040. throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
  3041. }
  3042. var normalCompletion = true,
  3043. didErr = false,
  3044. err;
  3045. return {
  3046. s: function () {
  3047. it = it.call(o);
  3048. },
  3049. n: function () {
  3050. var step = it.next();
  3051. normalCompletion = step.done;
  3052. return step;
  3053. },
  3054. e: function (_e2) {
  3055. didErr = true;
  3056. err = _e2;
  3057. },
  3058. f: function () {
  3059. try {
  3060. if (!normalCompletion && it.return != null) it.return();
  3061. } finally {
  3062. if (didErr) throw err;
  3063. }
  3064. }
  3065. };
  3066. }
  3067. function _unsupportedIterableToArray(o, minLen) {
  3068. var _context7;
  3069. if (!o) return;
  3070. if (typeof o === "string") return _arrayLikeToArray(o, minLen);
  3071. var n = _sliceInstanceProperty(_context7 = Object.prototype.toString.call(o)).call(_context7, 8, -1);
  3072. if (n === "Object" && o.constructor) n = o.constructor.name;
  3073. if (n === "Map" || n === "Set") return _Array$from(o);
  3074. if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen);
  3075. }
  3076. function _arrayLikeToArray(arr, len) {
  3077. if (len == null || len > arr.length) len = arr.length;
  3078. for (var i = 0, arr2 = new Array(len); i < len; i++) {
  3079. arr2[i] = arr[i];
  3080. }
  3081. return arr2;
  3082. }
  3083. var LocalDatastoreController = {
  3084. fromPinWithName: function (name
  3085. /*: string*/
  3086. )
  3087. /*: Array<Object>*/
  3088. {
  3089. return (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee() {
  3090. var values, objects;
  3091. return _regenerator.default.wrap(function (_context) {
  3092. while (1) {
  3093. switch (_context.prev = _context.next) {
  3094. case 0:
  3095. _context.next = 2;
  3096. return _Storage.default.getItemAsync(name);
  3097. case 2:
  3098. values = _context.sent;
  3099. if (values) {
  3100. _context.next = 5;
  3101. break;
  3102. }
  3103. return _context.abrupt("return", []);
  3104. case 5:
  3105. objects = JSON.parse(values);
  3106. return _context.abrupt("return", objects);
  3107. case 7:
  3108. case "end":
  3109. return _context.stop();
  3110. }
  3111. }
  3112. }, _callee);
  3113. }))();
  3114. },
  3115. pinWithName: function (name
  3116. /*: string*/
  3117. , value
  3118. /*: any*/
  3119. ) {
  3120. var values = (0, _stringify.default)(value);
  3121. return _Storage.default.setItemAsync(name, values);
  3122. },
  3123. unPinWithName: function (name
  3124. /*: string*/
  3125. ) {
  3126. return _Storage.default.removeItemAsync(name);
  3127. },
  3128. getAllContents: function ()
  3129. /*: Object*/
  3130. {
  3131. return (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee3() {
  3132. var keys;
  3133. return _regenerator.default.wrap(function (_context3) {
  3134. while (1) {
  3135. switch (_context3.prev = _context3.next) {
  3136. case 0:
  3137. _context3.next = 2;
  3138. return _Storage.default.getAllKeysAsync();
  3139. case 2:
  3140. keys = _context3.sent;
  3141. return _context3.abrupt("return", (0, _reduce.default)(keys).call(keys, /*#__PURE__*/function () {
  3142. var _ref = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee2(previousPromise, key) {
  3143. var LDS, value;
  3144. return _regenerator.default.wrap(function (_context2) {
  3145. while (1) {
  3146. switch (_context2.prev = _context2.next) {
  3147. case 0:
  3148. _context2.next = 2;
  3149. return previousPromise;
  3150. case 2:
  3151. LDS = _context2.sent;
  3152. if (!(0, _LocalDatastoreUtils.isLocalDatastoreKey)(key)) {
  3153. _context2.next = 8;
  3154. break;
  3155. }
  3156. _context2.next = 6;
  3157. return _Storage.default.getItemAsync(key);
  3158. case 6:
  3159. value = _context2.sent;
  3160. try {
  3161. LDS[key] = JSON.parse(value);
  3162. } catch (error) {
  3163. // eslint-disable-next-line no-console
  3164. console.error('Error getAllContents: ', error);
  3165. }
  3166. case 8:
  3167. return _context2.abrupt("return", LDS);
  3168. case 9:
  3169. case "end":
  3170. return _context2.stop();
  3171. }
  3172. }
  3173. }, _callee2);
  3174. }));
  3175. return function () {
  3176. return _ref.apply(this, arguments);
  3177. };
  3178. }(), _promise.default.resolve({})));
  3179. case 4:
  3180. case "end":
  3181. return _context3.stop();
  3182. }
  3183. }
  3184. }, _callee3);
  3185. }))();
  3186. },
  3187. // Used for testing
  3188. getRawStorage: function ()
  3189. /*: Object*/
  3190. {
  3191. return (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee5() {
  3192. var keys;
  3193. return _regenerator.default.wrap(function (_context5) {
  3194. while (1) {
  3195. switch (_context5.prev = _context5.next) {
  3196. case 0:
  3197. _context5.next = 2;
  3198. return _Storage.default.getAllKeysAsync();
  3199. case 2:
  3200. keys = _context5.sent;
  3201. return _context5.abrupt("return", (0, _reduce.default)(keys).call(keys, /*#__PURE__*/function () {
  3202. var _ref2 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee4(previousPromise, key) {
  3203. var LDS, value;
  3204. return _regenerator.default.wrap(function (_context4) {
  3205. while (1) {
  3206. switch (_context4.prev = _context4.next) {
  3207. case 0:
  3208. _context4.next = 2;
  3209. return previousPromise;
  3210. case 2:
  3211. LDS = _context4.sent;
  3212. _context4.next = 5;
  3213. return _Storage.default.getItemAsync(key);
  3214. case 5:
  3215. value = _context4.sent;
  3216. LDS[key] = value;
  3217. return _context4.abrupt("return", LDS);
  3218. case 8:
  3219. case "end":
  3220. return _context4.stop();
  3221. }
  3222. }
  3223. }, _callee4);
  3224. }));
  3225. return function () {
  3226. return _ref2.apply(this, arguments);
  3227. };
  3228. }(), _promise.default.resolve({})));
  3229. case 4:
  3230. case "end":
  3231. return _context5.stop();
  3232. }
  3233. }
  3234. }, _callee5);
  3235. }))();
  3236. },
  3237. clear: function ()
  3238. /*: Promise*/
  3239. {
  3240. var _this = this;
  3241. return (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee6() {
  3242. var keys, toRemove, _iterator, _step, key, promises;
  3243. return _regenerator.default.wrap(function (_context6) {
  3244. while (1) {
  3245. switch (_context6.prev = _context6.next) {
  3246. case 0:
  3247. _context6.next = 2;
  3248. return _Storage.default.getAllKeysAsync();
  3249. case 2:
  3250. keys = _context6.sent;
  3251. toRemove = [];
  3252. _iterator = _createForOfIteratorHelper(keys);
  3253. try {
  3254. for (_iterator.s(); !(_step = _iterator.n()).done;) {
  3255. key = _step.value;
  3256. if ((0, _LocalDatastoreUtils.isLocalDatastoreKey)(key)) {
  3257. toRemove.push(key);
  3258. }
  3259. }
  3260. } catch (err) {
  3261. _iterator.e(err);
  3262. } finally {
  3263. _iterator.f();
  3264. }
  3265. promises = (0, _map.default)(toRemove).call(toRemove, _this.unPinWithName);
  3266. return _context6.abrupt("return", _promise.default.all(promises));
  3267. case 8:
  3268. case "end":
  3269. return _context6.stop();
  3270. }
  3271. }
  3272. }, _callee6);
  3273. }))();
  3274. }
  3275. };
  3276. module.exports = LocalDatastoreController;
  3277. },{"./LocalDatastoreUtils":15,"./Storage":48,"@babel/runtime-corejs3/core-js-stable/array/from":78,"@babel/runtime-corejs3/core-js-stable/array/is-array":79,"@babel/runtime-corejs3/core-js-stable/instance/map":90,"@babel/runtime-corejs3/core-js-stable/instance/reduce":92,"@babel/runtime-corejs3/core-js-stable/instance/slice":93,"@babel/runtime-corejs3/core-js-stable/json/stringify":99,"@babel/runtime-corejs3/core-js-stable/promise":115,"@babel/runtime-corejs3/core-js-stable/symbol":119,"@babel/runtime-corejs3/core-js/get-iterator-method":125,"@babel/runtime-corejs3/helpers/asyncToGenerator":144,"@babel/runtime-corejs3/helpers/interopRequireDefault":152,"@babel/runtime-corejs3/regenerator":167}],15:[function(_dereq_,module,exports){
  3278. "use strict";
  3279. var _Object$defineProperty = _dereq_("@babel/runtime-corejs3/core-js-stable/object/define-property");
  3280. var _interopRequireDefault = _dereq_("@babel/runtime-corejs3/helpers/interopRequireDefault");
  3281. _Object$defineProperty(exports, "__esModule", {
  3282. value: true
  3283. });
  3284. exports.PIN_PREFIX = exports.OBJECT_PREFIX = exports.DEFAULT_PIN = void 0;
  3285. exports.isLocalDatastoreKey = isLocalDatastoreKey;
  3286. var _startsWith = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/instance/starts-with"));
  3287. /**
  3288. * Copyright (c) 2015-present, Parse, LLC.
  3289. * All rights reserved.
  3290. *
  3291. * This source code is licensed under the BSD-style license found in the
  3292. * LICENSE file in the root directory of this source tree. An additional grant
  3293. * of patent rights can be found in the PATENTS file in the same directory.
  3294. *
  3295. * @flow
  3296. * @private
  3297. */
  3298. var DEFAULT_PIN = '_default';
  3299. exports.DEFAULT_PIN = DEFAULT_PIN;
  3300. var PIN_PREFIX = 'parsePin_';
  3301. exports.PIN_PREFIX = PIN_PREFIX;
  3302. var OBJECT_PREFIX = 'Parse_LDS_';
  3303. exports.OBJECT_PREFIX = OBJECT_PREFIX;
  3304. function isLocalDatastoreKey(key
  3305. /*: string*/
  3306. )
  3307. /*: boolean*/
  3308. {
  3309. return !!(key && (key === DEFAULT_PIN || (0, _startsWith.default)(key).call(key, PIN_PREFIX) || (0, _startsWith.default)(key).call(key, OBJECT_PREFIX)));
  3310. }
  3311. },{"@babel/runtime-corejs3/core-js-stable/instance/starts-with":96,"@babel/runtime-corejs3/core-js-stable/object/define-property":105,"@babel/runtime-corejs3/helpers/interopRequireDefault":152}],16:[function(_dereq_,module,exports){
  3312. "use strict";
  3313. var _Object$defineProperty = _dereq_("@babel/runtime-corejs3/core-js-stable/object/define-property");
  3314. var _interopRequireDefault = _dereq_("@babel/runtime-corejs3/helpers/interopRequireDefault");
  3315. _Object$defineProperty(exports, "__esModule", {
  3316. value: true
  3317. });
  3318. exports.default = void 0;
  3319. var _regenerator = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/regenerator"));
  3320. var _keys = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/object/keys"));
  3321. var _filter = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/instance/filter"));
  3322. var _from = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/array/from"));
  3323. var _slice = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/instance/slice"));
  3324. var _asyncToGenerator2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/helpers/asyncToGenerator"));
  3325. var _classCallCheck2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/helpers/classCallCheck"));
  3326. var _createClass2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/helpers/createClass"));
  3327. var _ParseUser = _interopRequireDefault(_dereq_("./ParseUser"));
  3328. var _ParseQuery = _interopRequireDefault(_dereq_("./ParseQuery"));
  3329. var _ParseObject = _interopRequireDefault(_dereq_("./ParseObject"));
  3330. var _ParseACL = _interopRequireDefault(_dereq_("./ParseACL"));
  3331. var _createSigningData = _interopRequireDefault(_dereq_("./createSigningData"));
  3332. /* global window */
  3333. var web3EnablePromise = null;
  3334. var MoralisDot = /*#__PURE__*/function () {
  3335. function MoralisDot() {
  3336. (0, _classCallCheck2.default)(this, MoralisDot);
  3337. }
  3338. (0, _createClass2.default)(MoralisDot, null, [{
  3339. key: "web3IsInjected",
  3340. value: function () {
  3341. return (0, _keys.default)(window.injectedWeb3).length !== 0;
  3342. }
  3343. }, {
  3344. key: "enable",
  3345. value: function () {
  3346. var _enable = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee(opts) {
  3347. var _window$injectedWeb, _window$injectedWeb$t;
  3348. var type,
  3349. _args = arguments;
  3350. return _regenerator.default.wrap(function (_context) {
  3351. while (1) {
  3352. switch (_context.prev = _context.next) {
  3353. case 0:
  3354. type = _args.length > 1 && _args[1] !== undefined ? _args[1] : 'polkadot-js';
  3355. if (!web3EnablePromise) {
  3356. _context.next = 3;
  3357. break;
  3358. }
  3359. return _context.abrupt("return", web3EnablePromise);
  3360. case 3:
  3361. web3EnablePromise = (_window$injectedWeb = window.injectedWeb3) === null || _window$injectedWeb === void 0 ? void 0 : (_window$injectedWeb$t = _window$injectedWeb[type]) === null || _window$injectedWeb$t === void 0 ? void 0 : _window$injectedWeb$t.enable(opts);
  3362. return _context.abrupt("return", web3EnablePromise);
  3363. case 5:
  3364. case "end":
  3365. return _context.stop();
  3366. }
  3367. }
  3368. }, _callee);
  3369. }));
  3370. return function () {
  3371. return _enable.apply(this, arguments);
  3372. };
  3373. }()
  3374. }, {
  3375. key: "authenticate",
  3376. value: function () {
  3377. var _authenticate = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee2(opts) {
  3378. var _opts$name;
  3379. var allAccounts, account, address, dotAddress, accounts, message, data, signature, authData, user;
  3380. return _regenerator.default.wrap(function (_context2) {
  3381. while (1) {
  3382. switch (_context2.prev = _context2.next) {
  3383. case 0:
  3384. _context2.next = 2;
  3385. return MoralisDot.enable((_opts$name = opts === null || opts === void 0 ? void 0 : opts.name) !== null && _opts$name !== void 0 ? _opts$name : 'Moralis');
  3386. case 2:
  3387. MoralisDot.web3 = _context2.sent;
  3388. _context2.next = 5;
  3389. return MoralisDot.web3.accounts.get();
  3390. case 5:
  3391. allAccounts = _context2.sent;
  3392. account = allAccounts[0];
  3393. address = account === null || account === void 0 ? void 0 : account.address;
  3394. if (address) {
  3395. _context2.next = 10;
  3396. break;
  3397. }
  3398. throw new Error('Address not found');
  3399. case 10:
  3400. dotAddress = address;
  3401. accounts = [dotAddress];
  3402. message = MoralisDot.getSigningData();
  3403. _context2.next = 15;
  3404. return (0, _createSigningData.default)(message);
  3405. case 15:
  3406. data = _context2.sent;
  3407. _context2.next = 18;
  3408. return MoralisDot.sign(address, data);
  3409. case 18:
  3410. signature = _context2.sent;
  3411. authData = {
  3412. id: dotAddress,
  3413. signature: signature,
  3414. data: data
  3415. };
  3416. _context2.next = 22;
  3417. return _ParseUser.default.logInWith('moralisDot', {
  3418. authData: authData
  3419. });
  3420. case 22:
  3421. user = _context2.sent;
  3422. if (user) {
  3423. _context2.next = 25;
  3424. break;
  3425. }
  3426. throw new Error('Could not get user');
  3427. case 25:
  3428. _context2.next = 27;
  3429. return user.setACL(new _ParseACL.default(user));
  3430. case 27:
  3431. user.addAllUnique('dotAccounts', accounts);
  3432. user.set('dotAddress', dotAddress);
  3433. _context2.next = 31;
  3434. return user.save();
  3435. case 31:
  3436. return _context2.abrupt("return", user);
  3437. case 32:
  3438. case "end":
  3439. return _context2.stop();
  3440. }
  3441. }
  3442. }, _callee2);
  3443. }));
  3444. return function () {
  3445. return _authenticate.apply(this, arguments);
  3446. };
  3447. }()
  3448. }, {
  3449. key: "link",
  3450. value: function () {
  3451. var _link = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee3(account, options) {
  3452. var message, user, dotAddress, DotAddress, query, dotAddressRecord, data, signature, authData;
  3453. return _regenerator.default.wrap(function (_context3) {
  3454. while (1) {
  3455. switch (_context3.prev = _context3.next) {
  3456. case 0:
  3457. message = (options === null || options === void 0 ? void 0 : options.signingMessage) || MoralisDot.getSigningData();
  3458. _context3.next = 3;
  3459. return _ParseUser.default.current();
  3460. case 3:
  3461. user = _context3.sent;
  3462. dotAddress = account;
  3463. DotAddress = _ParseObject.default.extend('_DotAddress');
  3464. query = new _ParseQuery.default(DotAddress);
  3465. _context3.next = 9;
  3466. return query.get(dotAddress).catch(function () {
  3467. return null;
  3468. });
  3469. case 9:
  3470. dotAddressRecord = _context3.sent;
  3471. if (dotAddressRecord) {
  3472. _context3.next = 20;
  3473. break;
  3474. }
  3475. _context3.next = 13;
  3476. return (0, _createSigningData.default)(message);
  3477. case 13:
  3478. data = _context3.sent;
  3479. _context3.next = 16;
  3480. return MoralisDot.sign(dotAddress, data);
  3481. case 16:
  3482. signature = _context3.sent;
  3483. authData = {
  3484. id: dotAddress,
  3485. signature: signature,
  3486. data: data
  3487. };
  3488. _context3.next = 20;
  3489. return user.linkWith('moralisDot', {
  3490. authData: authData
  3491. });
  3492. case 20:
  3493. user.addAllUnique('dotAccounts', [dotAddress]);
  3494. user.set('dotAddress', dotAddress);
  3495. _context3.next = 24;
  3496. return user.save();
  3497. case 24:
  3498. return _context3.abrupt("return", user);
  3499. case 25:
  3500. case "end":
  3501. return _context3.stop();
  3502. }
  3503. }
  3504. }, _callee3);
  3505. }));
  3506. return function () {
  3507. return _link.apply(this, arguments);
  3508. };
  3509. }()
  3510. }, {
  3511. key: "unlink",
  3512. value: function () {
  3513. var _unlink = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee4(account) {
  3514. var _user$get;
  3515. var accountsLower, DotAddress, query, dotAddressRecord, user, accounts, nextAccounts;
  3516. return _regenerator.default.wrap(function (_context4) {
  3517. while (1) {
  3518. switch (_context4.prev = _context4.next) {
  3519. case 0:
  3520. accountsLower = account;
  3521. DotAddress = _ParseObject.default.extend('_DotAddress');
  3522. query = new _ParseQuery.default(DotAddress);
  3523. _context4.next = 5;
  3524. return query.get(accountsLower);
  3525. case 5:
  3526. dotAddressRecord = _context4.sent;
  3527. _context4.next = 8;
  3528. return dotAddressRecord.destroy();
  3529. case 8:
  3530. _context4.next = 10;
  3531. return _ParseUser.default.current();
  3532. case 10:
  3533. user = _context4.sent;
  3534. accounts = (_user$get = user.get('dotAccounts')) !== null && _user$get !== void 0 ? _user$get : [];
  3535. nextAccounts = (0, _filter.default)(accounts).call(accounts, function (v) {
  3536. return v !== accountsLower;
  3537. });
  3538. user.set('dotAccounts', nextAccounts);
  3539. user.set('dotAddress', nextAccounts[0]);
  3540. _context4.next = 17;
  3541. return user._unlinkFrom('moralisDot');
  3542. case 17:
  3543. _context4.next = 19;
  3544. return user.save();
  3545. case 19:
  3546. return _context4.abrupt("return", user);
  3547. case 20:
  3548. case "end":
  3549. return _context4.stop();
  3550. }
  3551. }
  3552. }, _callee4);
  3553. }));
  3554. return function () {
  3555. return _unlink.apply(this, arguments);
  3556. };
  3557. }()
  3558. }, {
  3559. key: "sign",
  3560. value: function () {
  3561. var _sign = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee5(address, data) {
  3562. var web3, _yield$web3$signer$si, signature;
  3563. return _regenerator.default.wrap(function (_context5) {
  3564. while (1) {
  3565. switch (_context5.prev = _context5.next) {
  3566. case 0:
  3567. if (web3EnablePromise) {
  3568. _context5.next = 2;
  3569. break;
  3570. }
  3571. throw new Error('Must enable MoralisDot');
  3572. case 2:
  3573. _context5.next = 4;
  3574. return web3EnablePromise;
  3575. case 4:
  3576. web3 = _context5.sent;
  3577. if (web3.signer) {
  3578. _context5.next = 7;
  3579. break;
  3580. }
  3581. throw new Error('No signer found');
  3582. case 7:
  3583. _context5.next = 9;
  3584. return web3.signer.signRaw({
  3585. address: address,
  3586. data: stringToHex(data),
  3587. type: 'bytes'
  3588. });
  3589. case 9:
  3590. _yield$web3$signer$si = _context5.sent;
  3591. signature = _yield$web3$signer$si.signature;
  3592. return _context5.abrupt("return", signature);
  3593. case 12:
  3594. case "end":
  3595. return _context5.stop();
  3596. }
  3597. }
  3598. }, _callee5);
  3599. }));
  3600. return function () {
  3601. return _sign.apply(this, arguments);
  3602. };
  3603. }()
  3604. }, {
  3605. key: "getSigningData",
  3606. value: function () {
  3607. return 'Moralis Authentication';
  3608. }
  3609. }]);
  3610. return MoralisDot;
  3611. }();
  3612. var _default = MoralisDot;
  3613. exports.default = _default;
  3614. function stringToHex(value) {
  3615. return toHexString(stringToU8a(value));
  3616. }
  3617. function stringToU8a(value) {
  3618. var u8a = new Uint8Array(value.length);
  3619. for (var i = 0; i < value.length; i++) {
  3620. u8a[i] = value.charCodeAt(i);
  3621. }
  3622. return u8a;
  3623. }
  3624. function toHexString(byteArray) {
  3625. return "0x".concat((0, _from.default)(byteArray, function (byte) {
  3626. var _context6; // eslint-disable-next-line no-bitwise
  3627. return (0, _slice.default)(_context6 = "0".concat((byte & 0xff).toString(16))).call(_context6, -2);
  3628. }).join(''));
  3629. }
  3630. },{"./ParseACL":26,"./ParseObject":36,"./ParseQuery":39,"./ParseUser":44,"./createSigningData":64,"@babel/runtime-corejs3/core-js-stable/array/from":78,"@babel/runtime-corejs3/core-js-stable/instance/filter":84,"@babel/runtime-corejs3/core-js-stable/instance/slice":93,"@babel/runtime-corejs3/core-js-stable/object/define-property":105,"@babel/runtime-corejs3/core-js-stable/object/keys":112,"@babel/runtime-corejs3/helpers/asyncToGenerator":144,"@babel/runtime-corejs3/helpers/classCallCheck":145,"@babel/runtime-corejs3/helpers/createClass":147,"@babel/runtime-corejs3/helpers/interopRequireDefault":152,"@babel/runtime-corejs3/regenerator":167}],17:[function(_dereq_,module,exports){
  3631. "use strict";
  3632. var _Object$defineProperty = _dereq_("@babel/runtime-corejs3/core-js-stable/object/define-property");
  3633. var _interopRequireDefault = _dereq_("@babel/runtime-corejs3/helpers/interopRequireDefault");
  3634. _Object$defineProperty(exports, "__esModule", {
  3635. value: true
  3636. });
  3637. exports.default = void 0;
  3638. var _filter = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/instance/filter"));
  3639. var _regenerator = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/regenerator"));
  3640. var _asyncToGenerator2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/helpers/asyncToGenerator"));
  3641. var _classCallCheck2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/helpers/classCallCheck"));
  3642. var _createClass2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/helpers/createClass"));
  3643. var _ParseUser = _interopRequireDefault(_dereq_("./ParseUser"));
  3644. var _ParseQuery = _interopRequireDefault(_dereq_("./ParseQuery"));
  3645. var _ParseObject = _interopRequireDefault(_dereq_("./ParseObject"));
  3646. var _ParseACL = _interopRequireDefault(_dereq_("./ParseACL"));
  3647. var _createSigningData = _interopRequireDefault(_dereq_("./createSigningData"));
  3648. /* global window */
  3649. var INIT_ERROR = 'Could not initialise ledger app, make sure Elrond app is open';
  3650. function getErdJs() {
  3651. return MoralisErd.getErdJs();
  3652. }
  3653. var MoralisErd = /*#__PURE__*/function () {
  3654. function MoralisErd() {
  3655. (0, _classCallCheck2.default)(this, MoralisErd);
  3656. }
  3657. (0, _createClass2.default)(MoralisErd, null, [{
  3658. key: "getErdJs",
  3659. value: function () {
  3660. if (typeof window !== 'undefined' && window.erdjs) return window.erdjs;
  3661. throw new Error('Please add erdjs scripts');
  3662. }
  3663. }, {
  3664. key: "gatewayAddress",
  3665. value: function () {
  3666. return 'https://gateway.elrond.com';
  3667. }
  3668. }, {
  3669. key: "hwProxy",
  3670. value: function () {
  3671. var _hwProxy = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee() {
  3672. var _getErdJs, ProxyProvider, proxy;
  3673. return _regenerator.default.wrap(function (_context) {
  3674. while (1) {
  3675. switch (_context.prev = _context.next) {
  3676. case 0:
  3677. if (!MoralisErd._proxy) {
  3678. _context.next = 2;
  3679. break;
  3680. }
  3681. return _context.abrupt("return", MoralisErd._proxy);
  3682. case 2:
  3683. _getErdJs = getErdJs(), ProxyProvider = _getErdJs.ProxyProvider;
  3684. proxy = new ProxyProvider(MoralisErd.gatewayAddress());
  3685. MoralisErd._proxy = proxy;
  3686. return _context.abrupt("return", MoralisErd._proxy);
  3687. case 6:
  3688. case "end":
  3689. return _context.stop();
  3690. }
  3691. }
  3692. }, _callee);
  3693. }));
  3694. return function () {
  3695. return _hwProxy.apply(this, arguments);
  3696. };
  3697. }()
  3698. }, {
  3699. key: "hwProvider",
  3700. value: function () {
  3701. return MoralisErd._hw;
  3702. }
  3703. }, {
  3704. key: "enable",
  3705. value: function () {
  3706. var _enable = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee2() {
  3707. var _getErdJs2, HWProvider, proxy, hw, success;
  3708. return _regenerator.default.wrap(function (_context2) {
  3709. while (1) {
  3710. switch (_context2.prev = _context2.next) {
  3711. case 0:
  3712. _getErdJs2 = getErdJs(), HWProvider = _getErdJs2.HWProvider;
  3713. _context2.next = 3;
  3714. return MoralisErd.hwProxy();
  3715. case 3:
  3716. proxy = _context2.sent;
  3717. hw = new HWProvider(proxy);
  3718. _context2.next = 7;
  3719. return hw.init();
  3720. case 7:
  3721. success = _context2.sent;
  3722. if (success) {
  3723. _context2.next = 10;
  3724. break;
  3725. }
  3726. throw new Error(INIT_ERROR);
  3727. case 10:
  3728. MoralisErd._hw = hw;
  3729. return _context2.abrupt("return", hw);
  3730. case 12:
  3731. case "end":
  3732. return _context2.stop();
  3733. }
  3734. }
  3735. }, _callee2);
  3736. }));
  3737. return function () {
  3738. return _enable.apply(this, arguments);
  3739. };
  3740. }()
  3741. }, {
  3742. key: "authenticate",
  3743. value: function () {
  3744. var _authenticate = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee3() {
  3745. var hw, address, erdAddress, accounts, message, data, signature, authData, user;
  3746. return _regenerator.default.wrap(function (_context3) {
  3747. while (1) {
  3748. switch (_context3.prev = _context3.next) {
  3749. case 0:
  3750. _context3.next = 2;
  3751. return MoralisErd.enable();
  3752. case 2:
  3753. hw = _context3.sent;
  3754. _context3.next = 5;
  3755. return hw.login();
  3756. case 5:
  3757. address = _context3.sent; // const account = await proxy.getAccount(address);
  3758. erdAddress = address.toLowerCase();
  3759. accounts = [erdAddress];
  3760. message = MoralisErd.getSigningData();
  3761. _context3.next = 11;
  3762. return (0, _createSigningData.default)(message);
  3763. case 11:
  3764. data = _context3.sent;
  3765. _context3.next = 14;
  3766. return MoralisErd.sign(data);
  3767. case 14:
  3768. signature = _context3.sent;
  3769. authData = {
  3770. id: erdAddress,
  3771. signature: signature,
  3772. data: data
  3773. };
  3774. _context3.next = 18;
  3775. return _ParseUser.default.logInWith('moralisErd', {
  3776. authData: authData
  3777. });
  3778. case 18:
  3779. user = _context3.sent;
  3780. if (user) {
  3781. _context3.next = 21;
  3782. break;
  3783. }
  3784. throw new Error('Could not get user');
  3785. case 21:
  3786. _context3.next = 23;
  3787. return user.setACL(new _ParseACL.default(user));
  3788. case 23:
  3789. user.addAllUnique('erdAccounts', accounts);
  3790. user.set('erdAddress', erdAddress);
  3791. _context3.next = 27;
  3792. return user.save();
  3793. case 27:
  3794. return _context3.abrupt("return", user);
  3795. case 28:
  3796. case "end":
  3797. return _context3.stop();
  3798. }
  3799. }
  3800. }, _callee3);
  3801. }));
  3802. return function () {
  3803. return _authenticate.apply(this, arguments);
  3804. };
  3805. }()
  3806. }, {
  3807. key: "link",
  3808. value: function () {
  3809. var _link = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee4(account, options) {
  3810. var message, user, erdAddress, ErdAddress, query, erdAddressRecord, data, signature, authData;
  3811. return _regenerator.default.wrap(function (_context4) {
  3812. while (1) {
  3813. switch (_context4.prev = _context4.next) {
  3814. case 0:
  3815. message = (options === null || options === void 0 ? void 0 : options.signingMessage) || MoralisErd.getSigningData();
  3816. _context4.next = 3;
  3817. return _ParseUser.default.current();
  3818. case 3:
  3819. user = _context4.sent;
  3820. erdAddress = account.toLowerCase();
  3821. ErdAddress = _ParseObject.default.extend('_ErdAddress');
  3822. query = new _ParseQuery.default(ErdAddress);
  3823. _context4.next = 9;
  3824. return query.get(erdAddress).catch(function () {
  3825. return null;
  3826. });
  3827. case 9:
  3828. erdAddressRecord = _context4.sent;
  3829. if (erdAddressRecord) {
  3830. _context4.next = 20;
  3831. break;
  3832. }
  3833. _context4.next = 13;
  3834. return (0, _createSigningData.default)(message);
  3835. case 13:
  3836. data = _context4.sent;
  3837. _context4.next = 16;
  3838. return MoralisErd.sign(data);
  3839. case 16:
  3840. signature = _context4.sent;
  3841. authData = {
  3842. id: erdAddress,
  3843. signature: signature,
  3844. data: data
  3845. };
  3846. _context4.next = 20;
  3847. return user.linkWith('moralisErd', {
  3848. authData: authData
  3849. });
  3850. case 20:
  3851. user.addAllUnique('erdAccounts', [erdAddress]);
  3852. user.set('erdAddress', erdAddress);
  3853. _context4.next = 24;
  3854. return user.save();
  3855. case 24:
  3856. return _context4.abrupt("return", user);
  3857. case 25:
  3858. case "end":
  3859. return _context4.stop();
  3860. }
  3861. }
  3862. }, _callee4);
  3863. }));
  3864. return function () {
  3865. return _link.apply(this, arguments);
  3866. };
  3867. }()
  3868. }, {
  3869. key: "unlink",
  3870. value: function () {
  3871. var _unlink = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee5(account) {
  3872. var _user$get;
  3873. var accountsLower, ErdAddress, query, erdAddressRecord, user, accounts, nextAccounts;
  3874. return _regenerator.default.wrap(function (_context5) {
  3875. while (1) {
  3876. switch (_context5.prev = _context5.next) {
  3877. case 0:
  3878. accountsLower = account.toLowerCase();
  3879. ErdAddress = _ParseObject.default.extend('_ErdAddress');
  3880. query = new _ParseQuery.default(ErdAddress);
  3881. _context5.next = 5;
  3882. return query.get(accountsLower);
  3883. case 5:
  3884. erdAddressRecord = _context5.sent;
  3885. _context5.next = 8;
  3886. return erdAddressRecord.destroy();
  3887. case 8:
  3888. _context5.next = 10;
  3889. return _ParseUser.default.current();
  3890. case 10:
  3891. user = _context5.sent;
  3892. accounts = (_user$get = user.get('erdAccounts')) !== null && _user$get !== void 0 ? _user$get : [];
  3893. nextAccounts = (0, _filter.default)(accounts).call(accounts, function (v) {
  3894. return v !== accountsLower;
  3895. });
  3896. user.set('erdAccounts', nextAccounts);
  3897. user.set('erdAddress', nextAccounts[0]);
  3898. _context5.next = 17;
  3899. return user._unlinkFrom('moralisErd');
  3900. case 17:
  3901. _context5.next = 19;
  3902. return user.save();
  3903. case 19:
  3904. return _context5.abrupt("return", user);
  3905. case 20:
  3906. case "end":
  3907. return _context5.stop();
  3908. }
  3909. }
  3910. }, _callee5);
  3911. }));
  3912. return function () {
  3913. return _unlink.apply(this, arguments);
  3914. };
  3915. }()
  3916. }, {
  3917. key: "sign",
  3918. value: function () {
  3919. var _sign = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee6(data) {
  3920. return _regenerator.default.wrap(function (_context6) {
  3921. while (1) {
  3922. switch (_context6.prev = _context6.next) {
  3923. case 0:
  3924. return _context6.abrupt("return", data);
  3925. case 1:
  3926. case "end":
  3927. return _context6.stop();
  3928. }
  3929. }
  3930. }, _callee6);
  3931. }));
  3932. return function () {
  3933. return _sign.apply(this, arguments);
  3934. };
  3935. }()
  3936. }, {
  3937. key: "getSigningData",
  3938. value: function () {
  3939. return 'Moralis Authentication';
  3940. }
  3941. }]);
  3942. return MoralisErd;
  3943. }();
  3944. var _default = MoralisErd;
  3945. exports.default = _default;
  3946. },{"./ParseACL":26,"./ParseObject":36,"./ParseQuery":39,"./ParseUser":44,"./createSigningData":64,"@babel/runtime-corejs3/core-js-stable/instance/filter":84,"@babel/runtime-corejs3/core-js-stable/object/define-property":105,"@babel/runtime-corejs3/helpers/asyncToGenerator":144,"@babel/runtime-corejs3/helpers/classCallCheck":145,"@babel/runtime-corejs3/helpers/createClass":147,"@babel/runtime-corejs3/helpers/interopRequireDefault":152,"@babel/runtime-corejs3/regenerator":167}],18:[function(_dereq_,module,exports){
  3947. "use strict";
  3948. var _Object$defineProperty = _dereq_("@babel/runtime-corejs3/core-js-stable/object/define-property");
  3949. var _interopRequireDefault = _dereq_("@babel/runtime-corejs3/helpers/interopRequireDefault");
  3950. _Object$defineProperty(exports, "__esModule", {
  3951. value: true
  3952. });
  3953. exports.default = void 0;
  3954. var _regenerator = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/regenerator"));
  3955. var _concat = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/instance/concat"));
  3956. var _filter = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/instance/filter"));
  3957. var _reduce = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/instance/reduce"));
  3958. var _padStart = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/instance/pad-start"));
  3959. var _indexOf = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/instance/index-of"));
  3960. var _asyncToGenerator2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/helpers/asyncToGenerator"));
  3961. var _classCallCheck2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/helpers/classCallCheck"));
  3962. var _createClass2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/helpers/createClass"));
  3963. var _defineProperty2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/helpers/defineProperty"));
  3964. var _toConsumableArray2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/helpers/toConsumableArray"));
  3965. var _createSigningData = _interopRequireDefault(_dereq_("./createSigningData"));
  3966. var _ParseUser = _interopRequireDefault(_dereq_("./ParseUser"));
  3967. var _ParseQuery = _interopRequireDefault(_dereq_("./ParseQuery"));
  3968. var _ParseObject = _interopRequireDefault(_dereq_("./ParseObject"));
  3969. var _ParseACL = _interopRequireDefault(_dereq_("./ParseACL"));
  3970. /* global window */
  3971. /* global solanaWeb3 */
  3972. var base64 = {
  3973. decode: function (s) {
  3974. return Uint8Array.from(atob(s), function (c) {
  3975. return c.charCodeAt(0);
  3976. });
  3977. },
  3978. encode: function (b) {
  3979. return btoa(String.fromCharCode.apply(String, (0, _toConsumableArray2.default)(new Uint8Array(b))));
  3980. }
  3981. };
  3982. var MoralisSol = /*#__PURE__*/function () {
  3983. function MoralisSol() {
  3984. (0, _classCallCheck2.default)(this, MoralisSol);
  3985. }
  3986. (0, _createClass2.default)(MoralisSol, null, [{
  3987. key: "authenticate",
  3988. value: function () {
  3989. var _authenticate = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee(options) {
  3990. var _context, _user$get;
  3991. var phantom, solAddress, accounts, message, data, signature, authData, user;
  3992. return _regenerator.default.wrap(function (_context2) {
  3993. while (1) {
  3994. switch (_context2.prev = _context2.next) {
  3995. case 0:
  3996. _context2.next = 2;
  3997. return MoralisSol.enable();
  3998. case 2:
  3999. phantom = _context2.sent;
  4000. if (phantom) {
  4001. _context2.next = 5;
  4002. break;
  4003. }
  4004. throw new Error('Phantom wallet not available');
  4005. case 5:
  4006. solAddress = phantom.publicKey.toString();
  4007. if (solAddress) {
  4008. _context2.next = 8;
  4009. break;
  4010. }
  4011. throw new Error('Address not found');
  4012. case 8:
  4013. accounts = [solAddress];
  4014. message = (options === null || options === void 0 ? void 0 : options.signingMessage) || MoralisSol.getSigningData();
  4015. _context2.next = 12;
  4016. return (0, _createSigningData.default)(message);
  4017. case 12:
  4018. data = _context2.sent;
  4019. _context2.next = 15;
  4020. return MoralisSol.sign(data);
  4021. case 15:
  4022. signature = _context2.sent;
  4023. authData = {
  4024. id: solAddress,
  4025. signature: signature,
  4026. data: data
  4027. };
  4028. _context2.next = 19;
  4029. return _ParseUser.default.logInWith('moralisSol', {
  4030. authData: authData
  4031. });
  4032. case 19:
  4033. user = _context2.sent;
  4034. _context2.next = 22;
  4035. return user.setACL(new _ParseACL.default(user));
  4036. case 22:
  4037. if (user) {
  4038. _context2.next = 24;
  4039. break;
  4040. }
  4041. throw new Error('Could not get user');
  4042. case 24:
  4043. user.set('solAccounts', uniq((0, _concat.default)(_context = []).call(_context, accounts, (_user$get = user.get('solAccounts')) !== null && _user$get !== void 0 ? _user$get : [])));
  4044. user.set('solAddress', solAddress);
  4045. _context2.next = 28;
  4046. return user.save();
  4047. case 28:
  4048. return _context2.abrupt("return", user);
  4049. case 29:
  4050. case "end":
  4051. return _context2.stop();
  4052. }
  4053. }
  4054. }, _callee);
  4055. }));
  4056. return function () {
  4057. return _authenticate.apply(this, arguments);
  4058. };
  4059. }()
  4060. }, {
  4061. key: "link",
  4062. value: function () {
  4063. var _link = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee2(account, options) {
  4064. var _context3, _user$get2;
  4065. var message, user, solAddress, SolAddress, query, solAddressRecord, data, signature, authData;
  4066. return _regenerator.default.wrap(function (_context4) {
  4067. while (1) {
  4068. switch (_context4.prev = _context4.next) {
  4069. case 0:
  4070. message = (options === null || options === void 0 ? void 0 : options.signingMessage) || MoralisSol.getSigningData();
  4071. _context4.next = 3;
  4072. return _ParseUser.default.current();
  4073. case 3:
  4074. user = _context4.sent;
  4075. solAddress = account;
  4076. SolAddress = _ParseObject.default.extend('_SolAddress');
  4077. query = new _ParseQuery.default(SolAddress);
  4078. _context4.next = 9;
  4079. return query.get(solAddress).catch(function () {
  4080. return null;
  4081. });
  4082. case 9:
  4083. solAddressRecord = _context4.sent;
  4084. if (solAddressRecord) {
  4085. _context4.next = 20;
  4086. break;
  4087. }
  4088. _context4.next = 13;
  4089. return (0, _createSigningData.default)(message);
  4090. case 13:
  4091. data = _context4.sent;
  4092. _context4.next = 16;
  4093. return MoralisSol.sign(solAddress, data);
  4094. case 16:
  4095. signature = _context4.sent;
  4096. authData = {
  4097. id: solAddress,
  4098. signature: signature,
  4099. data: data
  4100. };
  4101. _context4.next = 20;
  4102. return user.linkWith('moralisSol', {
  4103. authData: authData
  4104. });
  4105. case 20:
  4106. user.set('SolAccounts', uniq((0, _concat.default)(_context3 = [solAddress]).call(_context3, (_user$get2 = user.get('SolAccounts')) !== null && _user$get2 !== void 0 ? _user$get2 : [])));
  4107. user.set('solAddress', solAddress);
  4108. _context4.next = 24;
  4109. return user.save();
  4110. case 24:
  4111. return _context4.abrupt("return", user);
  4112. case 25:
  4113. case "end":
  4114. return _context4.stop();
  4115. }
  4116. }
  4117. }, _callee2);
  4118. }));
  4119. return function () {
  4120. return _link.apply(this, arguments);
  4121. };
  4122. }()
  4123. }, {
  4124. key: "unlink",
  4125. value: function () {
  4126. var _unlink = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee3(account) {
  4127. var _user$get3;
  4128. var accountsLower, SolAddress, query, solAddressRecord, user, accounts, nextAccounts;
  4129. return _regenerator.default.wrap(function (_context5) {
  4130. while (1) {
  4131. switch (_context5.prev = _context5.next) {
  4132. case 0:
  4133. accountsLower = account;
  4134. SolAddress = _ParseObject.default.extend('_SolAddress');
  4135. query = new _ParseQuery.default(SolAddress);
  4136. _context5.next = 5;
  4137. return query.get(accountsLower);
  4138. case 5:
  4139. solAddressRecord = _context5.sent;
  4140. _context5.next = 8;
  4141. return solAddressRecord.destroy();
  4142. case 8:
  4143. _context5.next = 10;
  4144. return _ParseUser.default.current();
  4145. case 10:
  4146. user = _context5.sent;
  4147. accounts = (_user$get3 = user.get('solAccounts')) !== null && _user$get3 !== void 0 ? _user$get3 : [];
  4148. nextAccounts = (0, _filter.default)(accounts).call(accounts, function (v) {
  4149. return v !== accountsLower;
  4150. });
  4151. user.set('solAccounts', nextAccounts);
  4152. user.set('solAddress', nextAccounts[0]);
  4153. _context5.next = 17;
  4154. return user._unlinkFrom('moralisSol');
  4155. case 17:
  4156. _context5.next = 19;
  4157. return user.save();
  4158. case 19:
  4159. return _context5.abrupt("return", user);
  4160. case 20:
  4161. case "end":
  4162. return _context5.stop();
  4163. }
  4164. }
  4165. }, _callee3);
  4166. }));
  4167. return function () {
  4168. return _unlink.apply(this, arguments);
  4169. };
  4170. }()
  4171. }, {
  4172. key: "sign",
  4173. value: function () {
  4174. var _sign = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee4(message) {
  4175. var phantom, encodedMessage, signedMessage;
  4176. return _regenerator.default.wrap(function (_context6) {
  4177. while (1) {
  4178. switch (_context6.prev = _context6.next) {
  4179. case 0:
  4180. _context6.next = 2;
  4181. return MoralisSol.enable();
  4182. case 2:
  4183. phantom = _context6.sent;
  4184. encodedMessage = new TextEncoder().encode(message);
  4185. _context6.next = 6;
  4186. return phantom.signMessage(encodedMessage, 'utf8');
  4187. case 6:
  4188. signedMessage = _context6.sent;
  4189. return _context6.abrupt("return", base64.encode(signedMessage.signature));
  4190. case 8:
  4191. case "end":
  4192. return _context6.stop();
  4193. }
  4194. }
  4195. }, _callee4);
  4196. }));
  4197. return function () {
  4198. return _sign.apply(this, arguments);
  4199. };
  4200. }()
  4201. }, {
  4202. key: "getSigningData",
  4203. value: function () {
  4204. return 'Moralis Authentication';
  4205. }
  4206. }]);
  4207. return MoralisSol;
  4208. }();
  4209. (0, _defineProperty2.default)(MoralisSol, "enable", /*#__PURE__*/(0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee5() {
  4210. var provider;
  4211. return _regenerator.default.wrap(function (_context8) {
  4212. while (1) {
  4213. switch (_context8.prev = _context8.next) {
  4214. case 0:
  4215. if (!(window && 'solana' in window)) {
  4216. _context8.next = 17;
  4217. break;
  4218. }
  4219. provider = window.solana;
  4220. if (!provider.isPhantom) {
  4221. _context8.next = 17;
  4222. break;
  4223. }
  4224. _context8.prev = 3;
  4225. _context8.next = 6;
  4226. return provider.connect({
  4227. onlyIfTrusted: true
  4228. });
  4229. case 6:
  4230. _context8.next = 16;
  4231. break;
  4232. case 8:
  4233. _context8.prev = 8;
  4234. _context8.t0 = _context8["catch"](3);
  4235. if (!(_context8.t0.message === 'User rejected the request.')) {
  4236. _context8.next = 15;
  4237. break;
  4238. }
  4239. _context8.next = 13;
  4240. return provider.connect();
  4241. case 13:
  4242. _context8.next = 16;
  4243. break;
  4244. case 15:
  4245. throw _context8.t0;
  4246. case 16:
  4247. return _context8.abrupt("return", provider);
  4248. case 17:
  4249. throw new Error('Phantom wallet not available');
  4250. case 18:
  4251. case "end":
  4252. return _context8.stop();
  4253. }
  4254. }
  4255. }, _callee5, null, [[3, 8]]);
  4256. })));
  4257. function toHexString(buffer
  4258. /*: Buffer*/
  4259. ) {
  4260. return (0, _reduce.default)(buffer).call(buffer, function (str, byte) {
  4261. var _context7;
  4262. return str + (0, _padStart.default)(_context7 = byte.toString(16)).call(_context7, 2, '0');
  4263. }, '');
  4264. }
  4265. function uniq(arr) {
  4266. return (0, _filter.default)(arr).call(arr, function (v, i) {
  4267. return (0, _indexOf.default)(arr).call(arr, v) === i;
  4268. });
  4269. }
  4270. var _default = MoralisSol;
  4271. exports.default = _default;
  4272. },{"./ParseACL":26,"./ParseObject":36,"./ParseQuery":39,"./ParseUser":44,"./createSigningData":64,"@babel/runtime-corejs3/core-js-stable/instance/concat":81,"@babel/runtime-corejs3/core-js-stable/instance/filter":84,"@babel/runtime-corejs3/core-js-stable/instance/index-of":88,"@babel/runtime-corejs3/core-js-stable/instance/pad-start":91,"@babel/runtime-corejs3/core-js-stable/instance/reduce":92,"@babel/runtime-corejs3/core-js-stable/object/define-property":105,"@babel/runtime-corejs3/helpers/asyncToGenerator":144,"@babel/runtime-corejs3/helpers/classCallCheck":145,"@babel/runtime-corejs3/helpers/createClass":147,"@babel/runtime-corejs3/helpers/defineProperty":148,"@babel/runtime-corejs3/helpers/interopRequireDefault":152,"@babel/runtime-corejs3/helpers/toConsumableArray":163,"@babel/runtime-corejs3/regenerator":167}],19:[function(_dereq_,module,exports){
  4273. "use strict";
  4274. var _Object$keys2 = _dereq_("@babel/runtime-corejs3/core-js-stable/object/keys");
  4275. var _Object$getOwnPropertySymbols = _dereq_("@babel/runtime-corejs3/core-js-stable/object/get-own-property-symbols");
  4276. var _filterInstanceProperty2 = _dereq_("@babel/runtime-corejs3/core-js-stable/instance/filter");
  4277. var _Object$getOwnPropertyDescriptor = _dereq_("@babel/runtime-corejs3/core-js-stable/object/get-own-property-descriptor");
  4278. var _forEachInstanceProperty2 = _dereq_("@babel/runtime-corejs3/core-js-stable/instance/for-each");
  4279. var _Object$getOwnPropertyDescriptors = _dereq_("@babel/runtime-corejs3/core-js-stable/object/get-own-property-descriptors");
  4280. var _Object$defineProperties = _dereq_("@babel/runtime-corejs3/core-js-stable/object/define-properties");
  4281. var _Object$defineProperty = _dereq_("@babel/runtime-corejs3/core-js-stable/object/define-property");
  4282. var _interopRequireDefault = _dereq_("@babel/runtime-corejs3/helpers/interopRequireDefault");
  4283. _Object$defineProperty(exports, "__esModule", {
  4284. value: true
  4285. });
  4286. exports.default = void 0;
  4287. var _regenerator = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/regenerator"));
  4288. var _forEach = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/instance/for-each"));
  4289. var _keys = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/object/keys"));
  4290. var _filter = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/instance/filter"));
  4291. var _includes = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/instance/includes"));
  4292. var _stringify = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/json/stringify"));
  4293. var _asyncToGenerator2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/helpers/asyncToGenerator"));
  4294. var _classCallCheck2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/helpers/classCallCheck"));
  4295. var _createClass2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/helpers/createClass"));
  4296. var _defineProperty2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/helpers/defineProperty"));
  4297. function ownKeys(object, enumerableOnly) {
  4298. var keys = _Object$keys2(object);
  4299. if (_Object$getOwnPropertySymbols) {
  4300. var symbols = _Object$getOwnPropertySymbols(object);
  4301. enumerableOnly && (symbols = _filterInstanceProperty2(symbols).call(symbols, function (sym) {
  4302. return _Object$getOwnPropertyDescriptor(object, sym).enumerable;
  4303. })), keys.push.apply(keys, symbols);
  4304. }
  4305. return keys;
  4306. }
  4307. function _objectSpread(target) {
  4308. for (var i = 1; i < arguments.length; i++) {
  4309. var _context10, _context11;
  4310. var source = null != arguments[i] ? arguments[i] : {};
  4311. i % 2 ? _forEachInstanceProperty2(_context10 = ownKeys(Object(source), !0)).call(_context10, function (key) {
  4312. (0, _defineProperty2.default)(target, key, source[key]);
  4313. }) : _Object$getOwnPropertyDescriptors ? _Object$defineProperties(target, _Object$getOwnPropertyDescriptors(source)) : _forEachInstanceProperty2(_context11 = ownKeys(Object(source))).call(_context11, function (key) {
  4314. _Object$defineProperty(target, key, _Object$getOwnPropertyDescriptor(source, key));
  4315. });
  4316. }
  4317. return target;
  4318. }
  4319. /**
  4320. * Automatically generated code, via genSolanaAPI.js
  4321. * Do not modify manually
  4322. */
  4323. var axios = _dereq_('axios');
  4324. var SolanaApi = /*#__PURE__*/function () {
  4325. function SolanaApi() {
  4326. (0, _classCallCheck2.default)(this, SolanaApi);
  4327. }
  4328. (0, _createClass2.default)(SolanaApi, null, [{
  4329. key: "initialize",
  4330. value: // URL will be changed when api is deployed
  4331. function (_ref) {
  4332. var apiKey = _ref.apiKey,
  4333. serverUrl = _ref.serverUrl,
  4334. _ref$Moralis = _ref.Moralis,
  4335. Moralis = _ref$Moralis === void 0 ? null : _ref$Moralis;
  4336. if (!serverUrl && !apiKey) {
  4337. throw new Error('SolanaApi.initialize failed: initialize with apiKey or serverUrl');
  4338. }
  4339. if (apiKey) this.apiKey = apiKey;
  4340. if (serverUrl) this.serverUrl = serverUrl;
  4341. this.Moralis = Moralis;
  4342. }
  4343. }, {
  4344. key: "getBody",
  4345. value: function (params, bodyParams) {
  4346. var _this = this;
  4347. if (!params || !bodyParams || !bodyParams.length) {
  4348. return undefined;
  4349. }
  4350. var body = {};
  4351. (0, _forEach.default)(bodyParams).call(bodyParams, function (_ref2) {
  4352. var key = _ref2.key,
  4353. type = _ref2.type,
  4354. required = _ref2.required;
  4355. if (params[key] === undefined) {
  4356. if (required) throw new Error("param ".concat(key, " is required!"));
  4357. } else if (type === _this.BodyParamTypes.setBody) {
  4358. body = params[key];
  4359. } else {
  4360. body[key] = params[key];
  4361. } // remove the param so it doesn't also get added as a query param
  4362. delete params[key];
  4363. });
  4364. return body;
  4365. }
  4366. }, {
  4367. key: "getParameterizedUrl",
  4368. value: function (url, params) {
  4369. var _context;
  4370. if (!(0, _keys.default)(params).length) return url; // find url params, they start with :
  4371. var requiredParams = (0, _filter.default)(_context = url.split('/')).call(_context, function (s) {
  4372. return s && (0, _includes.default)(s).call(s, ':');
  4373. });
  4374. if (!requiredParams.length) return url;
  4375. var parameterizedUrl = url;
  4376. (0, _forEach.default)(requiredParams).call(requiredParams, function (p) {
  4377. // strip the : and replace with param value
  4378. var key = p.substr(1);
  4379. var value = params[key];
  4380. if (!value) {
  4381. throw new Error("required param ".concat(key, " not provided"));
  4382. }
  4383. parameterizedUrl = parameterizedUrl.replace(p, value); // remove required param from param list
  4384. // so it doesn't become part of the query params
  4385. delete params[key];
  4386. });
  4387. return parameterizedUrl;
  4388. }
  4389. }, {
  4390. key: "getApiRateLimitInfo",
  4391. value: function (headers) {
  4392. return {
  4393. 'x-rate-limit-limit': headers['x-rate-limit-limit'],
  4394. 'x-rate-limit-remaining-ttl': headers['x-rate-limit-remaining-ttl'],
  4395. 'x-rate-limit-used': headers['x-rate-limit-used'],
  4396. 'x-rate-limit-remaining-ip-ttl': headers['x-rate-limit-remaining-ip-ttl'],
  4397. 'x-rate-limit-ip-used': headers['x-rate-limit-ip-used']
  4398. };
  4399. }
  4400. }, {
  4401. key: "getErrorMessage",
  4402. value: function (error, url) {
  4403. var _error$response, _error$response$data;
  4404. return (error === null || error === void 0 ? void 0 : (_error$response = error.response) === null || _error$response === void 0 ? void 0 : (_error$response$data = _error$response.data) === null || _error$response$data === void 0 ? void 0 : _error$response$data.message) || (error === null || error === void 0 ? void 0 : error.message) || (error === null || error === void 0 ? void 0 : error.toString()) || "Solana API error while calling ".concat(url);
  4405. }
  4406. }, {
  4407. key: "fetch",
  4408. value: function () {
  4409. var _fetch = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee(_ref3) {
  4410. var endpoint, providedParams, params, User, user;
  4411. return _regenerator.default.wrap(function (_context2) {
  4412. while (1) {
  4413. switch (_context2.prev = _context2.next) {
  4414. case 0:
  4415. endpoint = _ref3.endpoint, providedParams = _ref3.params; // Make a shallow copy to prevent modification of original params
  4416. params = _objectSpread({}, providedParams);
  4417. if (this.Moralis) {
  4418. User = this.Moralis.User;
  4419. user = User.current();
  4420. if (!params.address) {
  4421. if (user) {
  4422. params.address = user.get('solAddress');
  4423. }
  4424. }
  4425. }
  4426. if (!params.network) params.network = 'mainnet';
  4427. if (!params.responseType) params.responseType = 'native';
  4428. if (this.apiKey) {
  4429. _context2.next = 7;
  4430. break;
  4431. }
  4432. return _context2.abrupt("return", this.fetchFromServer(endpoint.name, params));
  4433. case 7:
  4434. return _context2.abrupt("return", this.fetchFromApi(endpoint, params));
  4435. case 8:
  4436. case "end":
  4437. return _context2.stop();
  4438. }
  4439. }
  4440. }, _callee, this);
  4441. }));
  4442. return function () {
  4443. return _fetch.apply(this, arguments);
  4444. };
  4445. }()
  4446. }, {
  4447. key: "fetchFromApi",
  4448. value: function () {
  4449. var _fetchFromApi = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee2(endpoint, params) {
  4450. var _endpoint$method, method, url, bodyParams, parameterizedUrl, body, response, _error$response2, status, headers, data, msg;
  4451. return _regenerator.default.wrap(function (_context3) {
  4452. while (1) {
  4453. switch (_context3.prev = _context3.next) {
  4454. case 0:
  4455. _endpoint$method = endpoint.method, method = _endpoint$method === void 0 ? 'GET' : _endpoint$method, url = endpoint.url, bodyParams = endpoint.bodyParams;
  4456. _context3.prev = 1;
  4457. parameterizedUrl = this.getParameterizedUrl(url, params);
  4458. body = this.getBody(params, bodyParams);
  4459. _context3.next = 6;
  4460. return axios(this.baseURL + parameterizedUrl, {
  4461. params: params,
  4462. method: method,
  4463. body: body,
  4464. headers: {
  4465. Accept: 'application/json',
  4466. 'Content-Type': 'application/json',
  4467. 'x-api-key': this.apiKey
  4468. }
  4469. });
  4470. case 6:
  4471. response = _context3.sent;
  4472. return _context3.abrupt("return", response.data);
  4473. case 10:
  4474. _context3.prev = 10;
  4475. _context3.t0 = _context3["catch"](1);
  4476. _error$response2 = _context3.t0.response, status = _error$response2.status, headers = _error$response2.headers, data = _error$response2.data;
  4477. if (status === 429) {
  4478. msg = "This Moralis Server is rate-limited because of the plan restrictions. See the details about the current rate and throttle limits: ".concat((0, _stringify.default)(this.getApiRateLimitInfo(headers)));
  4479. } else {
  4480. msg = this.getApiErrorMessage(_context3.t0, url);
  4481. }
  4482. throw new Error(msg);
  4483. case 15:
  4484. case "end":
  4485. return _context3.stop();
  4486. }
  4487. }
  4488. }, _callee2, this, [[1, 10]]);
  4489. }));
  4490. return function () {
  4491. return _fetchFromApi.apply(this, arguments);
  4492. };
  4493. }()
  4494. }, {
  4495. key: "fetchFromServer",
  4496. value: function () {
  4497. var _fetchFromServer = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee3(name, options) {
  4498. var http, user, response, _error$response3, _error$response3$data;
  4499. return _regenerator.default.wrap(function (_context4) {
  4500. while (1) {
  4501. switch (_context4.prev = _context4.next) {
  4502. case 0:
  4503. if (this.serverUrl) {
  4504. _context4.next = 2;
  4505. break;
  4506. }
  4507. throw new Error('SolanaAPI not initialized, run Moralis.start() first');
  4508. case 2:
  4509. _context4.prev = 2;
  4510. http = axios.create({
  4511. baseURL: this.serverUrl
  4512. });
  4513. user = this.Moralis.User.current();
  4514. if (user) {
  4515. options._SessionToken = user.attributes.sessionToken;
  4516. options._ApplicationId = this.Moralis.applicationId;
  4517. }
  4518. _context4.next = 8;
  4519. return http.post("/functions/sol-".concat(name), options, {
  4520. headers: {
  4521. Accept: 'application/json',
  4522. 'Content-Type': 'application/json'
  4523. }
  4524. });
  4525. case 8:
  4526. response = _context4.sent;
  4527. return _context4.abrupt("return", response.data.result);
  4528. case 12:
  4529. _context4.prev = 12;
  4530. _context4.t0 = _context4["catch"](2);
  4531. if (!((_error$response3 = _context4.t0.response) !== null && _error$response3 !== void 0 && (_error$response3$data = _error$response3.data) !== null && _error$response3$data !== void 0 && _error$response3$data.error)) {
  4532. _context4.next = 16;
  4533. break;
  4534. }
  4535. throw new Error(_context4.t0.response.data.error);
  4536. case 16:
  4537. throw _context4.t0;
  4538. case 17:
  4539. case "end":
  4540. return _context4.stop();
  4541. }
  4542. }
  4543. }, _callee3, this, [[2, 12]]);
  4544. }));
  4545. return function () {
  4546. return _fetchFromServer.apply(this, arguments);
  4547. };
  4548. }()
  4549. }]);
  4550. return SolanaApi;
  4551. }();
  4552. (0, _defineProperty2.default)(SolanaApi, "baseURL", 'https://solana-gateway.moralis.io');
  4553. (0, _defineProperty2.default)(SolanaApi, "BodyParamTypes", {
  4554. setBody: 'set body',
  4555. property: 'property'
  4556. });
  4557. (0, _defineProperty2.default)(SolanaApi, "account", {
  4558. balance: function () {
  4559. var _balance = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee4() {
  4560. var options,
  4561. _args4 = arguments;
  4562. return _regenerator.default.wrap(function (_context5) {
  4563. while (1) {
  4564. switch (_context5.prev = _context5.next) {
  4565. case 0:
  4566. options = _args4.length > 0 && _args4[0] !== undefined ? _args4[0] : {};
  4567. return _context5.abrupt("return", SolanaApi.fetch({
  4568. endpoint: {
  4569. "method": "GET",
  4570. "group": "account",
  4571. "name": "balance",
  4572. "url": "/account/:network/:address/balance"
  4573. },
  4574. params: options
  4575. }));
  4576. case 2:
  4577. case "end":
  4578. return _context5.stop();
  4579. }
  4580. }
  4581. }, _callee4);
  4582. }));
  4583. return function () {
  4584. return _balance.apply(this, arguments);
  4585. };
  4586. }(),
  4587. getSPL: function () {
  4588. var _getSPL = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee5() {
  4589. var options,
  4590. _args5 = arguments;
  4591. return _regenerator.default.wrap(function (_context6) {
  4592. while (1) {
  4593. switch (_context6.prev = _context6.next) {
  4594. case 0:
  4595. options = _args5.length > 0 && _args5[0] !== undefined ? _args5[0] : {};
  4596. return _context6.abrupt("return", SolanaApi.fetch({
  4597. endpoint: {
  4598. "method": "GET",
  4599. "group": "account",
  4600. "name": "getSPL",
  4601. "url": "/account/:network/:address/tokens"
  4602. },
  4603. params: options
  4604. }));
  4605. case 2:
  4606. case "end":
  4607. return _context6.stop();
  4608. }
  4609. }
  4610. }, _callee5);
  4611. }));
  4612. return function () {
  4613. return _getSPL.apply(this, arguments);
  4614. };
  4615. }(),
  4616. getNFTs: function () {
  4617. var _getNFTs = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee6() {
  4618. var options,
  4619. _args6 = arguments;
  4620. return _regenerator.default.wrap(function (_context7) {
  4621. while (1) {
  4622. switch (_context7.prev = _context7.next) {
  4623. case 0:
  4624. options = _args6.length > 0 && _args6[0] !== undefined ? _args6[0] : {};
  4625. return _context7.abrupt("return", SolanaApi.fetch({
  4626. endpoint: {
  4627. "method": "GET",
  4628. "group": "account",
  4629. "name": "getNFTs",
  4630. "url": "/account/:network/:address/nft"
  4631. },
  4632. params: options
  4633. }));
  4634. case 2:
  4635. case "end":
  4636. return _context7.stop();
  4637. }
  4638. }
  4639. }, _callee6);
  4640. }));
  4641. return function () {
  4642. return _getNFTs.apply(this, arguments);
  4643. };
  4644. }(),
  4645. getPortfolio: function () {
  4646. var _getPortfolio = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee7() {
  4647. var options,
  4648. _args7 = arguments;
  4649. return _regenerator.default.wrap(function (_context8) {
  4650. while (1) {
  4651. switch (_context8.prev = _context8.next) {
  4652. case 0:
  4653. options = _args7.length > 0 && _args7[0] !== undefined ? _args7[0] : {};
  4654. return _context8.abrupt("return", SolanaApi.fetch({
  4655. endpoint: {
  4656. "method": "GET",
  4657. "group": "account",
  4658. "name": "getPortfolio",
  4659. "url": "/account/:network/:address/portfolio"
  4660. },
  4661. params: options
  4662. }));
  4663. case 2:
  4664. case "end":
  4665. return _context8.stop();
  4666. }
  4667. }
  4668. }, _callee7);
  4669. }));
  4670. return function () {
  4671. return _getPortfolio.apply(this, arguments);
  4672. };
  4673. }()
  4674. });
  4675. (0, _defineProperty2.default)(SolanaApi, "nft", {
  4676. getNFTMetadata: function () {
  4677. var _getNFTMetadata = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee8() {
  4678. var options,
  4679. _args8 = arguments;
  4680. return _regenerator.default.wrap(function (_context9) {
  4681. while (1) {
  4682. switch (_context9.prev = _context9.next) {
  4683. case 0:
  4684. options = _args8.length > 0 && _args8[0] !== undefined ? _args8[0] : {};
  4685. return _context9.abrupt("return", SolanaApi.fetch({
  4686. endpoint: {
  4687. "method": "GET",
  4688. "group": "nft",
  4689. "name": "getNFTMetadata",
  4690. "url": "/nft/:network/:address/metadata"
  4691. },
  4692. params: options
  4693. }));
  4694. case 2:
  4695. case "end":
  4696. return _context9.stop();
  4697. }
  4698. }
  4699. }, _callee8);
  4700. }));
  4701. return function () {
  4702. return _getNFTMetadata.apply(this, arguments);
  4703. };
  4704. }()
  4705. });
  4706. var _default = SolanaApi;
  4707. exports.default = _default;
  4708. },{"@babel/runtime-corejs3/core-js-stable/instance/filter":84,"@babel/runtime-corejs3/core-js-stable/instance/for-each":86,"@babel/runtime-corejs3/core-js-stable/instance/includes":87,"@babel/runtime-corejs3/core-js-stable/json/stringify":99,"@babel/runtime-corejs3/core-js-stable/object/define-properties":104,"@babel/runtime-corejs3/core-js-stable/object/define-property":105,"@babel/runtime-corejs3/core-js-stable/object/get-own-property-descriptor":108,"@babel/runtime-corejs3/core-js-stable/object/get-own-property-descriptors":109,"@babel/runtime-corejs3/core-js-stable/object/get-own-property-symbols":110,"@babel/runtime-corejs3/core-js-stable/object/keys":112,"@babel/runtime-corejs3/helpers/asyncToGenerator":144,"@babel/runtime-corejs3/helpers/classCallCheck":145,"@babel/runtime-corejs3/helpers/createClass":147,"@babel/runtime-corejs3/helpers/defineProperty":148,"@babel/runtime-corejs3/helpers/interopRequireDefault":152,"@babel/runtime-corejs3/regenerator":167,"axios":291}],20:[function(_dereq_,module,exports){
  4709. "use strict";
  4710. var _Object$defineProperty = _dereq_("@babel/runtime-corejs3/core-js-stable/object/define-property");
  4711. var _interopRequireDefault = _dereq_("@babel/runtime-corejs3/helpers/interopRequireDefault");
  4712. _Object$defineProperty(exports, "__esModule", {
  4713. value: true
  4714. });
  4715. exports.default = void 0;
  4716. var _regenerator = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/regenerator"));
  4717. var _asyncToGenerator2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/helpers/asyncToGenerator"));
  4718. var MoralisUI = {
  4719. openPrompt: function () {
  4720. return (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee() {
  4721. return _regenerator.default.wrap(function (_context) {
  4722. while (1) {
  4723. switch (_context.prev = _context.next) {
  4724. case 0:
  4725. // eslint-disable-next-line no-console
  4726. console.warn('No prompt supplied');
  4727. case 1:
  4728. case "end":
  4729. return _context.stop();
  4730. }
  4731. }
  4732. }, _callee);
  4733. }))();
  4734. }
  4735. };
  4736. var _default = MoralisUI;
  4737. exports.default = _default;
  4738. },{"@babel/runtime-corejs3/core-js-stable/object/define-property":105,"@babel/runtime-corejs3/helpers/asyncToGenerator":144,"@babel/runtime-corejs3/helpers/interopRequireDefault":152,"@babel/runtime-corejs3/regenerator":167}],21:[function(_dereq_,module,exports){
  4739. "use strict";
  4740. var _typeof3 = _dereq_("@babel/runtime-corejs3/helpers/typeof");
  4741. var _sliceInstanceProperty = _dereq_("@babel/runtime-corejs3/core-js-stable/instance/slice");
  4742. var _Array$from = _dereq_("@babel/runtime-corejs3/core-js-stable/array/from");
  4743. var _Symbol = _dereq_("@babel/runtime-corejs3/core-js-stable/symbol");
  4744. var _getIteratorMethod = _dereq_("@babel/runtime-corejs3/core-js/get-iterator-method");
  4745. var _Array$isArray = _dereq_("@babel/runtime-corejs3/core-js-stable/array/is-array");
  4746. var _WeakMap = _dereq_("@babel/runtime-corejs3/core-js-stable/weak-map");
  4747. var _Object$defineProperty = _dereq_("@babel/runtime-corejs3/core-js-stable/object/define-property");
  4748. var _Object$getOwnPropertyDescriptor = _dereq_("@babel/runtime-corejs3/core-js-stable/object/get-own-property-descriptor");
  4749. var _interopRequireDefault = _dereq_("@babel/runtime-corejs3/helpers/interopRequireDefault");
  4750. _Object$defineProperty(exports, "__esModule", {
  4751. value: true
  4752. });
  4753. exports.default = void 0;
  4754. var _filter = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/instance/filter"));
  4755. var _forEach = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/instance/for-each"));
  4756. var _concat = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/instance/concat"));
  4757. var _stringify = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/json/stringify"));
  4758. var _map = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/instance/map"));
  4759. var _trim = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/instance/trim"));
  4760. var _find = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/instance/find"));
  4761. var _every = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/instance/every"));
  4762. var _values = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/object/values"));
  4763. var _bind = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/instance/bind"));
  4764. var _regenerator = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/regenerator"));
  4765. var _toConsumableArray2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/helpers/toConsumableArray"));
  4766. var _typeof2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/helpers/typeof"));
  4767. var _asyncToGenerator2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/helpers/asyncToGenerator"));
  4768. var _classCallCheck2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/helpers/classCallCheck"));
  4769. var _createClass2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/helpers/createClass"));
  4770. var _defineProperty2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/helpers/defineProperty"));
  4771. var _ethers = _dereq_("ethers");
  4772. var _events = _interopRequireDefault(_dereq_("events"));
  4773. var _ParseObject = _interopRequireDefault(_dereq_("./ParseObject"));
  4774. var _ParseQuery = _interopRequireDefault(_dereq_("./ParseQuery"));
  4775. var _ParseUser = _interopRequireDefault(_dereq_("./ParseUser"));
  4776. var _ParseACL = _interopRequireDefault(_dereq_("./ParseACL"));
  4777. var _MoralisErd = _interopRequireDefault(_dereq_("./MoralisErd"));
  4778. var _MoralisDot = _interopRequireDefault(_dereq_("./MoralisDot"));
  4779. var _MoralisSol = _interopRequireDefault(_dereq_("./MoralisSol"));
  4780. var _TransferUtils = _interopRequireDefault(_dereq_("./TransferUtils"));
  4781. var _Cloud = _dereq_("./Cloud");
  4782. var _createSigningData = _interopRequireDefault(_dereq_("./createSigningData"));
  4783. var _WalletConnectWeb3Connector = _interopRequireDefault(_dereq_("./Web3Connector/WalletConnectWeb3Connector"));
  4784. var _InjectedWeb3Connector = _interopRequireDefault(_dereq_("./Web3Connector/InjectedWeb3Connector"));
  4785. var _NetworkWeb3Connector = _interopRequireDefault(_dereq_("./Web3Connector/NetworkWeb3Connector"));
  4786. var _ParseError = _interopRequireDefault(_dereq_("./ParseError"));
  4787. var _InternalWeb3Provider = _interopRequireWildcard(_dereq_("./InternalWeb3Provider"));
  4788. var _detectProvider = _interopRequireDefault(_dereq_("@metamask/detect-provider"));
  4789. var _MagicWeb3Connector = _interopRequireDefault(_dereq_("./Web3Connector/MagicWeb3Connector"));
  4790. var _Web3AuthConnector = _dereq_("./Web3Connector/Web3AuthConnector");
  4791. var _context30, _context31, _context32, _context33, _context34, _context35;
  4792. function _getRequireWildcardCache(nodeInterop) {
  4793. if (typeof _WeakMap !== "function") return null;
  4794. var cacheBabelInterop = new _WeakMap();
  4795. var cacheNodeInterop = new _WeakMap();
  4796. return (_getRequireWildcardCache = function (nodeInterop) {
  4797. return nodeInterop ? cacheNodeInterop : cacheBabelInterop;
  4798. })(nodeInterop);
  4799. }
  4800. function _interopRequireWildcard(obj, nodeInterop) {
  4801. if (!nodeInterop && obj && obj.__esModule) {
  4802. return obj;
  4803. }
  4804. if (obj === null || _typeof3(obj) !== "object" && typeof obj !== "function") {
  4805. return {
  4806. default: obj
  4807. };
  4808. }
  4809. var cache = _getRequireWildcardCache(nodeInterop);
  4810. if (cache && cache.has(obj)) {
  4811. return cache.get(obj);
  4812. }
  4813. var newObj = {};
  4814. for (var key in obj) {
  4815. if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) {
  4816. var desc = _Object$defineProperty && _Object$getOwnPropertyDescriptor ? _Object$getOwnPropertyDescriptor(obj, key) : null;
  4817. if (desc && (desc.get || desc.set)) {
  4818. _Object$defineProperty(newObj, key, desc);
  4819. } else {
  4820. newObj[key] = obj[key];
  4821. }
  4822. }
  4823. }
  4824. newObj.default = obj;
  4825. if (cache) {
  4826. cache.set(obj, newObj);
  4827. }
  4828. return newObj;
  4829. }
  4830. function _createForOfIteratorHelper(o, allowArrayLike) {
  4831. var it = typeof _Symbol !== "undefined" && _getIteratorMethod(o) || o["@@iterator"];
  4832. if (!it) {
  4833. if (_Array$isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") {
  4834. if (it) o = it;
  4835. var i = 0;
  4836. var F = function () {};
  4837. return {
  4838. s: F,
  4839. n: function () {
  4840. if (i >= o.length) return {
  4841. done: true
  4842. };
  4843. return {
  4844. done: false,
  4845. value: o[i++]
  4846. };
  4847. },
  4848. e: function (_e) {
  4849. throw _e;
  4850. },
  4851. f: F
  4852. };
  4853. }
  4854. throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
  4855. }
  4856. var normalCompletion = true,
  4857. didErr = false,
  4858. err;
  4859. return {
  4860. s: function () {
  4861. it = it.call(o);
  4862. },
  4863. n: function () {
  4864. var step = it.next();
  4865. normalCompletion = step.done;
  4866. return step;
  4867. },
  4868. e: function (_e2) {
  4869. didErr = true;
  4870. err = _e2;
  4871. },
  4872. f: function () {
  4873. try {
  4874. if (!normalCompletion && it.return != null) it.return();
  4875. } finally {
  4876. if (didErr) throw err;
  4877. }
  4878. }
  4879. };
  4880. }
  4881. function _unsupportedIterableToArray(o, minLen) {
  4882. var _context36;
  4883. if (!o) return;
  4884. if (typeof o === "string") return _arrayLikeToArray(o, minLen);
  4885. var n = _sliceInstanceProperty(_context36 = Object.prototype.toString.call(o)).call(_context36, 8, -1);
  4886. if (n === "Object" && o.constructor) n = o.constructor.name;
  4887. if (n === "Map" || n === "Set") return _Array$from(o);
  4888. if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen);
  4889. }
  4890. function _arrayLikeToArray(arr, len) {
  4891. if (len == null || len > arr.length) len = arr.length;
  4892. for (var i = 0, arr2 = new Array(len); i < len; i++) {
  4893. arr2[i] = arr[i];
  4894. }
  4895. return arr2;
  4896. }
  4897. var MoralisEmitter = new _events.default();
  4898. var WARNING = 'Non ethereum enabled browser';
  4899. var ERROR_WEB3_MISSING = 'Missing web3 instance, make sure to call Moralis.enableWeb3() or Moralis.authenticate()';
  4900. var MoralisWeb3 = /*#__PURE__*/function () {
  4901. function MoralisWeb3() {
  4902. (0, _classCallCheck2.default)(this, MoralisWeb3);
  4903. }
  4904. (0, _createClass2.default)(MoralisWeb3, null, [{
  4905. key: "addListener",
  4906. value: // Ethers.js instance that will be set after calling enableWeb3
  4907. // Internal web3 provider, containing the Ethers.js Web3 library for internal usage for handling transactions, contracts etc.
  4908. function (eventName, listener) {
  4909. MoralisEmitter.on(eventName, listener);
  4910. return function () {
  4911. return MoralisEmitter.removeListener(eventName, listener);
  4912. };
  4913. }
  4914. }, {
  4915. key: "on",
  4916. value: function (eventName, listener) {
  4917. MoralisEmitter.on(eventName, listener);
  4918. return function () {
  4919. return MoralisEmitter.removeListener(eventName, listener);
  4920. };
  4921. }
  4922. }, {
  4923. key: "once",
  4924. value: function (eventName, listener) {
  4925. MoralisEmitter.once(eventName, listener);
  4926. return function () {
  4927. return MoralisEmitter.removeListener(eventName, listener);
  4928. };
  4929. }
  4930. }, {
  4931. key: "removeListener",
  4932. value: function (eventName, listener) {
  4933. return MoralisEmitter.removeListener(eventName, listener);
  4934. }
  4935. }, {
  4936. key: "off",
  4937. value: function (eventName, listener) {
  4938. return MoralisEmitter.off(eventName, listener);
  4939. }
  4940. }, {
  4941. key: "removeAllListeners",
  4942. value: function (eventName, listener) {
  4943. return MoralisEmitter.removeAllListeners(eventName, listener);
  4944. }
  4945. }, {
  4946. key: "isWeb3Enabled",
  4947. value: function () {
  4948. return this.ensureWeb3IsInstalled();
  4949. }
  4950. }, {
  4951. key: "handleWeb3AccountChanged",
  4952. value: function (account) {
  4953. MoralisEmitter.emit(_InternalWeb3Provider.InternalWeb3Events.ACCOUNT_CHANGED, account);
  4954. }
  4955. }, {
  4956. key: "handleWeb3ChainChanged",
  4957. value: function (chainId) {
  4958. var _this$internalWeb3Pro;
  4959. this.web3 = (_this$internalWeb3Pro = this.internalWeb3Provider) === null || _this$internalWeb3Pro === void 0 ? void 0 : _this$internalWeb3Pro.web3;
  4960. MoralisEmitter.emit(_InternalWeb3Provider.InternalWeb3Events.CHAIN_CHANGED, chainId);
  4961. }
  4962. }, {
  4963. key: "handleWeb3Connect",
  4964. value: function (connectInfo) {
  4965. MoralisEmitter.emit(_InternalWeb3Provider.InternalWeb3Events.PROVIDER_CONNECT, connectInfo);
  4966. }
  4967. }, {
  4968. key: "handleWeb3Disconnect",
  4969. value: function (error) {
  4970. if ((error === null || error === void 0 ? void 0 : error.message) === 'MetaMask: Disconnected from chain. Attempting to connect.') {
  4971. return;
  4972. }
  4973. this.cleanup();
  4974. MoralisEmitter.emit(_InternalWeb3Provider.InternalWeb3Events.PROVIDER_DISCONNECT, error);
  4975. }
  4976. }, {
  4977. key: "enableWeb3",
  4978. value: function () {
  4979. var _enableWeb = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee() {
  4980. var _this = this;
  4981. var options,
  4982. _options$connector,
  4983. Connector,
  4984. connector,
  4985. anyNetwork,
  4986. provider,
  4987. chainId,
  4988. account,
  4989. internalWeb3,
  4990. _yield$this$internalW,
  4991. web3,
  4992. _args = arguments;
  4993. return _regenerator.default.wrap(function (_context) {
  4994. while (1) {
  4995. switch (_context.prev = _context.next) {
  4996. case 0:
  4997. options = _args.length > 0 && _args[0] !== undefined ? _args[0] : {};
  4998. if (!this.isEnablingWeb3) {
  4999. _context.next = 3;
  5000. break;
  5001. }
  5002. throw new Error('Cannot execute Moralis.enableWeb3(), as Moralis Moralis.enableWeb3() already has been called, but is not finished yet ');
  5003. case 3:
  5004. _context.prev = 3;
  5005. this.isEnablingWeb3 = true;
  5006. if (this.speedyNodeApiKey) {
  5007. options.speedyNodeApiKey = this.speedyNodeApiKey;
  5008. options.provider = 'network';
  5009. }
  5010. Connector = (_options$connector = options === null || options === void 0 ? void 0 : options.connector) !== null && _options$connector !== void 0 ? _options$connector : MoralisWeb3.getWeb3Connector(options === null || options === void 0 ? void 0 : options.provider);
  5011. connector = new Connector(options);
  5012. anyNetwork = (options === null || options === void 0 ? void 0 : options.anyNetwork) === true ? true : false;
  5013. this.internalWeb3Provider = new _InternalWeb3Provider.default(connector, anyNetwork, options.privateKey);
  5014. this.internalWeb3Provider.on(_InternalWeb3Provider.InternalWeb3Events.ACCOUNT_CHANGED, function (args) {
  5015. return _this.handleWeb3AccountChanged(args);
  5016. });
  5017. this.internalWeb3Provider.on(_InternalWeb3Provider.InternalWeb3Events.CHAIN_CHANGED, function (args) {
  5018. return _this.handleWeb3ChainChanged(args);
  5019. });
  5020. this.internalWeb3Provider.on(_InternalWeb3Provider.InternalWeb3Events.PROVIDER_CONNECT, function (args) {
  5021. return _this.handleWeb3Connect(args);
  5022. });
  5023. this.internalWeb3Provider.on(_InternalWeb3Provider.InternalWeb3Events.PROVIDER_DISCONNECT, function (args) {
  5024. return _this.handleWeb3Disconnect(args);
  5025. });
  5026. _context.prev = 14;
  5027. _context.next = 17;
  5028. return this.internalWeb3Provider.activate(options);
  5029. case 17:
  5030. _yield$this$internalW = _context.sent;
  5031. provider = _yield$this$internalW.provider;
  5032. chainId = _yield$this$internalW.chainId;
  5033. account = _yield$this$internalW.account;
  5034. internalWeb3 = _yield$this$internalW.web3;
  5035. if (provider) {
  5036. _context.next = 24;
  5037. break;
  5038. }
  5039. throw new Error('Failed to activate, no provider returned');
  5040. case 24:
  5041. _context.next = 31;
  5042. break;
  5043. case 26:
  5044. _context.prev = 26;
  5045. _context.t0 = _context["catch"](14);
  5046. _context.next = 30;
  5047. return this.cleanup();
  5048. case 30:
  5049. throw _context.t0;
  5050. case 31:
  5051. web3 = internalWeb3;
  5052. this.web3 = internalWeb3;
  5053. MoralisEmitter.emit(_InternalWeb3Provider.InternalWeb3Events.WEB3_ENABLED, {
  5054. chainId: chainId,
  5055. account: account,
  5056. connector: connector,
  5057. provider: provider,
  5058. web3: web3
  5059. });
  5060. return _context.abrupt("return", web3);
  5061. case 37:
  5062. _context.prev = 37;
  5063. _context.t1 = _context["catch"](3);
  5064. throw _context.t1;
  5065. case 40:
  5066. _context.prev = 40;
  5067. this.isEnablingWeb3 = false;
  5068. return _context.finish(40);
  5069. case 43:
  5070. case "end":
  5071. return _context.stop();
  5072. }
  5073. }
  5074. }, _callee, this, [[3, 37, 40, 43], [14, 26]]);
  5075. }));
  5076. return function () {
  5077. return _enableWeb.apply(this, arguments);
  5078. };
  5079. }()
  5080. }, {
  5081. key: "isDotAuth",
  5082. value: function (options) {
  5083. switch (options === null || options === void 0 ? void 0 : options.type) {
  5084. case 'dot':
  5085. case 'polkadot':
  5086. case 'kusama':
  5087. return true;
  5088. default:
  5089. return false;
  5090. }
  5091. }
  5092. }, {
  5093. key: "isElrondAuth",
  5094. value: function (options) {
  5095. switch (options === null || options === void 0 ? void 0 : options.type) {
  5096. case 'erd':
  5097. case 'elrond':
  5098. return true;
  5099. default:
  5100. return false;
  5101. }
  5102. }
  5103. }, {
  5104. key: "isSolAuth",
  5105. value: function (options) {
  5106. switch (options === null || options === void 0 ? void 0 : options.type) {
  5107. case 'sol':
  5108. return true;
  5109. default:
  5110. return false;
  5111. }
  5112. }
  5113. }, {
  5114. key: "getWeb3Connector",
  5115. value: function (provider) {
  5116. switch (provider) {
  5117. case 'walletconnect':
  5118. case 'walletConnect':
  5119. case 'wc':
  5120. return _WalletConnectWeb3Connector.default;
  5121. case 'network':
  5122. return _NetworkWeb3Connector.default;
  5123. case 'magicLink':
  5124. return _MagicWeb3Connector.default;
  5125. case 'web3Auth':
  5126. return _Web3AuthConnector.Web3Auth;
  5127. default:
  5128. return _InjectedWeb3Connector.default;
  5129. }
  5130. }
  5131. }, {
  5132. key: "deactivateWeb3",
  5133. value: function () {
  5134. var _deactivateWeb = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee2() {
  5135. return _regenerator.default.wrap(function (_context2) {
  5136. while (1) {
  5137. switch (_context2.prev = _context2.next) {
  5138. case 0:
  5139. return _context2.abrupt("return", this.cleanup());
  5140. case 1:
  5141. case "end":
  5142. return _context2.stop();
  5143. }
  5144. }
  5145. }, _callee2, this);
  5146. }));
  5147. return function () {
  5148. return _deactivateWeb.apply(this, arguments);
  5149. };
  5150. }()
  5151. /**
  5152. * Cleanup previously established provider
  5153. */
  5154. }, {
  5155. key: "cleanup",
  5156. value: function () {
  5157. var _cleanup = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee3() {
  5158. return _regenerator.default.wrap(function (_context3) {
  5159. while (1) {
  5160. switch (_context3.prev = _context3.next) {
  5161. case 0:
  5162. if (!this.isEnablingWeb3) {
  5163. _context3.next = 2;
  5164. break;
  5165. }
  5166. return _context3.abrupt("return");
  5167. case 2:
  5168. if (this.web3 && this.internalWeb3Provider) {
  5169. MoralisEmitter.emit(_InternalWeb3Provider.InternalWeb3Events.WEB3_DEACTIVATED, {
  5170. connector: this.internalWeb3Provider.connector,
  5171. provider: this.internalWeb3Provider.provider
  5172. });
  5173. }
  5174. if (!this.internalWeb3Provider) {
  5175. _context3.next = 15;
  5176. break;
  5177. }
  5178. this.internalWeb3Provider.removeListener(_InternalWeb3Provider.InternalWeb3Events.ACCOUNT_CHANGED, this.handleWeb3AccountChanged);
  5179. this.internalWeb3Provider.removeListener(_InternalWeb3Provider.InternalWeb3Events.CHAIN_CHANGED, this.handleWeb3ChainChanged);
  5180. this.internalWeb3Provider.removeListener(_InternalWeb3Provider.InternalWeb3Events.PROVIDER_CONNECT, this.handleWeb3Connect);
  5181. this.internalWeb3Provider.removeListener(_InternalWeb3Provider.InternalWeb3Events.PROVIDER_DISCONNECT, this.handleWeb3Disconnect); // For example, if walletconnect has been enabled, then later on metamask, then wc is not the internalProvider, but still has an active connection
  5182. _context3.prev = 8;
  5183. _context3.next = 11;
  5184. return this.internalWeb3Provider.deactivate();
  5185. case 11:
  5186. _context3.next = 15;
  5187. break;
  5188. case 13:
  5189. _context3.prev = 13;
  5190. _context3.t0 = _context3["catch"](8);
  5191. case 15:
  5192. this.internalWeb3Provider = null;
  5193. this.web3 = null;
  5194. case 17:
  5195. case "end":
  5196. return _context3.stop();
  5197. }
  5198. }
  5199. }, _callee3, this, [[8, 13]]);
  5200. }));
  5201. return function () {
  5202. return _cleanup.apply(this, arguments);
  5203. };
  5204. }()
  5205. }, {
  5206. key: "authenticate",
  5207. value: function () {
  5208. var _authenticate = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee4(options) {
  5209. var isLoggedIn, _this$getInternalWeb, account, internalWeb3, signer, message, data, ethAddress, signature, authData, user;
  5210. return _regenerator.default.wrap(function (_context4) {
  5211. while (1) {
  5212. switch (_context4.prev = _context4.next) {
  5213. case 0:
  5214. _context4.next = 2;
  5215. return _ParseUser.default.currentAsync();
  5216. case 2:
  5217. isLoggedIn = _context4.sent;
  5218. if (!isLoggedIn) {
  5219. _context4.next = 6;
  5220. break;
  5221. }
  5222. _context4.next = 6;
  5223. return _ParseUser.default.logOut();
  5224. case 6:
  5225. if (!MoralisWeb3.isDotAuth(options)) {
  5226. _context4.next = 8;
  5227. break;
  5228. }
  5229. return _context4.abrupt("return", _MoralisDot.default.authenticate(options));
  5230. case 8:
  5231. if (!MoralisWeb3.isElrondAuth(options)) {
  5232. _context4.next = 10;
  5233. break;
  5234. }
  5235. return _context4.abrupt("return", _MoralisErd.default.authenticate(options));
  5236. case 10:
  5237. if (!MoralisWeb3.isSolAuth(options)) {
  5238. _context4.next = 12;
  5239. break;
  5240. }
  5241. return _context4.abrupt("return", _MoralisSol.default.authenticate(options));
  5242. case 12:
  5243. _context4.next = 14;
  5244. return this.enableWeb3(options);
  5245. case 14:
  5246. _this$getInternalWeb = this.getInternalWeb3Provider(), account = _this$getInternalWeb.account, internalWeb3 = _this$getInternalWeb.web3, signer = _this$getInternalWeb.signer;
  5247. if (account) {
  5248. _context4.next = 17;
  5249. break;
  5250. }
  5251. throw new Error('Cannot authenticate, no account returned from provider');
  5252. case 17:
  5253. message = (options === null || options === void 0 ? void 0 : options.signingMessage) || MoralisWeb3.getSigningData();
  5254. _context4.next = 20;
  5255. return (0, _createSigningData.default)(message);
  5256. case 20:
  5257. data = _context4.sent;
  5258. ethAddress = account.toLowerCase();
  5259. if (ethAddress) {
  5260. _context4.next = 24;
  5261. break;
  5262. }
  5263. throw new Error('Address not found');
  5264. case 24:
  5265. _context4.next = 26;
  5266. return signer.signMessage(data);
  5267. case 26:
  5268. signature = _context4.sent;
  5269. if (signature) {
  5270. _context4.next = 29;
  5271. break;
  5272. }
  5273. throw new Error('Data not signed');
  5274. case 29:
  5275. authData = {
  5276. id: ethAddress,
  5277. signature: signature,
  5278. data: data
  5279. };
  5280. _context4.next = 32;
  5281. return _ParseUser.default.logInWith('moralisEth', {
  5282. authData: authData
  5283. });
  5284. case 32:
  5285. user = _context4.sent;
  5286. if (user) {
  5287. _context4.next = 35;
  5288. break;
  5289. }
  5290. throw new Error('Could not get user');
  5291. case 35:
  5292. _context4.next = 37;
  5293. return user.setACL(new _ParseACL.default(user));
  5294. case 37:
  5295. user.addAllUnique('accounts', [ethAddress]);
  5296. user.set('ethAddress', ethAddress);
  5297. _context4.next = 41;
  5298. return user.save(null, options);
  5299. case 41:
  5300. return _context4.abrupt("return", user);
  5301. case 42:
  5302. case "end":
  5303. return _context4.stop();
  5304. }
  5305. }
  5306. }, _callee4, this);
  5307. }));
  5308. return function () {
  5309. return _authenticate.apply(this, arguments);
  5310. };
  5311. }()
  5312. }, {
  5313. key: "link",
  5314. value: function () {
  5315. var _link = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee5(account, options) {
  5316. var _this$getInternalWeb2, signer, message, user, ethAddress, EthAddress, query, ethAddressRecord, data, signature, authData;
  5317. return _regenerator.default.wrap(function (_context5) {
  5318. while (1) {
  5319. switch (_context5.prev = _context5.next) {
  5320. case 0:
  5321. _this$getInternalWeb2 = this.getInternalWeb3Provider(), signer = _this$getInternalWeb2.signer;
  5322. message = (options === null || options === void 0 ? void 0 : options.signingMessage) || MoralisWeb3.getSigningData();
  5323. _context5.next = 4;
  5324. return _ParseUser.default.currentAsync();
  5325. case 4:
  5326. user = _context5.sent;
  5327. ethAddress = account.toLowerCase();
  5328. EthAddress = _ParseObject.default.extend('_EthAddress');
  5329. query = new _ParseQuery.default(EthAddress);
  5330. _context5.next = 10;
  5331. return query.get(ethAddress).catch(function () {
  5332. return null;
  5333. });
  5334. case 10:
  5335. ethAddressRecord = _context5.sent;
  5336. if (ethAddressRecord) {
  5337. _context5.next = 23;
  5338. break;
  5339. }
  5340. _context5.next = 14;
  5341. return (0, _createSigningData.default)(message);
  5342. case 14:
  5343. data = _context5.sent;
  5344. _context5.next = 17;
  5345. return signer.signMessage(data);
  5346. case 17:
  5347. signature = _context5.sent;
  5348. if (signature) {
  5349. _context5.next = 20;
  5350. break;
  5351. }
  5352. throw new Error('Data not signed');
  5353. case 20:
  5354. authData = {
  5355. id: ethAddress,
  5356. signature: signature,
  5357. data: data
  5358. };
  5359. _context5.next = 23;
  5360. return user.linkWith('moralisEth', {
  5361. authData: authData
  5362. });
  5363. case 23:
  5364. user.addAllUnique('accounts', [ethAddress]);
  5365. user.set('ethAddress', ethAddress);
  5366. _context5.next = 27;
  5367. return user.save(null, options);
  5368. case 27:
  5369. return _context5.abrupt("return", user);
  5370. case 28:
  5371. case "end":
  5372. return _context5.stop();
  5373. }
  5374. }
  5375. }, _callee5, this);
  5376. }));
  5377. return function () {
  5378. return _link.apply(this, arguments);
  5379. };
  5380. }()
  5381. }, {
  5382. key: "unlink",
  5383. value: function () {
  5384. var _unlink = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee6(account) {
  5385. var _user$get;
  5386. var accountsLower, EthAddress, query, ethAddressRecord, user, accounts, nextAccounts;
  5387. return _regenerator.default.wrap(function (_context6) {
  5388. while (1) {
  5389. switch (_context6.prev = _context6.next) {
  5390. case 0:
  5391. accountsLower = account.toLowerCase();
  5392. EthAddress = _ParseObject.default.extend('_EthAddress');
  5393. query = new _ParseQuery.default(EthAddress);
  5394. _context6.next = 5;
  5395. return query.get(accountsLower);
  5396. case 5:
  5397. ethAddressRecord = _context6.sent;
  5398. _context6.next = 8;
  5399. return ethAddressRecord.destroy();
  5400. case 8:
  5401. _context6.next = 10;
  5402. return _ParseUser.default.currentAsync();
  5403. case 10:
  5404. user = _context6.sent;
  5405. accounts = (_user$get = user.get('accounts')) !== null && _user$get !== void 0 ? _user$get : [];
  5406. nextAccounts = (0, _filter.default)(accounts).call(accounts, function (v) {
  5407. return v !== accountsLower;
  5408. });
  5409. user.set('accounts', nextAccounts);
  5410. user.set('ethAddress', nextAccounts[0]);
  5411. _context6.next = 17;
  5412. return user._unlinkFrom('moralisEth');
  5413. case 17:
  5414. _context6.next = 19;
  5415. return user.save();
  5416. case 19:
  5417. return _context6.abrupt("return", user);
  5418. case 20:
  5419. case "end":
  5420. return _context6.stop();
  5421. }
  5422. }
  5423. }, _callee6);
  5424. }));
  5425. return function () {
  5426. return _unlink.apply(this, arguments);
  5427. };
  5428. }()
  5429. }, {
  5430. key: "initPlugins",
  5431. value: function () {
  5432. var _initPlugins = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee8(installedPlugins) {
  5433. var _this2 = this;
  5434. var specs, allPlugins;
  5435. return _regenerator.default.wrap(function (_context10) {
  5436. while (1) {
  5437. switch (_context10.prev = _context10.next) {
  5438. case 0:
  5439. _context10.t0 = installedPlugins;
  5440. if (_context10.t0) {
  5441. _context10.next = 5;
  5442. break;
  5443. }
  5444. _context10.next = 4;
  5445. return (0, _Cloud.run)('getPluginSpecs');
  5446. case 4:
  5447. _context10.t0 = _context10.sent;
  5448. case 5:
  5449. specs = _context10.t0;
  5450. if (!this.Plugins) this.Plugins = {};
  5451. if (specs) {
  5452. _context10.next = 9;
  5453. break;
  5454. }
  5455. return _context10.abrupt("return");
  5456. case 9:
  5457. allPlugins = this.Plugins;
  5458. (0, _forEach.default)(specs).call(specs, function (plugin) {
  5459. var _context7;
  5460. allPlugins[plugin.name] = {};
  5461. (0, _forEach.default)(_context7 = plugin.functions).call(_context7, function (f) {
  5462. allPlugins[plugin.name][f] = /*#__PURE__*/function () {
  5463. var _ref = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee7(params, options) {
  5464. var _context8;
  5465. var response, error, triggerReturn;
  5466. return _regenerator.default.wrap(function (_context9) {
  5467. while (1) {
  5468. switch (_context9.prev = _context9.next) {
  5469. case 0:
  5470. if (!options) options = {};
  5471. _context9.next = 3;
  5472. return (0, _Cloud.run)((0, _concat.default)(_context8 = "".concat(plugin.name, "_")).call(_context8, f), params);
  5473. case 3:
  5474. response = _context9.sent;
  5475. if (response.data.success) {
  5476. _context9.next = 7;
  5477. break;
  5478. }
  5479. error = (0, _stringify.default)(response.data.data, null, 2);
  5480. throw new Error("Something went wrong\n".concat(error));
  5481. case 7:
  5482. if (!(options.disableTriggers !== true)) {
  5483. _context9.next = 13;
  5484. break;
  5485. }
  5486. _context9.next = 10;
  5487. return _this2.handleTriggers(response.data.result.triggers, response.data.result.data);
  5488. case 10:
  5489. triggerReturn = _context9.sent;
  5490. if (!triggerReturn) {
  5491. _context9.next = 13;
  5492. break;
  5493. }
  5494. return _context9.abrupt("return", triggerReturn);
  5495. case 13:
  5496. return _context9.abrupt("return", response.data.result);
  5497. case 14:
  5498. case "end":
  5499. return _context9.stop();
  5500. }
  5501. }
  5502. }, _callee7);
  5503. }));
  5504. return function () {
  5505. return _ref.apply(this, arguments);
  5506. };
  5507. }();
  5508. });
  5509. });
  5510. this.Plugins = allPlugins;
  5511. case 12:
  5512. case "end":
  5513. return _context10.stop();
  5514. }
  5515. }
  5516. }, _callee8, this);
  5517. }));
  5518. return function () {
  5519. return _initPlugins.apply(this, arguments);
  5520. };
  5521. }()
  5522. }, {
  5523. key: "handleTriggers",
  5524. value: function () {
  5525. var _handleTriggers = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee9(triggersArray, payload) {
  5526. var _this3 = this;
  5527. var _loop, i, _ret;
  5528. return _regenerator.default.wrap(function (_context14) {
  5529. while (1) {
  5530. switch (_context14.prev = _context14.next) {
  5531. case 0:
  5532. if (triggersArray) {
  5533. _context14.next = 2;
  5534. break;
  5535. }
  5536. return _context14.abrupt("return");
  5537. case 2:
  5538. _loop = /*#__PURE__*/_regenerator.default.mark(function _loop(i) {
  5539. var _triggersArray$i, _triggersArray$i$data, _triggersArray$i2, _triggersArray$i2$dat, _triggersArray$i$data2, _triggersArray$i3, _triggersArray$i3$dat, _triggersArray$i4, _triggersArray$i4$dat, _triggersArray$i5, _triggersArray$i6, _triggersArray$i7, _triggersArray$i8, _triggersArray$i9, _triggersArray$i10, _triggersArray$i11, _triggersArray$i12, _triggersArray$i13, _triggersArray$i14, _triggersArray$i15, _triggersArray$i16, _triggersArray$i17, _triggersArray$i18, _triggersArray$i20, _triggersArray$i22, _triggersArray$i23, _triggersArray$i24;
  5540. var message, _response, _context11, _context12, _triggersArray$i19, _JSON$parse, domain, types, _message, signature, result, _JSON$parse2, _domain, _types, _message2;
  5541. return _regenerator.default.wrap(function (_context13) {
  5542. while (1) {
  5543. switch (_context13.prev = _context13.next) {
  5544. case 0:
  5545. _context13.t0 = triggersArray[i].name;
  5546. _context13.next = _context13.t0 === 'openUrl' ? 3 : _context13.t0 === 'web3Transaction' ? 5 : _context13.t0 === 'web3Sign' ? 18 : _context13.t0 === 'callPluginEndpoint' ? 33 : _context13.t0 === 'web3SignV4' ? 55 : 80;
  5547. break;
  5548. case 3:
  5549. if (triggersArray[i].newTab) window.open(triggersArray[i].url);else window.open(triggersArray[i].url, '_self');
  5550. return _context13.abrupt("break", 81);
  5551. case 5:
  5552. _context13.next = 7;
  5553. return _this3.getInternalWeb3Provider().signer.sendTransaction({
  5554. from: (_triggersArray$i = triggersArray[i]) === null || _triggersArray$i === void 0 ? void 0 : (_triggersArray$i$data = _triggersArray$i.data) === null || _triggersArray$i$data === void 0 ? void 0 : _triggersArray$i$data.from,
  5555. to: (_triggersArray$i2 = triggersArray[i]) === null || _triggersArray$i2 === void 0 ? void 0 : (_triggersArray$i2$dat = _triggersArray$i2.data) === null || _triggersArray$i2$dat === void 0 ? void 0 : _triggersArray$i2$dat.to,
  5556. value: _ethers.ethers.BigNumber.from((_triggersArray$i$data2 = (_triggersArray$i3 = triggersArray[i]) === null || _triggersArray$i3 === void 0 ? void 0 : (_triggersArray$i3$dat = _triggersArray$i3.data) === null || _triggersArray$i3$dat === void 0 ? void 0 : _triggersArray$i3$dat.value) !== null && _triggersArray$i$data2 !== void 0 ? _triggersArray$i$data2 : 0),
  5557. data: (_triggersArray$i4 = triggersArray[i]) === null || _triggersArray$i4 === void 0 ? void 0 : (_triggersArray$i4$dat = _triggersArray$i4.data) === null || _triggersArray$i4$dat === void 0 ? void 0 : _triggersArray$i4$dat.data
  5558. });
  5559. case 7:
  5560. _response = _context13.sent;
  5561. if (!(((_triggersArray$i5 = triggersArray[i]) === null || _triggersArray$i5 === void 0 ? void 0 : _triggersArray$i5.shouldAwait) === true)) {
  5562. _context13.next = 12;
  5563. break;
  5564. }
  5565. _context13.next = 11;
  5566. return _response.wait();
  5567. case 11:
  5568. _response = _context13.sent;
  5569. case 12:
  5570. // Save the response returned by the web3 trasanction
  5571. if (((_triggersArray$i6 = triggersArray[i]) === null || _triggersArray$i6 === void 0 ? void 0 : _triggersArray$i6.saveResponse) === true) _this3.memoryCard.save(_response); // Return payload and response
  5572. if (!(((_triggersArray$i7 = triggersArray[i]) === null || _triggersArray$i7 === void 0 ? void 0 : _triggersArray$i7.shouldReturnPayload) === true)) {
  5573. _context13.next = 15;
  5574. break;
  5575. }
  5576. return _context13.abrupt("return", {
  5577. v: {
  5578. payload: payload,
  5579. response: _response
  5580. }
  5581. });
  5582. case 15:
  5583. if (!(((_triggersArray$i8 = triggersArray[i]) === null || _triggersArray$i8 === void 0 ? void 0 : _triggersArray$i8.shouldReturnResponse) === true)) {
  5584. _context13.next = 17;
  5585. break;
  5586. }
  5587. return _context13.abrupt("return", {
  5588. v: _response
  5589. });
  5590. case 17:
  5591. return _context13.abrupt("break", 81);
  5592. case 18:
  5593. if (triggersArray[i].message) {
  5594. _context13.next = 20;
  5595. break;
  5596. }
  5597. throw new Error('web3Sign trigger does not have a message to sign');
  5598. case 20:
  5599. if (triggersArray[i].signer) {
  5600. _context13.next = 22;
  5601. break;
  5602. }
  5603. throw new Error('web3Sign trigger signer address missing or invalid');
  5604. case 22:
  5605. // eslint-disable-next-line no-case-declarations
  5606. message = JSON.parse(triggersArray[i].message);
  5607. delete message.types.EIP712Domain; // eslint-disable-next-line no-case-declarations
  5608. _context13.next = 26;
  5609. return _this3.getInternalWeb3Provider().signer._signTypedData(message.domain, message.types, message.message);
  5610. case 26:
  5611. _response = _context13.sent; // Save response
  5612. if (((_triggersArray$i9 = triggersArray[i]) === null || _triggersArray$i9 === void 0 ? void 0 : _triggersArray$i9.saveResponse) === true) _this3.memoryCard.save(_response); // Return payload and response
  5613. if (!(((_triggersArray$i10 = triggersArray[i]) === null || _triggersArray$i10 === void 0 ? void 0 : _triggersArray$i10.shouldReturnPayload) === true)) {
  5614. _context13.next = 30;
  5615. break;
  5616. }
  5617. return _context13.abrupt("return", {
  5618. v: {
  5619. payload: payload,
  5620. response: _response
  5621. }
  5622. });
  5623. case 30:
  5624. if (!(((_triggersArray$i11 = triggersArray[i]) === null || _triggersArray$i11 === void 0 ? void 0 : _triggersArray$i11.shouldReturnResponse) === true)) {
  5625. _context13.next = 32;
  5626. break;
  5627. }
  5628. return _context13.abrupt("return", {
  5629. v: _response
  5630. });
  5631. case 32:
  5632. return _context13.abrupt("break", 81);
  5633. case 33:
  5634. if (triggersArray[i].pluginName) {
  5635. _context13.next = 35;
  5636. break;
  5637. }
  5638. throw new Error('callPluginEndpoint trigger does not have an plugin name to call');
  5639. case 35:
  5640. if (triggersArray[i].endpoint) {
  5641. _context13.next = 37;
  5642. break;
  5643. }
  5644. throw new Error('callPluginEndpoint trigger does not have an endpoint to call');
  5645. case 37:
  5646. if (!(((_triggersArray$i12 = triggersArray[i]) === null || _triggersArray$i12 === void 0 ? void 0 : _triggersArray$i12.shouldAwait) === true)) {
  5647. _context13.next = 42;
  5648. break;
  5649. } // Check if a saved response has to be used to fill a parameter needed by the plugin
  5650. if (triggersArray[i].useSavedResponse === true) {
  5651. triggersArray[i].params[triggersArray[i].savedResponseAs] = _this3.memoryCard.get(triggersArray[i].savedResponseAt);
  5652. } // Call the endpoint
  5653. _context13.next = 41;
  5654. return (0, _Cloud.run)((0, _concat.default)(_context11 = "".concat(triggersArray[i].pluginName, "_")).call(_context11, triggersArray[i].endpoint), triggersArray[i].params);
  5655. case 41:
  5656. _response = _context13.sent;
  5657. case 42:
  5658. // Call a plugin endpoint (does NOT await)
  5659. if (((_triggersArray$i13 = triggersArray[i]) === null || _triggersArray$i13 === void 0 ? void 0 : _triggersArray$i13.shouldAwait) === false) {
  5660. // Check if a saved response has to be used to fill a parameter needed by the plugin
  5661. if (triggersArray[i].useSavedResponse === true) {
  5662. triggersArray[i].params[triggersArray[i].savedResponseAs] = _this3.memoryCard.get(triggersArray[i].savedResponseAt);
  5663. } // Call the endpoint
  5664. _response = (0, _Cloud.run)((0, _concat.default)(_context12 = "".concat(triggersArray[i].pluginName, "_")).call(_context12, triggersArray[i].endpoint), triggersArray[i].params);
  5665. } // If the response contains a trigger, run it
  5666. if (!(triggersArray[i].runResponseTrigger === true)) {
  5667. _context13.next = 47;
  5668. break;
  5669. }
  5670. _context13.next = 46;
  5671. return _this3.handleTriggers(_response.data.result.triggers, _response.data.result.data);
  5672. case 46:
  5673. _response = _context13.sent;
  5674. case 47:
  5675. // Save response
  5676. if (((_triggersArray$i14 = triggersArray[i]) === null || _triggersArray$i14 === void 0 ? void 0 : _triggersArray$i14.saveResponse) === true) _this3.memoryCard.save(_response); // If should not run the response trigger, continues the loop and does not return (to avoid breaking the loop execution and run other pending triggers)
  5677. if (!(((_triggersArray$i15 = triggersArray[i]) === null || _triggersArray$i15 === void 0 ? void 0 : _triggersArray$i15.runResponseTrigger) === false)) {
  5678. _context13.next = 50;
  5679. break;
  5680. }
  5681. return _context13.abrupt("return", "continue");
  5682. case 50:
  5683. if (!(((_triggersArray$i16 = triggersArray[i]) === null || _triggersArray$i16 === void 0 ? void 0 : _triggersArray$i16.shouldReturnPayload) === true)) {
  5684. _context13.next = 52;
  5685. break;
  5686. }
  5687. return _context13.abrupt("return", {
  5688. v: {
  5689. payload: 'payload',
  5690. response: _response
  5691. }
  5692. });
  5693. case 52:
  5694. if (!(((_triggersArray$i17 = triggersArray[i]) === null || _triggersArray$i17 === void 0 ? void 0 : _triggersArray$i17.shouldReturnResponse) === true)) {
  5695. _context13.next = 54;
  5696. break;
  5697. }
  5698. return _context13.abrupt("return", {
  5699. v: _response
  5700. });
  5701. case 54:
  5702. return _context13.abrupt("break", 81);
  5703. case 55:
  5704. if (triggersArray[i].parameters) {
  5705. _context13.next = 57;
  5706. break;
  5707. }
  5708. throw new Error('web3SignV4 trigger does not have `parameters` to sign');
  5709. case 57:
  5710. if (triggersArray[i].from) {
  5711. _context13.next = 59;
  5712. break;
  5713. }
  5714. throw new Error('web3SignV4 trigger does not have a `from` address');
  5715. case 59:
  5716. if (!(((_triggersArray$i18 = triggersArray[i]) === null || _triggersArray$i18 === void 0 ? void 0 : _triggersArray$i18.shouldAwait) === true)) {
  5717. _context13.next = 74;
  5718. break;
  5719. }
  5720. _context13.prev = 60;
  5721. _JSON$parse = JSON.parse(triggersArray[i].parameters[1]), domain = _JSON$parse.domain, types = _JSON$parse.types, _message = _JSON$parse.message;
  5722. if (types.EIP712Domain) {
  5723. // Ethers.js will compute this automatically
  5724. delete types.EIP712Domain;
  5725. }
  5726. _context13.next = 65;
  5727. return _this3.getInternalWeb3Provider().signer._signTypedData(domain, types, _message);
  5728. case 65:
  5729. signature = _context13.sent;
  5730. result = {
  5731. result: signature
  5732. };
  5733. if (((_triggersArray$i19 = triggersArray[i]) === null || _triggersArray$i19 === void 0 ? void 0 : _triggersArray$i19.saveResponse) === true) _this3.memoryCard.save(result);
  5734. _response = result;
  5735. _context13.next = 74;
  5736. break;
  5737. case 71:
  5738. _context13.prev = 71;
  5739. _context13.t1 = _context13["catch"](60);
  5740. throw new Error(_context13.t1.message || _context13.t1);
  5741. case 74:
  5742. if (((_triggersArray$i20 = triggersArray[i]) === null || _triggersArray$i20 === void 0 ? void 0 : _triggersArray$i20.shouldAwait) === false) {
  5743. _JSON$parse2 = JSON.parse(triggersArray[i].parameters[1]), _domain = _JSON$parse2.domain, _types = _JSON$parse2.types, _message2 = _JSON$parse2.message;
  5744. if (_types.EIP712Domain) {
  5745. // Ethers.js will compute this automatically
  5746. delete _types.EIP712Domain;
  5747. }
  5748. _this3.getInternalWeb3Provider().signer._signTypedData(_domain, _types, _message2) // eslint-disable-next-line no-loop-func
  5749. .then(function (signature) {
  5750. var _triggersArray$i21;
  5751. var result = {
  5752. result: signature
  5753. };
  5754. if (((_triggersArray$i21 = triggersArray[i]) === null || _triggersArray$i21 === void 0 ? void 0 : _triggersArray$i21.saveResponse) === true) _this3.memoryCard.save(result);
  5755. _response = result;
  5756. }).catch(function (error) {
  5757. throw new Error(error.message || error);
  5758. });
  5759. } // Return payload and response
  5760. if (!(((_triggersArray$i22 = triggersArray[i]) === null || _triggersArray$i22 === void 0 ? void 0 : _triggersArray$i22.shouldReturnPayload) === true)) {
  5761. _context13.next = 77;
  5762. break;
  5763. }
  5764. return _context13.abrupt("return", {
  5765. v: {
  5766. payload: payload,
  5767. response: _response
  5768. }
  5769. });
  5770. case 77:
  5771. if (!(((_triggersArray$i23 = triggersArray[i]) === null || _triggersArray$i23 === void 0 ? void 0 : _triggersArray$i23.shouldReturnResponse) === true)) {
  5772. _context13.next = 79;
  5773. break;
  5774. }
  5775. return _context13.abrupt("return", {
  5776. v: _response
  5777. });
  5778. case 79:
  5779. return _context13.abrupt("break", 81);
  5780. case 80:
  5781. throw new Error("Unknown trigger: \"".concat((_triggersArray$i24 = triggersArray[i]) === null || _triggersArray$i24 === void 0 ? void 0 : _triggersArray$i24.name, "\""));
  5782. case 81:
  5783. case "end":
  5784. return _context13.stop();
  5785. }
  5786. }
  5787. }, _loop, null, [[60, 71]]);
  5788. });
  5789. i = 0;
  5790. case 4:
  5791. if (!(i < triggersArray.length)) {
  5792. _context14.next = 14;
  5793. break;
  5794. }
  5795. return _context14.delegateYield(_loop(i), "t0", 6);
  5796. case 6:
  5797. _ret = _context14.t0;
  5798. if (!(_ret === "continue")) {
  5799. _context14.next = 9;
  5800. break;
  5801. }
  5802. return _context14.abrupt("continue", 11);
  5803. case 9:
  5804. if (!((0, _typeof2.default)(_ret) === "object")) {
  5805. _context14.next = 11;
  5806. break;
  5807. }
  5808. return _context14.abrupt("return", _ret.v);
  5809. case 11:
  5810. i++;
  5811. _context14.next = 4;
  5812. break;
  5813. case 14:
  5814. // Delete all saved data
  5815. this.memoryCard.deleteSaved();
  5816. case 15:
  5817. case "end":
  5818. return _context14.stop();
  5819. }
  5820. }
  5821. }, _callee9, this);
  5822. }));
  5823. return function () {
  5824. return _handleTriggers.apply(this, arguments);
  5825. };
  5826. }()
  5827. }, {
  5828. key: "getAllERC20",
  5829. value: function () {
  5830. var _getAllERC = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee10() {
  5831. var _ref2,
  5832. chain,
  5833. address,
  5834. result,
  5835. _args11 = arguments;
  5836. return _regenerator.default.wrap(function (_context15) {
  5837. while (1) {
  5838. switch (_context15.prev = _context15.next) {
  5839. case 0:
  5840. _ref2 = _args11.length > 0 && _args11[0] !== undefined ? _args11[0] : {}, chain = _ref2.chain, address = _ref2.address;
  5841. _context15.next = 3;
  5842. return (0, _Cloud.run)('getAllERC20', {
  5843. chain: chain,
  5844. address: address
  5845. });
  5846. case 3:
  5847. result = _context15.sent;
  5848. return _context15.abrupt("return", result);
  5849. case 5:
  5850. case "end":
  5851. return _context15.stop();
  5852. }
  5853. }
  5854. }, _callee10);
  5855. }));
  5856. return function () {
  5857. return _getAllERC.apply(this, arguments);
  5858. };
  5859. }()
  5860. }, {
  5861. key: "getERC20",
  5862. value: function () {
  5863. var _getERC = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee11() {
  5864. var _ref3,
  5865. chain,
  5866. address,
  5867. symbol,
  5868. tokenAddress,
  5869. result,
  5870. _args12 = arguments;
  5871. return _regenerator.default.wrap(function (_context16) {
  5872. while (1) {
  5873. switch (_context16.prev = _context16.next) {
  5874. case 0:
  5875. _ref3 = _args12.length > 0 && _args12[0] !== undefined ? _args12[0] : {}, chain = _ref3.chain, address = _ref3.address, symbol = _ref3.symbol, tokenAddress = _ref3.tokenAddress;
  5876. result = (0, _Cloud.run)('getERC20', {
  5877. chain: chain,
  5878. address: address,
  5879. symbol: symbol,
  5880. tokenAddress: tokenAddress
  5881. });
  5882. return _context16.abrupt("return", result);
  5883. case 3:
  5884. case "end":
  5885. return _context16.stop();
  5886. }
  5887. }
  5888. }, _callee11);
  5889. }));
  5890. return function () {
  5891. return _getERC.apply(this, arguments);
  5892. };
  5893. }()
  5894. }, {
  5895. key: "getNFTs",
  5896. value: function () {
  5897. var _ref4 = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},
  5898. _ref4$chain = _ref4.chain,
  5899. chain = _ref4$chain === void 0 ? 'Eth' : _ref4$chain,
  5900. _ref4$address = _ref4.address,
  5901. address = _ref4$address === void 0 ? '' : _ref4$address;
  5902. return (0, _Cloud.run)('getNFTs_old', {
  5903. chain: chain,
  5904. address: address
  5905. });
  5906. }
  5907. }, {
  5908. key: "getNFTsCount",
  5909. value: function () {
  5910. var _ref5 = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},
  5911. _ref5$chain = _ref5.chain,
  5912. chain = _ref5$chain === void 0 ? 'Eth' : _ref5$chain,
  5913. _ref5$address = _ref5.address,
  5914. address = _ref5$address === void 0 ? '' : _ref5$address;
  5915. return (0, _Cloud.run)('getNFTsCount_old', {
  5916. chain: chain,
  5917. address: address
  5918. });
  5919. }
  5920. }, {
  5921. key: "getTransactions",
  5922. value: function () {
  5923. var _ref6 = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},
  5924. _ref6$chain = _ref6.chain,
  5925. chain = _ref6$chain === void 0 ? 'Eth' : _ref6$chain,
  5926. _ref6$address = _ref6.address,
  5927. address = _ref6$address === void 0 ? '' : _ref6$address,
  5928. _ref6$order = _ref6.order,
  5929. order = _ref6$order === void 0 ? 'desc' : _ref6$order;
  5930. return (0, _Cloud.run)('getTransactions', {
  5931. chain: chain,
  5932. address: address,
  5933. order: order
  5934. });
  5935. }
  5936. }, {
  5937. key: "getTransactionsCount",
  5938. value: function () {
  5939. var _ref7 = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},
  5940. _ref7$chain = _ref7.chain,
  5941. chain = _ref7$chain === void 0 ? 'Eth' : _ref7$chain,
  5942. _ref7$address = _ref7.address,
  5943. address = _ref7$address === void 0 ? '' : _ref7$address;
  5944. return (0, _Cloud.run)('getTransactionsCount', {
  5945. chain: chain,
  5946. address: address
  5947. });
  5948. }
  5949. }, {
  5950. key: "transfer",
  5951. value: function () {
  5952. var _transfer = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee12() {
  5953. var _ref8,
  5954. _ref8$type,
  5955. type,
  5956. _ref8$receiver,
  5957. receiver,
  5958. _ref8$contractAddress,
  5959. contractAddress,
  5960. contract_address,
  5961. _ref8$amount,
  5962. amount,
  5963. _ref8$tokenId,
  5964. tokenId,
  5965. token_id,
  5966. _ref8$system,
  5967. system,
  5968. options,
  5969. _this$getInternalWeb3,
  5970. internalWeb3,
  5971. sender,
  5972. signer,
  5973. transferOperation,
  5974. customToken,
  5975. result,
  5976. _args13 = arguments;
  5977. return _regenerator.default.wrap(function (_context17) {
  5978. while (1) {
  5979. switch (_context17.prev = _context17.next) {
  5980. case 0:
  5981. _ref8 = _args13.length > 0 && _args13[0] !== undefined ? _args13[0] : {}, _ref8$type = _ref8.type, type = _ref8$type === void 0 ? 'native' : _ref8$type, _ref8$receiver = _ref8.receiver, receiver = _ref8$receiver === void 0 ? '' : _ref8$receiver, _ref8$contractAddress = _ref8.contractAddress, contractAddress = _ref8$contractAddress === void 0 ? '' : _ref8$contractAddress, contract_address = _ref8.contract_address, _ref8$amount = _ref8.amount, amount = _ref8$amount === void 0 ? '' : _ref8$amount, _ref8$tokenId = _ref8.tokenId, tokenId = _ref8$tokenId === void 0 ? '' : _ref8$tokenId, token_id = _ref8.token_id, _ref8$system = _ref8.system, system = _ref8$system === void 0 ? 'evm' : _ref8$system; // Allow snake-case for backwards compatibility
  5982. // eslint-disable-next-line camelcase
  5983. contractAddress = contractAddress || contract_address; // eslint-disable-next-line camelcase
  5984. tokenId = tokenId || token_id;
  5985. options = {
  5986. receiver: receiver,
  5987. contractAddress: contractAddress,
  5988. amount: amount,
  5989. tokenId: tokenId,
  5990. system: system
  5991. };
  5992. _TransferUtils.default.isSupportedType(type);
  5993. _TransferUtils.default.validateInput(type, options);
  5994. _this$getInternalWeb3 = this.getInternalWeb3Provider(), internalWeb3 = _this$getInternalWeb3.web3, sender = _this$getInternalWeb3.account, signer = _this$getInternalWeb3.signer;
  5995. if (sender) {
  5996. _context17.next = 9;
  5997. break;
  5998. }
  5999. throw new Error('Sender address not found');
  6000. case 9:
  6001. if (tokenId) _TransferUtils.default.isUint256(tokenId);
  6002. if (type !== 'native') {
  6003. customToken = new _ethers.ethers.Contract(contractAddress, _TransferUtils.default.abi[type], signer);
  6004. }
  6005. _context17.t0 = type;
  6006. _context17.next = _context17.t0 === 'native' ? 14 : _context17.t0 === 'erc20' ? 16 : _context17.t0 === 'erc721' ? 18 : _context17.t0 === 'erc1155' ? 20 : 22;
  6007. break;
  6008. case 14:
  6009. transferOperation = signer.sendTransaction({
  6010. to: receiver,
  6011. value: _ethers.ethers.BigNumber.from(amount)
  6012. });
  6013. return _context17.abrupt("break", 23);
  6014. case 16:
  6015. transferOperation = customToken.transfer(receiver, amount, {
  6016. from: sender
  6017. });
  6018. return _context17.abrupt("break", 23);
  6019. case 18:
  6020. transferOperation = customToken.safeTransferFrom(sender, receiver, "".concat(tokenId), {
  6021. from: sender
  6022. });
  6023. return _context17.abrupt("break", 23);
  6024. case 20:
  6025. transferOperation = customToken.safeTransferFrom(sender, receiver, "".concat(tokenId), amount, '0x', {
  6026. from: sender
  6027. });
  6028. return _context17.abrupt("break", 23);
  6029. case 22:
  6030. throw new Error("Unknown transfer type: \"".concat(type, "\""));
  6031. case 23:
  6032. _context17.next = 25;
  6033. return transferOperation;
  6034. case 25:
  6035. result = _context17.sent;
  6036. return _context17.abrupt("return", result);
  6037. case 27:
  6038. case "end":
  6039. return _context17.stop();
  6040. }
  6041. }
  6042. }, _callee12, this);
  6043. }));
  6044. return function () {
  6045. return _transfer.apply(this, arguments);
  6046. };
  6047. }()
  6048. }, {
  6049. key: "executeFunction",
  6050. value: function () {
  6051. var _executeFunction = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee13() {
  6052. var _functionData, _context25, _context26;
  6053. var _ref9,
  6054. contractAddress,
  6055. abi,
  6056. functionName,
  6057. msgValue,
  6058. _ref9$params,
  6059. params,
  6060. _ref9$overrides,
  6061. overrides,
  6062. contractOptions,
  6063. _this$getInternalWeb4,
  6064. account,
  6065. internalWeb3,
  6066. provider,
  6067. signerOrProvider,
  6068. overloadedFunction,
  6069. functionData,
  6070. _context18,
  6071. _context19,
  6072. nameWithoutTopics,
  6073. topics,
  6074. functionDataArray,
  6075. possibleTopics,
  6076. _functionDataArray,
  6077. _possibleTopics,
  6078. stateMutability,
  6079. isReadFunction,
  6080. currentAddress,
  6081. errors,
  6082. _iterator,
  6083. _step,
  6084. input,
  6085. value,
  6086. parsedInputs,
  6087. contract,
  6088. contractMethod,
  6089. response,
  6090. _args14 = arguments;
  6091. return _regenerator.default.wrap(function (_context27) {
  6092. while (1) {
  6093. switch (_context27.prev = _context27.next) {
  6094. case 0:
  6095. _ref9 = _args14.length > 0 && _args14[0] !== undefined ? _args14[0] : {}, contractAddress = _ref9.contractAddress, abi = _ref9.abi, functionName = _ref9.functionName, msgValue = _ref9.msgValue, _ref9$params = _ref9.params, params = _ref9$params === void 0 ? {} : _ref9$params, _ref9$overrides = _ref9.overrides, overrides = _ref9$overrides === void 0 ? {} : _ref9$overrides;
  6096. contractOptions = {};
  6097. _this$getInternalWeb4 = this.getInternalWeb3Provider(), account = _this$getInternalWeb4.account, internalWeb3 = _this$getInternalWeb4.web3, provider = _this$getInternalWeb4.provider, signerOrProvider = _this$getInternalWeb4.signerOrProvider; // Check if function is an overloaded function definition. ex "getMessage(string)", or "getMessage()"
  6098. overloadedFunction = functionName.match(/^(.+)\((.*)\)$/);
  6099. if (!overloadedFunction) {
  6100. _context27.next = 16;
  6101. break;
  6102. } // Get functiondata from overloaded function
  6103. nameWithoutTopics = overloadedFunction[1];
  6104. topics = (0, _filter.default)(_context18 = (0, _map.default)(_context19 = overloadedFunction[2].split(',')).call(_context19, function (topic) {
  6105. return (0, _trim.default)(topic).call(topic);
  6106. })).call(_context18, function (topic) {
  6107. return !!topic;
  6108. });
  6109. functionDataArray = (0, _filter.default)(abi).call(abi, function (x) {
  6110. return x.name === nameWithoutTopics;
  6111. });
  6112. if (!(functionDataArray.length === 0)) {
  6113. _context27.next = 10;
  6114. break;
  6115. }
  6116. throw new Error('Function does not exist in abi');
  6117. case 10:
  6118. functionData = (0, _find.default)(functionDataArray).call(functionDataArray, function (data) {
  6119. var _data$inputs$length, _context20;
  6120. return ((_data$inputs$length = data === null || data === void 0 ? void 0 : data.inputs.length) !== null && _data$inputs$length !== void 0 ? _data$inputs$length : 0) === topics.length && (0, _every.default)(_context20 = data.inputs).call(_context20, function (input, index) {
  6121. return input.type === topics[index];
  6122. });
  6123. });
  6124. if (functionData) {
  6125. _context27.next = 14;
  6126. break;
  6127. }
  6128. possibleTopics = (0, _map.default)(functionDataArray).call(functionDataArray, function (data) {
  6129. var _context21, _context22;
  6130. return (0, _concat.default)(_context21 = "".concat(data.name, "(")).call(_context21, (0, _map.default)(_context22 = data.inputs).call(_context22, function (input) {
  6131. return input.type;
  6132. }).join(','), ")");
  6133. });
  6134. throw new Error("Function with the provided topic does not exist in abi. Possible funcationNames: ".concat(possibleTopics.join(' ,')));
  6135. case 14:
  6136. _context27.next = 23;
  6137. break;
  6138. case 16:
  6139. // Get functiondata from 'normal' function
  6140. _functionDataArray = (0, _filter.default)(abi).call(abi, function (x) {
  6141. return x.name === functionName;
  6142. });
  6143. if (!(_functionDataArray.length === 0)) {
  6144. _context27.next = 19;
  6145. break;
  6146. }
  6147. throw new Error('Function does not exist in abi');
  6148. case 19:
  6149. if (!(_functionDataArray.length > 1)) {
  6150. _context27.next = 22;
  6151. break;
  6152. }
  6153. _possibleTopics = (0, _map.default)(_functionDataArray).call(_functionDataArray, function (data) {
  6154. var _context23, _context24;
  6155. return (0, _concat.default)(_context23 = "".concat(data.name, "(")).call(_context23, (0, _map.default)(_context24 = data.inputs).call(_context24, function (input) {
  6156. return input.type;
  6157. }).join(','), ")");
  6158. });
  6159. throw new Error("Multiple function definitions found in the abi. Please include the topic in the functionName. Possible funcationNames: ".concat(_possibleTopics.join(' ,')));
  6160. case 22:
  6161. functionData = _functionDataArray[0];
  6162. case 23:
  6163. stateMutability = (_functionData = functionData) === null || _functionData === void 0 ? void 0 : _functionData.stateMutability;
  6164. isReadFunction = stateMutability === 'view' || stateMutability === 'pure';
  6165. if (isReadFunction) {
  6166. _context27.next = 31;
  6167. break;
  6168. }
  6169. if (params.from) {
  6170. _context27.next = 31;
  6171. break;
  6172. }
  6173. currentAddress = account;
  6174. if (currentAddress) {
  6175. _context27.next = 30;
  6176. break;
  6177. }
  6178. throw new Error('From address is required');
  6179. case 30:
  6180. contractOptions.from = currentAddress;
  6181. case 31:
  6182. errors = [];
  6183. _iterator = _createForOfIteratorHelper(functionData.inputs);
  6184. try {
  6185. for (_iterator.s(); !(_step = _iterator.n()).done;) {
  6186. input = _step.value;
  6187. value = params[input.name];
  6188. if (!value && typeof value !== 'number' && typeof value !== 'boolean' && input.name !== '') {
  6189. errors.push("".concat(input.name, " is required"));
  6190. }
  6191. }
  6192. } catch (err) {
  6193. _iterator.e(err);
  6194. } finally {
  6195. _iterator.f();
  6196. }
  6197. if (!(errors.length > 0)) {
  6198. _context27.next = 36;
  6199. break;
  6200. }
  6201. throw errors;
  6202. case 36:
  6203. parsedInputs = (0, _map.default)(_context25 = functionData.inputs).call(_context25, function (x) {
  6204. return params[x.name];
  6205. });
  6206. contract = new _ethers.ethers.Contract(contractAddress, abi, signerOrProvider);
  6207. contractMethod = contract[functionName];
  6208. if (contractMethod) {
  6209. _context27.next = 41;
  6210. break;
  6211. }
  6212. throw new Error("Cannot find function \"".concat(functionName, "\" on the contract"));
  6213. case 41:
  6214. _context27.next = 43;
  6215. return contractMethod.apply(void 0, (0, _concat.default)(_context26 = (0, _toConsumableArray2.default)((0, _values.default)(parsedInputs))).call(_context26, [msgValue ? {
  6216. value: _ethers.ethers.BigNumber.from("".concat(msgValue))
  6217. } : {}]));
  6218. case 43:
  6219. response = _context27.sent;
  6220. return _context27.abrupt("return", response);
  6221. case 45:
  6222. case "end":
  6223. return _context27.stop();
  6224. }
  6225. }
  6226. }, _callee13, this);
  6227. }));
  6228. return function () {
  6229. return _executeFunction.apply(this, arguments);
  6230. };
  6231. }()
  6232. }, {
  6233. key: "getSigningData",
  6234. value: function () {
  6235. return "Moralis Authentication";
  6236. }
  6237. }, {
  6238. key: "ensureWeb3IsInstalled",
  6239. value: function () {
  6240. return this.internalWeb3Provider && this.internalWeb3Provider.web3 ? true : false;
  6241. }
  6242. /**
  6243. * Gets the internalWeb3Provider with validation to make sure it has been instansiated with 'enableWeb3()'
  6244. */
  6245. }, {
  6246. key: "getInternalWeb3Provider",
  6247. value: function () {
  6248. if (!this.ensureWeb3IsInstalled()) throw new Error(ERROR_WEB3_MISSING);
  6249. return this.internalWeb3Provider;
  6250. }
  6251. /**
  6252. * Gets web3 from the internalWeb3Provider with validation to make sure it has been instansiated with 'enableWeb3()'
  6253. */
  6254. }, {
  6255. key: "getInternalWeb3",
  6256. value: function () {
  6257. return this.getInternalWeb3Provider().web3;
  6258. }
  6259. }, {
  6260. key: "provider",
  6261. get: function () {
  6262. var _this$internalWeb3Pro2, _this$internalWeb3Pro3;
  6263. return (_this$internalWeb3Pro2 = (_this$internalWeb3Pro3 = this.internalWeb3Provider) === null || _this$internalWeb3Pro3 === void 0 ? void 0 : _this$internalWeb3Pro3.provider) !== null && _this$internalWeb3Pro2 !== void 0 ? _this$internalWeb3Pro2 : null;
  6264. }
  6265. }, {
  6266. key: "connector",
  6267. get: function () {
  6268. var _this$internalWeb3Pro4, _this$internalWeb3Pro5;
  6269. return (_this$internalWeb3Pro4 = (_this$internalWeb3Pro5 = this.internalWeb3Provider) === null || _this$internalWeb3Pro5 === void 0 ? void 0 : _this$internalWeb3Pro5.connector) !== null && _this$internalWeb3Pro4 !== void 0 ? _this$internalWeb3Pro4 : null;
  6270. }
  6271. }, {
  6272. key: "connectorType",
  6273. get: function () {
  6274. var _this$connector$type, _this$connector;
  6275. return (_this$connector$type = (_this$connector = this.connector) === null || _this$connector === void 0 ? void 0 : _this$connector.type) !== null && _this$connector$type !== void 0 ? _this$connector$type : null;
  6276. }
  6277. }, {
  6278. key: "network",
  6279. get: function () {
  6280. var _this$connector$netwo, _this$connector2;
  6281. return (_this$connector$netwo = (_this$connector2 = this.connector) === null || _this$connector2 === void 0 ? void 0 : _this$connector2.network) !== null && _this$connector$netwo !== void 0 ? _this$connector$netwo : null;
  6282. }
  6283. }, {
  6284. key: "account",
  6285. get: function () {
  6286. var _this$internalWeb3Pro6, _this$internalWeb3Pro7;
  6287. return (_this$internalWeb3Pro6 = (_this$internalWeb3Pro7 = this.internalWeb3Provider) === null || _this$internalWeb3Pro7 === void 0 ? void 0 : _this$internalWeb3Pro7.account) !== null && _this$internalWeb3Pro6 !== void 0 ? _this$internalWeb3Pro6 : null;
  6288. }
  6289. }, {
  6290. key: "chainId",
  6291. get: function () {
  6292. var _this$internalWeb3Pro8, _this$internalWeb3Pro9;
  6293. return (_this$internalWeb3Pro8 = (_this$internalWeb3Pro9 = this.internalWeb3Provider) === null || _this$internalWeb3Pro9 === void 0 ? void 0 : _this$internalWeb3Pro9.chainId) !== null && _this$internalWeb3Pro8 !== void 0 ? _this$internalWeb3Pro8 : null;
  6294. }
  6295. }, {
  6296. key: "getChainId",
  6297. value: function () {
  6298. return this.chainId;
  6299. }
  6300. }, {
  6301. key: "web3Library",
  6302. get: function () {
  6303. return _ethers.ethers;
  6304. }
  6305. }, {
  6306. key: "_forwardToConnector",
  6307. value: function (methodName, args) {
  6308. var _this$getInternalWeb5 = this.getInternalWeb3Provider(),
  6309. connector = _this$getInternalWeb5.connector;
  6310. var hasMethod = Boolean(connector[methodName]);
  6311. if (!hasMethod) {
  6312. var _context28;
  6313. throw new Error((0, _concat.default)(_context28 = "Cannot call ".concat(methodName, ", as it does not exist on connector type \"")).call(_context28, connector.type, "\""));
  6314. }
  6315. return connector[methodName].apply(connector, (0, _toConsumableArray2.default)(args));
  6316. }
  6317. }, {
  6318. key: "switchNetwork",
  6319. value: function () {
  6320. for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
  6321. args[_key] = arguments[_key];
  6322. }
  6323. return this._forwardToConnector('switchNetwork', args);
  6324. }
  6325. }, {
  6326. key: "addNetwork",
  6327. value: function () {
  6328. for (var _len2 = arguments.length, args = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
  6329. args[_key2] = arguments[_key2];
  6330. }
  6331. return this._forwardToConnector('addNetwork', args);
  6332. }
  6333. }, {
  6334. key: "isMetaMaskInstalled",
  6335. value: function () {
  6336. var _isMetaMaskInstalled = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee14() {
  6337. return _regenerator.default.wrap(function (_context29) {
  6338. while (1) {
  6339. switch (_context29.prev = _context29.next) {
  6340. case 0:
  6341. _context29.next = 2;
  6342. return (0, _detectProvider.default)();
  6343. case 2:
  6344. if (!_context29.sent) {
  6345. _context29.next = 6;
  6346. break;
  6347. }
  6348. _context29.t0 = true;
  6349. _context29.next = 7;
  6350. break;
  6351. case 6:
  6352. _context29.t0 = false;
  6353. case 7:
  6354. return _context29.abrupt("return", _context29.t0);
  6355. case 8:
  6356. case "end":
  6357. return _context29.stop();
  6358. }
  6359. }
  6360. }, _callee14);
  6361. }));
  6362. return function () {
  6363. return _isMetaMaskInstalled.apply(this, arguments);
  6364. };
  6365. }()
  6366. }]);
  6367. return MoralisWeb3;
  6368. }();
  6369. (0, _defineProperty2.default)(MoralisWeb3, "speedyNodeApiKey", void 0);
  6370. (0, _defineProperty2.default)(MoralisWeb3, "web3", null);
  6371. (0, _defineProperty2.default)(MoralisWeb3, "internalWeb3Provider", null);
  6372. (0, _defineProperty2.default)(MoralisWeb3, "Plugins", {});
  6373. (0, _defineProperty2.default)(MoralisWeb3, "isEnablingWeb3", false);
  6374. (0, _defineProperty2.default)(MoralisWeb3, "memoryCard", {
  6375. save: function (what) {
  6376. this.saved = what;
  6377. },
  6378. get: function (where) {
  6379. if (!this.saved) throw new Error('Nothing saved to memory card'); // In case the saved data is not an object but a simple string or number
  6380. if (where.length === 0) return this.getSaved();
  6381. var tmp;
  6382. var savedTmp = this.saved;
  6383. for (var i = 0; i < where.length; i++) {
  6384. tmp = savedTmp[where[i]];
  6385. savedTmp = tmp;
  6386. }
  6387. return savedTmp;
  6388. },
  6389. getSaved: function () {
  6390. return this.saved;
  6391. },
  6392. deleteSaved: function () {
  6393. this.saved = undefined;
  6394. }
  6395. });
  6396. MoralisWeb3.onConnect = (0, _bind.default)(_context30 = MoralisWeb3.on).call(_context30, MoralisWeb3, _InternalWeb3Provider.InternalWeb3Events.PROVIDER_CONNECT);
  6397. MoralisWeb3.onDisconnect = (0, _bind.default)(_context31 = MoralisWeb3.on).call(_context31, MoralisWeb3, _InternalWeb3Provider.InternalWeb3Events.PROVIDER_DISCONNECT);
  6398. MoralisWeb3.onWeb3Enabled = (0, _bind.default)(_context32 = MoralisWeb3.on).call(_context32, MoralisWeb3, _InternalWeb3Provider.InternalWeb3Events.WEB3_ENABLED);
  6399. MoralisWeb3.onWeb3Deactivated = (0, _bind.default)(_context33 = MoralisWeb3.on).call(_context33, MoralisWeb3, _InternalWeb3Provider.InternalWeb3Events.WEB3_DEACTIVATED);
  6400. MoralisWeb3.onChainChanged = (0, _bind.default)(_context34 = MoralisWeb3.on).call(_context34, MoralisWeb3, _InternalWeb3Provider.InternalWeb3Events.CHAIN_CHANGED);
  6401. MoralisWeb3.onAccountChanged = (0, _bind.default)(_context35 = MoralisWeb3.on).call(_context35, MoralisWeb3, _InternalWeb3Provider.InternalWeb3Events.ACCOUNT_CHANGED);
  6402. var _default = MoralisWeb3;
  6403. exports.default = _default;
  6404. },{"./Cloud":4,"./InternalWeb3Provider":10,"./MoralisDot":16,"./MoralisErd":17,"./MoralisSol":18,"./ParseACL":26,"./ParseError":29,"./ParseObject":36,"./ParseQuery":39,"./ParseUser":44,"./TransferUtils":51,"./Web3Connector/InjectedWeb3Connector":55,"./Web3Connector/MagicWeb3Connector":56,"./Web3Connector/NetworkWeb3Connector":58,"./Web3Connector/WalletConnectWeb3Connector":59,"./Web3Connector/Web3AuthConnector":60,"./createSigningData":64,"@babel/runtime-corejs3/core-js-stable/array/from":78,"@babel/runtime-corejs3/core-js-stable/array/is-array":79,"@babel/runtime-corejs3/core-js-stable/instance/bind":80,"@babel/runtime-corejs3/core-js-stable/instance/concat":81,"@babel/runtime-corejs3/core-js-stable/instance/every":83,"@babel/runtime-corejs3/core-js-stable/instance/filter":84,"@babel/runtime-corejs3/core-js-stable/instance/find":85,"@babel/runtime-corejs3/core-js-stable/instance/for-each":86,"@babel/runtime-corejs3/core-js-stable/instance/map":90,"@babel/runtime-corejs3/core-js-stable/instance/slice":93,"@babel/runtime-corejs3/core-js-stable/instance/trim":97,"@babel/runtime-corejs3/core-js-stable/json/stringify":99,"@babel/runtime-corejs3/core-js-stable/object/define-property":105,"@babel/runtime-corejs3/core-js-stable/object/get-own-property-descriptor":108,"@babel/runtime-corejs3/core-js-stable/object/values":113,"@babel/runtime-corejs3/core-js-stable/symbol":119,"@babel/runtime-corejs3/core-js-stable/weak-map":122,"@babel/runtime-corejs3/core-js/get-iterator-method":125,"@babel/runtime-corejs3/helpers/asyncToGenerator":144,"@babel/runtime-corejs3/helpers/classCallCheck":145,"@babel/runtime-corejs3/helpers/createClass":147,"@babel/runtime-corejs3/helpers/defineProperty":148,"@babel/runtime-corejs3/helpers/interopRequireDefault":152,"@babel/runtime-corejs3/helpers/toConsumableArray":163,"@babel/runtime-corejs3/helpers/typeof":164,"@babel/runtime-corejs3/regenerator":167,"@metamask/detect-provider":289,"ethers":773,"events":775}],22:[function(_dereq_,module,exports){
  6405. "use strict";
  6406. var _Object$keys2 = _dereq_("@babel/runtime-corejs3/core-js-stable/object/keys");
  6407. var _Object$getOwnPropertySymbols = _dereq_("@babel/runtime-corejs3/core-js-stable/object/get-own-property-symbols");
  6408. var _filterInstanceProperty2 = _dereq_("@babel/runtime-corejs3/core-js-stable/instance/filter");
  6409. var _Object$getOwnPropertyDescriptor = _dereq_("@babel/runtime-corejs3/core-js-stable/object/get-own-property-descriptor");
  6410. var _forEachInstanceProperty2 = _dereq_("@babel/runtime-corejs3/core-js-stable/instance/for-each");
  6411. var _Object$getOwnPropertyDescriptors = _dereq_("@babel/runtime-corejs3/core-js-stable/object/get-own-property-descriptors");
  6412. var _Object$defineProperties = _dereq_("@babel/runtime-corejs3/core-js-stable/object/define-properties");
  6413. var _Object$defineProperty = _dereq_("@babel/runtime-corejs3/core-js-stable/object/define-property");
  6414. var _interopRequireDefault = _dereq_("@babel/runtime-corejs3/helpers/interopRequireDefault");
  6415. _Object$defineProperty(exports, "__esModule", {
  6416. value: true
  6417. });
  6418. exports.default = void 0;
  6419. var _regenerator = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/regenerator"));
  6420. var _forEach = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/instance/for-each"));
  6421. var _keys = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/object/keys"));
  6422. var _filter = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/instance/filter"));
  6423. var _includes = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/instance/includes"));
  6424. var _stringify = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/json/stringify"));
  6425. var _asyncToGenerator2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/helpers/asyncToGenerator"));
  6426. var _classCallCheck2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/helpers/classCallCheck"));
  6427. var _createClass2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/helpers/createClass"));
  6428. var _defineProperty2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/helpers/defineProperty"));
  6429. function ownKeys(object, enumerableOnly) {
  6430. var keys = _Object$keys2(object);
  6431. if (_Object$getOwnPropertySymbols) {
  6432. var symbols = _Object$getOwnPropertySymbols(object);
  6433. enumerableOnly && (symbols = _filterInstanceProperty2(symbols).call(symbols, function (sym) {
  6434. return _Object$getOwnPropertyDescriptor(object, sym).enumerable;
  6435. })), keys.push.apply(keys, symbols);
  6436. }
  6437. return keys;
  6438. }
  6439. function _objectSpread(target) {
  6440. for (var i = 1; i < arguments.length; i++) {
  6441. var _context44, _context45;
  6442. var source = null != arguments[i] ? arguments[i] : {};
  6443. i % 2 ? _forEachInstanceProperty2(_context44 = ownKeys(Object(source), !0)).call(_context44, function (key) {
  6444. (0, _defineProperty2.default)(target, key, source[key]);
  6445. }) : _Object$getOwnPropertyDescriptors ? _Object$defineProperties(target, _Object$getOwnPropertyDescriptors(source)) : _forEachInstanceProperty2(_context45 = ownKeys(Object(source))).call(_context45, function (key) {
  6446. _Object$defineProperty(target, key, _Object$getOwnPropertyDescriptor(source, key));
  6447. });
  6448. }
  6449. return target;
  6450. }
  6451. /**
  6452. * Automatically generated code, via genWeb3API.js
  6453. * Do not modify manually
  6454. */
  6455. var axios = _dereq_('axios');
  6456. var Web3Api = /*#__PURE__*/function () {
  6457. function Web3Api() {
  6458. (0, _classCallCheck2.default)(this, Web3Api);
  6459. }
  6460. (0, _createClass2.default)(Web3Api, null, [{
  6461. key: "initialize",
  6462. value: function (_ref) {
  6463. var apiKey = _ref.apiKey,
  6464. serverUrl = _ref.serverUrl,
  6465. _ref$Moralis = _ref.Moralis,
  6466. Moralis = _ref$Moralis === void 0 ? null : _ref$Moralis;
  6467. if (!serverUrl && !apiKey) {
  6468. throw new Error('Web3Api.initialize failed: initialize with apiKey or serverUrl');
  6469. }
  6470. if (apiKey) this.apiKey = apiKey;
  6471. if (serverUrl) this.serverUrl = serverUrl;
  6472. this.Moralis = Moralis;
  6473. }
  6474. }, {
  6475. key: "getBody",
  6476. value: function (params, bodyParams) {
  6477. var _this = this;
  6478. if (!params || !bodyParams || !bodyParams.length) {
  6479. return undefined;
  6480. }
  6481. var body = {};
  6482. (0, _forEach.default)(bodyParams).call(bodyParams, function (_ref2) {
  6483. var key = _ref2.key,
  6484. type = _ref2.type,
  6485. required = _ref2.required;
  6486. if (params[key] === undefined) {
  6487. if (required) throw new Error("param ".concat(key, " is required!"));
  6488. } else if (type === _this.BodyParamTypes.setBody) {
  6489. body = params[key];
  6490. } else {
  6491. body[key] = params[key];
  6492. } // remove the param so it doesn't also get added as a query param
  6493. delete params[key];
  6494. });
  6495. return body;
  6496. }
  6497. }, {
  6498. key: "getParameterizedUrl",
  6499. value: function (url, params) {
  6500. var _context;
  6501. if (!(0, _keys.default)(params).length) return url; // find url params, they start with :
  6502. var requiredParams = (0, _filter.default)(_context = url.split('/')).call(_context, function (s) {
  6503. return s && (0, _includes.default)(s).call(s, ':');
  6504. });
  6505. if (!requiredParams.length) return url;
  6506. var parameterizedUrl = url;
  6507. (0, _forEach.default)(requiredParams).call(requiredParams, function (p) {
  6508. // strip the : and replace with param value
  6509. var key = p.substr(1);
  6510. var value = params[key];
  6511. if (!value) {
  6512. throw new Error("required param ".concat(key, " not provided"));
  6513. }
  6514. parameterizedUrl = parameterizedUrl.replace(p, value); // remove required param from param list
  6515. // so it doesn't become part of the query params
  6516. delete params[key];
  6517. });
  6518. return parameterizedUrl;
  6519. }
  6520. }, {
  6521. key: "getApiRateLimitInfo",
  6522. value: function (headers) {
  6523. return {
  6524. 'x-rate-limit-limit': headers['x-rate-limit-limit'],
  6525. 'x-rate-limit-remaining-ttl': headers['x-rate-limit-remaining-ttl'],
  6526. 'x-rate-limit-used': headers['x-rate-limit-used'],
  6527. 'x-rate-limit-remaining-ip-ttl': headers['x-rate-limit-remaining-ip-ttl'],
  6528. 'x-rate-limit-ip-used': headers['x-rate-limit-ip-used']
  6529. };
  6530. }
  6531. }, {
  6532. key: "getApiErrorMessage",
  6533. value: function (error, url) {
  6534. var _error$response, _error$response$data;
  6535. return (error === null || error === void 0 ? void 0 : (_error$response = error.response) === null || _error$response === void 0 ? void 0 : (_error$response$data = _error$response.data) === null || _error$response$data === void 0 ? void 0 : _error$response$data.message) || (error === null || error === void 0 ? void 0 : error.message) || (error === null || error === void 0 ? void 0 : error.toString()) || "Web3 API error while calling ".concat(url);
  6536. }
  6537. }, {
  6538. key: "fetch",
  6539. value: function () {
  6540. var _fetch = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee(_ref3) {
  6541. var endpoint, providedParams, params, _this$Moralis, User, account, user;
  6542. return _regenerator.default.wrap(function (_context2) {
  6543. while (1) {
  6544. switch (_context2.prev = _context2.next) {
  6545. case 0:
  6546. endpoint = _ref3.endpoint, providedParams = _ref3.params; // Make a shallow copy to prevent modification of original params
  6547. params = _objectSpread({}, providedParams);
  6548. if (this.Moralis) {
  6549. _this$Moralis = this.Moralis, User = _this$Moralis.User, account = _this$Moralis.account;
  6550. user = User.current();
  6551. if (!params.address) {
  6552. if (user) {
  6553. params.address = user.get('ethAddress');
  6554. } else if (account) {
  6555. params.address = account;
  6556. }
  6557. }
  6558. }
  6559. if (this.apiKey) {
  6560. _context2.next = 5;
  6561. break;
  6562. }
  6563. return _context2.abrupt("return", this.fetchFromServer(endpoint.name, params));
  6564. case 5:
  6565. return _context2.abrupt("return", this.fetchFromApi(endpoint, params));
  6566. case 6:
  6567. case "end":
  6568. return _context2.stop();
  6569. }
  6570. }
  6571. }, _callee, this);
  6572. }));
  6573. return function () {
  6574. return _fetch.apply(this, arguments);
  6575. };
  6576. }()
  6577. }, {
  6578. key: "fetchFromApi",
  6579. value: function () {
  6580. var _fetchFromApi = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee2(endpoint, params) {
  6581. var _endpoint$method, method, url, bodyParams, parameterizedUrl, body, response, _error$response2, status, headers, data, msg;
  6582. return _regenerator.default.wrap(function (_context3) {
  6583. while (1) {
  6584. switch (_context3.prev = _context3.next) {
  6585. case 0:
  6586. _endpoint$method = endpoint.method, method = _endpoint$method === void 0 ? 'GET' : _endpoint$method, url = endpoint.url, bodyParams = endpoint.bodyParams;
  6587. _context3.prev = 1;
  6588. parameterizedUrl = this.getParameterizedUrl(url, params);
  6589. body = this.getBody(params, bodyParams);
  6590. _context3.next = 6;
  6591. return axios(this.baseURL + parameterizedUrl, {
  6592. params: params,
  6593. method: method,
  6594. body: body,
  6595. headers: {
  6596. Accept: 'application/json',
  6597. 'Content-Type': 'application/json',
  6598. 'x-api-key': this.apiKey
  6599. }
  6600. });
  6601. case 6:
  6602. response = _context3.sent;
  6603. return _context3.abrupt("return", response.data);
  6604. case 10:
  6605. _context3.prev = 10;
  6606. _context3.t0 = _context3["catch"](1);
  6607. _error$response2 = _context3.t0.response, status = _error$response2.status, headers = _error$response2.headers, data = _error$response2.data;
  6608. if (status === 429) {
  6609. msg = "This Moralis Server is rate-limited because of the plan restrictions. See the details about the current rate and throttle limits: ".concat((0, _stringify.default)(this.getApiRateLimitInfo(headers)));
  6610. } else {
  6611. msg = this.getApiErrorMessage(_context3.t0, url);
  6612. }
  6613. throw new Error(msg);
  6614. case 15:
  6615. case "end":
  6616. return _context3.stop();
  6617. }
  6618. }
  6619. }, _callee2, this, [[1, 10]]);
  6620. }));
  6621. return function () {
  6622. return _fetchFromApi.apply(this, arguments);
  6623. };
  6624. }()
  6625. }, {
  6626. key: "fetchFromServer",
  6627. value: function () {
  6628. var _fetchFromServer = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee3(name, options) {
  6629. var http, user, response, _error$response3, _error$response3$data;
  6630. return _regenerator.default.wrap(function (_context4) {
  6631. while (1) {
  6632. switch (_context4.prev = _context4.next) {
  6633. case 0:
  6634. if (this.serverUrl) {
  6635. _context4.next = 2;
  6636. break;
  6637. }
  6638. throw new Error('Web3Api not initialized, run Moralis.start() first');
  6639. case 2:
  6640. _context4.prev = 2;
  6641. http = axios.create({
  6642. baseURL: this.serverUrl
  6643. });
  6644. if (!options.chain) options.chain = 'eth';
  6645. user = this.Moralis.User.current();
  6646. if (user) {
  6647. options._SessionToken = user.attributes.sessionToken;
  6648. options._ApplicationId = this.Moralis.applicationId;
  6649. }
  6650. _context4.next = 9;
  6651. return http.post("/functions/".concat(name), options, {
  6652. headers: {
  6653. Accept: 'application/json',
  6654. 'Content-Type': 'application/json'
  6655. }
  6656. });
  6657. case 9:
  6658. response = _context4.sent;
  6659. return _context4.abrupt("return", response.data.result);
  6660. case 13:
  6661. _context4.prev = 13;
  6662. _context4.t0 = _context4["catch"](2);
  6663. if (!((_error$response3 = _context4.t0.response) !== null && _error$response3 !== void 0 && (_error$response3$data = _error$response3.data) !== null && _error$response3$data !== void 0 && _error$response3$data.error)) {
  6664. _context4.next = 17;
  6665. break;
  6666. }
  6667. throw new Error(_context4.t0.response.data.error);
  6668. case 17:
  6669. throw _context4.t0;
  6670. case 18:
  6671. case "end":
  6672. return _context4.stop();
  6673. }
  6674. }
  6675. }, _callee3, this, [[2, 13]]);
  6676. }));
  6677. return function () {
  6678. return _fetchFromServer.apply(this, arguments);
  6679. };
  6680. }()
  6681. }]);
  6682. return Web3Api;
  6683. }();
  6684. (0, _defineProperty2.default)(Web3Api, "baseURL", 'https://deep-index.moralis.io/api/v2');
  6685. (0, _defineProperty2.default)(Web3Api, "BodyParamTypes", {
  6686. setBody: 'set body',
  6687. property: 'property'
  6688. });
  6689. (0, _defineProperty2.default)(Web3Api, "native", {
  6690. getBlock: function () {
  6691. var _getBlock = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee4() {
  6692. var options,
  6693. _args4 = arguments;
  6694. return _regenerator.default.wrap(function (_context5) {
  6695. while (1) {
  6696. switch (_context5.prev = _context5.next) {
  6697. case 0:
  6698. options = _args4.length > 0 && _args4[0] !== undefined ? _args4[0] : {};
  6699. return _context5.abrupt("return", Web3Api.fetch({
  6700. endpoint: {
  6701. "method": "GET",
  6702. "group": "native",
  6703. "name": "getBlock",
  6704. "url": "/block/:block_number_or_hash"
  6705. },
  6706. params: options
  6707. }));
  6708. case 2:
  6709. case "end":
  6710. return _context5.stop();
  6711. }
  6712. }
  6713. }, _callee4);
  6714. }));
  6715. return function () {
  6716. return _getBlock.apply(this, arguments);
  6717. };
  6718. }(),
  6719. getDateToBlock: function () {
  6720. var _getDateToBlock = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee5() {
  6721. var options,
  6722. _args5 = arguments;
  6723. return _regenerator.default.wrap(function (_context6) {
  6724. while (1) {
  6725. switch (_context6.prev = _context6.next) {
  6726. case 0:
  6727. options = _args5.length > 0 && _args5[0] !== undefined ? _args5[0] : {};
  6728. return _context6.abrupt("return", Web3Api.fetch({
  6729. endpoint: {
  6730. "method": "GET",
  6731. "group": "native",
  6732. "name": "getDateToBlock",
  6733. "url": "/dateToBlock"
  6734. },
  6735. params: options
  6736. }));
  6737. case 2:
  6738. case "end":
  6739. return _context6.stop();
  6740. }
  6741. }
  6742. }, _callee5);
  6743. }));
  6744. return function () {
  6745. return _getDateToBlock.apply(this, arguments);
  6746. };
  6747. }(),
  6748. getLogsByAddress: function () {
  6749. var _getLogsByAddress = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee6() {
  6750. var options,
  6751. _args6 = arguments;
  6752. return _regenerator.default.wrap(function (_context7) {
  6753. while (1) {
  6754. switch (_context7.prev = _context7.next) {
  6755. case 0:
  6756. options = _args6.length > 0 && _args6[0] !== undefined ? _args6[0] : {};
  6757. return _context7.abrupt("return", Web3Api.fetch({
  6758. endpoint: {
  6759. "method": "GET",
  6760. "group": "native",
  6761. "name": "getLogsByAddress",
  6762. "url": "/:address/logs"
  6763. },
  6764. params: options
  6765. }));
  6766. case 2:
  6767. case "end":
  6768. return _context7.stop();
  6769. }
  6770. }
  6771. }, _callee6);
  6772. }));
  6773. return function () {
  6774. return _getLogsByAddress.apply(this, arguments);
  6775. };
  6776. }(),
  6777. getNFTTransfersByBlock: function () {
  6778. var _getNFTTransfersByBlock = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee7() {
  6779. var options,
  6780. _args7 = arguments;
  6781. return _regenerator.default.wrap(function (_context8) {
  6782. while (1) {
  6783. switch (_context8.prev = _context8.next) {
  6784. case 0:
  6785. options = _args7.length > 0 && _args7[0] !== undefined ? _args7[0] : {};
  6786. return _context8.abrupt("return", Web3Api.fetch({
  6787. endpoint: {
  6788. "method": "GET",
  6789. "group": "native",
  6790. "name": "getNFTTransfersByBlock",
  6791. "url": "/block/:block_number_or_hash/nft/transfers"
  6792. },
  6793. params: options
  6794. }));
  6795. case 2:
  6796. case "end":
  6797. return _context8.stop();
  6798. }
  6799. }
  6800. }, _callee7);
  6801. }));
  6802. return function () {
  6803. return _getNFTTransfersByBlock.apply(this, arguments);
  6804. };
  6805. }(),
  6806. getTransaction: function () {
  6807. var _getTransaction = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee8() {
  6808. var options,
  6809. _args8 = arguments;
  6810. return _regenerator.default.wrap(function (_context9) {
  6811. while (1) {
  6812. switch (_context9.prev = _context9.next) {
  6813. case 0:
  6814. options = _args8.length > 0 && _args8[0] !== undefined ? _args8[0] : {};
  6815. return _context9.abrupt("return", Web3Api.fetch({
  6816. endpoint: {
  6817. "method": "GET",
  6818. "group": "native",
  6819. "name": "getTransaction",
  6820. "url": "/transaction/:transaction_hash"
  6821. },
  6822. params: options
  6823. }));
  6824. case 2:
  6825. case "end":
  6826. return _context9.stop();
  6827. }
  6828. }
  6829. }, _callee8);
  6830. }));
  6831. return function () {
  6832. return _getTransaction.apply(this, arguments);
  6833. };
  6834. }(),
  6835. getContractEvents: function () {
  6836. var _getContractEvents = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee9() {
  6837. var options,
  6838. _args9 = arguments;
  6839. return _regenerator.default.wrap(function (_context10) {
  6840. while (1) {
  6841. switch (_context10.prev = _context10.next) {
  6842. case 0:
  6843. options = _args9.length > 0 && _args9[0] !== undefined ? _args9[0] : {};
  6844. return _context10.abrupt("return", Web3Api.fetch({
  6845. endpoint: {
  6846. "method": "POST",
  6847. "group": "native",
  6848. "name": "getContractEvents",
  6849. "url": "/:address/events",
  6850. "bodyParams": [{
  6851. "key": "data",
  6852. "type": "set body",
  6853. "required": false
  6854. }]
  6855. },
  6856. params: options
  6857. }));
  6858. case 2:
  6859. case "end":
  6860. return _context10.stop();
  6861. }
  6862. }
  6863. }, _callee9);
  6864. }));
  6865. return function () {
  6866. return _getContractEvents.apply(this, arguments);
  6867. };
  6868. }(),
  6869. runContractFunction: function () {
  6870. var _runContractFunction = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee10() {
  6871. var options,
  6872. _args10 = arguments;
  6873. return _regenerator.default.wrap(function (_context11) {
  6874. while (1) {
  6875. switch (_context11.prev = _context11.next) {
  6876. case 0:
  6877. options = _args10.length > 0 && _args10[0] !== undefined ? _args10[0] : {};
  6878. return _context11.abrupt("return", Web3Api.fetch({
  6879. endpoint: {
  6880. "method": "POST",
  6881. "group": "native",
  6882. "name": "runContractFunction",
  6883. "url": "/:address/function",
  6884. "bodyParams": [{
  6885. "key": "abi",
  6886. "type": "property",
  6887. "required": true
  6888. }, {
  6889. "key": "params",
  6890. "type": "property",
  6891. "required": false
  6892. }]
  6893. },
  6894. params: options
  6895. }));
  6896. case 2:
  6897. case "end":
  6898. return _context11.stop();
  6899. }
  6900. }
  6901. }, _callee10);
  6902. }));
  6903. return function () {
  6904. return _runContractFunction.apply(this, arguments);
  6905. };
  6906. }()
  6907. });
  6908. (0, _defineProperty2.default)(Web3Api, "account", {
  6909. getTransactions: function () {
  6910. var _getTransactions = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee11() {
  6911. var options,
  6912. _args11 = arguments;
  6913. return _regenerator.default.wrap(function (_context12) {
  6914. while (1) {
  6915. switch (_context12.prev = _context12.next) {
  6916. case 0:
  6917. options = _args11.length > 0 && _args11[0] !== undefined ? _args11[0] : {};
  6918. return _context12.abrupt("return", Web3Api.fetch({
  6919. endpoint: {
  6920. "method": "GET",
  6921. "group": "account",
  6922. "name": "getTransactions",
  6923. "url": "/:address"
  6924. },
  6925. params: options
  6926. }));
  6927. case 2:
  6928. case "end":
  6929. return _context12.stop();
  6930. }
  6931. }
  6932. }, _callee11);
  6933. }));
  6934. return function () {
  6935. return _getTransactions.apply(this, arguments);
  6936. };
  6937. }(),
  6938. getNativeBalance: function () {
  6939. var _getNativeBalance = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee12() {
  6940. var options,
  6941. _args12 = arguments;
  6942. return _regenerator.default.wrap(function (_context13) {
  6943. while (1) {
  6944. switch (_context13.prev = _context13.next) {
  6945. case 0:
  6946. options = _args12.length > 0 && _args12[0] !== undefined ? _args12[0] : {};
  6947. return _context13.abrupt("return", Web3Api.fetch({
  6948. endpoint: {
  6949. "method": "GET",
  6950. "group": "account",
  6951. "name": "getNativeBalance",
  6952. "url": "/:address/balance"
  6953. },
  6954. params: options
  6955. }));
  6956. case 2:
  6957. case "end":
  6958. return _context13.stop();
  6959. }
  6960. }
  6961. }, _callee12);
  6962. }));
  6963. return function () {
  6964. return _getNativeBalance.apply(this, arguments);
  6965. };
  6966. }(),
  6967. getTokenBalances: function () {
  6968. var _getTokenBalances = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee13() {
  6969. var options,
  6970. _args13 = arguments;
  6971. return _regenerator.default.wrap(function (_context14) {
  6972. while (1) {
  6973. switch (_context14.prev = _context14.next) {
  6974. case 0:
  6975. options = _args13.length > 0 && _args13[0] !== undefined ? _args13[0] : {};
  6976. return _context14.abrupt("return", Web3Api.fetch({
  6977. endpoint: {
  6978. "method": "GET",
  6979. "group": "account",
  6980. "name": "getTokenBalances",
  6981. "url": "/:address/erc20"
  6982. },
  6983. params: options
  6984. }));
  6985. case 2:
  6986. case "end":
  6987. return _context14.stop();
  6988. }
  6989. }
  6990. }, _callee13);
  6991. }));
  6992. return function () {
  6993. return _getTokenBalances.apply(this, arguments);
  6994. };
  6995. }(),
  6996. getTokenTransfers: function () {
  6997. var _getTokenTransfers = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee14() {
  6998. var options,
  6999. _args14 = arguments;
  7000. return _regenerator.default.wrap(function (_context15) {
  7001. while (1) {
  7002. switch (_context15.prev = _context15.next) {
  7003. case 0:
  7004. options = _args14.length > 0 && _args14[0] !== undefined ? _args14[0] : {};
  7005. return _context15.abrupt("return", Web3Api.fetch({
  7006. endpoint: {
  7007. "method": "GET",
  7008. "group": "account",
  7009. "name": "getTokenTransfers",
  7010. "url": "/:address/erc20/transfers"
  7011. },
  7012. params: options
  7013. }));
  7014. case 2:
  7015. case "end":
  7016. return _context15.stop();
  7017. }
  7018. }
  7019. }, _callee14);
  7020. }));
  7021. return function () {
  7022. return _getTokenTransfers.apply(this, arguments);
  7023. };
  7024. }(),
  7025. getNFTs: function () {
  7026. var _getNFTs = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee15() {
  7027. var options,
  7028. _args15 = arguments;
  7029. return _regenerator.default.wrap(function (_context16) {
  7030. while (1) {
  7031. switch (_context16.prev = _context16.next) {
  7032. case 0:
  7033. options = _args15.length > 0 && _args15[0] !== undefined ? _args15[0] : {};
  7034. return _context16.abrupt("return", Web3Api.fetch({
  7035. endpoint: {
  7036. "method": "GET",
  7037. "group": "account",
  7038. "name": "getNFTs",
  7039. "url": "/:address/nft"
  7040. },
  7041. params: options
  7042. }));
  7043. case 2:
  7044. case "end":
  7045. return _context16.stop();
  7046. }
  7047. }
  7048. }, _callee15);
  7049. }));
  7050. return function () {
  7051. return _getNFTs.apply(this, arguments);
  7052. };
  7053. }(),
  7054. getNFTTransfers: function () {
  7055. var _getNFTTransfers = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee16() {
  7056. var options,
  7057. _args16 = arguments;
  7058. return _regenerator.default.wrap(function (_context17) {
  7059. while (1) {
  7060. switch (_context17.prev = _context17.next) {
  7061. case 0:
  7062. options = _args16.length > 0 && _args16[0] !== undefined ? _args16[0] : {};
  7063. return _context17.abrupt("return", Web3Api.fetch({
  7064. endpoint: {
  7065. "method": "GET",
  7066. "group": "account",
  7067. "name": "getNFTTransfers",
  7068. "url": "/:address/nft/transfers"
  7069. },
  7070. params: options
  7071. }));
  7072. case 2:
  7073. case "end":
  7074. return _context17.stop();
  7075. }
  7076. }
  7077. }, _callee16);
  7078. }));
  7079. return function () {
  7080. return _getNFTTransfers.apply(this, arguments);
  7081. };
  7082. }(),
  7083. getNFTsForContract: function () {
  7084. var _getNFTsForContract = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee17() {
  7085. var options,
  7086. _args17 = arguments;
  7087. return _regenerator.default.wrap(function (_context18) {
  7088. while (1) {
  7089. switch (_context18.prev = _context18.next) {
  7090. case 0:
  7091. options = _args17.length > 0 && _args17[0] !== undefined ? _args17[0] : {};
  7092. return _context18.abrupt("return", Web3Api.fetch({
  7093. endpoint: {
  7094. "method": "GET",
  7095. "group": "account",
  7096. "name": "getNFTsForContract",
  7097. "url": "/:address/nft/:token_address"
  7098. },
  7099. params: options
  7100. }));
  7101. case 2:
  7102. case "end":
  7103. return _context18.stop();
  7104. }
  7105. }
  7106. }, _callee17);
  7107. }));
  7108. return function () {
  7109. return _getNFTsForContract.apply(this, arguments);
  7110. };
  7111. }()
  7112. });
  7113. (0, _defineProperty2.default)(Web3Api, "token", {
  7114. getTokenMetadata: function () {
  7115. var _getTokenMetadata = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee18() {
  7116. var options,
  7117. _args18 = arguments;
  7118. return _regenerator.default.wrap(function (_context19) {
  7119. while (1) {
  7120. switch (_context19.prev = _context19.next) {
  7121. case 0:
  7122. options = _args18.length > 0 && _args18[0] !== undefined ? _args18[0] : {};
  7123. return _context19.abrupt("return", Web3Api.fetch({
  7124. endpoint: {
  7125. "method": "GET",
  7126. "group": "token",
  7127. "name": "getTokenMetadata",
  7128. "url": "/erc20/metadata"
  7129. },
  7130. params: options
  7131. }));
  7132. case 2:
  7133. case "end":
  7134. return _context19.stop();
  7135. }
  7136. }
  7137. }, _callee18);
  7138. }));
  7139. return function () {
  7140. return _getTokenMetadata.apply(this, arguments);
  7141. };
  7142. }(),
  7143. getNFTTrades: function () {
  7144. var _getNFTTrades = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee19() {
  7145. var options,
  7146. _args19 = arguments;
  7147. return _regenerator.default.wrap(function (_context20) {
  7148. while (1) {
  7149. switch (_context20.prev = _context20.next) {
  7150. case 0:
  7151. options = _args19.length > 0 && _args19[0] !== undefined ? _args19[0] : {};
  7152. return _context20.abrupt("return", Web3Api.fetch({
  7153. endpoint: {
  7154. "method": "GET",
  7155. "group": "token",
  7156. "name": "getNFTTrades",
  7157. "url": "/nft/:address/trades"
  7158. },
  7159. params: options
  7160. }));
  7161. case 2:
  7162. case "end":
  7163. return _context20.stop();
  7164. }
  7165. }
  7166. }, _callee19);
  7167. }));
  7168. return function () {
  7169. return _getNFTTrades.apply(this, arguments);
  7170. };
  7171. }(),
  7172. getNFTLowestPrice: function () {
  7173. var _getNFTLowestPrice = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee20() {
  7174. var options,
  7175. _args20 = arguments;
  7176. return _regenerator.default.wrap(function (_context21) {
  7177. while (1) {
  7178. switch (_context21.prev = _context21.next) {
  7179. case 0:
  7180. options = _args20.length > 0 && _args20[0] !== undefined ? _args20[0] : {};
  7181. return _context21.abrupt("return", Web3Api.fetch({
  7182. endpoint: {
  7183. "method": "GET",
  7184. "group": "token",
  7185. "name": "getNFTLowestPrice",
  7186. "url": "/nft/:address/lowestprice"
  7187. },
  7188. params: options
  7189. }));
  7190. case 2:
  7191. case "end":
  7192. return _context21.stop();
  7193. }
  7194. }
  7195. }, _callee20);
  7196. }));
  7197. return function () {
  7198. return _getNFTLowestPrice.apply(this, arguments);
  7199. };
  7200. }(),
  7201. getTokenMetadataBySymbol: function () {
  7202. var _getTokenMetadataBySymbol = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee21() {
  7203. var options,
  7204. _args21 = arguments;
  7205. return _regenerator.default.wrap(function (_context22) {
  7206. while (1) {
  7207. switch (_context22.prev = _context22.next) {
  7208. case 0:
  7209. options = _args21.length > 0 && _args21[0] !== undefined ? _args21[0] : {};
  7210. return _context22.abrupt("return", Web3Api.fetch({
  7211. endpoint: {
  7212. "method": "GET",
  7213. "group": "token",
  7214. "name": "getTokenMetadataBySymbol",
  7215. "url": "/erc20/metadata/symbols"
  7216. },
  7217. params: options
  7218. }));
  7219. case 2:
  7220. case "end":
  7221. return _context22.stop();
  7222. }
  7223. }
  7224. }, _callee21);
  7225. }));
  7226. return function () {
  7227. return _getTokenMetadataBySymbol.apply(this, arguments);
  7228. };
  7229. }(),
  7230. getTokenPrice: function () {
  7231. var _getTokenPrice = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee22() {
  7232. var options,
  7233. _args22 = arguments;
  7234. return _regenerator.default.wrap(function (_context23) {
  7235. while (1) {
  7236. switch (_context23.prev = _context23.next) {
  7237. case 0:
  7238. options = _args22.length > 0 && _args22[0] !== undefined ? _args22[0] : {};
  7239. return _context23.abrupt("return", Web3Api.fetch({
  7240. endpoint: {
  7241. "method": "GET",
  7242. "group": "token",
  7243. "name": "getTokenPrice",
  7244. "url": "/erc20/:address/price"
  7245. },
  7246. params: options
  7247. }));
  7248. case 2:
  7249. case "end":
  7250. return _context23.stop();
  7251. }
  7252. }
  7253. }, _callee22);
  7254. }));
  7255. return function () {
  7256. return _getTokenPrice.apply(this, arguments);
  7257. };
  7258. }(),
  7259. getTokenAddressTransfers: function () {
  7260. var _getTokenAddressTransfers = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee23() {
  7261. var options,
  7262. _args23 = arguments;
  7263. return _regenerator.default.wrap(function (_context24) {
  7264. while (1) {
  7265. switch (_context24.prev = _context24.next) {
  7266. case 0:
  7267. options = _args23.length > 0 && _args23[0] !== undefined ? _args23[0] : {};
  7268. return _context24.abrupt("return", Web3Api.fetch({
  7269. endpoint: {
  7270. "method": "GET",
  7271. "group": "token",
  7272. "name": "getTokenAddressTransfers",
  7273. "url": "/erc20/:address/transfers"
  7274. },
  7275. params: options
  7276. }));
  7277. case 2:
  7278. case "end":
  7279. return _context24.stop();
  7280. }
  7281. }
  7282. }, _callee23);
  7283. }));
  7284. return function () {
  7285. return _getTokenAddressTransfers.apply(this, arguments);
  7286. };
  7287. }(),
  7288. getTokenAllowance: function () {
  7289. var _getTokenAllowance = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee24() {
  7290. var options,
  7291. _args24 = arguments;
  7292. return _regenerator.default.wrap(function (_context25) {
  7293. while (1) {
  7294. switch (_context25.prev = _context25.next) {
  7295. case 0:
  7296. options = _args24.length > 0 && _args24[0] !== undefined ? _args24[0] : {};
  7297. return _context25.abrupt("return", Web3Api.fetch({
  7298. endpoint: {
  7299. "method": "GET",
  7300. "group": "token",
  7301. "name": "getTokenAllowance",
  7302. "url": "/erc20/:address/allowance"
  7303. },
  7304. params: options
  7305. }));
  7306. case 2:
  7307. case "end":
  7308. return _context25.stop();
  7309. }
  7310. }
  7311. }, _callee24);
  7312. }));
  7313. return function () {
  7314. return _getTokenAllowance.apply(this, arguments);
  7315. };
  7316. }(),
  7317. searchNFTs: function () {
  7318. var _searchNFTs = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee25() {
  7319. var options,
  7320. _args25 = arguments;
  7321. return _regenerator.default.wrap(function (_context26) {
  7322. while (1) {
  7323. switch (_context26.prev = _context26.next) {
  7324. case 0:
  7325. options = _args25.length > 0 && _args25[0] !== undefined ? _args25[0] : {};
  7326. return _context26.abrupt("return", Web3Api.fetch({
  7327. endpoint: {
  7328. "method": "GET",
  7329. "group": "token",
  7330. "name": "searchNFTs",
  7331. "url": "/nft/search"
  7332. },
  7333. params: options
  7334. }));
  7335. case 2:
  7336. case "end":
  7337. return _context26.stop();
  7338. }
  7339. }
  7340. }, _callee25);
  7341. }));
  7342. return function () {
  7343. return _searchNFTs.apply(this, arguments);
  7344. };
  7345. }(),
  7346. getNftTransfersFromToBlock: function () {
  7347. var _getNftTransfersFromToBlock = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee26() {
  7348. var options,
  7349. _args26 = arguments;
  7350. return _regenerator.default.wrap(function (_context27) {
  7351. while (1) {
  7352. switch (_context27.prev = _context27.next) {
  7353. case 0:
  7354. options = _args26.length > 0 && _args26[0] !== undefined ? _args26[0] : {};
  7355. return _context27.abrupt("return", Web3Api.fetch({
  7356. endpoint: {
  7357. "method": "GET",
  7358. "group": "token",
  7359. "name": "getNftTransfersFromToBlock",
  7360. "url": "/nft/transfers"
  7361. },
  7362. params: options
  7363. }));
  7364. case 2:
  7365. case "end":
  7366. return _context27.stop();
  7367. }
  7368. }
  7369. }, _callee26);
  7370. }));
  7371. return function () {
  7372. return _getNftTransfersFromToBlock.apply(this, arguments);
  7373. };
  7374. }(),
  7375. getAllTokenIds: function () {
  7376. var _getAllTokenIds = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee27() {
  7377. var options,
  7378. _args27 = arguments;
  7379. return _regenerator.default.wrap(function (_context28) {
  7380. while (1) {
  7381. switch (_context28.prev = _context28.next) {
  7382. case 0:
  7383. options = _args27.length > 0 && _args27[0] !== undefined ? _args27[0] : {};
  7384. return _context28.abrupt("return", Web3Api.fetch({
  7385. endpoint: {
  7386. "method": "GET",
  7387. "group": "token",
  7388. "name": "getAllTokenIds",
  7389. "url": "/nft/:address"
  7390. },
  7391. params: options
  7392. }));
  7393. case 2:
  7394. case "end":
  7395. return _context28.stop();
  7396. }
  7397. }
  7398. }, _callee27);
  7399. }));
  7400. return function () {
  7401. return _getAllTokenIds.apply(this, arguments);
  7402. };
  7403. }(),
  7404. getContractNFTTransfers: function () {
  7405. var _getContractNFTTransfers = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee28() {
  7406. var options,
  7407. _args28 = arguments;
  7408. return _regenerator.default.wrap(function (_context29) {
  7409. while (1) {
  7410. switch (_context29.prev = _context29.next) {
  7411. case 0:
  7412. options = _args28.length > 0 && _args28[0] !== undefined ? _args28[0] : {};
  7413. return _context29.abrupt("return", Web3Api.fetch({
  7414. endpoint: {
  7415. "method": "GET",
  7416. "group": "token",
  7417. "name": "getContractNFTTransfers",
  7418. "url": "/nft/:address/transfers"
  7419. },
  7420. params: options
  7421. }));
  7422. case 2:
  7423. case "end":
  7424. return _context29.stop();
  7425. }
  7426. }
  7427. }, _callee28);
  7428. }));
  7429. return function () {
  7430. return _getContractNFTTransfers.apply(this, arguments);
  7431. };
  7432. }(),
  7433. getNFTOwners: function () {
  7434. var _getNFTOwners = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee29() {
  7435. var options,
  7436. _args29 = arguments;
  7437. return _regenerator.default.wrap(function (_context30) {
  7438. while (1) {
  7439. switch (_context30.prev = _context30.next) {
  7440. case 0:
  7441. options = _args29.length > 0 && _args29[0] !== undefined ? _args29[0] : {};
  7442. return _context30.abrupt("return", Web3Api.fetch({
  7443. endpoint: {
  7444. "method": "GET",
  7445. "group": "token",
  7446. "name": "getNFTOwners",
  7447. "url": "/nft/:address/owners"
  7448. },
  7449. params: options
  7450. }));
  7451. case 2:
  7452. case "end":
  7453. return _context30.stop();
  7454. }
  7455. }
  7456. }, _callee29);
  7457. }));
  7458. return function () {
  7459. return _getNFTOwners.apply(this, arguments);
  7460. };
  7461. }(),
  7462. getNFTMetadata: function () {
  7463. var _getNFTMetadata = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee30() {
  7464. var options,
  7465. _args30 = arguments;
  7466. return _regenerator.default.wrap(function (_context31) {
  7467. while (1) {
  7468. switch (_context31.prev = _context31.next) {
  7469. case 0:
  7470. options = _args30.length > 0 && _args30[0] !== undefined ? _args30[0] : {};
  7471. return _context31.abrupt("return", Web3Api.fetch({
  7472. endpoint: {
  7473. "method": "GET",
  7474. "group": "token",
  7475. "name": "getNFTMetadata",
  7476. "url": "/nft/:address/metadata"
  7477. },
  7478. params: options
  7479. }));
  7480. case 2:
  7481. case "end":
  7482. return _context31.stop();
  7483. }
  7484. }
  7485. }, _callee30);
  7486. }));
  7487. return function () {
  7488. return _getNFTMetadata.apply(this, arguments);
  7489. };
  7490. }(),
  7491. reSyncMetadata: function () {
  7492. var _reSyncMetadata = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee31() {
  7493. var options,
  7494. _args31 = arguments;
  7495. return _regenerator.default.wrap(function (_context32) {
  7496. while (1) {
  7497. switch (_context32.prev = _context32.next) {
  7498. case 0:
  7499. options = _args31.length > 0 && _args31[0] !== undefined ? _args31[0] : {};
  7500. return _context32.abrupt("return", Web3Api.fetch({
  7501. endpoint: {
  7502. "method": "GET",
  7503. "group": "token",
  7504. "name": "reSyncMetadata",
  7505. "url": "/nft/:address/:token_id/metadata/resync"
  7506. },
  7507. params: options
  7508. }));
  7509. case 2:
  7510. case "end":
  7511. return _context32.stop();
  7512. }
  7513. }
  7514. }, _callee31);
  7515. }));
  7516. return function () {
  7517. return _reSyncMetadata.apply(this, arguments);
  7518. };
  7519. }(),
  7520. syncNFTContract: function () {
  7521. var _syncNFTContract = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee32() {
  7522. var options,
  7523. _args32 = arguments;
  7524. return _regenerator.default.wrap(function (_context33) {
  7525. while (1) {
  7526. switch (_context33.prev = _context33.next) {
  7527. case 0:
  7528. options = _args32.length > 0 && _args32[0] !== undefined ? _args32[0] : {};
  7529. return _context33.abrupt("return", Web3Api.fetch({
  7530. endpoint: {
  7531. "method": "PUT",
  7532. "group": "token",
  7533. "name": "syncNFTContract",
  7534. "url": "/nft/:address/sync"
  7535. },
  7536. params: options
  7537. }));
  7538. case 2:
  7539. case "end":
  7540. return _context33.stop();
  7541. }
  7542. }
  7543. }, _callee32);
  7544. }));
  7545. return function () {
  7546. return _syncNFTContract.apply(this, arguments);
  7547. };
  7548. }(),
  7549. getTokenIdMetadata: function () {
  7550. var _getTokenIdMetadata = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee33() {
  7551. var options,
  7552. _args33 = arguments;
  7553. return _regenerator.default.wrap(function (_context34) {
  7554. while (1) {
  7555. switch (_context34.prev = _context34.next) {
  7556. case 0:
  7557. options = _args33.length > 0 && _args33[0] !== undefined ? _args33[0] : {};
  7558. return _context34.abrupt("return", Web3Api.fetch({
  7559. endpoint: {
  7560. "method": "GET",
  7561. "group": "token",
  7562. "name": "getTokenIdMetadata",
  7563. "url": "/nft/:address/:token_id"
  7564. },
  7565. params: options
  7566. }));
  7567. case 2:
  7568. case "end":
  7569. return _context34.stop();
  7570. }
  7571. }
  7572. }, _callee33);
  7573. }));
  7574. return function () {
  7575. return _getTokenIdMetadata.apply(this, arguments);
  7576. };
  7577. }(),
  7578. getTokenIdOwners: function () {
  7579. var _getTokenIdOwners = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee34() {
  7580. var options,
  7581. _args34 = arguments;
  7582. return _regenerator.default.wrap(function (_context35) {
  7583. while (1) {
  7584. switch (_context35.prev = _context35.next) {
  7585. case 0:
  7586. options = _args34.length > 0 && _args34[0] !== undefined ? _args34[0] : {};
  7587. return _context35.abrupt("return", Web3Api.fetch({
  7588. endpoint: {
  7589. "method": "GET",
  7590. "group": "token",
  7591. "name": "getTokenIdOwners",
  7592. "url": "/nft/:address/:token_id/owners"
  7593. },
  7594. params: options
  7595. }));
  7596. case 2:
  7597. case "end":
  7598. return _context35.stop();
  7599. }
  7600. }
  7601. }, _callee34);
  7602. }));
  7603. return function () {
  7604. return _getTokenIdOwners.apply(this, arguments);
  7605. };
  7606. }(),
  7607. getWalletTokenIdTransfers: function () {
  7608. var _getWalletTokenIdTransfers = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee35() {
  7609. var options,
  7610. _args35 = arguments;
  7611. return _regenerator.default.wrap(function (_context36) {
  7612. while (1) {
  7613. switch (_context36.prev = _context36.next) {
  7614. case 0:
  7615. options = _args35.length > 0 && _args35[0] !== undefined ? _args35[0] : {};
  7616. return _context36.abrupt("return", Web3Api.fetch({
  7617. endpoint: {
  7618. "method": "GET",
  7619. "group": "token",
  7620. "name": "getWalletTokenIdTransfers",
  7621. "url": "/nft/:address/:token_id/transfers"
  7622. },
  7623. params: options
  7624. }));
  7625. case 2:
  7626. case "end":
  7627. return _context36.stop();
  7628. }
  7629. }
  7630. }, _callee35);
  7631. }));
  7632. return function () {
  7633. return _getWalletTokenIdTransfers.apply(this, arguments);
  7634. };
  7635. }()
  7636. });
  7637. (0, _defineProperty2.default)(Web3Api, "resolve", {
  7638. resolveDomain: function () {
  7639. var _resolveDomain = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee36() {
  7640. var options,
  7641. _args36 = arguments;
  7642. return _regenerator.default.wrap(function (_context37) {
  7643. while (1) {
  7644. switch (_context37.prev = _context37.next) {
  7645. case 0:
  7646. options = _args36.length > 0 && _args36[0] !== undefined ? _args36[0] : {};
  7647. return _context37.abrupt("return", Web3Api.fetch({
  7648. endpoint: {
  7649. "method": "GET",
  7650. "group": "resolve",
  7651. "name": "resolveDomain",
  7652. "url": "/resolve/:domain"
  7653. },
  7654. params: options
  7655. }));
  7656. case 2:
  7657. case "end":
  7658. return _context37.stop();
  7659. }
  7660. }
  7661. }, _callee36);
  7662. }));
  7663. return function () {
  7664. return _resolveDomain.apply(this, arguments);
  7665. };
  7666. }(),
  7667. resolveAddress: function () {
  7668. var _resolveAddress = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee37() {
  7669. var options,
  7670. _args37 = arguments;
  7671. return _regenerator.default.wrap(function (_context38) {
  7672. while (1) {
  7673. switch (_context38.prev = _context38.next) {
  7674. case 0:
  7675. options = _args37.length > 0 && _args37[0] !== undefined ? _args37[0] : {};
  7676. return _context38.abrupt("return", Web3Api.fetch({
  7677. endpoint: {
  7678. "method": "GET",
  7679. "group": "resolve",
  7680. "name": "resolveAddress",
  7681. "url": "/resolve/:address/reverse"
  7682. },
  7683. params: options
  7684. }));
  7685. case 2:
  7686. case "end":
  7687. return _context38.stop();
  7688. }
  7689. }
  7690. }, _callee37);
  7691. }));
  7692. return function () {
  7693. return _resolveAddress.apply(this, arguments);
  7694. };
  7695. }()
  7696. });
  7697. (0, _defineProperty2.default)(Web3Api, "defi", {
  7698. getPairReserves: function () {
  7699. var _getPairReserves = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee38() {
  7700. var options,
  7701. _args38 = arguments;
  7702. return _regenerator.default.wrap(function (_context39) {
  7703. while (1) {
  7704. switch (_context39.prev = _context39.next) {
  7705. case 0:
  7706. options = _args38.length > 0 && _args38[0] !== undefined ? _args38[0] : {};
  7707. return _context39.abrupt("return", Web3Api.fetch({
  7708. endpoint: {
  7709. "method": "GET",
  7710. "group": "defi",
  7711. "name": "getPairReserves",
  7712. "url": "/:pair_address/reserves"
  7713. },
  7714. params: options
  7715. }));
  7716. case 2:
  7717. case "end":
  7718. return _context39.stop();
  7719. }
  7720. }
  7721. }, _callee38);
  7722. }));
  7723. return function () {
  7724. return _getPairReserves.apply(this, arguments);
  7725. };
  7726. }(),
  7727. getPairAddress: function () {
  7728. var _getPairAddress = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee39() {
  7729. var options,
  7730. _args39 = arguments;
  7731. return _regenerator.default.wrap(function (_context40) {
  7732. while (1) {
  7733. switch (_context40.prev = _context40.next) {
  7734. case 0:
  7735. options = _args39.length > 0 && _args39[0] !== undefined ? _args39[0] : {};
  7736. return _context40.abrupt("return", Web3Api.fetch({
  7737. endpoint: {
  7738. "method": "GET",
  7739. "group": "defi",
  7740. "name": "getPairAddress",
  7741. "url": "/:token0_address/:token1_address/pairAddress"
  7742. },
  7743. params: options
  7744. }));
  7745. case 2:
  7746. case "end":
  7747. return _context40.stop();
  7748. }
  7749. }
  7750. }, _callee39);
  7751. }));
  7752. return function () {
  7753. return _getPairAddress.apply(this, arguments);
  7754. };
  7755. }()
  7756. });
  7757. (0, _defineProperty2.default)(Web3Api, "storage", {
  7758. uploadFolder: function () {
  7759. var _uploadFolder = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee40() {
  7760. var options,
  7761. _args40 = arguments;
  7762. return _regenerator.default.wrap(function (_context41) {
  7763. while (1) {
  7764. switch (_context41.prev = _context41.next) {
  7765. case 0:
  7766. options = _args40.length > 0 && _args40[0] !== undefined ? _args40[0] : {};
  7767. return _context41.abrupt("return", Web3Api.fetch({
  7768. endpoint: {
  7769. "method": "POST",
  7770. "group": "storage",
  7771. "name": "uploadFolder",
  7772. "url": "/ipfs/uploadFolder",
  7773. "bodyParams": [{
  7774. "key": "data",
  7775. "type": "set body",
  7776. "required": false
  7777. }]
  7778. },
  7779. params: options
  7780. }));
  7781. case 2:
  7782. case "end":
  7783. return _context41.stop();
  7784. }
  7785. }
  7786. }, _callee40);
  7787. }));
  7788. return function () {
  7789. return _uploadFolder.apply(this, arguments);
  7790. };
  7791. }()
  7792. });
  7793. (0, _defineProperty2.default)(Web3Api, "info", {
  7794. web3ApiVersion: function () {
  7795. var _web3ApiVersion = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee41() {
  7796. var options,
  7797. _args41 = arguments;
  7798. return _regenerator.default.wrap(function (_context42) {
  7799. while (1) {
  7800. switch (_context42.prev = _context42.next) {
  7801. case 0:
  7802. options = _args41.length > 0 && _args41[0] !== undefined ? _args41[0] : {};
  7803. return _context42.abrupt("return", Web3Api.fetch({
  7804. endpoint: {
  7805. "method": "GET",
  7806. "group": "info",
  7807. "name": "web3ApiVersion",
  7808. "url": "/web3/version"
  7809. },
  7810. params: options
  7811. }));
  7812. case 2:
  7813. case "end":
  7814. return _context42.stop();
  7815. }
  7816. }
  7817. }, _callee41);
  7818. }));
  7819. return function () {
  7820. return _web3ApiVersion.apply(this, arguments);
  7821. };
  7822. }(),
  7823. endpointWeights: function () {
  7824. var _endpointWeights = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee42() {
  7825. var options,
  7826. _args42 = arguments;
  7827. return _regenerator.default.wrap(function (_context43) {
  7828. while (1) {
  7829. switch (_context43.prev = _context43.next) {
  7830. case 0:
  7831. options = _args42.length > 0 && _args42[0] !== undefined ? _args42[0] : {};
  7832. return _context43.abrupt("return", Web3Api.fetch({
  7833. endpoint: {
  7834. "method": "GET",
  7835. "group": "info",
  7836. "name": "endpointWeights",
  7837. "url": "/info/endpointWeights"
  7838. },
  7839. params: options
  7840. }));
  7841. case 2:
  7842. case "end":
  7843. return _context43.stop();
  7844. }
  7845. }
  7846. }, _callee42);
  7847. }));
  7848. return function () {
  7849. return _endpointWeights.apply(this, arguments);
  7850. };
  7851. }()
  7852. });
  7853. var _default = Web3Api;
  7854. exports.default = _default;
  7855. },{"@babel/runtime-corejs3/core-js-stable/instance/filter":84,"@babel/runtime-corejs3/core-js-stable/instance/for-each":86,"@babel/runtime-corejs3/core-js-stable/instance/includes":87,"@babel/runtime-corejs3/core-js-stable/json/stringify":99,"@babel/runtime-corejs3/core-js-stable/object/define-properties":104,"@babel/runtime-corejs3/core-js-stable/object/define-property":105,"@babel/runtime-corejs3/core-js-stable/object/get-own-property-descriptor":108,"@babel/runtime-corejs3/core-js-stable/object/get-own-property-descriptors":109,"@babel/runtime-corejs3/core-js-stable/object/get-own-property-symbols":110,"@babel/runtime-corejs3/core-js-stable/object/keys":112,"@babel/runtime-corejs3/helpers/asyncToGenerator":144,"@babel/runtime-corejs3/helpers/classCallCheck":145,"@babel/runtime-corejs3/helpers/createClass":147,"@babel/runtime-corejs3/helpers/defineProperty":148,"@babel/runtime-corejs3/helpers/interopRequireDefault":152,"@babel/runtime-corejs3/regenerator":167,"axios":291}],23:[function(_dereq_,module,exports){
  7856. "use strict";
  7857. var _Object$keys = _dereq_("@babel/runtime-corejs3/core-js-stable/object/keys");
  7858. var _Object$getOwnPropertySymbols = _dereq_("@babel/runtime-corejs3/core-js-stable/object/get-own-property-symbols");
  7859. var _filterInstanceProperty = _dereq_("@babel/runtime-corejs3/core-js-stable/instance/filter");
  7860. var _Object$getOwnPropertyDescriptor = _dereq_("@babel/runtime-corejs3/core-js-stable/object/get-own-property-descriptor");
  7861. var _forEachInstanceProperty = _dereq_("@babel/runtime-corejs3/core-js-stable/instance/for-each");
  7862. var _Object$getOwnPropertyDescriptors = _dereq_("@babel/runtime-corejs3/core-js-stable/object/get-own-property-descriptors");
  7863. var _Object$defineProperties = _dereq_("@babel/runtime-corejs3/core-js-stable/object/define-properties");
  7864. var _Object$defineProperty = _dereq_("@babel/runtime-corejs3/core-js-stable/object/define-property");
  7865. var _interopRequireDefault = _dereq_("@babel/runtime-corejs3/helpers/interopRequireDefault");
  7866. _Object$defineProperty(exports, "__esModule", {
  7867. value: true
  7868. });
  7869. exports.commitServerChanges = commitServerChanges;
  7870. exports.defaultState = defaultState;
  7871. exports.estimateAttribute = estimateAttribute;
  7872. exports.estimateAttributes = estimateAttributes;
  7873. exports.mergeFirstPendingState = mergeFirstPendingState;
  7874. exports.popPendingState = popPendingState;
  7875. exports.pushPendingState = pushPendingState;
  7876. exports.setPendingOp = setPendingOp;
  7877. exports.setServerData = setServerData;
  7878. var _typeof2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/helpers/typeof"));
  7879. var _defineProperty2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/helpers/defineProperty"));
  7880. var _includes = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/instance/includes"));
  7881. var _stringify = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/json/stringify"));
  7882. var _encode = _interopRequireDefault(_dereq_("./encode"));
  7883. var _ParseFile = _interopRequireDefault(_dereq_("./ParseFile"));
  7884. var _ParseObject = _interopRequireDefault(_dereq_("./ParseObject"));
  7885. var _ParseRelation = _interopRequireDefault(_dereq_("./ParseRelation"));
  7886. var _TaskQueue = _interopRequireDefault(_dereq_("./TaskQueue"));
  7887. var _ParseOp = _dereq_("./ParseOp");
  7888. function ownKeys(object, enumerableOnly) {
  7889. var keys = _Object$keys(object);
  7890. if (_Object$getOwnPropertySymbols) {
  7891. var symbols = _Object$getOwnPropertySymbols(object);
  7892. enumerableOnly && (symbols = _filterInstanceProperty(symbols).call(symbols, function (sym) {
  7893. return _Object$getOwnPropertyDescriptor(object, sym).enumerable;
  7894. })), keys.push.apply(keys, symbols);
  7895. }
  7896. return keys;
  7897. }
  7898. function _objectSpread(target) {
  7899. for (var i = 1; i < arguments.length; i++) {
  7900. var _context, _context2;
  7901. var source = null != arguments[i] ? arguments[i] : {};
  7902. i % 2 ? _forEachInstanceProperty(_context = ownKeys(Object(source), !0)).call(_context, function (key) {
  7903. (0, _defineProperty2.default)(target, key, source[key]);
  7904. }) : _Object$getOwnPropertyDescriptors ? _Object$defineProperties(target, _Object$getOwnPropertyDescriptors(source)) : _forEachInstanceProperty(_context2 = ownKeys(Object(source))).call(_context2, function (key) {
  7905. _Object$defineProperty(target, key, _Object$getOwnPropertyDescriptor(source, key));
  7906. });
  7907. }
  7908. return target;
  7909. }
  7910. function defaultState()
  7911. /*: State*/
  7912. {
  7913. return {
  7914. serverData: {},
  7915. pendingOps: [{}],
  7916. objectCache: {},
  7917. tasks: new _TaskQueue.default(),
  7918. existed: false
  7919. };
  7920. }
  7921. function setServerData(serverData
  7922. /*: AttributeMap*/
  7923. , attributes
  7924. /*: AttributeMap*/
  7925. ) {
  7926. for (var _attr in attributes) {
  7927. if (typeof attributes[_attr] !== 'undefined') {
  7928. serverData[_attr] = attributes[_attr];
  7929. } else {
  7930. delete serverData[_attr];
  7931. }
  7932. }
  7933. }
  7934. function setPendingOp(pendingOps
  7935. /*: Array<OpsMap>*/
  7936. , attr
  7937. /*: string*/
  7938. , op
  7939. /*: ?Op*/
  7940. ) {
  7941. var last = pendingOps.length - 1;
  7942. if (op) {
  7943. pendingOps[last][attr] = op;
  7944. } else {
  7945. delete pendingOps[last][attr];
  7946. }
  7947. }
  7948. function pushPendingState(pendingOps
  7949. /*: Array<OpsMap>*/
  7950. ) {
  7951. pendingOps.push({});
  7952. }
  7953. function popPendingState(pendingOps
  7954. /*: Array<OpsMap>*/
  7955. )
  7956. /*: OpsMap*/
  7957. {
  7958. var first = pendingOps.shift();
  7959. if (!pendingOps.length) {
  7960. pendingOps[0] = {};
  7961. }
  7962. return first;
  7963. }
  7964. function mergeFirstPendingState(pendingOps
  7965. /*: Array<OpsMap>*/
  7966. ) {
  7967. var first = popPendingState(pendingOps);
  7968. var next = pendingOps[0];
  7969. for (var _attr2 in first) {
  7970. if (next[_attr2] && first[_attr2]) {
  7971. var merged = next[_attr2].mergeWith(first[_attr2]);
  7972. if (merged) {
  7973. next[_attr2] = merged;
  7974. }
  7975. } else {
  7976. next[_attr2] = first[_attr2];
  7977. }
  7978. }
  7979. }
  7980. function estimateAttribute(serverData
  7981. /*: AttributeMap*/
  7982. , pendingOps
  7983. /*: Array<OpsMap>*/
  7984. , className
  7985. /*: string*/
  7986. , id
  7987. /*: ?string*/
  7988. , attr
  7989. /*: string*/
  7990. )
  7991. /*: mixed*/
  7992. {
  7993. var value = serverData[attr];
  7994. for (var i = 0; i < pendingOps.length; i++) {
  7995. if (pendingOps[i][attr]) {
  7996. if (pendingOps[i][attr] instanceof _ParseOp.RelationOp) {
  7997. if (id) {
  7998. value = pendingOps[i][attr].applyTo(value, {
  7999. className: className,
  8000. id: id
  8001. }, attr);
  8002. }
  8003. } else {
  8004. value = pendingOps[i][attr].applyTo(value);
  8005. }
  8006. }
  8007. }
  8008. return value;
  8009. }
  8010. function estimateAttributes(serverData
  8011. /*: AttributeMap*/
  8012. , pendingOps
  8013. /*: Array<OpsMap>*/
  8014. , className
  8015. /*: string*/
  8016. , id
  8017. /*: ?string*/
  8018. )
  8019. /*: AttributeMap*/
  8020. {
  8021. var data = {};
  8022. for (var attr in serverData) {
  8023. data[attr] = serverData[attr];
  8024. }
  8025. for (var i = 0; i < pendingOps.length; i++) {
  8026. for (attr in pendingOps[i]) {
  8027. if (pendingOps[i][attr] instanceof _ParseOp.RelationOp) {
  8028. if (id) {
  8029. data[attr] = pendingOps[i][attr].applyTo(data[attr], {
  8030. className: className,
  8031. id: id
  8032. }, attr);
  8033. }
  8034. } else {
  8035. if ((0, _includes.default)(attr).call(attr, '.')) {
  8036. // convert a.b.c into { a: { b: { c: value } } }
  8037. var fields = attr.split('.');
  8038. var first = fields[0];
  8039. var last = fields[fields.length - 1];
  8040. data[first] = _objectSpread({}, serverData[first]);
  8041. var object = _objectSpread({}, data);
  8042. for (var _i = 0; _i < fields.length - 1; _i++) {
  8043. object = object[fields[_i]];
  8044. }
  8045. object[last] = pendingOps[i][attr].applyTo(object[last]);
  8046. } else {
  8047. data[attr] = pendingOps[i][attr].applyTo(data[attr]);
  8048. }
  8049. }
  8050. }
  8051. }
  8052. return data;
  8053. }
  8054. function commitServerChanges(serverData
  8055. /*: AttributeMap*/
  8056. , objectCache
  8057. /*: ObjectCache*/
  8058. , changes
  8059. /*: AttributeMap*/
  8060. ) {
  8061. for (var _attr3 in changes) {
  8062. var val = changes[_attr3];
  8063. serverData[_attr3] = val;
  8064. if (val && (0, _typeof2.default)(val) === 'object' && !(val instanceof _ParseObject.default) && !(val instanceof _ParseFile.default) && !(val instanceof _ParseRelation.default)) {
  8065. var json = (0, _encode.default)(val, false, true);
  8066. objectCache[_attr3] = (0, _stringify.default)(json);
  8067. }
  8068. }
  8069. }
  8070. },{"./ParseFile":30,"./ParseObject":36,"./ParseOp":37,"./ParseRelation":40,"./TaskQueue":50,"./encode":66,"@babel/runtime-corejs3/core-js-stable/instance/filter":84,"@babel/runtime-corejs3/core-js-stable/instance/for-each":86,"@babel/runtime-corejs3/core-js-stable/instance/includes":87,"@babel/runtime-corejs3/core-js-stable/json/stringify":99,"@babel/runtime-corejs3/core-js-stable/object/define-properties":104,"@babel/runtime-corejs3/core-js-stable/object/define-property":105,"@babel/runtime-corejs3/core-js-stable/object/get-own-property-descriptor":108,"@babel/runtime-corejs3/core-js-stable/object/get-own-property-descriptors":109,"@babel/runtime-corejs3/core-js-stable/object/get-own-property-symbols":110,"@babel/runtime-corejs3/core-js-stable/object/keys":112,"@babel/runtime-corejs3/helpers/defineProperty":148,"@babel/runtime-corejs3/helpers/interopRequireDefault":152,"@babel/runtime-corejs3/helpers/typeof":164}],24:[function(_dereq_,module,exports){
  8071. "use strict";
  8072. var _sliceInstanceProperty2 = _dereq_("@babel/runtime-corejs3/core-js-stable/instance/slice");
  8073. var _Array$from = _dereq_("@babel/runtime-corejs3/core-js-stable/array/from");
  8074. var _Symbol = _dereq_("@babel/runtime-corejs3/core-js-stable/symbol");
  8075. var _getIteratorMethod = _dereq_("@babel/runtime-corejs3/core-js/get-iterator-method");
  8076. var _Array$isArray2 = _dereq_("@babel/runtime-corejs3/core-js-stable/array/is-array");
  8077. var _interopRequireDefault = _dereq_("@babel/runtime-corejs3/helpers/interopRequireDefault");
  8078. var _typeof2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/helpers/typeof"));
  8079. var _indexOf = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/instance/index-of"));
  8080. var _isArray = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/array/is-array"));
  8081. var _slice = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/instance/slice"));
  8082. var _filter = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/instance/filter"));
  8083. var _map = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/instance/map"));
  8084. var _forEach = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/instance/for-each"));
  8085. var _keys = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/object/keys"));
  8086. function _createForOfIteratorHelper(o, allowArrayLike) {
  8087. var it = typeof _Symbol !== "undefined" && _getIteratorMethod(o) || o["@@iterator"];
  8088. if (!it) {
  8089. if (_Array$isArray2(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") {
  8090. if (it) o = it;
  8091. var i = 0;
  8092. var F = function () {};
  8093. return {
  8094. s: F,
  8095. n: function () {
  8096. if (i >= o.length) return {
  8097. done: true
  8098. };
  8099. return {
  8100. done: false,
  8101. value: o[i++]
  8102. };
  8103. },
  8104. e: function (_e) {
  8105. throw _e;
  8106. },
  8107. f: F
  8108. };
  8109. }
  8110. throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
  8111. }
  8112. var normalCompletion = true,
  8113. didErr = false,
  8114. err;
  8115. return {
  8116. s: function () {
  8117. it = it.call(o);
  8118. },
  8119. n: function () {
  8120. var step = it.next();
  8121. normalCompletion = step.done;
  8122. return step;
  8123. },
  8124. e: function (_e2) {
  8125. didErr = true;
  8126. err = _e2;
  8127. },
  8128. f: function () {
  8129. try {
  8130. if (!normalCompletion && it.return != null) it.return();
  8131. } finally {
  8132. if (didErr) throw err;
  8133. }
  8134. }
  8135. };
  8136. }
  8137. function _unsupportedIterableToArray(o, minLen) {
  8138. var _context5;
  8139. if (!o) return;
  8140. if (typeof o === "string") return _arrayLikeToArray(o, minLen);
  8141. var n = _sliceInstanceProperty2(_context5 = Object.prototype.toString.call(o)).call(_context5, 8, -1);
  8142. if (n === "Object" && o.constructor) n = o.constructor.name;
  8143. if (n === "Map" || n === "Set") return _Array$from(o);
  8144. if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen);
  8145. }
  8146. function _arrayLikeToArray(arr, len) {
  8147. if (len == null || len > arr.length) len = arr.length;
  8148. for (var i = 0, arr2 = new Array(len); i < len; i++) {
  8149. arr2[i] = arr[i];
  8150. }
  8151. return arr2;
  8152. }
  8153. /* eslint-disable no-loop-func */
  8154. var equalObjects = _dereq_('./equals').default;
  8155. var decode = _dereq_('./decode').default;
  8156. var ParseError = _dereq_('./ParseError').default;
  8157. var ParsePolygon = _dereq_('./ParsePolygon').default;
  8158. var ParseGeoPoint = _dereq_('./ParseGeoPoint').default;
  8159. /**
  8160. * contains -- Determines if an object is contained in a list with special handling for Parse pointers.
  8161. *
  8162. * @param haystack
  8163. * @param needle
  8164. * @private
  8165. * @returns {boolean}
  8166. */
  8167. function contains(haystack, needle) {
  8168. if (needle && needle.__type && (needle.__type === 'Pointer' || needle.__type === 'Object')) {
  8169. for (var i in haystack) {
  8170. var ptr = haystack[i];
  8171. if (typeof ptr === 'string' && ptr === needle.objectId) {
  8172. return true;
  8173. }
  8174. if (ptr.className === needle.className && ptr.objectId === needle.objectId) {
  8175. return true;
  8176. }
  8177. }
  8178. return false;
  8179. }
  8180. return (0, _indexOf.default)(haystack).call(haystack, needle) > -1;
  8181. }
  8182. function transformObject(object) {
  8183. if (object._toFullJSON) {
  8184. return object._toFullJSON();
  8185. }
  8186. return object;
  8187. }
  8188. /**
  8189. * matchesQuery -- Determines if an object would be returned by a Parse Query
  8190. * It's a lightweight, where-clause only implementation of a full query engine.
  8191. * Since we find queries that match objects, rather than objects that match
  8192. * queries, we can avoid building a full-blown query tool.
  8193. *
  8194. * @param className
  8195. * @param object
  8196. * @param objects
  8197. * @param query
  8198. * @private
  8199. * @returns {boolean}
  8200. */
  8201. function matchesQuery(className, object, objects, query) {
  8202. if (object.className !== className) {
  8203. return false;
  8204. }
  8205. var obj = object;
  8206. var q = query;
  8207. if (object.toJSON) {
  8208. obj = object.toJSON();
  8209. }
  8210. if (query.toJSON) {
  8211. q = query.toJSON().where;
  8212. }
  8213. obj.className = className;
  8214. for (var field in q) {
  8215. if (!matchesKeyConstraints(className, obj, objects, field, q[field])) {
  8216. return false;
  8217. }
  8218. }
  8219. return true;
  8220. }
  8221. function equalObjectsGeneric(obj, compareTo, eqlFn) {
  8222. if ((0, _isArray.default)(obj)) {
  8223. for (var i = 0; i < obj.length; i++) {
  8224. if (eqlFn(obj[i], compareTo)) {
  8225. return true;
  8226. }
  8227. }
  8228. return false;
  8229. }
  8230. return eqlFn(obj, compareTo);
  8231. }
  8232. /**
  8233. * Determines whether an object matches a single key's constraints
  8234. *
  8235. * @param className
  8236. * @param object
  8237. * @param objects
  8238. * @param key
  8239. * @param constraints
  8240. * @private
  8241. * @returns {boolean}
  8242. */
  8243. function matchesKeyConstraints(className, object, objects, key, constraints) {
  8244. if (constraints === null) {
  8245. return false;
  8246. }
  8247. if ((0, _indexOf.default)(key).call(key, '.') >= 0) {
  8248. // Key references a subobject
  8249. var keyComponents = key.split('.');
  8250. var subObjectKey = keyComponents[0];
  8251. var keyRemainder = (0, _slice.default)(keyComponents).call(keyComponents, 1).join('.');
  8252. return matchesKeyConstraints(className, object[subObjectKey] || {}, objects, keyRemainder, constraints);
  8253. }
  8254. var i;
  8255. if (key === '$or') {
  8256. for (i = 0; i < constraints.length; i++) {
  8257. if (matchesQuery(className, object, objects, constraints[i])) {
  8258. return true;
  8259. }
  8260. }
  8261. return false;
  8262. }
  8263. if (key === '$and') {
  8264. for (i = 0; i < constraints.length; i++) {
  8265. if (!matchesQuery(className, object, objects, constraints[i])) {
  8266. return false;
  8267. }
  8268. }
  8269. return true;
  8270. }
  8271. if (key === '$nor') {
  8272. for (i = 0; i < constraints.length; i++) {
  8273. if (matchesQuery(className, object, objects, constraints[i])) {
  8274. return false;
  8275. }
  8276. }
  8277. return true;
  8278. }
  8279. if (key === '$relatedTo') {
  8280. // Bail! We can't handle relational queries locally
  8281. return false;
  8282. }
  8283. if (!/^[A-Za-z][0-9A-Za-z_]*$/.test(key)) {
  8284. throw new ParseError(ParseError.INVALID_KEY_NAME, "Invalid Key: ".concat(key));
  8285. } // Equality (or Array contains) cases
  8286. if ((0, _typeof2.default)(constraints) !== 'object') {
  8287. if ((0, _isArray.default)(object[key])) {
  8288. var _context;
  8289. return (0, _indexOf.default)(_context = object[key]).call(_context, constraints) > -1;
  8290. }
  8291. return object[key] === constraints;
  8292. }
  8293. var compareTo;
  8294. if (constraints.__type) {
  8295. if (constraints.__type === 'Pointer') {
  8296. return equalObjectsGeneric(object[key], constraints, function (obj, ptr) {
  8297. return typeof obj !== 'undefined' && ptr.className === obj.className && ptr.objectId === obj.objectId;
  8298. });
  8299. }
  8300. return equalObjectsGeneric(decode(object[key]), decode(constraints), equalObjects);
  8301. } // More complex cases
  8302. for (var condition in constraints) {
  8303. compareTo = constraints[condition];
  8304. if (compareTo.__type) {
  8305. compareTo = decode(compareTo);
  8306. } // Compare Date Object or Date String
  8307. if (toString.call(compareTo) === '[object Date]' || typeof compareTo === 'string' && new Date(compareTo) !== 'Invalid Date' && !isNaN(new Date(compareTo))) {
  8308. object[key] = new Date(object[key].iso ? object[key].iso : object[key]);
  8309. }
  8310. switch (condition) {
  8311. case '$lt':
  8312. if (object[key] >= compareTo) {
  8313. return false;
  8314. }
  8315. break;
  8316. case '$lte':
  8317. if (object[key] > compareTo) {
  8318. return false;
  8319. }
  8320. break;
  8321. case '$gt':
  8322. if (object[key] <= compareTo) {
  8323. return false;
  8324. }
  8325. break;
  8326. case '$gte':
  8327. if (object[key] < compareTo) {
  8328. return false;
  8329. }
  8330. break;
  8331. case '$ne':
  8332. if (equalObjects(object[key], compareTo)) {
  8333. return false;
  8334. }
  8335. break;
  8336. case '$in':
  8337. if (!contains(compareTo, object[key])) {
  8338. return false;
  8339. }
  8340. break;
  8341. case '$nin':
  8342. if (contains(compareTo, object[key])) {
  8343. return false;
  8344. }
  8345. break;
  8346. case '$all':
  8347. for (i = 0; i < compareTo.length; i++) {
  8348. var _context2;
  8349. if ((0, _indexOf.default)(_context2 = object[key]).call(_context2, compareTo[i]) < 0) {
  8350. return false;
  8351. }
  8352. }
  8353. break;
  8354. case '$exists':
  8355. {
  8356. var propertyExists = typeof object[key] !== 'undefined';
  8357. var existenceIsRequired = constraints.$exists;
  8358. if (typeof constraints.$exists !== 'boolean') {
  8359. // The SDK will never submit a non-boolean for $exists, but if someone
  8360. // tries to submit a non-boolean for $exits outside the SDKs, just ignore it.
  8361. break;
  8362. }
  8363. if (!propertyExists && existenceIsRequired || propertyExists && !existenceIsRequired) {
  8364. return false;
  8365. }
  8366. break;
  8367. }
  8368. case '$regex':
  8369. {
  8370. if ((0, _typeof2.default)(compareTo) === 'object') {
  8371. return compareTo.test(object[key]);
  8372. } // JS doesn't support perl-style escaping
  8373. var expString = '';
  8374. var escapeEnd = -2;
  8375. var escapeStart = (0, _indexOf.default)(compareTo).call(compareTo, '\\Q');
  8376. while (escapeStart > -1) {
  8377. // Add the unescaped portion
  8378. expString += compareTo.substring(escapeEnd + 2, escapeStart);
  8379. escapeEnd = (0, _indexOf.default)(compareTo).call(compareTo, '\\E', escapeStart);
  8380. if (escapeEnd > -1) {
  8381. expString += compareTo.substring(escapeStart + 2, escapeEnd).replace(/\\\\\\\\E/g, '\\E').replace(/\W/g, '\\$&');
  8382. }
  8383. escapeStart = (0, _indexOf.default)(compareTo).call(compareTo, '\\Q', escapeEnd);
  8384. }
  8385. expString += compareTo.substring(Math.max(escapeStart, escapeEnd + 2));
  8386. var modifiers = constraints.$options || '';
  8387. modifiers = modifiers.replace('x', '').replace('s', ''); // Parse Server / Mongo support x and s modifiers but JS RegExp doesn't
  8388. var exp = new RegExp(expString, modifiers);
  8389. if (!exp.test(object[key])) {
  8390. return false;
  8391. }
  8392. break;
  8393. }
  8394. case '$nearSphere':
  8395. {
  8396. if (!compareTo || !object[key]) {
  8397. return false;
  8398. }
  8399. var distance = compareTo.radiansTo(object[key]);
  8400. var max = constraints.$maxDistance || Infinity;
  8401. return distance <= max;
  8402. }
  8403. case '$within':
  8404. {
  8405. if (!compareTo || !object[key]) {
  8406. return false;
  8407. }
  8408. var southWest = compareTo.$box[0];
  8409. var northEast = compareTo.$box[1];
  8410. if (southWest.latitude > northEast.latitude || southWest.longitude > northEast.longitude) {
  8411. // Invalid box, crosses the date line
  8412. return false;
  8413. }
  8414. return object[key].latitude > southWest.latitude && object[key].latitude < northEast.latitude && object[key].longitude > southWest.longitude && object[key].longitude < northEast.longitude;
  8415. }
  8416. case '$options':
  8417. // Not a query type, but a way to add options to $regex. Ignore and
  8418. // avoid the default
  8419. break;
  8420. case '$maxDistance':
  8421. // Not a query type, but a way to add a cap to $nearSphere. Ignore and
  8422. // avoid the default
  8423. break;
  8424. case '$select':
  8425. {
  8426. var subQueryObjects = (0, _filter.default)(objects).call(objects, function (obj, index, arr) {
  8427. return matchesQuery(compareTo.query.className, obj, arr, compareTo.query.where);
  8428. });
  8429. for (var _i = 0; _i < subQueryObjects.length; _i += 1) {
  8430. var subObject = transformObject(subQueryObjects[_i]);
  8431. return equalObjects(object[key], subObject[compareTo.key]);
  8432. }
  8433. return false;
  8434. }
  8435. case '$dontSelect':
  8436. {
  8437. var _subQueryObjects = (0, _filter.default)(objects).call(objects, function (obj, index, arr) {
  8438. return matchesQuery(compareTo.query.className, obj, arr, compareTo.query.where);
  8439. });
  8440. for (var _i2 = 0; _i2 < _subQueryObjects.length; _i2 += 1) {
  8441. var _subObject = transformObject(_subQueryObjects[_i2]);
  8442. return !equalObjects(object[key], _subObject[compareTo.key]);
  8443. }
  8444. return false;
  8445. }
  8446. case '$inQuery':
  8447. {
  8448. var _subQueryObjects2 = (0, _filter.default)(objects).call(objects, function (obj, index, arr) {
  8449. return matchesQuery(compareTo.className, obj, arr, compareTo.where);
  8450. });
  8451. for (var _i3 = 0; _i3 < _subQueryObjects2.length; _i3 += 1) {
  8452. var _subObject2 = transformObject(_subQueryObjects2[_i3]);
  8453. if (object[key].className === _subObject2.className && object[key].objectId === _subObject2.objectId) {
  8454. return true;
  8455. }
  8456. }
  8457. return false;
  8458. }
  8459. case '$notInQuery':
  8460. {
  8461. var _subQueryObjects3 = (0, _filter.default)(objects).call(objects, function (obj, index, arr) {
  8462. return matchesQuery(compareTo.className, obj, arr, compareTo.where);
  8463. });
  8464. for (var _i4 = 0; _i4 < _subQueryObjects3.length; _i4 += 1) {
  8465. var _subObject3 = transformObject(_subQueryObjects3[_i4]);
  8466. if (object[key].className === _subObject3.className && object[key].objectId === _subObject3.objectId) {
  8467. return false;
  8468. }
  8469. }
  8470. return true;
  8471. }
  8472. case '$containedBy':
  8473. {
  8474. var _iterator = _createForOfIteratorHelper(object[key]),
  8475. _step;
  8476. try {
  8477. for (_iterator.s(); !(_step = _iterator.n()).done;) {
  8478. var value = _step.value;
  8479. if (!contains(compareTo, value)) {
  8480. return false;
  8481. }
  8482. }
  8483. } catch (err) {
  8484. _iterator.e(err);
  8485. } finally {
  8486. _iterator.f();
  8487. }
  8488. return true;
  8489. }
  8490. case '$geoWithin':
  8491. {
  8492. var _context3;
  8493. var points = (0, _map.default)(_context3 = compareTo.$polygon).call(_context3, function (geoPoint) {
  8494. return [geoPoint.latitude, geoPoint.longitude];
  8495. });
  8496. var polygon = new ParsePolygon(points);
  8497. return polygon.containsPoint(object[key]);
  8498. }
  8499. case '$geoIntersects':
  8500. {
  8501. var _polygon = new ParsePolygon(object[key].coordinates);
  8502. var point = new ParseGeoPoint(compareTo.$point);
  8503. return _polygon.containsPoint(point);
  8504. }
  8505. default:
  8506. return false;
  8507. }
  8508. }
  8509. return true;
  8510. }
  8511. function validateQuery(query
  8512. /*: any*/
  8513. ) {
  8514. var _context4;
  8515. var q = query;
  8516. if (query.toJSON) {
  8517. q = query.toJSON().where;
  8518. }
  8519. var specialQuerykeys = ['$and', '$or', '$nor', '_rperm', '_wperm', '_perishable_token', '_email_verify_token', '_email_verify_token_expires_at', '_account_lockout_expires_at', '_failed_login_count'];
  8520. (0, _forEach.default)(_context4 = (0, _keys.default)(q)).call(_context4, function (key) {
  8521. if (q && q[key] && q[key].$regex) {
  8522. if (typeof q[key].$options === 'string') {
  8523. if (!q[key].$options.match(/^[imxs]+$/)) {
  8524. throw new ParseError(ParseError.INVALID_QUERY, "Bad $options value for query: ".concat(q[key].$options));
  8525. }
  8526. }
  8527. }
  8528. if ((0, _indexOf.default)(specialQuerykeys).call(specialQuerykeys, key) < 0 && !key.match(/^[a-zA-Z][a-zA-Z0-9_.]*$/)) {
  8529. throw new ParseError(ParseError.INVALID_KEY_NAME, "Invalid key name: ".concat(key));
  8530. }
  8531. });
  8532. }
  8533. var OfflineQuery = {
  8534. matchesQuery: matchesQuery,
  8535. validateQuery: validateQuery
  8536. };
  8537. module.exports = OfflineQuery;
  8538. },{"./ParseError":29,"./ParseGeoPoint":33,"./ParsePolygon":38,"./decode":65,"./equals":67,"@babel/runtime-corejs3/core-js-stable/array/from":78,"@babel/runtime-corejs3/core-js-stable/array/is-array":79,"@babel/runtime-corejs3/core-js-stable/instance/filter":84,"@babel/runtime-corejs3/core-js-stable/instance/for-each":86,"@babel/runtime-corejs3/core-js-stable/instance/index-of":88,"@babel/runtime-corejs3/core-js-stable/instance/map":90,"@babel/runtime-corejs3/core-js-stable/instance/slice":93,"@babel/runtime-corejs3/core-js-stable/object/keys":112,"@babel/runtime-corejs3/core-js-stable/symbol":119,"@babel/runtime-corejs3/core-js/get-iterator-method":125,"@babel/runtime-corejs3/helpers/interopRequireDefault":152,"@babel/runtime-corejs3/helpers/typeof":164}],25:[function(_dereq_,module,exports){
  8539. (function (process){(function (){
  8540. "use strict";
  8541. var _typeof = _dereq_("@babel/runtime-corejs3/helpers/typeof");
  8542. var _Reflect$construct = _dereq_("@babel/runtime-corejs3/core-js-stable/reflect/construct");
  8543. var _WeakMap = _dereq_("@babel/runtime-corejs3/core-js-stable/weak-map");
  8544. var _Object$defineProperty = _dereq_("@babel/runtime-corejs3/core-js-stable/object/define-property");
  8545. var _Object$getOwnPropertyDescriptor = _dereq_("@babel/runtime-corejs3/core-js-stable/object/get-own-property-descriptor");
  8546. var _interopRequireDefault = _dereq_("@babel/runtime-corejs3/helpers/interopRequireDefault");
  8547. var _promise = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/promise"));
  8548. var _regenerator = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/regenerator"));
  8549. var _asyncToGenerator2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/helpers/asyncToGenerator"));
  8550. var _classCallCheck2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/helpers/classCallCheck"));
  8551. var _createClass2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/helpers/createClass"));
  8552. var _inherits2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/helpers/inherits"));
  8553. var _possibleConstructorReturn2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/helpers/possibleConstructorReturn"));
  8554. var _getPrototypeOf2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/helpers/getPrototypeOf"));
  8555. var _decode = _interopRequireDefault(_dereq_("./decode"));
  8556. var _encode = _interopRequireDefault(_dereq_("./encode"));
  8557. var _CoreManager = _interopRequireDefault(_dereq_("./CoreManager"));
  8558. var _CryptoController = _interopRequireDefault(_dereq_("./CryptoController"));
  8559. var _InstallationController = _interopRequireDefault(_dereq_("./InstallationController"));
  8560. var ParseOp = _interopRequireWildcard(_dereq_("./ParseOp"));
  8561. var _RESTController2 = _interopRequireDefault(_dereq_("./RESTController"));
  8562. var _MoralisWeb2 = _interopRequireDefault(_dereq_("./MoralisWeb3"));
  8563. var _ethers = _dereq_("ethers");
  8564. var _filterConsole = _dereq_("./filterConsole");
  8565. function _getRequireWildcardCache(nodeInterop) {
  8566. if (typeof _WeakMap !== "function") return null;
  8567. var cacheBabelInterop = new _WeakMap();
  8568. var cacheNodeInterop = new _WeakMap();
  8569. return (_getRequireWildcardCache = function (nodeInterop) {
  8570. return nodeInterop ? cacheNodeInterop : cacheBabelInterop;
  8571. })(nodeInterop);
  8572. }
  8573. function _interopRequireWildcard(obj, nodeInterop) {
  8574. if (!nodeInterop && obj && obj.__esModule) {
  8575. return obj;
  8576. }
  8577. if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") {
  8578. return {
  8579. default: obj
  8580. };
  8581. }
  8582. var cache = _getRequireWildcardCache(nodeInterop);
  8583. if (cache && cache.has(obj)) {
  8584. return cache.get(obj);
  8585. }
  8586. var newObj = {};
  8587. for (var key in obj) {
  8588. if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) {
  8589. var desc = _Object$defineProperty && _Object$getOwnPropertyDescriptor ? _Object$getOwnPropertyDescriptor(obj, key) : null;
  8590. if (desc && (desc.get || desc.set)) {
  8591. _Object$defineProperty(newObj, key, desc);
  8592. } else {
  8593. newObj[key] = obj[key];
  8594. }
  8595. }
  8596. }
  8597. newObj.default = obj;
  8598. if (cache) {
  8599. cache.set(obj, newObj);
  8600. }
  8601. return newObj;
  8602. }
  8603. function _createSuper(Derived) {
  8604. var hasNativeReflectConstruct = _isNativeReflectConstruct();
  8605. return function () {
  8606. var Super = (0, _getPrototypeOf2.default)(Derived),
  8607. result;
  8608. if (hasNativeReflectConstruct) {
  8609. var NewTarget = (0, _getPrototypeOf2.default)(this).constructor;
  8610. result = _Reflect$construct(Super, arguments, NewTarget);
  8611. } else {
  8612. result = Super.apply(this, arguments);
  8613. }
  8614. return (0, _possibleConstructorReturn2.default)(this, result);
  8615. };
  8616. }
  8617. function _isNativeReflectConstruct() {
  8618. if (typeof Reflect === "undefined" || !_Reflect$construct) return false;
  8619. if (_Reflect$construct.sham) return false;
  8620. if (typeof Proxy === "function") return true;
  8621. try {
  8622. Boolean.prototype.valueOf.call(_Reflect$construct(Boolean, [], function () {}));
  8623. return true;
  8624. } catch (e) {
  8625. return false;
  8626. }
  8627. }
  8628. var _require = _dereq_('./utils'),
  8629. checkForSdkUpdates = _require.checkForSdkUpdates,
  8630. trackEvent = _require.trackEvent,
  8631. TrackingEventName = _require.TrackingEventName,
  8632. getSubdomain = _require.getSubdomain;
  8633. /**
  8634. * Contains all Moralis API classes and functions.
  8635. *
  8636. * @static
  8637. * @global
  8638. * @class
  8639. * @hideconstructor
  8640. */
  8641. var Moralis = /*#__PURE__*/function (_MoralisWeb) {
  8642. (0, _inherits2.default)(Moralis, _MoralisWeb);
  8643. var _super = _createSuper(Moralis);
  8644. function Moralis() {
  8645. (0, _classCallCheck2.default)(this, Moralis);
  8646. return _super.apply(this, arguments);
  8647. }
  8648. (0, _createClass2.default)(Moralis, null, [{
  8649. key: "start",
  8650. value:
  8651. /**
  8652. * Call this method to initialize all moralis instances (Moralis, Web3Api, plugins).
  8653. *
  8654. * @param {object} options Your Moralis Application ID and Server URL. Moralis.start({serverUrl,appId})
  8655. * @static
  8656. */
  8657. function () {
  8658. var _start = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee(options) {
  8659. var appId, serverUrl, plugins, javascriptKey, masterKey, moralisSecret, apiKey, trackOptions, _yield$this$getApiKey, web3ApiKey, speedyNodeApiKey;
  8660. return _regenerator.default.wrap(function (_context) {
  8661. while (1) {
  8662. switch (_context.prev = _context.next) {
  8663. case 0:
  8664. appId = options.appId, serverUrl = options.serverUrl, plugins = options.plugins, javascriptKey = options.javascriptKey, masterKey = options.masterKey, moralisSecret = options.moralisSecret;
  8665. if (serverUrl) {
  8666. _context.next = 4;
  8667. break;
  8668. }
  8669. throw new Error("Moralis.start failed: serverUrl is required");
  8670. case 4:
  8671. if (appId) {
  8672. _context.next = 6;
  8673. break;
  8674. }
  8675. throw new Error("Moralis.start failed: appId is required");
  8676. case 6:
  8677. if (moralisSecret) {
  8678. console.warn('Moralis.start warning: Using moralisSecret on the browser enviroment reveals critical information.');
  8679. }
  8680. _context.next = 18;
  8681. break;
  8682. case 9:
  8683. if (!moralisSecret) {
  8684. _context.next = 18;
  8685. break;
  8686. }
  8687. this.moralisSecret = moralisSecret;
  8688. _context.next = 13;
  8689. return this.getApiKeys(moralisSecret);
  8690. case 13:
  8691. _yield$this$getApiKey = _context.sent;
  8692. web3ApiKey = _yield$this$getApiKey.web3ApiKey;
  8693. speedyNodeApiKey = _yield$this$getApiKey.speedyNodeApiKey;
  8694. apiKey = web3ApiKey;
  8695. this.speedyNodeApiKey = speedyNodeApiKey;
  8696. case 18:
  8697. this.initialize(appId, javascriptKey, masterKey);
  8698. this.serverURL = serverUrl;
  8699. this.Web3API.initialize({
  8700. serverUrl: serverUrl,
  8701. apiKey: apiKey,
  8702. Moralis: Moralis
  8703. });
  8704. this.SolanaAPI.initialize({
  8705. serverUrl: serverUrl,
  8706. apiKey: apiKey,
  8707. Moralis: Moralis
  8708. });
  8709. if (!(appId && serverUrl)) {
  8710. _context.next = 28;
  8711. break;
  8712. }
  8713. trackOptions = {
  8714. subdomain: getSubdomain(serverUrl),
  8715. sdk_type: 'javascript',
  8716. sdk_version: "1.5.9",
  8717. sdk_enviroment: "browser",
  8718. appId: appId
  8719. };
  8720. _context.next = 26;
  8721. return this.initPlugins(plugins);
  8722. case 26:
  8723. _context.next = 29;
  8724. break;
  8725. case 28:
  8726. trackOptions = {
  8727. sdk_type: 'javascript',
  8728. sdk_version: "1.5.9",
  8729. sdk_enviroment: "browser"
  8730. };
  8731. case 29:
  8732. // Check if SDK is updated
  8733. checkForSdkUpdates(); // Track start function call
  8734. trackEvent(TrackingEventName.START_FUNCTION, serverUrl ? getSubdomain(serverUrl) : null, trackOptions);
  8735. case 31:
  8736. case "end":
  8737. return _context.stop();
  8738. }
  8739. }
  8740. }, _callee, this);
  8741. }));
  8742. return function () {
  8743. return _start.apply(this, arguments);
  8744. };
  8745. }()
  8746. /**
  8747. * Call this method to get apiKeys using moralis secret.
  8748. *
  8749. * @param {string} moralisSecret Your MoralisSecret
  8750. * @static
  8751. */
  8752. }, {
  8753. key: "getApiKeys",
  8754. value: function () {
  8755. var _getApiKeys = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee2(moralisSecret) {
  8756. var _RESTController, response;
  8757. return _regenerator.default.wrap(function (_context2) {
  8758. while (1) {
  8759. switch (_context2.prev = _context2.next) {
  8760. case 0:
  8761. _context2.prev = 0;
  8762. _RESTController = _CoreManager.default.getRESTController();
  8763. _context2.next = 4;
  8764. return _RESTController.ajax('GET', 'https://admin.moralis.io/api/publics/apiKeys', null, {
  8765. 'moralis-secret': moralisSecret,
  8766. Accept: 'application/json',
  8767. 'Content-Type': 'application/json'
  8768. });
  8769. case 4:
  8770. response = _context2.sent;
  8771. return _context2.abrupt("return", response.response.result);
  8772. case 8:
  8773. _context2.prev = 8;
  8774. _context2.t0 = _context2["catch"](0);
  8775. throw new Error("Could not fetch keys with moralisSecret");
  8776. case 11:
  8777. case "end":
  8778. return _context2.stop();
  8779. }
  8780. }
  8781. }, _callee2, null, [[0, 8]]);
  8782. }));
  8783. return function () {
  8784. return _getApiKeys.apply(this, arguments);
  8785. };
  8786. }()
  8787. /**
  8788. * Call this method first to set up your authentication tokens for Moralis.
  8789. *
  8790. * @param {string} applicationId Your Moralis Application ID.
  8791. * @param {string} [javaScriptKey] Your Moralis JavaScript Key (Not needed for moralis-server)
  8792. * @param {string} [masterKey] Your Moralis Master Key. (Node.js only!)
  8793. * @static
  8794. */
  8795. }, {
  8796. key: "initialize",
  8797. value: function (applicationId
  8798. /*: string*/
  8799. , javaScriptKey
  8800. /*: string*/
  8801. ) {
  8802. if ("browser" === 'browser' && _CoreManager.default.get('IS_NODE') && !process.env.SERVER_RENDERING) {
  8803. /* eslint-disable no-console */
  8804. console.log("It looks like you're using the browser version of the SDK in a " + "node.js environment. You should require('parse/node') instead.");
  8805. /* eslint-enable no-console */
  8806. }
  8807. Moralis._initialize(applicationId, javaScriptKey);
  8808. }
  8809. }, {
  8810. key: "_initialize",
  8811. value: function (applicationId
  8812. /*: string*/
  8813. , javaScriptKey
  8814. /*: string*/
  8815. , masterKey
  8816. /*: string*/
  8817. ) {
  8818. _CoreManager.default.set('APPLICATION_ID', applicationId);
  8819. _CoreManager.default.set('JAVASCRIPT_KEY', javaScriptKey);
  8820. _CoreManager.default.set('MASTER_KEY', masterKey);
  8821. _CoreManager.default.set('USE_MASTER_KEY', false);
  8822. }
  8823. /**
  8824. * Call this method to set your AsyncStorage engine
  8825. * Starting Parse@1.11, the ParseSDK do not provide a React AsyncStorage as the ReactNative module
  8826. * is not provided at a stable path and changes over versions.
  8827. *
  8828. * @param {AsyncStorage} storage a react native async storage.
  8829. * @static
  8830. */
  8831. }, {
  8832. key: "setAsyncStorage",
  8833. value: function (storage
  8834. /*: any*/
  8835. ) {
  8836. _CoreManager.default.setAsyncStorage(storage);
  8837. }
  8838. /**
  8839. * Call this method to set your LocalDatastoreStorage engine
  8840. * If using React-Native use {@link Moralis.setAsyncStorage Moralis.setAsyncStorage()}
  8841. *
  8842. * @param {LocalDatastoreController} controller a data storage.
  8843. * @static
  8844. */
  8845. }, {
  8846. key: "setLocalDatastoreController",
  8847. value: function (controller
  8848. /*: any*/
  8849. ) {
  8850. _CoreManager.default.setLocalDatastoreController(controller);
  8851. }
  8852. /**
  8853. * @member {string} Moralis.applicationId
  8854. * @static
  8855. */
  8856. }, {
  8857. key: "applicationId",
  8858. get: function () {
  8859. return _CoreManager.default.get('APPLICATION_ID');
  8860. }
  8861. /**
  8862. * @member {string} Moralis.javaScriptKey
  8863. * @static
  8864. */
  8865. ,
  8866. set: function (value) {
  8867. _CoreManager.default.set('APPLICATION_ID', value);
  8868. }
  8869. }, {
  8870. key: "javaScriptKey",
  8871. get: function () {
  8872. return _CoreManager.default.get('JAVASCRIPT_KEY');
  8873. }
  8874. /**
  8875. * @member {string} Moralis.masterKey
  8876. * @static
  8877. */
  8878. ,
  8879. set: function (value) {
  8880. _CoreManager.default.set('JAVASCRIPT_KEY', value);
  8881. }
  8882. }, {
  8883. key: "masterKey",
  8884. get: function () {
  8885. return _CoreManager.default.get('MASTER_KEY');
  8886. }
  8887. /**
  8888. * @member {string} Moralis.serverURL
  8889. * @static
  8890. */
  8891. ,
  8892. set: function (value) {
  8893. _CoreManager.default.set('MASTER_KEY', value);
  8894. }
  8895. }, {
  8896. key: "serverURL",
  8897. get: function () {
  8898. return _CoreManager.default.get('SERVER_URL');
  8899. }
  8900. /**
  8901. * @member {string} Moralis.serverAuthToken
  8902. * @static
  8903. */
  8904. ,
  8905. set: function (value) {
  8906. _CoreManager.default.set('SERVER_URL', value);
  8907. }
  8908. }, {
  8909. key: "serverAuthToken",
  8910. get: function () {
  8911. return _CoreManager.default.get('SERVER_AUTH_TOKEN');
  8912. }
  8913. /**
  8914. * @member {string} Moralis.serverAuthType
  8915. * @static
  8916. */
  8917. ,
  8918. set: function (value) {
  8919. _CoreManager.default.set('SERVER_AUTH_TOKEN', value);
  8920. }
  8921. }, {
  8922. key: "serverAuthType",
  8923. get: function () {
  8924. return _CoreManager.default.get('SERVER_AUTH_TYPE');
  8925. }
  8926. /**
  8927. * @member {string} Moralis.liveQueryServerURL
  8928. * @static
  8929. */
  8930. ,
  8931. set: function (value) {
  8932. _CoreManager.default.set('SERVER_AUTH_TYPE', value);
  8933. }
  8934. }, {
  8935. key: "liveQueryServerURL",
  8936. get: function () {
  8937. return _CoreManager.default.get('LIVEQUERY_SERVER_URL');
  8938. }
  8939. /**
  8940. * @member {string} Moralis.encryptedUser
  8941. * @static
  8942. */
  8943. ,
  8944. set: function (value) {
  8945. _CoreManager.default.set('LIVEQUERY_SERVER_URL', value);
  8946. }
  8947. }, {
  8948. key: "encryptedUser",
  8949. get: function () {
  8950. return _CoreManager.default.get('ENCRYPTED_USER');
  8951. }
  8952. /**
  8953. * @member {string} Moralis.secret
  8954. * @static
  8955. */
  8956. ,
  8957. set: function (value) {
  8958. _CoreManager.default.set('ENCRYPTED_USER', value);
  8959. }
  8960. }, {
  8961. key: "secret",
  8962. get: function () {
  8963. return _CoreManager.default.get('ENCRYPTED_KEY');
  8964. }
  8965. /**
  8966. * @member {boolean} Moralis.idempotency
  8967. * @static
  8968. */
  8969. ,
  8970. set: function (value) {
  8971. _CoreManager.default.set('ENCRYPTED_KEY', value);
  8972. }
  8973. }, {
  8974. key: "idempotency",
  8975. get: function () {
  8976. return _CoreManager.default.get('IDEMPOTENCY');
  8977. },
  8978. set: function (value) {
  8979. _CoreManager.default.set('IDEMPOTENCY', value);
  8980. }
  8981. }]);
  8982. return Moralis;
  8983. }(_MoralisWeb2.default);
  8984. Moralis.ACL = _dereq_('./ParseACL').default;
  8985. Moralis.Analytics = _dereq_('./Analytics');
  8986. Moralis.AnonymousUtils = _dereq_('./AnonymousUtils').default;
  8987. Moralis.Cloud = _dereq_('./Cloud');
  8988. Moralis.CLP = _dereq_('./ParseCLP').default;
  8989. Moralis.CoreManager = _dereq_('./CoreManager');
  8990. Moralis.Config = _dereq_('./ParseConfig').default;
  8991. Moralis.Error = _dereq_('./ParseError').default;
  8992. Moralis.FacebookUtils = _dereq_('./FacebookUtils').default;
  8993. Moralis.File = _dereq_('./ParseFile').default;
  8994. Moralis.GeoPoint = _dereq_('./ParseGeoPoint').default;
  8995. Moralis.Polygon = _dereq_('./ParsePolygon').default;
  8996. Moralis.Installation = _dereq_('./ParseInstallation').default;
  8997. Moralis.LocalDatastore = _dereq_('./LocalDatastore');
  8998. Moralis.Object = _dereq_('./ParseObject').default;
  8999. Moralis.Op = {
  9000. Set: ParseOp.SetOp,
  9001. Unset: ParseOp.UnsetOp,
  9002. Increment: ParseOp.IncrementOp,
  9003. Add: ParseOp.AddOp,
  9004. Remove: ParseOp.RemoveOp,
  9005. AddUnique: ParseOp.AddUniqueOp,
  9006. Relation: ParseOp.RelationOp
  9007. };
  9008. Moralis.Web3API = _dereq_('./MoralisWeb3Api').default;
  9009. Moralis.SolanaAPI = _dereq_('./MoralisSolanaApi').default;
  9010. Moralis.Push = _dereq_('./Push');
  9011. Moralis.Query = _dereq_('./ParseQuery').default;
  9012. Moralis.Relation = _dereq_('./ParseRelation').default;
  9013. Moralis.Role = _dereq_('./ParseRole').default;
  9014. Moralis.Schema = _dereq_('./ParseSchema').default;
  9015. Moralis.Session = _dereq_('./ParseSession').default;
  9016. Moralis.Storage = _dereq_('./Storage');
  9017. Moralis.User = _dereq_('./ParseUser').default;
  9018. Moralis.LiveQuery = _dereq_('./ParseLiveQuery').default;
  9019. Moralis.LiveQueryClient = _dereq_('./LiveQueryClient').default;
  9020. Moralis.Web3 = Moralis;
  9021. Moralis.Units = _dereq_('./UnitConvert'); // Moralis.Web3 = require('./MoralisWeb3').default;
  9022. Moralis.Elrond = _dereq_('./MoralisErd').default;
  9023. Moralis.Erd = Moralis.Elrond;
  9024. Moralis.Dot = _dereq_('./MoralisDot').default;
  9025. Moralis.UI = _dereq_('./MoralisUI').default;
  9026. Moralis.Chains = _dereq_('./Chains').default;
  9027. Moralis.AbstractWeb3Connector = _dereq_('./Web3Connector/AbstractWeb3Connector').default;
  9028. (0, _filterConsole.filterConsole)();
  9029. Moralis._request = function () {
  9030. for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
  9031. args[_key] = arguments[_key];
  9032. }
  9033. return _CoreManager.default.getRESTController().request.apply(null, args);
  9034. };
  9035. Moralis._ajax = function () {
  9036. for (var _len2 = arguments.length, args = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
  9037. args[_key2] = arguments[_key2];
  9038. }
  9039. return _CoreManager.default.getRESTController().ajax.apply(null, args);
  9040. }; // We attempt to match the signatures of the legacy versions of these methods
  9041. Moralis._decode = function (_, value) {
  9042. return (0, _decode.default)(value);
  9043. };
  9044. Moralis._encode = function (value, _, disallowObjects) {
  9045. return (0, _encode.default)(value, disallowObjects);
  9046. };
  9047. Moralis._getInstallationId = function () {
  9048. return _CoreManager.default.getInstallationController().currentInstallationId();
  9049. };
  9050. /**
  9051. * Enable pinning in your application.
  9052. * This must be called before your application can use pinning.
  9053. *
  9054. * @static
  9055. */
  9056. Moralis.enableLocalDatastore = function () {
  9057. Moralis.LocalDatastore.isEnabled = true;
  9058. };
  9059. /**
  9060. * Flag that indicates whether Local Datastore is enabled.
  9061. *
  9062. * @static
  9063. * @returns {boolean}
  9064. */
  9065. Moralis.isLocalDatastoreEnabled = function () {
  9066. return Moralis.LocalDatastore.isEnabled;
  9067. };
  9068. /**
  9069. * Gets all contents from Local Datastore
  9070. *
  9071. * <pre>
  9072. * await Moralis.dumpLocalDatastore();
  9073. * </pre>
  9074. *
  9075. * @static
  9076. * @returns {object}
  9077. */
  9078. Moralis.dumpLocalDatastore = function () {
  9079. if (!Moralis.LocalDatastore.isEnabled) {
  9080. console.log('Moralis.enableLocalDatastore() must be called first'); // eslint-disable-line no-console
  9081. return _promise.default.resolve({});
  9082. }
  9083. return Moralis.LocalDatastore._getAllContents();
  9084. };
  9085. /**
  9086. * Enable the current user encryption.
  9087. * This must be called before login any user.
  9088. *
  9089. * @static
  9090. */
  9091. Moralis.enableEncryptedUser = function () {
  9092. Moralis.encryptedUser = true;
  9093. };
  9094. /**
  9095. * Flag that indicates whether Encrypted User is enabled.
  9096. *
  9097. * @static
  9098. * @returns {boolean}
  9099. */
  9100. Moralis.isEncryptedUserEnabled = function () {
  9101. return Moralis.encryptedUser;
  9102. };
  9103. _CoreManager.default.setCryptoController(_CryptoController.default);
  9104. _CoreManager.default.setInstallationController(_InstallationController.default);
  9105. _CoreManager.default.setRESTController(_RESTController2.default);
  9106. // For legacy requires, of the form `var Moralis = require('moralis').Moralis`
  9107. Moralis.Moralis = Moralis;
  9108. module.exports = Moralis;
  9109. }).call(this)}).call(this,_dereq_('_process'))
  9110. },{"./Analytics":1,"./AnonymousUtils":2,"./Chains":3,"./Cloud":4,"./CoreManager":5,"./CryptoController":6,"./FacebookUtils":8,"./InstallationController":9,"./LiveQueryClient":11,"./LocalDatastore":13,"./MoralisDot":16,"./MoralisErd":17,"./MoralisSolanaApi":19,"./MoralisUI":20,"./MoralisWeb3":21,"./MoralisWeb3Api":22,"./ParseACL":26,"./ParseCLP":27,"./ParseConfig":28,"./ParseError":29,"./ParseFile":30,"./ParseGeoPoint":33,"./ParseInstallation":34,"./ParseLiveQuery":35,"./ParseObject":36,"./ParseOp":37,"./ParsePolygon":38,"./ParseQuery":39,"./ParseRelation":40,"./ParseRole":41,"./ParseSchema":42,"./ParseSession":43,"./ParseUser":44,"./Push":45,"./RESTController":46,"./Storage":48,"./UnitConvert":53,"./Web3Connector/AbstractWeb3Connector":54,"./decode":65,"./encode":66,"./filterConsole":69,"./utils":75,"@babel/runtime-corejs3/core-js-stable/object/define-property":105,"@babel/runtime-corejs3/core-js-stable/object/get-own-property-descriptor":108,"@babel/runtime-corejs3/core-js-stable/promise":115,"@babel/runtime-corejs3/core-js-stable/reflect/construct":116,"@babel/runtime-corejs3/core-js-stable/weak-map":122,"@babel/runtime-corejs3/helpers/asyncToGenerator":144,"@babel/runtime-corejs3/helpers/classCallCheck":145,"@babel/runtime-corejs3/helpers/createClass":147,"@babel/runtime-corejs3/helpers/getPrototypeOf":150,"@babel/runtime-corejs3/helpers/inherits":151,"@babel/runtime-corejs3/helpers/interopRequireDefault":152,"@babel/runtime-corejs3/helpers/possibleConstructorReturn":159,"@babel/runtime-corejs3/helpers/typeof":164,"@babel/runtime-corejs3/regenerator":167,"_process":323,"ethers":773}],26:[function(_dereq_,module,exports){
  9111. "use strict";
  9112. var _Object$defineProperty = _dereq_("@babel/runtime-corejs3/core-js-stable/object/define-property");
  9113. var _interopRequireDefault = _dereq_("@babel/runtime-corejs3/helpers/interopRequireDefault");
  9114. _Object$defineProperty(exports, "__esModule", {
  9115. value: true
  9116. });
  9117. exports.default = void 0;
  9118. var _keys = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/object/keys"));
  9119. var _typeof2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/helpers/typeof"));
  9120. var _classCallCheck2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/helpers/classCallCheck"));
  9121. var _createClass2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/helpers/createClass"));
  9122. var _defineProperty2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/helpers/defineProperty"));
  9123. var _ParseRole = _interopRequireDefault(_dereq_("./ParseRole"));
  9124. var _ParseUser = _interopRequireDefault(_dereq_("./ParseUser"));
  9125. /**
  9126. * Copyright (c) 2015-present, Parse, LLC.
  9127. * All rights reserved.
  9128. *
  9129. * This source code is licensed under the BSD-style license found in the
  9130. * LICENSE file in the root directory of this source tree. An additional grant
  9131. * of patent rights can be found in the PATENTS file in the same directory.
  9132. *
  9133. * @flow
  9134. */
  9135. var PUBLIC_KEY = '*';
  9136. /**
  9137. * Creates a new ACL.
  9138. * If no argument is given, the ACL has no permissions for anyone.
  9139. * If the argument is a Parse.User, the ACL will have read and write
  9140. * permission for only that user.
  9141. * If the argument is any other JSON object, that object will be interpretted
  9142. * as a serialized ACL created with toJSON().
  9143. *
  9144. * <p>An ACL, or Access Control List can be added to any
  9145. * <code>Parse.Object</code> to restrict access to only a subset of users
  9146. * of your application.</p>
  9147. *
  9148. * @alias Parse.ACL
  9149. */
  9150. var ParseACL = /*#__PURE__*/function () {
  9151. /**
  9152. * @param {(Parse.User | object)} arg1 The user to initialize the ACL for
  9153. */
  9154. function ParseACL(arg1
  9155. /*: ParseUser | ByIdMap*/
  9156. ) {
  9157. (0, _classCallCheck2.default)(this, ParseACL);
  9158. (0, _defineProperty2.default)(this, "permissionsById", void 0);
  9159. this.permissionsById = {};
  9160. if (arg1 && (0, _typeof2.default)(arg1) === 'object') {
  9161. if (arg1 instanceof _ParseUser.default) {
  9162. this.setReadAccess(arg1, true);
  9163. this.setWriteAccess(arg1, true);
  9164. } else {
  9165. for (var _userId in arg1) {
  9166. var accessList = arg1[_userId];
  9167. this.permissionsById[_userId] = {};
  9168. for (var _permission in accessList) {
  9169. var allowed = accessList[_permission];
  9170. if (_permission !== 'read' && _permission !== 'write') {
  9171. throw new TypeError('Tried to create an ACL with an invalid permission type.');
  9172. }
  9173. if (typeof allowed !== 'boolean') {
  9174. throw new TypeError('Tried to create an ACL with an invalid permission value.');
  9175. }
  9176. this.permissionsById[_userId][_permission] = allowed;
  9177. }
  9178. }
  9179. }
  9180. } else if (typeof arg1 === 'function') {
  9181. throw new TypeError('ParseACL constructed with a function. Did you forget ()?');
  9182. }
  9183. }
  9184. /**
  9185. * Returns a JSON-encoded version of the ACL.
  9186. *
  9187. * @returns {object}
  9188. */
  9189. (0, _createClass2.default)(ParseACL, [{
  9190. key: "toJSON",
  9191. value: function ()
  9192. /*: ByIdMap*/
  9193. {
  9194. var permissions = {};
  9195. for (var p in this.permissionsById) {
  9196. permissions[p] = this.permissionsById[p];
  9197. }
  9198. return permissions;
  9199. }
  9200. /**
  9201. * Returns whether this ACL is equal to another object
  9202. *
  9203. * @param {ParseACL} other The other object's ACL to compare to
  9204. * @returns {boolean}
  9205. */
  9206. }, {
  9207. key: "equals",
  9208. value: function (other
  9209. /*: ParseACL*/
  9210. )
  9211. /*: boolean*/
  9212. {
  9213. if (!(other instanceof ParseACL)) {
  9214. return false;
  9215. }
  9216. var users = (0, _keys.default)(this.permissionsById);
  9217. var otherUsers = (0, _keys.default)(other.permissionsById);
  9218. if (users.length !== otherUsers.length) {
  9219. return false;
  9220. }
  9221. for (var u in this.permissionsById) {
  9222. if (!other.permissionsById[u]) {
  9223. return false;
  9224. }
  9225. if (this.permissionsById[u].read !== other.permissionsById[u].read) {
  9226. return false;
  9227. }
  9228. if (this.permissionsById[u].write !== other.permissionsById[u].write) {
  9229. return false;
  9230. }
  9231. }
  9232. return true;
  9233. }
  9234. }, {
  9235. key: "_setAccess",
  9236. value: function (accessType
  9237. /*: string*/
  9238. , userId
  9239. /*: ParseUser | ParseRole | string*/
  9240. , allowed
  9241. /*: boolean*/
  9242. ) {
  9243. if (userId instanceof _ParseUser.default) {
  9244. userId = userId.id;
  9245. } else if (userId instanceof _ParseRole.default) {
  9246. var name = userId.getName();
  9247. if (!name) {
  9248. throw new TypeError('Role must have a name');
  9249. }
  9250. userId = "role:".concat(name);
  9251. }
  9252. if (typeof userId !== 'string') {
  9253. throw new TypeError('userId must be a string.');
  9254. }
  9255. if (typeof allowed !== 'boolean') {
  9256. throw new TypeError('allowed must be either true or false.');
  9257. }
  9258. var permissions = this.permissionsById[userId];
  9259. if (!permissions) {
  9260. if (!allowed) {
  9261. // The user already doesn't have this permission, so no action is needed
  9262. return;
  9263. }
  9264. permissions = {};
  9265. this.permissionsById[userId] = permissions;
  9266. }
  9267. if (allowed) {
  9268. this.permissionsById[userId][accessType] = true;
  9269. } else {
  9270. delete permissions[accessType];
  9271. if ((0, _keys.default)(permissions).length === 0) {
  9272. delete this.permissionsById[userId];
  9273. }
  9274. }
  9275. }
  9276. }, {
  9277. key: "_getAccess",
  9278. value: function (accessType
  9279. /*: string*/
  9280. , userId
  9281. /*: ParseUser | ParseRole | string*/
  9282. )
  9283. /*: boolean*/
  9284. {
  9285. if (userId instanceof _ParseUser.default) {
  9286. userId = userId.id;
  9287. if (!userId) {
  9288. throw new Error('Cannot get access for a ParseUser without an ID');
  9289. }
  9290. } else if (userId instanceof _ParseRole.default) {
  9291. var name = userId.getName();
  9292. if (!name) {
  9293. throw new TypeError('Role must have a name');
  9294. }
  9295. userId = "role:".concat(name);
  9296. }
  9297. var permissions = this.permissionsById[userId];
  9298. if (!permissions) {
  9299. return false;
  9300. }
  9301. return !!permissions[accessType];
  9302. }
  9303. /**
  9304. * Sets whether the given user is allowed to read this object.
  9305. *
  9306. * @param userId An instance of Parse.User or its objectId.
  9307. * @param {boolean} allowed Whether that user should have read access.
  9308. */
  9309. }, {
  9310. key: "setReadAccess",
  9311. value: function (userId
  9312. /*: ParseUser | ParseRole | string*/
  9313. , allowed
  9314. /*: boolean*/
  9315. ) {
  9316. this._setAccess('read', userId, allowed);
  9317. }
  9318. /**
  9319. * Get whether the given user id is *explicitly* allowed to read this object.
  9320. * Even if this returns false, the user may still be able to access it if
  9321. * getPublicReadAccess returns true or a role that the user belongs to has
  9322. * write access.
  9323. *
  9324. * @param userId An instance of Parse.User or its objectId, or a Parse.Role.
  9325. * @returns {boolean}
  9326. */
  9327. }, {
  9328. key: "getReadAccess",
  9329. value: function (userId
  9330. /*: ParseUser | ParseRole | string*/
  9331. )
  9332. /*: boolean*/
  9333. {
  9334. return this._getAccess('read', userId);
  9335. }
  9336. /**
  9337. * Sets whether the given user id is allowed to write this object.
  9338. *
  9339. * @param userId An instance of Parse.User or its objectId, or a Parse.Role..
  9340. * @param {boolean} allowed Whether that user should have write access.
  9341. */
  9342. }, {
  9343. key: "setWriteAccess",
  9344. value: function (userId
  9345. /*: ParseUser | ParseRole | string*/
  9346. , allowed
  9347. /*: boolean*/
  9348. ) {
  9349. this._setAccess('write', userId, allowed);
  9350. }
  9351. /**
  9352. * Gets whether the given user id is *explicitly* allowed to write this object.
  9353. * Even if this returns false, the user may still be able to write it if
  9354. * getPublicWriteAccess returns true or a role that the user belongs to has
  9355. * write access.
  9356. *
  9357. * @param userId An instance of Parse.User or its objectId, or a Parse.Role.
  9358. * @returns {boolean}
  9359. */
  9360. }, {
  9361. key: "getWriteAccess",
  9362. value: function (userId
  9363. /*: ParseUser | ParseRole | string*/
  9364. )
  9365. /*: boolean*/
  9366. {
  9367. return this._getAccess('write', userId);
  9368. }
  9369. /**
  9370. * Sets whether the public is allowed to read this object.
  9371. *
  9372. * @param {boolean} allowed
  9373. */
  9374. }, {
  9375. key: "setPublicReadAccess",
  9376. value: function (allowed
  9377. /*: boolean*/
  9378. ) {
  9379. this.setReadAccess(PUBLIC_KEY, allowed);
  9380. }
  9381. /**
  9382. * Gets whether the public is allowed to read this object.
  9383. *
  9384. * @returns {boolean}
  9385. */
  9386. }, {
  9387. key: "getPublicReadAccess",
  9388. value: function ()
  9389. /*: boolean*/
  9390. {
  9391. return this.getReadAccess(PUBLIC_KEY);
  9392. }
  9393. /**
  9394. * Sets whether the public is allowed to write this object.
  9395. *
  9396. * @param {boolean} allowed
  9397. */
  9398. }, {
  9399. key: "setPublicWriteAccess",
  9400. value: function (allowed
  9401. /*: boolean*/
  9402. ) {
  9403. this.setWriteAccess(PUBLIC_KEY, allowed);
  9404. }
  9405. /**
  9406. * Gets whether the public is allowed to write this object.
  9407. *
  9408. * @returns {boolean}
  9409. */
  9410. }, {
  9411. key: "getPublicWriteAccess",
  9412. value: function ()
  9413. /*: boolean*/
  9414. {
  9415. return this.getWriteAccess(PUBLIC_KEY);
  9416. }
  9417. /**
  9418. * Gets whether users belonging to the given role are allowed
  9419. * to read this object. Even if this returns false, the role may
  9420. * still be able to write it if a parent role has read access.
  9421. *
  9422. * @param role The name of the role, or a Parse.Role object.
  9423. * @returns {boolean} true if the role has read access. false otherwise.
  9424. * @throws {TypeError} If role is neither a Parse.Role nor a String.
  9425. */
  9426. }, {
  9427. key: "getRoleReadAccess",
  9428. value: function (role
  9429. /*: ParseRole | string*/
  9430. )
  9431. /*: boolean*/
  9432. {
  9433. if (role instanceof _ParseRole.default) {
  9434. // Normalize to the String name
  9435. role = role.getName();
  9436. }
  9437. if (typeof role !== 'string') {
  9438. throw new TypeError('role must be a ParseRole or a String');
  9439. }
  9440. return this.getReadAccess("role:".concat(role));
  9441. }
  9442. /**
  9443. * Gets whether users belonging to the given role are allowed
  9444. * to write this object. Even if this returns false, the role may
  9445. * still be able to write it if a parent role has write access.
  9446. *
  9447. * @param role The name of the role, or a Parse.Role object.
  9448. * @returns {boolean} true if the role has write access. false otherwise.
  9449. * @throws {TypeError} If role is neither a Parse.Role nor a String.
  9450. */
  9451. }, {
  9452. key: "getRoleWriteAccess",
  9453. value: function (role
  9454. /*: ParseRole | string*/
  9455. )
  9456. /*: boolean*/
  9457. {
  9458. if (role instanceof _ParseRole.default) {
  9459. // Normalize to the String name
  9460. role = role.getName();
  9461. }
  9462. if (typeof role !== 'string') {
  9463. throw new TypeError('role must be a ParseRole or a String');
  9464. }
  9465. return this.getWriteAccess("role:".concat(role));
  9466. }
  9467. /**
  9468. * Sets whether users belonging to the given role are allowed
  9469. * to read this object.
  9470. *
  9471. * @param role The name of the role, or a Parse.Role object.
  9472. * @param {boolean} allowed Whether the given role can read this object.
  9473. * @throws {TypeError} If role is neither a Parse.Role nor a String.
  9474. */
  9475. }, {
  9476. key: "setRoleReadAccess",
  9477. value: function (role
  9478. /*: ParseRole | string*/
  9479. , allowed
  9480. /*: boolean*/
  9481. ) {
  9482. if (role instanceof _ParseRole.default) {
  9483. // Normalize to the String name
  9484. role = role.getName();
  9485. }
  9486. if (typeof role !== 'string') {
  9487. throw new TypeError('role must be a ParseRole or a String');
  9488. }
  9489. this.setReadAccess("role:".concat(role), allowed);
  9490. }
  9491. /**
  9492. * Sets whether users belonging to the given role are allowed
  9493. * to write this object.
  9494. *
  9495. * @param role The name of the role, or a Parse.Role object.
  9496. * @param {boolean} allowed Whether the given role can write this object.
  9497. * @throws {TypeError} If role is neither a Parse.Role nor a String.
  9498. */
  9499. }, {
  9500. key: "setRoleWriteAccess",
  9501. value: function (role
  9502. /*: ParseRole | string*/
  9503. , allowed
  9504. /*: boolean*/
  9505. ) {
  9506. if (role instanceof _ParseRole.default) {
  9507. // Normalize to the String name
  9508. role = role.getName();
  9509. }
  9510. if (typeof role !== 'string') {
  9511. throw new TypeError('role must be a ParseRole or a String');
  9512. }
  9513. this.setWriteAccess("role:".concat(role), allowed);
  9514. }
  9515. }]);
  9516. return ParseACL;
  9517. }();
  9518. var _default = ParseACL;
  9519. exports.default = _default;
  9520. },{"./ParseRole":41,"./ParseUser":44,"@babel/runtime-corejs3/core-js-stable/object/define-property":105,"@babel/runtime-corejs3/core-js-stable/object/keys":112,"@babel/runtime-corejs3/helpers/classCallCheck":145,"@babel/runtime-corejs3/helpers/createClass":147,"@babel/runtime-corejs3/helpers/defineProperty":148,"@babel/runtime-corejs3/helpers/interopRequireDefault":152,"@babel/runtime-corejs3/helpers/typeof":164}],27:[function(_dereq_,module,exports){
  9521. "use strict";
  9522. var _sliceInstanceProperty2 = _dereq_("@babel/runtime-corejs3/core-js-stable/instance/slice");
  9523. var _Array$from = _dereq_("@babel/runtime-corejs3/core-js-stable/array/from");
  9524. var _Symbol = _dereq_("@babel/runtime-corejs3/core-js-stable/symbol");
  9525. var _getIteratorMethod = _dereq_("@babel/runtime-corejs3/core-js/get-iterator-method");
  9526. var _Array$isArray2 = _dereq_("@babel/runtime-corejs3/core-js-stable/array/is-array");
  9527. var _Object$keys2 = _dereq_("@babel/runtime-corejs3/core-js-stable/object/keys");
  9528. var _Object$getOwnPropertySymbols = _dereq_("@babel/runtime-corejs3/core-js-stable/object/get-own-property-symbols");
  9529. var _filterInstanceProperty = _dereq_("@babel/runtime-corejs3/core-js-stable/instance/filter");
  9530. var _Object$getOwnPropertyDescriptor = _dereq_("@babel/runtime-corejs3/core-js-stable/object/get-own-property-descriptor");
  9531. var _forEachInstanceProperty = _dereq_("@babel/runtime-corejs3/core-js-stable/instance/for-each");
  9532. var _Object$getOwnPropertyDescriptors = _dereq_("@babel/runtime-corejs3/core-js-stable/object/get-own-property-descriptors");
  9533. var _Object$defineProperties = _dereq_("@babel/runtime-corejs3/core-js-stable/object/define-properties");
  9534. var _Object$defineProperty = _dereq_("@babel/runtime-corejs3/core-js-stable/object/define-property");
  9535. var _interopRequireDefault = _dereq_("@babel/runtime-corejs3/helpers/interopRequireDefault");
  9536. _Object$defineProperty(exports, "__esModule", {
  9537. value: true
  9538. });
  9539. exports.default = void 0;
  9540. var _slicedToArray2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/helpers/slicedToArray"));
  9541. var _typeof2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/helpers/typeof"));
  9542. var _classCallCheck2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/helpers/classCallCheck"));
  9543. var _createClass2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/helpers/createClass"));
  9544. var _defineProperty2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/helpers/defineProperty"));
  9545. var _map = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/map"));
  9546. var _includes = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/instance/includes"));
  9547. var _every = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/instance/every"));
  9548. var _entries = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/instance/entries"));
  9549. var _slice = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/instance/slice"));
  9550. var _keys = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/object/keys"));
  9551. var _isArray = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/array/is-array"));
  9552. var _ParseRole = _interopRequireDefault(_dereq_("./ParseRole"));
  9553. var _ParseUser = _interopRequireDefault(_dereq_("./ParseUser"));
  9554. function ownKeys(object, enumerableOnly) {
  9555. var keys = _Object$keys2(object);
  9556. if (_Object$getOwnPropertySymbols) {
  9557. var symbols = _Object$getOwnPropertySymbols(object);
  9558. enumerableOnly && (symbols = _filterInstanceProperty(symbols).call(symbols, function (sym) {
  9559. return _Object$getOwnPropertyDescriptor(object, sym).enumerable;
  9560. })), keys.push.apply(keys, symbols);
  9561. }
  9562. return keys;
  9563. }
  9564. function _objectSpread(target) {
  9565. for (var i = 1; i < arguments.length; i++) {
  9566. var _context3, _context4;
  9567. var source = null != arguments[i] ? arguments[i] : {};
  9568. i % 2 ? _forEachInstanceProperty(_context3 = ownKeys(Object(source), !0)).call(_context3, function (key) {
  9569. (0, _defineProperty2.default)(target, key, source[key]);
  9570. }) : _Object$getOwnPropertyDescriptors ? _Object$defineProperties(target, _Object$getOwnPropertyDescriptors(source)) : _forEachInstanceProperty(_context4 = ownKeys(Object(source))).call(_context4, function (key) {
  9571. _Object$defineProperty(target, key, _Object$getOwnPropertyDescriptor(source, key));
  9572. });
  9573. }
  9574. return target;
  9575. }
  9576. function _createForOfIteratorHelper(o, allowArrayLike) {
  9577. var it = typeof _Symbol !== "undefined" && _getIteratorMethod(o) || o["@@iterator"];
  9578. if (!it) {
  9579. if (_Array$isArray2(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") {
  9580. if (it) o = it;
  9581. var i = 0;
  9582. var F = function () {};
  9583. return {
  9584. s: F,
  9585. n: function () {
  9586. if (i >= o.length) return {
  9587. done: true
  9588. };
  9589. return {
  9590. done: false,
  9591. value: o[i++]
  9592. };
  9593. },
  9594. e: function (_e) {
  9595. throw _e;
  9596. },
  9597. f: F
  9598. };
  9599. }
  9600. throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
  9601. }
  9602. var normalCompletion = true,
  9603. didErr = false,
  9604. err;
  9605. return {
  9606. s: function () {
  9607. it = it.call(o);
  9608. },
  9609. n: function () {
  9610. var step = it.next();
  9611. normalCompletion = step.done;
  9612. return step;
  9613. },
  9614. e: function (_e2) {
  9615. didErr = true;
  9616. err = _e2;
  9617. },
  9618. f: function () {
  9619. try {
  9620. if (!normalCompletion && it.return != null) it.return();
  9621. } finally {
  9622. if (didErr) throw err;
  9623. }
  9624. }
  9625. };
  9626. }
  9627. function _unsupportedIterableToArray(o, minLen) {
  9628. var _context2;
  9629. if (!o) return;
  9630. if (typeof o === "string") return _arrayLikeToArray(o, minLen);
  9631. var n = _sliceInstanceProperty2(_context2 = Object.prototype.toString.call(o)).call(_context2, 8, -1);
  9632. if (n === "Object" && o.constructor) n = o.constructor.name;
  9633. if (n === "Map" || n === "Set") return _Array$from(o);
  9634. if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen);
  9635. }
  9636. function _arrayLikeToArray(arr, len) {
  9637. if (len == null || len > arr.length) len = arr.length;
  9638. for (var i = 0, arr2 = new Array(len); i < len; i++) {
  9639. arr2[i] = arr[i];
  9640. }
  9641. return arr2;
  9642. }
  9643. var PUBLIC_KEY = '*';
  9644. var VALID_PERMISSIONS
  9645. /*: Map<string, UsersMap>*/
  9646. = new _map.default();
  9647. VALID_PERMISSIONS.set('get', {});
  9648. VALID_PERMISSIONS.set('find', {});
  9649. VALID_PERMISSIONS.set('count', {});
  9650. VALID_PERMISSIONS.set('create', {});
  9651. VALID_PERMISSIONS.set('update', {});
  9652. VALID_PERMISSIONS.set('delete', {});
  9653. VALID_PERMISSIONS.set('addField', {});
  9654. var VALID_PERMISSIONS_EXTENDED
  9655. /*: Map<string, UsersMap>*/
  9656. = new _map.default();
  9657. VALID_PERMISSIONS_EXTENDED.set('protectedFields', {});
  9658. /**
  9659. * Creates a new CLP.
  9660. * If no argument is given, the CLP has no permissions for anyone.
  9661. * If the argument is a Parse.User or Parse.Role, the CLP will have read and write
  9662. * permission for only that user or role.
  9663. * If the argument is any other JSON object, that object will be interpretted
  9664. * as a serialized CLP created with toJSON().
  9665. *
  9666. * <p>A CLP, or Class Level Permissions can be added to any
  9667. * <code>Parse.Schema</code> to restrict access to only a subset of users
  9668. * of your application.</p>
  9669. *
  9670. * <p>
  9671. * For get/count/find/create/update/delete/addField using the following functions:
  9672. *
  9673. * Entity is type Parse.User or Parse.Role or string
  9674. * Role is type Parse.Role or Name of Parse.Role
  9675. *
  9676. * getGetRequiresAuthentication()
  9677. * setGetRequiresAuthentication(allowed: boolean)
  9678. * getGetPointerFields()
  9679. * setGetPointerFields(pointerFields: string[])
  9680. * getGetAccess(entity: Entity)
  9681. * setGetAccess(entity: Entity, allowed: boolean)
  9682. * getPublicGetAccess()
  9683. * setPublicGetAccess(allowed: boolean)
  9684. * getRoleGetAccess(role: Role)
  9685. * setRoleGetAccess(role: Role, allowed: boolean)
  9686. * getFindRequiresAuthentication()
  9687. * setFindRequiresAuthentication(allowed: boolean)
  9688. * getFindPointerFields()
  9689. * setFindPointerFields(pointerFields: string[])
  9690. * getFindAccess(entity: Entity)
  9691. * setFindAccess(entity: Entity, allowed: boolean)
  9692. * getPublicFindAccess()
  9693. * setPublicFindAccess(allowed: boolean)
  9694. * getRoleFindAccess(role: Role)
  9695. * setRoleFindAccess(role: Role, allowed: boolean)
  9696. * getCountRequiresAuthentication()
  9697. * setCountRequiresAuthentication(allowed: boolean)
  9698. * getCountPointerFields()
  9699. * setCountPointerFields(pointerFields: string[])
  9700. * getCountAccess(entity: Entity)
  9701. * setCountAccess(entity: Entity, allowed: boolean)
  9702. * getPublicCountAccess()
  9703. * setPublicCountAccess(allowed: boolean)
  9704. * getRoleCountAccess(role: Role)
  9705. * setRoleCountAccess(role: Role, allowed: boolean)
  9706. * getCreateRequiresAuthentication()
  9707. * setCreateRequiresAuthentication(allowed: boolean)
  9708. * getCreatePointerFields()
  9709. * setCreatePointerFields(pointerFields: string[])
  9710. * getCreateAccess(entity: Entity)
  9711. * setCreateAccess(entity: Entity, allowed: boolean)
  9712. * getPublicCreateAccess()
  9713. * setPublicCreateAccess(allowed: Boolean)
  9714. * getRoleCreateAccess(role: Role)
  9715. * setRoleCreateAccess(role: Role, allowed: boolean)
  9716. * getUpdateRequiresAuthentication()
  9717. * setUpdateRequiresAuthentication(allowed: boolean)
  9718. * getUpdatePointerFields()
  9719. * setUpdatePointerFields(pointerFields: string[])
  9720. * getUpdateAccess(entity: Entity)
  9721. * setUpdateAccess(entity: Entity, allowed: boolean)
  9722. * getPublicUpdateAccess()
  9723. * setPublicUpdateAccess(allowed: boolean)
  9724. * getRoleUpdateAccess(role: Role)
  9725. * setRoleUpdateAccess(role: Role, allowed: boolean)
  9726. * getDeleteRequiresAuthentication()
  9727. * setDeleteRequiresAuthentication(allowed: boolean)
  9728. * getDeletePointerFields()
  9729. * setDeletePointerFields(pointerFields: string[])
  9730. * getDeleteAccess(entity: Entity)
  9731. * setDeleteAccess(entity: Entity, allowed: boolean)
  9732. * getPublicDeleteAccess()
  9733. * setPublicDeleteAccess(allowed: boolean)
  9734. * getRoleDeleteAccess(role: Role)
  9735. * setRoleDeleteAccess(role: Role, allowed: boolean)
  9736. * getAddFieldRequiresAuthentication()
  9737. * setAddFieldRequiresAuthentication(allowed: boolean)
  9738. * getAddFieldPointerFields()
  9739. * setAddFieldPointerFields(pointerFields: string[])
  9740. * getAddFieldAccess(entity: Entity)
  9741. * setAddFieldAccess(entity: Entity, allowed: boolean)
  9742. * getPublicAddFieldAccess()
  9743. * setPublicAddFieldAccess(allowed: boolean)
  9744. * getRoleAddFieldAccess(role: Role)
  9745. * setRoleAddFieldAccess(role: Role, allowed: boolean)
  9746. * </p>
  9747. *
  9748. * @alias Parse.CLP
  9749. */
  9750. var ParseCLP = /*#__PURE__*/function () {
  9751. /**
  9752. * @param {(Parse.User | Parse.Role | object)} userId The user to initialize the CLP for
  9753. */
  9754. function ParseCLP(userId
  9755. /*: ParseUser | ParseRole | PermissionsMap*/
  9756. ) {
  9757. var _this = this;
  9758. (0, _classCallCheck2.default)(this, ParseCLP);
  9759. (0, _defineProperty2.default)(this, "permissionsMap", void 0);
  9760. this.permissionsMap = {}; // Initialize permissions Map with default permissions
  9761. var _iterator = _createForOfIteratorHelper((0, _entries.default)(VALID_PERMISSIONS).call(VALID_PERMISSIONS)),
  9762. _step;
  9763. try {
  9764. var _loop = function () {
  9765. var _step$value = (0, _slicedToArray2.default)(_step.value, 2),
  9766. operation = _step$value[0],
  9767. group = _step$value[1];
  9768. _this.permissionsMap[operation] = _objectSpread({}, group);
  9769. var action = operation.charAt(0).toUpperCase() + (0, _slice.default)(operation).call(operation, 1);
  9770. _this["get".concat(action, "RequiresAuthentication")] = function () {
  9771. return this._getAccess(operation, 'requiresAuthentication');
  9772. };
  9773. _this["set".concat(action, "RequiresAuthentication")] = function (allowed) {
  9774. this._setAccess(operation, 'requiresAuthentication', allowed);
  9775. };
  9776. _this["get".concat(action, "PointerFields")] = function () {
  9777. return this._getAccess(operation, 'pointerFields', false);
  9778. };
  9779. _this["set".concat(action, "PointerFields")] = function (pointerFields) {
  9780. this._setArrayAccess(operation, 'pointerFields', pointerFields);
  9781. };
  9782. _this["get".concat(action, "Access")] = function (entity) {
  9783. return this._getAccess(operation, entity);
  9784. };
  9785. _this["set".concat(action, "Access")] = function (entity, allowed) {
  9786. this._setAccess(operation, entity, allowed);
  9787. };
  9788. _this["getPublic".concat(action, "Access")] = function () {
  9789. return this["get".concat(action, "Access")](PUBLIC_KEY);
  9790. };
  9791. _this["setPublic".concat(action, "Access")] = function (allowed) {
  9792. this["set".concat(action, "Access")](PUBLIC_KEY, allowed);
  9793. };
  9794. _this["getRole".concat(action, "Access")] = function (role) {
  9795. return this["get".concat(action, "Access")](this._getRoleName(role));
  9796. };
  9797. _this["setRole".concat(action, "Access")] = function (role, allowed) {
  9798. this["set".concat(action, "Access")](this._getRoleName(role), allowed);
  9799. };
  9800. };
  9801. for (_iterator.s(); !(_step = _iterator.n()).done;) {
  9802. _loop();
  9803. } // Initialize permissions Map with default extended permissions
  9804. } catch (err) {
  9805. _iterator.e(err);
  9806. } finally {
  9807. _iterator.f();
  9808. }
  9809. var _iterator2 = _createForOfIteratorHelper((0, _entries.default)(VALID_PERMISSIONS_EXTENDED).call(VALID_PERMISSIONS_EXTENDED)),
  9810. _step2;
  9811. try {
  9812. for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
  9813. var _step2$value = (0, _slicedToArray2.default)(_step2.value, 2),
  9814. operation = _step2$value[0],
  9815. group = _step2$value[1];
  9816. this.permissionsMap[operation] = _objectSpread({}, group);
  9817. }
  9818. } catch (err) {
  9819. _iterator2.e(err);
  9820. } finally {
  9821. _iterator2.f();
  9822. }
  9823. if (userId && (0, _typeof2.default)(userId) === 'object') {
  9824. if (userId instanceof _ParseUser.default) {
  9825. this.setReadAccess(userId, true);
  9826. this.setWriteAccess(userId, true);
  9827. } else if (userId instanceof _ParseRole.default) {
  9828. this.setRoleReadAccess(userId, true);
  9829. this.setRoleWriteAccess(userId, true);
  9830. } else {
  9831. for (var _permission in userId) {
  9832. var _context;
  9833. var users = userId[_permission];
  9834. var isValidPermission = !!VALID_PERMISSIONS.get(_permission);
  9835. var isValidPermissionExtended = !!VALID_PERMISSIONS_EXTENDED.get(_permission);
  9836. var isValidGroupPermission = (0, _includes.default)(_context = ['readUserFields', 'writeUserFields']).call(_context, _permission);
  9837. if (typeof _permission !== 'string' || !(isValidPermission || isValidPermissionExtended || isValidGroupPermission)) {
  9838. throw new TypeError('Tried to create an CLP with an invalid permission type.');
  9839. }
  9840. if (isValidGroupPermission) {
  9841. if ((0, _every.default)(users).call(users, function (pointer) {
  9842. return typeof pointer === 'string';
  9843. })) {
  9844. this.permissionsMap[_permission] = users;
  9845. continue;
  9846. } else {
  9847. throw new TypeError('Tried to create an CLP with an invalid permission value.');
  9848. }
  9849. }
  9850. for (var user in users) {
  9851. var allowed = users[user];
  9852. if (typeof allowed !== 'boolean' && !isValidPermissionExtended && user !== 'pointerFields') {
  9853. throw new TypeError('Tried to create an CLP with an invalid permission value.');
  9854. }
  9855. this.permissionsMap[_permission][user] = allowed;
  9856. }
  9857. }
  9858. }
  9859. } else if (typeof userId === 'function') {
  9860. throw new TypeError('ParseCLP constructed with a function. Did you forget ()?');
  9861. }
  9862. }
  9863. /**
  9864. * Returns a JSON-encoded version of the CLP.
  9865. *
  9866. * @returns {object}
  9867. */
  9868. (0, _createClass2.default)(ParseCLP, [{
  9869. key: "toJSON",
  9870. value: function ()
  9871. /*: PermissionsMap*/
  9872. {
  9873. return _objectSpread({}, this.permissionsMap);
  9874. }
  9875. /**
  9876. * Returns whether this CLP is equal to another object
  9877. *
  9878. * @param other The other object to compare to
  9879. * @returns {boolean}
  9880. */
  9881. }, {
  9882. key: "equals",
  9883. value: function (other
  9884. /*: ParseCLP*/
  9885. )
  9886. /*: boolean*/
  9887. {
  9888. if (!(other instanceof ParseCLP)) {
  9889. return false;
  9890. }
  9891. var permissions = (0, _keys.default)(this.permissionsMap);
  9892. var otherPermissions = (0, _keys.default)(other.permissionsMap);
  9893. if (permissions.length !== otherPermissions.length) {
  9894. return false;
  9895. }
  9896. for (var _permission2 in this.permissionsMap) {
  9897. if (!other.permissionsMap[_permission2]) {
  9898. return false;
  9899. }
  9900. var users = (0, _keys.default)(this.permissionsMap[_permission2]);
  9901. var otherUsers = (0, _keys.default)(other.permissionsMap[_permission2]);
  9902. if (users.length !== otherUsers.length) {
  9903. return false;
  9904. }
  9905. for (var user in this.permissionsMap[_permission2]) {
  9906. if (!other.permissionsMap[_permission2][user]) {
  9907. return false;
  9908. }
  9909. if (this.permissionsMap[_permission2][user] !== other.permissionsMap[_permission2][user]) {
  9910. return false;
  9911. }
  9912. }
  9913. }
  9914. return true;
  9915. }
  9916. }, {
  9917. key: "_getRoleName",
  9918. value: function (role
  9919. /*: ParseRole | string*/
  9920. )
  9921. /*: string*/
  9922. {
  9923. var name = role;
  9924. if (role instanceof _ParseRole.default) {
  9925. // Normalize to the String name
  9926. name = role.getName();
  9927. }
  9928. if (typeof name !== 'string') {
  9929. throw new TypeError('role must be a Parse.Role or a String');
  9930. }
  9931. return "role:".concat(name);
  9932. }
  9933. }, {
  9934. key: "_parseEntity",
  9935. value: function (entity
  9936. /*: Entity*/
  9937. ) {
  9938. var userId = entity;
  9939. if (userId instanceof _ParseUser.default) {
  9940. userId = userId.id;
  9941. if (!userId) {
  9942. throw new Error('Cannot get access for a Parse.User without an id.');
  9943. }
  9944. } else if (userId instanceof _ParseRole.default) {
  9945. userId = this._getRoleName(userId);
  9946. }
  9947. if (typeof userId !== 'string') {
  9948. throw new TypeError('userId must be a string.');
  9949. }
  9950. return userId;
  9951. }
  9952. }, {
  9953. key: "_setAccess",
  9954. value: function (permission
  9955. /*: string*/
  9956. , userId
  9957. /*: Entity*/
  9958. , allowed
  9959. /*: boolean*/
  9960. ) {
  9961. userId = this._parseEntity(userId);
  9962. if (typeof allowed !== 'boolean') {
  9963. throw new TypeError('allowed must be either true or false.');
  9964. }
  9965. var permissions = this.permissionsMap[permission][userId];
  9966. if (!permissions) {
  9967. if (!allowed) {
  9968. // The user already doesn't have this permission, so no action is needed
  9969. return;
  9970. }
  9971. this.permissionsMap[permission][userId] = {};
  9972. }
  9973. if (allowed) {
  9974. this.permissionsMap[permission][userId] = true;
  9975. } else {
  9976. delete this.permissionsMap[permission][userId];
  9977. }
  9978. }
  9979. }, {
  9980. key: "_getAccess",
  9981. value: function (permission
  9982. /*: string*/
  9983. , userId
  9984. /*: Entity*/
  9985. )
  9986. /*: boolean | string[]*/
  9987. {
  9988. var returnBoolean = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : true;
  9989. userId = this._parseEntity(userId);
  9990. var permissions = this.permissionsMap[permission][userId];
  9991. if (returnBoolean) {
  9992. if (!permissions) {
  9993. return false;
  9994. }
  9995. return !!this.permissionsMap[permission][userId];
  9996. }
  9997. return permissions;
  9998. }
  9999. }, {
  10000. key: "_setArrayAccess",
  10001. value: function (permission
  10002. /*: string*/
  10003. , userId
  10004. /*: Entity*/
  10005. , fields
  10006. /*: string*/
  10007. ) {
  10008. userId = this._parseEntity(userId);
  10009. var permissions = this.permissionsMap[permission][userId];
  10010. if (!permissions) {
  10011. this.permissionsMap[permission][userId] = [];
  10012. }
  10013. if (!fields || (0, _isArray.default)(fields) && fields.length === 0) {
  10014. delete this.permissionsMap[permission][userId];
  10015. } else if ((0, _isArray.default)(fields) && (0, _every.default)(fields).call(fields, function (field) {
  10016. return typeof field === 'string';
  10017. })) {
  10018. this.permissionsMap[permission][userId] = fields;
  10019. } else {
  10020. throw new TypeError('fields must be an array of strings or undefined.');
  10021. }
  10022. }
  10023. }, {
  10024. key: "_setGroupPointerPermission",
  10025. value: function (operation
  10026. /*: string*/
  10027. , pointerFields
  10028. /*: string[]*/
  10029. ) {
  10030. var fields = this.permissionsMap[operation];
  10031. if (!fields) {
  10032. this.permissionsMap[operation] = [];
  10033. }
  10034. if (!pointerFields || (0, _isArray.default)(pointerFields) && pointerFields.length === 0) {
  10035. delete this.permissionsMap[operation];
  10036. } else if ((0, _isArray.default)(pointerFields) && (0, _every.default)(pointerFields).call(pointerFields, function (field) {
  10037. return typeof field === 'string';
  10038. })) {
  10039. this.permissionsMap[operation] = pointerFields;
  10040. } else {
  10041. throw new TypeError("".concat(operation, ".pointerFields must be an array of strings or undefined."));
  10042. }
  10043. }
  10044. }, {
  10045. key: "_getGroupPointerPermissions",
  10046. value: function (operation
  10047. /*: string*/
  10048. )
  10049. /*: string[]*/
  10050. {
  10051. return this.permissionsMap[operation];
  10052. }
  10053. /**
  10054. * Sets user pointer fields to allow permission for get/count/find operations.
  10055. *
  10056. * @param {string[]} pointerFields User pointer fields
  10057. */
  10058. }, {
  10059. key: "setReadUserFields",
  10060. value: function (pointerFields
  10061. /*: string[]*/
  10062. ) {
  10063. this._setGroupPointerPermission('readUserFields', pointerFields);
  10064. }
  10065. /**
  10066. * @returns {string[]} User pointer fields
  10067. */
  10068. }, {
  10069. key: "getReadUserFields",
  10070. value: function ()
  10071. /*: string[]*/
  10072. {
  10073. return this._getGroupPointerPermissions('readUserFields');
  10074. }
  10075. /**
  10076. * Sets user pointer fields to allow permission for create/delete/update/addField operations
  10077. *
  10078. * @param {string[]} pointerFields User pointer fields
  10079. */
  10080. }, {
  10081. key: "setWriteUserFields",
  10082. value: function (pointerFields
  10083. /*: string[]*/
  10084. ) {
  10085. this._setGroupPointerPermission('writeUserFields', pointerFields);
  10086. }
  10087. /**
  10088. * @returns {string[]} User pointer fields
  10089. */
  10090. }, {
  10091. key: "getWriteUserFields",
  10092. value: function ()
  10093. /*: string[]*/
  10094. {
  10095. return this._getGroupPointerPermissions('writeUserFields');
  10096. }
  10097. /**
  10098. * Sets whether the given user is allowed to retrieve fields from this class.
  10099. *
  10100. * @param userId An instance of Parse.User or its objectId.
  10101. * @param {string[]} fields fields to be protected
  10102. */
  10103. }, {
  10104. key: "setProtectedFields",
  10105. value: function (userId
  10106. /*: Entity*/
  10107. , fields
  10108. /*: string[]*/
  10109. ) {
  10110. this._setArrayAccess('protectedFields', userId, fields);
  10111. }
  10112. /**
  10113. * Returns array of fields are accessable to this user.
  10114. *
  10115. * @param userId An instance of Parse.User or its objectId, or a Parse.Role.
  10116. * @returns {string[]}
  10117. */
  10118. }, {
  10119. key: "getProtectedFields",
  10120. value: function (userId
  10121. /*: Entity*/
  10122. )
  10123. /*: string[]*/
  10124. {
  10125. return this._getAccess('protectedFields', userId, false);
  10126. }
  10127. /**
  10128. * Sets whether the given user is allowed to read from this class.
  10129. *
  10130. * @param userId An instance of Parse.User or its objectId.
  10131. * @param {boolean} allowed whether that user should have read access.
  10132. */
  10133. }, {
  10134. key: "setReadAccess",
  10135. value: function (userId
  10136. /*: Entity*/
  10137. , allowed
  10138. /*: boolean*/
  10139. ) {
  10140. this._setAccess('find', userId, allowed);
  10141. this._setAccess('get', userId, allowed);
  10142. this._setAccess('count', userId, allowed);
  10143. }
  10144. /**
  10145. * Get whether the given user id is *explicitly* allowed to read from this class.
  10146. * Even if this returns false, the user may still be able to access it if
  10147. * getPublicReadAccess returns true or a role that the user belongs to has
  10148. * write access.
  10149. *
  10150. * @param userId An instance of Parse.User or its objectId, or a Parse.Role.
  10151. * @returns {boolean}
  10152. */
  10153. }, {
  10154. key: "getReadAccess",
  10155. value: function (userId
  10156. /*: Entity*/
  10157. )
  10158. /*: boolean*/
  10159. {
  10160. return this._getAccess('find', userId) && this._getAccess('get', userId) && this._getAccess('count', userId);
  10161. }
  10162. /**
  10163. * Sets whether the given user id is allowed to write to this class.
  10164. *
  10165. * @param userId An instance of Parse.User or its objectId, or a Parse.Role..
  10166. * @param {boolean} allowed Whether that user should have write access.
  10167. */
  10168. }, {
  10169. key: "setWriteAccess",
  10170. value: function (userId
  10171. /*: Entity*/
  10172. , allowed
  10173. /*: boolean*/
  10174. ) {
  10175. this._setAccess('create', userId, allowed);
  10176. this._setAccess('update', userId, allowed);
  10177. this._setAccess('delete', userId, allowed);
  10178. this._setAccess('addField', userId, allowed);
  10179. }
  10180. /**
  10181. * Gets whether the given user id is *explicitly* allowed to write to this class.
  10182. * Even if this returns false, the user may still be able to write it if
  10183. * getPublicWriteAccess returns true or a role that the user belongs to has
  10184. * write access.
  10185. *
  10186. * @param userId An instance of Parse.User or its objectId, or a Parse.Role.
  10187. * @returns {boolean}
  10188. */
  10189. }, {
  10190. key: "getWriteAccess",
  10191. value: function (userId
  10192. /*: Entity*/
  10193. )
  10194. /*: boolean*/
  10195. {
  10196. return this._getAccess('create', userId) && this._getAccess('update', userId) && this._getAccess('delete', userId) && this._getAccess('addField', userId);
  10197. }
  10198. /**
  10199. * Sets whether the public is allowed to read from this class.
  10200. *
  10201. * @param {boolean} allowed
  10202. */
  10203. }, {
  10204. key: "setPublicReadAccess",
  10205. value: function (allowed
  10206. /*: boolean*/
  10207. ) {
  10208. this.setReadAccess(PUBLIC_KEY, allowed);
  10209. }
  10210. /**
  10211. * Gets whether the public is allowed to read from this class.
  10212. *
  10213. * @returns {boolean}
  10214. */
  10215. }, {
  10216. key: "getPublicReadAccess",
  10217. value: function ()
  10218. /*: boolean*/
  10219. {
  10220. return this.getReadAccess(PUBLIC_KEY);
  10221. }
  10222. /**
  10223. * Sets whether the public is allowed to write to this class.
  10224. *
  10225. * @param {boolean} allowed
  10226. */
  10227. }, {
  10228. key: "setPublicWriteAccess",
  10229. value: function (allowed
  10230. /*: boolean*/
  10231. ) {
  10232. this.setWriteAccess(PUBLIC_KEY, allowed);
  10233. }
  10234. /**
  10235. * Gets whether the public is allowed to write to this class.
  10236. *
  10237. * @returns {boolean}
  10238. */
  10239. }, {
  10240. key: "getPublicWriteAccess",
  10241. value: function ()
  10242. /*: boolean*/
  10243. {
  10244. return this.getWriteAccess(PUBLIC_KEY);
  10245. }
  10246. /**
  10247. * Sets whether the public is allowed to protect fields in this class.
  10248. *
  10249. * @param {string[]} fields
  10250. */
  10251. }, {
  10252. key: "setPublicProtectedFields",
  10253. value: function (fields
  10254. /*: string[]*/
  10255. ) {
  10256. this.setProtectedFields(PUBLIC_KEY, fields);
  10257. }
  10258. /**
  10259. * Gets whether the public is allowed to read fields from this class.
  10260. *
  10261. * @returns {string[]}
  10262. */
  10263. }, {
  10264. key: "getPublicProtectedFields",
  10265. value: function ()
  10266. /*: string[]*/
  10267. {
  10268. return this.getProtectedFields(PUBLIC_KEY);
  10269. }
  10270. /**
  10271. * Gets whether users belonging to the given role are allowed
  10272. * to read from this class. Even if this returns false, the role may
  10273. * still be able to write it if a parent role has read access.
  10274. *
  10275. * @param role The name of the role, or a Parse.Role object.
  10276. * @returns {boolean} true if the role has read access. false otherwise.
  10277. * @throws {TypeError} If role is neither a Parse.Role nor a String.
  10278. */
  10279. }, {
  10280. key: "getRoleReadAccess",
  10281. value: function (role
  10282. /*: ParseRole | string*/
  10283. )
  10284. /*: boolean*/
  10285. {
  10286. return this.getReadAccess(this._getRoleName(role));
  10287. }
  10288. /**
  10289. * Gets whether users belonging to the given role are allowed
  10290. * to write to this user. Even if this returns false, the role may
  10291. * still be able to write it if a parent role has write access.
  10292. *
  10293. * @param role The name of the role, or a Parse.Role object.
  10294. * @returns {boolean} true if the role has write access. false otherwise.
  10295. * @throws {TypeError} If role is neither a Parse.Role nor a String.
  10296. */
  10297. }, {
  10298. key: "getRoleWriteAccess",
  10299. value: function (role
  10300. /*: ParseRole | string*/
  10301. )
  10302. /*: boolean*/
  10303. {
  10304. return this.getWriteAccess(this._getRoleName(role));
  10305. }
  10306. /**
  10307. * Sets whether users belonging to the given role are allowed
  10308. * to read from this class.
  10309. *
  10310. * @param role The name of the role, or a Parse.Role object.
  10311. * @param {boolean} allowed Whether the given role can read this object.
  10312. * @throws {TypeError} If role is neither a Parse.Role nor a String.
  10313. */
  10314. }, {
  10315. key: "setRoleReadAccess",
  10316. value: function (role
  10317. /*: ParseRole | string*/
  10318. , allowed
  10319. /*: boolean*/
  10320. ) {
  10321. this.setReadAccess(this._getRoleName(role), allowed);
  10322. }
  10323. /**
  10324. * Sets whether users belonging to the given role are allowed
  10325. * to write to this class.
  10326. *
  10327. * @param role The name of the role, or a Parse.Role object.
  10328. * @param {boolean} allowed Whether the given role can write this object.
  10329. * @throws {TypeError} If role is neither a Parse.Role nor a String.
  10330. */
  10331. }, {
  10332. key: "setRoleWriteAccess",
  10333. value: function (role
  10334. /*: ParseRole | string*/
  10335. , allowed
  10336. /*: boolean*/
  10337. ) {
  10338. this.setWriteAccess(this._getRoleName(role), allowed);
  10339. }
  10340. /**
  10341. * Gets whether users belonging to the given role are allowed
  10342. * to count to this user. Even if this returns false, the role may
  10343. * still be able to count it if a parent role has count access.
  10344. *
  10345. * @param role The name of the role, or a Parse.Role object.
  10346. * @returns {string[]}
  10347. * @throws {TypeError} If role is neither a Parse.Role nor a String.
  10348. */
  10349. }, {
  10350. key: "getRoleProtectedFields",
  10351. value: function (role
  10352. /*: ParseRole | string*/
  10353. )
  10354. /*: string[]*/
  10355. {
  10356. return this.getProtectedFields(this._getRoleName(role));
  10357. }
  10358. /**
  10359. * Sets whether users belonging to the given role are allowed
  10360. * to set access field in this class.
  10361. *
  10362. * @param role The name of the role, or a Parse.Role object.
  10363. * @param {string[]} fields Fields to be protected by Role.
  10364. * @throws {TypeError} If role is neither a Parse.Role nor a String.
  10365. */
  10366. }, {
  10367. key: "setRoleProtectedFields",
  10368. value: function (role
  10369. /*: ParseRole | string*/
  10370. , fields
  10371. /*: string[]*/
  10372. ) {
  10373. this.setProtectedFields(this._getRoleName(role), fields);
  10374. }
  10375. }]);
  10376. return ParseCLP;
  10377. }();
  10378. var _default = ParseCLP;
  10379. exports.default = _default;
  10380. },{"./ParseRole":41,"./ParseUser":44,"@babel/runtime-corejs3/core-js-stable/array/from":78,"@babel/runtime-corejs3/core-js-stable/array/is-array":79,"@babel/runtime-corejs3/core-js-stable/instance/entries":82,"@babel/runtime-corejs3/core-js-stable/instance/every":83,"@babel/runtime-corejs3/core-js-stable/instance/filter":84,"@babel/runtime-corejs3/core-js-stable/instance/for-each":86,"@babel/runtime-corejs3/core-js-stable/instance/includes":87,"@babel/runtime-corejs3/core-js-stable/instance/slice":93,"@babel/runtime-corejs3/core-js-stable/map":100,"@babel/runtime-corejs3/core-js-stable/object/define-properties":104,"@babel/runtime-corejs3/core-js-stable/object/define-property":105,"@babel/runtime-corejs3/core-js-stable/object/get-own-property-descriptor":108,"@babel/runtime-corejs3/core-js-stable/object/get-own-property-descriptors":109,"@babel/runtime-corejs3/core-js-stable/object/get-own-property-symbols":110,"@babel/runtime-corejs3/core-js-stable/object/keys":112,"@babel/runtime-corejs3/core-js-stable/symbol":119,"@babel/runtime-corejs3/core-js/get-iterator-method":125,"@babel/runtime-corejs3/helpers/classCallCheck":145,"@babel/runtime-corejs3/helpers/createClass":147,"@babel/runtime-corejs3/helpers/defineProperty":148,"@babel/runtime-corejs3/helpers/interopRequireDefault":152,"@babel/runtime-corejs3/helpers/slicedToArray":161,"@babel/runtime-corejs3/helpers/typeof":164}],28:[function(_dereq_,module,exports){
  10381. "use strict";
  10382. var _Object$defineProperty = _dereq_("@babel/runtime-corejs3/core-js-stable/object/define-property");
  10383. var _interopRequireDefault = _dereq_("@babel/runtime-corejs3/helpers/interopRequireDefault");
  10384. _Object$defineProperty(exports, "__esModule", {
  10385. value: true
  10386. });
  10387. exports.default = void 0;
  10388. var _promise = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/promise"));
  10389. var _stringify = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/json/stringify"));
  10390. var _typeof2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/helpers/typeof"));
  10391. var _classCallCheck2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/helpers/classCallCheck"));
  10392. var _createClass2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/helpers/createClass"));
  10393. var _defineProperty2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/helpers/defineProperty"));
  10394. var _CoreManager = _interopRequireDefault(_dereq_("./CoreManager"));
  10395. var _decode = _interopRequireDefault(_dereq_("./decode"));
  10396. var _encode = _interopRequireDefault(_dereq_("./encode"));
  10397. var _escape2 = _interopRequireDefault(_dereq_("./escape"));
  10398. var _ParseError = _interopRequireDefault(_dereq_("./ParseError"));
  10399. var _Storage = _interopRequireDefault(_dereq_("./Storage"));
  10400. /**
  10401. * Copyright (c) 2015-present, Parse, LLC.
  10402. * All rights reserved.
  10403. *
  10404. * This source code is licensed under the BSD-style license found in the
  10405. * LICENSE file in the root directory of this source tree. An additional grant
  10406. * of patent rights can be found in the PATENTS file in the same directory.
  10407. *
  10408. * @flow
  10409. */
  10410. /**
  10411. * Parse.Config is a local representation of configuration data that
  10412. * can be set from the Parse dashboard.
  10413. *
  10414. * @alias Parse.Config
  10415. */
  10416. var ParseConfig = /*#__PURE__*/function () {
  10417. function ParseConfig() {
  10418. (0, _classCallCheck2.default)(this, ParseConfig);
  10419. (0, _defineProperty2.default)(this, "attributes", void 0);
  10420. (0, _defineProperty2.default)(this, "_escapedAttributes", void 0);
  10421. this.attributes = {};
  10422. this._escapedAttributes = {};
  10423. }
  10424. /**
  10425. * Gets the value of an attribute.
  10426. *
  10427. * @param {string} attr The name of an attribute.
  10428. * @returns {*}
  10429. */
  10430. (0, _createClass2.default)(ParseConfig, [{
  10431. key: "get",
  10432. value: function (attr
  10433. /*: string*/
  10434. )
  10435. /*: any*/
  10436. {
  10437. return this.attributes[attr];
  10438. }
  10439. /**
  10440. * Gets the HTML-escaped value of an attribute.
  10441. *
  10442. * @param {string} attr The name of an attribute.
  10443. * @returns {string}
  10444. */
  10445. }, {
  10446. key: "escape",
  10447. value: function (attr
  10448. /*: string*/
  10449. )
  10450. /*: string*/
  10451. {
  10452. var html = this._escapedAttributes[attr];
  10453. if (html) {
  10454. return html;
  10455. }
  10456. var val = this.attributes[attr];
  10457. var escaped = '';
  10458. if (val != null) {
  10459. escaped = (0, _escape2.default)(val.toString());
  10460. }
  10461. this._escapedAttributes[attr] = escaped;
  10462. return escaped;
  10463. }
  10464. /**
  10465. * Retrieves the most recently-fetched configuration object, either from
  10466. * memory or from local storage if necessary.
  10467. *
  10468. * @static
  10469. * @returns {Parse.Config} The most recently-fetched Parse.Config if it
  10470. * exists, else an empty Parse.Config.
  10471. */
  10472. }], [{
  10473. key: "current",
  10474. value: function () {
  10475. var controller = _CoreManager.default.getConfigController();
  10476. return controller.current();
  10477. }
  10478. /**
  10479. * Gets a new configuration object from the server.
  10480. *
  10481. * @static
  10482. * @param {object} options
  10483. * Valid options are:<ul>
  10484. * <li>useMasterKey: In Cloud Code and Node only, causes the Master Key to
  10485. * be used for this request.
  10486. * </ul>
  10487. * @returns {Promise} A promise that is resolved with a newly-created
  10488. * configuration object when the get completes.
  10489. */
  10490. }, {
  10491. key: "get",
  10492. value: function () {
  10493. var options
  10494. /*: RequestOptions*/
  10495. = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
  10496. var controller = _CoreManager.default.getConfigController();
  10497. return controller.get(options);
  10498. }
  10499. /**
  10500. * Save value keys to the server.
  10501. *
  10502. * @static
  10503. * @param {object} attrs The config parameters and values.
  10504. * @param {object} masterKeyOnlyFlags The flags that define whether config parameters listed
  10505. * in `attrs` should be retrievable only by using the master key.
  10506. * For example: `param1: true` makes `param1` only retrievable by using the master key.
  10507. * If a parameter is not provided or set to `false`, it can be retrieved without
  10508. * using the master key.
  10509. * @returns {Promise} A promise that is resolved with a newly-created
  10510. * configuration object or with the current with the update.
  10511. */
  10512. }, {
  10513. key: "save",
  10514. value: function (attrs
  10515. /*: { [key: string]: any }*/
  10516. , masterKeyOnlyFlags
  10517. /*: { [key: string]: any }*/
  10518. ) {
  10519. var controller = _CoreManager.default.getConfigController(); // To avoid a mismatch with the local and the cloud config we get a new version
  10520. return controller.save(attrs, masterKeyOnlyFlags).then(function () {
  10521. return controller.get({
  10522. useMasterKey: true
  10523. });
  10524. }, function (error) {
  10525. return _promise.default.reject(error);
  10526. });
  10527. }
  10528. /**
  10529. * Used for testing
  10530. *
  10531. * @private
  10532. */
  10533. }, {
  10534. key: "_clearCache",
  10535. value: function () {
  10536. currentConfig = null;
  10537. }
  10538. }]);
  10539. return ParseConfig;
  10540. }();
  10541. var currentConfig = null;
  10542. var CURRENT_CONFIG_KEY = 'currentConfig';
  10543. function decodePayload(data) {
  10544. try {
  10545. var json = JSON.parse(data);
  10546. if (json && (0, _typeof2.default)(json) === 'object') {
  10547. return (0, _decode.default)(json);
  10548. }
  10549. } catch (e) {
  10550. return null;
  10551. }
  10552. }
  10553. var DefaultController = {
  10554. current: function () {
  10555. if (currentConfig) {
  10556. return currentConfig;
  10557. }
  10558. var config = new ParseConfig();
  10559. var storagePath = _Storage.default.generatePath(CURRENT_CONFIG_KEY);
  10560. if (!_Storage.default.async()) {
  10561. var configData = _Storage.default.getItem(storagePath);
  10562. if (configData) {
  10563. var attributes = decodePayload(configData);
  10564. if (attributes) {
  10565. config.attributes = attributes;
  10566. currentConfig = config;
  10567. }
  10568. }
  10569. return config;
  10570. } // Return a promise for async storage controllers
  10571. return _Storage.default.getItemAsync(storagePath).then(function (configData) {
  10572. if (configData) {
  10573. var _attributes = decodePayload(configData);
  10574. if (_attributes) {
  10575. config.attributes = _attributes;
  10576. currentConfig = config;
  10577. }
  10578. }
  10579. return config;
  10580. });
  10581. },
  10582. get: function () {
  10583. var options
  10584. /*: RequestOptions*/
  10585. = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
  10586. var RESTController = _CoreManager.default.getRESTController();
  10587. return RESTController.request('GET', 'config', {}, options).then(function (response) {
  10588. if (!response || !response.params) {
  10589. var error = new _ParseError.default(_ParseError.default.INVALID_JSON, 'Config JSON response invalid.');
  10590. return _promise.default.reject(error);
  10591. }
  10592. var config = new ParseConfig();
  10593. config.attributes = {};
  10594. for (var attr in response.params) {
  10595. config.attributes[attr] = (0, _decode.default)(response.params[attr]);
  10596. }
  10597. currentConfig = config;
  10598. return _Storage.default.setItemAsync(_Storage.default.generatePath(CURRENT_CONFIG_KEY), (0, _stringify.default)(response.params)).then(function () {
  10599. return config;
  10600. });
  10601. });
  10602. },
  10603. save: function (attrs
  10604. /*: { [key: string]: any }*/
  10605. , masterKeyOnlyFlags
  10606. /*: { [key: string]: any }*/
  10607. ) {
  10608. var RESTController = _CoreManager.default.getRESTController();
  10609. var encodedAttrs = {};
  10610. for (var _key in attrs) {
  10611. encodedAttrs[_key] = (0, _encode.default)(attrs[_key]);
  10612. }
  10613. return RESTController.request('PUT', 'config', {
  10614. params: encodedAttrs,
  10615. masterKeyOnly: masterKeyOnlyFlags
  10616. }, {
  10617. useMasterKey: true
  10618. }).then(function (response) {
  10619. if (response && response.result) {
  10620. return _promise.default.resolve();
  10621. }
  10622. var error = new _ParseError.default(_ParseError.default.INTERNAL_SERVER_ERROR, 'Error occured updating Config.');
  10623. return _promise.default.reject(error);
  10624. });
  10625. }
  10626. };
  10627. _CoreManager.default.setConfigController(DefaultController);
  10628. var _default = ParseConfig;
  10629. exports.default = _default;
  10630. },{"./CoreManager":5,"./ParseError":29,"./Storage":48,"./decode":65,"./encode":66,"./escape":68,"@babel/runtime-corejs3/core-js-stable/json/stringify":99,"@babel/runtime-corejs3/core-js-stable/object/define-property":105,"@babel/runtime-corejs3/core-js-stable/promise":115,"@babel/runtime-corejs3/helpers/classCallCheck":145,"@babel/runtime-corejs3/helpers/createClass":147,"@babel/runtime-corejs3/helpers/defineProperty":148,"@babel/runtime-corejs3/helpers/interopRequireDefault":152,"@babel/runtime-corejs3/helpers/typeof":164}],29:[function(_dereq_,module,exports){
  10631. "use strict";
  10632. var _Reflect$construct = _dereq_("@babel/runtime-corejs3/core-js-stable/reflect/construct");
  10633. var _Object$defineProperty2 = _dereq_("@babel/runtime-corejs3/core-js-stable/object/define-property");
  10634. var _interopRequireDefault = _dereq_("@babel/runtime-corejs3/helpers/interopRequireDefault");
  10635. _Object$defineProperty2(exports, "__esModule", {
  10636. value: true
  10637. });
  10638. exports.default = void 0;
  10639. var _defineProperty = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/object/define-property"));
  10640. var _concat = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/instance/concat"));
  10641. var _classCallCheck2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/helpers/classCallCheck"));
  10642. var _createClass2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/helpers/createClass"));
  10643. var _assertThisInitialized2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/helpers/assertThisInitialized"));
  10644. var _inherits2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/helpers/inherits"));
  10645. var _possibleConstructorReturn2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/helpers/possibleConstructorReturn"));
  10646. var _getPrototypeOf2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/helpers/getPrototypeOf"));
  10647. var _wrapNativeSuper2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/helpers/wrapNativeSuper"));
  10648. function _createSuper(Derived) {
  10649. var hasNativeReflectConstruct = _isNativeReflectConstruct();
  10650. return function () {
  10651. var Super = (0, _getPrototypeOf2.default)(Derived),
  10652. result;
  10653. if (hasNativeReflectConstruct) {
  10654. var NewTarget = (0, _getPrototypeOf2.default)(this).constructor;
  10655. result = _Reflect$construct(Super, arguments, NewTarget);
  10656. } else {
  10657. result = Super.apply(this, arguments);
  10658. }
  10659. return (0, _possibleConstructorReturn2.default)(this, result);
  10660. };
  10661. }
  10662. function _isNativeReflectConstruct() {
  10663. if (typeof Reflect === "undefined" || !_Reflect$construct) return false;
  10664. if (_Reflect$construct.sham) return false;
  10665. if (typeof Proxy === "function") return true;
  10666. try {
  10667. Boolean.prototype.valueOf.call(_Reflect$construct(Boolean, [], function () {}));
  10668. return true;
  10669. } catch (e) {
  10670. return false;
  10671. }
  10672. }
  10673. /**
  10674. * Copyright (c) 2015-present, Parse, LLC.
  10675. * All rights reserved.
  10676. *
  10677. * This source code is licensed under the BSD-style license found in the
  10678. * LICENSE file in the root directory of this source tree. An additional grant
  10679. * of patent rights can be found in the PATENTS file in the same directory.
  10680. */
  10681. /**
  10682. * Constructs a new Parse.Error object with the given code and message.
  10683. *
  10684. * @alias Parse.Error
  10685. */
  10686. var ParseError = /*#__PURE__*/function (_Error) {
  10687. (0, _inherits2.default)(ParseError, _Error);
  10688. var _super = _createSuper(ParseError);
  10689. /**
  10690. * @param {number} code An error code constant from <code>Parse.Error</code>.
  10691. * @param {string} message A detailed description of the error.
  10692. */
  10693. function ParseError(code, message) {
  10694. var _this;
  10695. (0, _classCallCheck2.default)(this, ParseError);
  10696. _this = _super.call(this, message);
  10697. _this.code = code;
  10698. (0, _defineProperty.default)((0, _assertThisInitialized2.default)(_this), 'message', {
  10699. enumerable: true,
  10700. value: message
  10701. });
  10702. return _this;
  10703. }
  10704. (0, _createClass2.default)(ParseError, [{
  10705. key: "toString",
  10706. value: function () {
  10707. var _context;
  10708. return (0, _concat.default)(_context = "ParseError: ".concat(this.code, " ")).call(_context, this.message);
  10709. }
  10710. }]);
  10711. return ParseError;
  10712. }( /*#__PURE__*/(0, _wrapNativeSuper2.default)(Error));
  10713. /**
  10714. * Error code indicating some error other than those enumerated here.
  10715. *
  10716. * @property {number} OTHER_CAUSE
  10717. * @static
  10718. */
  10719. ParseError.OTHER_CAUSE = -1;
  10720. /**
  10721. * Error code indicating that something has gone wrong with the server.
  10722. *
  10723. * @property {number} INTERNAL_SERVER_ERROR
  10724. * @static
  10725. */
  10726. ParseError.INTERNAL_SERVER_ERROR = 1;
  10727. /**
  10728. * Error code indicating the connection to the Parse servers failed.
  10729. *
  10730. * @property {number} CONNECTION_FAILED
  10731. * @static
  10732. */
  10733. ParseError.CONNECTION_FAILED = 100;
  10734. /**
  10735. * Error code indicating the specified object doesn't exist.
  10736. *
  10737. * @property {number} OBJECT_NOT_FOUND
  10738. * @static
  10739. */
  10740. ParseError.OBJECT_NOT_FOUND = 101;
  10741. /**
  10742. * Error code indicating you tried to query with a datatype that doesn't
  10743. * support it, like exact matching an array or object.
  10744. *
  10745. * @property {number} INVALID_QUERY
  10746. * @static
  10747. */
  10748. ParseError.INVALID_QUERY = 102;
  10749. /**
  10750. * Error code indicating a missing or invalid classname. Classnames are
  10751. * case-sensitive. They must start with a letter, and a-zA-Z0-9_ are the
  10752. * only valid characters.
  10753. *
  10754. * @property {number} INVALID_CLASS_NAME
  10755. * @static
  10756. */
  10757. ParseError.INVALID_CLASS_NAME = 103;
  10758. /**
  10759. * Error code indicating an unspecified object id.
  10760. *
  10761. * @property {number} MISSING_OBJECT_ID
  10762. * @static
  10763. */
  10764. ParseError.MISSING_OBJECT_ID = 104;
  10765. /**
  10766. * Error code indicating an invalid key name. Keys are case-sensitive. They
  10767. * must start with a letter, and a-zA-Z0-9_ are the only valid characters.
  10768. *
  10769. * @property {number} INVALID_KEY_NAME
  10770. * @static
  10771. */
  10772. ParseError.INVALID_KEY_NAME = 105;
  10773. /**
  10774. * Error code indicating a malformed pointer. You should not see this unless
  10775. * you have been mucking about changing internal Parse code.
  10776. *
  10777. * @property {number} INVALID_POINTER
  10778. * @static
  10779. */
  10780. ParseError.INVALID_POINTER = 106;
  10781. /**
  10782. * Error code indicating that badly formed JSON was received upstream. This
  10783. * either indicates you have done something unusual with modifying how
  10784. * things encode to JSON, or the network is failing badly.
  10785. *
  10786. * @property {number} INVALID_JSON
  10787. * @static
  10788. */
  10789. ParseError.INVALID_JSON = 107;
  10790. /**
  10791. * Error code indicating that the feature you tried to access is only
  10792. * available internally for testing purposes.
  10793. *
  10794. * @property {number} COMMAND_UNAVAILABLE
  10795. * @static
  10796. */
  10797. ParseError.COMMAND_UNAVAILABLE = 108;
  10798. /**
  10799. * You must call Parse.initialize before using the Parse library.
  10800. *
  10801. * @property {number} NOT_INITIALIZED
  10802. * @static
  10803. */
  10804. ParseError.NOT_INITIALIZED = 109;
  10805. /**
  10806. * Error code indicating that a field was set to an inconsistent type.
  10807. *
  10808. * @property {number} INCORRECT_TYPE
  10809. * @static
  10810. */
  10811. ParseError.INCORRECT_TYPE = 111;
  10812. /**
  10813. * Error code indicating an invalid channel name. A channel name is either
  10814. * an empty string (the broadcast channel) or contains only a-zA-Z0-9_
  10815. * characters and starts with a letter.
  10816. *
  10817. * @property {number} INVALID_CHANNEL_NAME
  10818. * @static
  10819. */
  10820. ParseError.INVALID_CHANNEL_NAME = 112;
  10821. /**
  10822. * Error code indicating that push is misconfigured.
  10823. *
  10824. * @property {number} PUSH_MISCONFIGURED
  10825. * @static
  10826. */
  10827. ParseError.PUSH_MISCONFIGURED = 115;
  10828. /**
  10829. * Error code indicating that the object is too large.
  10830. *
  10831. * @property {number} OBJECT_TOO_LARGE
  10832. * @static
  10833. */
  10834. ParseError.OBJECT_TOO_LARGE = 116;
  10835. /**
  10836. * Error code indicating that the operation isn't allowed for clients.
  10837. *
  10838. * @property {number} OPERATION_FORBIDDEN
  10839. * @static
  10840. */
  10841. ParseError.OPERATION_FORBIDDEN = 119;
  10842. /**
  10843. * Error code indicating the result was not found in the cache.
  10844. *
  10845. * @property {number} CACHE_MISS
  10846. * @static
  10847. */
  10848. ParseError.CACHE_MISS = 120;
  10849. /**
  10850. * Error code indicating that an invalid key was used in a nested
  10851. * JSONObject.
  10852. *
  10853. * @property {number} INVALID_NESTED_KEY
  10854. * @static
  10855. */
  10856. ParseError.INVALID_NESTED_KEY = 121;
  10857. /**
  10858. * Error code indicating that an invalid filename was used for ParseFile.
  10859. * A valid file name contains only a-zA-Z0-9_. characters and is between 1
  10860. * and 128 characters.
  10861. *
  10862. * @property {number} INVALID_FILE_NAME
  10863. * @static
  10864. */
  10865. ParseError.INVALID_FILE_NAME = 122;
  10866. /**
  10867. * Error code indicating an invalid ACL was provided.
  10868. *
  10869. * @property {number} INVALID_ACL
  10870. * @static
  10871. */
  10872. ParseError.INVALID_ACL = 123;
  10873. /**
  10874. * Error code indicating that the request timed out on the server. Typically
  10875. * this indicates that the request is too expensive to run.
  10876. *
  10877. * @property {number} TIMEOUT
  10878. * @static
  10879. */
  10880. ParseError.TIMEOUT = 124;
  10881. /**
  10882. * Error code indicating that the email address was invalid.
  10883. *
  10884. * @property {number} INVALID_EMAIL_ADDRESS
  10885. * @static
  10886. */
  10887. ParseError.INVALID_EMAIL_ADDRESS = 125;
  10888. /**
  10889. * Error code indicating a missing content type.
  10890. *
  10891. * @property {number} MISSING_CONTENT_TYPE
  10892. * @static
  10893. */
  10894. ParseError.MISSING_CONTENT_TYPE = 126;
  10895. /**
  10896. * Error code indicating a missing content length.
  10897. *
  10898. * @property {number} MISSING_CONTENT_LENGTH
  10899. * @static
  10900. */
  10901. ParseError.MISSING_CONTENT_LENGTH = 127;
  10902. /**
  10903. * Error code indicating an invalid content length.
  10904. *
  10905. * @property {number} INVALID_CONTENT_LENGTH
  10906. * @static
  10907. */
  10908. ParseError.INVALID_CONTENT_LENGTH = 128;
  10909. /**
  10910. * Error code indicating a file that was too large.
  10911. *
  10912. * @property {number} FILE_TOO_LARGE
  10913. * @static
  10914. */
  10915. ParseError.FILE_TOO_LARGE = 129;
  10916. /**
  10917. * Error code indicating an error saving a file.
  10918. *
  10919. * @property {number} FILE_SAVE_ERROR
  10920. * @static
  10921. */
  10922. ParseError.FILE_SAVE_ERROR = 130;
  10923. /**
  10924. * Error code indicating that a unique field was given a value that is
  10925. * already taken.
  10926. *
  10927. * @property {number} DUPLICATE_VALUE
  10928. * @static
  10929. */
  10930. ParseError.DUPLICATE_VALUE = 137;
  10931. /**
  10932. * Error code indicating that a role's name is invalid.
  10933. *
  10934. * @property {number} INVALID_ROLE_NAME
  10935. * @static
  10936. */
  10937. ParseError.INVALID_ROLE_NAME = 139;
  10938. /**
  10939. * Error code indicating that an application quota was exceeded. Upgrade to
  10940. * resolve.
  10941. *
  10942. * @property {number} EXCEEDED_QUOTA
  10943. * @static
  10944. */
  10945. ParseError.EXCEEDED_QUOTA = 140;
  10946. /**
  10947. * Error code indicating that a Cloud Code script failed.
  10948. *
  10949. * @property {number} SCRIPT_FAILED
  10950. * @static
  10951. */
  10952. ParseError.SCRIPT_FAILED = 141;
  10953. /**
  10954. * Error code indicating that a Cloud Code validation failed.
  10955. *
  10956. * @property {number} VALIDATION_ERROR
  10957. * @static
  10958. */
  10959. ParseError.VALIDATION_ERROR = 142;
  10960. /**
  10961. * Error code indicating that invalid image data was provided.
  10962. *
  10963. * @property {number} INVALID_IMAGE_DATA
  10964. * @static
  10965. */
  10966. ParseError.INVALID_IMAGE_DATA = 143;
  10967. /**
  10968. * Error code indicating an unsaved file.
  10969. *
  10970. * @property {number} UNSAVED_FILE_ERROR
  10971. * @static
  10972. */
  10973. ParseError.UNSAVED_FILE_ERROR = 151;
  10974. /**
  10975. * Error code indicating an invalid push time.
  10976. *
  10977. * @property {number} INVALID_PUSH_TIME_ERROR
  10978. * @static
  10979. */
  10980. ParseError.INVALID_PUSH_TIME_ERROR = 152;
  10981. /**
  10982. * Error code indicating an error deleting a file.
  10983. *
  10984. * @property {number} FILE_DELETE_ERROR
  10985. * @static
  10986. */
  10987. ParseError.FILE_DELETE_ERROR = 153;
  10988. /**
  10989. * Error code indicating an error deleting an unnamed file.
  10990. *
  10991. * @property {number} FILE_DELETE_UNNAMED_ERROR
  10992. * @static
  10993. */
  10994. ParseError.FILE_DELETE_UNNAMED_ERROR = 161;
  10995. /**
  10996. * Error code indicating that the application has exceeded its request
  10997. * limit.
  10998. *
  10999. * @property {number} REQUEST_LIMIT_EXCEEDED
  11000. * @static
  11001. */
  11002. ParseError.REQUEST_LIMIT_EXCEEDED = 155;
  11003. /**
  11004. * Error code indicating that the request was a duplicate and has been discarded due to
  11005. * idempotency rules.
  11006. *
  11007. * @property {number} DUPLICATE_REQUEST
  11008. * @static
  11009. */
  11010. ParseError.DUPLICATE_REQUEST = 159;
  11011. /**
  11012. * Error code indicating an invalid event name.
  11013. *
  11014. * @property {number} INVALID_EVENT_NAME
  11015. * @static
  11016. */
  11017. ParseError.INVALID_EVENT_NAME = 160;
  11018. /**
  11019. * Error code indicating that the username is missing or empty.
  11020. *
  11021. * @property {number} USERNAME_MISSING
  11022. * @static
  11023. */
  11024. ParseError.USERNAME_MISSING = 200;
  11025. /**
  11026. * Error code indicating that the password is missing or empty.
  11027. *
  11028. * @property {number} PASSWORD_MISSING
  11029. * @static
  11030. */
  11031. ParseError.PASSWORD_MISSING = 201;
  11032. /**
  11033. * Error code indicating that the username has already been taken.
  11034. *
  11035. * @property {number} USERNAME_TAKEN
  11036. * @static
  11037. */
  11038. ParseError.USERNAME_TAKEN = 202;
  11039. /**
  11040. * Error code indicating that the email has already been taken.
  11041. *
  11042. * @property {number} EMAIL_TAKEN
  11043. * @static
  11044. */
  11045. ParseError.EMAIL_TAKEN = 203;
  11046. /**
  11047. * Error code indicating that the email is missing, but must be specified.
  11048. *
  11049. * @property {number} EMAIL_MISSING
  11050. * @static
  11051. */
  11052. ParseError.EMAIL_MISSING = 204;
  11053. /**
  11054. * Error code indicating that a user with the specified email was not found.
  11055. *
  11056. * @property {number} EMAIL_NOT_FOUND
  11057. * @static
  11058. */
  11059. ParseError.EMAIL_NOT_FOUND = 205;
  11060. /**
  11061. * Error code indicating that a user object without a valid session could
  11062. * not be altered.
  11063. *
  11064. * @property {number} SESSION_MISSING
  11065. * @static
  11066. */
  11067. ParseError.SESSION_MISSING = 206;
  11068. /**
  11069. * Error code indicating that a user can only be created through signup.
  11070. *
  11071. * @property {number} MUST_CREATE_USER_THROUGH_SIGNUP
  11072. * @static
  11073. */
  11074. ParseError.MUST_CREATE_USER_THROUGH_SIGNUP = 207;
  11075. /**
  11076. * Error code indicating that an an account being linked is already linked
  11077. * to another user.
  11078. *
  11079. * @property {number} ACCOUNT_ALREADY_LINKED
  11080. * @static
  11081. */
  11082. ParseError.ACCOUNT_ALREADY_LINKED = 208;
  11083. /**
  11084. * Error code indicating that the current session token is invalid.
  11085. *
  11086. * @property {number} INVALID_SESSION_TOKEN
  11087. * @static
  11088. */
  11089. ParseError.INVALID_SESSION_TOKEN = 209;
  11090. /**
  11091. * Error code indicating an error enabling or verifying MFA
  11092. *
  11093. * @property {number} MFA_ERROR
  11094. * @static
  11095. */
  11096. ParseError.MFA_ERROR = 210;
  11097. /**
  11098. * Error code indicating that a valid MFA token must be provided
  11099. *
  11100. * @property {number} MFA_TOKEN_REQUIRED
  11101. * @static
  11102. */
  11103. ParseError.MFA_TOKEN_REQUIRED = 211;
  11104. /**
  11105. * Error code indicating that a user cannot be linked to an account because
  11106. * that account's id could not be found.
  11107. *
  11108. * @property {number} LINKED_ID_MISSING
  11109. * @static
  11110. */
  11111. ParseError.LINKED_ID_MISSING = 250;
  11112. /**
  11113. * Error code indicating that a user with a linked (e.g. Facebook) account
  11114. * has an invalid session.
  11115. *
  11116. * @property {number} INVALID_LINKED_SESSION
  11117. * @static
  11118. */
  11119. ParseError.INVALID_LINKED_SESSION = 251;
  11120. /**
  11121. * Error code indicating that a service being linked (e.g. Facebook or
  11122. * Twitter) is unsupported.
  11123. *
  11124. * @property {number} UNSUPPORTED_SERVICE
  11125. * @static
  11126. */
  11127. ParseError.UNSUPPORTED_SERVICE = 252;
  11128. /**
  11129. * Error code indicating an invalid operation occured on schema
  11130. *
  11131. * @property {number} INVALID_SCHEMA_OPERATION
  11132. * @static
  11133. */
  11134. ParseError.INVALID_SCHEMA_OPERATION = 255;
  11135. /**
  11136. * Error code indicating that there were multiple errors. Aggregate errors
  11137. * have an "errors" property, which is an array of error objects with more
  11138. * detail about each error that occurred.
  11139. *
  11140. * @property {number} AGGREGATE_ERROR
  11141. * @static
  11142. */
  11143. ParseError.AGGREGATE_ERROR = 600;
  11144. /**
  11145. * Error code indicating the client was unable to read an input file.
  11146. *
  11147. * @property {number} FILE_READ_ERROR
  11148. * @static
  11149. */
  11150. ParseError.FILE_READ_ERROR = 601;
  11151. /**
  11152. * Error code indicating a real error code is unavailable because
  11153. * we had to use an XDomainRequest object to allow CORS requests in
  11154. * Internet Explorer, which strips the body from HTTP responses that have
  11155. * a non-2XX status code.
  11156. *
  11157. * @property {number} X_DOMAIN_REQUEST
  11158. * @static
  11159. */
  11160. ParseError.X_DOMAIN_REQUEST = 602;
  11161. var _default = ParseError;
  11162. exports.default = _default;
  11163. },{"@babel/runtime-corejs3/core-js-stable/instance/concat":81,"@babel/runtime-corejs3/core-js-stable/object/define-property":105,"@babel/runtime-corejs3/core-js-stable/reflect/construct":116,"@babel/runtime-corejs3/helpers/assertThisInitialized":143,"@babel/runtime-corejs3/helpers/classCallCheck":145,"@babel/runtime-corejs3/helpers/createClass":147,"@babel/runtime-corejs3/helpers/getPrototypeOf":150,"@babel/runtime-corejs3/helpers/inherits":151,"@babel/runtime-corejs3/helpers/interopRequireDefault":152,"@babel/runtime-corejs3/helpers/possibleConstructorReturn":159,"@babel/runtime-corejs3/helpers/wrapNativeSuper":166}],30:[function(_dereq_,module,exports){
  11164. "use strict";
  11165. var _Object$keys2 = _dereq_("@babel/runtime-corejs3/core-js-stable/object/keys");
  11166. var _Object$getOwnPropertySymbols = _dereq_("@babel/runtime-corejs3/core-js-stable/object/get-own-property-symbols");
  11167. var _filterInstanceProperty = _dereq_("@babel/runtime-corejs3/core-js-stable/instance/filter");
  11168. var _Object$getOwnPropertyDescriptor = _dereq_("@babel/runtime-corejs3/core-js-stable/object/get-own-property-descriptor");
  11169. var _forEachInstanceProperty2 = _dereq_("@babel/runtime-corejs3/core-js-stable/instance/for-each");
  11170. var _Object$getOwnPropertyDescriptors = _dereq_("@babel/runtime-corejs3/core-js-stable/object/get-own-property-descriptors");
  11171. var _Object$defineProperties = _dereq_("@babel/runtime-corejs3/core-js-stable/object/define-properties");
  11172. var _Object$defineProperty = _dereq_("@babel/runtime-corejs3/core-js-stable/object/define-property");
  11173. var _interopRequireDefault = _dereq_("@babel/runtime-corejs3/helpers/interopRequireDefault");
  11174. _Object$defineProperty(exports, "__esModule", {
  11175. value: true
  11176. });
  11177. exports.default = void 0;
  11178. var _regenerator = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/regenerator"));
  11179. var _isArray = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/array/is-array"));
  11180. var _indexOf = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/instance/index-of"));
  11181. var _slice = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/instance/slice"));
  11182. var _forEach = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/instance/for-each"));
  11183. var _keys = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/object/keys"));
  11184. var _typeof2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/helpers/typeof"));
  11185. var _asyncToGenerator2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/helpers/asyncToGenerator"));
  11186. var _classCallCheck2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/helpers/classCallCheck"));
  11187. var _createClass2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/helpers/createClass"));
  11188. var _defineProperty2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/helpers/defineProperty"));
  11189. var _CoreManager = _interopRequireDefault(_dereq_("./CoreManager"));
  11190. var _ParseFileEncode = _dereq_("./ParseFileEncode");
  11191. function ownKeys(object, enumerableOnly) {
  11192. var keys = _Object$keys2(object);
  11193. if (_Object$getOwnPropertySymbols) {
  11194. var symbols = _Object$getOwnPropertySymbols(object);
  11195. enumerableOnly && (symbols = _filterInstanceProperty(symbols).call(symbols, function (sym) {
  11196. return _Object$getOwnPropertyDescriptor(object, sym).enumerable;
  11197. })), keys.push.apply(keys, symbols);
  11198. }
  11199. return keys;
  11200. }
  11201. function _objectSpread(target) {
  11202. for (var i = 1; i < arguments.length; i++) {
  11203. var _context4, _context5;
  11204. var source = null != arguments[i] ? arguments[i] : {};
  11205. i % 2 ? _forEachInstanceProperty2(_context4 = ownKeys(Object(source), !0)).call(_context4, function (key) {
  11206. (0, _defineProperty2.default)(target, key, source[key]);
  11207. }) : _Object$getOwnPropertyDescriptors ? _Object$defineProperties(target, _Object$getOwnPropertyDescriptors(source)) : _forEachInstanceProperty2(_context5 = ownKeys(Object(source))).call(_context5, function (key) {
  11208. _Object$defineProperty(target, key, _Object$getOwnPropertyDescriptor(source, key));
  11209. });
  11210. }
  11211. return target;
  11212. }
  11213. var ParseError = _dereq_('./ParseError').default;
  11214. /*:: type Base64 = { base64: string };*/
  11215. /*:: type Uri = { uri: string };*/
  11216. /*:: type FileData = Array<number> | Base64 | Blob | Uri;*/
  11217. /*:: export type FileSource =
  11218. | {
  11219. format: 'file',
  11220. file: Blob,
  11221. type: string,
  11222. }
  11223. | {
  11224. format: 'base64',
  11225. base64: string,
  11226. type: string,
  11227. }
  11228. | {
  11229. format: 'uri',
  11230. uri: string,
  11231. type: string,
  11232. };*/
  11233. var dataUriRegexp = /^data:([a-zA-Z]+\/[-a-zA-Z0-9+.]+)(;charset=[a-zA-Z0-9\-/]*)?;base64,/;
  11234. /**
  11235. * A Parse.File is a local representation of a file that is saved to the Parse
  11236. * cloud.
  11237. *
  11238. * @alias Parse.File
  11239. */
  11240. var ParseFile = /*#__PURE__*/function () {
  11241. /**
  11242. * @param name {String} The file's name. This will be prefixed by a unique
  11243. * value once the file has finished saving. The file name must begin with
  11244. * an alphanumeric character, and consist of alphanumeric characters,
  11245. * periods, spaces, underscores, or dashes.
  11246. * @param data {Array} The data for the file, as either:
  11247. * 1. an Array of byte value Numbers, or
  11248. * 2. an Object like { base64: "..." } with a base64-encoded String.
  11249. * 3. an Object like { uri: "..." } with a uri String.
  11250. * 4. a File object selected with a file upload control. (3) only works
  11251. * in Firefox 3.6+, Safari 6.0.2+, Chrome 7+, and IE 10+.
  11252. * For example:
  11253. * <pre>
  11254. * var fileUploadControl = $("#profilePhotoFileUpload")[0];
  11255. * if (fileUploadControl.files.length > 0) {
  11256. * var file = fileUploadControl.files[0];
  11257. * var name = "photo.jpg";
  11258. * var parseFile = new Parse.File(name, file);
  11259. * parseFile.save().then(function() {
  11260. * // The file has been saved to Parse.
  11261. * }, function(error) {
  11262. * // The file either could not be read, or could not be saved to Parse.
  11263. * });
  11264. * }</pre>
  11265. * @param type {String} Optional Content-Type header to use for the file. If
  11266. * this is omitted, the content type will be inferred from the name's
  11267. * extension.
  11268. * @param metadata {Object} Optional key value pairs to be stored with file object
  11269. * @param tags {Object} Optional key value pairs to be stored with file object
  11270. */
  11271. function ParseFile(name
  11272. /*: string*/
  11273. , data
  11274. /*:: ?: FileData*/
  11275. , type
  11276. /*:: ?: string*/
  11277. , metadata
  11278. /*:: ?: Object*/
  11279. , tags
  11280. /*:: ?: Object*/
  11281. ) {
  11282. (0, _classCallCheck2.default)(this, ParseFile);
  11283. (0, _defineProperty2.default)(this, "_name", void 0);
  11284. (0, _defineProperty2.default)(this, "_url", void 0);
  11285. (0, _defineProperty2.default)(this, "_hash", void 0);
  11286. (0, _defineProperty2.default)(this, "_ipfs", void 0);
  11287. (0, _defineProperty2.default)(this, "_source", void 0);
  11288. (0, _defineProperty2.default)(this, "_previousSave", void 0);
  11289. (0, _defineProperty2.default)(this, "_data", void 0);
  11290. (0, _defineProperty2.default)(this, "_requestTask", void 0);
  11291. (0, _defineProperty2.default)(this, "_metadata", void 0);
  11292. (0, _defineProperty2.default)(this, "_tags", void 0);
  11293. var specifiedType = type || '';
  11294. this._name = name;
  11295. this._metadata = metadata || {};
  11296. this._tags = tags || {};
  11297. if (data !== undefined) {
  11298. if ((0, _isArray.default)(data)) {
  11299. this._data = ParseFile.encodeBase64(data);
  11300. this._source = {
  11301. format: 'base64',
  11302. base64: this._data,
  11303. type: specifiedType
  11304. };
  11305. } else if (typeof Blob !== 'undefined' && data instanceof Blob) {
  11306. this._source = {
  11307. format: 'file',
  11308. file: data,
  11309. type: specifiedType
  11310. };
  11311. } else if (data && typeof data.uri === 'string' && data.uri !== undefined) {
  11312. this._source = {
  11313. format: 'uri',
  11314. uri: data.uri,
  11315. type: specifiedType
  11316. };
  11317. } else if (data && typeof data.base64 === 'string') {
  11318. var base64 = data.base64;
  11319. var commaIndex = (0, _indexOf.default)(base64).call(base64, ',');
  11320. if (commaIndex !== -1) {
  11321. var matches = dataUriRegexp.exec((0, _slice.default)(base64).call(base64, 0, commaIndex + 1)); // if data URI with type and charset, there will be 4 matches.
  11322. this._data = (0, _slice.default)(base64).call(base64, commaIndex + 1);
  11323. this._source = {
  11324. format: 'base64',
  11325. base64: this._data,
  11326. type: matches[1]
  11327. };
  11328. } else {
  11329. this._data = base64;
  11330. this._source = {
  11331. format: 'base64',
  11332. base64: base64,
  11333. type: specifiedType
  11334. };
  11335. }
  11336. } else {
  11337. throw new TypeError('Cannot create a Parse.File with that data.');
  11338. }
  11339. }
  11340. }
  11341. /**
  11342. * Return the data for the file, downloading it if not already present.
  11343. * Data is present if initialized with Byte Array, Base64 or Saved with Uri.
  11344. * Data is cleared if saved with File object selected with a file upload control
  11345. *
  11346. * @returns {Promise} Promise that is resolve with base64 data
  11347. */
  11348. (0, _createClass2.default)(ParseFile, [{
  11349. key: "getData",
  11350. value: function () {
  11351. var _getData = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee() {
  11352. var _this = this;
  11353. var options, controller, result;
  11354. return _regenerator.default.wrap(function (_context) {
  11355. while (1) {
  11356. switch (_context.prev = _context.next) {
  11357. case 0:
  11358. if (!this._data) {
  11359. _context.next = 2;
  11360. break;
  11361. }
  11362. return _context.abrupt("return", this._data);
  11363. case 2:
  11364. if (this._url) {
  11365. _context.next = 4;
  11366. break;
  11367. }
  11368. throw new Error('Cannot retrieve data for unsaved ParseFile.');
  11369. case 4:
  11370. options = {
  11371. requestTask: function (task) {
  11372. return _this._requestTask = task;
  11373. }
  11374. };
  11375. controller = _CoreManager.default.getFileController();
  11376. _context.next = 8;
  11377. return controller.download(this._url, options);
  11378. case 8:
  11379. result = _context.sent;
  11380. this._data = result.base64;
  11381. return _context.abrupt("return", this._data);
  11382. case 11:
  11383. case "end":
  11384. return _context.stop();
  11385. }
  11386. }
  11387. }, _callee, this);
  11388. }));
  11389. return function () {
  11390. return _getData.apply(this, arguments);
  11391. };
  11392. }()
  11393. /**
  11394. * Gets the name of the file. Before save is called, this is the filename
  11395. * given by the user. After save is called, that name gets prefixed with a
  11396. * unique identifier.
  11397. *
  11398. * @returns {string}
  11399. */
  11400. }, {
  11401. key: "name",
  11402. value: function ()
  11403. /*: string*/
  11404. {
  11405. return this._name;
  11406. }
  11407. /**
  11408. * Gets the url of the file. It is only available after you save the file or
  11409. * after you get the file from a Parse.Object.
  11410. *
  11411. * @param {object} options An object to specify url options
  11412. * @returns {string}
  11413. */
  11414. }, {
  11415. key: "url",
  11416. value: function (options
  11417. /*:: ?: { forceSecure?: boolean }*/
  11418. )
  11419. /*: ?string*/
  11420. {
  11421. options = options || {};
  11422. if (!this._url) {
  11423. return;
  11424. }
  11425. if (options.forceSecure) {
  11426. return this._url.replace(/^http:\/\//i, 'https://');
  11427. }
  11428. return this._url;
  11429. }
  11430. }, {
  11431. key: "ipfs",
  11432. value: function () {
  11433. return this._ipfs;
  11434. }
  11435. }, {
  11436. key: "hash",
  11437. value: function () {
  11438. return this._hash;
  11439. }
  11440. /**
  11441. * Gets the metadata of the file.
  11442. *
  11443. * @returns {object}
  11444. */
  11445. }, {
  11446. key: "metadata",
  11447. value: function ()
  11448. /*: Object*/
  11449. {
  11450. return this._metadata;
  11451. }
  11452. /**
  11453. * Gets the tags of the file.
  11454. *
  11455. * @returns {object}
  11456. */
  11457. }, {
  11458. key: "tags",
  11459. value: function ()
  11460. /*: Object*/
  11461. {
  11462. return this._tags;
  11463. }
  11464. /**
  11465. * Saves the file to the Parse cloud.
  11466. *
  11467. * @param {object} options
  11468. * * Valid options are:<ul>
  11469. * <li>useMasterKey: In Cloud Code and Node only, causes the Master Key to
  11470. * be used for this request.
  11471. * <li>sessionToken: A valid session token, used for making a request on
  11472. * behalf of a specific user.
  11473. * <li>progress: In Browser only, callback for upload progress. For example:
  11474. * <pre>
  11475. * let parseFile = new Parse.File(name, file);
  11476. * parseFile.save({
  11477. * progress: (progressValue, loaded, total, { type }) => {
  11478. * if (type === "upload" && progressValue !== null) {
  11479. * // Update the UI using progressValue
  11480. * }
  11481. * }
  11482. * });
  11483. * </pre>
  11484. * </ul>
  11485. * @returns {Promise} Promise that is resolved when the save finishes.
  11486. */
  11487. }, {
  11488. key: "save",
  11489. value: function (options
  11490. /*:: ?: FullOptions*/
  11491. ) {
  11492. var _this2 = this;
  11493. options = options || {};
  11494. options.requestTask = function (task) {
  11495. return _this2._requestTask = task;
  11496. };
  11497. options.metadata = this._metadata;
  11498. options.tags = this._tags;
  11499. var controller = _CoreManager.default.getFileController();
  11500. if (!this._previousSave) {
  11501. if (this._source.format === 'file') {
  11502. this._previousSave = controller.saveFile(this._name, this._source, options).then(function (res) {
  11503. _this2._name = res.name;
  11504. _this2._url = res.url;
  11505. _this2._hash = res.hash;
  11506. _this2._ipfs = res.ipfs;
  11507. _this2._data = null;
  11508. _this2._requestTask = null;
  11509. return _this2;
  11510. });
  11511. } else if (this._source.format === 'uri') {
  11512. this._previousSave = controller.download(this._source.uri, options).then(function (result) {
  11513. if (!(result && result.base64)) {
  11514. return {};
  11515. }
  11516. var newSource = {
  11517. format: 'base64',
  11518. base64: result.base64,
  11519. type: result.contentType
  11520. };
  11521. _this2._data = result.base64;
  11522. _this2._requestTask = null;
  11523. return controller.saveBase64(_this2._name, newSource, options);
  11524. }).then(function (res) {
  11525. _this2._name = res.name;
  11526. _this2._url = res.url;
  11527. _this2._hash = res.hash;
  11528. _this2._ipfs = res.ipfs;
  11529. _this2._requestTask = null;
  11530. return _this2;
  11531. });
  11532. } else {
  11533. this._previousSave = controller.saveBase64(this._name, this._source, options).then(function (res) {
  11534. _this2._name = res.name;
  11535. _this2._url = res.url;
  11536. _this2._hash = res.hash;
  11537. _this2._ipfs = res.ipfs;
  11538. _this2._requestTask = null;
  11539. return _this2;
  11540. });
  11541. }
  11542. }
  11543. if (this._previousSave) {
  11544. return this._previousSave;
  11545. }
  11546. }
  11547. }, {
  11548. key: "saveIPFS",
  11549. value: function (options
  11550. /*:: ?: FullOptions*/
  11551. ) {
  11552. return this.save(_objectSpread(_objectSpread({}, options), {}, {
  11553. ipfs: true
  11554. }));
  11555. }
  11556. /**
  11557. * Aborts the request if it has already been sent.
  11558. */
  11559. }, {
  11560. key: "cancel",
  11561. value: function () {
  11562. if (this._requestTask && typeof this._requestTask.abort === 'function') {
  11563. this._requestTask.abort();
  11564. }
  11565. this._requestTask = null;
  11566. }
  11567. /**
  11568. * Deletes the file from the Parse cloud.
  11569. * In Cloud Code and Node only with Master Key.
  11570. *
  11571. * @param {object} options
  11572. * * Valid options are:<ul>
  11573. * <li>useMasterKey: In Cloud Code and Node only, causes the Master Key to
  11574. * be used for this request.
  11575. * <pre>
  11576. * @returns {Promise} Promise that is resolved when the delete finishes.
  11577. */
  11578. }, {
  11579. key: "destroy",
  11580. value: function () {
  11581. var _this3 = this;
  11582. var options
  11583. /*:: ?: FullOptions*/
  11584. = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
  11585. if (!this._name) {
  11586. throw new ParseError(ParseError.FILE_DELETE_UNNAMED_ERROR, 'Cannot delete an unnamed file.');
  11587. }
  11588. var destroyOptions = {
  11589. useMasterKey: true
  11590. };
  11591. if (options.hasOwnProperty('useMasterKey')) {
  11592. destroyOptions.useMasterKey = options.useMasterKey;
  11593. }
  11594. var controller = _CoreManager.default.getFileController();
  11595. return controller.deleteFile(this._name, destroyOptions).then(function () {
  11596. _this3._data = null;
  11597. _this3._requestTask = null;
  11598. return _this3;
  11599. });
  11600. }
  11601. }, {
  11602. key: "toJSON",
  11603. value: function ()
  11604. /*: { name: ?string, url: ?string }*/
  11605. {
  11606. return {
  11607. __type: 'File',
  11608. name: this._name,
  11609. url: this._url,
  11610. ipfs: this._ipfs,
  11611. hash: this._hash
  11612. };
  11613. }
  11614. }, {
  11615. key: "equals",
  11616. value: function (other
  11617. /*: mixed*/
  11618. )
  11619. /*: boolean*/
  11620. {
  11621. if (this === other) {
  11622. return true;
  11623. } // Unsaved Files are never equal, since they will be saved to different URLs
  11624. return other instanceof ParseFile && this.name() === other.name() && this.url() === other.url() && typeof this.url() !== 'undefined';
  11625. }
  11626. /**
  11627. * Sets metadata to be saved with file object. Overwrites existing metadata
  11628. *
  11629. * @param {object} metadata Key value pairs to be stored with file object
  11630. */
  11631. }, {
  11632. key: "setMetadata",
  11633. value: function (metadata
  11634. /*: any*/
  11635. ) {
  11636. var _this4 = this;
  11637. if (metadata && (0, _typeof2.default)(metadata) === 'object') {
  11638. var _context2;
  11639. (0, _forEach.default)(_context2 = (0, _keys.default)(metadata)).call(_context2, function (key) {
  11640. _this4.addMetadata(key, metadata[key]);
  11641. });
  11642. }
  11643. }
  11644. /**
  11645. * Sets metadata to be saved with file object. Adds to existing metadata.
  11646. *
  11647. * @param {string} key key to store the metadata
  11648. * @param {*} value metadata
  11649. */
  11650. }, {
  11651. key: "addMetadata",
  11652. value: function (key
  11653. /*: string*/
  11654. , value
  11655. /*: any*/
  11656. ) {
  11657. if (typeof key === 'string') {
  11658. this._metadata[key] = value;
  11659. }
  11660. }
  11661. /**
  11662. * Sets tags to be saved with file object. Overwrites existing tags
  11663. *
  11664. * @param {object} tags Key value pairs to be stored with file object
  11665. */
  11666. }, {
  11667. key: "setTags",
  11668. value: function (tags
  11669. /*: any*/
  11670. ) {
  11671. var _this5 = this;
  11672. if (tags && (0, _typeof2.default)(tags) === 'object') {
  11673. var _context3;
  11674. (0, _forEach.default)(_context3 = (0, _keys.default)(tags)).call(_context3, function (key) {
  11675. _this5.addTag(key, tags[key]);
  11676. });
  11677. }
  11678. }
  11679. /**
  11680. * Sets tags to be saved with file object. Adds to existing tags.
  11681. *
  11682. * @param {string} key key to store tags
  11683. * @param {*} value tag
  11684. */
  11685. }, {
  11686. key: "addTag",
  11687. value: function (key
  11688. /*: string*/
  11689. , value
  11690. /*: string*/
  11691. ) {
  11692. if (typeof key === 'string') {
  11693. this._tags[key] = value;
  11694. }
  11695. }
  11696. }], [{
  11697. key: "fromJSON",
  11698. value: function (obj)
  11699. /*: ParseFile*/
  11700. {
  11701. if (obj.__type !== 'File') {
  11702. throw new TypeError('JSON object does not represent a ParseFile');
  11703. }
  11704. var file = new ParseFile(obj.name);
  11705. file._url = obj.url;
  11706. file._hash = obj.hash;
  11707. file._ipfs = obj.ipfs;
  11708. return file;
  11709. }
  11710. }, {
  11711. key: "encodeBase64",
  11712. value: function (bytes
  11713. /*: Array<number>*/
  11714. )
  11715. /*: string*/
  11716. {
  11717. return (0, _ParseFileEncode.encodeBase64)(bytes);
  11718. }
  11719. }]);
  11720. return ParseFile;
  11721. }();
  11722. _CoreManager.default.setFileController(_dereq_('./ParseFileController.default'));
  11723. var _default = ParseFile;
  11724. exports.default = _default;
  11725. exports.b64Digit = _ParseFileEncode.b64Digit;
  11726. },{"./CoreManager":5,"./ParseError":29,"./ParseFileController.default":31,"./ParseFileEncode":32,"@babel/runtime-corejs3/core-js-stable/array/is-array":79,"@babel/runtime-corejs3/core-js-stable/instance/filter":84,"@babel/runtime-corejs3/core-js-stable/instance/for-each":86,"@babel/runtime-corejs3/core-js-stable/instance/index-of":88,"@babel/runtime-corejs3/core-js-stable/instance/slice":93,"@babel/runtime-corejs3/core-js-stable/object/define-properties":104,"@babel/runtime-corejs3/core-js-stable/object/define-property":105,"@babel/runtime-corejs3/core-js-stable/object/get-own-property-descriptor":108,"@babel/runtime-corejs3/core-js-stable/object/get-own-property-descriptors":109,"@babel/runtime-corejs3/core-js-stable/object/get-own-property-symbols":110,"@babel/runtime-corejs3/core-js-stable/object/keys":112,"@babel/runtime-corejs3/helpers/asyncToGenerator":144,"@babel/runtime-corejs3/helpers/classCallCheck":145,"@babel/runtime-corejs3/helpers/createClass":147,"@babel/runtime-corejs3/helpers/defineProperty":148,"@babel/runtime-corejs3/helpers/interopRequireDefault":152,"@babel/runtime-corejs3/helpers/typeof":164,"@babel/runtime-corejs3/regenerator":167}],31:[function(_dereq_,module,exports){
  11727. "use strict";
  11728. var _Object$keys = _dereq_("@babel/runtime-corejs3/core-js-stable/object/keys");
  11729. var _Object$getOwnPropertySymbols = _dereq_("@babel/runtime-corejs3/core-js-stable/object/get-own-property-symbols");
  11730. var _filterInstanceProperty = _dereq_("@babel/runtime-corejs3/core-js-stable/instance/filter");
  11731. var _Object$getOwnPropertyDescriptor = _dereq_("@babel/runtime-corejs3/core-js-stable/object/get-own-property-descriptor");
  11732. var _forEachInstanceProperty = _dereq_("@babel/runtime-corejs3/core-js-stable/instance/for-each");
  11733. var _Object$getOwnPropertyDescriptors = _dereq_("@babel/runtime-corejs3/core-js-stable/object/get-own-property-descriptors");
  11734. var _Object$defineProperties = _dereq_("@babel/runtime-corejs3/core-js-stable/object/define-properties");
  11735. var _Object$defineProperty = _dereq_("@babel/runtime-corejs3/core-js-stable/object/define-property");
  11736. var _interopRequireDefault = _dereq_("@babel/runtime-corejs3/helpers/interopRequireDefault");
  11737. var _regenerator = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/regenerator"));
  11738. var _promise = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/promise"));
  11739. var _indexOf = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/instance/index-of"));
  11740. var _defineProperty2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/helpers/defineProperty"));
  11741. var _slicedToArray2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/helpers/slicedToArray"));
  11742. var _asyncToGenerator2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/helpers/asyncToGenerator"));
  11743. var _CoreManager = _interopRequireDefault(_dereq_("./CoreManager"));
  11744. var _ParseFileEncode = _dereq_("./ParseFileEncode");
  11745. function ownKeys(object, enumerableOnly) {
  11746. var keys = _Object$keys(object);
  11747. if (_Object$getOwnPropertySymbols) {
  11748. var symbols = _Object$getOwnPropertySymbols(object);
  11749. enumerableOnly && (symbols = _filterInstanceProperty(symbols).call(symbols, function (sym) {
  11750. return _Object$getOwnPropertyDescriptor(object, sym).enumerable;
  11751. })), keys.push.apply(keys, symbols);
  11752. }
  11753. return keys;
  11754. }
  11755. function _objectSpread(target) {
  11756. for (var i = 1; i < arguments.length; i++) {
  11757. var _context2, _context3;
  11758. var source = null != arguments[i] ? arguments[i] : {};
  11759. i % 2 ? _forEachInstanceProperty(_context2 = ownKeys(Object(source), !0)).call(_context2, function (key) {
  11760. (0, _defineProperty2.default)(target, key, source[key]);
  11761. }) : _Object$getOwnPropertyDescriptors ? _Object$defineProperties(target, _Object$getOwnPropertyDescriptors(source)) : _forEachInstanceProperty(_context3 = ownKeys(Object(source))).call(_context3, function (key) {
  11762. _Object$defineProperty(target, key, _Object$getOwnPropertyDescriptor(source, key));
  11763. });
  11764. }
  11765. return target;
  11766. }
  11767. var XHR = null;
  11768. if (typeof XMLHttpRequest !== 'undefined') {
  11769. XHR = XMLHttpRequest;
  11770. }
  11771. var DefaultController = {
  11772. saveFile: function () {
  11773. var _saveFile = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee(name
  11774. /*: string*/
  11775. , source
  11776. /*: FileSource*/
  11777. , options
  11778. /*:: ?: FullOptions*/
  11779. ) {
  11780. var base64Data, _base64Data$split, _base64Data$split2, first, second, data, newSource;
  11781. return _regenerator.default.wrap(function (_context) {
  11782. while (1) {
  11783. switch (_context.prev = _context.next) {
  11784. case 0:
  11785. if (!(source.format !== 'file')) {
  11786. _context.next = 2;
  11787. break;
  11788. }
  11789. throw new Error('saveFile can only be used with File-type sources.');
  11790. case 2:
  11791. _context.next = 4;
  11792. return new _promise.default(function (res, rej) {
  11793. // eslint-disable-next-line no-undef
  11794. var reader = new FileReader();
  11795. reader.onload = function () {
  11796. return res(reader.result);
  11797. };
  11798. reader.onerror = function (error) {
  11799. return rej(error);
  11800. };
  11801. reader.readAsDataURL(source.file);
  11802. });
  11803. case 4:
  11804. base64Data = _context.sent; // we only want the data after the comma
  11805. // For example: "data:application/pdf;base64,JVBERi0xLjQKJ..." we would only want "JVBERi0xLjQKJ..."
  11806. _base64Data$split = base64Data.split(','), _base64Data$split2 = (0, _slicedToArray2.default)(_base64Data$split, 2), first = _base64Data$split2[0], second = _base64Data$split2[1]; // in the event there is no 'data:application/pdf;base64,' at the beginning of the base64 string
  11807. // use the entire string instead
  11808. data = second ? second : first;
  11809. newSource = {
  11810. format: 'base64',
  11811. base64: data,
  11812. type: source.type || (source.file ? source.file.type : null)
  11813. };
  11814. _context.next = 10;
  11815. return DefaultController.saveBase64(name, newSource, options);
  11816. case 10:
  11817. return _context.abrupt("return", _context.sent);
  11818. case 11:
  11819. case "end":
  11820. return _context.stop();
  11821. }
  11822. }
  11823. }, _callee);
  11824. }));
  11825. return function () {
  11826. return _saveFile.apply(this, arguments);
  11827. };
  11828. }(),
  11829. saveBase64: function (name
  11830. /*: string*/
  11831. , source
  11832. /*: FileSource*/
  11833. , options
  11834. /*:: ?: FullOptions*/
  11835. ) {
  11836. if (source.format !== 'base64') {
  11837. throw new Error('saveBase64 can only be used with Base64-type sources.');
  11838. }
  11839. var data
  11840. /*: { base64: any, _ContentType?: any, fileData: Object }*/
  11841. = {
  11842. base64: source.base64,
  11843. fileData: {
  11844. ipfs: options.ipfs,
  11845. metadata: _objectSpread({}, options.metadata),
  11846. tags: _objectSpread({}, options.tags)
  11847. }
  11848. };
  11849. delete options.metadata;
  11850. delete options.tags;
  11851. if (source.type) {
  11852. data._ContentType = source.type;
  11853. }
  11854. var path = "files/".concat(name);
  11855. return _CoreManager.default.getRESTController().request('POST', path, data, options);
  11856. },
  11857. download: function (uri, options) {
  11858. if (XHR) {
  11859. return this.downloadAjax(uri, options);
  11860. }
  11861. return _promise.default.reject('Cannot make a request: No definition of XMLHttpRequest was found.');
  11862. },
  11863. downloadAjax: function (uri, options) {
  11864. return new _promise.default(function (resolve, reject) {
  11865. var xhr = new XHR();
  11866. xhr.open('GET', uri, true);
  11867. xhr.responseType = 'arraybuffer';
  11868. xhr.onerror = function (e) {
  11869. reject(e);
  11870. };
  11871. xhr.onreadystatechange = function () {
  11872. if (xhr.readyState !== xhr.DONE) {
  11873. return;
  11874. }
  11875. if (!this.response) {
  11876. return resolve({});
  11877. }
  11878. var bytes = new Uint8Array(this.response);
  11879. resolve({
  11880. base64: (0, _ParseFileEncode.encodeBase64)(bytes),
  11881. contentType: xhr.getResponseHeader('content-type')
  11882. });
  11883. };
  11884. options.requestTask(xhr);
  11885. xhr.send();
  11886. });
  11887. },
  11888. deleteFile: function (name
  11889. /*: string*/
  11890. , options
  11891. /*:: ?: FullOptions*/
  11892. ) {
  11893. var headers = {
  11894. 'X-Parse-Application-ID': _CoreManager.default.get('APPLICATION_ID')
  11895. };
  11896. if (options.useMasterKey) {
  11897. headers['X-Parse-Master-Key'] = _CoreManager.default.get('MASTER_KEY');
  11898. }
  11899. var url = _CoreManager.default.get('SERVER_URL');
  11900. if (url[url.length - 1] !== '/') {
  11901. url += '/';
  11902. }
  11903. url += "files/".concat(name);
  11904. return _CoreManager.default.getRESTController().ajax('DELETE', url, '', headers).catch(function (response) {
  11905. // TODO: return JSON object in server
  11906. if (!response || response === 'SyntaxError: Unexpected end of JSON input') {
  11907. return _promise.default.resolve();
  11908. }
  11909. return _CoreManager.default.getRESTController().handleError(response);
  11910. });
  11911. },
  11912. _setXHR: function (xhr
  11913. /*: any*/
  11914. ) {
  11915. XHR = xhr;
  11916. },
  11917. _getXHR: function () {
  11918. return XHR;
  11919. }
  11920. };
  11921. module.exports = DefaultController;
  11922. },{"./CoreManager":5,"./ParseFileEncode":32,"@babel/runtime-corejs3/core-js-stable/instance/filter":84,"@babel/runtime-corejs3/core-js-stable/instance/for-each":86,"@babel/runtime-corejs3/core-js-stable/instance/index-of":88,"@babel/runtime-corejs3/core-js-stable/object/define-properties":104,"@babel/runtime-corejs3/core-js-stable/object/define-property":105,"@babel/runtime-corejs3/core-js-stable/object/get-own-property-descriptor":108,"@babel/runtime-corejs3/core-js-stable/object/get-own-property-descriptors":109,"@babel/runtime-corejs3/core-js-stable/object/get-own-property-symbols":110,"@babel/runtime-corejs3/core-js-stable/object/keys":112,"@babel/runtime-corejs3/core-js-stable/promise":115,"@babel/runtime-corejs3/helpers/asyncToGenerator":144,"@babel/runtime-corejs3/helpers/defineProperty":148,"@babel/runtime-corejs3/helpers/interopRequireDefault":152,"@babel/runtime-corejs3/helpers/slicedToArray":161,"@babel/runtime-corejs3/regenerator":167}],32:[function(_dereq_,module,exports){
  11923. "use strict";
  11924. /* eslint-disable no-bitwise */
  11925. function b64Digit(number
  11926. /*: number*/
  11927. )
  11928. /*: string*/
  11929. {
  11930. if (number < 26) {
  11931. return String.fromCharCode(65 + number);
  11932. }
  11933. if (number < 52) {
  11934. return String.fromCharCode(97 + (number - 26));
  11935. }
  11936. if (number < 62) {
  11937. return String.fromCharCode(48 + (number - 52));
  11938. }
  11939. if (number === 62) {
  11940. return '+';
  11941. }
  11942. if (number === 63) {
  11943. return '/';
  11944. }
  11945. throw new TypeError("Tried to encode large digit ".concat(number, " in base64."));
  11946. }
  11947. function encodeBase64(bytes
  11948. /*: Array<number>*/
  11949. )
  11950. /*: string*/
  11951. {
  11952. var chunks = [];
  11953. chunks.length = Math.ceil(bytes.length / 3);
  11954. for (var i = 0; i < chunks.length; i++) {
  11955. var b1 = bytes[i * 3];
  11956. var b2 = bytes[i * 3 + 1] || 0;
  11957. var b3 = bytes[i * 3 + 2] || 0;
  11958. var has2 = i * 3 + 1 < bytes.length;
  11959. var has3 = i * 3 + 2 < bytes.length;
  11960. chunks[i] = [b64Digit(b1 >> 2 & 0x3f), b64Digit(b1 << 4 & 0x30 | b2 >> 4 & 0x0f), has2 ? b64Digit(b2 << 2 & 0x3c | b3 >> 6 & 0x03) : '=', has3 ? b64Digit(b3 & 0x3f) : '='].join('');
  11961. }
  11962. return chunks.join('');
  11963. }
  11964. module.exports = {
  11965. encodeBase64: encodeBase64,
  11966. b64Digit: b64Digit
  11967. };
  11968. },{}],33:[function(_dereq_,module,exports){
  11969. "use strict";
  11970. var _Object$defineProperty = _dereq_("@babel/runtime-corejs3/core-js-stable/object/define-property");
  11971. var _interopRequireDefault = _dereq_("@babel/runtime-corejs3/helpers/interopRequireDefault");
  11972. _Object$defineProperty(exports, "__esModule", {
  11973. value: true
  11974. });
  11975. exports.default = void 0;
  11976. var _isArray = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/array/is-array"));
  11977. var _typeof2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/helpers/typeof"));
  11978. var _classCallCheck2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/helpers/classCallCheck"));
  11979. var _createClass2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/helpers/createClass"));
  11980. var _defineProperty2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/helpers/defineProperty"));
  11981. /**
  11982. * Copyright (c) 2015-present, Parse, LLC.
  11983. * All rights reserved.
  11984. *
  11985. * This source code is licensed under the BSD-style license found in the
  11986. * LICENSE file in the root directory of this source tree. An additional grant
  11987. * of patent rights can be found in the PATENTS file in the same directory.
  11988. *
  11989. * @flow
  11990. */
  11991. /**
  11992. * Creates a new GeoPoint with any of the following forms:<br>
  11993. * <pre>
  11994. * new GeoPoint(otherGeoPoint)
  11995. * new GeoPoint(30, 30)
  11996. * new GeoPoint([30, 30])
  11997. * new GeoPoint({latitude: 30, longitude: 30})
  11998. * new GeoPoint() // defaults to (0, 0)
  11999. * </pre>
  12000. * <p>Represents a latitude / longitude point that may be associated
  12001. * with a key in a ParseObject or used as a reference point for geo queries.
  12002. * This allows proximity-based queries on the key.</p>
  12003. *
  12004. * <p>Only one key in a class may contain a GeoPoint.</p>
  12005. *
  12006. * <p>Example:<pre>
  12007. * var point = new Parse.GeoPoint(30.0, -20.0);
  12008. * var object = new Parse.Object("PlaceObject");
  12009. * object.set("location", point);
  12010. * object.save();</pre></p>
  12011. *
  12012. * @alias Parse.GeoPoint
  12013. */
  12014. /* global navigator */
  12015. var ParseGeoPoint = /*#__PURE__*/function () {
  12016. /**
  12017. * @param {(number[] | object | number)} arg1 Either a list of coordinate pairs, an object with `latitude`, `longitude`, or the latitude or the point.
  12018. * @param {number} arg2 The longitude of the GeoPoint
  12019. */
  12020. function ParseGeoPoint(arg1
  12021. /*: Array<number> | { latitude: number, longitude: number } | number*/
  12022. , arg2
  12023. /*:: ?: number*/
  12024. ) {
  12025. (0, _classCallCheck2.default)(this, ParseGeoPoint);
  12026. (0, _defineProperty2.default)(this, "_latitude", void 0);
  12027. (0, _defineProperty2.default)(this, "_longitude", void 0);
  12028. if ((0, _isArray.default)(arg1)) {
  12029. ParseGeoPoint._validate(arg1[0], arg1[1]);
  12030. this._latitude = arg1[0];
  12031. this._longitude = arg1[1];
  12032. } else if ((0, _typeof2.default)(arg1) === 'object') {
  12033. ParseGeoPoint._validate(arg1.latitude, arg1.longitude);
  12034. this._latitude = arg1.latitude;
  12035. this._longitude = arg1.longitude;
  12036. } else if (arg1 !== undefined && arg2 !== undefined) {
  12037. ParseGeoPoint._validate(arg1, arg2);
  12038. this._latitude = arg1;
  12039. this._longitude = arg2;
  12040. } else {
  12041. this._latitude = 0;
  12042. this._longitude = 0;
  12043. }
  12044. }
  12045. /**
  12046. * North-south portion of the coordinate, in range [-90, 90].
  12047. * Throws an exception if set out of range in a modern browser.
  12048. *
  12049. * @property {number} latitude
  12050. * @returns {number}
  12051. */
  12052. (0, _createClass2.default)(ParseGeoPoint, [{
  12053. key: "latitude",
  12054. get: function ()
  12055. /*: number*/
  12056. {
  12057. return this._latitude;
  12058. },
  12059. set: function (val
  12060. /*: number*/
  12061. ) {
  12062. ParseGeoPoint._validate(val, this.longitude);
  12063. this._latitude = val;
  12064. }
  12065. /**
  12066. * East-west portion of the coordinate, in range [-180, 180].
  12067. * Throws if set out of range in a modern browser.
  12068. *
  12069. * @property {number} longitude
  12070. * @returns {number}
  12071. */
  12072. }, {
  12073. key: "longitude",
  12074. get: function ()
  12075. /*: number*/
  12076. {
  12077. return this._longitude;
  12078. },
  12079. set: function (val
  12080. /*: number*/
  12081. ) {
  12082. ParseGeoPoint._validate(this.latitude, val);
  12083. this._longitude = val;
  12084. }
  12085. /**
  12086. * Returns a JSON representation of the GeoPoint, suitable for Parse.
  12087. *
  12088. * @returns {object}
  12089. */
  12090. }, {
  12091. key: "toJSON",
  12092. value: function ()
  12093. /*: { __type: string, latitude: number, longitude: number }*/
  12094. {
  12095. ParseGeoPoint._validate(this._latitude, this._longitude);
  12096. return {
  12097. __type: 'GeoPoint',
  12098. latitude: this._latitude,
  12099. longitude: this._longitude
  12100. };
  12101. }
  12102. }, {
  12103. key: "equals",
  12104. value: function (other
  12105. /*: mixed*/
  12106. )
  12107. /*: boolean*/
  12108. {
  12109. return other instanceof ParseGeoPoint && this.latitude === other.latitude && this.longitude === other.longitude;
  12110. }
  12111. /**
  12112. * Returns the distance from this GeoPoint to another in radians.
  12113. *
  12114. * @param {Parse.GeoPoint} point the other Parse.GeoPoint.
  12115. * @returns {number}
  12116. */
  12117. }, {
  12118. key: "radiansTo",
  12119. value: function (point
  12120. /*: ParseGeoPoint*/
  12121. )
  12122. /*: number*/
  12123. {
  12124. var d2r = Math.PI / 180.0;
  12125. var lat1rad = this.latitude * d2r;
  12126. var long1rad = this.longitude * d2r;
  12127. var lat2rad = point.latitude * d2r;
  12128. var long2rad = point.longitude * d2r;
  12129. var sinDeltaLatDiv2 = Math.sin((lat1rad - lat2rad) / 2);
  12130. var sinDeltaLongDiv2 = Math.sin((long1rad - long2rad) / 2); // Square of half the straight line chord distance between both points.
  12131. var a = sinDeltaLatDiv2 * sinDeltaLatDiv2 + Math.cos(lat1rad) * Math.cos(lat2rad) * sinDeltaLongDiv2 * sinDeltaLongDiv2;
  12132. a = Math.min(1.0, a);
  12133. return 2 * Math.asin(Math.sqrt(a));
  12134. }
  12135. /**
  12136. * Returns the distance from this GeoPoint to another in kilometers.
  12137. *
  12138. * @param {Parse.GeoPoint} point the other Parse.GeoPoint.
  12139. * @returns {number}
  12140. */
  12141. }, {
  12142. key: "kilometersTo",
  12143. value: function (point
  12144. /*: ParseGeoPoint*/
  12145. )
  12146. /*: number*/
  12147. {
  12148. return this.radiansTo(point) * 6371.0;
  12149. }
  12150. /**
  12151. * Returns the distance from this GeoPoint to another in miles.
  12152. *
  12153. * @param {Parse.GeoPoint} point the other Parse.GeoPoint.
  12154. * @returns {number}
  12155. */
  12156. }, {
  12157. key: "milesTo",
  12158. value: function (point
  12159. /*: ParseGeoPoint*/
  12160. )
  12161. /*: number*/
  12162. {
  12163. return this.radiansTo(point) * 3958.8;
  12164. }
  12165. /*
  12166. * Throws an exception if the given lat-long is out of bounds.
  12167. */
  12168. }], [{
  12169. key: "_validate",
  12170. value: function (latitude
  12171. /*: number*/
  12172. , longitude
  12173. /*: number*/
  12174. ) {
  12175. if (isNaN(latitude) || isNaN(longitude) || typeof latitude !== 'number' || typeof longitude !== 'number') {
  12176. throw new TypeError('GeoPoint latitude and longitude must be valid numbers');
  12177. }
  12178. if (latitude < -90.0) {
  12179. throw new TypeError("GeoPoint latitude out of bounds: ".concat(latitude, " < -90.0."));
  12180. }
  12181. if (latitude > 90.0) {
  12182. throw new TypeError("GeoPoint latitude out of bounds: ".concat(latitude, " > 90.0."));
  12183. }
  12184. if (longitude < -180.0) {
  12185. throw new TypeError("GeoPoint longitude out of bounds: ".concat(longitude, " < -180.0."));
  12186. }
  12187. if (longitude > 180.0) {
  12188. throw new TypeError("GeoPoint longitude out of bounds: ".concat(longitude, " > 180.0."));
  12189. }
  12190. }
  12191. /**
  12192. * Creates a GeoPoint with the user's current location, if available.
  12193. *
  12194. * @static
  12195. * @returns {Parse.GeoPoint} User's current location
  12196. */
  12197. }, {
  12198. key: "current",
  12199. value: function () {
  12200. return navigator.geolocation.getCurrentPosition(function (location) {
  12201. return new ParseGeoPoint(location.coords.latitude, location.coords.longitude);
  12202. });
  12203. }
  12204. }]);
  12205. return ParseGeoPoint;
  12206. }();
  12207. var _default = ParseGeoPoint;
  12208. exports.default = _default;
  12209. },{"@babel/runtime-corejs3/core-js-stable/array/is-array":79,"@babel/runtime-corejs3/core-js-stable/object/define-property":105,"@babel/runtime-corejs3/helpers/classCallCheck":145,"@babel/runtime-corejs3/helpers/createClass":147,"@babel/runtime-corejs3/helpers/defineProperty":148,"@babel/runtime-corejs3/helpers/interopRequireDefault":152,"@babel/runtime-corejs3/helpers/typeof":164}],34:[function(_dereq_,module,exports){
  12210. "use strict";
  12211. var _Reflect$construct = _dereq_("@babel/runtime-corejs3/core-js-stable/reflect/construct");
  12212. var _Object$defineProperty = _dereq_("@babel/runtime-corejs3/core-js-stable/object/define-property");
  12213. var _interopRequireDefault = _dereq_("@babel/runtime-corejs3/helpers/interopRequireDefault");
  12214. _Object$defineProperty(exports, "__esModule", {
  12215. value: true
  12216. });
  12217. exports.default = void 0;
  12218. var _typeof2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/helpers/typeof"));
  12219. var _createClass2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/helpers/createClass"));
  12220. var _classCallCheck2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/helpers/classCallCheck"));
  12221. var _inherits2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/helpers/inherits"));
  12222. var _possibleConstructorReturn2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/helpers/possibleConstructorReturn"));
  12223. var _getPrototypeOf2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/helpers/getPrototypeOf"));
  12224. var _ParseObject2 = _interopRequireDefault(_dereq_("./ParseObject"));
  12225. function _createSuper(Derived) {
  12226. var hasNativeReflectConstruct = _isNativeReflectConstruct();
  12227. return function () {
  12228. var Super = (0, _getPrototypeOf2.default)(Derived),
  12229. result;
  12230. if (hasNativeReflectConstruct) {
  12231. var NewTarget = (0, _getPrototypeOf2.default)(this).constructor;
  12232. result = _Reflect$construct(Super, arguments, NewTarget);
  12233. } else {
  12234. result = Super.apply(this, arguments);
  12235. }
  12236. return (0, _possibleConstructorReturn2.default)(this, result);
  12237. };
  12238. }
  12239. function _isNativeReflectConstruct() {
  12240. if (typeof Reflect === "undefined" || !_Reflect$construct) return false;
  12241. if (_Reflect$construct.sham) return false;
  12242. if (typeof Proxy === "function") return true;
  12243. try {
  12244. Boolean.prototype.valueOf.call(_Reflect$construct(Boolean, [], function () {}));
  12245. return true;
  12246. } catch (e) {
  12247. return false;
  12248. }
  12249. }
  12250. var Installation = /*#__PURE__*/function (_ParseObject) {
  12251. (0, _inherits2.default)(Installation, _ParseObject);
  12252. var _super = _createSuper(Installation);
  12253. function Installation(attributes
  12254. /*: ?AttributeMap*/
  12255. ) {
  12256. var _this;
  12257. (0, _classCallCheck2.default)(this, Installation);
  12258. _this = _super.call(this, '_Installation');
  12259. if (attributes && (0, _typeof2.default)(attributes) === 'object') {
  12260. if (!_this.set(attributes || {})) {
  12261. throw new Error("Can't create an invalid Installation");
  12262. }
  12263. }
  12264. return _this;
  12265. }
  12266. return (0, _createClass2.default)(Installation);
  12267. }(_ParseObject2.default);
  12268. exports.default = Installation;
  12269. _ParseObject2.default.registerSubclass('_Installation', Installation);
  12270. },{"./ParseObject":36,"@babel/runtime-corejs3/core-js-stable/object/define-property":105,"@babel/runtime-corejs3/core-js-stable/reflect/construct":116,"@babel/runtime-corejs3/helpers/classCallCheck":145,"@babel/runtime-corejs3/helpers/createClass":147,"@babel/runtime-corejs3/helpers/getPrototypeOf":150,"@babel/runtime-corejs3/helpers/inherits":151,"@babel/runtime-corejs3/helpers/interopRequireDefault":152,"@babel/runtime-corejs3/helpers/possibleConstructorReturn":159,"@babel/runtime-corejs3/helpers/typeof":164}],35:[function(_dereq_,module,exports){
  12271. "use strict";
  12272. var _Object$defineProperty = _dereq_("@babel/runtime-corejs3/core-js-stable/object/define-property");
  12273. var _interopRequireDefault = _dereq_("@babel/runtime-corejs3/helpers/interopRequireDefault");
  12274. _Object$defineProperty(exports, "__esModule", {
  12275. value: true
  12276. });
  12277. exports.default = void 0;
  12278. var _promise = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/promise"));
  12279. var _indexOf = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/instance/index-of"));
  12280. var _regenerator = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/regenerator"));
  12281. var _slicedToArray2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/helpers/slicedToArray"));
  12282. var _asyncToGenerator2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/helpers/asyncToGenerator"));
  12283. var _EventEmitter = _interopRequireDefault(_dereq_("./EventEmitter"));
  12284. var _LiveQueryClient = _interopRequireDefault(_dereq_("./LiveQueryClient"));
  12285. var _CoreManager = _interopRequireDefault(_dereq_("./CoreManager"));
  12286. /**
  12287. * Copyright (c) 2015-present, Parse, LLC.
  12288. * All rights reserved.
  12289. *
  12290. * This source code is licensed under the BSD-style license found in the
  12291. * LICENSE file in the root directory of this source tree. An additional grant
  12292. * of patent rights can be found in the PATENTS file in the same directory.
  12293. *
  12294. * @flow
  12295. */
  12296. function getLiveQueryClient()
  12297. /*: LiveQueryClient*/
  12298. {
  12299. return _CoreManager.default.getLiveQueryController().getDefaultLiveQueryClient();
  12300. }
  12301. /**
  12302. * We expose three events to help you monitor the status of the WebSocket connection:
  12303. *
  12304. * <p>Open - When we establish the WebSocket connection to the LiveQuery server, you'll get this event.
  12305. *
  12306. * <pre>
  12307. * Parse.LiveQuery.on('open', () => {
  12308. *
  12309. * });</pre></p>
  12310. *
  12311. * <p>Close - When we lose the WebSocket connection to the LiveQuery server, you'll get this event.
  12312. *
  12313. * <pre>
  12314. * Parse.LiveQuery.on('close', () => {
  12315. *
  12316. * });</pre></p>
  12317. *
  12318. * <p>Error - When some network error or LiveQuery server error happens, you'll get this event.
  12319. *
  12320. * <pre>
  12321. * Parse.LiveQuery.on('error', (error) => {
  12322. *
  12323. * });</pre></p>
  12324. *
  12325. * @class Parse.LiveQuery
  12326. * @static
  12327. */
  12328. var LiveQuery = new _EventEmitter.default();
  12329. /**
  12330. * After open is called, the LiveQuery will try to send a connect request
  12331. * to the LiveQuery server.
  12332. */
  12333. LiveQuery.open = /*#__PURE__*/(0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee() {
  12334. var liveQueryClient;
  12335. return _regenerator.default.wrap(function (_context) {
  12336. while (1) {
  12337. switch (_context.prev = _context.next) {
  12338. case 0:
  12339. _context.next = 2;
  12340. return getLiveQueryClient();
  12341. case 2:
  12342. liveQueryClient = _context.sent;
  12343. liveQueryClient.open();
  12344. case 4:
  12345. case "end":
  12346. return _context.stop();
  12347. }
  12348. }
  12349. }, _callee);
  12350. }));
  12351. /**
  12352. * When you're done using LiveQuery, you can call Parse.LiveQuery.close().
  12353. * This function will close the WebSocket connection to the LiveQuery server,
  12354. * cancel the auto reconnect, and unsubscribe all subscriptions based on it.
  12355. * If you call query.subscribe() after this, we'll create a new WebSocket
  12356. * connection to the LiveQuery server.
  12357. */
  12358. LiveQuery.close = /*#__PURE__*/(0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee2() {
  12359. var liveQueryClient;
  12360. return _regenerator.default.wrap(function (_context2) {
  12361. while (1) {
  12362. switch (_context2.prev = _context2.next) {
  12363. case 0:
  12364. _context2.next = 2;
  12365. return getLiveQueryClient();
  12366. case 2:
  12367. liveQueryClient = _context2.sent;
  12368. liveQueryClient.close();
  12369. case 4:
  12370. case "end":
  12371. return _context2.stop();
  12372. }
  12373. }
  12374. }, _callee2);
  12375. })); // Register a default onError callback to make sure we do not crash on error
  12376. LiveQuery.on('error', function () {});
  12377. var _default = LiveQuery;
  12378. exports.default = _default;
  12379. var defaultLiveQueryClient;
  12380. var DefaultLiveQueryController = {
  12381. setDefaultLiveQueryClient: function (liveQueryClient
  12382. /*: LiveQueryClient*/
  12383. ) {
  12384. defaultLiveQueryClient = liveQueryClient;
  12385. },
  12386. getDefaultLiveQueryClient: function ()
  12387. /*: Promise<LiveQueryClient>*/
  12388. {
  12389. return (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee3() {
  12390. var _yield$Promise$all, _yield$Promise$all2, currentUser, installationId, sessionToken, liveQueryServerURL, serverURL, protocol, host, applicationId, javascriptKey, masterKey;
  12391. return _regenerator.default.wrap(function (_context3) {
  12392. while (1) {
  12393. switch (_context3.prev = _context3.next) {
  12394. case 0:
  12395. if (!defaultLiveQueryClient) {
  12396. _context3.next = 2;
  12397. break;
  12398. }
  12399. return _context3.abrupt("return", defaultLiveQueryClient);
  12400. case 2:
  12401. _context3.next = 4;
  12402. return _promise.default.all([_CoreManager.default.getUserController().currentUserAsync(), _CoreManager.default.getInstallationController().currentInstallationId()]);
  12403. case 4:
  12404. _yield$Promise$all = _context3.sent;
  12405. _yield$Promise$all2 = (0, _slicedToArray2.default)(_yield$Promise$all, 2);
  12406. currentUser = _yield$Promise$all2[0];
  12407. installationId = _yield$Promise$all2[1];
  12408. sessionToken = currentUser ? currentUser.getSessionToken() : undefined;
  12409. liveQueryServerURL = _CoreManager.default.get('LIVEQUERY_SERVER_URL');
  12410. if (!(liveQueryServerURL && (0, _indexOf.default)(liveQueryServerURL).call(liveQueryServerURL, 'ws') !== 0)) {
  12411. _context3.next = 12;
  12412. break;
  12413. }
  12414. throw new Error('You need to set a proper Parse LiveQuery server url before using LiveQueryClient');
  12415. case 12:
  12416. // If we can not find Parse.liveQueryServerURL, we try to extract it from Parse.serverURL
  12417. if (!liveQueryServerURL) {
  12418. serverURL = _CoreManager.default.get('SERVER_URL');
  12419. protocol = (0, _indexOf.default)(serverURL).call(serverURL, 'https') === 0 ? 'wss://' : 'ws://';
  12420. host = serverURL.replace(/^https?:\/\//, '');
  12421. liveQueryServerURL = protocol + host;
  12422. _CoreManager.default.set('LIVEQUERY_SERVER_URL', liveQueryServerURL);
  12423. }
  12424. applicationId = _CoreManager.default.get('APPLICATION_ID');
  12425. javascriptKey = _CoreManager.default.get('JAVASCRIPT_KEY');
  12426. masterKey = _CoreManager.default.get('MASTER_KEY');
  12427. defaultLiveQueryClient = new _LiveQueryClient.default({
  12428. applicationId: applicationId,
  12429. serverURL: liveQueryServerURL,
  12430. javascriptKey: javascriptKey,
  12431. masterKey: masterKey,
  12432. sessionToken: sessionToken,
  12433. installationId: installationId
  12434. });
  12435. defaultLiveQueryClient.on('error', function (error) {
  12436. LiveQuery.emit('error', error);
  12437. });
  12438. defaultLiveQueryClient.on('open', function () {
  12439. LiveQuery.emit('open');
  12440. });
  12441. defaultLiveQueryClient.on('close', function () {
  12442. LiveQuery.emit('close');
  12443. });
  12444. return _context3.abrupt("return", defaultLiveQueryClient);
  12445. case 21:
  12446. case "end":
  12447. return _context3.stop();
  12448. }
  12449. }
  12450. }, _callee3);
  12451. }))();
  12452. },
  12453. _clearCachedDefaultClient: function () {
  12454. defaultLiveQueryClient = null;
  12455. }
  12456. };
  12457. _CoreManager.default.setLiveQueryController(DefaultLiveQueryController);
  12458. },{"./CoreManager":5,"./EventEmitter":7,"./LiveQueryClient":11,"@babel/runtime-corejs3/core-js-stable/instance/index-of":88,"@babel/runtime-corejs3/core-js-stable/object/define-property":105,"@babel/runtime-corejs3/core-js-stable/promise":115,"@babel/runtime-corejs3/helpers/asyncToGenerator":144,"@babel/runtime-corejs3/helpers/interopRequireDefault":152,"@babel/runtime-corejs3/helpers/slicedToArray":161,"@babel/runtime-corejs3/regenerator":167}],36:[function(_dereq_,module,exports){
  12459. "use strict";
  12460. var _typeof3 = _dereq_("@babel/runtime-corejs3/helpers/typeof");
  12461. var _Object$keys2 = _dereq_("@babel/runtime-corejs3/core-js-stable/object/keys");
  12462. var _Object$getOwnPropertySymbols = _dereq_("@babel/runtime-corejs3/core-js-stable/object/get-own-property-symbols");
  12463. var _filterInstanceProperty = _dereq_("@babel/runtime-corejs3/core-js-stable/instance/filter");
  12464. var _Object$getOwnPropertyDescriptor = _dereq_("@babel/runtime-corejs3/core-js-stable/object/get-own-property-descriptor");
  12465. var _forEachInstanceProperty2 = _dereq_("@babel/runtime-corejs3/core-js-stable/instance/for-each");
  12466. var _Object$getOwnPropertyDescriptors = _dereq_("@babel/runtime-corejs3/core-js-stable/object/get-own-property-descriptors");
  12467. var _Object$defineProperties = _dereq_("@babel/runtime-corejs3/core-js-stable/object/define-properties");
  12468. var _Object$defineProperty2 = _dereq_("@babel/runtime-corejs3/core-js-stable/object/define-property");
  12469. var _sliceInstanceProperty = _dereq_("@babel/runtime-corejs3/core-js-stable/instance/slice");
  12470. var _Array$from = _dereq_("@babel/runtime-corejs3/core-js-stable/array/from");
  12471. var _Symbol = _dereq_("@babel/runtime-corejs3/core-js-stable/symbol");
  12472. var _getIteratorMethod = _dereq_("@babel/runtime-corejs3/core-js/get-iterator-method");
  12473. var _Array$isArray2 = _dereq_("@babel/runtime-corejs3/core-js-stable/array/is-array");
  12474. var _WeakMap = _dereq_("@babel/runtime-corejs3/core-js-stable/weak-map");
  12475. var _interopRequireDefault = _dereq_("@babel/runtime-corejs3/helpers/interopRequireDefault");
  12476. _Object$defineProperty2(exports, "__esModule", {
  12477. value: true
  12478. });
  12479. exports.default = void 0;
  12480. var _regenerator = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/regenerator"));
  12481. var _asyncToGenerator2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/helpers/asyncToGenerator"));
  12482. var _typeof2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/helpers/typeof"));
  12483. var _classCallCheck2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/helpers/classCallCheck"));
  12484. var _createClass2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/helpers/createClass"));
  12485. var _defineProperty2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/helpers/defineProperty"));
  12486. var _indexOf = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/instance/index-of"));
  12487. var _freeze = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/object/freeze"));
  12488. var _keys = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/object/keys"));
  12489. var _forEach = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/instance/for-each"));
  12490. var _stringify = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/json/stringify"));
  12491. var _includes = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/instance/includes"));
  12492. var _getPrototypeOf = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/object/get-prototype-of"));
  12493. var _concat = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/instance/concat"));
  12494. var _isArray = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/array/is-array"));
  12495. var _promise = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/promise"));
  12496. var _create = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/object/create"));
  12497. var _defineProperty3 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/object/define-property"));
  12498. var _find = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/instance/find"));
  12499. var _map = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/instance/map"));
  12500. var _CoreManager = _interopRequireDefault(_dereq_("./CoreManager"));
  12501. var _canBeSerialized = _interopRequireDefault(_dereq_("./canBeSerialized"));
  12502. var _decode = _interopRequireDefault(_dereq_("./decode"));
  12503. var _encode = _interopRequireDefault(_dereq_("./encode"));
  12504. var _escape2 = _interopRequireDefault(_dereq_("./escape"));
  12505. var _ParseACL = _interopRequireDefault(_dereq_("./ParseACL"));
  12506. var _parseDate = _interopRequireDefault(_dereq_("./parseDate"));
  12507. var _ParseError = _interopRequireDefault(_dereq_("./ParseError"));
  12508. var _ParseFile = _interopRequireDefault(_dereq_("./ParseFile"));
  12509. var _promiseUtils = _dereq_("./promiseUtils");
  12510. var _LocalDatastoreUtils = _dereq_("./LocalDatastoreUtils");
  12511. var _ParseOp = _dereq_("./ParseOp");
  12512. var _ParseQuery = _interopRequireDefault(_dereq_("./ParseQuery"));
  12513. var _ParseRelation = _interopRequireDefault(_dereq_("./ParseRelation"));
  12514. var SingleInstanceStateController = _interopRequireWildcard(_dereq_("./SingleInstanceStateController"));
  12515. var _unique = _interopRequireDefault(_dereq_("./unique"));
  12516. var UniqueInstanceStateController = _interopRequireWildcard(_dereq_("./UniqueInstanceStateController"));
  12517. var _unsavedChildren = _interopRequireDefault(_dereq_("./unsavedChildren"));
  12518. function _getRequireWildcardCache(nodeInterop) {
  12519. if (typeof _WeakMap !== "function") return null;
  12520. var cacheBabelInterop = new _WeakMap();
  12521. var cacheNodeInterop = new _WeakMap();
  12522. return (_getRequireWildcardCache = function (nodeInterop) {
  12523. return nodeInterop ? cacheNodeInterop : cacheBabelInterop;
  12524. })(nodeInterop);
  12525. }
  12526. function _interopRequireWildcard(obj, nodeInterop) {
  12527. if (!nodeInterop && obj && obj.__esModule) {
  12528. return obj;
  12529. }
  12530. if (obj === null || _typeof3(obj) !== "object" && typeof obj !== "function") {
  12531. return {
  12532. default: obj
  12533. };
  12534. }
  12535. var cache = _getRequireWildcardCache(nodeInterop);
  12536. if (cache && cache.has(obj)) {
  12537. return cache.get(obj);
  12538. }
  12539. var newObj = {};
  12540. for (var key in obj) {
  12541. if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) {
  12542. var desc = _Object$defineProperty2 && _Object$getOwnPropertyDescriptor ? _Object$getOwnPropertyDescriptor(obj, key) : null;
  12543. if (desc && (desc.get || desc.set)) {
  12544. _Object$defineProperty2(newObj, key, desc);
  12545. } else {
  12546. newObj[key] = obj[key];
  12547. }
  12548. }
  12549. }
  12550. newObj.default = obj;
  12551. if (cache) {
  12552. cache.set(obj, newObj);
  12553. }
  12554. return newObj;
  12555. }
  12556. function _createForOfIteratorHelper(o, allowArrayLike) {
  12557. var it = typeof _Symbol !== "undefined" && _getIteratorMethod(o) || o["@@iterator"];
  12558. if (!it) {
  12559. if (_Array$isArray2(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") {
  12560. if (it) o = it;
  12561. var i = 0;
  12562. var F = function () {};
  12563. return {
  12564. s: F,
  12565. n: function () {
  12566. if (i >= o.length) return {
  12567. done: true
  12568. };
  12569. return {
  12570. done: false,
  12571. value: o[i++]
  12572. };
  12573. },
  12574. e: function (_e) {
  12575. throw _e;
  12576. },
  12577. f: F
  12578. };
  12579. }
  12580. throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
  12581. }
  12582. var normalCompletion = true,
  12583. didErr = false,
  12584. err;
  12585. return {
  12586. s: function () {
  12587. it = it.call(o);
  12588. },
  12589. n: function () {
  12590. var step = it.next();
  12591. normalCompletion = step.done;
  12592. return step;
  12593. },
  12594. e: function (_e2) {
  12595. didErr = true;
  12596. err = _e2;
  12597. },
  12598. f: function () {
  12599. try {
  12600. if (!normalCompletion && it.return != null) it.return();
  12601. } finally {
  12602. if (didErr) throw err;
  12603. }
  12604. }
  12605. };
  12606. }
  12607. function _unsupportedIterableToArray(o, minLen) {
  12608. var _context21;
  12609. if (!o) return;
  12610. if (typeof o === "string") return _arrayLikeToArray(o, minLen);
  12611. var n = _sliceInstanceProperty(_context21 = Object.prototype.toString.call(o)).call(_context21, 8, -1);
  12612. if (n === "Object" && o.constructor) n = o.constructor.name;
  12613. if (n === "Map" || n === "Set") return _Array$from(o);
  12614. if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen);
  12615. }
  12616. function _arrayLikeToArray(arr, len) {
  12617. if (len == null || len > arr.length) len = arr.length;
  12618. for (var i = 0, arr2 = new Array(len); i < len; i++) {
  12619. arr2[i] = arr[i];
  12620. }
  12621. return arr2;
  12622. }
  12623. function ownKeys(object, enumerableOnly) {
  12624. var keys = _Object$keys2(object);
  12625. if (_Object$getOwnPropertySymbols) {
  12626. var symbols = _Object$getOwnPropertySymbols(object);
  12627. enumerableOnly && (symbols = _filterInstanceProperty(symbols).call(symbols, function (sym) {
  12628. return _Object$getOwnPropertyDescriptor(object, sym).enumerable;
  12629. })), keys.push.apply(keys, symbols);
  12630. }
  12631. return keys;
  12632. }
  12633. function _objectSpread(target) {
  12634. for (var i = 1; i < arguments.length; i++) {
  12635. var _context19, _context20;
  12636. var source = null != arguments[i] ? arguments[i] : {};
  12637. i % 2 ? _forEachInstanceProperty2(_context19 = ownKeys(Object(source), !0)).call(_context19, function (key) {
  12638. (0, _defineProperty2.default)(target, key, source[key]);
  12639. }) : _Object$getOwnPropertyDescriptors ? _Object$defineProperties(target, _Object$getOwnPropertyDescriptors(source)) : _forEachInstanceProperty2(_context20 = ownKeys(Object(source))).call(_context20, function (key) {
  12640. _Object$defineProperty2(target, key, _Object$getOwnPropertyDescriptor(source, key));
  12641. });
  12642. }
  12643. return target;
  12644. }
  12645. var _require = _dereq_('uuid'),
  12646. uuidv4 = _require.v4;
  12647. /*:: export type Pointer = {
  12648. __type: string,
  12649. className: string,
  12650. objectId: string,
  12651. };*/
  12652. /*:: type SaveParams = {
  12653. method: string,
  12654. path: string,
  12655. body: AttributeMap,
  12656. };*/
  12657. /*:: type SaveOptions = FullOptions & {
  12658. cascadeSave?: boolean,
  12659. context?: AttributeMap,
  12660. };*/
  12661. // Mapping of class names to constructors, so we can populate objects from the
  12662. // server with appropriate subclasses of ParseObject
  12663. var classMap = {}; // Global counter for generating unique Ids for non-single-instance objects
  12664. var objectCount = 0; // On web clients, objects are single-instance: any two objects with the same Id
  12665. // will have the same attributes. However, this may be dangerous default
  12666. // behavior in a server scenario
  12667. var singleInstance = !_CoreManager.default.get('IS_NODE');
  12668. if (singleInstance) {
  12669. _CoreManager.default.setObjectStateController(SingleInstanceStateController);
  12670. } else {
  12671. _CoreManager.default.setObjectStateController(UniqueInstanceStateController);
  12672. }
  12673. function getServerUrlPath() {
  12674. var serverUrl = _CoreManager.default.get('SERVER_URL');
  12675. if (serverUrl[serverUrl.length - 1] !== '/') {
  12676. serverUrl += '/';
  12677. }
  12678. var url = serverUrl.replace(/https?:\/\//, '');
  12679. return url.substr((0, _indexOf.default)(url).call(url, '/'));
  12680. }
  12681. /**
  12682. * Creates a new model with defined attributes.
  12683. *
  12684. * <p>You won't normally call this method directly. It is recommended that
  12685. * you use a subclass of <code>Parse.Object</code> instead, created by calling
  12686. * <code>extend</code>.</p>
  12687. *
  12688. * <p>However, if you don't want to use a subclass, or aren't sure which
  12689. * subclass is appropriate, you can use this form:<pre>
  12690. * var object = new Parse.Object("ClassName");
  12691. * </pre>
  12692. * That is basically equivalent to:<pre>
  12693. * var MyClass = Parse.Object.extend("ClassName");
  12694. * var object = new MyClass();
  12695. * </pre></p>
  12696. *
  12697. * @alias Parse.Object
  12698. */
  12699. var ParseObject = /*#__PURE__*/function () {
  12700. /**
  12701. * @param {string} className The class name for the object
  12702. * @param {object} attributes The initial set of data to store in the object.
  12703. * @param {object} options The options for this object instance.
  12704. */
  12705. function ParseObject(className
  12706. /*: ?string | { className: string, [attr: string]: mixed }*/
  12707. , attributes
  12708. /*:: ?: { [attr: string]: mixed }*/
  12709. , options
  12710. /*:: ?: { ignoreValidation: boolean }*/
  12711. ) {
  12712. (0, _classCallCheck2.default)(this, ParseObject);
  12713. (0, _defineProperty2.default)(this, "id", void 0);
  12714. (0, _defineProperty2.default)(this, "_localId", void 0);
  12715. (0, _defineProperty2.default)(this, "_objCount", void 0);
  12716. (0, _defineProperty2.default)(this, "className", void 0); // Enable legacy initializers
  12717. if (typeof this.initialize === 'function') {
  12718. this.initialize.apply(this, arguments);
  12719. }
  12720. var toSet = null;
  12721. this._objCount = objectCount++;
  12722. if (typeof className === 'string') {
  12723. this.className = className;
  12724. if (attributes && (0, _typeof2.default)(attributes) === 'object') {
  12725. toSet = attributes;
  12726. }
  12727. } else if (className && (0, _typeof2.default)(className) === 'object') {
  12728. this.className = className.className;
  12729. toSet = {};
  12730. for (var _attr in className) {
  12731. if (_attr !== 'className') {
  12732. toSet[_attr] = className[_attr];
  12733. }
  12734. }
  12735. if (attributes && (0, _typeof2.default)(attributes) === 'object') {
  12736. options = attributes;
  12737. }
  12738. }
  12739. if (toSet && !this.set(toSet, options)) {
  12740. throw new Error("Can't create an invalid Parse Object");
  12741. }
  12742. }
  12743. /**
  12744. * The ID of this object, unique within its class.
  12745. *
  12746. * @property {string} id
  12747. */
  12748. (0, _createClass2.default)(ParseObject, [{
  12749. key: "attributes",
  12750. get:
  12751. /** Prototype getters / setters * */
  12752. function ()
  12753. /*: AttributeMap*/
  12754. {
  12755. var stateController = _CoreManager.default.getObjectStateController();
  12756. return (0, _freeze.default)(stateController.estimateAttributes(this._getStateIdentifier()));
  12757. }
  12758. /**
  12759. * The first time this object was saved on the server.
  12760. *
  12761. * @property {Date} createdAt
  12762. * @returns {Date}
  12763. */
  12764. }, {
  12765. key: "createdAt",
  12766. get: function ()
  12767. /*: ?Date*/
  12768. {
  12769. return this._getServerData().createdAt;
  12770. }
  12771. /**
  12772. * The last time this object was updated on the server.
  12773. *
  12774. * @property {Date} updatedAt
  12775. * @returns {Date}
  12776. */
  12777. }, {
  12778. key: "updatedAt",
  12779. get: function ()
  12780. /*: ?Date*/
  12781. {
  12782. return this._getServerData().updatedAt;
  12783. }
  12784. /** Private methods * */
  12785. /**
  12786. * Returns a local or server Id used uniquely identify this object
  12787. *
  12788. * @returns {string}
  12789. */
  12790. }, {
  12791. key: "_getId",
  12792. value: function ()
  12793. /*: string*/
  12794. {
  12795. if (typeof this.id === 'string') {
  12796. return this.id;
  12797. }
  12798. if (typeof this._localId === 'string') {
  12799. return this._localId;
  12800. }
  12801. var localId = "local".concat(uuidv4());
  12802. this._localId = localId;
  12803. return localId;
  12804. }
  12805. /**
  12806. * Returns a unique identifier used to pull data from the State Controller.
  12807. *
  12808. * @returns {Parse.Object|object}
  12809. */
  12810. }, {
  12811. key: "_getStateIdentifier",
  12812. value: function ()
  12813. /*: ParseObject | { id: string, className: string }*/
  12814. {
  12815. if (singleInstance) {
  12816. var id = this.id;
  12817. if (!id) {
  12818. id = this._getId();
  12819. }
  12820. return {
  12821. id: id,
  12822. className: this.className
  12823. };
  12824. }
  12825. return this;
  12826. }
  12827. }, {
  12828. key: "_getServerData",
  12829. value: function ()
  12830. /*: AttributeMap*/
  12831. {
  12832. var stateController = _CoreManager.default.getObjectStateController();
  12833. return stateController.getServerData(this._getStateIdentifier());
  12834. }
  12835. }, {
  12836. key: "_clearServerData",
  12837. value: function () {
  12838. var serverData = this._getServerData();
  12839. var unset = {};
  12840. for (var _attr2 in serverData) {
  12841. unset[_attr2] = undefined;
  12842. }
  12843. var stateController = _CoreManager.default.getObjectStateController();
  12844. stateController.setServerData(this._getStateIdentifier(), unset);
  12845. }
  12846. }, {
  12847. key: "_getPendingOps",
  12848. value: function ()
  12849. /*: Array<OpsMap>*/
  12850. {
  12851. var stateController = _CoreManager.default.getObjectStateController();
  12852. return stateController.getPendingOps(this._getStateIdentifier());
  12853. }
  12854. /**
  12855. * @param {Array<string>} [keysToClear] - if specified, only ops matching
  12856. * these fields will be cleared
  12857. */
  12858. }, {
  12859. key: "_clearPendingOps",
  12860. value: function (keysToClear
  12861. /*:: ?: Array<string>*/
  12862. ) {
  12863. var pending = this._getPendingOps();
  12864. var latest = pending[pending.length - 1];
  12865. var keys = keysToClear || (0, _keys.default)(latest);
  12866. (0, _forEach.default)(keys).call(keys, function (key) {
  12867. delete latest[key];
  12868. });
  12869. }
  12870. }, {
  12871. key: "_getDirtyObjectAttributes",
  12872. value: function ()
  12873. /*: AttributeMap*/
  12874. {
  12875. var attributes = this.attributes;
  12876. var stateController = _CoreManager.default.getObjectStateController();
  12877. var objectCache = stateController.getObjectCache(this._getStateIdentifier());
  12878. var dirty = {};
  12879. for (var _attr3 in attributes) {
  12880. var val = attributes[_attr3];
  12881. if (val && (0, _typeof2.default)(val) === 'object' && !(val instanceof ParseObject) && !(val instanceof _ParseFile.default) && !(val instanceof _ParseRelation.default)) {
  12882. // Due to the way browsers construct maps, the key order will not change
  12883. // unless the object is changed
  12884. try {
  12885. var json = (0, _encode.default)(val, false, true);
  12886. var stringified = (0, _stringify.default)(json);
  12887. if (objectCache[_attr3] !== stringified) {
  12888. dirty[_attr3] = val;
  12889. }
  12890. } catch (e) {
  12891. // Error occurred, possibly by a nested unsaved pointer in a mutable container
  12892. // No matter how it happened, it indicates a change in the attribute
  12893. dirty[_attr3] = val;
  12894. }
  12895. }
  12896. }
  12897. return dirty;
  12898. }
  12899. }, {
  12900. key: "_toFullJSON",
  12901. value: function (seen
  12902. /*:: ?: Array<any>*/
  12903. , offline
  12904. /*:: ?: boolean*/
  12905. )
  12906. /*: AttributeMap*/
  12907. {
  12908. var json
  12909. /*: { [key: string]: mixed }*/
  12910. = this.toJSON(seen, offline);
  12911. json.__type = 'Object';
  12912. json.className = this.className;
  12913. return json;
  12914. }
  12915. }, {
  12916. key: "_getSaveJSON",
  12917. value: function ()
  12918. /*: AttributeMap*/
  12919. {
  12920. var pending = this._getPendingOps();
  12921. var dirtyObjects = this._getDirtyObjectAttributes();
  12922. var json = {};
  12923. for (var attr in dirtyObjects) {
  12924. var isDotNotation = false;
  12925. for (var i = 0; i < pending.length; i += 1) {
  12926. for (var field in pending[i]) {
  12927. // Dot notation operations are handled later
  12928. if ((0, _includes.default)(field).call(field, '.')) {
  12929. var fieldName = field.split('.')[0];
  12930. if (fieldName === attr) {
  12931. isDotNotation = true;
  12932. break;
  12933. }
  12934. }
  12935. }
  12936. }
  12937. if (!isDotNotation) {
  12938. json[attr] = new _ParseOp.SetOp(dirtyObjects[attr]).toJSON();
  12939. }
  12940. }
  12941. for (attr in pending[0]) {
  12942. json[attr] = pending[0][attr].toJSON();
  12943. }
  12944. return json;
  12945. }
  12946. }, {
  12947. key: "_getSaveParams",
  12948. value: function ()
  12949. /*: SaveParams*/
  12950. {
  12951. var method = this.id ? 'PUT' : 'POST';
  12952. var body = this._getSaveJSON();
  12953. var path = "classes/".concat(this.className);
  12954. if (this.id) {
  12955. path += "/".concat(this.id);
  12956. } else if (this.className === '_User') {
  12957. path = 'users';
  12958. }
  12959. return {
  12960. method: method,
  12961. body: body,
  12962. path: path
  12963. };
  12964. }
  12965. }, {
  12966. key: "_finishFetch",
  12967. value: function (serverData
  12968. /*: AttributeMap*/
  12969. ) {
  12970. if (!this.id && serverData.objectId) {
  12971. this.id = serverData.objectId;
  12972. }
  12973. var stateController = _CoreManager.default.getObjectStateController();
  12974. stateController.initializeState(this._getStateIdentifier());
  12975. var decoded = {};
  12976. for (var _attr4 in serverData) {
  12977. if (_attr4 === 'ACL') {
  12978. decoded[_attr4] = new _ParseACL.default(serverData[_attr4]);
  12979. } else if (_attr4 !== 'objectId') {
  12980. decoded[_attr4] = (0, _decode.default)(serverData[_attr4]);
  12981. if (decoded[_attr4] instanceof _ParseRelation.default) {
  12982. decoded[_attr4]._ensureParentAndKey(this, _attr4);
  12983. }
  12984. }
  12985. }
  12986. if (decoded.createdAt && typeof decoded.createdAt === 'string') {
  12987. decoded.createdAt = (0, _parseDate.default)(decoded.createdAt);
  12988. }
  12989. if (decoded.updatedAt && typeof decoded.updatedAt === 'string') {
  12990. decoded.updatedAt = (0, _parseDate.default)(decoded.updatedAt);
  12991. }
  12992. if (!decoded.updatedAt && decoded.createdAt) {
  12993. decoded.updatedAt = decoded.createdAt;
  12994. }
  12995. stateController.commitServerChanges(this._getStateIdentifier(), decoded);
  12996. }
  12997. }, {
  12998. key: "_setExisted",
  12999. value: function (existed
  13000. /*: boolean*/
  13001. ) {
  13002. var stateController = _CoreManager.default.getObjectStateController();
  13003. var state = stateController.getState(this._getStateIdentifier());
  13004. if (state) {
  13005. state.existed = existed;
  13006. }
  13007. }
  13008. }, {
  13009. key: "_migrateId",
  13010. value: function (serverId
  13011. /*: string*/
  13012. ) {
  13013. if (this._localId && serverId) {
  13014. if (singleInstance) {
  13015. var stateController = _CoreManager.default.getObjectStateController();
  13016. var oldState = stateController.removeState(this._getStateIdentifier());
  13017. this.id = serverId;
  13018. delete this._localId;
  13019. if (oldState) {
  13020. stateController.initializeState(this._getStateIdentifier(), oldState);
  13021. }
  13022. } else {
  13023. this.id = serverId;
  13024. delete this._localId;
  13025. }
  13026. }
  13027. }
  13028. }, {
  13029. key: "_handleSaveResponse",
  13030. value: function (response
  13031. /*: AttributeMap*/
  13032. , status
  13033. /*: number*/
  13034. ) {
  13035. var changes = {};
  13036. var stateController = _CoreManager.default.getObjectStateController();
  13037. var pending = stateController.popPendingState(this._getStateIdentifier());
  13038. for (var attr in pending) {
  13039. if (pending[attr] instanceof _ParseOp.RelationOp) {
  13040. changes[attr] = pending[attr].applyTo(undefined, this, attr);
  13041. } else if (!(attr in response) && !(0, _includes.default)(attr).call(attr, '.')) {
  13042. // Only SetOps and UnsetOps should not come back with results
  13043. changes[attr] = pending[attr].applyTo(undefined);
  13044. }
  13045. }
  13046. for (attr in response) {
  13047. if ((attr === 'createdAt' || attr === 'updatedAt') && typeof response[attr] === 'string') {
  13048. changes[attr] = (0, _parseDate.default)(response[attr]);
  13049. } else if (attr === 'ACL') {
  13050. changes[attr] = new _ParseACL.default(response[attr]);
  13051. } else if (attr !== 'objectId') {
  13052. var val = (0, _decode.default)(response[attr]);
  13053. if (val && (0, _getPrototypeOf.default)(val) === Object.prototype) {
  13054. changes[attr] = _objectSpread(_objectSpread({}, this.attributes[attr]), val);
  13055. } else {
  13056. changes[attr] = val;
  13057. }
  13058. if (changes[attr] instanceof _ParseOp.UnsetOp) {
  13059. changes[attr] = undefined;
  13060. }
  13061. }
  13062. }
  13063. if (changes.createdAt && !changes.updatedAt) {
  13064. changes.updatedAt = changes.createdAt;
  13065. }
  13066. this._migrateId(response.objectId);
  13067. if (status !== 201) {
  13068. this._setExisted(true);
  13069. }
  13070. stateController.commitServerChanges(this._getStateIdentifier(), changes);
  13071. }
  13072. }, {
  13073. key: "_handleSaveError",
  13074. value: function () {
  13075. var stateController = _CoreManager.default.getObjectStateController();
  13076. stateController.mergeFirstPendingState(this._getStateIdentifier());
  13077. }
  13078. /** Public methods * */
  13079. }, {
  13080. key: "initialize",
  13081. value: function () {// NOOP
  13082. }
  13083. /**
  13084. * Returns a JSON version of the object suitable for saving to Parse.
  13085. *
  13086. * @param seen
  13087. * @param offline
  13088. * @returns {object}
  13089. */
  13090. }, {
  13091. key: "toJSON",
  13092. value: function (seen
  13093. /*: Array<any> | void*/
  13094. , offline
  13095. /*:: ?: boolean*/
  13096. )
  13097. /*: AttributeMap*/
  13098. {
  13099. var _context;
  13100. var seenEntry = this.id ? (0, _concat.default)(_context = "".concat(this.className, ":")).call(_context, this.id) : this;
  13101. seen = seen || [seenEntry];
  13102. var json = {};
  13103. var attrs = this.attributes;
  13104. for (var _attr5 in attrs) {
  13105. if ((_attr5 === 'createdAt' || _attr5 === 'updatedAt') && attrs[_attr5].toJSON) {
  13106. json[_attr5] = attrs[_attr5].toJSON();
  13107. } else {
  13108. json[_attr5] = (0, _encode.default)(attrs[_attr5], false, false, seen, offline);
  13109. }
  13110. }
  13111. var pending = this._getPendingOps();
  13112. for (var _attr6 in pending[0]) {
  13113. json[_attr6] = pending[0][_attr6].toJSON(offline);
  13114. }
  13115. if (this.id) {
  13116. json.objectId = this.id;
  13117. }
  13118. return json;
  13119. }
  13120. /**
  13121. * Determines whether this ParseObject is equal to another ParseObject
  13122. *
  13123. * @param {object} other - An other object ot compare
  13124. * @returns {boolean}
  13125. */
  13126. }, {
  13127. key: "equals",
  13128. value: function (other
  13129. /*: mixed*/
  13130. )
  13131. /*: boolean*/
  13132. {
  13133. if (this === other) {
  13134. return true;
  13135. }
  13136. return other instanceof ParseObject && this.className === other.className && this.id === other.id && typeof this.id !== 'undefined';
  13137. }
  13138. /**
  13139. * Returns true if this object has been modified since its last
  13140. * save/refresh. If an attribute is specified, it returns true only if that
  13141. * particular attribute has been modified since the last save/refresh.
  13142. *
  13143. * @param {string} attr An attribute name (optional).
  13144. * @returns {boolean}
  13145. */
  13146. }, {
  13147. key: "dirty",
  13148. value: function (attr
  13149. /*:: ?: string*/
  13150. )
  13151. /*: boolean*/
  13152. {
  13153. if (!this.id) {
  13154. return true;
  13155. }
  13156. var pendingOps = this._getPendingOps();
  13157. var dirtyObjects = this._getDirtyObjectAttributes();
  13158. if (attr) {
  13159. if (dirtyObjects.hasOwnProperty(attr)) {
  13160. return true;
  13161. }
  13162. for (var i = 0; i < pendingOps.length; i++) {
  13163. if (pendingOps[i].hasOwnProperty(attr)) {
  13164. return true;
  13165. }
  13166. }
  13167. return false;
  13168. }
  13169. if ((0, _keys.default)(pendingOps[0]).length !== 0) {
  13170. return true;
  13171. }
  13172. if ((0, _keys.default)(dirtyObjects).length !== 0) {
  13173. return true;
  13174. }
  13175. return false;
  13176. }
  13177. /**
  13178. * Returns an array of keys that have been modified since last save/refresh
  13179. *
  13180. * @returns {string[]}
  13181. */
  13182. }, {
  13183. key: "dirtyKeys",
  13184. value: function ()
  13185. /*: Array<string>*/
  13186. {
  13187. var pendingOps = this._getPendingOps();
  13188. var keys = {};
  13189. for (var i = 0; i < pendingOps.length; i++) {
  13190. for (var _attr7 in pendingOps[i]) {
  13191. keys[_attr7] = true;
  13192. }
  13193. }
  13194. var dirtyObjects = this._getDirtyObjectAttributes();
  13195. for (var _attr8 in dirtyObjects) {
  13196. keys[_attr8] = true;
  13197. }
  13198. return (0, _keys.default)(keys);
  13199. }
  13200. /**
  13201. * Returns true if the object has been fetched.
  13202. *
  13203. * @returns {boolean}
  13204. */
  13205. }, {
  13206. key: "isDataAvailable",
  13207. value: function ()
  13208. /*: boolean*/
  13209. {
  13210. var serverData = this._getServerData();
  13211. return !!(0, _keys.default)(serverData).length;
  13212. }
  13213. /**
  13214. * Gets a Pointer referencing this Object.
  13215. *
  13216. * @returns {Pointer}
  13217. */
  13218. }, {
  13219. key: "toPointer",
  13220. value: function ()
  13221. /*: Pointer*/
  13222. {
  13223. if (!this.id) {
  13224. throw new Error('Cannot create a pointer to an unsaved ParseObject');
  13225. }
  13226. return {
  13227. __type: 'Pointer',
  13228. className: this.className,
  13229. objectId: this.id
  13230. };
  13231. }
  13232. /**
  13233. * Gets a Pointer referencing this Object.
  13234. *
  13235. * @returns {Pointer}
  13236. */
  13237. }, {
  13238. key: "toOfflinePointer",
  13239. value: function ()
  13240. /*: Pointer*/
  13241. {
  13242. if (!this._localId) {
  13243. throw new Error('Cannot create a offline pointer to a saved ParseObject');
  13244. }
  13245. return {
  13246. __type: 'Object',
  13247. className: this.className,
  13248. _localId: this._localId
  13249. };
  13250. }
  13251. /**
  13252. * Gets the value of an attribute.
  13253. *
  13254. * @param {string} attr The string name of an attribute.
  13255. * @returns {*}
  13256. */
  13257. }, {
  13258. key: "get",
  13259. value: function (attr
  13260. /*: string*/
  13261. )
  13262. /*: mixed*/
  13263. {
  13264. return this.attributes[attr];
  13265. }
  13266. /**
  13267. * Gets a relation on the given class for the attribute.
  13268. *
  13269. * @param {string} attr The attribute to get the relation for.
  13270. * @returns {Parse.Relation}
  13271. */
  13272. }, {
  13273. key: "relation",
  13274. value: function (attr
  13275. /*: string*/
  13276. )
  13277. /*: ParseRelation*/
  13278. {
  13279. var value = this.get(attr);
  13280. if (value) {
  13281. if (!(value instanceof _ParseRelation.default)) {
  13282. throw new Error("Called relation() on non-relation field ".concat(attr));
  13283. }
  13284. value._ensureParentAndKey(this, attr);
  13285. return value;
  13286. }
  13287. return new _ParseRelation.default(this, attr);
  13288. }
  13289. /**
  13290. * Gets the HTML-escaped value of an attribute.
  13291. *
  13292. * @param {string} attr The string name of an attribute.
  13293. * @returns {string}
  13294. */
  13295. }, {
  13296. key: "escape",
  13297. value: function (attr
  13298. /*: string*/
  13299. )
  13300. /*: string*/
  13301. {
  13302. var val = this.attributes[attr];
  13303. if (val == null) {
  13304. return '';
  13305. }
  13306. if (typeof val !== 'string') {
  13307. if (typeof val.toString !== 'function') {
  13308. return '';
  13309. }
  13310. val = val.toString();
  13311. }
  13312. return (0, _escape2.default)(val);
  13313. }
  13314. /**
  13315. * Returns <code>true</code> if the attribute contains a value that is not
  13316. * null or undefined.
  13317. *
  13318. * @param {string} attr The string name of the attribute.
  13319. * @returns {boolean}
  13320. */
  13321. }, {
  13322. key: "has",
  13323. value: function (attr
  13324. /*: string*/
  13325. )
  13326. /*: boolean*/
  13327. {
  13328. var attributes = this.attributes;
  13329. if (attributes.hasOwnProperty(attr)) {
  13330. return attributes[attr] != null;
  13331. }
  13332. return false;
  13333. }
  13334. /**
  13335. * Sets a hash of model attributes on the object.
  13336. *
  13337. * <p>You can call it with an object containing keys and values, with one
  13338. * key and value, or dot notation. For example:<pre>
  13339. * gameTurn.set({
  13340. * player: player1,
  13341. * diceRoll: 2
  13342. * }, {
  13343. * error: function(gameTurnAgain, error) {
  13344. * // The set failed validation.
  13345. * }
  13346. * });
  13347. *
  13348. * game.set("currentPlayer", player2, {
  13349. * error: function(gameTurnAgain, error) {
  13350. * // The set failed validation.
  13351. * }
  13352. * });
  13353. *
  13354. * game.set("finished", true);</pre></p>
  13355. *
  13356. * game.set("player.score", 10);</pre></p>
  13357. *
  13358. * @param {(string|object)} key The key to set.
  13359. * @param {(string|object)} value The value to give it.
  13360. * @param {object} options A set of options for the set.
  13361. * The only supported option is <code>error</code>.
  13362. * @returns {(ParseObject|boolean)} true if the set succeeded.
  13363. */
  13364. }, {
  13365. key: "set",
  13366. value: function (key
  13367. /*: mixed*/
  13368. , value
  13369. /*: mixed*/
  13370. , options
  13371. /*:: ?: mixed*/
  13372. )
  13373. /*: ParseObject | boolean*/
  13374. {
  13375. var changes = {};
  13376. var newOps = {};
  13377. if (key && (0, _typeof2.default)(key) === 'object') {
  13378. changes = key;
  13379. options = value;
  13380. } else if (typeof key === 'string') {
  13381. changes[key] = value;
  13382. } else {
  13383. return this;
  13384. }
  13385. options = options || {};
  13386. var readonly = [];
  13387. if (typeof this.constructor.readOnlyAttributes === 'function') {
  13388. readonly = (0, _concat.default)(readonly).call(readonly, this.constructor.readOnlyAttributes());
  13389. }
  13390. for (var k in changes) {
  13391. if (k === 'createdAt' || k === 'updatedAt') {
  13392. // This property is read-only, but for legacy reasons we silently
  13393. // ignore it
  13394. continue;
  13395. }
  13396. if ((0, _indexOf.default)(readonly).call(readonly, k) > -1) {
  13397. throw new Error("Cannot modify readonly attribute: ".concat(k));
  13398. }
  13399. if (options.unset) {
  13400. newOps[k] = new _ParseOp.UnsetOp();
  13401. } else if (changes[k] instanceof _ParseOp.Op) {
  13402. newOps[k] = changes[k];
  13403. } else if (changes[k] && (0, _typeof2.default)(changes[k]) === 'object' && typeof changes[k].__op === 'string') {
  13404. newOps[k] = (0, _ParseOp.opFromJSON)(changes[k]);
  13405. } else if (k === 'objectId' || k === 'id') {
  13406. if (typeof changes[k] === 'string') {
  13407. this.id = changes[k];
  13408. }
  13409. } else if (k === 'ACL' && (0, _typeof2.default)(changes[k]) === 'object' && !(changes[k] instanceof _ParseACL.default)) {
  13410. newOps[k] = new _ParseOp.SetOp(new _ParseACL.default(changes[k]));
  13411. } else if (changes[k] instanceof _ParseRelation.default) {
  13412. var relation = new _ParseRelation.default(this, k);
  13413. relation.targetClassName = changes[k].targetClassName;
  13414. newOps[k] = new _ParseOp.SetOp(relation);
  13415. } else {
  13416. newOps[k] = new _ParseOp.SetOp(changes[k]);
  13417. }
  13418. }
  13419. var currentAttributes = this.attributes; // Only set nested fields if exists
  13420. var serverData = this._getServerData();
  13421. if (typeof key === 'string' && (0, _includes.default)(key).call(key, '.')) {
  13422. var field = key.split('.')[0];
  13423. if (!serverData[field]) {
  13424. return this;
  13425. }
  13426. } // Calculate new values
  13427. var newValues = {};
  13428. for (var _attr9 in newOps) {
  13429. if (newOps[_attr9] instanceof _ParseOp.RelationOp) {
  13430. newValues[_attr9] = newOps[_attr9].applyTo(currentAttributes[_attr9], this, _attr9);
  13431. } else if (!(newOps[_attr9] instanceof _ParseOp.UnsetOp)) {
  13432. newValues[_attr9] = newOps[_attr9].applyTo(currentAttributes[_attr9]);
  13433. }
  13434. } // Validate changes
  13435. if (!options.ignoreValidation) {
  13436. var validation = this.validate(newValues);
  13437. if (validation) {
  13438. if (typeof options.error === 'function') {
  13439. options.error(this, validation);
  13440. }
  13441. return false;
  13442. }
  13443. } // Consolidate Ops
  13444. var pendingOps = this._getPendingOps();
  13445. var last = pendingOps.length - 1;
  13446. var stateController = _CoreManager.default.getObjectStateController();
  13447. for (var _attr10 in newOps) {
  13448. var nextOp = newOps[_attr10].mergeWith(pendingOps[last][_attr10]);
  13449. stateController.setPendingOp(this._getStateIdentifier(), _attr10, nextOp);
  13450. }
  13451. return this;
  13452. }
  13453. /**
  13454. * Remove an attribute from the model. This is a noop if the attribute doesn't
  13455. * exist.
  13456. *
  13457. * @param {string} attr The string name of an attribute.
  13458. * @param options
  13459. * @returns {(ParseObject | boolean)}
  13460. */
  13461. }, {
  13462. key: "unset",
  13463. value: function (attr
  13464. /*: string*/
  13465. , options
  13466. /*:: ?: { [opt: string]: mixed }*/
  13467. )
  13468. /*: ParseObject | boolean*/
  13469. {
  13470. options = options || {};
  13471. options.unset = true;
  13472. return this.set(attr, null, options);
  13473. }
  13474. /**
  13475. * Atomically increments the value of the given attribute the next time the
  13476. * object is saved. If no amount is specified, 1 is used by default.
  13477. *
  13478. * @param attr {String} The key.
  13479. * @param amount {Number} The amount to increment by (optional).
  13480. * @returns {(ParseObject|boolean)}
  13481. */
  13482. }, {
  13483. key: "increment",
  13484. value: function (attr
  13485. /*: string*/
  13486. , amount
  13487. /*:: ?: number*/
  13488. )
  13489. /*: ParseObject | boolean*/
  13490. {
  13491. if (typeof amount === 'undefined') {
  13492. amount = 1;
  13493. }
  13494. if (typeof amount !== 'number') {
  13495. throw new Error('Cannot increment by a non-numeric amount.');
  13496. }
  13497. return this.set(attr, new _ParseOp.IncrementOp(amount));
  13498. }
  13499. /**
  13500. * Atomically decrements the value of the given attribute the next time the
  13501. * object is saved. If no amount is specified, 1 is used by default.
  13502. *
  13503. * @param attr {String} The key.
  13504. * @param amount {Number} The amount to decrement by (optional).
  13505. * @returns {(ParseObject | boolean)}
  13506. */
  13507. }, {
  13508. key: "decrement",
  13509. value: function (attr
  13510. /*: string*/
  13511. , amount
  13512. /*:: ?: number*/
  13513. )
  13514. /*: ParseObject | boolean*/
  13515. {
  13516. if (typeof amount === 'undefined') {
  13517. amount = 1;
  13518. }
  13519. if (typeof amount !== 'number') {
  13520. throw new Error('Cannot decrement by a non-numeric amount.');
  13521. }
  13522. return this.set(attr, new _ParseOp.IncrementOp(amount * -1));
  13523. }
  13524. /**
  13525. * Atomically add an object to the end of the array associated with a given
  13526. * key.
  13527. *
  13528. * @param attr {String} The key.
  13529. * @param item {} The item to add.
  13530. * @returns {(ParseObject | boolean)}
  13531. */
  13532. }, {
  13533. key: "add",
  13534. value: function (attr
  13535. /*: string*/
  13536. , item
  13537. /*: mixed*/
  13538. )
  13539. /*: ParseObject | boolean*/
  13540. {
  13541. return this.set(attr, new _ParseOp.AddOp([item]));
  13542. }
  13543. /**
  13544. * Atomically add the objects to the end of the array associated with a given
  13545. * key.
  13546. *
  13547. * @param attr {String} The key.
  13548. * @param items {Object[]} The items to add.
  13549. * @returns {(ParseObject | boolean)}
  13550. */
  13551. }, {
  13552. key: "addAll",
  13553. value: function (attr
  13554. /*: string*/
  13555. , items
  13556. /*: Array<mixed>*/
  13557. )
  13558. /*: ParseObject | boolean*/
  13559. {
  13560. return this.set(attr, new _ParseOp.AddOp(items));
  13561. }
  13562. /**
  13563. * Atomically add an object to the array associated with a given key, only
  13564. * if it is not already present in the array. The position of the insert is
  13565. * not guaranteed.
  13566. *
  13567. * @param attr {String} The key.
  13568. * @param item {} The object to add.
  13569. * @returns {(ParseObject | boolean)}
  13570. */
  13571. }, {
  13572. key: "addUnique",
  13573. value: function (attr
  13574. /*: string*/
  13575. , item
  13576. /*: mixed*/
  13577. )
  13578. /*: ParseObject | boolean*/
  13579. {
  13580. return this.set(attr, new _ParseOp.AddUniqueOp([item]));
  13581. }
  13582. /**
  13583. * Atomically add the objects to the array associated with a given key, only
  13584. * if it is not already present in the array. The position of the insert is
  13585. * not guaranteed.
  13586. *
  13587. * @param attr {String} The key.
  13588. * @param items {Object[]} The objects to add.
  13589. * @returns {(ParseObject | boolean)}
  13590. */
  13591. }, {
  13592. key: "addAllUnique",
  13593. value: function (attr
  13594. /*: string*/
  13595. , items
  13596. /*: Array<mixed>*/
  13597. )
  13598. /*: ParseObject | boolean*/
  13599. {
  13600. return this.set(attr, new _ParseOp.AddUniqueOp(items));
  13601. }
  13602. /**
  13603. * Atomically remove all instances of an object from the array associated
  13604. * with a given key.
  13605. *
  13606. * @param attr {String} The key.
  13607. * @param item {} The object to remove.
  13608. * @returns {(ParseObject | boolean)}
  13609. */
  13610. }, {
  13611. key: "remove",
  13612. value: function (attr
  13613. /*: string*/
  13614. , item
  13615. /*: mixed*/
  13616. )
  13617. /*: ParseObject | boolean*/
  13618. {
  13619. return this.set(attr, new _ParseOp.RemoveOp([item]));
  13620. }
  13621. /**
  13622. * Atomically remove all instances of the objects from the array associated
  13623. * with a given key.
  13624. *
  13625. * @param attr {String} The key.
  13626. * @param items {Object[]} The object to remove.
  13627. * @returns {(ParseObject | boolean)}
  13628. */
  13629. }, {
  13630. key: "removeAll",
  13631. value: function (attr
  13632. /*: string*/
  13633. , items
  13634. /*: Array<mixed>*/
  13635. )
  13636. /*: ParseObject | boolean*/
  13637. {
  13638. return this.set(attr, new _ParseOp.RemoveOp(items));
  13639. }
  13640. /**
  13641. * Returns an instance of a subclass of Parse.Op describing what kind of
  13642. * modification has been performed on this field since the last time it was
  13643. * saved. For example, after calling object.increment("x"), calling
  13644. * object.op("x") would return an instance of Parse.Op.Increment.
  13645. *
  13646. * @param attr {String} The key.
  13647. * @returns {Parse.Op} The operation, or undefined if none.
  13648. */
  13649. }, {
  13650. key: "op",
  13651. value: function (attr
  13652. /*: string*/
  13653. )
  13654. /*: ?Op*/
  13655. {
  13656. var pending = this._getPendingOps();
  13657. for (var i = pending.length; i--;) {
  13658. if (pending[i][attr]) {
  13659. return pending[i][attr];
  13660. }
  13661. }
  13662. }
  13663. /**
  13664. * Creates a new model with identical attributes to this one.
  13665. *
  13666. * @returns {Parse.Object}
  13667. */
  13668. }, {
  13669. key: "clone",
  13670. value: function clone()
  13671. /*: any*/
  13672. {
  13673. var clone = new this.constructor();
  13674. if (!clone.className) {
  13675. clone.className = this.className;
  13676. }
  13677. var attributes = this.attributes;
  13678. if (typeof this.constructor.readOnlyAttributes === 'function') {
  13679. var readonly = this.constructor.readOnlyAttributes() || []; // Attributes are frozen, so we have to rebuild an object,
  13680. // rather than delete readonly keys
  13681. var copy = {};
  13682. for (var a in attributes) {
  13683. if ((0, _indexOf.default)(readonly).call(readonly, a) < 0) {
  13684. copy[a] = attributes[a];
  13685. }
  13686. }
  13687. attributes = copy;
  13688. }
  13689. if (clone.set) {
  13690. clone.set(attributes);
  13691. }
  13692. return clone;
  13693. }
  13694. /**
  13695. * Creates a new instance of this object. Not to be confused with clone()
  13696. *
  13697. * @returns {Parse.Object}
  13698. */
  13699. }, {
  13700. key: "newInstance",
  13701. value: function ()
  13702. /*: any*/
  13703. {
  13704. var clone = new this.constructor();
  13705. if (!clone.className) {
  13706. clone.className = this.className;
  13707. }
  13708. clone.id = this.id;
  13709. if (singleInstance) {
  13710. // Just return an object with the right id
  13711. return clone;
  13712. }
  13713. var stateController = _CoreManager.default.getObjectStateController();
  13714. if (stateController) {
  13715. stateController.duplicateState(this._getStateIdentifier(), clone._getStateIdentifier());
  13716. }
  13717. return clone;
  13718. }
  13719. /**
  13720. * Returns true if this object has never been saved to Parse.
  13721. *
  13722. * @returns {boolean}
  13723. */
  13724. }, {
  13725. key: "isNew",
  13726. value: function ()
  13727. /*: boolean*/
  13728. {
  13729. return !this.id;
  13730. }
  13731. /**
  13732. * Returns true if this object was created by the Parse server when the
  13733. * object might have already been there (e.g. in the case of a Facebook
  13734. * login)
  13735. *
  13736. * @returns {boolean}
  13737. */
  13738. }, {
  13739. key: "existed",
  13740. value: function ()
  13741. /*: boolean*/
  13742. {
  13743. if (!this.id) {
  13744. return false;
  13745. }
  13746. var stateController = _CoreManager.default.getObjectStateController();
  13747. var state = stateController.getState(this._getStateIdentifier());
  13748. if (state) {
  13749. return state.existed;
  13750. }
  13751. return false;
  13752. }
  13753. /**
  13754. * Returns true if this object exists on the Server
  13755. *
  13756. * @param {object} options
  13757. * Valid options are:<ul>
  13758. * <li>useMasterKey: In Cloud Code and Node only, causes the Master Key to
  13759. * be used for this request.
  13760. * <li>sessionToken: A valid session token, used for making a request on
  13761. * behalf of a specific user.
  13762. * </ul>
  13763. * @returns {Promise<boolean>} A boolean promise that is fulfilled if object exists.
  13764. */
  13765. }, {
  13766. key: "exists",
  13767. value: function () {
  13768. var _exists = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee(options
  13769. /*:: ?: RequestOptions*/
  13770. ) {
  13771. var query;
  13772. return _regenerator.default.wrap(function (_context2) {
  13773. while (1) {
  13774. switch (_context2.prev = _context2.next) {
  13775. case 0:
  13776. if (this.id) {
  13777. _context2.next = 2;
  13778. break;
  13779. }
  13780. return _context2.abrupt("return", false);
  13781. case 2:
  13782. _context2.prev = 2;
  13783. query = new _ParseQuery.default(this.className);
  13784. _context2.next = 6;
  13785. return query.get(this.id, options);
  13786. case 6:
  13787. return _context2.abrupt("return", true);
  13788. case 9:
  13789. _context2.prev = 9;
  13790. _context2.t0 = _context2["catch"](2);
  13791. if (!(_context2.t0.code === _ParseError.default.OBJECT_NOT_FOUND)) {
  13792. _context2.next = 13;
  13793. break;
  13794. }
  13795. return _context2.abrupt("return", false);
  13796. case 13:
  13797. throw _context2.t0;
  13798. case 14:
  13799. case "end":
  13800. return _context2.stop();
  13801. }
  13802. }
  13803. }, _callee, this, [[2, 9]]);
  13804. }));
  13805. return function () {
  13806. return _exists.apply(this, arguments);
  13807. };
  13808. }()
  13809. /**
  13810. * Checks if the model is currently in a valid state.
  13811. *
  13812. * @returns {boolean}
  13813. */
  13814. }, {
  13815. key: "isValid",
  13816. value: function ()
  13817. /*: boolean*/
  13818. {
  13819. return !this.validate(this.attributes);
  13820. }
  13821. /**
  13822. * You should not call this function directly unless you subclass
  13823. * <code>Parse.Object</code>, in which case you can override this method
  13824. * to provide additional validation on <code>set</code> and
  13825. * <code>save</code>. Your implementation should return
  13826. *
  13827. * @param {object} attrs The current data to validate.
  13828. * @returns {Parse.Error|boolean} False if the data is valid. An error object otherwise.
  13829. * @see Parse.Object#set
  13830. */
  13831. }, {
  13832. key: "validate",
  13833. value: function (attrs
  13834. /*: AttributeMap*/
  13835. )
  13836. /*: ParseError | boolean*/
  13837. {
  13838. if (attrs.hasOwnProperty('ACL') && !(attrs.ACL instanceof _ParseACL.default)) {
  13839. return new _ParseError.default(_ParseError.default.OTHER_CAUSE, 'ACL must be a Parse ACL.');
  13840. }
  13841. for (var _key in attrs) {
  13842. if (!/^[A-Za-z][0-9A-Za-z_.]*$/.test(_key)) {
  13843. return new _ParseError.default(_ParseError.default.INVALID_KEY_NAME);
  13844. }
  13845. }
  13846. return false;
  13847. }
  13848. /**
  13849. * Returns the ACL for this object.
  13850. *
  13851. * @returns {Parse.ACL} An instance of Parse.ACL.
  13852. * @see Parse.Object#get
  13853. */
  13854. }, {
  13855. key: "getACL",
  13856. value: function ()
  13857. /*: ?ParseACL*/
  13858. {
  13859. var acl = this.get('ACL');
  13860. if (acl instanceof _ParseACL.default) {
  13861. return acl;
  13862. }
  13863. return null;
  13864. }
  13865. /**
  13866. * Sets the ACL to be used for this object.
  13867. *
  13868. * @param {Parse.ACL} acl An instance of Parse.ACL.
  13869. * @param {object} options
  13870. * @returns {(ParseObject | boolean)} Whether the set passed validation.
  13871. * @see Parse.Object#set
  13872. */
  13873. }, {
  13874. key: "setACL",
  13875. value: function (acl
  13876. /*: ParseACL*/
  13877. , options
  13878. /*:: ?: mixed*/
  13879. )
  13880. /*: ParseObject | boolean*/
  13881. {
  13882. return this.set('ACL', acl, options);
  13883. }
  13884. /**
  13885. * Clears any (or specific) changes to this object made since the last call to save()
  13886. *
  13887. * @param {string} [keys] - specify which fields to revert
  13888. */
  13889. }, {
  13890. key: "revert",
  13891. value: function ()
  13892. /*: void*/
  13893. {
  13894. var keysToRevert;
  13895. for (var _len = arguments.length, keys = new Array(_len), _key2 = 0; _key2 < _len; _key2++) {
  13896. keys[_key2] = arguments[_key2];
  13897. }
  13898. if (keys.length) {
  13899. keysToRevert = [];
  13900. var _iterator = _createForOfIteratorHelper(keys),
  13901. _step;
  13902. try {
  13903. for (_iterator.s(); !(_step = _iterator.n()).done;) {
  13904. var _key3 = _step.value;
  13905. if (typeof _key3 === 'string') {
  13906. keysToRevert.push(_key3);
  13907. } else {
  13908. throw new Error('Parse.Object#revert expects either no, or a list of string, arguments.');
  13909. }
  13910. }
  13911. } catch (err) {
  13912. _iterator.e(err);
  13913. } finally {
  13914. _iterator.f();
  13915. }
  13916. }
  13917. this._clearPendingOps(keysToRevert);
  13918. }
  13919. /**
  13920. * Clears all attributes on a model
  13921. *
  13922. * @returns {(ParseObject | boolean)}
  13923. */
  13924. }, {
  13925. key: "clear",
  13926. value: function ()
  13927. /*: ParseObject | boolean*/
  13928. {
  13929. var attributes = this.attributes;
  13930. var erasable = {};
  13931. var readonly = ['createdAt', 'updatedAt'];
  13932. if (typeof this.constructor.readOnlyAttributes === 'function') {
  13933. readonly = (0, _concat.default)(readonly).call(readonly, this.constructor.readOnlyAttributes());
  13934. }
  13935. for (var _attr11 in attributes) {
  13936. if ((0, _indexOf.default)(readonly).call(readonly, _attr11) < 0) {
  13937. erasable[_attr11] = true;
  13938. }
  13939. }
  13940. return this.set(erasable, {
  13941. unset: true
  13942. });
  13943. }
  13944. /**
  13945. * Fetch the model from the server. If the server's representation of the
  13946. * model differs from its current attributes, they will be overriden.
  13947. *
  13948. * @param {object} options
  13949. * Valid options are:<ul>
  13950. * <li>useMasterKey: In Cloud Code and Node only, causes the Master Key to
  13951. * be used for this request.
  13952. * <li>sessionToken: A valid session token, used for making a request on
  13953. * behalf of a specific user.
  13954. * <li>include: The name(s) of the key(s) to include. Can be a string, an array of strings,
  13955. * or an array of array of strings.
  13956. * <li>context: A dictionary that is accessible in Cloud Code `beforeFind` trigger.
  13957. * </ul>
  13958. * @returns {Promise} A promise that is fulfilled when the fetch
  13959. * completes.
  13960. */
  13961. }, {
  13962. key: "fetch",
  13963. value: function (options
  13964. /*: RequestOptions*/
  13965. )
  13966. /*: Promise*/
  13967. {
  13968. options = options || {};
  13969. var fetchOptions = {};
  13970. if (options.hasOwnProperty('useMasterKey')) {
  13971. fetchOptions.useMasterKey = options.useMasterKey;
  13972. }
  13973. if (options.hasOwnProperty('sessionToken')) {
  13974. fetchOptions.sessionToken = options.sessionToken;
  13975. }
  13976. if (options.hasOwnProperty('context') && (0, _typeof2.default)(options.context) === 'object') {
  13977. fetchOptions.context = options.context;
  13978. }
  13979. if (options.hasOwnProperty('include')) {
  13980. fetchOptions.include = [];
  13981. if ((0, _isArray.default)(options.include)) {
  13982. var _context3;
  13983. (0, _forEach.default)(_context3 = options.include).call(_context3, function (key) {
  13984. if ((0, _isArray.default)(key)) {
  13985. var _context4;
  13986. fetchOptions.include = (0, _concat.default)(_context4 = fetchOptions.include).call(_context4, key);
  13987. } else {
  13988. fetchOptions.include.push(key);
  13989. }
  13990. });
  13991. } else {
  13992. fetchOptions.include.push(options.include);
  13993. }
  13994. }
  13995. var controller = _CoreManager.default.getObjectController();
  13996. return controller.fetch(this, true, fetchOptions);
  13997. }
  13998. /**
  13999. * Fetch the model from the server. If the server's representation of the
  14000. * model differs from its current attributes, they will be overriden.
  14001. *
  14002. * Includes nested Parse.Objects for the provided key. You can use dot
  14003. * notation to specify which fields in the included object are also fetched.
  14004. *
  14005. * @param {string | Array<string | Array<string>>} keys The name(s) of the key(s) to include.
  14006. * @param {object} options
  14007. * Valid options are:<ul>
  14008. * <li>useMasterKey: In Cloud Code and Node only, causes the Master Key to
  14009. * be used for this request.
  14010. * <li>sessionToken: A valid session token, used for making a request on
  14011. * behalf of a specific user.
  14012. * </ul>
  14013. * @returns {Promise} A promise that is fulfilled when the fetch
  14014. * completes.
  14015. */
  14016. }, {
  14017. key: "fetchWithInclude",
  14018. value: function (keys
  14019. /*: String | Array<string | Array<string>>*/
  14020. , options
  14021. /*: RequestOptions*/
  14022. )
  14023. /*: Promise*/
  14024. {
  14025. options = options || {};
  14026. options.include = keys;
  14027. return this.fetch(options);
  14028. }
  14029. /**
  14030. * Set a hash of model attributes, and save the model to the server.
  14031. * updatedAt will be updated when the request returns.
  14032. * You can either call it as:<pre>
  14033. * object.save();</pre>
  14034. * or<pre>
  14035. * object.save(attrs);</pre>
  14036. * or<pre>
  14037. * object.save(null, options);</pre>
  14038. * or<pre>
  14039. * object.save(attrs, options);</pre>
  14040. * or<pre>
  14041. * object.save(key, value, options);</pre>
  14042. *
  14043. * For example, <pre>
  14044. * gameTurn.save({
  14045. * player: "Jake Cutter",
  14046. * diceRoll: 2
  14047. * }).then(function(gameTurnAgain) {
  14048. * // The save was successful.
  14049. * }, function(error) {
  14050. * // The save failed. Error is an instance of Parse.Error.
  14051. * });</pre>
  14052. *
  14053. * @param {string | object | null} [arg1]
  14054. * Valid options are:<ul>
  14055. * <li>`Object` - Key/value pairs to update on the object.</li>
  14056. * <li>`String` Key - Key of attribute to update (requires arg2 to also be string)</li>
  14057. * <li>`null` - Passing null for arg1 allows you to save the object with options passed in arg2.</li>
  14058. * </ul>
  14059. * @param {string | object} [arg2]
  14060. * <ul>
  14061. * <li>`String` Value - If arg1 was passed as a key, arg2 is the value that should be set on that key.</li>
  14062. * <li>`Object` Options - Valid options are:
  14063. * <ul>
  14064. * <li>useMasterKey: In Cloud Code and Node only, causes the Master Key to
  14065. * be used for this request.
  14066. * <li>sessionToken: A valid session token, used for making a request on
  14067. * behalf of a specific user.
  14068. * <li>cascadeSave: If `false`, nested objects will not be saved (default is `true`).
  14069. * <li>context: A dictionary that is accessible in Cloud Code `beforeSave` and `afterSave` triggers.
  14070. * </ul>
  14071. * </li>
  14072. * </ul>
  14073. * @param {object} [arg3]
  14074. * Used to pass option parameters to method if arg1 and arg2 were both passed as strings.
  14075. * Valid options are:
  14076. * <ul>
  14077. * <li>useMasterKey: In Cloud Code and Node only, causes the Master Key to
  14078. * be used for this request.
  14079. * <li>sessionToken: A valid session token, used for making a request on
  14080. * behalf of a specific user.
  14081. * <li>cascadeSave: If `false`, nested objects will not be saved (default is `true`).
  14082. * <li>context: A dictionary that is accessible in Cloud Code `beforeSave` and `afterSave` triggers.
  14083. * </ul>
  14084. * @returns {Promise} A promise that is fulfilled when the save
  14085. * completes.
  14086. */
  14087. }, {
  14088. key: "save",
  14089. value: function (arg1
  14090. /*: ?string | { [attr: string]: mixed }*/
  14091. , arg2
  14092. /*: SaveOptions | mixed*/
  14093. , arg3
  14094. /*:: ?: SaveOptions*/
  14095. )
  14096. /*: Promise*/
  14097. {
  14098. var _this = this;
  14099. var attrs;
  14100. var options;
  14101. if ((0, _typeof2.default)(arg1) === 'object' || typeof arg1 === 'undefined') {
  14102. attrs = arg1;
  14103. if ((0, _typeof2.default)(arg2) === 'object') {
  14104. options = arg2;
  14105. }
  14106. } else {
  14107. attrs = {};
  14108. attrs[arg1] = arg2;
  14109. options = arg3;
  14110. }
  14111. if (attrs) {
  14112. var validation = this.validate(attrs);
  14113. if (validation) {
  14114. return _promise.default.reject(validation);
  14115. }
  14116. this.set(attrs, options);
  14117. }
  14118. options = options || {};
  14119. var saveOptions = {};
  14120. if (options.hasOwnProperty('useMasterKey')) {
  14121. saveOptions.useMasterKey = !!options.useMasterKey;
  14122. }
  14123. if (options.hasOwnProperty('sessionToken') && typeof options.sessionToken === 'string') {
  14124. saveOptions.sessionToken = options.sessionToken;
  14125. }
  14126. if (options.hasOwnProperty('installationId') && typeof options.installationId === 'string') {
  14127. saveOptions.installationId = options.installationId;
  14128. }
  14129. if (options.hasOwnProperty('context') && (0, _typeof2.default)(options.context) === 'object') {
  14130. saveOptions.context = options.context;
  14131. }
  14132. var controller = _CoreManager.default.getObjectController();
  14133. var unsaved = options.cascadeSave !== false ? (0, _unsavedChildren.default)(this) : null;
  14134. return controller.save(unsaved, saveOptions).then(function () {
  14135. return controller.save(_this, saveOptions);
  14136. });
  14137. }
  14138. /**
  14139. * Destroy this model on the server if it was already persisted.
  14140. *
  14141. * @param {object} options
  14142. * Valid options are:<ul>
  14143. * <li>useMasterKey: In Cloud Code and Node only, causes the Master Key to
  14144. * be used for this request.
  14145. * <li>sessionToken: A valid session token, used for making a request on
  14146. * behalf of a specific user.
  14147. * <li>context: A dictionary that is accessible in Cloud Code `beforeDelete` and `afterDelete` triggers.
  14148. * </ul>
  14149. * @returns {Promise} A promise that is fulfilled when the destroy
  14150. * completes.
  14151. */
  14152. }, {
  14153. key: "destroy",
  14154. value: function (options
  14155. /*: RequestOptions*/
  14156. )
  14157. /*: Promise*/
  14158. {
  14159. options = options || {};
  14160. var destroyOptions = {};
  14161. if (options.hasOwnProperty('useMasterKey')) {
  14162. destroyOptions.useMasterKey = options.useMasterKey;
  14163. }
  14164. if (options.hasOwnProperty('sessionToken')) {
  14165. destroyOptions.sessionToken = options.sessionToken;
  14166. }
  14167. if (options.hasOwnProperty('context') && (0, _typeof2.default)(options.context) === 'object') {
  14168. destroyOptions.context = options.context;
  14169. }
  14170. if (!this.id) {
  14171. return _promise.default.resolve();
  14172. }
  14173. return _CoreManager.default.getObjectController().destroy(this, destroyOptions);
  14174. }
  14175. /**
  14176. * Asynchronously stores the object and every object it points to in the local datastore,
  14177. * recursively, using a default pin name: _default.
  14178. *
  14179. * If those other objects have not been fetched from Parse, they will not be stored.
  14180. * However, if they have changed data, all the changes will be retained.
  14181. *
  14182. * <pre>
  14183. * await object.pin();
  14184. * </pre>
  14185. *
  14186. * To retrieve object:
  14187. * <code>query.fromLocalDatastore()</code> or <code>query.fromPin()</code>
  14188. *
  14189. * @returns {Promise} A promise that is fulfilled when the pin completes.
  14190. */
  14191. }, {
  14192. key: "pin",
  14193. value: function ()
  14194. /*: Promise<void>*/
  14195. {
  14196. return ParseObject.pinAllWithName(_LocalDatastoreUtils.DEFAULT_PIN, [this]);
  14197. }
  14198. /**
  14199. * Asynchronously removes the object and every object it points to in the local datastore,
  14200. * recursively, using a default pin name: _default.
  14201. *
  14202. * <pre>
  14203. * await object.unPin();
  14204. * </pre>
  14205. *
  14206. * @returns {Promise} A promise that is fulfilled when the unPin completes.
  14207. */
  14208. }, {
  14209. key: "unPin",
  14210. value: function ()
  14211. /*: Promise<void>*/
  14212. {
  14213. return ParseObject.unPinAllWithName(_LocalDatastoreUtils.DEFAULT_PIN, [this]);
  14214. }
  14215. /**
  14216. * Asynchronously returns if the object is pinned
  14217. *
  14218. * <pre>
  14219. * const isPinned = await object.isPinned();
  14220. * </pre>
  14221. *
  14222. * @returns {Promise<boolean>} A boolean promise that is fulfilled if object is pinned.
  14223. */
  14224. }, {
  14225. key: "isPinned",
  14226. value: function () {
  14227. var _isPinned = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee2() {
  14228. var localDatastore, objectKey, pin;
  14229. return _regenerator.default.wrap(function (_context5) {
  14230. while (1) {
  14231. switch (_context5.prev = _context5.next) {
  14232. case 0:
  14233. localDatastore = _CoreManager.default.getLocalDatastore();
  14234. if (localDatastore.isEnabled) {
  14235. _context5.next = 3;
  14236. break;
  14237. }
  14238. return _context5.abrupt("return", _promise.default.reject('Parse.enableLocalDatastore() must be called first'));
  14239. case 3:
  14240. objectKey = localDatastore.getKeyForObject(this);
  14241. _context5.next = 6;
  14242. return localDatastore.fromPinWithName(objectKey);
  14243. case 6:
  14244. pin = _context5.sent;
  14245. return _context5.abrupt("return", pin.length > 0);
  14246. case 8:
  14247. case "end":
  14248. return _context5.stop();
  14249. }
  14250. }
  14251. }, _callee2, this);
  14252. }));
  14253. return function () {
  14254. return _isPinned.apply(this, arguments);
  14255. };
  14256. }()
  14257. /**
  14258. * Asynchronously stores the objects and every object they point to in the local datastore, recursively.
  14259. *
  14260. * If those other objects have not been fetched from Parse, they will not be stored.
  14261. * However, if they have changed data, all the changes will be retained.
  14262. *
  14263. * <pre>
  14264. * await object.pinWithName(name);
  14265. * </pre>
  14266. *
  14267. * To retrieve object:
  14268. * <code>query.fromLocalDatastore()</code> or <code>query.fromPinWithName(name)</code>
  14269. *
  14270. * @param {string} name Name of Pin.
  14271. * @returns {Promise} A promise that is fulfilled when the pin completes.
  14272. */
  14273. }, {
  14274. key: "pinWithName",
  14275. value: function (name
  14276. /*: string*/
  14277. )
  14278. /*: Promise<void>*/
  14279. {
  14280. return ParseObject.pinAllWithName(name, [this]);
  14281. }
  14282. /**
  14283. * Asynchronously removes the object and every object it points to in the local datastore, recursively.
  14284. *
  14285. * <pre>
  14286. * await object.unPinWithName(name);
  14287. * </pre>
  14288. *
  14289. * @param {string} name Name of Pin.
  14290. * @returns {Promise} A promise that is fulfilled when the unPin completes.
  14291. */
  14292. }, {
  14293. key: "unPinWithName",
  14294. value: function (name
  14295. /*: string*/
  14296. )
  14297. /*: Promise<void>*/
  14298. {
  14299. return ParseObject.unPinAllWithName(name, [this]);
  14300. }
  14301. /**
  14302. * Asynchronously loads data from the local datastore into this object.
  14303. *
  14304. * <pre>
  14305. * await object.fetchFromLocalDatastore();
  14306. * </pre>
  14307. *
  14308. * You can create an unfetched pointer with <code>Parse.Object.createWithoutData()</code>
  14309. * and then call <code>fetchFromLocalDatastore()</code> on it.
  14310. *
  14311. * @returns {Promise} A promise that is fulfilled when the fetch completes.
  14312. */
  14313. }, {
  14314. key: "fetchFromLocalDatastore",
  14315. value: function () {
  14316. var _fetchFromLocalDatastore = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee3() {
  14317. var localDatastore, objectKey, pinned, result;
  14318. return _regenerator.default.wrap(function (_context6) {
  14319. while (1) {
  14320. switch (_context6.prev = _context6.next) {
  14321. case 0:
  14322. localDatastore = _CoreManager.default.getLocalDatastore();
  14323. if (localDatastore.isEnabled) {
  14324. _context6.next = 3;
  14325. break;
  14326. }
  14327. throw new Error('Parse.enableLocalDatastore() must be called first');
  14328. case 3:
  14329. objectKey = localDatastore.getKeyForObject(this);
  14330. _context6.next = 6;
  14331. return localDatastore._serializeObject(objectKey);
  14332. case 6:
  14333. pinned = _context6.sent;
  14334. if (pinned) {
  14335. _context6.next = 9;
  14336. break;
  14337. }
  14338. throw new Error('Cannot fetch an unsaved ParseObject');
  14339. case 9:
  14340. result = ParseObject.fromJSON(pinned);
  14341. this._finishFetch(result.toJSON());
  14342. return _context6.abrupt("return", this);
  14343. case 12:
  14344. case "end":
  14345. return _context6.stop();
  14346. }
  14347. }
  14348. }, _callee3, this);
  14349. }));
  14350. return function () {
  14351. return _fetchFromLocalDatastore.apply(this, arguments);
  14352. };
  14353. }()
  14354. /** Static methods * */
  14355. }], [{
  14356. key: "_clearAllState",
  14357. value: function () {
  14358. var stateController = _CoreManager.default.getObjectStateController();
  14359. stateController.clearAllState();
  14360. }
  14361. /**
  14362. * Fetches the given list of Parse.Object.
  14363. * If any error is encountered, stops and calls the error handler.
  14364. *
  14365. * <pre>
  14366. * Parse.Object.fetchAll([object1, object2, ...])
  14367. * .then((list) => {
  14368. * // All the objects were fetched.
  14369. * }, (error) => {
  14370. * // An error occurred while fetching one of the objects.
  14371. * });
  14372. * </pre>
  14373. *
  14374. * @param {Array} list A list of <code>Parse.Object</code>.
  14375. * @param {object} options
  14376. * Valid options are:<ul>
  14377. * <li>useMasterKey: In Cloud Code and Node only, causes the Master Key to
  14378. * be used for this request.
  14379. * <li>sessionToken: A valid session token, used for making a request on
  14380. * behalf of a specific user.
  14381. * <li>include: The name(s) of the key(s) to include. Can be a string, an array of strings,
  14382. * or an array of array of strings.
  14383. * </ul>
  14384. * @static
  14385. * @returns {Parse.Object[]}
  14386. */
  14387. }, {
  14388. key: "fetchAll",
  14389. value: function (list
  14390. /*: Array<ParseObject>*/
  14391. ) {
  14392. var options
  14393. /*: RequestOptions*/
  14394. = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
  14395. var queryOptions = {};
  14396. if (options.hasOwnProperty('useMasterKey')) {
  14397. queryOptions.useMasterKey = options.useMasterKey;
  14398. }
  14399. if (options.hasOwnProperty('sessionToken')) {
  14400. queryOptions.sessionToken = options.sessionToken;
  14401. }
  14402. if (options.hasOwnProperty('include')) {
  14403. queryOptions.include = ParseObject.handleIncludeOptions(options);
  14404. }
  14405. return _CoreManager.default.getObjectController().fetch(list, true, queryOptions);
  14406. }
  14407. /**
  14408. * Fetches the given list of Parse.Object.
  14409. *
  14410. * Includes nested Parse.Objects for the provided key. You can use dot
  14411. * notation to specify which fields in the included object are also fetched.
  14412. *
  14413. * If any error is encountered, stops and calls the error handler.
  14414. *
  14415. * <pre>
  14416. * Parse.Object.fetchAllWithInclude([object1, object2, ...], [pointer1, pointer2, ...])
  14417. * .then((list) => {
  14418. * // All the objects were fetched.
  14419. * }, (error) => {
  14420. * // An error occurred while fetching one of the objects.
  14421. * });
  14422. * </pre>
  14423. *
  14424. * @param {Array} list A list of <code>Parse.Object</code>.
  14425. * @param {string | Array<string | Array<string>>} keys The name(s) of the key(s) to include.
  14426. * @param {object} options
  14427. * Valid options are:<ul>
  14428. * <li>useMasterKey: In Cloud Code and Node only, causes the Master Key to
  14429. * be used for this request.
  14430. * <li>sessionToken: A valid session token, used for making a request on
  14431. * behalf of a specific user.
  14432. * </ul>
  14433. * @static
  14434. * @returns {Parse.Object[]}
  14435. */
  14436. }, {
  14437. key: "fetchAllWithInclude",
  14438. value: function (list
  14439. /*: Array<ParseObject>*/
  14440. , keys
  14441. /*: String | Array<string | Array<string>>*/
  14442. , options
  14443. /*: RequestOptions*/
  14444. ) {
  14445. options = options || {};
  14446. options.include = keys;
  14447. return ParseObject.fetchAll(list, options);
  14448. }
  14449. /**
  14450. * Fetches the given list of Parse.Object if needed.
  14451. * If any error is encountered, stops and calls the error handler.
  14452. *
  14453. * Includes nested Parse.Objects for the provided key. You can use dot
  14454. * notation to specify which fields in the included object are also fetched.
  14455. *
  14456. * If any error is encountered, stops and calls the error handler.
  14457. *
  14458. * <pre>
  14459. * Parse.Object.fetchAllIfNeededWithInclude([object1, object2, ...], [pointer1, pointer2, ...])
  14460. * .then((list) => {
  14461. * // All the objects were fetched.
  14462. * }, (error) => {
  14463. * // An error occurred while fetching one of the objects.
  14464. * });
  14465. * </pre>
  14466. *
  14467. * @param {Array} list A list of <code>Parse.Object</code>.
  14468. * @param {string | Array<string | Array<string>>} keys The name(s) of the key(s) to include.
  14469. * @param {object} options
  14470. * Valid options are:<ul>
  14471. * <li>useMasterKey: In Cloud Code and Node only, causes the Master Key to
  14472. * be used for this request.
  14473. * <li>sessionToken: A valid session token, used for making a request on
  14474. * behalf of a specific user.
  14475. * </ul>
  14476. * @static
  14477. * @returns {Parse.Object[]}
  14478. */
  14479. }, {
  14480. key: "fetchAllIfNeededWithInclude",
  14481. value: function (list
  14482. /*: Array<ParseObject>*/
  14483. , keys
  14484. /*: String | Array<string | Array<string>>*/
  14485. , options
  14486. /*: RequestOptions*/
  14487. ) {
  14488. options = options || {};
  14489. options.include = keys;
  14490. return ParseObject.fetchAllIfNeeded(list, options);
  14491. }
  14492. /**
  14493. * Fetches the given list of Parse.Object if needed.
  14494. * If any error is encountered, stops and calls the error handler.
  14495. *
  14496. * <pre>
  14497. * Parse.Object.fetchAllIfNeeded([object1, ...])
  14498. * .then((list) => {
  14499. * // Objects were fetched and updated.
  14500. * }, (error) => {
  14501. * // An error occurred while fetching one of the objects.
  14502. * });
  14503. * </pre>
  14504. *
  14505. * @param {Array} list A list of <code>Parse.Object</code>.
  14506. * @param {object} options
  14507. * @static
  14508. * @returns {Parse.Object[]}
  14509. */
  14510. }, {
  14511. key: "fetchAllIfNeeded",
  14512. value: function (list
  14513. /*: Array<ParseObject>*/
  14514. , options) {
  14515. options = options || {};
  14516. var queryOptions = {};
  14517. if (options.hasOwnProperty('useMasterKey')) {
  14518. queryOptions.useMasterKey = options.useMasterKey;
  14519. }
  14520. if (options.hasOwnProperty('sessionToken')) {
  14521. queryOptions.sessionToken = options.sessionToken;
  14522. }
  14523. if (options.hasOwnProperty('include')) {
  14524. queryOptions.include = ParseObject.handleIncludeOptions(options);
  14525. }
  14526. return _CoreManager.default.getObjectController().fetch(list, false, queryOptions);
  14527. }
  14528. }, {
  14529. key: "handleIncludeOptions",
  14530. value: function (options) {
  14531. var include = [];
  14532. if ((0, _isArray.default)(options.include)) {
  14533. var _context7;
  14534. (0, _forEach.default)(_context7 = options.include).call(_context7, function (key) {
  14535. if ((0, _isArray.default)(key)) {
  14536. include = (0, _concat.default)(include).call(include, key);
  14537. } else {
  14538. include.push(key);
  14539. }
  14540. });
  14541. } else {
  14542. include.push(options.include);
  14543. }
  14544. return include;
  14545. }
  14546. /**
  14547. * Destroy the given list of models on the server if it was already persisted.
  14548. *
  14549. * <p>Unlike saveAll, if an error occurs while deleting an individual model,
  14550. * this method will continue trying to delete the rest of the models if
  14551. * possible, except in the case of a fatal error like a connection error.
  14552. *
  14553. * <p>In particular, the Parse.Error object returned in the case of error may
  14554. * be one of two types:
  14555. *
  14556. * <ul>
  14557. * <li>A Parse.Error.AGGREGATE_ERROR. This object's "errors" property is an
  14558. * array of other Parse.Error objects. Each error object in this array
  14559. * has an "object" property that references the object that could not be
  14560. * deleted (for instance, because that object could not be found).</li>
  14561. * <li>A non-aggregate Parse.Error. This indicates a serious error that
  14562. * caused the delete operation to be aborted partway through (for
  14563. * instance, a connection failure in the middle of the delete).</li>
  14564. * </ul>
  14565. *
  14566. * <pre>
  14567. * Parse.Object.destroyAll([object1, object2, ...])
  14568. * .then((list) => {
  14569. * // All the objects were deleted.
  14570. * }, (error) => {
  14571. * // An error occurred while deleting one or more of the objects.
  14572. * // If this is an aggregate error, then we can inspect each error
  14573. * // object individually to determine the reason why a particular
  14574. * // object was not deleted.
  14575. * if (error.code === Parse.Error.AGGREGATE_ERROR) {
  14576. * for (var i = 0; i < error.errors.length; i++) {
  14577. * console.log("Couldn't delete " + error.errors[i].object.id +
  14578. * "due to " + error.errors[i].message);
  14579. * }
  14580. * } else {
  14581. * console.log("Delete aborted because of " + error.message);
  14582. * }
  14583. * });
  14584. * </pre>
  14585. *
  14586. * @param {Array} list A list of <code>Parse.Object</code>.
  14587. * @param {object} options
  14588. * @static
  14589. * @returns {Promise} A promise that is fulfilled when the destroyAll
  14590. * completes.
  14591. */
  14592. }, {
  14593. key: "destroyAll",
  14594. value: function (list
  14595. /*: Array<ParseObject>*/
  14596. ) {
  14597. var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
  14598. var destroyOptions = {};
  14599. if (options.hasOwnProperty('useMasterKey')) {
  14600. destroyOptions.useMasterKey = options.useMasterKey;
  14601. }
  14602. if (options.hasOwnProperty('sessionToken')) {
  14603. destroyOptions.sessionToken = options.sessionToken;
  14604. }
  14605. if (options.hasOwnProperty('batchSize') && typeof options.batchSize === 'number') {
  14606. destroyOptions.batchSize = options.batchSize;
  14607. }
  14608. if (options.hasOwnProperty('context') && (0, _typeof2.default)(options.context) === 'object') {
  14609. destroyOptions.context = options.context;
  14610. }
  14611. return _CoreManager.default.getObjectController().destroy(list, destroyOptions);
  14612. }
  14613. /**
  14614. * Saves the given list of Parse.Object.
  14615. * If any error is encountered, stops and calls the error handler.
  14616. *
  14617. * <pre>
  14618. * Parse.Object.saveAll([object1, object2, ...])
  14619. * .then((list) => {
  14620. * // All the objects were saved.
  14621. * }, (error) => {
  14622. * // An error occurred while saving one of the objects.
  14623. * });
  14624. * </pre>
  14625. *
  14626. * @param {Array} list A list of <code>Parse.Object</code>.
  14627. * @param {object} options
  14628. * @static
  14629. * @returns {Parse.Object[]}
  14630. */
  14631. }, {
  14632. key: "saveAll",
  14633. value: function (list
  14634. /*: Array<ParseObject>*/
  14635. ) {
  14636. var options
  14637. /*: RequestOptions*/
  14638. = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
  14639. var saveOptions = {};
  14640. if (options.hasOwnProperty('useMasterKey')) {
  14641. saveOptions.useMasterKey = options.useMasterKey;
  14642. }
  14643. if (options.hasOwnProperty('sessionToken')) {
  14644. saveOptions.sessionToken = options.sessionToken;
  14645. }
  14646. if (options.hasOwnProperty('batchSize') && typeof options.batchSize === 'number') {
  14647. saveOptions.batchSize = options.batchSize;
  14648. }
  14649. if (options.hasOwnProperty('context') && (0, _typeof2.default)(options.context) === 'object') {
  14650. saveOptions.context = options.context;
  14651. }
  14652. return _CoreManager.default.getObjectController().save(list, saveOptions);
  14653. }
  14654. /**
  14655. * Creates a reference to a subclass of Parse.Object with the given id. This
  14656. * does not exist on Parse.Object, only on subclasses.
  14657. *
  14658. * <p>A shortcut for: <pre>
  14659. * var Foo = Parse.Object.extend("Foo");
  14660. * var pointerToFoo = new Foo();
  14661. * pointerToFoo.id = "myObjectId";
  14662. * </pre>
  14663. *
  14664. * @param {string} id The ID of the object to create a reference to.
  14665. * @static
  14666. * @returns {Parse.Object} A Parse.Object reference.
  14667. */
  14668. }, {
  14669. key: "createWithoutData",
  14670. value: function (id
  14671. /*: string*/
  14672. ) {
  14673. var obj = new this();
  14674. obj.id = id;
  14675. return obj;
  14676. }
  14677. /**
  14678. * Creates a new instance of a Parse Object from a JSON representation.
  14679. *
  14680. * @param {object} json The JSON map of the Object's data
  14681. * @param {boolean} override In single instance mode, all old server data
  14682. * is overwritten if this is set to true
  14683. * @static
  14684. * @returns {Parse.Object} A Parse.Object reference
  14685. */
  14686. }, {
  14687. key: "fromJSON",
  14688. value: function (json
  14689. /*: any*/
  14690. , override
  14691. /*:: ?: boolean*/
  14692. ) {
  14693. if (!json.className) {
  14694. throw new Error('Cannot create an object without a className');
  14695. }
  14696. var constructor = classMap[json.className];
  14697. var o = constructor ? new constructor() : new ParseObject(json.className);
  14698. var otherAttributes = {};
  14699. for (var _attr12 in json) {
  14700. if (_attr12 !== 'className' && _attr12 !== '__type') {
  14701. otherAttributes[_attr12] = json[_attr12];
  14702. }
  14703. }
  14704. if (override) {
  14705. // id needs to be set before clearServerData can work
  14706. if (otherAttributes.objectId) {
  14707. o.id = otherAttributes.objectId;
  14708. }
  14709. var preserved = null;
  14710. if (typeof o._preserveFieldsOnFetch === 'function') {
  14711. preserved = o._preserveFieldsOnFetch();
  14712. }
  14713. o._clearServerData();
  14714. if (preserved) {
  14715. o._finishFetch(preserved);
  14716. }
  14717. }
  14718. o._finishFetch(otherAttributes);
  14719. if (json.objectId) {
  14720. o._setExisted(true);
  14721. }
  14722. return o;
  14723. }
  14724. /**
  14725. * Registers a subclass of Parse.Object with a specific class name.
  14726. * When objects of that class are retrieved from a query, they will be
  14727. * instantiated with this subclass.
  14728. * This is only necessary when using ES6 subclassing.
  14729. *
  14730. * @param {string} className The class name of the subclass
  14731. * @param {Function} constructor The subclass
  14732. */
  14733. }, {
  14734. key: "registerSubclass",
  14735. value: function (className
  14736. /*: string*/
  14737. , constructor
  14738. /*: any*/
  14739. ) {
  14740. if (typeof className !== 'string') {
  14741. throw new TypeError('The first argument must be a valid class name.');
  14742. }
  14743. if (typeof constructor === 'undefined') {
  14744. throw new TypeError('You must supply a subclass constructor.');
  14745. }
  14746. if (typeof constructor !== 'function') {
  14747. throw new TypeError('You must register the subclass constructor. ' + 'Did you attempt to register an instance of the subclass?');
  14748. }
  14749. classMap[className] = constructor;
  14750. if (!constructor.className) {
  14751. constructor.className = className;
  14752. }
  14753. }
  14754. /**
  14755. * Creates a new subclass of Parse.Object for the given Parse class name.
  14756. *
  14757. * <p>Every extension of a Parse class will inherit from the most recent
  14758. * previous extension of that class. When a Parse.Object is automatically
  14759. * created by parsing JSON, it will use the most recent extension of that
  14760. * class.</p>
  14761. *
  14762. * <p>You should call either:<pre>
  14763. * var MyClass = Parse.Object.extend("MyClass", {
  14764. * <i>Instance methods</i>,
  14765. * initialize: function(attrs, options) {
  14766. * this.someInstanceProperty = [],
  14767. * <i>Other instance properties</i>
  14768. * }
  14769. * }, {
  14770. * <i>Class properties</i>
  14771. * });</pre>
  14772. * or, for Backbone compatibility:<pre>
  14773. * var MyClass = Parse.Object.extend({
  14774. * className: "MyClass",
  14775. * <i>Instance methods</i>,
  14776. * initialize: function(attrs, options) {
  14777. * this.someInstanceProperty = [],
  14778. * <i>Other instance properties</i>
  14779. * }
  14780. * }, {
  14781. * <i>Class properties</i>
  14782. * });</pre></p>
  14783. *
  14784. * @param {string} className The name of the Parse class backing this model.
  14785. * @param {object} protoProps Instance properties to add to instances of the
  14786. * class returned from this method.
  14787. * @param {object} classProps Class properties to add the class returned from
  14788. * this method.
  14789. * @returns {Parse.Object} A new subclass of Parse.Object.
  14790. */
  14791. }, {
  14792. key: "extend",
  14793. value: function (className
  14794. /*: any*/
  14795. , protoProps
  14796. /*: any*/
  14797. , classProps
  14798. /*: any*/
  14799. ) {
  14800. if (typeof className !== 'string') {
  14801. if (className && typeof className.className === 'string') {
  14802. return ParseObject.extend(className.className, className, protoProps);
  14803. }
  14804. throw new Error("Parse.Object.extend's first argument should be the className.");
  14805. }
  14806. var adjustedClassName = className;
  14807. if (adjustedClassName === 'User' && _CoreManager.default.get('PERFORM_USER_REWRITE')) {
  14808. adjustedClassName = '_User';
  14809. }
  14810. var parentProto = ParseObject.prototype;
  14811. if (this.hasOwnProperty('__super__') && this.__super__) {
  14812. parentProto = this.prototype;
  14813. } else if (classMap[adjustedClassName]) {
  14814. parentProto = classMap[adjustedClassName].prototype;
  14815. }
  14816. var ParseObjectSubclass = function (attributes, options) {
  14817. this.className = adjustedClassName;
  14818. this._objCount = objectCount++; // Enable legacy initializers
  14819. if (typeof this.initialize === 'function') {
  14820. this.initialize.apply(this, arguments);
  14821. }
  14822. if (attributes && (0, _typeof2.default)(attributes) === 'object') {
  14823. if (!this.set(attributes || {}, options)) {
  14824. throw new Error("Can't create an invalid Parse Object");
  14825. }
  14826. }
  14827. };
  14828. ParseObjectSubclass.className = adjustedClassName;
  14829. ParseObjectSubclass.__super__ = parentProto;
  14830. ParseObjectSubclass.prototype = (0, _create.default)(parentProto, {
  14831. constructor: {
  14832. value: ParseObjectSubclass,
  14833. enumerable: false,
  14834. writable: true,
  14835. configurable: true
  14836. }
  14837. });
  14838. if (protoProps) {
  14839. for (var prop in protoProps) {
  14840. if (prop !== 'className') {
  14841. (0, _defineProperty3.default)(ParseObjectSubclass.prototype, prop, {
  14842. value: protoProps[prop],
  14843. enumerable: false,
  14844. writable: true,
  14845. configurable: true
  14846. });
  14847. }
  14848. }
  14849. }
  14850. if (classProps) {
  14851. for (var _prop in classProps) {
  14852. if (_prop !== 'className') {
  14853. (0, _defineProperty3.default)(ParseObjectSubclass, _prop, {
  14854. value: classProps[_prop],
  14855. enumerable: false,
  14856. writable: true,
  14857. configurable: true
  14858. });
  14859. }
  14860. }
  14861. }
  14862. ParseObjectSubclass.extend = function (name, protoProps, classProps) {
  14863. if (typeof name === 'string') {
  14864. return ParseObject.extend.call(ParseObjectSubclass, name, protoProps, classProps);
  14865. }
  14866. return ParseObject.extend.call(ParseObjectSubclass, adjustedClassName, name, protoProps);
  14867. };
  14868. ParseObjectSubclass.createWithoutData = ParseObject.createWithoutData;
  14869. classMap[adjustedClassName] = ParseObjectSubclass;
  14870. return ParseObjectSubclass;
  14871. }
  14872. /**
  14873. * Enable single instance objects, where any local objects with the same Id
  14874. * share the same attributes, and stay synchronized with each other.
  14875. * This is disabled by default in server environments, since it can lead to
  14876. * security issues.
  14877. *
  14878. * @static
  14879. */
  14880. }, {
  14881. key: "enableSingleInstance",
  14882. value: function () {
  14883. singleInstance = true;
  14884. _CoreManager.default.setObjectStateController(SingleInstanceStateController);
  14885. }
  14886. /**
  14887. * Disable single instance objects, where any local objects with the same Id
  14888. * share the same attributes, and stay synchronized with each other.
  14889. * When disabled, you can have two instances of the same object in memory
  14890. * without them sharing attributes.
  14891. *
  14892. * @static
  14893. */
  14894. }, {
  14895. key: "disableSingleInstance",
  14896. value: function () {
  14897. singleInstance = false;
  14898. _CoreManager.default.setObjectStateController(UniqueInstanceStateController);
  14899. }
  14900. /**
  14901. * Asynchronously stores the objects and every object they point to in the local datastore,
  14902. * recursively, using a default pin name: _default.
  14903. *
  14904. * If those other objects have not been fetched from Parse, they will not be stored.
  14905. * However, if they have changed data, all the changes will be retained.
  14906. *
  14907. * <pre>
  14908. * await Parse.Object.pinAll([...]);
  14909. * </pre>
  14910. *
  14911. * To retrieve object:
  14912. * <code>query.fromLocalDatastore()</code> or <code>query.fromPin()</code>
  14913. *
  14914. * @param {Array} objects A list of <code>Parse.Object</code>.
  14915. * @returns {Promise} A promise that is fulfilled when the pin completes.
  14916. * @static
  14917. */
  14918. }, {
  14919. key: "pinAll",
  14920. value: function (objects
  14921. /*: Array<ParseObject>*/
  14922. )
  14923. /*: Promise<void>*/
  14924. {
  14925. var localDatastore = _CoreManager.default.getLocalDatastore();
  14926. if (!localDatastore.isEnabled) {
  14927. return _promise.default.reject('Parse.enableLocalDatastore() must be called first');
  14928. }
  14929. return ParseObject.pinAllWithName(_LocalDatastoreUtils.DEFAULT_PIN, objects);
  14930. }
  14931. /**
  14932. * Asynchronously stores the objects and every object they point to in the local datastore, recursively.
  14933. *
  14934. * If those other objects have not been fetched from Parse, they will not be stored.
  14935. * However, if they have changed data, all the changes will be retained.
  14936. *
  14937. * <pre>
  14938. * await Parse.Object.pinAllWithName(name, [obj1, obj2, ...]);
  14939. * </pre>
  14940. *
  14941. * To retrieve object:
  14942. * <code>query.fromLocalDatastore()</code> or <code>query.fromPinWithName(name)</code>
  14943. *
  14944. * @param {string} name Name of Pin.
  14945. * @param {Array} objects A list of <code>Parse.Object</code>.
  14946. * @returns {Promise} A promise that is fulfilled when the pin completes.
  14947. * @static
  14948. */
  14949. }, {
  14950. key: "pinAllWithName",
  14951. value: function (name
  14952. /*: string*/
  14953. , objects
  14954. /*: Array<ParseObject>*/
  14955. )
  14956. /*: Promise<void>*/
  14957. {
  14958. var localDatastore = _CoreManager.default.getLocalDatastore();
  14959. if (!localDatastore.isEnabled) {
  14960. return _promise.default.reject('Parse.enableLocalDatastore() must be called first');
  14961. }
  14962. return localDatastore._handlePinAllWithName(name, objects);
  14963. }
  14964. /**
  14965. * Asynchronously removes the objects and every object they point to in the local datastore,
  14966. * recursively, using a default pin name: _default.
  14967. *
  14968. * <pre>
  14969. * await Parse.Object.unPinAll([...]);
  14970. * </pre>
  14971. *
  14972. * @param {Array} objects A list of <code>Parse.Object</code>.
  14973. * @returns {Promise} A promise that is fulfilled when the unPin completes.
  14974. * @static
  14975. */
  14976. }, {
  14977. key: "unPinAll",
  14978. value: function (objects
  14979. /*: Array<ParseObject>*/
  14980. )
  14981. /*: Promise<void>*/
  14982. {
  14983. var localDatastore = _CoreManager.default.getLocalDatastore();
  14984. if (!localDatastore.isEnabled) {
  14985. return _promise.default.reject('Parse.enableLocalDatastore() must be called first');
  14986. }
  14987. return ParseObject.unPinAllWithName(_LocalDatastoreUtils.DEFAULT_PIN, objects);
  14988. }
  14989. /**
  14990. * Asynchronously removes the objects and every object they point to in the local datastore, recursively.
  14991. *
  14992. * <pre>
  14993. * await Parse.Object.unPinAllWithName(name, [obj1, obj2, ...]);
  14994. * </pre>
  14995. *
  14996. * @param {string} name Name of Pin.
  14997. * @param {Array} objects A list of <code>Parse.Object</code>.
  14998. * @returns {Promise} A promise that is fulfilled when the unPin completes.
  14999. * @static
  15000. */
  15001. }, {
  15002. key: "unPinAllWithName",
  15003. value: function (name
  15004. /*: string*/
  15005. , objects
  15006. /*: Array<ParseObject>*/
  15007. )
  15008. /*: Promise<void>*/
  15009. {
  15010. var localDatastore = _CoreManager.default.getLocalDatastore();
  15011. if (!localDatastore.isEnabled) {
  15012. return _promise.default.reject('Parse.enableLocalDatastore() must be called first');
  15013. }
  15014. return localDatastore._handleUnPinAllWithName(name, objects);
  15015. }
  15016. /**
  15017. * Asynchronously removes all objects in the local datastore using a default pin name: _default.
  15018. *
  15019. * <pre>
  15020. * await Parse.Object.unPinAllObjects();
  15021. * </pre>
  15022. *
  15023. * @returns {Promise} A promise that is fulfilled when the unPin completes.
  15024. * @static
  15025. */
  15026. }, {
  15027. key: "unPinAllObjects",
  15028. value: function ()
  15029. /*: Promise<void>*/
  15030. {
  15031. var localDatastore = _CoreManager.default.getLocalDatastore();
  15032. if (!localDatastore.isEnabled) {
  15033. return _promise.default.reject('Parse.enableLocalDatastore() must be called first');
  15034. }
  15035. return localDatastore.unPinWithName(_LocalDatastoreUtils.DEFAULT_PIN);
  15036. }
  15037. /**
  15038. * Asynchronously removes all objects with the specified pin name.
  15039. * Deletes the pin name also.
  15040. *
  15041. * <pre>
  15042. * await Parse.Object.unPinAllObjectsWithName(name);
  15043. * </pre>
  15044. *
  15045. * @param {string} name Name of Pin.
  15046. * @returns {Promise} A promise that is fulfilled when the unPin completes.
  15047. * @static
  15048. */
  15049. }, {
  15050. key: "unPinAllObjectsWithName",
  15051. value: function (name
  15052. /*: string*/
  15053. )
  15054. /*: Promise<void>*/
  15055. {
  15056. var localDatastore = _CoreManager.default.getLocalDatastore();
  15057. if (!localDatastore.isEnabled) {
  15058. return _promise.default.reject('Parse.enableLocalDatastore() must be called first');
  15059. }
  15060. return localDatastore.unPinWithName(_LocalDatastoreUtils.PIN_PREFIX + name);
  15061. }
  15062. }]);
  15063. return ParseObject;
  15064. }();
  15065. var DefaultController = {
  15066. fetch: function (target
  15067. /*: ParseObject | Array<ParseObject>*/
  15068. , forceFetch
  15069. /*: boolean*/
  15070. , options
  15071. /*: RequestOptions*/
  15072. )
  15073. /*: Promise<Array<void> | ParseObject>*/
  15074. {
  15075. var localDatastore = _CoreManager.default.getLocalDatastore();
  15076. if ((0, _isArray.default)(target)) {
  15077. if (target.length < 1) {
  15078. return _promise.default.resolve([]);
  15079. }
  15080. var objs = [];
  15081. var ids = [];
  15082. var className = null;
  15083. var results = [];
  15084. var error = null;
  15085. (0, _forEach.default)(target).call(target, function (el) {
  15086. if (error) {
  15087. return;
  15088. }
  15089. if (!className) {
  15090. // eslint-disable-next-line prefer-destructuring
  15091. className = el.className;
  15092. }
  15093. if (className !== el.className) {
  15094. error = new _ParseError.default(_ParseError.default.INVALID_CLASS_NAME, 'All objects should be of the same class');
  15095. }
  15096. if (!el.id) {
  15097. error = new _ParseError.default(_ParseError.default.MISSING_OBJECT_ID, 'All objects must have an ID');
  15098. }
  15099. if (forceFetch || !el.isDataAvailable()) {
  15100. ids.push(el.id);
  15101. objs.push(el);
  15102. }
  15103. results.push(el);
  15104. });
  15105. if (error) {
  15106. return _promise.default.reject(error);
  15107. }
  15108. var query = new _ParseQuery.default(className);
  15109. query.containedIn('objectId', ids);
  15110. if (options && options.include) {
  15111. query.include(options.include);
  15112. }
  15113. query._limit = ids.length;
  15114. return (0, _find.default)(query).call(query, options).then( /*#__PURE__*/function () {
  15115. var _ref = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee4(objects) {
  15116. var idMap, i, obj, _i, _obj, id, _iterator2, _step2, object;
  15117. return _regenerator.default.wrap(function (_context8) {
  15118. while (1) {
  15119. switch (_context8.prev = _context8.next) {
  15120. case 0:
  15121. idMap = {};
  15122. (0, _forEach.default)(objects).call(objects, function (o) {
  15123. idMap[o.id] = o;
  15124. });
  15125. i = 0;
  15126. case 3:
  15127. if (!(i < objs.length)) {
  15128. _context8.next = 11;
  15129. break;
  15130. }
  15131. obj = objs[i];
  15132. if (!(!obj || !obj.id || !idMap[obj.id])) {
  15133. _context8.next = 8;
  15134. break;
  15135. }
  15136. if (!forceFetch) {
  15137. _context8.next = 8;
  15138. break;
  15139. }
  15140. return _context8.abrupt("return", _promise.default.reject(new _ParseError.default(_ParseError.default.OBJECT_NOT_FOUND, 'All objects must exist on the server.')));
  15141. case 8:
  15142. i++;
  15143. _context8.next = 3;
  15144. break;
  15145. case 11:
  15146. if (!singleInstance) {
  15147. // If single instance objects are disabled, we need to replace the
  15148. for (_i = 0; _i < results.length; _i++) {
  15149. _obj = results[_i];
  15150. if (_obj && _obj.id && idMap[_obj.id]) {
  15151. id = _obj.id;
  15152. _obj._finishFetch(idMap[id].toJSON());
  15153. results[_i] = idMap[id];
  15154. }
  15155. }
  15156. }
  15157. _iterator2 = _createForOfIteratorHelper(results);
  15158. _context8.prev = 13;
  15159. _iterator2.s();
  15160. case 15:
  15161. if ((_step2 = _iterator2.n()).done) {
  15162. _context8.next = 21;
  15163. break;
  15164. }
  15165. object = _step2.value;
  15166. _context8.next = 19;
  15167. return localDatastore._updateObjectIfPinned(object);
  15168. case 19:
  15169. _context8.next = 15;
  15170. break;
  15171. case 21:
  15172. _context8.next = 26;
  15173. break;
  15174. case 23:
  15175. _context8.prev = 23;
  15176. _context8.t0 = _context8["catch"](13);
  15177. _iterator2.e(_context8.t0);
  15178. case 26:
  15179. _context8.prev = 26;
  15180. _iterator2.f();
  15181. return _context8.finish(26);
  15182. case 29:
  15183. return _context8.abrupt("return", _promise.default.resolve(results));
  15184. case 30:
  15185. case "end":
  15186. return _context8.stop();
  15187. }
  15188. }
  15189. }, _callee4, null, [[13, 23, 26, 29]]);
  15190. }));
  15191. return function () {
  15192. return _ref.apply(this, arguments);
  15193. };
  15194. }());
  15195. }
  15196. if (target instanceof ParseObject) {
  15197. var _context9;
  15198. if (!target.id) {
  15199. return _promise.default.reject(new _ParseError.default(_ParseError.default.MISSING_OBJECT_ID, 'Object does not have an ID'));
  15200. }
  15201. var RESTController = _CoreManager.default.getRESTController();
  15202. var params = {};
  15203. if (options && options.include) {
  15204. params.include = options.include.join();
  15205. }
  15206. return RESTController.request('GET', (0, _concat.default)(_context9 = "classes/".concat(target.className, "/")).call(_context9, target._getId()), params, options).then( /*#__PURE__*/function () {
  15207. var _ref2 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee5(response) {
  15208. return _regenerator.default.wrap(function (_context10) {
  15209. while (1) {
  15210. switch (_context10.prev = _context10.next) {
  15211. case 0:
  15212. target._clearPendingOps();
  15213. target._clearServerData();
  15214. target._finishFetch(response);
  15215. _context10.next = 5;
  15216. return localDatastore._updateObjectIfPinned(target);
  15217. case 5:
  15218. return _context10.abrupt("return", target);
  15219. case 6:
  15220. case "end":
  15221. return _context10.stop();
  15222. }
  15223. }
  15224. }, _callee5);
  15225. }));
  15226. return function () {
  15227. return _ref2.apply(this, arguments);
  15228. };
  15229. }());
  15230. }
  15231. return _promise.default.resolve();
  15232. },
  15233. destroy: function (target
  15234. /*: ParseObject | Array<ParseObject>*/
  15235. , options
  15236. /*: RequestOptions*/
  15237. )
  15238. /*: Promise<Array<void> | ParseObject>*/
  15239. {
  15240. return (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee8() {
  15241. var batchSize, localDatastore, RESTController, batches, deleteCompleted, errors, _context14;
  15242. return _regenerator.default.wrap(function (_context16) {
  15243. while (1) {
  15244. switch (_context16.prev = _context16.next) {
  15245. case 0:
  15246. batchSize = options && options.batchSize ? options.batchSize : _CoreManager.default.get('REQUEST_BATCH_SIZE');
  15247. localDatastore = _CoreManager.default.getLocalDatastore();
  15248. RESTController = _CoreManager.default.getRESTController();
  15249. if (!(0, _isArray.default)(target)) {
  15250. _context16.next = 13;
  15251. break;
  15252. }
  15253. if (!(target.length < 1)) {
  15254. _context16.next = 6;
  15255. break;
  15256. }
  15257. return _context16.abrupt("return", _promise.default.resolve([]));
  15258. case 6:
  15259. batches = [[]];
  15260. (0, _forEach.default)(target).call(target, function (obj) {
  15261. if (!obj.id) {
  15262. return;
  15263. }
  15264. batches[batches.length - 1].push(obj);
  15265. if (batches[batches.length - 1].length >= batchSize) {
  15266. batches.push([]);
  15267. }
  15268. });
  15269. if (batches[batches.length - 1].length === 0) {
  15270. // If the last batch is empty, remove it
  15271. batches.pop();
  15272. }
  15273. deleteCompleted = _promise.default.resolve();
  15274. errors = [];
  15275. (0, _forEach.default)(batches).call(batches, function (batch) {
  15276. deleteCompleted = deleteCompleted.then(function () {
  15277. return RESTController.request('POST', 'batch', {
  15278. requests: (0, _map.default)(batch).call(batch, function (obj) {
  15279. var _context11, _context12;
  15280. return {
  15281. method: 'DELETE',
  15282. path: (0, _concat.default)(_context11 = (0, _concat.default)(_context12 = "".concat(getServerUrlPath(), "classes/")).call(_context12, obj.className, "/")).call(_context11, obj._getId()),
  15283. body: {}
  15284. };
  15285. })
  15286. }, options).then(function (results) {
  15287. for (var i = 0; i < results.length; i++) {
  15288. if (results[i] && results[i].hasOwnProperty('error')) {
  15289. var err = new _ParseError.default(results[i].error.code, results[i].error.error);
  15290. err.object = batch[i];
  15291. errors.push(err);
  15292. }
  15293. }
  15294. });
  15295. });
  15296. });
  15297. return _context16.abrupt("return", deleteCompleted.then( /*#__PURE__*/(0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee6() {
  15298. var aggregate, _iterator3, _step3, object;
  15299. return _regenerator.default.wrap(function (_context13) {
  15300. while (1) {
  15301. switch (_context13.prev = _context13.next) {
  15302. case 0:
  15303. if (!errors.length) {
  15304. _context13.next = 4;
  15305. break;
  15306. }
  15307. aggregate = new _ParseError.default(_ParseError.default.AGGREGATE_ERROR);
  15308. aggregate.errors = errors;
  15309. return _context13.abrupt("return", _promise.default.reject(aggregate));
  15310. case 4:
  15311. _iterator3 = _createForOfIteratorHelper(target);
  15312. _context13.prev = 5;
  15313. _iterator3.s();
  15314. case 7:
  15315. if ((_step3 = _iterator3.n()).done) {
  15316. _context13.next = 13;
  15317. break;
  15318. }
  15319. object = _step3.value;
  15320. _context13.next = 11;
  15321. return localDatastore._destroyObjectIfPinned(object);
  15322. case 11:
  15323. _context13.next = 7;
  15324. break;
  15325. case 13:
  15326. _context13.next = 18;
  15327. break;
  15328. case 15:
  15329. _context13.prev = 15;
  15330. _context13.t0 = _context13["catch"](5);
  15331. _iterator3.e(_context13.t0);
  15332. case 18:
  15333. _context13.prev = 18;
  15334. _iterator3.f();
  15335. return _context13.finish(18);
  15336. case 21:
  15337. return _context13.abrupt("return", _promise.default.resolve(target));
  15338. case 22:
  15339. case "end":
  15340. return _context13.stop();
  15341. }
  15342. }
  15343. }, _callee6, null, [[5, 15, 18, 21]]);
  15344. }))));
  15345. case 13:
  15346. if (!(target instanceof ParseObject)) {
  15347. _context16.next = 15;
  15348. break;
  15349. }
  15350. return _context16.abrupt("return", RESTController.request('DELETE', (0, _concat.default)(_context14 = "classes/".concat(target.className, "/")).call(_context14, target._getId()), {}, options).then( /*#__PURE__*/(0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee7() {
  15351. return _regenerator.default.wrap(function (_context15) {
  15352. while (1) {
  15353. switch (_context15.prev = _context15.next) {
  15354. case 0:
  15355. _context15.next = 2;
  15356. return localDatastore._destroyObjectIfPinned(target);
  15357. case 2:
  15358. return _context15.abrupt("return", _promise.default.resolve(target));
  15359. case 3:
  15360. case "end":
  15361. return _context15.stop();
  15362. }
  15363. }
  15364. }, _callee7);
  15365. }))));
  15366. case 15:
  15367. return _context16.abrupt("return", _promise.default.resolve(target));
  15368. case 16:
  15369. case "end":
  15370. return _context16.stop();
  15371. }
  15372. }
  15373. }, _callee8);
  15374. }))();
  15375. },
  15376. save: function (target
  15377. /*: ParseObject | Array<ParseObject | ParseFile>*/
  15378. , options
  15379. /*: RequestOptions*/
  15380. ) {
  15381. var batchSize = options && options.batchSize ? options.batchSize : _CoreManager.default.get('REQUEST_BATCH_SIZE');
  15382. var localDatastore = _CoreManager.default.getLocalDatastore();
  15383. var mapIdForPin = {};
  15384. var RESTController = _CoreManager.default.getRESTController();
  15385. var stateController = _CoreManager.default.getObjectStateController();
  15386. options = options || {};
  15387. options.returnStatus = options.returnStatus || true;
  15388. if ((0, _isArray.default)(target)) {
  15389. if (target.length < 1) {
  15390. return _promise.default.resolve([]);
  15391. }
  15392. var unsaved = (0, _concat.default)(target).call(target);
  15393. for (var i = 0; i < target.length; i++) {
  15394. if (target[i] instanceof ParseObject) {
  15395. unsaved = (0, _concat.default)(unsaved).call(unsaved, (0, _unsavedChildren.default)(target[i], true));
  15396. }
  15397. }
  15398. unsaved = (0, _unique.default)(unsaved);
  15399. var filesSaved
  15400. /*: Array<ParseFile>*/
  15401. = [];
  15402. var pending
  15403. /*: Array<ParseObject>*/
  15404. = [];
  15405. (0, _forEach.default)(unsaved).call(unsaved, function (el) {
  15406. if (el instanceof _ParseFile.default) {
  15407. filesSaved.push(el.save(options));
  15408. } else if (el instanceof ParseObject) {
  15409. pending.push(el);
  15410. }
  15411. });
  15412. return _promise.default.all(filesSaved).then(function () {
  15413. var objectError = null;
  15414. return (0, _promiseUtils.continueWhile)(function () {
  15415. return pending.length > 0;
  15416. }, function () {
  15417. var batch = [];
  15418. var nextPending = [];
  15419. (0, _forEach.default)(pending).call(pending, function (el) {
  15420. if (batch.length < batchSize && (0, _canBeSerialized.default)(el)) {
  15421. batch.push(el);
  15422. } else {
  15423. nextPending.push(el);
  15424. }
  15425. });
  15426. pending = nextPending;
  15427. if (batch.length < 1) {
  15428. return _promise.default.reject(new _ParseError.default(_ParseError.default.OTHER_CAUSE, 'Tried to save a batch with a cycle.'));
  15429. } // Queue up tasks for each object in the batch.
  15430. // When every task is ready, the API request will execute
  15431. var batchReturned = new _promiseUtils.resolvingPromise();
  15432. var batchReady = [];
  15433. var batchTasks = [];
  15434. (0, _forEach.default)(batch).call(batch, function (obj, index) {
  15435. var ready = new _promiseUtils.resolvingPromise();
  15436. batchReady.push(ready);
  15437. stateController.pushPendingState(obj._getStateIdentifier());
  15438. batchTasks.push(stateController.enqueueTask(obj._getStateIdentifier(), function () {
  15439. ready.resolve();
  15440. return batchReturned.then(function (responses) {
  15441. if (responses[index].hasOwnProperty('success')) {
  15442. var objectId = responses[index].success.objectId;
  15443. var status = responses[index]._status;
  15444. delete responses[index]._status;
  15445. mapIdForPin[objectId] = obj._localId;
  15446. obj._handleSaveResponse(responses[index].success, status);
  15447. } else {
  15448. if (!objectError && responses[index].hasOwnProperty('error')) {
  15449. var serverError = responses[index].error;
  15450. objectError = new _ParseError.default(serverError.code, serverError.error); // Cancel the rest of the save
  15451. pending = [];
  15452. }
  15453. obj._handleSaveError();
  15454. }
  15455. });
  15456. }));
  15457. });
  15458. (0, _promiseUtils.when)(batchReady).then(function () {
  15459. // Kick off the batch request
  15460. return RESTController.request('POST', 'batch', {
  15461. requests: (0, _map.default)(batch).call(batch, function (obj) {
  15462. var params = obj._getSaveParams();
  15463. params.path = getServerUrlPath() + params.path;
  15464. return params;
  15465. })
  15466. }, options);
  15467. }).then(batchReturned.resolve, function (error) {
  15468. batchReturned.reject(new _ParseError.default(_ParseError.default.INCORRECT_TYPE, error.message));
  15469. });
  15470. return (0, _promiseUtils.when)(batchTasks);
  15471. }).then( /*#__PURE__*/(0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee9() {
  15472. var _iterator4, _step4, object;
  15473. return _regenerator.default.wrap(function (_context17) {
  15474. while (1) {
  15475. switch (_context17.prev = _context17.next) {
  15476. case 0:
  15477. if (!objectError) {
  15478. _context17.next = 2;
  15479. break;
  15480. }
  15481. return _context17.abrupt("return", _promise.default.reject(objectError));
  15482. case 2:
  15483. _iterator4 = _createForOfIteratorHelper(target);
  15484. _context17.prev = 3;
  15485. _iterator4.s();
  15486. case 5:
  15487. if ((_step4 = _iterator4.n()).done) {
  15488. _context17.next = 13;
  15489. break;
  15490. }
  15491. object = _step4.value;
  15492. _context17.next = 9;
  15493. return localDatastore._updateLocalIdForObject(mapIdForPin[object.id], object);
  15494. case 9:
  15495. _context17.next = 11;
  15496. return localDatastore._updateObjectIfPinned(object);
  15497. case 11:
  15498. _context17.next = 5;
  15499. break;
  15500. case 13:
  15501. _context17.next = 18;
  15502. break;
  15503. case 15:
  15504. _context17.prev = 15;
  15505. _context17.t0 = _context17["catch"](3);
  15506. _iterator4.e(_context17.t0);
  15507. case 18:
  15508. _context17.prev = 18;
  15509. _iterator4.f();
  15510. return _context17.finish(18);
  15511. case 21:
  15512. return _context17.abrupt("return", _promise.default.resolve(target));
  15513. case 22:
  15514. case "end":
  15515. return _context17.stop();
  15516. }
  15517. }
  15518. }, _callee9, null, [[3, 15, 18, 21]]);
  15519. })));
  15520. });
  15521. }
  15522. if (target instanceof ParseObject) {
  15523. // generate _localId in case if cascadeSave=false
  15524. target._getId();
  15525. var localId = target._localId; // copying target lets Flow guarantee the pointer isn't modified elsewhere
  15526. var targetCopy = target;
  15527. var task = function () {
  15528. var params = targetCopy._getSaveParams();
  15529. return RESTController.request(params.method, params.path, params.body, options).then(function (response) {
  15530. var status = response._status;
  15531. delete response._status;
  15532. targetCopy._handleSaveResponse(response, status);
  15533. }, function (error) {
  15534. targetCopy._handleSaveError();
  15535. return _promise.default.reject(error);
  15536. });
  15537. };
  15538. stateController.pushPendingState(target._getStateIdentifier());
  15539. return stateController.enqueueTask(target._getStateIdentifier(), task).then( /*#__PURE__*/(0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee10() {
  15540. return _regenerator.default.wrap(function (_context18) {
  15541. while (1) {
  15542. switch (_context18.prev = _context18.next) {
  15543. case 0:
  15544. _context18.next = 2;
  15545. return localDatastore._updateLocalIdForObject(localId, target);
  15546. case 2:
  15547. _context18.next = 4;
  15548. return localDatastore._updateObjectIfPinned(target);
  15549. case 4:
  15550. return _context18.abrupt("return", target);
  15551. case 5:
  15552. case "end":
  15553. return _context18.stop();
  15554. }
  15555. }
  15556. }, _callee10);
  15557. })), function (error) {
  15558. return _promise.default.reject(error);
  15559. });
  15560. }
  15561. return _promise.default.resolve();
  15562. }
  15563. };
  15564. _CoreManager.default.setObjectController(DefaultController);
  15565. var _default = ParseObject;
  15566. exports.default = _default;
  15567. },{"./CoreManager":5,"./LocalDatastoreUtils":15,"./ParseACL":26,"./ParseError":29,"./ParseFile":30,"./ParseOp":37,"./ParseQuery":39,"./ParseRelation":40,"./SingleInstanceStateController":47,"./UniqueInstanceStateController":52,"./canBeSerialized":63,"./decode":65,"./encode":66,"./escape":68,"./parseDate":71,"./promiseUtils":72,"./unique":73,"./unsavedChildren":74,"@babel/runtime-corejs3/core-js-stable/array/from":78,"@babel/runtime-corejs3/core-js-stable/array/is-array":79,"@babel/runtime-corejs3/core-js-stable/instance/concat":81,"@babel/runtime-corejs3/core-js-stable/instance/filter":84,"@babel/runtime-corejs3/core-js-stable/instance/find":85,"@babel/runtime-corejs3/core-js-stable/instance/for-each":86,"@babel/runtime-corejs3/core-js-stable/instance/includes":87,"@babel/runtime-corejs3/core-js-stable/instance/index-of":88,"@babel/runtime-corejs3/core-js-stable/instance/map":90,"@babel/runtime-corejs3/core-js-stable/instance/slice":93,"@babel/runtime-corejs3/core-js-stable/json/stringify":99,"@babel/runtime-corejs3/core-js-stable/object/create":103,"@babel/runtime-corejs3/core-js-stable/object/define-properties":104,"@babel/runtime-corejs3/core-js-stable/object/define-property":105,"@babel/runtime-corejs3/core-js-stable/object/freeze":107,"@babel/runtime-corejs3/core-js-stable/object/get-own-property-descriptor":108,"@babel/runtime-corejs3/core-js-stable/object/get-own-property-descriptors":109,"@babel/runtime-corejs3/core-js-stable/object/get-own-property-symbols":110,"@babel/runtime-corejs3/core-js-stable/object/get-prototype-of":111,"@babel/runtime-corejs3/core-js-stable/object/keys":112,"@babel/runtime-corejs3/core-js-stable/promise":115,"@babel/runtime-corejs3/core-js-stable/symbol":119,"@babel/runtime-corejs3/core-js-stable/weak-map":122,"@babel/runtime-corejs3/core-js/get-iterator-method":125,"@babel/runtime-corejs3/helpers/asyncToGenerator":144,"@babel/runtime-corejs3/helpers/classCallCheck":145,"@babel/runtime-corejs3/helpers/createClass":147,"@babel/runtime-corejs3/helpers/defineProperty":148,"@babel/runtime-corejs3/helpers/interopRequireDefault":152,"@babel/runtime-corejs3/helpers/typeof":164,"@babel/runtime-corejs3/regenerator":167,"uuid":797}],37:[function(_dereq_,module,exports){
  15568. "use strict";
  15569. var _Reflect$construct = _dereq_("@babel/runtime-corejs3/core-js-stable/reflect/construct");
  15570. var _Object$defineProperty = _dereq_("@babel/runtime-corejs3/core-js-stable/object/define-property");
  15571. var _interopRequireDefault = _dereq_("@babel/runtime-corejs3/helpers/interopRequireDefault");
  15572. _Object$defineProperty(exports, "__esModule", {
  15573. value: true
  15574. });
  15575. exports.UnsetOp = exports.SetOp = exports.RemoveOp = exports.RelationOp = exports.Op = exports.IncrementOp = exports.AddUniqueOp = exports.AddOp = void 0;
  15576. exports.opFromJSON = opFromJSON;
  15577. var _assertThisInitialized2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/helpers/assertThisInitialized"));
  15578. var _inherits2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/helpers/inherits"));
  15579. var _possibleConstructorReturn2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/helpers/possibleConstructorReturn"));
  15580. var _getPrototypeOf2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/helpers/getPrototypeOf"));
  15581. var _defineProperty2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/helpers/defineProperty"));
  15582. var _classCallCheck2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/helpers/classCallCheck"));
  15583. var _createClass2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/helpers/createClass"));
  15584. var _isArray = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/array/is-array"));
  15585. var _concat = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/instance/concat"));
  15586. var _forEach = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/instance/for-each"));
  15587. var _indexOf = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/instance/index-of"));
  15588. var _splice = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/instance/splice"));
  15589. var _map = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/instance/map"));
  15590. var _arrayContainsObject = _interopRequireDefault(_dereq_("./arrayContainsObject"));
  15591. var _decode = _interopRequireDefault(_dereq_("./decode"));
  15592. var _encode = _interopRequireDefault(_dereq_("./encode"));
  15593. var _ParseObject = _interopRequireDefault(_dereq_("./ParseObject"));
  15594. var _ParseRelation = _interopRequireDefault(_dereq_("./ParseRelation"));
  15595. var _unique = _interopRequireDefault(_dereq_("./unique"));
  15596. function _createSuper(Derived) {
  15597. var hasNativeReflectConstruct = _isNativeReflectConstruct();
  15598. return function () {
  15599. var Super = (0, _getPrototypeOf2.default)(Derived),
  15600. result;
  15601. if (hasNativeReflectConstruct) {
  15602. var NewTarget = (0, _getPrototypeOf2.default)(this).constructor;
  15603. result = _Reflect$construct(Super, arguments, NewTarget);
  15604. } else {
  15605. result = Super.apply(this, arguments);
  15606. }
  15607. return (0, _possibleConstructorReturn2.default)(this, result);
  15608. };
  15609. }
  15610. function _isNativeReflectConstruct() {
  15611. if (typeof Reflect === "undefined" || !_Reflect$construct) return false;
  15612. if (_Reflect$construct.sham) return false;
  15613. if (typeof Proxy === "function") return true;
  15614. try {
  15615. Boolean.prototype.valueOf.call(_Reflect$construct(Boolean, [], function () {}));
  15616. return true;
  15617. } catch (e) {
  15618. return false;
  15619. }
  15620. }
  15621. function opFromJSON(json
  15622. /*: { [key: string]: any }*/
  15623. )
  15624. /*: ?Op*/
  15625. {
  15626. if (!json || !json.__op) {
  15627. return null;
  15628. }
  15629. switch (json.__op) {
  15630. case 'Delete':
  15631. return new UnsetOp();
  15632. case 'Increment':
  15633. return new IncrementOp(json.amount);
  15634. case 'Add':
  15635. return new AddOp((0, _decode.default)(json.objects));
  15636. case 'AddUnique':
  15637. return new AddUniqueOp((0, _decode.default)(json.objects));
  15638. case 'Remove':
  15639. return new RemoveOp((0, _decode.default)(json.objects));
  15640. case 'AddRelation':
  15641. {
  15642. var toAdd = (0, _decode.default)(json.objects);
  15643. if (!(0, _isArray.default)(toAdd)) {
  15644. return new RelationOp([], []);
  15645. }
  15646. return new RelationOp(toAdd, []);
  15647. }
  15648. case 'RemoveRelation':
  15649. {
  15650. var toRemove = (0, _decode.default)(json.objects);
  15651. if (!(0, _isArray.default)(toRemove)) {
  15652. return new RelationOp([], []);
  15653. }
  15654. return new RelationOp([], toRemove);
  15655. }
  15656. case 'Batch':
  15657. {
  15658. var _toAdd = [];
  15659. var _toRemove = [];
  15660. for (var i = 0; i < json.ops.length; i++) {
  15661. if (json.ops[i].__op === 'AddRelation') {
  15662. _toAdd = (0, _concat.default)(_toAdd).call(_toAdd, (0, _decode.default)(json.ops[i].objects));
  15663. } else if (json.ops[i].__op === 'RemoveRelation') {
  15664. _toRemove = (0, _concat.default)(_toRemove).call(_toRemove, (0, _decode.default)(json.ops[i].objects));
  15665. }
  15666. }
  15667. return new RelationOp(_toAdd, _toRemove);
  15668. }
  15669. default:
  15670. return null;
  15671. }
  15672. }
  15673. var Op = /*#__PURE__*/function () {
  15674. function Op() {
  15675. (0, _classCallCheck2.default)(this, Op);
  15676. }
  15677. (0, _createClass2.default)(Op, [{
  15678. key: "applyTo",
  15679. value: // Empty parent class
  15680. function ()
  15681. /*: mixed*/
  15682. {}
  15683. /* eslint-disable-line no-unused-vars */
  15684. }, {
  15685. key: "mergeWith",
  15686. value: function ()
  15687. /*: ?Op*/
  15688. {}
  15689. /* eslint-disable-line no-unused-vars */
  15690. }, {
  15691. key: "toJSON",
  15692. value: function ()
  15693. /*: mixed*/
  15694. {}
  15695. }]);
  15696. return Op;
  15697. }();
  15698. exports.Op = Op;
  15699. var SetOp = /*#__PURE__*/function (_Op) {
  15700. (0, _inherits2.default)(SetOp, _Op);
  15701. var _super = _createSuper(SetOp);
  15702. function SetOp(value
  15703. /*: mixed*/
  15704. ) {
  15705. var _this;
  15706. (0, _classCallCheck2.default)(this, SetOp);
  15707. _this = _super.call(this);
  15708. (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "_value", void 0);
  15709. _this._value = value;
  15710. return _this;
  15711. }
  15712. (0, _createClass2.default)(SetOp, [{
  15713. key: "applyTo",
  15714. value: function ()
  15715. /*: mixed*/
  15716. {
  15717. return this._value;
  15718. }
  15719. }, {
  15720. key: "mergeWith",
  15721. value: function ()
  15722. /*: SetOp*/
  15723. {
  15724. return new SetOp(this._value);
  15725. }
  15726. }, {
  15727. key: "toJSON",
  15728. value: function (offline
  15729. /*:: ?: boolean*/
  15730. ) {
  15731. return (0, _encode.default)(this._value, false, true, undefined, offline);
  15732. }
  15733. }]);
  15734. return SetOp;
  15735. }(Op);
  15736. exports.SetOp = SetOp;
  15737. var UnsetOp = /*#__PURE__*/function (_Op2) {
  15738. (0, _inherits2.default)(UnsetOp, _Op2);
  15739. var _super2 = _createSuper(UnsetOp);
  15740. function UnsetOp() {
  15741. (0, _classCallCheck2.default)(this, UnsetOp);
  15742. return _super2.apply(this, arguments);
  15743. }
  15744. (0, _createClass2.default)(UnsetOp, [{
  15745. key: "applyTo",
  15746. value: function () {
  15747. return undefined;
  15748. }
  15749. }, {
  15750. key: "mergeWith",
  15751. value: function ()
  15752. /*: UnsetOp*/
  15753. {
  15754. return new UnsetOp();
  15755. }
  15756. }, {
  15757. key: "toJSON",
  15758. value: function ()
  15759. /*: { __op: string }*/
  15760. {
  15761. return {
  15762. __op: 'Delete'
  15763. };
  15764. }
  15765. }]);
  15766. return UnsetOp;
  15767. }(Op);
  15768. exports.UnsetOp = UnsetOp;
  15769. var IncrementOp = /*#__PURE__*/function (_Op3) {
  15770. (0, _inherits2.default)(IncrementOp, _Op3);
  15771. var _super3 = _createSuper(IncrementOp);
  15772. function IncrementOp(amount
  15773. /*: number*/
  15774. ) {
  15775. var _this2;
  15776. (0, _classCallCheck2.default)(this, IncrementOp);
  15777. _this2 = _super3.call(this);
  15778. (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this2), "_amount", void 0);
  15779. if (typeof amount !== 'number') {
  15780. throw new TypeError('Increment Op must be initialized with a numeric amount.');
  15781. }
  15782. _this2._amount = amount;
  15783. return _this2;
  15784. }
  15785. (0, _createClass2.default)(IncrementOp, [{
  15786. key: "applyTo",
  15787. value: function (value
  15788. /*: ?mixed*/
  15789. )
  15790. /*: number*/
  15791. {
  15792. if (typeof value === 'undefined') {
  15793. return this._amount;
  15794. }
  15795. if (typeof value !== 'number') {
  15796. throw new TypeError('Cannot increment a non-numeric value.');
  15797. }
  15798. return this._amount + value;
  15799. }
  15800. }, {
  15801. key: "mergeWith",
  15802. value: function (previous
  15803. /*: Op*/
  15804. )
  15805. /*: Op*/
  15806. {
  15807. if (!previous) {
  15808. return this;
  15809. }
  15810. if (previous instanceof SetOp) {
  15811. return new SetOp(this.applyTo(previous._value));
  15812. }
  15813. if (previous instanceof UnsetOp) {
  15814. return new SetOp(this._amount);
  15815. }
  15816. if (previous instanceof IncrementOp) {
  15817. return new IncrementOp(this.applyTo(previous._amount));
  15818. }
  15819. throw new Error('Cannot merge Increment Op with the previous Op');
  15820. }
  15821. }, {
  15822. key: "toJSON",
  15823. value: function ()
  15824. /*: { __op: string, amount: number }*/
  15825. {
  15826. return {
  15827. __op: 'Increment',
  15828. amount: this._amount
  15829. };
  15830. }
  15831. }]);
  15832. return IncrementOp;
  15833. }(Op);
  15834. exports.IncrementOp = IncrementOp;
  15835. var AddOp = /*#__PURE__*/function (_Op4) {
  15836. (0, _inherits2.default)(AddOp, _Op4);
  15837. var _super4 = _createSuper(AddOp);
  15838. function AddOp(value
  15839. /*: mixed | Array<mixed>*/
  15840. ) {
  15841. var _this3;
  15842. (0, _classCallCheck2.default)(this, AddOp);
  15843. _this3 = _super4.call(this);
  15844. (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this3), "_value", void 0);
  15845. _this3._value = (0, _isArray.default)(value) ? value : [value];
  15846. return _this3;
  15847. }
  15848. (0, _createClass2.default)(AddOp, [{
  15849. key: "applyTo",
  15850. value: function (value
  15851. /*: mixed*/
  15852. )
  15853. /*: Array<mixed>*/
  15854. {
  15855. if (value == null) {
  15856. return this._value;
  15857. }
  15858. if ((0, _isArray.default)(value)) {
  15859. return (0, _concat.default)(value).call(value, this._value);
  15860. }
  15861. throw new Error('Cannot add elements to a non-array value');
  15862. }
  15863. }, {
  15864. key: "mergeWith",
  15865. value: function (previous
  15866. /*: Op*/
  15867. )
  15868. /*: Op*/
  15869. {
  15870. if (!previous) {
  15871. return this;
  15872. }
  15873. if (previous instanceof SetOp) {
  15874. return new SetOp(this.applyTo(previous._value));
  15875. }
  15876. if (previous instanceof UnsetOp) {
  15877. return new SetOp(this._value);
  15878. }
  15879. if (previous instanceof AddOp) {
  15880. return new AddOp(this.applyTo(previous._value));
  15881. }
  15882. throw new Error('Cannot merge Add Op with the previous Op');
  15883. }
  15884. }, {
  15885. key: "toJSON",
  15886. value: function ()
  15887. /*: { __op: string, objects: mixed }*/
  15888. {
  15889. return {
  15890. __op: 'Add',
  15891. objects: (0, _encode.default)(this._value, false, true)
  15892. };
  15893. }
  15894. }]);
  15895. return AddOp;
  15896. }(Op);
  15897. exports.AddOp = AddOp;
  15898. var AddUniqueOp = /*#__PURE__*/function (_Op5) {
  15899. (0, _inherits2.default)(AddUniqueOp, _Op5);
  15900. var _super5 = _createSuper(AddUniqueOp);
  15901. function AddUniqueOp(value
  15902. /*: mixed | Array<mixed>*/
  15903. ) {
  15904. var _this4;
  15905. (0, _classCallCheck2.default)(this, AddUniqueOp);
  15906. _this4 = _super5.call(this);
  15907. (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this4), "_value", void 0);
  15908. _this4._value = (0, _unique.default)((0, _isArray.default)(value) ? value : [value]);
  15909. return _this4;
  15910. }
  15911. (0, _createClass2.default)(AddUniqueOp, [{
  15912. key: "applyTo",
  15913. value: function (value
  15914. /*: mixed | Array<mixed>*/
  15915. )
  15916. /*: Array<mixed>*/
  15917. {
  15918. if (value == null) {
  15919. return this._value || [];
  15920. }
  15921. if ((0, _isArray.default)(value)) {
  15922. var _context;
  15923. var toAdd = [];
  15924. (0, _forEach.default)(_context = this._value).call(_context, function (v) {
  15925. if (v instanceof _ParseObject.default) {
  15926. if (!(0, _arrayContainsObject.default)(value, v)) {
  15927. toAdd.push(v);
  15928. }
  15929. } else {
  15930. if ((0, _indexOf.default)(value).call(value, v) < 0) {
  15931. toAdd.push(v);
  15932. }
  15933. }
  15934. });
  15935. return (0, _concat.default)(value).call(value, toAdd);
  15936. }
  15937. throw new Error('Cannot add elements to a non-array value');
  15938. }
  15939. }, {
  15940. key: "mergeWith",
  15941. value: function (previous
  15942. /*: Op*/
  15943. )
  15944. /*: Op*/
  15945. {
  15946. if (!previous) {
  15947. return this;
  15948. }
  15949. if (previous instanceof SetOp) {
  15950. return new SetOp(this.applyTo(previous._value));
  15951. }
  15952. if (previous instanceof UnsetOp) {
  15953. return new SetOp(this._value);
  15954. }
  15955. if (previous instanceof AddUniqueOp) {
  15956. return new AddUniqueOp(this.applyTo(previous._value));
  15957. }
  15958. throw new Error('Cannot merge AddUnique Op with the previous Op');
  15959. }
  15960. }, {
  15961. key: "toJSON",
  15962. value: function ()
  15963. /*: { __op: string, objects: mixed }*/
  15964. {
  15965. return {
  15966. __op: 'AddUnique',
  15967. objects: (0, _encode.default)(this._value, false, true)
  15968. };
  15969. }
  15970. }]);
  15971. return AddUniqueOp;
  15972. }(Op);
  15973. exports.AddUniqueOp = AddUniqueOp;
  15974. var RemoveOp = /*#__PURE__*/function (_Op6) {
  15975. (0, _inherits2.default)(RemoveOp, _Op6);
  15976. var _super6 = _createSuper(RemoveOp);
  15977. function RemoveOp(value
  15978. /*: mixed | Array<mixed>*/
  15979. ) {
  15980. var _this5;
  15981. (0, _classCallCheck2.default)(this, RemoveOp);
  15982. _this5 = _super6.call(this);
  15983. (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this5), "_value", void 0);
  15984. _this5._value = (0, _unique.default)((0, _isArray.default)(value) ? value : [value]);
  15985. return _this5;
  15986. }
  15987. (0, _createClass2.default)(RemoveOp, [{
  15988. key: "applyTo",
  15989. value: function (value
  15990. /*: mixed | Array<mixed>*/
  15991. )
  15992. /*: Array<mixed>*/
  15993. {
  15994. if (value == null) {
  15995. return [];
  15996. }
  15997. if ((0, _isArray.default)(value)) {
  15998. // var i = value.indexOf(this._value);
  15999. var removed = (0, _concat.default)(value).call(value, []);
  16000. for (var i = 0; i < this._value.length; i++) {
  16001. var index = (0, _indexOf.default)(removed).call(removed, this._value[i]);
  16002. while (index > -1) {
  16003. (0, _splice.default)(removed).call(removed, index, 1);
  16004. index = (0, _indexOf.default)(removed).call(removed, this._value[i]);
  16005. }
  16006. if (this._value[i] instanceof _ParseObject.default && this._value[i].id) {
  16007. for (var j = 0; j < removed.length; j++) {
  16008. if (removed[j] instanceof _ParseObject.default && this._value[i].id === removed[j].id) {
  16009. (0, _splice.default)(removed).call(removed, j, 1);
  16010. j--;
  16011. }
  16012. }
  16013. }
  16014. }
  16015. return removed;
  16016. }
  16017. throw new Error('Cannot remove elements from a non-array value');
  16018. }
  16019. }, {
  16020. key: "mergeWith",
  16021. value: function (previous
  16022. /*: Op*/
  16023. )
  16024. /*: Op*/
  16025. {
  16026. if (!previous) {
  16027. return this;
  16028. }
  16029. if (previous instanceof SetOp) {
  16030. return new SetOp(this.applyTo(previous._value));
  16031. }
  16032. if (previous instanceof UnsetOp) {
  16033. return new UnsetOp();
  16034. }
  16035. if (previous instanceof RemoveOp) {
  16036. var _context2;
  16037. var uniques = (0, _concat.default)(_context2 = previous._value).call(_context2, []);
  16038. for (var i = 0; i < this._value.length; i++) {
  16039. if (this._value[i] instanceof _ParseObject.default) {
  16040. if (!(0, _arrayContainsObject.default)(uniques, this._value[i])) {
  16041. uniques.push(this._value[i]);
  16042. }
  16043. } else {
  16044. if ((0, _indexOf.default)(uniques).call(uniques, this._value[i]) < 0) {
  16045. uniques.push(this._value[i]);
  16046. }
  16047. }
  16048. }
  16049. return new RemoveOp(uniques);
  16050. }
  16051. throw new Error('Cannot merge Remove Op with the previous Op');
  16052. }
  16053. }, {
  16054. key: "toJSON",
  16055. value: function ()
  16056. /*: { __op: string, objects: mixed }*/
  16057. {
  16058. return {
  16059. __op: 'Remove',
  16060. objects: (0, _encode.default)(this._value, false, true)
  16061. };
  16062. }
  16063. }]);
  16064. return RemoveOp;
  16065. }(Op);
  16066. exports.RemoveOp = RemoveOp;
  16067. var RelationOp = /*#__PURE__*/function (_Op7) {
  16068. (0, _inherits2.default)(RelationOp, _Op7);
  16069. var _super7 = _createSuper(RelationOp);
  16070. function RelationOp(adds
  16071. /*: Array<ParseObject | string>*/
  16072. , removes
  16073. /*: Array<ParseObject | string>*/
  16074. ) {
  16075. var _this6;
  16076. (0, _classCallCheck2.default)(this, RelationOp);
  16077. _this6 = _super7.call(this);
  16078. (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this6), "_targetClassName", void 0);
  16079. (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this6), "relationsToAdd", void 0);
  16080. (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this6), "relationsToRemove", void 0);
  16081. _this6._targetClassName = null;
  16082. if ((0, _isArray.default)(adds)) {
  16083. _this6.relationsToAdd = (0, _unique.default)((0, _map.default)(adds).call(adds, _this6._extractId, (0, _assertThisInitialized2.default)(_this6)));
  16084. }
  16085. if ((0, _isArray.default)(removes)) {
  16086. _this6.relationsToRemove = (0, _unique.default)((0, _map.default)(removes).call(removes, _this6._extractId, (0, _assertThisInitialized2.default)(_this6)));
  16087. }
  16088. return _this6;
  16089. }
  16090. (0, _createClass2.default)(RelationOp, [{
  16091. key: "_extractId",
  16092. value: function (obj
  16093. /*: string | ParseObject*/
  16094. )
  16095. /*: string*/
  16096. {
  16097. if (typeof obj === 'string') {
  16098. return obj;
  16099. }
  16100. if (!obj.id) {
  16101. throw new Error('You cannot add or remove an unsaved Parse Object from a relation');
  16102. }
  16103. if (!this._targetClassName) {
  16104. this._targetClassName = obj.className;
  16105. }
  16106. if (this._targetClassName !== obj.className) {
  16107. var _context3;
  16108. throw new Error((0, _concat.default)(_context3 = "Tried to create a Relation with 2 different object types: ".concat(this._targetClassName, " and ")).call(_context3, obj.className, "."));
  16109. }
  16110. return obj.id;
  16111. }
  16112. }, {
  16113. key: "applyTo",
  16114. value: function (value
  16115. /*: mixed*/
  16116. , object
  16117. /*:: ?: { className: string, id: ?string }*/
  16118. , key
  16119. /*:: ?: string*/
  16120. )
  16121. /*: ?ParseRelation*/
  16122. {
  16123. if (!value) {
  16124. var _context4;
  16125. if (!object || !key) {
  16126. throw new Error('Cannot apply a RelationOp without either a previous value, or an object and a key');
  16127. }
  16128. var parent = new _ParseObject.default(object.className);
  16129. if (object.id && (0, _indexOf.default)(_context4 = object.id).call(_context4, 'local') === 0) {
  16130. parent._localId = object.id;
  16131. } else if (object.id) {
  16132. parent.id = object.id;
  16133. }
  16134. var relation = new _ParseRelation.default(parent, key);
  16135. relation.targetClassName = this._targetClassName;
  16136. return relation;
  16137. }
  16138. if (value instanceof _ParseRelation.default) {
  16139. if (this._targetClassName) {
  16140. if (value.targetClassName) {
  16141. if (this._targetClassName !== value.targetClassName) {
  16142. var _context5;
  16143. throw new Error((0, _concat.default)(_context5 = "Related object must be a ".concat(value.targetClassName, ", but a ")).call(_context5, this._targetClassName, " was passed in."));
  16144. }
  16145. } else {
  16146. value.targetClassName = this._targetClassName;
  16147. }
  16148. }
  16149. return value;
  16150. }
  16151. throw new Error('Relation cannot be applied to a non-relation field');
  16152. }
  16153. }, {
  16154. key: "mergeWith",
  16155. value: function (previous
  16156. /*: Op*/
  16157. )
  16158. /*: Op*/
  16159. {
  16160. if (!previous) {
  16161. return this;
  16162. }
  16163. if (previous instanceof UnsetOp) {
  16164. throw new Error('You cannot modify a relation after deleting it.');
  16165. }
  16166. if (previous instanceof SetOp && previous._value instanceof _ParseRelation.default) {
  16167. return this;
  16168. }
  16169. if (previous instanceof RelationOp) {
  16170. var _context7, _context8, _context9, _context10, _context11, _context12;
  16171. if (previous._targetClassName && previous._targetClassName !== this._targetClassName) {
  16172. var _context6;
  16173. throw new Error((0, _concat.default)(_context6 = "Related object must be of class ".concat(previous._targetClassName, ", but ")).call(_context6, this._targetClassName || 'null', " was passed in."));
  16174. }
  16175. var newAdd = (0, _concat.default)(_context7 = previous.relationsToAdd).call(_context7, []);
  16176. (0, _forEach.default)(_context8 = this.relationsToRemove).call(_context8, function (r) {
  16177. var index = (0, _indexOf.default)(newAdd).call(newAdd, r);
  16178. if (index > -1) {
  16179. (0, _splice.default)(newAdd).call(newAdd, index, 1);
  16180. }
  16181. });
  16182. (0, _forEach.default)(_context9 = this.relationsToAdd).call(_context9, function (r) {
  16183. var index = (0, _indexOf.default)(newAdd).call(newAdd, r);
  16184. if (index < 0) {
  16185. newAdd.push(r);
  16186. }
  16187. });
  16188. var newRemove = (0, _concat.default)(_context10 = previous.relationsToRemove).call(_context10, []);
  16189. (0, _forEach.default)(_context11 = this.relationsToAdd).call(_context11, function (r) {
  16190. var index = (0, _indexOf.default)(newRemove).call(newRemove, r);
  16191. if (index > -1) {
  16192. (0, _splice.default)(newRemove).call(newRemove, index, 1);
  16193. }
  16194. });
  16195. (0, _forEach.default)(_context12 = this.relationsToRemove).call(_context12, function (r) {
  16196. var index = (0, _indexOf.default)(newRemove).call(newRemove, r);
  16197. if (index < 0) {
  16198. newRemove.push(r);
  16199. }
  16200. });
  16201. var newRelation = new RelationOp(newAdd, newRemove);
  16202. newRelation._targetClassName = this._targetClassName;
  16203. return newRelation;
  16204. }
  16205. throw new Error('Cannot merge Relation Op with the previous Op');
  16206. }
  16207. }, {
  16208. key: "toJSON",
  16209. value: function ()
  16210. /*: { __op?: string, objects?: mixed, ops?: mixed }*/
  16211. {
  16212. var _this7 = this;
  16213. var idToPointer = function (id) {
  16214. return {
  16215. __type: 'Pointer',
  16216. className: _this7._targetClassName,
  16217. objectId: id
  16218. };
  16219. };
  16220. var adds = null;
  16221. var removes = null;
  16222. var pointers = null;
  16223. if (this.relationsToAdd.length > 0) {
  16224. var _context13;
  16225. pointers = (0, _map.default)(_context13 = this.relationsToAdd).call(_context13, idToPointer);
  16226. adds = {
  16227. __op: 'AddRelation',
  16228. objects: pointers
  16229. };
  16230. }
  16231. if (this.relationsToRemove.length > 0) {
  16232. var _context14;
  16233. pointers = (0, _map.default)(_context14 = this.relationsToRemove).call(_context14, idToPointer);
  16234. removes = {
  16235. __op: 'RemoveRelation',
  16236. objects: pointers
  16237. };
  16238. }
  16239. if (adds && removes) {
  16240. return {
  16241. __op: 'Batch',
  16242. ops: [adds, removes]
  16243. };
  16244. }
  16245. return adds || removes || {};
  16246. }
  16247. }]);
  16248. return RelationOp;
  16249. }(Op);
  16250. exports.RelationOp = RelationOp;
  16251. },{"./ParseObject":36,"./ParseRelation":40,"./arrayContainsObject":62,"./decode":65,"./encode":66,"./unique":73,"@babel/runtime-corejs3/core-js-stable/array/is-array":79,"@babel/runtime-corejs3/core-js-stable/instance/concat":81,"@babel/runtime-corejs3/core-js-stable/instance/for-each":86,"@babel/runtime-corejs3/core-js-stable/instance/index-of":88,"@babel/runtime-corejs3/core-js-stable/instance/map":90,"@babel/runtime-corejs3/core-js-stable/instance/splice":95,"@babel/runtime-corejs3/core-js-stable/object/define-property":105,"@babel/runtime-corejs3/core-js-stable/reflect/construct":116,"@babel/runtime-corejs3/helpers/assertThisInitialized":143,"@babel/runtime-corejs3/helpers/classCallCheck":145,"@babel/runtime-corejs3/helpers/createClass":147,"@babel/runtime-corejs3/helpers/defineProperty":148,"@babel/runtime-corejs3/helpers/getPrototypeOf":150,"@babel/runtime-corejs3/helpers/inherits":151,"@babel/runtime-corejs3/helpers/interopRequireDefault":152,"@babel/runtime-corejs3/helpers/possibleConstructorReturn":159}],38:[function(_dereq_,module,exports){
  16252. "use strict";
  16253. var _Object$defineProperty = _dereq_("@babel/runtime-corejs3/core-js-stable/object/define-property");
  16254. var _interopRequireDefault = _dereq_("@babel/runtime-corejs3/helpers/interopRequireDefault");
  16255. _Object$defineProperty(exports, "__esModule", {
  16256. value: true
  16257. });
  16258. exports.default = void 0;
  16259. var _isArray = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/array/is-array"));
  16260. var _classCallCheck2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/helpers/classCallCheck"));
  16261. var _createClass2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/helpers/createClass"));
  16262. var _defineProperty2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/helpers/defineProperty"));
  16263. var _ParseGeoPoint = _interopRequireDefault(_dereq_("./ParseGeoPoint"));
  16264. /**
  16265. * Copyright (c) 2015-present, Parse, LLC.
  16266. * All rights reserved.
  16267. *
  16268. * This source code is licensed under the BSD-style license found in the
  16269. * LICENSE file in the root directory of this source tree. An additional grant
  16270. * of patent rights can be found in the PATENTS file in the same directory.
  16271. *
  16272. * @flow
  16273. */
  16274. /**
  16275. * Creates a new Polygon with any of the following forms:<br>
  16276. * <pre>
  16277. * new Polygon([[0,0],[0,1],[1,1],[1,0]])
  16278. * new Polygon([GeoPoint, GeoPoint, GeoPoint])
  16279. * </pre>
  16280. *
  16281. * <p>Represents a coordinates that may be associated
  16282. * with a key in a ParseObject or used as a reference point for geo queries.
  16283. * This allows proximity-based queries on the key.</p>
  16284. *
  16285. * <p>Example:<pre>
  16286. * var polygon = new Parse.Polygon([[0,0],[0,1],[1,1],[1,0]]);
  16287. * var object = new Parse.Object("PlaceObject");
  16288. * object.set("area", polygon);
  16289. * object.save();</pre></p>
  16290. *
  16291. * @alias Parse.Polygon
  16292. */
  16293. var ParsePolygon = /*#__PURE__*/function () {
  16294. /**
  16295. * @param {(number[][] | Parse.GeoPoint[])} coordinates An Array of coordinate pairs
  16296. */
  16297. function ParsePolygon(coordinates
  16298. /*: Array<Array<number>> | Array<ParseGeoPoint>*/
  16299. ) {
  16300. (0, _classCallCheck2.default)(this, ParsePolygon);
  16301. (0, _defineProperty2.default)(this, "_coordinates", void 0);
  16302. this._coordinates = ParsePolygon._validate(coordinates);
  16303. }
  16304. /**
  16305. * Coordinates value for this Polygon.
  16306. * Throws an exception if not valid type.
  16307. *
  16308. * @property {(number[][] | Parse.GeoPoint[])} coordinates list of coordinates
  16309. * @returns {number[][]}
  16310. */
  16311. (0, _createClass2.default)(ParsePolygon, [{
  16312. key: "coordinates",
  16313. get: function ()
  16314. /*: Array<Array<number>>*/
  16315. {
  16316. return this._coordinates;
  16317. },
  16318. set: function (coords
  16319. /*: Array<Array<number>> | Array<ParseGeoPoint>*/
  16320. ) {
  16321. this._coordinates = ParsePolygon._validate(coords);
  16322. }
  16323. /**
  16324. * Returns a JSON representation of the Polygon, suitable for Parse.
  16325. *
  16326. * @returns {object}
  16327. */
  16328. }, {
  16329. key: "toJSON",
  16330. value: function ()
  16331. /*: { __type: string, coordinates: Array<Array<number>> }*/
  16332. {
  16333. ParsePolygon._validate(this._coordinates);
  16334. return {
  16335. __type: 'Polygon',
  16336. coordinates: this._coordinates
  16337. };
  16338. }
  16339. /**
  16340. * Checks if two polygons are equal
  16341. *
  16342. * @param {(Parse.Polygon | object)} other
  16343. * @returns {boolean}
  16344. */
  16345. }, {
  16346. key: "equals",
  16347. value: function (other
  16348. /*: mixed*/
  16349. )
  16350. /*: boolean*/
  16351. {
  16352. if (!(other instanceof ParsePolygon) || this.coordinates.length !== other.coordinates.length) {
  16353. return false;
  16354. }
  16355. var isEqual = true;
  16356. for (var i = 1; i < this._coordinates.length; i += 1) {
  16357. if (this._coordinates[i][0] !== other.coordinates[i][0] || this._coordinates[i][1] !== other.coordinates[i][1]) {
  16358. isEqual = false;
  16359. break;
  16360. }
  16361. }
  16362. return isEqual;
  16363. }
  16364. /**
  16365. *
  16366. * @param {Parse.GeoPoint} point
  16367. * @returns {boolean} Returns if the point is contained in the polygon
  16368. */
  16369. }, {
  16370. key: "containsPoint",
  16371. value: function (point
  16372. /*: ParseGeoPoint*/
  16373. )
  16374. /*: boolean*/
  16375. {
  16376. var minX = this._coordinates[0][0];
  16377. var maxX = this._coordinates[0][0];
  16378. var minY = this._coordinates[0][1];
  16379. var maxY = this._coordinates[0][1];
  16380. for (var i = 1; i < this._coordinates.length; i += 1) {
  16381. var p = this._coordinates[i];
  16382. minX = Math.min(p[0], minX);
  16383. maxX = Math.max(p[0], maxX);
  16384. minY = Math.min(p[1], minY);
  16385. maxY = Math.max(p[1], maxY);
  16386. }
  16387. var outside = point.latitude < minX || point.latitude > maxX || point.longitude < minY || point.longitude > maxY;
  16388. if (outside) {
  16389. return false;
  16390. }
  16391. var inside = false;
  16392. for (var _i = 0, j = this._coordinates.length - 1; _i < this._coordinates.length; j = _i++) {
  16393. var startX = this._coordinates[_i][0];
  16394. var startY = this._coordinates[_i][1];
  16395. var endX = this._coordinates[j][0];
  16396. var endY = this._coordinates[j][1];
  16397. var intersect = startY > point.longitude !== endY > point.longitude && point.latitude < (endX - startX) * (point.longitude - startY) / (endY - startY) + startX;
  16398. if (intersect) {
  16399. inside = !inside;
  16400. }
  16401. }
  16402. return inside;
  16403. }
  16404. /**
  16405. * Validates that the list of coordinates can form a valid polygon
  16406. *
  16407. * @param {Array} coords the list of coordinates to validate as a polygon
  16408. * @throws {TypeError}
  16409. * @returns {number[][]} Array of coordinates if validated.
  16410. */
  16411. }], [{
  16412. key: "_validate",
  16413. value: function (coords
  16414. /*: Array<Array<number>> | Array<ParseGeoPoint>*/
  16415. )
  16416. /*: Array<Array<number>>*/
  16417. {
  16418. if (!(0, _isArray.default)(coords)) {
  16419. throw new TypeError('Coordinates must be an Array');
  16420. }
  16421. if (coords.length < 3) {
  16422. throw new TypeError('Polygon must have at least 3 GeoPoints or Points');
  16423. }
  16424. var points = [];
  16425. for (var i = 0; i < coords.length; i += 1) {
  16426. var coord = coords[i];
  16427. var geoPoint = void 0;
  16428. if (coord instanceof _ParseGeoPoint.default) {
  16429. geoPoint = coord;
  16430. } else if ((0, _isArray.default)(coord) && coord.length === 2) {
  16431. geoPoint = new _ParseGeoPoint.default(coord[0], coord[1]);
  16432. } else {
  16433. throw new TypeError('Coordinates must be an Array of GeoPoints or Points');
  16434. }
  16435. points.push([geoPoint.latitude, geoPoint.longitude]);
  16436. }
  16437. return points;
  16438. }
  16439. }]);
  16440. return ParsePolygon;
  16441. }();
  16442. var _default = ParsePolygon;
  16443. exports.default = _default;
  16444. },{"./ParseGeoPoint":33,"@babel/runtime-corejs3/core-js-stable/array/is-array":79,"@babel/runtime-corejs3/core-js-stable/object/define-property":105,"@babel/runtime-corejs3/helpers/classCallCheck":145,"@babel/runtime-corejs3/helpers/createClass":147,"@babel/runtime-corejs3/helpers/defineProperty":148,"@babel/runtime-corejs3/helpers/interopRequireDefault":152}],39:[function(_dereq_,module,exports){
  16445. "use strict";
  16446. var _Object$defineProperty = _dereq_("@babel/runtime-corejs3/core-js-stable/object/define-property");
  16447. var _interopRequireDefault = _dereq_("@babel/runtime-corejs3/helpers/interopRequireDefault");
  16448. _Object$defineProperty(exports, "__esModule", {
  16449. value: true
  16450. });
  16451. exports.default = void 0;
  16452. var _regenerator = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/regenerator"));
  16453. var _slicedToArray2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/helpers/slicedToArray"));
  16454. var _toConsumableArray2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/helpers/toConsumableArray"));
  16455. var _asyncToGenerator2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/helpers/asyncToGenerator"));
  16456. var _classCallCheck2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/helpers/classCallCheck"));
  16457. var _createClass2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/helpers/createClass"));
  16458. var _defineProperty2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/helpers/defineProperty"));
  16459. var _typeof2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/helpers/typeof"));
  16460. var _forEach = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/instance/for-each"));
  16461. var _indexOf = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/instance/index-of"));
  16462. var _keys = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/object/keys"));
  16463. var _slice = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/instance/slice"));
  16464. var _map2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/instance/map"));
  16465. var _filter2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/instance/filter"));
  16466. var _keys2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/instance/keys"));
  16467. var _concat = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/instance/concat"));
  16468. var _includes = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/instance/includes"));
  16469. var _sort = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/instance/sort"));
  16470. var _splice = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/instance/splice"));
  16471. var _promise = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/promise"));
  16472. var _find = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/instance/find"));
  16473. var _isArray = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/array/is-array"));
  16474. var _entries = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/object/entries"));
  16475. var _CoreManager = _interopRequireDefault(_dereq_("./CoreManager"));
  16476. var _encode = _interopRequireDefault(_dereq_("./encode"));
  16477. var _promiseUtils = _dereq_("./promiseUtils");
  16478. var _ParseError = _interopRequireDefault(_dereq_("./ParseError"));
  16479. var _ParseGeoPoint = _interopRequireDefault(_dereq_("./ParseGeoPoint"));
  16480. var _ParseObject = _interopRequireDefault(_dereq_("./ParseObject"));
  16481. var _OfflineQuery = _interopRequireDefault(_dereq_("./OfflineQuery"));
  16482. var _LocalDatastoreUtils = _dereq_("./LocalDatastoreUtils");
  16483. /*
  16484. * Copyright (c) 2015-present, Parse, LLC.
  16485. * All rights reserved.
  16486. *
  16487. * This source code is licensed under the BSD-style license found in the
  16488. * LICENSE file in the root directory of this source tree. An additional grant
  16489. * of patent rights can be found in the PATENTS file in the same directory.
  16490. *
  16491. * @flow
  16492. */
  16493. /**
  16494. * Converts a string into a regex that matches it.
  16495. * Surrounding with \Q .. \E does this, we just need to escape any \E's in
  16496. * the text separately.
  16497. *
  16498. * @param s
  16499. * @private
  16500. * @returns {string}
  16501. */
  16502. function quote(s
  16503. /*: string*/
  16504. )
  16505. /*: string*/
  16506. {
  16507. return "\\Q".concat(s.replace('\\E', '\\E\\\\E\\Q'), "\\E");
  16508. }
  16509. /**
  16510. * Extracts the class name from queries. If not all queries have the same
  16511. * class name an error will be thrown.
  16512. *
  16513. * @param queries
  16514. * @private
  16515. * @returns {string}
  16516. */
  16517. function _getClassNameFromQueries(queries
  16518. /*: Array<ParseQuery>*/
  16519. )
  16520. /*: ?string*/
  16521. {
  16522. var className = null;
  16523. (0, _forEach.default)(queries).call(queries, function (q) {
  16524. if (!className) {
  16525. // eslint-disable-next-line prefer-destructuring
  16526. className = q.className;
  16527. }
  16528. if (className !== q.className) {
  16529. throw new Error('All queries must be for the same class.');
  16530. }
  16531. });
  16532. return className;
  16533. }
  16534. /*
  16535. * Handles pre-populating the result data of a query with select fields,
  16536. * making sure that the data object contains keys for all objects that have
  16537. * been requested with a select, so that our cached state updates correctly.
  16538. */
  16539. function handleSelectResult(data
  16540. /*: any*/
  16541. , select
  16542. /*: Array<string>*/
  16543. ) {
  16544. var serverDataMask = {};
  16545. (0, _forEach.default)(select).call(select, function (field) {
  16546. var hasSubObjectSelect = (0, _indexOf.default)(field).call(field, '.') !== -1;
  16547. if (!hasSubObjectSelect && !data.hasOwnProperty(field)) {
  16548. // this field was selected, but is missing from the retrieved data
  16549. data[field] = undefined;
  16550. } else if (hasSubObjectSelect) {
  16551. // this field references a sub-object,
  16552. // so we need to walk down the path components
  16553. var pathComponents = field.split('.');
  16554. var _obj = data;
  16555. var serverMask = serverDataMask;
  16556. (0, _forEach.default)(pathComponents).call(pathComponents, function (component, index, arr) {
  16557. // add keys if the expected data is missing
  16558. if (_obj && !_obj.hasOwnProperty(component)) {
  16559. _obj[component] = undefined;
  16560. }
  16561. if (_obj && (0, _typeof2.default)(_obj) === 'object') {
  16562. _obj = _obj[component];
  16563. } // add this path component to the server mask so we can fill it in later if needed
  16564. if (index < arr.length - 1) {
  16565. if (!serverMask[component]) {
  16566. serverMask[component] = {};
  16567. }
  16568. serverMask = serverMask[component];
  16569. }
  16570. });
  16571. }
  16572. });
  16573. if ((0, _keys.default)(serverDataMask).length > 0) {
  16574. // When selecting from sub-objects, we don't want to blow away the missing
  16575. // information that we may have retrieved before. We've already added any
  16576. // missing selected keys to sub-objects, but we still need to add in the
  16577. // data for any previously retrieved sub-objects that were not selected.
  16578. var serverData = _CoreManager.default.getObjectStateController().getServerData({
  16579. id: data.objectId,
  16580. className: data.className
  16581. });
  16582. copyMissingDataWithMask(serverData, data, serverDataMask, false);
  16583. }
  16584. }
  16585. function copyMissingDataWithMask(src, dest, mask, copyThisLevel) {
  16586. // copy missing elements at this level
  16587. if (copyThisLevel) {
  16588. for (var _key in src) {
  16589. if (src.hasOwnProperty(_key) && !dest.hasOwnProperty(_key)) {
  16590. dest[_key] = src[_key];
  16591. }
  16592. }
  16593. }
  16594. for (var _key2 in mask) {
  16595. if (dest[_key2] !== undefined && dest[_key2] !== null && src !== undefined && src !== null) {
  16596. // traverse into objects as needed
  16597. copyMissingDataWithMask(src[_key2], dest[_key2], mask[_key2], true);
  16598. }
  16599. }
  16600. }
  16601. function handleOfflineSort(a, b, sorts) {
  16602. var order = sorts[0];
  16603. var operator = (0, _slice.default)(order).call(order, 0, 1);
  16604. var isDescending = operator === '-';
  16605. if (isDescending) {
  16606. order = order.substring(1);
  16607. }
  16608. if (order === '_created_at') {
  16609. order = 'createdAt';
  16610. }
  16611. if (order === '_updated_at') {
  16612. order = 'updatedAt';
  16613. }
  16614. if (!/^[A-Za-z][0-9A-Za-z_]*$/.test(order) || order === 'password') {
  16615. throw new _ParseError.default(_ParseError.default.INVALID_KEY_NAME, "Invalid Key: ".concat(order));
  16616. }
  16617. var field1 = a.get(order);
  16618. var field2 = b.get(order);
  16619. if (field1 < field2) {
  16620. return isDescending ? 1 : -1;
  16621. }
  16622. if (field1 > field2) {
  16623. return isDescending ? -1 : 1;
  16624. }
  16625. if (sorts.length > 1) {
  16626. var remainingSorts = (0, _slice.default)(sorts).call(sorts, 1);
  16627. return handleOfflineSort(a, b, remainingSorts);
  16628. }
  16629. return 0;
  16630. }
  16631. /**
  16632. * Creates a new parse Parse.Query for the given Parse.Object subclass.
  16633. *
  16634. * <p>Parse.Query defines a query that is used to fetch Parse.Objects. The
  16635. * most common use case is finding all objects that match a query through the
  16636. * <code>find</code> method. for example, this sample code fetches all objects
  16637. * of class <code>myclass</code>. it calls a different function depending on
  16638. * whether the fetch succeeded or not.
  16639. *
  16640. * <pre>
  16641. * var query = new Parse.Query(myclass);
  16642. * query.find().then((results) => {
  16643. * // results is an array of parse.object.
  16644. * }).catch((error) => {
  16645. * // error is an instance of parse.error.
  16646. * });</pre></p>
  16647. *
  16648. * <p>a Parse.Query can also be used to retrieve a single object whose id is
  16649. * known, through the get method. for example, this sample code fetches an
  16650. * object of class <code>myclass</code> and id <code>myid</code>. it calls a
  16651. * different function depending on whether the fetch succeeded or not.
  16652. *
  16653. * <pre>
  16654. * var query = new Parse.Query(myclass);
  16655. * query.get(myid).then((object) => {
  16656. * // object is an instance of parse.object.
  16657. * }).catch((error) => {
  16658. * // error is an instance of parse.error.
  16659. * });</pre></p>
  16660. *
  16661. * <p>a Parse.Query can also be used to count the number of objects that match
  16662. * the query without retrieving all of those objects. for example, this
  16663. * sample code counts the number of objects of the class <code>myclass</code>
  16664. * <pre>
  16665. * var query = new Parse.Query(myclass);
  16666. * query.count().then((number) => {
  16667. * // there are number instances of myclass.
  16668. * }).catch((error) => {
  16669. * // error is an instance of Parse.Error.
  16670. * });</pre></p>
  16671. *
  16672. * @alias Parse.Query
  16673. */
  16674. var ParseQuery = /*#__PURE__*/function () {
  16675. /**
  16676. * @property {string} className
  16677. */
  16678. /**
  16679. * @param {(string | Parse.Object)} objectClass An instance of a subclass of Parse.Object, or a Parse className string.
  16680. */
  16681. function ParseQuery(objectClass
  16682. /*: string | ParseObject*/
  16683. ) {
  16684. (0, _classCallCheck2.default)(this, ParseQuery);
  16685. (0, _defineProperty2.default)(this, "className", void 0);
  16686. (0, _defineProperty2.default)(this, "_where", void 0);
  16687. (0, _defineProperty2.default)(this, "_include", void 0);
  16688. (0, _defineProperty2.default)(this, "_exclude", void 0);
  16689. (0, _defineProperty2.default)(this, "_select", void 0);
  16690. (0, _defineProperty2.default)(this, "_limit", void 0);
  16691. (0, _defineProperty2.default)(this, "_skip", void 0);
  16692. (0, _defineProperty2.default)(this, "_count", void 0);
  16693. (0, _defineProperty2.default)(this, "_order", void 0);
  16694. (0, _defineProperty2.default)(this, "_readPreference", void 0);
  16695. (0, _defineProperty2.default)(this, "_includeReadPreference", void 0);
  16696. (0, _defineProperty2.default)(this, "_subqueryReadPreference", void 0);
  16697. (0, _defineProperty2.default)(this, "_queriesLocalDatastore", void 0);
  16698. (0, _defineProperty2.default)(this, "_localDatastorePinName", void 0);
  16699. (0, _defineProperty2.default)(this, "_extraOptions", void 0);
  16700. (0, _defineProperty2.default)(this, "_hint", void 0);
  16701. (0, _defineProperty2.default)(this, "_explain", void 0);
  16702. (0, _defineProperty2.default)(this, "_xhrRequest", void 0);
  16703. if (typeof objectClass === 'string') {
  16704. if (objectClass === 'User' && _CoreManager.default.get('PERFORM_USER_REWRITE')) {
  16705. this.className = '_User';
  16706. } else {
  16707. this.className = objectClass;
  16708. }
  16709. } else if (objectClass instanceof _ParseObject.default) {
  16710. this.className = objectClass.className;
  16711. } else if (typeof objectClass === 'function') {
  16712. if (typeof objectClass.className === 'string') {
  16713. this.className = objectClass.className;
  16714. } else {
  16715. var _obj2 = new objectClass();
  16716. this.className = _obj2.className;
  16717. }
  16718. } else {
  16719. throw new TypeError('A ParseQuery must be constructed with a ParseObject or class name.');
  16720. }
  16721. this._where = {};
  16722. this._include = [];
  16723. this._exclude = [];
  16724. this._count = false; // negative limit is not sent in the server request
  16725. this._limit = -1;
  16726. this._skip = 0;
  16727. this._readPreference = null;
  16728. this._includeReadPreference = null;
  16729. this._subqueryReadPreference = null;
  16730. this._queriesLocalDatastore = false;
  16731. this._localDatastorePinName = null;
  16732. this._extraOptions = {};
  16733. this._xhrRequest = {
  16734. task: null,
  16735. onchange: function () {}
  16736. };
  16737. }
  16738. /**
  16739. * Adds constraint that at least one of the passed in queries matches.
  16740. *
  16741. * @param {Array} queries
  16742. * @returns {Parse.Query} Returns the query, so you can chain this call.
  16743. */
  16744. (0, _createClass2.default)(ParseQuery, [{
  16745. key: "_orQuery",
  16746. value: function (queries
  16747. /*: Array<ParseQuery>*/
  16748. )
  16749. /*: ParseQuery*/
  16750. {
  16751. var queryJSON = (0, _map2.default)(queries).call(queries, function (q) {
  16752. return q.toJSON().where;
  16753. });
  16754. this._where.$or = queryJSON;
  16755. return this;
  16756. }
  16757. /**
  16758. * Adds constraint that all of the passed in queries match.
  16759. *
  16760. * @param {Array} queries
  16761. * @returns {Parse.Query} Returns the query, so you can chain this call.
  16762. */
  16763. }, {
  16764. key: "_andQuery",
  16765. value: function (queries
  16766. /*: Array<ParseQuery>*/
  16767. )
  16768. /*: ParseQuery*/
  16769. {
  16770. var queryJSON = (0, _map2.default)(queries).call(queries, function (q) {
  16771. return q.toJSON().where;
  16772. });
  16773. this._where.$and = queryJSON;
  16774. return this;
  16775. }
  16776. /**
  16777. * Adds constraint that none of the passed in queries match.
  16778. *
  16779. * @param {Array} queries
  16780. * @returns {Parse.Query} Returns the query, so you can chain this call.
  16781. */
  16782. }, {
  16783. key: "_norQuery",
  16784. value: function (queries
  16785. /*: Array<ParseQuery>*/
  16786. )
  16787. /*: ParseQuery*/
  16788. {
  16789. var queryJSON = (0, _map2.default)(queries).call(queries, function (q) {
  16790. return q.toJSON().where;
  16791. });
  16792. this._where.$nor = queryJSON;
  16793. return this;
  16794. }
  16795. /**
  16796. * Helper for condition queries
  16797. *
  16798. * @param key
  16799. * @param condition
  16800. * @param value
  16801. * @returns {Parse.Query}
  16802. */
  16803. }, {
  16804. key: "_addCondition",
  16805. value: function (key
  16806. /*: string*/
  16807. , condition
  16808. /*: string*/
  16809. , value
  16810. /*: mixed*/
  16811. )
  16812. /*: ParseQuery*/
  16813. {
  16814. if (!this._where[key] || typeof this._where[key] === 'string') {
  16815. this._where[key] = {};
  16816. }
  16817. this._where[key][condition] = (0, _encode.default)(value, false, true);
  16818. return this;
  16819. }
  16820. /**
  16821. * Converts string for regular expression at the beginning
  16822. *
  16823. * @param string
  16824. * @returns {string}
  16825. */
  16826. }, {
  16827. key: "_regexStartWith",
  16828. value: function (string
  16829. /*: string*/
  16830. )
  16831. /*: string*/
  16832. {
  16833. return "^".concat(quote(string));
  16834. }
  16835. }, {
  16836. key: "_handleOfflineQuery",
  16837. value: function () {
  16838. var _handleOfflineQuery2 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee(params
  16839. /*: any*/
  16840. ) {
  16841. var _context,
  16842. _this2 = this;
  16843. var localDatastore, objects, results, keys, alwaysSelectedKeys, sorts, count, limit;
  16844. return _regenerator.default.wrap(function (_context3) {
  16845. while (1) {
  16846. switch (_context3.prev = _context3.next) {
  16847. case 0:
  16848. _OfflineQuery.default.validateQuery(this);
  16849. localDatastore = _CoreManager.default.getLocalDatastore();
  16850. _context3.next = 4;
  16851. return localDatastore._serializeObjectsFromPinName(this._localDatastorePinName);
  16852. case 4:
  16853. objects = _context3.sent;
  16854. results = (0, _filter2.default)(_context = (0, _map2.default)(objects).call(objects, function (json, index, arr) {
  16855. var object = _ParseObject.default.fromJSON(json, false);
  16856. if (json._localId && !json.objectId) {
  16857. object._localId = json._localId;
  16858. }
  16859. if (!_OfflineQuery.default.matchesQuery(_this2.className, object, arr, _this2)) {
  16860. return null;
  16861. }
  16862. return object;
  16863. })).call(_context, function (object) {
  16864. return object !== null;
  16865. });
  16866. if ((0, _keys2.default)(params)) {
  16867. keys = (0, _keys2.default)(params).split(',');
  16868. alwaysSelectedKeys = ['className', 'objectId', 'createdAt', 'updatedAt', 'ACL'];
  16869. keys = (0, _concat.default)(keys).call(keys, alwaysSelectedKeys);
  16870. results = (0, _map2.default)(results).call(results, function (object) {
  16871. var _context2;
  16872. var json = object._toFullJSON();
  16873. (0, _forEach.default)(_context2 = (0, _keys.default)(json)).call(_context2, function (key) {
  16874. if (!(0, _includes.default)(keys).call(keys, key)) {
  16875. delete json[key];
  16876. }
  16877. });
  16878. return _ParseObject.default.fromJSON(json, false);
  16879. });
  16880. }
  16881. if (params.order) {
  16882. sorts = params.order.split(',');
  16883. (0, _sort.default)(results).call(results, function (a, b) {
  16884. return handleOfflineSort(a, b, sorts);
  16885. });
  16886. } // count total before applying limit/skip
  16887. if (params.count) {
  16888. // total count from response
  16889. count = results.length;
  16890. }
  16891. if (params.skip) {
  16892. if (params.skip >= results.length) {
  16893. results = [];
  16894. } else {
  16895. results = (0, _splice.default)(results).call(results, params.skip, results.length);
  16896. }
  16897. }
  16898. limit = results.length;
  16899. if (params.limit !== 0 && params.limit < results.length) {
  16900. // eslint-disable-next-line prefer-destructuring
  16901. limit = params.limit;
  16902. }
  16903. results = (0, _splice.default)(results).call(results, 0, limit);
  16904. if (!(typeof count === 'number')) {
  16905. _context3.next = 15;
  16906. break;
  16907. }
  16908. return _context3.abrupt("return", {
  16909. results: results,
  16910. count: count
  16911. });
  16912. case 15:
  16913. return _context3.abrupt("return", results);
  16914. case 16:
  16915. case "end":
  16916. return _context3.stop();
  16917. }
  16918. }
  16919. }, _callee, this);
  16920. }));
  16921. return function () {
  16922. return _handleOfflineQuery2.apply(this, arguments);
  16923. };
  16924. }()
  16925. /**
  16926. * Returns a JSON representation of this query.
  16927. *
  16928. * @returns {object} The JSON representation of the query.
  16929. */
  16930. }, {
  16931. key: "toJSON",
  16932. value: function ()
  16933. /*: QueryJSON*/
  16934. {
  16935. var params
  16936. /*: QueryJSON*/
  16937. = {
  16938. where: this._where
  16939. };
  16940. if (this._include.length) {
  16941. params.include = this._include.join(',');
  16942. }
  16943. if (this._exclude.length) {
  16944. params.excludeKeys = this._exclude.join(',');
  16945. }
  16946. if (this._select) {
  16947. params.keys = this._select.join(',');
  16948. }
  16949. if (this._count) {
  16950. params.count = 1;
  16951. }
  16952. if (this._limit >= 0) {
  16953. params.limit = this._limit;
  16954. }
  16955. if (this._skip > 0) {
  16956. params.skip = this._skip;
  16957. }
  16958. if (this._order) {
  16959. params.order = this._order.join(',');
  16960. }
  16961. if (this._readPreference) {
  16962. params.readPreference = this._readPreference;
  16963. }
  16964. if (this._includeReadPreference) {
  16965. params.includeReadPreference = this._includeReadPreference;
  16966. }
  16967. if (this._subqueryReadPreference) {
  16968. params.subqueryReadPreference = this._subqueryReadPreference;
  16969. }
  16970. if (this._hint) {
  16971. params.hint = this._hint;
  16972. }
  16973. if (this._explain) {
  16974. params.explain = true;
  16975. }
  16976. for (var _key3 in this._extraOptions) {
  16977. params[_key3] = this._extraOptions[_key3];
  16978. }
  16979. return params;
  16980. }
  16981. /**
  16982. * Return a query with conditions from json, can be useful to send query from server side to client
  16983. * Not static, all query conditions was set before calling this method will be deleted.
  16984. * For example on the server side we have
  16985. * var query = new Parse.Query("className");
  16986. * query.equalTo(key: value);
  16987. * query.limit(100);
  16988. * ... (others queries)
  16989. * Create JSON representation of Query Object
  16990. * var jsonFromServer = query.fromJSON();
  16991. *
  16992. * On client side getting query:
  16993. * var query = new Parse.Query("className");
  16994. * query.fromJSON(jsonFromServer);
  16995. *
  16996. * and continue to query...
  16997. * query.skip(100).find().then(...);
  16998. *
  16999. * @param {QueryJSON} json from Parse.Query.toJSON() method
  17000. * @returns {Parse.Query} Returns the query, so you can chain this call.
  17001. */
  17002. }, {
  17003. key: "withJSON",
  17004. value: function (json
  17005. /*: QueryJSON*/
  17006. )
  17007. /*: ParseQuery*/
  17008. {
  17009. if (json.where) {
  17010. this._where = json.where;
  17011. }
  17012. if (json.include) {
  17013. this._include = json.include.split(',');
  17014. }
  17015. if ((0, _keys2.default)(json)) {
  17016. this._select = (0, _keys2.default)(json).split(',');
  17017. }
  17018. if (json.excludeKeys) {
  17019. this._exclude = json.excludeKeys.split(',');
  17020. }
  17021. if (json.count) {
  17022. this._count = json.count === 1;
  17023. }
  17024. if (json.limit) {
  17025. this._limit = json.limit;
  17026. }
  17027. if (json.skip) {
  17028. this._skip = json.skip;
  17029. }
  17030. if (json.order) {
  17031. this._order = json.order.split(',');
  17032. }
  17033. if (json.readPreference) {
  17034. this._readPreference = json.readPreference;
  17035. }
  17036. if (json.includeReadPreference) {
  17037. this._includeReadPreference = json.includeReadPreference;
  17038. }
  17039. if (json.subqueryReadPreference) {
  17040. this._subqueryReadPreference = json.subqueryReadPreference;
  17041. }
  17042. if (json.hint) {
  17043. this._hint = json.hint;
  17044. }
  17045. if (json.explain) {
  17046. this._explain = !!json.explain;
  17047. }
  17048. for (var _key4 in json) {
  17049. if (json.hasOwnProperty(_key4)) {
  17050. var _context4;
  17051. if ((0, _indexOf.default)(_context4 = ['where', 'include', 'keys', 'count', 'limit', 'skip', 'order', 'readPreference', 'includeReadPreference', 'subqueryReadPreference', 'hint', 'explain']).call(_context4, _key4) === -1) {
  17052. this._extraOptions[_key4] = json[_key4];
  17053. }
  17054. }
  17055. }
  17056. return this;
  17057. }
  17058. /**
  17059. * Static method to restore Parse.Query by json representation
  17060. * Internally calling Parse.Query.withJSON
  17061. *
  17062. * @param {string} className
  17063. * @param {QueryJSON} json from Parse.Query.toJSON() method
  17064. * @returns {Parse.Query} new created query
  17065. */
  17066. }, {
  17067. key: "get",
  17068. value:
  17069. /**
  17070. * Constructs a Parse.Object whose id is already known by fetching data from
  17071. * the server. Unlike the <code>first</code> method, it never returns undefined.
  17072. *
  17073. * @param {string} objectId The id of the object to be fetched.
  17074. * @param {object} options
  17075. * Valid options are:<ul>
  17076. * <li>useMasterKey: In Cloud Code and Node only, causes the Master Key to
  17077. * be used for this request.
  17078. * <li>sessionToken: A valid session token, used for making a request on
  17079. * behalf of a specific user.
  17080. * <li>context: A dictionary that is accessible in Cloud Code `beforeFind` trigger.
  17081. * </ul>
  17082. *
  17083. * @returns {Promise} A promise that is resolved with the result when
  17084. * the query completes.
  17085. */
  17086. function (objectId
  17087. /*: string*/
  17088. , options
  17089. /*:: ?: FullOptions*/
  17090. )
  17091. /*: Promise<ParseObject>*/
  17092. {
  17093. this.equalTo('objectId', objectId);
  17094. var firstOptions = {};
  17095. if (options && options.hasOwnProperty('useMasterKey')) {
  17096. firstOptions.useMasterKey = options.useMasterKey;
  17097. }
  17098. if (options && options.hasOwnProperty('sessionToken')) {
  17099. firstOptions.sessionToken = options.sessionToken;
  17100. }
  17101. if (options && options.hasOwnProperty('context') && (0, _typeof2.default)(options.context) === 'object') {
  17102. firstOptions.context = options.context;
  17103. }
  17104. return this.first(firstOptions).then(function (response) {
  17105. if (response) {
  17106. return response;
  17107. }
  17108. var errorObject = new _ParseError.default(_ParseError.default.OBJECT_NOT_FOUND, 'Object not found.');
  17109. return _promise.default.reject(errorObject);
  17110. });
  17111. }
  17112. /**
  17113. * Retrieves a list of ParseObjects that satisfy this query.
  17114. *
  17115. * @param {object} options Valid options
  17116. * are:<ul>
  17117. * <li>useMasterKey: In Cloud Code and Node only, causes the Master Key to
  17118. * be used for this request.
  17119. * <li>sessionToken: A valid session token, used for making a request on
  17120. * behalf of a specific user.
  17121. * <li>context: A dictionary that is accessible in Cloud Code `beforeFind` trigger.
  17122. * </ul>
  17123. *
  17124. * @returns {Promise} A promise that is resolved with the results when
  17125. * the query completes.
  17126. */
  17127. }, {
  17128. key: "find",
  17129. value: function (options
  17130. /*:: ?: FullOptions*/
  17131. )
  17132. /*: Promise<Array<ParseObject>>*/
  17133. {
  17134. var _this3 = this;
  17135. options = options || {};
  17136. var findOptions = {};
  17137. if (options.hasOwnProperty('useMasterKey')) {
  17138. findOptions.useMasterKey = options.useMasterKey;
  17139. }
  17140. if (options.hasOwnProperty('sessionToken')) {
  17141. findOptions.sessionToken = options.sessionToken;
  17142. }
  17143. if (options.hasOwnProperty('context') && (0, _typeof2.default)(options.context) === 'object') {
  17144. findOptions.context = options.context;
  17145. }
  17146. this._setRequestTask(findOptions);
  17147. var controller = _CoreManager.default.getQueryController();
  17148. var select = this._select;
  17149. if (this._queriesLocalDatastore) {
  17150. return this._handleOfflineQuery(this.toJSON());
  17151. }
  17152. return (0, _find.default)(controller).call(controller, this.className, this.toJSON(), findOptions).then(function (response) {
  17153. var _context5; // Return generic object when explain is used
  17154. if (_this3._explain) {
  17155. return response.results;
  17156. }
  17157. var results = (0, _map2.default)(_context5 = response.results).call(_context5, function (data) {
  17158. // In cases of relations, the server may send back a className
  17159. // on the top level of the payload
  17160. var override = response.className || _this3.className;
  17161. if (!data.className) {
  17162. data.className = override;
  17163. } // Make sure the data object contains keys for all objects that
  17164. // have been requested with a select, so that our cached state
  17165. // updates correctly.
  17166. if (select) {
  17167. handleSelectResult(data, select);
  17168. }
  17169. return _ParseObject.default.fromJSON(data, !select);
  17170. });
  17171. var count = response.count;
  17172. if (typeof count === 'number') {
  17173. return {
  17174. results: results,
  17175. count: count
  17176. };
  17177. }
  17178. return results;
  17179. });
  17180. }
  17181. /**
  17182. * Retrieves a complete list of ParseObjects that satisfy this query.
  17183. * Using `eachBatch` under the hood to fetch all the valid objects.
  17184. *
  17185. * @param {object} options Valid options are:<ul>
  17186. * <li>batchSize: How many objects to yield in each batch (default: 100)
  17187. * <li>useMasterKey: In Cloud Code and Node only, causes the Master Key to
  17188. * be used for this request.
  17189. * <li>sessionToken: A valid session token, used for making a request on
  17190. * behalf of a specific user.
  17191. * </ul>
  17192. * @returns {Promise} A promise that is resolved with the results when
  17193. * the query completes.
  17194. */
  17195. }, {
  17196. key: "findAll",
  17197. value: function () {
  17198. var _findAll = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee2(options
  17199. /*:: ?: BatchOptions*/
  17200. ) {
  17201. var result;
  17202. return _regenerator.default.wrap(function (_context7) {
  17203. while (1) {
  17204. switch (_context7.prev = _context7.next) {
  17205. case 0:
  17206. result
  17207. /*: ParseObject[]*/
  17208. = [];
  17209. _context7.next = 3;
  17210. return this.eachBatch(function (objects
  17211. /*: ParseObject[]*/
  17212. ) {
  17213. var _context6;
  17214. result = (0, _concat.default)(_context6 = []).call(_context6, (0, _toConsumableArray2.default)(result), (0, _toConsumableArray2.default)(objects));
  17215. }, options);
  17216. case 3:
  17217. return _context7.abrupt("return", result);
  17218. case 4:
  17219. case "end":
  17220. return _context7.stop();
  17221. }
  17222. }
  17223. }, _callee2, this);
  17224. }));
  17225. return function () {
  17226. return _findAll.apply(this, arguments);
  17227. };
  17228. }()
  17229. /**
  17230. * Counts the number of objects that match this query.
  17231. *
  17232. * @param {object} options
  17233. * Valid options are:<ul>
  17234. * <li>useMasterKey: In Cloud Code and Node only, causes the Master Key to
  17235. * be used for this request.
  17236. * <li>sessionToken: A valid session token, used for making a request on
  17237. * behalf of a specific user.
  17238. * </ul>
  17239. *
  17240. * @returns {Promise} A promise that is resolved with the count when
  17241. * the query completes.
  17242. */
  17243. }, {
  17244. key: "count",
  17245. value: function (options
  17246. /*:: ?: FullOptions*/
  17247. )
  17248. /*: Promise<number>*/
  17249. {
  17250. options = options || {};
  17251. var findOptions = {};
  17252. if (options.hasOwnProperty('useMasterKey')) {
  17253. findOptions.useMasterKey = options.useMasterKey;
  17254. }
  17255. if (options.hasOwnProperty('sessionToken')) {
  17256. findOptions.sessionToken = options.sessionToken;
  17257. }
  17258. this._setRequestTask(findOptions);
  17259. var controller = _CoreManager.default.getQueryController();
  17260. var params = this.toJSON();
  17261. params.limit = 0;
  17262. params.count = 1;
  17263. return (0, _find.default)(controller).call(controller, this.className, params, findOptions).then(function (result) {
  17264. return result.count;
  17265. });
  17266. }
  17267. /**
  17268. * Executes a distinct query and returns unique values
  17269. *
  17270. * @param {string} key A field to find distinct values
  17271. * @param {object} options
  17272. * Valid options are:<ul>
  17273. * <li>sessionToken: A valid session token, used for making a request on
  17274. * behalf of a specific user.
  17275. * </ul>
  17276. *
  17277. * @returns {Promise} A promise that is resolved with the query completes.
  17278. */
  17279. }, {
  17280. key: "distinct",
  17281. value: function (key
  17282. /*: string*/
  17283. , options
  17284. /*:: ?: FullOptions*/
  17285. )
  17286. /*: Promise<Array<mixed>>*/
  17287. {
  17288. options = options || {};
  17289. var distinctOptions = {};
  17290. distinctOptions.useMasterKey = true;
  17291. if (options.hasOwnProperty('sessionToken')) {
  17292. distinctOptions.sessionToken = options.sessionToken;
  17293. }
  17294. this._setRequestTask(distinctOptions);
  17295. var controller = _CoreManager.default.getQueryController();
  17296. var params = {
  17297. distinct: key,
  17298. where: this._where,
  17299. hint: this._hint
  17300. };
  17301. return controller.aggregate(this.className, params, distinctOptions).then(function (results) {
  17302. return results.results;
  17303. });
  17304. }
  17305. /**
  17306. * Executes an aggregate query and returns aggregate results
  17307. *
  17308. * @param {(Array|object)} pipeline Array or Object of stages to process query
  17309. * @param {object} options Valid options are:<ul>
  17310. * <li>sessionToken: A valid session token, used for making a request on
  17311. * behalf of a specific user.
  17312. * </ul>
  17313. *
  17314. * @returns {Promise} A promise that is resolved with the query completes.
  17315. */
  17316. }, {
  17317. key: "aggregate",
  17318. value: function (pipeline
  17319. /*: mixed*/
  17320. , options
  17321. /*:: ?: FullOptions*/
  17322. )
  17323. /*: Promise<Array<mixed>>*/
  17324. {
  17325. options = options || {};
  17326. var aggregateOptions = {};
  17327. aggregateOptions.useMasterKey = true;
  17328. if (options.hasOwnProperty('sessionToken')) {
  17329. aggregateOptions.sessionToken = options.sessionToken;
  17330. }
  17331. this._setRequestTask(aggregateOptions);
  17332. var controller = _CoreManager.default.getQueryController();
  17333. if (!(0, _isArray.default)(pipeline) && (0, _typeof2.default)(pipeline) !== 'object') {
  17334. throw new Error('Invalid pipeline must be Array or Object');
  17335. }
  17336. if ((0, _keys.default)(this._where || {}).length) {
  17337. if (!(0, _isArray.default)(pipeline)) {
  17338. pipeline = [pipeline];
  17339. }
  17340. pipeline.unshift({
  17341. match: this._where
  17342. });
  17343. }
  17344. var params = {
  17345. pipeline: pipeline,
  17346. hint: this._hint,
  17347. explain: this._explain,
  17348. readPreference: this._readPreference
  17349. };
  17350. return controller.aggregate(this.className, params, aggregateOptions).then(function (results) {
  17351. return results.results;
  17352. });
  17353. }
  17354. /**
  17355. * Retrieves at most one Parse.Object that satisfies this query.
  17356. *
  17357. * Returns the object if there is one, otherwise undefined.
  17358. *
  17359. * @param {object} options Valid options are:<ul>
  17360. * <li>useMasterKey: In Cloud Code and Node only, causes the Master Key to
  17361. * be used for this request.
  17362. * <li>sessionToken: A valid session token, used for making a request on
  17363. * behalf of a specific user.
  17364. * <li>context: A dictionary that is accessible in Cloud Code `beforeFind` trigger.
  17365. * </ul>
  17366. *
  17367. * @returns {Promise} A promise that is resolved with the object when
  17368. * the query completes.
  17369. */
  17370. }, {
  17371. key: "first",
  17372. value: function (options
  17373. /*:: ?: FullOptions*/
  17374. )
  17375. /*: Promise<ParseObject | void>*/
  17376. {
  17377. var _this4 = this;
  17378. options = options || {};
  17379. var findOptions = {};
  17380. if (options.hasOwnProperty('useMasterKey')) {
  17381. findOptions.useMasterKey = options.useMasterKey;
  17382. }
  17383. if (options.hasOwnProperty('sessionToken')) {
  17384. findOptions.sessionToken = options.sessionToken;
  17385. }
  17386. if (options.hasOwnProperty('context') && (0, _typeof2.default)(options.context) === 'object') {
  17387. findOptions.context = options.context;
  17388. }
  17389. this._setRequestTask(findOptions);
  17390. var controller = _CoreManager.default.getQueryController();
  17391. var params = this.toJSON();
  17392. params.limit = 1;
  17393. var select = this._select;
  17394. if (this._queriesLocalDatastore) {
  17395. return this._handleOfflineQuery(params).then(function (objects) {
  17396. if (!objects[0]) {
  17397. return undefined;
  17398. }
  17399. return objects[0];
  17400. });
  17401. }
  17402. return (0, _find.default)(controller).call(controller, this.className, params, findOptions).then(function (response) {
  17403. var objects = response.results;
  17404. if (!objects[0]) {
  17405. return undefined;
  17406. }
  17407. if (!objects[0].className) {
  17408. objects[0].className = _this4.className;
  17409. } // Make sure the data object contains keys for all objects that
  17410. // have been requested with a select, so that our cached state
  17411. // updates correctly.
  17412. if (select) {
  17413. handleSelectResult(objects[0], select);
  17414. }
  17415. return _ParseObject.default.fromJSON(objects[0], !select);
  17416. });
  17417. }
  17418. /**
  17419. * Iterates over objects matching a query, calling a callback for each batch.
  17420. * If the callback returns a promise, the iteration will not continue until
  17421. * that promise has been fulfilled. If the callback returns a rejected
  17422. * promise, then iteration will stop with that error. The items are processed
  17423. * in an unspecified order. The query may not have any sort order, and may
  17424. * not use limit or skip.
  17425. *
  17426. * @param {Function} callback Callback that will be called with each result
  17427. * of the query.
  17428. * @param {object} options Valid options are:<ul>
  17429. * <li>batchSize: How many objects to yield in each batch (default: 100)
  17430. * <li>useMasterKey: In Cloud Code and Node only, causes the Master Key to
  17431. * be used for this request.
  17432. * <li>sessionToken: A valid session token, used for making a request on
  17433. * behalf of a specific user.
  17434. * <li>context: A dictionary that is accessible in Cloud Code `beforeFind` trigger.
  17435. * </ul>
  17436. * @returns {Promise} A promise that will be fulfilled once the
  17437. * iteration has completed.
  17438. */
  17439. }, {
  17440. key: "eachBatch",
  17441. value: function (callback
  17442. /*: (objs: Array<ParseObject>) => Promise<*>*/
  17443. , options
  17444. /*:: ?: BatchOptions*/
  17445. )
  17446. /*: Promise<void>*/
  17447. {
  17448. var _context8;
  17449. options = options || {};
  17450. if (this._order || this._skip || this._limit >= 0) {
  17451. return _promise.default.reject('Cannot iterate on a query with sort, skip, or limit.');
  17452. }
  17453. var query = new ParseQuery(this.className);
  17454. query._limit = options.batchSize || 100;
  17455. query._include = (0, _map2.default)(_context8 = this._include).call(_context8, function (i) {
  17456. return i;
  17457. });
  17458. if (this._select) {
  17459. var _context9;
  17460. query._select = (0, _map2.default)(_context9 = this._select).call(_context9, function (s) {
  17461. return s;
  17462. });
  17463. }
  17464. query._hint = this._hint;
  17465. query._where = {};
  17466. for (var _attr in this._where) {
  17467. var val = this._where[_attr];
  17468. if ((0, _isArray.default)(val)) {
  17469. query._where[_attr] = (0, _map2.default)(val).call(val, function (v) {
  17470. return v;
  17471. });
  17472. } else if (val && (0, _typeof2.default)(val) === 'object') {
  17473. var conditionMap = {};
  17474. query._where[_attr] = conditionMap;
  17475. for (var cond in val) {
  17476. conditionMap[cond] = val[cond];
  17477. }
  17478. } else {
  17479. query._where[_attr] = val;
  17480. }
  17481. }
  17482. query.ascending('objectId');
  17483. var findOptions = {};
  17484. if (options.hasOwnProperty('useMasterKey')) {
  17485. findOptions.useMasterKey = options.useMasterKey;
  17486. }
  17487. if (options.hasOwnProperty('sessionToken')) {
  17488. findOptions.sessionToken = options.sessionToken;
  17489. }
  17490. if (options.hasOwnProperty('context') && (0, _typeof2.default)(options.context) === 'object') {
  17491. findOptions.context = options.context;
  17492. }
  17493. var finished = false;
  17494. var previousResults = [];
  17495. return (0, _promiseUtils.continueWhile)(function () {
  17496. return !finished;
  17497. }, /*#__PURE__*/(0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee3() {
  17498. var _yield$Promise$all, _yield$Promise$all2, results;
  17499. return _regenerator.default.wrap(function (_context10) {
  17500. while (1) {
  17501. switch (_context10.prev = _context10.next) {
  17502. case 0:
  17503. _context10.next = 2;
  17504. return _promise.default.all([(0, _find.default)(query).call(query, findOptions), _promise.default.resolve(previousResults.length > 0 && callback(previousResults))]);
  17505. case 2:
  17506. _yield$Promise$all = _context10.sent;
  17507. _yield$Promise$all2 = (0, _slicedToArray2.default)(_yield$Promise$all, 1);
  17508. results = _yield$Promise$all2[0];
  17509. if (!(results.length >= query._limit)) {
  17510. _context10.next = 10;
  17511. break;
  17512. }
  17513. query.greaterThan('objectId', results[results.length - 1].id);
  17514. previousResults = results;
  17515. _context10.next = 17;
  17516. break;
  17517. case 10:
  17518. if (!(results.length > 0)) {
  17519. _context10.next = 16;
  17520. break;
  17521. }
  17522. _context10.next = 13;
  17523. return _promise.default.resolve(callback(results));
  17524. case 13:
  17525. finished = true;
  17526. _context10.next = 17;
  17527. break;
  17528. case 16:
  17529. finished = true;
  17530. case 17:
  17531. case "end":
  17532. return _context10.stop();
  17533. }
  17534. }
  17535. }, _callee3);
  17536. })));
  17537. }
  17538. /**
  17539. * Iterates over each result of a query, calling a callback for each one. If
  17540. * the callback returns a promise, the iteration will not continue until
  17541. * that promise has been fulfilled. If the callback returns a rejected
  17542. * promise, then iteration will stop with that error. The items are
  17543. * processed in an unspecified order. The query may not have any sort order,
  17544. * and may not use limit or skip.
  17545. *
  17546. * @param {Function} callback Callback that will be called with each result
  17547. * of the query.
  17548. * @param {object} options Valid options are:<ul>
  17549. * <li>useMasterKey: In Cloud Code and Node only, causes the Master Key to
  17550. * be used for this request.
  17551. * <li>sessionToken: A valid session token, used for making a request on
  17552. * behalf of a specific user.
  17553. * </ul>
  17554. * @returns {Promise} A promise that will be fulfilled once the
  17555. * iteration has completed.
  17556. */
  17557. }, {
  17558. key: "each",
  17559. value: function (callback
  17560. /*: (obj: ParseObject) => any*/
  17561. , options
  17562. /*:: ?: BatchOptions*/
  17563. )
  17564. /*: Promise<void>*/
  17565. {
  17566. return this.eachBatch(function (results) {
  17567. var callbacksDone = _promise.default.resolve();
  17568. (0, _forEach.default)(results).call(results, function (result) {
  17569. callbacksDone = callbacksDone.then(function () {
  17570. return callback(result);
  17571. });
  17572. });
  17573. return callbacksDone;
  17574. }, options);
  17575. }
  17576. /**
  17577. * Adds a hint to force index selection. (https://docs.mongodb.com/manual/reference/operator/meta/hint/)
  17578. *
  17579. * @param {(string|object)} value String or Object of index that should be used when executing query
  17580. * @returns {Parse.Query} Returns the query, so you can chain this call.
  17581. */
  17582. }, {
  17583. key: "hint",
  17584. value: function (value
  17585. /*: mixed*/
  17586. )
  17587. /*: ParseQuery*/
  17588. {
  17589. if (typeof value === 'undefined') {
  17590. delete this._hint;
  17591. }
  17592. this._hint = value;
  17593. return this;
  17594. }
  17595. /**
  17596. * Investigates the query execution plan. Useful for optimizing queries. (https://docs.mongodb.com/manual/reference/operator/meta/explain/)
  17597. *
  17598. * @param {boolean} explain Used to toggle the information on the query plan.
  17599. * @returns {Parse.Query} Returns the query, so you can chain this call.
  17600. */
  17601. }, {
  17602. key: "explain",
  17603. value: function ()
  17604. /*: ParseQuery*/
  17605. {
  17606. var _explain
  17607. /*: boolean*/
  17608. = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : true;
  17609. if (typeof _explain !== 'boolean') {
  17610. throw new Error('You can only set explain to a boolean value');
  17611. }
  17612. this._explain = _explain;
  17613. return this;
  17614. }
  17615. /**
  17616. * Iterates over each result of a query, calling a callback for each one. If
  17617. * the callback returns a promise, the iteration will not continue until
  17618. * that promise has been fulfilled. If the callback returns a rejected
  17619. * promise, then iteration will stop with that error. The items are
  17620. * processed in an unspecified order. The query may not have any sort order,
  17621. * and may not use limit or skip.
  17622. *
  17623. * @param {Function} callback Callback <ul>
  17624. * <li>currentObject: The current Parse.Object being processed in the array.</li>
  17625. * <li>index: The index of the current Parse.Object being processed in the array.</li>
  17626. * <li>query: The query map was called upon.</li>
  17627. * </ul>
  17628. *
  17629. * @param {object} options Valid options are:<ul>
  17630. * <li>useMasterKey: In Cloud Code and Node only, causes the Master Key to
  17631. * be used for this request.
  17632. * <li>sessionToken: A valid session token, used for making a request on
  17633. * behalf of a specific user.
  17634. * </ul>
  17635. * @returns {Promise} A promise that will be fulfilled once the
  17636. * iteration has completed.
  17637. */
  17638. }, {
  17639. key: "map",
  17640. value: function () {
  17641. var _map = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee4(callback
  17642. /*: (currentObject: ParseObject, index: number, query: ParseQuery) => any*/
  17643. , options
  17644. /*:: ?: BatchOptions*/
  17645. ) {
  17646. var _this5 = this;
  17647. var array, index;
  17648. return _regenerator.default.wrap(function (_context11) {
  17649. while (1) {
  17650. switch (_context11.prev = _context11.next) {
  17651. case 0:
  17652. array = [];
  17653. index = 0;
  17654. _context11.next = 4;
  17655. return this.each(function (object) {
  17656. return _promise.default.resolve(callback(object, index, _this5)).then(function (result) {
  17657. array.push(result);
  17658. index += 1;
  17659. });
  17660. }, options);
  17661. case 4:
  17662. return _context11.abrupt("return", array);
  17663. case 5:
  17664. case "end":
  17665. return _context11.stop();
  17666. }
  17667. }
  17668. }, _callee4, this);
  17669. }));
  17670. return function () {
  17671. return _map.apply(this, arguments);
  17672. };
  17673. }()
  17674. /**
  17675. * Iterates over each result of a query, calling a callback for each one. If
  17676. * the callback returns a promise, the iteration will not continue until
  17677. * that promise has been fulfilled. If the callback returns a rejected
  17678. * promise, then iteration will stop with that error. The items are
  17679. * processed in an unspecified order. The query may not have any sort order,
  17680. * and may not use limit or skip.
  17681. *
  17682. * @param {Function} callback Callback <ul>
  17683. * <li>accumulator: The accumulator accumulates the callback's return values. It is the accumulated value previously returned in the last invocation of the callback.</li>
  17684. * <li>currentObject: The current Parse.Object being processed in the array.</li>
  17685. * <li>index: The index of the current Parse.Object being processed in the array.</li>
  17686. * </ul>
  17687. * @param {*} initialValue A value to use as the first argument to the first call of the callback. If no initialValue is supplied, the first object in the query will be used and skipped.
  17688. * @param {object} options Valid options are:<ul>
  17689. * <li>useMasterKey: In Cloud Code and Node only, causes the Master Key to
  17690. * be used for this request.
  17691. * <li>sessionToken: A valid session token, used for making a request on
  17692. * behalf of a specific user.
  17693. * </ul>
  17694. * @returns {Promise} A promise that will be fulfilled once the
  17695. * iteration has completed.
  17696. */
  17697. }, {
  17698. key: "reduce",
  17699. value: function () {
  17700. var _reduce = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee5(callback
  17701. /*: (accumulator: any, currentObject: ParseObject, index: number) => any*/
  17702. , initialValue
  17703. /*: any*/
  17704. , options
  17705. /*:: ?: BatchOptions*/
  17706. ) {
  17707. var accumulator, index;
  17708. return _regenerator.default.wrap(function (_context12) {
  17709. while (1) {
  17710. switch (_context12.prev = _context12.next) {
  17711. case 0:
  17712. accumulator = initialValue;
  17713. index = 0;
  17714. _context12.next = 4;
  17715. return this.each(function (object) {
  17716. // If no initial value was given, we take the first object from the query
  17717. // as the initial value and don't call the callback with it.
  17718. if (index === 0 && initialValue === undefined) {
  17719. accumulator = object;
  17720. index += 1;
  17721. return;
  17722. }
  17723. return _promise.default.resolve(callback(accumulator, object, index)).then(function (result) {
  17724. accumulator = result;
  17725. index += 1;
  17726. });
  17727. }, options);
  17728. case 4:
  17729. if (!(index === 0 && initialValue === undefined)) {
  17730. _context12.next = 6;
  17731. break;
  17732. }
  17733. throw new TypeError('Reducing empty query result set with no initial value');
  17734. case 6:
  17735. return _context12.abrupt("return", accumulator);
  17736. case 7:
  17737. case "end":
  17738. return _context12.stop();
  17739. }
  17740. }
  17741. }, _callee5, this);
  17742. }));
  17743. return function () {
  17744. return _reduce.apply(this, arguments);
  17745. };
  17746. }()
  17747. /**
  17748. * Iterates over each result of a query, calling a callback for each one. If
  17749. * the callback returns a promise, the iteration will not continue until
  17750. * that promise has been fulfilled. If the callback returns a rejected
  17751. * promise, then iteration will stop with that error. The items are
  17752. * processed in an unspecified order. The query may not have any sort order,
  17753. * and may not use limit or skip.
  17754. *
  17755. * @param {Function} callback Callback <ul>
  17756. * <li>currentObject: The current Parse.Object being processed in the array.</li>
  17757. * <li>index: The index of the current Parse.Object being processed in the array.</li>
  17758. * <li>query: The query filter was called upon.</li>
  17759. * </ul>
  17760. *
  17761. * @param {object} options Valid options are:<ul>
  17762. * <li>useMasterKey: In Cloud Code and Node only, causes the Master Key to
  17763. * be used for this request.
  17764. * <li>sessionToken: A valid session token, used for making a request on
  17765. * behalf of a specific user.
  17766. * </ul>
  17767. * @returns {Promise} A promise that will be fulfilled once the
  17768. * iteration has completed.
  17769. */
  17770. }, {
  17771. key: "filter",
  17772. value: function () {
  17773. var _filter = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee6(callback
  17774. /*: (currentObject: ParseObject, index: number, query: ParseQuery) => boolean*/
  17775. , options
  17776. /*:: ?: BatchOptions*/
  17777. ) {
  17778. var _this6 = this;
  17779. var array, index;
  17780. return _regenerator.default.wrap(function (_context13) {
  17781. while (1) {
  17782. switch (_context13.prev = _context13.next) {
  17783. case 0:
  17784. array = [];
  17785. index = 0;
  17786. _context13.next = 4;
  17787. return this.each(function (object) {
  17788. return _promise.default.resolve(callback(object, index, _this6)).then(function (flag) {
  17789. if (flag) {
  17790. array.push(object);
  17791. }
  17792. index += 1;
  17793. });
  17794. }, options);
  17795. case 4:
  17796. return _context13.abrupt("return", array);
  17797. case 5:
  17798. case "end":
  17799. return _context13.stop();
  17800. }
  17801. }
  17802. }, _callee6, this);
  17803. }));
  17804. return function () {
  17805. return _filter.apply(this, arguments);
  17806. };
  17807. }()
  17808. /** Query Conditions * */
  17809. /**
  17810. * Adds a constraint to the query that requires a particular key's value to
  17811. * be equal to the provided value.
  17812. *
  17813. * @param {string} key The key to check.
  17814. * @param value The value that the Parse.Object must contain.
  17815. * @returns {Parse.Query} Returns the query, so you can chain this call.
  17816. */
  17817. }, {
  17818. key: "equalTo",
  17819. value: function (key
  17820. /*: string | { [key: string]: any }*/
  17821. , value
  17822. /*: ?mixed*/
  17823. )
  17824. /*: ParseQuery*/
  17825. {
  17826. var _this7 = this;
  17827. if (key && (0, _typeof2.default)(key) === 'object') {
  17828. var _context14;
  17829. (0, _forEach.default)(_context14 = (0, _entries.default)(key)).call(_context14, function (_ref2) {
  17830. var _ref3 = (0, _slicedToArray2.default)(_ref2, 2),
  17831. k = _ref3[0],
  17832. val = _ref3[1];
  17833. return _this7.equalTo(k, val);
  17834. });
  17835. return this;
  17836. }
  17837. if (typeof value === 'undefined') {
  17838. return this.doesNotExist(key);
  17839. }
  17840. this._where[key] = (0, _encode.default)(value, false, true);
  17841. return this;
  17842. }
  17843. /**
  17844. * Adds a constraint to the query that requires a particular key's value to
  17845. * be not equal to the provided value.
  17846. *
  17847. * @param {string} key The key to check.
  17848. * @param value The value that must not be equalled.
  17849. * @returns {Parse.Query} Returns the query, so you can chain this call.
  17850. */
  17851. }, {
  17852. key: "notEqualTo",
  17853. value: function (key
  17854. /*: string | { [key: string]: any }*/
  17855. , value
  17856. /*: ?mixed*/
  17857. )
  17858. /*: ParseQuery*/
  17859. {
  17860. var _this8 = this;
  17861. if (key && (0, _typeof2.default)(key) === 'object') {
  17862. var _context15;
  17863. (0, _forEach.default)(_context15 = (0, _entries.default)(key)).call(_context15, function (_ref4) {
  17864. var _ref5 = (0, _slicedToArray2.default)(_ref4, 2),
  17865. k = _ref5[0],
  17866. val = _ref5[1];
  17867. return _this8.notEqualTo(k, val);
  17868. });
  17869. return this;
  17870. }
  17871. return this._addCondition(key, '$ne', value);
  17872. }
  17873. /**
  17874. * Adds a constraint to the query that requires a particular key's value to
  17875. * be less than the provided value.
  17876. *
  17877. * @param {string} key The key to check.
  17878. * @param value The value that provides an upper bound.
  17879. * @returns {Parse.Query} Returns the query, so you can chain this call.
  17880. */
  17881. }, {
  17882. key: "lessThan",
  17883. value: function (key
  17884. /*: string*/
  17885. , value
  17886. /*: mixed*/
  17887. )
  17888. /*: ParseQuery*/
  17889. {
  17890. return this._addCondition(key, '$lt', value);
  17891. }
  17892. /**
  17893. * Adds a constraint to the query that requires a particular key's value to
  17894. * be greater than the provided value.
  17895. *
  17896. * @param {string} key The key to check.
  17897. * @param value The value that provides an lower bound.
  17898. * @returns {Parse.Query} Returns the query, so you can chain this call.
  17899. */
  17900. }, {
  17901. key: "greaterThan",
  17902. value: function (key
  17903. /*: string*/
  17904. , value
  17905. /*: mixed*/
  17906. )
  17907. /*: ParseQuery*/
  17908. {
  17909. return this._addCondition(key, '$gt', value);
  17910. }
  17911. /**
  17912. * Adds a constraint to the query that requires a particular key's value to
  17913. * be less than or equal to the provided value.
  17914. *
  17915. * @param {string} key The key to check.
  17916. * @param value The value that provides an upper bound.
  17917. * @returns {Parse.Query} Returns the query, so you can chain this call.
  17918. */
  17919. }, {
  17920. key: "lessThanOrEqualTo",
  17921. value: function (key
  17922. /*: string*/
  17923. , value
  17924. /*: mixed*/
  17925. )
  17926. /*: ParseQuery*/
  17927. {
  17928. return this._addCondition(key, '$lte', value);
  17929. }
  17930. /**
  17931. * Adds a constraint to the query that requires a particular key's value to
  17932. * be greater than or equal to the provided value.
  17933. *
  17934. * @param {string} key The key to check.
  17935. * @param {*} value The value that provides an lower bound.
  17936. * @returns {Parse.Query} Returns the query, so you can chain this call.
  17937. */
  17938. }, {
  17939. key: "greaterThanOrEqualTo",
  17940. value: function (key
  17941. /*: string*/
  17942. , value
  17943. /*: mixed*/
  17944. )
  17945. /*: ParseQuery*/
  17946. {
  17947. return this._addCondition(key, '$gte', value);
  17948. }
  17949. /**
  17950. * Adds a constraint to the query that requires a particular key's value to
  17951. * be contained in the provided list of values.
  17952. *
  17953. * @param {string} key The key to check.
  17954. * @param {*} value The values that will match.
  17955. * @returns {Parse.Query} Returns the query, so you can chain this call.
  17956. */
  17957. }, {
  17958. key: "containedIn",
  17959. value: function (key
  17960. /*: string*/
  17961. , value
  17962. /*: mixed*/
  17963. )
  17964. /*: ParseQuery*/
  17965. {
  17966. return this._addCondition(key, '$in', value);
  17967. }
  17968. /**
  17969. * Adds a constraint to the query that requires a particular key's value to
  17970. * not be contained in the provided list of values.
  17971. *
  17972. * @param {string} key The key to check.
  17973. * @param {*} value The values that will not match.
  17974. * @returns {Parse.Query} Returns the query, so you can chain this call.
  17975. */
  17976. }, {
  17977. key: "notContainedIn",
  17978. value: function (key
  17979. /*: string*/
  17980. , value
  17981. /*: mixed*/
  17982. )
  17983. /*: ParseQuery*/
  17984. {
  17985. return this._addCondition(key, '$nin', value);
  17986. }
  17987. /**
  17988. * Adds a constraint to the query that requires a particular key's value to
  17989. * be contained by the provided list of values. Get objects where all array elements match.
  17990. *
  17991. * @param {string} key The key to check.
  17992. * @param {Array} values The values that will match.
  17993. * @returns {Parse.Query} Returns the query, so you can chain this call.
  17994. */
  17995. }, {
  17996. key: "containedBy",
  17997. value: function (key
  17998. /*: string*/
  17999. , values
  18000. /*: Array<mixed>*/
  18001. )
  18002. /*: ParseQuery*/
  18003. {
  18004. return this._addCondition(key, '$containedBy', values);
  18005. }
  18006. /**
  18007. * Adds a constraint to the query that requires a particular key's value to
  18008. * contain each one of the provided list of values.
  18009. *
  18010. * @param {string} key The key to check. This key's value must be an array.
  18011. * @param {Array} values The values that will match.
  18012. * @returns {Parse.Query} Returns the query, so you can chain this call.
  18013. */
  18014. }, {
  18015. key: "containsAll",
  18016. value: function (key
  18017. /*: string*/
  18018. , values
  18019. /*: Array<mixed>*/
  18020. )
  18021. /*: ParseQuery*/
  18022. {
  18023. return this._addCondition(key, '$all', values);
  18024. }
  18025. /**
  18026. * Adds a constraint to the query that requires a particular key's value to
  18027. * contain each one of the provided list of values starting with given strings.
  18028. *
  18029. * @param {string} key The key to check. This key's value must be an array.
  18030. * @param {Array<string>} values The string values that will match as starting string.
  18031. * @returns {Parse.Query} Returns the query, so you can chain this call.
  18032. */
  18033. }, {
  18034. key: "containsAllStartingWith",
  18035. value: function (key
  18036. /*: string*/
  18037. , values
  18038. /*: Array<string>*/
  18039. )
  18040. /*: ParseQuery*/
  18041. {
  18042. var _this = this;
  18043. if (!(0, _isArray.default)(values)) {
  18044. values = [values];
  18045. }
  18046. var regexObject = (0, _map2.default)(values).call(values, function (value) {
  18047. return {
  18048. $regex: _this._regexStartWith(value)
  18049. };
  18050. });
  18051. return this.containsAll(key, regexObject);
  18052. }
  18053. /**
  18054. * Adds a constraint for finding objects that contain the given key.
  18055. *
  18056. * @param {string} key The key that should exist.
  18057. * @returns {Parse.Query} Returns the query, so you can chain this call.
  18058. */
  18059. }, {
  18060. key: "exists",
  18061. value: function (key
  18062. /*: string*/
  18063. )
  18064. /*: ParseQuery*/
  18065. {
  18066. return this._addCondition(key, '$exists', true);
  18067. }
  18068. /**
  18069. * Adds a constraint for finding objects that do not contain a given key.
  18070. *
  18071. * @param {string} key The key that should not exist
  18072. * @returns {Parse.Query} Returns the query, so you can chain this call.
  18073. */
  18074. }, {
  18075. key: "doesNotExist",
  18076. value: function (key
  18077. /*: string*/
  18078. )
  18079. /*: ParseQuery*/
  18080. {
  18081. return this._addCondition(key, '$exists', false);
  18082. }
  18083. /**
  18084. * Adds a regular expression constraint for finding string values that match
  18085. * the provided regular expression.
  18086. * This may be slow for large datasets.
  18087. *
  18088. * @param {string} key The key that the string to match is stored in.
  18089. * @param {RegExp} regex The regular expression pattern to match.
  18090. * @param {string} modifiers The regular expression mode.
  18091. * @returns {Parse.Query} Returns the query, so you can chain this call.
  18092. */
  18093. }, {
  18094. key: "matches",
  18095. value: function (key
  18096. /*: string*/
  18097. , regex
  18098. /*: RegExp*/
  18099. , modifiers
  18100. /*: string*/
  18101. )
  18102. /*: ParseQuery*/
  18103. {
  18104. this._addCondition(key, '$regex', regex);
  18105. if (!modifiers) {
  18106. modifiers = '';
  18107. }
  18108. if (regex.ignoreCase) {
  18109. modifiers += 'i';
  18110. }
  18111. if (regex.multiline) {
  18112. modifiers += 'm';
  18113. }
  18114. if (modifiers.length) {
  18115. this._addCondition(key, '$options', modifiers);
  18116. }
  18117. return this;
  18118. }
  18119. /**
  18120. * Adds a constraint that requires that a key's value matches a Parse.Query
  18121. * constraint.
  18122. *
  18123. * @param {string} key The key that the contains the object to match the
  18124. * query.
  18125. * @param {Parse.Query} query The query that should match.
  18126. * @returns {Parse.Query} Returns the query, so you can chain this call.
  18127. */
  18128. }, {
  18129. key: "matchesQuery",
  18130. value: function (key
  18131. /*: string*/
  18132. , query
  18133. /*: ParseQuery*/
  18134. )
  18135. /*: ParseQuery*/
  18136. {
  18137. var queryJSON = query.toJSON();
  18138. queryJSON.className = query.className;
  18139. return this._addCondition(key, '$inQuery', queryJSON);
  18140. }
  18141. /**
  18142. * Adds a constraint that requires that a key's value not matches a
  18143. * Parse.Query constraint.
  18144. *
  18145. * @param {string} key The key that the contains the object to match the
  18146. * query.
  18147. * @param {Parse.Query} query The query that should not match.
  18148. * @returns {Parse.Query} Returns the query, so you can chain this call.
  18149. */
  18150. }, {
  18151. key: "doesNotMatchQuery",
  18152. value: function (key
  18153. /*: string*/
  18154. , query
  18155. /*: ParseQuery*/
  18156. )
  18157. /*: ParseQuery*/
  18158. {
  18159. var queryJSON = query.toJSON();
  18160. queryJSON.className = query.className;
  18161. return this._addCondition(key, '$notInQuery', queryJSON);
  18162. }
  18163. /**
  18164. * Adds a constraint that requires that a key's value matches a value in
  18165. * an object returned by a different Parse.Query.
  18166. *
  18167. * @param {string} key The key that contains the value that is being
  18168. * matched.
  18169. * @param {string} queryKey The key in the objects returned by the query to
  18170. * match against.
  18171. * @param {Parse.Query} query The query to run.
  18172. * @returns {Parse.Query} Returns the query, so you can chain this call.
  18173. */
  18174. }, {
  18175. key: "matchesKeyInQuery",
  18176. value: function (key
  18177. /*: string*/
  18178. , queryKey
  18179. /*: string*/
  18180. , query
  18181. /*: ParseQuery*/
  18182. )
  18183. /*: ParseQuery*/
  18184. {
  18185. var queryJSON = query.toJSON();
  18186. queryJSON.className = query.className;
  18187. return this._addCondition(key, '$select', {
  18188. key: queryKey,
  18189. query: queryJSON
  18190. });
  18191. }
  18192. /**
  18193. * Adds a constraint that requires that a key's value not match a value in
  18194. * an object returned by a different Parse.Query.
  18195. *
  18196. * @param {string} key The key that contains the value that is being
  18197. * excluded.
  18198. * @param {string} queryKey The key in the objects returned by the query to
  18199. * match against.
  18200. * @param {Parse.Query} query The query to run.
  18201. * @returns {Parse.Query} Returns the query, so you can chain this call.
  18202. */
  18203. }, {
  18204. key: "doesNotMatchKeyInQuery",
  18205. value: function (key
  18206. /*: string*/
  18207. , queryKey
  18208. /*: string*/
  18209. , query
  18210. /*: ParseQuery*/
  18211. )
  18212. /*: ParseQuery*/
  18213. {
  18214. var queryJSON = query.toJSON();
  18215. queryJSON.className = query.className;
  18216. return this._addCondition(key, '$dontSelect', {
  18217. key: queryKey,
  18218. query: queryJSON
  18219. });
  18220. }
  18221. /**
  18222. * Adds a constraint for finding string values that contain a provided
  18223. * string. This may be slow for large datasets.
  18224. *
  18225. * @param {string} key The key that the string to match is stored in.
  18226. * @param {string} substring The substring that the value must contain.
  18227. * @returns {Parse.Query} Returns the query, so you can chain this call.
  18228. */
  18229. }, {
  18230. key: "contains",
  18231. value: function (key
  18232. /*: string*/
  18233. , substring
  18234. /*: string*/
  18235. )
  18236. /*: ParseQuery*/
  18237. {
  18238. if (typeof substring !== 'string') {
  18239. throw new Error('The value being searched for must be a string.');
  18240. }
  18241. return this._addCondition(key, '$regex', quote(substring));
  18242. }
  18243. /**
  18244. * Adds a constraint for finding string values that contain a provided
  18245. * string. This may be slow for large datasets. Requires Parse-Server > 2.5.0
  18246. *
  18247. * In order to sort you must use select and ascending ($score is required)
  18248. * <pre>
  18249. * query.fullText('field', 'term');
  18250. * query.ascending('$score');
  18251. * query.select('$score');
  18252. * </pre>
  18253. *
  18254. * To retrieve the weight / rank
  18255. * <pre>
  18256. * object->get('score');
  18257. * </pre>
  18258. *
  18259. * You can define optionals by providing an object as a third parameter
  18260. * <pre>
  18261. * query.fullText('field', 'term', { language: 'es', diacriticSensitive: true });
  18262. * </pre>
  18263. *
  18264. * @param {string} key The key that the string to match is stored in.
  18265. * @param {string} value The string to search
  18266. * @param {object} options (Optional)
  18267. * @param {string} options.language The language that determines the list of stop words for the search and the rules for the stemmer and tokenizer.
  18268. * @param {boolean} options.caseSensitive A boolean flag to enable or disable case sensitive search.
  18269. * @param {boolean} options.diacriticSensitive A boolean flag to enable or disable diacritic sensitive search.
  18270. * @returns {Parse.Query} Returns the query, so you can chain this call.
  18271. */
  18272. }, {
  18273. key: "fullText",
  18274. value: function (key
  18275. /*: string*/
  18276. , value
  18277. /*: string*/
  18278. , options
  18279. /*: ?Object*/
  18280. )
  18281. /*: ParseQuery*/
  18282. {
  18283. options = options || {};
  18284. if (!key) {
  18285. throw new Error('A key is required.');
  18286. }
  18287. if (!value) {
  18288. throw new Error('A search term is required');
  18289. }
  18290. if (typeof value !== 'string') {
  18291. throw new Error('The value being searched for must be a string.');
  18292. }
  18293. var fullOptions = {};
  18294. fullOptions.$term = value;
  18295. for (var option in options) {
  18296. switch (option) {
  18297. case 'language':
  18298. fullOptions.$language = options[option];
  18299. break;
  18300. case 'caseSensitive':
  18301. fullOptions.$caseSensitive = options[option];
  18302. break;
  18303. case 'diacriticSensitive':
  18304. fullOptions.$diacriticSensitive = options[option];
  18305. break;
  18306. default:
  18307. throw new Error("Unknown option: ".concat(option));
  18308. }
  18309. }
  18310. return this._addCondition(key, '$text', {
  18311. $search: fullOptions
  18312. });
  18313. }
  18314. /**
  18315. * Method to sort the full text search by text score
  18316. *
  18317. * @returns {Parse.Query} Returns the query, so you can chain this call.
  18318. */
  18319. }, {
  18320. key: "sortByTextScore",
  18321. value: function () {
  18322. this.ascending('$score');
  18323. this.select(['$score']);
  18324. return this;
  18325. }
  18326. /**
  18327. * Adds a constraint for finding string values that start with a provided
  18328. * string. This query will use the backend index, so it will be fast even
  18329. * for large datasets.
  18330. *
  18331. * @param {string} key The key that the string to match is stored in.
  18332. * @param {string} prefix The substring that the value must start with.
  18333. * @returns {Parse.Query} Returns the query, so you can chain this call.
  18334. */
  18335. }, {
  18336. key: "startsWith",
  18337. value: function (key
  18338. /*: string*/
  18339. , prefix
  18340. /*: string*/
  18341. )
  18342. /*: ParseQuery*/
  18343. {
  18344. if (typeof prefix !== 'string') {
  18345. throw new Error('The value being searched for must be a string.');
  18346. }
  18347. return this._addCondition(key, '$regex', this._regexStartWith(prefix));
  18348. }
  18349. /**
  18350. * Adds a constraint for finding string values that end with a provided
  18351. * string. This will be slow for large datasets.
  18352. *
  18353. * @param {string} key The key that the string to match is stored in.
  18354. * @param {string} suffix The substring that the value must end with.
  18355. * @returns {Parse.Query} Returns the query, so you can chain this call.
  18356. */
  18357. }, {
  18358. key: "endsWith",
  18359. value: function (key
  18360. /*: string*/
  18361. , suffix
  18362. /*: string*/
  18363. )
  18364. /*: ParseQuery*/
  18365. {
  18366. if (typeof suffix !== 'string') {
  18367. throw new Error('The value being searched for must be a string.');
  18368. }
  18369. return this._addCondition(key, '$regex', "".concat(quote(suffix), "$"));
  18370. }
  18371. /**
  18372. * Adds a proximity based constraint for finding objects with key point
  18373. * values near the point given.
  18374. *
  18375. * @param {string} key The key that the Parse.GeoPoint is stored in.
  18376. * @param {Parse.GeoPoint} point The reference Parse.GeoPoint that is used.
  18377. * @returns {Parse.Query} Returns the query, so you can chain this call.
  18378. */
  18379. }, {
  18380. key: "near",
  18381. value: function (key
  18382. /*: string*/
  18383. , point
  18384. /*: ParseGeoPoint*/
  18385. )
  18386. /*: ParseQuery*/
  18387. {
  18388. if (!(point instanceof _ParseGeoPoint.default)) {
  18389. // Try to cast it as a GeoPoint
  18390. point = new _ParseGeoPoint.default(point);
  18391. }
  18392. return this._addCondition(key, '$nearSphere', point);
  18393. }
  18394. /**
  18395. * Adds a proximity based constraint for finding objects with key point
  18396. * values near the point given and within the maximum distance given.
  18397. *
  18398. * @param {string} key The key that the Parse.GeoPoint is stored in.
  18399. * @param {Parse.GeoPoint} point The reference Parse.GeoPoint that is used.
  18400. * @param {number} maxDistance Maximum distance (in radians) of results to return.
  18401. * @param {boolean} sorted A Bool value that is true if results should be
  18402. * sorted by distance ascending, false is no sorting is required,
  18403. * defaults to true.
  18404. * @returns {Parse.Query} Returns the query, so you can chain this call.
  18405. */
  18406. }, {
  18407. key: "withinRadians",
  18408. value: function (key
  18409. /*: string*/
  18410. , point
  18411. /*: ParseGeoPoint*/
  18412. , maxDistance
  18413. /*: number*/
  18414. , sorted
  18415. /*: boolean*/
  18416. )
  18417. /*: ParseQuery*/
  18418. {
  18419. if (sorted || sorted === undefined) {
  18420. this.near(key, point);
  18421. return this._addCondition(key, '$maxDistance', maxDistance);
  18422. }
  18423. return this._addCondition(key, '$geoWithin', {
  18424. $centerSphere: [[point.longitude, point.latitude], maxDistance]
  18425. });
  18426. }
  18427. /**
  18428. * Adds a proximity based constraint for finding objects with key point
  18429. * values near the point given and within the maximum distance given.
  18430. * Radius of earth used is 3958.8 miles.
  18431. *
  18432. * @param {string} key The key that the Parse.GeoPoint is stored in.
  18433. * @param {Parse.GeoPoint} point The reference Parse.GeoPoint that is used.
  18434. * @param {number} maxDistance Maximum distance (in miles) of results to return.
  18435. * @param {boolean} sorted A Bool value that is true if results should be
  18436. * sorted by distance ascending, false is no sorting is required,
  18437. * defaults to true.
  18438. * @returns {Parse.Query} Returns the query, so you can chain this call.
  18439. */
  18440. }, {
  18441. key: "withinMiles",
  18442. value: function (key
  18443. /*: string*/
  18444. , point
  18445. /*: ParseGeoPoint*/
  18446. , maxDistance
  18447. /*: number*/
  18448. , sorted
  18449. /*: boolean*/
  18450. )
  18451. /*: ParseQuery*/
  18452. {
  18453. return this.withinRadians(key, point, maxDistance / 3958.8, sorted);
  18454. }
  18455. /**
  18456. * Adds a proximity based constraint for finding objects with key point
  18457. * values near the point given and within the maximum distance given.
  18458. * Radius of earth used is 6371.0 kilometers.
  18459. *
  18460. * @param {string} key The key that the Parse.GeoPoint is stored in.
  18461. * @param {Parse.GeoPoint} point The reference Parse.GeoPoint that is used.
  18462. * @param {number} maxDistance Maximum distance (in kilometers) of results to return.
  18463. * @param {boolean} sorted A Bool value that is true if results should be
  18464. * sorted by distance ascending, false is no sorting is required,
  18465. * defaults to true.
  18466. * @returns {Parse.Query} Returns the query, so you can chain this call.
  18467. */
  18468. }, {
  18469. key: "withinKilometers",
  18470. value: function (key
  18471. /*: string*/
  18472. , point
  18473. /*: ParseGeoPoint*/
  18474. , maxDistance
  18475. /*: number*/
  18476. , sorted
  18477. /*: boolean*/
  18478. )
  18479. /*: ParseQuery*/
  18480. {
  18481. return this.withinRadians(key, point, maxDistance / 6371.0, sorted);
  18482. }
  18483. /**
  18484. * Adds a constraint to the query that requires a particular key's
  18485. * coordinates be contained within a given rectangular geographic bounding
  18486. * box.
  18487. *
  18488. * @param {string} key The key to be constrained.
  18489. * @param {Parse.GeoPoint} southwest
  18490. * The lower-left inclusive corner of the box.
  18491. * @param {Parse.GeoPoint} northeast
  18492. * The upper-right inclusive corner of the box.
  18493. * @returns {Parse.Query} Returns the query, so you can chain this call.
  18494. */
  18495. }, {
  18496. key: "withinGeoBox",
  18497. value: function (key
  18498. /*: string*/
  18499. , southwest
  18500. /*: ParseGeoPoint*/
  18501. , northeast
  18502. /*: ParseGeoPoint*/
  18503. )
  18504. /*: ParseQuery*/
  18505. {
  18506. if (!(southwest instanceof _ParseGeoPoint.default)) {
  18507. southwest = new _ParseGeoPoint.default(southwest);
  18508. }
  18509. if (!(northeast instanceof _ParseGeoPoint.default)) {
  18510. northeast = new _ParseGeoPoint.default(northeast);
  18511. }
  18512. this._addCondition(key, '$within', {
  18513. $box: [southwest, northeast]
  18514. });
  18515. return this;
  18516. }
  18517. /**
  18518. * Adds a constraint to the query that requires a particular key's
  18519. * coordinates be contained within and on the bounds of a given polygon.
  18520. * Supports closed and open (last point is connected to first) paths
  18521. *
  18522. * Polygon must have at least 3 points
  18523. *
  18524. * @param {string} key The key to be constrained.
  18525. * @param {Array} points Array of Coordinates / GeoPoints
  18526. * @returns {Parse.Query} Returns the query, so you can chain this call.
  18527. */
  18528. }, {
  18529. key: "withinPolygon",
  18530. value: function (key
  18531. /*: string*/
  18532. , points
  18533. /*: Array<Array<number>>*/
  18534. )
  18535. /*: ParseQuery*/
  18536. {
  18537. return this._addCondition(key, '$geoWithin', {
  18538. $polygon: points
  18539. });
  18540. }
  18541. /**
  18542. * Add a constraint to the query that requires a particular key's
  18543. * coordinates that contains a ParseGeoPoint
  18544. *
  18545. * @param {string} key The key to be constrained.
  18546. * @param {Parse.GeoPoint} point
  18547. * @returns {Parse.Query} Returns the query, so you can chain this call.
  18548. */
  18549. }, {
  18550. key: "polygonContains",
  18551. value: function (key
  18552. /*: string*/
  18553. , point
  18554. /*: ParseGeoPoint*/
  18555. )
  18556. /*: ParseQuery*/
  18557. {
  18558. return this._addCondition(key, '$geoIntersects', {
  18559. $point: point
  18560. });
  18561. }
  18562. /** Query Orderings * */
  18563. /**
  18564. * Sorts the results in ascending order by the given key.
  18565. *
  18566. * @param {(string|string[])} keys The key to order by, which is a
  18567. * string of comma separated values, or an Array of keys, or multiple keys.
  18568. * @returns {Parse.Query} Returns the query, so you can chain this call.
  18569. */
  18570. }, {
  18571. key: "ascending",
  18572. value: function ()
  18573. /*: ParseQuery*/
  18574. {
  18575. this._order = [];
  18576. for (var _len = arguments.length, keys = new Array(_len), _key5 = 0; _key5 < _len; _key5++) {
  18577. keys[_key5] = arguments[_key5];
  18578. }
  18579. return this.addAscending.apply(this, keys);
  18580. }
  18581. /**
  18582. * Sorts the results in ascending order by the given key,
  18583. * but can also add secondary sort descriptors without overwriting _order.
  18584. *
  18585. * @param {(string|string[])} keys The key to order by, which is a
  18586. * string of comma separated values, or an Array of keys, or multiple keys.
  18587. * @returns {Parse.Query} Returns the query, so you can chain this call.
  18588. */
  18589. }, {
  18590. key: "addAscending",
  18591. value: function ()
  18592. /*: ParseQuery*/
  18593. {
  18594. var _this9 = this;
  18595. if (!this._order) {
  18596. this._order = [];
  18597. }
  18598. for (var _len2 = arguments.length, keys = new Array(_len2), _key6 = 0; _key6 < _len2; _key6++) {
  18599. keys[_key6] = arguments[_key6];
  18600. }
  18601. (0, _forEach.default)(keys).call(keys, function (key) {
  18602. var _context16;
  18603. if ((0, _isArray.default)(key)) {
  18604. key = key.join();
  18605. }
  18606. _this9._order = (0, _concat.default)(_context16 = _this9._order).call(_context16, key.replace(/\s/g, '').split(','));
  18607. });
  18608. return this;
  18609. }
  18610. /**
  18611. * Sorts the results in descending order by the given key.
  18612. *
  18613. * @param {(string|string[])} keys The key to order by, which is a
  18614. * string of comma separated values, or an Array of keys, or multiple keys.
  18615. * @returns {Parse.Query} Returns the query, so you can chain this call.
  18616. */
  18617. }, {
  18618. key: "descending",
  18619. value: function ()
  18620. /*: ParseQuery*/
  18621. {
  18622. this._order = [];
  18623. for (var _len3 = arguments.length, keys = new Array(_len3), _key7 = 0; _key7 < _len3; _key7++) {
  18624. keys[_key7] = arguments[_key7];
  18625. }
  18626. return this.addDescending.apply(this, keys);
  18627. }
  18628. /**
  18629. * Sorts the results in descending order by the given key,
  18630. * but can also add secondary sort descriptors without overwriting _order.
  18631. *
  18632. * @param {(string|string[])} keys The key to order by, which is a
  18633. * string of comma separated values, or an Array of keys, or multiple keys.
  18634. * @returns {Parse.Query} Returns the query, so you can chain this call.
  18635. */
  18636. }, {
  18637. key: "addDescending",
  18638. value: function ()
  18639. /*: ParseQuery*/
  18640. {
  18641. var _this10 = this;
  18642. if (!this._order) {
  18643. this._order = [];
  18644. }
  18645. for (var _len4 = arguments.length, keys = new Array(_len4), _key8 = 0; _key8 < _len4; _key8++) {
  18646. keys[_key8] = arguments[_key8];
  18647. }
  18648. (0, _forEach.default)(keys).call(keys, function (key) {
  18649. var _context17, _context18;
  18650. if ((0, _isArray.default)(key)) {
  18651. key = key.join();
  18652. }
  18653. _this10._order = (0, _concat.default)(_context17 = _this10._order).call(_context17, (0, _map2.default)(_context18 = key.replace(/\s/g, '').split(',')).call(_context18, function (k) {
  18654. return "-".concat(k);
  18655. }));
  18656. });
  18657. return this;
  18658. }
  18659. /** Query Options * */
  18660. /**
  18661. * Sets the number of results to skip before returning any results.
  18662. * This is useful for pagination.
  18663. * Default is to skip zero results.
  18664. *
  18665. * @param {number} n the number of results to skip.
  18666. * @returns {Parse.Query} Returns the query, so you can chain this call.
  18667. */
  18668. }, {
  18669. key: "skip",
  18670. value: function (n
  18671. /*: number*/
  18672. )
  18673. /*: ParseQuery*/
  18674. {
  18675. if (typeof n !== 'number' || n < 0) {
  18676. throw new Error('You can only skip by a positive number');
  18677. }
  18678. this._skip = n;
  18679. return this;
  18680. }
  18681. /**
  18682. * Sets the limit of the number of results to return. The default limit is 100.
  18683. *
  18684. * @param {number} n the number of results to limit to.
  18685. * @returns {Parse.Query} Returns the query, so you can chain this call.
  18686. */
  18687. }, {
  18688. key: "limit",
  18689. value: function (n
  18690. /*: number*/
  18691. )
  18692. /*: ParseQuery*/
  18693. {
  18694. if (typeof n !== 'number') {
  18695. throw new Error('You can only set the limit to a numeric value');
  18696. }
  18697. this._limit = n;
  18698. return this;
  18699. }
  18700. /**
  18701. * Sets the flag to include with response the total number of objects satisfying this query,
  18702. * despite limits/skip. Might be useful for pagination.
  18703. * Note that result of this query will be wrapped as an object with
  18704. * `results`: holding {ParseObject} array and `count`: integer holding total number
  18705. *
  18706. * @param {boolean} includeCount false - disable, true - enable.
  18707. * @returns {Parse.Query} Returns the query, so you can chain this call.
  18708. */
  18709. }, {
  18710. key: "withCount",
  18711. value: function ()
  18712. /*: ParseQuery*/
  18713. {
  18714. var includeCount
  18715. /*: boolean*/
  18716. = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : true;
  18717. if (typeof includeCount !== 'boolean') {
  18718. throw new Error('You can only set withCount to a boolean value');
  18719. }
  18720. this._count = includeCount;
  18721. return this;
  18722. }
  18723. /**
  18724. * Includes nested Parse.Objects for the provided key. You can use dot
  18725. * notation to specify which fields in the included object are also fetched.
  18726. *
  18727. * You can include all nested Parse.Objects by passing in '*'.
  18728. * Requires Parse Server 3.0.0+
  18729. * <pre>query.include('*');</pre>
  18730. *
  18731. * @param {...string|Array<string>} keys The name(s) of the key(s) to include.
  18732. * @returns {Parse.Query} Returns the query, so you can chain this call.
  18733. */
  18734. }, {
  18735. key: "include",
  18736. value: function ()
  18737. /*: ParseQuery*/
  18738. {
  18739. var _this11 = this;
  18740. for (var _len5 = arguments.length, keys = new Array(_len5), _key9 = 0; _key9 < _len5; _key9++) {
  18741. keys[_key9] = arguments[_key9];
  18742. }
  18743. (0, _forEach.default)(keys).call(keys, function (key) {
  18744. if ((0, _isArray.default)(key)) {
  18745. var _context19;
  18746. _this11._include = (0, _concat.default)(_context19 = _this11._include).call(_context19, key);
  18747. } else {
  18748. _this11._include.push(key);
  18749. }
  18750. });
  18751. return this;
  18752. }
  18753. /**
  18754. * Includes all nested Parse.Objects.
  18755. *
  18756. * Requires Parse Server 3.0.0+
  18757. *
  18758. * @returns {Parse.Query} Returns the query, so you can chain this call.
  18759. */
  18760. }, {
  18761. key: "includeAll",
  18762. value: function ()
  18763. /*: ParseQuery*/
  18764. {
  18765. return this.include('*');
  18766. }
  18767. /**
  18768. * Restricts the fields of the returned Parse.Objects to include only the
  18769. * provided keys. If this is called multiple times, then all of the keys
  18770. * specified in each of the calls will be included.
  18771. *
  18772. * @param {...string|Array<string>} keys The name(s) of the key(s) to include.
  18773. * @returns {Parse.Query} Returns the query, so you can chain this call.
  18774. */
  18775. }, {
  18776. key: "select",
  18777. value: function ()
  18778. /*: ParseQuery*/
  18779. {
  18780. var _this12 = this;
  18781. if (!this._select) {
  18782. this._select = [];
  18783. }
  18784. for (var _len6 = arguments.length, keys = new Array(_len6), _key10 = 0; _key10 < _len6; _key10++) {
  18785. keys[_key10] = arguments[_key10];
  18786. }
  18787. (0, _forEach.default)(keys).call(keys, function (key) {
  18788. if ((0, _isArray.default)(key)) {
  18789. var _context20;
  18790. _this12._select = (0, _concat.default)(_context20 = _this12._select).call(_context20, key);
  18791. } else {
  18792. _this12._select.push(key);
  18793. }
  18794. });
  18795. return this;
  18796. }
  18797. /**
  18798. * Restricts the fields of the returned Parse.Objects to all keys except the
  18799. * provided keys. Exclude takes precedence over select and include.
  18800. *
  18801. * Requires Parse Server 3.6.0+
  18802. *
  18803. * @param {...string|Array<string>} keys The name(s) of the key(s) to exclude.
  18804. * @returns {Parse.Query} Returns the query, so you can chain this call.
  18805. */
  18806. }, {
  18807. key: "exclude",
  18808. value: function ()
  18809. /*: ParseQuery*/
  18810. {
  18811. var _this13 = this;
  18812. for (var _len7 = arguments.length, keys = new Array(_len7), _key11 = 0; _key11 < _len7; _key11++) {
  18813. keys[_key11] = arguments[_key11];
  18814. }
  18815. (0, _forEach.default)(keys).call(keys, function (key) {
  18816. if ((0, _isArray.default)(key)) {
  18817. var _context21;
  18818. _this13._exclude = (0, _concat.default)(_context21 = _this13._exclude).call(_context21, key);
  18819. } else {
  18820. _this13._exclude.push(key);
  18821. }
  18822. });
  18823. return this;
  18824. }
  18825. /**
  18826. * Changes the read preference that the backend will use when performing the query to the database.
  18827. *
  18828. * @param {string} readPreference The read preference for the main query.
  18829. * @param {string} includeReadPreference The read preference for the queries to include pointers.
  18830. * @param {string} subqueryReadPreference The read preference for the sub queries.
  18831. * @returns {Parse.Query} Returns the query, so you can chain this call.
  18832. */
  18833. }, {
  18834. key: "readPreference",
  18835. value: function (_readPreference
  18836. /*: string*/
  18837. , includeReadPreference
  18838. /*:: ?: string*/
  18839. , subqueryReadPreference
  18840. /*:: ?: string*/
  18841. )
  18842. /*: ParseQuery*/
  18843. {
  18844. this._readPreference = _readPreference;
  18845. this._includeReadPreference = includeReadPreference;
  18846. this._subqueryReadPreference = subqueryReadPreference;
  18847. return this;
  18848. }
  18849. }, {
  18850. key: "onChange",
  18851. value: function (onUpdate
  18852. /*: any*/
  18853. , onError
  18854. /*:: ?: any*/
  18855. /*:: ?: string*/
  18856. )
  18857. /*: Promise<LiveQuerySubscription>*/
  18858. {
  18859. var sub = null;
  18860. this.subscribe().then(function (subscription) {
  18861. sub = subscription;
  18862. subscription.on('create', function (object) {
  18863. onUpdate(object);
  18864. });
  18865. subscription.on('update', function (object) {
  18866. onUpdate(object);
  18867. });
  18868. subscription.on('error', function (err) {
  18869. if (onError) {
  18870. onError(err);
  18871. } else {
  18872. // eslint-disable-next-line no-console
  18873. console.warn('Subscription error', err);
  18874. }
  18875. });
  18876. }).catch(function (err) {
  18877. if (onError) {
  18878. onError(err);
  18879. } else {
  18880. // eslint-disable-next-line no-console
  18881. console.warn('Subscription connection error', err);
  18882. }
  18883. });
  18884. return function () {
  18885. if (sub) {
  18886. sub.unsubscribe();
  18887. }
  18888. };
  18889. }
  18890. /**
  18891. * Subscribe this query to get liveQuery updates
  18892. *
  18893. * @param {string} sessionToken (optional) Defaults to the currentUser
  18894. * @returns {Promise<LiveQuerySubscription>} Returns the liveQuerySubscription, it's an event emitter
  18895. * which can be used to get liveQuery updates.
  18896. */
  18897. }, {
  18898. key: "subscribe",
  18899. value: function () {
  18900. var _subscribe = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee7(sessionToken
  18901. /*:: ?: string*/
  18902. ) {
  18903. var currentUser, liveQueryClient, subscription;
  18904. return _regenerator.default.wrap(function (_context22) {
  18905. while (1) {
  18906. switch (_context22.prev = _context22.next) {
  18907. case 0:
  18908. _context22.next = 2;
  18909. return _CoreManager.default.getUserController().currentUserAsync();
  18910. case 2:
  18911. currentUser = _context22.sent;
  18912. if (!sessionToken) {
  18913. sessionToken = currentUser ? currentUser.getSessionToken() : undefined;
  18914. }
  18915. _context22.next = 6;
  18916. return _CoreManager.default.getLiveQueryController().getDefaultLiveQueryClient();
  18917. case 6:
  18918. liveQueryClient = _context22.sent;
  18919. if (liveQueryClient.shouldOpen()) {
  18920. liveQueryClient.open();
  18921. }
  18922. subscription = liveQueryClient.subscribe(this, sessionToken);
  18923. return _context22.abrupt("return", subscription.subscribePromise.then(function () {
  18924. return subscription;
  18925. }));
  18926. case 10:
  18927. case "end":
  18928. return _context22.stop();
  18929. }
  18930. }
  18931. }, _callee7, this);
  18932. }));
  18933. return function () {
  18934. return _subscribe.apply(this, arguments);
  18935. };
  18936. }()
  18937. /**
  18938. * Constructs a Parse.Query that is the OR of the passed in queries. For
  18939. * example:
  18940. * <pre>var compoundQuery = Parse.Query.or(query1, query2, query3);</pre>
  18941. *
  18942. * will create a compoundQuery that is an or of the query1, query2, and
  18943. * query3.
  18944. *
  18945. * @param {...Parse.Query} queries The list of queries to OR.
  18946. * @static
  18947. * @returns {Parse.Query} The query that is the OR of the passed in queries.
  18948. */
  18949. }, {
  18950. key: "fromNetwork",
  18951. value:
  18952. /**
  18953. * Change the source of this query to the server.
  18954. *
  18955. * @returns {Parse.Query} Returns the query, so you can chain this call.
  18956. */
  18957. function ()
  18958. /*: ParseQuery*/
  18959. {
  18960. this._queriesLocalDatastore = false;
  18961. this._localDatastorePinName = null;
  18962. return this;
  18963. }
  18964. /**
  18965. * Changes the source of this query to all pinned objects.
  18966. *
  18967. * @returns {Parse.Query} Returns the query, so you can chain this call.
  18968. */
  18969. }, {
  18970. key: "fromLocalDatastore",
  18971. value: function ()
  18972. /*: ParseQuery*/
  18973. {
  18974. return this.fromPinWithName(null);
  18975. }
  18976. /**
  18977. * Changes the source of this query to the default group of pinned objects.
  18978. *
  18979. * @returns {Parse.Query} Returns the query, so you can chain this call.
  18980. */
  18981. }, {
  18982. key: "fromPin",
  18983. value: function ()
  18984. /*: ParseQuery*/
  18985. {
  18986. return this.fromPinWithName(_LocalDatastoreUtils.DEFAULT_PIN);
  18987. }
  18988. /**
  18989. * Changes the source of this query to a specific group of pinned objects.
  18990. *
  18991. * @param {string} name The name of query source.
  18992. * @returns {Parse.Query} Returns the query, so you can chain this call.
  18993. */
  18994. }, {
  18995. key: "fromPinWithName",
  18996. value: function (name
  18997. /*:: ?: string*/
  18998. )
  18999. /*: ParseQuery*/
  19000. {
  19001. var localDatastore = _CoreManager.default.getLocalDatastore();
  19002. if (localDatastore.checkIfEnabled()) {
  19003. this._queriesLocalDatastore = true;
  19004. this._localDatastorePinName = name;
  19005. }
  19006. return this;
  19007. }
  19008. /**
  19009. * Cancels the current network request (if any is running).
  19010. *
  19011. * @returns {Parse.Query} Returns the query, so you can chain this call.
  19012. */
  19013. }, {
  19014. key: "cancel",
  19015. value: function ()
  19016. /*: ParseQuery*/
  19017. {
  19018. var _this14 = this;
  19019. if (this._xhrRequest.task && typeof this._xhrRequest.task.abort === 'function') {
  19020. this._xhrRequest.task._aborted = true;
  19021. this._xhrRequest.task.abort();
  19022. this._xhrRequest.task = null;
  19023. this._xhrRequest.onchange = function () {};
  19024. return this;
  19025. }
  19026. return this._xhrRequest.onchange = function () {
  19027. return _this14.cancel();
  19028. };
  19029. }
  19030. }, {
  19031. key: "_setRequestTask",
  19032. value: function (options) {
  19033. var _this15 = this;
  19034. options.requestTask = function (task) {
  19035. _this15._xhrRequest.task = task;
  19036. _this15._xhrRequest.onchange();
  19037. };
  19038. }
  19039. }], [{
  19040. key: "fromJSON",
  19041. value: function (className
  19042. /*: string*/
  19043. , json
  19044. /*: QueryJSON*/
  19045. )
  19046. /*: ParseQuery*/
  19047. {
  19048. var query = new ParseQuery(className);
  19049. return query.withJSON(json);
  19050. }
  19051. }, {
  19052. key: "or",
  19053. value: function ()
  19054. /*: ParseQuery*/
  19055. {
  19056. for (var _len8 = arguments.length, queries = new Array(_len8), _key12 = 0; _key12 < _len8; _key12++) {
  19057. queries[_key12] = arguments[_key12];
  19058. }
  19059. var className = _getClassNameFromQueries(queries);
  19060. var query = new ParseQuery(className);
  19061. query._orQuery(queries);
  19062. return query;
  19063. }
  19064. /**
  19065. * Constructs a Parse.Query that is the AND of the passed in queries. For
  19066. * example:
  19067. * <pre>var compoundQuery = Parse.Query.and(query1, query2, query3);</pre>
  19068. *
  19069. * will create a compoundQuery that is an and of the query1, query2, and
  19070. * query3.
  19071. *
  19072. * @param {...Parse.Query} queries The list of queries to AND.
  19073. * @static
  19074. * @returns {Parse.Query} The query that is the AND of the passed in queries.
  19075. */
  19076. }, {
  19077. key: "and",
  19078. value: function ()
  19079. /*: ParseQuery*/
  19080. {
  19081. for (var _len9 = arguments.length, queries = new Array(_len9), _key13 = 0; _key13 < _len9; _key13++) {
  19082. queries[_key13] = arguments[_key13];
  19083. }
  19084. var className = _getClassNameFromQueries(queries);
  19085. var query = new ParseQuery(className);
  19086. query._andQuery(queries);
  19087. return query;
  19088. }
  19089. /**
  19090. * Constructs a Parse.Query that is the NOR of the passed in queries. For
  19091. * example:
  19092. * <pre>const compoundQuery = Parse.Query.nor(query1, query2, query3);</pre>
  19093. *
  19094. * will create a compoundQuery that is a nor of the query1, query2, and
  19095. * query3.
  19096. *
  19097. * @param {...Parse.Query} queries The list of queries to NOR.
  19098. * @static
  19099. * @returns {Parse.Query} The query that is the NOR of the passed in queries.
  19100. */
  19101. }, {
  19102. key: "nor",
  19103. value: function ()
  19104. /*: ParseQuery*/
  19105. {
  19106. for (var _len10 = arguments.length, queries = new Array(_len10), _key14 = 0; _key14 < _len10; _key14++) {
  19107. queries[_key14] = arguments[_key14];
  19108. }
  19109. var className = _getClassNameFromQueries(queries);
  19110. var query = new ParseQuery(className);
  19111. query._norQuery(queries);
  19112. return query;
  19113. }
  19114. }]);
  19115. return ParseQuery;
  19116. }();
  19117. var DefaultController = {
  19118. find: function (className
  19119. /*: string*/
  19120. , params
  19121. /*: QueryJSON*/
  19122. , options
  19123. /*: RequestOptions*/
  19124. )
  19125. /*: Promise<Array<ParseObject>>*/
  19126. {
  19127. var RESTController = _CoreManager.default.getRESTController();
  19128. return RESTController.request('GET', "classes/".concat(className), params, options);
  19129. },
  19130. aggregate: function (className
  19131. /*: string*/
  19132. , params
  19133. /*: any*/
  19134. , options
  19135. /*: RequestOptions*/
  19136. )
  19137. /*: Promise<Array<mixed>>*/
  19138. {
  19139. var RESTController = _CoreManager.default.getRESTController();
  19140. return RESTController.request('GET', "aggregate/".concat(className), params, options);
  19141. }
  19142. };
  19143. _CoreManager.default.setQueryController(DefaultController);
  19144. var _default = ParseQuery;
  19145. exports.default = _default;
  19146. },{"./CoreManager":5,"./LocalDatastoreUtils":15,"./OfflineQuery":24,"./ParseError":29,"./ParseGeoPoint":33,"./ParseObject":36,"./encode":66,"./promiseUtils":72,"@babel/runtime-corejs3/core-js-stable/array/is-array":79,"@babel/runtime-corejs3/core-js-stable/instance/concat":81,"@babel/runtime-corejs3/core-js-stable/instance/filter":84,"@babel/runtime-corejs3/core-js-stable/instance/find":85,"@babel/runtime-corejs3/core-js-stable/instance/for-each":86,"@babel/runtime-corejs3/core-js-stable/instance/includes":87,"@babel/runtime-corejs3/core-js-stable/instance/index-of":88,"@babel/runtime-corejs3/core-js-stable/instance/keys":89,"@babel/runtime-corejs3/core-js-stable/instance/map":90,"@babel/runtime-corejs3/core-js-stable/instance/slice":93,"@babel/runtime-corejs3/core-js-stable/instance/sort":94,"@babel/runtime-corejs3/core-js-stable/instance/splice":95,"@babel/runtime-corejs3/core-js-stable/object/define-property":105,"@babel/runtime-corejs3/core-js-stable/object/entries":106,"@babel/runtime-corejs3/core-js-stable/object/keys":112,"@babel/runtime-corejs3/core-js-stable/promise":115,"@babel/runtime-corejs3/helpers/asyncToGenerator":144,"@babel/runtime-corejs3/helpers/classCallCheck":145,"@babel/runtime-corejs3/helpers/createClass":147,"@babel/runtime-corejs3/helpers/defineProperty":148,"@babel/runtime-corejs3/helpers/interopRequireDefault":152,"@babel/runtime-corejs3/helpers/slicedToArray":161,"@babel/runtime-corejs3/helpers/toConsumableArray":163,"@babel/runtime-corejs3/helpers/typeof":164,"@babel/runtime-corejs3/regenerator":167}],40:[function(_dereq_,module,exports){
  19147. "use strict";
  19148. var _Object$defineProperty = _dereq_("@babel/runtime-corejs3/core-js-stable/object/define-property");
  19149. var _interopRequireDefault = _dereq_("@babel/runtime-corejs3/helpers/interopRequireDefault");
  19150. _Object$defineProperty(exports, "__esModule", {
  19151. value: true
  19152. });
  19153. exports.default = void 0;
  19154. var _isArray = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/array/is-array"));
  19155. var _classCallCheck2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/helpers/classCallCheck"));
  19156. var _createClass2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/helpers/createClass"));
  19157. var _defineProperty2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/helpers/defineProperty"));
  19158. var _ParseOp = _dereq_("./ParseOp");
  19159. var _ParseObject = _interopRequireDefault(_dereq_("./ParseObject"));
  19160. var _ParseQuery = _interopRequireDefault(_dereq_("./ParseQuery"));
  19161. /**
  19162. * Copyright (c) 2015-present, Parse, LLC.
  19163. * All rights reserved.
  19164. *
  19165. * This source code is licensed under the BSD-style license found in the
  19166. * LICENSE file in the root directory of this source tree. An additional grant
  19167. * of patent rights can be found in the PATENTS file in the same directory.
  19168. *
  19169. * @flow
  19170. */
  19171. /**
  19172. * Creates a new Relation for the given parent object and key. This
  19173. * constructor should rarely be used directly, but rather created by
  19174. * Parse.Object.relation.
  19175. *
  19176. * <p>
  19177. * A class that is used to access all of the children of a many-to-many
  19178. * relationship. Each instance of Parse.Relation is associated with a
  19179. * particular parent object and key.
  19180. * </p>
  19181. *
  19182. * @alias Parse.Relation
  19183. */
  19184. var ParseRelation = /*#__PURE__*/function () {
  19185. /**
  19186. * @param {Parse.Object} parent The parent of this relation.
  19187. * @param {string} key The key for this relation on the parent.
  19188. */
  19189. function ParseRelation(parent
  19190. /*: ?ParseObject*/
  19191. , key
  19192. /*: ?string*/
  19193. ) {
  19194. (0, _classCallCheck2.default)(this, ParseRelation);
  19195. (0, _defineProperty2.default)(this, "parent", void 0);
  19196. (0, _defineProperty2.default)(this, "key", void 0);
  19197. (0, _defineProperty2.default)(this, "targetClassName", void 0);
  19198. this.parent = parent;
  19199. this.key = key;
  19200. this.targetClassName = null;
  19201. }
  19202. /*
  19203. * Makes sure that this relation has the right parent and key.
  19204. */
  19205. (0, _createClass2.default)(ParseRelation, [{
  19206. key: "_ensureParentAndKey",
  19207. value: function (parent
  19208. /*: ParseObject*/
  19209. , key
  19210. /*: string*/
  19211. ) {
  19212. this.key = this.key || key;
  19213. if (this.key !== key) {
  19214. throw new Error('Internal Error. Relation retrieved from two different keys.');
  19215. }
  19216. if (this.parent) {
  19217. if (this.parent.className !== parent.className) {
  19218. throw new Error('Internal Error. Relation retrieved from two different Objects.');
  19219. }
  19220. if (this.parent.id) {
  19221. if (this.parent.id !== parent.id) {
  19222. throw new Error('Internal Error. Relation retrieved from two different Objects.');
  19223. }
  19224. } else if (parent.id) {
  19225. this.parent = parent;
  19226. }
  19227. } else {
  19228. this.parent = parent;
  19229. }
  19230. }
  19231. /**
  19232. * Adds a Parse.Object or an array of Parse.Objects to the relation.
  19233. *
  19234. * @param {(Parse.Object|Array)} objects The item or items to add.
  19235. * @returns {Parse.Object} The parent of the relation.
  19236. */
  19237. }, {
  19238. key: "add",
  19239. value: function (objects
  19240. /*: ParseObject | Array<ParseObject | string>*/
  19241. )
  19242. /*: ParseObject*/
  19243. {
  19244. if (!(0, _isArray.default)(objects)) {
  19245. objects = [objects];
  19246. }
  19247. var change = new _ParseOp.RelationOp(objects, []);
  19248. var parent = this.parent;
  19249. if (!parent) {
  19250. throw new Error('Cannot add to a Relation without a parent');
  19251. }
  19252. if (objects.length === 0) {
  19253. return parent;
  19254. }
  19255. parent.set(this.key, change);
  19256. this.targetClassName = change._targetClassName;
  19257. return parent;
  19258. }
  19259. /**
  19260. * Removes a Parse.Object or an array of Parse.Objects from this relation.
  19261. *
  19262. * @param {(Parse.Object|Array)} objects The item or items to remove.
  19263. */
  19264. }, {
  19265. key: "remove",
  19266. value: function (objects
  19267. /*: ParseObject | Array<ParseObject | string>*/
  19268. ) {
  19269. if (!(0, _isArray.default)(objects)) {
  19270. objects = [objects];
  19271. }
  19272. var change = new _ParseOp.RelationOp([], objects);
  19273. if (!this.parent) {
  19274. throw new Error('Cannot remove from a Relation without a parent');
  19275. }
  19276. if (objects.length === 0) {
  19277. return;
  19278. }
  19279. this.parent.set(this.key, change);
  19280. this.targetClassName = change._targetClassName;
  19281. }
  19282. /**
  19283. * Returns a JSON version of the object suitable for saving to disk.
  19284. *
  19285. * @returns {object} JSON representation of Relation
  19286. */
  19287. }, {
  19288. key: "toJSON",
  19289. value: function ()
  19290. /*: { __type: 'Relation', className: ?string }*/
  19291. {
  19292. return {
  19293. __type: 'Relation',
  19294. className: this.targetClassName
  19295. };
  19296. }
  19297. /**
  19298. * Returns a Parse.Query that is limited to objects in this
  19299. * relation.
  19300. *
  19301. * @returns {Parse.Query} Relation Query
  19302. */
  19303. }, {
  19304. key: "query",
  19305. value: function query()
  19306. /*: ParseQuery*/
  19307. {
  19308. var query;
  19309. var parent = this.parent;
  19310. if (!parent) {
  19311. throw new Error('Cannot construct a query for a Relation without a parent');
  19312. }
  19313. if (!this.targetClassName) {
  19314. query = new _ParseQuery.default(parent.className);
  19315. query._extraOptions.redirectClassNameForKey = this.key;
  19316. } else {
  19317. query = new _ParseQuery.default(this.targetClassName);
  19318. }
  19319. query._addCondition('$relatedTo', 'object', {
  19320. __type: 'Pointer',
  19321. className: parent.className,
  19322. objectId: parent.id
  19323. });
  19324. query._addCondition('$relatedTo', 'key', this.key);
  19325. return query;
  19326. }
  19327. }]);
  19328. return ParseRelation;
  19329. }();
  19330. var _default = ParseRelation;
  19331. exports.default = _default;
  19332. },{"./ParseObject":36,"./ParseOp":37,"./ParseQuery":39,"@babel/runtime-corejs3/core-js-stable/array/is-array":79,"@babel/runtime-corejs3/core-js-stable/object/define-property":105,"@babel/runtime-corejs3/helpers/classCallCheck":145,"@babel/runtime-corejs3/helpers/createClass":147,"@babel/runtime-corejs3/helpers/defineProperty":148,"@babel/runtime-corejs3/helpers/interopRequireDefault":152}],41:[function(_dereq_,module,exports){
  19333. "use strict";
  19334. var _Reflect$construct = _dereq_("@babel/runtime-corejs3/core-js-stable/reflect/construct");
  19335. var _Object$defineProperty = _dereq_("@babel/runtime-corejs3/core-js-stable/object/define-property");
  19336. var _interopRequireDefault = _dereq_("@babel/runtime-corejs3/helpers/interopRequireDefault");
  19337. _Object$defineProperty(exports, "__esModule", {
  19338. value: true
  19339. });
  19340. exports.default = void 0;
  19341. var _classCallCheck2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/helpers/classCallCheck"));
  19342. var _createClass2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/helpers/createClass"));
  19343. var _get2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/helpers/get"));
  19344. var _inherits2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/helpers/inherits"));
  19345. var _possibleConstructorReturn2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/helpers/possibleConstructorReturn"));
  19346. var _getPrototypeOf2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/helpers/getPrototypeOf"));
  19347. var _ParseACL = _interopRequireDefault(_dereq_("./ParseACL"));
  19348. var _ParseError = _interopRequireDefault(_dereq_("./ParseError"));
  19349. var _ParseObject2 = _interopRequireDefault(_dereq_("./ParseObject"));
  19350. function _createSuper(Derived) {
  19351. var hasNativeReflectConstruct = _isNativeReflectConstruct();
  19352. return function () {
  19353. var Super = (0, _getPrototypeOf2.default)(Derived),
  19354. result;
  19355. if (hasNativeReflectConstruct) {
  19356. var NewTarget = (0, _getPrototypeOf2.default)(this).constructor;
  19357. result = _Reflect$construct(Super, arguments, NewTarget);
  19358. } else {
  19359. result = Super.apply(this, arguments);
  19360. }
  19361. return (0, _possibleConstructorReturn2.default)(this, result);
  19362. };
  19363. }
  19364. function _isNativeReflectConstruct() {
  19365. if (typeof Reflect === "undefined" || !_Reflect$construct) return false;
  19366. if (_Reflect$construct.sham) return false;
  19367. if (typeof Proxy === "function") return true;
  19368. try {
  19369. Boolean.prototype.valueOf.call(_Reflect$construct(Boolean, [], function () {}));
  19370. return true;
  19371. } catch (e) {
  19372. return false;
  19373. }
  19374. }
  19375. /**
  19376. * Represents a Role on the Parse server. Roles represent groupings of
  19377. * Users for the purposes of granting permissions (e.g. specifying an ACL
  19378. * for an Object). Roles are specified by their sets of child users and
  19379. * child roles, all of which are granted any permissions that the parent
  19380. * role has.
  19381. *
  19382. * <p>Roles must have a name (which cannot be changed after creation of the
  19383. * role), and must specify an ACL.</p>
  19384. *
  19385. * @alias Parse.Role
  19386. * @augments Parse.Object
  19387. */
  19388. var ParseRole = /*#__PURE__*/function (_ParseObject) {
  19389. (0, _inherits2.default)(ParseRole, _ParseObject);
  19390. var _super = _createSuper(ParseRole);
  19391. /**
  19392. * @param {string} name The name of the Role to create.
  19393. * @param {Parse.ACL} acl The ACL for this role. Roles must have an ACL.
  19394. * A Parse.Role is a local representation of a role persisted to the Parse
  19395. * cloud.
  19396. */
  19397. function ParseRole(name
  19398. /*: string*/
  19399. , acl
  19400. /*: ParseACL*/
  19401. ) {
  19402. var _this;
  19403. (0, _classCallCheck2.default)(this, ParseRole);
  19404. _this = _super.call(this, '_Role');
  19405. if (typeof name === 'string' && acl instanceof _ParseACL.default) {
  19406. _this.setName(name);
  19407. _this.setACL(acl);
  19408. }
  19409. return _this;
  19410. }
  19411. /**
  19412. * Gets the name of the role. You can alternatively call role.get("name")
  19413. *
  19414. * @returns {string} the name of the role.
  19415. */
  19416. (0, _createClass2.default)(ParseRole, [{
  19417. key: "getName",
  19418. value: function ()
  19419. /*: ?string*/
  19420. {
  19421. var name = this.get('name');
  19422. if (name == null || typeof name === 'string') {
  19423. return name;
  19424. }
  19425. return '';
  19426. }
  19427. /**
  19428. * Sets the name for a role. This value must be set before the role has
  19429. * been saved to the server, and cannot be set once the role has been
  19430. * saved.
  19431. *
  19432. * <p>
  19433. * A role's name can only contain alphanumeric characters, _, -, and
  19434. * spaces.
  19435. * </p>
  19436. *
  19437. * <p>This is equivalent to calling role.set("name", name)</p>
  19438. *
  19439. * @param {string} name The name of the role.
  19440. * @param {object} options Standard options object with success and error
  19441. * callbacks.
  19442. * @returns {(ParseObject|boolean)} true if the set succeeded.
  19443. */
  19444. }, {
  19445. key: "setName",
  19446. value: function (name
  19447. /*: string*/
  19448. , options
  19449. /*:: ?: mixed*/
  19450. )
  19451. /*: ParseObject | boolean*/
  19452. {
  19453. return this.set('name', name, options);
  19454. }
  19455. /**
  19456. * Gets the Parse.Relation for the Parse.Users that are direct
  19457. * children of this role. These users are granted any privileges that this
  19458. * role has been granted (e.g. read or write access through ACLs). You can
  19459. * add or remove users from the role through this relation.
  19460. *
  19461. * <p>This is equivalent to calling role.relation("users")</p>
  19462. *
  19463. * @returns {Parse.Relation} the relation for the users belonging to this
  19464. * role.
  19465. */
  19466. }, {
  19467. key: "getUsers",
  19468. value: function ()
  19469. /*: ParseRelation*/
  19470. {
  19471. return this.relation('users');
  19472. }
  19473. /**
  19474. * Gets the Parse.Relation for the Parse.Roles that are direct
  19475. * children of this role. These roles' users are granted any privileges that
  19476. * this role has been granted (e.g. read or write access through ACLs). You
  19477. * can add or remove child roles from this role through this relation.
  19478. *
  19479. * <p>This is equivalent to calling role.relation("roles")</p>
  19480. *
  19481. * @returns {Parse.Relation} the relation for the roles belonging to this
  19482. * role.
  19483. */
  19484. }, {
  19485. key: "getRoles",
  19486. value: function ()
  19487. /*: ParseRelation*/
  19488. {
  19489. return this.relation('roles');
  19490. }
  19491. }, {
  19492. key: "validate",
  19493. value: function (attrs
  19494. /*: AttributeMap*/
  19495. , options
  19496. /*:: ?: mixed*/
  19497. )
  19498. /*: ParseError | boolean*/
  19499. {
  19500. var isInvalid = (0, _get2.default)((0, _getPrototypeOf2.default)(ParseRole.prototype), "validate", this).call(this, attrs, options);
  19501. if (isInvalid) {
  19502. return isInvalid;
  19503. }
  19504. if ('name' in attrs && attrs.name !== this.getName()) {
  19505. var newName = attrs.name;
  19506. if (this.id && this.id !== attrs.objectId) {
  19507. // Check to see if the objectId being set matches this.id
  19508. // This happens during a fetch -- the id is set before calling fetch
  19509. // Let the name be set in this case
  19510. return new _ParseError.default(_ParseError.default.OTHER_CAUSE, "A role's name can only be set before it has been saved.");
  19511. }
  19512. if (typeof newName !== 'string') {
  19513. return new _ParseError.default(_ParseError.default.OTHER_CAUSE, "A role's name must be a String.");
  19514. }
  19515. if (!/^[0-9a-zA-Z\-_ ]+$/.test(newName)) {
  19516. return new _ParseError.default(_ParseError.default.OTHER_CAUSE, "A role's name can be only contain alphanumeric characters, _, -, and spaces.");
  19517. }
  19518. }
  19519. return false;
  19520. }
  19521. }]);
  19522. return ParseRole;
  19523. }(_ParseObject2.default);
  19524. _ParseObject2.default.registerSubclass('_Role', ParseRole);
  19525. var _default = ParseRole;
  19526. exports.default = _default;
  19527. },{"./ParseACL":26,"./ParseError":29,"./ParseObject":36,"@babel/runtime-corejs3/core-js-stable/object/define-property":105,"@babel/runtime-corejs3/core-js-stable/reflect/construct":116,"@babel/runtime-corejs3/helpers/classCallCheck":145,"@babel/runtime-corejs3/helpers/createClass":147,"@babel/runtime-corejs3/helpers/get":149,"@babel/runtime-corejs3/helpers/getPrototypeOf":150,"@babel/runtime-corejs3/helpers/inherits":151,"@babel/runtime-corejs3/helpers/interopRequireDefault":152,"@babel/runtime-corejs3/helpers/possibleConstructorReturn":159}],42:[function(_dereq_,module,exports){
  19528. "use strict";
  19529. var _Object$defineProperty = _dereq_("@babel/runtime-corejs3/core-js-stable/object/define-property");
  19530. var _interopRequireDefault = _dereq_("@babel/runtime-corejs3/helpers/interopRequireDefault");
  19531. _Object$defineProperty(exports, "__esModule", {
  19532. value: true
  19533. });
  19534. exports.default = void 0;
  19535. var _indexOf = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/instance/index-of"));
  19536. var _classCallCheck2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/helpers/classCallCheck"));
  19537. var _createClass2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/helpers/createClass"));
  19538. var _defineProperty2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/helpers/defineProperty"));
  19539. var _CoreManager = _interopRequireDefault(_dereq_("./CoreManager"));
  19540. var _ParseObject = _interopRequireDefault(_dereq_("./ParseObject"));
  19541. var _ParseCLP = _interopRequireDefault(_dereq_("./ParseCLP"));
  19542. /**
  19543. * Copyright (c) 2015-present, Parse, LLC.
  19544. * All rights reserved.
  19545. *
  19546. * This source code is licensed under the BSD-style license found in the
  19547. * LICENSE file in the root directory of this source tree. An additional grant
  19548. * of patent rights can be found in the PATENTS file in the same directory.
  19549. *
  19550. * @flow
  19551. */
  19552. var FIELD_TYPES = ['String', 'Number', 'Boolean', 'Date', 'File', 'GeoPoint', 'Polygon', 'Array', 'Object', 'Pointer', 'Relation'];
  19553. /*:: type FieldOptions = {
  19554. required: boolean,
  19555. defaultValue: mixed,
  19556. };*/
  19557. /**
  19558. * A Parse.Schema object is for handling schema data from Parse.
  19559. * <p>All the schemas methods require MasterKey.
  19560. *
  19561. * When adding fields, you may set required and default values. (Requires Parse Server 3.7.0+)
  19562. *
  19563. * <pre>
  19564. * const options = { required: true, defaultValue: 'hello world' };
  19565. * const schema = new Parse.Schema('MyClass');
  19566. * schema.addString('field', options);
  19567. * schema.addIndex('index_name', { 'field': 1 });
  19568. * schema.save();
  19569. * </pre>
  19570. * </p>
  19571. *
  19572. * @alias Parse.Schema
  19573. */
  19574. var ParseSchema = /*#__PURE__*/function () {
  19575. /**
  19576. * @param {string} className Parse Class string.
  19577. */
  19578. function ParseSchema(className
  19579. /*: string*/
  19580. ) {
  19581. (0, _classCallCheck2.default)(this, ParseSchema);
  19582. (0, _defineProperty2.default)(this, "className", void 0);
  19583. (0, _defineProperty2.default)(this, "_fields", void 0);
  19584. (0, _defineProperty2.default)(this, "_indexes", void 0);
  19585. (0, _defineProperty2.default)(this, "_clp", void 0);
  19586. if (typeof className === 'string') {
  19587. if (className === 'User' && _CoreManager.default.get('PERFORM_USER_REWRITE')) {
  19588. this.className = '_User';
  19589. } else {
  19590. this.className = className;
  19591. }
  19592. }
  19593. this._fields = {};
  19594. this._indexes = {};
  19595. }
  19596. /**
  19597. * Static method to get all schemas
  19598. *
  19599. * @returns {Promise} A promise that is resolved with the result when
  19600. * the query completes.
  19601. */
  19602. (0, _createClass2.default)(ParseSchema, [{
  19603. key: "get",
  19604. value:
  19605. /**
  19606. * Get the Schema from Parse
  19607. *
  19608. * @returns {Promise} A promise that is resolved with the result when
  19609. * the query completes.
  19610. */
  19611. function () {
  19612. this.assertClassName();
  19613. var controller = _CoreManager.default.getSchemaController();
  19614. return controller.get(this.className).then(function (response) {
  19615. if (!response) {
  19616. throw new Error('Schema not found.');
  19617. }
  19618. return response;
  19619. });
  19620. }
  19621. /**
  19622. * Create a new Schema on Parse
  19623. *
  19624. * @returns {Promise} A promise that is resolved with the result when
  19625. * the query completes.
  19626. */
  19627. }, {
  19628. key: "save",
  19629. value: function () {
  19630. this.assertClassName();
  19631. var controller = _CoreManager.default.getSchemaController();
  19632. var params = {
  19633. className: this.className,
  19634. fields: this._fields,
  19635. indexes: this._indexes,
  19636. classLevelPermissions: this._clp
  19637. };
  19638. return controller.create(this.className, params);
  19639. }
  19640. /**
  19641. * Update a Schema on Parse
  19642. *
  19643. * @returns {Promise} A promise that is resolved with the result when
  19644. * the query completes.
  19645. */
  19646. }, {
  19647. key: "update",
  19648. value: function () {
  19649. this.assertClassName();
  19650. var controller = _CoreManager.default.getSchemaController();
  19651. var params = {
  19652. className: this.className,
  19653. fields: this._fields,
  19654. indexes: this._indexes,
  19655. classLevelPermissions: this._clp
  19656. };
  19657. this._fields = {};
  19658. this._indexes = {};
  19659. return controller.update(this.className, params);
  19660. }
  19661. /**
  19662. * Removing a Schema from Parse
  19663. * Can only be used on Schema without objects
  19664. *
  19665. * @returns {Promise} A promise that is resolved with the result when
  19666. * the query completes.
  19667. */
  19668. }, {
  19669. key: "delete",
  19670. value: function () {
  19671. this.assertClassName();
  19672. var controller = _CoreManager.default.getSchemaController();
  19673. return controller.delete(this.className);
  19674. }
  19675. /**
  19676. * Removes all objects from a Schema (class) in Parse.
  19677. * EXERCISE CAUTION, running this will delete all objects for this schema and cannot be reversed
  19678. *
  19679. * @returns {Promise} A promise that is resolved with the result when
  19680. * the query completes.
  19681. */
  19682. }, {
  19683. key: "purge",
  19684. value: function () {
  19685. this.assertClassName();
  19686. var controller = _CoreManager.default.getSchemaController();
  19687. return controller.purge(this.className);
  19688. }
  19689. /**
  19690. * Assert if ClassName has been filled
  19691. *
  19692. * @private
  19693. */
  19694. }, {
  19695. key: "assertClassName",
  19696. value: function () {
  19697. if (!this.className) {
  19698. throw new Error('You must set a Class Name before making any request.');
  19699. }
  19700. }
  19701. /**
  19702. * Sets Class Level Permissions when creating / updating a Schema.
  19703. * EXERCISE CAUTION, running this may override CLP for this schema and cannot be reversed
  19704. *
  19705. * @param {object | Parse.CLP} clp Class Level Permissions
  19706. * @returns {Parse.Schema} Returns the schema, so you can chain this call.
  19707. */
  19708. }, {
  19709. key: "setCLP",
  19710. value: function (clp
  19711. /*: PermissionsMap | ParseCLP*/
  19712. ) {
  19713. if (clp instanceof _ParseCLP.default) {
  19714. this._clp = clp.toJSON();
  19715. } else {
  19716. this._clp = clp;
  19717. }
  19718. return this;
  19719. }
  19720. /**
  19721. * Adding a Field to Create / Update a Schema
  19722. *
  19723. * @param {string} name Name of the field that will be created on Parse
  19724. * @param {string} type Can be a (String|Number|Boolean|Date|Parse.File|Parse.GeoPoint|Array|Object|Pointer|Parse.Relation)
  19725. * @param {object} options
  19726. * Valid options are:<ul>
  19727. * <li>required: If field is not set, save operation fails (Requires Parse Server 3.7.0+)
  19728. * <li>defaultValue: If field is not set, a default value is selected (Requires Parse Server 3.7.0+)
  19729. * </ul>
  19730. * @returns {Parse.Schema} Returns the schema, so you can chain this call.
  19731. */
  19732. }, {
  19733. key: "addField",
  19734. value: function (name
  19735. /*: string*/
  19736. , type
  19737. /*: string*/
  19738. ) {
  19739. var options
  19740. /*: FieldOptions*/
  19741. = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
  19742. type = type || 'String';
  19743. if (!name) {
  19744. throw new Error('field name may not be null.');
  19745. }
  19746. if ((0, _indexOf.default)(FIELD_TYPES).call(FIELD_TYPES, type) === -1) {
  19747. throw new Error("".concat(type, " is not a valid type."));
  19748. }
  19749. var fieldOptions = {
  19750. type: type
  19751. };
  19752. if (typeof options.required === 'boolean') {
  19753. fieldOptions.required = options.required;
  19754. }
  19755. if (options.defaultValue !== undefined) {
  19756. fieldOptions.defaultValue = options.defaultValue;
  19757. }
  19758. this._fields[name] = fieldOptions;
  19759. return this;
  19760. }
  19761. /**
  19762. * Adding an Index to Create / Update a Schema
  19763. *
  19764. * @param {string} name Name of the index
  19765. * @param {object} index { field: value }
  19766. * @returns {Parse.Schema} Returns the schema, so you can chain this call.
  19767. *
  19768. * <pre>
  19769. * schema.addIndex('index_name', { 'field': 1 });
  19770. * </pre>
  19771. */
  19772. }, {
  19773. key: "addIndex",
  19774. value: function (name
  19775. /*: string*/
  19776. , index
  19777. /*: any*/
  19778. ) {
  19779. if (!name) {
  19780. throw new Error('index name may not be null.');
  19781. }
  19782. if (!index) {
  19783. throw new Error('index may not be null.');
  19784. }
  19785. this._indexes[name] = index;
  19786. return this;
  19787. }
  19788. /**
  19789. * Adding String Field
  19790. *
  19791. * @param {string} name Name of the field that will be created on Parse
  19792. * @param {object} options See {@link https://parseplatform.org/Parse-SDK-JS/api/master/Parse.Schema.html#addField addField}
  19793. * @returns {Parse.Schema} Returns the schema, so you can chain this call.
  19794. */
  19795. }, {
  19796. key: "addString",
  19797. value: function (name
  19798. /*: string*/
  19799. , options
  19800. /*: FieldOptions*/
  19801. ) {
  19802. return this.addField(name, 'String', options);
  19803. }
  19804. /**
  19805. * Adding Number Field
  19806. *
  19807. * @param {string} name Name of the field that will be created on Parse
  19808. * @param {object} options See {@link https://parseplatform.org/Parse-SDK-JS/api/master/Parse.Schema.html#addField addField}
  19809. * @returns {Parse.Schema} Returns the schema, so you can chain this call.
  19810. */
  19811. }, {
  19812. key: "addNumber",
  19813. value: function (name
  19814. /*: string*/
  19815. , options
  19816. /*: FieldOptions*/
  19817. ) {
  19818. return this.addField(name, 'Number', options);
  19819. }
  19820. /**
  19821. * Adding Boolean Field
  19822. *
  19823. * @param {string} name Name of the field that will be created on Parse
  19824. * @param {object} options See {@link https://parseplatform.org/Parse-SDK-JS/api/master/Parse.Schema.html#addField addField}
  19825. * @returns {Parse.Schema} Returns the schema, so you can chain this call.
  19826. */
  19827. }, {
  19828. key: "addBoolean",
  19829. value: function (name
  19830. /*: string*/
  19831. , options
  19832. /*: FieldOptions*/
  19833. ) {
  19834. return this.addField(name, 'Boolean', options);
  19835. }
  19836. /**
  19837. * Adding Date Field
  19838. *
  19839. * @param {string} name Name of the field that will be created on Parse
  19840. * @param {object} options See {@link https://parseplatform.org/Parse-SDK-JS/api/master/Parse.Schema.html#addField addField}
  19841. * @returns {Parse.Schema} Returns the schema, so you can chain this call.
  19842. */
  19843. }, {
  19844. key: "addDate",
  19845. value: function (name
  19846. /*: string*/
  19847. , options
  19848. /*: FieldOptions*/
  19849. ) {
  19850. if (options && options.defaultValue) {
  19851. options.defaultValue = {
  19852. __type: 'Date',
  19853. iso: new Date(options.defaultValue)
  19854. };
  19855. }
  19856. return this.addField(name, 'Date', options);
  19857. }
  19858. /**
  19859. * Adding File Field
  19860. *
  19861. * @param {string} name Name of the field that will be created on Parse
  19862. * @param {object} options See {@link https://parseplatform.org/Parse-SDK-JS/api/master/Parse.Schema.html#addField addField}
  19863. * @returns {Parse.Schema} Returns the schema, so you can chain this call.
  19864. */
  19865. }, {
  19866. key: "addFile",
  19867. value: function (name
  19868. /*: string*/
  19869. , options
  19870. /*: FieldOptions*/
  19871. ) {
  19872. return this.addField(name, 'File', options);
  19873. }
  19874. /**
  19875. * Adding GeoPoint Field
  19876. *
  19877. * @param {string} name Name of the field that will be created on Parse
  19878. * @param {object} options See {@link https://parseplatform.org/Parse-SDK-JS/api/master/Parse.Schema.html#addField addField}
  19879. * @returns {Parse.Schema} Returns the schema, so you can chain this call.
  19880. */
  19881. }, {
  19882. key: "addGeoPoint",
  19883. value: function (name
  19884. /*: string*/
  19885. , options
  19886. /*: FieldOptions*/
  19887. ) {
  19888. return this.addField(name, 'GeoPoint', options);
  19889. }
  19890. /**
  19891. * Adding Polygon Field
  19892. *
  19893. * @param {string} name Name of the field that will be created on Parse
  19894. * @param {object} options See {@link https://parseplatform.org/Parse-SDK-JS/api/master/Parse.Schema.html#addField addField}
  19895. * @returns {Parse.Schema} Returns the schema, so you can chain this call.
  19896. */
  19897. }, {
  19898. key: "addPolygon",
  19899. value: function (name
  19900. /*: string*/
  19901. , options
  19902. /*: FieldOptions*/
  19903. ) {
  19904. return this.addField(name, 'Polygon', options);
  19905. }
  19906. /**
  19907. * Adding Array Field
  19908. *
  19909. * @param {string} name Name of the field that will be created on Parse
  19910. * @param {object} options See {@link https://parseplatform.org/Parse-SDK-JS/api/master/Parse.Schema.html#addField addField}
  19911. * @returns {Parse.Schema} Returns the schema, so you can chain this call.
  19912. */
  19913. }, {
  19914. key: "addArray",
  19915. value: function (name
  19916. /*: string*/
  19917. , options
  19918. /*: FieldOptions*/
  19919. ) {
  19920. return this.addField(name, 'Array', options);
  19921. }
  19922. /**
  19923. * Adding Object Field
  19924. *
  19925. * @param {string} name Name of the field that will be created on Parse
  19926. * @param {object} options See {@link https://parseplatform.org/Parse-SDK-JS/api/master/Parse.Schema.html#addField addField}
  19927. * @returns {Parse.Schema} Returns the schema, so you can chain this call.
  19928. */
  19929. }, {
  19930. key: "addObject",
  19931. value: function (name
  19932. /*: string*/
  19933. , options
  19934. /*: FieldOptions*/
  19935. ) {
  19936. return this.addField(name, 'Object', options);
  19937. }
  19938. /**
  19939. * Adding Pointer Field
  19940. *
  19941. * @param {string} name Name of the field that will be created on Parse
  19942. * @param {string} targetClass Name of the target Pointer Class
  19943. * @param {object} options See {@link https://parseplatform.org/Parse-SDK-JS/api/master/Parse.Schema.html#addField addField}
  19944. * @returns {Parse.Schema} Returns the schema, so you can chain this call.
  19945. */
  19946. }, {
  19947. key: "addPointer",
  19948. value: function (name
  19949. /*: string*/
  19950. , targetClass
  19951. /*: string*/
  19952. ) {
  19953. var options
  19954. /*: FieldOptions*/
  19955. = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
  19956. if (!name) {
  19957. throw new Error('field name may not be null.');
  19958. }
  19959. if (!targetClass) {
  19960. throw new Error('You need to set the targetClass of the Pointer.');
  19961. }
  19962. var fieldOptions = {
  19963. type: 'Pointer',
  19964. targetClass: targetClass
  19965. };
  19966. if (typeof options.required === 'boolean') {
  19967. fieldOptions.required = options.required;
  19968. }
  19969. if (options.defaultValue !== undefined) {
  19970. fieldOptions.defaultValue = options.defaultValue;
  19971. if (options.defaultValue instanceof _ParseObject.default) {
  19972. fieldOptions.defaultValue = options.defaultValue.toPointer();
  19973. }
  19974. }
  19975. this._fields[name] = fieldOptions;
  19976. return this;
  19977. }
  19978. /**
  19979. * Adding Relation Field
  19980. *
  19981. * @param {string} name Name of the field that will be created on Parse
  19982. * @param {string} targetClass Name of the target Pointer Class
  19983. * @returns {Parse.Schema} Returns the schema, so you can chain this call.
  19984. */
  19985. }, {
  19986. key: "addRelation",
  19987. value: function (name
  19988. /*: string*/
  19989. , targetClass
  19990. /*: string*/
  19991. ) {
  19992. if (!name) {
  19993. throw new Error('field name may not be null.');
  19994. }
  19995. if (!targetClass) {
  19996. throw new Error('You need to set the targetClass of the Relation.');
  19997. }
  19998. this._fields[name] = {
  19999. type: 'Relation',
  20000. targetClass: targetClass
  20001. };
  20002. return this;
  20003. }
  20004. /**
  20005. * Deleting a Field to Update on a Schema
  20006. *
  20007. * @param {string} name Name of the field
  20008. * @returns {Parse.Schema} Returns the schema, so you can chain this call.
  20009. */
  20010. }, {
  20011. key: "deleteField",
  20012. value: function (name
  20013. /*: string*/
  20014. ) {
  20015. this._fields[name] = {
  20016. __op: 'Delete'
  20017. };
  20018. return this;
  20019. }
  20020. /**
  20021. * Deleting an Index to Update on a Schema
  20022. *
  20023. * @param {string} name Name of the field
  20024. * @returns {Parse.Schema} Returns the schema, so you can chain this call.
  20025. */
  20026. }, {
  20027. key: "deleteIndex",
  20028. value: function (name
  20029. /*: string*/
  20030. ) {
  20031. this._indexes[name] = {
  20032. __op: 'Delete'
  20033. };
  20034. return this;
  20035. }
  20036. }], [{
  20037. key: "all",
  20038. value: function () {
  20039. var controller = _CoreManager.default.getSchemaController();
  20040. return controller.get('').then(function (response) {
  20041. if (response.results.length === 0) {
  20042. throw new Error('Schema not found.');
  20043. }
  20044. return response.results;
  20045. });
  20046. }
  20047. }]);
  20048. return ParseSchema;
  20049. }();
  20050. var DefaultController = {
  20051. send: function (className
  20052. /*: string*/
  20053. , method
  20054. /*: string*/
  20055. )
  20056. /*: Promise*/
  20057. {
  20058. var params
  20059. /*: any*/
  20060. = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
  20061. var RESTController = _CoreManager.default.getRESTController();
  20062. return RESTController.request(method, "schemas/".concat(className), params, {
  20063. useMasterKey: true
  20064. });
  20065. },
  20066. get: function (className
  20067. /*: string*/
  20068. )
  20069. /*: Promise*/
  20070. {
  20071. return this.send(className, 'GET');
  20072. },
  20073. create: function (className
  20074. /*: string*/
  20075. , params
  20076. /*: any*/
  20077. )
  20078. /*: Promise*/
  20079. {
  20080. return this.send(className, 'POST', params);
  20081. },
  20082. update: function (className
  20083. /*: string*/
  20084. , params
  20085. /*: any*/
  20086. )
  20087. /*: Promise*/
  20088. {
  20089. return this.send(className, 'PUT', params);
  20090. },
  20091. delete: function (className
  20092. /*: string*/
  20093. )
  20094. /*: Promise*/
  20095. {
  20096. return this.send(className, 'DELETE');
  20097. },
  20098. purge: function (className
  20099. /*: string*/
  20100. )
  20101. /*: Promise*/
  20102. {
  20103. var RESTController = _CoreManager.default.getRESTController();
  20104. return RESTController.request('DELETE', "purge/".concat(className), {}, {
  20105. useMasterKey: true
  20106. });
  20107. }
  20108. };
  20109. _CoreManager.default.setSchemaController(DefaultController);
  20110. var _default = ParseSchema;
  20111. exports.default = _default;
  20112. },{"./CoreManager":5,"./ParseCLP":27,"./ParseObject":36,"@babel/runtime-corejs3/core-js-stable/instance/index-of":88,"@babel/runtime-corejs3/core-js-stable/object/define-property":105,"@babel/runtime-corejs3/helpers/classCallCheck":145,"@babel/runtime-corejs3/helpers/createClass":147,"@babel/runtime-corejs3/helpers/defineProperty":148,"@babel/runtime-corejs3/helpers/interopRequireDefault":152}],43:[function(_dereq_,module,exports){
  20113. "use strict";
  20114. var _Reflect$construct = _dereq_("@babel/runtime-corejs3/core-js-stable/reflect/construct");
  20115. var _Object$defineProperty = _dereq_("@babel/runtime-corejs3/core-js-stable/object/define-property");
  20116. var _interopRequireDefault = _dereq_("@babel/runtime-corejs3/helpers/interopRequireDefault");
  20117. _Object$defineProperty(exports, "__esModule", {
  20118. value: true
  20119. });
  20120. exports.default = void 0;
  20121. var _promise = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/promise"));
  20122. var _typeof2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/helpers/typeof"));
  20123. var _classCallCheck2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/helpers/classCallCheck"));
  20124. var _createClass2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/helpers/createClass"));
  20125. var _inherits2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/helpers/inherits"));
  20126. var _possibleConstructorReturn2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/helpers/possibleConstructorReturn"));
  20127. var _getPrototypeOf2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/helpers/getPrototypeOf"));
  20128. var _CoreManager = _interopRequireDefault(_dereq_("./CoreManager"));
  20129. var _isRevocableSession = _interopRequireDefault(_dereq_("./isRevocableSession"));
  20130. var _ParseObject2 = _interopRequireDefault(_dereq_("./ParseObject"));
  20131. var _ParseUser = _interopRequireDefault(_dereq_("./ParseUser"));
  20132. function _createSuper(Derived) {
  20133. var hasNativeReflectConstruct = _isNativeReflectConstruct();
  20134. return function () {
  20135. var Super = (0, _getPrototypeOf2.default)(Derived),
  20136. result;
  20137. if (hasNativeReflectConstruct) {
  20138. var NewTarget = (0, _getPrototypeOf2.default)(this).constructor;
  20139. result = _Reflect$construct(Super, arguments, NewTarget);
  20140. } else {
  20141. result = Super.apply(this, arguments);
  20142. }
  20143. return (0, _possibleConstructorReturn2.default)(this, result);
  20144. };
  20145. }
  20146. function _isNativeReflectConstruct() {
  20147. if (typeof Reflect === "undefined" || !_Reflect$construct) return false;
  20148. if (_Reflect$construct.sham) return false;
  20149. if (typeof Proxy === "function") return true;
  20150. try {
  20151. Boolean.prototype.valueOf.call(_Reflect$construct(Boolean, [], function () {}));
  20152. return true;
  20153. } catch (e) {
  20154. return false;
  20155. }
  20156. }
  20157. /**
  20158. * <p>A Parse.Session object is a local representation of a revocable session.
  20159. * This class is a subclass of a Parse.Object, and retains the same
  20160. * functionality of a Parse.Object.</p>
  20161. *
  20162. * @alias Parse.Session
  20163. * @augments Parse.Object
  20164. */
  20165. var ParseSession = /*#__PURE__*/function (_ParseObject) {
  20166. (0, _inherits2.default)(ParseSession, _ParseObject);
  20167. var _super = _createSuper(ParseSession);
  20168. /**
  20169. * @param {object} attributes The initial set of data to store in the user.
  20170. */
  20171. function ParseSession(attributes
  20172. /*: ?AttributeMap*/
  20173. ) {
  20174. var _this;
  20175. (0, _classCallCheck2.default)(this, ParseSession);
  20176. _this = _super.call(this, '_Session');
  20177. if (attributes && (0, _typeof2.default)(attributes) === 'object') {
  20178. if (!_this.set(attributes || {})) {
  20179. throw new Error("Can't create an invalid Session");
  20180. }
  20181. }
  20182. return _this;
  20183. }
  20184. /**
  20185. * Returns the session token string.
  20186. *
  20187. * @returns {string}
  20188. */
  20189. (0, _createClass2.default)(ParseSession, [{
  20190. key: "getSessionToken",
  20191. value: function ()
  20192. /*: string*/
  20193. {
  20194. var token = this.get('sessionToken');
  20195. if (typeof token === 'string') {
  20196. return token;
  20197. }
  20198. return '';
  20199. }
  20200. }], [{
  20201. key: "readOnlyAttributes",
  20202. value: function () {
  20203. return ['createdWith', 'expiresAt', 'installationId', 'restricted', 'sessionToken', 'user'];
  20204. }
  20205. /**
  20206. * Retrieves the Session object for the currently logged in session.
  20207. *
  20208. * @param {object} options useMasterKey
  20209. * @static
  20210. * @returns {Promise} A promise that is resolved with the Parse.Session
  20211. * object after it has been fetched. If there is no current user, the
  20212. * promise will be rejected.
  20213. */
  20214. }, {
  20215. key: "current",
  20216. value: function (options
  20217. /*: FullOptions*/
  20218. ) {
  20219. options = options || {};
  20220. var controller = _CoreManager.default.getSessionController();
  20221. var sessionOptions = {};
  20222. if (options.hasOwnProperty('useMasterKey')) {
  20223. sessionOptions.useMasterKey = options.useMasterKey;
  20224. }
  20225. return _ParseUser.default.currentAsync().then(function (user) {
  20226. if (!user) {
  20227. return _promise.default.reject('There is no current user.');
  20228. }
  20229. sessionOptions.sessionToken = user.getSessionToken();
  20230. return controller.getSession(sessionOptions);
  20231. });
  20232. }
  20233. /**
  20234. * Determines whether the current session token is revocable.
  20235. * This method is useful for migrating Express.js or Node.js web apps to
  20236. * use revocable sessions. If you are migrating an app that uses the Parse
  20237. * SDK in the browser only, please use Parse.User.enableRevocableSession()
  20238. * instead, so that sessions can be automatically upgraded.
  20239. *
  20240. * @static
  20241. * @returns {boolean}
  20242. */
  20243. }, {
  20244. key: "isCurrentSessionRevocable",
  20245. value: function ()
  20246. /*: boolean*/
  20247. {
  20248. var currentUser = _ParseUser.default.current();
  20249. if (currentUser) {
  20250. return (0, _isRevocableSession.default)(currentUser.getSessionToken() || '');
  20251. }
  20252. return false;
  20253. }
  20254. }]);
  20255. return ParseSession;
  20256. }(_ParseObject2.default);
  20257. _ParseObject2.default.registerSubclass('_Session', ParseSession);
  20258. var DefaultController = {
  20259. getSession: function (options
  20260. /*: RequestOptions*/
  20261. )
  20262. /*: Promise<ParseSession>*/
  20263. {
  20264. var RESTController = _CoreManager.default.getRESTController();
  20265. var session = new ParseSession();
  20266. return RESTController.request('GET', 'sessions/me', {}, options).then(function (sessionData) {
  20267. session._finishFetch(sessionData);
  20268. session._setExisted(true);
  20269. return session;
  20270. });
  20271. }
  20272. };
  20273. _CoreManager.default.setSessionController(DefaultController);
  20274. var _default = ParseSession;
  20275. exports.default = _default;
  20276. },{"./CoreManager":5,"./ParseObject":36,"./ParseUser":44,"./isRevocableSession":70,"@babel/runtime-corejs3/core-js-stable/object/define-property":105,"@babel/runtime-corejs3/core-js-stable/promise":115,"@babel/runtime-corejs3/core-js-stable/reflect/construct":116,"@babel/runtime-corejs3/helpers/classCallCheck":145,"@babel/runtime-corejs3/helpers/createClass":147,"@babel/runtime-corejs3/helpers/getPrototypeOf":150,"@babel/runtime-corejs3/helpers/inherits":151,"@babel/runtime-corejs3/helpers/interopRequireDefault":152,"@babel/runtime-corejs3/helpers/possibleConstructorReturn":159,"@babel/runtime-corejs3/helpers/typeof":164}],44:[function(_dereq_,module,exports){
  20277. "use strict";
  20278. var _Reflect$construct = _dereq_("@babel/runtime-corejs3/core-js-stable/reflect/construct");
  20279. var _Object$defineProperty2 = _dereq_("@babel/runtime-corejs3/core-js-stable/object/define-property");
  20280. var _interopRequireDefault = _dereq_("@babel/runtime-corejs3/helpers/interopRequireDefault");
  20281. _Object$defineProperty2(exports, "__esModule", {
  20282. value: true
  20283. });
  20284. exports.default = void 0;
  20285. var _regenerator = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/regenerator"));
  20286. var _promise = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/promise"));
  20287. var _defineProperty = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/object/define-property"));
  20288. var _stringify = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/json/stringify"));
  20289. var _asyncToGenerator2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/helpers/asyncToGenerator"));
  20290. var _typeof2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/helpers/typeof"));
  20291. var _classCallCheck2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/helpers/classCallCheck"));
  20292. var _createClass2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/helpers/createClass"));
  20293. var _get2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/helpers/get"));
  20294. var _inherits2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/helpers/inherits"));
  20295. var _possibleConstructorReturn2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/helpers/possibleConstructorReturn"));
  20296. var _getPrototypeOf2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/helpers/getPrototypeOf"));
  20297. var _AnonymousUtils = _interopRequireDefault(_dereq_("./AnonymousUtils"));
  20298. var _CoreManager = _interopRequireDefault(_dereq_("./CoreManager"));
  20299. var _isRevocableSession = _interopRequireDefault(_dereq_("./isRevocableSession"));
  20300. var _ParseError = _interopRequireDefault(_dereq_("./ParseError"));
  20301. var _ParseObject2 = _interopRequireDefault(_dereq_("./ParseObject"));
  20302. var _ParseSession = _interopRequireDefault(_dereq_("./ParseSession"));
  20303. var _MoralisWeb = _interopRequireDefault(_dereq_("./MoralisWeb3"));
  20304. var _Storage = _interopRequireDefault(_dereq_("./Storage"));
  20305. function _createSuper(Derived) {
  20306. var hasNativeReflectConstruct = _isNativeReflectConstruct();
  20307. return function () {
  20308. var Super = (0, _getPrototypeOf2.default)(Derived),
  20309. result;
  20310. if (hasNativeReflectConstruct) {
  20311. var NewTarget = (0, _getPrototypeOf2.default)(this).constructor;
  20312. result = _Reflect$construct(Super, arguments, NewTarget);
  20313. } else {
  20314. result = Super.apply(this, arguments);
  20315. }
  20316. return (0, _possibleConstructorReturn2.default)(this, result);
  20317. };
  20318. }
  20319. function _isNativeReflectConstruct() {
  20320. if (typeof Reflect === "undefined" || !_Reflect$construct) return false;
  20321. if (_Reflect$construct.sham) return false;
  20322. if (typeof Proxy === "function") return true;
  20323. try {
  20324. Boolean.prototype.valueOf.call(_Reflect$construct(Boolean, [], function () {}));
  20325. return true;
  20326. } catch (e) {
  20327. return false;
  20328. }
  20329. }
  20330. var CURRENT_USER_KEY = 'currentUser';
  20331. var canUseCurrentUser = !_CoreManager.default.get('IS_NODE');
  20332. var currentUserCacheMatchesDisk = false;
  20333. var currentUserCache = null;
  20334. var authProviders = {};
  20335. /**
  20336. * <p>A Parse.User object is a local representation of a user persisted to the
  20337. * Parse cloud. This class is a subclass of a Parse.Object, and retains the
  20338. * same functionality of a Parse.Object, but also extends it with various
  20339. * user specific methods, like authentication, signing up, and validation of
  20340. * uniqueness.</p>
  20341. *
  20342. * @alias Parse.User
  20343. * @augments Parse.Object
  20344. */
  20345. var ParseUser = /*#__PURE__*/function (_ParseObject) {
  20346. (0, _inherits2.default)(ParseUser, _ParseObject);
  20347. var _super = _createSuper(ParseUser);
  20348. /**
  20349. * @param {object} attributes The initial set of data to store in the user.
  20350. */
  20351. function ParseUser(attributes
  20352. /*: ?AttributeMap*/
  20353. ) {
  20354. var _this;
  20355. (0, _classCallCheck2.default)(this, ParseUser);
  20356. _this = _super.call(this, '_User');
  20357. if (attributes && (0, _typeof2.default)(attributes) === 'object') {
  20358. if (!_this.set(attributes || {})) {
  20359. throw new Error("Can't create an invalid Parse User");
  20360. }
  20361. }
  20362. return _this;
  20363. }
  20364. /**
  20365. * Request a revocable session token to replace the older style of token.
  20366. *
  20367. * @param {object} options
  20368. * @returns {Promise} A promise that is resolved when the replacement
  20369. * token has been fetched.
  20370. */
  20371. (0, _createClass2.default)(ParseUser, [{
  20372. key: "_upgradeToRevocableSession",
  20373. value: function (options
  20374. /*: RequestOptions*/
  20375. )
  20376. /*: Promise<void>*/
  20377. {
  20378. options = options || {};
  20379. var upgradeOptions = {};
  20380. if (options.hasOwnProperty('useMasterKey')) {
  20381. upgradeOptions.useMasterKey = options.useMasterKey;
  20382. }
  20383. var controller = _CoreManager.default.getUserController();
  20384. return controller.upgradeToRevocableSession(this, upgradeOptions);
  20385. }
  20386. /**
  20387. * Parse allows you to link your users with {@link https://docs.parseplatform.org/parse-server/guide/#oauth-and-3rd-party-authentication 3rd party authentication}, enabling
  20388. * your users to sign up or log into your application using their existing identities.
  20389. * Since 2.9.0
  20390. *
  20391. * @see {@link https://docs.parseplatform.org/js/guide/#linking-users Linking Users}
  20392. * @param {string | AuthProvider} provider Name of auth provider or {@link https://parseplatform.org/Parse-SDK-JS/api/master/AuthProvider.html AuthProvider}
  20393. * @param {object} options
  20394. * <ul>
  20395. * <li>If provider is string, options is {@link http://docs.parseplatform.org/parse-server/guide/#supported-3rd-party-authentications authData}
  20396. * <li>If provider is AuthProvider, options is saveOpts
  20397. * </ul>
  20398. * @param {object} saveOpts useMasterKey / sessionToken
  20399. * @returns {Promise} A promise that is fulfilled with the user is linked
  20400. */
  20401. }, {
  20402. key: "linkWith",
  20403. value: function (provider
  20404. /*: any*/
  20405. , options
  20406. /*: { authData?: AuthData }*/
  20407. )
  20408. /*: Promise<ParseUser>*/
  20409. {
  20410. var _this2 = this;
  20411. var saveOpts
  20412. /*:: ?: FullOptions*/
  20413. = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
  20414. saveOpts.sessionToken = saveOpts.sessionToken || this.getSessionToken() || '';
  20415. var authType;
  20416. if (typeof provider === 'string') {
  20417. authType = provider;
  20418. if (authProviders[provider]) {
  20419. provider = authProviders[provider];
  20420. } else {
  20421. var authProvider = {
  20422. restoreAuthentication: function () {
  20423. return true;
  20424. },
  20425. getAuthType: function () {
  20426. return authType;
  20427. }
  20428. };
  20429. authProviders[authProvider.getAuthType()] = authProvider;
  20430. provider = authProvider;
  20431. }
  20432. } else {
  20433. authType = provider.getAuthType();
  20434. }
  20435. if (options && options.hasOwnProperty('authData')) {
  20436. var authData = this.get('authData') || {};
  20437. if ((0, _typeof2.default)(authData) !== 'object') {
  20438. throw new Error('Invalid type: authData field should be an object');
  20439. }
  20440. authData[authType] = options.authData;
  20441. var controller = _CoreManager.default.getUserController();
  20442. return controller.linkWith(this, authData, saveOpts);
  20443. }
  20444. return new _promise.default(function (resolve, reject) {
  20445. provider.authenticate({
  20446. success: function (provider, result) {
  20447. var opts = {};
  20448. opts.authData = result;
  20449. _this2.linkWith(provider, opts, saveOpts).then(function () {
  20450. resolve(_this2);
  20451. }, function (error) {
  20452. reject(error);
  20453. });
  20454. },
  20455. error: function (provider, _error) {
  20456. reject(_error);
  20457. }
  20458. });
  20459. });
  20460. }
  20461. /**
  20462. * @param provider
  20463. * @param options
  20464. * @param saveOpts
  20465. * @deprecated since 2.9.0 see {@link https://parseplatform.org/Parse-SDK-JS/api/master/Parse.User.html#linkWith linkWith}
  20466. * @returns {Promise}
  20467. */
  20468. }, {
  20469. key: "_linkWith",
  20470. value: function (provider
  20471. /*: any*/
  20472. , options
  20473. /*: { authData?: AuthData }*/
  20474. )
  20475. /*: Promise<ParseUser>*/
  20476. {
  20477. var saveOpts
  20478. /*:: ?: FullOptions*/
  20479. = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
  20480. return this.linkWith(provider, options, saveOpts);
  20481. }
  20482. /**
  20483. * Synchronizes auth data for a provider (e.g. puts the access token in the
  20484. * right place to be used by the Facebook SDK).
  20485. *
  20486. * @param provider
  20487. */
  20488. }, {
  20489. key: "_synchronizeAuthData",
  20490. value: function (provider
  20491. /*: string*/
  20492. ) {
  20493. if (!this.isCurrent() || !provider) {
  20494. return;
  20495. }
  20496. var authType;
  20497. if (typeof provider === 'string') {
  20498. authType = provider;
  20499. provider = authProviders[authType];
  20500. } else {
  20501. authType = provider.getAuthType();
  20502. }
  20503. var authData = this.get('authData');
  20504. if (!provider || !authData || (0, _typeof2.default)(authData) !== 'object') {
  20505. return;
  20506. }
  20507. var success = provider.restoreAuthentication(authData[authType]);
  20508. if (!success) {
  20509. this._unlinkFrom(provider);
  20510. }
  20511. }
  20512. /**
  20513. * Synchronizes authData for all providers.
  20514. */
  20515. }, {
  20516. key: "_synchronizeAllAuthData",
  20517. value: function () {
  20518. var authData = this.get('authData');
  20519. if ((0, _typeof2.default)(authData) !== 'object') {
  20520. return;
  20521. }
  20522. for (var _key in authData) {
  20523. this._synchronizeAuthData(_key);
  20524. }
  20525. }
  20526. /**
  20527. * Removes null values from authData (which exist temporarily for unlinking)
  20528. */
  20529. }, {
  20530. key: "_cleanupAuthData",
  20531. value: function () {
  20532. if (!this.isCurrent()) {
  20533. return;
  20534. }
  20535. var authData = this.get('authData');
  20536. if ((0, _typeof2.default)(authData) !== 'object') {
  20537. return;
  20538. }
  20539. for (var _key2 in authData) {
  20540. if (!authData[_key2]) {
  20541. delete authData[_key2];
  20542. }
  20543. }
  20544. }
  20545. /**
  20546. * Unlinks a user from a service.
  20547. *
  20548. * @param {string | AuthProvider} provider Name of auth provider or {@link https://parseplatform.org/Parse-SDK-JS/api/master/AuthProvider.html AuthProvider}
  20549. * @param {object} options MasterKey / SessionToken
  20550. * @returns {Promise} A promise that is fulfilled when the unlinking
  20551. * finishes.
  20552. */
  20553. }, {
  20554. key: "_unlinkFrom",
  20555. value: function (provider
  20556. /*: any*/
  20557. , options
  20558. /*:: ?: FullOptions*/
  20559. )
  20560. /*: Promise<ParseUser>*/
  20561. {
  20562. var _this3 = this;
  20563. return this.linkWith(provider, {
  20564. authData: null
  20565. }, options).then(function () {
  20566. _this3._synchronizeAuthData(provider);
  20567. return _promise.default.resolve(_this3);
  20568. });
  20569. }
  20570. /**
  20571. * Checks whether a user is linked to a service.
  20572. *
  20573. * @param {object} provider service to link to
  20574. * @returns {boolean} true if link was successful
  20575. */
  20576. }, {
  20577. key: "_isLinked",
  20578. value: function (provider
  20579. /*: any*/
  20580. )
  20581. /*: boolean*/
  20582. {
  20583. var authType;
  20584. if (typeof provider === 'string') {
  20585. authType = provider;
  20586. } else {
  20587. authType = provider.getAuthType();
  20588. }
  20589. var authData = this.get('authData') || {};
  20590. if ((0, _typeof2.default)(authData) !== 'object') {
  20591. return false;
  20592. }
  20593. return !!authData[authType];
  20594. }
  20595. /**
  20596. * Deauthenticates all providers.
  20597. */
  20598. }, {
  20599. key: "_logOutWithAll",
  20600. value: function () {
  20601. var authData = this.get('authData');
  20602. if ((0, _typeof2.default)(authData) !== 'object') {
  20603. return;
  20604. }
  20605. for (var _key3 in authData) {
  20606. this._logOutWith(_key3);
  20607. }
  20608. }
  20609. /**
  20610. * Deauthenticates a single provider (e.g. removing access tokens from the
  20611. * Facebook SDK).
  20612. *
  20613. * @param {object} provider service to logout of
  20614. */
  20615. }, {
  20616. key: "_logOutWith",
  20617. value: function (provider
  20618. /*: any*/
  20619. ) {
  20620. if (!this.isCurrent()) {
  20621. return;
  20622. }
  20623. if (typeof provider === 'string') {
  20624. provider = authProviders[provider];
  20625. }
  20626. if (provider && provider.deauthenticate) {
  20627. provider.deauthenticate();
  20628. }
  20629. }
  20630. /**
  20631. * Class instance method used to maintain specific keys when a fetch occurs.
  20632. * Used to ensure that the session token is not lost.
  20633. *
  20634. * @returns {object} sessionToken
  20635. */
  20636. }, {
  20637. key: "_preserveFieldsOnFetch",
  20638. value: function ()
  20639. /*: AttributeMap*/
  20640. {
  20641. return {
  20642. sessionToken: this.get('sessionToken')
  20643. };
  20644. }
  20645. /**
  20646. * Returns true if <code>current</code> would return this user.
  20647. *
  20648. * @returns {boolean} true if user is cached on disk
  20649. */
  20650. }, {
  20651. key: "isCurrent",
  20652. value: function ()
  20653. /*: boolean*/
  20654. {
  20655. var current = ParseUser.current();
  20656. return !!current && current.id === this.id;
  20657. }
  20658. /**
  20659. * Returns get("username").
  20660. *
  20661. * @returns {string}
  20662. */
  20663. }, {
  20664. key: "getUsername",
  20665. value: function ()
  20666. /*: ?string*/
  20667. {
  20668. var username = this.get('username');
  20669. if (username == null || typeof username === 'string') {
  20670. return username;
  20671. }
  20672. return '';
  20673. }
  20674. /**
  20675. * Calls set("username", username, options) and returns the result.
  20676. *
  20677. * @param {string} username
  20678. */
  20679. }, {
  20680. key: "setUsername",
  20681. value: function (username
  20682. /*: string*/
  20683. ) {
  20684. // Strip anonymity, even we do not support anonymous user in js SDK, we may
  20685. // encounter anonymous user created by android/iOS in cloud code.
  20686. var authData = this.get('authData');
  20687. if (authData && (0, _typeof2.default)(authData) === 'object' && authData.hasOwnProperty('anonymous')) {
  20688. // We need to set anonymous to null instead of deleting it in order to remove it from Parse.
  20689. authData.anonymous = null;
  20690. }
  20691. this.set('username', username);
  20692. }
  20693. /**
  20694. * Calls set("password", password, options) and returns the result.
  20695. *
  20696. * @param {string} password User's Password
  20697. */
  20698. }, {
  20699. key: "setPassword",
  20700. value: function (password
  20701. /*: string*/
  20702. ) {
  20703. this.set('password', password);
  20704. }
  20705. /**
  20706. * Returns get("email").
  20707. *
  20708. * @returns {string} User's Email
  20709. */
  20710. }, {
  20711. key: "getEmail",
  20712. value: function ()
  20713. /*: ?string*/
  20714. {
  20715. var email = this.get('email');
  20716. if (email == null || typeof email === 'string') {
  20717. return email;
  20718. }
  20719. return '';
  20720. }
  20721. /**
  20722. * Calls set("email", email) and returns the result.
  20723. *
  20724. * @param {string} email
  20725. * @returns {boolean}
  20726. */
  20727. }, {
  20728. key: "setEmail",
  20729. value: function (email
  20730. /*: string*/
  20731. ) {
  20732. return this.set('email', email);
  20733. }
  20734. /**
  20735. * Returns the session token for this user, if the user has been logged in,
  20736. * or if it is the result of a query with the master key. Otherwise, returns
  20737. * undefined.
  20738. *
  20739. * @returns {string} the session token, or undefined
  20740. */
  20741. }, {
  20742. key: "getSessionToken",
  20743. value: function ()
  20744. /*: ?string*/
  20745. {
  20746. var token = this.get('sessionToken');
  20747. if (token == null || typeof token === 'string') {
  20748. return token;
  20749. }
  20750. return '';
  20751. }
  20752. /**
  20753. * Checks whether this user is the current user and has been authenticated.
  20754. *
  20755. * @returns {boolean} whether this user is the current user and is logged in.
  20756. */
  20757. }, {
  20758. key: "authenticated",
  20759. value: function ()
  20760. /*: boolean*/
  20761. {
  20762. var current = ParseUser.current();
  20763. return !!this.get('sessionToken') && !!current && current.id === this.id;
  20764. }
  20765. /**
  20766. * Signs up a new user. You should call this instead of save for
  20767. * new Parse.Users. This will create a new Parse.User on the server, and
  20768. * also persist the session on disk so that you can access the user using
  20769. * <code>current</code>.
  20770. *
  20771. * <p>A username and password must be set before calling signUp.</p>
  20772. *
  20773. * @param {object} attrs Extra fields to set on the new user, or null.
  20774. * @param {object} options
  20775. * @returns {Promise} A promise that is fulfilled when the signup
  20776. * finishes.
  20777. */
  20778. }, {
  20779. key: "signUp",
  20780. value: function (attrs
  20781. /*: AttributeMap*/
  20782. , options
  20783. /*:: ?: FullOptions*/
  20784. )
  20785. /*: Promise<ParseUser>*/
  20786. {
  20787. options = options || {};
  20788. var signupOptions = {};
  20789. if (options.hasOwnProperty('useMasterKey')) {
  20790. signupOptions.useMasterKey = options.useMasterKey;
  20791. }
  20792. if (options.hasOwnProperty('installationId')) {
  20793. signupOptions.installationId = options.installationId;
  20794. }
  20795. var controller = _CoreManager.default.getUserController();
  20796. return controller.signUp(this, attrs, signupOptions);
  20797. }
  20798. /**
  20799. * Logs in a Parse.User. On success, this saves the session to disk,
  20800. * so you can retrieve the currently logged in user using
  20801. * <code>current</code>.
  20802. *
  20803. * <p>A username and password must be set before calling logIn.</p>
  20804. *
  20805. * @param {object} options
  20806. * @returns {Promise} A promise that is fulfilled with the user when
  20807. * the login is complete.
  20808. */
  20809. }, {
  20810. key: "logIn",
  20811. value: function (options
  20812. /*:: ?: FullOptions*/
  20813. )
  20814. /*: Promise<ParseUser>*/
  20815. {
  20816. options = options || {};
  20817. var loginOptions = {
  20818. usePost: true
  20819. };
  20820. if (options.hasOwnProperty('useMasterKey')) {
  20821. loginOptions.useMasterKey = options.useMasterKey;
  20822. }
  20823. if (options.hasOwnProperty('installationId')) {
  20824. loginOptions.installationId = options.installationId;
  20825. }
  20826. if (options.hasOwnProperty('usePost')) {
  20827. loginOptions.usePost = options.usePost;
  20828. }
  20829. var controller = _CoreManager.default.getUserController();
  20830. return controller.logIn(this, loginOptions);
  20831. }
  20832. /**
  20833. * Wrap the default save behavior with functionality to save to local
  20834. * storage if this is current user.
  20835. *
  20836. * @param {...any} args
  20837. * @returns {Promise}
  20838. */
  20839. }, {
  20840. key: "save",
  20841. value: function ()
  20842. /*: Promise<ParseUser>*/
  20843. {
  20844. var _this4 = this;
  20845. for (var _len = arguments.length, args = new Array(_len), _key4 = 0; _key4 < _len; _key4++) {
  20846. args[_key4] = arguments[_key4];
  20847. }
  20848. return (0, _get2.default)((0, _getPrototypeOf2.default)(ParseUser.prototype), "save", this).apply(this, args).then(function () {
  20849. if (_this4.isCurrent()) {
  20850. return _CoreManager.default.getUserController().updateUserOnDisk(_this4);
  20851. }
  20852. return _this4;
  20853. });
  20854. }
  20855. /**
  20856. * Wrap the default destroy behavior with functionality that logs out
  20857. * the current user when it is destroyed
  20858. *
  20859. * @param {...any} args
  20860. * @returns {Parse.User}
  20861. */
  20862. }, {
  20863. key: "destroy",
  20864. value: function ()
  20865. /*: Promise<ParseUser>*/
  20866. {
  20867. var _this5 = this;
  20868. for (var _len2 = arguments.length, args = new Array(_len2), _key5 = 0; _key5 < _len2; _key5++) {
  20869. args[_key5] = arguments[_key5];
  20870. }
  20871. return (0, _get2.default)((0, _getPrototypeOf2.default)(ParseUser.prototype), "destroy", this).apply(this, args).then(function () {
  20872. if (_this5.isCurrent()) {
  20873. return _CoreManager.default.getUserController().removeUserFromDisk();
  20874. }
  20875. return _this5;
  20876. });
  20877. }
  20878. /**
  20879. * Wrap the default fetch behavior with functionality to save to local
  20880. * storage if this is current user.
  20881. *
  20882. * @param {...any} args
  20883. * @returns {Parse.User}
  20884. */
  20885. }, {
  20886. key: "fetch",
  20887. value: function ()
  20888. /*: Promise<ParseUser>*/
  20889. {
  20890. var _this6 = this;
  20891. for (var _len3 = arguments.length, args = new Array(_len3), _key6 = 0; _key6 < _len3; _key6++) {
  20892. args[_key6] = arguments[_key6];
  20893. }
  20894. return (0, _get2.default)((0, _getPrototypeOf2.default)(ParseUser.prototype), "fetch", this).apply(this, args).then(function () {
  20895. if (_this6.isCurrent()) {
  20896. return _CoreManager.default.getUserController().updateUserOnDisk(_this6);
  20897. }
  20898. return _this6;
  20899. });
  20900. }
  20901. /**
  20902. * Wrap the default fetchWithInclude behavior with functionality to save to local
  20903. * storage if this is current user.
  20904. *
  20905. * @param {...any} args
  20906. * @returns {Parse.User}
  20907. */
  20908. }, {
  20909. key: "fetchWithInclude",
  20910. value: function ()
  20911. /*: Promise<ParseUser>*/
  20912. {
  20913. var _this7 = this;
  20914. for (var _len4 = arguments.length, args = new Array(_len4), _key7 = 0; _key7 < _len4; _key7++) {
  20915. args[_key7] = arguments[_key7];
  20916. }
  20917. return (0, _get2.default)((0, _getPrototypeOf2.default)(ParseUser.prototype), "fetchWithInclude", this).apply(this, args).then(function () {
  20918. if (_this7.isCurrent()) {
  20919. return _CoreManager.default.getUserController().updateUserOnDisk(_this7);
  20920. }
  20921. return _this7;
  20922. });
  20923. }
  20924. /**
  20925. * Verify whether a given password is the password of the current user.
  20926. *
  20927. * @param {string} password A password to be verified
  20928. * @param {object} options
  20929. * @returns {Promise} A promise that is fulfilled with a user
  20930. * when the password is correct.
  20931. */
  20932. }, {
  20933. key: "verifyPassword",
  20934. value: function (password
  20935. /*: string*/
  20936. , options
  20937. /*:: ?: RequestOptions*/
  20938. )
  20939. /*: Promise<ParseUser>*/
  20940. {
  20941. var username = this.getUsername() || '';
  20942. return ParseUser.verifyPassword(username, password, options);
  20943. }
  20944. }], [{
  20945. key: "readOnlyAttributes",
  20946. value: function () {
  20947. return ['sessionToken'];
  20948. }
  20949. /**
  20950. * Adds functionality to the existing Parse.User class.
  20951. *
  20952. * @param {object} protoProps A set of properties to add to the prototype
  20953. * @param {object} classProps A set of static properties to add to the class
  20954. * @static
  20955. * @returns {Parse.User} The newly extended Parse.User class
  20956. */
  20957. }, {
  20958. key: "extend",
  20959. value: function (protoProps
  20960. /*: { [prop: string]: any }*/
  20961. , classProps
  20962. /*: { [prop: string]: any }*/
  20963. ) {
  20964. if (protoProps) {
  20965. for (var _prop in protoProps) {
  20966. if (_prop !== 'className') {
  20967. (0, _defineProperty.default)(ParseUser.prototype, _prop, {
  20968. value: protoProps[_prop],
  20969. enumerable: false,
  20970. writable: true,
  20971. configurable: true
  20972. });
  20973. }
  20974. }
  20975. }
  20976. if (classProps) {
  20977. for (var _prop2 in classProps) {
  20978. if (_prop2 !== 'className') {
  20979. (0, _defineProperty.default)(ParseUser, _prop2, {
  20980. value: classProps[_prop2],
  20981. enumerable: false,
  20982. writable: true,
  20983. configurable: true
  20984. });
  20985. }
  20986. }
  20987. }
  20988. return ParseUser;
  20989. }
  20990. /**
  20991. * Retrieves the currently logged in ParseUser with a valid session,
  20992. * either from memory or localStorage, if necessary.
  20993. *
  20994. * @static
  20995. * @returns {Parse.Object} The currently logged in Parse.User.
  20996. */
  20997. }, {
  20998. key: "current",
  20999. value: function ()
  21000. /*: ?ParseUser*/
  21001. {
  21002. if (!canUseCurrentUser) {
  21003. return null;
  21004. }
  21005. var controller = _CoreManager.default.getUserController();
  21006. return controller.currentUser();
  21007. }
  21008. /**
  21009. * Retrieves the currently logged in ParseUser from asynchronous Storage.
  21010. *
  21011. * @static
  21012. * @returns {Promise} A Promise that is resolved with the currently
  21013. * logged in Parse User
  21014. */
  21015. }, {
  21016. key: "currentAsync",
  21017. value: function ()
  21018. /*: Promise<?ParseUser>*/
  21019. {
  21020. if (!canUseCurrentUser) {
  21021. return _promise.default.resolve(null);
  21022. }
  21023. var controller = _CoreManager.default.getUserController();
  21024. return controller.currentUserAsync();
  21025. }
  21026. /**
  21027. * Signs up a new user with a username (or email) and password.
  21028. * This will create a new Parse.User on the server, and also persist the
  21029. * session in localStorage so that you can access the user using
  21030. * {@link #current}.
  21031. *
  21032. * @param {string} username The username (or email) to sign up with.
  21033. * @param {string} password The password to sign up with.
  21034. * @param {object} attrs Extra fields to set on the new user.
  21035. * @param {object} options
  21036. * @static
  21037. * @returns {Promise} A promise that is fulfilled with the user when
  21038. * the signup completes.
  21039. */
  21040. }, {
  21041. key: "signUp",
  21042. value: function (username
  21043. /*: string*/
  21044. , password
  21045. /*: string*/
  21046. , attrs
  21047. /*: AttributeMap*/
  21048. , options
  21049. /*:: ?: FullOptions*/
  21050. ) {
  21051. attrs = attrs || {};
  21052. attrs.username = username;
  21053. attrs.password = password;
  21054. var user = new this(attrs);
  21055. return user.signUp({}, options);
  21056. }
  21057. /**
  21058. * Logs in a user with a username (or email) and password. On success, this
  21059. * saves the session to disk, so you can retrieve the currently logged in
  21060. * user using <code>current</code>.
  21061. *
  21062. * @param {string} username The username (or email) to log in with.
  21063. * @param {string} password The password to log in with.
  21064. * @param {object} options
  21065. * @static
  21066. * @returns {Promise} A promise that is fulfilled with the user when
  21067. * the login completes.
  21068. */
  21069. }, {
  21070. key: "logIn",
  21071. value: function (username
  21072. /*: string*/
  21073. , password
  21074. /*: string*/
  21075. , options
  21076. /*:: ?: FullOptions*/
  21077. ) {
  21078. if (typeof username !== 'string') {
  21079. return _promise.default.reject(new _ParseError.default(_ParseError.default.OTHER_CAUSE, 'Username must be a string.'));
  21080. }
  21081. if (typeof password !== 'string') {
  21082. return _promise.default.reject(new _ParseError.default(_ParseError.default.OTHER_CAUSE, 'Password must be a string.'));
  21083. }
  21084. var user = new this();
  21085. user._finishFetch({
  21086. username: username,
  21087. password: password
  21088. });
  21089. return user.logIn(options);
  21090. }
  21091. }, {
  21092. key: "loginOrSignup",
  21093. value: function (username
  21094. /*: string*/
  21095. , password
  21096. /*: string*/
  21097. ) {
  21098. var _this8 = this;
  21099. return this.logIn(username, password).catch(function (err) {
  21100. if (err.code === 101) {
  21101. var newUser = new _this8();
  21102. newUser.set('username', username);
  21103. newUser.set('password', password);
  21104. return newUser.signUp();
  21105. }
  21106. throw err;
  21107. });
  21108. }
  21109. /**
  21110. * Logs in a user with a session token. On success, this saves the session
  21111. * to disk, so you can retrieve the currently logged in user using
  21112. * <code>current</code>.
  21113. *
  21114. * @param {string} sessionToken The sessionToken to log in with.
  21115. * @param {object} options
  21116. * @static
  21117. * @returns {Promise} A promise that is fulfilled with the user when
  21118. * the login completes.
  21119. */
  21120. }, {
  21121. key: "become",
  21122. value: function (sessionToken
  21123. /*: string*/
  21124. , options
  21125. /*:: ?: RequestOptions*/
  21126. ) {
  21127. if (!canUseCurrentUser) {
  21128. throw new Error('It is not memory-safe to become a user in a server environment');
  21129. }
  21130. options = options || {};
  21131. var becomeOptions
  21132. /*: RequestOptions*/
  21133. = {
  21134. sessionToken: sessionToken
  21135. };
  21136. if (options.hasOwnProperty('useMasterKey')) {
  21137. becomeOptions.useMasterKey = options.useMasterKey;
  21138. }
  21139. var controller = _CoreManager.default.getUserController();
  21140. var user = new this();
  21141. return controller.become(user, becomeOptions);
  21142. }
  21143. /**
  21144. * Retrieves a user with a session token.
  21145. *
  21146. * @param {string} sessionToken The sessionToken to get user with.
  21147. * @param {object} options
  21148. * @static
  21149. * @returns {Promise} A promise that is fulfilled with the user is fetched.
  21150. */
  21151. }, {
  21152. key: "me",
  21153. value: function (sessionToken
  21154. /*: string*/
  21155. ) {
  21156. var options
  21157. /*:: ?: RequestOptions*/
  21158. = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
  21159. var controller = _CoreManager.default.getUserController();
  21160. var meOptions
  21161. /*: RequestOptions*/
  21162. = {
  21163. sessionToken: sessionToken
  21164. };
  21165. if (options.useMasterKey) {
  21166. meOptions.useMasterKey = options.useMasterKey;
  21167. }
  21168. var user = new this();
  21169. return controller.me(user, meOptions);
  21170. }
  21171. /**
  21172. * Logs in a user with a session token. On success, this saves the session
  21173. * to disk, so you can retrieve the currently logged in user using
  21174. * <code>current</code>. If there is no session token the user will not logged in.
  21175. *
  21176. * @param {object} userJSON The JSON map of the User's data
  21177. * @static
  21178. * @returns {Promise} A promise that is fulfilled with the user when
  21179. * the login completes.
  21180. */
  21181. }, {
  21182. key: "hydrate",
  21183. value: function (userJSON
  21184. /*: AttributeMap*/
  21185. ) {
  21186. var controller = _CoreManager.default.getUserController();
  21187. var user = new this();
  21188. return controller.hydrate(user, userJSON);
  21189. }
  21190. /**
  21191. * Static version of {@link https://parseplatform.org/Parse-SDK-JS/api/master/Parse.User.html#linkWith linkWith}
  21192. *
  21193. * @param provider
  21194. * @param options
  21195. * @param saveOpts
  21196. * @static
  21197. * @returns {Promise}
  21198. */
  21199. }, {
  21200. key: "logInWith",
  21201. value: function (provider
  21202. /*: any*/
  21203. , options
  21204. /*: { authData?: AuthData }*/
  21205. , saveOpts
  21206. /*:: ?: FullOptions*/
  21207. )
  21208. /*: Promise<ParseUser>*/
  21209. {
  21210. var user = new this();
  21211. return user.linkWith(provider, options, saveOpts);
  21212. }
  21213. /**
  21214. * Logs out the currently logged in user session. This will remove the
  21215. * session from disk, log out of linked services, and future calls to
  21216. * <code>current</code> will return <code>null</code>.
  21217. *
  21218. * @param {object} options
  21219. * @static
  21220. * @returns {Promise} A promise that is resolved when the session is
  21221. * destroyed on the server.
  21222. */
  21223. }, {
  21224. key: "logOut",
  21225. value: function () {
  21226. var options
  21227. /*: RequestOptions*/
  21228. = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
  21229. var controller = _CoreManager.default.getUserController();
  21230. return controller.logOut(options);
  21231. }
  21232. /**
  21233. * Requests a password reset email to be sent to the specified email address
  21234. * associated with the user account. This email allows the user to securely
  21235. * reset their password on the Parse site.
  21236. *
  21237. * @param {string} email The email address associated with the user that
  21238. * forgot their password.
  21239. * @param {object} options
  21240. * @static
  21241. * @returns {Promise}
  21242. */
  21243. }, {
  21244. key: "requestPasswordReset",
  21245. value: function (email
  21246. /*: string*/
  21247. , options
  21248. /*:: ?: RequestOptions*/
  21249. ) {
  21250. options = options || {};
  21251. var requestOptions = {};
  21252. if (options.hasOwnProperty('useMasterKey')) {
  21253. requestOptions.useMasterKey = options.useMasterKey;
  21254. }
  21255. var controller = _CoreManager.default.getUserController();
  21256. return controller.requestPasswordReset(email, requestOptions);
  21257. }
  21258. /**
  21259. * Request an email verification.
  21260. *
  21261. * @param {string} email The email address associated with the user that
  21262. * forgot their password.
  21263. * @param {object} options
  21264. * @static
  21265. * @returns {Promise}
  21266. */
  21267. }, {
  21268. key: "requestEmailVerification",
  21269. value: function (email
  21270. /*: string*/
  21271. , options
  21272. /*:: ?: RequestOptions*/
  21273. ) {
  21274. options = options || {};
  21275. var requestOptions = {};
  21276. if (options.hasOwnProperty('useMasterKey')) {
  21277. requestOptions.useMasterKey = options.useMasterKey;
  21278. }
  21279. var controller = _CoreManager.default.getUserController();
  21280. return controller.requestEmailVerification(email, requestOptions);
  21281. }
  21282. /**
  21283. * Verify whether a given password is the password of the current user.
  21284. *
  21285. * @param {string} username A username to be used for identificaiton
  21286. * @param {string} password A password to be verified
  21287. * @param {object} options
  21288. * @static
  21289. * @returns {Promise} A promise that is fulfilled with a user
  21290. * when the password is correct.
  21291. */
  21292. }, {
  21293. key: "verifyPassword",
  21294. value: function (username
  21295. /*: string*/
  21296. , password
  21297. /*: string*/
  21298. , options
  21299. /*:: ?: RequestOptions*/
  21300. ) {
  21301. if (typeof username !== 'string') {
  21302. return _promise.default.reject(new _ParseError.default(_ParseError.default.OTHER_CAUSE, 'Username must be a string.'));
  21303. }
  21304. if (typeof password !== 'string') {
  21305. return _promise.default.reject(new _ParseError.default(_ParseError.default.OTHER_CAUSE, 'Password must be a string.'));
  21306. }
  21307. options = options || {};
  21308. var verificationOption = {};
  21309. if (options.hasOwnProperty('useMasterKey')) {
  21310. verificationOption.useMasterKey = options.useMasterKey;
  21311. }
  21312. var controller = _CoreManager.default.getUserController();
  21313. return controller.verifyPassword(username, password, verificationOption);
  21314. }
  21315. /**
  21316. * Allow someone to define a custom User class without className
  21317. * being rewritten to _User. The default behavior is to rewrite
  21318. * User to _User for legacy reasons. This allows developers to
  21319. * override that behavior.
  21320. *
  21321. * @param {boolean} isAllowed Whether or not to allow custom User class
  21322. * @static
  21323. */
  21324. }, {
  21325. key: "allowCustomUserClass",
  21326. value: function (isAllowed
  21327. /*: boolean*/
  21328. ) {
  21329. _CoreManager.default.set('PERFORM_USER_REWRITE', !isAllowed);
  21330. }
  21331. /**
  21332. * Allows a legacy application to start using revocable sessions. If the
  21333. * current session token is not revocable, a request will be made for a new,
  21334. * revocable session.
  21335. * It is not necessary to call this method from cloud code unless you are
  21336. * handling user signup or login from the server side. In a cloud code call,
  21337. * this function will not attempt to upgrade the current token.
  21338. *
  21339. * @param {object} options
  21340. * @static
  21341. * @returns {Promise} A promise that is resolved when the process has
  21342. * completed. If a replacement session token is requested, the promise
  21343. * will be resolved after a new token has been fetched.
  21344. */
  21345. }, {
  21346. key: "enableRevocableSession",
  21347. value: function (options
  21348. /*:: ?: RequestOptions*/
  21349. ) {
  21350. options = options || {};
  21351. _CoreManager.default.set('FORCE_REVOCABLE_SESSION', true);
  21352. if (canUseCurrentUser) {
  21353. var current = ParseUser.current();
  21354. if (current) {
  21355. return current._upgradeToRevocableSession(options);
  21356. }
  21357. }
  21358. return _promise.default.resolve();
  21359. }
  21360. /**
  21361. * Enables the use of become or the current user in a server
  21362. * environment. These features are disabled by default, since they depend on
  21363. * global objects that are not memory-safe for most servers.
  21364. *
  21365. * @static
  21366. */
  21367. }, {
  21368. key: "enableUnsafeCurrentUser",
  21369. value: function () {
  21370. canUseCurrentUser = true;
  21371. }
  21372. /**
  21373. * Disables the use of become or the current user in any environment.
  21374. * These features are disabled on servers by default, since they depend on
  21375. * global objects that are not memory-safe for most servers.
  21376. *
  21377. * @static
  21378. */
  21379. }, {
  21380. key: "disableUnsafeCurrentUser",
  21381. value: function () {
  21382. canUseCurrentUser = false;
  21383. }
  21384. /**
  21385. * When registering users with {@link https://parseplatform.org/Parse-SDK-JS/api/master/Parse.User.html#linkWith linkWith} a basic auth provider
  21386. * is automatically created for you.
  21387. *
  21388. * For advanced authentication, you can register an Auth provider to
  21389. * implement custom authentication, deauthentication.
  21390. *
  21391. * @param provider
  21392. * @see {@link https://parseplatform.org/Parse-SDK-JS/api/master/AuthProvider.html AuthProvider}
  21393. * @see {@link https://docs.parseplatform.org/js/guide/#custom-authentication-module Custom Authentication Module}
  21394. * @static
  21395. */
  21396. }, {
  21397. key: "_registerAuthenticationProvider",
  21398. value: function (provider
  21399. /*: any*/
  21400. ) {
  21401. authProviders[provider.getAuthType()] = provider; // Synchronize the current user with the auth provider.
  21402. ParseUser.currentAsync().then(function (current) {
  21403. if (current) {
  21404. current._synchronizeAuthData(provider.getAuthType());
  21405. }
  21406. });
  21407. }
  21408. /**
  21409. * @param provider
  21410. * @param options
  21411. * @param saveOpts
  21412. * @deprecated since 2.9.0 see {@link https://parseplatform.org/Parse-SDK-JS/api/master/Parse.User.html#logInWith logInWith}
  21413. * @static
  21414. * @returns {Promise}
  21415. */
  21416. }, {
  21417. key: "_logInWith",
  21418. value: function (provider
  21419. /*: any*/
  21420. , options
  21421. /*: { authData?: AuthData }*/
  21422. , saveOpts
  21423. /*:: ?: FullOptions*/
  21424. ) {
  21425. var user = new this();
  21426. return user.linkWith(provider, options, saveOpts);
  21427. }
  21428. }, {
  21429. key: "_clearCache",
  21430. value: function () {
  21431. currentUserCache = null;
  21432. currentUserCacheMatchesDisk = false;
  21433. }
  21434. }, {
  21435. key: "_setCurrentUserCache",
  21436. value: function (user
  21437. /*: ParseUser*/
  21438. ) {
  21439. currentUserCache = user;
  21440. }
  21441. }]);
  21442. return ParseUser;
  21443. }(_ParseObject2.default);
  21444. _ParseObject2.default.registerSubclass('_User', ParseUser);
  21445. var DefaultController = {
  21446. updateUserOnDisk: function (user) {
  21447. var path = _Storage.default.generatePath(CURRENT_USER_KEY);
  21448. var json = user.toJSON();
  21449. delete json.password;
  21450. json.className = '_User';
  21451. var userData = (0, _stringify.default)(json);
  21452. if (_CoreManager.default.get('ENCRYPTED_USER')) {
  21453. var crypto = _CoreManager.default.getCryptoController();
  21454. userData = crypto.encrypt(json, _CoreManager.default.get('ENCRYPTED_KEY'));
  21455. }
  21456. return _Storage.default.setItemAsync(path, userData).then(function () {
  21457. return user;
  21458. });
  21459. },
  21460. removeUserFromDisk: function () {
  21461. var path = _Storage.default.generatePath(CURRENT_USER_KEY);
  21462. currentUserCacheMatchesDisk = true;
  21463. currentUserCache = null;
  21464. return _Storage.default.removeItemAsync(path);
  21465. },
  21466. setCurrentUser: function (user) {
  21467. var _this9 = this;
  21468. return (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee() {
  21469. var currentUser;
  21470. return _regenerator.default.wrap(function (_context) {
  21471. while (1) {
  21472. switch (_context.prev = _context.next) {
  21473. case 0:
  21474. _context.next = 2;
  21475. return _this9.currentUserAsync();
  21476. case 2:
  21477. currentUser = _context.sent;
  21478. if (!(currentUser && !user.equals(currentUser) && _AnonymousUtils.default.isLinked(currentUser))) {
  21479. _context.next = 6;
  21480. break;
  21481. }
  21482. _context.next = 6;
  21483. return currentUser.destroy({
  21484. sessionToken: currentUser.getSessionToken()
  21485. });
  21486. case 6:
  21487. currentUserCache = user;
  21488. user._cleanupAuthData();
  21489. user._synchronizeAllAuthData();
  21490. return _context.abrupt("return", DefaultController.updateUserOnDisk(user));
  21491. case 10:
  21492. case "end":
  21493. return _context.stop();
  21494. }
  21495. }
  21496. }, _callee);
  21497. }))();
  21498. },
  21499. currentUser: function ()
  21500. /*: ?ParseUser*/
  21501. {
  21502. if (currentUserCache) {
  21503. return currentUserCache;
  21504. }
  21505. if (currentUserCacheMatchesDisk) {
  21506. return null;
  21507. }
  21508. if (_Storage.default.async()) {
  21509. throw new Error('Cannot call currentUser() when using a platform with an async ' + 'storage system. Call currentUserAsync() instead.');
  21510. }
  21511. var path = _Storage.default.generatePath(CURRENT_USER_KEY);
  21512. var userData = _Storage.default.getItem(path);
  21513. currentUserCacheMatchesDisk = true;
  21514. if (!userData) {
  21515. currentUserCache = null;
  21516. return null;
  21517. }
  21518. if (_CoreManager.default.get('ENCRYPTED_USER')) {
  21519. var crypto = _CoreManager.default.getCryptoController();
  21520. userData = crypto.decrypt(userData, _CoreManager.default.get('ENCRYPTED_KEY'));
  21521. }
  21522. userData = JSON.parse(userData);
  21523. if (!userData.className) {
  21524. userData.className = '_User';
  21525. }
  21526. if (userData._id) {
  21527. if (userData.objectId !== userData._id) {
  21528. userData.objectId = userData._id;
  21529. }
  21530. delete userData._id;
  21531. }
  21532. if (userData._sessionToken) {
  21533. userData.sessionToken = userData._sessionToken;
  21534. delete userData._sessionToken;
  21535. }
  21536. var current = _ParseObject2.default.fromJSON(userData);
  21537. currentUserCache = current;
  21538. current._synchronizeAllAuthData();
  21539. return current;
  21540. },
  21541. currentUserAsync: function ()
  21542. /*: Promise<?ParseUser>*/
  21543. {
  21544. if (currentUserCache) {
  21545. return _promise.default.resolve(currentUserCache);
  21546. }
  21547. if (currentUserCacheMatchesDisk) {
  21548. return _promise.default.resolve(null);
  21549. }
  21550. var path = _Storage.default.generatePath(CURRENT_USER_KEY);
  21551. return _Storage.default.getItemAsync(path).then(function (userData) {
  21552. currentUserCacheMatchesDisk = true;
  21553. if (!userData) {
  21554. currentUserCache = null;
  21555. return _promise.default.resolve(null);
  21556. }
  21557. if (_CoreManager.default.get('ENCRYPTED_USER')) {
  21558. var crypto = _CoreManager.default.getCryptoController();
  21559. userData = crypto.decrypt(userData.toString(), _CoreManager.default.get('ENCRYPTED_KEY'));
  21560. }
  21561. userData = JSON.parse(userData);
  21562. if (!userData.className) {
  21563. userData.className = '_User';
  21564. }
  21565. if (userData._id) {
  21566. if (userData.objectId !== userData._id) {
  21567. userData.objectId = userData._id;
  21568. }
  21569. delete userData._id;
  21570. }
  21571. if (userData._sessionToken) {
  21572. userData.sessionToken = userData._sessionToken;
  21573. delete userData._sessionToken;
  21574. }
  21575. var current = _ParseObject2.default.fromJSON(userData);
  21576. currentUserCache = current;
  21577. current._synchronizeAllAuthData();
  21578. return _promise.default.resolve(current);
  21579. });
  21580. },
  21581. signUp: function (user
  21582. /*: ParseUser*/
  21583. , attrs
  21584. /*: AttributeMap*/
  21585. , options
  21586. /*: RequestOptions*/
  21587. )
  21588. /*: Promise<ParseUser>*/
  21589. {
  21590. var username = attrs && attrs.username || user.get('username');
  21591. var password = attrs && attrs.password || user.get('password');
  21592. if (!username || !username.length) {
  21593. return _promise.default.reject(new _ParseError.default(_ParseError.default.OTHER_CAUSE, 'Cannot sign up user with an empty username.'));
  21594. }
  21595. if (!password || !password.length) {
  21596. return _promise.default.reject(new _ParseError.default(_ParseError.default.OTHER_CAUSE, 'Cannot sign up user with an empty password.'));
  21597. }
  21598. return user.save(attrs, options).then(function () {
  21599. // Clear the password field
  21600. user._finishFetch({
  21601. password: undefined
  21602. });
  21603. if (canUseCurrentUser) {
  21604. return DefaultController.setCurrentUser(user);
  21605. }
  21606. return user;
  21607. });
  21608. },
  21609. logIn: function (user
  21610. /*: ParseUser*/
  21611. , options
  21612. /*: RequestOptions*/
  21613. )
  21614. /*: Promise<ParseUser>*/
  21615. {
  21616. var RESTController = _CoreManager.default.getRESTController();
  21617. var stateController = _CoreManager.default.getObjectStateController();
  21618. var auth = {
  21619. username: user.get('username'),
  21620. password: user.get('password')
  21621. };
  21622. return RESTController.request(options.usePost ? 'POST' : 'GET', 'login', auth, options).then(function (response) {
  21623. user._migrateId(response.objectId);
  21624. user._setExisted(true);
  21625. stateController.setPendingOp(user._getStateIdentifier(), 'username', undefined);
  21626. stateController.setPendingOp(user._getStateIdentifier(), 'password', undefined);
  21627. response.password = undefined;
  21628. user._finishFetch(response);
  21629. if (!canUseCurrentUser) {
  21630. // We can't set the current user, so just return the one we logged in
  21631. return _promise.default.resolve(user);
  21632. }
  21633. return DefaultController.setCurrentUser(user);
  21634. });
  21635. },
  21636. become: function (user
  21637. /*: ParseUser*/
  21638. , options
  21639. /*: RequestOptions*/
  21640. )
  21641. /*: Promise<ParseUser>*/
  21642. {
  21643. var RESTController = _CoreManager.default.getRESTController();
  21644. return RESTController.request('GET', 'users/me', {}, options).then(function (response) {
  21645. user._finishFetch(response);
  21646. user._setExisted(true);
  21647. return DefaultController.setCurrentUser(user);
  21648. });
  21649. },
  21650. hydrate: function (user
  21651. /*: ParseUser*/
  21652. , userJSON
  21653. /*: AttributeMap*/
  21654. )
  21655. /*: Promise<ParseUser>*/
  21656. {
  21657. user._finishFetch(userJSON);
  21658. user._setExisted(true);
  21659. if (userJSON.sessionToken && canUseCurrentUser) {
  21660. return DefaultController.setCurrentUser(user);
  21661. }
  21662. return _promise.default.resolve(user);
  21663. },
  21664. me: function (user
  21665. /*: ParseUser*/
  21666. , options
  21667. /*: RequestOptions*/
  21668. )
  21669. /*: Promise<ParseUser>*/
  21670. {
  21671. var RESTController = _CoreManager.default.getRESTController();
  21672. return RESTController.request('GET', 'users/me', {}, options).then(function (response) {
  21673. user._finishFetch(response);
  21674. user._setExisted(true);
  21675. return user;
  21676. });
  21677. },
  21678. logOut: function (options
  21679. /*: RequestOptions*/
  21680. )
  21681. /*: Promise<ParseUser>*/
  21682. {
  21683. var Moralis = _dereq_('./Parse');
  21684. Moralis.cleanup();
  21685. var RESTController = _CoreManager.default.getRESTController();
  21686. if (options.sessionToken) {
  21687. return RESTController.request('POST', 'logout', {}, options);
  21688. }
  21689. return DefaultController.currentUserAsync().then(function (currentUser) {
  21690. var path = _Storage.default.generatePath(CURRENT_USER_KEY);
  21691. var promise = _Storage.default.removeItemAsync(path);
  21692. if (currentUser !== null) {
  21693. var isAnonymous = _AnonymousUtils.default.isLinked(currentUser);
  21694. var currentSession = currentUser.getSessionToken();
  21695. if (currentSession && (0, _isRevocableSession.default)(currentSession)) {
  21696. promise = promise.then(function () {
  21697. if (isAnonymous) {
  21698. return currentUser.destroy({
  21699. sessionToken: currentSession
  21700. });
  21701. }
  21702. }).then(function () {
  21703. return RESTController.request('POST', 'logout', {}, {
  21704. sessionToken: currentSession
  21705. });
  21706. });
  21707. }
  21708. currentUser._logOutWithAll();
  21709. currentUser._finishFetch({
  21710. sessionToken: undefined
  21711. });
  21712. currentUser._clearServerData();
  21713. }
  21714. currentUserCacheMatchesDisk = true;
  21715. currentUserCache = null;
  21716. return promise;
  21717. });
  21718. },
  21719. requestPasswordReset: function (email
  21720. /*: string*/
  21721. , options
  21722. /*: RequestOptions*/
  21723. ) {
  21724. var RESTController = _CoreManager.default.getRESTController();
  21725. return RESTController.request('POST', 'requestPasswordReset', {
  21726. email: email
  21727. }, options);
  21728. },
  21729. upgradeToRevocableSession: function (user
  21730. /*: ParseUser*/
  21731. , options
  21732. /*: RequestOptions*/
  21733. ) {
  21734. var token = user.getSessionToken();
  21735. if (!token) {
  21736. return _promise.default.reject(new _ParseError.default(_ParseError.default.SESSION_MISSING, 'Cannot upgrade a user with no session token'));
  21737. }
  21738. options.sessionToken = token;
  21739. var RESTController = _CoreManager.default.getRESTController();
  21740. return RESTController.request('POST', 'upgradeToRevocableSession', {}, options).then(function (result) {
  21741. var session = new _ParseSession.default();
  21742. session._finishFetch(result);
  21743. user._finishFetch({
  21744. sessionToken: session.getSessionToken()
  21745. });
  21746. if (user.isCurrent()) {
  21747. return DefaultController.setCurrentUser(user);
  21748. }
  21749. return _promise.default.resolve(user);
  21750. });
  21751. },
  21752. linkWith: function (user
  21753. /*: ParseUser*/
  21754. , authData
  21755. /*: AuthData*/
  21756. , options
  21757. /*: FullOptions*/
  21758. ) {
  21759. return user.save({
  21760. authData: authData
  21761. }, options).then(function () {
  21762. if (canUseCurrentUser) {
  21763. return DefaultController.setCurrentUser(user);
  21764. }
  21765. return user;
  21766. });
  21767. },
  21768. verifyPassword: function (username
  21769. /*: string*/
  21770. , password
  21771. /*: string*/
  21772. , options
  21773. /*: RequestOptions*/
  21774. ) {
  21775. var RESTController = _CoreManager.default.getRESTController();
  21776. return RESTController.request('GET', 'verifyPassword', {
  21777. username: username,
  21778. password: password
  21779. }, options);
  21780. },
  21781. requestEmailVerification: function (email
  21782. /*: string*/
  21783. , options
  21784. /*: RequestOptions*/
  21785. ) {
  21786. var RESTController = _CoreManager.default.getRESTController();
  21787. return RESTController.request('POST', 'verificationEmailRequest', {
  21788. email: email
  21789. }, options);
  21790. }
  21791. };
  21792. _CoreManager.default.setUserController(DefaultController);
  21793. var _default = ParseUser;
  21794. exports.default = _default;
  21795. },{"./AnonymousUtils":2,"./CoreManager":5,"./MoralisWeb3":21,"./Parse":25,"./ParseError":29,"./ParseObject":36,"./ParseSession":43,"./Storage":48,"./isRevocableSession":70,"@babel/runtime-corejs3/core-js-stable/json/stringify":99,"@babel/runtime-corejs3/core-js-stable/object/define-property":105,"@babel/runtime-corejs3/core-js-stable/promise":115,"@babel/runtime-corejs3/core-js-stable/reflect/construct":116,"@babel/runtime-corejs3/helpers/asyncToGenerator":144,"@babel/runtime-corejs3/helpers/classCallCheck":145,"@babel/runtime-corejs3/helpers/createClass":147,"@babel/runtime-corejs3/helpers/get":149,"@babel/runtime-corejs3/helpers/getPrototypeOf":150,"@babel/runtime-corejs3/helpers/inherits":151,"@babel/runtime-corejs3/helpers/interopRequireDefault":152,"@babel/runtime-corejs3/helpers/possibleConstructorReturn":159,"@babel/runtime-corejs3/helpers/typeof":164,"@babel/runtime-corejs3/regenerator":167}],45:[function(_dereq_,module,exports){
  21796. "use strict";
  21797. var _Object$defineProperty = _dereq_("@babel/runtime-corejs3/core-js-stable/object/define-property");
  21798. var _interopRequireDefault = _dereq_("@babel/runtime-corejs3/helpers/interopRequireDefault");
  21799. _Object$defineProperty(exports, "__esModule", {
  21800. value: true
  21801. });
  21802. exports.send = send;
  21803. var _typeof2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/helpers/typeof"));
  21804. var _CoreManager = _interopRequireDefault(_dereq_("./CoreManager"));
  21805. var _ParseQuery = _interopRequireDefault(_dereq_("./ParseQuery"));
  21806. /**
  21807. * Copyright (c) 2015-present, Parse, LLC.
  21808. * All rights reserved.
  21809. *
  21810. * This source code is licensed under the BSD-style license found in the
  21811. * LICENSE file in the root directory of this source tree. An additional grant
  21812. * of patent rights can be found in the PATENTS file in the same directory.
  21813. *
  21814. * @flow
  21815. */
  21816. /**
  21817. * Contains functions to deal with Push in Parse.
  21818. *
  21819. * @class Parse.Push
  21820. * @static
  21821. * @hideconstructor
  21822. */
  21823. /**
  21824. * Sends a push notification.
  21825. * **Available in Cloud Code only.**
  21826. *
  21827. * See {@link https://docs.parseplatform.org/js/guide/#push-notifications Push Notification Guide}
  21828. *
  21829. * @function send
  21830. * @name Parse.Push.send
  21831. * @param {object} data - The data of the push notification. Valid fields
  21832. * are:
  21833. * <ol>
  21834. * <li>channels - An Array of channels to push to.</li>
  21835. * <li>push_time - A Date object for when to send the push.</li>
  21836. * <li>expiration_time - A Date object for when to expire
  21837. * the push.</li>
  21838. * <li>expiration_interval - The seconds from now to expire the push.</li>
  21839. * <li>where - A Parse.Query over Parse.Installation that is used to match
  21840. * a set of installations to push to.</li>
  21841. * <li>data - The data to send as part of the push.</li>
  21842. * <ol>
  21843. * @returns {Promise} A promise that is fulfilled when the push request
  21844. * completes.
  21845. */
  21846. function send(data
  21847. /*: PushData*/
  21848. )
  21849. /*: Promise*/
  21850. {
  21851. if (data.where && data.where instanceof _ParseQuery.default) {
  21852. data.where = data.where.toJSON().where;
  21853. }
  21854. if (data.push_time && (0, _typeof2.default)(data.push_time) === 'object') {
  21855. data.push_time = data.push_time.toJSON();
  21856. }
  21857. if (data.expiration_time && (0, _typeof2.default)(data.expiration_time) === 'object') {
  21858. data.expiration_time = data.expiration_time.toJSON();
  21859. }
  21860. if (data.expiration_time && data.expiration_interval) {
  21861. throw new Error('expiration_time and expiration_interval cannot both be set.');
  21862. }
  21863. return _CoreManager.default.getPushController().send(data);
  21864. }
  21865. var DefaultController = {
  21866. send: function (data
  21867. /*: PushData*/
  21868. ) {
  21869. return _CoreManager.default.getRESTController().request('POST', 'push', data, {
  21870. useMasterKey: true
  21871. });
  21872. }
  21873. };
  21874. _CoreManager.default.setPushController(DefaultController);
  21875. },{"./CoreManager":5,"./ParseQuery":39,"@babel/runtime-corejs3/core-js-stable/object/define-property":105,"@babel/runtime-corejs3/helpers/interopRequireDefault":152,"@babel/runtime-corejs3/helpers/typeof":164}],46:[function(_dereq_,module,exports){
  21876. (function (process){(function (){
  21877. "use strict";
  21878. var _Object$keys = _dereq_("@babel/runtime-corejs3/core-js-stable/object/keys");
  21879. var _Object$getOwnPropertySymbols = _dereq_("@babel/runtime-corejs3/core-js-stable/object/get-own-property-symbols");
  21880. var _filterInstanceProperty = _dereq_("@babel/runtime-corejs3/core-js-stable/instance/filter");
  21881. var _Object$getOwnPropertyDescriptor = _dereq_("@babel/runtime-corejs3/core-js-stable/object/get-own-property-descriptor");
  21882. var _forEachInstanceProperty = _dereq_("@babel/runtime-corejs3/core-js-stable/instance/for-each");
  21883. var _Object$getOwnPropertyDescriptors = _dereq_("@babel/runtime-corejs3/core-js-stable/object/get-own-property-descriptors");
  21884. var _Object$defineProperties = _dereq_("@babel/runtime-corejs3/core-js-stable/object/define-properties");
  21885. var _Object$defineProperty = _dereq_("@babel/runtime-corejs3/core-js-stable/object/define-property");
  21886. var _interopRequireDefault = _dereq_("@babel/runtime-corejs3/helpers/interopRequireDefault");
  21887. var _defineProperty2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/helpers/defineProperty"));
  21888. var _typeof2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/helpers/typeof"));
  21889. var _promise = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/promise"));
  21890. var _stringify = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/json/stringify"));
  21891. var _includes = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/instance/includes"));
  21892. var _setTimeout2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/set-timeout"));
  21893. var _concat = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/instance/concat"));
  21894. var _CoreManager = _interopRequireDefault(_dereq_("./CoreManager"));
  21895. var _ParseError = _interopRequireDefault(_dereq_("./ParseError"));
  21896. var _promiseUtils = _dereq_("./promiseUtils");
  21897. function ownKeys(object, enumerableOnly) {
  21898. var keys = _Object$keys(object);
  21899. if (_Object$getOwnPropertySymbols) {
  21900. var symbols = _Object$getOwnPropertySymbols(object);
  21901. enumerableOnly && (symbols = _filterInstanceProperty(symbols).call(symbols, function (sym) {
  21902. return _Object$getOwnPropertyDescriptor(object, sym).enumerable;
  21903. })), keys.push.apply(keys, symbols);
  21904. }
  21905. return keys;
  21906. }
  21907. function _objectSpread(target) {
  21908. for (var i = 1; i < arguments.length; i++) {
  21909. var _context5, _context6;
  21910. var source = null != arguments[i] ? arguments[i] : {};
  21911. i % 2 ? _forEachInstanceProperty(_context5 = ownKeys(Object(source), !0)).call(_context5, function (key) {
  21912. (0, _defineProperty2.default)(target, key, source[key]);
  21913. }) : _Object$getOwnPropertyDescriptors ? _Object$defineProperties(target, _Object$getOwnPropertyDescriptors(source)) : _forEachInstanceProperty(_context6 = ownKeys(Object(source))).call(_context6, function (key) {
  21914. _Object$defineProperty(target, key, _Object$getOwnPropertyDescriptor(source, key));
  21915. });
  21916. }
  21917. return target;
  21918. }
  21919. /**
  21920. * Copyright (c) 2015-present, Parse, LLC.
  21921. * All rights reserved.
  21922. *
  21923. * This source code is licensed under the BSD-style license found in the
  21924. * LICENSE file in the root directory of this source tree. An additional grant
  21925. * of patent rights can be found in the PATENTS file in the same directory.
  21926. *
  21927. * @flow
  21928. */
  21929. /* global XMLHttpRequest, XDomainRequest */
  21930. var _require = _dereq_('uuid'),
  21931. uuidv4 = _require.v4;
  21932. var XHR = null;
  21933. if (typeof XMLHttpRequest !== 'undefined') {
  21934. XHR = XMLHttpRequest;
  21935. }
  21936. var useXDomainRequest = false;
  21937. if (typeof XDomainRequest !== 'undefined' && !('withCredentials' in new XMLHttpRequest())) {
  21938. useXDomainRequest = true;
  21939. }
  21940. function ajaxIE9(method
  21941. /*: string*/
  21942. , url
  21943. /*: string*/
  21944. , data
  21945. /*: any*/
  21946. , headers
  21947. /*:: ?: any*/
  21948. , options
  21949. /*:: ?: FullOptions*/
  21950. ) {
  21951. return new _promise.default(function (resolve, reject) {
  21952. var xdr = new XDomainRequest();
  21953. xdr.onload = function () {
  21954. var response;
  21955. try {
  21956. response = JSON.parse(xdr.responseText);
  21957. } catch (e) {
  21958. reject(e);
  21959. }
  21960. if (response) {
  21961. resolve({
  21962. response: response
  21963. });
  21964. }
  21965. };
  21966. xdr.onerror = xdr.ontimeout = function () {
  21967. // Let's fake a real error message.
  21968. var fakeResponse = {
  21969. responseText: (0, _stringify.default)({
  21970. code: _ParseError.default.X_DOMAIN_REQUEST,
  21971. error: "IE's XDomainRequest does not supply error info."
  21972. })
  21973. };
  21974. reject(fakeResponse);
  21975. };
  21976. xdr.onprogress = function () {
  21977. if (options && typeof options.progress === 'function') {
  21978. options.progress(xdr.responseText);
  21979. }
  21980. };
  21981. xdr.open(method, url);
  21982. xdr.send(data);
  21983. if (options && typeof options.requestTask === 'function') {
  21984. options.requestTask(xdr);
  21985. }
  21986. });
  21987. }
  21988. var RESTController = {
  21989. ajax: function (method
  21990. /*: string*/
  21991. , url
  21992. /*: string*/
  21993. , data
  21994. /*: any*/
  21995. , headers
  21996. /*:: ?: any*/
  21997. , options
  21998. /*:: ?: FullOptions*/
  21999. ) {
  22000. var _context;
  22001. if (useXDomainRequest) {
  22002. return ajaxIE9(method, url, data, headers, options);
  22003. }
  22004. var promise = (0, _promiseUtils.resolvingPromise)();
  22005. var isIdempotent = _CoreManager.default.get('IDEMPOTENCY') && (0, _includes.default)(_context = ['POST', 'PUT']).call(_context, method);
  22006. var requestId = isIdempotent ? uuidv4() : '';
  22007. var attempts = 0;
  22008. var dispatch = function dispatch() {
  22009. if (XHR == null) {
  22010. throw new Error('Cannot make a request: No definition of XMLHttpRequest was found.');
  22011. }
  22012. var handled = false;
  22013. var xhr = new XHR();
  22014. xhr.onreadystatechange = function () {
  22015. if (xhr.readyState !== 4 || handled || xhr._aborted) {
  22016. return;
  22017. }
  22018. handled = true;
  22019. if (xhr.status >= 200 && xhr.status < 300) {
  22020. var response;
  22021. try {
  22022. response = JSON.parse(xhr.responseText);
  22023. if (typeof xhr.getResponseHeader === 'function') {
  22024. var _context2;
  22025. if ((0, _includes.default)(_context2 = xhr.getAllResponseHeaders() || '').call(_context2, 'x-parse-job-status-id: ')) {
  22026. response = xhr.getResponseHeader('x-parse-job-status-id');
  22027. }
  22028. }
  22029. } catch (e) {
  22030. promise.reject(e.toString());
  22031. }
  22032. if (response) {
  22033. promise.resolve({
  22034. response: response,
  22035. status: xhr.status,
  22036. xhr: xhr
  22037. });
  22038. }
  22039. } else if (xhr.status >= 500 || xhr.status === 0) {
  22040. // retry on 5XX or node-xmlhttprequest error
  22041. if (++attempts < _CoreManager.default.get('REQUEST_ATTEMPT_LIMIT')) {
  22042. // Exponentially-growing random delay
  22043. var delay = Math.round(Math.random() * 125 * Math.pow(2, attempts));
  22044. (0, _setTimeout2.default)(dispatch, delay);
  22045. } else if (xhr.status === 0) {
  22046. promise.reject('Unable to connect to the Parse API');
  22047. } else {
  22048. // After the retry limit is reached, fail
  22049. promise.reject(xhr);
  22050. }
  22051. } else {
  22052. promise.reject(xhr);
  22053. }
  22054. };
  22055. headers = headers || {};
  22056. if (typeof headers['Content-Type'] !== 'string') {
  22057. // Avoid pre-flight
  22058. headers['Content-Type'] = 'text/plain';
  22059. }
  22060. if (_CoreManager.default.get('IS_NODE')) {
  22061. var _context3;
  22062. headers['User-Agent'] = (0, _concat.default)(_context3 = "Parse/".concat(_CoreManager.default.get('VERSION'), " (NodeJS ")).call(_context3, process.versions.node, ")");
  22063. }
  22064. if (isIdempotent) {
  22065. headers['X-Parse-Request-Id'] = requestId;
  22066. }
  22067. if (_CoreManager.default.get('SERVER_AUTH_TYPE') && _CoreManager.default.get('SERVER_AUTH_TOKEN')) {
  22068. var _context4;
  22069. headers.Authorization = (0, _concat.default)(_context4 = "".concat(_CoreManager.default.get('SERVER_AUTH_TYPE'), " ")).call(_context4, _CoreManager.default.get('SERVER_AUTH_TOKEN'));
  22070. }
  22071. var customHeaders = _CoreManager.default.get('REQUEST_HEADERS');
  22072. for (var key in customHeaders) {
  22073. headers[key] = customHeaders[key];
  22074. }
  22075. function handleProgress(type, event) {
  22076. if (options && typeof options.progress === 'function') {
  22077. if (event.lengthComputable) {
  22078. options.progress(event.loaded / event.total, event.loaded, event.total, {
  22079. type: type
  22080. });
  22081. } else {
  22082. options.progress(null, null, null, {
  22083. type: type
  22084. });
  22085. }
  22086. }
  22087. }
  22088. xhr.onprogress = function (event) {
  22089. handleProgress('download', event);
  22090. };
  22091. if (xhr.upload) {
  22092. xhr.upload.onprogress = function (event) {
  22093. handleProgress('upload', event);
  22094. };
  22095. }
  22096. xhr.open(method, url, true);
  22097. for (var h in headers) {
  22098. xhr.setRequestHeader(h, headers[h]);
  22099. }
  22100. xhr.onabort = function () {
  22101. promise.resolve({
  22102. response: {
  22103. results: []
  22104. },
  22105. status: 0,
  22106. xhr: xhr
  22107. });
  22108. };
  22109. xhr.send(data);
  22110. if (options && typeof options.requestTask === 'function') {
  22111. options.requestTask(xhr);
  22112. }
  22113. };
  22114. dispatch();
  22115. return promise;
  22116. },
  22117. request: function (method
  22118. /*: string*/
  22119. , path
  22120. /*: string*/
  22121. , data
  22122. /*: mixed*/
  22123. , options
  22124. /*:: ?: RequestOptions*/
  22125. ) {
  22126. options = options || {};
  22127. var url = _CoreManager.default.get('SERVER_URL');
  22128. if (url[url.length - 1] !== '/') {
  22129. url += '/';
  22130. }
  22131. url += path;
  22132. var payload = {};
  22133. if (data && (0, _typeof2.default)(data) === 'object') {
  22134. for (var k in data) {
  22135. payload[k] = data[k];
  22136. }
  22137. } // Add context
  22138. var _options = options,
  22139. context = _options.context;
  22140. if (context !== undefined) {
  22141. payload._context = context;
  22142. }
  22143. if (method !== 'POST') {
  22144. payload._method = method;
  22145. method = 'POST';
  22146. }
  22147. payload._ApplicationId = _CoreManager.default.get('APPLICATION_ID');
  22148. var jsKey = _CoreManager.default.get('JAVASCRIPT_KEY');
  22149. if (jsKey) {
  22150. payload._JavaScriptKey = jsKey;
  22151. }
  22152. payload._ClientVersion = _CoreManager.default.get('VERSION');
  22153. var _options2 = options,
  22154. useMasterKey = _options2.useMasterKey;
  22155. if (typeof useMasterKey === 'undefined') {
  22156. useMasterKey = _CoreManager.default.get('USE_MASTER_KEY');
  22157. }
  22158. if (useMasterKey) {
  22159. if (_CoreManager.default.get('MASTER_KEY')) {
  22160. delete payload._JavaScriptKey;
  22161. payload._MasterKey = _CoreManager.default.get('MASTER_KEY');
  22162. }
  22163. }
  22164. if (_CoreManager.default.get('FORCE_REVOCABLE_SESSION')) {
  22165. payload._RevocableSession = '1';
  22166. }
  22167. var _options3 = options,
  22168. installationId = _options3.installationId;
  22169. var installationIdPromise;
  22170. if (installationId && typeof installationId === 'string') {
  22171. installationIdPromise = _promise.default.resolve(installationId);
  22172. } else {
  22173. var installationController = _CoreManager.default.getInstallationController();
  22174. installationIdPromise = installationController.currentInstallationId();
  22175. }
  22176. return installationIdPromise.then(function (iid) {
  22177. payload._InstallationId = iid;
  22178. var userController = _CoreManager.default.getUserController();
  22179. if (options && typeof options.sessionToken === 'string') {
  22180. return _promise.default.resolve(options.sessionToken);
  22181. }
  22182. if (userController) {
  22183. return userController.currentUserAsync().then(function (user) {
  22184. if (user) {
  22185. return _promise.default.resolve(user.getSessionToken());
  22186. }
  22187. return _promise.default.resolve(null);
  22188. });
  22189. }
  22190. return _promise.default.resolve(null);
  22191. }).then(function (token) {
  22192. if (token) {
  22193. payload._SessionToken = token;
  22194. }
  22195. var payloadString = (0, _stringify.default)(payload);
  22196. return RESTController.ajax(method, url, payloadString, {}, options).then(function (_ref) {
  22197. var response = _ref.response,
  22198. status = _ref.status;
  22199. if (options.returnStatus) {
  22200. return _objectSpread(_objectSpread({}, response), {}, {
  22201. _status: status
  22202. });
  22203. }
  22204. return response;
  22205. });
  22206. }).catch(RESTController.handleError);
  22207. },
  22208. handleError: function (response) {
  22209. // Transform the error into an instance of ParseError by trying to parse
  22210. // the error string as JSON
  22211. var error;
  22212. if (response && response.responseText) {
  22213. try {
  22214. var errorJSON = JSON.parse(response.responseText);
  22215. error = new _ParseError.default(errorJSON.code, errorJSON.error);
  22216. } catch (e) {
  22217. // If we fail to parse the error text, that's okay.
  22218. error = new _ParseError.default(_ParseError.default.INVALID_JSON, "Received an error with invalid JSON from Parse: ".concat(response.responseText));
  22219. }
  22220. } else {
  22221. var message = response.message ? response.message : response;
  22222. error = new _ParseError.default(_ParseError.default.CONNECTION_FAILED, "XMLHttpRequest failed: ".concat((0, _stringify.default)(message)));
  22223. }
  22224. return _promise.default.reject(error);
  22225. },
  22226. _setXHR: function (xhr
  22227. /*: any*/
  22228. ) {
  22229. XHR = xhr;
  22230. },
  22231. _getXHR: function () {
  22232. return XHR;
  22233. }
  22234. };
  22235. module.exports = RESTController;
  22236. }).call(this)}).call(this,_dereq_('_process'))
  22237. },{"./CoreManager":5,"./ParseError":29,"./promiseUtils":72,"@babel/runtime-corejs3/core-js-stable/instance/concat":81,"@babel/runtime-corejs3/core-js-stable/instance/filter":84,"@babel/runtime-corejs3/core-js-stable/instance/for-each":86,"@babel/runtime-corejs3/core-js-stable/instance/includes":87,"@babel/runtime-corejs3/core-js-stable/json/stringify":99,"@babel/runtime-corejs3/core-js-stable/object/define-properties":104,"@babel/runtime-corejs3/core-js-stable/object/define-property":105,"@babel/runtime-corejs3/core-js-stable/object/get-own-property-descriptor":108,"@babel/runtime-corejs3/core-js-stable/object/get-own-property-descriptors":109,"@babel/runtime-corejs3/core-js-stable/object/get-own-property-symbols":110,"@babel/runtime-corejs3/core-js-stable/object/keys":112,"@babel/runtime-corejs3/core-js-stable/promise":115,"@babel/runtime-corejs3/core-js-stable/set-timeout":117,"@babel/runtime-corejs3/helpers/defineProperty":148,"@babel/runtime-corejs3/helpers/interopRequireDefault":152,"@babel/runtime-corejs3/helpers/typeof":164,"_process":323,"uuid":797}],47:[function(_dereq_,module,exports){
  22238. "use strict";
  22239. var _typeof = _dereq_("@babel/runtime-corejs3/helpers/typeof");
  22240. var _WeakMap = _dereq_("@babel/runtime-corejs3/core-js-stable/weak-map");
  22241. var _Object$defineProperty = _dereq_("@babel/runtime-corejs3/core-js-stable/object/define-property");
  22242. var _Object$getOwnPropertyDescriptor = _dereq_("@babel/runtime-corejs3/core-js-stable/object/get-own-property-descriptor");
  22243. _Object$defineProperty(exports, "__esModule", {
  22244. value: true
  22245. });
  22246. exports.clearAllState = clearAllState;
  22247. exports.commitServerChanges = commitServerChanges;
  22248. exports.duplicateState = duplicateState;
  22249. exports.enqueueTask = enqueueTask;
  22250. exports.estimateAttribute = estimateAttribute;
  22251. exports.estimateAttributes = estimateAttributes;
  22252. exports.getObjectCache = getObjectCache;
  22253. exports.getPendingOps = getPendingOps;
  22254. exports.getServerData = getServerData;
  22255. exports.getState = getState;
  22256. exports.initializeState = initializeState;
  22257. exports.mergeFirstPendingState = mergeFirstPendingState;
  22258. exports.popPendingState = popPendingState;
  22259. exports.pushPendingState = pushPendingState;
  22260. exports.removeState = removeState;
  22261. exports.setPendingOp = setPendingOp;
  22262. exports.setServerData = setServerData;
  22263. var ObjectStateMutations = _interopRequireWildcard(_dereq_("./ObjectStateMutations"));
  22264. function _getRequireWildcardCache(nodeInterop) {
  22265. if (typeof _WeakMap !== "function") return null;
  22266. var cacheBabelInterop = new _WeakMap();
  22267. var cacheNodeInterop = new _WeakMap();
  22268. return (_getRequireWildcardCache = function (nodeInterop) {
  22269. return nodeInterop ? cacheNodeInterop : cacheBabelInterop;
  22270. })(nodeInterop);
  22271. }
  22272. function _interopRequireWildcard(obj, nodeInterop) {
  22273. if (!nodeInterop && obj && obj.__esModule) {
  22274. return obj;
  22275. }
  22276. if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") {
  22277. return {
  22278. default: obj
  22279. };
  22280. }
  22281. var cache = _getRequireWildcardCache(nodeInterop);
  22282. if (cache && cache.has(obj)) {
  22283. return cache.get(obj);
  22284. }
  22285. var newObj = {};
  22286. for (var key in obj) {
  22287. if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) {
  22288. var desc = _Object$defineProperty && _Object$getOwnPropertyDescriptor ? _Object$getOwnPropertyDescriptor(obj, key) : null;
  22289. if (desc && (desc.get || desc.set)) {
  22290. _Object$defineProperty(newObj, key, desc);
  22291. } else {
  22292. newObj[key] = obj[key];
  22293. }
  22294. }
  22295. }
  22296. newObj.default = obj;
  22297. if (cache) {
  22298. cache.set(obj, newObj);
  22299. }
  22300. return newObj;
  22301. }
  22302. /**
  22303. * Copyright (c) 2015-present, Parse, LLC.
  22304. * All rights reserved.
  22305. *
  22306. * This source code is licensed under the BSD-style license found in the
  22307. * LICENSE file in the root directory of this source tree. An additional grant
  22308. * of patent rights can be found in the PATENTS file in the same directory.
  22309. *
  22310. * @flow
  22311. */
  22312. var objectState
  22313. /*: {
  22314. [className: string]: {
  22315. [id: string]: State,
  22316. },
  22317. }*/
  22318. = {};
  22319. function getState(obj
  22320. /*: ObjectIdentifier*/
  22321. )
  22322. /*: ?State*/
  22323. {
  22324. var classData = objectState[obj.className];
  22325. if (classData) {
  22326. return classData[obj.id] || null;
  22327. }
  22328. return null;
  22329. }
  22330. function initializeState(obj
  22331. /*: ObjectIdentifier*/
  22332. , initial
  22333. /*:: ?: State*/
  22334. )
  22335. /*: State*/
  22336. {
  22337. var state = getState(obj);
  22338. if (state) {
  22339. return state;
  22340. }
  22341. if (!objectState[obj.className]) {
  22342. objectState[obj.className] = {};
  22343. }
  22344. if (!initial) {
  22345. initial = ObjectStateMutations.defaultState();
  22346. }
  22347. state = objectState[obj.className][obj.id] = initial;
  22348. return state;
  22349. }
  22350. function removeState(obj
  22351. /*: ObjectIdentifier*/
  22352. )
  22353. /*: ?State*/
  22354. {
  22355. var state = getState(obj);
  22356. if (state === null) {
  22357. return null;
  22358. }
  22359. delete objectState[obj.className][obj.id];
  22360. return state;
  22361. }
  22362. function getServerData(obj
  22363. /*: ObjectIdentifier*/
  22364. )
  22365. /*: AttributeMap*/
  22366. {
  22367. var state = getState(obj);
  22368. if (state) {
  22369. return state.serverData;
  22370. }
  22371. return {};
  22372. }
  22373. function setServerData(obj
  22374. /*: ObjectIdentifier*/
  22375. , attributes
  22376. /*: AttributeMap*/
  22377. ) {
  22378. var _initializeState = initializeState(obj),
  22379. serverData = _initializeState.serverData;
  22380. ObjectStateMutations.setServerData(serverData, attributes);
  22381. }
  22382. function getPendingOps(obj
  22383. /*: ObjectIdentifier*/
  22384. )
  22385. /*: Array<OpsMap>*/
  22386. {
  22387. var state = getState(obj);
  22388. if (state) {
  22389. return state.pendingOps;
  22390. }
  22391. return [{}];
  22392. }
  22393. function setPendingOp(obj
  22394. /*: ObjectIdentifier*/
  22395. , attr
  22396. /*: string*/
  22397. , op
  22398. /*: ?Op*/
  22399. ) {
  22400. var _initializeState2 = initializeState(obj),
  22401. pendingOps = _initializeState2.pendingOps;
  22402. ObjectStateMutations.setPendingOp(pendingOps, attr, op);
  22403. }
  22404. function pushPendingState(obj
  22405. /*: ObjectIdentifier*/
  22406. ) {
  22407. var _initializeState3 = initializeState(obj),
  22408. pendingOps = _initializeState3.pendingOps;
  22409. ObjectStateMutations.pushPendingState(pendingOps);
  22410. }
  22411. function popPendingState(obj
  22412. /*: ObjectIdentifier*/
  22413. )
  22414. /*: OpsMap*/
  22415. {
  22416. var _initializeState4 = initializeState(obj),
  22417. pendingOps = _initializeState4.pendingOps;
  22418. return ObjectStateMutations.popPendingState(pendingOps);
  22419. }
  22420. function mergeFirstPendingState(obj
  22421. /*: ObjectIdentifier*/
  22422. ) {
  22423. var pendingOps = getPendingOps(obj);
  22424. ObjectStateMutations.mergeFirstPendingState(pendingOps);
  22425. }
  22426. function getObjectCache(obj
  22427. /*: ObjectIdentifier*/
  22428. )
  22429. /*: ObjectCache*/
  22430. {
  22431. var state = getState(obj);
  22432. if (state) {
  22433. return state.objectCache;
  22434. }
  22435. return {};
  22436. }
  22437. function estimateAttribute(obj
  22438. /*: ObjectIdentifier*/
  22439. , attr
  22440. /*: string*/
  22441. )
  22442. /*: mixed*/
  22443. {
  22444. var serverData = getServerData(obj);
  22445. var pendingOps = getPendingOps(obj);
  22446. return ObjectStateMutations.estimateAttribute(serverData, pendingOps, obj.className, obj.id, attr);
  22447. }
  22448. function estimateAttributes(obj
  22449. /*: ObjectIdentifier*/
  22450. )
  22451. /*: AttributeMap*/
  22452. {
  22453. var serverData = getServerData(obj);
  22454. var pendingOps = getPendingOps(obj);
  22455. return ObjectStateMutations.estimateAttributes(serverData, pendingOps, obj.className, obj.id);
  22456. }
  22457. function commitServerChanges(obj
  22458. /*: ObjectIdentifier*/
  22459. , changes
  22460. /*: AttributeMap*/
  22461. ) {
  22462. var state = initializeState(obj);
  22463. ObjectStateMutations.commitServerChanges(state.serverData, state.objectCache, changes);
  22464. }
  22465. function enqueueTask(obj
  22466. /*: ObjectIdentifier*/
  22467. , task
  22468. /*: () => Promise*/
  22469. )
  22470. /*: Promise*/
  22471. {
  22472. var state = initializeState(obj);
  22473. return state.tasks.enqueue(task);
  22474. }
  22475. function clearAllState() {
  22476. objectState = {};
  22477. }
  22478. function duplicateState(source
  22479. /*: { id: string }*/
  22480. , dest
  22481. /*: { id: string }*/
  22482. ) {
  22483. dest.id = source.id;
  22484. }
  22485. },{"./ObjectStateMutations":23,"@babel/runtime-corejs3/core-js-stable/object/define-property":105,"@babel/runtime-corejs3/core-js-stable/object/get-own-property-descriptor":108,"@babel/runtime-corejs3/core-js-stable/weak-map":122,"@babel/runtime-corejs3/helpers/typeof":164}],48:[function(_dereq_,module,exports){
  22486. "use strict";
  22487. var _interopRequireDefault = _dereq_("@babel/runtime-corejs3/helpers/interopRequireDefault");
  22488. var _promise = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/promise"));
  22489. var _concat = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/instance/concat"));
  22490. var _CoreManager = _interopRequireDefault(_dereq_("./CoreManager"));
  22491. /**
  22492. * Copyright (c) 2015-present, Parse, LLC.
  22493. * All rights reserved.
  22494. *
  22495. * This source code is licensed under the BSD-style license found in the
  22496. * LICENSE file in the root directory of this source tree. An additional grant
  22497. * of patent rights can be found in the PATENTS file in the same directory.
  22498. *
  22499. * @flow
  22500. */
  22501. var Storage = {
  22502. async: function ()
  22503. /*: boolean*/
  22504. {
  22505. var controller = _CoreManager.default.getStorageController();
  22506. return !!controller.async;
  22507. },
  22508. getItem: function (path
  22509. /*: string*/
  22510. )
  22511. /*: ?string*/
  22512. {
  22513. var controller = _CoreManager.default.getStorageController();
  22514. if (controller.async === 1) {
  22515. throw new Error('Synchronous storage is not supported by the current storage controller');
  22516. }
  22517. return controller.getItem(path);
  22518. },
  22519. getItemAsync: function (path
  22520. /*: string*/
  22521. )
  22522. /*: Promise<string>*/
  22523. {
  22524. var controller = _CoreManager.default.getStorageController();
  22525. if (controller.async === 1) {
  22526. return controller.getItemAsync(path);
  22527. }
  22528. return _promise.default.resolve(controller.getItem(path));
  22529. },
  22530. setItem: function (path
  22531. /*: string*/
  22532. , value
  22533. /*: string*/
  22534. )
  22535. /*: void*/
  22536. {
  22537. var controller = _CoreManager.default.getStorageController();
  22538. if (controller.async === 1) {
  22539. throw new Error('Synchronous storage is not supported by the current storage controller');
  22540. }
  22541. return controller.setItem(path, value);
  22542. },
  22543. setItemAsync: function (path
  22544. /*: string*/
  22545. , value
  22546. /*: string*/
  22547. )
  22548. /*: Promise<void>*/
  22549. {
  22550. var controller = _CoreManager.default.getStorageController();
  22551. if (controller.async === 1) {
  22552. return controller.setItemAsync(path, value);
  22553. }
  22554. return _promise.default.resolve(controller.setItem(path, value));
  22555. },
  22556. removeItem: function (path
  22557. /*: string*/
  22558. )
  22559. /*: void*/
  22560. {
  22561. var controller = _CoreManager.default.getStorageController();
  22562. if (controller.async === 1) {
  22563. throw new Error('Synchronous storage is not supported by the current storage controller');
  22564. }
  22565. return controller.removeItem(path);
  22566. },
  22567. removeItemAsync: function (path
  22568. /*: string*/
  22569. )
  22570. /*: Promise<void>*/
  22571. {
  22572. var controller = _CoreManager.default.getStorageController();
  22573. if (controller.async === 1) {
  22574. return controller.removeItemAsync(path);
  22575. }
  22576. return _promise.default.resolve(controller.removeItem(path));
  22577. },
  22578. getAllKeys: function ()
  22579. /*: Array<string>*/
  22580. {
  22581. var controller = _CoreManager.default.getStorageController();
  22582. if (controller.async === 1) {
  22583. throw new Error('Synchronous storage is not supported by the current storage controller');
  22584. }
  22585. return controller.getAllKeys();
  22586. },
  22587. getAllKeysAsync: function ()
  22588. /*: Promise<Array<string>>*/
  22589. {
  22590. var controller = _CoreManager.default.getStorageController();
  22591. if (controller.async === 1) {
  22592. return controller.getAllKeysAsync();
  22593. }
  22594. return _promise.default.resolve(controller.getAllKeys());
  22595. },
  22596. generatePath: function (path
  22597. /*: string*/
  22598. )
  22599. /*: string*/
  22600. {
  22601. var _context;
  22602. if (!_CoreManager.default.get('APPLICATION_ID')) {
  22603. throw new Error('You need to call Moralis.start with an applicationId before using Moralis.');
  22604. }
  22605. if (typeof path !== 'string') {
  22606. throw new Error('Tried to get a Storage path that was not a String.');
  22607. }
  22608. if (path[0] === '/') {
  22609. path = path.substr(1);
  22610. }
  22611. return (0, _concat.default)(_context = "Parse/".concat(_CoreManager.default.get('APPLICATION_ID'), "/")).call(_context, path);
  22612. },
  22613. _clear: function () {
  22614. var controller = _CoreManager.default.getStorageController();
  22615. if (controller.hasOwnProperty('clear')) {
  22616. controller.clear();
  22617. }
  22618. }
  22619. };
  22620. module.exports = Storage;
  22621. _CoreManager.default.setStorageController(_dereq_('./StorageController.browser'));
  22622. },{"./CoreManager":5,"./StorageController.browser":49,"@babel/runtime-corejs3/core-js-stable/instance/concat":81,"@babel/runtime-corejs3/core-js-stable/promise":115,"@babel/runtime-corejs3/helpers/interopRequireDefault":152}],49:[function(_dereq_,module,exports){
  22623. "use strict";
  22624. /**
  22625. * Copyright (c) 2015-present, Parse, LLC.
  22626. * All rights reserved.
  22627. *
  22628. * This source code is licensed under the BSD-style license found in the
  22629. * LICENSE file in the root directory of this source tree. An additional grant
  22630. * of patent rights can be found in the PATENTS file in the same directory.
  22631. *
  22632. * @flow
  22633. * @private
  22634. */
  22635. /* global localStorage */
  22636. var StorageController = {
  22637. async: 0,
  22638. getItem: function (path
  22639. /*: string*/
  22640. )
  22641. /*: ?string*/
  22642. {
  22643. return localStorage.getItem(path);
  22644. },
  22645. setItem: function (path
  22646. /*: string*/
  22647. , value
  22648. /*: string*/
  22649. ) {
  22650. try {
  22651. localStorage.setItem(path, value);
  22652. } catch (e) {
  22653. // Quota exceeded, possibly due to Safari Private Browsing mode
  22654. // eslint-disable-next-line no-console
  22655. console.log(e.message);
  22656. }
  22657. },
  22658. removeItem: function (path
  22659. /*: string*/
  22660. ) {
  22661. localStorage.removeItem(path);
  22662. },
  22663. getAllKeys: function () {
  22664. var keys = [];
  22665. for (var i = 0; i < localStorage.length; i += 1) {
  22666. keys.push(localStorage.key(i));
  22667. }
  22668. return keys;
  22669. },
  22670. clear: function () {
  22671. localStorage.clear();
  22672. }
  22673. };
  22674. module.exports = StorageController;
  22675. },{}],50:[function(_dereq_,module,exports){
  22676. "use strict";
  22677. var _interopRequireDefault = _dereq_("@babel/runtime-corejs3/helpers/interopRequireDefault");
  22678. var _classCallCheck2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/helpers/classCallCheck"));
  22679. var _createClass2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/helpers/createClass"));
  22680. var _defineProperty2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/helpers/defineProperty"));
  22681. var _promiseUtils = _dereq_("./promiseUtils");
  22682. /**
  22683. * Copyright (c) 2015-present, Parse, LLC.
  22684. * All rights reserved.
  22685. *
  22686. * This source code is licensed under the BSD-style license found in the
  22687. * LICENSE file in the root directory of this source tree. An additional grant
  22688. * of patent rights can be found in the PATENTS file in the same directory.
  22689. *
  22690. * @flow
  22691. */
  22692. var TaskQueue = /*#__PURE__*/function () {
  22693. function TaskQueue() {
  22694. (0, _classCallCheck2.default)(this, TaskQueue);
  22695. (0, _defineProperty2.default)(this, "queue", void 0);
  22696. this.queue = [];
  22697. }
  22698. (0, _createClass2.default)(TaskQueue, [{
  22699. key: "enqueue",
  22700. value: function (task
  22701. /*: () => Promise*/
  22702. )
  22703. /*: Promise*/
  22704. {
  22705. var _this = this;
  22706. var taskComplete = new _promiseUtils.resolvingPromise();
  22707. this.queue.push({
  22708. task: task,
  22709. _completion: taskComplete
  22710. });
  22711. if (this.queue.length === 1) {
  22712. task().then(function () {
  22713. _this._dequeue();
  22714. taskComplete.resolve();
  22715. }, function (error) {
  22716. _this._dequeue();
  22717. taskComplete.reject(error);
  22718. });
  22719. }
  22720. return taskComplete;
  22721. }
  22722. }, {
  22723. key: "_dequeue",
  22724. value: function () {
  22725. var _this2 = this;
  22726. this.queue.shift();
  22727. if (this.queue.length) {
  22728. var next = this.queue[0];
  22729. next.task().then(function () {
  22730. _this2._dequeue();
  22731. next._completion.resolve();
  22732. }, function (error) {
  22733. _this2._dequeue();
  22734. next._completion.reject(error);
  22735. });
  22736. }
  22737. }
  22738. }]);
  22739. return TaskQueue;
  22740. }();
  22741. module.exports = TaskQueue;
  22742. },{"./promiseUtils":72,"@babel/runtime-corejs3/helpers/classCallCheck":145,"@babel/runtime-corejs3/helpers/createClass":147,"@babel/runtime-corejs3/helpers/defineProperty":148,"@babel/runtime-corejs3/helpers/interopRequireDefault":152}],51:[function(_dereq_,module,exports){
  22743. "use strict";
  22744. var _interopRequireDefault = _dereq_("@babel/runtime-corejs3/helpers/interopRequireDefault");
  22745. var _keys = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/object/keys"));
  22746. var _indexOf = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/instance/index-of"));
  22747. var _isInteger = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/number/is-integer"));
  22748. var supportedTypes = ['native', 'erc20', 'erc721', 'erc1155'];
  22749. var ERC1155TransferABI = [{
  22750. inputs: [{
  22751. internalType: 'address',
  22752. name: 'from',
  22753. type: 'address'
  22754. }, {
  22755. internalType: 'address',
  22756. name: 'to',
  22757. type: 'address'
  22758. }, {
  22759. internalType: 'uint256',
  22760. name: 'id',
  22761. type: 'uint256'
  22762. }, {
  22763. internalType: 'uint256',
  22764. name: 'value',
  22765. type: 'uint256'
  22766. }, {
  22767. internalType: 'bytes',
  22768. name: 'data',
  22769. type: 'bytes'
  22770. }],
  22771. outputs: [{
  22772. name: '',
  22773. type: 'bool'
  22774. }],
  22775. name: 'safeTransferFrom',
  22776. type: 'function',
  22777. constant: false,
  22778. payable: false
  22779. }, {
  22780. inputs: [{
  22781. internalType: 'address',
  22782. name: 'from',
  22783. type: 'address'
  22784. }, {
  22785. internalType: 'address',
  22786. name: 'to',
  22787. type: 'address'
  22788. }, {
  22789. internalType: 'uint256',
  22790. name: 'id',
  22791. type: 'uint256'
  22792. }, {
  22793. internalType: 'uint256',
  22794. name: 'value',
  22795. type: 'uint256'
  22796. }],
  22797. outputs: [{
  22798. name: '',
  22799. type: 'bool'
  22800. }],
  22801. name: 'transferFrom',
  22802. type: 'function',
  22803. constant: false,
  22804. payable: false
  22805. }];
  22806. var ERC721TransferABI = [{
  22807. inputs: [{
  22808. internalType: 'address',
  22809. name: 'from',
  22810. type: 'address'
  22811. }, {
  22812. internalType: 'address',
  22813. name: 'to',
  22814. type: 'address'
  22815. }, {
  22816. internalType: 'uint256',
  22817. name: 'tokenId',
  22818. type: 'uint256'
  22819. }],
  22820. outputs: [{
  22821. name: '',
  22822. type: 'bool'
  22823. }],
  22824. name: 'safeTransferFrom',
  22825. type: 'function',
  22826. constant: false,
  22827. payable: false
  22828. }, {
  22829. inputs: [{
  22830. internalType: 'address',
  22831. name: 'from',
  22832. type: 'address'
  22833. }, {
  22834. internalType: 'address',
  22835. name: 'to',
  22836. type: 'address'
  22837. }, {
  22838. internalType: 'uint256',
  22839. name: 'tokenId',
  22840. type: 'uint256'
  22841. }],
  22842. outputs: [{
  22843. name: '',
  22844. type: 'bool'
  22845. }],
  22846. name: 'transferFrom',
  22847. type: 'function',
  22848. constant: false,
  22849. payable: false
  22850. }];
  22851. var ERC20TransferABI = [{
  22852. constant: false,
  22853. inputs: [{
  22854. name: '_to',
  22855. type: 'address'
  22856. }, {
  22857. name: '_value',
  22858. type: 'uint256'
  22859. }],
  22860. name: 'transfer',
  22861. outputs: [{
  22862. name: '',
  22863. type: 'bool'
  22864. }],
  22865. payable: false,
  22866. stateMutability: 'nonpayable',
  22867. type: 'function'
  22868. }, {
  22869. constant: true,
  22870. inputs: [{
  22871. name: '_owner',
  22872. type: 'address'
  22873. }],
  22874. name: 'balanceOf',
  22875. outputs: [{
  22876. name: 'balance',
  22877. type: 'uint256'
  22878. }],
  22879. payable: false,
  22880. stateMutability: 'view',
  22881. type: 'function'
  22882. }];
  22883. var tokenParams = {
  22884. native: {
  22885. receiver: '',
  22886. amount: ''
  22887. },
  22888. erc20: {
  22889. contractAddress: '',
  22890. receiver: '',
  22891. amount: ''
  22892. },
  22893. erc721: {
  22894. contractAddress: '',
  22895. receiver: '',
  22896. tokenId: ''
  22897. },
  22898. erc1155: {
  22899. contractAddress: '',
  22900. receiver: '',
  22901. tokenId: '',
  22902. amount: ''
  22903. }
  22904. };
  22905. var isNotEmpty = function (value) {
  22906. return typeof value !== 'undefined' && value ? true : false;
  22907. };
  22908. var validateInput = function (type, payload) {
  22909. var errors = [];
  22910. var parameters = tokenParams[type];
  22911. for (var _i = 0, _Object$keys = (0, _keys.default)(parameters); _i < _Object$keys.length; _i++) {
  22912. var key = _Object$keys[_i];
  22913. if (!isNotEmpty(payload[key])) {
  22914. errors.push("".concat(key, " is required"));
  22915. }
  22916. }
  22917. if (errors.length > 0) {
  22918. throw errors;
  22919. }
  22920. };
  22921. var isSupportedType = function (type) {
  22922. if ((0, _indexOf.default)(supportedTypes).call(supportedTypes, type) === -1) throw 'Unsupported type';
  22923. return true;
  22924. };
  22925. var isUint256 = function (tokenId) {
  22926. if (!(0, _isInteger.default)(+tokenId) || +tokenId < 0) throw new Error('Invalid token Id');
  22927. return true;
  22928. };
  22929. module.exports = {
  22930. abi: {
  22931. erc1155: ERC1155TransferABI,
  22932. erc721: ERC721TransferABI,
  22933. erc20: ERC20TransferABI
  22934. },
  22935. validateInput: validateInput,
  22936. isSupportedType: isSupportedType,
  22937. isNotEmpty: isNotEmpty,
  22938. isUint256: isUint256
  22939. };
  22940. },{"@babel/runtime-corejs3/core-js-stable/instance/index-of":88,"@babel/runtime-corejs3/core-js-stable/number/is-integer":101,"@babel/runtime-corejs3/core-js-stable/object/keys":112,"@babel/runtime-corejs3/helpers/interopRequireDefault":152}],52:[function(_dereq_,module,exports){
  22941. "use strict";
  22942. var _typeof = _dereq_("@babel/runtime-corejs3/helpers/typeof");
  22943. var _WeakMap2 = _dereq_("@babel/runtime-corejs3/core-js-stable/weak-map");
  22944. var _Object$defineProperty = _dereq_("@babel/runtime-corejs3/core-js-stable/object/define-property");
  22945. var _Object$getOwnPropertyDescriptor = _dereq_("@babel/runtime-corejs3/core-js-stable/object/get-own-property-descriptor");
  22946. var _interopRequireDefault = _dereq_("@babel/runtime-corejs3/helpers/interopRequireDefault");
  22947. _Object$defineProperty(exports, "__esModule", {
  22948. value: true
  22949. });
  22950. exports.clearAllState = clearAllState;
  22951. exports.commitServerChanges = commitServerChanges;
  22952. exports.duplicateState = duplicateState;
  22953. exports.enqueueTask = enqueueTask;
  22954. exports.estimateAttribute = estimateAttribute;
  22955. exports.estimateAttributes = estimateAttributes;
  22956. exports.getObjectCache = getObjectCache;
  22957. exports.getPendingOps = getPendingOps;
  22958. exports.getServerData = getServerData;
  22959. exports.getState = getState;
  22960. exports.initializeState = initializeState;
  22961. exports.mergeFirstPendingState = mergeFirstPendingState;
  22962. exports.popPendingState = popPendingState;
  22963. exports.pushPendingState = pushPendingState;
  22964. exports.removeState = removeState;
  22965. exports.setPendingOp = setPendingOp;
  22966. exports.setServerData = setServerData;
  22967. var _weakMap = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/weak-map"));
  22968. var ObjectStateMutations = _interopRequireWildcard(_dereq_("./ObjectStateMutations"));
  22969. var _TaskQueue = _interopRequireDefault(_dereq_("./TaskQueue"));
  22970. function _getRequireWildcardCache(nodeInterop) {
  22971. if (typeof _WeakMap2 !== "function") return null;
  22972. var cacheBabelInterop = new _WeakMap2();
  22973. var cacheNodeInterop = new _WeakMap2();
  22974. return (_getRequireWildcardCache = function (nodeInterop) {
  22975. return nodeInterop ? cacheNodeInterop : cacheBabelInterop;
  22976. })(nodeInterop);
  22977. }
  22978. function _interopRequireWildcard(obj, nodeInterop) {
  22979. if (!nodeInterop && obj && obj.__esModule) {
  22980. return obj;
  22981. }
  22982. if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") {
  22983. return {
  22984. default: obj
  22985. };
  22986. }
  22987. var cache = _getRequireWildcardCache(nodeInterop);
  22988. if (cache && cache.has(obj)) {
  22989. return cache.get(obj);
  22990. }
  22991. var newObj = {};
  22992. for (var key in obj) {
  22993. if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) {
  22994. var desc = _Object$defineProperty && _Object$getOwnPropertyDescriptor ? _Object$getOwnPropertyDescriptor(obj, key) : null;
  22995. if (desc && (desc.get || desc.set)) {
  22996. _Object$defineProperty(newObj, key, desc);
  22997. } else {
  22998. newObj[key] = obj[key];
  22999. }
  23000. }
  23001. }
  23002. newObj.default = obj;
  23003. if (cache) {
  23004. cache.set(obj, newObj);
  23005. }
  23006. return newObj;
  23007. }
  23008. /**
  23009. * Copyright (c) 2015-present, Parse, LLC.
  23010. * All rights reserved.
  23011. *
  23012. * This source code is licensed under the BSD-style license found in the
  23013. * LICENSE file in the root directory of this source tree. An additional grant
  23014. * of patent rights can be found in the PATENTS file in the same directory.
  23015. *
  23016. * @flow
  23017. */
  23018. var objectState = new _weakMap.default();
  23019. function getState(obj
  23020. /*: ParseObject*/
  23021. )
  23022. /*: ?State*/
  23023. {
  23024. var classData = objectState.get(obj);
  23025. return classData || null;
  23026. }
  23027. function initializeState(obj
  23028. /*: ParseObject*/
  23029. , initial
  23030. /*:: ?: State*/
  23031. )
  23032. /*: State*/
  23033. {
  23034. var state = getState(obj);
  23035. if (state) {
  23036. return state;
  23037. }
  23038. if (!initial) {
  23039. initial = {
  23040. serverData: {},
  23041. pendingOps: [{}],
  23042. objectCache: {},
  23043. tasks: new _TaskQueue.default(),
  23044. existed: false
  23045. };
  23046. }
  23047. state = initial;
  23048. objectState.set(obj, state);
  23049. return state;
  23050. }
  23051. function removeState(obj
  23052. /*: ParseObject*/
  23053. )
  23054. /*: ?State*/
  23055. {
  23056. var state = getState(obj);
  23057. if (state === null) {
  23058. return null;
  23059. }
  23060. objectState.delete(obj);
  23061. return state;
  23062. }
  23063. function getServerData(obj
  23064. /*: ParseObject*/
  23065. )
  23066. /*: AttributeMap*/
  23067. {
  23068. var state = getState(obj);
  23069. if (state) {
  23070. return state.serverData;
  23071. }
  23072. return {};
  23073. }
  23074. function setServerData(obj
  23075. /*: ParseObject*/
  23076. , attributes
  23077. /*: AttributeMap*/
  23078. ) {
  23079. var _initializeState = initializeState(obj),
  23080. serverData = _initializeState.serverData;
  23081. ObjectStateMutations.setServerData(serverData, attributes);
  23082. }
  23083. function getPendingOps(obj
  23084. /*: ParseObject*/
  23085. )
  23086. /*: Array<OpsMap>*/
  23087. {
  23088. var state = getState(obj);
  23089. if (state) {
  23090. return state.pendingOps;
  23091. }
  23092. return [{}];
  23093. }
  23094. function setPendingOp(obj
  23095. /*: ParseObject*/
  23096. , attr
  23097. /*: string*/
  23098. , op
  23099. /*: ?Op*/
  23100. ) {
  23101. var _initializeState2 = initializeState(obj),
  23102. pendingOps = _initializeState2.pendingOps;
  23103. ObjectStateMutations.setPendingOp(pendingOps, attr, op);
  23104. }
  23105. function pushPendingState(obj
  23106. /*: ParseObject*/
  23107. ) {
  23108. var _initializeState3 = initializeState(obj),
  23109. pendingOps = _initializeState3.pendingOps;
  23110. ObjectStateMutations.pushPendingState(pendingOps);
  23111. }
  23112. function popPendingState(obj
  23113. /*: ParseObject*/
  23114. )
  23115. /*: OpsMap*/
  23116. {
  23117. var _initializeState4 = initializeState(obj),
  23118. pendingOps = _initializeState4.pendingOps;
  23119. return ObjectStateMutations.popPendingState(pendingOps);
  23120. }
  23121. function mergeFirstPendingState(obj
  23122. /*: ParseObject*/
  23123. ) {
  23124. var pendingOps = getPendingOps(obj);
  23125. ObjectStateMutations.mergeFirstPendingState(pendingOps);
  23126. }
  23127. function getObjectCache(obj
  23128. /*: ParseObject*/
  23129. )
  23130. /*: ObjectCache*/
  23131. {
  23132. var state = getState(obj);
  23133. if (state) {
  23134. return state.objectCache;
  23135. }
  23136. return {};
  23137. }
  23138. function estimateAttribute(obj
  23139. /*: ParseObject*/
  23140. , attr
  23141. /*: string*/
  23142. )
  23143. /*: mixed*/
  23144. {
  23145. var serverData = getServerData(obj);
  23146. var pendingOps = getPendingOps(obj);
  23147. return ObjectStateMutations.estimateAttribute(serverData, pendingOps, obj.className, obj.id, attr);
  23148. }
  23149. function estimateAttributes(obj
  23150. /*: ParseObject*/
  23151. )
  23152. /*: AttributeMap*/
  23153. {
  23154. var serverData = getServerData(obj);
  23155. var pendingOps = getPendingOps(obj);
  23156. return ObjectStateMutations.estimateAttributes(serverData, pendingOps, obj.className, obj.id);
  23157. }
  23158. function commitServerChanges(obj
  23159. /*: ParseObject*/
  23160. , changes
  23161. /*: AttributeMap*/
  23162. ) {
  23163. var state = initializeState(obj);
  23164. ObjectStateMutations.commitServerChanges(state.serverData, state.objectCache, changes);
  23165. }
  23166. function enqueueTask(obj
  23167. /*: ParseObject*/
  23168. , task
  23169. /*: () => Promise*/
  23170. )
  23171. /*: Promise*/
  23172. {
  23173. var state = initializeState(obj);
  23174. return state.tasks.enqueue(task);
  23175. }
  23176. function duplicateState(source
  23177. /*: ParseObject*/
  23178. , dest
  23179. /*: ParseObject*/
  23180. )
  23181. /*: void*/
  23182. {
  23183. var oldState = initializeState(source);
  23184. var newState = initializeState(dest);
  23185. for (var key in oldState.serverData) {
  23186. newState.serverData[key] = oldState.serverData[key];
  23187. }
  23188. for (var index = 0; index < oldState.pendingOps.length; index++) {
  23189. for (var _key in oldState.pendingOps[index]) {
  23190. newState.pendingOps[index][_key] = oldState.pendingOps[index][_key];
  23191. }
  23192. }
  23193. for (var _key2 in oldState.objectCache) {
  23194. newState.objectCache[_key2] = oldState.objectCache[_key2];
  23195. }
  23196. newState.existed = oldState.existed;
  23197. }
  23198. function clearAllState() {
  23199. objectState = new _weakMap.default();
  23200. }
  23201. },{"./ObjectStateMutations":23,"./TaskQueue":50,"@babel/runtime-corejs3/core-js-stable/object/define-property":105,"@babel/runtime-corejs3/core-js-stable/object/get-own-property-descriptor":108,"@babel/runtime-corejs3/core-js-stable/weak-map":122,"@babel/runtime-corejs3/helpers/interopRequireDefault":152,"@babel/runtime-corejs3/helpers/typeof":164}],53:[function(_dereq_,module,exports){
  23202. "use strict";
  23203. var _interopRequireDefault = _dereq_("@babel/runtime-corejs3/helpers/interopRequireDefault");
  23204. var _classCallCheck2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/helpers/classCallCheck"));
  23205. var _createClass2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/helpers/createClass"));
  23206. var _ethers = _dereq_("ethers");
  23207. var UnitConverter = /*#__PURE__*/function () {
  23208. function UnitConverter() {
  23209. (0, _classCallCheck2.default)(this, UnitConverter);
  23210. }
  23211. (0, _createClass2.default)(UnitConverter, null, [{
  23212. key: "ETH",
  23213. value: function (value) {
  23214. return _ethers.ethers.utils.parseEther("".concat(value)).toString();
  23215. }
  23216. }, {
  23217. key: "Token",
  23218. value: function (value) {
  23219. var decimals = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 18;
  23220. return _ethers.ethers.utils.parseUnits("".concat(value), +decimals).toString();
  23221. }
  23222. }, {
  23223. key: "FromWei",
  23224. value: function (value) {
  23225. var decimals = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 18;
  23226. var result = _ethers.ethers.utils.formatUnits(value, decimals); // formatUnits will always add a trailing 0, remove this as we want to return "1" instead of "1.0"
  23227. var splitResult = result.split('.');
  23228. if (splitResult[1] === '0') {
  23229. return splitResult[0];
  23230. }
  23231. return result;
  23232. }
  23233. }]);
  23234. return UnitConverter;
  23235. }();
  23236. module.exports = UnitConverter;
  23237. },{"@babel/runtime-corejs3/helpers/classCallCheck":145,"@babel/runtime-corejs3/helpers/createClass":147,"@babel/runtime-corejs3/helpers/interopRequireDefault":152,"ethers":773}],54:[function(_dereq_,module,exports){
  23238. "use strict";
  23239. var _Reflect$construct = _dereq_("@babel/runtime-corejs3/core-js-stable/reflect/construct");
  23240. var _Object$defineProperty = _dereq_("@babel/runtime-corejs3/core-js-stable/object/define-property");
  23241. var _interopRequireDefault = _dereq_("@babel/runtime-corejs3/helpers/interopRequireDefault");
  23242. _Object$defineProperty(exports, "__esModule", {
  23243. value: true
  23244. });
  23245. exports.default = void 0;
  23246. var _regenerator = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/regenerator"));
  23247. var _bind = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/instance/bind"));
  23248. var _asyncToGenerator2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/helpers/asyncToGenerator"));
  23249. var _classCallCheck2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/helpers/classCallCheck"));
  23250. var _createClass2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/helpers/createClass"));
  23251. var _assertThisInitialized2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/helpers/assertThisInitialized"));
  23252. var _inherits2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/helpers/inherits"));
  23253. var _possibleConstructorReturn2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/helpers/possibleConstructorReturn"));
  23254. var _getPrototypeOf2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/helpers/getPrototypeOf"));
  23255. var _defineProperty2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/helpers/defineProperty"));
  23256. var _events = _interopRequireDefault(_dereq_("events"));
  23257. var _verifyChainId = _interopRequireDefault(_dereq_("../utils/verifyChainId"));
  23258. var _events2 = _dereq_("./events");
  23259. function _createSuper(Derived) {
  23260. var hasNativeReflectConstruct = _isNativeReflectConstruct();
  23261. return function () {
  23262. var Super = (0, _getPrototypeOf2.default)(Derived),
  23263. result;
  23264. if (hasNativeReflectConstruct) {
  23265. var NewTarget = (0, _getPrototypeOf2.default)(this).constructor;
  23266. result = _Reflect$construct(Super, arguments, NewTarget);
  23267. } else {
  23268. result = Super.apply(this, arguments);
  23269. }
  23270. return (0, _possibleConstructorReturn2.default)(this, result);
  23271. };
  23272. }
  23273. function _isNativeReflectConstruct() {
  23274. if (typeof Reflect === "undefined" || !_Reflect$construct) return false;
  23275. if (_Reflect$construct.sham) return false;
  23276. if (typeof Proxy === "function") return true;
  23277. try {
  23278. Boolean.prototype.valueOf.call(_Reflect$construct(Boolean, [], function () {}));
  23279. return true;
  23280. } catch (e) {
  23281. return false;
  23282. }
  23283. }
  23284. /**
  23285. * Abstract connector to connect EIP-1193 providers to Moralis
  23286. *
  23287. * It should implement at least:
  23288. * - activate()
  23289. * - Emit ConnectorEvent.CHAIN_CHANGED when the chain has changed (if possible)
  23290. * - Emit ConnectorEvent.ACCOUNT_CHANGED when the account has changed (if possible)
  23291. * - type: a name to identify
  23292. * - network: the network type that is used (eg. 'evm')
  23293. */
  23294. var AbstractWeb3Connector = /*#__PURE__*/function (_EventEmitter) {
  23295. (0, _inherits2.default)(AbstractWeb3Connector, _EventEmitter);
  23296. var _super = _createSuper(AbstractWeb3Connector);
  23297. function AbstractWeb3Connector() {
  23298. var _context, _context2, _context3, _context4;
  23299. var _this;
  23300. (0, _classCallCheck2.default)(this, AbstractWeb3Connector);
  23301. _this = _super.call(this);
  23302. (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "type", 'abstract');
  23303. (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "network", 'evm');
  23304. (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "account", null);
  23305. (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "chainId", null);
  23306. _this.handleAccountsChanged = (0, _bind.default)(_context = _this.handleAccountsChanged).call(_context, (0, _assertThisInitialized2.default)(_this));
  23307. _this.handleChainChanged = (0, _bind.default)(_context2 = _this.handleChainChanged).call(_context2, (0, _assertThisInitialized2.default)(_this));
  23308. _this.handleConnect = (0, _bind.default)(_context3 = _this.handleConnect).call(_context3, (0, _assertThisInitialized2.default)(_this));
  23309. _this.handleDisconnect = (0, _bind.default)(_context4 = _this.handleDisconnect).call(_context4, (0, _assertThisInitialized2.default)(_this));
  23310. return _this;
  23311. }
  23312. (0, _createClass2.default)(AbstractWeb3Connector, [{
  23313. key: "subscribeToEvents",
  23314. value: function (provider) {
  23315. if (provider && provider.on) {
  23316. provider.on(_events2.EthereumEvents.CHAIN_CHANGED, this.handleChainChanged);
  23317. provider.on(_events2.EthereumEvents.ACCOUNTS_CHANGED, this.handleAccountsChanged);
  23318. provider.on(_events2.EthereumEvents.CONNECT, this.handleConnect);
  23319. provider.on(_events2.EthereumEvents.DISCONNECT, this.handleDisconnect);
  23320. }
  23321. }
  23322. }, {
  23323. key: "unsubscribeToEvents",
  23324. value: function (provider) {
  23325. if (provider && provider.removeListener) {
  23326. provider.removeListener(_events2.EthereumEvents.CHAIN_CHANGED, this.handleChainChanged);
  23327. provider.removeListener(_events2.EthereumEvents.ACCOUNTS_CHANGED, this.handleAccountsChanged);
  23328. provider.removeListener(_events2.EthereumEvents.CONNECT, this.handleConnect);
  23329. provider.removeListener(_events2.EthereumEvents.DISCONNECT, this.handleDisconnect);
  23330. }
  23331. }
  23332. /**
  23333. * Activates the provider.
  23334. * Should returns an object with:
  23335. * - provider: A valid EIP-1193 provider
  23336. * - chainId(optional): the chainId that has been connected to (in hex format)
  23337. * - account(optional): the address that is connected to the provider
  23338. */
  23339. }, {
  23340. key: "activate",
  23341. value: function () {
  23342. var _activate = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee() {
  23343. return _regenerator.default.wrap(function (_context5) {
  23344. while (1) {
  23345. switch (_context5.prev = _context5.next) {
  23346. case 0:
  23347. throw new Error('Not implemented: activate()');
  23348. case 1:
  23349. case "end":
  23350. return _context5.stop();
  23351. }
  23352. }
  23353. }, _callee);
  23354. }));
  23355. return function () {
  23356. return _activate.apply(this, arguments);
  23357. };
  23358. }()
  23359. /**
  23360. * Updates account and emit event, on EIP-1193 accountsChanged events
  23361. */
  23362. }, {
  23363. key: "handleAccountsChanged",
  23364. value: function (accounts) {
  23365. var account = accounts && accounts[0] ? accounts[0].toLowerCase() : null;
  23366. this.account = account;
  23367. this.emit(_events2.ConnectorEvents.ACCOUNT_CHANGED, account);
  23368. }
  23369. /**
  23370. * Updates chainId and emit event, on EIP-1193 accountsChanged events
  23371. */
  23372. }, {
  23373. key: "handleChainChanged",
  23374. value: function (chainId) {
  23375. var newChainId = (0, _verifyChainId.default)(chainId);
  23376. this.chainId = newChainId;
  23377. this.emit(_events2.ConnectorEvents.CHAIN_CHANGED, newChainId);
  23378. }
  23379. }, {
  23380. key: "handleConnect",
  23381. value: function (connectInfo) {
  23382. this.emit(_events2.ConnectorEvents.CONNECT, connectInfo);
  23383. }
  23384. }, {
  23385. key: "handleDisconnect",
  23386. value: function (error) {
  23387. this.emit(_events2.ConnectorEvents.DISCONNECT, error);
  23388. }
  23389. /**
  23390. * Cleans all active listners, connections and stale references
  23391. */
  23392. }, {
  23393. key: "deactivate",
  23394. value: function () {
  23395. var _deactivate = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee2() {
  23396. return _regenerator.default.wrap(function (_context6) {
  23397. while (1) {
  23398. switch (_context6.prev = _context6.next) {
  23399. case 0:
  23400. this.unsubscribeToEvents(this.provider);
  23401. this.account = null;
  23402. this.chainId = null;
  23403. case 3:
  23404. case "end":
  23405. return _context6.stop();
  23406. }
  23407. }
  23408. }, _callee2, this);
  23409. }));
  23410. return function () {
  23411. return _deactivate.apply(this, arguments);
  23412. };
  23413. }()
  23414. }]);
  23415. return AbstractWeb3Connector;
  23416. }(_events.default);
  23417. var _default = AbstractWeb3Connector;
  23418. exports.default = _default;
  23419. },{"../utils/verifyChainId":77,"./events":61,"@babel/runtime-corejs3/core-js-stable/instance/bind":80,"@babel/runtime-corejs3/core-js-stable/object/define-property":105,"@babel/runtime-corejs3/core-js-stable/reflect/construct":116,"@babel/runtime-corejs3/helpers/assertThisInitialized":143,"@babel/runtime-corejs3/helpers/asyncToGenerator":144,"@babel/runtime-corejs3/helpers/classCallCheck":145,"@babel/runtime-corejs3/helpers/createClass":147,"@babel/runtime-corejs3/helpers/defineProperty":148,"@babel/runtime-corejs3/helpers/getPrototypeOf":150,"@babel/runtime-corejs3/helpers/inherits":151,"@babel/runtime-corejs3/helpers/interopRequireDefault":152,"@babel/runtime-corejs3/helpers/possibleConstructorReturn":159,"@babel/runtime-corejs3/regenerator":167,"events":775}],55:[function(_dereq_,module,exports){
  23420. "use strict";
  23421. var _Reflect$construct = _dereq_("@babel/runtime-corejs3/core-js-stable/reflect/construct");
  23422. var _Object$defineProperty = _dereq_("@babel/runtime-corejs3/core-js-stable/object/define-property");
  23423. var _interopRequireDefault = _dereq_("@babel/runtime-corejs3/helpers/interopRequireDefault");
  23424. _Object$defineProperty(exports, "__esModule", {
  23425. value: true
  23426. });
  23427. exports.default = exports.InjectedEvents = void 0;
  23428. var _regenerator = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/regenerator"));
  23429. var _slicedToArray2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/helpers/slicedToArray"));
  23430. var _asyncToGenerator2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/helpers/asyncToGenerator"));
  23431. var _assertThisInitialized2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/helpers/assertThisInitialized"));
  23432. var _defineProperty2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/helpers/defineProperty"));
  23433. var _createClass2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/helpers/createClass"));
  23434. var _classCallCheck2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/helpers/classCallCheck"));
  23435. var _inherits2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/helpers/inherits"));
  23436. var _possibleConstructorReturn2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/helpers/possibleConstructorReturn"));
  23437. var _getPrototypeOf2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/helpers/getPrototypeOf"));
  23438. var _wrapNativeSuper2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/helpers/wrapNativeSuper"));
  23439. var _freeze = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/object/freeze"));
  23440. var _concat = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/instance/concat"));
  23441. var _promise = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/promise"));
  23442. var _AbstractWeb3Connector = _interopRequireDefault(_dereq_("./AbstractWeb3Connector"));
  23443. var _events = _interopRequireDefault(_dereq_("events"));
  23444. var _verifyChainId = _interopRequireDefault(_dereq_("../utils/verifyChainId"));
  23445. function _createSuper(Derived) {
  23446. var hasNativeReflectConstruct = _isNativeReflectConstruct();
  23447. return function () {
  23448. var Super = (0, _getPrototypeOf2.default)(Derived),
  23449. result;
  23450. if (hasNativeReflectConstruct) {
  23451. var NewTarget = (0, _getPrototypeOf2.default)(this).constructor;
  23452. result = _Reflect$construct(Super, arguments, NewTarget);
  23453. } else {
  23454. result = Super.apply(this, arguments);
  23455. }
  23456. return (0, _possibleConstructorReturn2.default)(this, result);
  23457. };
  23458. }
  23459. function _isNativeReflectConstruct() {
  23460. if (typeof Reflect === "undefined" || !_Reflect$construct) return false;
  23461. if (_Reflect$construct.sham) return false;
  23462. if (typeof Proxy === "function") return true;
  23463. try {
  23464. Boolean.prototype.valueOf.call(_Reflect$construct(Boolean, [], function () {}));
  23465. return true;
  23466. } catch (e) {
  23467. return false;
  23468. }
  23469. }
  23470. var InjectedEvents = (0, _freeze.default)({
  23471. ACCOUNTS_CHANGED: 'accountsChanged',
  23472. CHAIN_CHANGED: 'chainChanged',
  23473. CONNECT: 'connect',
  23474. DISCONNECT: 'disconnect'
  23475. });
  23476. exports.InjectedEvents = InjectedEvents;
  23477. var NoEthereumProviderError = /*#__PURE__*/function (_Error) {
  23478. (0, _inherits2.default)(NoEthereumProviderError, _Error);
  23479. var _super = _createSuper(NoEthereumProviderError);
  23480. function NoEthereumProviderError() {
  23481. var _this;
  23482. (0, _classCallCheck2.default)(this, NoEthereumProviderError);
  23483. _this = _super.call(this);
  23484. _this.message = 'Non ethereum enabled browser';
  23485. return _this;
  23486. }
  23487. return (0, _createClass2.default)(NoEthereumProviderError);
  23488. }( /*#__PURE__*/(0, _wrapNativeSuper2.default)(Error));
  23489. /**
  23490. * Connector to connect an injected provider (like Metamask) to Moralis
  23491. * The provider should be injected in window.ethereum
  23492. */
  23493. var InjectedWeb3Connector = /*#__PURE__*/function (_AbstractWeb3Connecto) {
  23494. (0, _inherits2.default)(InjectedWeb3Connector, _AbstractWeb3Connecto);
  23495. var _super2 = _createSuper(InjectedWeb3Connector);
  23496. function InjectedWeb3Connector() {
  23497. var _context;
  23498. var _this2;
  23499. (0, _classCallCheck2.default)(this, InjectedWeb3Connector);
  23500. for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
  23501. args[_key] = arguments[_key];
  23502. }
  23503. _this2 = _super2.call.apply(_super2, (0, _concat.default)(_context = [this]).call(_context, args));
  23504. (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this2), "type", 'injected');
  23505. return _this2;
  23506. }
  23507. (0, _createClass2.default)(InjectedWeb3Connector, [{
  23508. key: "verifyEthereumBrowser",
  23509. value: function () {
  23510. var _window;
  23511. if (!((_window = window) !== null && _window !== void 0 && _window.ethereum)) {
  23512. throw new NoEthereumProviderError();
  23513. }
  23514. }
  23515. }, {
  23516. key: "activate",
  23517. value: function () {
  23518. var _activate = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee() {
  23519. var _yield$Promise$all, _yield$Promise$all2, accounts, chainId, account, provider;
  23520. return _regenerator.default.wrap(function (_context2) {
  23521. while (1) {
  23522. switch (_context2.prev = _context2.next) {
  23523. case 0:
  23524. this.verifyEthereumBrowser();
  23525. _context2.next = 3;
  23526. return _promise.default.all([window.ethereum.request({
  23527. method: 'eth_requestAccounts'
  23528. }), window.ethereum.request({
  23529. method: 'eth_chainId'
  23530. })]);
  23531. case 3:
  23532. _yield$Promise$all = _context2.sent;
  23533. _yield$Promise$all2 = (0, _slicedToArray2.default)(_yield$Promise$all, 2);
  23534. accounts = _yield$Promise$all2[0];
  23535. chainId = _yield$Promise$all2[1];
  23536. account = accounts[0] ? accounts[0].toLowerCase() : null;
  23537. provider = window.ethereum;
  23538. this.chainId = chainId;
  23539. this.account = account;
  23540. this.provider = provider;
  23541. this.subscribeToEvents(provider);
  23542. return _context2.abrupt("return", {
  23543. provider: provider,
  23544. chainId: chainId,
  23545. account: account
  23546. });
  23547. case 14:
  23548. case "end":
  23549. return _context2.stop();
  23550. }
  23551. }
  23552. }, _callee, this);
  23553. }));
  23554. return function () {
  23555. return _activate.apply(this, arguments);
  23556. };
  23557. }()
  23558. }, {
  23559. key: "switchNetwork",
  23560. value: function () {
  23561. var _switchNetwork = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee2(chainId) {
  23562. var currentNetwork;
  23563. return _regenerator.default.wrap(function (_context3) {
  23564. while (1) {
  23565. switch (_context3.prev = _context3.next) {
  23566. case 0:
  23567. this.verifyEthereumBrowser();
  23568. chainId = (0, _verifyChainId.default)(chainId);
  23569. currentNetwork = this.chainId;
  23570. if (!(currentNetwork === chainId)) {
  23571. _context3.next = 5;
  23572. break;
  23573. }
  23574. return _context3.abrupt("return");
  23575. case 5:
  23576. _context3.next = 7;
  23577. return window.ethereum.request({
  23578. method: 'wallet_switchEthereumChain',
  23579. params: [{
  23580. chainId: chainId
  23581. }]
  23582. });
  23583. case 7:
  23584. case "end":
  23585. return _context3.stop();
  23586. }
  23587. }
  23588. }, _callee2, this);
  23589. }));
  23590. return function () {
  23591. return _switchNetwork.apply(this, arguments);
  23592. };
  23593. }()
  23594. }, {
  23595. key: "addNetwork",
  23596. value: function () {
  23597. var _addNetwork = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee3(chainId, chainName, currencyName, currencySymbol, rpcUrl, blockExplorerUrl) {
  23598. var newchainId;
  23599. return _regenerator.default.wrap(function (_context4) {
  23600. while (1) {
  23601. switch (_context4.prev = _context4.next) {
  23602. case 0:
  23603. this.verifyEthereumBrowser();
  23604. newchainId = (0, _verifyChainId.default)(chainId);
  23605. _context4.next = 4;
  23606. return window.ethereum.request({
  23607. method: 'wallet_addEthereumChain',
  23608. params: [{
  23609. chainId: newchainId,
  23610. chainName: chainName,
  23611. nativeCurrency: {
  23612. name: currencyName,
  23613. symbol: currencySymbol,
  23614. decimals: 18
  23615. },
  23616. rpcUrls: [rpcUrl],
  23617. blockExplorerUrls: blockExplorerUrl ? [blockExplorerUrl] : null
  23618. }]
  23619. });
  23620. case 4:
  23621. case "end":
  23622. return _context4.stop();
  23623. }
  23624. }
  23625. }, _callee3, this);
  23626. }));
  23627. return function () {
  23628. return _addNetwork.apply(this, arguments);
  23629. };
  23630. }()
  23631. }]);
  23632. return InjectedWeb3Connector;
  23633. }(_AbstractWeb3Connector.default);
  23634. var _default = InjectedWeb3Connector;
  23635. exports.default = _default;
  23636. },{"../utils/verifyChainId":77,"./AbstractWeb3Connector":54,"@babel/runtime-corejs3/core-js-stable/instance/concat":81,"@babel/runtime-corejs3/core-js-stable/object/define-property":105,"@babel/runtime-corejs3/core-js-stable/object/freeze":107,"@babel/runtime-corejs3/core-js-stable/promise":115,"@babel/runtime-corejs3/core-js-stable/reflect/construct":116,"@babel/runtime-corejs3/helpers/assertThisInitialized":143,"@babel/runtime-corejs3/helpers/asyncToGenerator":144,"@babel/runtime-corejs3/helpers/classCallCheck":145,"@babel/runtime-corejs3/helpers/createClass":147,"@babel/runtime-corejs3/helpers/defineProperty":148,"@babel/runtime-corejs3/helpers/getPrototypeOf":150,"@babel/runtime-corejs3/helpers/inherits":151,"@babel/runtime-corejs3/helpers/interopRequireDefault":152,"@babel/runtime-corejs3/helpers/possibleConstructorReturn":159,"@babel/runtime-corejs3/helpers/slicedToArray":161,"@babel/runtime-corejs3/helpers/wrapNativeSuper":166,"@babel/runtime-corejs3/regenerator":167,"events":775}],56:[function(_dereq_,module,exports){
  23637. "use strict";
  23638. var _Reflect$construct = _dereq_("@babel/runtime-corejs3/core-js-stable/reflect/construct");
  23639. var _Object$defineProperty = _dereq_("@babel/runtime-corejs3/core-js-stable/object/define-property");
  23640. var _interopRequireDefault = _dereq_("@babel/runtime-corejs3/helpers/interopRequireDefault");
  23641. _Object$defineProperty(exports, "__esModule", {
  23642. value: true
  23643. });
  23644. exports.default = void 0;
  23645. var _regenerator = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/regenerator"));
  23646. var _concat = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/instance/concat"));
  23647. var _asyncToGenerator2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/helpers/asyncToGenerator"));
  23648. var _classCallCheck2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/helpers/classCallCheck"));
  23649. var _createClass2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/helpers/createClass"));
  23650. var _assertThisInitialized2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/helpers/assertThisInitialized"));
  23651. var _inherits2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/helpers/inherits"));
  23652. var _possibleConstructorReturn2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/helpers/possibleConstructorReturn"));
  23653. var _getPrototypeOf2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/helpers/getPrototypeOf"));
  23654. var _defineProperty2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/helpers/defineProperty"));
  23655. var _ethers = _dereq_("ethers");
  23656. var _AbstractWeb3Connector = _interopRequireDefault(_dereq_("./AbstractWeb3Connector"));
  23657. function _createSuper(Derived) {
  23658. var hasNativeReflectConstruct = _isNativeReflectConstruct();
  23659. return function () {
  23660. var Super = (0, _getPrototypeOf2.default)(Derived),
  23661. result;
  23662. if (hasNativeReflectConstruct) {
  23663. var NewTarget = (0, _getPrototypeOf2.default)(this).constructor;
  23664. result = _Reflect$construct(Super, arguments, NewTarget);
  23665. } else {
  23666. result = Super.apply(this, arguments);
  23667. }
  23668. return (0, _possibleConstructorReturn2.default)(this, result);
  23669. };
  23670. }
  23671. function _isNativeReflectConstruct() {
  23672. if (typeof Reflect === "undefined" || !_Reflect$construct) return false;
  23673. if (_Reflect$construct.sham) return false;
  23674. if (typeof Proxy === "function") return true;
  23675. try {
  23676. Boolean.prototype.valueOf.call(_Reflect$construct(Boolean, [], function () {}));
  23677. return true;
  23678. } catch (e) {
  23679. return false;
  23680. }
  23681. }
  23682. var MagicWeb3Connector = /*#__PURE__*/function (_AbstractWeb3Connecto) {
  23683. (0, _inherits2.default)(MagicWeb3Connector, _AbstractWeb3Connecto);
  23684. var _super = _createSuper(MagicWeb3Connector);
  23685. function MagicWeb3Connector() {
  23686. var _context;
  23687. var _this;
  23688. (0, _classCallCheck2.default)(this, MagicWeb3Connector);
  23689. for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
  23690. args[_key] = arguments[_key];
  23691. }
  23692. _this = _super.call.apply(_super, (0, _concat.default)(_context = [this]).call(_context, args));
  23693. (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "type", 'MagicLink');
  23694. (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "deactivate", /*#__PURE__*/(0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee() {
  23695. return _regenerator.default.wrap(function (_context2) {
  23696. while (1) {
  23697. switch (_context2.prev = _context2.next) {
  23698. case 0:
  23699. _this.unsubscribeToEvents(_this.provider);
  23700. if (!_this.magicUser) {
  23701. _context2.next = 4;
  23702. break;
  23703. }
  23704. _context2.next = 4;
  23705. return _this.magicUser.user.logout();
  23706. case 4:
  23707. _this.account = null;
  23708. _this.chainId = null;
  23709. _this.provider = null;
  23710. case 7:
  23711. case "end":
  23712. return _context2.stop();
  23713. }
  23714. }
  23715. }, _callee);
  23716. })));
  23717. return _this;
  23718. }
  23719. (0, _createClass2.default)(MagicWeb3Connector, [{
  23720. key: "activate",
  23721. value: function () {
  23722. var _activate = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee2() {
  23723. var _ref2,
  23724. email,
  23725. apiKey,
  23726. network,
  23727. newSession,
  23728. magic,
  23729. ether,
  23730. Magic,
  23731. _require,
  23732. _window,
  23733. _magic,
  23734. _magic2,
  23735. _magic2$user,
  23736. loggedIn,
  23737. signer,
  23738. _yield$ether$getNetwo,
  23739. chainId,
  23740. address,
  23741. _args2 = arguments;
  23742. return _regenerator.default.wrap(function (_context3) {
  23743. while (1) {
  23744. switch (_context3.prev = _context3.next) {
  23745. case 0:
  23746. _ref2 = _args2.length > 0 && _args2[0] !== undefined ? _args2[0] : {}, email = _ref2.email, apiKey = _ref2.apiKey, network = _ref2.network, newSession = _ref2.newSession;
  23747. magic = null;
  23748. ether = null;
  23749. if (email) {
  23750. _context3.next = 5;
  23751. break;
  23752. }
  23753. throw new Error('"email" not provided, please provide Email');
  23754. case 5:
  23755. if (apiKey) {
  23756. _context3.next = 7;
  23757. break;
  23758. }
  23759. throw new Error('"apiKey" not provided, please provide Api Key');
  23760. case 7:
  23761. if (network) {
  23762. _context3.next = 9;
  23763. break;
  23764. }
  23765. throw new Error('"network" not provided, please provide network');
  23766. case 9:
  23767. try {
  23768. Magic = (_require = _dereq_('magic-sdk')) === null || _require === void 0 ? void 0 : _require.Magic;
  23769. } catch (error) {// Do nothing. User might not need walletconnect
  23770. }
  23771. if (!Magic) {
  23772. Magic = (_window = window) === null || _window === void 0 ? void 0 : _window.Magic;
  23773. }
  23774. if (Magic) {
  23775. _context3.next = 13;
  23776. break;
  23777. }
  23778. throw new Error('Cannot enable via MagicLink: dependency "magic-sdk" is missing');
  23779. case 13:
  23780. _context3.prev = 13;
  23781. magic = new Magic(apiKey, {
  23782. network: network
  23783. });
  23784. if (!newSession) {
  23785. _context3.next = 24;
  23786. break;
  23787. }
  23788. if (!((_magic = magic) !== null && _magic !== void 0 && _magic.user)) {
  23789. _context3.next = 24;
  23790. break;
  23791. }
  23792. _context3.prev = 17;
  23793. _context3.next = 20;
  23794. return (_magic2 = magic) === null || _magic2 === void 0 ? void 0 : (_magic2$user = _magic2.user) === null || _magic2$user === void 0 ? void 0 : _magic2$user.logout();
  23795. case 20:
  23796. _context3.next = 24;
  23797. break;
  23798. case 22:
  23799. _context3.prev = 22;
  23800. _context3.t0 = _context3["catch"](17);
  23801. case 24:
  23802. ether = new _ethers.ethers.providers.Web3Provider(magic.rpcProvider);
  23803. _context3.next = 27;
  23804. return magic.auth.loginWithMagicLink({
  23805. email: email
  23806. });
  23807. case 27:
  23808. _context3.next = 32;
  23809. break;
  23810. case 29:
  23811. _context3.prev = 29;
  23812. _context3.t1 = _context3["catch"](13);
  23813. throw new Error('Error during enable via MagicLink, please double check network and apikey');
  23814. case 32:
  23815. _context3.next = 34;
  23816. return magic.user.isLoggedIn();
  23817. case 34:
  23818. loggedIn = _context3.sent;
  23819. if (!loggedIn) {
  23820. _context3.next = 50;
  23821. break;
  23822. }
  23823. signer = ether.getSigner();
  23824. _context3.next = 39;
  23825. return ether.getNetwork();
  23826. case 39:
  23827. _yield$ether$getNetwo = _context3.sent;
  23828. chainId = _yield$ether$getNetwo.chainId;
  23829. _context3.next = 43;
  23830. return signer.getAddress();
  23831. case 43:
  23832. address = _context3.sent.toLowerCase(); // Assign Constants
  23833. this.account = address;
  23834. this.provider = ether.provider;
  23835. this.chainId = "0x".concat(chainId.toString(16)); // Assign magic user for deactivation
  23836. this.magicUser = magic;
  23837. this.subscribeToEvents(this.provider);
  23838. return _context3.abrupt("return", {
  23839. provider: this.provider,
  23840. account: this.account,
  23841. chainId: this.chainId
  23842. });
  23843. case 50:
  23844. throw new Error('Error during enable via MagicLink, login to magic failed');
  23845. case 51:
  23846. case "end":
  23847. return _context3.stop();
  23848. }
  23849. }
  23850. }, _callee2, this, [[13, 29], [17, 22]]);
  23851. }));
  23852. return function () {
  23853. return _activate.apply(this, arguments);
  23854. };
  23855. }()
  23856. }]);
  23857. return MagicWeb3Connector;
  23858. }(_AbstractWeb3Connector.default);
  23859. exports.default = MagicWeb3Connector;
  23860. },{"./AbstractWeb3Connector":54,"@babel/runtime-corejs3/core-js-stable/instance/concat":81,"@babel/runtime-corejs3/core-js-stable/object/define-property":105,"@babel/runtime-corejs3/core-js-stable/reflect/construct":116,"@babel/runtime-corejs3/helpers/assertThisInitialized":143,"@babel/runtime-corejs3/helpers/asyncToGenerator":144,"@babel/runtime-corejs3/helpers/classCallCheck":145,"@babel/runtime-corejs3/helpers/createClass":147,"@babel/runtime-corejs3/helpers/defineProperty":148,"@babel/runtime-corejs3/helpers/getPrototypeOf":150,"@babel/runtime-corejs3/helpers/inherits":151,"@babel/runtime-corejs3/helpers/interopRequireDefault":152,"@babel/runtime-corejs3/helpers/possibleConstructorReturn":159,"@babel/runtime-corejs3/regenerator":167,"ethers":773,"magic-sdk":323}],57:[function(_dereq_,module,exports){
  23861. "use strict";
  23862. var _Object$defineProperty = _dereq_("@babel/runtime-corejs3/core-js-stable/object/define-property");
  23863. _Object$defineProperty(exports, "__esModule", {
  23864. value: true
  23865. });
  23866. exports.getMoralisRpcs = void 0;
  23867. var getMoralisRpcs = function (speedyNodeKey) {
  23868. return {
  23869. 1: "https://speedy-nodes-nyc.moralis.io/".concat(speedyNodeKey, "/eth/mainnet"),
  23870. 3: "https://speedy-nodes-nyc.moralis.io/".concat(speedyNodeKey, "/eth/ropsten"),
  23871. 4: "https://speedy-nodes-nyc.moralis.io/".concat(speedyNodeKey, "/eth/rinkeby"),
  23872. 5: "https://speedy-nodes-nyc.moralis.io/".concat(speedyNodeKey, "/eth/goerli"),
  23873. 42: "https://speedy-nodes-nyc.moralis.io/".concat(speedyNodeKey, "/eth/kovan"),
  23874. 137: "https://speedy-nodes-nyc.moralis.io/".concat(speedyNodeKey, "/polygon/mainnet"),
  23875. 80001: "https://speedy-nodes-nyc.moralis.io/".concat(speedyNodeKey, "/polygon/mumbai"),
  23876. 56: "https://speedy-nodes-nyc.moralis.io/".concat(speedyNodeKey, "/bsc/mainnet"),
  23877. 97: "https://speedy-nodes-nyc.moralis.io/".concat(speedyNodeKey, "/bsc/testnet"),
  23878. 43114: "https://speedy-nodes-nyc.moralis.io/".concat(speedyNodeKey, "/avalanche/mainnet"),
  23879. 43113: "https://speedy-nodes-nyc.moralis.io/".concat(speedyNodeKey, "/avalanche/testnet"),
  23880. 250: "https://speedy-nodes-nyc.moralis.io/".concat(speedyNodeKey, "/fantom/mainnet")
  23881. };
  23882. };
  23883. exports.getMoralisRpcs = getMoralisRpcs;
  23884. },{"@babel/runtime-corejs3/core-js-stable/object/define-property":105}],58:[function(_dereq_,module,exports){
  23885. "use strict";
  23886. var _Reflect$construct = _dereq_("@babel/runtime-corejs3/core-js-stable/reflect/construct");
  23887. var _Object$defineProperty = _dereq_("@babel/runtime-corejs3/core-js-stable/object/define-property");
  23888. var _interopRequireDefault = _dereq_("@babel/runtime-corejs3/helpers/interopRequireDefault");
  23889. _Object$defineProperty(exports, "__esModule", {
  23890. value: true
  23891. });
  23892. exports.default = void 0;
  23893. var _regenerator = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/regenerator"));
  23894. var _stringify = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/json/stringify"));
  23895. var _concat = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/instance/concat"));
  23896. var _url = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/url"));
  23897. var _keys = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/object/keys"));
  23898. var _reduce = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/instance/reduce"));
  23899. var _assertThisInitialized2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/helpers/assertThisInitialized"));
  23900. var _inherits2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/helpers/inherits"));
  23901. var _possibleConstructorReturn2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/helpers/possibleConstructorReturn"));
  23902. var _getPrototypeOf2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/helpers/getPrototypeOf"));
  23903. var _asyncToGenerator2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/helpers/asyncToGenerator"));
  23904. var _createClass2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/helpers/createClass"));
  23905. var _classCallCheck2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/helpers/classCallCheck"));
  23906. var _defineProperty2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/helpers/defineProperty"));
  23907. var _CoreManager = _interopRequireDefault(_dereq_("../CoreManager"));
  23908. var _convert = _dereq_("../utils/convert");
  23909. var _verifyChainId = _interopRequireDefault(_dereq_("../utils/verifyChainId"));
  23910. var _AbstractWeb3Connector = _interopRequireDefault(_dereq_("./AbstractWeb3Connector"));
  23911. var _MoralisRpcs = _dereq_("./MoralisRpcs");
  23912. var _ethers = _dereq_("ethers");
  23913. function _createSuper(Derived) {
  23914. var hasNativeReflectConstruct = _isNativeReflectConstruct();
  23915. return function () {
  23916. var Super = (0, _getPrototypeOf2.default)(Derived),
  23917. result;
  23918. if (hasNativeReflectConstruct) {
  23919. var NewTarget = (0, _getPrototypeOf2.default)(this).constructor;
  23920. result = _Reflect$construct(Super, arguments, NewTarget);
  23921. } else {
  23922. result = Super.apply(this, arguments);
  23923. }
  23924. return (0, _possibleConstructorReturn2.default)(this, result);
  23925. };
  23926. }
  23927. function _isNativeReflectConstruct() {
  23928. if (typeof Reflect === "undefined" || !_Reflect$construct) return false;
  23929. if (_Reflect$construct.sham) return false;
  23930. if (typeof Proxy === "function") return true;
  23931. try {
  23932. Boolean.prototype.valueOf.call(_Reflect$construct(Boolean, [], function () {}));
  23933. return true;
  23934. } catch (e) {
  23935. return false;
  23936. }
  23937. }
  23938. var MiniRpcProvider = /*#__PURE__*/(0, _createClass2.default)(function MiniRpcProvider(chainId, url) {
  23939. var _this = this;
  23940. (0, _classCallCheck2.default)(this, MiniRpcProvider);
  23941. (0, _defineProperty2.default)(this, "request", /*#__PURE__*/function () {
  23942. var _ref = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee(method, params) {
  23943. var RESTController, response, _context, body, _body$error, _body$error2, _body$error3, _context2;
  23944. return _regenerator.default.wrap(function (_context3) {
  23945. while (1) {
  23946. switch (_context3.prev = _context3.next) {
  23947. case 0:
  23948. if (typeof method !== 'string') {
  23949. // eslint-disable-next-line prefer-destructuring
  23950. params = method.params; // eslint-disable-next-line prefer-destructuring
  23951. method = method.method;
  23952. }
  23953. RESTController = _CoreManager.default.getRESTController();
  23954. _context3.prev = 2;
  23955. _context3.next = 5;
  23956. return RESTController.ajax('POST', _this.url, (0, _stringify.default)({
  23957. jsonrpc: '2.0',
  23958. id: 1,
  23959. method: method,
  23960. params: params
  23961. }), {
  23962. 'Content-Type': 'application/json'
  23963. });
  23964. case 5:
  23965. response = _context3.sent;
  23966. if (response) {
  23967. _context3.next = 8;
  23968. break;
  23969. }
  23970. throw new Error('No response');
  23971. case 8:
  23972. if (!(!response.status || response.status > 400)) {
  23973. _context3.next = 10;
  23974. break;
  23975. }
  23976. throw new Error((0, _concat.default)(_context = "Error response [".concat(response.status, "] ")).call(_context, response.statusText));
  23977. case 10:
  23978. body = response.response;
  23979. if (!('error' in body)) {
  23980. _context3.next = 13;
  23981. break;
  23982. }
  23983. throw new Error(body === null || body === void 0 ? void 0 : (_body$error = body.error) === null || _body$error === void 0 ? void 0 : _body$error.message, body === null || body === void 0 ? void 0 : (_body$error2 = body.error) === null || _body$error2 === void 0 ? void 0 : _body$error2.code, body === null || body === void 0 ? void 0 : (_body$error3 = body.error) === null || _body$error3 === void 0 ? void 0 : _body$error3.data);
  23984. case 13:
  23985. if ('result' in body) {
  23986. _context3.next = 15;
  23987. break;
  23988. }
  23989. throw new Error("Received unexpected JSON-RPC response");
  23990. case 15:
  23991. return _context3.abrupt("return", body.result);
  23992. case 18:
  23993. _context3.prev = 18;
  23994. _context3.t0 = _context3["catch"](2);
  23995. throw new Error((0, _concat.default)(_context2 = "Failed to make \"".concat(method, "\" request with networkConnector: \"")).call(_context2, _context3.t0.message, "\""));
  23996. case 21:
  23997. case "end":
  23998. return _context3.stop();
  23999. }
  24000. }
  24001. }, _callee, null, [[2, 18]]);
  24002. }));
  24003. return function () {
  24004. return _ref.apply(this, arguments);
  24005. };
  24006. }());
  24007. this.chainId = chainId;
  24008. this.url = url;
  24009. var parsed = new _url.default(url);
  24010. this.host = parsed.host;
  24011. this.path = parsed.pathname;
  24012. });
  24013. /**
  24014. * Connect to web3 via a network url
  24015. * Note: this has no knowledge of any user accounts
  24016. */
  24017. var NetworkWeb3Connector = /*#__PURE__*/function (_AbstractWeb3Connecto) {
  24018. (0, _inherits2.default)(NetworkWeb3Connector, _AbstractWeb3Connecto);
  24019. var _super = _createSuper(NetworkWeb3Connector);
  24020. function NetworkWeb3Connector() {
  24021. var _ref3, _context4;
  24022. var _this2;
  24023. var _ref2 = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},
  24024. urls = _ref2.urls,
  24025. defaultChainId = _ref2.defaultChainId,
  24026. chainId = _ref2.chainId,
  24027. speedyNodeApiKey = _ref2.speedyNodeApiKey;
  24028. (0, _classCallCheck2.default)(this, NetworkWeb3Connector);
  24029. _this2 = _super.call(this);
  24030. (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this2), "type", 'network');
  24031. if (!urls && speedyNodeApiKey) {
  24032. urls = (0, _MoralisRpcs.getMoralisRpcs)(speedyNodeApiKey);
  24033. }
  24034. if (!urls && !speedyNodeApiKey) {
  24035. throw new Error('Cannot connect to rpc: No urls or speedyNodeApiKey provided for NetworkWeb3Connector.');
  24036. }
  24037. if ("browser" !== 'node' && speedyNodeApiKey) {
  24038. // eslint-disable-next-line no-console
  24039. console.warn('Using speedyNodeApiKey on the browser enviroment is not recommended, as it is publicly visible.');
  24040. }
  24041. _this2.chainId = (0, _verifyChainId.default)((_ref3 = chainId !== null && chainId !== void 0 ? chainId : defaultChainId) !== null && _ref3 !== void 0 ? _ref3 : Number((0, _keys.default)(urls)[0]));
  24042. _this2.providers = (0, _reduce.default)(_context4 = (0, _keys.default)(urls)).call(_context4, function (accumulator, chainId) {
  24043. accumulator[Number(chainId)] = new MiniRpcProvider(Number(chainId), urls[Number(chainId)]);
  24044. return accumulator;
  24045. }, {});
  24046. return _this2;
  24047. }
  24048. (0, _createClass2.default)(NetworkWeb3Connector, [{
  24049. key: "activate",
  24050. value: function () {
  24051. var _activate = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee2() {
  24052. var _ref4,
  24053. providedChainId,
  24054. _ref4$privateKey,
  24055. privateKey,
  24056. provider,
  24057. _args2 = arguments;
  24058. return _regenerator.default.wrap(function (_context5) {
  24059. while (1) {
  24060. switch (_context5.prev = _context5.next) {
  24061. case 0:
  24062. _ref4 = _args2.length > 0 && _args2[0] !== undefined ? _args2[0] : {}, providedChainId = _ref4.chainId, _ref4$privateKey = _ref4.privateKey, privateKey = _ref4$privateKey === void 0 ? null : _ref4$privateKey;
  24063. if (providedChainId) {
  24064. this.chainId = (0, _verifyChainId.default)(providedChainId);
  24065. }
  24066. provider = this.providers[(0, _convert.fromHexToDecimal)(this.chainId)];
  24067. if (provider) {
  24068. _context5.next = 5;
  24069. break;
  24070. }
  24071. throw new Error("No rpc url provided for chainId ".concat(this.chainId));
  24072. case 5:
  24073. if (!(privateKey != null)) {
  24074. _context5.next = 9;
  24075. break;
  24076. }
  24077. _context5.next = 8;
  24078. return new _ethers.ethers.Wallet(privateKey).getAddress();
  24079. case 8:
  24080. this.account = _context5.sent;
  24081. case 9:
  24082. return _context5.abrupt("return", {
  24083. provider: provider,
  24084. chainId: this.chainId,
  24085. account: this.account
  24086. });
  24087. case 10:
  24088. case "end":
  24089. return _context5.stop();
  24090. }
  24091. }
  24092. }, _callee2, this);
  24093. }));
  24094. return function () {
  24095. return _activate.apply(this, arguments);
  24096. };
  24097. }()
  24098. }]);
  24099. return NetworkWeb3Connector;
  24100. }(_AbstractWeb3Connector.default);
  24101. var _default = NetworkWeb3Connector;
  24102. exports.default = _default;
  24103. },{"../CoreManager":5,"../utils/convert":76,"../utils/verifyChainId":77,"./AbstractWeb3Connector":54,"./MoralisRpcs":57,"@babel/runtime-corejs3/core-js-stable/instance/concat":81,"@babel/runtime-corejs3/core-js-stable/instance/reduce":92,"@babel/runtime-corejs3/core-js-stable/json/stringify":99,"@babel/runtime-corejs3/core-js-stable/object/define-property":105,"@babel/runtime-corejs3/core-js-stable/object/keys":112,"@babel/runtime-corejs3/core-js-stable/reflect/construct":116,"@babel/runtime-corejs3/core-js-stable/url":121,"@babel/runtime-corejs3/helpers/assertThisInitialized":143,"@babel/runtime-corejs3/helpers/asyncToGenerator":144,"@babel/runtime-corejs3/helpers/classCallCheck":145,"@babel/runtime-corejs3/helpers/createClass":147,"@babel/runtime-corejs3/helpers/defineProperty":148,"@babel/runtime-corejs3/helpers/getPrototypeOf":150,"@babel/runtime-corejs3/helpers/inherits":151,"@babel/runtime-corejs3/helpers/interopRequireDefault":152,"@babel/runtime-corejs3/helpers/possibleConstructorReturn":159,"@babel/runtime-corejs3/regenerator":167,"ethers":773}],59:[function(_dereq_,module,exports){
  24104. "use strict";
  24105. var _Reflect$construct = _dereq_("@babel/runtime-corejs3/core-js-stable/reflect/construct");
  24106. var _Object$defineProperty = _dereq_("@babel/runtime-corejs3/core-js-stable/object/define-property");
  24107. var _interopRequireDefault = _dereq_("@babel/runtime-corejs3/helpers/interopRequireDefault");
  24108. _Object$defineProperty(exports, "__esModule", {
  24109. value: true
  24110. });
  24111. exports.default = exports.WalletConnectEvent = void 0;
  24112. var _regenerator = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/regenerator"));
  24113. var _asyncToGenerator2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/helpers/asyncToGenerator"));
  24114. var _classCallCheck2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/helpers/classCallCheck"));
  24115. var _createClass2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/helpers/createClass"));
  24116. var _assertThisInitialized2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/helpers/assertThisInitialized"));
  24117. var _inherits2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/helpers/inherits"));
  24118. var _possibleConstructorReturn2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/helpers/possibleConstructorReturn"));
  24119. var _getPrototypeOf2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/helpers/getPrototypeOf"));
  24120. var _defineProperty2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/helpers/defineProperty"));
  24121. var _freeze = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/object/freeze"));
  24122. var _concat = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/instance/concat"));
  24123. var _verifyChainId = _interopRequireDefault(_dereq_("../utils/verifyChainId"));
  24124. var _AbstractWeb3Connector = _interopRequireDefault(_dereq_("./AbstractWeb3Connector"));
  24125. var _events = _dereq_("./events");
  24126. var _MoralisRpcs = _dereq_("./MoralisRpcs");
  24127. function _createSuper(Derived) {
  24128. var hasNativeReflectConstruct = _isNativeReflectConstruct();
  24129. return function () {
  24130. var Super = (0, _getPrototypeOf2.default)(Derived),
  24131. result;
  24132. if (hasNativeReflectConstruct) {
  24133. var NewTarget = (0, _getPrototypeOf2.default)(this).constructor;
  24134. result = _Reflect$construct(Super, arguments, NewTarget);
  24135. } else {
  24136. result = Super.apply(this, arguments);
  24137. }
  24138. return (0, _possibleConstructorReturn2.default)(this, result);
  24139. };
  24140. }
  24141. function _isNativeReflectConstruct() {
  24142. if (typeof Reflect === "undefined" || !_Reflect$construct) return false;
  24143. if (_Reflect$construct.sham) return false;
  24144. if (typeof Proxy === "function") return true;
  24145. try {
  24146. Boolean.prototype.valueOf.call(_Reflect$construct(Boolean, [], function () {}));
  24147. return true;
  24148. } catch (e) {
  24149. return false;
  24150. }
  24151. }
  24152. var WalletConnectEvent = (0, _freeze.default)({
  24153. ACCOUNTS_CHANGED: 'accountsChanged',
  24154. CHAIN_CHANGED: 'chainChanged',
  24155. DISCONNECT: 'disconnect'
  24156. });
  24157. /**
  24158. * Connector to connect an WalletConenct provider to Moralis
  24159. * Note: this assumes using WalletConnect v1
  24160. * // TODO: support WalletConnect v2
  24161. */
  24162. exports.WalletConnectEvent = WalletConnectEvent;
  24163. var WalletConnectWeb3Connector = /*#__PURE__*/function (_AbstractWeb3Connecto) {
  24164. (0, _inherits2.default)(WalletConnectWeb3Connector, _AbstractWeb3Connecto);
  24165. var _super = _createSuper(WalletConnectWeb3Connector);
  24166. function WalletConnectWeb3Connector() {
  24167. var _context;
  24168. var _this;
  24169. (0, _classCallCheck2.default)(this, WalletConnectWeb3Connector);
  24170. for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
  24171. args[_key] = arguments[_key];
  24172. }
  24173. _this = _super.call.apply(_super, (0, _concat.default)(_context = [this]).call(_context, args));
  24174. (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "type", 'WalletConnect');
  24175. return _this;
  24176. }
  24177. (0, _createClass2.default)(WalletConnectWeb3Connector, [{
  24178. key: "activate",
  24179. value: function () {
  24180. var _activate = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee() {
  24181. var _ref,
  24182. providedChainId,
  24183. mobileLinks,
  24184. newSession,
  24185. WalletConnectProvider,
  24186. config,
  24187. _require,
  24188. _window,
  24189. _window$WalletConnect,
  24190. accounts,
  24191. account,
  24192. chainId,
  24193. verifiedChainId,
  24194. _args = arguments;
  24195. return _regenerator.default.wrap(function (_context2) {
  24196. while (1) {
  24197. switch (_context2.prev = _context2.next) {
  24198. case 0:
  24199. _ref = _args.length > 0 && _args[0] !== undefined ? _args[0] : {}, providedChainId = _ref.chainId, mobileLinks = _ref.mobileLinks, newSession = _ref.newSession; // Log out of any previous sessions
  24200. if (newSession) {
  24201. this.cleanup();
  24202. }
  24203. if (this.provider) {
  24204. _context2.next = 9;
  24205. break;
  24206. }
  24207. config = {
  24208. rpc: (0, _MoralisRpcs.getMoralisRpcs)('WalletConnect'),
  24209. chainId: providedChainId,
  24210. qrcodeModalOptions: {
  24211. mobileLinks: mobileLinks
  24212. }
  24213. };
  24214. try {
  24215. WalletConnectProvider = (_require = _dereq_('@walletconnect/web3-provider')) === null || _require === void 0 ? void 0 : _require.default;
  24216. } catch (error) {// Do nothing. User might not need walletconnect
  24217. }
  24218. if (!WalletConnectProvider) {
  24219. WalletConnectProvider = (_window = window) === null || _window === void 0 ? void 0 : (_window$WalletConnect = _window.WalletConnectProvider) === null || _window$WalletConnect === void 0 ? void 0 : _window$WalletConnect.default;
  24220. }
  24221. if (WalletConnectProvider) {
  24222. _context2.next = 8;
  24223. break;
  24224. }
  24225. throw new Error('Cannot enable via WalletConnect: dependency "@walletconnect/web3-provider" is missing');
  24226. case 8:
  24227. if (typeof WalletConnectProvider === 'function') {
  24228. this.provider = new WalletConnectProvider(config);
  24229. } else {
  24230. this.provider = new window.WalletConnectProvider(config);
  24231. }
  24232. case 9:
  24233. if (this.provider) {
  24234. _context2.next = 11;
  24235. break;
  24236. }
  24237. throw new Error('Could not connect via WalletConnect, error in connecting to provider');
  24238. case 11:
  24239. _context2.next = 13;
  24240. return this.provider.enable();
  24241. case 13:
  24242. accounts = _context2.sent;
  24243. account = accounts[0].toLowerCase();
  24244. chainId = this.provider.chainId;
  24245. verifiedChainId = (0, _verifyChainId.default)(chainId);
  24246. this.account = account;
  24247. this.chainId = verifiedChainId;
  24248. this.subscribeToEvents(this.provider);
  24249. return _context2.abrupt("return", {
  24250. provider: this.provider,
  24251. account: account,
  24252. chainId: verifiedChainId
  24253. });
  24254. case 21:
  24255. case "end":
  24256. return _context2.stop();
  24257. }
  24258. }
  24259. }, _callee, this);
  24260. }));
  24261. return function () {
  24262. return _activate.apply(this, arguments);
  24263. };
  24264. }() // Cleanup old sessions
  24265. }, {
  24266. key: "cleanup",
  24267. value: function () {
  24268. try {
  24269. if (window) {
  24270. window.localStorage.removeItem('walletconnect');
  24271. }
  24272. } catch (error) {// Do nothing
  24273. }
  24274. }
  24275. }, {
  24276. key: "deactivate",
  24277. value: function () {
  24278. var _deactivate = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee2() {
  24279. return _regenerator.default.wrap(function (_context3) {
  24280. while (1) {
  24281. switch (_context3.prev = _context3.next) {
  24282. case 0:
  24283. this.unsubscribeToEvents(this.provider);
  24284. if (!this.provider) {
  24285. _context3.next = 9;
  24286. break;
  24287. }
  24288. _context3.prev = 2;
  24289. _context3.next = 5;
  24290. return this.provider.close();
  24291. case 5:
  24292. _context3.next = 9;
  24293. break;
  24294. case 7:
  24295. _context3.prev = 7;
  24296. _context3.t0 = _context3["catch"](2);
  24297. case 9:
  24298. this.account = null;
  24299. this.chainId = null;
  24300. this.provider = null;
  24301. case 12:
  24302. case "end":
  24303. return _context3.stop();
  24304. }
  24305. }
  24306. }, _callee2, this, [[2, 7]]);
  24307. }));
  24308. return function () {
  24309. return _deactivate.apply(this, arguments);
  24310. };
  24311. }()
  24312. }]);
  24313. return WalletConnectWeb3Connector;
  24314. }(_AbstractWeb3Connector.default);
  24315. var _default = WalletConnectWeb3Connector;
  24316. exports.default = _default;
  24317. },{"../utils/verifyChainId":77,"./AbstractWeb3Connector":54,"./MoralisRpcs":57,"./events":61,"@babel/runtime-corejs3/core-js-stable/instance/concat":81,"@babel/runtime-corejs3/core-js-stable/object/define-property":105,"@babel/runtime-corejs3/core-js-stable/object/freeze":107,"@babel/runtime-corejs3/core-js-stable/reflect/construct":116,"@babel/runtime-corejs3/helpers/assertThisInitialized":143,"@babel/runtime-corejs3/helpers/asyncToGenerator":144,"@babel/runtime-corejs3/helpers/classCallCheck":145,"@babel/runtime-corejs3/helpers/createClass":147,"@babel/runtime-corejs3/helpers/defineProperty":148,"@babel/runtime-corejs3/helpers/getPrototypeOf":150,"@babel/runtime-corejs3/helpers/inherits":151,"@babel/runtime-corejs3/helpers/interopRequireDefault":152,"@babel/runtime-corejs3/helpers/possibleConstructorReturn":159,"@babel/runtime-corejs3/regenerator":167,"@walletconnect/web3-provider":323}],60:[function(_dereq_,module,exports){
  24318. "use strict";
  24319. var _Reflect$construct = _dereq_("@babel/runtime-corejs3/core-js-stable/reflect/construct");
  24320. var _Object$defineProperty = _dereq_("@babel/runtime-corejs3/core-js-stable/object/define-property");
  24321. var _interopRequireDefault = _dereq_("@babel/runtime-corejs3/helpers/interopRequireDefault");
  24322. _Object$defineProperty(exports, "__esModule", {
  24323. value: true
  24324. });
  24325. exports.Web3Auth = void 0;
  24326. var _regenerator = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/regenerator"));
  24327. var _concat = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/instance/concat"));
  24328. var _promise = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/promise"));
  24329. var _asyncToGenerator2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/helpers/asyncToGenerator"));
  24330. var _createClass2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/helpers/createClass"));
  24331. var _classCallCheck2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/helpers/classCallCheck"));
  24332. var _assertThisInitialized2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/helpers/assertThisInitialized"));
  24333. var _inherits2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/helpers/inherits"));
  24334. var _possibleConstructorReturn2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/helpers/possibleConstructorReturn"));
  24335. var _getPrototypeOf2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/helpers/getPrototypeOf"));
  24336. var _defineProperty2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/helpers/defineProperty"));
  24337. var _ethers = _dereq_("ethers");
  24338. var _verifyChainId = _interopRequireDefault(_dereq_("../utils/verifyChainId"));
  24339. var _AbstractWeb3Connector = _interopRequireDefault(_dereq_("./AbstractWeb3Connector"));
  24340. function _createSuper(Derived) {
  24341. var hasNativeReflectConstruct = _isNativeReflectConstruct();
  24342. return function () {
  24343. var Super = (0, _getPrototypeOf2.default)(Derived),
  24344. result;
  24345. if (hasNativeReflectConstruct) {
  24346. var NewTarget = (0, _getPrototypeOf2.default)(this).constructor;
  24347. result = _Reflect$construct(Super, arguments, NewTarget);
  24348. } else {
  24349. result = Super.apply(this, arguments);
  24350. }
  24351. return (0, _possibleConstructorReturn2.default)(this, result);
  24352. };
  24353. }
  24354. function _isNativeReflectConstruct() {
  24355. if (typeof Reflect === "undefined" || !_Reflect$construct) return false;
  24356. if (_Reflect$construct.sham) return false;
  24357. if (typeof Proxy === "function") return true;
  24358. try {
  24359. Boolean.prototype.valueOf.call(_Reflect$construct(Boolean, [], function () {}));
  24360. return true;
  24361. } catch (e) {
  24362. return false;
  24363. }
  24364. }
  24365. var Web3Auth = /*#__PURE__*/function (_AbstractWeb3Connecto) {
  24366. (0, _inherits2.default)(Web3Auth, _AbstractWeb3Connecto);
  24367. var _super = _createSuper(Web3Auth);
  24368. function Web3Auth() {
  24369. var _context;
  24370. var _this;
  24371. (0, _classCallCheck2.default)(this, Web3Auth);
  24372. for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
  24373. args[_key] = arguments[_key];
  24374. }
  24375. _this = _super.call.apply(_super, (0, _concat.default)(_context = [this]).call(_context, args));
  24376. (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "type", 'web3Auth');
  24377. (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "activate", /*#__PURE__*/(0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee() {
  24378. var _ref2,
  24379. _ref2$chainId,
  24380. chainId,
  24381. clientId,
  24382. theme,
  24383. appLogo,
  24384. loginMethodsOrder,
  24385. _Web3Auth,
  24386. _require,
  24387. _window,
  24388. _window$Web3auth,
  24389. ethChainConfig,
  24390. web3auth,
  24391. provider,
  24392. _web3auth,
  24393. _web3auth2,
  24394. _web3auth3,
  24395. isSocialLogin,
  24396. ether,
  24397. signer,
  24398. values,
  24399. providerChainId,
  24400. _args = arguments;
  24401. return _regenerator.default.wrap(function (_context2) {
  24402. while (1) {
  24403. switch (_context2.prev = _context2.next) {
  24404. case 0:
  24405. _ref2 = _args.length > 0 && _args[0] !== undefined ? _args[0] : {}, _ref2$chainId = _ref2.chainId, chainId = _ref2$chainId === void 0 ? '0x1' : _ref2$chainId, clientId = _ref2.clientId, theme = _ref2.theme, appLogo = _ref2.appLogo, loginMethodsOrder = _ref2.loginMethodsOrder;
  24406. if (clientId) {
  24407. _context2.next = 3;
  24408. break;
  24409. }
  24410. throw new Error('"clientId" not provided, please provide clientId');
  24411. case 3:
  24412. try {
  24413. _Web3Auth = (_require = _dereq_('@web3auth/web3auth')) === null || _require === void 0 ? void 0 : _require.Web3Auth;
  24414. } catch (_unused) {// Do Nothing Individual Checks are done below
  24415. } // Check if user is using CDN to import
  24416. if (!_Web3Auth) {
  24417. _Web3Auth = (_window = window) === null || _window === void 0 ? void 0 : (_window$Web3auth = _window.Web3auth) === null || _window$Web3auth === void 0 ? void 0 : _window$Web3auth.Web3Auth;
  24418. } // Error checking for if library is not installed
  24419. if (_Web3Auth) {
  24420. _context2.next = 7;
  24421. break;
  24422. }
  24423. throw new Error('"@web3auth/web3auth" not installed, please install');
  24424. case 7:
  24425. // Build config
  24426. ethChainConfig = {
  24427. chainNamespace: 'eip155',
  24428. chainId: (0, _verifyChainId.default)(chainId)
  24429. }; // Build Web3Auth
  24430. try {
  24431. web3auth = new _Web3Auth({
  24432. chainConfig: ethChainConfig,
  24433. uiConfig: {
  24434. theme: theme !== null && theme !== void 0 ? theme : 'dark',
  24435. appLogo: appLogo !== null && appLogo !== void 0 ? appLogo : 'https://moralis.io/wp-content/uploads/2021/05/moralisWhiteLogo.svg',
  24436. loginMethodsOrder: loginMethodsOrder
  24437. },
  24438. clientId: clientId
  24439. });
  24440. } catch (_unused2) {// Do Nothing error checked below
  24441. }
  24442. if (web3auth) {
  24443. _context2.next = 11;
  24444. break;
  24445. }
  24446. throw new Error('Could not connect via Web3Auth, error during initializing Web3Auth');
  24447. case 11:
  24448. _context2.next = 13;
  24449. return web3auth.initModal();
  24450. case 13:
  24451. provider = null;
  24452. _context2.prev = 14;
  24453. _context2.next = 17;
  24454. return web3auth.connect();
  24455. case 17:
  24456. provider = _context2.sent;
  24457. _context2.next = 22;
  24458. break;
  24459. case 20:
  24460. _context2.prev = 20;
  24461. _context2.t0 = _context2["catch"](14);
  24462. case 22:
  24463. if (provider) {
  24464. _context2.next = 24;
  24465. break;
  24466. }
  24467. throw new Error('Could not connect via Web3Auth, error in connecting to provider');
  24468. case 24:
  24469. _context2.prev = 24;
  24470. isSocialLogin = (_web3auth = web3auth) !== null && _web3auth !== void 0 && _web3auth.provider ? false : true;
  24471. ether = new _ethers.ethers.providers.Web3Provider((_web3auth2 = web3auth) !== null && _web3auth2 !== void 0 && _web3auth2.provider ? web3auth.provider : web3auth);
  24472. signer = ether.getSigner();
  24473. _context2.next = 30;
  24474. return _promise.default.all([ether.getNetwork(), signer.getAddress()]);
  24475. case 30:
  24476. values = _context2.sent;
  24477. providerChainId = values[0].chainId;
  24478. _this.account = values[1].toLocaleLowerCase();
  24479. _this.chainId = "0x".concat(providerChainId.toString(16));
  24480. _this.provider = isSocialLogin ? ether : (_web3auth3 = web3auth) === null || _web3auth3 === void 0 ? void 0 : _web3auth3.provider;
  24481. _this.web3Instance = web3auth;
  24482. _this.subscribeToEvents(_this.provider);
  24483. return _context2.abrupt("return", {
  24484. chainId: _this.chainId,
  24485. account: _this.account,
  24486. provider: _this.provider
  24487. });
  24488. case 40:
  24489. _context2.prev = 40;
  24490. _context2.t1 = _context2["catch"](24);
  24491. throw new Error('Could not connect via Web3Auth, error while authenticating');
  24492. case 43:
  24493. case "end":
  24494. return _context2.stop();
  24495. }
  24496. }
  24497. }, _callee, null, [[14, 20], [24, 40]]);
  24498. })));
  24499. (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "deactivate", /*#__PURE__*/(0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee2() {
  24500. return _regenerator.default.wrap(function (_context3) {
  24501. while (1) {
  24502. switch (_context3.prev = _context3.next) {
  24503. case 0:
  24504. _this.unsubscribeToEvents(_this.provider);
  24505. if (!_this.web3Instance) {
  24506. _context3.next = 4;
  24507. break;
  24508. }
  24509. _context3.next = 4;
  24510. return _this.web3Instance.logout();
  24511. case 4:
  24512. _this.account = null;
  24513. _this.chainId = null;
  24514. _this.provider = null;
  24515. case 7:
  24516. case "end":
  24517. return _context3.stop();
  24518. }
  24519. }
  24520. }, _callee2);
  24521. })));
  24522. return _this;
  24523. }
  24524. return (0, _createClass2.default)(Web3Auth);
  24525. }(_AbstractWeb3Connector.default);
  24526. exports.Web3Auth = Web3Auth;
  24527. },{"../utils/verifyChainId":77,"./AbstractWeb3Connector":54,"@babel/runtime-corejs3/core-js-stable/instance/concat":81,"@babel/runtime-corejs3/core-js-stable/object/define-property":105,"@babel/runtime-corejs3/core-js-stable/promise":115,"@babel/runtime-corejs3/core-js-stable/reflect/construct":116,"@babel/runtime-corejs3/helpers/assertThisInitialized":143,"@babel/runtime-corejs3/helpers/asyncToGenerator":144,"@babel/runtime-corejs3/helpers/classCallCheck":145,"@babel/runtime-corejs3/helpers/createClass":147,"@babel/runtime-corejs3/helpers/defineProperty":148,"@babel/runtime-corejs3/helpers/getPrototypeOf":150,"@babel/runtime-corejs3/helpers/inherits":151,"@babel/runtime-corejs3/helpers/interopRequireDefault":152,"@babel/runtime-corejs3/helpers/possibleConstructorReturn":159,"@babel/runtime-corejs3/regenerator":167,"@web3auth/web3auth":323,"ethers":773}],61:[function(_dereq_,module,exports){
  24528. "use strict";
  24529. var _Object$defineProperty = _dereq_("@babel/runtime-corejs3/core-js-stable/object/define-property");
  24530. var _interopRequireDefault = _dereq_("@babel/runtime-corejs3/helpers/interopRequireDefault");
  24531. _Object$defineProperty(exports, "__esModule", {
  24532. value: true
  24533. });
  24534. exports.EthereumEvents = exports.ConnectorEvents = void 0;
  24535. var _freeze = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/object/freeze")); // Events being emitted by an eip-1193 provider
  24536. // See https://eips.ethereum.org/EIPS/eip-1193#events
  24537. var EthereumEvents = (0, _freeze.default)({
  24538. CONNECT: 'connect',
  24539. DISCONNECT: 'disconnect',
  24540. CHAIN_CHANGED: 'chainChanged',
  24541. ACCOUNTS_CHANGED: 'accountsChanged'
  24542. }); // Events emitted by the connectors,
  24543. // The InternalWeb3Provider of Moralis will listen to these
  24544. exports.EthereumEvents = EthereumEvents;
  24545. var ConnectorEvents = (0, _freeze.default)({
  24546. CONNECT: 'connect',
  24547. DISCONNECT: 'disconnect',
  24548. CHAIN_CHANGED: 'chainChanged',
  24549. ACCOUNT_CHANGED: 'accountChanged'
  24550. });
  24551. exports.ConnectorEvents = ConnectorEvents;
  24552. },{"@babel/runtime-corejs3/core-js-stable/object/define-property":105,"@babel/runtime-corejs3/core-js-stable/object/freeze":107,"@babel/runtime-corejs3/helpers/interopRequireDefault":152}],62:[function(_dereq_,module,exports){
  24553. "use strict";
  24554. var _Object$defineProperty = _dereq_("@babel/runtime-corejs3/core-js-stable/object/define-property");
  24555. var _interopRequireDefault = _dereq_("@babel/runtime-corejs3/helpers/interopRequireDefault");
  24556. _Object$defineProperty(exports, "__esModule", {
  24557. value: true
  24558. });
  24559. exports.default = arrayContainsObject;
  24560. var _indexOf = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/instance/index-of"));
  24561. var _ParseObject = _interopRequireDefault(_dereq_("./ParseObject"));
  24562. /**
  24563. * Copyright (c) 2015-present, Parse, LLC.
  24564. * All rights reserved.
  24565. *
  24566. * This source code is licensed under the BSD-style license found in the
  24567. * LICENSE file in the root directory of this source tree. An additional grant
  24568. * of patent rights can be found in the PATENTS file in the same directory.
  24569. *
  24570. * @flow
  24571. */
  24572. function arrayContainsObject(array
  24573. /*: Array<any>*/
  24574. , object
  24575. /*: ParseObject*/
  24576. )
  24577. /*: boolean*/
  24578. {
  24579. if ((0, _indexOf.default)(array).call(array, object) > -1) {
  24580. return true;
  24581. }
  24582. for (var i = 0; i < array.length; i++) {
  24583. if (array[i] instanceof _ParseObject.default && array[i].className === object.className && array[i]._getId() === object._getId()) {
  24584. return true;
  24585. }
  24586. }
  24587. return false;
  24588. }
  24589. },{"./ParseObject":36,"@babel/runtime-corejs3/core-js-stable/instance/index-of":88,"@babel/runtime-corejs3/core-js-stable/object/define-property":105,"@babel/runtime-corejs3/helpers/interopRequireDefault":152}],63:[function(_dereq_,module,exports){
  24590. "use strict";
  24591. var _Object$defineProperty = _dereq_("@babel/runtime-corejs3/core-js-stable/object/define-property");
  24592. var _interopRequireDefault = _dereq_("@babel/runtime-corejs3/helpers/interopRequireDefault");
  24593. _Object$defineProperty(exports, "__esModule", {
  24594. value: true
  24595. });
  24596. exports.default = canBeSerialized;
  24597. var _isArray = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/array/is-array"));
  24598. var _typeof2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/helpers/typeof"));
  24599. var _ParseFile = _interopRequireDefault(_dereq_("./ParseFile"));
  24600. var _ParseObject = _interopRequireDefault(_dereq_("./ParseObject"));
  24601. var _ParseRelation = _interopRequireDefault(_dereq_("./ParseRelation"));
  24602. /**
  24603. * Copyright (c) 2015-present, Parse, LLC.
  24604. * All rights reserved.
  24605. *
  24606. * This source code is licensed under the BSD-style license found in the
  24607. * LICENSE file in the root directory of this source tree. An additional grant
  24608. * of patent rights can be found in the PATENTS file in the same directory.
  24609. *
  24610. * @flow
  24611. */
  24612. function canBeSerialized(obj
  24613. /*: ParseObject*/
  24614. )
  24615. /*: boolean*/
  24616. {
  24617. if (!(obj instanceof _ParseObject.default)) {
  24618. return true;
  24619. }
  24620. var attributes = obj.attributes;
  24621. for (var attr in attributes) {
  24622. var val = attributes[attr];
  24623. if (!canBeSerializedHelper(val)) {
  24624. return false;
  24625. }
  24626. }
  24627. return true;
  24628. }
  24629. function canBeSerializedHelper(value
  24630. /*: any*/
  24631. )
  24632. /*: boolean*/
  24633. {
  24634. if ((0, _typeof2.default)(value) !== 'object') {
  24635. return true;
  24636. }
  24637. if (value instanceof _ParseRelation.default) {
  24638. return true;
  24639. }
  24640. if (value instanceof _ParseObject.default) {
  24641. return !!value.id;
  24642. }
  24643. if (value instanceof _ParseFile.default) {
  24644. if (value.url()) {
  24645. return true;
  24646. }
  24647. return false;
  24648. }
  24649. if ((0, _isArray.default)(value)) {
  24650. for (var i = 0; i < value.length; i++) {
  24651. if (!canBeSerializedHelper(value[i])) {
  24652. return false;
  24653. }
  24654. }
  24655. return true;
  24656. }
  24657. for (var k in value) {
  24658. if (!canBeSerializedHelper(value[k])) {
  24659. return false;
  24660. }
  24661. }
  24662. return true;
  24663. }
  24664. },{"./ParseFile":30,"./ParseObject":36,"./ParseRelation":40,"@babel/runtime-corejs3/core-js-stable/array/is-array":79,"@babel/runtime-corejs3/core-js-stable/object/define-property":105,"@babel/runtime-corejs3/helpers/interopRequireDefault":152,"@babel/runtime-corejs3/helpers/typeof":164}],64:[function(_dereq_,module,exports){
  24665. "use strict";
  24666. var _Object$defineProperty = _dereq_("@babel/runtime-corejs3/core-js-stable/object/define-property");
  24667. var _interopRequireDefault = _dereq_("@babel/runtime-corejs3/helpers/interopRequireDefault");
  24668. _Object$defineProperty(exports, "__esModule", {
  24669. value: true
  24670. });
  24671. exports.default = createSigningData;
  24672. var _regenerator = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/regenerator"));
  24673. var _concat = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/instance/concat"));
  24674. var _asyncToGenerator2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/helpers/asyncToGenerator"));
  24675. var _CoreManager = _interopRequireDefault(_dereq_("./CoreManager"));
  24676. var _Cloud = _dereq_("./Cloud");
  24677. /**
  24678. * Creates the data for the authentication message by extending the message
  24679. * with a unique string with applicationId and current time
  24680. */
  24681. function createSigningData() {
  24682. return _createSigningData.apply(this, arguments);
  24683. }
  24684. function _createSigningData() {
  24685. _createSigningData = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee(message) {
  24686. var data, _context, _context2, _yield$run, dateTime, applicationId;
  24687. return _regenerator.default.wrap(function (_context3) {
  24688. while (1) {
  24689. switch (_context3.prev = _context3.next) {
  24690. case 0:
  24691. _context3.prev = 0;
  24692. _context3.next = 3;
  24693. return (0, _Cloud.run)('getServerTime');
  24694. case 3:
  24695. _yield$run = _context3.sent;
  24696. dateTime = _yield$run.dateTime;
  24697. applicationId = _CoreManager.default.get('APPLICATION_ID');
  24698. data = (0, _concat.default)(_context = (0, _concat.default)(_context2 = "".concat(message, "\n\nId: ")).call(_context2, applicationId, ":")).call(_context, dateTime);
  24699. _context3.next = 12;
  24700. break;
  24701. case 9:
  24702. _context3.prev = 9;
  24703. _context3.t0 = _context3["catch"](0);
  24704. data = "".concat(message);
  24705. case 12:
  24706. return _context3.abrupt("return", data);
  24707. case 13:
  24708. case "end":
  24709. return _context3.stop();
  24710. }
  24711. }
  24712. }, _callee, null, [[0, 9]]);
  24713. }));
  24714. return _createSigningData.apply(this, arguments);
  24715. }
  24716. },{"./Cloud":4,"./CoreManager":5,"@babel/runtime-corejs3/core-js-stable/instance/concat":81,"@babel/runtime-corejs3/core-js-stable/object/define-property":105,"@babel/runtime-corejs3/helpers/asyncToGenerator":144,"@babel/runtime-corejs3/helpers/interopRequireDefault":152,"@babel/runtime-corejs3/regenerator":167}],65:[function(_dereq_,module,exports){
  24717. "use strict";
  24718. var _Object$defineProperty = _dereq_("@babel/runtime-corejs3/core-js-stable/object/define-property");
  24719. var _interopRequireDefault = _dereq_("@babel/runtime-corejs3/helpers/interopRequireDefault");
  24720. _Object$defineProperty(exports, "__esModule", {
  24721. value: true
  24722. });
  24723. exports.default = decode;
  24724. var _isArray = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/array/is-array"));
  24725. var _forEach = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/instance/for-each"));
  24726. var _typeof2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/helpers/typeof"));
  24727. var _ParseACL = _interopRequireDefault(_dereq_("./ParseACL"));
  24728. var _ParseFile = _interopRequireDefault(_dereq_("./ParseFile"));
  24729. var _ParseGeoPoint = _interopRequireDefault(_dereq_("./ParseGeoPoint"));
  24730. var _ParsePolygon = _interopRequireDefault(_dereq_("./ParsePolygon"));
  24731. var _ParseObject = _interopRequireDefault(_dereq_("./ParseObject"));
  24732. var _ParseOp = _dereq_("./ParseOp");
  24733. var _ParseRelation = _interopRequireDefault(_dereq_("./ParseRelation"));
  24734. /**
  24735. * Copyright (c) 2015-present, Parse, LLC.
  24736. * All rights reserved.
  24737. *
  24738. * This source code is licensed under the BSD-style license found in the
  24739. * LICENSE file in the root directory of this source tree. An additional grant
  24740. * of patent rights can be found in the PATENTS file in the same directory.
  24741. *
  24742. * @flow
  24743. */
  24744. // eslint-disable-line no-unused-vars
  24745. function decode(value
  24746. /*: any*/
  24747. )
  24748. /*: any*/
  24749. {
  24750. if (value === null || (0, _typeof2.default)(value) !== 'object') {
  24751. return value;
  24752. }
  24753. if ((0, _isArray.default)(value)) {
  24754. var dup = [];
  24755. (0, _forEach.default)(value).call(value, function (v, i) {
  24756. dup[i] = decode(v);
  24757. });
  24758. return dup;
  24759. }
  24760. if (typeof value.__op === 'string') {
  24761. return (0, _ParseOp.opFromJSON)(value);
  24762. }
  24763. if (value.__type === 'Pointer' && value.className) {
  24764. return _ParseObject.default.fromJSON(value);
  24765. }
  24766. if (value.__type === 'Object' && value.className) {
  24767. return _ParseObject.default.fromJSON(value);
  24768. }
  24769. if (value.__type === 'Relation') {
  24770. // The parent and key fields will be populated by the parent
  24771. var relation = new _ParseRelation.default(null, null);
  24772. relation.targetClassName = value.className;
  24773. return relation;
  24774. }
  24775. if (value.__type === 'Date') {
  24776. return new Date(value.iso);
  24777. }
  24778. if (value.__type === 'File') {
  24779. return _ParseFile.default.fromJSON(value);
  24780. }
  24781. if (value.__type === 'GeoPoint') {
  24782. return new _ParseGeoPoint.default({
  24783. latitude: value.latitude,
  24784. longitude: value.longitude
  24785. });
  24786. }
  24787. if (value.__type === 'Polygon') {
  24788. return new _ParsePolygon.default(value.coordinates);
  24789. }
  24790. var copy = {};
  24791. for (var k in value) {
  24792. copy[k] = decode(value[k]);
  24793. }
  24794. return copy;
  24795. }
  24796. },{"./ParseACL":26,"./ParseFile":30,"./ParseGeoPoint":33,"./ParseObject":36,"./ParseOp":37,"./ParsePolygon":38,"./ParseRelation":40,"@babel/runtime-corejs3/core-js-stable/array/is-array":79,"@babel/runtime-corejs3/core-js-stable/instance/for-each":86,"@babel/runtime-corejs3/core-js-stable/object/define-property":105,"@babel/runtime-corejs3/helpers/interopRequireDefault":152,"@babel/runtime-corejs3/helpers/typeof":164}],66:[function(_dereq_,module,exports){
  24797. "use strict";
  24798. var _Object$defineProperty = _dereq_("@babel/runtime-corejs3/core-js-stable/object/define-property");
  24799. var _interopRequireDefault = _dereq_("@babel/runtime-corejs3/helpers/interopRequireDefault");
  24800. _Object$defineProperty(exports, "__esModule", {
  24801. value: true
  24802. });
  24803. exports.default = _default;
  24804. var _typeof2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/helpers/typeof"));
  24805. var _concat = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/instance/concat"));
  24806. var _indexOf = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/instance/index-of"));
  24807. var _keys = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/object/keys"));
  24808. var _startsWith = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/instance/starts-with"));
  24809. var _isArray = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/array/is-array"));
  24810. var _map = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/instance/map"));
  24811. var _ParseACL = _interopRequireDefault(_dereq_("./ParseACL"));
  24812. var _ParseFile = _interopRequireDefault(_dereq_("./ParseFile"));
  24813. var _ParseGeoPoint = _interopRequireDefault(_dereq_("./ParseGeoPoint"));
  24814. var _ParsePolygon = _interopRequireDefault(_dereq_("./ParsePolygon"));
  24815. var _ParseObject = _interopRequireDefault(_dereq_("./ParseObject"));
  24816. var _ParseOp = _dereq_("./ParseOp");
  24817. var _ParseRelation = _interopRequireDefault(_dereq_("./ParseRelation"));
  24818. /**
  24819. * Copyright (c) 2015-present, Parse, LLC.
  24820. * All rights reserved.
  24821. *
  24822. * This source code is licensed under the BSD-style license found in the
  24823. * LICENSE file in the root directory of this source tree. An additional grant
  24824. * of patent rights can be found in the PATENTS file in the same directory.
  24825. *
  24826. * @flow
  24827. */
  24828. function encode(value
  24829. /*: mixed*/
  24830. , disallowObjects
  24831. /*: boolean*/
  24832. , forcePointers
  24833. /*: boolean*/
  24834. , seen
  24835. /*: Array<mixed>*/
  24836. , offline
  24837. /*: boolean*/
  24838. )
  24839. /*: any*/
  24840. {
  24841. if (value instanceof _ParseObject.default) {
  24842. var _context;
  24843. if (disallowObjects) {
  24844. throw new Error('Parse Objects not allowed here');
  24845. }
  24846. var seenEntry = value.id ? (0, _concat.default)(_context = "".concat(value.className, ":")).call(_context, value.id) : value;
  24847. if (forcePointers || !seen || (0, _indexOf.default)(seen).call(seen, seenEntry) > -1 || value.dirty() || (0, _keys.default)(value._getServerData()).length < 1) {
  24848. var _context2;
  24849. if (offline && (0, _startsWith.default)(_context2 = value._getId()).call(_context2, 'local')) {
  24850. return value.toOfflinePointer();
  24851. }
  24852. return value.toPointer();
  24853. }
  24854. seen = (0, _concat.default)(seen).call(seen, seenEntry);
  24855. return value._toFullJSON(seen, offline);
  24856. }
  24857. if (value instanceof _ParseOp.Op || value instanceof _ParseACL.default || value instanceof _ParseGeoPoint.default || value instanceof _ParsePolygon.default || value instanceof _ParseRelation.default) {
  24858. return value.toJSON();
  24859. }
  24860. if (value instanceof _ParseFile.default) {
  24861. if (!value.url()) {
  24862. throw new Error('Tried to encode an unsaved file.');
  24863. }
  24864. return value.toJSON();
  24865. }
  24866. if (Object.prototype.toString.call(value) === '[object Date]') {
  24867. if (isNaN(value)) {
  24868. throw new Error('Tried to encode an invalid date.');
  24869. }
  24870. return {
  24871. __type: 'Date',
  24872. iso: value
  24873. /*: any*/
  24874. .toJSON()
  24875. };
  24876. }
  24877. if (Object.prototype.toString.call(value) === '[object RegExp]' && typeof value.source === 'string') {
  24878. return value.source;
  24879. }
  24880. if ((0, _isArray.default)(value)) {
  24881. return (0, _map.default)(value).call(value, function (v) {
  24882. return encode(v, disallowObjects, forcePointers, seen, offline);
  24883. });
  24884. }
  24885. if (value && (0, _typeof2.default)(value) === 'object') {
  24886. var output = {};
  24887. for (var k in value) {
  24888. output[k] = encode(value[k], disallowObjects, forcePointers, seen, offline);
  24889. }
  24890. return output;
  24891. }
  24892. return value;
  24893. }
  24894. function _default(value
  24895. /*: mixed*/
  24896. , disallowObjects
  24897. /*:: ?: boolean*/
  24898. , forcePointers
  24899. /*:: ?: boolean*/
  24900. , seen
  24901. /*:: ?: Array<mixed>*/
  24902. , offline
  24903. /*:: ?: boolean*/
  24904. )
  24905. /*: any*/
  24906. {
  24907. return encode(value, !!disallowObjects, !!forcePointers, seen || [], offline);
  24908. }
  24909. },{"./ParseACL":26,"./ParseFile":30,"./ParseGeoPoint":33,"./ParseObject":36,"./ParseOp":37,"./ParsePolygon":38,"./ParseRelation":40,"@babel/runtime-corejs3/core-js-stable/array/is-array":79,"@babel/runtime-corejs3/core-js-stable/instance/concat":81,"@babel/runtime-corejs3/core-js-stable/instance/index-of":88,"@babel/runtime-corejs3/core-js-stable/instance/map":90,"@babel/runtime-corejs3/core-js-stable/instance/starts-with":96,"@babel/runtime-corejs3/core-js-stable/object/define-property":105,"@babel/runtime-corejs3/core-js-stable/object/keys":112,"@babel/runtime-corejs3/helpers/interopRequireDefault":152,"@babel/runtime-corejs3/helpers/typeof":164}],67:[function(_dereq_,module,exports){
  24910. "use strict";
  24911. var _Object$defineProperty = _dereq_("@babel/runtime-corejs3/core-js-stable/object/define-property");
  24912. var _interopRequireDefault = _dereq_("@babel/runtime-corejs3/helpers/interopRequireDefault");
  24913. _Object$defineProperty(exports, "__esModule", {
  24914. value: true
  24915. });
  24916. exports.default = equals;
  24917. var _isArray = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/array/is-array"));
  24918. var _keys = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/object/keys"));
  24919. var _typeof2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/helpers/typeof"));
  24920. var _ParseACL = _interopRequireDefault(_dereq_("./ParseACL"));
  24921. var _ParseFile = _interopRequireDefault(_dereq_("./ParseFile"));
  24922. var _ParseGeoPoint = _interopRequireDefault(_dereq_("./ParseGeoPoint"));
  24923. var _ParseObject = _interopRequireDefault(_dereq_("./ParseObject"));
  24924. /**
  24925. * Copyright (c) 2015-present, Parse, LLC.
  24926. * All rights reserved.
  24927. *
  24928. * This source code is licensed under the BSD-style license found in the
  24929. * LICENSE file in the root directory of this source tree. An additional grant
  24930. * of patent rights can be found in the PATENTS file in the same directory.
  24931. */
  24932. function equals(a, b) {
  24933. var toString = Object.prototype.toString;
  24934. if (toString.call(a) === '[object Date]' || toString.call(b) === '[object Date]') {
  24935. var dateA = new Date(a);
  24936. var dateB = new Date(b);
  24937. return +dateA === +dateB;
  24938. }
  24939. if ((0, _typeof2.default)(a) !== (0, _typeof2.default)(b)) {
  24940. return false;
  24941. }
  24942. if (!a || (0, _typeof2.default)(a) !== 'object') {
  24943. // a is a primitive
  24944. return a === b;
  24945. }
  24946. if ((0, _isArray.default)(a) || (0, _isArray.default)(b)) {
  24947. if (!(0, _isArray.default)(a) || !(0, _isArray.default)(b)) {
  24948. return false;
  24949. }
  24950. if (a.length !== b.length) {
  24951. return false;
  24952. }
  24953. for (var i = a.length; i--;) {
  24954. if (!equals(a[i], b[i])) {
  24955. return false;
  24956. }
  24957. }
  24958. return true;
  24959. }
  24960. if (a instanceof _ParseACL.default || a instanceof _ParseFile.default || a instanceof _ParseGeoPoint.default || a instanceof _ParseObject.default) {
  24961. return a.equals(b);
  24962. }
  24963. if (b instanceof _ParseObject.default) {
  24964. if (a.__type === 'Object' || a.__type === 'Pointer') {
  24965. return a.objectId === b.id && a.className === b.className;
  24966. }
  24967. }
  24968. if ((0, _keys.default)(a).length !== (0, _keys.default)(b).length) {
  24969. return false;
  24970. }
  24971. for (var k in a) {
  24972. if (!equals(a[k], b[k])) {
  24973. return false;
  24974. }
  24975. }
  24976. return true;
  24977. }
  24978. },{"./ParseACL":26,"./ParseFile":30,"./ParseGeoPoint":33,"./ParseObject":36,"@babel/runtime-corejs3/core-js-stable/array/is-array":79,"@babel/runtime-corejs3/core-js-stable/object/define-property":105,"@babel/runtime-corejs3/core-js-stable/object/keys":112,"@babel/runtime-corejs3/helpers/interopRequireDefault":152,"@babel/runtime-corejs3/helpers/typeof":164}],68:[function(_dereq_,module,exports){
  24979. "use strict";
  24980. var _Object$defineProperty = _dereq_("@babel/runtime-corejs3/core-js-stable/object/define-property");
  24981. _Object$defineProperty(exports, "__esModule", {
  24982. value: true
  24983. });
  24984. exports.default = escape;
  24985. /*
  24986. * Copyright (c) 2015-present, Parse, LLC.
  24987. * All rights reserved.
  24988. *
  24989. * This source code is licensed under the BSD-style license found in the
  24990. * LICENSE file in the root directory of this source tree. An additional grant
  24991. * of patent rights can be found in the PATENTS file in the same directory.
  24992. *
  24993. * @flow
  24994. */
  24995. var encoded = {
  24996. '&': '&amp;',
  24997. '<': '&lt;',
  24998. '>': '&gt;',
  24999. '/': '&#x2F;',
  25000. "'": '&#x27;',
  25001. '"': '&quot;'
  25002. };
  25003. function escape(str
  25004. /*: string*/
  25005. )
  25006. /*: string*/
  25007. {
  25008. return str.replace(/[&<>/'"]/g, function (char) {
  25009. return encoded[char];
  25010. });
  25011. }
  25012. },{"@babel/runtime-corejs3/core-js-stable/object/define-property":105}],69:[function(_dereq_,module,exports){
  25013. "use strict";
  25014. var _interopRequireDefault = _dereq_("@babel/runtime-corejs3/helpers/interopRequireDefault");
  25015. var _filter = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/instance/filter"));
  25016. var _includes = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/instance/includes"));
  25017. /* eslint-disable no-console */
  25018. /* global window */
  25019. var filteredWarnings = [// Optional dependencies, where we handle the dependency check on run-time
  25020. "Module not found: Can't resolve '@walletconnect/web3-provider'", "Module not found: Can't resolve 'magic-sdk'", "Module not found: Can't resolve '@web3auth/web3auth'"];
  25021. /**
  25022. * Filters console messages that include text from the blacklist
  25023. */
  25024. var filterConsole = function () {
  25025. // Filter console.warn
  25026. var preservedConsoleWarn = console.warn;
  25027. console.warn = function () {
  25028. for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
  25029. args[_key] = arguments[_key];
  25030. }
  25031. var value = args ? args[0] : null; // For the current use-cases we only care about the first argument being string
  25032. if (!value || typeof value !== 'string') {
  25033. return preservedConsoleWarn.apply(console, args);
  25034. } // Raplace all types of single quotes to one format
  25035. value = value.replace('’', "'").replace('‘', "'").replace('’', "'"); // Filter out blacklisted strings
  25036. if ((0, _filter.default)(filteredWarnings).call(filteredWarnings, function (filter) {
  25037. return (0, _includes.default)(value).call(value, filter);
  25038. }).length >= 1) {
  25039. return;
  25040. } // Otherwise return default function
  25041. return preservedConsoleWarn.apply(console, args);
  25042. };
  25043. };
  25044. module.exports = {
  25045. filterConsole: filterConsole
  25046. };
  25047. },{"@babel/runtime-corejs3/core-js-stable/instance/filter":84,"@babel/runtime-corejs3/core-js-stable/instance/includes":87,"@babel/runtime-corejs3/helpers/interopRequireDefault":152}],70:[function(_dereq_,module,exports){
  25048. "use strict";
  25049. var _Object$defineProperty = _dereq_("@babel/runtime-corejs3/core-js-stable/object/define-property");
  25050. var _interopRequireDefault = _dereq_("@babel/runtime-corejs3/helpers/interopRequireDefault");
  25051. _Object$defineProperty(exports, "__esModule", {
  25052. value: true
  25053. });
  25054. exports.default = isRevocableSession;
  25055. var _indexOf = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/instance/index-of"));
  25056. /**
  25057. * Copyright (c) 2015-present, Parse, LLC.
  25058. * All rights reserved.
  25059. *
  25060. * This source code is licensed under the BSD-style license found in the
  25061. * LICENSE file in the root directory of this source tree. An additional grant
  25062. * of patent rights can be found in the PATENTS file in the same directory.
  25063. *
  25064. * @flow
  25065. */
  25066. function isRevocableSession(token
  25067. /*: string*/
  25068. )
  25069. /*: boolean*/
  25070. {
  25071. return (0, _indexOf.default)(token).call(token, 'r:') > -1;
  25072. }
  25073. },{"@babel/runtime-corejs3/core-js-stable/instance/index-of":88,"@babel/runtime-corejs3/core-js-stable/object/define-property":105,"@babel/runtime-corejs3/helpers/interopRequireDefault":152}],71:[function(_dereq_,module,exports){
  25074. "use strict";
  25075. var _Object$defineProperty = _dereq_("@babel/runtime-corejs3/core-js-stable/object/define-property");
  25076. var _interopRequireDefault = _dereq_("@babel/runtime-corejs3/helpers/interopRequireDefault");
  25077. _Object$defineProperty(exports, "__esModule", {
  25078. value: true
  25079. });
  25080. exports.default = parseDate;
  25081. var _parseInt2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/parse-int"));
  25082. /**
  25083. * Copyright (c) 2015-present, Parse, LLC.
  25084. * All rights reserved.
  25085. *
  25086. * This source code is licensed under the BSD-style license found in the
  25087. * LICENSE file in the root directory of this source tree. An additional grant
  25088. * of patent rights can be found in the PATENTS file in the same directory.
  25089. *
  25090. * @flow
  25091. */
  25092. function parseDate(iso8601
  25093. /*: string*/
  25094. )
  25095. /*: ?Date*/
  25096. {
  25097. var regexp = new RegExp('^([0-9]{1,4})-([0-9]{1,2})-([0-9]{1,2})' + 'T' + '([0-9]{1,2}):([0-9]{1,2}):([0-9]{1,2})' + '(.([0-9]+))?' + 'Z$');
  25098. var match = regexp.exec(iso8601);
  25099. if (!match) {
  25100. return null;
  25101. }
  25102. var year = (0, _parseInt2.default)(match[1]) || 0;
  25103. var month = ((0, _parseInt2.default)(match[2]) || 1) - 1;
  25104. var day = (0, _parseInt2.default)(match[3]) || 0;
  25105. var hour = (0, _parseInt2.default)(match[4]) || 0;
  25106. var minute = (0, _parseInt2.default)(match[5]) || 0;
  25107. var second = (0, _parseInt2.default)(match[6]) || 0;
  25108. var milli = (0, _parseInt2.default)(match[8]) || 0;
  25109. return new Date(Date.UTC(year, month, day, hour, minute, second, milli));
  25110. }
  25111. },{"@babel/runtime-corejs3/core-js-stable/object/define-property":105,"@babel/runtime-corejs3/core-js-stable/parse-int":114,"@babel/runtime-corejs3/helpers/interopRequireDefault":152}],72:[function(_dereq_,module,exports){
  25112. "use strict";
  25113. var _Object$defineProperty = _dereq_("@babel/runtime-corejs3/core-js-stable/object/define-property");
  25114. var _interopRequireDefault = _dereq_("@babel/runtime-corejs3/helpers/interopRequireDefault");
  25115. _Object$defineProperty(exports, "__esModule", {
  25116. value: true
  25117. });
  25118. exports.continueWhile = continueWhile;
  25119. exports.resolvingPromise = resolvingPromise;
  25120. exports.when = when;
  25121. var _promise = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/promise"));
  25122. var _isArray = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/array/is-array")); // Create Deferred Promise
  25123. function resolvingPromise() {
  25124. var res;
  25125. var rej;
  25126. var promise = new _promise.default(function (resolve, reject) {
  25127. res = resolve;
  25128. rej = reject;
  25129. });
  25130. promise.resolve = res;
  25131. promise.reject = rej;
  25132. return promise;
  25133. }
  25134. function when(promises) {
  25135. var objects;
  25136. var arrayArgument = (0, _isArray.default)(promises);
  25137. if (arrayArgument) {
  25138. objects = promises;
  25139. } else {
  25140. objects = arguments;
  25141. }
  25142. var total = objects.length;
  25143. var hadError = false;
  25144. var results = [];
  25145. var returnValue = arrayArgument ? [results] : results;
  25146. var errors = [];
  25147. results.length = objects.length;
  25148. errors.length = objects.length;
  25149. if (total === 0) {
  25150. return _promise.default.resolve(returnValue);
  25151. }
  25152. var promise = new resolvingPromise();
  25153. var resolveOne = function () {
  25154. total--;
  25155. if (total <= 0) {
  25156. if (hadError) {
  25157. promise.reject(errors);
  25158. } else {
  25159. promise.resolve(returnValue);
  25160. }
  25161. }
  25162. };
  25163. var chain = function (object, index) {
  25164. if (object && typeof object.then === 'function') {
  25165. object.then(function (result) {
  25166. results[index] = result;
  25167. resolveOne();
  25168. }, function (error) {
  25169. errors[index] = error;
  25170. hadError = true;
  25171. resolveOne();
  25172. });
  25173. } else {
  25174. results[index] = object;
  25175. resolveOne();
  25176. }
  25177. };
  25178. for (var i = 0; i < objects.length; i++) {
  25179. chain(objects[i], i);
  25180. }
  25181. return promise;
  25182. }
  25183. function continueWhile(test, emitter) {
  25184. if (test()) {
  25185. return emitter().then(function () {
  25186. return continueWhile(test, emitter);
  25187. });
  25188. }
  25189. return _promise.default.resolve();
  25190. }
  25191. },{"@babel/runtime-corejs3/core-js-stable/array/is-array":79,"@babel/runtime-corejs3/core-js-stable/object/define-property":105,"@babel/runtime-corejs3/core-js-stable/promise":115,"@babel/runtime-corejs3/helpers/interopRequireDefault":152}],73:[function(_dereq_,module,exports){
  25192. "use strict";
  25193. var _Object$defineProperty = _dereq_("@babel/runtime-corejs3/core-js-stable/object/define-property");
  25194. var _interopRequireDefault = _dereq_("@babel/runtime-corejs3/helpers/interopRequireDefault");
  25195. _Object$defineProperty(exports, "__esModule", {
  25196. value: true
  25197. });
  25198. exports.default = unique;
  25199. var _forEach = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/instance/for-each"));
  25200. var _indexOf = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/instance/index-of"));
  25201. var _arrayContainsObject = _interopRequireDefault(_dereq_("./arrayContainsObject"));
  25202. var _ParseObject = _interopRequireDefault(_dereq_("./ParseObject"));
  25203. /**
  25204. * Copyright (c) 2015-present, Parse, LLC.
  25205. * All rights reserved.
  25206. *
  25207. * This source code is licensed under the BSD-style license found in the
  25208. * LICENSE file in the root directory of this source tree. An additional grant
  25209. * of patent rights can be found in the PATENTS file in the same directory.
  25210. *
  25211. * @flow
  25212. */
  25213. function unique
  25214. /*:: <T>*/
  25215. (arr
  25216. /*: Array<T>*/
  25217. )
  25218. /*: Array<T>*/
  25219. {
  25220. var uniques = [];
  25221. (0, _forEach.default)(arr).call(arr, function (value) {
  25222. if (value instanceof _ParseObject.default) {
  25223. if (!(0, _arrayContainsObject.default)(uniques, value)) {
  25224. uniques.push(value);
  25225. }
  25226. } else {
  25227. if ((0, _indexOf.default)(uniques).call(uniques, value) < 0) {
  25228. uniques.push(value);
  25229. }
  25230. }
  25231. });
  25232. return uniques;
  25233. }
  25234. },{"./ParseObject":36,"./arrayContainsObject":62,"@babel/runtime-corejs3/core-js-stable/instance/for-each":86,"@babel/runtime-corejs3/core-js-stable/instance/index-of":88,"@babel/runtime-corejs3/core-js-stable/object/define-property":105,"@babel/runtime-corejs3/helpers/interopRequireDefault":152}],74:[function(_dereq_,module,exports){
  25235. "use strict";
  25236. var _Object$defineProperty = _dereq_("@babel/runtime-corejs3/core-js-stable/object/define-property");
  25237. var _interopRequireDefault = _dereq_("@babel/runtime-corejs3/helpers/interopRequireDefault");
  25238. _Object$defineProperty(exports, "__esModule", {
  25239. value: true
  25240. });
  25241. exports.default = unsavedChildren;
  25242. var _typeof2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/helpers/typeof"));
  25243. var _concat = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/instance/concat"));
  25244. var _indexOf = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/instance/index-of"));
  25245. var _isArray = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/array/is-array"));
  25246. var _forEach = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/instance/for-each"));
  25247. var _ParseFile = _interopRequireDefault(_dereq_("./ParseFile"));
  25248. var _ParseObject = _interopRequireDefault(_dereq_("./ParseObject"));
  25249. var _ParseRelation = _interopRequireDefault(_dereq_("./ParseRelation"));
  25250. /**
  25251. * Copyright (c) 2015-present, Parse, LLC.
  25252. * All rights reserved.
  25253. *
  25254. * This source code is licensed under the BSD-style license found in the
  25255. * LICENSE file in the root directory of this source tree. An additional grant
  25256. * of patent rights can be found in the PATENTS file in the same directory.
  25257. *
  25258. * @flow
  25259. */
  25260. /**
  25261. * Return an array of unsaved children, which are either Parse Objects or Files.
  25262. * If it encounters any dirty Objects without Ids, it will throw an exception.
  25263. *
  25264. * @param {Parse.Object} obj
  25265. * @param {boolean} allowDeepUnsaved
  25266. * @returns {Array}
  25267. */
  25268. function unsavedChildren(obj
  25269. /*: ParseObject*/
  25270. , allowDeepUnsaved
  25271. /*:: ?: boolean*/
  25272. )
  25273. /*: Array<ParseFile | ParseObject>*/
  25274. {
  25275. var _context;
  25276. var encountered = {
  25277. objects: {},
  25278. files: []
  25279. };
  25280. var identifier = (0, _concat.default)(_context = "".concat(obj.className, ":")).call(_context, obj._getId());
  25281. encountered.objects[identifier] = obj.dirty() ? obj : true;
  25282. var attributes = obj.attributes;
  25283. for (var attr in attributes) {
  25284. if ((0, _typeof2.default)(attributes[attr]) === 'object') {
  25285. traverse(attributes[attr], encountered, false, !!allowDeepUnsaved);
  25286. }
  25287. }
  25288. var unsaved = [];
  25289. for (var id in encountered.objects) {
  25290. if (id !== identifier && encountered.objects[id] !== true) {
  25291. unsaved.push(encountered.objects[id]);
  25292. }
  25293. }
  25294. return (0, _concat.default)(unsaved).call(unsaved, encountered.files);
  25295. }
  25296. function traverse(obj
  25297. /*: ParseObject*/
  25298. , encountered
  25299. /*: EncounterMap*/
  25300. , shouldThrow
  25301. /*: boolean*/
  25302. , allowDeepUnsaved
  25303. /*: boolean*/
  25304. ) {
  25305. if (obj instanceof _ParseObject.default) {
  25306. var _context2;
  25307. if (!obj.id && shouldThrow) {
  25308. throw new Error('Cannot create a pointer to an unsaved Object.');
  25309. }
  25310. var _identifier = (0, _concat.default)(_context2 = "".concat(obj.className, ":")).call(_context2, obj._getId());
  25311. if (!encountered.objects[_identifier]) {
  25312. encountered.objects[_identifier] = obj.dirty() ? obj : true;
  25313. var attributes = obj.attributes;
  25314. for (var attr in attributes) {
  25315. if ((0, _typeof2.default)(attributes[attr]) === 'object') {
  25316. traverse(attributes[attr], encountered, !allowDeepUnsaved, allowDeepUnsaved);
  25317. }
  25318. }
  25319. }
  25320. return;
  25321. }
  25322. if (obj instanceof _ParseFile.default) {
  25323. var _context3;
  25324. if (!obj.url() && (0, _indexOf.default)(_context3 = encountered.files).call(_context3, obj) < 0) {
  25325. encountered.files.push(obj);
  25326. }
  25327. return;
  25328. }
  25329. if (obj instanceof _ParseRelation.default) {
  25330. return;
  25331. }
  25332. if ((0, _isArray.default)(obj)) {
  25333. (0, _forEach.default)(obj).call(obj, function (el) {
  25334. if ((0, _typeof2.default)(el) === 'object') {
  25335. traverse(el, encountered, shouldThrow, allowDeepUnsaved);
  25336. }
  25337. });
  25338. }
  25339. for (var k in obj) {
  25340. if ((0, _typeof2.default)(obj[k]) === 'object') {
  25341. traverse(obj[k], encountered, shouldThrow, allowDeepUnsaved);
  25342. }
  25343. }
  25344. }
  25345. },{"./ParseFile":30,"./ParseObject":36,"./ParseRelation":40,"@babel/runtime-corejs3/core-js-stable/array/is-array":79,"@babel/runtime-corejs3/core-js-stable/instance/concat":81,"@babel/runtime-corejs3/core-js-stable/instance/for-each":86,"@babel/runtime-corejs3/core-js-stable/instance/index-of":88,"@babel/runtime-corejs3/core-js-stable/object/define-property":105,"@babel/runtime-corejs3/helpers/interopRequireDefault":152,"@babel/runtime-corejs3/helpers/typeof":164}],75:[function(_dereq_,module,exports){
  25346. "use strict";
  25347. var _typeof = _dereq_("@babel/runtime-corejs3/helpers/typeof");
  25348. var _WeakMap = _dereq_("@babel/runtime-corejs3/core-js-stable/weak-map");
  25349. var _reduceInstanceProperty = _dereq_("@babel/runtime-corejs3/core-js-stable/instance/reduce");
  25350. var _Object$keys2 = _dereq_("@babel/runtime-corejs3/core-js-stable/object/keys");
  25351. var _Object$create = _dereq_("@babel/runtime-corejs3/core-js-stable/object/create");
  25352. var _Symbol$replace = _dereq_("@babel/runtime-corejs3/core-js-stable/symbol/replace");
  25353. var _sliceInstanceProperty = _dereq_("@babel/runtime-corejs3/core-js-stable/instance/slice");
  25354. var _interopRequireDefault = _dereq_("@babel/runtime-corejs3/helpers/interopRequireDefault");
  25355. var _regenerator = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/regenerator"));
  25356. var _inherits2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/helpers/inherits"));
  25357. var _setPrototypeOf2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/helpers/setPrototypeOf"));
  25358. var _slicedToArray2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/helpers/slicedToArray"));
  25359. var _asyncToGenerator2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/helpers/asyncToGenerator"));
  25360. var _freeze = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/object/freeze"));
  25361. var _map = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/instance/map"));
  25362. var _entries = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/object/entries"));
  25363. var _forEach = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/instance/for-each"));
  25364. var _keys = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/object/keys"));
  25365. var _isNan = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/number/is-nan"));
  25366. var _stringify = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/json/stringify"));
  25367. var _RESTController = _interopRequireDefault(_dereq_("./RESTController"));
  25368. function _wrapRegExp() {
  25369. _wrapRegExp = function (re, groups) {
  25370. return new BabelRegExp(re, void 0, groups);
  25371. };
  25372. var _super = RegExp.prototype,
  25373. _groups = new _WeakMap();
  25374. function BabelRegExp(re, flags, groups) {
  25375. var _this = new RegExp(re, flags);
  25376. return _groups.set(_this, groups || _groups.get(re)), (0, _setPrototypeOf2.default)(_this, BabelRegExp.prototype);
  25377. }
  25378. function buildGroups(result, re) {
  25379. var _context10;
  25380. var g = _groups.get(re);
  25381. return _reduceInstanceProperty(_context10 = _Object$keys2(g)).call(_context10, function (groups, name) {
  25382. return groups[name] = result[g[name]], groups;
  25383. }, _Object$create(null));
  25384. }
  25385. return (0, _inherits2.default)(BabelRegExp, RegExp), BabelRegExp.prototype.exec = function (str) {
  25386. var result = _super.exec.call(this, str);
  25387. return result && (result.groups = buildGroups(result, this)), result;
  25388. }, BabelRegExp.prototype[_Symbol$replace] = function (str, substitution) {
  25389. if ("string" == typeof substitution) {
  25390. var groups = _groups.get(this);
  25391. return _super[_Symbol$replace].call(this, str, substitution.replace(/\$<([^>]+)>/g, function (_, name) {
  25392. return "$" + groups[name];
  25393. }));
  25394. }
  25395. if ("function" == typeof substitution) {
  25396. var _this = this;
  25397. return _super[_Symbol$replace].call(this, str, function () {
  25398. var args = arguments;
  25399. return "object" != _typeof(args[args.length - 1]) && (args = _sliceInstanceProperty([]).call(args)).push(buildGroups(args, _this)), substitution.apply(this, args);
  25400. });
  25401. }
  25402. return _super[_Symbol$replace].call(this, str, substitution);
  25403. }, _wrapRegExp.apply(this, arguments);
  25404. }
  25405. var DEEP_INDEX_API_HOST = 'deep-index.moralis.io';
  25406. var DEEP_INDEX_SWAGGER_PATH = '/api-docs/v2/swagger.json';
  25407. var TrackingEventName = (0, _freeze.default)({
  25408. START_FUNCTION: 'Moralis SDK start'
  25409. });
  25410. var fetchSwaggerJson = /*#__PURE__*/function () {
  25411. var _ref = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee() {
  25412. var _yield$RESTController, response;
  25413. return _regenerator.default.wrap(function (_context) {
  25414. while (1) {
  25415. switch (_context.prev = _context.next) {
  25416. case 0:
  25417. _context.next = 2;
  25418. return _RESTController.default.ajax('GET', "https://".concat(DEEP_INDEX_API_HOST).concat(DEEP_INDEX_SWAGGER_PATH));
  25419. case 2:
  25420. _yield$RESTController = _context.sent;
  25421. response = _yield$RESTController.response;
  25422. return _context.abrupt("return", response);
  25423. case 5:
  25424. case "end":
  25425. return _context.stop();
  25426. }
  25427. }
  25428. }, _callee);
  25429. }));
  25430. return function () {
  25431. return _ref.apply(this, arguments);
  25432. };
  25433. }();
  25434. var getPathByTag = function (swaggerJSON) {
  25435. var _context2;
  25436. var pathByTag = {};
  25437. var pathDetails = {};
  25438. (0, _map.default)(_context2 = (0, _entries.default)(swaggerJSON.paths)).call(_context2, function (_ref2) {
  25439. var _context3;
  25440. var _ref3 = (0, _slicedToArray2.default)(_ref2, 2),
  25441. pathName = _ref3[0],
  25442. requestData = _ref3[1];
  25443. return (0, _forEach.default)(_context3 = (0, _entries.default)(requestData)).call(_context3, function (_ref4) {
  25444. var _ref5 = (0, _slicedToArray2.default)(_ref4, 2),
  25445. method = _ref5[0],
  25446. data = _ref5[1];
  25447. var tags = data.tags;
  25448. if (tags.length > 0) {
  25449. if (!pathByTag[tags[0]]) {
  25450. pathByTag[tags[0]] = [];
  25451. }
  25452. pathByTag[tags[0]].push(data.operationId);
  25453. pathDetails[data.operationId] = {
  25454. method: method,
  25455. pathName: pathName,
  25456. data: data
  25457. };
  25458. }
  25459. });
  25460. });
  25461. return {
  25462. pathByTag: pathByTag,
  25463. pathDetails: pathDetails
  25464. };
  25465. };
  25466. var fetchEndpoints = /*#__PURE__*/function () {
  25467. var _ref6 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee2() {
  25468. var _context4;
  25469. var swaggerJSON, _yield$getPathByTag, pathDetails, data;
  25470. return _regenerator.default.wrap(function (_context5) {
  25471. while (1) {
  25472. switch (_context5.prev = _context5.next) {
  25473. case 0:
  25474. _context5.next = 2;
  25475. return fetchSwaggerJson();
  25476. case 2:
  25477. swaggerJSON = _context5.sent;
  25478. _context5.next = 5;
  25479. return getPathByTag(swaggerJSON);
  25480. case 5:
  25481. _yield$getPathByTag = _context5.sent;
  25482. pathDetails = _yield$getPathByTag.pathDetails;
  25483. data = [];
  25484. (0, _forEach.default)(_context4 = (0, _keys.default)(pathDetails)).call(_context4, function (x) {
  25485. var item = pathDetails[x];
  25486. var endpoint = {
  25487. method: item.method.toUpperCase(),
  25488. group: item.data.tags[0],
  25489. name: x,
  25490. url: item.pathName.split('{').join(':').split('}').join('')
  25491. };
  25492. data.push(endpoint);
  25493. });
  25494. return _context5.abrupt("return", data);
  25495. case 10:
  25496. case "end":
  25497. return _context5.stop();
  25498. }
  25499. }
  25500. }, _callee2);
  25501. }));
  25502. return function () {
  25503. return _ref6.apply(this, arguments);
  25504. };
  25505. }();
  25506. /**
  25507. * Compares if the semantic version of version1 is larger than version2
  25508. */
  25509. var isSemanticVersionLarger = function (version1, version2) {
  25510. var _context6, _context7;
  25511. var _version1$split = version1.split('-'),
  25512. _version1$split2 = (0, _slicedToArray2.default)(_version1$split, 2),
  25513. version1Main = _version1$split2[0],
  25514. version1Pre = _version1$split2[1];
  25515. var version1Arr = (0, _map.default)(_context6 = version1Main.split('.')).call(_context6, function (s) {
  25516. return Number(s);
  25517. });
  25518. var _version2$split = version2.split('-'),
  25519. _version2$split2 = (0, _slicedToArray2.default)(_version2$split, 2),
  25520. version2Main = _version2$split2[0],
  25521. version2Pre = _version2$split2[1];
  25522. var version2Arr = (0, _map.default)(_context7 = version2Main.split('.')).call(_context7, function (s) {
  25523. return Number(s);
  25524. });
  25525. for (var index = 0; index < 3; index++) {
  25526. var compare1 = version1Arr[index];
  25527. var compare2 = version2Arr[index];
  25528. if (compare1 > compare2) return true;
  25529. if (compare1 < compare2) return false;
  25530. if (!(0, _isNan.default)(compare1) && (0, _isNan.default)(compare2)) return true;
  25531. if ((0, _isNan.default)(compare1) && !(0, _isNan.default)(compare2)) return false;
  25532. } // Compare pre-releasees if main versions are the same
  25533. if (version1Pre && version2Pre) {
  25534. var _version1Pre$split$, _version2Pre$split$;
  25535. var version1PreNumber = (_version1Pre$split$ = version1Pre.split('.')[1]) !== null && _version1Pre$split$ !== void 0 ? _version1Pre$split$ : 0;
  25536. var version2PreNumber = (_version2Pre$split$ = version2Pre.split('.')[1]) !== null && _version2Pre$split$ !== void 0 ? _version2Pre$split$ : 0;
  25537. return version1PreNumber > version2PreNumber;
  25538. } // If version2 is a pre-release and version1 is not, then version 1 is newer
  25539. if (version2Pre) {
  25540. return true;
  25541. }
  25542. return false;
  25543. };
  25544. var checkForSdkUpdates = /*#__PURE__*/function () {
  25545. var _ref7 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee3() {
  25546. var _yield$RESTController2, response, latestVersion, installedVersion;
  25547. return _regenerator.default.wrap(function (_context8) {
  25548. while (1) {
  25549. switch (_context8.prev = _context8.next) {
  25550. case 0:
  25551. _context8.prev = 0;
  25552. _context8.next = 3;
  25553. return _RESTController.default.ajax('GET', 'https://www.unpkg.com/moralis/package.json');
  25554. case 3:
  25555. _yield$RESTController2 = _context8.sent;
  25556. response = _yield$RESTController2.response;
  25557. latestVersion = response.version;
  25558. installedVersion = "1.5.9";
  25559. if (isSemanticVersionLarger(latestVersion, installedVersion)) // eslint-disable-next-line no-console
  25560. console.warn("You are not using the latest version of the SDK. Please update it as soon as possible to enjoy the newest features. Most recent version: ".concat(latestVersion));
  25561. _context8.next = 12;
  25562. break;
  25563. case 10:
  25564. _context8.prev = 10;
  25565. _context8.t0 = _context8["catch"](0);
  25566. case 12:
  25567. case "end":
  25568. return _context8.stop();
  25569. }
  25570. }
  25571. }, _callee3, null, [[0, 10]]);
  25572. }));
  25573. return function () {
  25574. return _ref7.apply(this, arguments);
  25575. };
  25576. }();
  25577. var trackEvent = /*#__PURE__*/function () {
  25578. var _ref8 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee4(name, subdomain, options) {
  25579. var _yield$RESTController3, response;
  25580. return _regenerator.default.wrap(function (_context9) {
  25581. while (1) {
  25582. switch (_context9.prev = _context9.next) {
  25583. case 0:
  25584. _context9.prev = 0;
  25585. _context9.next = 3;
  25586. return _RESTController.default.ajax('POST', 'https://internal-api.moralis.io/api/functions/trackEvent', (0, _stringify.default)({
  25587. subdomain: subdomain,
  25588. event: name,
  25589. options: options
  25590. }), {
  25591. Accept: 'application/json',
  25592. 'Content-Type': 'application/json'
  25593. });
  25594. case 3:
  25595. _yield$RESTController3 = _context9.sent;
  25596. response = _yield$RESTController3.response;
  25597. return _context9.abrupt("return", response.result);
  25598. case 8:
  25599. _context9.prev = 8;
  25600. _context9.t0 = _context9["catch"](0);
  25601. case 10:
  25602. case "end":
  25603. return _context9.stop();
  25604. }
  25605. }
  25606. }, _callee4, null, [[0, 8]]);
  25607. }));
  25608. return function () {
  25609. return _ref8.apply(this, arguments);
  25610. };
  25611. }();
  25612. /**
  25613. * Regex to validate serverUrl, for example: https://xxxxxxxxxxxx.yyyyyyyyyy.zzzzzz:1234/server
  25614. * It's very generous and doesn't assume the value of domain, subdomain and port, it only checks if we can extract
  25615. * a subddomain
  25616. */
  25617. var validServerUrlRegex = /*#__PURE__*/_wrapRegExp(/^https?:\/\/([0-9A-Z_a-z]+\.[0-9A-Z_a-z]+\.[0-9A-Z_a-z]+)(:[0-9]{4})?\/server\/?$/, {
  25618. subdomain: 1
  25619. });
  25620. var validateServerUrl = function (serverUrl) {
  25621. return validServerUrlRegex.test(serverUrl);
  25622. };
  25623. var getSubdomain = function (serverUrl) {
  25624. var _match$groups$subdoma, _match$groups;
  25625. var isValidServerUrl = validateServerUrl(serverUrl);
  25626. if (!isValidServerUrl) {
  25627. return null;
  25628. }
  25629. var match = validServerUrlRegex.exec(serverUrl);
  25630. return (_match$groups$subdoma = match === null || match === void 0 ? void 0 : (_match$groups = match.groups) === null || _match$groups === void 0 ? void 0 : _match$groups.subdomain) !== null && _match$groups$subdoma !== void 0 ? _match$groups$subdoma : null;
  25631. };
  25632. module.exports = {
  25633. fetchSwaggerJson: fetchSwaggerJson,
  25634. getPathByTag: getPathByTag,
  25635. fetchEndpoints: fetchEndpoints,
  25636. checkForSdkUpdates: checkForSdkUpdates,
  25637. trackEvent: trackEvent,
  25638. TrackingEventName: TrackingEventName,
  25639. getSubdomain: getSubdomain
  25640. };
  25641. },{"./RESTController":46,"@babel/runtime-corejs3/core-js-stable/instance/for-each":86,"@babel/runtime-corejs3/core-js-stable/instance/map":90,"@babel/runtime-corejs3/core-js-stable/instance/reduce":92,"@babel/runtime-corejs3/core-js-stable/instance/slice":93,"@babel/runtime-corejs3/core-js-stable/json/stringify":99,"@babel/runtime-corejs3/core-js-stable/number/is-nan":102,"@babel/runtime-corejs3/core-js-stable/object/create":103,"@babel/runtime-corejs3/core-js-stable/object/entries":106,"@babel/runtime-corejs3/core-js-stable/object/freeze":107,"@babel/runtime-corejs3/core-js-stable/object/keys":112,"@babel/runtime-corejs3/core-js-stable/symbol/replace":120,"@babel/runtime-corejs3/core-js-stable/weak-map":122,"@babel/runtime-corejs3/helpers/asyncToGenerator":144,"@babel/runtime-corejs3/helpers/inherits":151,"@babel/runtime-corejs3/helpers/interopRequireDefault":152,"@babel/runtime-corejs3/helpers/setPrototypeOf":160,"@babel/runtime-corejs3/helpers/slicedToArray":161,"@babel/runtime-corejs3/helpers/typeof":164,"@babel/runtime-corejs3/regenerator":167}],76:[function(_dereq_,module,exports){
  25642. "use strict";
  25643. var _interopRequireDefault = _dereq_("@babel/runtime-corejs3/helpers/interopRequireDefault");
  25644. var _parseInt2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/parse-int"));
  25645. function fromDecimalToHex(number) {
  25646. if (typeof number !== 'number') throw 'The input provided should be a number';
  25647. return "0x".concat(number.toString(16));
  25648. }
  25649. function fromHexToDecimal(hex) {
  25650. if (typeof hex !== 'string') throw 'The input provided should be a string';
  25651. return (0, _parseInt2.default)(hex, 16);
  25652. }
  25653. module.exports = {
  25654. fromDecimalToHex: fromDecimalToHex,
  25655. fromHexToDecimal: fromHexToDecimal
  25656. };
  25657. },{"@babel/runtime-corejs3/core-js-stable/parse-int":114,"@babel/runtime-corejs3/helpers/interopRequireDefault":152}],77:[function(_dereq_,module,exports){
  25658. "use strict";
  25659. var _Object$defineProperty = _dereq_("@babel/runtime-corejs3/core-js-stable/object/define-property");
  25660. _Object$defineProperty(exports, "__esModule", {
  25661. value: true
  25662. });
  25663. exports.default = void 0;
  25664. var _convert = _dereq_("./convert");
  25665. /**
  25666. * Converts chainId to a hex if it is a number
  25667. */
  25668. function verifyChainId(chainId) {
  25669. if (typeof chainId === 'number') chainId = (0, _convert.fromDecimalToHex)(chainId);
  25670. return chainId;
  25671. }
  25672. var _default = verifyChainId;
  25673. exports.default = _default;
  25674. },{"./convert":76,"@babel/runtime-corejs3/core-js-stable/object/define-property":105}],78:[function(_dereq_,module,exports){
  25675. module.exports = _dereq_("core-js-pure/stable/array/from");
  25676. },{"core-js-pure/stable/array/from":691}],79:[function(_dereq_,module,exports){
  25677. module.exports = _dereq_("core-js-pure/stable/array/is-array");
  25678. },{"core-js-pure/stable/array/is-array":692}],80:[function(_dereq_,module,exports){
  25679. module.exports = _dereq_("core-js-pure/stable/instance/bind");
  25680. },{"core-js-pure/stable/instance/bind":698}],81:[function(_dereq_,module,exports){
  25681. module.exports = _dereq_("core-js-pure/stable/instance/concat");
  25682. },{"core-js-pure/stable/instance/concat":699}],82:[function(_dereq_,module,exports){
  25683. module.exports = _dereq_("core-js-pure/stable/instance/entries");
  25684. },{"core-js-pure/stable/instance/entries":700}],83:[function(_dereq_,module,exports){
  25685. module.exports = _dereq_("core-js-pure/stable/instance/every");
  25686. },{"core-js-pure/stable/instance/every":701}],84:[function(_dereq_,module,exports){
  25687. module.exports = _dereq_("core-js-pure/stable/instance/filter");
  25688. },{"core-js-pure/stable/instance/filter":702}],85:[function(_dereq_,module,exports){
  25689. module.exports = _dereq_("core-js-pure/stable/instance/find");
  25690. },{"core-js-pure/stable/instance/find":703}],86:[function(_dereq_,module,exports){
  25691. module.exports = _dereq_("core-js-pure/stable/instance/for-each");
  25692. },{"core-js-pure/stable/instance/for-each":704}],87:[function(_dereq_,module,exports){
  25693. module.exports = _dereq_("core-js-pure/stable/instance/includes");
  25694. },{"core-js-pure/stable/instance/includes":705}],88:[function(_dereq_,module,exports){
  25695. module.exports = _dereq_("core-js-pure/stable/instance/index-of");
  25696. },{"core-js-pure/stable/instance/index-of":706}],89:[function(_dereq_,module,exports){
  25697. module.exports = _dereq_("core-js-pure/stable/instance/keys");
  25698. },{"core-js-pure/stable/instance/keys":707}],90:[function(_dereq_,module,exports){
  25699. module.exports = _dereq_("core-js-pure/stable/instance/map");
  25700. },{"core-js-pure/stable/instance/map":708}],91:[function(_dereq_,module,exports){
  25701. module.exports = _dereq_("core-js-pure/stable/instance/pad-start");
  25702. },{"core-js-pure/stable/instance/pad-start":709}],92:[function(_dereq_,module,exports){
  25703. module.exports = _dereq_("core-js-pure/stable/instance/reduce");
  25704. },{"core-js-pure/stable/instance/reduce":710}],93:[function(_dereq_,module,exports){
  25705. module.exports = _dereq_("core-js-pure/stable/instance/slice");
  25706. },{"core-js-pure/stable/instance/slice":711}],94:[function(_dereq_,module,exports){
  25707. module.exports = _dereq_("core-js-pure/stable/instance/sort");
  25708. },{"core-js-pure/stable/instance/sort":712}],95:[function(_dereq_,module,exports){
  25709. module.exports = _dereq_("core-js-pure/stable/instance/splice");
  25710. },{"core-js-pure/stable/instance/splice":713}],96:[function(_dereq_,module,exports){
  25711. module.exports = _dereq_("core-js-pure/stable/instance/starts-with");
  25712. },{"core-js-pure/stable/instance/starts-with":714}],97:[function(_dereq_,module,exports){
  25713. module.exports = _dereq_("core-js-pure/stable/instance/trim");
  25714. },{"core-js-pure/stable/instance/trim":715}],98:[function(_dereq_,module,exports){
  25715. module.exports = _dereq_("core-js-pure/stable/instance/values");
  25716. },{"core-js-pure/stable/instance/values":716}],99:[function(_dereq_,module,exports){
  25717. module.exports = _dereq_("core-js-pure/stable/json/stringify");
  25718. },{"core-js-pure/stable/json/stringify":717}],100:[function(_dereq_,module,exports){
  25719. module.exports = _dereq_("core-js-pure/stable/map");
  25720. },{"core-js-pure/stable/map":718}],101:[function(_dereq_,module,exports){
  25721. module.exports = _dereq_("core-js-pure/stable/number/is-integer");
  25722. },{"core-js-pure/stable/number/is-integer":719}],102:[function(_dereq_,module,exports){
  25723. module.exports = _dereq_("core-js-pure/stable/number/is-nan");
  25724. },{"core-js-pure/stable/number/is-nan":720}],103:[function(_dereq_,module,exports){
  25725. module.exports = _dereq_("core-js-pure/stable/object/create");
  25726. },{"core-js-pure/stable/object/create":721}],104:[function(_dereq_,module,exports){
  25727. module.exports = _dereq_("core-js-pure/stable/object/define-properties");
  25728. },{"core-js-pure/stable/object/define-properties":722}],105:[function(_dereq_,module,exports){
  25729. module.exports = _dereq_("core-js-pure/stable/object/define-property");
  25730. },{"core-js-pure/stable/object/define-property":723}],106:[function(_dereq_,module,exports){
  25731. module.exports = _dereq_("core-js-pure/stable/object/entries");
  25732. },{"core-js-pure/stable/object/entries":724}],107:[function(_dereq_,module,exports){
  25733. module.exports = _dereq_("core-js-pure/stable/object/freeze");
  25734. },{"core-js-pure/stable/object/freeze":725}],108:[function(_dereq_,module,exports){
  25735. module.exports = _dereq_("core-js-pure/stable/object/get-own-property-descriptor");
  25736. },{"core-js-pure/stable/object/get-own-property-descriptor":726}],109:[function(_dereq_,module,exports){
  25737. module.exports = _dereq_("core-js-pure/stable/object/get-own-property-descriptors");
  25738. },{"core-js-pure/stable/object/get-own-property-descriptors":727}],110:[function(_dereq_,module,exports){
  25739. module.exports = _dereq_("core-js-pure/stable/object/get-own-property-symbols");
  25740. },{"core-js-pure/stable/object/get-own-property-symbols":728}],111:[function(_dereq_,module,exports){
  25741. module.exports = _dereq_("core-js-pure/stable/object/get-prototype-of");
  25742. },{"core-js-pure/stable/object/get-prototype-of":729}],112:[function(_dereq_,module,exports){
  25743. module.exports = _dereq_("core-js-pure/stable/object/keys");
  25744. },{"core-js-pure/stable/object/keys":730}],113:[function(_dereq_,module,exports){
  25745. module.exports = _dereq_("core-js-pure/stable/object/values");
  25746. },{"core-js-pure/stable/object/values":732}],114:[function(_dereq_,module,exports){
  25747. module.exports = _dereq_("core-js-pure/stable/parse-int");
  25748. },{"core-js-pure/stable/parse-int":733}],115:[function(_dereq_,module,exports){
  25749. module.exports = _dereq_("core-js-pure/stable/promise");
  25750. },{"core-js-pure/stable/promise":734}],116:[function(_dereq_,module,exports){
  25751. module.exports = _dereq_("core-js-pure/stable/reflect/construct");
  25752. },{"core-js-pure/stable/reflect/construct":735}],117:[function(_dereq_,module,exports){
  25753. module.exports = _dereq_("core-js-pure/stable/set-timeout");
  25754. },{"core-js-pure/stable/set-timeout":737}],118:[function(_dereq_,module,exports){
  25755. module.exports = _dereq_("core-js-pure/stable/set");
  25756. },{"core-js-pure/stable/set":738}],119:[function(_dereq_,module,exports){
  25757. module.exports = _dereq_("core-js-pure/stable/symbol");
  25758. },{"core-js-pure/stable/symbol":739}],120:[function(_dereq_,module,exports){
  25759. module.exports = _dereq_("core-js-pure/stable/symbol/replace");
  25760. },{"core-js-pure/stable/symbol/replace":741}],121:[function(_dereq_,module,exports){
  25761. module.exports = _dereq_("core-js-pure/stable/url");
  25762. },{"core-js-pure/stable/url":742}],122:[function(_dereq_,module,exports){
  25763. module.exports = _dereq_("core-js-pure/stable/weak-map");
  25764. },{"core-js-pure/stable/weak-map":743}],123:[function(_dereq_,module,exports){
  25765. module.exports = _dereq_("core-js-pure/features/array/from");
  25766. },{"core-js-pure/features/array/from":404}],124:[function(_dereq_,module,exports){
  25767. module.exports = _dereq_("core-js-pure/features/array/is-array");
  25768. },{"core-js-pure/features/array/is-array":405}],125:[function(_dereq_,module,exports){
  25769. module.exports = _dereq_("core-js-pure/features/get-iterator-method");
  25770. },{"core-js-pure/features/get-iterator-method":406}],126:[function(_dereq_,module,exports){
  25771. module.exports = _dereq_("core-js-pure/features/instance/bind");
  25772. },{"core-js-pure/features/instance/bind":407}],127:[function(_dereq_,module,exports){
  25773. module.exports = _dereq_("core-js-pure/features/instance/index-of");
  25774. },{"core-js-pure/features/instance/index-of":408}],128:[function(_dereq_,module,exports){
  25775. module.exports = _dereq_("core-js-pure/features/instance/slice");
  25776. },{"core-js-pure/features/instance/slice":409}],129:[function(_dereq_,module,exports){
  25777. module.exports = _dereq_("core-js-pure/features/map");
  25778. },{"core-js-pure/features/map":410}],130:[function(_dereq_,module,exports){
  25779. module.exports = _dereq_("core-js-pure/features/object/create");
  25780. },{"core-js-pure/features/object/create":411}],131:[function(_dereq_,module,exports){
  25781. module.exports = _dereq_("core-js-pure/features/object/define-property");
  25782. },{"core-js-pure/features/object/define-property":412}],132:[function(_dereq_,module,exports){
  25783. module.exports = _dereq_("core-js-pure/features/object/get-own-property-descriptor");
  25784. },{"core-js-pure/features/object/get-own-property-descriptor":413}],133:[function(_dereq_,module,exports){
  25785. module.exports = _dereq_("core-js-pure/features/object/get-prototype-of");
  25786. },{"core-js-pure/features/object/get-prototype-of":414}],134:[function(_dereq_,module,exports){
  25787. module.exports = _dereq_("core-js-pure/features/object/set-prototype-of");
  25788. },{"core-js-pure/features/object/set-prototype-of":415}],135:[function(_dereq_,module,exports){
  25789. module.exports = _dereq_("core-js-pure/features/promise");
  25790. },{"core-js-pure/features/promise":416}],136:[function(_dereq_,module,exports){
  25791. module.exports = _dereq_("core-js-pure/features/reflect/construct");
  25792. },{"core-js-pure/features/reflect/construct":417}],137:[function(_dereq_,module,exports){
  25793. module.exports = _dereq_("core-js-pure/features/reflect/get");
  25794. },{"core-js-pure/features/reflect/get":418}],138:[function(_dereq_,module,exports){
  25795. module.exports = _dereq_("core-js-pure/features/symbol");
  25796. },{"core-js-pure/features/symbol":419}],139:[function(_dereq_,module,exports){
  25797. module.exports = _dereq_("core-js-pure/features/symbol/iterator");
  25798. },{"core-js-pure/features/symbol/iterator":420}],140:[function(_dereq_,module,exports){
  25799. function _arrayLikeToArray(arr, len) {
  25800. if (len == null || len > arr.length) len = arr.length;
  25801. for (var i = 0, arr2 = new Array(len); i < len; i++) {
  25802. arr2[i] = arr[i];
  25803. }
  25804. return arr2;
  25805. }
  25806. module.exports = _arrayLikeToArray, module.exports.__esModule = true, module.exports["default"] = module.exports;
  25807. },{}],141:[function(_dereq_,module,exports){
  25808. var _Array$isArray = _dereq_("@babel/runtime-corejs3/core-js/array/is-array");
  25809. function _arrayWithHoles(arr) {
  25810. if (_Array$isArray(arr)) return arr;
  25811. }
  25812. module.exports = _arrayWithHoles, module.exports.__esModule = true, module.exports["default"] = module.exports;
  25813. },{"@babel/runtime-corejs3/core-js/array/is-array":124}],142:[function(_dereq_,module,exports){
  25814. var _Array$isArray = _dereq_("@babel/runtime-corejs3/core-js/array/is-array");
  25815. var arrayLikeToArray = _dereq_("./arrayLikeToArray.js");
  25816. function _arrayWithoutHoles(arr) {
  25817. if (_Array$isArray(arr)) return arrayLikeToArray(arr);
  25818. }
  25819. module.exports = _arrayWithoutHoles, module.exports.__esModule = true, module.exports["default"] = module.exports;
  25820. },{"./arrayLikeToArray.js":140,"@babel/runtime-corejs3/core-js/array/is-array":124}],143:[function(_dereq_,module,exports){
  25821. function _assertThisInitialized(self) {
  25822. if (self === void 0) {
  25823. throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
  25824. }
  25825. return self;
  25826. }
  25827. module.exports = _assertThisInitialized, module.exports.__esModule = true, module.exports["default"] = module.exports;
  25828. },{}],144:[function(_dereq_,module,exports){
  25829. var _Promise = _dereq_("@babel/runtime-corejs3/core-js/promise");
  25830. function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {
  25831. try {
  25832. var info = gen[key](arg);
  25833. var value = info.value;
  25834. } catch (error) {
  25835. reject(error);
  25836. return;
  25837. }
  25838. if (info.done) {
  25839. resolve(value);
  25840. } else {
  25841. _Promise.resolve(value).then(_next, _throw);
  25842. }
  25843. }
  25844. function _asyncToGenerator(fn) {
  25845. return function () {
  25846. var self = this,
  25847. args = arguments;
  25848. return new _Promise(function (resolve, reject) {
  25849. var gen = fn.apply(self, args);
  25850. function _next(value) {
  25851. asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value);
  25852. }
  25853. function _throw(err) {
  25854. asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err);
  25855. }
  25856. _next(undefined);
  25857. });
  25858. };
  25859. }
  25860. module.exports = _asyncToGenerator, module.exports.__esModule = true, module.exports["default"] = module.exports;
  25861. },{"@babel/runtime-corejs3/core-js/promise":135}],145:[function(_dereq_,module,exports){
  25862. function _classCallCheck(instance, Constructor) {
  25863. if (!(instance instanceof Constructor)) {
  25864. throw new TypeError("Cannot call a class as a function");
  25865. }
  25866. }
  25867. module.exports = _classCallCheck, module.exports.__esModule = true, module.exports["default"] = module.exports;
  25868. },{}],146:[function(_dereq_,module,exports){
  25869. var _Reflect$construct = _dereq_("@babel/runtime-corejs3/core-js/reflect/construct");
  25870. var _bindInstanceProperty = _dereq_("@babel/runtime-corejs3/core-js/instance/bind");
  25871. var setPrototypeOf = _dereq_("./setPrototypeOf.js");
  25872. var isNativeReflectConstruct = _dereq_("./isNativeReflectConstruct.js");
  25873. function _construct(Parent, args, Class) {
  25874. if (isNativeReflectConstruct()) {
  25875. module.exports = _construct = _Reflect$construct, module.exports.__esModule = true, module.exports["default"] = module.exports;
  25876. } else {
  25877. module.exports = _construct = function _construct(Parent, args, Class) {
  25878. var a = [null];
  25879. a.push.apply(a, args);
  25880. var Constructor = _bindInstanceProperty(Function).apply(Parent, a);
  25881. var instance = new Constructor();
  25882. if (Class) setPrototypeOf(instance, Class.prototype);
  25883. return instance;
  25884. }, module.exports.__esModule = true, module.exports["default"] = module.exports;
  25885. }
  25886. return _construct.apply(null, arguments);
  25887. }
  25888. module.exports = _construct, module.exports.__esModule = true, module.exports["default"] = module.exports;
  25889. },{"./isNativeReflectConstruct.js":154,"./setPrototypeOf.js":160,"@babel/runtime-corejs3/core-js/instance/bind":126,"@babel/runtime-corejs3/core-js/reflect/construct":136}],147:[function(_dereq_,module,exports){
  25890. var _Object$defineProperty = _dereq_("@babel/runtime-corejs3/core-js/object/define-property");
  25891. function _defineProperties(target, props) {
  25892. for (var i = 0; i < props.length; i++) {
  25893. var descriptor = props[i];
  25894. descriptor.enumerable = descriptor.enumerable || false;
  25895. descriptor.configurable = true;
  25896. if ("value" in descriptor) descriptor.writable = true;
  25897. _Object$defineProperty(target, descriptor.key, descriptor);
  25898. }
  25899. }
  25900. function _createClass(Constructor, protoProps, staticProps) {
  25901. if (protoProps) _defineProperties(Constructor.prototype, protoProps);
  25902. if (staticProps) _defineProperties(Constructor, staticProps);
  25903. _Object$defineProperty(Constructor, "prototype", {
  25904. writable: false
  25905. });
  25906. return Constructor;
  25907. }
  25908. module.exports = _createClass, module.exports.__esModule = true, module.exports["default"] = module.exports;
  25909. },{"@babel/runtime-corejs3/core-js/object/define-property":131}],148:[function(_dereq_,module,exports){
  25910. var _Object$defineProperty = _dereq_("@babel/runtime-corejs3/core-js/object/define-property");
  25911. function _defineProperty(obj, key, value) {
  25912. if (key in obj) {
  25913. _Object$defineProperty(obj, key, {
  25914. value: value,
  25915. enumerable: true,
  25916. configurable: true,
  25917. writable: true
  25918. });
  25919. } else {
  25920. obj[key] = value;
  25921. }
  25922. return obj;
  25923. }
  25924. module.exports = _defineProperty, module.exports.__esModule = true, module.exports["default"] = module.exports;
  25925. },{"@babel/runtime-corejs3/core-js/object/define-property":131}],149:[function(_dereq_,module,exports){
  25926. var _Reflect$get = _dereq_("@babel/runtime-corejs3/core-js/reflect/get");
  25927. var _Object$getOwnPropertyDescriptor = _dereq_("@babel/runtime-corejs3/core-js/object/get-own-property-descriptor");
  25928. var superPropBase = _dereq_("./superPropBase.js");
  25929. function _get() {
  25930. if (typeof Reflect !== "undefined" && _Reflect$get) {
  25931. module.exports = _get = _Reflect$get, module.exports.__esModule = true, module.exports["default"] = module.exports;
  25932. } else {
  25933. module.exports = _get = function _get(target, property, receiver) {
  25934. var base = superPropBase(target, property);
  25935. if (!base) return;
  25936. var desc = _Object$getOwnPropertyDescriptor(base, property);
  25937. if (desc.get) {
  25938. return desc.get.call(arguments.length < 3 ? target : receiver);
  25939. }
  25940. return desc.value;
  25941. }, module.exports.__esModule = true, module.exports["default"] = module.exports;
  25942. }
  25943. return _get.apply(this, arguments);
  25944. }
  25945. module.exports = _get, module.exports.__esModule = true, module.exports["default"] = module.exports;
  25946. },{"./superPropBase.js":162,"@babel/runtime-corejs3/core-js/object/get-own-property-descriptor":132,"@babel/runtime-corejs3/core-js/reflect/get":137}],150:[function(_dereq_,module,exports){
  25947. var _Object$setPrototypeOf = _dereq_("@babel/runtime-corejs3/core-js/object/set-prototype-of");
  25948. var _Object$getPrototypeOf = _dereq_("@babel/runtime-corejs3/core-js/object/get-prototype-of");
  25949. function _getPrototypeOf(o) {
  25950. module.exports = _getPrototypeOf = _Object$setPrototypeOf ? _Object$getPrototypeOf : function _getPrototypeOf(o) {
  25951. return o.__proto__ || _Object$getPrototypeOf(o);
  25952. }, module.exports.__esModule = true, module.exports["default"] = module.exports;
  25953. return _getPrototypeOf(o);
  25954. }
  25955. module.exports = _getPrototypeOf, module.exports.__esModule = true, module.exports["default"] = module.exports;
  25956. },{"@babel/runtime-corejs3/core-js/object/get-prototype-of":133,"@babel/runtime-corejs3/core-js/object/set-prototype-of":134}],151:[function(_dereq_,module,exports){
  25957. var _Object$create = _dereq_("@babel/runtime-corejs3/core-js/object/create");
  25958. var _Object$defineProperty = _dereq_("@babel/runtime-corejs3/core-js/object/define-property");
  25959. var setPrototypeOf = _dereq_("./setPrototypeOf.js");
  25960. function _inherits(subClass, superClass) {
  25961. if (typeof superClass !== "function" && superClass !== null) {
  25962. throw new TypeError("Super expression must either be null or a function");
  25963. }
  25964. subClass.prototype = _Object$create(superClass && superClass.prototype, {
  25965. constructor: {
  25966. value: subClass,
  25967. writable: true,
  25968. configurable: true
  25969. }
  25970. });
  25971. _Object$defineProperty(subClass, "prototype", {
  25972. writable: false
  25973. });
  25974. if (superClass) setPrototypeOf(subClass, superClass);
  25975. }
  25976. module.exports = _inherits, module.exports.__esModule = true, module.exports["default"] = module.exports;
  25977. },{"./setPrototypeOf.js":160,"@babel/runtime-corejs3/core-js/object/create":130,"@babel/runtime-corejs3/core-js/object/define-property":131}],152:[function(_dereq_,module,exports){
  25978. function _interopRequireDefault(obj) {
  25979. return obj && obj.__esModule ? obj : {
  25980. "default": obj
  25981. };
  25982. }
  25983. module.exports = _interopRequireDefault, module.exports.__esModule = true, module.exports["default"] = module.exports;
  25984. },{}],153:[function(_dereq_,module,exports){
  25985. var _indexOfInstanceProperty = _dereq_("@babel/runtime-corejs3/core-js/instance/index-of");
  25986. function _isNativeFunction(fn) {
  25987. var _context;
  25988. return _indexOfInstanceProperty(_context = Function.toString.call(fn)).call(_context, "[native code]") !== -1;
  25989. }
  25990. module.exports = _isNativeFunction, module.exports.__esModule = true, module.exports["default"] = module.exports;
  25991. },{"@babel/runtime-corejs3/core-js/instance/index-of":127}],154:[function(_dereq_,module,exports){
  25992. var _Reflect$construct = _dereq_("@babel/runtime-corejs3/core-js/reflect/construct");
  25993. function _isNativeReflectConstruct() {
  25994. if (typeof Reflect === "undefined" || !_Reflect$construct) return false;
  25995. if (_Reflect$construct.sham) return false;
  25996. if (typeof Proxy === "function") return true;
  25997. try {
  25998. Boolean.prototype.valueOf.call(_Reflect$construct(Boolean, [], function () {}));
  25999. return true;
  26000. } catch (e) {
  26001. return false;
  26002. }
  26003. }
  26004. module.exports = _isNativeReflectConstruct, module.exports.__esModule = true, module.exports["default"] = module.exports;
  26005. },{"@babel/runtime-corejs3/core-js/reflect/construct":136}],155:[function(_dereq_,module,exports){
  26006. var _Symbol = _dereq_("@babel/runtime-corejs3/core-js/symbol");
  26007. var _getIteratorMethod = _dereq_("@babel/runtime-corejs3/core-js/get-iterator-method");
  26008. var _Array$from = _dereq_("@babel/runtime-corejs3/core-js/array/from");
  26009. function _iterableToArray(iter) {
  26010. if (typeof _Symbol !== "undefined" && _getIteratorMethod(iter) != null || iter["@@iterator"] != null) return _Array$from(iter);
  26011. }
  26012. module.exports = _iterableToArray, module.exports.__esModule = true, module.exports["default"] = module.exports;
  26013. },{"@babel/runtime-corejs3/core-js/array/from":123,"@babel/runtime-corejs3/core-js/get-iterator-method":125,"@babel/runtime-corejs3/core-js/symbol":138}],156:[function(_dereq_,module,exports){
  26014. var _Symbol = _dereq_("@babel/runtime-corejs3/core-js/symbol");
  26015. var _getIteratorMethod = _dereq_("@babel/runtime-corejs3/core-js/get-iterator-method");
  26016. function _iterableToArrayLimit(arr, i) {
  26017. var _i = arr == null ? null : typeof _Symbol !== "undefined" && _getIteratorMethod(arr) || arr["@@iterator"];
  26018. if (_i == null) return;
  26019. var _arr = [];
  26020. var _n = true;
  26021. var _d = false;
  26022. var _s, _e;
  26023. try {
  26024. for (_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true) {
  26025. _arr.push(_s.value);
  26026. if (i && _arr.length === i) break;
  26027. }
  26028. } catch (err) {
  26029. _d = true;
  26030. _e = err;
  26031. } finally {
  26032. try {
  26033. if (!_n && _i["return"] != null) _i["return"]();
  26034. } finally {
  26035. if (_d) throw _e;
  26036. }
  26037. }
  26038. return _arr;
  26039. }
  26040. module.exports = _iterableToArrayLimit, module.exports.__esModule = true, module.exports["default"] = module.exports;
  26041. },{"@babel/runtime-corejs3/core-js/get-iterator-method":125,"@babel/runtime-corejs3/core-js/symbol":138}],157:[function(_dereq_,module,exports){
  26042. function _nonIterableRest() {
  26043. throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
  26044. }
  26045. module.exports = _nonIterableRest, module.exports.__esModule = true, module.exports["default"] = module.exports;
  26046. },{}],158:[function(_dereq_,module,exports){
  26047. function _nonIterableSpread() {
  26048. throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
  26049. }
  26050. module.exports = _nonIterableSpread, module.exports.__esModule = true, module.exports["default"] = module.exports;
  26051. },{}],159:[function(_dereq_,module,exports){
  26052. var _typeof = _dereq_("./typeof.js")["default"];
  26053. var assertThisInitialized = _dereq_("./assertThisInitialized.js");
  26054. function _possibleConstructorReturn(self, call) {
  26055. if (call && (_typeof(call) === "object" || typeof call === "function")) {
  26056. return call;
  26057. } else if (call !== void 0) {
  26058. throw new TypeError("Derived constructors may only return object or undefined");
  26059. }
  26060. return assertThisInitialized(self);
  26061. }
  26062. module.exports = _possibleConstructorReturn, module.exports.__esModule = true, module.exports["default"] = module.exports;
  26063. },{"./assertThisInitialized.js":143,"./typeof.js":164}],160:[function(_dereq_,module,exports){
  26064. var _Object$setPrototypeOf = _dereq_("@babel/runtime-corejs3/core-js/object/set-prototype-of");
  26065. function _setPrototypeOf(o, p) {
  26066. module.exports = _setPrototypeOf = _Object$setPrototypeOf || function _setPrototypeOf(o, p) {
  26067. o.__proto__ = p;
  26068. return o;
  26069. }, module.exports.__esModule = true, module.exports["default"] = module.exports;
  26070. return _setPrototypeOf(o, p);
  26071. }
  26072. module.exports = _setPrototypeOf, module.exports.__esModule = true, module.exports["default"] = module.exports;
  26073. },{"@babel/runtime-corejs3/core-js/object/set-prototype-of":134}],161:[function(_dereq_,module,exports){
  26074. var arrayWithHoles = _dereq_("./arrayWithHoles.js");
  26075. var iterableToArrayLimit = _dereq_("./iterableToArrayLimit.js");
  26076. var unsupportedIterableToArray = _dereq_("./unsupportedIterableToArray.js");
  26077. var nonIterableRest = _dereq_("./nonIterableRest.js");
  26078. function _slicedToArray(arr, i) {
  26079. return arrayWithHoles(arr) || iterableToArrayLimit(arr, i) || unsupportedIterableToArray(arr, i) || nonIterableRest();
  26080. }
  26081. module.exports = _slicedToArray, module.exports.__esModule = true, module.exports["default"] = module.exports;
  26082. },{"./arrayWithHoles.js":141,"./iterableToArrayLimit.js":156,"./nonIterableRest.js":157,"./unsupportedIterableToArray.js":165}],162:[function(_dereq_,module,exports){
  26083. var getPrototypeOf = _dereq_("./getPrototypeOf.js");
  26084. function _superPropBase(object, property) {
  26085. while (!Object.prototype.hasOwnProperty.call(object, property)) {
  26086. object = getPrototypeOf(object);
  26087. if (object === null) break;
  26088. }
  26089. return object;
  26090. }
  26091. module.exports = _superPropBase, module.exports.__esModule = true, module.exports["default"] = module.exports;
  26092. },{"./getPrototypeOf.js":150}],163:[function(_dereq_,module,exports){
  26093. var arrayWithoutHoles = _dereq_("./arrayWithoutHoles.js");
  26094. var iterableToArray = _dereq_("./iterableToArray.js");
  26095. var unsupportedIterableToArray = _dereq_("./unsupportedIterableToArray.js");
  26096. var nonIterableSpread = _dereq_("./nonIterableSpread.js");
  26097. function _toConsumableArray(arr) {
  26098. return arrayWithoutHoles(arr) || iterableToArray(arr) || unsupportedIterableToArray(arr) || nonIterableSpread();
  26099. }
  26100. module.exports = _toConsumableArray, module.exports.__esModule = true, module.exports["default"] = module.exports;
  26101. },{"./arrayWithoutHoles.js":142,"./iterableToArray.js":155,"./nonIterableSpread.js":158,"./unsupportedIterableToArray.js":165}],164:[function(_dereq_,module,exports){
  26102. var _Symbol = _dereq_("@babel/runtime-corejs3/core-js/symbol");
  26103. var _Symbol$iterator = _dereq_("@babel/runtime-corejs3/core-js/symbol/iterator");
  26104. function _typeof(obj) {
  26105. "@babel/helpers - typeof";
  26106. return (module.exports = _typeof = "function" == typeof _Symbol && "symbol" == typeof _Symbol$iterator ? function (obj) {
  26107. return typeof obj;
  26108. } : function (obj) {
  26109. return obj && "function" == typeof _Symbol && obj.constructor === _Symbol && obj !== _Symbol.prototype ? "symbol" : typeof obj;
  26110. }, module.exports.__esModule = true, module.exports["default"] = module.exports), _typeof(obj);
  26111. }
  26112. module.exports = _typeof, module.exports.__esModule = true, module.exports["default"] = module.exports;
  26113. },{"@babel/runtime-corejs3/core-js/symbol":138,"@babel/runtime-corejs3/core-js/symbol/iterator":139}],165:[function(_dereq_,module,exports){
  26114. var _sliceInstanceProperty = _dereq_("@babel/runtime-corejs3/core-js/instance/slice");
  26115. var _Array$from = _dereq_("@babel/runtime-corejs3/core-js/array/from");
  26116. var arrayLikeToArray = _dereq_("./arrayLikeToArray.js");
  26117. function _unsupportedIterableToArray(o, minLen) {
  26118. var _context;
  26119. if (!o) return;
  26120. if (typeof o === "string") return arrayLikeToArray(o, minLen);
  26121. var n = _sliceInstanceProperty(_context = Object.prototype.toString.call(o)).call(_context, 8, -1);
  26122. if (n === "Object" && o.constructor) n = o.constructor.name;
  26123. if (n === "Map" || n === "Set") return _Array$from(o);
  26124. if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return arrayLikeToArray(o, minLen);
  26125. }
  26126. module.exports = _unsupportedIterableToArray, module.exports.__esModule = true, module.exports["default"] = module.exports;
  26127. },{"./arrayLikeToArray.js":140,"@babel/runtime-corejs3/core-js/array/from":123,"@babel/runtime-corejs3/core-js/instance/slice":128}],166:[function(_dereq_,module,exports){
  26128. var _Map = _dereq_("@babel/runtime-corejs3/core-js/map");
  26129. var _Object$create = _dereq_("@babel/runtime-corejs3/core-js/object/create");
  26130. var getPrototypeOf = _dereq_("./getPrototypeOf.js");
  26131. var setPrototypeOf = _dereq_("./setPrototypeOf.js");
  26132. var isNativeFunction = _dereq_("./isNativeFunction.js");
  26133. var construct = _dereq_("./construct.js");
  26134. function _wrapNativeSuper(Class) {
  26135. var _cache = typeof _Map === "function" ? new _Map() : undefined;
  26136. module.exports = _wrapNativeSuper = function _wrapNativeSuper(Class) {
  26137. if (Class === null || !isNativeFunction(Class)) return Class;
  26138. if (typeof Class !== "function") {
  26139. throw new TypeError("Super expression must either be null or a function");
  26140. }
  26141. if (typeof _cache !== "undefined") {
  26142. if (_cache.has(Class)) return _cache.get(Class);
  26143. _cache.set(Class, Wrapper);
  26144. }
  26145. function Wrapper() {
  26146. return construct(Class, arguments, getPrototypeOf(this).constructor);
  26147. }
  26148. Wrapper.prototype = _Object$create(Class.prototype, {
  26149. constructor: {
  26150. value: Wrapper,
  26151. enumerable: false,
  26152. writable: true,
  26153. configurable: true
  26154. }
  26155. });
  26156. return setPrototypeOf(Wrapper, Class);
  26157. }, module.exports.__esModule = true, module.exports["default"] = module.exports;
  26158. return _wrapNativeSuper(Class);
  26159. }
  26160. module.exports = _wrapNativeSuper, module.exports.__esModule = true, module.exports["default"] = module.exports;
  26161. },{"./construct.js":146,"./getPrototypeOf.js":150,"./isNativeFunction.js":153,"./setPrototypeOf.js":160,"@babel/runtime-corejs3/core-js/map":129,"@babel/runtime-corejs3/core-js/object/create":130}],167:[function(_dereq_,module,exports){
  26162. module.exports = _dereq_("regenerator-runtime");
  26163. },{"regenerator-runtime":794}],168:[function(_dereq_,module,exports){
  26164. "use strict";
  26165. Object.defineProperty(exports, "__esModule", { value: true });
  26166. exports.version = void 0;
  26167. exports.version = "abi/5.6.0";
  26168. },{}],169:[function(_dereq_,module,exports){
  26169. "use strict";
  26170. Object.defineProperty(exports, "__esModule", { value: true });
  26171. exports.defaultAbiCoder = exports.AbiCoder = void 0;
  26172. // See: https://github.com/ethereum/wiki/wiki/Ethereum-Contract-ABI
  26173. var bytes_1 = _dereq_("@ethersproject/bytes");
  26174. var properties_1 = _dereq_("@ethersproject/properties");
  26175. var logger_1 = _dereq_("@ethersproject/logger");
  26176. var _version_1 = _dereq_("./_version");
  26177. var logger = new logger_1.Logger(_version_1.version);
  26178. var abstract_coder_1 = _dereq_("./coders/abstract-coder");
  26179. var address_1 = _dereq_("./coders/address");
  26180. var array_1 = _dereq_("./coders/array");
  26181. var boolean_1 = _dereq_("./coders/boolean");
  26182. var bytes_2 = _dereq_("./coders/bytes");
  26183. var fixed_bytes_1 = _dereq_("./coders/fixed-bytes");
  26184. var null_1 = _dereq_("./coders/null");
  26185. var number_1 = _dereq_("./coders/number");
  26186. var string_1 = _dereq_("./coders/string");
  26187. var tuple_1 = _dereq_("./coders/tuple");
  26188. var fragments_1 = _dereq_("./fragments");
  26189. var paramTypeBytes = new RegExp(/^bytes([0-9]*)$/);
  26190. var paramTypeNumber = new RegExp(/^(u?int)([0-9]*)$/);
  26191. var AbiCoder = /** @class */ (function () {
  26192. function AbiCoder(coerceFunc) {
  26193. var _newTarget = this.constructor;
  26194. logger.checkNew(_newTarget, AbiCoder);
  26195. (0, properties_1.defineReadOnly)(this, "coerceFunc", coerceFunc || null);
  26196. }
  26197. AbiCoder.prototype._getCoder = function (param) {
  26198. var _this = this;
  26199. switch (param.baseType) {
  26200. case "address":
  26201. return new address_1.AddressCoder(param.name);
  26202. case "bool":
  26203. return new boolean_1.BooleanCoder(param.name);
  26204. case "string":
  26205. return new string_1.StringCoder(param.name);
  26206. case "bytes":
  26207. return new bytes_2.BytesCoder(param.name);
  26208. case "array":
  26209. return new array_1.ArrayCoder(this._getCoder(param.arrayChildren), param.arrayLength, param.name);
  26210. case "tuple":
  26211. return new tuple_1.TupleCoder((param.components || []).map(function (component) {
  26212. return _this._getCoder(component);
  26213. }), param.name);
  26214. case "":
  26215. return new null_1.NullCoder(param.name);
  26216. }
  26217. // u?int[0-9]*
  26218. var match = param.type.match(paramTypeNumber);
  26219. if (match) {
  26220. var size = parseInt(match[2] || "256");
  26221. if (size === 0 || size > 256 || (size % 8) !== 0) {
  26222. logger.throwArgumentError("invalid " + match[1] + " bit length", "param", param);
  26223. }
  26224. return new number_1.NumberCoder(size / 8, (match[1] === "int"), param.name);
  26225. }
  26226. // bytes[0-9]+
  26227. match = param.type.match(paramTypeBytes);
  26228. if (match) {
  26229. var size = parseInt(match[1]);
  26230. if (size === 0 || size > 32) {
  26231. logger.throwArgumentError("invalid bytes length", "param", param);
  26232. }
  26233. return new fixed_bytes_1.FixedBytesCoder(size, param.name);
  26234. }
  26235. return logger.throwArgumentError("invalid type", "type", param.type);
  26236. };
  26237. AbiCoder.prototype._getWordSize = function () { return 32; };
  26238. AbiCoder.prototype._getReader = function (data, allowLoose) {
  26239. return new abstract_coder_1.Reader(data, this._getWordSize(), this.coerceFunc, allowLoose);
  26240. };
  26241. AbiCoder.prototype._getWriter = function () {
  26242. return new abstract_coder_1.Writer(this._getWordSize());
  26243. };
  26244. AbiCoder.prototype.getDefaultValue = function (types) {
  26245. var _this = this;
  26246. var coders = types.map(function (type) { return _this._getCoder(fragments_1.ParamType.from(type)); });
  26247. var coder = new tuple_1.TupleCoder(coders, "_");
  26248. return coder.defaultValue();
  26249. };
  26250. AbiCoder.prototype.encode = function (types, values) {
  26251. var _this = this;
  26252. if (types.length !== values.length) {
  26253. logger.throwError("types/values length mismatch", logger_1.Logger.errors.INVALID_ARGUMENT, {
  26254. count: { types: types.length, values: values.length },
  26255. value: { types: types, values: values }
  26256. });
  26257. }
  26258. var coders = types.map(function (type) { return _this._getCoder(fragments_1.ParamType.from(type)); });
  26259. var coder = (new tuple_1.TupleCoder(coders, "_"));
  26260. var writer = this._getWriter();
  26261. coder.encode(writer, values);
  26262. return writer.data;
  26263. };
  26264. AbiCoder.prototype.decode = function (types, data, loose) {
  26265. var _this = this;
  26266. var coders = types.map(function (type) { return _this._getCoder(fragments_1.ParamType.from(type)); });
  26267. var coder = new tuple_1.TupleCoder(coders, "_");
  26268. return coder.decode(this._getReader((0, bytes_1.arrayify)(data), loose));
  26269. };
  26270. return AbiCoder;
  26271. }());
  26272. exports.AbiCoder = AbiCoder;
  26273. exports.defaultAbiCoder = new AbiCoder();
  26274. },{"./_version":168,"./coders/abstract-coder":170,"./coders/address":171,"./coders/array":173,"./coders/boolean":174,"./coders/bytes":175,"./coders/fixed-bytes":176,"./coders/null":177,"./coders/number":178,"./coders/string":179,"./coders/tuple":180,"./fragments":181,"@ethersproject/bytes":199,"@ethersproject/logger":223,"@ethersproject/properties":229}],170:[function(_dereq_,module,exports){
  26275. "use strict";
  26276. Object.defineProperty(exports, "__esModule", { value: true });
  26277. exports.Reader = exports.Writer = exports.Coder = exports.checkResultErrors = void 0;
  26278. var bytes_1 = _dereq_("@ethersproject/bytes");
  26279. var bignumber_1 = _dereq_("@ethersproject/bignumber");
  26280. var properties_1 = _dereq_("@ethersproject/properties");
  26281. var logger_1 = _dereq_("@ethersproject/logger");
  26282. var _version_1 = _dereq_("../_version");
  26283. var logger = new logger_1.Logger(_version_1.version);
  26284. function checkResultErrors(result) {
  26285. // Find the first error (if any)
  26286. var errors = [];
  26287. var checkErrors = function (path, object) {
  26288. if (!Array.isArray(object)) {
  26289. return;
  26290. }
  26291. for (var key in object) {
  26292. var childPath = path.slice();
  26293. childPath.push(key);
  26294. try {
  26295. checkErrors(childPath, object[key]);
  26296. }
  26297. catch (error) {
  26298. errors.push({ path: childPath, error: error });
  26299. }
  26300. }
  26301. };
  26302. checkErrors([], result);
  26303. return errors;
  26304. }
  26305. exports.checkResultErrors = checkResultErrors;
  26306. var Coder = /** @class */ (function () {
  26307. function Coder(name, type, localName, dynamic) {
  26308. // @TODO: defineReadOnly these
  26309. this.name = name;
  26310. this.type = type;
  26311. this.localName = localName;
  26312. this.dynamic = dynamic;
  26313. }
  26314. Coder.prototype._throwError = function (message, value) {
  26315. logger.throwArgumentError(message, this.localName, value);
  26316. };
  26317. return Coder;
  26318. }());
  26319. exports.Coder = Coder;
  26320. var Writer = /** @class */ (function () {
  26321. function Writer(wordSize) {
  26322. (0, properties_1.defineReadOnly)(this, "wordSize", wordSize || 32);
  26323. this._data = [];
  26324. this._dataLength = 0;
  26325. this._padding = new Uint8Array(wordSize);
  26326. }
  26327. Object.defineProperty(Writer.prototype, "data", {
  26328. get: function () {
  26329. return (0, bytes_1.hexConcat)(this._data);
  26330. },
  26331. enumerable: false,
  26332. configurable: true
  26333. });
  26334. Object.defineProperty(Writer.prototype, "length", {
  26335. get: function () { return this._dataLength; },
  26336. enumerable: false,
  26337. configurable: true
  26338. });
  26339. Writer.prototype._writeData = function (data) {
  26340. this._data.push(data);
  26341. this._dataLength += data.length;
  26342. return data.length;
  26343. };
  26344. Writer.prototype.appendWriter = function (writer) {
  26345. return this._writeData((0, bytes_1.concat)(writer._data));
  26346. };
  26347. // Arrayish items; padded on the right to wordSize
  26348. Writer.prototype.writeBytes = function (value) {
  26349. var bytes = (0, bytes_1.arrayify)(value);
  26350. var paddingOffset = bytes.length % this.wordSize;
  26351. if (paddingOffset) {
  26352. bytes = (0, bytes_1.concat)([bytes, this._padding.slice(paddingOffset)]);
  26353. }
  26354. return this._writeData(bytes);
  26355. };
  26356. Writer.prototype._getValue = function (value) {
  26357. var bytes = (0, bytes_1.arrayify)(bignumber_1.BigNumber.from(value));
  26358. if (bytes.length > this.wordSize) {
  26359. logger.throwError("value out-of-bounds", logger_1.Logger.errors.BUFFER_OVERRUN, {
  26360. length: this.wordSize,
  26361. offset: bytes.length
  26362. });
  26363. }
  26364. if (bytes.length % this.wordSize) {
  26365. bytes = (0, bytes_1.concat)([this._padding.slice(bytes.length % this.wordSize), bytes]);
  26366. }
  26367. return bytes;
  26368. };
  26369. // BigNumberish items; padded on the left to wordSize
  26370. Writer.prototype.writeValue = function (value) {
  26371. return this._writeData(this._getValue(value));
  26372. };
  26373. Writer.prototype.writeUpdatableValue = function () {
  26374. var _this = this;
  26375. var offset = this._data.length;
  26376. this._data.push(this._padding);
  26377. this._dataLength += this.wordSize;
  26378. return function (value) {
  26379. _this._data[offset] = _this._getValue(value);
  26380. };
  26381. };
  26382. return Writer;
  26383. }());
  26384. exports.Writer = Writer;
  26385. var Reader = /** @class */ (function () {
  26386. function Reader(data, wordSize, coerceFunc, allowLoose) {
  26387. (0, properties_1.defineReadOnly)(this, "_data", (0, bytes_1.arrayify)(data));
  26388. (0, properties_1.defineReadOnly)(this, "wordSize", wordSize || 32);
  26389. (0, properties_1.defineReadOnly)(this, "_coerceFunc", coerceFunc);
  26390. (0, properties_1.defineReadOnly)(this, "allowLoose", allowLoose);
  26391. this._offset = 0;
  26392. }
  26393. Object.defineProperty(Reader.prototype, "data", {
  26394. get: function () { return (0, bytes_1.hexlify)(this._data); },
  26395. enumerable: false,
  26396. configurable: true
  26397. });
  26398. Object.defineProperty(Reader.prototype, "consumed", {
  26399. get: function () { return this._offset; },
  26400. enumerable: false,
  26401. configurable: true
  26402. });
  26403. // The default Coerce function
  26404. Reader.coerce = function (name, value) {
  26405. var match = name.match("^u?int([0-9]+)$");
  26406. if (match && parseInt(match[1]) <= 48) {
  26407. value = value.toNumber();
  26408. }
  26409. return value;
  26410. };
  26411. Reader.prototype.coerce = function (name, value) {
  26412. if (this._coerceFunc) {
  26413. return this._coerceFunc(name, value);
  26414. }
  26415. return Reader.coerce(name, value);
  26416. };
  26417. Reader.prototype._peekBytes = function (offset, length, loose) {
  26418. var alignedLength = Math.ceil(length / this.wordSize) * this.wordSize;
  26419. if (this._offset + alignedLength > this._data.length) {
  26420. if (this.allowLoose && loose && this._offset + length <= this._data.length) {
  26421. alignedLength = length;
  26422. }
  26423. else {
  26424. logger.throwError("data out-of-bounds", logger_1.Logger.errors.BUFFER_OVERRUN, {
  26425. length: this._data.length,
  26426. offset: this._offset + alignedLength
  26427. });
  26428. }
  26429. }
  26430. return this._data.slice(this._offset, this._offset + alignedLength);
  26431. };
  26432. Reader.prototype.subReader = function (offset) {
  26433. return new Reader(this._data.slice(this._offset + offset), this.wordSize, this._coerceFunc, this.allowLoose);
  26434. };
  26435. Reader.prototype.readBytes = function (length, loose) {
  26436. var bytes = this._peekBytes(0, length, !!loose);
  26437. this._offset += bytes.length;
  26438. // @TODO: Make sure the length..end bytes are all 0?
  26439. return bytes.slice(0, length);
  26440. };
  26441. Reader.prototype.readValue = function () {
  26442. return bignumber_1.BigNumber.from(this.readBytes(this.wordSize));
  26443. };
  26444. return Reader;
  26445. }());
  26446. exports.Reader = Reader;
  26447. },{"../_version":168,"@ethersproject/bignumber":196,"@ethersproject/bytes":199,"@ethersproject/logger":223,"@ethersproject/properties":229}],171:[function(_dereq_,module,exports){
  26448. "use strict";
  26449. var __extends = (this && this.__extends) || (function () {
  26450. var extendStatics = function (d, b) {
  26451. extendStatics = Object.setPrototypeOf ||
  26452. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  26453. function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
  26454. return extendStatics(d, b);
  26455. };
  26456. return function (d, b) {
  26457. if (typeof b !== "function" && b !== null)
  26458. throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
  26459. extendStatics(d, b);
  26460. function __() { this.constructor = d; }
  26461. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  26462. };
  26463. })();
  26464. Object.defineProperty(exports, "__esModule", { value: true });
  26465. exports.AddressCoder = void 0;
  26466. var address_1 = _dereq_("@ethersproject/address");
  26467. var bytes_1 = _dereq_("@ethersproject/bytes");
  26468. var abstract_coder_1 = _dereq_("./abstract-coder");
  26469. var AddressCoder = /** @class */ (function (_super) {
  26470. __extends(AddressCoder, _super);
  26471. function AddressCoder(localName) {
  26472. return _super.call(this, "address", "address", localName, false) || this;
  26473. }
  26474. AddressCoder.prototype.defaultValue = function () {
  26475. return "0x0000000000000000000000000000000000000000";
  26476. };
  26477. AddressCoder.prototype.encode = function (writer, value) {
  26478. try {
  26479. value = (0, address_1.getAddress)(value);
  26480. }
  26481. catch (error) {
  26482. this._throwError(error.message, value);
  26483. }
  26484. return writer.writeValue(value);
  26485. };
  26486. AddressCoder.prototype.decode = function (reader) {
  26487. return (0, address_1.getAddress)((0, bytes_1.hexZeroPad)(reader.readValue().toHexString(), 20));
  26488. };
  26489. return AddressCoder;
  26490. }(abstract_coder_1.Coder));
  26491. exports.AddressCoder = AddressCoder;
  26492. },{"./abstract-coder":170,"@ethersproject/address":189,"@ethersproject/bytes":199}],172:[function(_dereq_,module,exports){
  26493. "use strict";
  26494. var __extends = (this && this.__extends) || (function () {
  26495. var extendStatics = function (d, b) {
  26496. extendStatics = Object.setPrototypeOf ||
  26497. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  26498. function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
  26499. return extendStatics(d, b);
  26500. };
  26501. return function (d, b) {
  26502. if (typeof b !== "function" && b !== null)
  26503. throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
  26504. extendStatics(d, b);
  26505. function __() { this.constructor = d; }
  26506. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  26507. };
  26508. })();
  26509. Object.defineProperty(exports, "__esModule", { value: true });
  26510. exports.AnonymousCoder = void 0;
  26511. var abstract_coder_1 = _dereq_("./abstract-coder");
  26512. // Clones the functionality of an existing Coder, but without a localName
  26513. var AnonymousCoder = /** @class */ (function (_super) {
  26514. __extends(AnonymousCoder, _super);
  26515. function AnonymousCoder(coder) {
  26516. var _this = _super.call(this, coder.name, coder.type, undefined, coder.dynamic) || this;
  26517. _this.coder = coder;
  26518. return _this;
  26519. }
  26520. AnonymousCoder.prototype.defaultValue = function () {
  26521. return this.coder.defaultValue();
  26522. };
  26523. AnonymousCoder.prototype.encode = function (writer, value) {
  26524. return this.coder.encode(writer, value);
  26525. };
  26526. AnonymousCoder.prototype.decode = function (reader) {
  26527. return this.coder.decode(reader);
  26528. };
  26529. return AnonymousCoder;
  26530. }(abstract_coder_1.Coder));
  26531. exports.AnonymousCoder = AnonymousCoder;
  26532. },{"./abstract-coder":170}],173:[function(_dereq_,module,exports){
  26533. "use strict";
  26534. var __extends = (this && this.__extends) || (function () {
  26535. var extendStatics = function (d, b) {
  26536. extendStatics = Object.setPrototypeOf ||
  26537. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  26538. function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
  26539. return extendStatics(d, b);
  26540. };
  26541. return function (d, b) {
  26542. if (typeof b !== "function" && b !== null)
  26543. throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
  26544. extendStatics(d, b);
  26545. function __() { this.constructor = d; }
  26546. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  26547. };
  26548. })();
  26549. Object.defineProperty(exports, "__esModule", { value: true });
  26550. exports.ArrayCoder = exports.unpack = exports.pack = void 0;
  26551. var logger_1 = _dereq_("@ethersproject/logger");
  26552. var _version_1 = _dereq_("../_version");
  26553. var logger = new logger_1.Logger(_version_1.version);
  26554. var abstract_coder_1 = _dereq_("./abstract-coder");
  26555. var anonymous_1 = _dereq_("./anonymous");
  26556. function pack(writer, coders, values) {
  26557. var arrayValues = null;
  26558. if (Array.isArray(values)) {
  26559. arrayValues = values;
  26560. }
  26561. else if (values && typeof (values) === "object") {
  26562. var unique_1 = {};
  26563. arrayValues = coders.map(function (coder) {
  26564. var name = coder.localName;
  26565. if (!name) {
  26566. logger.throwError("cannot encode object for signature with missing names", logger_1.Logger.errors.INVALID_ARGUMENT, {
  26567. argument: "values",
  26568. coder: coder,
  26569. value: values
  26570. });
  26571. }
  26572. if (unique_1[name]) {
  26573. logger.throwError("cannot encode object for signature with duplicate names", logger_1.Logger.errors.INVALID_ARGUMENT, {
  26574. argument: "values",
  26575. coder: coder,
  26576. value: values
  26577. });
  26578. }
  26579. unique_1[name] = true;
  26580. return values[name];
  26581. });
  26582. }
  26583. else {
  26584. logger.throwArgumentError("invalid tuple value", "tuple", values);
  26585. }
  26586. if (coders.length !== arrayValues.length) {
  26587. logger.throwArgumentError("types/value length mismatch", "tuple", values);
  26588. }
  26589. var staticWriter = new abstract_coder_1.Writer(writer.wordSize);
  26590. var dynamicWriter = new abstract_coder_1.Writer(writer.wordSize);
  26591. var updateFuncs = [];
  26592. coders.forEach(function (coder, index) {
  26593. var value = arrayValues[index];
  26594. if (coder.dynamic) {
  26595. // Get current dynamic offset (for the future pointer)
  26596. var dynamicOffset_1 = dynamicWriter.length;
  26597. // Encode the dynamic value into the dynamicWriter
  26598. coder.encode(dynamicWriter, value);
  26599. // Prepare to populate the correct offset once we are done
  26600. var updateFunc_1 = staticWriter.writeUpdatableValue();
  26601. updateFuncs.push(function (baseOffset) {
  26602. updateFunc_1(baseOffset + dynamicOffset_1);
  26603. });
  26604. }
  26605. else {
  26606. coder.encode(staticWriter, value);
  26607. }
  26608. });
  26609. // Backfill all the dynamic offsets, now that we know the static length
  26610. updateFuncs.forEach(function (func) { func(staticWriter.length); });
  26611. var length = writer.appendWriter(staticWriter);
  26612. length += writer.appendWriter(dynamicWriter);
  26613. return length;
  26614. }
  26615. exports.pack = pack;
  26616. function unpack(reader, coders) {
  26617. var values = [];
  26618. // A reader anchored to this base
  26619. var baseReader = reader.subReader(0);
  26620. coders.forEach(function (coder) {
  26621. var value = null;
  26622. if (coder.dynamic) {
  26623. var offset = reader.readValue();
  26624. var offsetReader = baseReader.subReader(offset.toNumber());
  26625. try {
  26626. value = coder.decode(offsetReader);
  26627. }
  26628. catch (error) {
  26629. // Cannot recover from this
  26630. if (error.code === logger_1.Logger.errors.BUFFER_OVERRUN) {
  26631. throw error;
  26632. }
  26633. value = error;
  26634. value.baseType = coder.name;
  26635. value.name = coder.localName;
  26636. value.type = coder.type;
  26637. }
  26638. }
  26639. else {
  26640. try {
  26641. value = coder.decode(reader);
  26642. }
  26643. catch (error) {
  26644. // Cannot recover from this
  26645. if (error.code === logger_1.Logger.errors.BUFFER_OVERRUN) {
  26646. throw error;
  26647. }
  26648. value = error;
  26649. value.baseType = coder.name;
  26650. value.name = coder.localName;
  26651. value.type = coder.type;
  26652. }
  26653. }
  26654. if (value != undefined) {
  26655. values.push(value);
  26656. }
  26657. });
  26658. // We only output named properties for uniquely named coders
  26659. var uniqueNames = coders.reduce(function (accum, coder) {
  26660. var name = coder.localName;
  26661. if (name) {
  26662. if (!accum[name]) {
  26663. accum[name] = 0;
  26664. }
  26665. accum[name]++;
  26666. }
  26667. return accum;
  26668. }, {});
  26669. // Add any named parameters (i.e. tuples)
  26670. coders.forEach(function (coder, index) {
  26671. var name = coder.localName;
  26672. if (!name || uniqueNames[name] !== 1) {
  26673. return;
  26674. }
  26675. if (name === "length") {
  26676. name = "_length";
  26677. }
  26678. if (values[name] != null) {
  26679. return;
  26680. }
  26681. var value = values[index];
  26682. if (value instanceof Error) {
  26683. Object.defineProperty(values, name, {
  26684. enumerable: true,
  26685. get: function () { throw value; }
  26686. });
  26687. }
  26688. else {
  26689. values[name] = value;
  26690. }
  26691. });
  26692. var _loop_1 = function (i) {
  26693. var value = values[i];
  26694. if (value instanceof Error) {
  26695. Object.defineProperty(values, i, {
  26696. enumerable: true,
  26697. get: function () { throw value; }
  26698. });
  26699. }
  26700. };
  26701. for (var i = 0; i < values.length; i++) {
  26702. _loop_1(i);
  26703. }
  26704. return Object.freeze(values);
  26705. }
  26706. exports.unpack = unpack;
  26707. var ArrayCoder = /** @class */ (function (_super) {
  26708. __extends(ArrayCoder, _super);
  26709. function ArrayCoder(coder, length, localName) {
  26710. var _this = this;
  26711. var type = (coder.type + "[" + (length >= 0 ? length : "") + "]");
  26712. var dynamic = (length === -1 || coder.dynamic);
  26713. _this = _super.call(this, "array", type, localName, dynamic) || this;
  26714. _this.coder = coder;
  26715. _this.length = length;
  26716. return _this;
  26717. }
  26718. ArrayCoder.prototype.defaultValue = function () {
  26719. // Verifies the child coder is valid (even if the array is dynamic or 0-length)
  26720. var defaultChild = this.coder.defaultValue();
  26721. var result = [];
  26722. for (var i = 0; i < this.length; i++) {
  26723. result.push(defaultChild);
  26724. }
  26725. return result;
  26726. };
  26727. ArrayCoder.prototype.encode = function (writer, value) {
  26728. if (!Array.isArray(value)) {
  26729. this._throwError("expected array value", value);
  26730. }
  26731. var count = this.length;
  26732. if (count === -1) {
  26733. count = value.length;
  26734. writer.writeValue(value.length);
  26735. }
  26736. logger.checkArgumentCount(value.length, count, "coder array" + (this.localName ? (" " + this.localName) : ""));
  26737. var coders = [];
  26738. for (var i = 0; i < value.length; i++) {
  26739. coders.push(this.coder);
  26740. }
  26741. return pack(writer, coders, value);
  26742. };
  26743. ArrayCoder.prototype.decode = function (reader) {
  26744. var count = this.length;
  26745. if (count === -1) {
  26746. count = reader.readValue().toNumber();
  26747. // Check that there is *roughly* enough data to ensure
  26748. // stray random data is not being read as a length. Each
  26749. // slot requires at least 32 bytes for their value (or 32
  26750. // bytes as a link to the data). This could use a much
  26751. // tighter bound, but we are erroring on the side of safety.
  26752. if (count * 32 > reader._data.length) {
  26753. logger.throwError("insufficient data length", logger_1.Logger.errors.BUFFER_OVERRUN, {
  26754. length: reader._data.length,
  26755. count: count
  26756. });
  26757. }
  26758. }
  26759. var coders = [];
  26760. for (var i = 0; i < count; i++) {
  26761. coders.push(new anonymous_1.AnonymousCoder(this.coder));
  26762. }
  26763. return reader.coerce(this.name, unpack(reader, coders));
  26764. };
  26765. return ArrayCoder;
  26766. }(abstract_coder_1.Coder));
  26767. exports.ArrayCoder = ArrayCoder;
  26768. },{"../_version":168,"./abstract-coder":170,"./anonymous":172,"@ethersproject/logger":223}],174:[function(_dereq_,module,exports){
  26769. "use strict";
  26770. var __extends = (this && this.__extends) || (function () {
  26771. var extendStatics = function (d, b) {
  26772. extendStatics = Object.setPrototypeOf ||
  26773. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  26774. function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
  26775. return extendStatics(d, b);
  26776. };
  26777. return function (d, b) {
  26778. if (typeof b !== "function" && b !== null)
  26779. throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
  26780. extendStatics(d, b);
  26781. function __() { this.constructor = d; }
  26782. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  26783. };
  26784. })();
  26785. Object.defineProperty(exports, "__esModule", { value: true });
  26786. exports.BooleanCoder = void 0;
  26787. var abstract_coder_1 = _dereq_("./abstract-coder");
  26788. var BooleanCoder = /** @class */ (function (_super) {
  26789. __extends(BooleanCoder, _super);
  26790. function BooleanCoder(localName) {
  26791. return _super.call(this, "bool", "bool", localName, false) || this;
  26792. }
  26793. BooleanCoder.prototype.defaultValue = function () {
  26794. return false;
  26795. };
  26796. BooleanCoder.prototype.encode = function (writer, value) {
  26797. return writer.writeValue(value ? 1 : 0);
  26798. };
  26799. BooleanCoder.prototype.decode = function (reader) {
  26800. return reader.coerce(this.type, !reader.readValue().isZero());
  26801. };
  26802. return BooleanCoder;
  26803. }(abstract_coder_1.Coder));
  26804. exports.BooleanCoder = BooleanCoder;
  26805. },{"./abstract-coder":170}],175:[function(_dereq_,module,exports){
  26806. "use strict";
  26807. var __extends = (this && this.__extends) || (function () {
  26808. var extendStatics = function (d, b) {
  26809. extendStatics = Object.setPrototypeOf ||
  26810. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  26811. function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
  26812. return extendStatics(d, b);
  26813. };
  26814. return function (d, b) {
  26815. if (typeof b !== "function" && b !== null)
  26816. throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
  26817. extendStatics(d, b);
  26818. function __() { this.constructor = d; }
  26819. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  26820. };
  26821. })();
  26822. Object.defineProperty(exports, "__esModule", { value: true });
  26823. exports.BytesCoder = exports.DynamicBytesCoder = void 0;
  26824. var bytes_1 = _dereq_("@ethersproject/bytes");
  26825. var abstract_coder_1 = _dereq_("./abstract-coder");
  26826. var DynamicBytesCoder = /** @class */ (function (_super) {
  26827. __extends(DynamicBytesCoder, _super);
  26828. function DynamicBytesCoder(type, localName) {
  26829. return _super.call(this, type, type, localName, true) || this;
  26830. }
  26831. DynamicBytesCoder.prototype.defaultValue = function () {
  26832. return "0x";
  26833. };
  26834. DynamicBytesCoder.prototype.encode = function (writer, value) {
  26835. value = (0, bytes_1.arrayify)(value);
  26836. var length = writer.writeValue(value.length);
  26837. length += writer.writeBytes(value);
  26838. return length;
  26839. };
  26840. DynamicBytesCoder.prototype.decode = function (reader) {
  26841. return reader.readBytes(reader.readValue().toNumber(), true);
  26842. };
  26843. return DynamicBytesCoder;
  26844. }(abstract_coder_1.Coder));
  26845. exports.DynamicBytesCoder = DynamicBytesCoder;
  26846. var BytesCoder = /** @class */ (function (_super) {
  26847. __extends(BytesCoder, _super);
  26848. function BytesCoder(localName) {
  26849. return _super.call(this, "bytes", localName) || this;
  26850. }
  26851. BytesCoder.prototype.decode = function (reader) {
  26852. return reader.coerce(this.name, (0, bytes_1.hexlify)(_super.prototype.decode.call(this, reader)));
  26853. };
  26854. return BytesCoder;
  26855. }(DynamicBytesCoder));
  26856. exports.BytesCoder = BytesCoder;
  26857. },{"./abstract-coder":170,"@ethersproject/bytes":199}],176:[function(_dereq_,module,exports){
  26858. "use strict";
  26859. var __extends = (this && this.__extends) || (function () {
  26860. var extendStatics = function (d, b) {
  26861. extendStatics = Object.setPrototypeOf ||
  26862. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  26863. function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
  26864. return extendStatics(d, b);
  26865. };
  26866. return function (d, b) {
  26867. if (typeof b !== "function" && b !== null)
  26868. throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
  26869. extendStatics(d, b);
  26870. function __() { this.constructor = d; }
  26871. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  26872. };
  26873. })();
  26874. Object.defineProperty(exports, "__esModule", { value: true });
  26875. exports.FixedBytesCoder = void 0;
  26876. var bytes_1 = _dereq_("@ethersproject/bytes");
  26877. var abstract_coder_1 = _dereq_("./abstract-coder");
  26878. // @TODO: Merge this with bytes
  26879. var FixedBytesCoder = /** @class */ (function (_super) {
  26880. __extends(FixedBytesCoder, _super);
  26881. function FixedBytesCoder(size, localName) {
  26882. var _this = this;
  26883. var name = "bytes" + String(size);
  26884. _this = _super.call(this, name, name, localName, false) || this;
  26885. _this.size = size;
  26886. return _this;
  26887. }
  26888. FixedBytesCoder.prototype.defaultValue = function () {
  26889. return ("0x0000000000000000000000000000000000000000000000000000000000000000").substring(0, 2 + this.size * 2);
  26890. };
  26891. FixedBytesCoder.prototype.encode = function (writer, value) {
  26892. var data = (0, bytes_1.arrayify)(value);
  26893. if (data.length !== this.size) {
  26894. this._throwError("incorrect data length", value);
  26895. }
  26896. return writer.writeBytes(data);
  26897. };
  26898. FixedBytesCoder.prototype.decode = function (reader) {
  26899. return reader.coerce(this.name, (0, bytes_1.hexlify)(reader.readBytes(this.size)));
  26900. };
  26901. return FixedBytesCoder;
  26902. }(abstract_coder_1.Coder));
  26903. exports.FixedBytesCoder = FixedBytesCoder;
  26904. },{"./abstract-coder":170,"@ethersproject/bytes":199}],177:[function(_dereq_,module,exports){
  26905. "use strict";
  26906. var __extends = (this && this.__extends) || (function () {
  26907. var extendStatics = function (d, b) {
  26908. extendStatics = Object.setPrototypeOf ||
  26909. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  26910. function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
  26911. return extendStatics(d, b);
  26912. };
  26913. return function (d, b) {
  26914. if (typeof b !== "function" && b !== null)
  26915. throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
  26916. extendStatics(d, b);
  26917. function __() { this.constructor = d; }
  26918. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  26919. };
  26920. })();
  26921. Object.defineProperty(exports, "__esModule", { value: true });
  26922. exports.NullCoder = void 0;
  26923. var abstract_coder_1 = _dereq_("./abstract-coder");
  26924. var NullCoder = /** @class */ (function (_super) {
  26925. __extends(NullCoder, _super);
  26926. function NullCoder(localName) {
  26927. return _super.call(this, "null", "", localName, false) || this;
  26928. }
  26929. NullCoder.prototype.defaultValue = function () {
  26930. return null;
  26931. };
  26932. NullCoder.prototype.encode = function (writer, value) {
  26933. if (value != null) {
  26934. this._throwError("not null", value);
  26935. }
  26936. return writer.writeBytes([]);
  26937. };
  26938. NullCoder.prototype.decode = function (reader) {
  26939. reader.readBytes(0);
  26940. return reader.coerce(this.name, null);
  26941. };
  26942. return NullCoder;
  26943. }(abstract_coder_1.Coder));
  26944. exports.NullCoder = NullCoder;
  26945. },{"./abstract-coder":170}],178:[function(_dereq_,module,exports){
  26946. "use strict";
  26947. var __extends = (this && this.__extends) || (function () {
  26948. var extendStatics = function (d, b) {
  26949. extendStatics = Object.setPrototypeOf ||
  26950. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  26951. function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
  26952. return extendStatics(d, b);
  26953. };
  26954. return function (d, b) {
  26955. if (typeof b !== "function" && b !== null)
  26956. throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
  26957. extendStatics(d, b);
  26958. function __() { this.constructor = d; }
  26959. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  26960. };
  26961. })();
  26962. Object.defineProperty(exports, "__esModule", { value: true });
  26963. exports.NumberCoder = void 0;
  26964. var bignumber_1 = _dereq_("@ethersproject/bignumber");
  26965. var constants_1 = _dereq_("@ethersproject/constants");
  26966. var abstract_coder_1 = _dereq_("./abstract-coder");
  26967. var NumberCoder = /** @class */ (function (_super) {
  26968. __extends(NumberCoder, _super);
  26969. function NumberCoder(size, signed, localName) {
  26970. var _this = this;
  26971. var name = ((signed ? "int" : "uint") + (size * 8));
  26972. _this = _super.call(this, name, name, localName, false) || this;
  26973. _this.size = size;
  26974. _this.signed = signed;
  26975. return _this;
  26976. }
  26977. NumberCoder.prototype.defaultValue = function () {
  26978. return 0;
  26979. };
  26980. NumberCoder.prototype.encode = function (writer, value) {
  26981. var v = bignumber_1.BigNumber.from(value);
  26982. // Check bounds are safe for encoding
  26983. var maxUintValue = constants_1.MaxUint256.mask(writer.wordSize * 8);
  26984. if (this.signed) {
  26985. var bounds = maxUintValue.mask(this.size * 8 - 1);
  26986. if (v.gt(bounds) || v.lt(bounds.add(constants_1.One).mul(constants_1.NegativeOne))) {
  26987. this._throwError("value out-of-bounds", value);
  26988. }
  26989. }
  26990. else if (v.lt(constants_1.Zero) || v.gt(maxUintValue.mask(this.size * 8))) {
  26991. this._throwError("value out-of-bounds", value);
  26992. }
  26993. v = v.toTwos(this.size * 8).mask(this.size * 8);
  26994. if (this.signed) {
  26995. v = v.fromTwos(this.size * 8).toTwos(8 * writer.wordSize);
  26996. }
  26997. return writer.writeValue(v);
  26998. };
  26999. NumberCoder.prototype.decode = function (reader) {
  27000. var value = reader.readValue().mask(this.size * 8);
  27001. if (this.signed) {
  27002. value = value.fromTwos(this.size * 8);
  27003. }
  27004. return reader.coerce(this.name, value);
  27005. };
  27006. return NumberCoder;
  27007. }(abstract_coder_1.Coder));
  27008. exports.NumberCoder = NumberCoder;
  27009. },{"./abstract-coder":170,"@ethersproject/bignumber":196,"@ethersproject/constants":203}],179:[function(_dereq_,module,exports){
  27010. "use strict";
  27011. var __extends = (this && this.__extends) || (function () {
  27012. var extendStatics = function (d, b) {
  27013. extendStatics = Object.setPrototypeOf ||
  27014. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  27015. function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
  27016. return extendStatics(d, b);
  27017. };
  27018. return function (d, b) {
  27019. if (typeof b !== "function" && b !== null)
  27020. throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
  27021. extendStatics(d, b);
  27022. function __() { this.constructor = d; }
  27023. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  27024. };
  27025. })();
  27026. Object.defineProperty(exports, "__esModule", { value: true });
  27027. exports.StringCoder = void 0;
  27028. var strings_1 = _dereq_("@ethersproject/strings");
  27029. var bytes_1 = _dereq_("./bytes");
  27030. var StringCoder = /** @class */ (function (_super) {
  27031. __extends(StringCoder, _super);
  27032. function StringCoder(localName) {
  27033. return _super.call(this, "string", localName) || this;
  27034. }
  27035. StringCoder.prototype.defaultValue = function () {
  27036. return "";
  27037. };
  27038. StringCoder.prototype.encode = function (writer, value) {
  27039. return _super.prototype.encode.call(this, writer, (0, strings_1.toUtf8Bytes)(value));
  27040. };
  27041. StringCoder.prototype.decode = function (reader) {
  27042. return (0, strings_1.toUtf8String)(_super.prototype.decode.call(this, reader));
  27043. };
  27044. return StringCoder;
  27045. }(bytes_1.DynamicBytesCoder));
  27046. exports.StringCoder = StringCoder;
  27047. },{"./bytes":175,"@ethersproject/strings":266}],180:[function(_dereq_,module,exports){
  27048. "use strict";
  27049. var __extends = (this && this.__extends) || (function () {
  27050. var extendStatics = function (d, b) {
  27051. extendStatics = Object.setPrototypeOf ||
  27052. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  27053. function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
  27054. return extendStatics(d, b);
  27055. };
  27056. return function (d, b) {
  27057. if (typeof b !== "function" && b !== null)
  27058. throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
  27059. extendStatics(d, b);
  27060. function __() { this.constructor = d; }
  27061. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  27062. };
  27063. })();
  27064. Object.defineProperty(exports, "__esModule", { value: true });
  27065. exports.TupleCoder = void 0;
  27066. var abstract_coder_1 = _dereq_("./abstract-coder");
  27067. var array_1 = _dereq_("./array");
  27068. var TupleCoder = /** @class */ (function (_super) {
  27069. __extends(TupleCoder, _super);
  27070. function TupleCoder(coders, localName) {
  27071. var _this = this;
  27072. var dynamic = false;
  27073. var types = [];
  27074. coders.forEach(function (coder) {
  27075. if (coder.dynamic) {
  27076. dynamic = true;
  27077. }
  27078. types.push(coder.type);
  27079. });
  27080. var type = ("tuple(" + types.join(",") + ")");
  27081. _this = _super.call(this, "tuple", type, localName, dynamic) || this;
  27082. _this.coders = coders;
  27083. return _this;
  27084. }
  27085. TupleCoder.prototype.defaultValue = function () {
  27086. var values = [];
  27087. this.coders.forEach(function (coder) {
  27088. values.push(coder.defaultValue());
  27089. });
  27090. // We only output named properties for uniquely named coders
  27091. var uniqueNames = this.coders.reduce(function (accum, coder) {
  27092. var name = coder.localName;
  27093. if (name) {
  27094. if (!accum[name]) {
  27095. accum[name] = 0;
  27096. }
  27097. accum[name]++;
  27098. }
  27099. return accum;
  27100. }, {});
  27101. // Add named values
  27102. this.coders.forEach(function (coder, index) {
  27103. var name = coder.localName;
  27104. if (!name || uniqueNames[name] !== 1) {
  27105. return;
  27106. }
  27107. if (name === "length") {
  27108. name = "_length";
  27109. }
  27110. if (values[name] != null) {
  27111. return;
  27112. }
  27113. values[name] = values[index];
  27114. });
  27115. return Object.freeze(values);
  27116. };
  27117. TupleCoder.prototype.encode = function (writer, value) {
  27118. return (0, array_1.pack)(writer, this.coders, value);
  27119. };
  27120. TupleCoder.prototype.decode = function (reader) {
  27121. return reader.coerce(this.name, (0, array_1.unpack)(reader, this.coders));
  27122. };
  27123. return TupleCoder;
  27124. }(abstract_coder_1.Coder));
  27125. exports.TupleCoder = TupleCoder;
  27126. },{"./abstract-coder":170,"./array":173}],181:[function(_dereq_,module,exports){
  27127. "use strict";
  27128. var __extends = (this && this.__extends) || (function () {
  27129. var extendStatics = function (d, b) {
  27130. extendStatics = Object.setPrototypeOf ||
  27131. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  27132. function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
  27133. return extendStatics(d, b);
  27134. };
  27135. return function (d, b) {
  27136. if (typeof b !== "function" && b !== null)
  27137. throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
  27138. extendStatics(d, b);
  27139. function __() { this.constructor = d; }
  27140. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  27141. };
  27142. })();
  27143. Object.defineProperty(exports, "__esModule", { value: true });
  27144. exports.ErrorFragment = exports.FunctionFragment = exports.ConstructorFragment = exports.EventFragment = exports.Fragment = exports.ParamType = exports.FormatTypes = void 0;
  27145. var bignumber_1 = _dereq_("@ethersproject/bignumber");
  27146. var properties_1 = _dereq_("@ethersproject/properties");
  27147. var logger_1 = _dereq_("@ethersproject/logger");
  27148. var _version_1 = _dereq_("./_version");
  27149. var logger = new logger_1.Logger(_version_1.version);
  27150. ;
  27151. var _constructorGuard = {};
  27152. var ModifiersBytes = { calldata: true, memory: true, storage: true };
  27153. var ModifiersNest = { calldata: true, memory: true };
  27154. function checkModifier(type, name) {
  27155. if (type === "bytes" || type === "string") {
  27156. if (ModifiersBytes[name]) {
  27157. return true;
  27158. }
  27159. }
  27160. else if (type === "address") {
  27161. if (name === "payable") {
  27162. return true;
  27163. }
  27164. }
  27165. else if (type.indexOf("[") >= 0 || type === "tuple") {
  27166. if (ModifiersNest[name]) {
  27167. return true;
  27168. }
  27169. }
  27170. if (ModifiersBytes[name] || name === "payable") {
  27171. logger.throwArgumentError("invalid modifier", "name", name);
  27172. }
  27173. return false;
  27174. }
  27175. // @TODO: Make sure that children of an indexed tuple are marked with a null indexed
  27176. function parseParamType(param, allowIndexed) {
  27177. var originalParam = param;
  27178. function throwError(i) {
  27179. logger.throwArgumentError("unexpected character at position " + i, "param", param);
  27180. }
  27181. param = param.replace(/\s/g, " ");
  27182. function newNode(parent) {
  27183. var node = { type: "", name: "", parent: parent, state: { allowType: true } };
  27184. if (allowIndexed) {
  27185. node.indexed = false;
  27186. }
  27187. return node;
  27188. }
  27189. var parent = { type: "", name: "", state: { allowType: true } };
  27190. var node = parent;
  27191. for (var i = 0; i < param.length; i++) {
  27192. var c = param[i];
  27193. switch (c) {
  27194. case "(":
  27195. if (node.state.allowType && node.type === "") {
  27196. node.type = "tuple";
  27197. }
  27198. else if (!node.state.allowParams) {
  27199. throwError(i);
  27200. }
  27201. node.state.allowType = false;
  27202. node.type = verifyType(node.type);
  27203. node.components = [newNode(node)];
  27204. node = node.components[0];
  27205. break;
  27206. case ")":
  27207. delete node.state;
  27208. if (node.name === "indexed") {
  27209. if (!allowIndexed) {
  27210. throwError(i);
  27211. }
  27212. node.indexed = true;
  27213. node.name = "";
  27214. }
  27215. if (checkModifier(node.type, node.name)) {
  27216. node.name = "";
  27217. }
  27218. node.type = verifyType(node.type);
  27219. var child = node;
  27220. node = node.parent;
  27221. if (!node) {
  27222. throwError(i);
  27223. }
  27224. delete child.parent;
  27225. node.state.allowParams = false;
  27226. node.state.allowName = true;
  27227. node.state.allowArray = true;
  27228. break;
  27229. case ",":
  27230. delete node.state;
  27231. if (node.name === "indexed") {
  27232. if (!allowIndexed) {
  27233. throwError(i);
  27234. }
  27235. node.indexed = true;
  27236. node.name = "";
  27237. }
  27238. if (checkModifier(node.type, node.name)) {
  27239. node.name = "";
  27240. }
  27241. node.type = verifyType(node.type);
  27242. var sibling = newNode(node.parent);
  27243. //{ type: "", name: "", parent: node.parent, state: { allowType: true } };
  27244. node.parent.components.push(sibling);
  27245. delete node.parent;
  27246. node = sibling;
  27247. break;
  27248. // Hit a space...
  27249. case " ":
  27250. // If reading type, the type is done and may read a param or name
  27251. if (node.state.allowType) {
  27252. if (node.type !== "") {
  27253. node.type = verifyType(node.type);
  27254. delete node.state.allowType;
  27255. node.state.allowName = true;
  27256. node.state.allowParams = true;
  27257. }
  27258. }
  27259. // If reading name, the name is done
  27260. if (node.state.allowName) {
  27261. if (node.name !== "") {
  27262. if (node.name === "indexed") {
  27263. if (!allowIndexed) {
  27264. throwError(i);
  27265. }
  27266. if (node.indexed) {
  27267. throwError(i);
  27268. }
  27269. node.indexed = true;
  27270. node.name = "";
  27271. }
  27272. else if (checkModifier(node.type, node.name)) {
  27273. node.name = "";
  27274. }
  27275. else {
  27276. node.state.allowName = false;
  27277. }
  27278. }
  27279. }
  27280. break;
  27281. case "[":
  27282. if (!node.state.allowArray) {
  27283. throwError(i);
  27284. }
  27285. node.type += c;
  27286. node.state.allowArray = false;
  27287. node.state.allowName = false;
  27288. node.state.readArray = true;
  27289. break;
  27290. case "]":
  27291. if (!node.state.readArray) {
  27292. throwError(i);
  27293. }
  27294. node.type += c;
  27295. node.state.readArray = false;
  27296. node.state.allowArray = true;
  27297. node.state.allowName = true;
  27298. break;
  27299. default:
  27300. if (node.state.allowType) {
  27301. node.type += c;
  27302. node.state.allowParams = true;
  27303. node.state.allowArray = true;
  27304. }
  27305. else if (node.state.allowName) {
  27306. node.name += c;
  27307. delete node.state.allowArray;
  27308. }
  27309. else if (node.state.readArray) {
  27310. node.type += c;
  27311. }
  27312. else {
  27313. throwError(i);
  27314. }
  27315. }
  27316. }
  27317. if (node.parent) {
  27318. logger.throwArgumentError("unexpected eof", "param", param);
  27319. }
  27320. delete parent.state;
  27321. if (node.name === "indexed") {
  27322. if (!allowIndexed) {
  27323. throwError(originalParam.length - 7);
  27324. }
  27325. if (node.indexed) {
  27326. throwError(originalParam.length - 7);
  27327. }
  27328. node.indexed = true;
  27329. node.name = "";
  27330. }
  27331. else if (checkModifier(node.type, node.name)) {
  27332. node.name = "";
  27333. }
  27334. parent.type = verifyType(parent.type);
  27335. return parent;
  27336. }
  27337. function populate(object, params) {
  27338. for (var key in params) {
  27339. (0, properties_1.defineReadOnly)(object, key, params[key]);
  27340. }
  27341. }
  27342. exports.FormatTypes = Object.freeze({
  27343. // Bare formatting, as is needed for computing a sighash of an event or function
  27344. sighash: "sighash",
  27345. // Human-Readable with Minimal spacing and without names (compact human-readable)
  27346. minimal: "minimal",
  27347. // Human-Readable with nice spacing, including all names
  27348. full: "full",
  27349. // JSON-format a la Solidity
  27350. json: "json"
  27351. });
  27352. var paramTypeArray = new RegExp(/^(.*)\[([0-9]*)\]$/);
  27353. var ParamType = /** @class */ (function () {
  27354. function ParamType(constructorGuard, params) {
  27355. if (constructorGuard !== _constructorGuard) {
  27356. logger.throwError("use fromString", logger_1.Logger.errors.UNSUPPORTED_OPERATION, {
  27357. operation: "new ParamType()"
  27358. });
  27359. }
  27360. populate(this, params);
  27361. var match = this.type.match(paramTypeArray);
  27362. if (match) {
  27363. populate(this, {
  27364. arrayLength: parseInt(match[2] || "-1"),
  27365. arrayChildren: ParamType.fromObject({
  27366. type: match[1],
  27367. components: this.components
  27368. }),
  27369. baseType: "array"
  27370. });
  27371. }
  27372. else {
  27373. populate(this, {
  27374. arrayLength: null,
  27375. arrayChildren: null,
  27376. baseType: ((this.components != null) ? "tuple" : this.type)
  27377. });
  27378. }
  27379. this._isParamType = true;
  27380. Object.freeze(this);
  27381. }
  27382. // Format the parameter fragment
  27383. // - sighash: "(uint256,address)"
  27384. // - minimal: "tuple(uint256,address) indexed"
  27385. // - full: "tuple(uint256 foo, address bar) indexed baz"
  27386. ParamType.prototype.format = function (format) {
  27387. if (!format) {
  27388. format = exports.FormatTypes.sighash;
  27389. }
  27390. if (!exports.FormatTypes[format]) {
  27391. logger.throwArgumentError("invalid format type", "format", format);
  27392. }
  27393. if (format === exports.FormatTypes.json) {
  27394. var result_1 = {
  27395. type: ((this.baseType === "tuple") ? "tuple" : this.type),
  27396. name: (this.name || undefined)
  27397. };
  27398. if (typeof (this.indexed) === "boolean") {
  27399. result_1.indexed = this.indexed;
  27400. }
  27401. if (this.components) {
  27402. result_1.components = this.components.map(function (comp) { return JSON.parse(comp.format(format)); });
  27403. }
  27404. return JSON.stringify(result_1);
  27405. }
  27406. var result = "";
  27407. // Array
  27408. if (this.baseType === "array") {
  27409. result += this.arrayChildren.format(format);
  27410. result += "[" + (this.arrayLength < 0 ? "" : String(this.arrayLength)) + "]";
  27411. }
  27412. else {
  27413. if (this.baseType === "tuple") {
  27414. if (format !== exports.FormatTypes.sighash) {
  27415. result += this.type;
  27416. }
  27417. result += "(" + this.components.map(function (comp) { return comp.format(format); }).join((format === exports.FormatTypes.full) ? ", " : ",") + ")";
  27418. }
  27419. else {
  27420. result += this.type;
  27421. }
  27422. }
  27423. if (format !== exports.FormatTypes.sighash) {
  27424. if (this.indexed === true) {
  27425. result += " indexed";
  27426. }
  27427. if (format === exports.FormatTypes.full && this.name) {
  27428. result += " " + this.name;
  27429. }
  27430. }
  27431. return result;
  27432. };
  27433. ParamType.from = function (value, allowIndexed) {
  27434. if (typeof (value) === "string") {
  27435. return ParamType.fromString(value, allowIndexed);
  27436. }
  27437. return ParamType.fromObject(value);
  27438. };
  27439. ParamType.fromObject = function (value) {
  27440. if (ParamType.isParamType(value)) {
  27441. return value;
  27442. }
  27443. return new ParamType(_constructorGuard, {
  27444. name: (value.name || null),
  27445. type: verifyType(value.type),
  27446. indexed: ((value.indexed == null) ? null : !!value.indexed),
  27447. components: (value.components ? value.components.map(ParamType.fromObject) : null)
  27448. });
  27449. };
  27450. ParamType.fromString = function (value, allowIndexed) {
  27451. function ParamTypify(node) {
  27452. return ParamType.fromObject({
  27453. name: node.name,
  27454. type: node.type,
  27455. indexed: node.indexed,
  27456. components: node.components
  27457. });
  27458. }
  27459. return ParamTypify(parseParamType(value, !!allowIndexed));
  27460. };
  27461. ParamType.isParamType = function (value) {
  27462. return !!(value != null && value._isParamType);
  27463. };
  27464. return ParamType;
  27465. }());
  27466. exports.ParamType = ParamType;
  27467. ;
  27468. function parseParams(value, allowIndex) {
  27469. return splitNesting(value).map(function (param) { return ParamType.fromString(param, allowIndex); });
  27470. }
  27471. var Fragment = /** @class */ (function () {
  27472. function Fragment(constructorGuard, params) {
  27473. if (constructorGuard !== _constructorGuard) {
  27474. logger.throwError("use a static from method", logger_1.Logger.errors.UNSUPPORTED_OPERATION, {
  27475. operation: "new Fragment()"
  27476. });
  27477. }
  27478. populate(this, params);
  27479. this._isFragment = true;
  27480. Object.freeze(this);
  27481. }
  27482. Fragment.from = function (value) {
  27483. if (Fragment.isFragment(value)) {
  27484. return value;
  27485. }
  27486. if (typeof (value) === "string") {
  27487. return Fragment.fromString(value);
  27488. }
  27489. return Fragment.fromObject(value);
  27490. };
  27491. Fragment.fromObject = function (value) {
  27492. if (Fragment.isFragment(value)) {
  27493. return value;
  27494. }
  27495. switch (value.type) {
  27496. case "function":
  27497. return FunctionFragment.fromObject(value);
  27498. case "event":
  27499. return EventFragment.fromObject(value);
  27500. case "constructor":
  27501. return ConstructorFragment.fromObject(value);
  27502. case "error":
  27503. return ErrorFragment.fromObject(value);
  27504. case "fallback":
  27505. case "receive":
  27506. // @TODO: Something? Maybe return a FunctionFragment? A custom DefaultFunctionFragment?
  27507. return null;
  27508. }
  27509. return logger.throwArgumentError("invalid fragment object", "value", value);
  27510. };
  27511. Fragment.fromString = function (value) {
  27512. // Make sure the "returns" is surrounded by a space and all whitespace is exactly one space
  27513. value = value.replace(/\s/g, " ");
  27514. value = value.replace(/\(/g, " (").replace(/\)/g, ") ").replace(/\s+/g, " ");
  27515. value = value.trim();
  27516. if (value.split(" ")[0] === "event") {
  27517. return EventFragment.fromString(value.substring(5).trim());
  27518. }
  27519. else if (value.split(" ")[0] === "function") {
  27520. return FunctionFragment.fromString(value.substring(8).trim());
  27521. }
  27522. else if (value.split("(")[0].trim() === "constructor") {
  27523. return ConstructorFragment.fromString(value.trim());
  27524. }
  27525. else if (value.split(" ")[0] === "error") {
  27526. return ErrorFragment.fromString(value.substring(5).trim());
  27527. }
  27528. return logger.throwArgumentError("unsupported fragment", "value", value);
  27529. };
  27530. Fragment.isFragment = function (value) {
  27531. return !!(value && value._isFragment);
  27532. };
  27533. return Fragment;
  27534. }());
  27535. exports.Fragment = Fragment;
  27536. var EventFragment = /** @class */ (function (_super) {
  27537. __extends(EventFragment, _super);
  27538. function EventFragment() {
  27539. return _super !== null && _super.apply(this, arguments) || this;
  27540. }
  27541. EventFragment.prototype.format = function (format) {
  27542. if (!format) {
  27543. format = exports.FormatTypes.sighash;
  27544. }
  27545. if (!exports.FormatTypes[format]) {
  27546. logger.throwArgumentError("invalid format type", "format", format);
  27547. }
  27548. if (format === exports.FormatTypes.json) {
  27549. return JSON.stringify({
  27550. type: "event",
  27551. anonymous: this.anonymous,
  27552. name: this.name,
  27553. inputs: this.inputs.map(function (input) { return JSON.parse(input.format(format)); })
  27554. });
  27555. }
  27556. var result = "";
  27557. if (format !== exports.FormatTypes.sighash) {
  27558. result += "event ";
  27559. }
  27560. result += this.name + "(" + this.inputs.map(function (input) { return input.format(format); }).join((format === exports.FormatTypes.full) ? ", " : ",") + ") ";
  27561. if (format !== exports.FormatTypes.sighash) {
  27562. if (this.anonymous) {
  27563. result += "anonymous ";
  27564. }
  27565. }
  27566. return result.trim();
  27567. };
  27568. EventFragment.from = function (value) {
  27569. if (typeof (value) === "string") {
  27570. return EventFragment.fromString(value);
  27571. }
  27572. return EventFragment.fromObject(value);
  27573. };
  27574. EventFragment.fromObject = function (value) {
  27575. if (EventFragment.isEventFragment(value)) {
  27576. return value;
  27577. }
  27578. if (value.type !== "event") {
  27579. logger.throwArgumentError("invalid event object", "value", value);
  27580. }
  27581. var params = {
  27582. name: verifyIdentifier(value.name),
  27583. anonymous: value.anonymous,
  27584. inputs: (value.inputs ? value.inputs.map(ParamType.fromObject) : []),
  27585. type: "event"
  27586. };
  27587. return new EventFragment(_constructorGuard, params);
  27588. };
  27589. EventFragment.fromString = function (value) {
  27590. var match = value.match(regexParen);
  27591. if (!match) {
  27592. logger.throwArgumentError("invalid event string", "value", value);
  27593. }
  27594. var anonymous = false;
  27595. match[3].split(" ").forEach(function (modifier) {
  27596. switch (modifier.trim()) {
  27597. case "anonymous":
  27598. anonymous = true;
  27599. break;
  27600. case "":
  27601. break;
  27602. default:
  27603. logger.warn("unknown modifier: " + modifier);
  27604. }
  27605. });
  27606. return EventFragment.fromObject({
  27607. name: match[1].trim(),
  27608. anonymous: anonymous,
  27609. inputs: parseParams(match[2], true),
  27610. type: "event"
  27611. });
  27612. };
  27613. EventFragment.isEventFragment = function (value) {
  27614. return (value && value._isFragment && value.type === "event");
  27615. };
  27616. return EventFragment;
  27617. }(Fragment));
  27618. exports.EventFragment = EventFragment;
  27619. function parseGas(value, params) {
  27620. params.gas = null;
  27621. var comps = value.split("@");
  27622. if (comps.length !== 1) {
  27623. if (comps.length > 2) {
  27624. logger.throwArgumentError("invalid human-readable ABI signature", "value", value);
  27625. }
  27626. if (!comps[1].match(/^[0-9]+$/)) {
  27627. logger.throwArgumentError("invalid human-readable ABI signature gas", "value", value);
  27628. }
  27629. params.gas = bignumber_1.BigNumber.from(comps[1]);
  27630. return comps[0];
  27631. }
  27632. return value;
  27633. }
  27634. function parseModifiers(value, params) {
  27635. params.constant = false;
  27636. params.payable = false;
  27637. params.stateMutability = "nonpayable";
  27638. value.split(" ").forEach(function (modifier) {
  27639. switch (modifier.trim()) {
  27640. case "constant":
  27641. params.constant = true;
  27642. break;
  27643. case "payable":
  27644. params.payable = true;
  27645. params.stateMutability = "payable";
  27646. break;
  27647. case "nonpayable":
  27648. params.payable = false;
  27649. params.stateMutability = "nonpayable";
  27650. break;
  27651. case "pure":
  27652. params.constant = true;
  27653. params.stateMutability = "pure";
  27654. break;
  27655. case "view":
  27656. params.constant = true;
  27657. params.stateMutability = "view";
  27658. break;
  27659. case "external":
  27660. case "public":
  27661. case "":
  27662. break;
  27663. default:
  27664. console.log("unknown modifier: " + modifier);
  27665. }
  27666. });
  27667. }
  27668. function verifyState(value) {
  27669. var result = {
  27670. constant: false,
  27671. payable: true,
  27672. stateMutability: "payable"
  27673. };
  27674. if (value.stateMutability != null) {
  27675. result.stateMutability = value.stateMutability;
  27676. // Set (and check things are consistent) the constant property
  27677. result.constant = (result.stateMutability === "view" || result.stateMutability === "pure");
  27678. if (value.constant != null) {
  27679. if ((!!value.constant) !== result.constant) {
  27680. logger.throwArgumentError("cannot have constant function with mutability " + result.stateMutability, "value", value);
  27681. }
  27682. }
  27683. // Set (and check things are consistent) the payable property
  27684. result.payable = (result.stateMutability === "payable");
  27685. if (value.payable != null) {
  27686. if ((!!value.payable) !== result.payable) {
  27687. logger.throwArgumentError("cannot have payable function with mutability " + result.stateMutability, "value", value);
  27688. }
  27689. }
  27690. }
  27691. else if (value.payable != null) {
  27692. result.payable = !!value.payable;
  27693. // If payable we can assume non-constant; otherwise we can't assume
  27694. if (value.constant == null && !result.payable && value.type !== "constructor") {
  27695. logger.throwArgumentError("unable to determine stateMutability", "value", value);
  27696. }
  27697. result.constant = !!value.constant;
  27698. if (result.constant) {
  27699. result.stateMutability = "view";
  27700. }
  27701. else {
  27702. result.stateMutability = (result.payable ? "payable" : "nonpayable");
  27703. }
  27704. if (result.payable && result.constant) {
  27705. logger.throwArgumentError("cannot have constant payable function", "value", value);
  27706. }
  27707. }
  27708. else if (value.constant != null) {
  27709. result.constant = !!value.constant;
  27710. result.payable = !result.constant;
  27711. result.stateMutability = (result.constant ? "view" : "payable");
  27712. }
  27713. else if (value.type !== "constructor") {
  27714. logger.throwArgumentError("unable to determine stateMutability", "value", value);
  27715. }
  27716. return result;
  27717. }
  27718. var ConstructorFragment = /** @class */ (function (_super) {
  27719. __extends(ConstructorFragment, _super);
  27720. function ConstructorFragment() {
  27721. return _super !== null && _super.apply(this, arguments) || this;
  27722. }
  27723. ConstructorFragment.prototype.format = function (format) {
  27724. if (!format) {
  27725. format = exports.FormatTypes.sighash;
  27726. }
  27727. if (!exports.FormatTypes[format]) {
  27728. logger.throwArgumentError("invalid format type", "format", format);
  27729. }
  27730. if (format === exports.FormatTypes.json) {
  27731. return JSON.stringify({
  27732. type: "constructor",
  27733. stateMutability: ((this.stateMutability !== "nonpayable") ? this.stateMutability : undefined),
  27734. payable: this.payable,
  27735. gas: (this.gas ? this.gas.toNumber() : undefined),
  27736. inputs: this.inputs.map(function (input) { return JSON.parse(input.format(format)); })
  27737. });
  27738. }
  27739. if (format === exports.FormatTypes.sighash) {
  27740. logger.throwError("cannot format a constructor for sighash", logger_1.Logger.errors.UNSUPPORTED_OPERATION, {
  27741. operation: "format(sighash)"
  27742. });
  27743. }
  27744. var result = "constructor(" + this.inputs.map(function (input) { return input.format(format); }).join((format === exports.FormatTypes.full) ? ", " : ",") + ") ";
  27745. if (this.stateMutability && this.stateMutability !== "nonpayable") {
  27746. result += this.stateMutability + " ";
  27747. }
  27748. return result.trim();
  27749. };
  27750. ConstructorFragment.from = function (value) {
  27751. if (typeof (value) === "string") {
  27752. return ConstructorFragment.fromString(value);
  27753. }
  27754. return ConstructorFragment.fromObject(value);
  27755. };
  27756. ConstructorFragment.fromObject = function (value) {
  27757. if (ConstructorFragment.isConstructorFragment(value)) {
  27758. return value;
  27759. }
  27760. if (value.type !== "constructor") {
  27761. logger.throwArgumentError("invalid constructor object", "value", value);
  27762. }
  27763. var state = verifyState(value);
  27764. if (state.constant) {
  27765. logger.throwArgumentError("constructor cannot be constant", "value", value);
  27766. }
  27767. var params = {
  27768. name: null,
  27769. type: value.type,
  27770. inputs: (value.inputs ? value.inputs.map(ParamType.fromObject) : []),
  27771. payable: state.payable,
  27772. stateMutability: state.stateMutability,
  27773. gas: (value.gas ? bignumber_1.BigNumber.from(value.gas) : null)
  27774. };
  27775. return new ConstructorFragment(_constructorGuard, params);
  27776. };
  27777. ConstructorFragment.fromString = function (value) {
  27778. var params = { type: "constructor" };
  27779. value = parseGas(value, params);
  27780. var parens = value.match(regexParen);
  27781. if (!parens || parens[1].trim() !== "constructor") {
  27782. logger.throwArgumentError("invalid constructor string", "value", value);
  27783. }
  27784. params.inputs = parseParams(parens[2].trim(), false);
  27785. parseModifiers(parens[3].trim(), params);
  27786. return ConstructorFragment.fromObject(params);
  27787. };
  27788. ConstructorFragment.isConstructorFragment = function (value) {
  27789. return (value && value._isFragment && value.type === "constructor");
  27790. };
  27791. return ConstructorFragment;
  27792. }(Fragment));
  27793. exports.ConstructorFragment = ConstructorFragment;
  27794. var FunctionFragment = /** @class */ (function (_super) {
  27795. __extends(FunctionFragment, _super);
  27796. function FunctionFragment() {
  27797. return _super !== null && _super.apply(this, arguments) || this;
  27798. }
  27799. FunctionFragment.prototype.format = function (format) {
  27800. if (!format) {
  27801. format = exports.FormatTypes.sighash;
  27802. }
  27803. if (!exports.FormatTypes[format]) {
  27804. logger.throwArgumentError("invalid format type", "format", format);
  27805. }
  27806. if (format === exports.FormatTypes.json) {
  27807. return JSON.stringify({
  27808. type: "function",
  27809. name: this.name,
  27810. constant: this.constant,
  27811. stateMutability: ((this.stateMutability !== "nonpayable") ? this.stateMutability : undefined),
  27812. payable: this.payable,
  27813. gas: (this.gas ? this.gas.toNumber() : undefined),
  27814. inputs: this.inputs.map(function (input) { return JSON.parse(input.format(format)); }),
  27815. outputs: this.outputs.map(function (output) { return JSON.parse(output.format(format)); }),
  27816. });
  27817. }
  27818. var result = "";
  27819. if (format !== exports.FormatTypes.sighash) {
  27820. result += "function ";
  27821. }
  27822. result += this.name + "(" + this.inputs.map(function (input) { return input.format(format); }).join((format === exports.FormatTypes.full) ? ", " : ",") + ") ";
  27823. if (format !== exports.FormatTypes.sighash) {
  27824. if (this.stateMutability) {
  27825. if (this.stateMutability !== "nonpayable") {
  27826. result += (this.stateMutability + " ");
  27827. }
  27828. }
  27829. else if (this.constant) {
  27830. result += "view ";
  27831. }
  27832. if (this.outputs && this.outputs.length) {
  27833. result += "returns (" + this.outputs.map(function (output) { return output.format(format); }).join(", ") + ") ";
  27834. }
  27835. if (this.gas != null) {
  27836. result += "@" + this.gas.toString() + " ";
  27837. }
  27838. }
  27839. return result.trim();
  27840. };
  27841. FunctionFragment.from = function (value) {
  27842. if (typeof (value) === "string") {
  27843. return FunctionFragment.fromString(value);
  27844. }
  27845. return FunctionFragment.fromObject(value);
  27846. };
  27847. FunctionFragment.fromObject = function (value) {
  27848. if (FunctionFragment.isFunctionFragment(value)) {
  27849. return value;
  27850. }
  27851. if (value.type !== "function") {
  27852. logger.throwArgumentError("invalid function object", "value", value);
  27853. }
  27854. var state = verifyState(value);
  27855. var params = {
  27856. type: value.type,
  27857. name: verifyIdentifier(value.name),
  27858. constant: state.constant,
  27859. inputs: (value.inputs ? value.inputs.map(ParamType.fromObject) : []),
  27860. outputs: (value.outputs ? value.outputs.map(ParamType.fromObject) : []),
  27861. payable: state.payable,
  27862. stateMutability: state.stateMutability,
  27863. gas: (value.gas ? bignumber_1.BigNumber.from(value.gas) : null)
  27864. };
  27865. return new FunctionFragment(_constructorGuard, params);
  27866. };
  27867. FunctionFragment.fromString = function (value) {
  27868. var params = { type: "function" };
  27869. value = parseGas(value, params);
  27870. var comps = value.split(" returns ");
  27871. if (comps.length > 2) {
  27872. logger.throwArgumentError("invalid function string", "value", value);
  27873. }
  27874. var parens = comps[0].match(regexParen);
  27875. if (!parens) {
  27876. logger.throwArgumentError("invalid function signature", "value", value);
  27877. }
  27878. params.name = parens[1].trim();
  27879. if (params.name) {
  27880. verifyIdentifier(params.name);
  27881. }
  27882. params.inputs = parseParams(parens[2], false);
  27883. parseModifiers(parens[3].trim(), params);
  27884. // We have outputs
  27885. if (comps.length > 1) {
  27886. var returns = comps[1].match(regexParen);
  27887. if (returns[1].trim() != "" || returns[3].trim() != "") {
  27888. logger.throwArgumentError("unexpected tokens", "value", value);
  27889. }
  27890. params.outputs = parseParams(returns[2], false);
  27891. }
  27892. else {
  27893. params.outputs = [];
  27894. }
  27895. return FunctionFragment.fromObject(params);
  27896. };
  27897. FunctionFragment.isFunctionFragment = function (value) {
  27898. return (value && value._isFragment && value.type === "function");
  27899. };
  27900. return FunctionFragment;
  27901. }(ConstructorFragment));
  27902. exports.FunctionFragment = FunctionFragment;
  27903. //export class StructFragment extends Fragment {
  27904. //}
  27905. function checkForbidden(fragment) {
  27906. var sig = fragment.format();
  27907. if (sig === "Error(string)" || sig === "Panic(uint256)") {
  27908. logger.throwArgumentError("cannot specify user defined " + sig + " error", "fragment", fragment);
  27909. }
  27910. return fragment;
  27911. }
  27912. var ErrorFragment = /** @class */ (function (_super) {
  27913. __extends(ErrorFragment, _super);
  27914. function ErrorFragment() {
  27915. return _super !== null && _super.apply(this, arguments) || this;
  27916. }
  27917. ErrorFragment.prototype.format = function (format) {
  27918. if (!format) {
  27919. format = exports.FormatTypes.sighash;
  27920. }
  27921. if (!exports.FormatTypes[format]) {
  27922. logger.throwArgumentError("invalid format type", "format", format);
  27923. }
  27924. if (format === exports.FormatTypes.json) {
  27925. return JSON.stringify({
  27926. type: "error",
  27927. name: this.name,
  27928. inputs: this.inputs.map(function (input) { return JSON.parse(input.format(format)); }),
  27929. });
  27930. }
  27931. var result = "";
  27932. if (format !== exports.FormatTypes.sighash) {
  27933. result += "error ";
  27934. }
  27935. result += this.name + "(" + this.inputs.map(function (input) { return input.format(format); }).join((format === exports.FormatTypes.full) ? ", " : ",") + ") ";
  27936. return result.trim();
  27937. };
  27938. ErrorFragment.from = function (value) {
  27939. if (typeof (value) === "string") {
  27940. return ErrorFragment.fromString(value);
  27941. }
  27942. return ErrorFragment.fromObject(value);
  27943. };
  27944. ErrorFragment.fromObject = function (value) {
  27945. if (ErrorFragment.isErrorFragment(value)) {
  27946. return value;
  27947. }
  27948. if (value.type !== "error") {
  27949. logger.throwArgumentError("invalid error object", "value", value);
  27950. }
  27951. var params = {
  27952. type: value.type,
  27953. name: verifyIdentifier(value.name),
  27954. inputs: (value.inputs ? value.inputs.map(ParamType.fromObject) : [])
  27955. };
  27956. return checkForbidden(new ErrorFragment(_constructorGuard, params));
  27957. };
  27958. ErrorFragment.fromString = function (value) {
  27959. var params = { type: "error" };
  27960. var parens = value.match(regexParen);
  27961. if (!parens) {
  27962. logger.throwArgumentError("invalid error signature", "value", value);
  27963. }
  27964. params.name = parens[1].trim();
  27965. if (params.name) {
  27966. verifyIdentifier(params.name);
  27967. }
  27968. params.inputs = parseParams(parens[2], false);
  27969. return checkForbidden(ErrorFragment.fromObject(params));
  27970. };
  27971. ErrorFragment.isErrorFragment = function (value) {
  27972. return (value && value._isFragment && value.type === "error");
  27973. };
  27974. return ErrorFragment;
  27975. }(Fragment));
  27976. exports.ErrorFragment = ErrorFragment;
  27977. function verifyType(type) {
  27978. // These need to be transformed to their full description
  27979. if (type.match(/^uint($|[^1-9])/)) {
  27980. type = "uint256" + type.substring(4);
  27981. }
  27982. else if (type.match(/^int($|[^1-9])/)) {
  27983. type = "int256" + type.substring(3);
  27984. }
  27985. // @TODO: more verification
  27986. return type;
  27987. }
  27988. // See: https://github.com/ethereum/solidity/blob/1f8f1a3db93a548d0555e3e14cfc55a10e25b60e/docs/grammar/SolidityLexer.g4#L234
  27989. var regexIdentifier = new RegExp("^[a-zA-Z$_][a-zA-Z0-9$_]*$");
  27990. function verifyIdentifier(value) {
  27991. if (!value || !value.match(regexIdentifier)) {
  27992. logger.throwArgumentError("invalid identifier \"" + value + "\"", "value", value);
  27993. }
  27994. return value;
  27995. }
  27996. var regexParen = new RegExp("^([^)(]*)\\((.*)\\)([^)(]*)$");
  27997. function splitNesting(value) {
  27998. value = value.trim();
  27999. var result = [];
  28000. var accum = "";
  28001. var depth = 0;
  28002. for (var offset = 0; offset < value.length; offset++) {
  28003. var c = value[offset];
  28004. if (c === "," && depth === 0) {
  28005. result.push(accum);
  28006. accum = "";
  28007. }
  28008. else {
  28009. accum += c;
  28010. if (c === "(") {
  28011. depth++;
  28012. }
  28013. else if (c === ")") {
  28014. depth--;
  28015. if (depth === -1) {
  28016. logger.throwArgumentError("unbalanced parenthesis", "value", value);
  28017. }
  28018. }
  28019. }
  28020. }
  28021. if (accum) {
  28022. result.push(accum);
  28023. }
  28024. return result;
  28025. }
  28026. },{"./_version":168,"@ethersproject/bignumber":196,"@ethersproject/logger":223,"@ethersproject/properties":229}],182:[function(_dereq_,module,exports){
  28027. "use strict";
  28028. Object.defineProperty(exports, "__esModule", { value: true });
  28029. exports.TransactionDescription = exports.LogDescription = exports.checkResultErrors = exports.Indexed = exports.Interface = exports.defaultAbiCoder = exports.AbiCoder = exports.FormatTypes = exports.ParamType = exports.FunctionFragment = exports.Fragment = exports.EventFragment = exports.ErrorFragment = exports.ConstructorFragment = void 0;
  28030. var fragments_1 = _dereq_("./fragments");
  28031. Object.defineProperty(exports, "ConstructorFragment", { enumerable: true, get: function () { return fragments_1.ConstructorFragment; } });
  28032. Object.defineProperty(exports, "ErrorFragment", { enumerable: true, get: function () { return fragments_1.ErrorFragment; } });
  28033. Object.defineProperty(exports, "EventFragment", { enumerable: true, get: function () { return fragments_1.EventFragment; } });
  28034. Object.defineProperty(exports, "FormatTypes", { enumerable: true, get: function () { return fragments_1.FormatTypes; } });
  28035. Object.defineProperty(exports, "Fragment", { enumerable: true, get: function () { return fragments_1.Fragment; } });
  28036. Object.defineProperty(exports, "FunctionFragment", { enumerable: true, get: function () { return fragments_1.FunctionFragment; } });
  28037. Object.defineProperty(exports, "ParamType", { enumerable: true, get: function () { return fragments_1.ParamType; } });
  28038. var abi_coder_1 = _dereq_("./abi-coder");
  28039. Object.defineProperty(exports, "AbiCoder", { enumerable: true, get: function () { return abi_coder_1.AbiCoder; } });
  28040. Object.defineProperty(exports, "defaultAbiCoder", { enumerable: true, get: function () { return abi_coder_1.defaultAbiCoder; } });
  28041. var interface_1 = _dereq_("./interface");
  28042. Object.defineProperty(exports, "checkResultErrors", { enumerable: true, get: function () { return interface_1.checkResultErrors; } });
  28043. Object.defineProperty(exports, "Indexed", { enumerable: true, get: function () { return interface_1.Indexed; } });
  28044. Object.defineProperty(exports, "Interface", { enumerable: true, get: function () { return interface_1.Interface; } });
  28045. Object.defineProperty(exports, "LogDescription", { enumerable: true, get: function () { return interface_1.LogDescription; } });
  28046. Object.defineProperty(exports, "TransactionDescription", { enumerable: true, get: function () { return interface_1.TransactionDescription; } });
  28047. },{"./abi-coder":169,"./fragments":181,"./interface":183}],183:[function(_dereq_,module,exports){
  28048. "use strict";
  28049. var __extends = (this && this.__extends) || (function () {
  28050. var extendStatics = function (d, b) {
  28051. extendStatics = Object.setPrototypeOf ||
  28052. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  28053. function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
  28054. return extendStatics(d, b);
  28055. };
  28056. return function (d, b) {
  28057. if (typeof b !== "function" && b !== null)
  28058. throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
  28059. extendStatics(d, b);
  28060. function __() { this.constructor = d; }
  28061. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  28062. };
  28063. })();
  28064. Object.defineProperty(exports, "__esModule", { value: true });
  28065. exports.Interface = exports.Indexed = exports.ErrorDescription = exports.TransactionDescription = exports.LogDescription = exports.checkResultErrors = void 0;
  28066. var address_1 = _dereq_("@ethersproject/address");
  28067. var bignumber_1 = _dereq_("@ethersproject/bignumber");
  28068. var bytes_1 = _dereq_("@ethersproject/bytes");
  28069. var hash_1 = _dereq_("@ethersproject/hash");
  28070. var keccak256_1 = _dereq_("@ethersproject/keccak256");
  28071. var properties_1 = _dereq_("@ethersproject/properties");
  28072. var abi_coder_1 = _dereq_("./abi-coder");
  28073. var abstract_coder_1 = _dereq_("./coders/abstract-coder");
  28074. Object.defineProperty(exports, "checkResultErrors", { enumerable: true, get: function () { return abstract_coder_1.checkResultErrors; } });
  28075. var fragments_1 = _dereq_("./fragments");
  28076. var logger_1 = _dereq_("@ethersproject/logger");
  28077. var _version_1 = _dereq_("./_version");
  28078. var logger = new logger_1.Logger(_version_1.version);
  28079. var LogDescription = /** @class */ (function (_super) {
  28080. __extends(LogDescription, _super);
  28081. function LogDescription() {
  28082. return _super !== null && _super.apply(this, arguments) || this;
  28083. }
  28084. return LogDescription;
  28085. }(properties_1.Description));
  28086. exports.LogDescription = LogDescription;
  28087. var TransactionDescription = /** @class */ (function (_super) {
  28088. __extends(TransactionDescription, _super);
  28089. function TransactionDescription() {
  28090. return _super !== null && _super.apply(this, arguments) || this;
  28091. }
  28092. return TransactionDescription;
  28093. }(properties_1.Description));
  28094. exports.TransactionDescription = TransactionDescription;
  28095. var ErrorDescription = /** @class */ (function (_super) {
  28096. __extends(ErrorDescription, _super);
  28097. function ErrorDescription() {
  28098. return _super !== null && _super.apply(this, arguments) || this;
  28099. }
  28100. return ErrorDescription;
  28101. }(properties_1.Description));
  28102. exports.ErrorDescription = ErrorDescription;
  28103. var Indexed = /** @class */ (function (_super) {
  28104. __extends(Indexed, _super);
  28105. function Indexed() {
  28106. return _super !== null && _super.apply(this, arguments) || this;
  28107. }
  28108. Indexed.isIndexed = function (value) {
  28109. return !!(value && value._isIndexed);
  28110. };
  28111. return Indexed;
  28112. }(properties_1.Description));
  28113. exports.Indexed = Indexed;
  28114. var BuiltinErrors = {
  28115. "0x08c379a0": { signature: "Error(string)", name: "Error", inputs: ["string"], reason: true },
  28116. "0x4e487b71": { signature: "Panic(uint256)", name: "Panic", inputs: ["uint256"] }
  28117. };
  28118. function wrapAccessError(property, error) {
  28119. var wrap = new Error("deferred error during ABI decoding triggered accessing " + property);
  28120. wrap.error = error;
  28121. return wrap;
  28122. }
  28123. /*
  28124. function checkNames(fragment: Fragment, type: "input" | "output", params: Array<ParamType>): void {
  28125. params.reduce((accum, param) => {
  28126. if (param.name) {
  28127. if (accum[param.name]) {
  28128. logger.throwArgumentError(`duplicate ${ type } parameter ${ JSON.stringify(param.name) } in ${ fragment.format("full") }`, "fragment", fragment);
  28129. }
  28130. accum[param.name] = true;
  28131. }
  28132. return accum;
  28133. }, <{ [ name: string ]: boolean }>{ });
  28134. }
  28135. */
  28136. var Interface = /** @class */ (function () {
  28137. function Interface(fragments) {
  28138. var _newTarget = this.constructor;
  28139. var _this = this;
  28140. logger.checkNew(_newTarget, Interface);
  28141. var abi = [];
  28142. if (typeof (fragments) === "string") {
  28143. abi = JSON.parse(fragments);
  28144. }
  28145. else {
  28146. abi = fragments;
  28147. }
  28148. (0, properties_1.defineReadOnly)(this, "fragments", abi.map(function (fragment) {
  28149. return fragments_1.Fragment.from(fragment);
  28150. }).filter(function (fragment) { return (fragment != null); }));
  28151. (0, properties_1.defineReadOnly)(this, "_abiCoder", (0, properties_1.getStatic)(_newTarget, "getAbiCoder")());
  28152. (0, properties_1.defineReadOnly)(this, "functions", {});
  28153. (0, properties_1.defineReadOnly)(this, "errors", {});
  28154. (0, properties_1.defineReadOnly)(this, "events", {});
  28155. (0, properties_1.defineReadOnly)(this, "structs", {});
  28156. // Add all fragments by their signature
  28157. this.fragments.forEach(function (fragment) {
  28158. var bucket = null;
  28159. switch (fragment.type) {
  28160. case "constructor":
  28161. if (_this.deploy) {
  28162. logger.warn("duplicate definition - constructor");
  28163. return;
  28164. }
  28165. //checkNames(fragment, "input", fragment.inputs);
  28166. (0, properties_1.defineReadOnly)(_this, "deploy", fragment);
  28167. return;
  28168. case "function":
  28169. //checkNames(fragment, "input", fragment.inputs);
  28170. //checkNames(fragment, "output", (<FunctionFragment>fragment).outputs);
  28171. bucket = _this.functions;
  28172. break;
  28173. case "event":
  28174. //checkNames(fragment, "input", fragment.inputs);
  28175. bucket = _this.events;
  28176. break;
  28177. case "error":
  28178. bucket = _this.errors;
  28179. break;
  28180. default:
  28181. return;
  28182. }
  28183. var signature = fragment.format();
  28184. if (bucket[signature]) {
  28185. logger.warn("duplicate definition - " + signature);
  28186. return;
  28187. }
  28188. bucket[signature] = fragment;
  28189. });
  28190. // If we do not have a constructor add a default
  28191. if (!this.deploy) {
  28192. (0, properties_1.defineReadOnly)(this, "deploy", fragments_1.ConstructorFragment.from({
  28193. payable: false,
  28194. type: "constructor"
  28195. }));
  28196. }
  28197. (0, properties_1.defineReadOnly)(this, "_isInterface", true);
  28198. }
  28199. Interface.prototype.format = function (format) {
  28200. if (!format) {
  28201. format = fragments_1.FormatTypes.full;
  28202. }
  28203. if (format === fragments_1.FormatTypes.sighash) {
  28204. logger.throwArgumentError("interface does not support formatting sighash", "format", format);
  28205. }
  28206. var abi = this.fragments.map(function (fragment) { return fragment.format(format); });
  28207. // We need to re-bundle the JSON fragments a bit
  28208. if (format === fragments_1.FormatTypes.json) {
  28209. return JSON.stringify(abi.map(function (j) { return JSON.parse(j); }));
  28210. }
  28211. return abi;
  28212. };
  28213. // Sub-classes can override these to handle other blockchains
  28214. Interface.getAbiCoder = function () {
  28215. return abi_coder_1.defaultAbiCoder;
  28216. };
  28217. Interface.getAddress = function (address) {
  28218. return (0, address_1.getAddress)(address);
  28219. };
  28220. Interface.getSighash = function (fragment) {
  28221. return (0, bytes_1.hexDataSlice)((0, hash_1.id)(fragment.format()), 0, 4);
  28222. };
  28223. Interface.getEventTopic = function (eventFragment) {
  28224. return (0, hash_1.id)(eventFragment.format());
  28225. };
  28226. // Find a function definition by any means necessary (unless it is ambiguous)
  28227. Interface.prototype.getFunction = function (nameOrSignatureOrSighash) {
  28228. if ((0, bytes_1.isHexString)(nameOrSignatureOrSighash)) {
  28229. for (var name_1 in this.functions) {
  28230. if (nameOrSignatureOrSighash === this.getSighash(name_1)) {
  28231. return this.functions[name_1];
  28232. }
  28233. }
  28234. logger.throwArgumentError("no matching function", "sighash", nameOrSignatureOrSighash);
  28235. }
  28236. // It is a bare name, look up the function (will return null if ambiguous)
  28237. if (nameOrSignatureOrSighash.indexOf("(") === -1) {
  28238. var name_2 = nameOrSignatureOrSighash.trim();
  28239. var matching = Object.keys(this.functions).filter(function (f) { return (f.split("(" /* fix:) */)[0] === name_2); });
  28240. if (matching.length === 0) {
  28241. logger.throwArgumentError("no matching function", "name", name_2);
  28242. }
  28243. else if (matching.length > 1) {
  28244. logger.throwArgumentError("multiple matching functions", "name", name_2);
  28245. }
  28246. return this.functions[matching[0]];
  28247. }
  28248. // Normalize the signature and lookup the function
  28249. var result = this.functions[fragments_1.FunctionFragment.fromString(nameOrSignatureOrSighash).format()];
  28250. if (!result) {
  28251. logger.throwArgumentError("no matching function", "signature", nameOrSignatureOrSighash);
  28252. }
  28253. return result;
  28254. };
  28255. // Find an event definition by any means necessary (unless it is ambiguous)
  28256. Interface.prototype.getEvent = function (nameOrSignatureOrTopic) {
  28257. if ((0, bytes_1.isHexString)(nameOrSignatureOrTopic)) {
  28258. var topichash = nameOrSignatureOrTopic.toLowerCase();
  28259. for (var name_3 in this.events) {
  28260. if (topichash === this.getEventTopic(name_3)) {
  28261. return this.events[name_3];
  28262. }
  28263. }
  28264. logger.throwArgumentError("no matching event", "topichash", topichash);
  28265. }
  28266. // It is a bare name, look up the function (will return null if ambiguous)
  28267. if (nameOrSignatureOrTopic.indexOf("(") === -1) {
  28268. var name_4 = nameOrSignatureOrTopic.trim();
  28269. var matching = Object.keys(this.events).filter(function (f) { return (f.split("(" /* fix:) */)[0] === name_4); });
  28270. if (matching.length === 0) {
  28271. logger.throwArgumentError("no matching event", "name", name_4);
  28272. }
  28273. else if (matching.length > 1) {
  28274. logger.throwArgumentError("multiple matching events", "name", name_4);
  28275. }
  28276. return this.events[matching[0]];
  28277. }
  28278. // Normalize the signature and lookup the function
  28279. var result = this.events[fragments_1.EventFragment.fromString(nameOrSignatureOrTopic).format()];
  28280. if (!result) {
  28281. logger.throwArgumentError("no matching event", "signature", nameOrSignatureOrTopic);
  28282. }
  28283. return result;
  28284. };
  28285. // Find a function definition by any means necessary (unless it is ambiguous)
  28286. Interface.prototype.getError = function (nameOrSignatureOrSighash) {
  28287. if ((0, bytes_1.isHexString)(nameOrSignatureOrSighash)) {
  28288. var getSighash = (0, properties_1.getStatic)(this.constructor, "getSighash");
  28289. for (var name_5 in this.errors) {
  28290. var error = this.errors[name_5];
  28291. if (nameOrSignatureOrSighash === getSighash(error)) {
  28292. return this.errors[name_5];
  28293. }
  28294. }
  28295. logger.throwArgumentError("no matching error", "sighash", nameOrSignatureOrSighash);
  28296. }
  28297. // It is a bare name, look up the function (will return null if ambiguous)
  28298. if (nameOrSignatureOrSighash.indexOf("(") === -1) {
  28299. var name_6 = nameOrSignatureOrSighash.trim();
  28300. var matching = Object.keys(this.errors).filter(function (f) { return (f.split("(" /* fix:) */)[0] === name_6); });
  28301. if (matching.length === 0) {
  28302. logger.throwArgumentError("no matching error", "name", name_6);
  28303. }
  28304. else if (matching.length > 1) {
  28305. logger.throwArgumentError("multiple matching errors", "name", name_6);
  28306. }
  28307. return this.errors[matching[0]];
  28308. }
  28309. // Normalize the signature and lookup the function
  28310. var result = this.errors[fragments_1.FunctionFragment.fromString(nameOrSignatureOrSighash).format()];
  28311. if (!result) {
  28312. logger.throwArgumentError("no matching error", "signature", nameOrSignatureOrSighash);
  28313. }
  28314. return result;
  28315. };
  28316. // Get the sighash (the bytes4 selector) used by Solidity to identify a function
  28317. Interface.prototype.getSighash = function (fragment) {
  28318. if (typeof (fragment) === "string") {
  28319. try {
  28320. fragment = this.getFunction(fragment);
  28321. }
  28322. catch (error) {
  28323. try {
  28324. fragment = this.getError(fragment);
  28325. }
  28326. catch (_) {
  28327. throw error;
  28328. }
  28329. }
  28330. }
  28331. return (0, properties_1.getStatic)(this.constructor, "getSighash")(fragment);
  28332. };
  28333. // Get the topic (the bytes32 hash) used by Solidity to identify an event
  28334. Interface.prototype.getEventTopic = function (eventFragment) {
  28335. if (typeof (eventFragment) === "string") {
  28336. eventFragment = this.getEvent(eventFragment);
  28337. }
  28338. return (0, properties_1.getStatic)(this.constructor, "getEventTopic")(eventFragment);
  28339. };
  28340. Interface.prototype._decodeParams = function (params, data) {
  28341. return this._abiCoder.decode(params, data);
  28342. };
  28343. Interface.prototype._encodeParams = function (params, values) {
  28344. return this._abiCoder.encode(params, values);
  28345. };
  28346. Interface.prototype.encodeDeploy = function (values) {
  28347. return this._encodeParams(this.deploy.inputs, values || []);
  28348. };
  28349. Interface.prototype.decodeErrorResult = function (fragment, data) {
  28350. if (typeof (fragment) === "string") {
  28351. fragment = this.getError(fragment);
  28352. }
  28353. var bytes = (0, bytes_1.arrayify)(data);
  28354. if ((0, bytes_1.hexlify)(bytes.slice(0, 4)) !== this.getSighash(fragment)) {
  28355. logger.throwArgumentError("data signature does not match error " + fragment.name + ".", "data", (0, bytes_1.hexlify)(bytes));
  28356. }
  28357. return this._decodeParams(fragment.inputs, bytes.slice(4));
  28358. };
  28359. Interface.prototype.encodeErrorResult = function (fragment, values) {
  28360. if (typeof (fragment) === "string") {
  28361. fragment = this.getError(fragment);
  28362. }
  28363. return (0, bytes_1.hexlify)((0, bytes_1.concat)([
  28364. this.getSighash(fragment),
  28365. this._encodeParams(fragment.inputs, values || [])
  28366. ]));
  28367. };
  28368. // Decode the data for a function call (e.g. tx.data)
  28369. Interface.prototype.decodeFunctionData = function (functionFragment, data) {
  28370. if (typeof (functionFragment) === "string") {
  28371. functionFragment = this.getFunction(functionFragment);
  28372. }
  28373. var bytes = (0, bytes_1.arrayify)(data);
  28374. if ((0, bytes_1.hexlify)(bytes.slice(0, 4)) !== this.getSighash(functionFragment)) {
  28375. logger.throwArgumentError("data signature does not match function " + functionFragment.name + ".", "data", (0, bytes_1.hexlify)(bytes));
  28376. }
  28377. return this._decodeParams(functionFragment.inputs, bytes.slice(4));
  28378. };
  28379. // Encode the data for a function call (e.g. tx.data)
  28380. Interface.prototype.encodeFunctionData = function (functionFragment, values) {
  28381. if (typeof (functionFragment) === "string") {
  28382. functionFragment = this.getFunction(functionFragment);
  28383. }
  28384. return (0, bytes_1.hexlify)((0, bytes_1.concat)([
  28385. this.getSighash(functionFragment),
  28386. this._encodeParams(functionFragment.inputs, values || [])
  28387. ]));
  28388. };
  28389. // Decode the result from a function call (e.g. from eth_call)
  28390. Interface.prototype.decodeFunctionResult = function (functionFragment, data) {
  28391. if (typeof (functionFragment) === "string") {
  28392. functionFragment = this.getFunction(functionFragment);
  28393. }
  28394. var bytes = (0, bytes_1.arrayify)(data);
  28395. var reason = null;
  28396. var errorArgs = null;
  28397. var errorName = null;
  28398. var errorSignature = null;
  28399. switch (bytes.length % this._abiCoder._getWordSize()) {
  28400. case 0:
  28401. try {
  28402. return this._abiCoder.decode(functionFragment.outputs, bytes);
  28403. }
  28404. catch (error) { }
  28405. break;
  28406. case 4: {
  28407. var selector = (0, bytes_1.hexlify)(bytes.slice(0, 4));
  28408. var builtin = BuiltinErrors[selector];
  28409. if (builtin) {
  28410. errorArgs = this._abiCoder.decode(builtin.inputs, bytes.slice(4));
  28411. errorName = builtin.name;
  28412. errorSignature = builtin.signature;
  28413. if (builtin.reason) {
  28414. reason = errorArgs[0];
  28415. }
  28416. }
  28417. else {
  28418. try {
  28419. var error = this.getError(selector);
  28420. errorArgs = this._abiCoder.decode(error.inputs, bytes.slice(4));
  28421. errorName = error.name;
  28422. errorSignature = error.format();
  28423. }
  28424. catch (error) { }
  28425. }
  28426. break;
  28427. }
  28428. }
  28429. return logger.throwError("call revert exception", logger_1.Logger.errors.CALL_EXCEPTION, {
  28430. method: functionFragment.format(),
  28431. errorArgs: errorArgs,
  28432. errorName: errorName,
  28433. errorSignature: errorSignature,
  28434. reason: reason
  28435. });
  28436. };
  28437. // Encode the result for a function call (e.g. for eth_call)
  28438. Interface.prototype.encodeFunctionResult = function (functionFragment, values) {
  28439. if (typeof (functionFragment) === "string") {
  28440. functionFragment = this.getFunction(functionFragment);
  28441. }
  28442. return (0, bytes_1.hexlify)(this._abiCoder.encode(functionFragment.outputs, values || []));
  28443. };
  28444. // Create the filter for the event with search criteria (e.g. for eth_filterLog)
  28445. Interface.prototype.encodeFilterTopics = function (eventFragment, values) {
  28446. var _this = this;
  28447. if (typeof (eventFragment) === "string") {
  28448. eventFragment = this.getEvent(eventFragment);
  28449. }
  28450. if (values.length > eventFragment.inputs.length) {
  28451. logger.throwError("too many arguments for " + eventFragment.format(), logger_1.Logger.errors.UNEXPECTED_ARGUMENT, {
  28452. argument: "values",
  28453. value: values
  28454. });
  28455. }
  28456. var topics = [];
  28457. if (!eventFragment.anonymous) {
  28458. topics.push(this.getEventTopic(eventFragment));
  28459. }
  28460. var encodeTopic = function (param, value) {
  28461. if (param.type === "string") {
  28462. return (0, hash_1.id)(value);
  28463. }
  28464. else if (param.type === "bytes") {
  28465. return (0, keccak256_1.keccak256)((0, bytes_1.hexlify)(value));
  28466. }
  28467. // Check addresses are valid
  28468. if (param.type === "address") {
  28469. _this._abiCoder.encode(["address"], [value]);
  28470. }
  28471. return (0, bytes_1.hexZeroPad)((0, bytes_1.hexlify)(value), 32);
  28472. };
  28473. values.forEach(function (value, index) {
  28474. var param = eventFragment.inputs[index];
  28475. if (!param.indexed) {
  28476. if (value != null) {
  28477. logger.throwArgumentError("cannot filter non-indexed parameters; must be null", ("contract." + param.name), value);
  28478. }
  28479. return;
  28480. }
  28481. if (value == null) {
  28482. topics.push(null);
  28483. }
  28484. else if (param.baseType === "array" || param.baseType === "tuple") {
  28485. logger.throwArgumentError("filtering with tuples or arrays not supported", ("contract." + param.name), value);
  28486. }
  28487. else if (Array.isArray(value)) {
  28488. topics.push(value.map(function (value) { return encodeTopic(param, value); }));
  28489. }
  28490. else {
  28491. topics.push(encodeTopic(param, value));
  28492. }
  28493. });
  28494. // Trim off trailing nulls
  28495. while (topics.length && topics[topics.length - 1] === null) {
  28496. topics.pop();
  28497. }
  28498. return topics;
  28499. };
  28500. Interface.prototype.encodeEventLog = function (eventFragment, values) {
  28501. var _this = this;
  28502. if (typeof (eventFragment) === "string") {
  28503. eventFragment = this.getEvent(eventFragment);
  28504. }
  28505. var topics = [];
  28506. var dataTypes = [];
  28507. var dataValues = [];
  28508. if (!eventFragment.anonymous) {
  28509. topics.push(this.getEventTopic(eventFragment));
  28510. }
  28511. if (values.length !== eventFragment.inputs.length) {
  28512. logger.throwArgumentError("event arguments/values mismatch", "values", values);
  28513. }
  28514. eventFragment.inputs.forEach(function (param, index) {
  28515. var value = values[index];
  28516. if (param.indexed) {
  28517. if (param.type === "string") {
  28518. topics.push((0, hash_1.id)(value));
  28519. }
  28520. else if (param.type === "bytes") {
  28521. topics.push((0, keccak256_1.keccak256)(value));
  28522. }
  28523. else if (param.baseType === "tuple" || param.baseType === "array") {
  28524. // @TODO
  28525. throw new Error("not implemented");
  28526. }
  28527. else {
  28528. topics.push(_this._abiCoder.encode([param.type], [value]));
  28529. }
  28530. }
  28531. else {
  28532. dataTypes.push(param);
  28533. dataValues.push(value);
  28534. }
  28535. });
  28536. return {
  28537. data: this._abiCoder.encode(dataTypes, dataValues),
  28538. topics: topics
  28539. };
  28540. };
  28541. // Decode a filter for the event and the search criteria
  28542. Interface.prototype.decodeEventLog = function (eventFragment, data, topics) {
  28543. if (typeof (eventFragment) === "string") {
  28544. eventFragment = this.getEvent(eventFragment);
  28545. }
  28546. if (topics != null && !eventFragment.anonymous) {
  28547. var topicHash = this.getEventTopic(eventFragment);
  28548. if (!(0, bytes_1.isHexString)(topics[0], 32) || topics[0].toLowerCase() !== topicHash) {
  28549. logger.throwError("fragment/topic mismatch", logger_1.Logger.errors.INVALID_ARGUMENT, { argument: "topics[0]", expected: topicHash, value: topics[0] });
  28550. }
  28551. topics = topics.slice(1);
  28552. }
  28553. var indexed = [];
  28554. var nonIndexed = [];
  28555. var dynamic = [];
  28556. eventFragment.inputs.forEach(function (param, index) {
  28557. if (param.indexed) {
  28558. if (param.type === "string" || param.type === "bytes" || param.baseType === "tuple" || param.baseType === "array") {
  28559. indexed.push(fragments_1.ParamType.fromObject({ type: "bytes32", name: param.name }));
  28560. dynamic.push(true);
  28561. }
  28562. else {
  28563. indexed.push(param);
  28564. dynamic.push(false);
  28565. }
  28566. }
  28567. else {
  28568. nonIndexed.push(param);
  28569. dynamic.push(false);
  28570. }
  28571. });
  28572. var resultIndexed = (topics != null) ? this._abiCoder.decode(indexed, (0, bytes_1.concat)(topics)) : null;
  28573. var resultNonIndexed = this._abiCoder.decode(nonIndexed, data, true);
  28574. var result = [];
  28575. var nonIndexedIndex = 0, indexedIndex = 0;
  28576. eventFragment.inputs.forEach(function (param, index) {
  28577. if (param.indexed) {
  28578. if (resultIndexed == null) {
  28579. result[index] = new Indexed({ _isIndexed: true, hash: null });
  28580. }
  28581. else if (dynamic[index]) {
  28582. result[index] = new Indexed({ _isIndexed: true, hash: resultIndexed[indexedIndex++] });
  28583. }
  28584. else {
  28585. try {
  28586. result[index] = resultIndexed[indexedIndex++];
  28587. }
  28588. catch (error) {
  28589. result[index] = error;
  28590. }
  28591. }
  28592. }
  28593. else {
  28594. try {
  28595. result[index] = resultNonIndexed[nonIndexedIndex++];
  28596. }
  28597. catch (error) {
  28598. result[index] = error;
  28599. }
  28600. }
  28601. // Add the keyword argument if named and safe
  28602. if (param.name && result[param.name] == null) {
  28603. var value_1 = result[index];
  28604. // Make error named values throw on access
  28605. if (value_1 instanceof Error) {
  28606. Object.defineProperty(result, param.name, {
  28607. enumerable: true,
  28608. get: function () { throw wrapAccessError("property " + JSON.stringify(param.name), value_1); }
  28609. });
  28610. }
  28611. else {
  28612. result[param.name] = value_1;
  28613. }
  28614. }
  28615. });
  28616. var _loop_1 = function (i) {
  28617. var value = result[i];
  28618. if (value instanceof Error) {
  28619. Object.defineProperty(result, i, {
  28620. enumerable: true,
  28621. get: function () { throw wrapAccessError("index " + i, value); }
  28622. });
  28623. }
  28624. };
  28625. // Make all error indexed values throw on access
  28626. for (var i = 0; i < result.length; i++) {
  28627. _loop_1(i);
  28628. }
  28629. return Object.freeze(result);
  28630. };
  28631. // Given a transaction, find the matching function fragment (if any) and
  28632. // determine all its properties and call parameters
  28633. Interface.prototype.parseTransaction = function (tx) {
  28634. var fragment = this.getFunction(tx.data.substring(0, 10).toLowerCase());
  28635. if (!fragment) {
  28636. return null;
  28637. }
  28638. return new TransactionDescription({
  28639. args: this._abiCoder.decode(fragment.inputs, "0x" + tx.data.substring(10)),
  28640. functionFragment: fragment,
  28641. name: fragment.name,
  28642. signature: fragment.format(),
  28643. sighash: this.getSighash(fragment),
  28644. value: bignumber_1.BigNumber.from(tx.value || "0"),
  28645. });
  28646. };
  28647. // @TODO
  28648. //parseCallResult(data: BytesLike): ??
  28649. // Given an event log, find the matching event fragment (if any) and
  28650. // determine all its properties and values
  28651. Interface.prototype.parseLog = function (log) {
  28652. var fragment = this.getEvent(log.topics[0]);
  28653. if (!fragment || fragment.anonymous) {
  28654. return null;
  28655. }
  28656. // @TODO: If anonymous, and the only method, and the input count matches, should we parse?
  28657. // Probably not, because just because it is the only event in the ABI does
  28658. // not mean we have the full ABI; maybe just a fragment?
  28659. return new LogDescription({
  28660. eventFragment: fragment,
  28661. name: fragment.name,
  28662. signature: fragment.format(),
  28663. topic: this.getEventTopic(fragment),
  28664. args: this.decodeEventLog(fragment, log.data, log.topics)
  28665. });
  28666. };
  28667. Interface.prototype.parseError = function (data) {
  28668. var hexData = (0, bytes_1.hexlify)(data);
  28669. var fragment = this.getError(hexData.substring(0, 10).toLowerCase());
  28670. if (!fragment) {
  28671. return null;
  28672. }
  28673. return new ErrorDescription({
  28674. args: this._abiCoder.decode(fragment.inputs, "0x" + hexData.substring(10)),
  28675. errorFragment: fragment,
  28676. name: fragment.name,
  28677. signature: fragment.format(),
  28678. sighash: this.getSighash(fragment),
  28679. });
  28680. };
  28681. /*
  28682. static from(value: Array<Fragment | string | JsonAbi> | string | Interface) {
  28683. if (Interface.isInterface(value)) {
  28684. return value;
  28685. }
  28686. if (typeof(value) === "string") {
  28687. return new Interface(JSON.parse(value));
  28688. }
  28689. return new Interface(value);
  28690. }
  28691. */
  28692. Interface.isInterface = function (value) {
  28693. return !!(value && value._isInterface);
  28694. };
  28695. return Interface;
  28696. }());
  28697. exports.Interface = Interface;
  28698. },{"./_version":168,"./abi-coder":169,"./coders/abstract-coder":170,"./fragments":181,"@ethersproject/address":189,"@ethersproject/bignumber":196,"@ethersproject/bytes":199,"@ethersproject/hash":209,"@ethersproject/keccak256":221,"@ethersproject/logger":223,"@ethersproject/properties":229}],184:[function(_dereq_,module,exports){
  28699. "use strict";
  28700. Object.defineProperty(exports, "__esModule", { value: true });
  28701. exports.version = void 0;
  28702. exports.version = "abstract-provider/5.6.0";
  28703. },{}],185:[function(_dereq_,module,exports){
  28704. "use strict";
  28705. var __extends = (this && this.__extends) || (function () {
  28706. var extendStatics = function (d, b) {
  28707. extendStatics = Object.setPrototypeOf ||
  28708. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  28709. function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
  28710. return extendStatics(d, b);
  28711. };
  28712. return function (d, b) {
  28713. if (typeof b !== "function" && b !== null)
  28714. throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
  28715. extendStatics(d, b);
  28716. function __() { this.constructor = d; }
  28717. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  28718. };
  28719. })();
  28720. var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
  28721. function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
  28722. return new (P || (P = Promise))(function (resolve, reject) {
  28723. function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
  28724. function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
  28725. function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
  28726. step((generator = generator.apply(thisArg, _arguments || [])).next());
  28727. });
  28728. };
  28729. var __generator = (this && this.__generator) || function (thisArg, body) {
  28730. var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
  28731. return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
  28732. function verb(n) { return function (v) { return step([n, v]); }; }
  28733. function step(op) {
  28734. if (f) throw new TypeError("Generator is already executing.");
  28735. while (_) try {
  28736. if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
  28737. if (y = 0, t) op = [op[0] & 2, t.value];
  28738. switch (op[0]) {
  28739. case 0: case 1: t = op; break;
  28740. case 4: _.label++; return { value: op[1], done: false };
  28741. case 5: _.label++; y = op[1]; op = [0]; continue;
  28742. case 7: op = _.ops.pop(); _.trys.pop(); continue;
  28743. default:
  28744. if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
  28745. if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
  28746. if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
  28747. if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
  28748. if (t[2]) _.ops.pop();
  28749. _.trys.pop(); continue;
  28750. }
  28751. op = body.call(thisArg, _);
  28752. } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
  28753. if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
  28754. }
  28755. };
  28756. Object.defineProperty(exports, "__esModule", { value: true });
  28757. exports.Provider = exports.TransactionOrderForkEvent = exports.TransactionForkEvent = exports.BlockForkEvent = exports.ForkEvent = void 0;
  28758. var bignumber_1 = _dereq_("@ethersproject/bignumber");
  28759. var bytes_1 = _dereq_("@ethersproject/bytes");
  28760. var properties_1 = _dereq_("@ethersproject/properties");
  28761. var logger_1 = _dereq_("@ethersproject/logger");
  28762. var _version_1 = _dereq_("./_version");
  28763. var logger = new logger_1.Logger(_version_1.version);
  28764. ;
  28765. ;
  28766. //export type CallTransactionable = {
  28767. // call(transaction: TransactionRequest): Promise<TransactionResponse>;
  28768. //};
  28769. var ForkEvent = /** @class */ (function (_super) {
  28770. __extends(ForkEvent, _super);
  28771. function ForkEvent() {
  28772. return _super !== null && _super.apply(this, arguments) || this;
  28773. }
  28774. ForkEvent.isForkEvent = function (value) {
  28775. return !!(value && value._isForkEvent);
  28776. };
  28777. return ForkEvent;
  28778. }(properties_1.Description));
  28779. exports.ForkEvent = ForkEvent;
  28780. var BlockForkEvent = /** @class */ (function (_super) {
  28781. __extends(BlockForkEvent, _super);
  28782. function BlockForkEvent(blockHash, expiry) {
  28783. var _this = this;
  28784. if (!(0, bytes_1.isHexString)(blockHash, 32)) {
  28785. logger.throwArgumentError("invalid blockHash", "blockHash", blockHash);
  28786. }
  28787. _this = _super.call(this, {
  28788. _isForkEvent: true,
  28789. _isBlockForkEvent: true,
  28790. expiry: (expiry || 0),
  28791. blockHash: blockHash
  28792. }) || this;
  28793. return _this;
  28794. }
  28795. return BlockForkEvent;
  28796. }(ForkEvent));
  28797. exports.BlockForkEvent = BlockForkEvent;
  28798. var TransactionForkEvent = /** @class */ (function (_super) {
  28799. __extends(TransactionForkEvent, _super);
  28800. function TransactionForkEvent(hash, expiry) {
  28801. var _this = this;
  28802. if (!(0, bytes_1.isHexString)(hash, 32)) {
  28803. logger.throwArgumentError("invalid transaction hash", "hash", hash);
  28804. }
  28805. _this = _super.call(this, {
  28806. _isForkEvent: true,
  28807. _isTransactionForkEvent: true,
  28808. expiry: (expiry || 0),
  28809. hash: hash
  28810. }) || this;
  28811. return _this;
  28812. }
  28813. return TransactionForkEvent;
  28814. }(ForkEvent));
  28815. exports.TransactionForkEvent = TransactionForkEvent;
  28816. var TransactionOrderForkEvent = /** @class */ (function (_super) {
  28817. __extends(TransactionOrderForkEvent, _super);
  28818. function TransactionOrderForkEvent(beforeHash, afterHash, expiry) {
  28819. var _this = this;
  28820. if (!(0, bytes_1.isHexString)(beforeHash, 32)) {
  28821. logger.throwArgumentError("invalid transaction hash", "beforeHash", beforeHash);
  28822. }
  28823. if (!(0, bytes_1.isHexString)(afterHash, 32)) {
  28824. logger.throwArgumentError("invalid transaction hash", "afterHash", afterHash);
  28825. }
  28826. _this = _super.call(this, {
  28827. _isForkEvent: true,
  28828. _isTransactionOrderForkEvent: true,
  28829. expiry: (expiry || 0),
  28830. beforeHash: beforeHash,
  28831. afterHash: afterHash
  28832. }) || this;
  28833. return _this;
  28834. }
  28835. return TransactionOrderForkEvent;
  28836. }(ForkEvent));
  28837. exports.TransactionOrderForkEvent = TransactionOrderForkEvent;
  28838. ///////////////////////////////
  28839. // Exported Abstracts
  28840. var Provider = /** @class */ (function () {
  28841. function Provider() {
  28842. var _newTarget = this.constructor;
  28843. logger.checkAbstract(_newTarget, Provider);
  28844. (0, properties_1.defineReadOnly)(this, "_isProvider", true);
  28845. }
  28846. Provider.prototype.getFeeData = function () {
  28847. return __awaiter(this, void 0, void 0, function () {
  28848. var _a, block, gasPrice, maxFeePerGas, maxPriorityFeePerGas;
  28849. return __generator(this, function (_b) {
  28850. switch (_b.label) {
  28851. case 0: return [4 /*yield*/, (0, properties_1.resolveProperties)({
  28852. block: this.getBlock("latest"),
  28853. gasPrice: this.getGasPrice().catch(function (error) {
  28854. // @TODO: Why is this now failing on Calaveras?
  28855. //console.log(error);
  28856. return null;
  28857. })
  28858. })];
  28859. case 1:
  28860. _a = _b.sent(), block = _a.block, gasPrice = _a.gasPrice;
  28861. maxFeePerGas = null, maxPriorityFeePerGas = null;
  28862. if (block && block.baseFeePerGas) {
  28863. // We may want to compute this more accurately in the future,
  28864. // using the formula "check if the base fee is correct".
  28865. // See: https://eips.ethereum.org/EIPS/eip-1559
  28866. maxPriorityFeePerGas = bignumber_1.BigNumber.from("1500000000");
  28867. maxFeePerGas = block.baseFeePerGas.mul(2).add(maxPriorityFeePerGas);
  28868. }
  28869. return [2 /*return*/, { maxFeePerGas: maxFeePerGas, maxPriorityFeePerGas: maxPriorityFeePerGas, gasPrice: gasPrice }];
  28870. }
  28871. });
  28872. });
  28873. };
  28874. // Alias for "on"
  28875. Provider.prototype.addListener = function (eventName, listener) {
  28876. return this.on(eventName, listener);
  28877. };
  28878. // Alias for "off"
  28879. Provider.prototype.removeListener = function (eventName, listener) {
  28880. return this.off(eventName, listener);
  28881. };
  28882. Provider.isProvider = function (value) {
  28883. return !!(value && value._isProvider);
  28884. };
  28885. return Provider;
  28886. }());
  28887. exports.Provider = Provider;
  28888. },{"./_version":184,"@ethersproject/bignumber":196,"@ethersproject/bytes":199,"@ethersproject/logger":223,"@ethersproject/properties":229}],186:[function(_dereq_,module,exports){
  28889. "use strict";
  28890. Object.defineProperty(exports, "__esModule", { value: true });
  28891. exports.version = void 0;
  28892. exports.version = "abstract-signer/5.6.0";
  28893. },{}],187:[function(_dereq_,module,exports){
  28894. "use strict";
  28895. var __extends = (this && this.__extends) || (function () {
  28896. var extendStatics = function (d, b) {
  28897. extendStatics = Object.setPrototypeOf ||
  28898. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  28899. function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
  28900. return extendStatics(d, b);
  28901. };
  28902. return function (d, b) {
  28903. if (typeof b !== "function" && b !== null)
  28904. throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
  28905. extendStatics(d, b);
  28906. function __() { this.constructor = d; }
  28907. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  28908. };
  28909. })();
  28910. var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
  28911. function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
  28912. return new (P || (P = Promise))(function (resolve, reject) {
  28913. function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
  28914. function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
  28915. function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
  28916. step((generator = generator.apply(thisArg, _arguments || [])).next());
  28917. });
  28918. };
  28919. var __generator = (this && this.__generator) || function (thisArg, body) {
  28920. var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
  28921. return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
  28922. function verb(n) { return function (v) { return step([n, v]); }; }
  28923. function step(op) {
  28924. if (f) throw new TypeError("Generator is already executing.");
  28925. while (_) try {
  28926. if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
  28927. if (y = 0, t) op = [op[0] & 2, t.value];
  28928. switch (op[0]) {
  28929. case 0: case 1: t = op; break;
  28930. case 4: _.label++; return { value: op[1], done: false };
  28931. case 5: _.label++; y = op[1]; op = [0]; continue;
  28932. case 7: op = _.ops.pop(); _.trys.pop(); continue;
  28933. default:
  28934. if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
  28935. if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
  28936. if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
  28937. if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
  28938. if (t[2]) _.ops.pop();
  28939. _.trys.pop(); continue;
  28940. }
  28941. op = body.call(thisArg, _);
  28942. } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
  28943. if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
  28944. }
  28945. };
  28946. Object.defineProperty(exports, "__esModule", { value: true });
  28947. exports.VoidSigner = exports.Signer = void 0;
  28948. var properties_1 = _dereq_("@ethersproject/properties");
  28949. var logger_1 = _dereq_("@ethersproject/logger");
  28950. var _version_1 = _dereq_("./_version");
  28951. var logger = new logger_1.Logger(_version_1.version);
  28952. var allowedTransactionKeys = [
  28953. "accessList", "ccipReadEnabled", "chainId", "customData", "data", "from", "gasLimit", "gasPrice", "maxFeePerGas", "maxPriorityFeePerGas", "nonce", "to", "type", "value"
  28954. ];
  28955. var forwardErrors = [
  28956. logger_1.Logger.errors.INSUFFICIENT_FUNDS,
  28957. logger_1.Logger.errors.NONCE_EXPIRED,
  28958. logger_1.Logger.errors.REPLACEMENT_UNDERPRICED,
  28959. ];
  28960. ;
  28961. ;
  28962. var Signer = /** @class */ (function () {
  28963. ///////////////////
  28964. // Sub-classes MUST call super
  28965. function Signer() {
  28966. var _newTarget = this.constructor;
  28967. logger.checkAbstract(_newTarget, Signer);
  28968. (0, properties_1.defineReadOnly)(this, "_isSigner", true);
  28969. }
  28970. ///////////////////
  28971. // Sub-classes MAY override these
  28972. Signer.prototype.getBalance = function (blockTag) {
  28973. return __awaiter(this, void 0, void 0, function () {
  28974. return __generator(this, function (_a) {
  28975. switch (_a.label) {
  28976. case 0:
  28977. this._checkProvider("getBalance");
  28978. return [4 /*yield*/, this.provider.getBalance(this.getAddress(), blockTag)];
  28979. case 1: return [2 /*return*/, _a.sent()];
  28980. }
  28981. });
  28982. });
  28983. };
  28984. Signer.prototype.getTransactionCount = function (blockTag) {
  28985. return __awaiter(this, void 0, void 0, function () {
  28986. return __generator(this, function (_a) {
  28987. switch (_a.label) {
  28988. case 0:
  28989. this._checkProvider("getTransactionCount");
  28990. return [4 /*yield*/, this.provider.getTransactionCount(this.getAddress(), blockTag)];
  28991. case 1: return [2 /*return*/, _a.sent()];
  28992. }
  28993. });
  28994. });
  28995. };
  28996. // Populates "from" if unspecified, and estimates the gas for the transaction
  28997. Signer.prototype.estimateGas = function (transaction) {
  28998. return __awaiter(this, void 0, void 0, function () {
  28999. var tx;
  29000. return __generator(this, function (_a) {
  29001. switch (_a.label) {
  29002. case 0:
  29003. this._checkProvider("estimateGas");
  29004. return [4 /*yield*/, (0, properties_1.resolveProperties)(this.checkTransaction(transaction))];
  29005. case 1:
  29006. tx = _a.sent();
  29007. return [4 /*yield*/, this.provider.estimateGas(tx)];
  29008. case 2: return [2 /*return*/, _a.sent()];
  29009. }
  29010. });
  29011. });
  29012. };
  29013. // Populates "from" if unspecified, and calls with the transaction
  29014. Signer.prototype.call = function (transaction, blockTag) {
  29015. return __awaiter(this, void 0, void 0, function () {
  29016. var tx;
  29017. return __generator(this, function (_a) {
  29018. switch (_a.label) {
  29019. case 0:
  29020. this._checkProvider("call");
  29021. return [4 /*yield*/, (0, properties_1.resolveProperties)(this.checkTransaction(transaction))];
  29022. case 1:
  29023. tx = _a.sent();
  29024. return [4 /*yield*/, this.provider.call(tx, blockTag)];
  29025. case 2: return [2 /*return*/, _a.sent()];
  29026. }
  29027. });
  29028. });
  29029. };
  29030. // Populates all fields in a transaction, signs it and sends it to the network
  29031. Signer.prototype.sendTransaction = function (transaction) {
  29032. return __awaiter(this, void 0, void 0, function () {
  29033. var tx, signedTx;
  29034. return __generator(this, function (_a) {
  29035. switch (_a.label) {
  29036. case 0:
  29037. this._checkProvider("sendTransaction");
  29038. return [4 /*yield*/, this.populateTransaction(transaction)];
  29039. case 1:
  29040. tx = _a.sent();
  29041. return [4 /*yield*/, this.signTransaction(tx)];
  29042. case 2:
  29043. signedTx = _a.sent();
  29044. return [4 /*yield*/, this.provider.sendTransaction(signedTx)];
  29045. case 3: return [2 /*return*/, _a.sent()];
  29046. }
  29047. });
  29048. });
  29049. };
  29050. Signer.prototype.getChainId = function () {
  29051. return __awaiter(this, void 0, void 0, function () {
  29052. var network;
  29053. return __generator(this, function (_a) {
  29054. switch (_a.label) {
  29055. case 0:
  29056. this._checkProvider("getChainId");
  29057. return [4 /*yield*/, this.provider.getNetwork()];
  29058. case 1:
  29059. network = _a.sent();
  29060. return [2 /*return*/, network.chainId];
  29061. }
  29062. });
  29063. });
  29064. };
  29065. Signer.prototype.getGasPrice = function () {
  29066. return __awaiter(this, void 0, void 0, function () {
  29067. return __generator(this, function (_a) {
  29068. switch (_a.label) {
  29069. case 0:
  29070. this._checkProvider("getGasPrice");
  29071. return [4 /*yield*/, this.provider.getGasPrice()];
  29072. case 1: return [2 /*return*/, _a.sent()];
  29073. }
  29074. });
  29075. });
  29076. };
  29077. Signer.prototype.getFeeData = function () {
  29078. return __awaiter(this, void 0, void 0, function () {
  29079. return __generator(this, function (_a) {
  29080. switch (_a.label) {
  29081. case 0:
  29082. this._checkProvider("getFeeData");
  29083. return [4 /*yield*/, this.provider.getFeeData()];
  29084. case 1: return [2 /*return*/, _a.sent()];
  29085. }
  29086. });
  29087. });
  29088. };
  29089. Signer.prototype.resolveName = function (name) {
  29090. return __awaiter(this, void 0, void 0, function () {
  29091. return __generator(this, function (_a) {
  29092. switch (_a.label) {
  29093. case 0:
  29094. this._checkProvider("resolveName");
  29095. return [4 /*yield*/, this.provider.resolveName(name)];
  29096. case 1: return [2 /*return*/, _a.sent()];
  29097. }
  29098. });
  29099. });
  29100. };
  29101. // Checks a transaction does not contain invalid keys and if
  29102. // no "from" is provided, populates it.
  29103. // - does NOT require a provider
  29104. // - adds "from" is not present
  29105. // - returns a COPY (safe to mutate the result)
  29106. // By default called from: (overriding these prevents it)
  29107. // - call
  29108. // - estimateGas
  29109. // - populateTransaction (and therefor sendTransaction)
  29110. Signer.prototype.checkTransaction = function (transaction) {
  29111. for (var key in transaction) {
  29112. if (allowedTransactionKeys.indexOf(key) === -1) {
  29113. logger.throwArgumentError("invalid transaction key: " + key, "transaction", transaction);
  29114. }
  29115. }
  29116. var tx = (0, properties_1.shallowCopy)(transaction);
  29117. if (tx.from == null) {
  29118. tx.from = this.getAddress();
  29119. }
  29120. else {
  29121. // Make sure any provided address matches this signer
  29122. tx.from = Promise.all([
  29123. Promise.resolve(tx.from),
  29124. this.getAddress()
  29125. ]).then(function (result) {
  29126. if (result[0].toLowerCase() !== result[1].toLowerCase()) {
  29127. logger.throwArgumentError("from address mismatch", "transaction", transaction);
  29128. }
  29129. return result[0];
  29130. });
  29131. }
  29132. return tx;
  29133. };
  29134. // Populates ALL keys for a transaction and checks that "from" matches
  29135. // this Signer. Should be used by sendTransaction but NOT by signTransaction.
  29136. // By default called from: (overriding these prevents it)
  29137. // - sendTransaction
  29138. //
  29139. // Notes:
  29140. // - We allow gasPrice for EIP-1559 as long as it matches maxFeePerGas
  29141. Signer.prototype.populateTransaction = function (transaction) {
  29142. return __awaiter(this, void 0, void 0, function () {
  29143. var tx, hasEip1559, feeData, gasPrice;
  29144. var _this = this;
  29145. return __generator(this, function (_a) {
  29146. switch (_a.label) {
  29147. case 0: return [4 /*yield*/, (0, properties_1.resolveProperties)(this.checkTransaction(transaction))];
  29148. case 1:
  29149. tx = _a.sent();
  29150. if (tx.to != null) {
  29151. tx.to = Promise.resolve(tx.to).then(function (to) { return __awaiter(_this, void 0, void 0, function () {
  29152. var address;
  29153. return __generator(this, function (_a) {
  29154. switch (_a.label) {
  29155. case 0:
  29156. if (to == null) {
  29157. return [2 /*return*/, null];
  29158. }
  29159. return [4 /*yield*/, this.resolveName(to)];
  29160. case 1:
  29161. address = _a.sent();
  29162. if (address == null) {
  29163. logger.throwArgumentError("provided ENS name resolves to null", "tx.to", to);
  29164. }
  29165. return [2 /*return*/, address];
  29166. }
  29167. });
  29168. }); });
  29169. // Prevent this error from causing an UnhandledPromiseException
  29170. tx.to.catch(function (error) { });
  29171. }
  29172. hasEip1559 = (tx.maxFeePerGas != null || tx.maxPriorityFeePerGas != null);
  29173. if (tx.gasPrice != null && (tx.type === 2 || hasEip1559)) {
  29174. logger.throwArgumentError("eip-1559 transaction do not support gasPrice", "transaction", transaction);
  29175. }
  29176. else if ((tx.type === 0 || tx.type === 1) && hasEip1559) {
  29177. logger.throwArgumentError("pre-eip-1559 transaction do not support maxFeePerGas/maxPriorityFeePerGas", "transaction", transaction);
  29178. }
  29179. if (!((tx.type === 2 || tx.type == null) && (tx.maxFeePerGas != null && tx.maxPriorityFeePerGas != null))) return [3 /*break*/, 2];
  29180. // Fully-formed EIP-1559 transaction (skip getFeeData)
  29181. tx.type = 2;
  29182. return [3 /*break*/, 5];
  29183. case 2:
  29184. if (!(tx.type === 0 || tx.type === 1)) return [3 /*break*/, 3];
  29185. // Explicit Legacy or EIP-2930 transaction
  29186. // Populate missing gasPrice
  29187. if (tx.gasPrice == null) {
  29188. tx.gasPrice = this.getGasPrice();
  29189. }
  29190. return [3 /*break*/, 5];
  29191. case 3: return [4 /*yield*/, this.getFeeData()];
  29192. case 4:
  29193. feeData = _a.sent();
  29194. if (tx.type == null) {
  29195. // We need to auto-detect the intended type of this transaction...
  29196. if (feeData.maxFeePerGas != null && feeData.maxPriorityFeePerGas != null) {
  29197. // The network supports EIP-1559!
  29198. // Upgrade transaction from null to eip-1559
  29199. tx.type = 2;
  29200. if (tx.gasPrice != null) {
  29201. gasPrice = tx.gasPrice;
  29202. delete tx.gasPrice;
  29203. tx.maxFeePerGas = gasPrice;
  29204. tx.maxPriorityFeePerGas = gasPrice;
  29205. }
  29206. else {
  29207. // Populate missing fee data
  29208. if (tx.maxFeePerGas == null) {
  29209. tx.maxFeePerGas = feeData.maxFeePerGas;
  29210. }
  29211. if (tx.maxPriorityFeePerGas == null) {
  29212. tx.maxPriorityFeePerGas = feeData.maxPriorityFeePerGas;
  29213. }
  29214. }
  29215. }
  29216. else if (feeData.gasPrice != null) {
  29217. // Network doesn't support EIP-1559...
  29218. // ...but they are trying to use EIP-1559 properties
  29219. if (hasEip1559) {
  29220. logger.throwError("network does not support EIP-1559", logger_1.Logger.errors.UNSUPPORTED_OPERATION, {
  29221. operation: "populateTransaction"
  29222. });
  29223. }
  29224. // Populate missing fee data
  29225. if (tx.gasPrice == null) {
  29226. tx.gasPrice = feeData.gasPrice;
  29227. }
  29228. // Explicitly set untyped transaction to legacy
  29229. tx.type = 0;
  29230. }
  29231. else {
  29232. // getFeeData has failed us.
  29233. logger.throwError("failed to get consistent fee data", logger_1.Logger.errors.UNSUPPORTED_OPERATION, {
  29234. operation: "signer.getFeeData"
  29235. });
  29236. }
  29237. }
  29238. else if (tx.type === 2) {
  29239. // Explicitly using EIP-1559
  29240. // Populate missing fee data
  29241. if (tx.maxFeePerGas == null) {
  29242. tx.maxFeePerGas = feeData.maxFeePerGas;
  29243. }
  29244. if (tx.maxPriorityFeePerGas == null) {
  29245. tx.maxPriorityFeePerGas = feeData.maxPriorityFeePerGas;
  29246. }
  29247. }
  29248. _a.label = 5;
  29249. case 5:
  29250. if (tx.nonce == null) {
  29251. tx.nonce = this.getTransactionCount("pending");
  29252. }
  29253. if (tx.gasLimit == null) {
  29254. tx.gasLimit = this.estimateGas(tx).catch(function (error) {
  29255. if (forwardErrors.indexOf(error.code) >= 0) {
  29256. throw error;
  29257. }
  29258. return logger.throwError("cannot estimate gas; transaction may fail or may require manual gas limit", logger_1.Logger.errors.UNPREDICTABLE_GAS_LIMIT, {
  29259. error: error,
  29260. tx: tx
  29261. });
  29262. });
  29263. }
  29264. if (tx.chainId == null) {
  29265. tx.chainId = this.getChainId();
  29266. }
  29267. else {
  29268. tx.chainId = Promise.all([
  29269. Promise.resolve(tx.chainId),
  29270. this.getChainId()
  29271. ]).then(function (results) {
  29272. if (results[1] !== 0 && results[0] !== results[1]) {
  29273. logger.throwArgumentError("chainId address mismatch", "transaction", transaction);
  29274. }
  29275. return results[0];
  29276. });
  29277. }
  29278. return [4 /*yield*/, (0, properties_1.resolveProperties)(tx)];
  29279. case 6: return [2 /*return*/, _a.sent()];
  29280. }
  29281. });
  29282. });
  29283. };
  29284. ///////////////////
  29285. // Sub-classes SHOULD leave these alone
  29286. Signer.prototype._checkProvider = function (operation) {
  29287. if (!this.provider) {
  29288. logger.throwError("missing provider", logger_1.Logger.errors.UNSUPPORTED_OPERATION, {
  29289. operation: (operation || "_checkProvider")
  29290. });
  29291. }
  29292. };
  29293. Signer.isSigner = function (value) {
  29294. return !!(value && value._isSigner);
  29295. };
  29296. return Signer;
  29297. }());
  29298. exports.Signer = Signer;
  29299. var VoidSigner = /** @class */ (function (_super) {
  29300. __extends(VoidSigner, _super);
  29301. function VoidSigner(address, provider) {
  29302. var _newTarget = this.constructor;
  29303. var _this = this;
  29304. logger.checkNew(_newTarget, VoidSigner);
  29305. _this = _super.call(this) || this;
  29306. (0, properties_1.defineReadOnly)(_this, "address", address);
  29307. (0, properties_1.defineReadOnly)(_this, "provider", provider || null);
  29308. return _this;
  29309. }
  29310. VoidSigner.prototype.getAddress = function () {
  29311. return Promise.resolve(this.address);
  29312. };
  29313. VoidSigner.prototype._fail = function (message, operation) {
  29314. return Promise.resolve().then(function () {
  29315. logger.throwError(message, logger_1.Logger.errors.UNSUPPORTED_OPERATION, { operation: operation });
  29316. });
  29317. };
  29318. VoidSigner.prototype.signMessage = function (message) {
  29319. return this._fail("VoidSigner cannot sign messages", "signMessage");
  29320. };
  29321. VoidSigner.prototype.signTransaction = function (transaction) {
  29322. return this._fail("VoidSigner cannot sign transactions", "signTransaction");
  29323. };
  29324. VoidSigner.prototype._signTypedData = function (domain, types, value) {
  29325. return this._fail("VoidSigner cannot sign typed data", "signTypedData");
  29326. };
  29327. VoidSigner.prototype.connect = function (provider) {
  29328. return new VoidSigner(this.address, provider);
  29329. };
  29330. return VoidSigner;
  29331. }(Signer));
  29332. exports.VoidSigner = VoidSigner;
  29333. },{"./_version":186,"@ethersproject/logger":223,"@ethersproject/properties":229}],188:[function(_dereq_,module,exports){
  29334. "use strict";
  29335. Object.defineProperty(exports, "__esModule", { value: true });
  29336. exports.version = void 0;
  29337. exports.version = "address/5.6.0";
  29338. },{}],189:[function(_dereq_,module,exports){
  29339. "use strict";
  29340. Object.defineProperty(exports, "__esModule", { value: true });
  29341. exports.getCreate2Address = exports.getContractAddress = exports.getIcapAddress = exports.isAddress = exports.getAddress = void 0;
  29342. var bytes_1 = _dereq_("@ethersproject/bytes");
  29343. var bignumber_1 = _dereq_("@ethersproject/bignumber");
  29344. var keccak256_1 = _dereq_("@ethersproject/keccak256");
  29345. var rlp_1 = _dereq_("@ethersproject/rlp");
  29346. var logger_1 = _dereq_("@ethersproject/logger");
  29347. var _version_1 = _dereq_("./_version");
  29348. var logger = new logger_1.Logger(_version_1.version);
  29349. function getChecksumAddress(address) {
  29350. if (!(0, bytes_1.isHexString)(address, 20)) {
  29351. logger.throwArgumentError("invalid address", "address", address);
  29352. }
  29353. address = address.toLowerCase();
  29354. var chars = address.substring(2).split("");
  29355. var expanded = new Uint8Array(40);
  29356. for (var i = 0; i < 40; i++) {
  29357. expanded[i] = chars[i].charCodeAt(0);
  29358. }
  29359. var hashed = (0, bytes_1.arrayify)((0, keccak256_1.keccak256)(expanded));
  29360. for (var i = 0; i < 40; i += 2) {
  29361. if ((hashed[i >> 1] >> 4) >= 8) {
  29362. chars[i] = chars[i].toUpperCase();
  29363. }
  29364. if ((hashed[i >> 1] & 0x0f) >= 8) {
  29365. chars[i + 1] = chars[i + 1].toUpperCase();
  29366. }
  29367. }
  29368. return "0x" + chars.join("");
  29369. }
  29370. // Shims for environments that are missing some required constants and functions
  29371. var MAX_SAFE_INTEGER = 0x1fffffffffffff;
  29372. function log10(x) {
  29373. if (Math.log10) {
  29374. return Math.log10(x);
  29375. }
  29376. return Math.log(x) / Math.LN10;
  29377. }
  29378. // See: https://en.wikipedia.org/wiki/International_Bank_Account_Number
  29379. // Create lookup table
  29380. var ibanLookup = {};
  29381. for (var i = 0; i < 10; i++) {
  29382. ibanLookup[String(i)] = String(i);
  29383. }
  29384. for (var i = 0; i < 26; i++) {
  29385. ibanLookup[String.fromCharCode(65 + i)] = String(10 + i);
  29386. }
  29387. // How many decimal digits can we process? (for 64-bit float, this is 15)
  29388. var safeDigits = Math.floor(log10(MAX_SAFE_INTEGER));
  29389. function ibanChecksum(address) {
  29390. address = address.toUpperCase();
  29391. address = address.substring(4) + address.substring(0, 2) + "00";
  29392. var expanded = address.split("").map(function (c) { return ibanLookup[c]; }).join("");
  29393. // Javascript can handle integers safely up to 15 (decimal) digits
  29394. while (expanded.length >= safeDigits) {
  29395. var block = expanded.substring(0, safeDigits);
  29396. expanded = parseInt(block, 10) % 97 + expanded.substring(block.length);
  29397. }
  29398. var checksum = String(98 - (parseInt(expanded, 10) % 97));
  29399. while (checksum.length < 2) {
  29400. checksum = "0" + checksum;
  29401. }
  29402. return checksum;
  29403. }
  29404. ;
  29405. function getAddress(address) {
  29406. var result = null;
  29407. if (typeof (address) !== "string") {
  29408. logger.throwArgumentError("invalid address", "address", address);
  29409. }
  29410. if (address.match(/^(0x)?[0-9a-fA-F]{40}$/)) {
  29411. // Missing the 0x prefix
  29412. if (address.substring(0, 2) !== "0x") {
  29413. address = "0x" + address;
  29414. }
  29415. result = getChecksumAddress(address);
  29416. // It is a checksummed address with a bad checksum
  29417. if (address.match(/([A-F].*[a-f])|([a-f].*[A-F])/) && result !== address) {
  29418. logger.throwArgumentError("bad address checksum", "address", address);
  29419. }
  29420. // Maybe ICAP? (we only support direct mode)
  29421. }
  29422. else if (address.match(/^XE[0-9]{2}[0-9A-Za-z]{30,31}$/)) {
  29423. // It is an ICAP address with a bad checksum
  29424. if (address.substring(2, 4) !== ibanChecksum(address)) {
  29425. logger.throwArgumentError("bad icap checksum", "address", address);
  29426. }
  29427. result = (0, bignumber_1._base36To16)(address.substring(4));
  29428. while (result.length < 40) {
  29429. result = "0" + result;
  29430. }
  29431. result = getChecksumAddress("0x" + result);
  29432. }
  29433. else {
  29434. logger.throwArgumentError("invalid address", "address", address);
  29435. }
  29436. return result;
  29437. }
  29438. exports.getAddress = getAddress;
  29439. function isAddress(address) {
  29440. try {
  29441. getAddress(address);
  29442. return true;
  29443. }
  29444. catch (error) { }
  29445. return false;
  29446. }
  29447. exports.isAddress = isAddress;
  29448. function getIcapAddress(address) {
  29449. var base36 = (0, bignumber_1._base16To36)(getAddress(address).substring(2)).toUpperCase();
  29450. while (base36.length < 30) {
  29451. base36 = "0" + base36;
  29452. }
  29453. return "XE" + ibanChecksum("XE00" + base36) + base36;
  29454. }
  29455. exports.getIcapAddress = getIcapAddress;
  29456. // http://ethereum.stackexchange.com/questions/760/how-is-the-address-of-an-ethereum-contract-computed
  29457. function getContractAddress(transaction) {
  29458. var from = null;
  29459. try {
  29460. from = getAddress(transaction.from);
  29461. }
  29462. catch (error) {
  29463. logger.throwArgumentError("missing from address", "transaction", transaction);
  29464. }
  29465. var nonce = (0, bytes_1.stripZeros)((0, bytes_1.arrayify)(bignumber_1.BigNumber.from(transaction.nonce).toHexString()));
  29466. return getAddress((0, bytes_1.hexDataSlice)((0, keccak256_1.keccak256)((0, rlp_1.encode)([from, nonce])), 12));
  29467. }
  29468. exports.getContractAddress = getContractAddress;
  29469. function getCreate2Address(from, salt, initCodeHash) {
  29470. if ((0, bytes_1.hexDataLength)(salt) !== 32) {
  29471. logger.throwArgumentError("salt must be 32 bytes", "salt", salt);
  29472. }
  29473. if ((0, bytes_1.hexDataLength)(initCodeHash) !== 32) {
  29474. logger.throwArgumentError("initCodeHash must be 32 bytes", "initCodeHash", initCodeHash);
  29475. }
  29476. return getAddress((0, bytes_1.hexDataSlice)((0, keccak256_1.keccak256)((0, bytes_1.concat)(["0xff", getAddress(from), salt, initCodeHash])), 12));
  29477. }
  29478. exports.getCreate2Address = getCreate2Address;
  29479. },{"./_version":188,"@ethersproject/bignumber":196,"@ethersproject/bytes":199,"@ethersproject/keccak256":221,"@ethersproject/logger":223,"@ethersproject/rlp":253}],190:[function(_dereq_,module,exports){
  29480. "use strict";
  29481. Object.defineProperty(exports, "__esModule", { value: true });
  29482. exports.encode = exports.decode = void 0;
  29483. var bytes_1 = _dereq_("@ethersproject/bytes");
  29484. function decode(textData) {
  29485. textData = atob(textData);
  29486. var data = [];
  29487. for (var i = 0; i < textData.length; i++) {
  29488. data.push(textData.charCodeAt(i));
  29489. }
  29490. return (0, bytes_1.arrayify)(data);
  29491. }
  29492. exports.decode = decode;
  29493. function encode(data) {
  29494. data = (0, bytes_1.arrayify)(data);
  29495. var textData = "";
  29496. for (var i = 0; i < data.length; i++) {
  29497. textData += String.fromCharCode(data[i]);
  29498. }
  29499. return btoa(textData);
  29500. }
  29501. exports.encode = encode;
  29502. },{"@ethersproject/bytes":199}],191:[function(_dereq_,module,exports){
  29503. "use strict";
  29504. Object.defineProperty(exports, "__esModule", { value: true });
  29505. exports.encode = exports.decode = void 0;
  29506. var base64_1 = _dereq_("./base64");
  29507. Object.defineProperty(exports, "decode", { enumerable: true, get: function () { return base64_1.decode; } });
  29508. Object.defineProperty(exports, "encode", { enumerable: true, get: function () { return base64_1.encode; } });
  29509. },{"./base64":190}],192:[function(_dereq_,module,exports){
  29510. "use strict";
  29511. /**
  29512. * var basex = require("base-x");
  29513. *
  29514. * This implementation is heavily based on base-x. The main reason to
  29515. * deviate was to prevent the dependency of Buffer.
  29516. *
  29517. * Contributors:
  29518. *
  29519. * base-x encoding
  29520. * Forked from https://github.com/cryptocoinjs/bs58
  29521. * Originally written by Mike Hearn for BitcoinJ
  29522. * Copyright (c) 2011 Google Inc
  29523. * Ported to JavaScript by Stefan Thomas
  29524. * Merged Buffer refactorings from base58-native by Stephen Pair
  29525. * Copyright (c) 2013 BitPay Inc
  29526. *
  29527. * The MIT License (MIT)
  29528. *
  29529. * Copyright base-x contributors (c) 2016
  29530. *
  29531. * Permission is hereby granted, free of charge, to any person obtaining a
  29532. * copy of this software and associated documentation files (the "Software"),
  29533. * to deal in the Software without restriction, including without limitation
  29534. * the rights to use, copy, modify, merge, publish, distribute, sublicense,
  29535. * and/or sell copies of the Software, and to permit persons to whom the
  29536. * Software is furnished to do so, subject to the following conditions:
  29537. *
  29538. * The above copyright notice and this permission notice shall be included in
  29539. * all copies or substantial portions of the Software.
  29540. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  29541. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  29542. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  29543. * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  29544. * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
  29545. * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
  29546. * IN THE SOFTWARE.
  29547. *
  29548. */
  29549. Object.defineProperty(exports, "__esModule", { value: true });
  29550. exports.Base58 = exports.Base32 = exports.BaseX = void 0;
  29551. var bytes_1 = _dereq_("@ethersproject/bytes");
  29552. var properties_1 = _dereq_("@ethersproject/properties");
  29553. var BaseX = /** @class */ (function () {
  29554. function BaseX(alphabet) {
  29555. (0, properties_1.defineReadOnly)(this, "alphabet", alphabet);
  29556. (0, properties_1.defineReadOnly)(this, "base", alphabet.length);
  29557. (0, properties_1.defineReadOnly)(this, "_alphabetMap", {});
  29558. (0, properties_1.defineReadOnly)(this, "_leader", alphabet.charAt(0));
  29559. // pre-compute lookup table
  29560. for (var i = 0; i < alphabet.length; i++) {
  29561. this._alphabetMap[alphabet.charAt(i)] = i;
  29562. }
  29563. }
  29564. BaseX.prototype.encode = function (value) {
  29565. var source = (0, bytes_1.arrayify)(value);
  29566. if (source.length === 0) {
  29567. return "";
  29568. }
  29569. var digits = [0];
  29570. for (var i = 0; i < source.length; ++i) {
  29571. var carry = source[i];
  29572. for (var j = 0; j < digits.length; ++j) {
  29573. carry += digits[j] << 8;
  29574. digits[j] = carry % this.base;
  29575. carry = (carry / this.base) | 0;
  29576. }
  29577. while (carry > 0) {
  29578. digits.push(carry % this.base);
  29579. carry = (carry / this.base) | 0;
  29580. }
  29581. }
  29582. var string = "";
  29583. // deal with leading zeros
  29584. for (var k = 0; source[k] === 0 && k < source.length - 1; ++k) {
  29585. string += this._leader;
  29586. }
  29587. // convert digits to a string
  29588. for (var q = digits.length - 1; q >= 0; --q) {
  29589. string += this.alphabet[digits[q]];
  29590. }
  29591. return string;
  29592. };
  29593. BaseX.prototype.decode = function (value) {
  29594. if (typeof (value) !== "string") {
  29595. throw new TypeError("Expected String");
  29596. }
  29597. var bytes = [];
  29598. if (value.length === 0) {
  29599. return new Uint8Array(bytes);
  29600. }
  29601. bytes.push(0);
  29602. for (var i = 0; i < value.length; i++) {
  29603. var byte = this._alphabetMap[value[i]];
  29604. if (byte === undefined) {
  29605. throw new Error("Non-base" + this.base + " character");
  29606. }
  29607. var carry = byte;
  29608. for (var j = 0; j < bytes.length; ++j) {
  29609. carry += bytes[j] * this.base;
  29610. bytes[j] = carry & 0xff;
  29611. carry >>= 8;
  29612. }
  29613. while (carry > 0) {
  29614. bytes.push(carry & 0xff);
  29615. carry >>= 8;
  29616. }
  29617. }
  29618. // deal with leading zeros
  29619. for (var k = 0; value[k] === this._leader && k < value.length - 1; ++k) {
  29620. bytes.push(0);
  29621. }
  29622. return (0, bytes_1.arrayify)(new Uint8Array(bytes.reverse()));
  29623. };
  29624. return BaseX;
  29625. }());
  29626. exports.BaseX = BaseX;
  29627. var Base32 = new BaseX("abcdefghijklmnopqrstuvwxyz234567");
  29628. exports.Base32 = Base32;
  29629. var Base58 = new BaseX("123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz");
  29630. exports.Base58 = Base58;
  29631. //console.log(Base58.decode("Qmd2V777o5XvJbYMeMb8k2nU5f8d3ciUQ5YpYuWhzv8iDj"))
  29632. //console.log(Base58.encode(Base58.decode("Qmd2V777o5XvJbYMeMb8k2nU5f8d3ciUQ5YpYuWhzv8iDj")))
  29633. },{"@ethersproject/bytes":199,"@ethersproject/properties":229}],193:[function(_dereq_,module,exports){
  29634. "use strict";
  29635. Object.defineProperty(exports, "__esModule", { value: true });
  29636. exports.version = void 0;
  29637. exports.version = "bignumber/5.6.0";
  29638. },{}],194:[function(_dereq_,module,exports){
  29639. "use strict";
  29640. var __importDefault = (this && this.__importDefault) || function (mod) {
  29641. return (mod && mod.__esModule) ? mod : { "default": mod };
  29642. };
  29643. Object.defineProperty(exports, "__esModule", { value: true });
  29644. exports._base16To36 = exports._base36To16 = exports.BigNumber = exports.isBigNumberish = void 0;
  29645. /**
  29646. * BigNumber
  29647. *
  29648. * A wrapper around the BN.js object. We use the BN.js library
  29649. * because it is used by elliptic, so it is required regardless.
  29650. *
  29651. */
  29652. var bn_js_1 = __importDefault(_dereq_("bn.js"));
  29653. var BN = bn_js_1.default.BN;
  29654. var bytes_1 = _dereq_("@ethersproject/bytes");
  29655. var logger_1 = _dereq_("@ethersproject/logger");
  29656. var _version_1 = _dereq_("./_version");
  29657. var logger = new logger_1.Logger(_version_1.version);
  29658. var _constructorGuard = {};
  29659. var MAX_SAFE = 0x1fffffffffffff;
  29660. function isBigNumberish(value) {
  29661. return (value != null) && (BigNumber.isBigNumber(value) ||
  29662. (typeof (value) === "number" && (value % 1) === 0) ||
  29663. (typeof (value) === "string" && !!value.match(/^-?[0-9]+$/)) ||
  29664. (0, bytes_1.isHexString)(value) ||
  29665. (typeof (value) === "bigint") ||
  29666. (0, bytes_1.isBytes)(value));
  29667. }
  29668. exports.isBigNumberish = isBigNumberish;
  29669. // Only warn about passing 10 into radix once
  29670. var _warnedToStringRadix = false;
  29671. var BigNumber = /** @class */ (function () {
  29672. function BigNumber(constructorGuard, hex) {
  29673. var _newTarget = this.constructor;
  29674. logger.checkNew(_newTarget, BigNumber);
  29675. if (constructorGuard !== _constructorGuard) {
  29676. logger.throwError("cannot call constructor directly; use BigNumber.from", logger_1.Logger.errors.UNSUPPORTED_OPERATION, {
  29677. operation: "new (BigNumber)"
  29678. });
  29679. }
  29680. this._hex = hex;
  29681. this._isBigNumber = true;
  29682. Object.freeze(this);
  29683. }
  29684. BigNumber.prototype.fromTwos = function (value) {
  29685. return toBigNumber(toBN(this).fromTwos(value));
  29686. };
  29687. BigNumber.prototype.toTwos = function (value) {
  29688. return toBigNumber(toBN(this).toTwos(value));
  29689. };
  29690. BigNumber.prototype.abs = function () {
  29691. if (this._hex[0] === "-") {
  29692. return BigNumber.from(this._hex.substring(1));
  29693. }
  29694. return this;
  29695. };
  29696. BigNumber.prototype.add = function (other) {
  29697. return toBigNumber(toBN(this).add(toBN(other)));
  29698. };
  29699. BigNumber.prototype.sub = function (other) {
  29700. return toBigNumber(toBN(this).sub(toBN(other)));
  29701. };
  29702. BigNumber.prototype.div = function (other) {
  29703. var o = BigNumber.from(other);
  29704. if (o.isZero()) {
  29705. throwFault("division-by-zero", "div");
  29706. }
  29707. return toBigNumber(toBN(this).div(toBN(other)));
  29708. };
  29709. BigNumber.prototype.mul = function (other) {
  29710. return toBigNumber(toBN(this).mul(toBN(other)));
  29711. };
  29712. BigNumber.prototype.mod = function (other) {
  29713. var value = toBN(other);
  29714. if (value.isNeg()) {
  29715. throwFault("division-by-zero", "mod");
  29716. }
  29717. return toBigNumber(toBN(this).umod(value));
  29718. };
  29719. BigNumber.prototype.pow = function (other) {
  29720. var value = toBN(other);
  29721. if (value.isNeg()) {
  29722. throwFault("negative-power", "pow");
  29723. }
  29724. return toBigNumber(toBN(this).pow(value));
  29725. };
  29726. BigNumber.prototype.and = function (other) {
  29727. var value = toBN(other);
  29728. if (this.isNegative() || value.isNeg()) {
  29729. throwFault("unbound-bitwise-result", "and");
  29730. }
  29731. return toBigNumber(toBN(this).and(value));
  29732. };
  29733. BigNumber.prototype.or = function (other) {
  29734. var value = toBN(other);
  29735. if (this.isNegative() || value.isNeg()) {
  29736. throwFault("unbound-bitwise-result", "or");
  29737. }
  29738. return toBigNumber(toBN(this).or(value));
  29739. };
  29740. BigNumber.prototype.xor = function (other) {
  29741. var value = toBN(other);
  29742. if (this.isNegative() || value.isNeg()) {
  29743. throwFault("unbound-bitwise-result", "xor");
  29744. }
  29745. return toBigNumber(toBN(this).xor(value));
  29746. };
  29747. BigNumber.prototype.mask = function (value) {
  29748. if (this.isNegative() || value < 0) {
  29749. throwFault("negative-width", "mask");
  29750. }
  29751. return toBigNumber(toBN(this).maskn(value));
  29752. };
  29753. BigNumber.prototype.shl = function (value) {
  29754. if (this.isNegative() || value < 0) {
  29755. throwFault("negative-width", "shl");
  29756. }
  29757. return toBigNumber(toBN(this).shln(value));
  29758. };
  29759. BigNumber.prototype.shr = function (value) {
  29760. if (this.isNegative() || value < 0) {
  29761. throwFault("negative-width", "shr");
  29762. }
  29763. return toBigNumber(toBN(this).shrn(value));
  29764. };
  29765. BigNumber.prototype.eq = function (other) {
  29766. return toBN(this).eq(toBN(other));
  29767. };
  29768. BigNumber.prototype.lt = function (other) {
  29769. return toBN(this).lt(toBN(other));
  29770. };
  29771. BigNumber.prototype.lte = function (other) {
  29772. return toBN(this).lte(toBN(other));
  29773. };
  29774. BigNumber.prototype.gt = function (other) {
  29775. return toBN(this).gt(toBN(other));
  29776. };
  29777. BigNumber.prototype.gte = function (other) {
  29778. return toBN(this).gte(toBN(other));
  29779. };
  29780. BigNumber.prototype.isNegative = function () {
  29781. return (this._hex[0] === "-");
  29782. };
  29783. BigNumber.prototype.isZero = function () {
  29784. return toBN(this).isZero();
  29785. };
  29786. BigNumber.prototype.toNumber = function () {
  29787. try {
  29788. return toBN(this).toNumber();
  29789. }
  29790. catch (error) {
  29791. throwFault("overflow", "toNumber", this.toString());
  29792. }
  29793. return null;
  29794. };
  29795. BigNumber.prototype.toBigInt = function () {
  29796. try {
  29797. return BigInt(this.toString());
  29798. }
  29799. catch (e) { }
  29800. return logger.throwError("this platform does not support BigInt", logger_1.Logger.errors.UNSUPPORTED_OPERATION, {
  29801. value: this.toString()
  29802. });
  29803. };
  29804. BigNumber.prototype.toString = function () {
  29805. // Lots of people expect this, which we do not support, so check (See: #889)
  29806. if (arguments.length > 0) {
  29807. if (arguments[0] === 10) {
  29808. if (!_warnedToStringRadix) {
  29809. _warnedToStringRadix = true;
  29810. logger.warn("BigNumber.toString does not accept any parameters; base-10 is assumed");
  29811. }
  29812. }
  29813. else if (arguments[0] === 16) {
  29814. logger.throwError("BigNumber.toString does not accept any parameters; use bigNumber.toHexString()", logger_1.Logger.errors.UNEXPECTED_ARGUMENT, {});
  29815. }
  29816. else {
  29817. logger.throwError("BigNumber.toString does not accept parameters", logger_1.Logger.errors.UNEXPECTED_ARGUMENT, {});
  29818. }
  29819. }
  29820. return toBN(this).toString(10);
  29821. };
  29822. BigNumber.prototype.toHexString = function () {
  29823. return this._hex;
  29824. };
  29825. BigNumber.prototype.toJSON = function (key) {
  29826. return { type: "BigNumber", hex: this.toHexString() };
  29827. };
  29828. BigNumber.from = function (value) {
  29829. if (value instanceof BigNumber) {
  29830. return value;
  29831. }
  29832. if (typeof (value) === "string") {
  29833. if (value.match(/^-?0x[0-9a-f]+$/i)) {
  29834. return new BigNumber(_constructorGuard, toHex(value));
  29835. }
  29836. if (value.match(/^-?[0-9]+$/)) {
  29837. return new BigNumber(_constructorGuard, toHex(new BN(value)));
  29838. }
  29839. return logger.throwArgumentError("invalid BigNumber string", "value", value);
  29840. }
  29841. if (typeof (value) === "number") {
  29842. if (value % 1) {
  29843. throwFault("underflow", "BigNumber.from", value);
  29844. }
  29845. if (value >= MAX_SAFE || value <= -MAX_SAFE) {
  29846. throwFault("overflow", "BigNumber.from", value);
  29847. }
  29848. return BigNumber.from(String(value));
  29849. }
  29850. var anyValue = value;
  29851. if (typeof (anyValue) === "bigint") {
  29852. return BigNumber.from(anyValue.toString());
  29853. }
  29854. if ((0, bytes_1.isBytes)(anyValue)) {
  29855. return BigNumber.from((0, bytes_1.hexlify)(anyValue));
  29856. }
  29857. if (anyValue) {
  29858. // Hexable interface (takes priority)
  29859. if (anyValue.toHexString) {
  29860. var hex = anyValue.toHexString();
  29861. if (typeof (hex) === "string") {
  29862. return BigNumber.from(hex);
  29863. }
  29864. }
  29865. else {
  29866. // For now, handle legacy JSON-ified values (goes away in v6)
  29867. var hex = anyValue._hex;
  29868. // New-form JSON
  29869. if (hex == null && anyValue.type === "BigNumber") {
  29870. hex = anyValue.hex;
  29871. }
  29872. if (typeof (hex) === "string") {
  29873. if ((0, bytes_1.isHexString)(hex) || (hex[0] === "-" && (0, bytes_1.isHexString)(hex.substring(1)))) {
  29874. return BigNumber.from(hex);
  29875. }
  29876. }
  29877. }
  29878. }
  29879. return logger.throwArgumentError("invalid BigNumber value", "value", value);
  29880. };
  29881. BigNumber.isBigNumber = function (value) {
  29882. return !!(value && value._isBigNumber);
  29883. };
  29884. return BigNumber;
  29885. }());
  29886. exports.BigNumber = BigNumber;
  29887. // Normalize the hex string
  29888. function toHex(value) {
  29889. // For BN, call on the hex string
  29890. if (typeof (value) !== "string") {
  29891. return toHex(value.toString(16));
  29892. }
  29893. // If negative, prepend the negative sign to the normalized positive value
  29894. if (value[0] === "-") {
  29895. // Strip off the negative sign
  29896. value = value.substring(1);
  29897. // Cannot have multiple negative signs (e.g. "--0x04")
  29898. if (value[0] === "-") {
  29899. logger.throwArgumentError("invalid hex", "value", value);
  29900. }
  29901. // Call toHex on the positive component
  29902. value = toHex(value);
  29903. // Do not allow "-0x00"
  29904. if (value === "0x00") {
  29905. return value;
  29906. }
  29907. // Negate the value
  29908. return "-" + value;
  29909. }
  29910. // Add a "0x" prefix if missing
  29911. if (value.substring(0, 2) !== "0x") {
  29912. value = "0x" + value;
  29913. }
  29914. // Normalize zero
  29915. if (value === "0x") {
  29916. return "0x00";
  29917. }
  29918. // Make the string even length
  29919. if (value.length % 2) {
  29920. value = "0x0" + value.substring(2);
  29921. }
  29922. // Trim to smallest even-length string
  29923. while (value.length > 4 && value.substring(0, 4) === "0x00") {
  29924. value = "0x" + value.substring(4);
  29925. }
  29926. return value;
  29927. }
  29928. function toBigNumber(value) {
  29929. return BigNumber.from(toHex(value));
  29930. }
  29931. function toBN(value) {
  29932. var hex = BigNumber.from(value).toHexString();
  29933. if (hex[0] === "-") {
  29934. return (new BN("-" + hex.substring(3), 16));
  29935. }
  29936. return new BN(hex.substring(2), 16);
  29937. }
  29938. function throwFault(fault, operation, value) {
  29939. var params = { fault: fault, operation: operation };
  29940. if (value != null) {
  29941. params.value = value;
  29942. }
  29943. return logger.throwError(fault, logger_1.Logger.errors.NUMERIC_FAULT, params);
  29944. }
  29945. // value should have no prefix
  29946. function _base36To16(value) {
  29947. return (new BN(value, 36)).toString(16);
  29948. }
  29949. exports._base36To16 = _base36To16;
  29950. // value should have no prefix
  29951. function _base16To36(value) {
  29952. return (new BN(value, 16)).toString(36);
  29953. }
  29954. exports._base16To36 = _base16To36;
  29955. },{"./_version":193,"@ethersproject/bytes":199,"@ethersproject/logger":223,"bn.js":197}],195:[function(_dereq_,module,exports){
  29956. "use strict";
  29957. Object.defineProperty(exports, "__esModule", { value: true });
  29958. exports.FixedNumber = exports.FixedFormat = exports.parseFixed = exports.formatFixed = void 0;
  29959. var bytes_1 = _dereq_("@ethersproject/bytes");
  29960. var logger_1 = _dereq_("@ethersproject/logger");
  29961. var _version_1 = _dereq_("./_version");
  29962. var logger = new logger_1.Logger(_version_1.version);
  29963. var bignumber_1 = _dereq_("./bignumber");
  29964. var _constructorGuard = {};
  29965. var Zero = bignumber_1.BigNumber.from(0);
  29966. var NegativeOne = bignumber_1.BigNumber.from(-1);
  29967. function throwFault(message, fault, operation, value) {
  29968. var params = { fault: fault, operation: operation };
  29969. if (value !== undefined) {
  29970. params.value = value;
  29971. }
  29972. return logger.throwError(message, logger_1.Logger.errors.NUMERIC_FAULT, params);
  29973. }
  29974. // Constant to pull zeros from for multipliers
  29975. var zeros = "0";
  29976. while (zeros.length < 256) {
  29977. zeros += zeros;
  29978. }
  29979. // Returns a string "1" followed by decimal "0"s
  29980. function getMultiplier(decimals) {
  29981. if (typeof (decimals) !== "number") {
  29982. try {
  29983. decimals = bignumber_1.BigNumber.from(decimals).toNumber();
  29984. }
  29985. catch (e) { }
  29986. }
  29987. if (typeof (decimals) === "number" && decimals >= 0 && decimals <= 256 && !(decimals % 1)) {
  29988. return ("1" + zeros.substring(0, decimals));
  29989. }
  29990. return logger.throwArgumentError("invalid decimal size", "decimals", decimals);
  29991. }
  29992. function formatFixed(value, decimals) {
  29993. if (decimals == null) {
  29994. decimals = 0;
  29995. }
  29996. var multiplier = getMultiplier(decimals);
  29997. // Make sure wei is a big number (convert as necessary)
  29998. value = bignumber_1.BigNumber.from(value);
  29999. var negative = value.lt(Zero);
  30000. if (negative) {
  30001. value = value.mul(NegativeOne);
  30002. }
  30003. var fraction = value.mod(multiplier).toString();
  30004. while (fraction.length < multiplier.length - 1) {
  30005. fraction = "0" + fraction;
  30006. }
  30007. // Strip training 0
  30008. fraction = fraction.match(/^([0-9]*[1-9]|0)(0*)/)[1];
  30009. var whole = value.div(multiplier).toString();
  30010. if (multiplier.length === 1) {
  30011. value = whole;
  30012. }
  30013. else {
  30014. value = whole + "." + fraction;
  30015. }
  30016. if (negative) {
  30017. value = "-" + value;
  30018. }
  30019. return value;
  30020. }
  30021. exports.formatFixed = formatFixed;
  30022. function parseFixed(value, decimals) {
  30023. if (decimals == null) {
  30024. decimals = 0;
  30025. }
  30026. var multiplier = getMultiplier(decimals);
  30027. if (typeof (value) !== "string" || !value.match(/^-?[0-9.]+$/)) {
  30028. logger.throwArgumentError("invalid decimal value", "value", value);
  30029. }
  30030. // Is it negative?
  30031. var negative = (value.substring(0, 1) === "-");
  30032. if (negative) {
  30033. value = value.substring(1);
  30034. }
  30035. if (value === ".") {
  30036. logger.throwArgumentError("missing value", "value", value);
  30037. }
  30038. // Split it into a whole and fractional part
  30039. var comps = value.split(".");
  30040. if (comps.length > 2) {
  30041. logger.throwArgumentError("too many decimal points", "value", value);
  30042. }
  30043. var whole = comps[0], fraction = comps[1];
  30044. if (!whole) {
  30045. whole = "0";
  30046. }
  30047. if (!fraction) {
  30048. fraction = "0";
  30049. }
  30050. // Trim trailing zeros
  30051. while (fraction[fraction.length - 1] === "0") {
  30052. fraction = fraction.substring(0, fraction.length - 1);
  30053. }
  30054. // Check the fraction doesn't exceed our decimals size
  30055. if (fraction.length > multiplier.length - 1) {
  30056. throwFault("fractional component exceeds decimals", "underflow", "parseFixed");
  30057. }
  30058. // If decimals is 0, we have an empty string for fraction
  30059. if (fraction === "") {
  30060. fraction = "0";
  30061. }
  30062. // Fully pad the string with zeros to get to wei
  30063. while (fraction.length < multiplier.length - 1) {
  30064. fraction += "0";
  30065. }
  30066. var wholeValue = bignumber_1.BigNumber.from(whole);
  30067. var fractionValue = bignumber_1.BigNumber.from(fraction);
  30068. var wei = (wholeValue.mul(multiplier)).add(fractionValue);
  30069. if (negative) {
  30070. wei = wei.mul(NegativeOne);
  30071. }
  30072. return wei;
  30073. }
  30074. exports.parseFixed = parseFixed;
  30075. var FixedFormat = /** @class */ (function () {
  30076. function FixedFormat(constructorGuard, signed, width, decimals) {
  30077. if (constructorGuard !== _constructorGuard) {
  30078. logger.throwError("cannot use FixedFormat constructor; use FixedFormat.from", logger_1.Logger.errors.UNSUPPORTED_OPERATION, {
  30079. operation: "new FixedFormat"
  30080. });
  30081. }
  30082. this.signed = signed;
  30083. this.width = width;
  30084. this.decimals = decimals;
  30085. this.name = (signed ? "" : "u") + "fixed" + String(width) + "x" + String(decimals);
  30086. this._multiplier = getMultiplier(decimals);
  30087. Object.freeze(this);
  30088. }
  30089. FixedFormat.from = function (value) {
  30090. if (value instanceof FixedFormat) {
  30091. return value;
  30092. }
  30093. if (typeof (value) === "number") {
  30094. value = "fixed128x" + value;
  30095. }
  30096. var signed = true;
  30097. var width = 128;
  30098. var decimals = 18;
  30099. if (typeof (value) === "string") {
  30100. if (value === "fixed") {
  30101. // defaults...
  30102. }
  30103. else if (value === "ufixed") {
  30104. signed = false;
  30105. }
  30106. else {
  30107. var match = value.match(/^(u?)fixed([0-9]+)x([0-9]+)$/);
  30108. if (!match) {
  30109. logger.throwArgumentError("invalid fixed format", "format", value);
  30110. }
  30111. signed = (match[1] !== "u");
  30112. width = parseInt(match[2]);
  30113. decimals = parseInt(match[3]);
  30114. }
  30115. }
  30116. else if (value) {
  30117. var check = function (key, type, defaultValue) {
  30118. if (value[key] == null) {
  30119. return defaultValue;
  30120. }
  30121. if (typeof (value[key]) !== type) {
  30122. logger.throwArgumentError("invalid fixed format (" + key + " not " + type + ")", "format." + key, value[key]);
  30123. }
  30124. return value[key];
  30125. };
  30126. signed = check("signed", "boolean", signed);
  30127. width = check("width", "number", width);
  30128. decimals = check("decimals", "number", decimals);
  30129. }
  30130. if (width % 8) {
  30131. logger.throwArgumentError("invalid fixed format width (not byte aligned)", "format.width", width);
  30132. }
  30133. if (decimals > 80) {
  30134. logger.throwArgumentError("invalid fixed format (decimals too large)", "format.decimals", decimals);
  30135. }
  30136. return new FixedFormat(_constructorGuard, signed, width, decimals);
  30137. };
  30138. return FixedFormat;
  30139. }());
  30140. exports.FixedFormat = FixedFormat;
  30141. var FixedNumber = /** @class */ (function () {
  30142. function FixedNumber(constructorGuard, hex, value, format) {
  30143. var _newTarget = this.constructor;
  30144. logger.checkNew(_newTarget, FixedNumber);
  30145. if (constructorGuard !== _constructorGuard) {
  30146. logger.throwError("cannot use FixedNumber constructor; use FixedNumber.from", logger_1.Logger.errors.UNSUPPORTED_OPERATION, {
  30147. operation: "new FixedFormat"
  30148. });
  30149. }
  30150. this.format = format;
  30151. this._hex = hex;
  30152. this._value = value;
  30153. this._isFixedNumber = true;
  30154. Object.freeze(this);
  30155. }
  30156. FixedNumber.prototype._checkFormat = function (other) {
  30157. if (this.format.name !== other.format.name) {
  30158. logger.throwArgumentError("incompatible format; use fixedNumber.toFormat", "other", other);
  30159. }
  30160. };
  30161. FixedNumber.prototype.addUnsafe = function (other) {
  30162. this._checkFormat(other);
  30163. var a = parseFixed(this._value, this.format.decimals);
  30164. var b = parseFixed(other._value, other.format.decimals);
  30165. return FixedNumber.fromValue(a.add(b), this.format.decimals, this.format);
  30166. };
  30167. FixedNumber.prototype.subUnsafe = function (other) {
  30168. this._checkFormat(other);
  30169. var a = parseFixed(this._value, this.format.decimals);
  30170. var b = parseFixed(other._value, other.format.decimals);
  30171. return FixedNumber.fromValue(a.sub(b), this.format.decimals, this.format);
  30172. };
  30173. FixedNumber.prototype.mulUnsafe = function (other) {
  30174. this._checkFormat(other);
  30175. var a = parseFixed(this._value, this.format.decimals);
  30176. var b = parseFixed(other._value, other.format.decimals);
  30177. return FixedNumber.fromValue(a.mul(b).div(this.format._multiplier), this.format.decimals, this.format);
  30178. };
  30179. FixedNumber.prototype.divUnsafe = function (other) {
  30180. this._checkFormat(other);
  30181. var a = parseFixed(this._value, this.format.decimals);
  30182. var b = parseFixed(other._value, other.format.decimals);
  30183. return FixedNumber.fromValue(a.mul(this.format._multiplier).div(b), this.format.decimals, this.format);
  30184. };
  30185. FixedNumber.prototype.floor = function () {
  30186. var comps = this.toString().split(".");
  30187. if (comps.length === 1) {
  30188. comps.push("0");
  30189. }
  30190. var result = FixedNumber.from(comps[0], this.format);
  30191. var hasFraction = !comps[1].match(/^(0*)$/);
  30192. if (this.isNegative() && hasFraction) {
  30193. result = result.subUnsafe(ONE.toFormat(result.format));
  30194. }
  30195. return result;
  30196. };
  30197. FixedNumber.prototype.ceiling = function () {
  30198. var comps = this.toString().split(".");
  30199. if (comps.length === 1) {
  30200. comps.push("0");
  30201. }
  30202. var result = FixedNumber.from(comps[0], this.format);
  30203. var hasFraction = !comps[1].match(/^(0*)$/);
  30204. if (!this.isNegative() && hasFraction) {
  30205. result = result.addUnsafe(ONE.toFormat(result.format));
  30206. }
  30207. return result;
  30208. };
  30209. // @TODO: Support other rounding algorithms
  30210. FixedNumber.prototype.round = function (decimals) {
  30211. if (decimals == null) {
  30212. decimals = 0;
  30213. }
  30214. // If we are already in range, we're done
  30215. var comps = this.toString().split(".");
  30216. if (comps.length === 1) {
  30217. comps.push("0");
  30218. }
  30219. if (decimals < 0 || decimals > 80 || (decimals % 1)) {
  30220. logger.throwArgumentError("invalid decimal count", "decimals", decimals);
  30221. }
  30222. if (comps[1].length <= decimals) {
  30223. return this;
  30224. }
  30225. var factor = FixedNumber.from("1" + zeros.substring(0, decimals), this.format);
  30226. var bump = BUMP.toFormat(this.format);
  30227. return this.mulUnsafe(factor).addUnsafe(bump).floor().divUnsafe(factor);
  30228. };
  30229. FixedNumber.prototype.isZero = function () {
  30230. return (this._value === "0.0" || this._value === "0");
  30231. };
  30232. FixedNumber.prototype.isNegative = function () {
  30233. return (this._value[0] === "-");
  30234. };
  30235. FixedNumber.prototype.toString = function () { return this._value; };
  30236. FixedNumber.prototype.toHexString = function (width) {
  30237. if (width == null) {
  30238. return this._hex;
  30239. }
  30240. if (width % 8) {
  30241. logger.throwArgumentError("invalid byte width", "width", width);
  30242. }
  30243. var hex = bignumber_1.BigNumber.from(this._hex).fromTwos(this.format.width).toTwos(width).toHexString();
  30244. return (0, bytes_1.hexZeroPad)(hex, width / 8);
  30245. };
  30246. FixedNumber.prototype.toUnsafeFloat = function () { return parseFloat(this.toString()); };
  30247. FixedNumber.prototype.toFormat = function (format) {
  30248. return FixedNumber.fromString(this._value, format);
  30249. };
  30250. FixedNumber.fromValue = function (value, decimals, format) {
  30251. // If decimals looks more like a format, and there is no format, shift the parameters
  30252. if (format == null && decimals != null && !(0, bignumber_1.isBigNumberish)(decimals)) {
  30253. format = decimals;
  30254. decimals = null;
  30255. }
  30256. if (decimals == null) {
  30257. decimals = 0;
  30258. }
  30259. if (format == null) {
  30260. format = "fixed";
  30261. }
  30262. return FixedNumber.fromString(formatFixed(value, decimals), FixedFormat.from(format));
  30263. };
  30264. FixedNumber.fromString = function (value, format) {
  30265. if (format == null) {
  30266. format = "fixed";
  30267. }
  30268. var fixedFormat = FixedFormat.from(format);
  30269. var numeric = parseFixed(value, fixedFormat.decimals);
  30270. if (!fixedFormat.signed && numeric.lt(Zero)) {
  30271. throwFault("unsigned value cannot be negative", "overflow", "value", value);
  30272. }
  30273. var hex = null;
  30274. if (fixedFormat.signed) {
  30275. hex = numeric.toTwos(fixedFormat.width).toHexString();
  30276. }
  30277. else {
  30278. hex = numeric.toHexString();
  30279. hex = (0, bytes_1.hexZeroPad)(hex, fixedFormat.width / 8);
  30280. }
  30281. var decimal = formatFixed(numeric, fixedFormat.decimals);
  30282. return new FixedNumber(_constructorGuard, hex, decimal, fixedFormat);
  30283. };
  30284. FixedNumber.fromBytes = function (value, format) {
  30285. if (format == null) {
  30286. format = "fixed";
  30287. }
  30288. var fixedFormat = FixedFormat.from(format);
  30289. if ((0, bytes_1.arrayify)(value).length > fixedFormat.width / 8) {
  30290. throw new Error("overflow");
  30291. }
  30292. var numeric = bignumber_1.BigNumber.from(value);
  30293. if (fixedFormat.signed) {
  30294. numeric = numeric.fromTwos(fixedFormat.width);
  30295. }
  30296. var hex = numeric.toTwos((fixedFormat.signed ? 0 : 1) + fixedFormat.width).toHexString();
  30297. var decimal = formatFixed(numeric, fixedFormat.decimals);
  30298. return new FixedNumber(_constructorGuard, hex, decimal, fixedFormat);
  30299. };
  30300. FixedNumber.from = function (value, format) {
  30301. if (typeof (value) === "string") {
  30302. return FixedNumber.fromString(value, format);
  30303. }
  30304. if ((0, bytes_1.isBytes)(value)) {
  30305. return FixedNumber.fromBytes(value, format);
  30306. }
  30307. try {
  30308. return FixedNumber.fromValue(value, 0, format);
  30309. }
  30310. catch (error) {
  30311. // Allow NUMERIC_FAULT to bubble up
  30312. if (error.code !== logger_1.Logger.errors.INVALID_ARGUMENT) {
  30313. throw error;
  30314. }
  30315. }
  30316. return logger.throwArgumentError("invalid FixedNumber value", "value", value);
  30317. };
  30318. FixedNumber.isFixedNumber = function (value) {
  30319. return !!(value && value._isFixedNumber);
  30320. };
  30321. return FixedNumber;
  30322. }());
  30323. exports.FixedNumber = FixedNumber;
  30324. var ONE = FixedNumber.from(1);
  30325. var BUMP = FixedNumber.from("0.5");
  30326. },{"./_version":193,"./bignumber":194,"@ethersproject/bytes":199,"@ethersproject/logger":223}],196:[function(_dereq_,module,exports){
  30327. "use strict";
  30328. Object.defineProperty(exports, "__esModule", { value: true });
  30329. exports._base36To16 = exports._base16To36 = exports.parseFixed = exports.FixedNumber = exports.FixedFormat = exports.formatFixed = exports.BigNumber = void 0;
  30330. var bignumber_1 = _dereq_("./bignumber");
  30331. Object.defineProperty(exports, "BigNumber", { enumerable: true, get: function () { return bignumber_1.BigNumber; } });
  30332. var fixednumber_1 = _dereq_("./fixednumber");
  30333. Object.defineProperty(exports, "formatFixed", { enumerable: true, get: function () { return fixednumber_1.formatFixed; } });
  30334. Object.defineProperty(exports, "FixedFormat", { enumerable: true, get: function () { return fixednumber_1.FixedFormat; } });
  30335. Object.defineProperty(exports, "FixedNumber", { enumerable: true, get: function () { return fixednumber_1.FixedNumber; } });
  30336. Object.defineProperty(exports, "parseFixed", { enumerable: true, get: function () { return fixednumber_1.parseFixed; } });
  30337. // Internal methods used by address
  30338. var bignumber_2 = _dereq_("./bignumber");
  30339. Object.defineProperty(exports, "_base16To36", { enumerable: true, get: function () { return bignumber_2._base16To36; } });
  30340. Object.defineProperty(exports, "_base36To16", { enumerable: true, get: function () { return bignumber_2._base36To16; } });
  30341. },{"./bignumber":194,"./fixednumber":195}],197:[function(_dereq_,module,exports){
  30342. (function (module, exports) {
  30343. 'use strict';
  30344. // Utils
  30345. function assert (val, msg) {
  30346. if (!val) throw new Error(msg || 'Assertion failed');
  30347. }
  30348. // Could use `inherits` module, but don't want to move from single file
  30349. // architecture yet.
  30350. function inherits (ctor, superCtor) {
  30351. ctor.super_ = superCtor;
  30352. var TempCtor = function () {};
  30353. TempCtor.prototype = superCtor.prototype;
  30354. ctor.prototype = new TempCtor();
  30355. ctor.prototype.constructor = ctor;
  30356. }
  30357. // BN
  30358. function BN (number, base, endian) {
  30359. if (BN.isBN(number)) {
  30360. return number;
  30361. }
  30362. this.negative = 0;
  30363. this.words = null;
  30364. this.length = 0;
  30365. // Reduction context
  30366. this.red = null;
  30367. if (number !== null) {
  30368. if (base === 'le' || base === 'be') {
  30369. endian = base;
  30370. base = 10;
  30371. }
  30372. this._init(number || 0, base || 10, endian || 'be');
  30373. }
  30374. }
  30375. if (typeof module === 'object') {
  30376. module.exports = BN;
  30377. } else {
  30378. exports.BN = BN;
  30379. }
  30380. BN.BN = BN;
  30381. BN.wordSize = 26;
  30382. var Buffer;
  30383. try {
  30384. if (typeof window !== 'undefined' && typeof window.Buffer !== 'undefined') {
  30385. Buffer = window.Buffer;
  30386. } else {
  30387. Buffer = _dereq_('buffer').Buffer;
  30388. }
  30389. } catch (e) {
  30390. }
  30391. BN.isBN = function isBN (num) {
  30392. if (num instanceof BN) {
  30393. return true;
  30394. }
  30395. return num !== null && typeof num === 'object' &&
  30396. num.constructor.wordSize === BN.wordSize && Array.isArray(num.words);
  30397. };
  30398. BN.max = function max (left, right) {
  30399. if (left.cmp(right) > 0) return left;
  30400. return right;
  30401. };
  30402. BN.min = function min (left, right) {
  30403. if (left.cmp(right) < 0) return left;
  30404. return right;
  30405. };
  30406. BN.prototype._init = function init (number, base, endian) {
  30407. if (typeof number === 'number') {
  30408. return this._initNumber(number, base, endian);
  30409. }
  30410. if (typeof number === 'object') {
  30411. return this._initArray(number, base, endian);
  30412. }
  30413. if (base === 'hex') {
  30414. base = 16;
  30415. }
  30416. assert(base === (base | 0) && base >= 2 && base <= 36);
  30417. number = number.toString().replace(/\s+/g, '');
  30418. var start = 0;
  30419. if (number[0] === '-') {
  30420. start++;
  30421. this.negative = 1;
  30422. }
  30423. if (start < number.length) {
  30424. if (base === 16) {
  30425. this._parseHex(number, start, endian);
  30426. } else {
  30427. this._parseBase(number, base, start);
  30428. if (endian === 'le') {
  30429. this._initArray(this.toArray(), base, endian);
  30430. }
  30431. }
  30432. }
  30433. };
  30434. BN.prototype._initNumber = function _initNumber (number, base, endian) {
  30435. if (number < 0) {
  30436. this.negative = 1;
  30437. number = -number;
  30438. }
  30439. if (number < 0x4000000) {
  30440. this.words = [ number & 0x3ffffff ];
  30441. this.length = 1;
  30442. } else if (number < 0x10000000000000) {
  30443. this.words = [
  30444. number & 0x3ffffff,
  30445. (number / 0x4000000) & 0x3ffffff
  30446. ];
  30447. this.length = 2;
  30448. } else {
  30449. assert(number < 0x20000000000000); // 2 ^ 53 (unsafe)
  30450. this.words = [
  30451. number & 0x3ffffff,
  30452. (number / 0x4000000) & 0x3ffffff,
  30453. 1
  30454. ];
  30455. this.length = 3;
  30456. }
  30457. if (endian !== 'le') return;
  30458. // Reverse the bytes
  30459. this._initArray(this.toArray(), base, endian);
  30460. };
  30461. BN.prototype._initArray = function _initArray (number, base, endian) {
  30462. // Perhaps a Uint8Array
  30463. assert(typeof number.length === 'number');
  30464. if (number.length <= 0) {
  30465. this.words = [ 0 ];
  30466. this.length = 1;
  30467. return this;
  30468. }
  30469. this.length = Math.ceil(number.length / 3);
  30470. this.words = new Array(this.length);
  30471. for (var i = 0; i < this.length; i++) {
  30472. this.words[i] = 0;
  30473. }
  30474. var j, w;
  30475. var off = 0;
  30476. if (endian === 'be') {
  30477. for (i = number.length - 1, j = 0; i >= 0; i -= 3) {
  30478. w = number[i] | (number[i - 1] << 8) | (number[i - 2] << 16);
  30479. this.words[j] |= (w << off) & 0x3ffffff;
  30480. this.words[j + 1] = (w >>> (26 - off)) & 0x3ffffff;
  30481. off += 24;
  30482. if (off >= 26) {
  30483. off -= 26;
  30484. j++;
  30485. }
  30486. }
  30487. } else if (endian === 'le') {
  30488. for (i = 0, j = 0; i < number.length; i += 3) {
  30489. w = number[i] | (number[i + 1] << 8) | (number[i + 2] << 16);
  30490. this.words[j] |= (w << off) & 0x3ffffff;
  30491. this.words[j + 1] = (w >>> (26 - off)) & 0x3ffffff;
  30492. off += 24;
  30493. if (off >= 26) {
  30494. off -= 26;
  30495. j++;
  30496. }
  30497. }
  30498. }
  30499. return this.strip();
  30500. };
  30501. function parseHex4Bits (string, index) {
  30502. var c = string.charCodeAt(index);
  30503. // 'A' - 'F'
  30504. if (c >= 65 && c <= 70) {
  30505. return c - 55;
  30506. // 'a' - 'f'
  30507. } else if (c >= 97 && c <= 102) {
  30508. return c - 87;
  30509. // '0' - '9'
  30510. } else {
  30511. return (c - 48) & 0xf;
  30512. }
  30513. }
  30514. function parseHexByte (string, lowerBound, index) {
  30515. var r = parseHex4Bits(string, index);
  30516. if (index - 1 >= lowerBound) {
  30517. r |= parseHex4Bits(string, index - 1) << 4;
  30518. }
  30519. return r;
  30520. }
  30521. BN.prototype._parseHex = function _parseHex (number, start, endian) {
  30522. // Create possibly bigger array to ensure that it fits the number
  30523. this.length = Math.ceil((number.length - start) / 6);
  30524. this.words = new Array(this.length);
  30525. for (var i = 0; i < this.length; i++) {
  30526. this.words[i] = 0;
  30527. }
  30528. // 24-bits chunks
  30529. var off = 0;
  30530. var j = 0;
  30531. var w;
  30532. if (endian === 'be') {
  30533. for (i = number.length - 1; i >= start; i -= 2) {
  30534. w = parseHexByte(number, start, i) << off;
  30535. this.words[j] |= w & 0x3ffffff;
  30536. if (off >= 18) {
  30537. off -= 18;
  30538. j += 1;
  30539. this.words[j] |= w >>> 26;
  30540. } else {
  30541. off += 8;
  30542. }
  30543. }
  30544. } else {
  30545. var parseLength = number.length - start;
  30546. for (i = parseLength % 2 === 0 ? start + 1 : start; i < number.length; i += 2) {
  30547. w = parseHexByte(number, start, i) << off;
  30548. this.words[j] |= w & 0x3ffffff;
  30549. if (off >= 18) {
  30550. off -= 18;
  30551. j += 1;
  30552. this.words[j] |= w >>> 26;
  30553. } else {
  30554. off += 8;
  30555. }
  30556. }
  30557. }
  30558. this.strip();
  30559. };
  30560. function parseBase (str, start, end, mul) {
  30561. var r = 0;
  30562. var len = Math.min(str.length, end);
  30563. for (var i = start; i < len; i++) {
  30564. var c = str.charCodeAt(i) - 48;
  30565. r *= mul;
  30566. // 'a'
  30567. if (c >= 49) {
  30568. r += c - 49 + 0xa;
  30569. // 'A'
  30570. } else if (c >= 17) {
  30571. r += c - 17 + 0xa;
  30572. // '0' - '9'
  30573. } else {
  30574. r += c;
  30575. }
  30576. }
  30577. return r;
  30578. }
  30579. BN.prototype._parseBase = function _parseBase (number, base, start) {
  30580. // Initialize as zero
  30581. this.words = [ 0 ];
  30582. this.length = 1;
  30583. // Find length of limb in base
  30584. for (var limbLen = 0, limbPow = 1; limbPow <= 0x3ffffff; limbPow *= base) {
  30585. limbLen++;
  30586. }
  30587. limbLen--;
  30588. limbPow = (limbPow / base) | 0;
  30589. var total = number.length - start;
  30590. var mod = total % limbLen;
  30591. var end = Math.min(total, total - mod) + start;
  30592. var word = 0;
  30593. for (var i = start; i < end; i += limbLen) {
  30594. word = parseBase(number, i, i + limbLen, base);
  30595. this.imuln(limbPow);
  30596. if (this.words[0] + word < 0x4000000) {
  30597. this.words[0] += word;
  30598. } else {
  30599. this._iaddn(word);
  30600. }
  30601. }
  30602. if (mod !== 0) {
  30603. var pow = 1;
  30604. word = parseBase(number, i, number.length, base);
  30605. for (i = 0; i < mod; i++) {
  30606. pow *= base;
  30607. }
  30608. this.imuln(pow);
  30609. if (this.words[0] + word < 0x4000000) {
  30610. this.words[0] += word;
  30611. } else {
  30612. this._iaddn(word);
  30613. }
  30614. }
  30615. this.strip();
  30616. };
  30617. BN.prototype.copy = function copy (dest) {
  30618. dest.words = new Array(this.length);
  30619. for (var i = 0; i < this.length; i++) {
  30620. dest.words[i] = this.words[i];
  30621. }
  30622. dest.length = this.length;
  30623. dest.negative = this.negative;
  30624. dest.red = this.red;
  30625. };
  30626. BN.prototype.clone = function clone () {
  30627. var r = new BN(null);
  30628. this.copy(r);
  30629. return r;
  30630. };
  30631. BN.prototype._expand = function _expand (size) {
  30632. while (this.length < size) {
  30633. this.words[this.length++] = 0;
  30634. }
  30635. return this;
  30636. };
  30637. // Remove leading `0` from `this`
  30638. BN.prototype.strip = function strip () {
  30639. while (this.length > 1 && this.words[this.length - 1] === 0) {
  30640. this.length--;
  30641. }
  30642. return this._normSign();
  30643. };
  30644. BN.prototype._normSign = function _normSign () {
  30645. // -0 = 0
  30646. if (this.length === 1 && this.words[0] === 0) {
  30647. this.negative = 0;
  30648. }
  30649. return this;
  30650. };
  30651. BN.prototype.inspect = function inspect () {
  30652. return (this.red ? '<BN-R: ' : '<BN: ') + this.toString(16) + '>';
  30653. };
  30654. /*
  30655. var zeros = [];
  30656. var groupSizes = [];
  30657. var groupBases = [];
  30658. var s = '';
  30659. var i = -1;
  30660. while (++i < BN.wordSize) {
  30661. zeros[i] = s;
  30662. s += '0';
  30663. }
  30664. groupSizes[0] = 0;
  30665. groupSizes[1] = 0;
  30666. groupBases[0] = 0;
  30667. groupBases[1] = 0;
  30668. var base = 2 - 1;
  30669. while (++base < 36 + 1) {
  30670. var groupSize = 0;
  30671. var groupBase = 1;
  30672. while (groupBase < (1 << BN.wordSize) / base) {
  30673. groupBase *= base;
  30674. groupSize += 1;
  30675. }
  30676. groupSizes[base] = groupSize;
  30677. groupBases[base] = groupBase;
  30678. }
  30679. */
  30680. var zeros = [
  30681. '',
  30682. '0',
  30683. '00',
  30684. '000',
  30685. '0000',
  30686. '00000',
  30687. '000000',
  30688. '0000000',
  30689. '00000000',
  30690. '000000000',
  30691. '0000000000',
  30692. '00000000000',
  30693. '000000000000',
  30694. '0000000000000',
  30695. '00000000000000',
  30696. '000000000000000',
  30697. '0000000000000000',
  30698. '00000000000000000',
  30699. '000000000000000000',
  30700. '0000000000000000000',
  30701. '00000000000000000000',
  30702. '000000000000000000000',
  30703. '0000000000000000000000',
  30704. '00000000000000000000000',
  30705. '000000000000000000000000',
  30706. '0000000000000000000000000'
  30707. ];
  30708. var groupSizes = [
  30709. 0, 0,
  30710. 25, 16, 12, 11, 10, 9, 8,
  30711. 8, 7, 7, 7, 7, 6, 6,
  30712. 6, 6, 6, 6, 6, 5, 5,
  30713. 5, 5, 5, 5, 5, 5, 5,
  30714. 5, 5, 5, 5, 5, 5, 5
  30715. ];
  30716. var groupBases = [
  30717. 0, 0,
  30718. 33554432, 43046721, 16777216, 48828125, 60466176, 40353607, 16777216,
  30719. 43046721, 10000000, 19487171, 35831808, 62748517, 7529536, 11390625,
  30720. 16777216, 24137569, 34012224, 47045881, 64000000, 4084101, 5153632,
  30721. 6436343, 7962624, 9765625, 11881376, 14348907, 17210368, 20511149,
  30722. 24300000, 28629151, 33554432, 39135393, 45435424, 52521875, 60466176
  30723. ];
  30724. BN.prototype.toString = function toString (base, padding) {
  30725. base = base || 10;
  30726. padding = padding | 0 || 1;
  30727. var out;
  30728. if (base === 16 || base === 'hex') {
  30729. out = '';
  30730. var off = 0;
  30731. var carry = 0;
  30732. for (var i = 0; i < this.length; i++) {
  30733. var w = this.words[i];
  30734. var word = (((w << off) | carry) & 0xffffff).toString(16);
  30735. carry = (w >>> (24 - off)) & 0xffffff;
  30736. if (carry !== 0 || i !== this.length - 1) {
  30737. out = zeros[6 - word.length] + word + out;
  30738. } else {
  30739. out = word + out;
  30740. }
  30741. off += 2;
  30742. if (off >= 26) {
  30743. off -= 26;
  30744. i--;
  30745. }
  30746. }
  30747. if (carry !== 0) {
  30748. out = carry.toString(16) + out;
  30749. }
  30750. while (out.length % padding !== 0) {
  30751. out = '0' + out;
  30752. }
  30753. if (this.negative !== 0) {
  30754. out = '-' + out;
  30755. }
  30756. return out;
  30757. }
  30758. if (base === (base | 0) && base >= 2 && base <= 36) {
  30759. // var groupSize = Math.floor(BN.wordSize * Math.LN2 / Math.log(base));
  30760. var groupSize = groupSizes[base];
  30761. // var groupBase = Math.pow(base, groupSize);
  30762. var groupBase = groupBases[base];
  30763. out = '';
  30764. var c = this.clone();
  30765. c.negative = 0;
  30766. while (!c.isZero()) {
  30767. var r = c.modn(groupBase).toString(base);
  30768. c = c.idivn(groupBase);
  30769. if (!c.isZero()) {
  30770. out = zeros[groupSize - r.length] + r + out;
  30771. } else {
  30772. out = r + out;
  30773. }
  30774. }
  30775. if (this.isZero()) {
  30776. out = '0' + out;
  30777. }
  30778. while (out.length % padding !== 0) {
  30779. out = '0' + out;
  30780. }
  30781. if (this.negative !== 0) {
  30782. out = '-' + out;
  30783. }
  30784. return out;
  30785. }
  30786. assert(false, 'Base should be between 2 and 36');
  30787. };
  30788. BN.prototype.toNumber = function toNumber () {
  30789. var ret = this.words[0];
  30790. if (this.length === 2) {
  30791. ret += this.words[1] * 0x4000000;
  30792. } else if (this.length === 3 && this.words[2] === 0x01) {
  30793. // NOTE: at this stage it is known that the top bit is set
  30794. ret += 0x10000000000000 + (this.words[1] * 0x4000000);
  30795. } else if (this.length > 2) {
  30796. assert(false, 'Number can only safely store up to 53 bits');
  30797. }
  30798. return (this.negative !== 0) ? -ret : ret;
  30799. };
  30800. BN.prototype.toJSON = function toJSON () {
  30801. return this.toString(16);
  30802. };
  30803. BN.prototype.toBuffer = function toBuffer (endian, length) {
  30804. assert(typeof Buffer !== 'undefined');
  30805. return this.toArrayLike(Buffer, endian, length);
  30806. };
  30807. BN.prototype.toArray = function toArray (endian, length) {
  30808. return this.toArrayLike(Array, endian, length);
  30809. };
  30810. BN.prototype.toArrayLike = function toArrayLike (ArrayType, endian, length) {
  30811. var byteLength = this.byteLength();
  30812. var reqLength = length || Math.max(1, byteLength);
  30813. assert(byteLength <= reqLength, 'byte array longer than desired length');
  30814. assert(reqLength > 0, 'Requested array length <= 0');
  30815. this.strip();
  30816. var littleEndian = endian === 'le';
  30817. var res = new ArrayType(reqLength);
  30818. var b, i;
  30819. var q = this.clone();
  30820. if (!littleEndian) {
  30821. // Assume big-endian
  30822. for (i = 0; i < reqLength - byteLength; i++) {
  30823. res[i] = 0;
  30824. }
  30825. for (i = 0; !q.isZero(); i++) {
  30826. b = q.andln(0xff);
  30827. q.iushrn(8);
  30828. res[reqLength - i - 1] = b;
  30829. }
  30830. } else {
  30831. for (i = 0; !q.isZero(); i++) {
  30832. b = q.andln(0xff);
  30833. q.iushrn(8);
  30834. res[i] = b;
  30835. }
  30836. for (; i < reqLength; i++) {
  30837. res[i] = 0;
  30838. }
  30839. }
  30840. return res;
  30841. };
  30842. if (Math.clz32) {
  30843. BN.prototype._countBits = function _countBits (w) {
  30844. return 32 - Math.clz32(w);
  30845. };
  30846. } else {
  30847. BN.prototype._countBits = function _countBits (w) {
  30848. var t = w;
  30849. var r = 0;
  30850. if (t >= 0x1000) {
  30851. r += 13;
  30852. t >>>= 13;
  30853. }
  30854. if (t >= 0x40) {
  30855. r += 7;
  30856. t >>>= 7;
  30857. }
  30858. if (t >= 0x8) {
  30859. r += 4;
  30860. t >>>= 4;
  30861. }
  30862. if (t >= 0x02) {
  30863. r += 2;
  30864. t >>>= 2;
  30865. }
  30866. return r + t;
  30867. };
  30868. }
  30869. BN.prototype._zeroBits = function _zeroBits (w) {
  30870. // Short-cut
  30871. if (w === 0) return 26;
  30872. var t = w;
  30873. var r = 0;
  30874. if ((t & 0x1fff) === 0) {
  30875. r += 13;
  30876. t >>>= 13;
  30877. }
  30878. if ((t & 0x7f) === 0) {
  30879. r += 7;
  30880. t >>>= 7;
  30881. }
  30882. if ((t & 0xf) === 0) {
  30883. r += 4;
  30884. t >>>= 4;
  30885. }
  30886. if ((t & 0x3) === 0) {
  30887. r += 2;
  30888. t >>>= 2;
  30889. }
  30890. if ((t & 0x1) === 0) {
  30891. r++;
  30892. }
  30893. return r;
  30894. };
  30895. // Return number of used bits in a BN
  30896. BN.prototype.bitLength = function bitLength () {
  30897. var w = this.words[this.length - 1];
  30898. var hi = this._countBits(w);
  30899. return (this.length - 1) * 26 + hi;
  30900. };
  30901. function toBitArray (num) {
  30902. var w = new Array(num.bitLength());
  30903. for (var bit = 0; bit < w.length; bit++) {
  30904. var off = (bit / 26) | 0;
  30905. var wbit = bit % 26;
  30906. w[bit] = (num.words[off] & (1 << wbit)) >>> wbit;
  30907. }
  30908. return w;
  30909. }
  30910. // Number of trailing zero bits
  30911. BN.prototype.zeroBits = function zeroBits () {
  30912. if (this.isZero()) return 0;
  30913. var r = 0;
  30914. for (var i = 0; i < this.length; i++) {
  30915. var b = this._zeroBits(this.words[i]);
  30916. r += b;
  30917. if (b !== 26) break;
  30918. }
  30919. return r;
  30920. };
  30921. BN.prototype.byteLength = function byteLength () {
  30922. return Math.ceil(this.bitLength() / 8);
  30923. };
  30924. BN.prototype.toTwos = function toTwos (width) {
  30925. if (this.negative !== 0) {
  30926. return this.abs().inotn(width).iaddn(1);
  30927. }
  30928. return this.clone();
  30929. };
  30930. BN.prototype.fromTwos = function fromTwos (width) {
  30931. if (this.testn(width - 1)) {
  30932. return this.notn(width).iaddn(1).ineg();
  30933. }
  30934. return this.clone();
  30935. };
  30936. BN.prototype.isNeg = function isNeg () {
  30937. return this.negative !== 0;
  30938. };
  30939. // Return negative clone of `this`
  30940. BN.prototype.neg = function neg () {
  30941. return this.clone().ineg();
  30942. };
  30943. BN.prototype.ineg = function ineg () {
  30944. if (!this.isZero()) {
  30945. this.negative ^= 1;
  30946. }
  30947. return this;
  30948. };
  30949. // Or `num` with `this` in-place
  30950. BN.prototype.iuor = function iuor (num) {
  30951. while (this.length < num.length) {
  30952. this.words[this.length++] = 0;
  30953. }
  30954. for (var i = 0; i < num.length; i++) {
  30955. this.words[i] = this.words[i] | num.words[i];
  30956. }
  30957. return this.strip();
  30958. };
  30959. BN.prototype.ior = function ior (num) {
  30960. assert((this.negative | num.negative) === 0);
  30961. return this.iuor(num);
  30962. };
  30963. // Or `num` with `this`
  30964. BN.prototype.or = function or (num) {
  30965. if (this.length > num.length) return this.clone().ior(num);
  30966. return num.clone().ior(this);
  30967. };
  30968. BN.prototype.uor = function uor (num) {
  30969. if (this.length > num.length) return this.clone().iuor(num);
  30970. return num.clone().iuor(this);
  30971. };
  30972. // And `num` with `this` in-place
  30973. BN.prototype.iuand = function iuand (num) {
  30974. // b = min-length(num, this)
  30975. var b;
  30976. if (this.length > num.length) {
  30977. b = num;
  30978. } else {
  30979. b = this;
  30980. }
  30981. for (var i = 0; i < b.length; i++) {
  30982. this.words[i] = this.words[i] & num.words[i];
  30983. }
  30984. this.length = b.length;
  30985. return this.strip();
  30986. };
  30987. BN.prototype.iand = function iand (num) {
  30988. assert((this.negative | num.negative) === 0);
  30989. return this.iuand(num);
  30990. };
  30991. // And `num` with `this`
  30992. BN.prototype.and = function and (num) {
  30993. if (this.length > num.length) return this.clone().iand(num);
  30994. return num.clone().iand(this);
  30995. };
  30996. BN.prototype.uand = function uand (num) {
  30997. if (this.length > num.length) return this.clone().iuand(num);
  30998. return num.clone().iuand(this);
  30999. };
  31000. // Xor `num` with `this` in-place
  31001. BN.prototype.iuxor = function iuxor (num) {
  31002. // a.length > b.length
  31003. var a;
  31004. var b;
  31005. if (this.length > num.length) {
  31006. a = this;
  31007. b = num;
  31008. } else {
  31009. a = num;
  31010. b = this;
  31011. }
  31012. for (var i = 0; i < b.length; i++) {
  31013. this.words[i] = a.words[i] ^ b.words[i];
  31014. }
  31015. if (this !== a) {
  31016. for (; i < a.length; i++) {
  31017. this.words[i] = a.words[i];
  31018. }
  31019. }
  31020. this.length = a.length;
  31021. return this.strip();
  31022. };
  31023. BN.prototype.ixor = function ixor (num) {
  31024. assert((this.negative | num.negative) === 0);
  31025. return this.iuxor(num);
  31026. };
  31027. // Xor `num` with `this`
  31028. BN.prototype.xor = function xor (num) {
  31029. if (this.length > num.length) return this.clone().ixor(num);
  31030. return num.clone().ixor(this);
  31031. };
  31032. BN.prototype.uxor = function uxor (num) {
  31033. if (this.length > num.length) return this.clone().iuxor(num);
  31034. return num.clone().iuxor(this);
  31035. };
  31036. // Not ``this`` with ``width`` bitwidth
  31037. BN.prototype.inotn = function inotn (width) {
  31038. assert(typeof width === 'number' && width >= 0);
  31039. var bytesNeeded = Math.ceil(width / 26) | 0;
  31040. var bitsLeft = width % 26;
  31041. // Extend the buffer with leading zeroes
  31042. this._expand(bytesNeeded);
  31043. if (bitsLeft > 0) {
  31044. bytesNeeded--;
  31045. }
  31046. // Handle complete words
  31047. for (var i = 0; i < bytesNeeded; i++) {
  31048. this.words[i] = ~this.words[i] & 0x3ffffff;
  31049. }
  31050. // Handle the residue
  31051. if (bitsLeft > 0) {
  31052. this.words[i] = ~this.words[i] & (0x3ffffff >> (26 - bitsLeft));
  31053. }
  31054. // And remove leading zeroes
  31055. return this.strip();
  31056. };
  31057. BN.prototype.notn = function notn (width) {
  31058. return this.clone().inotn(width);
  31059. };
  31060. // Set `bit` of `this`
  31061. BN.prototype.setn = function setn (bit, val) {
  31062. assert(typeof bit === 'number' && bit >= 0);
  31063. var off = (bit / 26) | 0;
  31064. var wbit = bit % 26;
  31065. this._expand(off + 1);
  31066. if (val) {
  31067. this.words[off] = this.words[off] | (1 << wbit);
  31068. } else {
  31069. this.words[off] = this.words[off] & ~(1 << wbit);
  31070. }
  31071. return this.strip();
  31072. };
  31073. // Add `num` to `this` in-place
  31074. BN.prototype.iadd = function iadd (num) {
  31075. var r;
  31076. // negative + positive
  31077. if (this.negative !== 0 && num.negative === 0) {
  31078. this.negative = 0;
  31079. r = this.isub(num);
  31080. this.negative ^= 1;
  31081. return this._normSign();
  31082. // positive + negative
  31083. } else if (this.negative === 0 && num.negative !== 0) {
  31084. num.negative = 0;
  31085. r = this.isub(num);
  31086. num.negative = 1;
  31087. return r._normSign();
  31088. }
  31089. // a.length > b.length
  31090. var a, b;
  31091. if (this.length > num.length) {
  31092. a = this;
  31093. b = num;
  31094. } else {
  31095. a = num;
  31096. b = this;
  31097. }
  31098. var carry = 0;
  31099. for (var i = 0; i < b.length; i++) {
  31100. r = (a.words[i] | 0) + (b.words[i] | 0) + carry;
  31101. this.words[i] = r & 0x3ffffff;
  31102. carry = r >>> 26;
  31103. }
  31104. for (; carry !== 0 && i < a.length; i++) {
  31105. r = (a.words[i] | 0) + carry;
  31106. this.words[i] = r & 0x3ffffff;
  31107. carry = r >>> 26;
  31108. }
  31109. this.length = a.length;
  31110. if (carry !== 0) {
  31111. this.words[this.length] = carry;
  31112. this.length++;
  31113. // Copy the rest of the words
  31114. } else if (a !== this) {
  31115. for (; i < a.length; i++) {
  31116. this.words[i] = a.words[i];
  31117. }
  31118. }
  31119. return this;
  31120. };
  31121. // Add `num` to `this`
  31122. BN.prototype.add = function add (num) {
  31123. var res;
  31124. if (num.negative !== 0 && this.negative === 0) {
  31125. num.negative = 0;
  31126. res = this.sub(num);
  31127. num.negative ^= 1;
  31128. return res;
  31129. } else if (num.negative === 0 && this.negative !== 0) {
  31130. this.negative = 0;
  31131. res = num.sub(this);
  31132. this.negative = 1;
  31133. return res;
  31134. }
  31135. if (this.length > num.length) return this.clone().iadd(num);
  31136. return num.clone().iadd(this);
  31137. };
  31138. // Subtract `num` from `this` in-place
  31139. BN.prototype.isub = function isub (num) {
  31140. // this - (-num) = this + num
  31141. if (num.negative !== 0) {
  31142. num.negative = 0;
  31143. var r = this.iadd(num);
  31144. num.negative = 1;
  31145. return r._normSign();
  31146. // -this - num = -(this + num)
  31147. } else if (this.negative !== 0) {
  31148. this.negative = 0;
  31149. this.iadd(num);
  31150. this.negative = 1;
  31151. return this._normSign();
  31152. }
  31153. // At this point both numbers are positive
  31154. var cmp = this.cmp(num);
  31155. // Optimization - zeroify
  31156. if (cmp === 0) {
  31157. this.negative = 0;
  31158. this.length = 1;
  31159. this.words[0] = 0;
  31160. return this;
  31161. }
  31162. // a > b
  31163. var a, b;
  31164. if (cmp > 0) {
  31165. a = this;
  31166. b = num;
  31167. } else {
  31168. a = num;
  31169. b = this;
  31170. }
  31171. var carry = 0;
  31172. for (var i = 0; i < b.length; i++) {
  31173. r = (a.words[i] | 0) - (b.words[i] | 0) + carry;
  31174. carry = r >> 26;
  31175. this.words[i] = r & 0x3ffffff;
  31176. }
  31177. for (; carry !== 0 && i < a.length; i++) {
  31178. r = (a.words[i] | 0) + carry;
  31179. carry = r >> 26;
  31180. this.words[i] = r & 0x3ffffff;
  31181. }
  31182. // Copy rest of the words
  31183. if (carry === 0 && i < a.length && a !== this) {
  31184. for (; i < a.length; i++) {
  31185. this.words[i] = a.words[i];
  31186. }
  31187. }
  31188. this.length = Math.max(this.length, i);
  31189. if (a !== this) {
  31190. this.negative = 1;
  31191. }
  31192. return this.strip();
  31193. };
  31194. // Subtract `num` from `this`
  31195. BN.prototype.sub = function sub (num) {
  31196. return this.clone().isub(num);
  31197. };
  31198. function smallMulTo (self, num, out) {
  31199. out.negative = num.negative ^ self.negative;
  31200. var len = (self.length + num.length) | 0;
  31201. out.length = len;
  31202. len = (len - 1) | 0;
  31203. // Peel one iteration (compiler can't do it, because of code complexity)
  31204. var a = self.words[0] | 0;
  31205. var b = num.words[0] | 0;
  31206. var r = a * b;
  31207. var lo = r & 0x3ffffff;
  31208. var carry = (r / 0x4000000) | 0;
  31209. out.words[0] = lo;
  31210. for (var k = 1; k < len; k++) {
  31211. // Sum all words with the same `i + j = k` and accumulate `ncarry`,
  31212. // note that ncarry could be >= 0x3ffffff
  31213. var ncarry = carry >>> 26;
  31214. var rword = carry & 0x3ffffff;
  31215. var maxJ = Math.min(k, num.length - 1);
  31216. for (var j = Math.max(0, k - self.length + 1); j <= maxJ; j++) {
  31217. var i = (k - j) | 0;
  31218. a = self.words[i] | 0;
  31219. b = num.words[j] | 0;
  31220. r = a * b + rword;
  31221. ncarry += (r / 0x4000000) | 0;
  31222. rword = r & 0x3ffffff;
  31223. }
  31224. out.words[k] = rword | 0;
  31225. carry = ncarry | 0;
  31226. }
  31227. if (carry !== 0) {
  31228. out.words[k] = carry | 0;
  31229. } else {
  31230. out.length--;
  31231. }
  31232. return out.strip();
  31233. }
  31234. // TODO(indutny): it may be reasonable to omit it for users who don't need
  31235. // to work with 256-bit numbers, otherwise it gives 20% improvement for 256-bit
  31236. // multiplication (like elliptic secp256k1).
  31237. var comb10MulTo = function comb10MulTo (self, num, out) {
  31238. var a = self.words;
  31239. var b = num.words;
  31240. var o = out.words;
  31241. var c = 0;
  31242. var lo;
  31243. var mid;
  31244. var hi;
  31245. var a0 = a[0] | 0;
  31246. var al0 = a0 & 0x1fff;
  31247. var ah0 = a0 >>> 13;
  31248. var a1 = a[1] | 0;
  31249. var al1 = a1 & 0x1fff;
  31250. var ah1 = a1 >>> 13;
  31251. var a2 = a[2] | 0;
  31252. var al2 = a2 & 0x1fff;
  31253. var ah2 = a2 >>> 13;
  31254. var a3 = a[3] | 0;
  31255. var al3 = a3 & 0x1fff;
  31256. var ah3 = a3 >>> 13;
  31257. var a4 = a[4] | 0;
  31258. var al4 = a4 & 0x1fff;
  31259. var ah4 = a4 >>> 13;
  31260. var a5 = a[5] | 0;
  31261. var al5 = a5 & 0x1fff;
  31262. var ah5 = a5 >>> 13;
  31263. var a6 = a[6] | 0;
  31264. var al6 = a6 & 0x1fff;
  31265. var ah6 = a6 >>> 13;
  31266. var a7 = a[7] | 0;
  31267. var al7 = a7 & 0x1fff;
  31268. var ah7 = a7 >>> 13;
  31269. var a8 = a[8] | 0;
  31270. var al8 = a8 & 0x1fff;
  31271. var ah8 = a8 >>> 13;
  31272. var a9 = a[9] | 0;
  31273. var al9 = a9 & 0x1fff;
  31274. var ah9 = a9 >>> 13;
  31275. var b0 = b[0] | 0;
  31276. var bl0 = b0 & 0x1fff;
  31277. var bh0 = b0 >>> 13;
  31278. var b1 = b[1] | 0;
  31279. var bl1 = b1 & 0x1fff;
  31280. var bh1 = b1 >>> 13;
  31281. var b2 = b[2] | 0;
  31282. var bl2 = b2 & 0x1fff;
  31283. var bh2 = b2 >>> 13;
  31284. var b3 = b[3] | 0;
  31285. var bl3 = b3 & 0x1fff;
  31286. var bh3 = b3 >>> 13;
  31287. var b4 = b[4] | 0;
  31288. var bl4 = b4 & 0x1fff;
  31289. var bh4 = b4 >>> 13;
  31290. var b5 = b[5] | 0;
  31291. var bl5 = b5 & 0x1fff;
  31292. var bh5 = b5 >>> 13;
  31293. var b6 = b[6] | 0;
  31294. var bl6 = b6 & 0x1fff;
  31295. var bh6 = b6 >>> 13;
  31296. var b7 = b[7] | 0;
  31297. var bl7 = b7 & 0x1fff;
  31298. var bh7 = b7 >>> 13;
  31299. var b8 = b[8] | 0;
  31300. var bl8 = b8 & 0x1fff;
  31301. var bh8 = b8 >>> 13;
  31302. var b9 = b[9] | 0;
  31303. var bl9 = b9 & 0x1fff;
  31304. var bh9 = b9 >>> 13;
  31305. out.negative = self.negative ^ num.negative;
  31306. out.length = 19;
  31307. /* k = 0 */
  31308. lo = Math.imul(al0, bl0);
  31309. mid = Math.imul(al0, bh0);
  31310. mid = (mid + Math.imul(ah0, bl0)) | 0;
  31311. hi = Math.imul(ah0, bh0);
  31312. var w0 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0;
  31313. c = (((hi + (mid >>> 13)) | 0) + (w0 >>> 26)) | 0;
  31314. w0 &= 0x3ffffff;
  31315. /* k = 1 */
  31316. lo = Math.imul(al1, bl0);
  31317. mid = Math.imul(al1, bh0);
  31318. mid = (mid + Math.imul(ah1, bl0)) | 0;
  31319. hi = Math.imul(ah1, bh0);
  31320. lo = (lo + Math.imul(al0, bl1)) | 0;
  31321. mid = (mid + Math.imul(al0, bh1)) | 0;
  31322. mid = (mid + Math.imul(ah0, bl1)) | 0;
  31323. hi = (hi + Math.imul(ah0, bh1)) | 0;
  31324. var w1 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0;
  31325. c = (((hi + (mid >>> 13)) | 0) + (w1 >>> 26)) | 0;
  31326. w1 &= 0x3ffffff;
  31327. /* k = 2 */
  31328. lo = Math.imul(al2, bl0);
  31329. mid = Math.imul(al2, bh0);
  31330. mid = (mid + Math.imul(ah2, bl0)) | 0;
  31331. hi = Math.imul(ah2, bh0);
  31332. lo = (lo + Math.imul(al1, bl1)) | 0;
  31333. mid = (mid + Math.imul(al1, bh1)) | 0;
  31334. mid = (mid + Math.imul(ah1, bl1)) | 0;
  31335. hi = (hi + Math.imul(ah1, bh1)) | 0;
  31336. lo = (lo + Math.imul(al0, bl2)) | 0;
  31337. mid = (mid + Math.imul(al0, bh2)) | 0;
  31338. mid = (mid + Math.imul(ah0, bl2)) | 0;
  31339. hi = (hi + Math.imul(ah0, bh2)) | 0;
  31340. var w2 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0;
  31341. c = (((hi + (mid >>> 13)) | 0) + (w2 >>> 26)) | 0;
  31342. w2 &= 0x3ffffff;
  31343. /* k = 3 */
  31344. lo = Math.imul(al3, bl0);
  31345. mid = Math.imul(al3, bh0);
  31346. mid = (mid + Math.imul(ah3, bl0)) | 0;
  31347. hi = Math.imul(ah3, bh0);
  31348. lo = (lo + Math.imul(al2, bl1)) | 0;
  31349. mid = (mid + Math.imul(al2, bh1)) | 0;
  31350. mid = (mid + Math.imul(ah2, bl1)) | 0;
  31351. hi = (hi + Math.imul(ah2, bh1)) | 0;
  31352. lo = (lo + Math.imul(al1, bl2)) | 0;
  31353. mid = (mid + Math.imul(al1, bh2)) | 0;
  31354. mid = (mid + Math.imul(ah1, bl2)) | 0;
  31355. hi = (hi + Math.imul(ah1, bh2)) | 0;
  31356. lo = (lo + Math.imul(al0, bl3)) | 0;
  31357. mid = (mid + Math.imul(al0, bh3)) | 0;
  31358. mid = (mid + Math.imul(ah0, bl3)) | 0;
  31359. hi = (hi + Math.imul(ah0, bh3)) | 0;
  31360. var w3 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0;
  31361. c = (((hi + (mid >>> 13)) | 0) + (w3 >>> 26)) | 0;
  31362. w3 &= 0x3ffffff;
  31363. /* k = 4 */
  31364. lo = Math.imul(al4, bl0);
  31365. mid = Math.imul(al4, bh0);
  31366. mid = (mid + Math.imul(ah4, bl0)) | 0;
  31367. hi = Math.imul(ah4, bh0);
  31368. lo = (lo + Math.imul(al3, bl1)) | 0;
  31369. mid = (mid + Math.imul(al3, bh1)) | 0;
  31370. mid = (mid + Math.imul(ah3, bl1)) | 0;
  31371. hi = (hi + Math.imul(ah3, bh1)) | 0;
  31372. lo = (lo + Math.imul(al2, bl2)) | 0;
  31373. mid = (mid + Math.imul(al2, bh2)) | 0;
  31374. mid = (mid + Math.imul(ah2, bl2)) | 0;
  31375. hi = (hi + Math.imul(ah2, bh2)) | 0;
  31376. lo = (lo + Math.imul(al1, bl3)) | 0;
  31377. mid = (mid + Math.imul(al1, bh3)) | 0;
  31378. mid = (mid + Math.imul(ah1, bl3)) | 0;
  31379. hi = (hi + Math.imul(ah1, bh3)) | 0;
  31380. lo = (lo + Math.imul(al0, bl4)) | 0;
  31381. mid = (mid + Math.imul(al0, bh4)) | 0;
  31382. mid = (mid + Math.imul(ah0, bl4)) | 0;
  31383. hi = (hi + Math.imul(ah0, bh4)) | 0;
  31384. var w4 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0;
  31385. c = (((hi + (mid >>> 13)) | 0) + (w4 >>> 26)) | 0;
  31386. w4 &= 0x3ffffff;
  31387. /* k = 5 */
  31388. lo = Math.imul(al5, bl0);
  31389. mid = Math.imul(al5, bh0);
  31390. mid = (mid + Math.imul(ah5, bl0)) | 0;
  31391. hi = Math.imul(ah5, bh0);
  31392. lo = (lo + Math.imul(al4, bl1)) | 0;
  31393. mid = (mid + Math.imul(al4, bh1)) | 0;
  31394. mid = (mid + Math.imul(ah4, bl1)) | 0;
  31395. hi = (hi + Math.imul(ah4, bh1)) | 0;
  31396. lo = (lo + Math.imul(al3, bl2)) | 0;
  31397. mid = (mid + Math.imul(al3, bh2)) | 0;
  31398. mid = (mid + Math.imul(ah3, bl2)) | 0;
  31399. hi = (hi + Math.imul(ah3, bh2)) | 0;
  31400. lo = (lo + Math.imul(al2, bl3)) | 0;
  31401. mid = (mid + Math.imul(al2, bh3)) | 0;
  31402. mid = (mid + Math.imul(ah2, bl3)) | 0;
  31403. hi = (hi + Math.imul(ah2, bh3)) | 0;
  31404. lo = (lo + Math.imul(al1, bl4)) | 0;
  31405. mid = (mid + Math.imul(al1, bh4)) | 0;
  31406. mid = (mid + Math.imul(ah1, bl4)) | 0;
  31407. hi = (hi + Math.imul(ah1, bh4)) | 0;
  31408. lo = (lo + Math.imul(al0, bl5)) | 0;
  31409. mid = (mid + Math.imul(al0, bh5)) | 0;
  31410. mid = (mid + Math.imul(ah0, bl5)) | 0;
  31411. hi = (hi + Math.imul(ah0, bh5)) | 0;
  31412. var w5 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0;
  31413. c = (((hi + (mid >>> 13)) | 0) + (w5 >>> 26)) | 0;
  31414. w5 &= 0x3ffffff;
  31415. /* k = 6 */
  31416. lo = Math.imul(al6, bl0);
  31417. mid = Math.imul(al6, bh0);
  31418. mid = (mid + Math.imul(ah6, bl0)) | 0;
  31419. hi = Math.imul(ah6, bh0);
  31420. lo = (lo + Math.imul(al5, bl1)) | 0;
  31421. mid = (mid + Math.imul(al5, bh1)) | 0;
  31422. mid = (mid + Math.imul(ah5, bl1)) | 0;
  31423. hi = (hi + Math.imul(ah5, bh1)) | 0;
  31424. lo = (lo + Math.imul(al4, bl2)) | 0;
  31425. mid = (mid + Math.imul(al4, bh2)) | 0;
  31426. mid = (mid + Math.imul(ah4, bl2)) | 0;
  31427. hi = (hi + Math.imul(ah4, bh2)) | 0;
  31428. lo = (lo + Math.imul(al3, bl3)) | 0;
  31429. mid = (mid + Math.imul(al3, bh3)) | 0;
  31430. mid = (mid + Math.imul(ah3, bl3)) | 0;
  31431. hi = (hi + Math.imul(ah3, bh3)) | 0;
  31432. lo = (lo + Math.imul(al2, bl4)) | 0;
  31433. mid = (mid + Math.imul(al2, bh4)) | 0;
  31434. mid = (mid + Math.imul(ah2, bl4)) | 0;
  31435. hi = (hi + Math.imul(ah2, bh4)) | 0;
  31436. lo = (lo + Math.imul(al1, bl5)) | 0;
  31437. mid = (mid + Math.imul(al1, bh5)) | 0;
  31438. mid = (mid + Math.imul(ah1, bl5)) | 0;
  31439. hi = (hi + Math.imul(ah1, bh5)) | 0;
  31440. lo = (lo + Math.imul(al0, bl6)) | 0;
  31441. mid = (mid + Math.imul(al0, bh6)) | 0;
  31442. mid = (mid + Math.imul(ah0, bl6)) | 0;
  31443. hi = (hi + Math.imul(ah0, bh6)) | 0;
  31444. var w6 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0;
  31445. c = (((hi + (mid >>> 13)) | 0) + (w6 >>> 26)) | 0;
  31446. w6 &= 0x3ffffff;
  31447. /* k = 7 */
  31448. lo = Math.imul(al7, bl0);
  31449. mid = Math.imul(al7, bh0);
  31450. mid = (mid + Math.imul(ah7, bl0)) | 0;
  31451. hi = Math.imul(ah7, bh0);
  31452. lo = (lo + Math.imul(al6, bl1)) | 0;
  31453. mid = (mid + Math.imul(al6, bh1)) | 0;
  31454. mid = (mid + Math.imul(ah6, bl1)) | 0;
  31455. hi = (hi + Math.imul(ah6, bh1)) | 0;
  31456. lo = (lo + Math.imul(al5, bl2)) | 0;
  31457. mid = (mid + Math.imul(al5, bh2)) | 0;
  31458. mid = (mid + Math.imul(ah5, bl2)) | 0;
  31459. hi = (hi + Math.imul(ah5, bh2)) | 0;
  31460. lo = (lo + Math.imul(al4, bl3)) | 0;
  31461. mid = (mid + Math.imul(al4, bh3)) | 0;
  31462. mid = (mid + Math.imul(ah4, bl3)) | 0;
  31463. hi = (hi + Math.imul(ah4, bh3)) | 0;
  31464. lo = (lo + Math.imul(al3, bl4)) | 0;
  31465. mid = (mid + Math.imul(al3, bh4)) | 0;
  31466. mid = (mid + Math.imul(ah3, bl4)) | 0;
  31467. hi = (hi + Math.imul(ah3, bh4)) | 0;
  31468. lo = (lo + Math.imul(al2, bl5)) | 0;
  31469. mid = (mid + Math.imul(al2, bh5)) | 0;
  31470. mid = (mid + Math.imul(ah2, bl5)) | 0;
  31471. hi = (hi + Math.imul(ah2, bh5)) | 0;
  31472. lo = (lo + Math.imul(al1, bl6)) | 0;
  31473. mid = (mid + Math.imul(al1, bh6)) | 0;
  31474. mid = (mid + Math.imul(ah1, bl6)) | 0;
  31475. hi = (hi + Math.imul(ah1, bh6)) | 0;
  31476. lo = (lo + Math.imul(al0, bl7)) | 0;
  31477. mid = (mid + Math.imul(al0, bh7)) | 0;
  31478. mid = (mid + Math.imul(ah0, bl7)) | 0;
  31479. hi = (hi + Math.imul(ah0, bh7)) | 0;
  31480. var w7 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0;
  31481. c = (((hi + (mid >>> 13)) | 0) + (w7 >>> 26)) | 0;
  31482. w7 &= 0x3ffffff;
  31483. /* k = 8 */
  31484. lo = Math.imul(al8, bl0);
  31485. mid = Math.imul(al8, bh0);
  31486. mid = (mid + Math.imul(ah8, bl0)) | 0;
  31487. hi = Math.imul(ah8, bh0);
  31488. lo = (lo + Math.imul(al7, bl1)) | 0;
  31489. mid = (mid + Math.imul(al7, bh1)) | 0;
  31490. mid = (mid + Math.imul(ah7, bl1)) | 0;
  31491. hi = (hi + Math.imul(ah7, bh1)) | 0;
  31492. lo = (lo + Math.imul(al6, bl2)) | 0;
  31493. mid = (mid + Math.imul(al6, bh2)) | 0;
  31494. mid = (mid + Math.imul(ah6, bl2)) | 0;
  31495. hi = (hi + Math.imul(ah6, bh2)) | 0;
  31496. lo = (lo + Math.imul(al5, bl3)) | 0;
  31497. mid = (mid + Math.imul(al5, bh3)) | 0;
  31498. mid = (mid + Math.imul(ah5, bl3)) | 0;
  31499. hi = (hi + Math.imul(ah5, bh3)) | 0;
  31500. lo = (lo + Math.imul(al4, bl4)) | 0;
  31501. mid = (mid + Math.imul(al4, bh4)) | 0;
  31502. mid = (mid + Math.imul(ah4, bl4)) | 0;
  31503. hi = (hi + Math.imul(ah4, bh4)) | 0;
  31504. lo = (lo + Math.imul(al3, bl5)) | 0;
  31505. mid = (mid + Math.imul(al3, bh5)) | 0;
  31506. mid = (mid + Math.imul(ah3, bl5)) | 0;
  31507. hi = (hi + Math.imul(ah3, bh5)) | 0;
  31508. lo = (lo + Math.imul(al2, bl6)) | 0;
  31509. mid = (mid + Math.imul(al2, bh6)) | 0;
  31510. mid = (mid + Math.imul(ah2, bl6)) | 0;
  31511. hi = (hi + Math.imul(ah2, bh6)) | 0;
  31512. lo = (lo + Math.imul(al1, bl7)) | 0;
  31513. mid = (mid + Math.imul(al1, bh7)) | 0;
  31514. mid = (mid + Math.imul(ah1, bl7)) | 0;
  31515. hi = (hi + Math.imul(ah1, bh7)) | 0;
  31516. lo = (lo + Math.imul(al0, bl8)) | 0;
  31517. mid = (mid + Math.imul(al0, bh8)) | 0;
  31518. mid = (mid + Math.imul(ah0, bl8)) | 0;
  31519. hi = (hi + Math.imul(ah0, bh8)) | 0;
  31520. var w8 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0;
  31521. c = (((hi + (mid >>> 13)) | 0) + (w8 >>> 26)) | 0;
  31522. w8 &= 0x3ffffff;
  31523. /* k = 9 */
  31524. lo = Math.imul(al9, bl0);
  31525. mid = Math.imul(al9, bh0);
  31526. mid = (mid + Math.imul(ah9, bl0)) | 0;
  31527. hi = Math.imul(ah9, bh0);
  31528. lo = (lo + Math.imul(al8, bl1)) | 0;
  31529. mid = (mid + Math.imul(al8, bh1)) | 0;
  31530. mid = (mid + Math.imul(ah8, bl1)) | 0;
  31531. hi = (hi + Math.imul(ah8, bh1)) | 0;
  31532. lo = (lo + Math.imul(al7, bl2)) | 0;
  31533. mid = (mid + Math.imul(al7, bh2)) | 0;
  31534. mid = (mid + Math.imul(ah7, bl2)) | 0;
  31535. hi = (hi + Math.imul(ah7, bh2)) | 0;
  31536. lo = (lo + Math.imul(al6, bl3)) | 0;
  31537. mid = (mid + Math.imul(al6, bh3)) | 0;
  31538. mid = (mid + Math.imul(ah6, bl3)) | 0;
  31539. hi = (hi + Math.imul(ah6, bh3)) | 0;
  31540. lo = (lo + Math.imul(al5, bl4)) | 0;
  31541. mid = (mid + Math.imul(al5, bh4)) | 0;
  31542. mid = (mid + Math.imul(ah5, bl4)) | 0;
  31543. hi = (hi + Math.imul(ah5, bh4)) | 0;
  31544. lo = (lo + Math.imul(al4, bl5)) | 0;
  31545. mid = (mid + Math.imul(al4, bh5)) | 0;
  31546. mid = (mid + Math.imul(ah4, bl5)) | 0;
  31547. hi = (hi + Math.imul(ah4, bh5)) | 0;
  31548. lo = (lo + Math.imul(al3, bl6)) | 0;
  31549. mid = (mid + Math.imul(al3, bh6)) | 0;
  31550. mid = (mid + Math.imul(ah3, bl6)) | 0;
  31551. hi = (hi + Math.imul(ah3, bh6)) | 0;
  31552. lo = (lo + Math.imul(al2, bl7)) | 0;
  31553. mid = (mid + Math.imul(al2, bh7)) | 0;
  31554. mid = (mid + Math.imul(ah2, bl7)) | 0;
  31555. hi = (hi + Math.imul(ah2, bh7)) | 0;
  31556. lo = (lo + Math.imul(al1, bl8)) | 0;
  31557. mid = (mid + Math.imul(al1, bh8)) | 0;
  31558. mid = (mid + Math.imul(ah1, bl8)) | 0;
  31559. hi = (hi + Math.imul(ah1, bh8)) | 0;
  31560. lo = (lo + Math.imul(al0, bl9)) | 0;
  31561. mid = (mid + Math.imul(al0, bh9)) | 0;
  31562. mid = (mid + Math.imul(ah0, bl9)) | 0;
  31563. hi = (hi + Math.imul(ah0, bh9)) | 0;
  31564. var w9 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0;
  31565. c = (((hi + (mid >>> 13)) | 0) + (w9 >>> 26)) | 0;
  31566. w9 &= 0x3ffffff;
  31567. /* k = 10 */
  31568. lo = Math.imul(al9, bl1);
  31569. mid = Math.imul(al9, bh1);
  31570. mid = (mid + Math.imul(ah9, bl1)) | 0;
  31571. hi = Math.imul(ah9, bh1);
  31572. lo = (lo + Math.imul(al8, bl2)) | 0;
  31573. mid = (mid + Math.imul(al8, bh2)) | 0;
  31574. mid = (mid + Math.imul(ah8, bl2)) | 0;
  31575. hi = (hi + Math.imul(ah8, bh2)) | 0;
  31576. lo = (lo + Math.imul(al7, bl3)) | 0;
  31577. mid = (mid + Math.imul(al7, bh3)) | 0;
  31578. mid = (mid + Math.imul(ah7, bl3)) | 0;
  31579. hi = (hi + Math.imul(ah7, bh3)) | 0;
  31580. lo = (lo + Math.imul(al6, bl4)) | 0;
  31581. mid = (mid + Math.imul(al6, bh4)) | 0;
  31582. mid = (mid + Math.imul(ah6, bl4)) | 0;
  31583. hi = (hi + Math.imul(ah6, bh4)) | 0;
  31584. lo = (lo + Math.imul(al5, bl5)) | 0;
  31585. mid = (mid + Math.imul(al5, bh5)) | 0;
  31586. mid = (mid + Math.imul(ah5, bl5)) | 0;
  31587. hi = (hi + Math.imul(ah5, bh5)) | 0;
  31588. lo = (lo + Math.imul(al4, bl6)) | 0;
  31589. mid = (mid + Math.imul(al4, bh6)) | 0;
  31590. mid = (mid + Math.imul(ah4, bl6)) | 0;
  31591. hi = (hi + Math.imul(ah4, bh6)) | 0;
  31592. lo = (lo + Math.imul(al3, bl7)) | 0;
  31593. mid = (mid + Math.imul(al3, bh7)) | 0;
  31594. mid = (mid + Math.imul(ah3, bl7)) | 0;
  31595. hi = (hi + Math.imul(ah3, bh7)) | 0;
  31596. lo = (lo + Math.imul(al2, bl8)) | 0;
  31597. mid = (mid + Math.imul(al2, bh8)) | 0;
  31598. mid = (mid + Math.imul(ah2, bl8)) | 0;
  31599. hi = (hi + Math.imul(ah2, bh8)) | 0;
  31600. lo = (lo + Math.imul(al1, bl9)) | 0;
  31601. mid = (mid + Math.imul(al1, bh9)) | 0;
  31602. mid = (mid + Math.imul(ah1, bl9)) | 0;
  31603. hi = (hi + Math.imul(ah1, bh9)) | 0;
  31604. var w10 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0;
  31605. c = (((hi + (mid >>> 13)) | 0) + (w10 >>> 26)) | 0;
  31606. w10 &= 0x3ffffff;
  31607. /* k = 11 */
  31608. lo = Math.imul(al9, bl2);
  31609. mid = Math.imul(al9, bh2);
  31610. mid = (mid + Math.imul(ah9, bl2)) | 0;
  31611. hi = Math.imul(ah9, bh2);
  31612. lo = (lo + Math.imul(al8, bl3)) | 0;
  31613. mid = (mid + Math.imul(al8, bh3)) | 0;
  31614. mid = (mid + Math.imul(ah8, bl3)) | 0;
  31615. hi = (hi + Math.imul(ah8, bh3)) | 0;
  31616. lo = (lo + Math.imul(al7, bl4)) | 0;
  31617. mid = (mid + Math.imul(al7, bh4)) | 0;
  31618. mid = (mid + Math.imul(ah7, bl4)) | 0;
  31619. hi = (hi + Math.imul(ah7, bh4)) | 0;
  31620. lo = (lo + Math.imul(al6, bl5)) | 0;
  31621. mid = (mid + Math.imul(al6, bh5)) | 0;
  31622. mid = (mid + Math.imul(ah6, bl5)) | 0;
  31623. hi = (hi + Math.imul(ah6, bh5)) | 0;
  31624. lo = (lo + Math.imul(al5, bl6)) | 0;
  31625. mid = (mid + Math.imul(al5, bh6)) | 0;
  31626. mid = (mid + Math.imul(ah5, bl6)) | 0;
  31627. hi = (hi + Math.imul(ah5, bh6)) | 0;
  31628. lo = (lo + Math.imul(al4, bl7)) | 0;
  31629. mid = (mid + Math.imul(al4, bh7)) | 0;
  31630. mid = (mid + Math.imul(ah4, bl7)) | 0;
  31631. hi = (hi + Math.imul(ah4, bh7)) | 0;
  31632. lo = (lo + Math.imul(al3, bl8)) | 0;
  31633. mid = (mid + Math.imul(al3, bh8)) | 0;
  31634. mid = (mid + Math.imul(ah3, bl8)) | 0;
  31635. hi = (hi + Math.imul(ah3, bh8)) | 0;
  31636. lo = (lo + Math.imul(al2, bl9)) | 0;
  31637. mid = (mid + Math.imul(al2, bh9)) | 0;
  31638. mid = (mid + Math.imul(ah2, bl9)) | 0;
  31639. hi = (hi + Math.imul(ah2, bh9)) | 0;
  31640. var w11 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0;
  31641. c = (((hi + (mid >>> 13)) | 0) + (w11 >>> 26)) | 0;
  31642. w11 &= 0x3ffffff;
  31643. /* k = 12 */
  31644. lo = Math.imul(al9, bl3);
  31645. mid = Math.imul(al9, bh3);
  31646. mid = (mid + Math.imul(ah9, bl3)) | 0;
  31647. hi = Math.imul(ah9, bh3);
  31648. lo = (lo + Math.imul(al8, bl4)) | 0;
  31649. mid = (mid + Math.imul(al8, bh4)) | 0;
  31650. mid = (mid + Math.imul(ah8, bl4)) | 0;
  31651. hi = (hi + Math.imul(ah8, bh4)) | 0;
  31652. lo = (lo + Math.imul(al7, bl5)) | 0;
  31653. mid = (mid + Math.imul(al7, bh5)) | 0;
  31654. mid = (mid + Math.imul(ah7, bl5)) | 0;
  31655. hi = (hi + Math.imul(ah7, bh5)) | 0;
  31656. lo = (lo + Math.imul(al6, bl6)) | 0;
  31657. mid = (mid + Math.imul(al6, bh6)) | 0;
  31658. mid = (mid + Math.imul(ah6, bl6)) | 0;
  31659. hi = (hi + Math.imul(ah6, bh6)) | 0;
  31660. lo = (lo + Math.imul(al5, bl7)) | 0;
  31661. mid = (mid + Math.imul(al5, bh7)) | 0;
  31662. mid = (mid + Math.imul(ah5, bl7)) | 0;
  31663. hi = (hi + Math.imul(ah5, bh7)) | 0;
  31664. lo = (lo + Math.imul(al4, bl8)) | 0;
  31665. mid = (mid + Math.imul(al4, bh8)) | 0;
  31666. mid = (mid + Math.imul(ah4, bl8)) | 0;
  31667. hi = (hi + Math.imul(ah4, bh8)) | 0;
  31668. lo = (lo + Math.imul(al3, bl9)) | 0;
  31669. mid = (mid + Math.imul(al3, bh9)) | 0;
  31670. mid = (mid + Math.imul(ah3, bl9)) | 0;
  31671. hi = (hi + Math.imul(ah3, bh9)) | 0;
  31672. var w12 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0;
  31673. c = (((hi + (mid >>> 13)) | 0) + (w12 >>> 26)) | 0;
  31674. w12 &= 0x3ffffff;
  31675. /* k = 13 */
  31676. lo = Math.imul(al9, bl4);
  31677. mid = Math.imul(al9, bh4);
  31678. mid = (mid + Math.imul(ah9, bl4)) | 0;
  31679. hi = Math.imul(ah9, bh4);
  31680. lo = (lo + Math.imul(al8, bl5)) | 0;
  31681. mid = (mid + Math.imul(al8, bh5)) | 0;
  31682. mid = (mid + Math.imul(ah8, bl5)) | 0;
  31683. hi = (hi + Math.imul(ah8, bh5)) | 0;
  31684. lo = (lo + Math.imul(al7, bl6)) | 0;
  31685. mid = (mid + Math.imul(al7, bh6)) | 0;
  31686. mid = (mid + Math.imul(ah7, bl6)) | 0;
  31687. hi = (hi + Math.imul(ah7, bh6)) | 0;
  31688. lo = (lo + Math.imul(al6, bl7)) | 0;
  31689. mid = (mid + Math.imul(al6, bh7)) | 0;
  31690. mid = (mid + Math.imul(ah6, bl7)) | 0;
  31691. hi = (hi + Math.imul(ah6, bh7)) | 0;
  31692. lo = (lo + Math.imul(al5, bl8)) | 0;
  31693. mid = (mid + Math.imul(al5, bh8)) | 0;
  31694. mid = (mid + Math.imul(ah5, bl8)) | 0;
  31695. hi = (hi + Math.imul(ah5, bh8)) | 0;
  31696. lo = (lo + Math.imul(al4, bl9)) | 0;
  31697. mid = (mid + Math.imul(al4, bh9)) | 0;
  31698. mid = (mid + Math.imul(ah4, bl9)) | 0;
  31699. hi = (hi + Math.imul(ah4, bh9)) | 0;
  31700. var w13 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0;
  31701. c = (((hi + (mid >>> 13)) | 0) + (w13 >>> 26)) | 0;
  31702. w13 &= 0x3ffffff;
  31703. /* k = 14 */
  31704. lo = Math.imul(al9, bl5);
  31705. mid = Math.imul(al9, bh5);
  31706. mid = (mid + Math.imul(ah9, bl5)) | 0;
  31707. hi = Math.imul(ah9, bh5);
  31708. lo = (lo + Math.imul(al8, bl6)) | 0;
  31709. mid = (mid + Math.imul(al8, bh6)) | 0;
  31710. mid = (mid + Math.imul(ah8, bl6)) | 0;
  31711. hi = (hi + Math.imul(ah8, bh6)) | 0;
  31712. lo = (lo + Math.imul(al7, bl7)) | 0;
  31713. mid = (mid + Math.imul(al7, bh7)) | 0;
  31714. mid = (mid + Math.imul(ah7, bl7)) | 0;
  31715. hi = (hi + Math.imul(ah7, bh7)) | 0;
  31716. lo = (lo + Math.imul(al6, bl8)) | 0;
  31717. mid = (mid + Math.imul(al6, bh8)) | 0;
  31718. mid = (mid + Math.imul(ah6, bl8)) | 0;
  31719. hi = (hi + Math.imul(ah6, bh8)) | 0;
  31720. lo = (lo + Math.imul(al5, bl9)) | 0;
  31721. mid = (mid + Math.imul(al5, bh9)) | 0;
  31722. mid = (mid + Math.imul(ah5, bl9)) | 0;
  31723. hi = (hi + Math.imul(ah5, bh9)) | 0;
  31724. var w14 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0;
  31725. c = (((hi + (mid >>> 13)) | 0) + (w14 >>> 26)) | 0;
  31726. w14 &= 0x3ffffff;
  31727. /* k = 15 */
  31728. lo = Math.imul(al9, bl6);
  31729. mid = Math.imul(al9, bh6);
  31730. mid = (mid + Math.imul(ah9, bl6)) | 0;
  31731. hi = Math.imul(ah9, bh6);
  31732. lo = (lo + Math.imul(al8, bl7)) | 0;
  31733. mid = (mid + Math.imul(al8, bh7)) | 0;
  31734. mid = (mid + Math.imul(ah8, bl7)) | 0;
  31735. hi = (hi + Math.imul(ah8, bh7)) | 0;
  31736. lo = (lo + Math.imul(al7, bl8)) | 0;
  31737. mid = (mid + Math.imul(al7, bh8)) | 0;
  31738. mid = (mid + Math.imul(ah7, bl8)) | 0;
  31739. hi = (hi + Math.imul(ah7, bh8)) | 0;
  31740. lo = (lo + Math.imul(al6, bl9)) | 0;
  31741. mid = (mid + Math.imul(al6, bh9)) | 0;
  31742. mid = (mid + Math.imul(ah6, bl9)) | 0;
  31743. hi = (hi + Math.imul(ah6, bh9)) | 0;
  31744. var w15 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0;
  31745. c = (((hi + (mid >>> 13)) | 0) + (w15 >>> 26)) | 0;
  31746. w15 &= 0x3ffffff;
  31747. /* k = 16 */
  31748. lo = Math.imul(al9, bl7);
  31749. mid = Math.imul(al9, bh7);
  31750. mid = (mid + Math.imul(ah9, bl7)) | 0;
  31751. hi = Math.imul(ah9, bh7);
  31752. lo = (lo + Math.imul(al8, bl8)) | 0;
  31753. mid = (mid + Math.imul(al8, bh8)) | 0;
  31754. mid = (mid + Math.imul(ah8, bl8)) | 0;
  31755. hi = (hi + Math.imul(ah8, bh8)) | 0;
  31756. lo = (lo + Math.imul(al7, bl9)) | 0;
  31757. mid = (mid + Math.imul(al7, bh9)) | 0;
  31758. mid = (mid + Math.imul(ah7, bl9)) | 0;
  31759. hi = (hi + Math.imul(ah7, bh9)) | 0;
  31760. var w16 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0;
  31761. c = (((hi + (mid >>> 13)) | 0) + (w16 >>> 26)) | 0;
  31762. w16 &= 0x3ffffff;
  31763. /* k = 17 */
  31764. lo = Math.imul(al9, bl8);
  31765. mid = Math.imul(al9, bh8);
  31766. mid = (mid + Math.imul(ah9, bl8)) | 0;
  31767. hi = Math.imul(ah9, bh8);
  31768. lo = (lo + Math.imul(al8, bl9)) | 0;
  31769. mid = (mid + Math.imul(al8, bh9)) | 0;
  31770. mid = (mid + Math.imul(ah8, bl9)) | 0;
  31771. hi = (hi + Math.imul(ah8, bh9)) | 0;
  31772. var w17 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0;
  31773. c = (((hi + (mid >>> 13)) | 0) + (w17 >>> 26)) | 0;
  31774. w17 &= 0x3ffffff;
  31775. /* k = 18 */
  31776. lo = Math.imul(al9, bl9);
  31777. mid = Math.imul(al9, bh9);
  31778. mid = (mid + Math.imul(ah9, bl9)) | 0;
  31779. hi = Math.imul(ah9, bh9);
  31780. var w18 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0;
  31781. c = (((hi + (mid >>> 13)) | 0) + (w18 >>> 26)) | 0;
  31782. w18 &= 0x3ffffff;
  31783. o[0] = w0;
  31784. o[1] = w1;
  31785. o[2] = w2;
  31786. o[3] = w3;
  31787. o[4] = w4;
  31788. o[5] = w5;
  31789. o[6] = w6;
  31790. o[7] = w7;
  31791. o[8] = w8;
  31792. o[9] = w9;
  31793. o[10] = w10;
  31794. o[11] = w11;
  31795. o[12] = w12;
  31796. o[13] = w13;
  31797. o[14] = w14;
  31798. o[15] = w15;
  31799. o[16] = w16;
  31800. o[17] = w17;
  31801. o[18] = w18;
  31802. if (c !== 0) {
  31803. o[19] = c;
  31804. out.length++;
  31805. }
  31806. return out;
  31807. };
  31808. // Polyfill comb
  31809. if (!Math.imul) {
  31810. comb10MulTo = smallMulTo;
  31811. }
  31812. function bigMulTo (self, num, out) {
  31813. out.negative = num.negative ^ self.negative;
  31814. out.length = self.length + num.length;
  31815. var carry = 0;
  31816. var hncarry = 0;
  31817. for (var k = 0; k < out.length - 1; k++) {
  31818. // Sum all words with the same `i + j = k` and accumulate `ncarry`,
  31819. // note that ncarry could be >= 0x3ffffff
  31820. var ncarry = hncarry;
  31821. hncarry = 0;
  31822. var rword = carry & 0x3ffffff;
  31823. var maxJ = Math.min(k, num.length - 1);
  31824. for (var j = Math.max(0, k - self.length + 1); j <= maxJ; j++) {
  31825. var i = k - j;
  31826. var a = self.words[i] | 0;
  31827. var b = num.words[j] | 0;
  31828. var r = a * b;
  31829. var lo = r & 0x3ffffff;
  31830. ncarry = (ncarry + ((r / 0x4000000) | 0)) | 0;
  31831. lo = (lo + rword) | 0;
  31832. rword = lo & 0x3ffffff;
  31833. ncarry = (ncarry + (lo >>> 26)) | 0;
  31834. hncarry += ncarry >>> 26;
  31835. ncarry &= 0x3ffffff;
  31836. }
  31837. out.words[k] = rword;
  31838. carry = ncarry;
  31839. ncarry = hncarry;
  31840. }
  31841. if (carry !== 0) {
  31842. out.words[k] = carry;
  31843. } else {
  31844. out.length--;
  31845. }
  31846. return out.strip();
  31847. }
  31848. function jumboMulTo (self, num, out) {
  31849. var fftm = new FFTM();
  31850. return fftm.mulp(self, num, out);
  31851. }
  31852. BN.prototype.mulTo = function mulTo (num, out) {
  31853. var res;
  31854. var len = this.length + num.length;
  31855. if (this.length === 10 && num.length === 10) {
  31856. res = comb10MulTo(this, num, out);
  31857. } else if (len < 63) {
  31858. res = smallMulTo(this, num, out);
  31859. } else if (len < 1024) {
  31860. res = bigMulTo(this, num, out);
  31861. } else {
  31862. res = jumboMulTo(this, num, out);
  31863. }
  31864. return res;
  31865. };
  31866. // Cooley-Tukey algorithm for FFT
  31867. // slightly revisited to rely on looping instead of recursion
  31868. function FFTM (x, y) {
  31869. this.x = x;
  31870. this.y = y;
  31871. }
  31872. FFTM.prototype.makeRBT = function makeRBT (N) {
  31873. var t = new Array(N);
  31874. var l = BN.prototype._countBits(N) - 1;
  31875. for (var i = 0; i < N; i++) {
  31876. t[i] = this.revBin(i, l, N);
  31877. }
  31878. return t;
  31879. };
  31880. // Returns binary-reversed representation of `x`
  31881. FFTM.prototype.revBin = function revBin (x, l, N) {
  31882. if (x === 0 || x === N - 1) return x;
  31883. var rb = 0;
  31884. for (var i = 0; i < l; i++) {
  31885. rb |= (x & 1) << (l - i - 1);
  31886. x >>= 1;
  31887. }
  31888. return rb;
  31889. };
  31890. // Performs "tweedling" phase, therefore 'emulating'
  31891. // behaviour of the recursive algorithm
  31892. FFTM.prototype.permute = function permute (rbt, rws, iws, rtws, itws, N) {
  31893. for (var i = 0; i < N; i++) {
  31894. rtws[i] = rws[rbt[i]];
  31895. itws[i] = iws[rbt[i]];
  31896. }
  31897. };
  31898. FFTM.prototype.transform = function transform (rws, iws, rtws, itws, N, rbt) {
  31899. this.permute(rbt, rws, iws, rtws, itws, N);
  31900. for (var s = 1; s < N; s <<= 1) {
  31901. var l = s << 1;
  31902. var rtwdf = Math.cos(2 * Math.PI / l);
  31903. var itwdf = Math.sin(2 * Math.PI / l);
  31904. for (var p = 0; p < N; p += l) {
  31905. var rtwdf_ = rtwdf;
  31906. var itwdf_ = itwdf;
  31907. for (var j = 0; j < s; j++) {
  31908. var re = rtws[p + j];
  31909. var ie = itws[p + j];
  31910. var ro = rtws[p + j + s];
  31911. var io = itws[p + j + s];
  31912. var rx = rtwdf_ * ro - itwdf_ * io;
  31913. io = rtwdf_ * io + itwdf_ * ro;
  31914. ro = rx;
  31915. rtws[p + j] = re + ro;
  31916. itws[p + j] = ie + io;
  31917. rtws[p + j + s] = re - ro;
  31918. itws[p + j + s] = ie - io;
  31919. /* jshint maxdepth : false */
  31920. if (j !== l) {
  31921. rx = rtwdf * rtwdf_ - itwdf * itwdf_;
  31922. itwdf_ = rtwdf * itwdf_ + itwdf * rtwdf_;
  31923. rtwdf_ = rx;
  31924. }
  31925. }
  31926. }
  31927. }
  31928. };
  31929. FFTM.prototype.guessLen13b = function guessLen13b (n, m) {
  31930. var N = Math.max(m, n) | 1;
  31931. var odd = N & 1;
  31932. var i = 0;
  31933. for (N = N / 2 | 0; N; N = N >>> 1) {
  31934. i++;
  31935. }
  31936. return 1 << i + 1 + odd;
  31937. };
  31938. FFTM.prototype.conjugate = function conjugate (rws, iws, N) {
  31939. if (N <= 1) return;
  31940. for (var i = 0; i < N / 2; i++) {
  31941. var t = rws[i];
  31942. rws[i] = rws[N - i - 1];
  31943. rws[N - i - 1] = t;
  31944. t = iws[i];
  31945. iws[i] = -iws[N - i - 1];
  31946. iws[N - i - 1] = -t;
  31947. }
  31948. };
  31949. FFTM.prototype.normalize13b = function normalize13b (ws, N) {
  31950. var carry = 0;
  31951. for (var i = 0; i < N / 2; i++) {
  31952. var w = Math.round(ws[2 * i + 1] / N) * 0x2000 +
  31953. Math.round(ws[2 * i] / N) +
  31954. carry;
  31955. ws[i] = w & 0x3ffffff;
  31956. if (w < 0x4000000) {
  31957. carry = 0;
  31958. } else {
  31959. carry = w / 0x4000000 | 0;
  31960. }
  31961. }
  31962. return ws;
  31963. };
  31964. FFTM.prototype.convert13b = function convert13b (ws, len, rws, N) {
  31965. var carry = 0;
  31966. for (var i = 0; i < len; i++) {
  31967. carry = carry + (ws[i] | 0);
  31968. rws[2 * i] = carry & 0x1fff; carry = carry >>> 13;
  31969. rws[2 * i + 1] = carry & 0x1fff; carry = carry >>> 13;
  31970. }
  31971. // Pad with zeroes
  31972. for (i = 2 * len; i < N; ++i) {
  31973. rws[i] = 0;
  31974. }
  31975. assert(carry === 0);
  31976. assert((carry & ~0x1fff) === 0);
  31977. };
  31978. FFTM.prototype.stub = function stub (N) {
  31979. var ph = new Array(N);
  31980. for (var i = 0; i < N; i++) {
  31981. ph[i] = 0;
  31982. }
  31983. return ph;
  31984. };
  31985. FFTM.prototype.mulp = function mulp (x, y, out) {
  31986. var N = 2 * this.guessLen13b(x.length, y.length);
  31987. var rbt = this.makeRBT(N);
  31988. var _ = this.stub(N);
  31989. var rws = new Array(N);
  31990. var rwst = new Array(N);
  31991. var iwst = new Array(N);
  31992. var nrws = new Array(N);
  31993. var nrwst = new Array(N);
  31994. var niwst = new Array(N);
  31995. var rmws = out.words;
  31996. rmws.length = N;
  31997. this.convert13b(x.words, x.length, rws, N);
  31998. this.convert13b(y.words, y.length, nrws, N);
  31999. this.transform(rws, _, rwst, iwst, N, rbt);
  32000. this.transform(nrws, _, nrwst, niwst, N, rbt);
  32001. for (var i = 0; i < N; i++) {
  32002. var rx = rwst[i] * nrwst[i] - iwst[i] * niwst[i];
  32003. iwst[i] = rwst[i] * niwst[i] + iwst[i] * nrwst[i];
  32004. rwst[i] = rx;
  32005. }
  32006. this.conjugate(rwst, iwst, N);
  32007. this.transform(rwst, iwst, rmws, _, N, rbt);
  32008. this.conjugate(rmws, _, N);
  32009. this.normalize13b(rmws, N);
  32010. out.negative = x.negative ^ y.negative;
  32011. out.length = x.length + y.length;
  32012. return out.strip();
  32013. };
  32014. // Multiply `this` by `num`
  32015. BN.prototype.mul = function mul (num) {
  32016. var out = new BN(null);
  32017. out.words = new Array(this.length + num.length);
  32018. return this.mulTo(num, out);
  32019. };
  32020. // Multiply employing FFT
  32021. BN.prototype.mulf = function mulf (num) {
  32022. var out = new BN(null);
  32023. out.words = new Array(this.length + num.length);
  32024. return jumboMulTo(this, num, out);
  32025. };
  32026. // In-place Multiplication
  32027. BN.prototype.imul = function imul (num) {
  32028. return this.clone().mulTo(num, this);
  32029. };
  32030. BN.prototype.imuln = function imuln (num) {
  32031. assert(typeof num === 'number');
  32032. assert(num < 0x4000000);
  32033. // Carry
  32034. var carry = 0;
  32035. for (var i = 0; i < this.length; i++) {
  32036. var w = (this.words[i] | 0) * num;
  32037. var lo = (w & 0x3ffffff) + (carry & 0x3ffffff);
  32038. carry >>= 26;
  32039. carry += (w / 0x4000000) | 0;
  32040. // NOTE: lo is 27bit maximum
  32041. carry += lo >>> 26;
  32042. this.words[i] = lo & 0x3ffffff;
  32043. }
  32044. if (carry !== 0) {
  32045. this.words[i] = carry;
  32046. this.length++;
  32047. }
  32048. return this;
  32049. };
  32050. BN.prototype.muln = function muln (num) {
  32051. return this.clone().imuln(num);
  32052. };
  32053. // `this` * `this`
  32054. BN.prototype.sqr = function sqr () {
  32055. return this.mul(this);
  32056. };
  32057. // `this` * `this` in-place
  32058. BN.prototype.isqr = function isqr () {
  32059. return this.imul(this.clone());
  32060. };
  32061. // Math.pow(`this`, `num`)
  32062. BN.prototype.pow = function pow (num) {
  32063. var w = toBitArray(num);
  32064. if (w.length === 0) return new BN(1);
  32065. // Skip leading zeroes
  32066. var res = this;
  32067. for (var i = 0; i < w.length; i++, res = res.sqr()) {
  32068. if (w[i] !== 0) break;
  32069. }
  32070. if (++i < w.length) {
  32071. for (var q = res.sqr(); i < w.length; i++, q = q.sqr()) {
  32072. if (w[i] === 0) continue;
  32073. res = res.mul(q);
  32074. }
  32075. }
  32076. return res;
  32077. };
  32078. // Shift-left in-place
  32079. BN.prototype.iushln = function iushln (bits) {
  32080. assert(typeof bits === 'number' && bits >= 0);
  32081. var r = bits % 26;
  32082. var s = (bits - r) / 26;
  32083. var carryMask = (0x3ffffff >>> (26 - r)) << (26 - r);
  32084. var i;
  32085. if (r !== 0) {
  32086. var carry = 0;
  32087. for (i = 0; i < this.length; i++) {
  32088. var newCarry = this.words[i] & carryMask;
  32089. var c = ((this.words[i] | 0) - newCarry) << r;
  32090. this.words[i] = c | carry;
  32091. carry = newCarry >>> (26 - r);
  32092. }
  32093. if (carry) {
  32094. this.words[i] = carry;
  32095. this.length++;
  32096. }
  32097. }
  32098. if (s !== 0) {
  32099. for (i = this.length - 1; i >= 0; i--) {
  32100. this.words[i + s] = this.words[i];
  32101. }
  32102. for (i = 0; i < s; i++) {
  32103. this.words[i] = 0;
  32104. }
  32105. this.length += s;
  32106. }
  32107. return this.strip();
  32108. };
  32109. BN.prototype.ishln = function ishln (bits) {
  32110. // TODO(indutny): implement me
  32111. assert(this.negative === 0);
  32112. return this.iushln(bits);
  32113. };
  32114. // Shift-right in-place
  32115. // NOTE: `hint` is a lowest bit before trailing zeroes
  32116. // NOTE: if `extended` is present - it will be filled with destroyed bits
  32117. BN.prototype.iushrn = function iushrn (bits, hint, extended) {
  32118. assert(typeof bits === 'number' && bits >= 0);
  32119. var h;
  32120. if (hint) {
  32121. h = (hint - (hint % 26)) / 26;
  32122. } else {
  32123. h = 0;
  32124. }
  32125. var r = bits % 26;
  32126. var s = Math.min((bits - r) / 26, this.length);
  32127. var mask = 0x3ffffff ^ ((0x3ffffff >>> r) << r);
  32128. var maskedWords = extended;
  32129. h -= s;
  32130. h = Math.max(0, h);
  32131. // Extended mode, copy masked part
  32132. if (maskedWords) {
  32133. for (var i = 0; i < s; i++) {
  32134. maskedWords.words[i] = this.words[i];
  32135. }
  32136. maskedWords.length = s;
  32137. }
  32138. if (s === 0) {
  32139. // No-op, we should not move anything at all
  32140. } else if (this.length > s) {
  32141. this.length -= s;
  32142. for (i = 0; i < this.length; i++) {
  32143. this.words[i] = this.words[i + s];
  32144. }
  32145. } else {
  32146. this.words[0] = 0;
  32147. this.length = 1;
  32148. }
  32149. var carry = 0;
  32150. for (i = this.length - 1; i >= 0 && (carry !== 0 || i >= h); i--) {
  32151. var word = this.words[i] | 0;
  32152. this.words[i] = (carry << (26 - r)) | (word >>> r);
  32153. carry = word & mask;
  32154. }
  32155. // Push carried bits as a mask
  32156. if (maskedWords && carry !== 0) {
  32157. maskedWords.words[maskedWords.length++] = carry;
  32158. }
  32159. if (this.length === 0) {
  32160. this.words[0] = 0;
  32161. this.length = 1;
  32162. }
  32163. return this.strip();
  32164. };
  32165. BN.prototype.ishrn = function ishrn (bits, hint, extended) {
  32166. // TODO(indutny): implement me
  32167. assert(this.negative === 0);
  32168. return this.iushrn(bits, hint, extended);
  32169. };
  32170. // Shift-left
  32171. BN.prototype.shln = function shln (bits) {
  32172. return this.clone().ishln(bits);
  32173. };
  32174. BN.prototype.ushln = function ushln (bits) {
  32175. return this.clone().iushln(bits);
  32176. };
  32177. // Shift-right
  32178. BN.prototype.shrn = function shrn (bits) {
  32179. return this.clone().ishrn(bits);
  32180. };
  32181. BN.prototype.ushrn = function ushrn (bits) {
  32182. return this.clone().iushrn(bits);
  32183. };
  32184. // Test if n bit is set
  32185. BN.prototype.testn = function testn (bit) {
  32186. assert(typeof bit === 'number' && bit >= 0);
  32187. var r = bit % 26;
  32188. var s = (bit - r) / 26;
  32189. var q = 1 << r;
  32190. // Fast case: bit is much higher than all existing words
  32191. if (this.length <= s) return false;
  32192. // Check bit and return
  32193. var w = this.words[s];
  32194. return !!(w & q);
  32195. };
  32196. // Return only lowers bits of number (in-place)
  32197. BN.prototype.imaskn = function imaskn (bits) {
  32198. assert(typeof bits === 'number' && bits >= 0);
  32199. var r = bits % 26;
  32200. var s = (bits - r) / 26;
  32201. assert(this.negative === 0, 'imaskn works only with positive numbers');
  32202. if (this.length <= s) {
  32203. return this;
  32204. }
  32205. if (r !== 0) {
  32206. s++;
  32207. }
  32208. this.length = Math.min(s, this.length);
  32209. if (r !== 0) {
  32210. var mask = 0x3ffffff ^ ((0x3ffffff >>> r) << r);
  32211. this.words[this.length - 1] &= mask;
  32212. }
  32213. return this.strip();
  32214. };
  32215. // Return only lowers bits of number
  32216. BN.prototype.maskn = function maskn (bits) {
  32217. return this.clone().imaskn(bits);
  32218. };
  32219. // Add plain number `num` to `this`
  32220. BN.prototype.iaddn = function iaddn (num) {
  32221. assert(typeof num === 'number');
  32222. assert(num < 0x4000000);
  32223. if (num < 0) return this.isubn(-num);
  32224. // Possible sign change
  32225. if (this.negative !== 0) {
  32226. if (this.length === 1 && (this.words[0] | 0) < num) {
  32227. this.words[0] = num - (this.words[0] | 0);
  32228. this.negative = 0;
  32229. return this;
  32230. }
  32231. this.negative = 0;
  32232. this.isubn(num);
  32233. this.negative = 1;
  32234. return this;
  32235. }
  32236. // Add without checks
  32237. return this._iaddn(num);
  32238. };
  32239. BN.prototype._iaddn = function _iaddn (num) {
  32240. this.words[0] += num;
  32241. // Carry
  32242. for (var i = 0; i < this.length && this.words[i] >= 0x4000000; i++) {
  32243. this.words[i] -= 0x4000000;
  32244. if (i === this.length - 1) {
  32245. this.words[i + 1] = 1;
  32246. } else {
  32247. this.words[i + 1]++;
  32248. }
  32249. }
  32250. this.length = Math.max(this.length, i + 1);
  32251. return this;
  32252. };
  32253. // Subtract plain number `num` from `this`
  32254. BN.prototype.isubn = function isubn (num) {
  32255. assert(typeof num === 'number');
  32256. assert(num < 0x4000000);
  32257. if (num < 0) return this.iaddn(-num);
  32258. if (this.negative !== 0) {
  32259. this.negative = 0;
  32260. this.iaddn(num);
  32261. this.negative = 1;
  32262. return this;
  32263. }
  32264. this.words[0] -= num;
  32265. if (this.length === 1 && this.words[0] < 0) {
  32266. this.words[0] = -this.words[0];
  32267. this.negative = 1;
  32268. } else {
  32269. // Carry
  32270. for (var i = 0; i < this.length && this.words[i] < 0; i++) {
  32271. this.words[i] += 0x4000000;
  32272. this.words[i + 1] -= 1;
  32273. }
  32274. }
  32275. return this.strip();
  32276. };
  32277. BN.prototype.addn = function addn (num) {
  32278. return this.clone().iaddn(num);
  32279. };
  32280. BN.prototype.subn = function subn (num) {
  32281. return this.clone().isubn(num);
  32282. };
  32283. BN.prototype.iabs = function iabs () {
  32284. this.negative = 0;
  32285. return this;
  32286. };
  32287. BN.prototype.abs = function abs () {
  32288. return this.clone().iabs();
  32289. };
  32290. BN.prototype._ishlnsubmul = function _ishlnsubmul (num, mul, shift) {
  32291. var len = num.length + shift;
  32292. var i;
  32293. this._expand(len);
  32294. var w;
  32295. var carry = 0;
  32296. for (i = 0; i < num.length; i++) {
  32297. w = (this.words[i + shift] | 0) + carry;
  32298. var right = (num.words[i] | 0) * mul;
  32299. w -= right & 0x3ffffff;
  32300. carry = (w >> 26) - ((right / 0x4000000) | 0);
  32301. this.words[i + shift] = w & 0x3ffffff;
  32302. }
  32303. for (; i < this.length - shift; i++) {
  32304. w = (this.words[i + shift] | 0) + carry;
  32305. carry = w >> 26;
  32306. this.words[i + shift] = w & 0x3ffffff;
  32307. }
  32308. if (carry === 0) return this.strip();
  32309. // Subtraction overflow
  32310. assert(carry === -1);
  32311. carry = 0;
  32312. for (i = 0; i < this.length; i++) {
  32313. w = -(this.words[i] | 0) + carry;
  32314. carry = w >> 26;
  32315. this.words[i] = w & 0x3ffffff;
  32316. }
  32317. this.negative = 1;
  32318. return this.strip();
  32319. };
  32320. BN.prototype._wordDiv = function _wordDiv (num, mode) {
  32321. var shift = this.length - num.length;
  32322. var a = this.clone();
  32323. var b = num;
  32324. // Normalize
  32325. var bhi = b.words[b.length - 1] | 0;
  32326. var bhiBits = this._countBits(bhi);
  32327. shift = 26 - bhiBits;
  32328. if (shift !== 0) {
  32329. b = b.ushln(shift);
  32330. a.iushln(shift);
  32331. bhi = b.words[b.length - 1] | 0;
  32332. }
  32333. // Initialize quotient
  32334. var m = a.length - b.length;
  32335. var q;
  32336. if (mode !== 'mod') {
  32337. q = new BN(null);
  32338. q.length = m + 1;
  32339. q.words = new Array(q.length);
  32340. for (var i = 0; i < q.length; i++) {
  32341. q.words[i] = 0;
  32342. }
  32343. }
  32344. var diff = a.clone()._ishlnsubmul(b, 1, m);
  32345. if (diff.negative === 0) {
  32346. a = diff;
  32347. if (q) {
  32348. q.words[m] = 1;
  32349. }
  32350. }
  32351. for (var j = m - 1; j >= 0; j--) {
  32352. var qj = (a.words[b.length + j] | 0) * 0x4000000 +
  32353. (a.words[b.length + j - 1] | 0);
  32354. // NOTE: (qj / bhi) is (0x3ffffff * 0x4000000 + 0x3ffffff) / 0x2000000 max
  32355. // (0x7ffffff)
  32356. qj = Math.min((qj / bhi) | 0, 0x3ffffff);
  32357. a._ishlnsubmul(b, qj, j);
  32358. while (a.negative !== 0) {
  32359. qj--;
  32360. a.negative = 0;
  32361. a._ishlnsubmul(b, 1, j);
  32362. if (!a.isZero()) {
  32363. a.negative ^= 1;
  32364. }
  32365. }
  32366. if (q) {
  32367. q.words[j] = qj;
  32368. }
  32369. }
  32370. if (q) {
  32371. q.strip();
  32372. }
  32373. a.strip();
  32374. // Denormalize
  32375. if (mode !== 'div' && shift !== 0) {
  32376. a.iushrn(shift);
  32377. }
  32378. return {
  32379. div: q || null,
  32380. mod: a
  32381. };
  32382. };
  32383. // NOTE: 1) `mode` can be set to `mod` to request mod only,
  32384. // to `div` to request div only, or be absent to
  32385. // request both div & mod
  32386. // 2) `positive` is true if unsigned mod is requested
  32387. BN.prototype.divmod = function divmod (num, mode, positive) {
  32388. assert(!num.isZero());
  32389. if (this.isZero()) {
  32390. return {
  32391. div: new BN(0),
  32392. mod: new BN(0)
  32393. };
  32394. }
  32395. var div, mod, res;
  32396. if (this.negative !== 0 && num.negative === 0) {
  32397. res = this.neg().divmod(num, mode);
  32398. if (mode !== 'mod') {
  32399. div = res.div.neg();
  32400. }
  32401. if (mode !== 'div') {
  32402. mod = res.mod.neg();
  32403. if (positive && mod.negative !== 0) {
  32404. mod.iadd(num);
  32405. }
  32406. }
  32407. return {
  32408. div: div,
  32409. mod: mod
  32410. };
  32411. }
  32412. if (this.negative === 0 && num.negative !== 0) {
  32413. res = this.divmod(num.neg(), mode);
  32414. if (mode !== 'mod') {
  32415. div = res.div.neg();
  32416. }
  32417. return {
  32418. div: div,
  32419. mod: res.mod
  32420. };
  32421. }
  32422. if ((this.negative & num.negative) !== 0) {
  32423. res = this.neg().divmod(num.neg(), mode);
  32424. if (mode !== 'div') {
  32425. mod = res.mod.neg();
  32426. if (positive && mod.negative !== 0) {
  32427. mod.isub(num);
  32428. }
  32429. }
  32430. return {
  32431. div: res.div,
  32432. mod: mod
  32433. };
  32434. }
  32435. // Both numbers are positive at this point
  32436. // Strip both numbers to approximate shift value
  32437. if (num.length > this.length || this.cmp(num) < 0) {
  32438. return {
  32439. div: new BN(0),
  32440. mod: this
  32441. };
  32442. }
  32443. // Very short reduction
  32444. if (num.length === 1) {
  32445. if (mode === 'div') {
  32446. return {
  32447. div: this.divn(num.words[0]),
  32448. mod: null
  32449. };
  32450. }
  32451. if (mode === 'mod') {
  32452. return {
  32453. div: null,
  32454. mod: new BN(this.modn(num.words[0]))
  32455. };
  32456. }
  32457. return {
  32458. div: this.divn(num.words[0]),
  32459. mod: new BN(this.modn(num.words[0]))
  32460. };
  32461. }
  32462. return this._wordDiv(num, mode);
  32463. };
  32464. // Find `this` / `num`
  32465. BN.prototype.div = function div (num) {
  32466. return this.divmod(num, 'div', false).div;
  32467. };
  32468. // Find `this` % `num`
  32469. BN.prototype.mod = function mod (num) {
  32470. return this.divmod(num, 'mod', false).mod;
  32471. };
  32472. BN.prototype.umod = function umod (num) {
  32473. return this.divmod(num, 'mod', true).mod;
  32474. };
  32475. // Find Round(`this` / `num`)
  32476. BN.prototype.divRound = function divRound (num) {
  32477. var dm = this.divmod(num);
  32478. // Fast case - exact division
  32479. if (dm.mod.isZero()) return dm.div;
  32480. var mod = dm.div.negative !== 0 ? dm.mod.isub(num) : dm.mod;
  32481. var half = num.ushrn(1);
  32482. var r2 = num.andln(1);
  32483. var cmp = mod.cmp(half);
  32484. // Round down
  32485. if (cmp < 0 || r2 === 1 && cmp === 0) return dm.div;
  32486. // Round up
  32487. return dm.div.negative !== 0 ? dm.div.isubn(1) : dm.div.iaddn(1);
  32488. };
  32489. BN.prototype.modn = function modn (num) {
  32490. assert(num <= 0x3ffffff);
  32491. var p = (1 << 26) % num;
  32492. var acc = 0;
  32493. for (var i = this.length - 1; i >= 0; i--) {
  32494. acc = (p * acc + (this.words[i] | 0)) % num;
  32495. }
  32496. return acc;
  32497. };
  32498. // In-place division by number
  32499. BN.prototype.idivn = function idivn (num) {
  32500. assert(num <= 0x3ffffff);
  32501. var carry = 0;
  32502. for (var i = this.length - 1; i >= 0; i--) {
  32503. var w = (this.words[i] | 0) + carry * 0x4000000;
  32504. this.words[i] = (w / num) | 0;
  32505. carry = w % num;
  32506. }
  32507. return this.strip();
  32508. };
  32509. BN.prototype.divn = function divn (num) {
  32510. return this.clone().idivn(num);
  32511. };
  32512. BN.prototype.egcd = function egcd (p) {
  32513. assert(p.negative === 0);
  32514. assert(!p.isZero());
  32515. var x = this;
  32516. var y = p.clone();
  32517. if (x.negative !== 0) {
  32518. x = x.umod(p);
  32519. } else {
  32520. x = x.clone();
  32521. }
  32522. // A * x + B * y = x
  32523. var A = new BN(1);
  32524. var B = new BN(0);
  32525. // C * x + D * y = y
  32526. var C = new BN(0);
  32527. var D = new BN(1);
  32528. var g = 0;
  32529. while (x.isEven() && y.isEven()) {
  32530. x.iushrn(1);
  32531. y.iushrn(1);
  32532. ++g;
  32533. }
  32534. var yp = y.clone();
  32535. var xp = x.clone();
  32536. while (!x.isZero()) {
  32537. for (var i = 0, im = 1; (x.words[0] & im) === 0 && i < 26; ++i, im <<= 1);
  32538. if (i > 0) {
  32539. x.iushrn(i);
  32540. while (i-- > 0) {
  32541. if (A.isOdd() || B.isOdd()) {
  32542. A.iadd(yp);
  32543. B.isub(xp);
  32544. }
  32545. A.iushrn(1);
  32546. B.iushrn(1);
  32547. }
  32548. }
  32549. for (var j = 0, jm = 1; (y.words[0] & jm) === 0 && j < 26; ++j, jm <<= 1);
  32550. if (j > 0) {
  32551. y.iushrn(j);
  32552. while (j-- > 0) {
  32553. if (C.isOdd() || D.isOdd()) {
  32554. C.iadd(yp);
  32555. D.isub(xp);
  32556. }
  32557. C.iushrn(1);
  32558. D.iushrn(1);
  32559. }
  32560. }
  32561. if (x.cmp(y) >= 0) {
  32562. x.isub(y);
  32563. A.isub(C);
  32564. B.isub(D);
  32565. } else {
  32566. y.isub(x);
  32567. C.isub(A);
  32568. D.isub(B);
  32569. }
  32570. }
  32571. return {
  32572. a: C,
  32573. b: D,
  32574. gcd: y.iushln(g)
  32575. };
  32576. };
  32577. // This is reduced incarnation of the binary EEA
  32578. // above, designated to invert members of the
  32579. // _prime_ fields F(p) at a maximal speed
  32580. BN.prototype._invmp = function _invmp (p) {
  32581. assert(p.negative === 0);
  32582. assert(!p.isZero());
  32583. var a = this;
  32584. var b = p.clone();
  32585. if (a.negative !== 0) {
  32586. a = a.umod(p);
  32587. } else {
  32588. a = a.clone();
  32589. }
  32590. var x1 = new BN(1);
  32591. var x2 = new BN(0);
  32592. var delta = b.clone();
  32593. while (a.cmpn(1) > 0 && b.cmpn(1) > 0) {
  32594. for (var i = 0, im = 1; (a.words[0] & im) === 0 && i < 26; ++i, im <<= 1);
  32595. if (i > 0) {
  32596. a.iushrn(i);
  32597. while (i-- > 0) {
  32598. if (x1.isOdd()) {
  32599. x1.iadd(delta);
  32600. }
  32601. x1.iushrn(1);
  32602. }
  32603. }
  32604. for (var j = 0, jm = 1; (b.words[0] & jm) === 0 && j < 26; ++j, jm <<= 1);
  32605. if (j > 0) {
  32606. b.iushrn(j);
  32607. while (j-- > 0) {
  32608. if (x2.isOdd()) {
  32609. x2.iadd(delta);
  32610. }
  32611. x2.iushrn(1);
  32612. }
  32613. }
  32614. if (a.cmp(b) >= 0) {
  32615. a.isub(b);
  32616. x1.isub(x2);
  32617. } else {
  32618. b.isub(a);
  32619. x2.isub(x1);
  32620. }
  32621. }
  32622. var res;
  32623. if (a.cmpn(1) === 0) {
  32624. res = x1;
  32625. } else {
  32626. res = x2;
  32627. }
  32628. if (res.cmpn(0) < 0) {
  32629. res.iadd(p);
  32630. }
  32631. return res;
  32632. };
  32633. BN.prototype.gcd = function gcd (num) {
  32634. if (this.isZero()) return num.abs();
  32635. if (num.isZero()) return this.abs();
  32636. var a = this.clone();
  32637. var b = num.clone();
  32638. a.negative = 0;
  32639. b.negative = 0;
  32640. // Remove common factor of two
  32641. for (var shift = 0; a.isEven() && b.isEven(); shift++) {
  32642. a.iushrn(1);
  32643. b.iushrn(1);
  32644. }
  32645. do {
  32646. while (a.isEven()) {
  32647. a.iushrn(1);
  32648. }
  32649. while (b.isEven()) {
  32650. b.iushrn(1);
  32651. }
  32652. var r = a.cmp(b);
  32653. if (r < 0) {
  32654. // Swap `a` and `b` to make `a` always bigger than `b`
  32655. var t = a;
  32656. a = b;
  32657. b = t;
  32658. } else if (r === 0 || b.cmpn(1) === 0) {
  32659. break;
  32660. }
  32661. a.isub(b);
  32662. } while (true);
  32663. return b.iushln(shift);
  32664. };
  32665. // Invert number in the field F(num)
  32666. BN.prototype.invm = function invm (num) {
  32667. return this.egcd(num).a.umod(num);
  32668. };
  32669. BN.prototype.isEven = function isEven () {
  32670. return (this.words[0] & 1) === 0;
  32671. };
  32672. BN.prototype.isOdd = function isOdd () {
  32673. return (this.words[0] & 1) === 1;
  32674. };
  32675. // And first word and num
  32676. BN.prototype.andln = function andln (num) {
  32677. return this.words[0] & num;
  32678. };
  32679. // Increment at the bit position in-line
  32680. BN.prototype.bincn = function bincn (bit) {
  32681. assert(typeof bit === 'number');
  32682. var r = bit % 26;
  32683. var s = (bit - r) / 26;
  32684. var q = 1 << r;
  32685. // Fast case: bit is much higher than all existing words
  32686. if (this.length <= s) {
  32687. this._expand(s + 1);
  32688. this.words[s] |= q;
  32689. return this;
  32690. }
  32691. // Add bit and propagate, if needed
  32692. var carry = q;
  32693. for (var i = s; carry !== 0 && i < this.length; i++) {
  32694. var w = this.words[i] | 0;
  32695. w += carry;
  32696. carry = w >>> 26;
  32697. w &= 0x3ffffff;
  32698. this.words[i] = w;
  32699. }
  32700. if (carry !== 0) {
  32701. this.words[i] = carry;
  32702. this.length++;
  32703. }
  32704. return this;
  32705. };
  32706. BN.prototype.isZero = function isZero () {
  32707. return this.length === 1 && this.words[0] === 0;
  32708. };
  32709. BN.prototype.cmpn = function cmpn (num) {
  32710. var negative = num < 0;
  32711. if (this.negative !== 0 && !negative) return -1;
  32712. if (this.negative === 0 && negative) return 1;
  32713. this.strip();
  32714. var res;
  32715. if (this.length > 1) {
  32716. res = 1;
  32717. } else {
  32718. if (negative) {
  32719. num = -num;
  32720. }
  32721. assert(num <= 0x3ffffff, 'Number is too big');
  32722. var w = this.words[0] | 0;
  32723. res = w === num ? 0 : w < num ? -1 : 1;
  32724. }
  32725. if (this.negative !== 0) return -res | 0;
  32726. return res;
  32727. };
  32728. // Compare two numbers and return:
  32729. // 1 - if `this` > `num`
  32730. // 0 - if `this` == `num`
  32731. // -1 - if `this` < `num`
  32732. BN.prototype.cmp = function cmp (num) {
  32733. if (this.negative !== 0 && num.negative === 0) return -1;
  32734. if (this.negative === 0 && num.negative !== 0) return 1;
  32735. var res = this.ucmp(num);
  32736. if (this.negative !== 0) return -res | 0;
  32737. return res;
  32738. };
  32739. // Unsigned comparison
  32740. BN.prototype.ucmp = function ucmp (num) {
  32741. // At this point both numbers have the same sign
  32742. if (this.length > num.length) return 1;
  32743. if (this.length < num.length) return -1;
  32744. var res = 0;
  32745. for (var i = this.length - 1; i >= 0; i--) {
  32746. var a = this.words[i] | 0;
  32747. var b = num.words[i] | 0;
  32748. if (a === b) continue;
  32749. if (a < b) {
  32750. res = -1;
  32751. } else if (a > b) {
  32752. res = 1;
  32753. }
  32754. break;
  32755. }
  32756. return res;
  32757. };
  32758. BN.prototype.gtn = function gtn (num) {
  32759. return this.cmpn(num) === 1;
  32760. };
  32761. BN.prototype.gt = function gt (num) {
  32762. return this.cmp(num) === 1;
  32763. };
  32764. BN.prototype.gten = function gten (num) {
  32765. return this.cmpn(num) >= 0;
  32766. };
  32767. BN.prototype.gte = function gte (num) {
  32768. return this.cmp(num) >= 0;
  32769. };
  32770. BN.prototype.ltn = function ltn (num) {
  32771. return this.cmpn(num) === -1;
  32772. };
  32773. BN.prototype.lt = function lt (num) {
  32774. return this.cmp(num) === -1;
  32775. };
  32776. BN.prototype.lten = function lten (num) {
  32777. return this.cmpn(num) <= 0;
  32778. };
  32779. BN.prototype.lte = function lte (num) {
  32780. return this.cmp(num) <= 0;
  32781. };
  32782. BN.prototype.eqn = function eqn (num) {
  32783. return this.cmpn(num) === 0;
  32784. };
  32785. BN.prototype.eq = function eq (num) {
  32786. return this.cmp(num) === 0;
  32787. };
  32788. //
  32789. // A reduce context, could be using montgomery or something better, depending
  32790. // on the `m` itself.
  32791. //
  32792. BN.red = function red (num) {
  32793. return new Red(num);
  32794. };
  32795. BN.prototype.toRed = function toRed (ctx) {
  32796. assert(!this.red, 'Already a number in reduction context');
  32797. assert(this.negative === 0, 'red works only with positives');
  32798. return ctx.convertTo(this)._forceRed(ctx);
  32799. };
  32800. BN.prototype.fromRed = function fromRed () {
  32801. assert(this.red, 'fromRed works only with numbers in reduction context');
  32802. return this.red.convertFrom(this);
  32803. };
  32804. BN.prototype._forceRed = function _forceRed (ctx) {
  32805. this.red = ctx;
  32806. return this;
  32807. };
  32808. BN.prototype.forceRed = function forceRed (ctx) {
  32809. assert(!this.red, 'Already a number in reduction context');
  32810. return this._forceRed(ctx);
  32811. };
  32812. BN.prototype.redAdd = function redAdd (num) {
  32813. assert(this.red, 'redAdd works only with red numbers');
  32814. return this.red.add(this, num);
  32815. };
  32816. BN.prototype.redIAdd = function redIAdd (num) {
  32817. assert(this.red, 'redIAdd works only with red numbers');
  32818. return this.red.iadd(this, num);
  32819. };
  32820. BN.prototype.redSub = function redSub (num) {
  32821. assert(this.red, 'redSub works only with red numbers');
  32822. return this.red.sub(this, num);
  32823. };
  32824. BN.prototype.redISub = function redISub (num) {
  32825. assert(this.red, 'redISub works only with red numbers');
  32826. return this.red.isub(this, num);
  32827. };
  32828. BN.prototype.redShl = function redShl (num) {
  32829. assert(this.red, 'redShl works only with red numbers');
  32830. return this.red.shl(this, num);
  32831. };
  32832. BN.prototype.redMul = function redMul (num) {
  32833. assert(this.red, 'redMul works only with red numbers');
  32834. this.red._verify2(this, num);
  32835. return this.red.mul(this, num);
  32836. };
  32837. BN.prototype.redIMul = function redIMul (num) {
  32838. assert(this.red, 'redMul works only with red numbers');
  32839. this.red._verify2(this, num);
  32840. return this.red.imul(this, num);
  32841. };
  32842. BN.prototype.redSqr = function redSqr () {
  32843. assert(this.red, 'redSqr works only with red numbers');
  32844. this.red._verify1(this);
  32845. return this.red.sqr(this);
  32846. };
  32847. BN.prototype.redISqr = function redISqr () {
  32848. assert(this.red, 'redISqr works only with red numbers');
  32849. this.red._verify1(this);
  32850. return this.red.isqr(this);
  32851. };
  32852. // Square root over p
  32853. BN.prototype.redSqrt = function redSqrt () {
  32854. assert(this.red, 'redSqrt works only with red numbers');
  32855. this.red._verify1(this);
  32856. return this.red.sqrt(this);
  32857. };
  32858. BN.prototype.redInvm = function redInvm () {
  32859. assert(this.red, 'redInvm works only with red numbers');
  32860. this.red._verify1(this);
  32861. return this.red.invm(this);
  32862. };
  32863. // Return negative clone of `this` % `red modulo`
  32864. BN.prototype.redNeg = function redNeg () {
  32865. assert(this.red, 'redNeg works only with red numbers');
  32866. this.red._verify1(this);
  32867. return this.red.neg(this);
  32868. };
  32869. BN.prototype.redPow = function redPow (num) {
  32870. assert(this.red && !num.red, 'redPow(normalNum)');
  32871. this.red._verify1(this);
  32872. return this.red.pow(this, num);
  32873. };
  32874. // Prime numbers with efficient reduction
  32875. var primes = {
  32876. k256: null,
  32877. p224: null,
  32878. p192: null,
  32879. p25519: null
  32880. };
  32881. // Pseudo-Mersenne prime
  32882. function MPrime (name, p) {
  32883. // P = 2 ^ N - K
  32884. this.name = name;
  32885. this.p = new BN(p, 16);
  32886. this.n = this.p.bitLength();
  32887. this.k = new BN(1).iushln(this.n).isub(this.p);
  32888. this.tmp = this._tmp();
  32889. }
  32890. MPrime.prototype._tmp = function _tmp () {
  32891. var tmp = new BN(null);
  32892. tmp.words = new Array(Math.ceil(this.n / 13));
  32893. return tmp;
  32894. };
  32895. MPrime.prototype.ireduce = function ireduce (num) {
  32896. // Assumes that `num` is less than `P^2`
  32897. // num = HI * (2 ^ N - K) + HI * K + LO = HI * K + LO (mod P)
  32898. var r = num;
  32899. var rlen;
  32900. do {
  32901. this.split(r, this.tmp);
  32902. r = this.imulK(r);
  32903. r = r.iadd(this.tmp);
  32904. rlen = r.bitLength();
  32905. } while (rlen > this.n);
  32906. var cmp = rlen < this.n ? -1 : r.ucmp(this.p);
  32907. if (cmp === 0) {
  32908. r.words[0] = 0;
  32909. r.length = 1;
  32910. } else if (cmp > 0) {
  32911. r.isub(this.p);
  32912. } else {
  32913. if (r.strip !== undefined) {
  32914. // r is BN v4 instance
  32915. r.strip();
  32916. } else {
  32917. // r is BN v5 instance
  32918. r._strip();
  32919. }
  32920. }
  32921. return r;
  32922. };
  32923. MPrime.prototype.split = function split (input, out) {
  32924. input.iushrn(this.n, 0, out);
  32925. };
  32926. MPrime.prototype.imulK = function imulK (num) {
  32927. return num.imul(this.k);
  32928. };
  32929. function K256 () {
  32930. MPrime.call(
  32931. this,
  32932. 'k256',
  32933. 'ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe fffffc2f');
  32934. }
  32935. inherits(K256, MPrime);
  32936. K256.prototype.split = function split (input, output) {
  32937. // 256 = 9 * 26 + 22
  32938. var mask = 0x3fffff;
  32939. var outLen = Math.min(input.length, 9);
  32940. for (var i = 0; i < outLen; i++) {
  32941. output.words[i] = input.words[i];
  32942. }
  32943. output.length = outLen;
  32944. if (input.length <= 9) {
  32945. input.words[0] = 0;
  32946. input.length = 1;
  32947. return;
  32948. }
  32949. // Shift by 9 limbs
  32950. var prev = input.words[9];
  32951. output.words[output.length++] = prev & mask;
  32952. for (i = 10; i < input.length; i++) {
  32953. var next = input.words[i] | 0;
  32954. input.words[i - 10] = ((next & mask) << 4) | (prev >>> 22);
  32955. prev = next;
  32956. }
  32957. prev >>>= 22;
  32958. input.words[i - 10] = prev;
  32959. if (prev === 0 && input.length > 10) {
  32960. input.length -= 10;
  32961. } else {
  32962. input.length -= 9;
  32963. }
  32964. };
  32965. K256.prototype.imulK = function imulK (num) {
  32966. // K = 0x1000003d1 = [ 0x40, 0x3d1 ]
  32967. num.words[num.length] = 0;
  32968. num.words[num.length + 1] = 0;
  32969. num.length += 2;
  32970. // bounded at: 0x40 * 0x3ffffff + 0x3d0 = 0x100000390
  32971. var lo = 0;
  32972. for (var i = 0; i < num.length; i++) {
  32973. var w = num.words[i] | 0;
  32974. lo += w * 0x3d1;
  32975. num.words[i] = lo & 0x3ffffff;
  32976. lo = w * 0x40 + ((lo / 0x4000000) | 0);
  32977. }
  32978. // Fast length reduction
  32979. if (num.words[num.length - 1] === 0) {
  32980. num.length--;
  32981. if (num.words[num.length - 1] === 0) {
  32982. num.length--;
  32983. }
  32984. }
  32985. return num;
  32986. };
  32987. function P224 () {
  32988. MPrime.call(
  32989. this,
  32990. 'p224',
  32991. 'ffffffff ffffffff ffffffff ffffffff 00000000 00000000 00000001');
  32992. }
  32993. inherits(P224, MPrime);
  32994. function P192 () {
  32995. MPrime.call(
  32996. this,
  32997. 'p192',
  32998. 'ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff');
  32999. }
  33000. inherits(P192, MPrime);
  33001. function P25519 () {
  33002. // 2 ^ 255 - 19
  33003. MPrime.call(
  33004. this,
  33005. '25519',
  33006. '7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed');
  33007. }
  33008. inherits(P25519, MPrime);
  33009. P25519.prototype.imulK = function imulK (num) {
  33010. // K = 0x13
  33011. var carry = 0;
  33012. for (var i = 0; i < num.length; i++) {
  33013. var hi = (num.words[i] | 0) * 0x13 + carry;
  33014. var lo = hi & 0x3ffffff;
  33015. hi >>>= 26;
  33016. num.words[i] = lo;
  33017. carry = hi;
  33018. }
  33019. if (carry !== 0) {
  33020. num.words[num.length++] = carry;
  33021. }
  33022. return num;
  33023. };
  33024. // Exported mostly for testing purposes, use plain name instead
  33025. BN._prime = function prime (name) {
  33026. // Cached version of prime
  33027. if (primes[name]) return primes[name];
  33028. var prime;
  33029. if (name === 'k256') {
  33030. prime = new K256();
  33031. } else if (name === 'p224') {
  33032. prime = new P224();
  33033. } else if (name === 'p192') {
  33034. prime = new P192();
  33035. } else if (name === 'p25519') {
  33036. prime = new P25519();
  33037. } else {
  33038. throw new Error('Unknown prime ' + name);
  33039. }
  33040. primes[name] = prime;
  33041. return prime;
  33042. };
  33043. //
  33044. // Base reduction engine
  33045. //
  33046. function Red (m) {
  33047. if (typeof m === 'string') {
  33048. var prime = BN._prime(m);
  33049. this.m = prime.p;
  33050. this.prime = prime;
  33051. } else {
  33052. assert(m.gtn(1), 'modulus must be greater than 1');
  33053. this.m = m;
  33054. this.prime = null;
  33055. }
  33056. }
  33057. Red.prototype._verify1 = function _verify1 (a) {
  33058. assert(a.negative === 0, 'red works only with positives');
  33059. assert(a.red, 'red works only with red numbers');
  33060. };
  33061. Red.prototype._verify2 = function _verify2 (a, b) {
  33062. assert((a.negative | b.negative) === 0, 'red works only with positives');
  33063. assert(a.red && a.red === b.red,
  33064. 'red works only with red numbers');
  33065. };
  33066. Red.prototype.imod = function imod (a) {
  33067. if (this.prime) return this.prime.ireduce(a)._forceRed(this);
  33068. return a.umod(this.m)._forceRed(this);
  33069. };
  33070. Red.prototype.neg = function neg (a) {
  33071. if (a.isZero()) {
  33072. return a.clone();
  33073. }
  33074. return this.m.sub(a)._forceRed(this);
  33075. };
  33076. Red.prototype.add = function add (a, b) {
  33077. this._verify2(a, b);
  33078. var res = a.add(b);
  33079. if (res.cmp(this.m) >= 0) {
  33080. res.isub(this.m);
  33081. }
  33082. return res._forceRed(this);
  33083. };
  33084. Red.prototype.iadd = function iadd (a, b) {
  33085. this._verify2(a, b);
  33086. var res = a.iadd(b);
  33087. if (res.cmp(this.m) >= 0) {
  33088. res.isub(this.m);
  33089. }
  33090. return res;
  33091. };
  33092. Red.prototype.sub = function sub (a, b) {
  33093. this._verify2(a, b);
  33094. var res = a.sub(b);
  33095. if (res.cmpn(0) < 0) {
  33096. res.iadd(this.m);
  33097. }
  33098. return res._forceRed(this);
  33099. };
  33100. Red.prototype.isub = function isub (a, b) {
  33101. this._verify2(a, b);
  33102. var res = a.isub(b);
  33103. if (res.cmpn(0) < 0) {
  33104. res.iadd(this.m);
  33105. }
  33106. return res;
  33107. };
  33108. Red.prototype.shl = function shl (a, num) {
  33109. this._verify1(a);
  33110. return this.imod(a.ushln(num));
  33111. };
  33112. Red.prototype.imul = function imul (a, b) {
  33113. this._verify2(a, b);
  33114. return this.imod(a.imul(b));
  33115. };
  33116. Red.prototype.mul = function mul (a, b) {
  33117. this._verify2(a, b);
  33118. return this.imod(a.mul(b));
  33119. };
  33120. Red.prototype.isqr = function isqr (a) {
  33121. return this.imul(a, a.clone());
  33122. };
  33123. Red.prototype.sqr = function sqr (a) {
  33124. return this.mul(a, a);
  33125. };
  33126. Red.prototype.sqrt = function sqrt (a) {
  33127. if (a.isZero()) return a.clone();
  33128. var mod3 = this.m.andln(3);
  33129. assert(mod3 % 2 === 1);
  33130. // Fast case
  33131. if (mod3 === 3) {
  33132. var pow = this.m.add(new BN(1)).iushrn(2);
  33133. return this.pow(a, pow);
  33134. }
  33135. // Tonelli-Shanks algorithm (Totally unoptimized and slow)
  33136. //
  33137. // Find Q and S, that Q * 2 ^ S = (P - 1)
  33138. var q = this.m.subn(1);
  33139. var s = 0;
  33140. while (!q.isZero() && q.andln(1) === 0) {
  33141. s++;
  33142. q.iushrn(1);
  33143. }
  33144. assert(!q.isZero());
  33145. var one = new BN(1).toRed(this);
  33146. var nOne = one.redNeg();
  33147. // Find quadratic non-residue
  33148. // NOTE: Max is such because of generalized Riemann hypothesis.
  33149. var lpow = this.m.subn(1).iushrn(1);
  33150. var z = this.m.bitLength();
  33151. z = new BN(2 * z * z).toRed(this);
  33152. while (this.pow(z, lpow).cmp(nOne) !== 0) {
  33153. z.redIAdd(nOne);
  33154. }
  33155. var c = this.pow(z, q);
  33156. var r = this.pow(a, q.addn(1).iushrn(1));
  33157. var t = this.pow(a, q);
  33158. var m = s;
  33159. while (t.cmp(one) !== 0) {
  33160. var tmp = t;
  33161. for (var i = 0; tmp.cmp(one) !== 0; i++) {
  33162. tmp = tmp.redSqr();
  33163. }
  33164. assert(i < m);
  33165. var b = this.pow(c, new BN(1).iushln(m - i - 1));
  33166. r = r.redMul(b);
  33167. c = b.redSqr();
  33168. t = t.redMul(c);
  33169. m = i;
  33170. }
  33171. return r;
  33172. };
  33173. Red.prototype.invm = function invm (a) {
  33174. var inv = a._invmp(this.m);
  33175. if (inv.negative !== 0) {
  33176. inv.negative = 0;
  33177. return this.imod(inv).redNeg();
  33178. } else {
  33179. return this.imod(inv);
  33180. }
  33181. };
  33182. Red.prototype.pow = function pow (a, num) {
  33183. if (num.isZero()) return new BN(1).toRed(this);
  33184. if (num.cmpn(1) === 0) return a.clone();
  33185. var windowSize = 4;
  33186. var wnd = new Array(1 << windowSize);
  33187. wnd[0] = new BN(1).toRed(this);
  33188. wnd[1] = a;
  33189. for (var i = 2; i < wnd.length; i++) {
  33190. wnd[i] = this.mul(wnd[i - 1], a);
  33191. }
  33192. var res = wnd[0];
  33193. var current = 0;
  33194. var currentLen = 0;
  33195. var start = num.bitLength() % 26;
  33196. if (start === 0) {
  33197. start = 26;
  33198. }
  33199. for (i = num.length - 1; i >= 0; i--) {
  33200. var word = num.words[i];
  33201. for (var j = start - 1; j >= 0; j--) {
  33202. var bit = (word >> j) & 1;
  33203. if (res !== wnd[0]) {
  33204. res = this.sqr(res);
  33205. }
  33206. if (bit === 0 && current === 0) {
  33207. currentLen = 0;
  33208. continue;
  33209. }
  33210. current <<= 1;
  33211. current |= bit;
  33212. currentLen++;
  33213. if (currentLen !== windowSize && (i !== 0 || j !== 0)) continue;
  33214. res = this.mul(res, wnd[current]);
  33215. currentLen = 0;
  33216. current = 0;
  33217. }
  33218. start = 26;
  33219. }
  33220. return res;
  33221. };
  33222. Red.prototype.convertTo = function convertTo (num) {
  33223. var r = num.umod(this.m);
  33224. return r === num ? r.clone() : r;
  33225. };
  33226. Red.prototype.convertFrom = function convertFrom (num) {
  33227. var res = num.clone();
  33228. res.red = null;
  33229. return res;
  33230. };
  33231. //
  33232. // Montgomery method engine
  33233. //
  33234. BN.mont = function mont (num) {
  33235. return new Mont(num);
  33236. };
  33237. function Mont (m) {
  33238. Red.call(this, m);
  33239. this.shift = this.m.bitLength();
  33240. if (this.shift % 26 !== 0) {
  33241. this.shift += 26 - (this.shift % 26);
  33242. }
  33243. this.r = new BN(1).iushln(this.shift);
  33244. this.r2 = this.imod(this.r.sqr());
  33245. this.rinv = this.r._invmp(this.m);
  33246. this.minv = this.rinv.mul(this.r).isubn(1).div(this.m);
  33247. this.minv = this.minv.umod(this.r);
  33248. this.minv = this.r.sub(this.minv);
  33249. }
  33250. inherits(Mont, Red);
  33251. Mont.prototype.convertTo = function convertTo (num) {
  33252. return this.imod(num.ushln(this.shift));
  33253. };
  33254. Mont.prototype.convertFrom = function convertFrom (num) {
  33255. var r = this.imod(num.mul(this.rinv));
  33256. r.red = null;
  33257. return r;
  33258. };
  33259. Mont.prototype.imul = function imul (a, b) {
  33260. if (a.isZero() || b.isZero()) {
  33261. a.words[0] = 0;
  33262. a.length = 1;
  33263. return a;
  33264. }
  33265. var t = a.imul(b);
  33266. var c = t.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m);
  33267. var u = t.isub(c).iushrn(this.shift);
  33268. var res = u;
  33269. if (u.cmp(this.m) >= 0) {
  33270. res = u.isub(this.m);
  33271. } else if (u.cmpn(0) < 0) {
  33272. res = u.iadd(this.m);
  33273. }
  33274. return res._forceRed(this);
  33275. };
  33276. Mont.prototype.mul = function mul (a, b) {
  33277. if (a.isZero() || b.isZero()) return new BN(0)._forceRed(this);
  33278. var t = a.mul(b);
  33279. var c = t.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m);
  33280. var u = t.isub(c).iushrn(this.shift);
  33281. var res = u;
  33282. if (u.cmp(this.m) >= 0) {
  33283. res = u.isub(this.m);
  33284. } else if (u.cmpn(0) < 0) {
  33285. res = u.iadd(this.m);
  33286. }
  33287. return res._forceRed(this);
  33288. };
  33289. Mont.prototype.invm = function invm (a) {
  33290. // (AR)^-1 * R^2 = (A^-1 * R^-1) * R^2 = A^-1 * R
  33291. var res = this.imod(a._invmp(this.m).mul(this.r2));
  33292. return res._forceRed(this);
  33293. };
  33294. })(typeof module === 'undefined' || module, this);
  33295. },{"buffer":undefined}],198:[function(_dereq_,module,exports){
  33296. "use strict";
  33297. Object.defineProperty(exports, "__esModule", { value: true });
  33298. exports.version = void 0;
  33299. exports.version = "bytes/5.6.0";
  33300. },{}],199:[function(_dereq_,module,exports){
  33301. "use strict";
  33302. Object.defineProperty(exports, "__esModule", { value: true });
  33303. exports.joinSignature = exports.splitSignature = exports.hexZeroPad = exports.hexStripZeros = exports.hexValue = exports.hexConcat = exports.hexDataSlice = exports.hexDataLength = exports.hexlify = exports.isHexString = exports.zeroPad = exports.stripZeros = exports.concat = exports.arrayify = exports.isBytes = exports.isBytesLike = void 0;
  33304. var logger_1 = _dereq_("@ethersproject/logger");
  33305. var _version_1 = _dereq_("./_version");
  33306. var logger = new logger_1.Logger(_version_1.version);
  33307. ///////////////////////////////
  33308. function isHexable(value) {
  33309. return !!(value.toHexString);
  33310. }
  33311. function addSlice(array) {
  33312. if (array.slice) {
  33313. return array;
  33314. }
  33315. array.slice = function () {
  33316. var args = Array.prototype.slice.call(arguments);
  33317. return addSlice(new Uint8Array(Array.prototype.slice.apply(array, args)));
  33318. };
  33319. return array;
  33320. }
  33321. function isBytesLike(value) {
  33322. return ((isHexString(value) && !(value.length % 2)) || isBytes(value));
  33323. }
  33324. exports.isBytesLike = isBytesLike;
  33325. function isInteger(value) {
  33326. return (typeof (value) === "number" && value == value && (value % 1) === 0);
  33327. }
  33328. function isBytes(value) {
  33329. if (value == null) {
  33330. return false;
  33331. }
  33332. if (value.constructor === Uint8Array) {
  33333. return true;
  33334. }
  33335. if (typeof (value) === "string") {
  33336. return false;
  33337. }
  33338. if (!isInteger(value.length) || value.length < 0) {
  33339. return false;
  33340. }
  33341. for (var i = 0; i < value.length; i++) {
  33342. var v = value[i];
  33343. if (!isInteger(v) || v < 0 || v >= 256) {
  33344. return false;
  33345. }
  33346. }
  33347. return true;
  33348. }
  33349. exports.isBytes = isBytes;
  33350. function arrayify(value, options) {
  33351. if (!options) {
  33352. options = {};
  33353. }
  33354. if (typeof (value) === "number") {
  33355. logger.checkSafeUint53(value, "invalid arrayify value");
  33356. var result = [];
  33357. while (value) {
  33358. result.unshift(value & 0xff);
  33359. value = parseInt(String(value / 256));
  33360. }
  33361. if (result.length === 0) {
  33362. result.push(0);
  33363. }
  33364. return addSlice(new Uint8Array(result));
  33365. }
  33366. if (options.allowMissingPrefix && typeof (value) === "string" && value.substring(0, 2) !== "0x") {
  33367. value = "0x" + value;
  33368. }
  33369. if (isHexable(value)) {
  33370. value = value.toHexString();
  33371. }
  33372. if (isHexString(value)) {
  33373. var hex = value.substring(2);
  33374. if (hex.length % 2) {
  33375. if (options.hexPad === "left") {
  33376. hex = "0x0" + hex.substring(2);
  33377. }
  33378. else if (options.hexPad === "right") {
  33379. hex += "0";
  33380. }
  33381. else {
  33382. logger.throwArgumentError("hex data is odd-length", "value", value);
  33383. }
  33384. }
  33385. var result = [];
  33386. for (var i = 0; i < hex.length; i += 2) {
  33387. result.push(parseInt(hex.substring(i, i + 2), 16));
  33388. }
  33389. return addSlice(new Uint8Array(result));
  33390. }
  33391. if (isBytes(value)) {
  33392. return addSlice(new Uint8Array(value));
  33393. }
  33394. return logger.throwArgumentError("invalid arrayify value", "value", value);
  33395. }
  33396. exports.arrayify = arrayify;
  33397. function concat(items) {
  33398. var objects = items.map(function (item) { return arrayify(item); });
  33399. var length = objects.reduce(function (accum, item) { return (accum + item.length); }, 0);
  33400. var result = new Uint8Array(length);
  33401. objects.reduce(function (offset, object) {
  33402. result.set(object, offset);
  33403. return offset + object.length;
  33404. }, 0);
  33405. return addSlice(result);
  33406. }
  33407. exports.concat = concat;
  33408. function stripZeros(value) {
  33409. var result = arrayify(value);
  33410. if (result.length === 0) {
  33411. return result;
  33412. }
  33413. // Find the first non-zero entry
  33414. var start = 0;
  33415. while (start < result.length && result[start] === 0) {
  33416. start++;
  33417. }
  33418. // If we started with zeros, strip them
  33419. if (start) {
  33420. result = result.slice(start);
  33421. }
  33422. return result;
  33423. }
  33424. exports.stripZeros = stripZeros;
  33425. function zeroPad(value, length) {
  33426. value = arrayify(value);
  33427. if (value.length > length) {
  33428. logger.throwArgumentError("value out of range", "value", arguments[0]);
  33429. }
  33430. var result = new Uint8Array(length);
  33431. result.set(value, length - value.length);
  33432. return addSlice(result);
  33433. }
  33434. exports.zeroPad = zeroPad;
  33435. function isHexString(value, length) {
  33436. if (typeof (value) !== "string" || !value.match(/^0x[0-9A-Fa-f]*$/)) {
  33437. return false;
  33438. }
  33439. if (length && value.length !== 2 + 2 * length) {
  33440. return false;
  33441. }
  33442. return true;
  33443. }
  33444. exports.isHexString = isHexString;
  33445. var HexCharacters = "0123456789abcdef";
  33446. function hexlify(value, options) {
  33447. if (!options) {
  33448. options = {};
  33449. }
  33450. if (typeof (value) === "number") {
  33451. logger.checkSafeUint53(value, "invalid hexlify value");
  33452. var hex = "";
  33453. while (value) {
  33454. hex = HexCharacters[value & 0xf] + hex;
  33455. value = Math.floor(value / 16);
  33456. }
  33457. if (hex.length) {
  33458. if (hex.length % 2) {
  33459. hex = "0" + hex;
  33460. }
  33461. return "0x" + hex;
  33462. }
  33463. return "0x00";
  33464. }
  33465. if (typeof (value) === "bigint") {
  33466. value = value.toString(16);
  33467. if (value.length % 2) {
  33468. return ("0x0" + value);
  33469. }
  33470. return "0x" + value;
  33471. }
  33472. if (options.allowMissingPrefix && typeof (value) === "string" && value.substring(0, 2) !== "0x") {
  33473. value = "0x" + value;
  33474. }
  33475. if (isHexable(value)) {
  33476. return value.toHexString();
  33477. }
  33478. if (isHexString(value)) {
  33479. if (value.length % 2) {
  33480. if (options.hexPad === "left") {
  33481. value = "0x0" + value.substring(2);
  33482. }
  33483. else if (options.hexPad === "right") {
  33484. value += "0";
  33485. }
  33486. else {
  33487. logger.throwArgumentError("hex data is odd-length", "value", value);
  33488. }
  33489. }
  33490. return value.toLowerCase();
  33491. }
  33492. if (isBytes(value)) {
  33493. var result = "0x";
  33494. for (var i = 0; i < value.length; i++) {
  33495. var v = value[i];
  33496. result += HexCharacters[(v & 0xf0) >> 4] + HexCharacters[v & 0x0f];
  33497. }
  33498. return result;
  33499. }
  33500. return logger.throwArgumentError("invalid hexlify value", "value", value);
  33501. }
  33502. exports.hexlify = hexlify;
  33503. /*
  33504. function unoddify(value: BytesLike | Hexable | number): BytesLike | Hexable | number {
  33505. if (typeof(value) === "string" && value.length % 2 && value.substring(0, 2) === "0x") {
  33506. return "0x0" + value.substring(2);
  33507. }
  33508. return value;
  33509. }
  33510. */
  33511. function hexDataLength(data) {
  33512. if (typeof (data) !== "string") {
  33513. data = hexlify(data);
  33514. }
  33515. else if (!isHexString(data) || (data.length % 2)) {
  33516. return null;
  33517. }
  33518. return (data.length - 2) / 2;
  33519. }
  33520. exports.hexDataLength = hexDataLength;
  33521. function hexDataSlice(data, offset, endOffset) {
  33522. if (typeof (data) !== "string") {
  33523. data = hexlify(data);
  33524. }
  33525. else if (!isHexString(data) || (data.length % 2)) {
  33526. logger.throwArgumentError("invalid hexData", "value", data);
  33527. }
  33528. offset = 2 + 2 * offset;
  33529. if (endOffset != null) {
  33530. return "0x" + data.substring(offset, 2 + 2 * endOffset);
  33531. }
  33532. return "0x" + data.substring(offset);
  33533. }
  33534. exports.hexDataSlice = hexDataSlice;
  33535. function hexConcat(items) {
  33536. var result = "0x";
  33537. items.forEach(function (item) {
  33538. result += hexlify(item).substring(2);
  33539. });
  33540. return result;
  33541. }
  33542. exports.hexConcat = hexConcat;
  33543. function hexValue(value) {
  33544. var trimmed = hexStripZeros(hexlify(value, { hexPad: "left" }));
  33545. if (trimmed === "0x") {
  33546. return "0x0";
  33547. }
  33548. return trimmed;
  33549. }
  33550. exports.hexValue = hexValue;
  33551. function hexStripZeros(value) {
  33552. if (typeof (value) !== "string") {
  33553. value = hexlify(value);
  33554. }
  33555. if (!isHexString(value)) {
  33556. logger.throwArgumentError("invalid hex string", "value", value);
  33557. }
  33558. value = value.substring(2);
  33559. var offset = 0;
  33560. while (offset < value.length && value[offset] === "0") {
  33561. offset++;
  33562. }
  33563. return "0x" + value.substring(offset);
  33564. }
  33565. exports.hexStripZeros = hexStripZeros;
  33566. function hexZeroPad(value, length) {
  33567. if (typeof (value) !== "string") {
  33568. value = hexlify(value);
  33569. }
  33570. else if (!isHexString(value)) {
  33571. logger.throwArgumentError("invalid hex string", "value", value);
  33572. }
  33573. if (value.length > 2 * length + 2) {
  33574. logger.throwArgumentError("value out of range", "value", arguments[1]);
  33575. }
  33576. while (value.length < 2 * length + 2) {
  33577. value = "0x0" + value.substring(2);
  33578. }
  33579. return value;
  33580. }
  33581. exports.hexZeroPad = hexZeroPad;
  33582. function splitSignature(signature) {
  33583. var result = {
  33584. r: "0x",
  33585. s: "0x",
  33586. _vs: "0x",
  33587. recoveryParam: 0,
  33588. v: 0,
  33589. yParityAndS: "0x",
  33590. compact: "0x"
  33591. };
  33592. if (isBytesLike(signature)) {
  33593. var bytes = arrayify(signature);
  33594. // Get the r, s and v
  33595. if (bytes.length === 64) {
  33596. // EIP-2098; pull the v from the top bit of s and clear it
  33597. result.v = 27 + (bytes[32] >> 7);
  33598. bytes[32] &= 0x7f;
  33599. result.r = hexlify(bytes.slice(0, 32));
  33600. result.s = hexlify(bytes.slice(32, 64));
  33601. }
  33602. else if (bytes.length === 65) {
  33603. result.r = hexlify(bytes.slice(0, 32));
  33604. result.s = hexlify(bytes.slice(32, 64));
  33605. result.v = bytes[64];
  33606. }
  33607. else {
  33608. logger.throwArgumentError("invalid signature string", "signature", signature);
  33609. }
  33610. // Allow a recid to be used as the v
  33611. if (result.v < 27) {
  33612. if (result.v === 0 || result.v === 1) {
  33613. result.v += 27;
  33614. }
  33615. else {
  33616. logger.throwArgumentError("signature invalid v byte", "signature", signature);
  33617. }
  33618. }
  33619. // Compute recoveryParam from v
  33620. result.recoveryParam = 1 - (result.v % 2);
  33621. // Compute _vs from recoveryParam and s
  33622. if (result.recoveryParam) {
  33623. bytes[32] |= 0x80;
  33624. }
  33625. result._vs = hexlify(bytes.slice(32, 64));
  33626. }
  33627. else {
  33628. result.r = signature.r;
  33629. result.s = signature.s;
  33630. result.v = signature.v;
  33631. result.recoveryParam = signature.recoveryParam;
  33632. result._vs = signature._vs;
  33633. // If the _vs is available, use it to populate missing s, v and recoveryParam
  33634. // and verify non-missing s, v and recoveryParam
  33635. if (result._vs != null) {
  33636. var vs_1 = zeroPad(arrayify(result._vs), 32);
  33637. result._vs = hexlify(vs_1);
  33638. // Set or check the recid
  33639. var recoveryParam = ((vs_1[0] >= 128) ? 1 : 0);
  33640. if (result.recoveryParam == null) {
  33641. result.recoveryParam = recoveryParam;
  33642. }
  33643. else if (result.recoveryParam !== recoveryParam) {
  33644. logger.throwArgumentError("signature recoveryParam mismatch _vs", "signature", signature);
  33645. }
  33646. // Set or check the s
  33647. vs_1[0] &= 0x7f;
  33648. var s = hexlify(vs_1);
  33649. if (result.s == null) {
  33650. result.s = s;
  33651. }
  33652. else if (result.s !== s) {
  33653. logger.throwArgumentError("signature v mismatch _vs", "signature", signature);
  33654. }
  33655. }
  33656. // Use recid and v to populate each other
  33657. if (result.recoveryParam == null) {
  33658. if (result.v == null) {
  33659. logger.throwArgumentError("signature missing v and recoveryParam", "signature", signature);
  33660. }
  33661. else if (result.v === 0 || result.v === 1) {
  33662. result.recoveryParam = result.v;
  33663. }
  33664. else {
  33665. result.recoveryParam = 1 - (result.v % 2);
  33666. }
  33667. }
  33668. else {
  33669. if (result.v == null) {
  33670. result.v = 27 + result.recoveryParam;
  33671. }
  33672. else {
  33673. var recId = (result.v === 0 || result.v === 1) ? result.v : (1 - (result.v % 2));
  33674. if (result.recoveryParam !== recId) {
  33675. logger.throwArgumentError("signature recoveryParam mismatch v", "signature", signature);
  33676. }
  33677. }
  33678. }
  33679. if (result.r == null || !isHexString(result.r)) {
  33680. logger.throwArgumentError("signature missing or invalid r", "signature", signature);
  33681. }
  33682. else {
  33683. result.r = hexZeroPad(result.r, 32);
  33684. }
  33685. if (result.s == null || !isHexString(result.s)) {
  33686. logger.throwArgumentError("signature missing or invalid s", "signature", signature);
  33687. }
  33688. else {
  33689. result.s = hexZeroPad(result.s, 32);
  33690. }
  33691. var vs = arrayify(result.s);
  33692. if (vs[0] >= 128) {
  33693. logger.throwArgumentError("signature s out of range", "signature", signature);
  33694. }
  33695. if (result.recoveryParam) {
  33696. vs[0] |= 0x80;
  33697. }
  33698. var _vs = hexlify(vs);
  33699. if (result._vs) {
  33700. if (!isHexString(result._vs)) {
  33701. logger.throwArgumentError("signature invalid _vs", "signature", signature);
  33702. }
  33703. result._vs = hexZeroPad(result._vs, 32);
  33704. }
  33705. // Set or check the _vs
  33706. if (result._vs == null) {
  33707. result._vs = _vs;
  33708. }
  33709. else if (result._vs !== _vs) {
  33710. logger.throwArgumentError("signature _vs mismatch v and s", "signature", signature);
  33711. }
  33712. }
  33713. result.yParityAndS = result._vs;
  33714. result.compact = result.r + result.yParityAndS.substring(2);
  33715. return result;
  33716. }
  33717. exports.splitSignature = splitSignature;
  33718. function joinSignature(signature) {
  33719. signature = splitSignature(signature);
  33720. return hexlify(concat([
  33721. signature.r,
  33722. signature.s,
  33723. (signature.recoveryParam ? "0x1c" : "0x1b")
  33724. ]));
  33725. }
  33726. exports.joinSignature = joinSignature;
  33727. },{"./_version":198,"@ethersproject/logger":223}],200:[function(_dereq_,module,exports){
  33728. "use strict";
  33729. Object.defineProperty(exports, "__esModule", { value: true });
  33730. exports.AddressZero = void 0;
  33731. exports.AddressZero = "0x0000000000000000000000000000000000000000";
  33732. },{}],201:[function(_dereq_,module,exports){
  33733. "use strict";
  33734. Object.defineProperty(exports, "__esModule", { value: true });
  33735. exports.MaxInt256 = exports.MinInt256 = exports.MaxUint256 = exports.WeiPerEther = exports.Two = exports.One = exports.Zero = exports.NegativeOne = void 0;
  33736. var bignumber_1 = _dereq_("@ethersproject/bignumber");
  33737. var NegativeOne = ( /*#__PURE__*/bignumber_1.BigNumber.from(-1));
  33738. exports.NegativeOne = NegativeOne;
  33739. var Zero = ( /*#__PURE__*/bignumber_1.BigNumber.from(0));
  33740. exports.Zero = Zero;
  33741. var One = ( /*#__PURE__*/bignumber_1.BigNumber.from(1));
  33742. exports.One = One;
  33743. var Two = ( /*#__PURE__*/bignumber_1.BigNumber.from(2));
  33744. exports.Two = Two;
  33745. var WeiPerEther = ( /*#__PURE__*/bignumber_1.BigNumber.from("1000000000000000000"));
  33746. exports.WeiPerEther = WeiPerEther;
  33747. var MaxUint256 = ( /*#__PURE__*/bignumber_1.BigNumber.from("0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff"));
  33748. exports.MaxUint256 = MaxUint256;
  33749. var MinInt256 = ( /*#__PURE__*/bignumber_1.BigNumber.from("-0x8000000000000000000000000000000000000000000000000000000000000000"));
  33750. exports.MinInt256 = MinInt256;
  33751. var MaxInt256 = ( /*#__PURE__*/bignumber_1.BigNumber.from("0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff"));
  33752. exports.MaxInt256 = MaxInt256;
  33753. },{"@ethersproject/bignumber":196}],202:[function(_dereq_,module,exports){
  33754. "use strict";
  33755. Object.defineProperty(exports, "__esModule", { value: true });
  33756. exports.HashZero = void 0;
  33757. exports.HashZero = "0x0000000000000000000000000000000000000000000000000000000000000000";
  33758. },{}],203:[function(_dereq_,module,exports){
  33759. "use strict";
  33760. Object.defineProperty(exports, "__esModule", { value: true });
  33761. exports.EtherSymbol = exports.HashZero = exports.MaxInt256 = exports.MinInt256 = exports.MaxUint256 = exports.WeiPerEther = exports.Two = exports.One = exports.Zero = exports.NegativeOne = exports.AddressZero = void 0;
  33762. var addresses_1 = _dereq_("./addresses");
  33763. Object.defineProperty(exports, "AddressZero", { enumerable: true, get: function () { return addresses_1.AddressZero; } });
  33764. var bignumbers_1 = _dereq_("./bignumbers");
  33765. Object.defineProperty(exports, "NegativeOne", { enumerable: true, get: function () { return bignumbers_1.NegativeOne; } });
  33766. Object.defineProperty(exports, "Zero", { enumerable: true, get: function () { return bignumbers_1.Zero; } });
  33767. Object.defineProperty(exports, "One", { enumerable: true, get: function () { return bignumbers_1.One; } });
  33768. Object.defineProperty(exports, "Two", { enumerable: true, get: function () { return bignumbers_1.Two; } });
  33769. Object.defineProperty(exports, "WeiPerEther", { enumerable: true, get: function () { return bignumbers_1.WeiPerEther; } });
  33770. Object.defineProperty(exports, "MaxUint256", { enumerable: true, get: function () { return bignumbers_1.MaxUint256; } });
  33771. Object.defineProperty(exports, "MinInt256", { enumerable: true, get: function () { return bignumbers_1.MinInt256; } });
  33772. Object.defineProperty(exports, "MaxInt256", { enumerable: true, get: function () { return bignumbers_1.MaxInt256; } });
  33773. var hashes_1 = _dereq_("./hashes");
  33774. Object.defineProperty(exports, "HashZero", { enumerable: true, get: function () { return hashes_1.HashZero; } });
  33775. var strings_1 = _dereq_("./strings");
  33776. Object.defineProperty(exports, "EtherSymbol", { enumerable: true, get: function () { return strings_1.EtherSymbol; } });
  33777. },{"./addresses":200,"./bignumbers":201,"./hashes":202,"./strings":204}],204:[function(_dereq_,module,exports){
  33778. "use strict";
  33779. Object.defineProperty(exports, "__esModule", { value: true });
  33780. exports.EtherSymbol = void 0;
  33781. // NFKC (composed) // (decomposed)
  33782. exports.EtherSymbol = "\u039e"; // "\uD835\uDF63";
  33783. },{}],205:[function(_dereq_,module,exports){
  33784. "use strict";
  33785. Object.defineProperty(exports, "__esModule", { value: true });
  33786. exports.version = void 0;
  33787. exports.version = "contracts/5.6.0";
  33788. },{}],206:[function(_dereq_,module,exports){
  33789. "use strict";
  33790. var __extends = (this && this.__extends) || (function () {
  33791. var extendStatics = function (d, b) {
  33792. extendStatics = Object.setPrototypeOf ||
  33793. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  33794. function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
  33795. return extendStatics(d, b);
  33796. };
  33797. return function (d, b) {
  33798. if (typeof b !== "function" && b !== null)
  33799. throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
  33800. extendStatics(d, b);
  33801. function __() { this.constructor = d; }
  33802. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  33803. };
  33804. })();
  33805. var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
  33806. function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
  33807. return new (P || (P = Promise))(function (resolve, reject) {
  33808. function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
  33809. function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
  33810. function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
  33811. step((generator = generator.apply(thisArg, _arguments || [])).next());
  33812. });
  33813. };
  33814. var __generator = (this && this.__generator) || function (thisArg, body) {
  33815. var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
  33816. return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
  33817. function verb(n) { return function (v) { return step([n, v]); }; }
  33818. function step(op) {
  33819. if (f) throw new TypeError("Generator is already executing.");
  33820. while (_) try {
  33821. if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
  33822. if (y = 0, t) op = [op[0] & 2, t.value];
  33823. switch (op[0]) {
  33824. case 0: case 1: t = op; break;
  33825. case 4: _.label++; return { value: op[1], done: false };
  33826. case 5: _.label++; y = op[1]; op = [0]; continue;
  33827. case 7: op = _.ops.pop(); _.trys.pop(); continue;
  33828. default:
  33829. if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
  33830. if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
  33831. if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
  33832. if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
  33833. if (t[2]) _.ops.pop();
  33834. _.trys.pop(); continue;
  33835. }
  33836. op = body.call(thisArg, _);
  33837. } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
  33838. if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
  33839. }
  33840. };
  33841. var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
  33842. if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
  33843. if (ar || !(i in from)) {
  33844. if (!ar) ar = Array.prototype.slice.call(from, 0, i);
  33845. ar[i] = from[i];
  33846. }
  33847. }
  33848. return to.concat(ar || Array.prototype.slice.call(from));
  33849. };
  33850. Object.defineProperty(exports, "__esModule", { value: true });
  33851. exports.ContractFactory = exports.Contract = exports.BaseContract = void 0;
  33852. var abi_1 = _dereq_("@ethersproject/abi");
  33853. var abstract_provider_1 = _dereq_("@ethersproject/abstract-provider");
  33854. var abstract_signer_1 = _dereq_("@ethersproject/abstract-signer");
  33855. var address_1 = _dereq_("@ethersproject/address");
  33856. var bignumber_1 = _dereq_("@ethersproject/bignumber");
  33857. var bytes_1 = _dereq_("@ethersproject/bytes");
  33858. var properties_1 = _dereq_("@ethersproject/properties");
  33859. var transactions_1 = _dereq_("@ethersproject/transactions");
  33860. var logger_1 = _dereq_("@ethersproject/logger");
  33861. var _version_1 = _dereq_("./_version");
  33862. var logger = new logger_1.Logger(_version_1.version);
  33863. ;
  33864. ;
  33865. ///////////////////////////////
  33866. var allowedTransactionKeys = {
  33867. chainId: true, data: true, from: true, gasLimit: true, gasPrice: true, nonce: true, to: true, value: true,
  33868. type: true, accessList: true,
  33869. maxFeePerGas: true, maxPriorityFeePerGas: true,
  33870. customData: true,
  33871. ccipReadEnabled: true
  33872. };
  33873. function resolveName(resolver, nameOrPromise) {
  33874. return __awaiter(this, void 0, void 0, function () {
  33875. var name, address;
  33876. return __generator(this, function (_a) {
  33877. switch (_a.label) {
  33878. case 0: return [4 /*yield*/, nameOrPromise];
  33879. case 1:
  33880. name = _a.sent();
  33881. if (typeof (name) !== "string") {
  33882. logger.throwArgumentError("invalid address or ENS name", "name", name);
  33883. }
  33884. // If it is already an address, just use it (after adding checksum)
  33885. try {
  33886. return [2 /*return*/, (0, address_1.getAddress)(name)];
  33887. }
  33888. catch (error) { }
  33889. if (!resolver) {
  33890. logger.throwError("a provider or signer is needed to resolve ENS names", logger_1.Logger.errors.UNSUPPORTED_OPERATION, {
  33891. operation: "resolveName"
  33892. });
  33893. }
  33894. return [4 /*yield*/, resolver.resolveName(name)];
  33895. case 2:
  33896. address = _a.sent();
  33897. if (address == null) {
  33898. logger.throwArgumentError("resolver or addr is not configured for ENS name", "name", name);
  33899. }
  33900. return [2 /*return*/, address];
  33901. }
  33902. });
  33903. });
  33904. }
  33905. // Recursively replaces ENS names with promises to resolve the name and resolves all properties
  33906. function resolveAddresses(resolver, value, paramType) {
  33907. return __awaiter(this, void 0, void 0, function () {
  33908. return __generator(this, function (_a) {
  33909. switch (_a.label) {
  33910. case 0:
  33911. if (!Array.isArray(paramType)) return [3 /*break*/, 2];
  33912. return [4 /*yield*/, Promise.all(paramType.map(function (paramType, index) {
  33913. return resolveAddresses(resolver, ((Array.isArray(value)) ? value[index] : value[paramType.name]), paramType);
  33914. }))];
  33915. case 1: return [2 /*return*/, _a.sent()];
  33916. case 2:
  33917. if (!(paramType.type === "address")) return [3 /*break*/, 4];
  33918. return [4 /*yield*/, resolveName(resolver, value)];
  33919. case 3: return [2 /*return*/, _a.sent()];
  33920. case 4:
  33921. if (!(paramType.type === "tuple")) return [3 /*break*/, 6];
  33922. return [4 /*yield*/, resolveAddresses(resolver, value, paramType.components)];
  33923. case 5: return [2 /*return*/, _a.sent()];
  33924. case 6:
  33925. if (!(paramType.baseType === "array")) return [3 /*break*/, 8];
  33926. if (!Array.isArray(value)) {
  33927. return [2 /*return*/, Promise.reject(logger.makeError("invalid value for array", logger_1.Logger.errors.INVALID_ARGUMENT, {
  33928. argument: "value",
  33929. value: value
  33930. }))];
  33931. }
  33932. return [4 /*yield*/, Promise.all(value.map(function (v) { return resolveAddresses(resolver, v, paramType.arrayChildren); }))];
  33933. case 7: return [2 /*return*/, _a.sent()];
  33934. case 8: return [2 /*return*/, value];
  33935. }
  33936. });
  33937. });
  33938. }
  33939. function populateTransaction(contract, fragment, args) {
  33940. return __awaiter(this, void 0, void 0, function () {
  33941. var overrides, resolved, data, tx, ro, intrinsic, bytes, i, roValue, leftovers;
  33942. var _this = this;
  33943. return __generator(this, function (_a) {
  33944. switch (_a.label) {
  33945. case 0:
  33946. overrides = {};
  33947. if (args.length === fragment.inputs.length + 1 && typeof (args[args.length - 1]) === "object") {
  33948. overrides = (0, properties_1.shallowCopy)(args.pop());
  33949. }
  33950. // Make sure the parameter count matches
  33951. logger.checkArgumentCount(args.length, fragment.inputs.length, "passed to contract");
  33952. // Populate "from" override (allow promises)
  33953. if (contract.signer) {
  33954. if (overrides.from) {
  33955. // Contracts with a Signer are from the Signer's frame-of-reference;
  33956. // but we allow overriding "from" if it matches the signer
  33957. overrides.from = (0, properties_1.resolveProperties)({
  33958. override: resolveName(contract.signer, overrides.from),
  33959. signer: contract.signer.getAddress()
  33960. }).then(function (check) { return __awaiter(_this, void 0, void 0, function () {
  33961. return __generator(this, function (_a) {
  33962. if ((0, address_1.getAddress)(check.signer) !== check.override) {
  33963. logger.throwError("Contract with a Signer cannot override from", logger_1.Logger.errors.UNSUPPORTED_OPERATION, {
  33964. operation: "overrides.from"
  33965. });
  33966. }
  33967. return [2 /*return*/, check.override];
  33968. });
  33969. }); });
  33970. }
  33971. else {
  33972. overrides.from = contract.signer.getAddress();
  33973. }
  33974. }
  33975. else if (overrides.from) {
  33976. overrides.from = resolveName(contract.provider, overrides.from);
  33977. //} else {
  33978. // Contracts without a signer can override "from", and if
  33979. // unspecified the zero address is used
  33980. //overrides.from = AddressZero;
  33981. }
  33982. return [4 /*yield*/, (0, properties_1.resolveProperties)({
  33983. args: resolveAddresses(contract.signer || contract.provider, args, fragment.inputs),
  33984. address: contract.resolvedAddress,
  33985. overrides: ((0, properties_1.resolveProperties)(overrides) || {})
  33986. })];
  33987. case 1:
  33988. resolved = _a.sent();
  33989. data = contract.interface.encodeFunctionData(fragment, resolved.args);
  33990. tx = {
  33991. data: data,
  33992. to: resolved.address
  33993. };
  33994. ro = resolved.overrides;
  33995. // Populate simple overrides
  33996. if (ro.nonce != null) {
  33997. tx.nonce = bignumber_1.BigNumber.from(ro.nonce).toNumber();
  33998. }
  33999. if (ro.gasLimit != null) {
  34000. tx.gasLimit = bignumber_1.BigNumber.from(ro.gasLimit);
  34001. }
  34002. if (ro.gasPrice != null) {
  34003. tx.gasPrice = bignumber_1.BigNumber.from(ro.gasPrice);
  34004. }
  34005. if (ro.maxFeePerGas != null) {
  34006. tx.maxFeePerGas = bignumber_1.BigNumber.from(ro.maxFeePerGas);
  34007. }
  34008. if (ro.maxPriorityFeePerGas != null) {
  34009. tx.maxPriorityFeePerGas = bignumber_1.BigNumber.from(ro.maxPriorityFeePerGas);
  34010. }
  34011. if (ro.from != null) {
  34012. tx.from = ro.from;
  34013. }
  34014. if (ro.type != null) {
  34015. tx.type = ro.type;
  34016. }
  34017. if (ro.accessList != null) {
  34018. tx.accessList = (0, transactions_1.accessListify)(ro.accessList);
  34019. }
  34020. // If there was no "gasLimit" override, but the ABI specifies a default, use it
  34021. if (tx.gasLimit == null && fragment.gas != null) {
  34022. intrinsic = 21000;
  34023. bytes = (0, bytes_1.arrayify)(data);
  34024. for (i = 0; i < bytes.length; i++) {
  34025. intrinsic += 4;
  34026. if (bytes[i]) {
  34027. intrinsic += 64;
  34028. }
  34029. }
  34030. tx.gasLimit = bignumber_1.BigNumber.from(fragment.gas).add(intrinsic);
  34031. }
  34032. // Populate "value" override
  34033. if (ro.value) {
  34034. roValue = bignumber_1.BigNumber.from(ro.value);
  34035. if (!roValue.isZero() && !fragment.payable) {
  34036. logger.throwError("non-payable method cannot override value", logger_1.Logger.errors.UNSUPPORTED_OPERATION, {
  34037. operation: "overrides.value",
  34038. value: overrides.value
  34039. });
  34040. }
  34041. tx.value = roValue;
  34042. }
  34043. if (ro.customData) {
  34044. tx.customData = (0, properties_1.shallowCopy)(ro.customData);
  34045. }
  34046. if (ro.ccipReadEnabled) {
  34047. tx.ccipReadEnabled = !!ro.ccipReadEnabled;
  34048. }
  34049. // Remove the overrides
  34050. delete overrides.nonce;
  34051. delete overrides.gasLimit;
  34052. delete overrides.gasPrice;
  34053. delete overrides.from;
  34054. delete overrides.value;
  34055. delete overrides.type;
  34056. delete overrides.accessList;
  34057. delete overrides.maxFeePerGas;
  34058. delete overrides.maxPriorityFeePerGas;
  34059. delete overrides.customData;
  34060. delete overrides.ccipReadEnabled;
  34061. leftovers = Object.keys(overrides).filter(function (key) { return (overrides[key] != null); });
  34062. if (leftovers.length) {
  34063. logger.throwError("cannot override " + leftovers.map(function (l) { return JSON.stringify(l); }).join(","), logger_1.Logger.errors.UNSUPPORTED_OPERATION, {
  34064. operation: "overrides",
  34065. overrides: leftovers
  34066. });
  34067. }
  34068. return [2 /*return*/, tx];
  34069. }
  34070. });
  34071. });
  34072. }
  34073. function buildPopulate(contract, fragment) {
  34074. return function () {
  34075. var args = [];
  34076. for (var _i = 0; _i < arguments.length; _i++) {
  34077. args[_i] = arguments[_i];
  34078. }
  34079. return populateTransaction(contract, fragment, args);
  34080. };
  34081. }
  34082. function buildEstimate(contract, fragment) {
  34083. var signerOrProvider = (contract.signer || contract.provider);
  34084. return function () {
  34085. var args = [];
  34086. for (var _i = 0; _i < arguments.length; _i++) {
  34087. args[_i] = arguments[_i];
  34088. }
  34089. return __awaiter(this, void 0, void 0, function () {
  34090. var tx;
  34091. return __generator(this, function (_a) {
  34092. switch (_a.label) {
  34093. case 0:
  34094. if (!signerOrProvider) {
  34095. logger.throwError("estimate require a provider or signer", logger_1.Logger.errors.UNSUPPORTED_OPERATION, {
  34096. operation: "estimateGas"
  34097. });
  34098. }
  34099. return [4 /*yield*/, populateTransaction(contract, fragment, args)];
  34100. case 1:
  34101. tx = _a.sent();
  34102. return [4 /*yield*/, signerOrProvider.estimateGas(tx)];
  34103. case 2: return [2 /*return*/, _a.sent()];
  34104. }
  34105. });
  34106. });
  34107. };
  34108. }
  34109. function addContractWait(contract, tx) {
  34110. var wait = tx.wait.bind(tx);
  34111. tx.wait = function (confirmations) {
  34112. return wait(confirmations).then(function (receipt) {
  34113. receipt.events = receipt.logs.map(function (log) {
  34114. var event = (0, properties_1.deepCopy)(log);
  34115. var parsed = null;
  34116. try {
  34117. parsed = contract.interface.parseLog(log);
  34118. }
  34119. catch (e) { }
  34120. // Successfully parsed the event log; include it
  34121. if (parsed) {
  34122. event.args = parsed.args;
  34123. event.decode = function (data, topics) {
  34124. return contract.interface.decodeEventLog(parsed.eventFragment, data, topics);
  34125. };
  34126. event.event = parsed.name;
  34127. event.eventSignature = parsed.signature;
  34128. }
  34129. // Useful operations
  34130. event.removeListener = function () { return contract.provider; };
  34131. event.getBlock = function () {
  34132. return contract.provider.getBlock(receipt.blockHash);
  34133. };
  34134. event.getTransaction = function () {
  34135. return contract.provider.getTransaction(receipt.transactionHash);
  34136. };
  34137. event.getTransactionReceipt = function () {
  34138. return Promise.resolve(receipt);
  34139. };
  34140. return event;
  34141. });
  34142. return receipt;
  34143. });
  34144. };
  34145. }
  34146. function buildCall(contract, fragment, collapseSimple) {
  34147. var signerOrProvider = (contract.signer || contract.provider);
  34148. return function () {
  34149. var args = [];
  34150. for (var _i = 0; _i < arguments.length; _i++) {
  34151. args[_i] = arguments[_i];
  34152. }
  34153. return __awaiter(this, void 0, void 0, function () {
  34154. var blockTag, overrides, tx, result, value;
  34155. return __generator(this, function (_a) {
  34156. switch (_a.label) {
  34157. case 0:
  34158. blockTag = undefined;
  34159. if (!(args.length === fragment.inputs.length + 1 && typeof (args[args.length - 1]) === "object")) return [3 /*break*/, 3];
  34160. overrides = (0, properties_1.shallowCopy)(args.pop());
  34161. if (!(overrides.blockTag != null)) return [3 /*break*/, 2];
  34162. return [4 /*yield*/, overrides.blockTag];
  34163. case 1:
  34164. blockTag = _a.sent();
  34165. _a.label = 2;
  34166. case 2:
  34167. delete overrides.blockTag;
  34168. args.push(overrides);
  34169. _a.label = 3;
  34170. case 3:
  34171. if (!(contract.deployTransaction != null)) return [3 /*break*/, 5];
  34172. return [4 /*yield*/, contract._deployed(blockTag)];
  34173. case 4:
  34174. _a.sent();
  34175. _a.label = 5;
  34176. case 5: return [4 /*yield*/, populateTransaction(contract, fragment, args)];
  34177. case 6:
  34178. tx = _a.sent();
  34179. return [4 /*yield*/, signerOrProvider.call(tx, blockTag)];
  34180. case 7:
  34181. result = _a.sent();
  34182. try {
  34183. value = contract.interface.decodeFunctionResult(fragment, result);
  34184. if (collapseSimple && fragment.outputs.length === 1) {
  34185. value = value[0];
  34186. }
  34187. return [2 /*return*/, value];
  34188. }
  34189. catch (error) {
  34190. if (error.code === logger_1.Logger.errors.CALL_EXCEPTION) {
  34191. error.address = contract.address;
  34192. error.args = args;
  34193. error.transaction = tx;
  34194. }
  34195. throw error;
  34196. }
  34197. return [2 /*return*/];
  34198. }
  34199. });
  34200. });
  34201. };
  34202. }
  34203. function buildSend(contract, fragment) {
  34204. return function () {
  34205. var args = [];
  34206. for (var _i = 0; _i < arguments.length; _i++) {
  34207. args[_i] = arguments[_i];
  34208. }
  34209. return __awaiter(this, void 0, void 0, function () {
  34210. var txRequest, tx;
  34211. return __generator(this, function (_a) {
  34212. switch (_a.label) {
  34213. case 0:
  34214. if (!contract.signer) {
  34215. logger.throwError("sending a transaction requires a signer", logger_1.Logger.errors.UNSUPPORTED_OPERATION, {
  34216. operation: "sendTransaction"
  34217. });
  34218. }
  34219. if (!(contract.deployTransaction != null)) return [3 /*break*/, 2];
  34220. return [4 /*yield*/, contract._deployed()];
  34221. case 1:
  34222. _a.sent();
  34223. _a.label = 2;
  34224. case 2: return [4 /*yield*/, populateTransaction(contract, fragment, args)];
  34225. case 3:
  34226. txRequest = _a.sent();
  34227. return [4 /*yield*/, contract.signer.sendTransaction(txRequest)];
  34228. case 4:
  34229. tx = _a.sent();
  34230. // Tweak the tx.wait so the receipt has extra properties
  34231. addContractWait(contract, tx);
  34232. return [2 /*return*/, tx];
  34233. }
  34234. });
  34235. });
  34236. };
  34237. }
  34238. function buildDefault(contract, fragment, collapseSimple) {
  34239. if (fragment.constant) {
  34240. return buildCall(contract, fragment, collapseSimple);
  34241. }
  34242. return buildSend(contract, fragment);
  34243. }
  34244. function getEventTag(filter) {
  34245. if (filter.address && (filter.topics == null || filter.topics.length === 0)) {
  34246. return "*";
  34247. }
  34248. return (filter.address || "*") + "@" + (filter.topics ? filter.topics.map(function (topic) {
  34249. if (Array.isArray(topic)) {
  34250. return topic.join("|");
  34251. }
  34252. return topic;
  34253. }).join(":") : "");
  34254. }
  34255. var RunningEvent = /** @class */ (function () {
  34256. function RunningEvent(tag, filter) {
  34257. (0, properties_1.defineReadOnly)(this, "tag", tag);
  34258. (0, properties_1.defineReadOnly)(this, "filter", filter);
  34259. this._listeners = [];
  34260. }
  34261. RunningEvent.prototype.addListener = function (listener, once) {
  34262. this._listeners.push({ listener: listener, once: once });
  34263. };
  34264. RunningEvent.prototype.removeListener = function (listener) {
  34265. var done = false;
  34266. this._listeners = this._listeners.filter(function (item) {
  34267. if (done || item.listener !== listener) {
  34268. return true;
  34269. }
  34270. done = true;
  34271. return false;
  34272. });
  34273. };
  34274. RunningEvent.prototype.removeAllListeners = function () {
  34275. this._listeners = [];
  34276. };
  34277. RunningEvent.prototype.listeners = function () {
  34278. return this._listeners.map(function (i) { return i.listener; });
  34279. };
  34280. RunningEvent.prototype.listenerCount = function () {
  34281. return this._listeners.length;
  34282. };
  34283. RunningEvent.prototype.run = function (args) {
  34284. var _this = this;
  34285. var listenerCount = this.listenerCount();
  34286. this._listeners = this._listeners.filter(function (item) {
  34287. var argsCopy = args.slice();
  34288. // Call the callback in the next event loop
  34289. setTimeout(function () {
  34290. item.listener.apply(_this, argsCopy);
  34291. }, 0);
  34292. // Reschedule it if it not "once"
  34293. return !(item.once);
  34294. });
  34295. return listenerCount;
  34296. };
  34297. RunningEvent.prototype.prepareEvent = function (event) {
  34298. };
  34299. // Returns the array that will be applied to an emit
  34300. RunningEvent.prototype.getEmit = function (event) {
  34301. return [event];
  34302. };
  34303. return RunningEvent;
  34304. }());
  34305. var ErrorRunningEvent = /** @class */ (function (_super) {
  34306. __extends(ErrorRunningEvent, _super);
  34307. function ErrorRunningEvent() {
  34308. return _super.call(this, "error", null) || this;
  34309. }
  34310. return ErrorRunningEvent;
  34311. }(RunningEvent));
  34312. // @TODO Fragment should inherit Wildcard? and just override getEmit?
  34313. // or have a common abstract super class, with enough constructor
  34314. // options to configure both.
  34315. // A Fragment Event will populate all the properties that Wildcard
  34316. // will, and additionally dereference the arguments when emitting
  34317. var FragmentRunningEvent = /** @class */ (function (_super) {
  34318. __extends(FragmentRunningEvent, _super);
  34319. function FragmentRunningEvent(address, contractInterface, fragment, topics) {
  34320. var _this = this;
  34321. var filter = {
  34322. address: address
  34323. };
  34324. var topic = contractInterface.getEventTopic(fragment);
  34325. if (topics) {
  34326. if (topic !== topics[0]) {
  34327. logger.throwArgumentError("topic mismatch", "topics", topics);
  34328. }
  34329. filter.topics = topics.slice();
  34330. }
  34331. else {
  34332. filter.topics = [topic];
  34333. }
  34334. _this = _super.call(this, getEventTag(filter), filter) || this;
  34335. (0, properties_1.defineReadOnly)(_this, "address", address);
  34336. (0, properties_1.defineReadOnly)(_this, "interface", contractInterface);
  34337. (0, properties_1.defineReadOnly)(_this, "fragment", fragment);
  34338. return _this;
  34339. }
  34340. FragmentRunningEvent.prototype.prepareEvent = function (event) {
  34341. var _this = this;
  34342. _super.prototype.prepareEvent.call(this, event);
  34343. event.event = this.fragment.name;
  34344. event.eventSignature = this.fragment.format();
  34345. event.decode = function (data, topics) {
  34346. return _this.interface.decodeEventLog(_this.fragment, data, topics);
  34347. };
  34348. try {
  34349. event.args = this.interface.decodeEventLog(this.fragment, event.data, event.topics);
  34350. }
  34351. catch (error) {
  34352. event.args = null;
  34353. event.decodeError = error;
  34354. }
  34355. };
  34356. FragmentRunningEvent.prototype.getEmit = function (event) {
  34357. var errors = (0, abi_1.checkResultErrors)(event.args);
  34358. if (errors.length) {
  34359. throw errors[0].error;
  34360. }
  34361. var args = (event.args || []).slice();
  34362. args.push(event);
  34363. return args;
  34364. };
  34365. return FragmentRunningEvent;
  34366. }(RunningEvent));
  34367. // A Wildcard Event will attempt to populate:
  34368. // - event The name of the event name
  34369. // - eventSignature The full signature of the event
  34370. // - decode A function to decode data and topics
  34371. // - args The decoded data and topics
  34372. var WildcardRunningEvent = /** @class */ (function (_super) {
  34373. __extends(WildcardRunningEvent, _super);
  34374. function WildcardRunningEvent(address, contractInterface) {
  34375. var _this = _super.call(this, "*", { address: address }) || this;
  34376. (0, properties_1.defineReadOnly)(_this, "address", address);
  34377. (0, properties_1.defineReadOnly)(_this, "interface", contractInterface);
  34378. return _this;
  34379. }
  34380. WildcardRunningEvent.prototype.prepareEvent = function (event) {
  34381. var _this = this;
  34382. _super.prototype.prepareEvent.call(this, event);
  34383. try {
  34384. var parsed_1 = this.interface.parseLog(event);
  34385. event.event = parsed_1.name;
  34386. event.eventSignature = parsed_1.signature;
  34387. event.decode = function (data, topics) {
  34388. return _this.interface.decodeEventLog(parsed_1.eventFragment, data, topics);
  34389. };
  34390. event.args = parsed_1.args;
  34391. }
  34392. catch (error) {
  34393. // No matching event
  34394. }
  34395. };
  34396. return WildcardRunningEvent;
  34397. }(RunningEvent));
  34398. var BaseContract = /** @class */ (function () {
  34399. function BaseContract(addressOrName, contractInterface, signerOrProvider) {
  34400. var _newTarget = this.constructor;
  34401. var _this = this;
  34402. logger.checkNew(_newTarget, Contract);
  34403. // @TODO: Maybe still check the addressOrName looks like a valid address or name?
  34404. //address = getAddress(address);
  34405. (0, properties_1.defineReadOnly)(this, "interface", (0, properties_1.getStatic)(_newTarget, "getInterface")(contractInterface));
  34406. if (signerOrProvider == null) {
  34407. (0, properties_1.defineReadOnly)(this, "provider", null);
  34408. (0, properties_1.defineReadOnly)(this, "signer", null);
  34409. }
  34410. else if (abstract_signer_1.Signer.isSigner(signerOrProvider)) {
  34411. (0, properties_1.defineReadOnly)(this, "provider", signerOrProvider.provider || null);
  34412. (0, properties_1.defineReadOnly)(this, "signer", signerOrProvider);
  34413. }
  34414. else if (abstract_provider_1.Provider.isProvider(signerOrProvider)) {
  34415. (0, properties_1.defineReadOnly)(this, "provider", signerOrProvider);
  34416. (0, properties_1.defineReadOnly)(this, "signer", null);
  34417. }
  34418. else {
  34419. logger.throwArgumentError("invalid signer or provider", "signerOrProvider", signerOrProvider);
  34420. }
  34421. (0, properties_1.defineReadOnly)(this, "callStatic", {});
  34422. (0, properties_1.defineReadOnly)(this, "estimateGas", {});
  34423. (0, properties_1.defineReadOnly)(this, "functions", {});
  34424. (0, properties_1.defineReadOnly)(this, "populateTransaction", {});
  34425. (0, properties_1.defineReadOnly)(this, "filters", {});
  34426. {
  34427. var uniqueFilters_1 = {};
  34428. Object.keys(this.interface.events).forEach(function (eventSignature) {
  34429. var event = _this.interface.events[eventSignature];
  34430. (0, properties_1.defineReadOnly)(_this.filters, eventSignature, function () {
  34431. var args = [];
  34432. for (var _i = 0; _i < arguments.length; _i++) {
  34433. args[_i] = arguments[_i];
  34434. }
  34435. return {
  34436. address: _this.address,
  34437. topics: _this.interface.encodeFilterTopics(event, args)
  34438. };
  34439. });
  34440. if (!uniqueFilters_1[event.name]) {
  34441. uniqueFilters_1[event.name] = [];
  34442. }
  34443. uniqueFilters_1[event.name].push(eventSignature);
  34444. });
  34445. Object.keys(uniqueFilters_1).forEach(function (name) {
  34446. var filters = uniqueFilters_1[name];
  34447. if (filters.length === 1) {
  34448. (0, properties_1.defineReadOnly)(_this.filters, name, _this.filters[filters[0]]);
  34449. }
  34450. else {
  34451. logger.warn("Duplicate definition of " + name + " (" + filters.join(", ") + ")");
  34452. }
  34453. });
  34454. }
  34455. (0, properties_1.defineReadOnly)(this, "_runningEvents", {});
  34456. (0, properties_1.defineReadOnly)(this, "_wrappedEmits", {});
  34457. if (addressOrName == null) {
  34458. logger.throwArgumentError("invalid contract address or ENS name", "addressOrName", addressOrName);
  34459. }
  34460. (0, properties_1.defineReadOnly)(this, "address", addressOrName);
  34461. if (this.provider) {
  34462. (0, properties_1.defineReadOnly)(this, "resolvedAddress", resolveName(this.provider, addressOrName));
  34463. }
  34464. else {
  34465. try {
  34466. (0, properties_1.defineReadOnly)(this, "resolvedAddress", Promise.resolve((0, address_1.getAddress)(addressOrName)));
  34467. }
  34468. catch (error) {
  34469. // Without a provider, we cannot use ENS names
  34470. logger.throwError("provider is required to use ENS name as contract address", logger_1.Logger.errors.UNSUPPORTED_OPERATION, {
  34471. operation: "new Contract"
  34472. });
  34473. }
  34474. }
  34475. // Swallow bad ENS names to prevent Unhandled Exceptions
  34476. this.resolvedAddress.catch(function (e) { });
  34477. var uniqueNames = {};
  34478. var uniqueSignatures = {};
  34479. Object.keys(this.interface.functions).forEach(function (signature) {
  34480. var fragment = _this.interface.functions[signature];
  34481. // Check that the signature is unique; if not the ABI generation has
  34482. // not been cleaned or may be incorrectly generated
  34483. if (uniqueSignatures[signature]) {
  34484. logger.warn("Duplicate ABI entry for " + JSON.stringify(signature));
  34485. return;
  34486. }
  34487. uniqueSignatures[signature] = true;
  34488. // Track unique names; we only expose bare named functions if they
  34489. // are ambiguous
  34490. {
  34491. var name_1 = fragment.name;
  34492. if (!uniqueNames["%" + name_1]) {
  34493. uniqueNames["%" + name_1] = [];
  34494. }
  34495. uniqueNames["%" + name_1].push(signature);
  34496. }
  34497. if (_this[signature] == null) {
  34498. (0, properties_1.defineReadOnly)(_this, signature, buildDefault(_this, fragment, true));
  34499. }
  34500. // We do not collapse simple calls on this bucket, which allows
  34501. // frameworks to safely use this without introspection as well as
  34502. // allows decoding error recovery.
  34503. if (_this.functions[signature] == null) {
  34504. (0, properties_1.defineReadOnly)(_this.functions, signature, buildDefault(_this, fragment, false));
  34505. }
  34506. if (_this.callStatic[signature] == null) {
  34507. (0, properties_1.defineReadOnly)(_this.callStatic, signature, buildCall(_this, fragment, true));
  34508. }
  34509. if (_this.populateTransaction[signature] == null) {
  34510. (0, properties_1.defineReadOnly)(_this.populateTransaction, signature, buildPopulate(_this, fragment));
  34511. }
  34512. if (_this.estimateGas[signature] == null) {
  34513. (0, properties_1.defineReadOnly)(_this.estimateGas, signature, buildEstimate(_this, fragment));
  34514. }
  34515. });
  34516. Object.keys(uniqueNames).forEach(function (name) {
  34517. // Ambiguous names to not get attached as bare names
  34518. var signatures = uniqueNames[name];
  34519. if (signatures.length > 1) {
  34520. return;
  34521. }
  34522. // Strip off the leading "%" used for prototype protection
  34523. name = name.substring(1);
  34524. var signature = signatures[0];
  34525. // If overwriting a member property that is null, swallow the error
  34526. try {
  34527. if (_this[name] == null) {
  34528. (0, properties_1.defineReadOnly)(_this, name, _this[signature]);
  34529. }
  34530. }
  34531. catch (e) { }
  34532. if (_this.functions[name] == null) {
  34533. (0, properties_1.defineReadOnly)(_this.functions, name, _this.functions[signature]);
  34534. }
  34535. if (_this.callStatic[name] == null) {
  34536. (0, properties_1.defineReadOnly)(_this.callStatic, name, _this.callStatic[signature]);
  34537. }
  34538. if (_this.populateTransaction[name] == null) {
  34539. (0, properties_1.defineReadOnly)(_this.populateTransaction, name, _this.populateTransaction[signature]);
  34540. }
  34541. if (_this.estimateGas[name] == null) {
  34542. (0, properties_1.defineReadOnly)(_this.estimateGas, name, _this.estimateGas[signature]);
  34543. }
  34544. });
  34545. }
  34546. BaseContract.getContractAddress = function (transaction) {
  34547. return (0, address_1.getContractAddress)(transaction);
  34548. };
  34549. BaseContract.getInterface = function (contractInterface) {
  34550. if (abi_1.Interface.isInterface(contractInterface)) {
  34551. return contractInterface;
  34552. }
  34553. return new abi_1.Interface(contractInterface);
  34554. };
  34555. // @TODO: Allow timeout?
  34556. BaseContract.prototype.deployed = function () {
  34557. return this._deployed();
  34558. };
  34559. BaseContract.prototype._deployed = function (blockTag) {
  34560. var _this = this;
  34561. if (!this._deployedPromise) {
  34562. // If we were just deployed, we know the transaction we should occur in
  34563. if (this.deployTransaction) {
  34564. this._deployedPromise = this.deployTransaction.wait().then(function () {
  34565. return _this;
  34566. });
  34567. }
  34568. else {
  34569. // @TODO: Once we allow a timeout to be passed in, we will wait
  34570. // up to that many blocks for getCode
  34571. // Otherwise, poll for our code to be deployed
  34572. this._deployedPromise = this.provider.getCode(this.address, blockTag).then(function (code) {
  34573. if (code === "0x") {
  34574. logger.throwError("contract not deployed", logger_1.Logger.errors.UNSUPPORTED_OPERATION, {
  34575. contractAddress: _this.address,
  34576. operation: "getDeployed"
  34577. });
  34578. }
  34579. return _this;
  34580. });
  34581. }
  34582. }
  34583. return this._deployedPromise;
  34584. };
  34585. // @TODO:
  34586. // estimateFallback(overrides?: TransactionRequest): Promise<BigNumber>
  34587. // @TODO:
  34588. // estimateDeploy(bytecode: string, ...args): Promise<BigNumber>
  34589. BaseContract.prototype.fallback = function (overrides) {
  34590. var _this = this;
  34591. if (!this.signer) {
  34592. logger.throwError("sending a transactions require a signer", logger_1.Logger.errors.UNSUPPORTED_OPERATION, { operation: "sendTransaction(fallback)" });
  34593. }
  34594. var tx = (0, properties_1.shallowCopy)(overrides || {});
  34595. ["from", "to"].forEach(function (key) {
  34596. if (tx[key] == null) {
  34597. return;
  34598. }
  34599. logger.throwError("cannot override " + key, logger_1.Logger.errors.UNSUPPORTED_OPERATION, { operation: key });
  34600. });
  34601. tx.to = this.resolvedAddress;
  34602. return this.deployed().then(function () {
  34603. return _this.signer.sendTransaction(tx);
  34604. });
  34605. };
  34606. // Reconnect to a different signer or provider
  34607. BaseContract.prototype.connect = function (signerOrProvider) {
  34608. if (typeof (signerOrProvider) === "string") {
  34609. signerOrProvider = new abstract_signer_1.VoidSigner(signerOrProvider, this.provider);
  34610. }
  34611. var contract = new (this.constructor)(this.address, this.interface, signerOrProvider);
  34612. if (this.deployTransaction) {
  34613. (0, properties_1.defineReadOnly)(contract, "deployTransaction", this.deployTransaction);
  34614. }
  34615. return contract;
  34616. };
  34617. // Re-attach to a different on-chain instance of this contract
  34618. BaseContract.prototype.attach = function (addressOrName) {
  34619. return new (this.constructor)(addressOrName, this.interface, this.signer || this.provider);
  34620. };
  34621. BaseContract.isIndexed = function (value) {
  34622. return abi_1.Indexed.isIndexed(value);
  34623. };
  34624. BaseContract.prototype._normalizeRunningEvent = function (runningEvent) {
  34625. // Already have an instance of this event running; we can re-use it
  34626. if (this._runningEvents[runningEvent.tag]) {
  34627. return this._runningEvents[runningEvent.tag];
  34628. }
  34629. return runningEvent;
  34630. };
  34631. BaseContract.prototype._getRunningEvent = function (eventName) {
  34632. if (typeof (eventName) === "string") {
  34633. // Listen for "error" events (if your contract has an error event, include
  34634. // the full signature to bypass this special event keyword)
  34635. if (eventName === "error") {
  34636. return this._normalizeRunningEvent(new ErrorRunningEvent());
  34637. }
  34638. // Listen for any event that is registered
  34639. if (eventName === "event") {
  34640. return this._normalizeRunningEvent(new RunningEvent("event", null));
  34641. }
  34642. // Listen for any event
  34643. if (eventName === "*") {
  34644. return this._normalizeRunningEvent(new WildcardRunningEvent(this.address, this.interface));
  34645. }
  34646. // Get the event Fragment (throws if ambiguous/unknown event)
  34647. var fragment = this.interface.getEvent(eventName);
  34648. return this._normalizeRunningEvent(new FragmentRunningEvent(this.address, this.interface, fragment));
  34649. }
  34650. // We have topics to filter by...
  34651. if (eventName.topics && eventName.topics.length > 0) {
  34652. // Is it a known topichash? (throws if no matching topichash)
  34653. try {
  34654. var topic = eventName.topics[0];
  34655. if (typeof (topic) !== "string") {
  34656. throw new Error("invalid topic"); // @TODO: May happen for anonymous events
  34657. }
  34658. var fragment = this.interface.getEvent(topic);
  34659. return this._normalizeRunningEvent(new FragmentRunningEvent(this.address, this.interface, fragment, eventName.topics));
  34660. }
  34661. catch (error) { }
  34662. // Filter by the unknown topichash
  34663. var filter = {
  34664. address: this.address,
  34665. topics: eventName.topics
  34666. };
  34667. return this._normalizeRunningEvent(new RunningEvent(getEventTag(filter), filter));
  34668. }
  34669. return this._normalizeRunningEvent(new WildcardRunningEvent(this.address, this.interface));
  34670. };
  34671. BaseContract.prototype._checkRunningEvents = function (runningEvent) {
  34672. if (runningEvent.listenerCount() === 0) {
  34673. delete this._runningEvents[runningEvent.tag];
  34674. // If we have a poller for this, remove it
  34675. var emit = this._wrappedEmits[runningEvent.tag];
  34676. if (emit && runningEvent.filter) {
  34677. this.provider.off(runningEvent.filter, emit);
  34678. delete this._wrappedEmits[runningEvent.tag];
  34679. }
  34680. }
  34681. };
  34682. // Subclasses can override this to gracefully recover
  34683. // from parse errors if they wish
  34684. BaseContract.prototype._wrapEvent = function (runningEvent, log, listener) {
  34685. var _this = this;
  34686. var event = (0, properties_1.deepCopy)(log);
  34687. event.removeListener = function () {
  34688. if (!listener) {
  34689. return;
  34690. }
  34691. runningEvent.removeListener(listener);
  34692. _this._checkRunningEvents(runningEvent);
  34693. };
  34694. event.getBlock = function () { return _this.provider.getBlock(log.blockHash); };
  34695. event.getTransaction = function () { return _this.provider.getTransaction(log.transactionHash); };
  34696. event.getTransactionReceipt = function () { return _this.provider.getTransactionReceipt(log.transactionHash); };
  34697. // This may throw if the topics and data mismatch the signature
  34698. runningEvent.prepareEvent(event);
  34699. return event;
  34700. };
  34701. BaseContract.prototype._addEventListener = function (runningEvent, listener, once) {
  34702. var _this = this;
  34703. if (!this.provider) {
  34704. logger.throwError("events require a provider or a signer with a provider", logger_1.Logger.errors.UNSUPPORTED_OPERATION, { operation: "once" });
  34705. }
  34706. runningEvent.addListener(listener, once);
  34707. // Track this running event and its listeners (may already be there; but no hard in updating)
  34708. this._runningEvents[runningEvent.tag] = runningEvent;
  34709. // If we are not polling the provider, start polling
  34710. if (!this._wrappedEmits[runningEvent.tag]) {
  34711. var wrappedEmit = function (log) {
  34712. var event = _this._wrapEvent(runningEvent, log, listener);
  34713. // Try to emit the result for the parameterized event...
  34714. if (event.decodeError == null) {
  34715. try {
  34716. var args = runningEvent.getEmit(event);
  34717. _this.emit.apply(_this, __spreadArray([runningEvent.filter], args, false));
  34718. }
  34719. catch (error) {
  34720. event.decodeError = error.error;
  34721. }
  34722. }
  34723. // Always emit "event" for fragment-base events
  34724. if (runningEvent.filter != null) {
  34725. _this.emit("event", event);
  34726. }
  34727. // Emit "error" if there was an error
  34728. if (event.decodeError != null) {
  34729. _this.emit("error", event.decodeError, event);
  34730. }
  34731. };
  34732. this._wrappedEmits[runningEvent.tag] = wrappedEmit;
  34733. // Special events, like "error" do not have a filter
  34734. if (runningEvent.filter != null) {
  34735. this.provider.on(runningEvent.filter, wrappedEmit);
  34736. }
  34737. }
  34738. };
  34739. BaseContract.prototype.queryFilter = function (event, fromBlockOrBlockhash, toBlock) {
  34740. var _this = this;
  34741. var runningEvent = this._getRunningEvent(event);
  34742. var filter = (0, properties_1.shallowCopy)(runningEvent.filter);
  34743. if (typeof (fromBlockOrBlockhash) === "string" && (0, bytes_1.isHexString)(fromBlockOrBlockhash, 32)) {
  34744. if (toBlock != null) {
  34745. logger.throwArgumentError("cannot specify toBlock with blockhash", "toBlock", toBlock);
  34746. }
  34747. filter.blockHash = fromBlockOrBlockhash;
  34748. }
  34749. else {
  34750. filter.fromBlock = ((fromBlockOrBlockhash != null) ? fromBlockOrBlockhash : 0);
  34751. filter.toBlock = ((toBlock != null) ? toBlock : "latest");
  34752. }
  34753. return this.provider.getLogs(filter).then(function (logs) {
  34754. return logs.map(function (log) { return _this._wrapEvent(runningEvent, log, null); });
  34755. });
  34756. };
  34757. BaseContract.prototype.on = function (event, listener) {
  34758. this._addEventListener(this._getRunningEvent(event), listener, false);
  34759. return this;
  34760. };
  34761. BaseContract.prototype.once = function (event, listener) {
  34762. this._addEventListener(this._getRunningEvent(event), listener, true);
  34763. return this;
  34764. };
  34765. BaseContract.prototype.emit = function (eventName) {
  34766. var args = [];
  34767. for (var _i = 1; _i < arguments.length; _i++) {
  34768. args[_i - 1] = arguments[_i];
  34769. }
  34770. if (!this.provider) {
  34771. return false;
  34772. }
  34773. var runningEvent = this._getRunningEvent(eventName);
  34774. var result = (runningEvent.run(args) > 0);
  34775. // May have drained all the "once" events; check for living events
  34776. this._checkRunningEvents(runningEvent);
  34777. return result;
  34778. };
  34779. BaseContract.prototype.listenerCount = function (eventName) {
  34780. var _this = this;
  34781. if (!this.provider) {
  34782. return 0;
  34783. }
  34784. if (eventName == null) {
  34785. return Object.keys(this._runningEvents).reduce(function (accum, key) {
  34786. return accum + _this._runningEvents[key].listenerCount();
  34787. }, 0);
  34788. }
  34789. return this._getRunningEvent(eventName).listenerCount();
  34790. };
  34791. BaseContract.prototype.listeners = function (eventName) {
  34792. if (!this.provider) {
  34793. return [];
  34794. }
  34795. if (eventName == null) {
  34796. var result_1 = [];
  34797. for (var tag in this._runningEvents) {
  34798. this._runningEvents[tag].listeners().forEach(function (listener) {
  34799. result_1.push(listener);
  34800. });
  34801. }
  34802. return result_1;
  34803. }
  34804. return this._getRunningEvent(eventName).listeners();
  34805. };
  34806. BaseContract.prototype.removeAllListeners = function (eventName) {
  34807. if (!this.provider) {
  34808. return this;
  34809. }
  34810. if (eventName == null) {
  34811. for (var tag in this._runningEvents) {
  34812. var runningEvent_1 = this._runningEvents[tag];
  34813. runningEvent_1.removeAllListeners();
  34814. this._checkRunningEvents(runningEvent_1);
  34815. }
  34816. return this;
  34817. }
  34818. // Delete any listeners
  34819. var runningEvent = this._getRunningEvent(eventName);
  34820. runningEvent.removeAllListeners();
  34821. this._checkRunningEvents(runningEvent);
  34822. return this;
  34823. };
  34824. BaseContract.prototype.off = function (eventName, listener) {
  34825. if (!this.provider) {
  34826. return this;
  34827. }
  34828. var runningEvent = this._getRunningEvent(eventName);
  34829. runningEvent.removeListener(listener);
  34830. this._checkRunningEvents(runningEvent);
  34831. return this;
  34832. };
  34833. BaseContract.prototype.removeListener = function (eventName, listener) {
  34834. return this.off(eventName, listener);
  34835. };
  34836. return BaseContract;
  34837. }());
  34838. exports.BaseContract = BaseContract;
  34839. var Contract = /** @class */ (function (_super) {
  34840. __extends(Contract, _super);
  34841. function Contract() {
  34842. return _super !== null && _super.apply(this, arguments) || this;
  34843. }
  34844. return Contract;
  34845. }(BaseContract));
  34846. exports.Contract = Contract;
  34847. var ContractFactory = /** @class */ (function () {
  34848. function ContractFactory(contractInterface, bytecode, signer) {
  34849. var _newTarget = this.constructor;
  34850. var bytecodeHex = null;
  34851. if (typeof (bytecode) === "string") {
  34852. bytecodeHex = bytecode;
  34853. }
  34854. else if ((0, bytes_1.isBytes)(bytecode)) {
  34855. bytecodeHex = (0, bytes_1.hexlify)(bytecode);
  34856. }
  34857. else if (bytecode && typeof (bytecode.object) === "string") {
  34858. // Allow the bytecode object from the Solidity compiler
  34859. bytecodeHex = bytecode.object;
  34860. }
  34861. else {
  34862. // Crash in the next verification step
  34863. bytecodeHex = "!";
  34864. }
  34865. // Make sure it is 0x prefixed
  34866. if (bytecodeHex.substring(0, 2) !== "0x") {
  34867. bytecodeHex = "0x" + bytecodeHex;
  34868. }
  34869. // Make sure the final result is valid bytecode
  34870. if (!(0, bytes_1.isHexString)(bytecodeHex) || (bytecodeHex.length % 2)) {
  34871. logger.throwArgumentError("invalid bytecode", "bytecode", bytecode);
  34872. }
  34873. // If we have a signer, make sure it is valid
  34874. if (signer && !abstract_signer_1.Signer.isSigner(signer)) {
  34875. logger.throwArgumentError("invalid signer", "signer", signer);
  34876. }
  34877. (0, properties_1.defineReadOnly)(this, "bytecode", bytecodeHex);
  34878. (0, properties_1.defineReadOnly)(this, "interface", (0, properties_1.getStatic)(_newTarget, "getInterface")(contractInterface));
  34879. (0, properties_1.defineReadOnly)(this, "signer", signer || null);
  34880. }
  34881. // @TODO: Future; rename to populateTransaction?
  34882. ContractFactory.prototype.getDeployTransaction = function () {
  34883. var args = [];
  34884. for (var _i = 0; _i < arguments.length; _i++) {
  34885. args[_i] = arguments[_i];
  34886. }
  34887. var tx = {};
  34888. // If we have 1 additional argument, we allow transaction overrides
  34889. if (args.length === this.interface.deploy.inputs.length + 1 && typeof (args[args.length - 1]) === "object") {
  34890. tx = (0, properties_1.shallowCopy)(args.pop());
  34891. for (var key in tx) {
  34892. if (!allowedTransactionKeys[key]) {
  34893. throw new Error("unknown transaction override " + key);
  34894. }
  34895. }
  34896. }
  34897. // Do not allow these to be overridden in a deployment transaction
  34898. ["data", "from", "to"].forEach(function (key) {
  34899. if (tx[key] == null) {
  34900. return;
  34901. }
  34902. logger.throwError("cannot override " + key, logger_1.Logger.errors.UNSUPPORTED_OPERATION, { operation: key });
  34903. });
  34904. if (tx.value) {
  34905. var value = bignumber_1.BigNumber.from(tx.value);
  34906. if (!value.isZero() && !this.interface.deploy.payable) {
  34907. logger.throwError("non-payable constructor cannot override value", logger_1.Logger.errors.UNSUPPORTED_OPERATION, {
  34908. operation: "overrides.value",
  34909. value: tx.value
  34910. });
  34911. }
  34912. }
  34913. // Make sure the call matches the constructor signature
  34914. logger.checkArgumentCount(args.length, this.interface.deploy.inputs.length, " in Contract constructor");
  34915. // Set the data to the bytecode + the encoded constructor arguments
  34916. tx.data = (0, bytes_1.hexlify)((0, bytes_1.concat)([
  34917. this.bytecode,
  34918. this.interface.encodeDeploy(args)
  34919. ]));
  34920. return tx;
  34921. };
  34922. ContractFactory.prototype.deploy = function () {
  34923. var args = [];
  34924. for (var _i = 0; _i < arguments.length; _i++) {
  34925. args[_i] = arguments[_i];
  34926. }
  34927. return __awaiter(this, void 0, void 0, function () {
  34928. var overrides, params, unsignedTx, tx, address, contract;
  34929. return __generator(this, function (_a) {
  34930. switch (_a.label) {
  34931. case 0:
  34932. overrides = {};
  34933. // If 1 extra parameter was passed in, it contains overrides
  34934. if (args.length === this.interface.deploy.inputs.length + 1) {
  34935. overrides = args.pop();
  34936. }
  34937. // Make sure the call matches the constructor signature
  34938. logger.checkArgumentCount(args.length, this.interface.deploy.inputs.length, " in Contract constructor");
  34939. return [4 /*yield*/, resolveAddresses(this.signer, args, this.interface.deploy.inputs)];
  34940. case 1:
  34941. params = _a.sent();
  34942. params.push(overrides);
  34943. unsignedTx = this.getDeployTransaction.apply(this, params);
  34944. return [4 /*yield*/, this.signer.sendTransaction(unsignedTx)];
  34945. case 2:
  34946. tx = _a.sent();
  34947. address = (0, properties_1.getStatic)(this.constructor, "getContractAddress")(tx);
  34948. contract = (0, properties_1.getStatic)(this.constructor, "getContract")(address, this.interface, this.signer);
  34949. // Add the modified wait that wraps events
  34950. addContractWait(contract, tx);
  34951. (0, properties_1.defineReadOnly)(contract, "deployTransaction", tx);
  34952. return [2 /*return*/, contract];
  34953. }
  34954. });
  34955. });
  34956. };
  34957. ContractFactory.prototype.attach = function (address) {
  34958. return (this.constructor).getContract(address, this.interface, this.signer);
  34959. };
  34960. ContractFactory.prototype.connect = function (signer) {
  34961. return new (this.constructor)(this.interface, this.bytecode, signer);
  34962. };
  34963. ContractFactory.fromSolidity = function (compilerOutput, signer) {
  34964. if (compilerOutput == null) {
  34965. logger.throwError("missing compiler output", logger_1.Logger.errors.MISSING_ARGUMENT, { argument: "compilerOutput" });
  34966. }
  34967. if (typeof (compilerOutput) === "string") {
  34968. compilerOutput = JSON.parse(compilerOutput);
  34969. }
  34970. var abi = compilerOutput.abi;
  34971. var bytecode = null;
  34972. if (compilerOutput.bytecode) {
  34973. bytecode = compilerOutput.bytecode;
  34974. }
  34975. else if (compilerOutput.evm && compilerOutput.evm.bytecode) {
  34976. bytecode = compilerOutput.evm.bytecode;
  34977. }
  34978. return new this(abi, bytecode, signer);
  34979. };
  34980. ContractFactory.getInterface = function (contractInterface) {
  34981. return Contract.getInterface(contractInterface);
  34982. };
  34983. ContractFactory.getContractAddress = function (tx) {
  34984. return (0, address_1.getContractAddress)(tx);
  34985. };
  34986. ContractFactory.getContract = function (address, contractInterface, signer) {
  34987. return new Contract(address, contractInterface, signer);
  34988. };
  34989. return ContractFactory;
  34990. }());
  34991. exports.ContractFactory = ContractFactory;
  34992. },{"./_version":205,"@ethersproject/abi":182,"@ethersproject/abstract-provider":185,"@ethersproject/abstract-signer":187,"@ethersproject/address":189,"@ethersproject/bignumber":196,"@ethersproject/bytes":199,"@ethersproject/logger":223,"@ethersproject/properties":229,"@ethersproject/transactions":269}],207:[function(_dereq_,module,exports){
  34993. "use strict";
  34994. Object.defineProperty(exports, "__esModule", { value: true });
  34995. exports.version = void 0;
  34996. exports.version = "hash/5.6.0";
  34997. },{}],208:[function(_dereq_,module,exports){
  34998. "use strict";
  34999. Object.defineProperty(exports, "__esModule", { value: true });
  35000. exports.id = void 0;
  35001. var keccak256_1 = _dereq_("@ethersproject/keccak256");
  35002. var strings_1 = _dereq_("@ethersproject/strings");
  35003. function id(text) {
  35004. return (0, keccak256_1.keccak256)((0, strings_1.toUtf8Bytes)(text));
  35005. }
  35006. exports.id = id;
  35007. },{"@ethersproject/keccak256":221,"@ethersproject/strings":266}],209:[function(_dereq_,module,exports){
  35008. "use strict";
  35009. Object.defineProperty(exports, "__esModule", { value: true });
  35010. exports._TypedDataEncoder = exports.hashMessage = exports.messagePrefix = exports.isValidName = exports.namehash = exports.dnsEncode = exports.id = void 0;
  35011. var id_1 = _dereq_("./id");
  35012. Object.defineProperty(exports, "id", { enumerable: true, get: function () { return id_1.id; } });
  35013. var namehash_1 = _dereq_("./namehash");
  35014. Object.defineProperty(exports, "dnsEncode", { enumerable: true, get: function () { return namehash_1.dnsEncode; } });
  35015. Object.defineProperty(exports, "isValidName", { enumerable: true, get: function () { return namehash_1.isValidName; } });
  35016. Object.defineProperty(exports, "namehash", { enumerable: true, get: function () { return namehash_1.namehash; } });
  35017. var message_1 = _dereq_("./message");
  35018. Object.defineProperty(exports, "hashMessage", { enumerable: true, get: function () { return message_1.hashMessage; } });
  35019. Object.defineProperty(exports, "messagePrefix", { enumerable: true, get: function () { return message_1.messagePrefix; } });
  35020. var typed_data_1 = _dereq_("./typed-data");
  35021. Object.defineProperty(exports, "_TypedDataEncoder", { enumerable: true, get: function () { return typed_data_1.TypedDataEncoder; } });
  35022. },{"./id":208,"./message":210,"./namehash":211,"./typed-data":212}],210:[function(_dereq_,module,exports){
  35023. "use strict";
  35024. Object.defineProperty(exports, "__esModule", { value: true });
  35025. exports.hashMessage = exports.messagePrefix = void 0;
  35026. var bytes_1 = _dereq_("@ethersproject/bytes");
  35027. var keccak256_1 = _dereq_("@ethersproject/keccak256");
  35028. var strings_1 = _dereq_("@ethersproject/strings");
  35029. exports.messagePrefix = "\x19Ethereum Signed Message:\n";
  35030. function hashMessage(message) {
  35031. if (typeof (message) === "string") {
  35032. message = (0, strings_1.toUtf8Bytes)(message);
  35033. }
  35034. return (0, keccak256_1.keccak256)((0, bytes_1.concat)([
  35035. (0, strings_1.toUtf8Bytes)(exports.messagePrefix),
  35036. (0, strings_1.toUtf8Bytes)(String(message.length)),
  35037. message
  35038. ]));
  35039. }
  35040. exports.hashMessage = hashMessage;
  35041. },{"@ethersproject/bytes":199,"@ethersproject/keccak256":221,"@ethersproject/strings":266}],211:[function(_dereq_,module,exports){
  35042. "use strict";
  35043. Object.defineProperty(exports, "__esModule", { value: true });
  35044. exports.dnsEncode = exports.namehash = exports.isValidName = void 0;
  35045. var bytes_1 = _dereq_("@ethersproject/bytes");
  35046. var strings_1 = _dereq_("@ethersproject/strings");
  35047. var keccak256_1 = _dereq_("@ethersproject/keccak256");
  35048. var logger_1 = _dereq_("@ethersproject/logger");
  35049. var _version_1 = _dereq_("./_version");
  35050. var logger = new logger_1.Logger(_version_1.version);
  35051. var Zeros = new Uint8Array(32);
  35052. Zeros.fill(0);
  35053. var Partition = new RegExp("^((.*)\\.)?([^.]+)$");
  35054. function isValidName(name) {
  35055. try {
  35056. var comps = name.split(".");
  35057. for (var i = 0; i < comps.length; i++) {
  35058. if ((0, strings_1.nameprep)(comps[i]).length === 0) {
  35059. throw new Error("empty");
  35060. }
  35061. }
  35062. return true;
  35063. }
  35064. catch (error) { }
  35065. return false;
  35066. }
  35067. exports.isValidName = isValidName;
  35068. function namehash(name) {
  35069. /* istanbul ignore if */
  35070. if (typeof (name) !== "string") {
  35071. logger.throwArgumentError("invalid ENS name; not a string", "name", name);
  35072. }
  35073. var current = name;
  35074. var result = Zeros;
  35075. while (current.length) {
  35076. var partition = current.match(Partition);
  35077. if (partition == null || partition[2] === "") {
  35078. logger.throwArgumentError("invalid ENS address; missing component", "name", name);
  35079. }
  35080. var label = (0, strings_1.toUtf8Bytes)((0, strings_1.nameprep)(partition[3]));
  35081. result = (0, keccak256_1.keccak256)((0, bytes_1.concat)([result, (0, keccak256_1.keccak256)(label)]));
  35082. current = partition[2] || "";
  35083. }
  35084. return (0, bytes_1.hexlify)(result);
  35085. }
  35086. exports.namehash = namehash;
  35087. function dnsEncode(name) {
  35088. return (0, bytes_1.hexlify)((0, bytes_1.concat)(name.split(".").map(function (comp) {
  35089. // We jam in an _ prefix to fill in with the length later
  35090. // Note: Nameprep throws if the component is over 63 bytes
  35091. var bytes = (0, strings_1.toUtf8Bytes)("_" + (0, strings_1.nameprep)(comp));
  35092. bytes[0] = bytes.length - 1;
  35093. return bytes;
  35094. }))) + "00";
  35095. }
  35096. exports.dnsEncode = dnsEncode;
  35097. },{"./_version":207,"@ethersproject/bytes":199,"@ethersproject/keccak256":221,"@ethersproject/logger":223,"@ethersproject/strings":266}],212:[function(_dereq_,module,exports){
  35098. "use strict";
  35099. var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
  35100. function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
  35101. return new (P || (P = Promise))(function (resolve, reject) {
  35102. function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
  35103. function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
  35104. function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
  35105. step((generator = generator.apply(thisArg, _arguments || [])).next());
  35106. });
  35107. };
  35108. var __generator = (this && this.__generator) || function (thisArg, body) {
  35109. var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
  35110. return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
  35111. function verb(n) { return function (v) { return step([n, v]); }; }
  35112. function step(op) {
  35113. if (f) throw new TypeError("Generator is already executing.");
  35114. while (_) try {
  35115. if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
  35116. if (y = 0, t) op = [op[0] & 2, t.value];
  35117. switch (op[0]) {
  35118. case 0: case 1: t = op; break;
  35119. case 4: _.label++; return { value: op[1], done: false };
  35120. case 5: _.label++; y = op[1]; op = [0]; continue;
  35121. case 7: op = _.ops.pop(); _.trys.pop(); continue;
  35122. default:
  35123. if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
  35124. if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
  35125. if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
  35126. if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
  35127. if (t[2]) _.ops.pop();
  35128. _.trys.pop(); continue;
  35129. }
  35130. op = body.call(thisArg, _);
  35131. } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
  35132. if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
  35133. }
  35134. };
  35135. Object.defineProperty(exports, "__esModule", { value: true });
  35136. exports.TypedDataEncoder = void 0;
  35137. var address_1 = _dereq_("@ethersproject/address");
  35138. var bignumber_1 = _dereq_("@ethersproject/bignumber");
  35139. var bytes_1 = _dereq_("@ethersproject/bytes");
  35140. var keccak256_1 = _dereq_("@ethersproject/keccak256");
  35141. var properties_1 = _dereq_("@ethersproject/properties");
  35142. var logger_1 = _dereq_("@ethersproject/logger");
  35143. var _version_1 = _dereq_("./_version");
  35144. var logger = new logger_1.Logger(_version_1.version);
  35145. var id_1 = _dereq_("./id");
  35146. var padding = new Uint8Array(32);
  35147. padding.fill(0);
  35148. var NegativeOne = bignumber_1.BigNumber.from(-1);
  35149. var Zero = bignumber_1.BigNumber.from(0);
  35150. var One = bignumber_1.BigNumber.from(1);
  35151. var MaxUint256 = bignumber_1.BigNumber.from("0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff");
  35152. function hexPadRight(value) {
  35153. var bytes = (0, bytes_1.arrayify)(value);
  35154. var padOffset = bytes.length % 32;
  35155. if (padOffset) {
  35156. return (0, bytes_1.hexConcat)([bytes, padding.slice(padOffset)]);
  35157. }
  35158. return (0, bytes_1.hexlify)(bytes);
  35159. }
  35160. var hexTrue = (0, bytes_1.hexZeroPad)(One.toHexString(), 32);
  35161. var hexFalse = (0, bytes_1.hexZeroPad)(Zero.toHexString(), 32);
  35162. var domainFieldTypes = {
  35163. name: "string",
  35164. version: "string",
  35165. chainId: "uint256",
  35166. verifyingContract: "address",
  35167. salt: "bytes32"
  35168. };
  35169. var domainFieldNames = [
  35170. "name", "version", "chainId", "verifyingContract", "salt"
  35171. ];
  35172. function checkString(key) {
  35173. return function (value) {
  35174. if (typeof (value) !== "string") {
  35175. logger.throwArgumentError("invalid domain value for " + JSON.stringify(key), "domain." + key, value);
  35176. }
  35177. return value;
  35178. };
  35179. }
  35180. var domainChecks = {
  35181. name: checkString("name"),
  35182. version: checkString("version"),
  35183. chainId: function (value) {
  35184. try {
  35185. return bignumber_1.BigNumber.from(value).toString();
  35186. }
  35187. catch (error) { }
  35188. return logger.throwArgumentError("invalid domain value for \"chainId\"", "domain.chainId", value);
  35189. },
  35190. verifyingContract: function (value) {
  35191. try {
  35192. return (0, address_1.getAddress)(value).toLowerCase();
  35193. }
  35194. catch (error) { }
  35195. return logger.throwArgumentError("invalid domain value \"verifyingContract\"", "domain.verifyingContract", value);
  35196. },
  35197. salt: function (value) {
  35198. try {
  35199. var bytes = (0, bytes_1.arrayify)(value);
  35200. if (bytes.length !== 32) {
  35201. throw new Error("bad length");
  35202. }
  35203. return (0, bytes_1.hexlify)(bytes);
  35204. }
  35205. catch (error) { }
  35206. return logger.throwArgumentError("invalid domain value \"salt\"", "domain.salt", value);
  35207. }
  35208. };
  35209. function getBaseEncoder(type) {
  35210. // intXX and uintXX
  35211. {
  35212. var match = type.match(/^(u?)int(\d*)$/);
  35213. if (match) {
  35214. var signed = (match[1] === "");
  35215. var width = parseInt(match[2] || "256");
  35216. if (width % 8 !== 0 || width > 256 || (match[2] && match[2] !== String(width))) {
  35217. logger.throwArgumentError("invalid numeric width", "type", type);
  35218. }
  35219. var boundsUpper_1 = MaxUint256.mask(signed ? (width - 1) : width);
  35220. var boundsLower_1 = signed ? boundsUpper_1.add(One).mul(NegativeOne) : Zero;
  35221. return function (value) {
  35222. var v = bignumber_1.BigNumber.from(value);
  35223. if (v.lt(boundsLower_1) || v.gt(boundsUpper_1)) {
  35224. logger.throwArgumentError("value out-of-bounds for " + type, "value", value);
  35225. }
  35226. return (0, bytes_1.hexZeroPad)(v.toTwos(256).toHexString(), 32);
  35227. };
  35228. }
  35229. }
  35230. // bytesXX
  35231. {
  35232. var match = type.match(/^bytes(\d+)$/);
  35233. if (match) {
  35234. var width_1 = parseInt(match[1]);
  35235. if (width_1 === 0 || width_1 > 32 || match[1] !== String(width_1)) {
  35236. logger.throwArgumentError("invalid bytes width", "type", type);
  35237. }
  35238. return function (value) {
  35239. var bytes = (0, bytes_1.arrayify)(value);
  35240. if (bytes.length !== width_1) {
  35241. logger.throwArgumentError("invalid length for " + type, "value", value);
  35242. }
  35243. return hexPadRight(value);
  35244. };
  35245. }
  35246. }
  35247. switch (type) {
  35248. case "address": return function (value) {
  35249. return (0, bytes_1.hexZeroPad)((0, address_1.getAddress)(value), 32);
  35250. };
  35251. case "bool": return function (value) {
  35252. return ((!value) ? hexFalse : hexTrue);
  35253. };
  35254. case "bytes": return function (value) {
  35255. return (0, keccak256_1.keccak256)(value);
  35256. };
  35257. case "string": return function (value) {
  35258. return (0, id_1.id)(value);
  35259. };
  35260. }
  35261. return null;
  35262. }
  35263. function encodeType(name, fields) {
  35264. return name + "(" + fields.map(function (_a) {
  35265. var name = _a.name, type = _a.type;
  35266. return (type + " " + name);
  35267. }).join(",") + ")";
  35268. }
  35269. var TypedDataEncoder = /** @class */ (function () {
  35270. function TypedDataEncoder(types) {
  35271. (0, properties_1.defineReadOnly)(this, "types", Object.freeze((0, properties_1.deepCopy)(types)));
  35272. (0, properties_1.defineReadOnly)(this, "_encoderCache", {});
  35273. (0, properties_1.defineReadOnly)(this, "_types", {});
  35274. // Link struct types to their direct child structs
  35275. var links = {};
  35276. // Link structs to structs which contain them as a child
  35277. var parents = {};
  35278. // Link all subtypes within a given struct
  35279. var subtypes = {};
  35280. Object.keys(types).forEach(function (type) {
  35281. links[type] = {};
  35282. parents[type] = [];
  35283. subtypes[type] = {};
  35284. });
  35285. var _loop_1 = function (name_1) {
  35286. var uniqueNames = {};
  35287. types[name_1].forEach(function (field) {
  35288. // Check each field has a unique name
  35289. if (uniqueNames[field.name]) {
  35290. logger.throwArgumentError("duplicate variable name " + JSON.stringify(field.name) + " in " + JSON.stringify(name_1), "types", types);
  35291. }
  35292. uniqueNames[field.name] = true;
  35293. // Get the base type (drop any array specifiers)
  35294. var baseType = field.type.match(/^([^\x5b]*)(\x5b|$)/)[1];
  35295. if (baseType === name_1) {
  35296. logger.throwArgumentError("circular type reference to " + JSON.stringify(baseType), "types", types);
  35297. }
  35298. // Is this a base encoding type?
  35299. var encoder = getBaseEncoder(baseType);
  35300. if (encoder) {
  35301. return;
  35302. }
  35303. if (!parents[baseType]) {
  35304. logger.throwArgumentError("unknown type " + JSON.stringify(baseType), "types", types);
  35305. }
  35306. // Add linkage
  35307. parents[baseType].push(name_1);
  35308. links[name_1][baseType] = true;
  35309. });
  35310. };
  35311. for (var name_1 in types) {
  35312. _loop_1(name_1);
  35313. }
  35314. // Deduce the primary type
  35315. var primaryTypes = Object.keys(parents).filter(function (n) { return (parents[n].length === 0); });
  35316. if (primaryTypes.length === 0) {
  35317. logger.throwArgumentError("missing primary type", "types", types);
  35318. }
  35319. else if (primaryTypes.length > 1) {
  35320. logger.throwArgumentError("ambiguous primary types or unused types: " + primaryTypes.map(function (t) { return (JSON.stringify(t)); }).join(", "), "types", types);
  35321. }
  35322. (0, properties_1.defineReadOnly)(this, "primaryType", primaryTypes[0]);
  35323. // Check for circular type references
  35324. function checkCircular(type, found) {
  35325. if (found[type]) {
  35326. logger.throwArgumentError("circular type reference to " + JSON.stringify(type), "types", types);
  35327. }
  35328. found[type] = true;
  35329. Object.keys(links[type]).forEach(function (child) {
  35330. if (!parents[child]) {
  35331. return;
  35332. }
  35333. // Recursively check children
  35334. checkCircular(child, found);
  35335. // Mark all ancestors as having this decendant
  35336. Object.keys(found).forEach(function (subtype) {
  35337. subtypes[subtype][child] = true;
  35338. });
  35339. });
  35340. delete found[type];
  35341. }
  35342. checkCircular(this.primaryType, {});
  35343. // Compute each fully describe type
  35344. for (var name_2 in subtypes) {
  35345. var st = Object.keys(subtypes[name_2]);
  35346. st.sort();
  35347. this._types[name_2] = encodeType(name_2, types[name_2]) + st.map(function (t) { return encodeType(t, types[t]); }).join("");
  35348. }
  35349. }
  35350. TypedDataEncoder.prototype.getEncoder = function (type) {
  35351. var encoder = this._encoderCache[type];
  35352. if (!encoder) {
  35353. encoder = this._encoderCache[type] = this._getEncoder(type);
  35354. }
  35355. return encoder;
  35356. };
  35357. TypedDataEncoder.prototype._getEncoder = function (type) {
  35358. var _this = this;
  35359. // Basic encoder type (address, bool, uint256, etc)
  35360. {
  35361. var encoder = getBaseEncoder(type);
  35362. if (encoder) {
  35363. return encoder;
  35364. }
  35365. }
  35366. // Array
  35367. var match = type.match(/^(.*)(\x5b(\d*)\x5d)$/);
  35368. if (match) {
  35369. var subtype_1 = match[1];
  35370. var subEncoder_1 = this.getEncoder(subtype_1);
  35371. var length_1 = parseInt(match[3]);
  35372. return function (value) {
  35373. if (length_1 >= 0 && value.length !== length_1) {
  35374. logger.throwArgumentError("array length mismatch; expected length ${ arrayLength }", "value", value);
  35375. }
  35376. var result = value.map(subEncoder_1);
  35377. if (_this._types[subtype_1]) {
  35378. result = result.map(keccak256_1.keccak256);
  35379. }
  35380. return (0, keccak256_1.keccak256)((0, bytes_1.hexConcat)(result));
  35381. };
  35382. }
  35383. // Struct
  35384. var fields = this.types[type];
  35385. if (fields) {
  35386. var encodedType_1 = (0, id_1.id)(this._types[type]);
  35387. return function (value) {
  35388. var values = fields.map(function (_a) {
  35389. var name = _a.name, type = _a.type;
  35390. var result = _this.getEncoder(type)(value[name]);
  35391. if (_this._types[type]) {
  35392. return (0, keccak256_1.keccak256)(result);
  35393. }
  35394. return result;
  35395. });
  35396. values.unshift(encodedType_1);
  35397. return (0, bytes_1.hexConcat)(values);
  35398. };
  35399. }
  35400. return logger.throwArgumentError("unknown type: " + type, "type", type);
  35401. };
  35402. TypedDataEncoder.prototype.encodeType = function (name) {
  35403. var result = this._types[name];
  35404. if (!result) {
  35405. logger.throwArgumentError("unknown type: " + JSON.stringify(name), "name", name);
  35406. }
  35407. return result;
  35408. };
  35409. TypedDataEncoder.prototype.encodeData = function (type, value) {
  35410. return this.getEncoder(type)(value);
  35411. };
  35412. TypedDataEncoder.prototype.hashStruct = function (name, value) {
  35413. return (0, keccak256_1.keccak256)(this.encodeData(name, value));
  35414. };
  35415. TypedDataEncoder.prototype.encode = function (value) {
  35416. return this.encodeData(this.primaryType, value);
  35417. };
  35418. TypedDataEncoder.prototype.hash = function (value) {
  35419. return this.hashStruct(this.primaryType, value);
  35420. };
  35421. TypedDataEncoder.prototype._visit = function (type, value, callback) {
  35422. var _this = this;
  35423. // Basic encoder type (address, bool, uint256, etc)
  35424. {
  35425. var encoder = getBaseEncoder(type);
  35426. if (encoder) {
  35427. return callback(type, value);
  35428. }
  35429. }
  35430. // Array
  35431. var match = type.match(/^(.*)(\x5b(\d*)\x5d)$/);
  35432. if (match) {
  35433. var subtype_2 = match[1];
  35434. var length_2 = parseInt(match[3]);
  35435. if (length_2 >= 0 && value.length !== length_2) {
  35436. logger.throwArgumentError("array length mismatch; expected length ${ arrayLength }", "value", value);
  35437. }
  35438. return value.map(function (v) { return _this._visit(subtype_2, v, callback); });
  35439. }
  35440. // Struct
  35441. var fields = this.types[type];
  35442. if (fields) {
  35443. return fields.reduce(function (accum, _a) {
  35444. var name = _a.name, type = _a.type;
  35445. accum[name] = _this._visit(type, value[name], callback);
  35446. return accum;
  35447. }, {});
  35448. }
  35449. return logger.throwArgumentError("unknown type: " + type, "type", type);
  35450. };
  35451. TypedDataEncoder.prototype.visit = function (value, callback) {
  35452. return this._visit(this.primaryType, value, callback);
  35453. };
  35454. TypedDataEncoder.from = function (types) {
  35455. return new TypedDataEncoder(types);
  35456. };
  35457. TypedDataEncoder.getPrimaryType = function (types) {
  35458. return TypedDataEncoder.from(types).primaryType;
  35459. };
  35460. TypedDataEncoder.hashStruct = function (name, types, value) {
  35461. return TypedDataEncoder.from(types).hashStruct(name, value);
  35462. };
  35463. TypedDataEncoder.hashDomain = function (domain) {
  35464. var domainFields = [];
  35465. for (var name_3 in domain) {
  35466. var type = domainFieldTypes[name_3];
  35467. if (!type) {
  35468. logger.throwArgumentError("invalid typed-data domain key: " + JSON.stringify(name_3), "domain", domain);
  35469. }
  35470. domainFields.push({ name: name_3, type: type });
  35471. }
  35472. domainFields.sort(function (a, b) {
  35473. return domainFieldNames.indexOf(a.name) - domainFieldNames.indexOf(b.name);
  35474. });
  35475. return TypedDataEncoder.hashStruct("EIP712Domain", { EIP712Domain: domainFields }, domain);
  35476. };
  35477. TypedDataEncoder.encode = function (domain, types, value) {
  35478. return (0, bytes_1.hexConcat)([
  35479. "0x1901",
  35480. TypedDataEncoder.hashDomain(domain),
  35481. TypedDataEncoder.from(types).hash(value)
  35482. ]);
  35483. };
  35484. TypedDataEncoder.hash = function (domain, types, value) {
  35485. return (0, keccak256_1.keccak256)(TypedDataEncoder.encode(domain, types, value));
  35486. };
  35487. // Replaces all address types with ENS names with their looked up address
  35488. TypedDataEncoder.resolveNames = function (domain, types, value, resolveName) {
  35489. return __awaiter(this, void 0, void 0, function () {
  35490. var ensCache, encoder, _a, _b, _i, name_4, _c, _d;
  35491. return __generator(this, function (_e) {
  35492. switch (_e.label) {
  35493. case 0:
  35494. // Make a copy to isolate it from the object passed in
  35495. domain = (0, properties_1.shallowCopy)(domain);
  35496. ensCache = {};
  35497. // Do we need to look up the domain's verifyingContract?
  35498. if (domain.verifyingContract && !(0, bytes_1.isHexString)(domain.verifyingContract, 20)) {
  35499. ensCache[domain.verifyingContract] = "0x";
  35500. }
  35501. encoder = TypedDataEncoder.from(types);
  35502. // Get a list of all the addresses
  35503. encoder.visit(value, function (type, value) {
  35504. if (type === "address" && !(0, bytes_1.isHexString)(value, 20)) {
  35505. ensCache[value] = "0x";
  35506. }
  35507. return value;
  35508. });
  35509. _a = [];
  35510. for (_b in ensCache)
  35511. _a.push(_b);
  35512. _i = 0;
  35513. _e.label = 1;
  35514. case 1:
  35515. if (!(_i < _a.length)) return [3 /*break*/, 4];
  35516. name_4 = _a[_i];
  35517. _c = ensCache;
  35518. _d = name_4;
  35519. return [4 /*yield*/, resolveName(name_4)];
  35520. case 2:
  35521. _c[_d] = _e.sent();
  35522. _e.label = 3;
  35523. case 3:
  35524. _i++;
  35525. return [3 /*break*/, 1];
  35526. case 4:
  35527. // Replace the domain verifyingContract if needed
  35528. if (domain.verifyingContract && ensCache[domain.verifyingContract]) {
  35529. domain.verifyingContract = ensCache[domain.verifyingContract];
  35530. }
  35531. // Replace all ENS names with their address
  35532. value = encoder.visit(value, function (type, value) {
  35533. if (type === "address" && ensCache[value]) {
  35534. return ensCache[value];
  35535. }
  35536. return value;
  35537. });
  35538. return [2 /*return*/, { domain: domain, value: value }];
  35539. }
  35540. });
  35541. });
  35542. };
  35543. TypedDataEncoder.getPayload = function (domain, types, value) {
  35544. // Validate the domain fields
  35545. TypedDataEncoder.hashDomain(domain);
  35546. // Derive the EIP712Domain Struct reference type
  35547. var domainValues = {};
  35548. var domainTypes = [];
  35549. domainFieldNames.forEach(function (name) {
  35550. var value = domain[name];
  35551. if (value == null) {
  35552. return;
  35553. }
  35554. domainValues[name] = domainChecks[name](value);
  35555. domainTypes.push({ name: name, type: domainFieldTypes[name] });
  35556. });
  35557. var encoder = TypedDataEncoder.from(types);
  35558. var typesWithDomain = (0, properties_1.shallowCopy)(types);
  35559. if (typesWithDomain.EIP712Domain) {
  35560. logger.throwArgumentError("types must not contain EIP712Domain type", "types.EIP712Domain", types);
  35561. }
  35562. else {
  35563. typesWithDomain.EIP712Domain = domainTypes;
  35564. }
  35565. // Validate the data structures and types
  35566. encoder.encode(value);
  35567. return {
  35568. types: typesWithDomain,
  35569. domain: domainValues,
  35570. primaryType: encoder.primaryType,
  35571. message: encoder.visit(value, function (type, value) {
  35572. // bytes
  35573. if (type.match(/^bytes(\d*)/)) {
  35574. return (0, bytes_1.hexlify)((0, bytes_1.arrayify)(value));
  35575. }
  35576. // uint or int
  35577. if (type.match(/^u?int/)) {
  35578. return bignumber_1.BigNumber.from(value).toString();
  35579. }
  35580. switch (type) {
  35581. case "address":
  35582. return value.toLowerCase();
  35583. case "bool":
  35584. return !!value;
  35585. case "string":
  35586. if (typeof (value) !== "string") {
  35587. logger.throwArgumentError("invalid string", "value", value);
  35588. }
  35589. return value;
  35590. }
  35591. return logger.throwArgumentError("unsupported type", "type", type);
  35592. })
  35593. };
  35594. };
  35595. return TypedDataEncoder;
  35596. }());
  35597. exports.TypedDataEncoder = TypedDataEncoder;
  35598. },{"./_version":207,"./id":208,"@ethersproject/address":189,"@ethersproject/bignumber":196,"@ethersproject/bytes":199,"@ethersproject/keccak256":221,"@ethersproject/logger":223,"@ethersproject/properties":229}],213:[function(_dereq_,module,exports){
  35599. "use strict";
  35600. Object.defineProperty(exports, "__esModule", { value: true });
  35601. exports.version = void 0;
  35602. exports.version = "hdnode/5.6.0";
  35603. },{}],214:[function(_dereq_,module,exports){
  35604. "use strict";
  35605. Object.defineProperty(exports, "__esModule", { value: true });
  35606. exports.getAccountPath = exports.isValidMnemonic = exports.entropyToMnemonic = exports.mnemonicToEntropy = exports.mnemonicToSeed = exports.HDNode = exports.defaultPath = void 0;
  35607. var basex_1 = _dereq_("@ethersproject/basex");
  35608. var bytes_1 = _dereq_("@ethersproject/bytes");
  35609. var bignumber_1 = _dereq_("@ethersproject/bignumber");
  35610. var strings_1 = _dereq_("@ethersproject/strings");
  35611. var pbkdf2_1 = _dereq_("@ethersproject/pbkdf2");
  35612. var properties_1 = _dereq_("@ethersproject/properties");
  35613. var signing_key_1 = _dereq_("@ethersproject/signing-key");
  35614. var sha2_1 = _dereq_("@ethersproject/sha2");
  35615. var transactions_1 = _dereq_("@ethersproject/transactions");
  35616. var wordlists_1 = _dereq_("@ethersproject/wordlists");
  35617. var logger_1 = _dereq_("@ethersproject/logger");
  35618. var _version_1 = _dereq_("./_version");
  35619. var logger = new logger_1.Logger(_version_1.version);
  35620. var N = bignumber_1.BigNumber.from("0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141");
  35621. // "Bitcoin seed"
  35622. var MasterSecret = (0, strings_1.toUtf8Bytes)("Bitcoin seed");
  35623. var HardenedBit = 0x80000000;
  35624. // Returns a byte with the MSB bits set
  35625. function getUpperMask(bits) {
  35626. return ((1 << bits) - 1) << (8 - bits);
  35627. }
  35628. // Returns a byte with the LSB bits set
  35629. function getLowerMask(bits) {
  35630. return (1 << bits) - 1;
  35631. }
  35632. function bytes32(value) {
  35633. return (0, bytes_1.hexZeroPad)((0, bytes_1.hexlify)(value), 32);
  35634. }
  35635. function base58check(data) {
  35636. return basex_1.Base58.encode((0, bytes_1.concat)([data, (0, bytes_1.hexDataSlice)((0, sha2_1.sha256)((0, sha2_1.sha256)(data)), 0, 4)]));
  35637. }
  35638. function getWordlist(wordlist) {
  35639. if (wordlist == null) {
  35640. return wordlists_1.wordlists["en"];
  35641. }
  35642. if (typeof (wordlist) === "string") {
  35643. var words = wordlists_1.wordlists[wordlist];
  35644. if (words == null) {
  35645. logger.throwArgumentError("unknown locale", "wordlist", wordlist);
  35646. }
  35647. return words;
  35648. }
  35649. return wordlist;
  35650. }
  35651. var _constructorGuard = {};
  35652. exports.defaultPath = "m/44'/60'/0'/0/0";
  35653. ;
  35654. var HDNode = /** @class */ (function () {
  35655. /**
  35656. * This constructor should not be called directly.
  35657. *
  35658. * Please use:
  35659. * - fromMnemonic
  35660. * - fromSeed
  35661. */
  35662. function HDNode(constructorGuard, privateKey, publicKey, parentFingerprint, chainCode, index, depth, mnemonicOrPath) {
  35663. var _newTarget = this.constructor;
  35664. logger.checkNew(_newTarget, HDNode);
  35665. /* istanbul ignore if */
  35666. if (constructorGuard !== _constructorGuard) {
  35667. throw new Error("HDNode constructor cannot be called directly");
  35668. }
  35669. if (privateKey) {
  35670. var signingKey = new signing_key_1.SigningKey(privateKey);
  35671. (0, properties_1.defineReadOnly)(this, "privateKey", signingKey.privateKey);
  35672. (0, properties_1.defineReadOnly)(this, "publicKey", signingKey.compressedPublicKey);
  35673. }
  35674. else {
  35675. (0, properties_1.defineReadOnly)(this, "privateKey", null);
  35676. (0, properties_1.defineReadOnly)(this, "publicKey", (0, bytes_1.hexlify)(publicKey));
  35677. }
  35678. (0, properties_1.defineReadOnly)(this, "parentFingerprint", parentFingerprint);
  35679. (0, properties_1.defineReadOnly)(this, "fingerprint", (0, bytes_1.hexDataSlice)((0, sha2_1.ripemd160)((0, sha2_1.sha256)(this.publicKey)), 0, 4));
  35680. (0, properties_1.defineReadOnly)(this, "address", (0, transactions_1.computeAddress)(this.publicKey));
  35681. (0, properties_1.defineReadOnly)(this, "chainCode", chainCode);
  35682. (0, properties_1.defineReadOnly)(this, "index", index);
  35683. (0, properties_1.defineReadOnly)(this, "depth", depth);
  35684. if (mnemonicOrPath == null) {
  35685. // From a source that does not preserve the path (e.g. extended keys)
  35686. (0, properties_1.defineReadOnly)(this, "mnemonic", null);
  35687. (0, properties_1.defineReadOnly)(this, "path", null);
  35688. }
  35689. else if (typeof (mnemonicOrPath) === "string") {
  35690. // From a source that does not preserve the mnemonic (e.g. neutered)
  35691. (0, properties_1.defineReadOnly)(this, "mnemonic", null);
  35692. (0, properties_1.defineReadOnly)(this, "path", mnemonicOrPath);
  35693. }
  35694. else {
  35695. // From a fully qualified source
  35696. (0, properties_1.defineReadOnly)(this, "mnemonic", mnemonicOrPath);
  35697. (0, properties_1.defineReadOnly)(this, "path", mnemonicOrPath.path);
  35698. }
  35699. }
  35700. Object.defineProperty(HDNode.prototype, "extendedKey", {
  35701. get: function () {
  35702. // We only support the mainnet values for now, but if anyone needs
  35703. // testnet values, let me know. I believe current sentiment is that
  35704. // we should always use mainnet, and use BIP-44 to derive the network
  35705. // - Mainnet: public=0x0488B21E, private=0x0488ADE4
  35706. // - Testnet: public=0x043587CF, private=0x04358394
  35707. if (this.depth >= 256) {
  35708. throw new Error("Depth too large!");
  35709. }
  35710. return base58check((0, bytes_1.concat)([
  35711. ((this.privateKey != null) ? "0x0488ADE4" : "0x0488B21E"),
  35712. (0, bytes_1.hexlify)(this.depth),
  35713. this.parentFingerprint,
  35714. (0, bytes_1.hexZeroPad)((0, bytes_1.hexlify)(this.index), 4),
  35715. this.chainCode,
  35716. ((this.privateKey != null) ? (0, bytes_1.concat)(["0x00", this.privateKey]) : this.publicKey),
  35717. ]));
  35718. },
  35719. enumerable: false,
  35720. configurable: true
  35721. });
  35722. HDNode.prototype.neuter = function () {
  35723. return new HDNode(_constructorGuard, null, this.publicKey, this.parentFingerprint, this.chainCode, this.index, this.depth, this.path);
  35724. };
  35725. HDNode.prototype._derive = function (index) {
  35726. if (index > 0xffffffff) {
  35727. throw new Error("invalid index - " + String(index));
  35728. }
  35729. // Base path
  35730. var path = this.path;
  35731. if (path) {
  35732. path += "/" + (index & ~HardenedBit);
  35733. }
  35734. var data = new Uint8Array(37);
  35735. if (index & HardenedBit) {
  35736. if (!this.privateKey) {
  35737. throw new Error("cannot derive child of neutered node");
  35738. }
  35739. // Data = 0x00 || ser_256(k_par)
  35740. data.set((0, bytes_1.arrayify)(this.privateKey), 1);
  35741. // Hardened path
  35742. if (path) {
  35743. path += "'";
  35744. }
  35745. }
  35746. else {
  35747. // Data = ser_p(point(k_par))
  35748. data.set((0, bytes_1.arrayify)(this.publicKey));
  35749. }
  35750. // Data += ser_32(i)
  35751. for (var i = 24; i >= 0; i -= 8) {
  35752. data[33 + (i >> 3)] = ((index >> (24 - i)) & 0xff);
  35753. }
  35754. var I = (0, bytes_1.arrayify)((0, sha2_1.computeHmac)(sha2_1.SupportedAlgorithm.sha512, this.chainCode, data));
  35755. var IL = I.slice(0, 32);
  35756. var IR = I.slice(32);
  35757. // The private key
  35758. var ki = null;
  35759. // The public key
  35760. var Ki = null;
  35761. if (this.privateKey) {
  35762. ki = bytes32(bignumber_1.BigNumber.from(IL).add(this.privateKey).mod(N));
  35763. }
  35764. else {
  35765. var ek = new signing_key_1.SigningKey((0, bytes_1.hexlify)(IL));
  35766. Ki = ek._addPoint(this.publicKey);
  35767. }
  35768. var mnemonicOrPath = path;
  35769. var srcMnemonic = this.mnemonic;
  35770. if (srcMnemonic) {
  35771. mnemonicOrPath = Object.freeze({
  35772. phrase: srcMnemonic.phrase,
  35773. path: path,
  35774. locale: (srcMnemonic.locale || "en")
  35775. });
  35776. }
  35777. return new HDNode(_constructorGuard, ki, Ki, this.fingerprint, bytes32(IR), index, this.depth + 1, mnemonicOrPath);
  35778. };
  35779. HDNode.prototype.derivePath = function (path) {
  35780. var components = path.split("/");
  35781. if (components.length === 0 || (components[0] === "m" && this.depth !== 0)) {
  35782. throw new Error("invalid path - " + path);
  35783. }
  35784. if (components[0] === "m") {
  35785. components.shift();
  35786. }
  35787. var result = this;
  35788. for (var i = 0; i < components.length; i++) {
  35789. var component = components[i];
  35790. if (component.match(/^[0-9]+'$/)) {
  35791. var index = parseInt(component.substring(0, component.length - 1));
  35792. if (index >= HardenedBit) {
  35793. throw new Error("invalid path index - " + component);
  35794. }
  35795. result = result._derive(HardenedBit + index);
  35796. }
  35797. else if (component.match(/^[0-9]+$/)) {
  35798. var index = parseInt(component);
  35799. if (index >= HardenedBit) {
  35800. throw new Error("invalid path index - " + component);
  35801. }
  35802. result = result._derive(index);
  35803. }
  35804. else {
  35805. throw new Error("invalid path component - " + component);
  35806. }
  35807. }
  35808. return result;
  35809. };
  35810. HDNode._fromSeed = function (seed, mnemonic) {
  35811. var seedArray = (0, bytes_1.arrayify)(seed);
  35812. if (seedArray.length < 16 || seedArray.length > 64) {
  35813. throw new Error("invalid seed");
  35814. }
  35815. var I = (0, bytes_1.arrayify)((0, sha2_1.computeHmac)(sha2_1.SupportedAlgorithm.sha512, MasterSecret, seedArray));
  35816. return new HDNode(_constructorGuard, bytes32(I.slice(0, 32)), null, "0x00000000", bytes32(I.slice(32)), 0, 0, mnemonic);
  35817. };
  35818. HDNode.fromMnemonic = function (mnemonic, password, wordlist) {
  35819. // If a locale name was passed in, find the associated wordlist
  35820. wordlist = getWordlist(wordlist);
  35821. // Normalize the case and spacing in the mnemonic (throws if the mnemonic is invalid)
  35822. mnemonic = entropyToMnemonic(mnemonicToEntropy(mnemonic, wordlist), wordlist);
  35823. return HDNode._fromSeed(mnemonicToSeed(mnemonic, password), {
  35824. phrase: mnemonic,
  35825. path: "m",
  35826. locale: wordlist.locale
  35827. });
  35828. };
  35829. HDNode.fromSeed = function (seed) {
  35830. return HDNode._fromSeed(seed, null);
  35831. };
  35832. HDNode.fromExtendedKey = function (extendedKey) {
  35833. var bytes = basex_1.Base58.decode(extendedKey);
  35834. if (bytes.length !== 82 || base58check(bytes.slice(0, 78)) !== extendedKey) {
  35835. logger.throwArgumentError("invalid extended key", "extendedKey", "[REDACTED]");
  35836. }
  35837. var depth = bytes[4];
  35838. var parentFingerprint = (0, bytes_1.hexlify)(bytes.slice(5, 9));
  35839. var index = parseInt((0, bytes_1.hexlify)(bytes.slice(9, 13)).substring(2), 16);
  35840. var chainCode = (0, bytes_1.hexlify)(bytes.slice(13, 45));
  35841. var key = bytes.slice(45, 78);
  35842. switch ((0, bytes_1.hexlify)(bytes.slice(0, 4))) {
  35843. // Public Key
  35844. case "0x0488b21e":
  35845. case "0x043587cf":
  35846. return new HDNode(_constructorGuard, null, (0, bytes_1.hexlify)(key), parentFingerprint, chainCode, index, depth, null);
  35847. // Private Key
  35848. case "0x0488ade4":
  35849. case "0x04358394 ":
  35850. if (key[0] !== 0) {
  35851. break;
  35852. }
  35853. return new HDNode(_constructorGuard, (0, bytes_1.hexlify)(key.slice(1)), null, parentFingerprint, chainCode, index, depth, null);
  35854. }
  35855. return logger.throwArgumentError("invalid extended key", "extendedKey", "[REDACTED]");
  35856. };
  35857. return HDNode;
  35858. }());
  35859. exports.HDNode = HDNode;
  35860. function mnemonicToSeed(mnemonic, password) {
  35861. if (!password) {
  35862. password = "";
  35863. }
  35864. var salt = (0, strings_1.toUtf8Bytes)("mnemonic" + password, strings_1.UnicodeNormalizationForm.NFKD);
  35865. return (0, pbkdf2_1.pbkdf2)((0, strings_1.toUtf8Bytes)(mnemonic, strings_1.UnicodeNormalizationForm.NFKD), salt, 2048, 64, "sha512");
  35866. }
  35867. exports.mnemonicToSeed = mnemonicToSeed;
  35868. function mnemonicToEntropy(mnemonic, wordlist) {
  35869. wordlist = getWordlist(wordlist);
  35870. logger.checkNormalize();
  35871. var words = wordlist.split(mnemonic);
  35872. if ((words.length % 3) !== 0) {
  35873. throw new Error("invalid mnemonic");
  35874. }
  35875. var entropy = (0, bytes_1.arrayify)(new Uint8Array(Math.ceil(11 * words.length / 8)));
  35876. var offset = 0;
  35877. for (var i = 0; i < words.length; i++) {
  35878. var index = wordlist.getWordIndex(words[i].normalize("NFKD"));
  35879. if (index === -1) {
  35880. throw new Error("invalid mnemonic");
  35881. }
  35882. for (var bit = 0; bit < 11; bit++) {
  35883. if (index & (1 << (10 - bit))) {
  35884. entropy[offset >> 3] |= (1 << (7 - (offset % 8)));
  35885. }
  35886. offset++;
  35887. }
  35888. }
  35889. var entropyBits = 32 * words.length / 3;
  35890. var checksumBits = words.length / 3;
  35891. var checksumMask = getUpperMask(checksumBits);
  35892. var checksum = (0, bytes_1.arrayify)((0, sha2_1.sha256)(entropy.slice(0, entropyBits / 8)))[0] & checksumMask;
  35893. if (checksum !== (entropy[entropy.length - 1] & checksumMask)) {
  35894. throw new Error("invalid checksum");
  35895. }
  35896. return (0, bytes_1.hexlify)(entropy.slice(0, entropyBits / 8));
  35897. }
  35898. exports.mnemonicToEntropy = mnemonicToEntropy;
  35899. function entropyToMnemonic(entropy, wordlist) {
  35900. wordlist = getWordlist(wordlist);
  35901. entropy = (0, bytes_1.arrayify)(entropy);
  35902. if ((entropy.length % 4) !== 0 || entropy.length < 16 || entropy.length > 32) {
  35903. throw new Error("invalid entropy");
  35904. }
  35905. var indices = [0];
  35906. var remainingBits = 11;
  35907. for (var i = 0; i < entropy.length; i++) {
  35908. // Consume the whole byte (with still more to go)
  35909. if (remainingBits > 8) {
  35910. indices[indices.length - 1] <<= 8;
  35911. indices[indices.length - 1] |= entropy[i];
  35912. remainingBits -= 8;
  35913. // This byte will complete an 11-bit index
  35914. }
  35915. else {
  35916. indices[indices.length - 1] <<= remainingBits;
  35917. indices[indices.length - 1] |= entropy[i] >> (8 - remainingBits);
  35918. // Start the next word
  35919. indices.push(entropy[i] & getLowerMask(8 - remainingBits));
  35920. remainingBits += 3;
  35921. }
  35922. }
  35923. // Compute the checksum bits
  35924. var checksumBits = entropy.length / 4;
  35925. var checksum = (0, bytes_1.arrayify)((0, sha2_1.sha256)(entropy))[0] & getUpperMask(checksumBits);
  35926. // Shift the checksum into the word indices
  35927. indices[indices.length - 1] <<= checksumBits;
  35928. indices[indices.length - 1] |= (checksum >> (8 - checksumBits));
  35929. return wordlist.join(indices.map(function (index) { return wordlist.getWord(index); }));
  35930. }
  35931. exports.entropyToMnemonic = entropyToMnemonic;
  35932. function isValidMnemonic(mnemonic, wordlist) {
  35933. try {
  35934. mnemonicToEntropy(mnemonic, wordlist);
  35935. return true;
  35936. }
  35937. catch (error) { }
  35938. return false;
  35939. }
  35940. exports.isValidMnemonic = isValidMnemonic;
  35941. function getAccountPath(index) {
  35942. if (typeof (index) !== "number" || index < 0 || index >= HardenedBit || index % 1) {
  35943. logger.throwArgumentError("invalid account index", "index", index);
  35944. }
  35945. return "m/44'/60'/" + index + "'/0/0";
  35946. }
  35947. exports.getAccountPath = getAccountPath;
  35948. },{"./_version":213,"@ethersproject/basex":192,"@ethersproject/bignumber":196,"@ethersproject/bytes":199,"@ethersproject/logger":223,"@ethersproject/pbkdf2":227,"@ethersproject/properties":229,"@ethersproject/sha2":256,"@ethersproject/signing-key":260,"@ethersproject/strings":266,"@ethersproject/transactions":269,"@ethersproject/wordlists":278}],215:[function(_dereq_,module,exports){
  35949. "use strict";
  35950. Object.defineProperty(exports, "__esModule", { value: true });
  35951. exports.version = void 0;
  35952. exports.version = "json-wallets/5.6.0";
  35953. },{}],216:[function(_dereq_,module,exports){
  35954. "use strict";
  35955. var __extends = (this && this.__extends) || (function () {
  35956. var extendStatics = function (d, b) {
  35957. extendStatics = Object.setPrototypeOf ||
  35958. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  35959. function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
  35960. return extendStatics(d, b);
  35961. };
  35962. return function (d, b) {
  35963. if (typeof b !== "function" && b !== null)
  35964. throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
  35965. extendStatics(d, b);
  35966. function __() { this.constructor = d; }
  35967. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  35968. };
  35969. })();
  35970. var __importDefault = (this && this.__importDefault) || function (mod) {
  35971. return (mod && mod.__esModule) ? mod : { "default": mod };
  35972. };
  35973. Object.defineProperty(exports, "__esModule", { value: true });
  35974. exports.decrypt = exports.CrowdsaleAccount = void 0;
  35975. var aes_js_1 = __importDefault(_dereq_("aes-js"));
  35976. var address_1 = _dereq_("@ethersproject/address");
  35977. var bytes_1 = _dereq_("@ethersproject/bytes");
  35978. var keccak256_1 = _dereq_("@ethersproject/keccak256");
  35979. var pbkdf2_1 = _dereq_("@ethersproject/pbkdf2");
  35980. var strings_1 = _dereq_("@ethersproject/strings");
  35981. var properties_1 = _dereq_("@ethersproject/properties");
  35982. var logger_1 = _dereq_("@ethersproject/logger");
  35983. var _version_1 = _dereq_("./_version");
  35984. var logger = new logger_1.Logger(_version_1.version);
  35985. var utils_1 = _dereq_("./utils");
  35986. var CrowdsaleAccount = /** @class */ (function (_super) {
  35987. __extends(CrowdsaleAccount, _super);
  35988. function CrowdsaleAccount() {
  35989. return _super !== null && _super.apply(this, arguments) || this;
  35990. }
  35991. CrowdsaleAccount.prototype.isCrowdsaleAccount = function (value) {
  35992. return !!(value && value._isCrowdsaleAccount);
  35993. };
  35994. return CrowdsaleAccount;
  35995. }(properties_1.Description));
  35996. exports.CrowdsaleAccount = CrowdsaleAccount;
  35997. // See: https://github.com/ethereum/pyethsaletool
  35998. function decrypt(json, password) {
  35999. var data = JSON.parse(json);
  36000. password = (0, utils_1.getPassword)(password);
  36001. // Ethereum Address
  36002. var ethaddr = (0, address_1.getAddress)((0, utils_1.searchPath)(data, "ethaddr"));
  36003. // Encrypted Seed
  36004. var encseed = (0, utils_1.looseArrayify)((0, utils_1.searchPath)(data, "encseed"));
  36005. if (!encseed || (encseed.length % 16) !== 0) {
  36006. logger.throwArgumentError("invalid encseed", "json", json);
  36007. }
  36008. var key = (0, bytes_1.arrayify)((0, pbkdf2_1.pbkdf2)(password, password, 2000, 32, "sha256")).slice(0, 16);
  36009. var iv = encseed.slice(0, 16);
  36010. var encryptedSeed = encseed.slice(16);
  36011. // Decrypt the seed
  36012. var aesCbc = new aes_js_1.default.ModeOfOperation.cbc(key, iv);
  36013. var seed = aes_js_1.default.padding.pkcs7.strip((0, bytes_1.arrayify)(aesCbc.decrypt(encryptedSeed)));
  36014. // This wallet format is weird... Convert the binary encoded hex to a string.
  36015. var seedHex = "";
  36016. for (var i = 0; i < seed.length; i++) {
  36017. seedHex += String.fromCharCode(seed[i]);
  36018. }
  36019. var seedHexBytes = (0, strings_1.toUtf8Bytes)(seedHex);
  36020. var privateKey = (0, keccak256_1.keccak256)(seedHexBytes);
  36021. return new CrowdsaleAccount({
  36022. _isCrowdsaleAccount: true,
  36023. address: ethaddr,
  36024. privateKey: privateKey
  36025. });
  36026. }
  36027. exports.decrypt = decrypt;
  36028. },{"./_version":215,"./utils":220,"@ethersproject/address":189,"@ethersproject/bytes":199,"@ethersproject/keccak256":221,"@ethersproject/logger":223,"@ethersproject/pbkdf2":227,"@ethersproject/properties":229,"@ethersproject/strings":266,"aes-js":290}],217:[function(_dereq_,module,exports){
  36029. "use strict";
  36030. Object.defineProperty(exports, "__esModule", { value: true });
  36031. exports.decryptJsonWalletSync = exports.decryptJsonWallet = exports.getJsonWalletAddress = exports.isKeystoreWallet = exports.isCrowdsaleWallet = exports.encryptKeystore = exports.decryptKeystoreSync = exports.decryptKeystore = exports.decryptCrowdsale = void 0;
  36032. var crowdsale_1 = _dereq_("./crowdsale");
  36033. Object.defineProperty(exports, "decryptCrowdsale", { enumerable: true, get: function () { return crowdsale_1.decrypt; } });
  36034. var inspect_1 = _dereq_("./inspect");
  36035. Object.defineProperty(exports, "getJsonWalletAddress", { enumerable: true, get: function () { return inspect_1.getJsonWalletAddress; } });
  36036. Object.defineProperty(exports, "isCrowdsaleWallet", { enumerable: true, get: function () { return inspect_1.isCrowdsaleWallet; } });
  36037. Object.defineProperty(exports, "isKeystoreWallet", { enumerable: true, get: function () { return inspect_1.isKeystoreWallet; } });
  36038. var keystore_1 = _dereq_("./keystore");
  36039. Object.defineProperty(exports, "decryptKeystore", { enumerable: true, get: function () { return keystore_1.decrypt; } });
  36040. Object.defineProperty(exports, "decryptKeystoreSync", { enumerable: true, get: function () { return keystore_1.decryptSync; } });
  36041. Object.defineProperty(exports, "encryptKeystore", { enumerable: true, get: function () { return keystore_1.encrypt; } });
  36042. function decryptJsonWallet(json, password, progressCallback) {
  36043. if ((0, inspect_1.isCrowdsaleWallet)(json)) {
  36044. if (progressCallback) {
  36045. progressCallback(0);
  36046. }
  36047. var account = (0, crowdsale_1.decrypt)(json, password);
  36048. if (progressCallback) {
  36049. progressCallback(1);
  36050. }
  36051. return Promise.resolve(account);
  36052. }
  36053. if ((0, inspect_1.isKeystoreWallet)(json)) {
  36054. return (0, keystore_1.decrypt)(json, password, progressCallback);
  36055. }
  36056. return Promise.reject(new Error("invalid JSON wallet"));
  36057. }
  36058. exports.decryptJsonWallet = decryptJsonWallet;
  36059. function decryptJsonWalletSync(json, password) {
  36060. if ((0, inspect_1.isCrowdsaleWallet)(json)) {
  36061. return (0, crowdsale_1.decrypt)(json, password);
  36062. }
  36063. if ((0, inspect_1.isKeystoreWallet)(json)) {
  36064. return (0, keystore_1.decryptSync)(json, password);
  36065. }
  36066. throw new Error("invalid JSON wallet");
  36067. }
  36068. exports.decryptJsonWalletSync = decryptJsonWalletSync;
  36069. },{"./crowdsale":216,"./inspect":218,"./keystore":219}],218:[function(_dereq_,module,exports){
  36070. "use strict";
  36071. Object.defineProperty(exports, "__esModule", { value: true });
  36072. exports.getJsonWalletAddress = exports.isKeystoreWallet = exports.isCrowdsaleWallet = void 0;
  36073. var address_1 = _dereq_("@ethersproject/address");
  36074. function isCrowdsaleWallet(json) {
  36075. var data = null;
  36076. try {
  36077. data = JSON.parse(json);
  36078. }
  36079. catch (error) {
  36080. return false;
  36081. }
  36082. return (data.encseed && data.ethaddr);
  36083. }
  36084. exports.isCrowdsaleWallet = isCrowdsaleWallet;
  36085. function isKeystoreWallet(json) {
  36086. var data = null;
  36087. try {
  36088. data = JSON.parse(json);
  36089. }
  36090. catch (error) {
  36091. return false;
  36092. }
  36093. if (!data.version || parseInt(data.version) !== data.version || parseInt(data.version) !== 3) {
  36094. return false;
  36095. }
  36096. // @TODO: Put more checks to make sure it has kdf, iv and all that good stuff
  36097. return true;
  36098. }
  36099. exports.isKeystoreWallet = isKeystoreWallet;
  36100. //export function isJsonWallet(json: string): boolean {
  36101. // return (isSecretStorageWallet(json) || isCrowdsaleWallet(json));
  36102. //}
  36103. function getJsonWalletAddress(json) {
  36104. if (isCrowdsaleWallet(json)) {
  36105. try {
  36106. return (0, address_1.getAddress)(JSON.parse(json).ethaddr);
  36107. }
  36108. catch (error) {
  36109. return null;
  36110. }
  36111. }
  36112. if (isKeystoreWallet(json)) {
  36113. try {
  36114. return (0, address_1.getAddress)(JSON.parse(json).address);
  36115. }
  36116. catch (error) {
  36117. return null;
  36118. }
  36119. }
  36120. return null;
  36121. }
  36122. exports.getJsonWalletAddress = getJsonWalletAddress;
  36123. },{"@ethersproject/address":189}],219:[function(_dereq_,module,exports){
  36124. "use strict";
  36125. var __extends = (this && this.__extends) || (function () {
  36126. var extendStatics = function (d, b) {
  36127. extendStatics = Object.setPrototypeOf ||
  36128. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  36129. function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
  36130. return extendStatics(d, b);
  36131. };
  36132. return function (d, b) {
  36133. if (typeof b !== "function" && b !== null)
  36134. throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
  36135. extendStatics(d, b);
  36136. function __() { this.constructor = d; }
  36137. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  36138. };
  36139. })();
  36140. var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
  36141. function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
  36142. return new (P || (P = Promise))(function (resolve, reject) {
  36143. function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
  36144. function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
  36145. function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
  36146. step((generator = generator.apply(thisArg, _arguments || [])).next());
  36147. });
  36148. };
  36149. var __generator = (this && this.__generator) || function (thisArg, body) {
  36150. var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
  36151. return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
  36152. function verb(n) { return function (v) { return step([n, v]); }; }
  36153. function step(op) {
  36154. if (f) throw new TypeError("Generator is already executing.");
  36155. while (_) try {
  36156. if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
  36157. if (y = 0, t) op = [op[0] & 2, t.value];
  36158. switch (op[0]) {
  36159. case 0: case 1: t = op; break;
  36160. case 4: _.label++; return { value: op[1], done: false };
  36161. case 5: _.label++; y = op[1]; op = [0]; continue;
  36162. case 7: op = _.ops.pop(); _.trys.pop(); continue;
  36163. default:
  36164. if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
  36165. if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
  36166. if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
  36167. if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
  36168. if (t[2]) _.ops.pop();
  36169. _.trys.pop(); continue;
  36170. }
  36171. op = body.call(thisArg, _);
  36172. } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
  36173. if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
  36174. }
  36175. };
  36176. var __importDefault = (this && this.__importDefault) || function (mod) {
  36177. return (mod && mod.__esModule) ? mod : { "default": mod };
  36178. };
  36179. Object.defineProperty(exports, "__esModule", { value: true });
  36180. exports.encrypt = exports.decrypt = exports.decryptSync = exports.KeystoreAccount = void 0;
  36181. var aes_js_1 = __importDefault(_dereq_("aes-js"));
  36182. var scrypt_js_1 = __importDefault(_dereq_("scrypt-js"));
  36183. var address_1 = _dereq_("@ethersproject/address");
  36184. var bytes_1 = _dereq_("@ethersproject/bytes");
  36185. var hdnode_1 = _dereq_("@ethersproject/hdnode");
  36186. var keccak256_1 = _dereq_("@ethersproject/keccak256");
  36187. var pbkdf2_1 = _dereq_("@ethersproject/pbkdf2");
  36188. var random_1 = _dereq_("@ethersproject/random");
  36189. var properties_1 = _dereq_("@ethersproject/properties");
  36190. var transactions_1 = _dereq_("@ethersproject/transactions");
  36191. var utils_1 = _dereq_("./utils");
  36192. var logger_1 = _dereq_("@ethersproject/logger");
  36193. var _version_1 = _dereq_("./_version");
  36194. var logger = new logger_1.Logger(_version_1.version);
  36195. // Exported Types
  36196. function hasMnemonic(value) {
  36197. return (value != null && value.mnemonic && value.mnemonic.phrase);
  36198. }
  36199. var KeystoreAccount = /** @class */ (function (_super) {
  36200. __extends(KeystoreAccount, _super);
  36201. function KeystoreAccount() {
  36202. return _super !== null && _super.apply(this, arguments) || this;
  36203. }
  36204. KeystoreAccount.prototype.isKeystoreAccount = function (value) {
  36205. return !!(value && value._isKeystoreAccount);
  36206. };
  36207. return KeystoreAccount;
  36208. }(properties_1.Description));
  36209. exports.KeystoreAccount = KeystoreAccount;
  36210. function _decrypt(data, key, ciphertext) {
  36211. var cipher = (0, utils_1.searchPath)(data, "crypto/cipher");
  36212. if (cipher === "aes-128-ctr") {
  36213. var iv = (0, utils_1.looseArrayify)((0, utils_1.searchPath)(data, "crypto/cipherparams/iv"));
  36214. var counter = new aes_js_1.default.Counter(iv);
  36215. var aesCtr = new aes_js_1.default.ModeOfOperation.ctr(key, counter);
  36216. return (0, bytes_1.arrayify)(aesCtr.decrypt(ciphertext));
  36217. }
  36218. return null;
  36219. }
  36220. function _getAccount(data, key) {
  36221. var ciphertext = (0, utils_1.looseArrayify)((0, utils_1.searchPath)(data, "crypto/ciphertext"));
  36222. var computedMAC = (0, bytes_1.hexlify)((0, keccak256_1.keccak256)((0, bytes_1.concat)([key.slice(16, 32), ciphertext]))).substring(2);
  36223. if (computedMAC !== (0, utils_1.searchPath)(data, "crypto/mac").toLowerCase()) {
  36224. throw new Error("invalid password");
  36225. }
  36226. var privateKey = _decrypt(data, key.slice(0, 16), ciphertext);
  36227. if (!privateKey) {
  36228. logger.throwError("unsupported cipher", logger_1.Logger.errors.UNSUPPORTED_OPERATION, {
  36229. operation: "decrypt"
  36230. });
  36231. }
  36232. var mnemonicKey = key.slice(32, 64);
  36233. var address = (0, transactions_1.computeAddress)(privateKey);
  36234. if (data.address) {
  36235. var check = data.address.toLowerCase();
  36236. if (check.substring(0, 2) !== "0x") {
  36237. check = "0x" + check;
  36238. }
  36239. if ((0, address_1.getAddress)(check) !== address) {
  36240. throw new Error("address mismatch");
  36241. }
  36242. }
  36243. var account = {
  36244. _isKeystoreAccount: true,
  36245. address: address,
  36246. privateKey: (0, bytes_1.hexlify)(privateKey)
  36247. };
  36248. // Version 0.1 x-ethers metadata must contain an encrypted mnemonic phrase
  36249. if ((0, utils_1.searchPath)(data, "x-ethers/version") === "0.1") {
  36250. var mnemonicCiphertext = (0, utils_1.looseArrayify)((0, utils_1.searchPath)(data, "x-ethers/mnemonicCiphertext"));
  36251. var mnemonicIv = (0, utils_1.looseArrayify)((0, utils_1.searchPath)(data, "x-ethers/mnemonicCounter"));
  36252. var mnemonicCounter = new aes_js_1.default.Counter(mnemonicIv);
  36253. var mnemonicAesCtr = new aes_js_1.default.ModeOfOperation.ctr(mnemonicKey, mnemonicCounter);
  36254. var path = (0, utils_1.searchPath)(data, "x-ethers/path") || hdnode_1.defaultPath;
  36255. var locale = (0, utils_1.searchPath)(data, "x-ethers/locale") || "en";
  36256. var entropy = (0, bytes_1.arrayify)(mnemonicAesCtr.decrypt(mnemonicCiphertext));
  36257. try {
  36258. var mnemonic = (0, hdnode_1.entropyToMnemonic)(entropy, locale);
  36259. var node = hdnode_1.HDNode.fromMnemonic(mnemonic, null, locale).derivePath(path);
  36260. if (node.privateKey != account.privateKey) {
  36261. throw new Error("mnemonic mismatch");
  36262. }
  36263. account.mnemonic = node.mnemonic;
  36264. }
  36265. catch (error) {
  36266. // If we don't have the locale wordlist installed to
  36267. // read this mnemonic, just bail and don't set the
  36268. // mnemonic
  36269. if (error.code !== logger_1.Logger.errors.INVALID_ARGUMENT || error.argument !== "wordlist") {
  36270. throw error;
  36271. }
  36272. }
  36273. }
  36274. return new KeystoreAccount(account);
  36275. }
  36276. function pbkdf2Sync(passwordBytes, salt, count, dkLen, prfFunc) {
  36277. return (0, bytes_1.arrayify)((0, pbkdf2_1.pbkdf2)(passwordBytes, salt, count, dkLen, prfFunc));
  36278. }
  36279. function pbkdf2(passwordBytes, salt, count, dkLen, prfFunc) {
  36280. return Promise.resolve(pbkdf2Sync(passwordBytes, salt, count, dkLen, prfFunc));
  36281. }
  36282. function _computeKdfKey(data, password, pbkdf2Func, scryptFunc, progressCallback) {
  36283. var passwordBytes = (0, utils_1.getPassword)(password);
  36284. var kdf = (0, utils_1.searchPath)(data, "crypto/kdf");
  36285. if (kdf && typeof (kdf) === "string") {
  36286. var throwError = function (name, value) {
  36287. return logger.throwArgumentError("invalid key-derivation function parameters", name, value);
  36288. };
  36289. if (kdf.toLowerCase() === "scrypt") {
  36290. var salt = (0, utils_1.looseArrayify)((0, utils_1.searchPath)(data, "crypto/kdfparams/salt"));
  36291. var N = parseInt((0, utils_1.searchPath)(data, "crypto/kdfparams/n"));
  36292. var r = parseInt((0, utils_1.searchPath)(data, "crypto/kdfparams/r"));
  36293. var p = parseInt((0, utils_1.searchPath)(data, "crypto/kdfparams/p"));
  36294. // Check for all required parameters
  36295. if (!N || !r || !p) {
  36296. throwError("kdf", kdf);
  36297. }
  36298. // Make sure N is a power of 2
  36299. if ((N & (N - 1)) !== 0) {
  36300. throwError("N", N);
  36301. }
  36302. var dkLen = parseInt((0, utils_1.searchPath)(data, "crypto/kdfparams/dklen"));
  36303. if (dkLen !== 32) {
  36304. throwError("dklen", dkLen);
  36305. }
  36306. return scryptFunc(passwordBytes, salt, N, r, p, 64, progressCallback);
  36307. }
  36308. else if (kdf.toLowerCase() === "pbkdf2") {
  36309. var salt = (0, utils_1.looseArrayify)((0, utils_1.searchPath)(data, "crypto/kdfparams/salt"));
  36310. var prfFunc = null;
  36311. var prf = (0, utils_1.searchPath)(data, "crypto/kdfparams/prf");
  36312. if (prf === "hmac-sha256") {
  36313. prfFunc = "sha256";
  36314. }
  36315. else if (prf === "hmac-sha512") {
  36316. prfFunc = "sha512";
  36317. }
  36318. else {
  36319. throwError("prf", prf);
  36320. }
  36321. var count = parseInt((0, utils_1.searchPath)(data, "crypto/kdfparams/c"));
  36322. var dkLen = parseInt((0, utils_1.searchPath)(data, "crypto/kdfparams/dklen"));
  36323. if (dkLen !== 32) {
  36324. throwError("dklen", dkLen);
  36325. }
  36326. return pbkdf2Func(passwordBytes, salt, count, dkLen, prfFunc);
  36327. }
  36328. }
  36329. return logger.throwArgumentError("unsupported key-derivation function", "kdf", kdf);
  36330. }
  36331. function decryptSync(json, password) {
  36332. var data = JSON.parse(json);
  36333. var key = _computeKdfKey(data, password, pbkdf2Sync, scrypt_js_1.default.syncScrypt);
  36334. return _getAccount(data, key);
  36335. }
  36336. exports.decryptSync = decryptSync;
  36337. function decrypt(json, password, progressCallback) {
  36338. return __awaiter(this, void 0, void 0, function () {
  36339. var data, key;
  36340. return __generator(this, function (_a) {
  36341. switch (_a.label) {
  36342. case 0:
  36343. data = JSON.parse(json);
  36344. return [4 /*yield*/, _computeKdfKey(data, password, pbkdf2, scrypt_js_1.default.scrypt, progressCallback)];
  36345. case 1:
  36346. key = _a.sent();
  36347. return [2 /*return*/, _getAccount(data, key)];
  36348. }
  36349. });
  36350. });
  36351. }
  36352. exports.decrypt = decrypt;
  36353. function encrypt(account, password, options, progressCallback) {
  36354. try {
  36355. // Check the address matches the private key
  36356. if ((0, address_1.getAddress)(account.address) !== (0, transactions_1.computeAddress)(account.privateKey)) {
  36357. throw new Error("address/privateKey mismatch");
  36358. }
  36359. // Check the mnemonic (if any) matches the private key
  36360. if (hasMnemonic(account)) {
  36361. var mnemonic = account.mnemonic;
  36362. var node = hdnode_1.HDNode.fromMnemonic(mnemonic.phrase, null, mnemonic.locale).derivePath(mnemonic.path || hdnode_1.defaultPath);
  36363. if (node.privateKey != account.privateKey) {
  36364. throw new Error("mnemonic mismatch");
  36365. }
  36366. }
  36367. }
  36368. catch (e) {
  36369. return Promise.reject(e);
  36370. }
  36371. // The options are optional, so adjust the call as needed
  36372. if (typeof (options) === "function" && !progressCallback) {
  36373. progressCallback = options;
  36374. options = {};
  36375. }
  36376. if (!options) {
  36377. options = {};
  36378. }
  36379. var privateKey = (0, bytes_1.arrayify)(account.privateKey);
  36380. var passwordBytes = (0, utils_1.getPassword)(password);
  36381. var entropy = null;
  36382. var path = null;
  36383. var locale = null;
  36384. if (hasMnemonic(account)) {
  36385. var srcMnemonic = account.mnemonic;
  36386. entropy = (0, bytes_1.arrayify)((0, hdnode_1.mnemonicToEntropy)(srcMnemonic.phrase, srcMnemonic.locale || "en"));
  36387. path = srcMnemonic.path || hdnode_1.defaultPath;
  36388. locale = srcMnemonic.locale || "en";
  36389. }
  36390. var client = options.client;
  36391. if (!client) {
  36392. client = "ethers.js";
  36393. }
  36394. // Check/generate the salt
  36395. var salt = null;
  36396. if (options.salt) {
  36397. salt = (0, bytes_1.arrayify)(options.salt);
  36398. }
  36399. else {
  36400. salt = (0, random_1.randomBytes)(32);
  36401. ;
  36402. }
  36403. // Override initialization vector
  36404. var iv = null;
  36405. if (options.iv) {
  36406. iv = (0, bytes_1.arrayify)(options.iv);
  36407. if (iv.length !== 16) {
  36408. throw new Error("invalid iv");
  36409. }
  36410. }
  36411. else {
  36412. iv = (0, random_1.randomBytes)(16);
  36413. }
  36414. // Override the uuid
  36415. var uuidRandom = null;
  36416. if (options.uuid) {
  36417. uuidRandom = (0, bytes_1.arrayify)(options.uuid);
  36418. if (uuidRandom.length !== 16) {
  36419. throw new Error("invalid uuid");
  36420. }
  36421. }
  36422. else {
  36423. uuidRandom = (0, random_1.randomBytes)(16);
  36424. }
  36425. // Override the scrypt password-based key derivation function parameters
  36426. var N = (1 << 17), r = 8, p = 1;
  36427. if (options.scrypt) {
  36428. if (options.scrypt.N) {
  36429. N = options.scrypt.N;
  36430. }
  36431. if (options.scrypt.r) {
  36432. r = options.scrypt.r;
  36433. }
  36434. if (options.scrypt.p) {
  36435. p = options.scrypt.p;
  36436. }
  36437. }
  36438. // We take 64 bytes:
  36439. // - 32 bytes As normal for the Web3 secret storage (derivedKey, macPrefix)
  36440. // - 32 bytes AES key to encrypt mnemonic with (required here to be Ethers Wallet)
  36441. return scrypt_js_1.default.scrypt(passwordBytes, salt, N, r, p, 64, progressCallback).then(function (key) {
  36442. key = (0, bytes_1.arrayify)(key);
  36443. // This will be used to encrypt the wallet (as per Web3 secret storage)
  36444. var derivedKey = key.slice(0, 16);
  36445. var macPrefix = key.slice(16, 32);
  36446. // This will be used to encrypt the mnemonic phrase (if any)
  36447. var mnemonicKey = key.slice(32, 64);
  36448. // Encrypt the private key
  36449. var counter = new aes_js_1.default.Counter(iv);
  36450. var aesCtr = new aes_js_1.default.ModeOfOperation.ctr(derivedKey, counter);
  36451. var ciphertext = (0, bytes_1.arrayify)(aesCtr.encrypt(privateKey));
  36452. // Compute the message authentication code, used to check the password
  36453. var mac = (0, keccak256_1.keccak256)((0, bytes_1.concat)([macPrefix, ciphertext]));
  36454. // See: https://github.com/ethereum/wiki/wiki/Web3-Secret-Storage-Definition
  36455. var data = {
  36456. address: account.address.substring(2).toLowerCase(),
  36457. id: (0, utils_1.uuidV4)(uuidRandom),
  36458. version: 3,
  36459. Crypto: {
  36460. cipher: "aes-128-ctr",
  36461. cipherparams: {
  36462. iv: (0, bytes_1.hexlify)(iv).substring(2),
  36463. },
  36464. ciphertext: (0, bytes_1.hexlify)(ciphertext).substring(2),
  36465. kdf: "scrypt",
  36466. kdfparams: {
  36467. salt: (0, bytes_1.hexlify)(salt).substring(2),
  36468. n: N,
  36469. dklen: 32,
  36470. p: p,
  36471. r: r
  36472. },
  36473. mac: mac.substring(2)
  36474. }
  36475. };
  36476. // If we have a mnemonic, encrypt it into the JSON wallet
  36477. if (entropy) {
  36478. var mnemonicIv = (0, random_1.randomBytes)(16);
  36479. var mnemonicCounter = new aes_js_1.default.Counter(mnemonicIv);
  36480. var mnemonicAesCtr = new aes_js_1.default.ModeOfOperation.ctr(mnemonicKey, mnemonicCounter);
  36481. var mnemonicCiphertext = (0, bytes_1.arrayify)(mnemonicAesCtr.encrypt(entropy));
  36482. var now = new Date();
  36483. var timestamp = (now.getUTCFullYear() + "-" +
  36484. (0, utils_1.zpad)(now.getUTCMonth() + 1, 2) + "-" +
  36485. (0, utils_1.zpad)(now.getUTCDate(), 2) + "T" +
  36486. (0, utils_1.zpad)(now.getUTCHours(), 2) + "-" +
  36487. (0, utils_1.zpad)(now.getUTCMinutes(), 2) + "-" +
  36488. (0, utils_1.zpad)(now.getUTCSeconds(), 2) + ".0Z");
  36489. data["x-ethers"] = {
  36490. client: client,
  36491. gethFilename: ("UTC--" + timestamp + "--" + data.address),
  36492. mnemonicCounter: (0, bytes_1.hexlify)(mnemonicIv).substring(2),
  36493. mnemonicCiphertext: (0, bytes_1.hexlify)(mnemonicCiphertext).substring(2),
  36494. path: path,
  36495. locale: locale,
  36496. version: "0.1"
  36497. };
  36498. }
  36499. return JSON.stringify(data);
  36500. });
  36501. }
  36502. exports.encrypt = encrypt;
  36503. },{"./_version":215,"./utils":220,"@ethersproject/address":189,"@ethersproject/bytes":199,"@ethersproject/hdnode":214,"@ethersproject/keccak256":221,"@ethersproject/logger":223,"@ethersproject/pbkdf2":227,"@ethersproject/properties":229,"@ethersproject/random":250,"@ethersproject/transactions":269,"aes-js":290,"scrypt-js":795}],220:[function(_dereq_,module,exports){
  36504. "use strict";
  36505. Object.defineProperty(exports, "__esModule", { value: true });
  36506. exports.uuidV4 = exports.searchPath = exports.getPassword = exports.zpad = exports.looseArrayify = void 0;
  36507. var bytes_1 = _dereq_("@ethersproject/bytes");
  36508. var strings_1 = _dereq_("@ethersproject/strings");
  36509. function looseArrayify(hexString) {
  36510. if (typeof (hexString) === 'string' && hexString.substring(0, 2) !== '0x') {
  36511. hexString = '0x' + hexString;
  36512. }
  36513. return (0, bytes_1.arrayify)(hexString);
  36514. }
  36515. exports.looseArrayify = looseArrayify;
  36516. function zpad(value, length) {
  36517. value = String(value);
  36518. while (value.length < length) {
  36519. value = '0' + value;
  36520. }
  36521. return value;
  36522. }
  36523. exports.zpad = zpad;
  36524. function getPassword(password) {
  36525. if (typeof (password) === 'string') {
  36526. return (0, strings_1.toUtf8Bytes)(password, strings_1.UnicodeNormalizationForm.NFKC);
  36527. }
  36528. return (0, bytes_1.arrayify)(password);
  36529. }
  36530. exports.getPassword = getPassword;
  36531. function searchPath(object, path) {
  36532. var currentChild = object;
  36533. var comps = path.toLowerCase().split('/');
  36534. for (var i = 0; i < comps.length; i++) {
  36535. // Search for a child object with a case-insensitive matching key
  36536. var matchingChild = null;
  36537. for (var key in currentChild) {
  36538. if (key.toLowerCase() === comps[i]) {
  36539. matchingChild = currentChild[key];
  36540. break;
  36541. }
  36542. }
  36543. // Didn't find one. :'(
  36544. if (matchingChild === null) {
  36545. return null;
  36546. }
  36547. // Now check this child...
  36548. currentChild = matchingChild;
  36549. }
  36550. return currentChild;
  36551. }
  36552. exports.searchPath = searchPath;
  36553. // See: https://www.ietf.org/rfc/rfc4122.txt (Section 4.4)
  36554. function uuidV4(randomBytes) {
  36555. var bytes = (0, bytes_1.arrayify)(randomBytes);
  36556. // Section: 4.1.3:
  36557. // - time_hi_and_version[12:16] = 0b0100
  36558. bytes[6] = (bytes[6] & 0x0f) | 0x40;
  36559. // Section 4.4
  36560. // - clock_seq_hi_and_reserved[6] = 0b0
  36561. // - clock_seq_hi_and_reserved[7] = 0b1
  36562. bytes[8] = (bytes[8] & 0x3f) | 0x80;
  36563. var value = (0, bytes_1.hexlify)(bytes);
  36564. return [
  36565. value.substring(2, 10),
  36566. value.substring(10, 14),
  36567. value.substring(14, 18),
  36568. value.substring(18, 22),
  36569. value.substring(22, 34),
  36570. ].join("-");
  36571. }
  36572. exports.uuidV4 = uuidV4;
  36573. },{"@ethersproject/bytes":199,"@ethersproject/strings":266}],221:[function(_dereq_,module,exports){
  36574. "use strict";
  36575. var __importDefault = (this && this.__importDefault) || function (mod) {
  36576. return (mod && mod.__esModule) ? mod : { "default": mod };
  36577. };
  36578. Object.defineProperty(exports, "__esModule", { value: true });
  36579. exports.keccak256 = void 0;
  36580. var js_sha3_1 = __importDefault(_dereq_("js-sha3"));
  36581. var bytes_1 = _dereq_("@ethersproject/bytes");
  36582. function keccak256(data) {
  36583. return '0x' + js_sha3_1.default.keccak_256((0, bytes_1.arrayify)(data));
  36584. }
  36585. exports.keccak256 = keccak256;
  36586. },{"@ethersproject/bytes":199,"js-sha3":790}],222:[function(_dereq_,module,exports){
  36587. "use strict";
  36588. Object.defineProperty(exports, "__esModule", { value: true });
  36589. exports.version = void 0;
  36590. exports.version = "logger/5.6.0";
  36591. },{}],223:[function(_dereq_,module,exports){
  36592. "use strict";
  36593. Object.defineProperty(exports, "__esModule", { value: true });
  36594. exports.Logger = exports.ErrorCode = exports.LogLevel = void 0;
  36595. var _permanentCensorErrors = false;
  36596. var _censorErrors = false;
  36597. var LogLevels = { debug: 1, "default": 2, info: 2, warning: 3, error: 4, off: 5 };
  36598. var _logLevel = LogLevels["default"];
  36599. var _version_1 = _dereq_("./_version");
  36600. var _globalLogger = null;
  36601. function _checkNormalize() {
  36602. try {
  36603. var missing_1 = [];
  36604. // Make sure all forms of normalization are supported
  36605. ["NFD", "NFC", "NFKD", "NFKC"].forEach(function (form) {
  36606. try {
  36607. if ("test".normalize(form) !== "test") {
  36608. throw new Error("bad normalize");
  36609. }
  36610. ;
  36611. }
  36612. catch (error) {
  36613. missing_1.push(form);
  36614. }
  36615. });
  36616. if (missing_1.length) {
  36617. throw new Error("missing " + missing_1.join(", "));
  36618. }
  36619. if (String.fromCharCode(0xe9).normalize("NFD") !== String.fromCharCode(0x65, 0x0301)) {
  36620. throw new Error("broken implementation");
  36621. }
  36622. }
  36623. catch (error) {
  36624. return error.message;
  36625. }
  36626. return null;
  36627. }
  36628. var _normalizeError = _checkNormalize();
  36629. var LogLevel;
  36630. (function (LogLevel) {
  36631. LogLevel["DEBUG"] = "DEBUG";
  36632. LogLevel["INFO"] = "INFO";
  36633. LogLevel["WARNING"] = "WARNING";
  36634. LogLevel["ERROR"] = "ERROR";
  36635. LogLevel["OFF"] = "OFF";
  36636. })(LogLevel = exports.LogLevel || (exports.LogLevel = {}));
  36637. var ErrorCode;
  36638. (function (ErrorCode) {
  36639. ///////////////////
  36640. // Generic Errors
  36641. // Unknown Error
  36642. ErrorCode["UNKNOWN_ERROR"] = "UNKNOWN_ERROR";
  36643. // Not Implemented
  36644. ErrorCode["NOT_IMPLEMENTED"] = "NOT_IMPLEMENTED";
  36645. // Unsupported Operation
  36646. // - operation
  36647. ErrorCode["UNSUPPORTED_OPERATION"] = "UNSUPPORTED_OPERATION";
  36648. // Network Error (i.e. Ethereum Network, such as an invalid chain ID)
  36649. // - event ("noNetwork" is not re-thrown in provider.ready; otherwise thrown)
  36650. ErrorCode["NETWORK_ERROR"] = "NETWORK_ERROR";
  36651. // Some sort of bad response from the server
  36652. ErrorCode["SERVER_ERROR"] = "SERVER_ERROR";
  36653. // Timeout
  36654. ErrorCode["TIMEOUT"] = "TIMEOUT";
  36655. ///////////////////
  36656. // Operational Errors
  36657. // Buffer Overrun
  36658. ErrorCode["BUFFER_OVERRUN"] = "BUFFER_OVERRUN";
  36659. // Numeric Fault
  36660. // - operation: the operation being executed
  36661. // - fault: the reason this faulted
  36662. ErrorCode["NUMERIC_FAULT"] = "NUMERIC_FAULT";
  36663. ///////////////////
  36664. // Argument Errors
  36665. // Missing new operator to an object
  36666. // - name: The name of the class
  36667. ErrorCode["MISSING_NEW"] = "MISSING_NEW";
  36668. // Invalid argument (e.g. value is incompatible with type) to a function:
  36669. // - argument: The argument name that was invalid
  36670. // - value: The value of the argument
  36671. ErrorCode["INVALID_ARGUMENT"] = "INVALID_ARGUMENT";
  36672. // Missing argument to a function:
  36673. // - count: The number of arguments received
  36674. // - expectedCount: The number of arguments expected
  36675. ErrorCode["MISSING_ARGUMENT"] = "MISSING_ARGUMENT";
  36676. // Too many arguments
  36677. // - count: The number of arguments received
  36678. // - expectedCount: The number of arguments expected
  36679. ErrorCode["UNEXPECTED_ARGUMENT"] = "UNEXPECTED_ARGUMENT";
  36680. ///////////////////
  36681. // Blockchain Errors
  36682. // Call exception
  36683. // - transaction: the transaction
  36684. // - address?: the contract address
  36685. // - args?: The arguments passed into the function
  36686. // - method?: The Solidity method signature
  36687. // - errorSignature?: The EIP848 error signature
  36688. // - errorArgs?: The EIP848 error parameters
  36689. // - reason: The reason (only for EIP848 "Error(string)")
  36690. ErrorCode["CALL_EXCEPTION"] = "CALL_EXCEPTION";
  36691. // Insufficient funds (< value + gasLimit * gasPrice)
  36692. // - transaction: the transaction attempted
  36693. ErrorCode["INSUFFICIENT_FUNDS"] = "INSUFFICIENT_FUNDS";
  36694. // Nonce has already been used
  36695. // - transaction: the transaction attempted
  36696. ErrorCode["NONCE_EXPIRED"] = "NONCE_EXPIRED";
  36697. // The replacement fee for the transaction is too low
  36698. // - transaction: the transaction attempted
  36699. ErrorCode["REPLACEMENT_UNDERPRICED"] = "REPLACEMENT_UNDERPRICED";
  36700. // The gas limit could not be estimated
  36701. // - transaction: the transaction passed to estimateGas
  36702. ErrorCode["UNPREDICTABLE_GAS_LIMIT"] = "UNPREDICTABLE_GAS_LIMIT";
  36703. // The transaction was replaced by one with a higher gas price
  36704. // - reason: "cancelled", "replaced" or "repriced"
  36705. // - cancelled: true if reason == "cancelled" or reason == "replaced")
  36706. // - hash: original transaction hash
  36707. // - replacement: the full TransactionsResponse for the replacement
  36708. // - receipt: the receipt of the replacement
  36709. ErrorCode["TRANSACTION_REPLACED"] = "TRANSACTION_REPLACED";
  36710. })(ErrorCode = exports.ErrorCode || (exports.ErrorCode = {}));
  36711. ;
  36712. var HEX = "0123456789abcdef";
  36713. var Logger = /** @class */ (function () {
  36714. function Logger(version) {
  36715. Object.defineProperty(this, "version", {
  36716. enumerable: true,
  36717. value: version,
  36718. writable: false
  36719. });
  36720. }
  36721. Logger.prototype._log = function (logLevel, args) {
  36722. var level = logLevel.toLowerCase();
  36723. if (LogLevels[level] == null) {
  36724. this.throwArgumentError("invalid log level name", "logLevel", logLevel);
  36725. }
  36726. if (_logLevel > LogLevels[level]) {
  36727. return;
  36728. }
  36729. console.log.apply(console, args);
  36730. };
  36731. Logger.prototype.debug = function () {
  36732. var args = [];
  36733. for (var _i = 0; _i < arguments.length; _i++) {
  36734. args[_i] = arguments[_i];
  36735. }
  36736. this._log(Logger.levels.DEBUG, args);
  36737. };
  36738. Logger.prototype.info = function () {
  36739. var args = [];
  36740. for (var _i = 0; _i < arguments.length; _i++) {
  36741. args[_i] = arguments[_i];
  36742. }
  36743. this._log(Logger.levels.INFO, args);
  36744. };
  36745. Logger.prototype.warn = function () {
  36746. var args = [];
  36747. for (var _i = 0; _i < arguments.length; _i++) {
  36748. args[_i] = arguments[_i];
  36749. }
  36750. this._log(Logger.levels.WARNING, args);
  36751. };
  36752. Logger.prototype.makeError = function (message, code, params) {
  36753. // Errors are being censored
  36754. if (_censorErrors) {
  36755. return this.makeError("censored error", code, {});
  36756. }
  36757. if (!code) {
  36758. code = Logger.errors.UNKNOWN_ERROR;
  36759. }
  36760. if (!params) {
  36761. params = {};
  36762. }
  36763. var messageDetails = [];
  36764. Object.keys(params).forEach(function (key) {
  36765. var value = params[key];
  36766. try {
  36767. if (value instanceof Uint8Array) {
  36768. var hex = "";
  36769. for (var i = 0; i < value.length; i++) {
  36770. hex += HEX[value[i] >> 4];
  36771. hex += HEX[value[i] & 0x0f];
  36772. }
  36773. messageDetails.push(key + "=Uint8Array(0x" + hex + ")");
  36774. }
  36775. else {
  36776. messageDetails.push(key + "=" + JSON.stringify(value));
  36777. }
  36778. }
  36779. catch (error) {
  36780. messageDetails.push(key + "=" + JSON.stringify(params[key].toString()));
  36781. }
  36782. });
  36783. messageDetails.push("code=" + code);
  36784. messageDetails.push("version=" + this.version);
  36785. var reason = message;
  36786. var url = "";
  36787. switch (code) {
  36788. case ErrorCode.NUMERIC_FAULT: {
  36789. url = "NUMERIC_FAULT";
  36790. var fault = message;
  36791. switch (fault) {
  36792. case "overflow":
  36793. case "underflow":
  36794. case "division-by-zero":
  36795. url += "-" + fault;
  36796. break;
  36797. case "negative-power":
  36798. case "negative-width":
  36799. url += "-unsupported";
  36800. break;
  36801. case "unbound-bitwise-result":
  36802. url += "-unbound-result";
  36803. break;
  36804. }
  36805. break;
  36806. }
  36807. case ErrorCode.CALL_EXCEPTION:
  36808. case ErrorCode.INSUFFICIENT_FUNDS:
  36809. case ErrorCode.MISSING_NEW:
  36810. case ErrorCode.NONCE_EXPIRED:
  36811. case ErrorCode.REPLACEMENT_UNDERPRICED:
  36812. case ErrorCode.TRANSACTION_REPLACED:
  36813. case ErrorCode.UNPREDICTABLE_GAS_LIMIT:
  36814. url = code;
  36815. break;
  36816. }
  36817. if (url) {
  36818. message += " [ See: https:/\/links.ethers.org/v5-errors-" + url + " ]";
  36819. }
  36820. if (messageDetails.length) {
  36821. message += " (" + messageDetails.join(", ") + ")";
  36822. }
  36823. // @TODO: Any??
  36824. var error = new Error(message);
  36825. error.reason = reason;
  36826. error.code = code;
  36827. Object.keys(params).forEach(function (key) {
  36828. error[key] = params[key];
  36829. });
  36830. return error;
  36831. };
  36832. Logger.prototype.throwError = function (message, code, params) {
  36833. throw this.makeError(message, code, params);
  36834. };
  36835. Logger.prototype.throwArgumentError = function (message, name, value) {
  36836. return this.throwError(message, Logger.errors.INVALID_ARGUMENT, {
  36837. argument: name,
  36838. value: value
  36839. });
  36840. };
  36841. Logger.prototype.assert = function (condition, message, code, params) {
  36842. if (!!condition) {
  36843. return;
  36844. }
  36845. this.throwError(message, code, params);
  36846. };
  36847. Logger.prototype.assertArgument = function (condition, message, name, value) {
  36848. if (!!condition) {
  36849. return;
  36850. }
  36851. this.throwArgumentError(message, name, value);
  36852. };
  36853. Logger.prototype.checkNormalize = function (message) {
  36854. if (message == null) {
  36855. message = "platform missing String.prototype.normalize";
  36856. }
  36857. if (_normalizeError) {
  36858. this.throwError("platform missing String.prototype.normalize", Logger.errors.UNSUPPORTED_OPERATION, {
  36859. operation: "String.prototype.normalize", form: _normalizeError
  36860. });
  36861. }
  36862. };
  36863. Logger.prototype.checkSafeUint53 = function (value, message) {
  36864. if (typeof (value) !== "number") {
  36865. return;
  36866. }
  36867. if (message == null) {
  36868. message = "value not safe";
  36869. }
  36870. if (value < 0 || value >= 0x1fffffffffffff) {
  36871. this.throwError(message, Logger.errors.NUMERIC_FAULT, {
  36872. operation: "checkSafeInteger",
  36873. fault: "out-of-safe-range",
  36874. value: value
  36875. });
  36876. }
  36877. if (value % 1) {
  36878. this.throwError(message, Logger.errors.NUMERIC_FAULT, {
  36879. operation: "checkSafeInteger",
  36880. fault: "non-integer",
  36881. value: value
  36882. });
  36883. }
  36884. };
  36885. Logger.prototype.checkArgumentCount = function (count, expectedCount, message) {
  36886. if (message) {
  36887. message = ": " + message;
  36888. }
  36889. else {
  36890. message = "";
  36891. }
  36892. if (count < expectedCount) {
  36893. this.throwError("missing argument" + message, Logger.errors.MISSING_ARGUMENT, {
  36894. count: count,
  36895. expectedCount: expectedCount
  36896. });
  36897. }
  36898. if (count > expectedCount) {
  36899. this.throwError("too many arguments" + message, Logger.errors.UNEXPECTED_ARGUMENT, {
  36900. count: count,
  36901. expectedCount: expectedCount
  36902. });
  36903. }
  36904. };
  36905. Logger.prototype.checkNew = function (target, kind) {
  36906. if (target === Object || target == null) {
  36907. this.throwError("missing new", Logger.errors.MISSING_NEW, { name: kind.name });
  36908. }
  36909. };
  36910. Logger.prototype.checkAbstract = function (target, kind) {
  36911. if (target === kind) {
  36912. this.throwError("cannot instantiate abstract class " + JSON.stringify(kind.name) + " directly; use a sub-class", Logger.errors.UNSUPPORTED_OPERATION, { name: target.name, operation: "new" });
  36913. }
  36914. else if (target === Object || target == null) {
  36915. this.throwError("missing new", Logger.errors.MISSING_NEW, { name: kind.name });
  36916. }
  36917. };
  36918. Logger.globalLogger = function () {
  36919. if (!_globalLogger) {
  36920. _globalLogger = new Logger(_version_1.version);
  36921. }
  36922. return _globalLogger;
  36923. };
  36924. Logger.setCensorship = function (censorship, permanent) {
  36925. if (!censorship && permanent) {
  36926. this.globalLogger().throwError("cannot permanently disable censorship", Logger.errors.UNSUPPORTED_OPERATION, {
  36927. operation: "setCensorship"
  36928. });
  36929. }
  36930. if (_permanentCensorErrors) {
  36931. if (!censorship) {
  36932. return;
  36933. }
  36934. this.globalLogger().throwError("error censorship permanent", Logger.errors.UNSUPPORTED_OPERATION, {
  36935. operation: "setCensorship"
  36936. });
  36937. }
  36938. _censorErrors = !!censorship;
  36939. _permanentCensorErrors = !!permanent;
  36940. };
  36941. Logger.setLogLevel = function (logLevel) {
  36942. var level = LogLevels[logLevel.toLowerCase()];
  36943. if (level == null) {
  36944. Logger.globalLogger().warn("invalid log level - " + logLevel);
  36945. return;
  36946. }
  36947. _logLevel = level;
  36948. };
  36949. Logger.from = function (version) {
  36950. return new Logger(version);
  36951. };
  36952. Logger.errors = ErrorCode;
  36953. Logger.levels = LogLevel;
  36954. return Logger;
  36955. }());
  36956. exports.Logger = Logger;
  36957. },{"./_version":222}],224:[function(_dereq_,module,exports){
  36958. "use strict";
  36959. Object.defineProperty(exports, "__esModule", { value: true });
  36960. exports.version = void 0;
  36961. exports.version = "networks/5.6.0";
  36962. },{}],225:[function(_dereq_,module,exports){
  36963. "use strict";
  36964. Object.defineProperty(exports, "__esModule", { value: true });
  36965. exports.getNetwork = void 0;
  36966. var logger_1 = _dereq_("@ethersproject/logger");
  36967. var _version_1 = _dereq_("./_version");
  36968. var logger = new logger_1.Logger(_version_1.version);
  36969. ;
  36970. function isRenetworkable(value) {
  36971. return (value && typeof (value.renetwork) === "function");
  36972. }
  36973. function ethDefaultProvider(network) {
  36974. var func = function (providers, options) {
  36975. if (options == null) {
  36976. options = {};
  36977. }
  36978. var providerList = [];
  36979. if (providers.InfuraProvider && options.infura !== "-") {
  36980. try {
  36981. providerList.push(new providers.InfuraProvider(network, options.infura));
  36982. }
  36983. catch (error) { }
  36984. }
  36985. if (providers.EtherscanProvider && options.etherscan !== "-") {
  36986. try {
  36987. providerList.push(new providers.EtherscanProvider(network, options.etherscan));
  36988. }
  36989. catch (error) { }
  36990. }
  36991. if (providers.AlchemyProvider && options.alchemy !== "-") {
  36992. try {
  36993. providerList.push(new providers.AlchemyProvider(network, options.alchemy));
  36994. }
  36995. catch (error) { }
  36996. }
  36997. if (providers.PocketProvider && options.pocket !== "-") {
  36998. // These networks are currently faulty on Pocket as their
  36999. // network does not handle the Berlin hardfork, which is
  37000. // live on these ones.
  37001. // @TODO: This goes away once Pocket has upgraded their nodes
  37002. var skip = ["goerli", "ropsten", "rinkeby"];
  37003. try {
  37004. var provider = new providers.PocketProvider(network);
  37005. if (provider.network && skip.indexOf(provider.network.name) === -1) {
  37006. providerList.push(provider);
  37007. }
  37008. }
  37009. catch (error) { }
  37010. }
  37011. if (providers.CloudflareProvider && options.cloudflare !== "-") {
  37012. try {
  37013. providerList.push(new providers.CloudflareProvider(network));
  37014. }
  37015. catch (error) { }
  37016. }
  37017. if (providerList.length === 0) {
  37018. return null;
  37019. }
  37020. if (providers.FallbackProvider) {
  37021. var quorum = 1;
  37022. if (options.quorum != null) {
  37023. quorum = options.quorum;
  37024. }
  37025. else if (network === "homestead") {
  37026. quorum = 2;
  37027. }
  37028. return new providers.FallbackProvider(providerList, quorum);
  37029. }
  37030. return providerList[0];
  37031. };
  37032. func.renetwork = function (network) {
  37033. return ethDefaultProvider(network);
  37034. };
  37035. return func;
  37036. }
  37037. function etcDefaultProvider(url, network) {
  37038. var func = function (providers, options) {
  37039. if (providers.JsonRpcProvider) {
  37040. return new providers.JsonRpcProvider(url, network);
  37041. }
  37042. return null;
  37043. };
  37044. func.renetwork = function (network) {
  37045. return etcDefaultProvider(url, network);
  37046. };
  37047. return func;
  37048. }
  37049. var homestead = {
  37050. chainId: 1,
  37051. ensAddress: "0x00000000000C2E074eC69A0dFb2997BA6C7d2e1e",
  37052. name: "homestead",
  37053. _defaultProvider: ethDefaultProvider("homestead")
  37054. };
  37055. var ropsten = {
  37056. chainId: 3,
  37057. ensAddress: "0x00000000000C2E074eC69A0dFb2997BA6C7d2e1e",
  37058. name: "ropsten",
  37059. _defaultProvider: ethDefaultProvider("ropsten")
  37060. };
  37061. var classicMordor = {
  37062. chainId: 63,
  37063. name: "classicMordor",
  37064. _defaultProvider: etcDefaultProvider("https://www.ethercluster.com/mordor", "classicMordor")
  37065. };
  37066. // See: https://chainlist.org
  37067. var networks = {
  37068. unspecified: { chainId: 0, name: "unspecified" },
  37069. homestead: homestead,
  37070. mainnet: homestead,
  37071. morden: { chainId: 2, name: "morden" },
  37072. ropsten: ropsten,
  37073. testnet: ropsten,
  37074. rinkeby: {
  37075. chainId: 4,
  37076. ensAddress: "0x00000000000C2E074eC69A0dFb2997BA6C7d2e1e",
  37077. name: "rinkeby",
  37078. _defaultProvider: ethDefaultProvider("rinkeby")
  37079. },
  37080. kovan: {
  37081. chainId: 42,
  37082. name: "kovan",
  37083. _defaultProvider: ethDefaultProvider("kovan")
  37084. },
  37085. goerli: {
  37086. chainId: 5,
  37087. ensAddress: "0x00000000000C2E074eC69A0dFb2997BA6C7d2e1e",
  37088. name: "goerli",
  37089. _defaultProvider: ethDefaultProvider("goerli")
  37090. },
  37091. kintsugi: { chainId: 1337702, name: "kintsugi" },
  37092. // ETC (See: #351)
  37093. classic: {
  37094. chainId: 61,
  37095. name: "classic",
  37096. _defaultProvider: etcDefaultProvider("https:/\/www.ethercluster.com/etc", "classic")
  37097. },
  37098. classicMorden: { chainId: 62, name: "classicMorden" },
  37099. classicMordor: classicMordor,
  37100. classicTestnet: classicMordor,
  37101. classicKotti: {
  37102. chainId: 6,
  37103. name: "classicKotti",
  37104. _defaultProvider: etcDefaultProvider("https:/\/www.ethercluster.com/kotti", "classicKotti")
  37105. },
  37106. xdai: { chainId: 100, name: "xdai" },
  37107. matic: { chainId: 137, name: "matic" },
  37108. maticmum: { chainId: 80001, name: "maticmum" },
  37109. optimism: { chainId: 10, name: "optimism" },
  37110. "optimism-kovan": { chainId: 69, name: "optimism-kovan" },
  37111. "optimism-goerli": { chainId: 420, name: "optimism-goerli" },
  37112. arbitrum: { chainId: 42161, name: "arbitrum" },
  37113. "arbitrum-rinkeby": { chainId: 421611, name: "arbitrum-rinkeby" },
  37114. bnb: { chainId: 56, name: "bnb" },
  37115. bnbt: { chainId: 97, name: "bnbt" },
  37116. };
  37117. /**
  37118. * getNetwork
  37119. *
  37120. * Converts a named common networks or chain ID (network ID) to a Network
  37121. * and verifies a network is a valid Network..
  37122. */
  37123. function getNetwork(network) {
  37124. // No network (null)
  37125. if (network == null) {
  37126. return null;
  37127. }
  37128. if (typeof (network) === "number") {
  37129. for (var name_1 in networks) {
  37130. var standard_1 = networks[name_1];
  37131. if (standard_1.chainId === network) {
  37132. return {
  37133. name: standard_1.name,
  37134. chainId: standard_1.chainId,
  37135. ensAddress: (standard_1.ensAddress || null),
  37136. _defaultProvider: (standard_1._defaultProvider || null)
  37137. };
  37138. }
  37139. }
  37140. return {
  37141. chainId: network,
  37142. name: "unknown"
  37143. };
  37144. }
  37145. if (typeof (network) === "string") {
  37146. var standard_2 = networks[network];
  37147. if (standard_2 == null) {
  37148. return null;
  37149. }
  37150. return {
  37151. name: standard_2.name,
  37152. chainId: standard_2.chainId,
  37153. ensAddress: standard_2.ensAddress,
  37154. _defaultProvider: (standard_2._defaultProvider || null)
  37155. };
  37156. }
  37157. var standard = networks[network.name];
  37158. // Not a standard network; check that it is a valid network in general
  37159. if (!standard) {
  37160. if (typeof (network.chainId) !== "number") {
  37161. logger.throwArgumentError("invalid network chainId", "network", network);
  37162. }
  37163. return network;
  37164. }
  37165. // Make sure the chainId matches the expected network chainId (or is 0; disable EIP-155)
  37166. if (network.chainId !== 0 && network.chainId !== standard.chainId) {
  37167. logger.throwArgumentError("network chainId mismatch", "network", network);
  37168. }
  37169. // @TODO: In the next major version add an attach function to a defaultProvider
  37170. // class and move the _defaultProvider internal to this file (extend Network)
  37171. var defaultProvider = network._defaultProvider || null;
  37172. if (defaultProvider == null && standard._defaultProvider) {
  37173. if (isRenetworkable(standard._defaultProvider)) {
  37174. defaultProvider = standard._defaultProvider.renetwork(network);
  37175. }
  37176. else {
  37177. defaultProvider = standard._defaultProvider;
  37178. }
  37179. }
  37180. // Standard Network (allow overriding the ENS address)
  37181. return {
  37182. name: network.name,
  37183. chainId: standard.chainId,
  37184. ensAddress: (network.ensAddress || standard.ensAddress || null),
  37185. _defaultProvider: defaultProvider
  37186. };
  37187. }
  37188. exports.getNetwork = getNetwork;
  37189. },{"./_version":224,"@ethersproject/logger":223}],226:[function(_dereq_,module,exports){
  37190. "use strict";
  37191. Object.defineProperty(exports, "__esModule", { value: true });
  37192. exports.pbkdf2 = void 0;
  37193. var bytes_1 = _dereq_("@ethersproject/bytes");
  37194. var sha2_1 = _dereq_("@ethersproject/sha2");
  37195. function pbkdf2(password, salt, iterations, keylen, hashAlgorithm) {
  37196. password = (0, bytes_1.arrayify)(password);
  37197. salt = (0, bytes_1.arrayify)(salt);
  37198. var hLen;
  37199. var l = 1;
  37200. var DK = new Uint8Array(keylen);
  37201. var block1 = new Uint8Array(salt.length + 4);
  37202. block1.set(salt);
  37203. //salt.copy(block1, 0, 0, salt.length)
  37204. var r;
  37205. var T;
  37206. for (var i = 1; i <= l; i++) {
  37207. //block1.writeUInt32BE(i, salt.length)
  37208. block1[salt.length] = (i >> 24) & 0xff;
  37209. block1[salt.length + 1] = (i >> 16) & 0xff;
  37210. block1[salt.length + 2] = (i >> 8) & 0xff;
  37211. block1[salt.length + 3] = i & 0xff;
  37212. //let U = createHmac(password).update(block1).digest();
  37213. var U = (0, bytes_1.arrayify)((0, sha2_1.computeHmac)(hashAlgorithm, password, block1));
  37214. if (!hLen) {
  37215. hLen = U.length;
  37216. T = new Uint8Array(hLen);
  37217. l = Math.ceil(keylen / hLen);
  37218. r = keylen - (l - 1) * hLen;
  37219. }
  37220. //U.copy(T, 0, 0, hLen)
  37221. T.set(U);
  37222. for (var j = 1; j < iterations; j++) {
  37223. //U = createHmac(password).update(U).digest();
  37224. U = (0, bytes_1.arrayify)((0, sha2_1.computeHmac)(hashAlgorithm, password, U));
  37225. for (var k = 0; k < hLen; k++)
  37226. T[k] ^= U[k];
  37227. }
  37228. var destPos = (i - 1) * hLen;
  37229. var len = (i === l ? r : hLen);
  37230. //T.copy(DK, destPos, 0, len)
  37231. DK.set((0, bytes_1.arrayify)(T).slice(0, len), destPos);
  37232. }
  37233. return (0, bytes_1.hexlify)(DK);
  37234. }
  37235. exports.pbkdf2 = pbkdf2;
  37236. },{"@ethersproject/bytes":199,"@ethersproject/sha2":256}],227:[function(_dereq_,module,exports){
  37237. "use strict";
  37238. Object.defineProperty(exports, "__esModule", { value: true });
  37239. exports.pbkdf2 = void 0;
  37240. var pbkdf2_1 = _dereq_("./pbkdf2");
  37241. Object.defineProperty(exports, "pbkdf2", { enumerable: true, get: function () { return pbkdf2_1.pbkdf2; } });
  37242. },{"./pbkdf2":226}],228:[function(_dereq_,module,exports){
  37243. "use strict";
  37244. Object.defineProperty(exports, "__esModule", { value: true });
  37245. exports.version = void 0;
  37246. exports.version = "properties/5.6.0";
  37247. },{}],229:[function(_dereq_,module,exports){
  37248. "use strict";
  37249. var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
  37250. function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
  37251. return new (P || (P = Promise))(function (resolve, reject) {
  37252. function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
  37253. function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
  37254. function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
  37255. step((generator = generator.apply(thisArg, _arguments || [])).next());
  37256. });
  37257. };
  37258. var __generator = (this && this.__generator) || function (thisArg, body) {
  37259. var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
  37260. return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
  37261. function verb(n) { return function (v) { return step([n, v]); }; }
  37262. function step(op) {
  37263. if (f) throw new TypeError("Generator is already executing.");
  37264. while (_) try {
  37265. if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
  37266. if (y = 0, t) op = [op[0] & 2, t.value];
  37267. switch (op[0]) {
  37268. case 0: case 1: t = op; break;
  37269. case 4: _.label++; return { value: op[1], done: false };
  37270. case 5: _.label++; y = op[1]; op = [0]; continue;
  37271. case 7: op = _.ops.pop(); _.trys.pop(); continue;
  37272. default:
  37273. if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
  37274. if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
  37275. if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
  37276. if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
  37277. if (t[2]) _.ops.pop();
  37278. _.trys.pop(); continue;
  37279. }
  37280. op = body.call(thisArg, _);
  37281. } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
  37282. if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
  37283. }
  37284. };
  37285. Object.defineProperty(exports, "__esModule", { value: true });
  37286. exports.Description = exports.deepCopy = exports.shallowCopy = exports.checkProperties = exports.resolveProperties = exports.getStatic = exports.defineReadOnly = void 0;
  37287. var logger_1 = _dereq_("@ethersproject/logger");
  37288. var _version_1 = _dereq_("./_version");
  37289. var logger = new logger_1.Logger(_version_1.version);
  37290. function defineReadOnly(object, name, value) {
  37291. Object.defineProperty(object, name, {
  37292. enumerable: true,
  37293. value: value,
  37294. writable: false,
  37295. });
  37296. }
  37297. exports.defineReadOnly = defineReadOnly;
  37298. // Crawl up the constructor chain to find a static method
  37299. function getStatic(ctor, key) {
  37300. for (var i = 0; i < 32; i++) {
  37301. if (ctor[key]) {
  37302. return ctor[key];
  37303. }
  37304. if (!ctor.prototype || typeof (ctor.prototype) !== "object") {
  37305. break;
  37306. }
  37307. ctor = Object.getPrototypeOf(ctor.prototype).constructor;
  37308. }
  37309. return null;
  37310. }
  37311. exports.getStatic = getStatic;
  37312. function resolveProperties(object) {
  37313. return __awaiter(this, void 0, void 0, function () {
  37314. var promises, results;
  37315. return __generator(this, function (_a) {
  37316. switch (_a.label) {
  37317. case 0:
  37318. promises = Object.keys(object).map(function (key) {
  37319. var value = object[key];
  37320. return Promise.resolve(value).then(function (v) { return ({ key: key, value: v }); });
  37321. });
  37322. return [4 /*yield*/, Promise.all(promises)];
  37323. case 1:
  37324. results = _a.sent();
  37325. return [2 /*return*/, results.reduce(function (accum, result) {
  37326. accum[(result.key)] = result.value;
  37327. return accum;
  37328. }, {})];
  37329. }
  37330. });
  37331. });
  37332. }
  37333. exports.resolveProperties = resolveProperties;
  37334. function checkProperties(object, properties) {
  37335. if (!object || typeof (object) !== "object") {
  37336. logger.throwArgumentError("invalid object", "object", object);
  37337. }
  37338. Object.keys(object).forEach(function (key) {
  37339. if (!properties[key]) {
  37340. logger.throwArgumentError("invalid object key - " + key, "transaction:" + key, object);
  37341. }
  37342. });
  37343. }
  37344. exports.checkProperties = checkProperties;
  37345. function shallowCopy(object) {
  37346. var result = {};
  37347. for (var key in object) {
  37348. result[key] = object[key];
  37349. }
  37350. return result;
  37351. }
  37352. exports.shallowCopy = shallowCopy;
  37353. var opaque = { bigint: true, boolean: true, "function": true, number: true, string: true };
  37354. function _isFrozen(object) {
  37355. // Opaque objects are not mutable, so safe to copy by assignment
  37356. if (object === undefined || object === null || opaque[typeof (object)]) {
  37357. return true;
  37358. }
  37359. if (Array.isArray(object) || typeof (object) === "object") {
  37360. if (!Object.isFrozen(object)) {
  37361. return false;
  37362. }
  37363. var keys = Object.keys(object);
  37364. for (var i = 0; i < keys.length; i++) {
  37365. var value = null;
  37366. try {
  37367. value = object[keys[i]];
  37368. }
  37369. catch (error) {
  37370. // If accessing a value triggers an error, it is a getter
  37371. // designed to do so (e.g. Result) and is therefore "frozen"
  37372. continue;
  37373. }
  37374. if (!_isFrozen(value)) {
  37375. return false;
  37376. }
  37377. }
  37378. return true;
  37379. }
  37380. return logger.throwArgumentError("Cannot deepCopy " + typeof (object), "object", object);
  37381. }
  37382. // Returns a new copy of object, such that no properties may be replaced.
  37383. // New properties may be added only to objects.
  37384. function _deepCopy(object) {
  37385. if (_isFrozen(object)) {
  37386. return object;
  37387. }
  37388. // Arrays are mutable, so we need to create a copy
  37389. if (Array.isArray(object)) {
  37390. return Object.freeze(object.map(function (item) { return deepCopy(item); }));
  37391. }
  37392. if (typeof (object) === "object") {
  37393. var result = {};
  37394. for (var key in object) {
  37395. var value = object[key];
  37396. if (value === undefined) {
  37397. continue;
  37398. }
  37399. defineReadOnly(result, key, deepCopy(value));
  37400. }
  37401. return result;
  37402. }
  37403. return logger.throwArgumentError("Cannot deepCopy " + typeof (object), "object", object);
  37404. }
  37405. function deepCopy(object) {
  37406. return _deepCopy(object);
  37407. }
  37408. exports.deepCopy = deepCopy;
  37409. var Description = /** @class */ (function () {
  37410. function Description(info) {
  37411. for (var key in info) {
  37412. this[key] = deepCopy(info[key]);
  37413. }
  37414. }
  37415. return Description;
  37416. }());
  37417. exports.Description = Description;
  37418. },{"./_version":228,"@ethersproject/logger":223}],230:[function(_dereq_,module,exports){
  37419. "use strict";
  37420. Object.defineProperty(exports, "__esModule", { value: true });
  37421. exports.version = void 0;
  37422. exports.version = "providers/5.6.0";
  37423. },{}],231:[function(_dereq_,module,exports){
  37424. "use strict";
  37425. var __extends = (this && this.__extends) || (function () {
  37426. var extendStatics = function (d, b) {
  37427. extendStatics = Object.setPrototypeOf ||
  37428. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  37429. function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
  37430. return extendStatics(d, b);
  37431. };
  37432. return function (d, b) {
  37433. if (typeof b !== "function" && b !== null)
  37434. throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
  37435. extendStatics(d, b);
  37436. function __() { this.constructor = d; }
  37437. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  37438. };
  37439. })();
  37440. Object.defineProperty(exports, "__esModule", { value: true });
  37441. exports.AlchemyProvider = exports.AlchemyWebSocketProvider = void 0;
  37442. var properties_1 = _dereq_("@ethersproject/properties");
  37443. var formatter_1 = _dereq_("./formatter");
  37444. var websocket_provider_1 = _dereq_("./websocket-provider");
  37445. var logger_1 = _dereq_("@ethersproject/logger");
  37446. var _version_1 = _dereq_("./_version");
  37447. var logger = new logger_1.Logger(_version_1.version);
  37448. var url_json_rpc_provider_1 = _dereq_("./url-json-rpc-provider");
  37449. // This key was provided to ethers.js by Alchemy to be used by the
  37450. // default provider, but it is recommended that for your own
  37451. // production environments, that you acquire your own API key at:
  37452. // https://dashboard.alchemyapi.io
  37453. var defaultApiKey = "_gg7wSSi0KMBsdKnGVfHDueq6xMB9EkC";
  37454. var AlchemyWebSocketProvider = /** @class */ (function (_super) {
  37455. __extends(AlchemyWebSocketProvider, _super);
  37456. function AlchemyWebSocketProvider(network, apiKey) {
  37457. var _this = this;
  37458. var provider = new AlchemyProvider(network, apiKey);
  37459. var url = provider.connection.url.replace(/^http/i, "ws")
  37460. .replace(".alchemyapi.", ".ws.alchemyapi.");
  37461. _this = _super.call(this, url, provider.network) || this;
  37462. (0, properties_1.defineReadOnly)(_this, "apiKey", provider.apiKey);
  37463. return _this;
  37464. }
  37465. AlchemyWebSocketProvider.prototype.isCommunityResource = function () {
  37466. return (this.apiKey === defaultApiKey);
  37467. };
  37468. return AlchemyWebSocketProvider;
  37469. }(websocket_provider_1.WebSocketProvider));
  37470. exports.AlchemyWebSocketProvider = AlchemyWebSocketProvider;
  37471. var AlchemyProvider = /** @class */ (function (_super) {
  37472. __extends(AlchemyProvider, _super);
  37473. function AlchemyProvider() {
  37474. return _super !== null && _super.apply(this, arguments) || this;
  37475. }
  37476. AlchemyProvider.getWebSocketProvider = function (network, apiKey) {
  37477. return new AlchemyWebSocketProvider(network, apiKey);
  37478. };
  37479. AlchemyProvider.getApiKey = function (apiKey) {
  37480. if (apiKey == null) {
  37481. return defaultApiKey;
  37482. }
  37483. if (apiKey && typeof (apiKey) !== "string") {
  37484. logger.throwArgumentError("invalid apiKey", "apiKey", apiKey);
  37485. }
  37486. return apiKey;
  37487. };
  37488. AlchemyProvider.getUrl = function (network, apiKey) {
  37489. var host = null;
  37490. switch (network.name) {
  37491. case "homestead":
  37492. host = "eth-mainnet.alchemyapi.io/v2/";
  37493. break;
  37494. case "ropsten":
  37495. host = "eth-ropsten.alchemyapi.io/v2/";
  37496. break;
  37497. case "rinkeby":
  37498. host = "eth-rinkeby.alchemyapi.io/v2/";
  37499. break;
  37500. case "goerli":
  37501. host = "eth-goerli.alchemyapi.io/v2/";
  37502. break;
  37503. case "kovan":
  37504. host = "eth-kovan.alchemyapi.io/v2/";
  37505. break;
  37506. case "matic":
  37507. host = "polygon-mainnet.g.alchemy.com/v2/";
  37508. break;
  37509. case "maticmum":
  37510. host = "polygon-mumbai.g.alchemy.com/v2/";
  37511. break;
  37512. case "arbitrum":
  37513. host = "arb-mainnet.g.alchemy.com/v2/";
  37514. break;
  37515. case "arbitrum-rinkeby":
  37516. host = "arb-rinkeby.g.alchemy.com/v2/";
  37517. break;
  37518. case "optimism":
  37519. host = "opt-mainnet.g.alchemy.com/v2/";
  37520. break;
  37521. case "optimism-kovan":
  37522. host = "opt-kovan.g.alchemy.com/v2/";
  37523. break;
  37524. default:
  37525. logger.throwArgumentError("unsupported network", "network", arguments[0]);
  37526. }
  37527. return {
  37528. allowGzip: true,
  37529. url: ("https:/" + "/" + host + apiKey),
  37530. throttleCallback: function (attempt, url) {
  37531. if (apiKey === defaultApiKey) {
  37532. (0, formatter_1.showThrottleMessage)();
  37533. }
  37534. return Promise.resolve(true);
  37535. }
  37536. };
  37537. };
  37538. AlchemyProvider.prototype.isCommunityResource = function () {
  37539. return (this.apiKey === defaultApiKey);
  37540. };
  37541. return AlchemyProvider;
  37542. }(url_json_rpc_provider_1.UrlJsonRpcProvider));
  37543. exports.AlchemyProvider = AlchemyProvider;
  37544. },{"./_version":230,"./formatter":238,"./url-json-rpc-provider":245,"./websocket-provider":247,"@ethersproject/logger":223,"@ethersproject/properties":229}],232:[function(_dereq_,module,exports){
  37545. "use strict";
  37546. var __extends = (this && this.__extends) || (function () {
  37547. var extendStatics = function (d, b) {
  37548. extendStatics = Object.setPrototypeOf ||
  37549. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  37550. function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
  37551. return extendStatics(d, b);
  37552. };
  37553. return function (d, b) {
  37554. if (typeof b !== "function" && b !== null)
  37555. throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
  37556. extendStatics(d, b);
  37557. function __() { this.constructor = d; }
  37558. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  37559. };
  37560. })();
  37561. var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
  37562. function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
  37563. return new (P || (P = Promise))(function (resolve, reject) {
  37564. function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
  37565. function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
  37566. function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
  37567. step((generator = generator.apply(thisArg, _arguments || [])).next());
  37568. });
  37569. };
  37570. var __generator = (this && this.__generator) || function (thisArg, body) {
  37571. var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
  37572. return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
  37573. function verb(n) { return function (v) { return step([n, v]); }; }
  37574. function step(op) {
  37575. if (f) throw new TypeError("Generator is already executing.");
  37576. while (_) try {
  37577. if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
  37578. if (y = 0, t) op = [op[0] & 2, t.value];
  37579. switch (op[0]) {
  37580. case 0: case 1: t = op; break;
  37581. case 4: _.label++; return { value: op[1], done: false };
  37582. case 5: _.label++; y = op[1]; op = [0]; continue;
  37583. case 7: op = _.ops.pop(); _.trys.pop(); continue;
  37584. default:
  37585. if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
  37586. if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
  37587. if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
  37588. if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
  37589. if (t[2]) _.ops.pop();
  37590. _.trys.pop(); continue;
  37591. }
  37592. op = body.call(thisArg, _);
  37593. } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
  37594. if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
  37595. }
  37596. };
  37597. var __importDefault = (this && this.__importDefault) || function (mod) {
  37598. return (mod && mod.__esModule) ? mod : { "default": mod };
  37599. };
  37600. Object.defineProperty(exports, "__esModule", { value: true });
  37601. exports.BaseProvider = exports.Resolver = exports.Event = void 0;
  37602. var abstract_provider_1 = _dereq_("@ethersproject/abstract-provider");
  37603. var basex_1 = _dereq_("@ethersproject/basex");
  37604. var bignumber_1 = _dereq_("@ethersproject/bignumber");
  37605. var bytes_1 = _dereq_("@ethersproject/bytes");
  37606. var constants_1 = _dereq_("@ethersproject/constants");
  37607. var hash_1 = _dereq_("@ethersproject/hash");
  37608. var networks_1 = _dereq_("@ethersproject/networks");
  37609. var properties_1 = _dereq_("@ethersproject/properties");
  37610. var sha2_1 = _dereq_("@ethersproject/sha2");
  37611. var strings_1 = _dereq_("@ethersproject/strings");
  37612. var web_1 = _dereq_("@ethersproject/web");
  37613. var bech32_1 = __importDefault(_dereq_("bech32"));
  37614. var logger_1 = _dereq_("@ethersproject/logger");
  37615. var _version_1 = _dereq_("./_version");
  37616. var logger = new logger_1.Logger(_version_1.version);
  37617. var formatter_1 = _dereq_("./formatter");
  37618. var MAX_CCIP_REDIRECTS = 10;
  37619. //////////////////////////////
  37620. // Event Serializeing
  37621. function checkTopic(topic) {
  37622. if (topic == null) {
  37623. return "null";
  37624. }
  37625. if ((0, bytes_1.hexDataLength)(topic) !== 32) {
  37626. logger.throwArgumentError("invalid topic", "topic", topic);
  37627. }
  37628. return topic.toLowerCase();
  37629. }
  37630. function serializeTopics(topics) {
  37631. // Remove trailing null AND-topics; they are redundant
  37632. topics = topics.slice();
  37633. while (topics.length > 0 && topics[topics.length - 1] == null) {
  37634. topics.pop();
  37635. }
  37636. return topics.map(function (topic) {
  37637. if (Array.isArray(topic)) {
  37638. // Only track unique OR-topics
  37639. var unique_1 = {};
  37640. topic.forEach(function (topic) {
  37641. unique_1[checkTopic(topic)] = true;
  37642. });
  37643. // The order of OR-topics does not matter
  37644. var sorted = Object.keys(unique_1);
  37645. sorted.sort();
  37646. return sorted.join("|");
  37647. }
  37648. else {
  37649. return checkTopic(topic);
  37650. }
  37651. }).join("&");
  37652. }
  37653. function deserializeTopics(data) {
  37654. if (data === "") {
  37655. return [];
  37656. }
  37657. return data.split(/&/g).map(function (topic) {
  37658. if (topic === "") {
  37659. return [];
  37660. }
  37661. var comps = topic.split("|").map(function (topic) {
  37662. return ((topic === "null") ? null : topic);
  37663. });
  37664. return ((comps.length === 1) ? comps[0] : comps);
  37665. });
  37666. }
  37667. function getEventTag(eventName) {
  37668. if (typeof (eventName) === "string") {
  37669. eventName = eventName.toLowerCase();
  37670. if ((0, bytes_1.hexDataLength)(eventName) === 32) {
  37671. return "tx:" + eventName;
  37672. }
  37673. if (eventName.indexOf(":") === -1) {
  37674. return eventName;
  37675. }
  37676. }
  37677. else if (Array.isArray(eventName)) {
  37678. return "filter:*:" + serializeTopics(eventName);
  37679. }
  37680. else if (abstract_provider_1.ForkEvent.isForkEvent(eventName)) {
  37681. logger.warn("not implemented");
  37682. throw new Error("not implemented");
  37683. }
  37684. else if (eventName && typeof (eventName) === "object") {
  37685. return "filter:" + (eventName.address || "*") + ":" + serializeTopics(eventName.topics || []);
  37686. }
  37687. throw new Error("invalid event - " + eventName);
  37688. }
  37689. //////////////////////////////
  37690. // Helper Object
  37691. function getTime() {
  37692. return (new Date()).getTime();
  37693. }
  37694. function stall(duration) {
  37695. return new Promise(function (resolve) {
  37696. setTimeout(resolve, duration);
  37697. });
  37698. }
  37699. //////////////////////////////
  37700. // Provider Object
  37701. /**
  37702. * EventType
  37703. * - "block"
  37704. * - "poll"
  37705. * - "didPoll"
  37706. * - "pending"
  37707. * - "error"
  37708. * - "network"
  37709. * - filter
  37710. * - topics array
  37711. * - transaction hash
  37712. */
  37713. var PollableEvents = ["block", "network", "pending", "poll"];
  37714. var Event = /** @class */ (function () {
  37715. function Event(tag, listener, once) {
  37716. (0, properties_1.defineReadOnly)(this, "tag", tag);
  37717. (0, properties_1.defineReadOnly)(this, "listener", listener);
  37718. (0, properties_1.defineReadOnly)(this, "once", once);
  37719. this._lastBlockNumber = -2;
  37720. this._inflight = false;
  37721. }
  37722. Object.defineProperty(Event.prototype, "event", {
  37723. get: function () {
  37724. switch (this.type) {
  37725. case "tx":
  37726. return this.hash;
  37727. case "filter":
  37728. return this.filter;
  37729. }
  37730. return this.tag;
  37731. },
  37732. enumerable: false,
  37733. configurable: true
  37734. });
  37735. Object.defineProperty(Event.prototype, "type", {
  37736. get: function () {
  37737. return this.tag.split(":")[0];
  37738. },
  37739. enumerable: false,
  37740. configurable: true
  37741. });
  37742. Object.defineProperty(Event.prototype, "hash", {
  37743. get: function () {
  37744. var comps = this.tag.split(":");
  37745. if (comps[0] !== "tx") {
  37746. return null;
  37747. }
  37748. return comps[1];
  37749. },
  37750. enumerable: false,
  37751. configurable: true
  37752. });
  37753. Object.defineProperty(Event.prototype, "filter", {
  37754. get: function () {
  37755. var comps = this.tag.split(":");
  37756. if (comps[0] !== "filter") {
  37757. return null;
  37758. }
  37759. var address = comps[1];
  37760. var topics = deserializeTopics(comps[2]);
  37761. var filter = {};
  37762. if (topics.length > 0) {
  37763. filter.topics = topics;
  37764. }
  37765. if (address && address !== "*") {
  37766. filter.address = address;
  37767. }
  37768. return filter;
  37769. },
  37770. enumerable: false,
  37771. configurable: true
  37772. });
  37773. Event.prototype.pollable = function () {
  37774. return (this.tag.indexOf(":") >= 0 || PollableEvents.indexOf(this.tag) >= 0);
  37775. };
  37776. return Event;
  37777. }());
  37778. exports.Event = Event;
  37779. ;
  37780. // https://github.com/satoshilabs/slips/blob/master/slip-0044.md
  37781. var coinInfos = {
  37782. "0": { symbol: "btc", p2pkh: 0x00, p2sh: 0x05, prefix: "bc" },
  37783. "2": { symbol: "ltc", p2pkh: 0x30, p2sh: 0x32, prefix: "ltc" },
  37784. "3": { symbol: "doge", p2pkh: 0x1e, p2sh: 0x16 },
  37785. "60": { symbol: "eth", ilk: "eth" },
  37786. "61": { symbol: "etc", ilk: "eth" },
  37787. "700": { symbol: "xdai", ilk: "eth" },
  37788. };
  37789. function bytes32ify(value) {
  37790. return (0, bytes_1.hexZeroPad)(bignumber_1.BigNumber.from(value).toHexString(), 32);
  37791. }
  37792. // Compute the Base58Check encoded data (checksum is first 4 bytes of sha256d)
  37793. function base58Encode(data) {
  37794. return basex_1.Base58.encode((0, bytes_1.concat)([data, (0, bytes_1.hexDataSlice)((0, sha2_1.sha256)((0, sha2_1.sha256)(data)), 0, 4)]));
  37795. }
  37796. var matcherIpfs = new RegExp("^(ipfs):/\/(.*)$", "i");
  37797. var matchers = [
  37798. new RegExp("^(https):/\/(.*)$", "i"),
  37799. new RegExp("^(data):(.*)$", "i"),
  37800. matcherIpfs,
  37801. new RegExp("^eip155:[0-9]+/(erc[0-9]+):(.*)$", "i"),
  37802. ];
  37803. function _parseString(result, start) {
  37804. try {
  37805. return (0, strings_1.toUtf8String)(_parseBytes(result, start));
  37806. }
  37807. catch (error) { }
  37808. return null;
  37809. }
  37810. function _parseBytes(result, start) {
  37811. if (result === "0x") {
  37812. return null;
  37813. }
  37814. var offset = bignumber_1.BigNumber.from((0, bytes_1.hexDataSlice)(result, start, start + 32)).toNumber();
  37815. var length = bignumber_1.BigNumber.from((0, bytes_1.hexDataSlice)(result, offset, offset + 32)).toNumber();
  37816. return (0, bytes_1.hexDataSlice)(result, offset + 32, offset + 32 + length);
  37817. }
  37818. // Trim off the ipfs:// prefix and return the default gateway URL
  37819. function getIpfsLink(link) {
  37820. if (link.match(/^ipfs:\/\/ipfs\//i)) {
  37821. link = link.substring(12);
  37822. }
  37823. else if (link.match(/^ipfs:\/\//i)) {
  37824. link = link.substring(7);
  37825. }
  37826. else {
  37827. logger.throwArgumentError("unsupported IPFS format", "link", link);
  37828. }
  37829. return "https://gateway.ipfs.io/ipfs/" + link;
  37830. }
  37831. function numPad(value) {
  37832. var result = (0, bytes_1.arrayify)(value);
  37833. if (result.length > 32) {
  37834. throw new Error("internal; should not happen");
  37835. }
  37836. var padded = new Uint8Array(32);
  37837. padded.set(result, 32 - result.length);
  37838. return padded;
  37839. }
  37840. function bytesPad(value) {
  37841. if ((value.length % 32) === 0) {
  37842. return value;
  37843. }
  37844. var result = new Uint8Array(Math.ceil(value.length / 32) * 32);
  37845. result.set(value);
  37846. return result;
  37847. }
  37848. // ABI Encodes a series of (bytes, bytes, ...)
  37849. function encodeBytes(datas) {
  37850. var result = [];
  37851. var byteCount = 0;
  37852. // Add place-holders for pointers as we add items
  37853. for (var i = 0; i < datas.length; i++) {
  37854. result.push(null);
  37855. byteCount += 32;
  37856. }
  37857. for (var i = 0; i < datas.length; i++) {
  37858. var data = (0, bytes_1.arrayify)(datas[i]);
  37859. // Update the bytes offset
  37860. result[i] = numPad(byteCount);
  37861. // The length and padded value of data
  37862. result.push(numPad(data.length));
  37863. result.push(bytesPad(data));
  37864. byteCount += 32 + Math.ceil(data.length / 32) * 32;
  37865. }
  37866. return (0, bytes_1.hexConcat)(result);
  37867. }
  37868. var Resolver = /** @class */ (function () {
  37869. // The resolvedAddress is only for creating a ReverseLookup resolver
  37870. function Resolver(provider, address, name, resolvedAddress) {
  37871. (0, properties_1.defineReadOnly)(this, "provider", provider);
  37872. (0, properties_1.defineReadOnly)(this, "name", name);
  37873. (0, properties_1.defineReadOnly)(this, "address", provider.formatter.address(address));
  37874. (0, properties_1.defineReadOnly)(this, "_resolvedAddress", resolvedAddress);
  37875. }
  37876. Resolver.prototype.supportsWildcard = function () {
  37877. var _this = this;
  37878. if (!this._supportsEip2544) {
  37879. // supportsInterface(bytes4 = selector("resolve(bytes,bytes)"))
  37880. this._supportsEip2544 = this.provider.call({
  37881. to: this.address,
  37882. data: "0x01ffc9a79061b92300000000000000000000000000000000000000000000000000000000"
  37883. }).then(function (result) {
  37884. return bignumber_1.BigNumber.from(result).eq(1);
  37885. }).catch(function (error) {
  37886. if (error.code === logger_1.Logger.errors.CALL_EXCEPTION) {
  37887. return false;
  37888. }
  37889. // Rethrow the error: link is down, etc. Let future attempts retry.
  37890. _this._supportsEip2544 = null;
  37891. throw error;
  37892. });
  37893. }
  37894. return this._supportsEip2544;
  37895. };
  37896. Resolver.prototype._fetch = function (selector, parameters) {
  37897. return __awaiter(this, void 0, void 0, function () {
  37898. var tx, parseBytes, result, error_1;
  37899. return __generator(this, function (_a) {
  37900. switch (_a.label) {
  37901. case 0:
  37902. tx = {
  37903. to: this.address,
  37904. ccipReadEnabled: true,
  37905. data: (0, bytes_1.hexConcat)([selector, (0, hash_1.namehash)(this.name), (parameters || "0x")])
  37906. };
  37907. parseBytes = false;
  37908. return [4 /*yield*/, this.supportsWildcard()];
  37909. case 1:
  37910. if (_a.sent()) {
  37911. parseBytes = true;
  37912. // selector("resolve(bytes,bytes)")
  37913. tx.data = (0, bytes_1.hexConcat)(["0x9061b923", encodeBytes([(0, hash_1.dnsEncode)(this.name), tx.data])]);
  37914. }
  37915. _a.label = 2;
  37916. case 2:
  37917. _a.trys.push([2, 4, , 5]);
  37918. return [4 /*yield*/, this.provider.call(tx)];
  37919. case 3:
  37920. result = _a.sent();
  37921. if (((0, bytes_1.arrayify)(result).length % 32) === 4) {
  37922. logger.throwError("resolver threw error", logger_1.Logger.errors.CALL_EXCEPTION, {
  37923. transaction: tx, data: result
  37924. });
  37925. }
  37926. if (parseBytes) {
  37927. result = _parseBytes(result, 0);
  37928. }
  37929. return [2 /*return*/, result];
  37930. case 4:
  37931. error_1 = _a.sent();
  37932. if (error_1.code === logger_1.Logger.errors.CALL_EXCEPTION) {
  37933. return [2 /*return*/, null];
  37934. }
  37935. throw error_1;
  37936. case 5: return [2 /*return*/];
  37937. }
  37938. });
  37939. });
  37940. };
  37941. Resolver.prototype._fetchBytes = function (selector, parameters) {
  37942. return __awaiter(this, void 0, void 0, function () {
  37943. var result;
  37944. return __generator(this, function (_a) {
  37945. switch (_a.label) {
  37946. case 0: return [4 /*yield*/, this._fetch(selector, parameters)];
  37947. case 1:
  37948. result = _a.sent();
  37949. if (result != null) {
  37950. return [2 /*return*/, _parseBytes(result, 0)];
  37951. }
  37952. return [2 /*return*/, null];
  37953. }
  37954. });
  37955. });
  37956. };
  37957. Resolver.prototype._getAddress = function (coinType, hexBytes) {
  37958. var coinInfo = coinInfos[String(coinType)];
  37959. if (coinInfo == null) {
  37960. logger.throwError("unsupported coin type: " + coinType, logger_1.Logger.errors.UNSUPPORTED_OPERATION, {
  37961. operation: "getAddress(" + coinType + ")"
  37962. });
  37963. }
  37964. if (coinInfo.ilk === "eth") {
  37965. return this.provider.formatter.address(hexBytes);
  37966. }
  37967. var bytes = (0, bytes_1.arrayify)(hexBytes);
  37968. // P2PKH: OP_DUP OP_HASH160 <pubKeyHash> OP_EQUALVERIFY OP_CHECKSIG
  37969. if (coinInfo.p2pkh != null) {
  37970. var p2pkh = hexBytes.match(/^0x76a9([0-9a-f][0-9a-f])([0-9a-f]*)88ac$/);
  37971. if (p2pkh) {
  37972. var length_1 = parseInt(p2pkh[1], 16);
  37973. if (p2pkh[2].length === length_1 * 2 && length_1 >= 1 && length_1 <= 75) {
  37974. return base58Encode((0, bytes_1.concat)([[coinInfo.p2pkh], ("0x" + p2pkh[2])]));
  37975. }
  37976. }
  37977. }
  37978. // P2SH: OP_HASH160 <scriptHash> OP_EQUAL
  37979. if (coinInfo.p2sh != null) {
  37980. var p2sh = hexBytes.match(/^0xa9([0-9a-f][0-9a-f])([0-9a-f]*)87$/);
  37981. if (p2sh) {
  37982. var length_2 = parseInt(p2sh[1], 16);
  37983. if (p2sh[2].length === length_2 * 2 && length_2 >= 1 && length_2 <= 75) {
  37984. return base58Encode((0, bytes_1.concat)([[coinInfo.p2sh], ("0x" + p2sh[2])]));
  37985. }
  37986. }
  37987. }
  37988. // Bech32
  37989. if (coinInfo.prefix != null) {
  37990. var length_3 = bytes[1];
  37991. // https://github.com/bitcoin/bips/blob/master/bip-0141.mediawiki#witness-program
  37992. var version_1 = bytes[0];
  37993. if (version_1 === 0x00) {
  37994. if (length_3 !== 20 && length_3 !== 32) {
  37995. version_1 = -1;
  37996. }
  37997. }
  37998. else {
  37999. version_1 = -1;
  38000. }
  38001. if (version_1 >= 0 && bytes.length === 2 + length_3 && length_3 >= 1 && length_3 <= 75) {
  38002. var words = bech32_1.default.toWords(bytes.slice(2));
  38003. words.unshift(version_1);
  38004. return bech32_1.default.encode(coinInfo.prefix, words);
  38005. }
  38006. }
  38007. return null;
  38008. };
  38009. Resolver.prototype.getAddress = function (coinType) {
  38010. return __awaiter(this, void 0, void 0, function () {
  38011. var result, error_2, hexBytes, address;
  38012. return __generator(this, function (_a) {
  38013. switch (_a.label) {
  38014. case 0:
  38015. if (coinType == null) {
  38016. coinType = 60;
  38017. }
  38018. if (!(coinType === 60)) return [3 /*break*/, 4];
  38019. _a.label = 1;
  38020. case 1:
  38021. _a.trys.push([1, 3, , 4]);
  38022. return [4 /*yield*/, this._fetch("0x3b3b57de")];
  38023. case 2:
  38024. result = _a.sent();
  38025. // No address
  38026. if (result === "0x" || result === constants_1.HashZero) {
  38027. return [2 /*return*/, null];
  38028. }
  38029. return [2 /*return*/, this.provider.formatter.callAddress(result)];
  38030. case 3:
  38031. error_2 = _a.sent();
  38032. if (error_2.code === logger_1.Logger.errors.CALL_EXCEPTION) {
  38033. return [2 /*return*/, null];
  38034. }
  38035. throw error_2;
  38036. case 4: return [4 /*yield*/, this._fetchBytes("0xf1cb7e06", bytes32ify(coinType))];
  38037. case 5:
  38038. hexBytes = _a.sent();
  38039. // No address
  38040. if (hexBytes == null || hexBytes === "0x") {
  38041. return [2 /*return*/, null];
  38042. }
  38043. address = this._getAddress(coinType, hexBytes);
  38044. if (address == null) {
  38045. logger.throwError("invalid or unsupported coin data", logger_1.Logger.errors.UNSUPPORTED_OPERATION, {
  38046. operation: "getAddress(" + coinType + ")",
  38047. coinType: coinType,
  38048. data: hexBytes
  38049. });
  38050. }
  38051. return [2 /*return*/, address];
  38052. }
  38053. });
  38054. });
  38055. };
  38056. Resolver.prototype.getAvatar = function () {
  38057. return __awaiter(this, void 0, void 0, function () {
  38058. var linkage, avatar, i, match, scheme, _a, selector, owner, _b, comps, addr, tokenId, tokenOwner, _c, _d, balance, _e, _f, tx, metadataUrl, _g, metadata, imageUrl, ipfs, error_3;
  38059. return __generator(this, function (_h) {
  38060. switch (_h.label) {
  38061. case 0:
  38062. linkage = [{ type: "name", content: this.name }];
  38063. _h.label = 1;
  38064. case 1:
  38065. _h.trys.push([1, 19, , 20]);
  38066. return [4 /*yield*/, this.getText("avatar")];
  38067. case 2:
  38068. avatar = _h.sent();
  38069. if (avatar == null) {
  38070. return [2 /*return*/, null];
  38071. }
  38072. i = 0;
  38073. _h.label = 3;
  38074. case 3:
  38075. if (!(i < matchers.length)) return [3 /*break*/, 18];
  38076. match = avatar.match(matchers[i]);
  38077. if (match == null) {
  38078. return [3 /*break*/, 17];
  38079. }
  38080. scheme = match[1].toLowerCase();
  38081. _a = scheme;
  38082. switch (_a) {
  38083. case "https": return [3 /*break*/, 4];
  38084. case "data": return [3 /*break*/, 5];
  38085. case "ipfs": return [3 /*break*/, 6];
  38086. case "erc721": return [3 /*break*/, 7];
  38087. case "erc1155": return [3 /*break*/, 7];
  38088. }
  38089. return [3 /*break*/, 17];
  38090. case 4:
  38091. linkage.push({ type: "url", content: avatar });
  38092. return [2 /*return*/, { linkage: linkage, url: avatar }];
  38093. case 5:
  38094. linkage.push({ type: "data", content: avatar });
  38095. return [2 /*return*/, { linkage: linkage, url: avatar }];
  38096. case 6:
  38097. linkage.push({ type: "ipfs", content: avatar });
  38098. return [2 /*return*/, { linkage: linkage, url: getIpfsLink(avatar) }];
  38099. case 7:
  38100. selector = (scheme === "erc721") ? "0xc87b56dd" : "0x0e89341c";
  38101. linkage.push({ type: scheme, content: avatar });
  38102. _b = this._resolvedAddress;
  38103. if (_b) return [3 /*break*/, 9];
  38104. return [4 /*yield*/, this.getAddress()];
  38105. case 8:
  38106. _b = (_h.sent());
  38107. _h.label = 9;
  38108. case 9:
  38109. owner = (_b);
  38110. comps = (match[2] || "").split("/");
  38111. if (comps.length !== 2) {
  38112. return [2 /*return*/, null];
  38113. }
  38114. return [4 /*yield*/, this.provider.formatter.address(comps[0])];
  38115. case 10:
  38116. addr = _h.sent();
  38117. tokenId = (0, bytes_1.hexZeroPad)(bignumber_1.BigNumber.from(comps[1]).toHexString(), 32);
  38118. if (!(scheme === "erc721")) return [3 /*break*/, 12];
  38119. _d = (_c = this.provider.formatter).callAddress;
  38120. return [4 /*yield*/, this.provider.call({
  38121. to: addr, data: (0, bytes_1.hexConcat)(["0x6352211e", tokenId])
  38122. })];
  38123. case 11:
  38124. tokenOwner = _d.apply(_c, [_h.sent()]);
  38125. if (owner !== tokenOwner) {
  38126. return [2 /*return*/, null];
  38127. }
  38128. linkage.push({ type: "owner", content: tokenOwner });
  38129. return [3 /*break*/, 14];
  38130. case 12:
  38131. if (!(scheme === "erc1155")) return [3 /*break*/, 14];
  38132. _f = (_e = bignumber_1.BigNumber).from;
  38133. return [4 /*yield*/, this.provider.call({
  38134. to: addr, data: (0, bytes_1.hexConcat)(["0x00fdd58e", (0, bytes_1.hexZeroPad)(owner, 32), tokenId])
  38135. })];
  38136. case 13:
  38137. balance = _f.apply(_e, [_h.sent()]);
  38138. if (balance.isZero()) {
  38139. return [2 /*return*/, null];
  38140. }
  38141. linkage.push({ type: "balance", content: balance.toString() });
  38142. _h.label = 14;
  38143. case 14:
  38144. tx = {
  38145. to: this.provider.formatter.address(comps[0]),
  38146. data: (0, bytes_1.hexConcat)([selector, tokenId])
  38147. };
  38148. _g = _parseString;
  38149. return [4 /*yield*/, this.provider.call(tx)];
  38150. case 15:
  38151. metadataUrl = _g.apply(void 0, [_h.sent(), 0]);
  38152. if (metadataUrl == null) {
  38153. return [2 /*return*/, null];
  38154. }
  38155. linkage.push({ type: "metadata-url-base", content: metadataUrl });
  38156. // ERC-1155 allows a generic {id} in the URL
  38157. if (scheme === "erc1155") {
  38158. metadataUrl = metadataUrl.replace("{id}", tokenId.substring(2));
  38159. linkage.push({ type: "metadata-url-expanded", content: metadataUrl });
  38160. }
  38161. // Transform IPFS metadata links
  38162. if (metadataUrl.match(/^ipfs:/i)) {
  38163. metadataUrl = getIpfsLink(metadataUrl);
  38164. }
  38165. linkage.push({ type: "metadata-url", content: metadataUrl });
  38166. return [4 /*yield*/, (0, web_1.fetchJson)(metadataUrl)];
  38167. case 16:
  38168. metadata = _h.sent();
  38169. if (!metadata) {
  38170. return [2 /*return*/, null];
  38171. }
  38172. linkage.push({ type: "metadata", content: JSON.stringify(metadata) });
  38173. imageUrl = metadata.image;
  38174. if (typeof (imageUrl) !== "string") {
  38175. return [2 /*return*/, null];
  38176. }
  38177. if (imageUrl.match(/^(https:\/\/|data:)/i)) {
  38178. // Allow
  38179. }
  38180. else {
  38181. ipfs = imageUrl.match(matcherIpfs);
  38182. if (ipfs == null) {
  38183. return [2 /*return*/, null];
  38184. }
  38185. linkage.push({ type: "url-ipfs", content: imageUrl });
  38186. imageUrl = getIpfsLink(imageUrl);
  38187. }
  38188. linkage.push({ type: "url", content: imageUrl });
  38189. return [2 /*return*/, { linkage: linkage, url: imageUrl }];
  38190. case 17:
  38191. i++;
  38192. return [3 /*break*/, 3];
  38193. case 18: return [3 /*break*/, 20];
  38194. case 19:
  38195. error_3 = _h.sent();
  38196. return [3 /*break*/, 20];
  38197. case 20: return [2 /*return*/, null];
  38198. }
  38199. });
  38200. });
  38201. };
  38202. Resolver.prototype.getContentHash = function () {
  38203. return __awaiter(this, void 0, void 0, function () {
  38204. var hexBytes, ipfs, length_4, swarm;
  38205. return __generator(this, function (_a) {
  38206. switch (_a.label) {
  38207. case 0: return [4 /*yield*/, this._fetchBytes("0xbc1c58d1")];
  38208. case 1:
  38209. hexBytes = _a.sent();
  38210. // No contenthash
  38211. if (hexBytes == null || hexBytes === "0x") {
  38212. return [2 /*return*/, null];
  38213. }
  38214. ipfs = hexBytes.match(/^0xe3010170(([0-9a-f][0-9a-f])([0-9a-f][0-9a-f])([0-9a-f]*))$/);
  38215. if (ipfs) {
  38216. length_4 = parseInt(ipfs[3], 16);
  38217. if (ipfs[4].length === length_4 * 2) {
  38218. return [2 /*return*/, "ipfs:/\/" + basex_1.Base58.encode("0x" + ipfs[1])];
  38219. }
  38220. }
  38221. swarm = hexBytes.match(/^0xe40101fa011b20([0-9a-f]*)$/);
  38222. if (swarm) {
  38223. if (swarm[1].length === (32 * 2)) {
  38224. return [2 /*return*/, "bzz:/\/" + swarm[1]];
  38225. }
  38226. }
  38227. return [2 /*return*/, logger.throwError("invalid or unsupported content hash data", logger_1.Logger.errors.UNSUPPORTED_OPERATION, {
  38228. operation: "getContentHash()",
  38229. data: hexBytes
  38230. })];
  38231. }
  38232. });
  38233. });
  38234. };
  38235. Resolver.prototype.getText = function (key) {
  38236. return __awaiter(this, void 0, void 0, function () {
  38237. var keyBytes, hexBytes;
  38238. return __generator(this, function (_a) {
  38239. switch (_a.label) {
  38240. case 0:
  38241. keyBytes = (0, strings_1.toUtf8Bytes)(key);
  38242. // The nodehash consumes the first slot, so the string pointer targets
  38243. // offset 64, with the length at offset 64 and data starting at offset 96
  38244. keyBytes = (0, bytes_1.concat)([bytes32ify(64), bytes32ify(keyBytes.length), keyBytes]);
  38245. // Pad to word-size (32 bytes)
  38246. if ((keyBytes.length % 32) !== 0) {
  38247. keyBytes = (0, bytes_1.concat)([keyBytes, (0, bytes_1.hexZeroPad)("0x", 32 - (key.length % 32))]);
  38248. }
  38249. return [4 /*yield*/, this._fetchBytes("0x59d1d43c", (0, bytes_1.hexlify)(keyBytes))];
  38250. case 1:
  38251. hexBytes = _a.sent();
  38252. if (hexBytes == null || hexBytes === "0x") {
  38253. return [2 /*return*/, null];
  38254. }
  38255. return [2 /*return*/, (0, strings_1.toUtf8String)(hexBytes)];
  38256. }
  38257. });
  38258. });
  38259. };
  38260. return Resolver;
  38261. }());
  38262. exports.Resolver = Resolver;
  38263. var defaultFormatter = null;
  38264. var nextPollId = 1;
  38265. var BaseProvider = /** @class */ (function (_super) {
  38266. __extends(BaseProvider, _super);
  38267. /**
  38268. * ready
  38269. *
  38270. * A Promise<Network> that resolves only once the provider is ready.
  38271. *
  38272. * Sub-classes that call the super with a network without a chainId
  38273. * MUST set this. Standard named networks have a known chainId.
  38274. *
  38275. */
  38276. function BaseProvider(network) {
  38277. var _newTarget = this.constructor;
  38278. var _this = this;
  38279. logger.checkNew(_newTarget, abstract_provider_1.Provider);
  38280. _this = _super.call(this) || this;
  38281. // Events being listened to
  38282. _this._events = [];
  38283. _this._emitted = { block: -2 };
  38284. _this.disableCcipRead = false;
  38285. _this.formatter = _newTarget.getFormatter();
  38286. // If network is any, this Provider allows the underlying
  38287. // network to change dynamically, and we auto-detect the
  38288. // current network
  38289. (0, properties_1.defineReadOnly)(_this, "anyNetwork", (network === "any"));
  38290. if (_this.anyNetwork) {
  38291. network = _this.detectNetwork();
  38292. }
  38293. if (network instanceof Promise) {
  38294. _this._networkPromise = network;
  38295. // Squash any "unhandled promise" errors; that do not need to be handled
  38296. network.catch(function (error) { });
  38297. // Trigger initial network setting (async)
  38298. _this._ready().catch(function (error) { });
  38299. }
  38300. else {
  38301. var knownNetwork = (0, properties_1.getStatic)(_newTarget, "getNetwork")(network);
  38302. if (knownNetwork) {
  38303. (0, properties_1.defineReadOnly)(_this, "_network", knownNetwork);
  38304. _this.emit("network", knownNetwork, null);
  38305. }
  38306. else {
  38307. logger.throwArgumentError("invalid network", "network", network);
  38308. }
  38309. }
  38310. _this._maxInternalBlockNumber = -1024;
  38311. _this._lastBlockNumber = -2;
  38312. _this._maxFilterBlockRange = 10;
  38313. _this._pollingInterval = 4000;
  38314. _this._fastQueryDate = 0;
  38315. return _this;
  38316. }
  38317. BaseProvider.prototype._ready = function () {
  38318. return __awaiter(this, void 0, void 0, function () {
  38319. var network, error_4;
  38320. return __generator(this, function (_a) {
  38321. switch (_a.label) {
  38322. case 0:
  38323. if (!(this._network == null)) return [3 /*break*/, 7];
  38324. network = null;
  38325. if (!this._networkPromise) return [3 /*break*/, 4];
  38326. _a.label = 1;
  38327. case 1:
  38328. _a.trys.push([1, 3, , 4]);
  38329. return [4 /*yield*/, this._networkPromise];
  38330. case 2:
  38331. network = _a.sent();
  38332. return [3 /*break*/, 4];
  38333. case 3:
  38334. error_4 = _a.sent();
  38335. return [3 /*break*/, 4];
  38336. case 4:
  38337. if (!(network == null)) return [3 /*break*/, 6];
  38338. return [4 /*yield*/, this.detectNetwork()];
  38339. case 5:
  38340. network = _a.sent();
  38341. _a.label = 6;
  38342. case 6:
  38343. // This should never happen; every Provider sub-class should have
  38344. // suggested a network by here (or have thrown).
  38345. if (!network) {
  38346. logger.throwError("no network detected", logger_1.Logger.errors.UNKNOWN_ERROR, {});
  38347. }
  38348. // Possible this call stacked so do not call defineReadOnly again
  38349. if (this._network == null) {
  38350. if (this.anyNetwork) {
  38351. this._network = network;
  38352. }
  38353. else {
  38354. (0, properties_1.defineReadOnly)(this, "_network", network);
  38355. }
  38356. this.emit("network", network, null);
  38357. }
  38358. _a.label = 7;
  38359. case 7: return [2 /*return*/, this._network];
  38360. }
  38361. });
  38362. });
  38363. };
  38364. Object.defineProperty(BaseProvider.prototype, "ready", {
  38365. // This will always return the most recently established network.
  38366. // For "any", this can change (a "network" event is emitted before
  38367. // any change is reflected); otherwise this cannot change
  38368. get: function () {
  38369. var _this = this;
  38370. return (0, web_1.poll)(function () {
  38371. return _this._ready().then(function (network) {
  38372. return network;
  38373. }, function (error) {
  38374. // If the network isn't running yet, we will wait
  38375. if (error.code === logger_1.Logger.errors.NETWORK_ERROR && error.event === "noNetwork") {
  38376. return undefined;
  38377. }
  38378. throw error;
  38379. });
  38380. });
  38381. },
  38382. enumerable: false,
  38383. configurable: true
  38384. });
  38385. // @TODO: Remove this and just create a singleton formatter
  38386. BaseProvider.getFormatter = function () {
  38387. if (defaultFormatter == null) {
  38388. defaultFormatter = new formatter_1.Formatter();
  38389. }
  38390. return defaultFormatter;
  38391. };
  38392. // @TODO: Remove this and just use getNetwork
  38393. BaseProvider.getNetwork = function (network) {
  38394. return (0, networks_1.getNetwork)((network == null) ? "homestead" : network);
  38395. };
  38396. BaseProvider.prototype.ccipReadFetch = function (tx, calldata, urls) {
  38397. return __awaiter(this, void 0, void 0, function () {
  38398. var sender, data, errorMessages, i, url, href, json, result, errorMessage;
  38399. return __generator(this, function (_a) {
  38400. switch (_a.label) {
  38401. case 0:
  38402. if (this.disableCcipRead || urls.length === 0) {
  38403. return [2 /*return*/, null];
  38404. }
  38405. sender = (tx.from || "0x0000000000000000000000000000000000000000").toLowerCase();
  38406. data = calldata.toLowerCase();
  38407. errorMessages = [];
  38408. i = 0;
  38409. _a.label = 1;
  38410. case 1:
  38411. if (!(i < urls.length)) return [3 /*break*/, 4];
  38412. url = urls[i];
  38413. href = url.replace("{sender}", sender).replace("{data}", data);
  38414. json = (url.indexOf("{data}") >= 0) ? null : JSON.stringify({ data: data, sender: sender });
  38415. return [4 /*yield*/, (0, web_1.fetchJson)({ url: href, errorPassThrough: true }, json, function (value, response) {
  38416. value.status = response.statusCode;
  38417. return value;
  38418. })];
  38419. case 2:
  38420. result = _a.sent();
  38421. if (result.data) {
  38422. return [2 /*return*/, result.data];
  38423. }
  38424. errorMessage = (result.message || "unknown error");
  38425. // 4xx indicates the result is not present; stop
  38426. if (result.status >= 400 && result.status < 500) {
  38427. return [2 /*return*/, logger.throwError("response not found during CCIP fetch: " + errorMessage, logger_1.Logger.errors.SERVER_ERROR, { url: url, errorMessage: errorMessage })];
  38428. }
  38429. // 5xx indicates server issue; try the next url
  38430. errorMessages.push(errorMessage);
  38431. _a.label = 3;
  38432. case 3:
  38433. i++;
  38434. return [3 /*break*/, 1];
  38435. case 4: return [2 /*return*/, logger.throwError("error encountered during CCIP fetch: " + errorMessages.map(function (m) { return JSON.stringify(m); }).join(", "), logger_1.Logger.errors.SERVER_ERROR, {
  38436. urls: urls,
  38437. errorMessages: errorMessages
  38438. })];
  38439. }
  38440. });
  38441. });
  38442. };
  38443. // Fetches the blockNumber, but will reuse any result that is less
  38444. // than maxAge old or has been requested since the last request
  38445. BaseProvider.prototype._getInternalBlockNumber = function (maxAge) {
  38446. return __awaiter(this, void 0, void 0, function () {
  38447. var internalBlockNumber, result, error_5, reqTime, checkInternalBlockNumber;
  38448. var _this = this;
  38449. return __generator(this, function (_a) {
  38450. switch (_a.label) {
  38451. case 0: return [4 /*yield*/, this._ready()];
  38452. case 1:
  38453. _a.sent();
  38454. if (!(maxAge > 0)) return [3 /*break*/, 7];
  38455. _a.label = 2;
  38456. case 2:
  38457. if (!this._internalBlockNumber) return [3 /*break*/, 7];
  38458. internalBlockNumber = this._internalBlockNumber;
  38459. _a.label = 3;
  38460. case 3:
  38461. _a.trys.push([3, 5, , 6]);
  38462. return [4 /*yield*/, internalBlockNumber];
  38463. case 4:
  38464. result = _a.sent();
  38465. if ((getTime() - result.respTime) <= maxAge) {
  38466. return [2 /*return*/, result.blockNumber];
  38467. }
  38468. // Too old; fetch a new value
  38469. return [3 /*break*/, 7];
  38470. case 5:
  38471. error_5 = _a.sent();
  38472. // The fetch rejected; if we are the first to get the
  38473. // rejection, drop through so we replace it with a new
  38474. // fetch; all others blocked will then get that fetch
  38475. // which won't match the one they "remembered" and loop
  38476. if (this._internalBlockNumber === internalBlockNumber) {
  38477. return [3 /*break*/, 7];
  38478. }
  38479. return [3 /*break*/, 6];
  38480. case 6: return [3 /*break*/, 2];
  38481. case 7:
  38482. reqTime = getTime();
  38483. checkInternalBlockNumber = (0, properties_1.resolveProperties)({
  38484. blockNumber: this.perform("getBlockNumber", {}),
  38485. networkError: this.getNetwork().then(function (network) { return (null); }, function (error) { return (error); })
  38486. }).then(function (_a) {
  38487. var blockNumber = _a.blockNumber, networkError = _a.networkError;
  38488. if (networkError) {
  38489. // Unremember this bad internal block number
  38490. if (_this._internalBlockNumber === checkInternalBlockNumber) {
  38491. _this._internalBlockNumber = null;
  38492. }
  38493. throw networkError;
  38494. }
  38495. var respTime = getTime();
  38496. blockNumber = bignumber_1.BigNumber.from(blockNumber).toNumber();
  38497. if (blockNumber < _this._maxInternalBlockNumber) {
  38498. blockNumber = _this._maxInternalBlockNumber;
  38499. }
  38500. _this._maxInternalBlockNumber = blockNumber;
  38501. _this._setFastBlockNumber(blockNumber); // @TODO: Still need this?
  38502. return { blockNumber: blockNumber, reqTime: reqTime, respTime: respTime };
  38503. });
  38504. this._internalBlockNumber = checkInternalBlockNumber;
  38505. // Swallow unhandled exceptions; if needed they are handled else where
  38506. checkInternalBlockNumber.catch(function (error) {
  38507. // Don't null the dead (rejected) fetch, if it has already been updated
  38508. if (_this._internalBlockNumber === checkInternalBlockNumber) {
  38509. _this._internalBlockNumber = null;
  38510. }
  38511. });
  38512. return [4 /*yield*/, checkInternalBlockNumber];
  38513. case 8: return [2 /*return*/, (_a.sent()).blockNumber];
  38514. }
  38515. });
  38516. });
  38517. };
  38518. BaseProvider.prototype.poll = function () {
  38519. return __awaiter(this, void 0, void 0, function () {
  38520. var pollId, runners, blockNumber, error_6, i;
  38521. var _this = this;
  38522. return __generator(this, function (_a) {
  38523. switch (_a.label) {
  38524. case 0:
  38525. pollId = nextPollId++;
  38526. runners = [];
  38527. blockNumber = null;
  38528. _a.label = 1;
  38529. case 1:
  38530. _a.trys.push([1, 3, , 4]);
  38531. return [4 /*yield*/, this._getInternalBlockNumber(100 + this.pollingInterval / 2)];
  38532. case 2:
  38533. blockNumber = _a.sent();
  38534. return [3 /*break*/, 4];
  38535. case 3:
  38536. error_6 = _a.sent();
  38537. this.emit("error", error_6);
  38538. return [2 /*return*/];
  38539. case 4:
  38540. this._setFastBlockNumber(blockNumber);
  38541. // Emit a poll event after we have the latest (fast) block number
  38542. this.emit("poll", pollId, blockNumber);
  38543. // If the block has not changed, meh.
  38544. if (blockNumber === this._lastBlockNumber) {
  38545. this.emit("didPoll", pollId);
  38546. return [2 /*return*/];
  38547. }
  38548. // First polling cycle, trigger a "block" events
  38549. if (this._emitted.block === -2) {
  38550. this._emitted.block = blockNumber - 1;
  38551. }
  38552. if (Math.abs((this._emitted.block) - blockNumber) > 1000) {
  38553. logger.warn("network block skew detected; skipping block events (emitted=" + this._emitted.block + " blockNumber" + blockNumber + ")");
  38554. this.emit("error", logger.makeError("network block skew detected", logger_1.Logger.errors.NETWORK_ERROR, {
  38555. blockNumber: blockNumber,
  38556. event: "blockSkew",
  38557. previousBlockNumber: this._emitted.block
  38558. }));
  38559. this.emit("block", blockNumber);
  38560. }
  38561. else {
  38562. // Notify all listener for each block that has passed
  38563. for (i = this._emitted.block + 1; i <= blockNumber; i++) {
  38564. this.emit("block", i);
  38565. }
  38566. }
  38567. // The emitted block was updated, check for obsolete events
  38568. if (this._emitted.block !== blockNumber) {
  38569. this._emitted.block = blockNumber;
  38570. Object.keys(this._emitted).forEach(function (key) {
  38571. // The block event does not expire
  38572. if (key === "block") {
  38573. return;
  38574. }
  38575. // The block we were at when we emitted this event
  38576. var eventBlockNumber = _this._emitted[key];
  38577. // We cannot garbage collect pending transactions or blocks here
  38578. // They should be garbage collected by the Provider when setting
  38579. // "pending" events
  38580. if (eventBlockNumber === "pending") {
  38581. return;
  38582. }
  38583. // Evict any transaction hashes or block hashes over 12 blocks
  38584. // old, since they should not return null anyways
  38585. if (blockNumber - eventBlockNumber > 12) {
  38586. delete _this._emitted[key];
  38587. }
  38588. });
  38589. }
  38590. // First polling cycle
  38591. if (this._lastBlockNumber === -2) {
  38592. this._lastBlockNumber = blockNumber - 1;
  38593. }
  38594. // Find all transaction hashes we are waiting on
  38595. this._events.forEach(function (event) {
  38596. switch (event.type) {
  38597. case "tx": {
  38598. var hash_2 = event.hash;
  38599. var runner = _this.getTransactionReceipt(hash_2).then(function (receipt) {
  38600. if (!receipt || receipt.blockNumber == null) {
  38601. return null;
  38602. }
  38603. _this._emitted["t:" + hash_2] = receipt.blockNumber;
  38604. _this.emit(hash_2, receipt);
  38605. return null;
  38606. }).catch(function (error) { _this.emit("error", error); });
  38607. runners.push(runner);
  38608. break;
  38609. }
  38610. case "filter": {
  38611. // We only allow a single getLogs to be in-flight at a time
  38612. if (!event._inflight) {
  38613. event._inflight = true;
  38614. // Filter from the last known event; due to load-balancing
  38615. // and some nodes returning updated block numbers before
  38616. // indexing events, a logs result with 0 entries cannot be
  38617. // trusted and we must retry a range which includes it again
  38618. var filter_1 = event.filter;
  38619. filter_1.fromBlock = event._lastBlockNumber + 1;
  38620. filter_1.toBlock = blockNumber;
  38621. // Prevent fitler ranges from growing too wild
  38622. if (filter_1.toBlock - _this._maxFilterBlockRange > filter_1.fromBlock) {
  38623. filter_1.fromBlock = filter_1.toBlock - _this._maxFilterBlockRange;
  38624. }
  38625. var runner = _this.getLogs(filter_1).then(function (logs) {
  38626. // Allow the next getLogs
  38627. event._inflight = false;
  38628. if (logs.length === 0) {
  38629. return;
  38630. }
  38631. logs.forEach(function (log) {
  38632. // Only when we get an event for a given block number
  38633. // can we trust the events are indexed
  38634. if (log.blockNumber > event._lastBlockNumber) {
  38635. event._lastBlockNumber = log.blockNumber;
  38636. }
  38637. // Make sure we stall requests to fetch blocks and txs
  38638. _this._emitted["b:" + log.blockHash] = log.blockNumber;
  38639. _this._emitted["t:" + log.transactionHash] = log.blockNumber;
  38640. _this.emit(filter_1, log);
  38641. });
  38642. }).catch(function (error) {
  38643. _this.emit("error", error);
  38644. // Allow another getLogs (the range was not updated)
  38645. event._inflight = false;
  38646. });
  38647. runners.push(runner);
  38648. }
  38649. break;
  38650. }
  38651. }
  38652. });
  38653. this._lastBlockNumber = blockNumber;
  38654. // Once all events for this loop have been processed, emit "didPoll"
  38655. Promise.all(runners).then(function () {
  38656. _this.emit("didPoll", pollId);
  38657. }).catch(function (error) { _this.emit("error", error); });
  38658. return [2 /*return*/];
  38659. }
  38660. });
  38661. });
  38662. };
  38663. // Deprecated; do not use this
  38664. BaseProvider.prototype.resetEventsBlock = function (blockNumber) {
  38665. this._lastBlockNumber = blockNumber - 1;
  38666. if (this.polling) {
  38667. this.poll();
  38668. }
  38669. };
  38670. Object.defineProperty(BaseProvider.prototype, "network", {
  38671. get: function () {
  38672. return this._network;
  38673. },
  38674. enumerable: false,
  38675. configurable: true
  38676. });
  38677. // This method should query the network if the underlying network
  38678. // can change, such as when connected to a JSON-RPC backend
  38679. BaseProvider.prototype.detectNetwork = function () {
  38680. return __awaiter(this, void 0, void 0, function () {
  38681. return __generator(this, function (_a) {
  38682. return [2 /*return*/, logger.throwError("provider does not support network detection", logger_1.Logger.errors.UNSUPPORTED_OPERATION, {
  38683. operation: "provider.detectNetwork"
  38684. })];
  38685. });
  38686. });
  38687. };
  38688. BaseProvider.prototype.getNetwork = function () {
  38689. return __awaiter(this, void 0, void 0, function () {
  38690. var network, currentNetwork, error;
  38691. return __generator(this, function (_a) {
  38692. switch (_a.label) {
  38693. case 0: return [4 /*yield*/, this._ready()];
  38694. case 1:
  38695. network = _a.sent();
  38696. return [4 /*yield*/, this.detectNetwork()];
  38697. case 2:
  38698. currentNetwork = _a.sent();
  38699. if (!(network.chainId !== currentNetwork.chainId)) return [3 /*break*/, 5];
  38700. if (!this.anyNetwork) return [3 /*break*/, 4];
  38701. this._network = currentNetwork;
  38702. // Reset all internal block number guards and caches
  38703. this._lastBlockNumber = -2;
  38704. this._fastBlockNumber = null;
  38705. this._fastBlockNumberPromise = null;
  38706. this._fastQueryDate = 0;
  38707. this._emitted.block = -2;
  38708. this._maxInternalBlockNumber = -1024;
  38709. this._internalBlockNumber = null;
  38710. // The "network" event MUST happen before this method resolves
  38711. // so any events have a chance to unregister, so we stall an
  38712. // additional event loop before returning from /this/ call
  38713. this.emit("network", currentNetwork, network);
  38714. return [4 /*yield*/, stall(0)];
  38715. case 3:
  38716. _a.sent();
  38717. return [2 /*return*/, this._network];
  38718. case 4:
  38719. error = logger.makeError("underlying network changed", logger_1.Logger.errors.NETWORK_ERROR, {
  38720. event: "changed",
  38721. network: network,
  38722. detectedNetwork: currentNetwork
  38723. });
  38724. this.emit("error", error);
  38725. throw error;
  38726. case 5: return [2 /*return*/, network];
  38727. }
  38728. });
  38729. });
  38730. };
  38731. Object.defineProperty(BaseProvider.prototype, "blockNumber", {
  38732. get: function () {
  38733. var _this = this;
  38734. this._getInternalBlockNumber(100 + this.pollingInterval / 2).then(function (blockNumber) {
  38735. _this._setFastBlockNumber(blockNumber);
  38736. }, function (error) { });
  38737. return (this._fastBlockNumber != null) ? this._fastBlockNumber : -1;
  38738. },
  38739. enumerable: false,
  38740. configurable: true
  38741. });
  38742. Object.defineProperty(BaseProvider.prototype, "polling", {
  38743. get: function () {
  38744. return (this._poller != null);
  38745. },
  38746. set: function (value) {
  38747. var _this = this;
  38748. if (value && !this._poller) {
  38749. this._poller = setInterval(function () { _this.poll(); }, this.pollingInterval);
  38750. if (!this._bootstrapPoll) {
  38751. this._bootstrapPoll = setTimeout(function () {
  38752. _this.poll();
  38753. // We block additional polls until the polling interval
  38754. // is done, to prevent overwhelming the poll function
  38755. _this._bootstrapPoll = setTimeout(function () {
  38756. // If polling was disabled, something may require a poke
  38757. // since starting the bootstrap poll and it was disabled
  38758. if (!_this._poller) {
  38759. _this.poll();
  38760. }
  38761. // Clear out the bootstrap so we can do another
  38762. _this._bootstrapPoll = null;
  38763. }, _this.pollingInterval);
  38764. }, 0);
  38765. }
  38766. }
  38767. else if (!value && this._poller) {
  38768. clearInterval(this._poller);
  38769. this._poller = null;
  38770. }
  38771. },
  38772. enumerable: false,
  38773. configurable: true
  38774. });
  38775. Object.defineProperty(BaseProvider.prototype, "pollingInterval", {
  38776. get: function () {
  38777. return this._pollingInterval;
  38778. },
  38779. set: function (value) {
  38780. var _this = this;
  38781. if (typeof (value) !== "number" || value <= 0 || parseInt(String(value)) != value) {
  38782. throw new Error("invalid polling interval");
  38783. }
  38784. this._pollingInterval = value;
  38785. if (this._poller) {
  38786. clearInterval(this._poller);
  38787. this._poller = setInterval(function () { _this.poll(); }, this._pollingInterval);
  38788. }
  38789. },
  38790. enumerable: false,
  38791. configurable: true
  38792. });
  38793. BaseProvider.prototype._getFastBlockNumber = function () {
  38794. var _this = this;
  38795. var now = getTime();
  38796. // Stale block number, request a newer value
  38797. if ((now - this._fastQueryDate) > 2 * this._pollingInterval) {
  38798. this._fastQueryDate = now;
  38799. this._fastBlockNumberPromise = this.getBlockNumber().then(function (blockNumber) {
  38800. if (_this._fastBlockNumber == null || blockNumber > _this._fastBlockNumber) {
  38801. _this._fastBlockNumber = blockNumber;
  38802. }
  38803. return _this._fastBlockNumber;
  38804. });
  38805. }
  38806. return this._fastBlockNumberPromise;
  38807. };
  38808. BaseProvider.prototype._setFastBlockNumber = function (blockNumber) {
  38809. // Older block, maybe a stale request
  38810. if (this._fastBlockNumber != null && blockNumber < this._fastBlockNumber) {
  38811. return;
  38812. }
  38813. // Update the time we updated the blocknumber
  38814. this._fastQueryDate = getTime();
  38815. // Newer block number, use it
  38816. if (this._fastBlockNumber == null || blockNumber > this._fastBlockNumber) {
  38817. this._fastBlockNumber = blockNumber;
  38818. this._fastBlockNumberPromise = Promise.resolve(blockNumber);
  38819. }
  38820. };
  38821. BaseProvider.prototype.waitForTransaction = function (transactionHash, confirmations, timeout) {
  38822. return __awaiter(this, void 0, void 0, function () {
  38823. return __generator(this, function (_a) {
  38824. return [2 /*return*/, this._waitForTransaction(transactionHash, (confirmations == null) ? 1 : confirmations, timeout || 0, null)];
  38825. });
  38826. });
  38827. };
  38828. BaseProvider.prototype._waitForTransaction = function (transactionHash, confirmations, timeout, replaceable) {
  38829. return __awaiter(this, void 0, void 0, function () {
  38830. var receipt;
  38831. var _this = this;
  38832. return __generator(this, function (_a) {
  38833. switch (_a.label) {
  38834. case 0: return [4 /*yield*/, this.getTransactionReceipt(transactionHash)];
  38835. case 1:
  38836. receipt = _a.sent();
  38837. // Receipt is already good
  38838. if ((receipt ? receipt.confirmations : 0) >= confirmations) {
  38839. return [2 /*return*/, receipt];
  38840. }
  38841. // Poll until the receipt is good...
  38842. return [2 /*return*/, new Promise(function (resolve, reject) {
  38843. var cancelFuncs = [];
  38844. var done = false;
  38845. var alreadyDone = function () {
  38846. if (done) {
  38847. return true;
  38848. }
  38849. done = true;
  38850. cancelFuncs.forEach(function (func) { func(); });
  38851. return false;
  38852. };
  38853. var minedHandler = function (receipt) {
  38854. if (receipt.confirmations < confirmations) {
  38855. return;
  38856. }
  38857. if (alreadyDone()) {
  38858. return;
  38859. }
  38860. resolve(receipt);
  38861. };
  38862. _this.on(transactionHash, minedHandler);
  38863. cancelFuncs.push(function () { _this.removeListener(transactionHash, minedHandler); });
  38864. if (replaceable) {
  38865. var lastBlockNumber_1 = replaceable.startBlock;
  38866. var scannedBlock_1 = null;
  38867. var replaceHandler_1 = function (blockNumber) { return __awaiter(_this, void 0, void 0, function () {
  38868. var _this = this;
  38869. return __generator(this, function (_a) {
  38870. switch (_a.label) {
  38871. case 0:
  38872. if (done) {
  38873. return [2 /*return*/];
  38874. }
  38875. // Wait 1 second; this is only used in the case of a fault, so
  38876. // we will trade off a little bit of latency for more consistent
  38877. // results and fewer JSON-RPC calls
  38878. return [4 /*yield*/, stall(1000)];
  38879. case 1:
  38880. // Wait 1 second; this is only used in the case of a fault, so
  38881. // we will trade off a little bit of latency for more consistent
  38882. // results and fewer JSON-RPC calls
  38883. _a.sent();
  38884. this.getTransactionCount(replaceable.from).then(function (nonce) { return __awaiter(_this, void 0, void 0, function () {
  38885. var mined, block, ti, tx, receipt_1, reason;
  38886. return __generator(this, function (_a) {
  38887. switch (_a.label) {
  38888. case 0:
  38889. if (done) {
  38890. return [2 /*return*/];
  38891. }
  38892. if (!(nonce <= replaceable.nonce)) return [3 /*break*/, 1];
  38893. lastBlockNumber_1 = blockNumber;
  38894. return [3 /*break*/, 9];
  38895. case 1: return [4 /*yield*/, this.getTransaction(transactionHash)];
  38896. case 2:
  38897. mined = _a.sent();
  38898. if (mined && mined.blockNumber != null) {
  38899. return [2 /*return*/];
  38900. }
  38901. // First time scanning. We start a little earlier for some
  38902. // wiggle room here to handle the eventually consistent nature
  38903. // of blockchain (e.g. the getTransactionCount was for a
  38904. // different block)
  38905. if (scannedBlock_1 == null) {
  38906. scannedBlock_1 = lastBlockNumber_1 - 3;
  38907. if (scannedBlock_1 < replaceable.startBlock) {
  38908. scannedBlock_1 = replaceable.startBlock;
  38909. }
  38910. }
  38911. _a.label = 3;
  38912. case 3:
  38913. if (!(scannedBlock_1 <= blockNumber)) return [3 /*break*/, 9];
  38914. if (done) {
  38915. return [2 /*return*/];
  38916. }
  38917. return [4 /*yield*/, this.getBlockWithTransactions(scannedBlock_1)];
  38918. case 4:
  38919. block = _a.sent();
  38920. ti = 0;
  38921. _a.label = 5;
  38922. case 5:
  38923. if (!(ti < block.transactions.length)) return [3 /*break*/, 8];
  38924. tx = block.transactions[ti];
  38925. // Successfully mined!
  38926. if (tx.hash === transactionHash) {
  38927. return [2 /*return*/];
  38928. }
  38929. if (!(tx.from === replaceable.from && tx.nonce === replaceable.nonce)) return [3 /*break*/, 7];
  38930. if (done) {
  38931. return [2 /*return*/];
  38932. }
  38933. return [4 /*yield*/, this.waitForTransaction(tx.hash, confirmations)];
  38934. case 6:
  38935. receipt_1 = _a.sent();
  38936. // Already resolved or rejected (prolly a timeout)
  38937. if (alreadyDone()) {
  38938. return [2 /*return*/];
  38939. }
  38940. reason = "replaced";
  38941. if (tx.data === replaceable.data && tx.to === replaceable.to && tx.value.eq(replaceable.value)) {
  38942. reason = "repriced";
  38943. }
  38944. else if (tx.data === "0x" && tx.from === tx.to && tx.value.isZero()) {
  38945. reason = "cancelled";
  38946. }
  38947. // Explain why we were replaced
  38948. reject(logger.makeError("transaction was replaced", logger_1.Logger.errors.TRANSACTION_REPLACED, {
  38949. cancelled: (reason === "replaced" || reason === "cancelled"),
  38950. reason: reason,
  38951. replacement: this._wrapTransaction(tx),
  38952. hash: transactionHash,
  38953. receipt: receipt_1
  38954. }));
  38955. return [2 /*return*/];
  38956. case 7:
  38957. ti++;
  38958. return [3 /*break*/, 5];
  38959. case 8:
  38960. scannedBlock_1++;
  38961. return [3 /*break*/, 3];
  38962. case 9:
  38963. if (done) {
  38964. return [2 /*return*/];
  38965. }
  38966. this.once("block", replaceHandler_1);
  38967. return [2 /*return*/];
  38968. }
  38969. });
  38970. }); }, function (error) {
  38971. if (done) {
  38972. return;
  38973. }
  38974. _this.once("block", replaceHandler_1);
  38975. });
  38976. return [2 /*return*/];
  38977. }
  38978. });
  38979. }); };
  38980. if (done) {
  38981. return;
  38982. }
  38983. _this.once("block", replaceHandler_1);
  38984. cancelFuncs.push(function () {
  38985. _this.removeListener("block", replaceHandler_1);
  38986. });
  38987. }
  38988. if (typeof (timeout) === "number" && timeout > 0) {
  38989. var timer_1 = setTimeout(function () {
  38990. if (alreadyDone()) {
  38991. return;
  38992. }
  38993. reject(logger.makeError("timeout exceeded", logger_1.Logger.errors.TIMEOUT, { timeout: timeout }));
  38994. }, timeout);
  38995. if (timer_1.unref) {
  38996. timer_1.unref();
  38997. }
  38998. cancelFuncs.push(function () { clearTimeout(timer_1); });
  38999. }
  39000. })];
  39001. }
  39002. });
  39003. });
  39004. };
  39005. BaseProvider.prototype.getBlockNumber = function () {
  39006. return __awaiter(this, void 0, void 0, function () {
  39007. return __generator(this, function (_a) {
  39008. return [2 /*return*/, this._getInternalBlockNumber(0)];
  39009. });
  39010. });
  39011. };
  39012. BaseProvider.prototype.getGasPrice = function () {
  39013. return __awaiter(this, void 0, void 0, function () {
  39014. var result;
  39015. return __generator(this, function (_a) {
  39016. switch (_a.label) {
  39017. case 0: return [4 /*yield*/, this.getNetwork()];
  39018. case 1:
  39019. _a.sent();
  39020. return [4 /*yield*/, this.perform("getGasPrice", {})];
  39021. case 2:
  39022. result = _a.sent();
  39023. try {
  39024. return [2 /*return*/, bignumber_1.BigNumber.from(result)];
  39025. }
  39026. catch (error) {
  39027. return [2 /*return*/, logger.throwError("bad result from backend", logger_1.Logger.errors.SERVER_ERROR, {
  39028. method: "getGasPrice",
  39029. result: result,
  39030. error: error
  39031. })];
  39032. }
  39033. return [2 /*return*/];
  39034. }
  39035. });
  39036. });
  39037. };
  39038. BaseProvider.prototype.getBalance = function (addressOrName, blockTag) {
  39039. return __awaiter(this, void 0, void 0, function () {
  39040. var params, result;
  39041. return __generator(this, function (_a) {
  39042. switch (_a.label) {
  39043. case 0: return [4 /*yield*/, this.getNetwork()];
  39044. case 1:
  39045. _a.sent();
  39046. return [4 /*yield*/, (0, properties_1.resolveProperties)({
  39047. address: this._getAddress(addressOrName),
  39048. blockTag: this._getBlockTag(blockTag)
  39049. })];
  39050. case 2:
  39051. params = _a.sent();
  39052. return [4 /*yield*/, this.perform("getBalance", params)];
  39053. case 3:
  39054. result = _a.sent();
  39055. try {
  39056. return [2 /*return*/, bignumber_1.BigNumber.from(result)];
  39057. }
  39058. catch (error) {
  39059. return [2 /*return*/, logger.throwError("bad result from backend", logger_1.Logger.errors.SERVER_ERROR, {
  39060. method: "getBalance",
  39061. params: params,
  39062. result: result,
  39063. error: error
  39064. })];
  39065. }
  39066. return [2 /*return*/];
  39067. }
  39068. });
  39069. });
  39070. };
  39071. BaseProvider.prototype.getTransactionCount = function (addressOrName, blockTag) {
  39072. return __awaiter(this, void 0, void 0, function () {
  39073. var params, result;
  39074. return __generator(this, function (_a) {
  39075. switch (_a.label) {
  39076. case 0: return [4 /*yield*/, this.getNetwork()];
  39077. case 1:
  39078. _a.sent();
  39079. return [4 /*yield*/, (0, properties_1.resolveProperties)({
  39080. address: this._getAddress(addressOrName),
  39081. blockTag: this._getBlockTag(blockTag)
  39082. })];
  39083. case 2:
  39084. params = _a.sent();
  39085. return [4 /*yield*/, this.perform("getTransactionCount", params)];
  39086. case 3:
  39087. result = _a.sent();
  39088. try {
  39089. return [2 /*return*/, bignumber_1.BigNumber.from(result).toNumber()];
  39090. }
  39091. catch (error) {
  39092. return [2 /*return*/, logger.throwError("bad result from backend", logger_1.Logger.errors.SERVER_ERROR, {
  39093. method: "getTransactionCount",
  39094. params: params,
  39095. result: result,
  39096. error: error
  39097. })];
  39098. }
  39099. return [2 /*return*/];
  39100. }
  39101. });
  39102. });
  39103. };
  39104. BaseProvider.prototype.getCode = function (addressOrName, blockTag) {
  39105. return __awaiter(this, void 0, void 0, function () {
  39106. var params, result;
  39107. return __generator(this, function (_a) {
  39108. switch (_a.label) {
  39109. case 0: return [4 /*yield*/, this.getNetwork()];
  39110. case 1:
  39111. _a.sent();
  39112. return [4 /*yield*/, (0, properties_1.resolveProperties)({
  39113. address: this._getAddress(addressOrName),
  39114. blockTag: this._getBlockTag(blockTag)
  39115. })];
  39116. case 2:
  39117. params = _a.sent();
  39118. return [4 /*yield*/, this.perform("getCode", params)];
  39119. case 3:
  39120. result = _a.sent();
  39121. try {
  39122. return [2 /*return*/, (0, bytes_1.hexlify)(result)];
  39123. }
  39124. catch (error) {
  39125. return [2 /*return*/, logger.throwError("bad result from backend", logger_1.Logger.errors.SERVER_ERROR, {
  39126. method: "getCode",
  39127. params: params,
  39128. result: result,
  39129. error: error
  39130. })];
  39131. }
  39132. return [2 /*return*/];
  39133. }
  39134. });
  39135. });
  39136. };
  39137. BaseProvider.prototype.getStorageAt = function (addressOrName, position, blockTag) {
  39138. return __awaiter(this, void 0, void 0, function () {
  39139. var params, result;
  39140. return __generator(this, function (_a) {
  39141. switch (_a.label) {
  39142. case 0: return [4 /*yield*/, this.getNetwork()];
  39143. case 1:
  39144. _a.sent();
  39145. return [4 /*yield*/, (0, properties_1.resolveProperties)({
  39146. address: this._getAddress(addressOrName),
  39147. blockTag: this._getBlockTag(blockTag),
  39148. position: Promise.resolve(position).then(function (p) { return (0, bytes_1.hexValue)(p); })
  39149. })];
  39150. case 2:
  39151. params = _a.sent();
  39152. return [4 /*yield*/, this.perform("getStorageAt", params)];
  39153. case 3:
  39154. result = _a.sent();
  39155. try {
  39156. return [2 /*return*/, (0, bytes_1.hexlify)(result)];
  39157. }
  39158. catch (error) {
  39159. return [2 /*return*/, logger.throwError("bad result from backend", logger_1.Logger.errors.SERVER_ERROR, {
  39160. method: "getStorageAt",
  39161. params: params,
  39162. result: result,
  39163. error: error
  39164. })];
  39165. }
  39166. return [2 /*return*/];
  39167. }
  39168. });
  39169. });
  39170. };
  39171. // This should be called by any subclass wrapping a TransactionResponse
  39172. BaseProvider.prototype._wrapTransaction = function (tx, hash, startBlock) {
  39173. var _this = this;
  39174. if (hash != null && (0, bytes_1.hexDataLength)(hash) !== 32) {
  39175. throw new Error("invalid response - sendTransaction");
  39176. }
  39177. var result = tx;
  39178. // Check the hash we expect is the same as the hash the server reported
  39179. if (hash != null && tx.hash !== hash) {
  39180. logger.throwError("Transaction hash mismatch from Provider.sendTransaction.", logger_1.Logger.errors.UNKNOWN_ERROR, { expectedHash: tx.hash, returnedHash: hash });
  39181. }
  39182. result.wait = function (confirms, timeout) { return __awaiter(_this, void 0, void 0, function () {
  39183. var replacement, receipt;
  39184. return __generator(this, function (_a) {
  39185. switch (_a.label) {
  39186. case 0:
  39187. if (confirms == null) {
  39188. confirms = 1;
  39189. }
  39190. if (timeout == null) {
  39191. timeout = 0;
  39192. }
  39193. replacement = undefined;
  39194. if (confirms !== 0 && startBlock != null) {
  39195. replacement = {
  39196. data: tx.data,
  39197. from: tx.from,
  39198. nonce: tx.nonce,
  39199. to: tx.to,
  39200. value: tx.value,
  39201. startBlock: startBlock
  39202. };
  39203. }
  39204. return [4 /*yield*/, this._waitForTransaction(tx.hash, confirms, timeout, replacement)];
  39205. case 1:
  39206. receipt = _a.sent();
  39207. if (receipt == null && confirms === 0) {
  39208. return [2 /*return*/, null];
  39209. }
  39210. // No longer pending, allow the polling loop to garbage collect this
  39211. this._emitted["t:" + tx.hash] = receipt.blockNumber;
  39212. if (receipt.status === 0) {
  39213. logger.throwError("transaction failed", logger_1.Logger.errors.CALL_EXCEPTION, {
  39214. transactionHash: tx.hash,
  39215. transaction: tx,
  39216. receipt: receipt
  39217. });
  39218. }
  39219. return [2 /*return*/, receipt];
  39220. }
  39221. });
  39222. }); };
  39223. return result;
  39224. };
  39225. BaseProvider.prototype.sendTransaction = function (signedTransaction) {
  39226. return __awaiter(this, void 0, void 0, function () {
  39227. var hexTx, tx, blockNumber, hash, error_7;
  39228. return __generator(this, function (_a) {
  39229. switch (_a.label) {
  39230. case 0: return [4 /*yield*/, this.getNetwork()];
  39231. case 1:
  39232. _a.sent();
  39233. return [4 /*yield*/, Promise.resolve(signedTransaction).then(function (t) { return (0, bytes_1.hexlify)(t); })];
  39234. case 2:
  39235. hexTx = _a.sent();
  39236. tx = this.formatter.transaction(signedTransaction);
  39237. if (tx.confirmations == null) {
  39238. tx.confirmations = 0;
  39239. }
  39240. return [4 /*yield*/, this._getInternalBlockNumber(100 + 2 * this.pollingInterval)];
  39241. case 3:
  39242. blockNumber = _a.sent();
  39243. _a.label = 4;
  39244. case 4:
  39245. _a.trys.push([4, 6, , 7]);
  39246. return [4 /*yield*/, this.perform("sendTransaction", { signedTransaction: hexTx })];
  39247. case 5:
  39248. hash = _a.sent();
  39249. return [2 /*return*/, this._wrapTransaction(tx, hash, blockNumber)];
  39250. case 6:
  39251. error_7 = _a.sent();
  39252. error_7.transaction = tx;
  39253. error_7.transactionHash = tx.hash;
  39254. throw error_7;
  39255. case 7: return [2 /*return*/];
  39256. }
  39257. });
  39258. });
  39259. };
  39260. BaseProvider.prototype._getTransactionRequest = function (transaction) {
  39261. return __awaiter(this, void 0, void 0, function () {
  39262. var values, tx, _a, _b;
  39263. var _this = this;
  39264. return __generator(this, function (_c) {
  39265. switch (_c.label) {
  39266. case 0: return [4 /*yield*/, transaction];
  39267. case 1:
  39268. values = _c.sent();
  39269. tx = {};
  39270. ["from", "to"].forEach(function (key) {
  39271. if (values[key] == null) {
  39272. return;
  39273. }
  39274. tx[key] = Promise.resolve(values[key]).then(function (v) { return (v ? _this._getAddress(v) : null); });
  39275. });
  39276. ["gasLimit", "gasPrice", "maxFeePerGas", "maxPriorityFeePerGas", "value"].forEach(function (key) {
  39277. if (values[key] == null) {
  39278. return;
  39279. }
  39280. tx[key] = Promise.resolve(values[key]).then(function (v) { return (v ? bignumber_1.BigNumber.from(v) : null); });
  39281. });
  39282. ["type"].forEach(function (key) {
  39283. if (values[key] == null) {
  39284. return;
  39285. }
  39286. tx[key] = Promise.resolve(values[key]).then(function (v) { return ((v != null) ? v : null); });
  39287. });
  39288. if (values.accessList) {
  39289. tx.accessList = this.formatter.accessList(values.accessList);
  39290. }
  39291. ["data"].forEach(function (key) {
  39292. if (values[key] == null) {
  39293. return;
  39294. }
  39295. tx[key] = Promise.resolve(values[key]).then(function (v) { return (v ? (0, bytes_1.hexlify)(v) : null); });
  39296. });
  39297. _b = (_a = this.formatter).transactionRequest;
  39298. return [4 /*yield*/, (0, properties_1.resolveProperties)(tx)];
  39299. case 2: return [2 /*return*/, _b.apply(_a, [_c.sent()])];
  39300. }
  39301. });
  39302. });
  39303. };
  39304. BaseProvider.prototype._getFilter = function (filter) {
  39305. return __awaiter(this, void 0, void 0, function () {
  39306. var result, _a, _b;
  39307. var _this = this;
  39308. return __generator(this, function (_c) {
  39309. switch (_c.label) {
  39310. case 0: return [4 /*yield*/, filter];
  39311. case 1:
  39312. filter = _c.sent();
  39313. result = {};
  39314. if (filter.address != null) {
  39315. result.address = this._getAddress(filter.address);
  39316. }
  39317. ["blockHash", "topics"].forEach(function (key) {
  39318. if (filter[key] == null) {
  39319. return;
  39320. }
  39321. result[key] = filter[key];
  39322. });
  39323. ["fromBlock", "toBlock"].forEach(function (key) {
  39324. if (filter[key] == null) {
  39325. return;
  39326. }
  39327. result[key] = _this._getBlockTag(filter[key]);
  39328. });
  39329. _b = (_a = this.formatter).filter;
  39330. return [4 /*yield*/, (0, properties_1.resolveProperties)(result)];
  39331. case 2: return [2 /*return*/, _b.apply(_a, [_c.sent()])];
  39332. }
  39333. });
  39334. });
  39335. };
  39336. BaseProvider.prototype._call = function (transaction, blockTag, attempt) {
  39337. return __awaiter(this, void 0, void 0, function () {
  39338. var txSender, result, data, sender, urls, urlsOffset, urlsLength, urlsData, u, url, calldata, callbackSelector, extraData, ccipResult, tx, error_8;
  39339. return __generator(this, function (_a) {
  39340. switch (_a.label) {
  39341. case 0:
  39342. if (attempt >= MAX_CCIP_REDIRECTS) {
  39343. logger.throwError("CCIP read exceeded maximum redirections", logger_1.Logger.errors.SERVER_ERROR, {
  39344. redirects: attempt,
  39345. transaction: transaction
  39346. });
  39347. }
  39348. txSender = transaction.to;
  39349. return [4 /*yield*/, this.perform("call", { transaction: transaction, blockTag: blockTag })];
  39350. case 1:
  39351. result = _a.sent();
  39352. if (!(attempt >= 0 && blockTag === "latest" && txSender != null && result.substring(0, 10) === "0x556f1830" && ((0, bytes_1.hexDataLength)(result) % 32 === 4))) return [3 /*break*/, 5];
  39353. _a.label = 2;
  39354. case 2:
  39355. _a.trys.push([2, 4, , 5]);
  39356. data = (0, bytes_1.hexDataSlice)(result, 4);
  39357. sender = (0, bytes_1.hexDataSlice)(data, 0, 32);
  39358. if (!bignumber_1.BigNumber.from(sender).eq(txSender)) {
  39359. logger.throwError("CCIP Read sender did not match", logger_1.Logger.errors.CALL_EXCEPTION, {
  39360. name: "OffchainLookup",
  39361. signature: "OffchainLookup(address,string[],bytes,bytes4,bytes)",
  39362. transaction: transaction,
  39363. data: result
  39364. });
  39365. }
  39366. urls = [];
  39367. urlsOffset = bignumber_1.BigNumber.from((0, bytes_1.hexDataSlice)(data, 32, 64)).toNumber();
  39368. urlsLength = bignumber_1.BigNumber.from((0, bytes_1.hexDataSlice)(data, urlsOffset, urlsOffset + 32)).toNumber();
  39369. urlsData = (0, bytes_1.hexDataSlice)(data, urlsOffset + 32);
  39370. for (u = 0; u < urlsLength; u++) {
  39371. url = _parseString(urlsData, u * 32);
  39372. if (url == null) {
  39373. logger.throwError("CCIP Read contained corrupt URL string", logger_1.Logger.errors.CALL_EXCEPTION, {
  39374. name: "OffchainLookup",
  39375. signature: "OffchainLookup(address,string[],bytes,bytes4,bytes)",
  39376. transaction: transaction,
  39377. data: result
  39378. });
  39379. }
  39380. urls.push(url);
  39381. }
  39382. calldata = _parseBytes(data, 64);
  39383. // Get the callbackSelector (bytes4)
  39384. if (!bignumber_1.BigNumber.from((0, bytes_1.hexDataSlice)(data, 100, 128)).isZero()) {
  39385. logger.throwError("CCIP Read callback selector included junk", logger_1.Logger.errors.CALL_EXCEPTION, {
  39386. name: "OffchainLookup",
  39387. signature: "OffchainLookup(address,string[],bytes,bytes4,bytes)",
  39388. transaction: transaction,
  39389. data: result
  39390. });
  39391. }
  39392. callbackSelector = (0, bytes_1.hexDataSlice)(data, 96, 100);
  39393. extraData = _parseBytes(data, 128);
  39394. return [4 /*yield*/, this.ccipReadFetch(transaction, calldata, urls)];
  39395. case 3:
  39396. ccipResult = _a.sent();
  39397. if (ccipResult == null) {
  39398. logger.throwError("CCIP Read disabled or provided no URLs", logger_1.Logger.errors.CALL_EXCEPTION, {
  39399. name: "OffchainLookup",
  39400. signature: "OffchainLookup(address,string[],bytes,bytes4,bytes)",
  39401. transaction: transaction,
  39402. data: result
  39403. });
  39404. }
  39405. tx = {
  39406. to: txSender,
  39407. data: (0, bytes_1.hexConcat)([callbackSelector, encodeBytes([ccipResult, extraData])])
  39408. };
  39409. return [2 /*return*/, this._call(tx, blockTag, attempt + 1)];
  39410. case 4:
  39411. error_8 = _a.sent();
  39412. if (error_8.code === logger_1.Logger.errors.SERVER_ERROR) {
  39413. throw error_8;
  39414. }
  39415. return [3 /*break*/, 5];
  39416. case 5:
  39417. try {
  39418. return [2 /*return*/, (0, bytes_1.hexlify)(result)];
  39419. }
  39420. catch (error) {
  39421. return [2 /*return*/, logger.throwError("bad result from backend", logger_1.Logger.errors.SERVER_ERROR, {
  39422. method: "call",
  39423. params: { transaction: transaction, blockTag: blockTag },
  39424. result: result,
  39425. error: error
  39426. })];
  39427. }
  39428. return [2 /*return*/];
  39429. }
  39430. });
  39431. });
  39432. };
  39433. BaseProvider.prototype.call = function (transaction, blockTag) {
  39434. return __awaiter(this, void 0, void 0, function () {
  39435. var resolved;
  39436. return __generator(this, function (_a) {
  39437. switch (_a.label) {
  39438. case 0: return [4 /*yield*/, this.getNetwork()];
  39439. case 1:
  39440. _a.sent();
  39441. return [4 /*yield*/, (0, properties_1.resolveProperties)({
  39442. transaction: this._getTransactionRequest(transaction),
  39443. blockTag: this._getBlockTag(blockTag),
  39444. ccipReadEnabled: Promise.resolve(transaction.ccipReadEnabled)
  39445. })];
  39446. case 2:
  39447. resolved = _a.sent();
  39448. return [2 /*return*/, this._call(resolved.transaction, resolved.blockTag, resolved.ccipReadEnabled ? 0 : -1)];
  39449. }
  39450. });
  39451. });
  39452. };
  39453. BaseProvider.prototype.estimateGas = function (transaction) {
  39454. return __awaiter(this, void 0, void 0, function () {
  39455. var params, result;
  39456. return __generator(this, function (_a) {
  39457. switch (_a.label) {
  39458. case 0: return [4 /*yield*/, this.getNetwork()];
  39459. case 1:
  39460. _a.sent();
  39461. return [4 /*yield*/, (0, properties_1.resolveProperties)({
  39462. transaction: this._getTransactionRequest(transaction)
  39463. })];
  39464. case 2:
  39465. params = _a.sent();
  39466. return [4 /*yield*/, this.perform("estimateGas", params)];
  39467. case 3:
  39468. result = _a.sent();
  39469. try {
  39470. return [2 /*return*/, bignumber_1.BigNumber.from(result)];
  39471. }
  39472. catch (error) {
  39473. return [2 /*return*/, logger.throwError("bad result from backend", logger_1.Logger.errors.SERVER_ERROR, {
  39474. method: "estimateGas",
  39475. params: params,
  39476. result: result,
  39477. error: error
  39478. })];
  39479. }
  39480. return [2 /*return*/];
  39481. }
  39482. });
  39483. });
  39484. };
  39485. BaseProvider.prototype._getAddress = function (addressOrName) {
  39486. return __awaiter(this, void 0, void 0, function () {
  39487. var address;
  39488. return __generator(this, function (_a) {
  39489. switch (_a.label) {
  39490. case 0: return [4 /*yield*/, addressOrName];
  39491. case 1:
  39492. addressOrName = _a.sent();
  39493. if (typeof (addressOrName) !== "string") {
  39494. logger.throwArgumentError("invalid address or ENS name", "name", addressOrName);
  39495. }
  39496. return [4 /*yield*/, this.resolveName(addressOrName)];
  39497. case 2:
  39498. address = _a.sent();
  39499. if (address == null) {
  39500. logger.throwError("ENS name not configured", logger_1.Logger.errors.UNSUPPORTED_OPERATION, {
  39501. operation: "resolveName(" + JSON.stringify(addressOrName) + ")"
  39502. });
  39503. }
  39504. return [2 /*return*/, address];
  39505. }
  39506. });
  39507. });
  39508. };
  39509. BaseProvider.prototype._getBlock = function (blockHashOrBlockTag, includeTransactions) {
  39510. return __awaiter(this, void 0, void 0, function () {
  39511. var blockNumber, params, _a, error_9;
  39512. var _this = this;
  39513. return __generator(this, function (_b) {
  39514. switch (_b.label) {
  39515. case 0: return [4 /*yield*/, this.getNetwork()];
  39516. case 1:
  39517. _b.sent();
  39518. return [4 /*yield*/, blockHashOrBlockTag];
  39519. case 2:
  39520. blockHashOrBlockTag = _b.sent();
  39521. blockNumber = -128;
  39522. params = {
  39523. includeTransactions: !!includeTransactions
  39524. };
  39525. if (!(0, bytes_1.isHexString)(blockHashOrBlockTag, 32)) return [3 /*break*/, 3];
  39526. params.blockHash = blockHashOrBlockTag;
  39527. return [3 /*break*/, 6];
  39528. case 3:
  39529. _b.trys.push([3, 5, , 6]);
  39530. _a = params;
  39531. return [4 /*yield*/, this._getBlockTag(blockHashOrBlockTag)];
  39532. case 4:
  39533. _a.blockTag = _b.sent();
  39534. if ((0, bytes_1.isHexString)(params.blockTag)) {
  39535. blockNumber = parseInt(params.blockTag.substring(2), 16);
  39536. }
  39537. return [3 /*break*/, 6];
  39538. case 5:
  39539. error_9 = _b.sent();
  39540. logger.throwArgumentError("invalid block hash or block tag", "blockHashOrBlockTag", blockHashOrBlockTag);
  39541. return [3 /*break*/, 6];
  39542. case 6: return [2 /*return*/, (0, web_1.poll)(function () { return __awaiter(_this, void 0, void 0, function () {
  39543. var block, blockNumber_1, i, tx, confirmations, blockWithTxs;
  39544. var _this = this;
  39545. return __generator(this, function (_a) {
  39546. switch (_a.label) {
  39547. case 0: return [4 /*yield*/, this.perform("getBlock", params)];
  39548. case 1:
  39549. block = _a.sent();
  39550. // Block was not found
  39551. if (block == null) {
  39552. // For blockhashes, if we didn't say it existed, that blockhash may
  39553. // not exist. If we did see it though, perhaps from a log, we know
  39554. // it exists, and this node is just not caught up yet.
  39555. if (params.blockHash != null) {
  39556. if (this._emitted["b:" + params.blockHash] == null) {
  39557. return [2 /*return*/, null];
  39558. }
  39559. }
  39560. // For block tags, if we are asking for a future block, we return null
  39561. if (params.blockTag != null) {
  39562. if (blockNumber > this._emitted.block) {
  39563. return [2 /*return*/, null];
  39564. }
  39565. }
  39566. // Retry on the next block
  39567. return [2 /*return*/, undefined];
  39568. }
  39569. if (!includeTransactions) return [3 /*break*/, 8];
  39570. blockNumber_1 = null;
  39571. i = 0;
  39572. _a.label = 2;
  39573. case 2:
  39574. if (!(i < block.transactions.length)) return [3 /*break*/, 7];
  39575. tx = block.transactions[i];
  39576. if (!(tx.blockNumber == null)) return [3 /*break*/, 3];
  39577. tx.confirmations = 0;
  39578. return [3 /*break*/, 6];
  39579. case 3:
  39580. if (!(tx.confirmations == null)) return [3 /*break*/, 6];
  39581. if (!(blockNumber_1 == null)) return [3 /*break*/, 5];
  39582. return [4 /*yield*/, this._getInternalBlockNumber(100 + 2 * this.pollingInterval)];
  39583. case 4:
  39584. blockNumber_1 = _a.sent();
  39585. _a.label = 5;
  39586. case 5:
  39587. confirmations = (blockNumber_1 - tx.blockNumber) + 1;
  39588. if (confirmations <= 0) {
  39589. confirmations = 1;
  39590. }
  39591. tx.confirmations = confirmations;
  39592. _a.label = 6;
  39593. case 6:
  39594. i++;
  39595. return [3 /*break*/, 2];
  39596. case 7:
  39597. blockWithTxs = this.formatter.blockWithTransactions(block);
  39598. blockWithTxs.transactions = blockWithTxs.transactions.map(function (tx) { return _this._wrapTransaction(tx); });
  39599. return [2 /*return*/, blockWithTxs];
  39600. case 8: return [2 /*return*/, this.formatter.block(block)];
  39601. }
  39602. });
  39603. }); }, { oncePoll: this })];
  39604. }
  39605. });
  39606. });
  39607. };
  39608. BaseProvider.prototype.getBlock = function (blockHashOrBlockTag) {
  39609. return (this._getBlock(blockHashOrBlockTag, false));
  39610. };
  39611. BaseProvider.prototype.getBlockWithTransactions = function (blockHashOrBlockTag) {
  39612. return (this._getBlock(blockHashOrBlockTag, true));
  39613. };
  39614. BaseProvider.prototype.getTransaction = function (transactionHash) {
  39615. return __awaiter(this, void 0, void 0, function () {
  39616. var params;
  39617. var _this = this;
  39618. return __generator(this, function (_a) {
  39619. switch (_a.label) {
  39620. case 0: return [4 /*yield*/, this.getNetwork()];
  39621. case 1:
  39622. _a.sent();
  39623. return [4 /*yield*/, transactionHash];
  39624. case 2:
  39625. transactionHash = _a.sent();
  39626. params = { transactionHash: this.formatter.hash(transactionHash, true) };
  39627. return [2 /*return*/, (0, web_1.poll)(function () { return __awaiter(_this, void 0, void 0, function () {
  39628. var result, tx, blockNumber, confirmations;
  39629. return __generator(this, function (_a) {
  39630. switch (_a.label) {
  39631. case 0: return [4 /*yield*/, this.perform("getTransaction", params)];
  39632. case 1:
  39633. result = _a.sent();
  39634. if (result == null) {
  39635. if (this._emitted["t:" + transactionHash] == null) {
  39636. return [2 /*return*/, null];
  39637. }
  39638. return [2 /*return*/, undefined];
  39639. }
  39640. tx = this.formatter.transactionResponse(result);
  39641. if (!(tx.blockNumber == null)) return [3 /*break*/, 2];
  39642. tx.confirmations = 0;
  39643. return [3 /*break*/, 4];
  39644. case 2:
  39645. if (!(tx.confirmations == null)) return [3 /*break*/, 4];
  39646. return [4 /*yield*/, this._getInternalBlockNumber(100 + 2 * this.pollingInterval)];
  39647. case 3:
  39648. blockNumber = _a.sent();
  39649. confirmations = (blockNumber - tx.blockNumber) + 1;
  39650. if (confirmations <= 0) {
  39651. confirmations = 1;
  39652. }
  39653. tx.confirmations = confirmations;
  39654. _a.label = 4;
  39655. case 4: return [2 /*return*/, this._wrapTransaction(tx)];
  39656. }
  39657. });
  39658. }); }, { oncePoll: this })];
  39659. }
  39660. });
  39661. });
  39662. };
  39663. BaseProvider.prototype.getTransactionReceipt = function (transactionHash) {
  39664. return __awaiter(this, void 0, void 0, function () {
  39665. var params;
  39666. var _this = this;
  39667. return __generator(this, function (_a) {
  39668. switch (_a.label) {
  39669. case 0: return [4 /*yield*/, this.getNetwork()];
  39670. case 1:
  39671. _a.sent();
  39672. return [4 /*yield*/, transactionHash];
  39673. case 2:
  39674. transactionHash = _a.sent();
  39675. params = { transactionHash: this.formatter.hash(transactionHash, true) };
  39676. return [2 /*return*/, (0, web_1.poll)(function () { return __awaiter(_this, void 0, void 0, function () {
  39677. var result, receipt, blockNumber, confirmations;
  39678. return __generator(this, function (_a) {
  39679. switch (_a.label) {
  39680. case 0: return [4 /*yield*/, this.perform("getTransactionReceipt", params)];
  39681. case 1:
  39682. result = _a.sent();
  39683. if (result == null) {
  39684. if (this._emitted["t:" + transactionHash] == null) {
  39685. return [2 /*return*/, null];
  39686. }
  39687. return [2 /*return*/, undefined];
  39688. }
  39689. // "geth-etc" returns receipts before they are ready
  39690. if (result.blockHash == null) {
  39691. return [2 /*return*/, undefined];
  39692. }
  39693. receipt = this.formatter.receipt(result);
  39694. if (!(receipt.blockNumber == null)) return [3 /*break*/, 2];
  39695. receipt.confirmations = 0;
  39696. return [3 /*break*/, 4];
  39697. case 2:
  39698. if (!(receipt.confirmations == null)) return [3 /*break*/, 4];
  39699. return [4 /*yield*/, this._getInternalBlockNumber(100 + 2 * this.pollingInterval)];
  39700. case 3:
  39701. blockNumber = _a.sent();
  39702. confirmations = (blockNumber - receipt.blockNumber) + 1;
  39703. if (confirmations <= 0) {
  39704. confirmations = 1;
  39705. }
  39706. receipt.confirmations = confirmations;
  39707. _a.label = 4;
  39708. case 4: return [2 /*return*/, receipt];
  39709. }
  39710. });
  39711. }); }, { oncePoll: this })];
  39712. }
  39713. });
  39714. });
  39715. };
  39716. BaseProvider.prototype.getLogs = function (filter) {
  39717. return __awaiter(this, void 0, void 0, function () {
  39718. var params, logs;
  39719. return __generator(this, function (_a) {
  39720. switch (_a.label) {
  39721. case 0: return [4 /*yield*/, this.getNetwork()];
  39722. case 1:
  39723. _a.sent();
  39724. return [4 /*yield*/, (0, properties_1.resolveProperties)({ filter: this._getFilter(filter) })];
  39725. case 2:
  39726. params = _a.sent();
  39727. return [4 /*yield*/, this.perform("getLogs", params)];
  39728. case 3:
  39729. logs = _a.sent();
  39730. logs.forEach(function (log) {
  39731. if (log.removed == null) {
  39732. log.removed = false;
  39733. }
  39734. });
  39735. return [2 /*return*/, formatter_1.Formatter.arrayOf(this.formatter.filterLog.bind(this.formatter))(logs)];
  39736. }
  39737. });
  39738. });
  39739. };
  39740. BaseProvider.prototype.getEtherPrice = function () {
  39741. return __awaiter(this, void 0, void 0, function () {
  39742. return __generator(this, function (_a) {
  39743. switch (_a.label) {
  39744. case 0: return [4 /*yield*/, this.getNetwork()];
  39745. case 1:
  39746. _a.sent();
  39747. return [2 /*return*/, this.perform("getEtherPrice", {})];
  39748. }
  39749. });
  39750. });
  39751. };
  39752. BaseProvider.prototype._getBlockTag = function (blockTag) {
  39753. return __awaiter(this, void 0, void 0, function () {
  39754. var blockNumber;
  39755. return __generator(this, function (_a) {
  39756. switch (_a.label) {
  39757. case 0: return [4 /*yield*/, blockTag];
  39758. case 1:
  39759. blockTag = _a.sent();
  39760. if (!(typeof (blockTag) === "number" && blockTag < 0)) return [3 /*break*/, 3];
  39761. if (blockTag % 1) {
  39762. logger.throwArgumentError("invalid BlockTag", "blockTag", blockTag);
  39763. }
  39764. return [4 /*yield*/, this._getInternalBlockNumber(100 + 2 * this.pollingInterval)];
  39765. case 2:
  39766. blockNumber = _a.sent();
  39767. blockNumber += blockTag;
  39768. if (blockNumber < 0) {
  39769. blockNumber = 0;
  39770. }
  39771. return [2 /*return*/, this.formatter.blockTag(blockNumber)];
  39772. case 3: return [2 /*return*/, this.formatter.blockTag(blockTag)];
  39773. }
  39774. });
  39775. });
  39776. };
  39777. BaseProvider.prototype.getResolver = function (name) {
  39778. return __awaiter(this, void 0, void 0, function () {
  39779. var currentName, addr, resolver, _a;
  39780. return __generator(this, function (_b) {
  39781. switch (_b.label) {
  39782. case 0:
  39783. currentName = name;
  39784. _b.label = 1;
  39785. case 1:
  39786. if (!true) return [3 /*break*/, 6];
  39787. if (currentName === "" || currentName === ".") {
  39788. return [2 /*return*/, null];
  39789. }
  39790. // Optimization since the eth node cannot change and does
  39791. // not have a wildcar resolver
  39792. if (name !== "eth" && currentName === "eth") {
  39793. return [2 /*return*/, null];
  39794. }
  39795. return [4 /*yield*/, this._getResolver(currentName, "getResolver")];
  39796. case 2:
  39797. addr = _b.sent();
  39798. if (!(addr != null)) return [3 /*break*/, 5];
  39799. resolver = new Resolver(this, addr, name);
  39800. _a = currentName !== name;
  39801. if (!_a) return [3 /*break*/, 4];
  39802. return [4 /*yield*/, resolver.supportsWildcard()];
  39803. case 3:
  39804. _a = !(_b.sent());
  39805. _b.label = 4;
  39806. case 4:
  39807. // Legacy resolver found, using EIP-2544 so it isn't safe to use
  39808. if (_a) {
  39809. return [2 /*return*/, null];
  39810. }
  39811. return [2 /*return*/, resolver];
  39812. case 5:
  39813. // Get the parent node
  39814. currentName = currentName.split(".").slice(1).join(".");
  39815. return [3 /*break*/, 1];
  39816. case 6: return [2 /*return*/];
  39817. }
  39818. });
  39819. });
  39820. };
  39821. BaseProvider.prototype._getResolver = function (name, operation) {
  39822. return __awaiter(this, void 0, void 0, function () {
  39823. var network, addrData, error_10;
  39824. return __generator(this, function (_a) {
  39825. switch (_a.label) {
  39826. case 0:
  39827. if (operation == null) {
  39828. operation = "ENS";
  39829. }
  39830. return [4 /*yield*/, this.getNetwork()];
  39831. case 1:
  39832. network = _a.sent();
  39833. // No ENS...
  39834. if (!network.ensAddress) {
  39835. logger.throwError("network does not support ENS", logger_1.Logger.errors.UNSUPPORTED_OPERATION, { operation: operation, network: network.name });
  39836. }
  39837. _a.label = 2;
  39838. case 2:
  39839. _a.trys.push([2, 4, , 5]);
  39840. return [4 /*yield*/, this.call({
  39841. to: network.ensAddress,
  39842. data: ("0x0178b8bf" + (0, hash_1.namehash)(name).substring(2))
  39843. })];
  39844. case 3:
  39845. addrData = _a.sent();
  39846. return [2 /*return*/, this.formatter.callAddress(addrData)];
  39847. case 4:
  39848. error_10 = _a.sent();
  39849. return [3 /*break*/, 5];
  39850. case 5: return [2 /*return*/, null];
  39851. }
  39852. });
  39853. });
  39854. };
  39855. BaseProvider.prototype.resolveName = function (name) {
  39856. return __awaiter(this, void 0, void 0, function () {
  39857. var resolver;
  39858. return __generator(this, function (_a) {
  39859. switch (_a.label) {
  39860. case 0: return [4 /*yield*/, name];
  39861. case 1:
  39862. name = _a.sent();
  39863. // If it is already an address, nothing to resolve
  39864. try {
  39865. return [2 /*return*/, Promise.resolve(this.formatter.address(name))];
  39866. }
  39867. catch (error) {
  39868. // If is is a hexstring, the address is bad (See #694)
  39869. if ((0, bytes_1.isHexString)(name)) {
  39870. throw error;
  39871. }
  39872. }
  39873. if (typeof (name) !== "string") {
  39874. logger.throwArgumentError("invalid ENS name", "name", name);
  39875. }
  39876. return [4 /*yield*/, this.getResolver(name)];
  39877. case 2:
  39878. resolver = _a.sent();
  39879. if (!resolver) {
  39880. return [2 /*return*/, null];
  39881. }
  39882. return [4 /*yield*/, resolver.getAddress()];
  39883. case 3: return [2 /*return*/, _a.sent()];
  39884. }
  39885. });
  39886. });
  39887. };
  39888. BaseProvider.prototype.lookupAddress = function (address) {
  39889. return __awaiter(this, void 0, void 0, function () {
  39890. var node, resolverAddr, name, _a, addr;
  39891. return __generator(this, function (_b) {
  39892. switch (_b.label) {
  39893. case 0: return [4 /*yield*/, address];
  39894. case 1:
  39895. address = _b.sent();
  39896. address = this.formatter.address(address);
  39897. node = address.substring(2).toLowerCase() + ".addr.reverse";
  39898. return [4 /*yield*/, this._getResolver(node, "lookupAddress")];
  39899. case 2:
  39900. resolverAddr = _b.sent();
  39901. if (resolverAddr == null) {
  39902. return [2 /*return*/, null];
  39903. }
  39904. _a = _parseString;
  39905. return [4 /*yield*/, this.call({
  39906. to: resolverAddr,
  39907. data: ("0x691f3431" + (0, hash_1.namehash)(node).substring(2))
  39908. })];
  39909. case 3:
  39910. name = _a.apply(void 0, [_b.sent(), 0]);
  39911. return [4 /*yield*/, this.resolveName(name)];
  39912. case 4:
  39913. addr = _b.sent();
  39914. if (addr != address) {
  39915. return [2 /*return*/, null];
  39916. }
  39917. return [2 /*return*/, name];
  39918. }
  39919. });
  39920. });
  39921. };
  39922. BaseProvider.prototype.getAvatar = function (nameOrAddress) {
  39923. return __awaiter(this, void 0, void 0, function () {
  39924. var resolver, address, node, resolverAddress, avatar_1, error_11, name_1, _a, error_12, avatar;
  39925. return __generator(this, function (_b) {
  39926. switch (_b.label) {
  39927. case 0:
  39928. resolver = null;
  39929. if (!(0, bytes_1.isHexString)(nameOrAddress)) return [3 /*break*/, 10];
  39930. address = this.formatter.address(nameOrAddress);
  39931. node = address.substring(2).toLowerCase() + ".addr.reverse";
  39932. return [4 /*yield*/, this._getResolver(node, "getAvatar")];
  39933. case 1:
  39934. resolverAddress = _b.sent();
  39935. if (!resolverAddress) {
  39936. return [2 /*return*/, null];
  39937. }
  39938. // Try resolving the avatar against the addr.reverse resolver
  39939. resolver = new Resolver(this, resolverAddress, node);
  39940. _b.label = 2;
  39941. case 2:
  39942. _b.trys.push([2, 4, , 5]);
  39943. return [4 /*yield*/, resolver.getAvatar()];
  39944. case 3:
  39945. avatar_1 = _b.sent();
  39946. if (avatar_1) {
  39947. return [2 /*return*/, avatar_1.url];
  39948. }
  39949. return [3 /*break*/, 5];
  39950. case 4:
  39951. error_11 = _b.sent();
  39952. if (error_11.code !== logger_1.Logger.errors.CALL_EXCEPTION) {
  39953. throw error_11;
  39954. }
  39955. return [3 /*break*/, 5];
  39956. case 5:
  39957. _b.trys.push([5, 8, , 9]);
  39958. _a = _parseString;
  39959. return [4 /*yield*/, this.call({
  39960. to: resolverAddress,
  39961. data: ("0x691f3431" + (0, hash_1.namehash)(node).substring(2))
  39962. })];
  39963. case 6:
  39964. name_1 = _a.apply(void 0, [_b.sent(), 0]);
  39965. return [4 /*yield*/, this.getResolver(name_1)];
  39966. case 7:
  39967. resolver = _b.sent();
  39968. return [3 /*break*/, 9];
  39969. case 8:
  39970. error_12 = _b.sent();
  39971. if (error_12.code !== logger_1.Logger.errors.CALL_EXCEPTION) {
  39972. throw error_12;
  39973. }
  39974. return [2 /*return*/, null];
  39975. case 9: return [3 /*break*/, 12];
  39976. case 10: return [4 /*yield*/, this.getResolver(nameOrAddress)];
  39977. case 11:
  39978. // ENS name; forward lookup with wildcard
  39979. resolver = _b.sent();
  39980. if (!resolver) {
  39981. return [2 /*return*/, null];
  39982. }
  39983. _b.label = 12;
  39984. case 12: return [4 /*yield*/, resolver.getAvatar()];
  39985. case 13:
  39986. avatar = _b.sent();
  39987. if (avatar == null) {
  39988. return [2 /*return*/, null];
  39989. }
  39990. return [2 /*return*/, avatar.url];
  39991. }
  39992. });
  39993. });
  39994. };
  39995. BaseProvider.prototype.perform = function (method, params) {
  39996. return logger.throwError(method + " not implemented", logger_1.Logger.errors.NOT_IMPLEMENTED, { operation: method });
  39997. };
  39998. BaseProvider.prototype._startEvent = function (event) {
  39999. this.polling = (this._events.filter(function (e) { return e.pollable(); }).length > 0);
  40000. };
  40001. BaseProvider.prototype._stopEvent = function (event) {
  40002. this.polling = (this._events.filter(function (e) { return e.pollable(); }).length > 0);
  40003. };
  40004. BaseProvider.prototype._addEventListener = function (eventName, listener, once) {
  40005. var event = new Event(getEventTag(eventName), listener, once);
  40006. this._events.push(event);
  40007. this._startEvent(event);
  40008. return this;
  40009. };
  40010. BaseProvider.prototype.on = function (eventName, listener) {
  40011. return this._addEventListener(eventName, listener, false);
  40012. };
  40013. BaseProvider.prototype.once = function (eventName, listener) {
  40014. return this._addEventListener(eventName, listener, true);
  40015. };
  40016. BaseProvider.prototype.emit = function (eventName) {
  40017. var _this = this;
  40018. var args = [];
  40019. for (var _i = 1; _i < arguments.length; _i++) {
  40020. args[_i - 1] = arguments[_i];
  40021. }
  40022. var result = false;
  40023. var stopped = [];
  40024. var eventTag = getEventTag(eventName);
  40025. this._events = this._events.filter(function (event) {
  40026. if (event.tag !== eventTag) {
  40027. return true;
  40028. }
  40029. setTimeout(function () {
  40030. event.listener.apply(_this, args);
  40031. }, 0);
  40032. result = true;
  40033. if (event.once) {
  40034. stopped.push(event);
  40035. return false;
  40036. }
  40037. return true;
  40038. });
  40039. stopped.forEach(function (event) { _this._stopEvent(event); });
  40040. return result;
  40041. };
  40042. BaseProvider.prototype.listenerCount = function (eventName) {
  40043. if (!eventName) {
  40044. return this._events.length;
  40045. }
  40046. var eventTag = getEventTag(eventName);
  40047. return this._events.filter(function (event) {
  40048. return (event.tag === eventTag);
  40049. }).length;
  40050. };
  40051. BaseProvider.prototype.listeners = function (eventName) {
  40052. if (eventName == null) {
  40053. return this._events.map(function (event) { return event.listener; });
  40054. }
  40055. var eventTag = getEventTag(eventName);
  40056. return this._events
  40057. .filter(function (event) { return (event.tag === eventTag); })
  40058. .map(function (event) { return event.listener; });
  40059. };
  40060. BaseProvider.prototype.off = function (eventName, listener) {
  40061. var _this = this;
  40062. if (listener == null) {
  40063. return this.removeAllListeners(eventName);
  40064. }
  40065. var stopped = [];
  40066. var found = false;
  40067. var eventTag = getEventTag(eventName);
  40068. this._events = this._events.filter(function (event) {
  40069. if (event.tag !== eventTag || event.listener != listener) {
  40070. return true;
  40071. }
  40072. if (found) {
  40073. return true;
  40074. }
  40075. found = true;
  40076. stopped.push(event);
  40077. return false;
  40078. });
  40079. stopped.forEach(function (event) { _this._stopEvent(event); });
  40080. return this;
  40081. };
  40082. BaseProvider.prototype.removeAllListeners = function (eventName) {
  40083. var _this = this;
  40084. var stopped = [];
  40085. if (eventName == null) {
  40086. stopped = this._events;
  40087. this._events = [];
  40088. }
  40089. else {
  40090. var eventTag_1 = getEventTag(eventName);
  40091. this._events = this._events.filter(function (event) {
  40092. if (event.tag !== eventTag_1) {
  40093. return true;
  40094. }
  40095. stopped.push(event);
  40096. return false;
  40097. });
  40098. }
  40099. stopped.forEach(function (event) { _this._stopEvent(event); });
  40100. return this;
  40101. };
  40102. return BaseProvider;
  40103. }(abstract_provider_1.Provider));
  40104. exports.BaseProvider = BaseProvider;
  40105. },{"./_version":230,"./formatter":238,"@ethersproject/abstract-provider":185,"@ethersproject/basex":192,"@ethersproject/bignumber":196,"@ethersproject/bytes":199,"@ethersproject/constants":203,"@ethersproject/hash":209,"@ethersproject/logger":223,"@ethersproject/networks":225,"@ethersproject/properties":229,"@ethersproject/sha2":256,"@ethersproject/strings":266,"@ethersproject/web":276,"bech32":321}],233:[function(_dereq_,module,exports){
  40106. "use strict";
  40107. Object.defineProperty(exports, "__esModule", { value: true });
  40108. exports.IpcProvider = void 0;
  40109. var IpcProvider = null;
  40110. exports.IpcProvider = IpcProvider;
  40111. },{}],234:[function(_dereq_,module,exports){
  40112. "use strict";
  40113. Object.defineProperty(exports, "__esModule", { value: true });
  40114. exports.WebSocket = void 0;
  40115. var logger_1 = _dereq_("@ethersproject/logger");
  40116. var _version_1 = _dereq_("./_version");
  40117. var WS = null;
  40118. exports.WebSocket = WS;
  40119. try {
  40120. exports.WebSocket = WS = WebSocket;
  40121. if (WS == null) {
  40122. throw new Error("inject please");
  40123. }
  40124. }
  40125. catch (error) {
  40126. var logger_2 = new logger_1.Logger(_version_1.version);
  40127. exports.WebSocket = WS = function () {
  40128. logger_2.throwError("WebSockets not supported in this environment", logger_1.Logger.errors.UNSUPPORTED_OPERATION, {
  40129. operation: "new WebSocket()"
  40130. });
  40131. };
  40132. }
  40133. },{"./_version":230,"@ethersproject/logger":223}],235:[function(_dereq_,module,exports){
  40134. "use strict";
  40135. var __extends = (this && this.__extends) || (function () {
  40136. var extendStatics = function (d, b) {
  40137. extendStatics = Object.setPrototypeOf ||
  40138. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  40139. function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
  40140. return extendStatics(d, b);
  40141. };
  40142. return function (d, b) {
  40143. if (typeof b !== "function" && b !== null)
  40144. throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
  40145. extendStatics(d, b);
  40146. function __() { this.constructor = d; }
  40147. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  40148. };
  40149. })();
  40150. var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
  40151. function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
  40152. return new (P || (P = Promise))(function (resolve, reject) {
  40153. function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
  40154. function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
  40155. function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
  40156. step((generator = generator.apply(thisArg, _arguments || [])).next());
  40157. });
  40158. };
  40159. var __generator = (this && this.__generator) || function (thisArg, body) {
  40160. var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
  40161. return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
  40162. function verb(n) { return function (v) { return step([n, v]); }; }
  40163. function step(op) {
  40164. if (f) throw new TypeError("Generator is already executing.");
  40165. while (_) try {
  40166. if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
  40167. if (y = 0, t) op = [op[0] & 2, t.value];
  40168. switch (op[0]) {
  40169. case 0: case 1: t = op; break;
  40170. case 4: _.label++; return { value: op[1], done: false };
  40171. case 5: _.label++; y = op[1]; op = [0]; continue;
  40172. case 7: op = _.ops.pop(); _.trys.pop(); continue;
  40173. default:
  40174. if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
  40175. if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
  40176. if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
  40177. if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
  40178. if (t[2]) _.ops.pop();
  40179. _.trys.pop(); continue;
  40180. }
  40181. op = body.call(thisArg, _);
  40182. } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
  40183. if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
  40184. }
  40185. };
  40186. Object.defineProperty(exports, "__esModule", { value: true });
  40187. exports.CloudflareProvider = void 0;
  40188. var url_json_rpc_provider_1 = _dereq_("./url-json-rpc-provider");
  40189. var logger_1 = _dereq_("@ethersproject/logger");
  40190. var _version_1 = _dereq_("./_version");
  40191. var logger = new logger_1.Logger(_version_1.version);
  40192. var CloudflareProvider = /** @class */ (function (_super) {
  40193. __extends(CloudflareProvider, _super);
  40194. function CloudflareProvider() {
  40195. return _super !== null && _super.apply(this, arguments) || this;
  40196. }
  40197. CloudflareProvider.getApiKey = function (apiKey) {
  40198. if (apiKey != null) {
  40199. logger.throwArgumentError("apiKey not supported for cloudflare", "apiKey", apiKey);
  40200. }
  40201. return null;
  40202. };
  40203. CloudflareProvider.getUrl = function (network, apiKey) {
  40204. var host = null;
  40205. switch (network.name) {
  40206. case "homestead":
  40207. host = "https://cloudflare-eth.com/";
  40208. break;
  40209. default:
  40210. logger.throwArgumentError("unsupported network", "network", arguments[0]);
  40211. }
  40212. return host;
  40213. };
  40214. CloudflareProvider.prototype.perform = function (method, params) {
  40215. return __awaiter(this, void 0, void 0, function () {
  40216. var block;
  40217. return __generator(this, function (_a) {
  40218. switch (_a.label) {
  40219. case 0:
  40220. if (!(method === "getBlockNumber")) return [3 /*break*/, 2];
  40221. return [4 /*yield*/, _super.prototype.perform.call(this, "getBlock", { blockTag: "latest" })];
  40222. case 1:
  40223. block = _a.sent();
  40224. return [2 /*return*/, block.number];
  40225. case 2: return [2 /*return*/, _super.prototype.perform.call(this, method, params)];
  40226. }
  40227. });
  40228. });
  40229. };
  40230. return CloudflareProvider;
  40231. }(url_json_rpc_provider_1.UrlJsonRpcProvider));
  40232. exports.CloudflareProvider = CloudflareProvider;
  40233. },{"./_version":230,"./url-json-rpc-provider":245,"@ethersproject/logger":223}],236:[function(_dereq_,module,exports){
  40234. "use strict";
  40235. var __extends = (this && this.__extends) || (function () {
  40236. var extendStatics = function (d, b) {
  40237. extendStatics = Object.setPrototypeOf ||
  40238. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  40239. function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
  40240. return extendStatics(d, b);
  40241. };
  40242. return function (d, b) {
  40243. if (typeof b !== "function" && b !== null)
  40244. throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
  40245. extendStatics(d, b);
  40246. function __() { this.constructor = d; }
  40247. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  40248. };
  40249. })();
  40250. var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
  40251. function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
  40252. return new (P || (P = Promise))(function (resolve, reject) {
  40253. function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
  40254. function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
  40255. function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
  40256. step((generator = generator.apply(thisArg, _arguments || [])).next());
  40257. });
  40258. };
  40259. var __generator = (this && this.__generator) || function (thisArg, body) {
  40260. var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
  40261. return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
  40262. function verb(n) { return function (v) { return step([n, v]); }; }
  40263. function step(op) {
  40264. if (f) throw new TypeError("Generator is already executing.");
  40265. while (_) try {
  40266. if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
  40267. if (y = 0, t) op = [op[0] & 2, t.value];
  40268. switch (op[0]) {
  40269. case 0: case 1: t = op; break;
  40270. case 4: _.label++; return { value: op[1], done: false };
  40271. case 5: _.label++; y = op[1]; op = [0]; continue;
  40272. case 7: op = _.ops.pop(); _.trys.pop(); continue;
  40273. default:
  40274. if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
  40275. if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
  40276. if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
  40277. if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
  40278. if (t[2]) _.ops.pop();
  40279. _.trys.pop(); continue;
  40280. }
  40281. op = body.call(thisArg, _);
  40282. } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
  40283. if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
  40284. }
  40285. };
  40286. Object.defineProperty(exports, "__esModule", { value: true });
  40287. exports.EtherscanProvider = void 0;
  40288. var bytes_1 = _dereq_("@ethersproject/bytes");
  40289. var properties_1 = _dereq_("@ethersproject/properties");
  40290. var transactions_1 = _dereq_("@ethersproject/transactions");
  40291. var web_1 = _dereq_("@ethersproject/web");
  40292. var formatter_1 = _dereq_("./formatter");
  40293. var logger_1 = _dereq_("@ethersproject/logger");
  40294. var _version_1 = _dereq_("./_version");
  40295. var logger = new logger_1.Logger(_version_1.version);
  40296. var base_provider_1 = _dereq_("./base-provider");
  40297. // The transaction has already been sanitized by the calls in Provider
  40298. function getTransactionPostData(transaction) {
  40299. var result = {};
  40300. for (var key in transaction) {
  40301. if (transaction[key] == null) {
  40302. continue;
  40303. }
  40304. var value = transaction[key];
  40305. if (key === "type" && value === 0) {
  40306. continue;
  40307. }
  40308. // Quantity-types require no leading zero, unless 0
  40309. if ({ type: true, gasLimit: true, gasPrice: true, maxFeePerGs: true, maxPriorityFeePerGas: true, nonce: true, value: true }[key]) {
  40310. value = (0, bytes_1.hexValue)((0, bytes_1.hexlify)(value));
  40311. }
  40312. else if (key === "accessList") {
  40313. value = "[" + (0, transactions_1.accessListify)(value).map(function (set) {
  40314. return "{address:\"" + set.address + "\",storageKeys:[\"" + set.storageKeys.join('","') + "\"]}";
  40315. }).join(",") + "]";
  40316. }
  40317. else {
  40318. value = (0, bytes_1.hexlify)(value);
  40319. }
  40320. result[key] = value;
  40321. }
  40322. return result;
  40323. }
  40324. function getResult(result) {
  40325. // getLogs, getHistory have weird success responses
  40326. if (result.status == 0 && (result.message === "No records found" || result.message === "No transactions found")) {
  40327. return result.result;
  40328. }
  40329. if (result.status != 1 || result.message != "OK") {
  40330. var error = new Error("invalid response");
  40331. error.result = JSON.stringify(result);
  40332. if ((result.result || "").toLowerCase().indexOf("rate limit") >= 0) {
  40333. error.throttleRetry = true;
  40334. }
  40335. throw error;
  40336. }
  40337. return result.result;
  40338. }
  40339. function getJsonResult(result) {
  40340. // This response indicates we are being throttled
  40341. if (result && result.status == 0 && result.message == "NOTOK" && (result.result || "").toLowerCase().indexOf("rate limit") >= 0) {
  40342. var error = new Error("throttled response");
  40343. error.result = JSON.stringify(result);
  40344. error.throttleRetry = true;
  40345. throw error;
  40346. }
  40347. if (result.jsonrpc != "2.0") {
  40348. // @TODO: not any
  40349. var error = new Error("invalid response");
  40350. error.result = JSON.stringify(result);
  40351. throw error;
  40352. }
  40353. if (result.error) {
  40354. // @TODO: not any
  40355. var error = new Error(result.error.message || "unknown error");
  40356. if (result.error.code) {
  40357. error.code = result.error.code;
  40358. }
  40359. if (result.error.data) {
  40360. error.data = result.error.data;
  40361. }
  40362. throw error;
  40363. }
  40364. return result.result;
  40365. }
  40366. // The blockTag was normalized as a string by the Provider pre-perform operations
  40367. function checkLogTag(blockTag) {
  40368. if (blockTag === "pending") {
  40369. throw new Error("pending not supported");
  40370. }
  40371. if (blockTag === "latest") {
  40372. return blockTag;
  40373. }
  40374. return parseInt(blockTag.substring(2), 16);
  40375. }
  40376. var defaultApiKey = "9D13ZE7XSBTJ94N9BNJ2MA33VMAY2YPIRB";
  40377. function checkError(method, error, transaction) {
  40378. // Undo the "convenience" some nodes are attempting to prevent backwards
  40379. // incompatibility; maybe for v6 consider forwarding reverts as errors
  40380. if (method === "call" && error.code === logger_1.Logger.errors.SERVER_ERROR) {
  40381. var e = error.error;
  40382. // Etherscan keeps changing their string
  40383. if (e && (e.message.match(/reverted/i) || e.message.match(/VM execution error/i))) {
  40384. // Etherscan prefixes the data like "Reverted 0x1234"
  40385. var data = e.data;
  40386. if (data) {
  40387. data = "0x" + data.replace(/^.*0x/i, "");
  40388. }
  40389. if ((0, bytes_1.isHexString)(data)) {
  40390. return data;
  40391. }
  40392. logger.throwError("missing revert data in call exception", logger_1.Logger.errors.CALL_EXCEPTION, {
  40393. error: error,
  40394. data: "0x"
  40395. });
  40396. }
  40397. }
  40398. // Get the message from any nested error structure
  40399. var message = error.message;
  40400. if (error.code === logger_1.Logger.errors.SERVER_ERROR) {
  40401. if (error.error && typeof (error.error.message) === "string") {
  40402. message = error.error.message;
  40403. }
  40404. else if (typeof (error.body) === "string") {
  40405. message = error.body;
  40406. }
  40407. else if (typeof (error.responseText) === "string") {
  40408. message = error.responseText;
  40409. }
  40410. }
  40411. message = (message || "").toLowerCase();
  40412. // "Insufficient funds. The account you tried to send transaction from does not have enough funds. Required 21464000000000 and got: 0"
  40413. if (message.match(/insufficient funds/)) {
  40414. logger.throwError("insufficient funds for intrinsic transaction cost", logger_1.Logger.errors.INSUFFICIENT_FUNDS, {
  40415. error: error,
  40416. method: method,
  40417. transaction: transaction
  40418. });
  40419. }
  40420. // "Transaction with the same hash was already imported."
  40421. if (message.match(/same hash was already imported|transaction nonce is too low|nonce too low/)) {
  40422. logger.throwError("nonce has already been used", logger_1.Logger.errors.NONCE_EXPIRED, {
  40423. error: error,
  40424. method: method,
  40425. transaction: transaction
  40426. });
  40427. }
  40428. // "Transaction gas price is too low. There is another transaction with same nonce in the queue. Try increasing the gas price or incrementing the nonce."
  40429. if (message.match(/another transaction with same nonce/)) {
  40430. logger.throwError("replacement fee too low", logger_1.Logger.errors.REPLACEMENT_UNDERPRICED, {
  40431. error: error,
  40432. method: method,
  40433. transaction: transaction
  40434. });
  40435. }
  40436. if (message.match(/execution failed due to an exception|execution reverted/)) {
  40437. logger.throwError("cannot estimate gas; transaction may fail or may require manual gas limit", logger_1.Logger.errors.UNPREDICTABLE_GAS_LIMIT, {
  40438. error: error,
  40439. method: method,
  40440. transaction: transaction
  40441. });
  40442. }
  40443. throw error;
  40444. }
  40445. var EtherscanProvider = /** @class */ (function (_super) {
  40446. __extends(EtherscanProvider, _super);
  40447. function EtherscanProvider(network, apiKey) {
  40448. var _newTarget = this.constructor;
  40449. var _this = this;
  40450. logger.checkNew(_newTarget, EtherscanProvider);
  40451. _this = _super.call(this, network) || this;
  40452. (0, properties_1.defineReadOnly)(_this, "baseUrl", _this.getBaseUrl());
  40453. (0, properties_1.defineReadOnly)(_this, "apiKey", apiKey || defaultApiKey);
  40454. return _this;
  40455. }
  40456. EtherscanProvider.prototype.getBaseUrl = function () {
  40457. switch (this.network ? this.network.name : "invalid") {
  40458. case "homestead":
  40459. return "https:/\/api.etherscan.io";
  40460. case "ropsten":
  40461. return "https:/\/api-ropsten.etherscan.io";
  40462. case "rinkeby":
  40463. return "https:/\/api-rinkeby.etherscan.io";
  40464. case "kovan":
  40465. return "https:/\/api-kovan.etherscan.io";
  40466. case "goerli":
  40467. return "https:/\/api-goerli.etherscan.io";
  40468. default:
  40469. }
  40470. return logger.throwArgumentError("unsupported network", "network", name);
  40471. };
  40472. EtherscanProvider.prototype.getUrl = function (module, params) {
  40473. var query = Object.keys(params).reduce(function (accum, key) {
  40474. var value = params[key];
  40475. if (value != null) {
  40476. accum += "&" + key + "=" + value;
  40477. }
  40478. return accum;
  40479. }, "");
  40480. var apiKey = ((this.apiKey) ? "&apikey=" + this.apiKey : "");
  40481. return this.baseUrl + "/api?module=" + module + query + apiKey;
  40482. };
  40483. EtherscanProvider.prototype.getPostUrl = function () {
  40484. return this.baseUrl + "/api";
  40485. };
  40486. EtherscanProvider.prototype.getPostData = function (module, params) {
  40487. params.module = module;
  40488. params.apikey = this.apiKey;
  40489. return params;
  40490. };
  40491. EtherscanProvider.prototype.fetch = function (module, params, post) {
  40492. return __awaiter(this, void 0, void 0, function () {
  40493. var url, payload, procFunc, connection, payloadStr, result;
  40494. var _this = this;
  40495. return __generator(this, function (_a) {
  40496. switch (_a.label) {
  40497. case 0:
  40498. url = (post ? this.getPostUrl() : this.getUrl(module, params));
  40499. payload = (post ? this.getPostData(module, params) : null);
  40500. procFunc = (module === "proxy") ? getJsonResult : getResult;
  40501. this.emit("debug", {
  40502. action: "request",
  40503. request: url,
  40504. provider: this
  40505. });
  40506. connection = {
  40507. url: url,
  40508. throttleSlotInterval: 1000,
  40509. throttleCallback: function (attempt, url) {
  40510. if (_this.isCommunityResource()) {
  40511. (0, formatter_1.showThrottleMessage)();
  40512. }
  40513. return Promise.resolve(true);
  40514. }
  40515. };
  40516. payloadStr = null;
  40517. if (payload) {
  40518. connection.headers = { "content-type": "application/x-www-form-urlencoded; charset=UTF-8" };
  40519. payloadStr = Object.keys(payload).map(function (key) {
  40520. return key + "=" + payload[key];
  40521. }).join("&");
  40522. }
  40523. return [4 /*yield*/, (0, web_1.fetchJson)(connection, payloadStr, procFunc || getJsonResult)];
  40524. case 1:
  40525. result = _a.sent();
  40526. this.emit("debug", {
  40527. action: "response",
  40528. request: url,
  40529. response: (0, properties_1.deepCopy)(result),
  40530. provider: this
  40531. });
  40532. return [2 /*return*/, result];
  40533. }
  40534. });
  40535. });
  40536. };
  40537. EtherscanProvider.prototype.detectNetwork = function () {
  40538. return __awaiter(this, void 0, void 0, function () {
  40539. return __generator(this, function (_a) {
  40540. return [2 /*return*/, this.network];
  40541. });
  40542. });
  40543. };
  40544. EtherscanProvider.prototype.perform = function (method, params) {
  40545. return __awaiter(this, void 0, void 0, function () {
  40546. var _a, postData, error_1, postData, error_2, args, topic0, logs, blocks, i, log, block, _b;
  40547. return __generator(this, function (_c) {
  40548. switch (_c.label) {
  40549. case 0:
  40550. _a = method;
  40551. switch (_a) {
  40552. case "getBlockNumber": return [3 /*break*/, 1];
  40553. case "getGasPrice": return [3 /*break*/, 2];
  40554. case "getBalance": return [3 /*break*/, 3];
  40555. case "getTransactionCount": return [3 /*break*/, 4];
  40556. case "getCode": return [3 /*break*/, 5];
  40557. case "getStorageAt": return [3 /*break*/, 6];
  40558. case "sendTransaction": return [3 /*break*/, 7];
  40559. case "getBlock": return [3 /*break*/, 8];
  40560. case "getTransaction": return [3 /*break*/, 9];
  40561. case "getTransactionReceipt": return [3 /*break*/, 10];
  40562. case "call": return [3 /*break*/, 11];
  40563. case "estimateGas": return [3 /*break*/, 15];
  40564. case "getLogs": return [3 /*break*/, 19];
  40565. case "getEtherPrice": return [3 /*break*/, 26];
  40566. }
  40567. return [3 /*break*/, 28];
  40568. case 1: return [2 /*return*/, this.fetch("proxy", { action: "eth_blockNumber" })];
  40569. case 2: return [2 /*return*/, this.fetch("proxy", { action: "eth_gasPrice" })];
  40570. case 3:
  40571. // Returns base-10 result
  40572. return [2 /*return*/, this.fetch("account", {
  40573. action: "balance",
  40574. address: params.address,
  40575. tag: params.blockTag
  40576. })];
  40577. case 4: return [2 /*return*/, this.fetch("proxy", {
  40578. action: "eth_getTransactionCount",
  40579. address: params.address,
  40580. tag: params.blockTag
  40581. })];
  40582. case 5: return [2 /*return*/, this.fetch("proxy", {
  40583. action: "eth_getCode",
  40584. address: params.address,
  40585. tag: params.blockTag
  40586. })];
  40587. case 6: return [2 /*return*/, this.fetch("proxy", {
  40588. action: "eth_getStorageAt",
  40589. address: params.address,
  40590. position: params.position,
  40591. tag: params.blockTag
  40592. })];
  40593. case 7: return [2 /*return*/, this.fetch("proxy", {
  40594. action: "eth_sendRawTransaction",
  40595. hex: params.signedTransaction
  40596. }, true).catch(function (error) {
  40597. return checkError("sendTransaction", error, params.signedTransaction);
  40598. })];
  40599. case 8:
  40600. if (params.blockTag) {
  40601. return [2 /*return*/, this.fetch("proxy", {
  40602. action: "eth_getBlockByNumber",
  40603. tag: params.blockTag,
  40604. boolean: (params.includeTransactions ? "true" : "false")
  40605. })];
  40606. }
  40607. throw new Error("getBlock by blockHash not implemented");
  40608. case 9: return [2 /*return*/, this.fetch("proxy", {
  40609. action: "eth_getTransactionByHash",
  40610. txhash: params.transactionHash
  40611. })];
  40612. case 10: return [2 /*return*/, this.fetch("proxy", {
  40613. action: "eth_getTransactionReceipt",
  40614. txhash: params.transactionHash
  40615. })];
  40616. case 11:
  40617. if (params.blockTag !== "latest") {
  40618. throw new Error("EtherscanProvider does not support blockTag for call");
  40619. }
  40620. postData = getTransactionPostData(params.transaction);
  40621. postData.module = "proxy";
  40622. postData.action = "eth_call";
  40623. _c.label = 12;
  40624. case 12:
  40625. _c.trys.push([12, 14, , 15]);
  40626. return [4 /*yield*/, this.fetch("proxy", postData, true)];
  40627. case 13: return [2 /*return*/, _c.sent()];
  40628. case 14:
  40629. error_1 = _c.sent();
  40630. return [2 /*return*/, checkError("call", error_1, params.transaction)];
  40631. case 15:
  40632. postData = getTransactionPostData(params.transaction);
  40633. postData.module = "proxy";
  40634. postData.action = "eth_estimateGas";
  40635. _c.label = 16;
  40636. case 16:
  40637. _c.trys.push([16, 18, , 19]);
  40638. return [4 /*yield*/, this.fetch("proxy", postData, true)];
  40639. case 17: return [2 /*return*/, _c.sent()];
  40640. case 18:
  40641. error_2 = _c.sent();
  40642. return [2 /*return*/, checkError("estimateGas", error_2, params.transaction)];
  40643. case 19:
  40644. args = { action: "getLogs" };
  40645. if (params.filter.fromBlock) {
  40646. args.fromBlock = checkLogTag(params.filter.fromBlock);
  40647. }
  40648. if (params.filter.toBlock) {
  40649. args.toBlock = checkLogTag(params.filter.toBlock);
  40650. }
  40651. if (params.filter.address) {
  40652. args.address = params.filter.address;
  40653. }
  40654. // @TODO: We can handle slightly more complicated logs using the logs API
  40655. if (params.filter.topics && params.filter.topics.length > 0) {
  40656. if (params.filter.topics.length > 1) {
  40657. logger.throwError("unsupported topic count", logger_1.Logger.errors.UNSUPPORTED_OPERATION, { topics: params.filter.topics });
  40658. }
  40659. if (params.filter.topics.length === 1) {
  40660. topic0 = params.filter.topics[0];
  40661. if (typeof (topic0) !== "string" || topic0.length !== 66) {
  40662. logger.throwError("unsupported topic format", logger_1.Logger.errors.UNSUPPORTED_OPERATION, { topic0: topic0 });
  40663. }
  40664. args.topic0 = topic0;
  40665. }
  40666. }
  40667. return [4 /*yield*/, this.fetch("logs", args)];
  40668. case 20:
  40669. logs = _c.sent();
  40670. blocks = {};
  40671. i = 0;
  40672. _c.label = 21;
  40673. case 21:
  40674. if (!(i < logs.length)) return [3 /*break*/, 25];
  40675. log = logs[i];
  40676. if (log.blockHash != null) {
  40677. return [3 /*break*/, 24];
  40678. }
  40679. if (!(blocks[log.blockNumber] == null)) return [3 /*break*/, 23];
  40680. return [4 /*yield*/, this.getBlock(log.blockNumber)];
  40681. case 22:
  40682. block = _c.sent();
  40683. if (block) {
  40684. blocks[log.blockNumber] = block.hash;
  40685. }
  40686. _c.label = 23;
  40687. case 23:
  40688. log.blockHash = blocks[log.blockNumber];
  40689. _c.label = 24;
  40690. case 24:
  40691. i++;
  40692. return [3 /*break*/, 21];
  40693. case 25: return [2 /*return*/, logs];
  40694. case 26:
  40695. if (this.network.name !== "homestead") {
  40696. return [2 /*return*/, 0.0];
  40697. }
  40698. _b = parseFloat;
  40699. return [4 /*yield*/, this.fetch("stats", { action: "ethprice" })];
  40700. case 27: return [2 /*return*/, _b.apply(void 0, [(_c.sent()).ethusd])];
  40701. case 28: return [3 /*break*/, 29];
  40702. case 29: return [2 /*return*/, _super.prototype.perform.call(this, method, params)];
  40703. }
  40704. });
  40705. });
  40706. };
  40707. // Note: The `page` page parameter only allows pagination within the
  40708. // 10,000 window available without a page and offset parameter
  40709. // Error: Result window is too large, PageNo x Offset size must
  40710. // be less than or equal to 10000
  40711. EtherscanProvider.prototype.getHistory = function (addressOrName, startBlock, endBlock) {
  40712. return __awaiter(this, void 0, void 0, function () {
  40713. var params, result;
  40714. var _a;
  40715. var _this = this;
  40716. return __generator(this, function (_b) {
  40717. switch (_b.label) {
  40718. case 0:
  40719. _a = {
  40720. action: "txlist"
  40721. };
  40722. return [4 /*yield*/, this.resolveName(addressOrName)];
  40723. case 1:
  40724. params = (_a.address = (_b.sent()),
  40725. _a.startblock = ((startBlock == null) ? 0 : startBlock),
  40726. _a.endblock = ((endBlock == null) ? 99999999 : endBlock),
  40727. _a.sort = "asc",
  40728. _a);
  40729. return [4 /*yield*/, this.fetch("account", params)];
  40730. case 2:
  40731. result = _b.sent();
  40732. return [2 /*return*/, result.map(function (tx) {
  40733. ["contractAddress", "to"].forEach(function (key) {
  40734. if (tx[key] == "") {
  40735. delete tx[key];
  40736. }
  40737. });
  40738. if (tx.creates == null && tx.contractAddress != null) {
  40739. tx.creates = tx.contractAddress;
  40740. }
  40741. var item = _this.formatter.transactionResponse(tx);
  40742. if (tx.timeStamp) {
  40743. item.timestamp = parseInt(tx.timeStamp);
  40744. }
  40745. return item;
  40746. })];
  40747. }
  40748. });
  40749. });
  40750. };
  40751. EtherscanProvider.prototype.isCommunityResource = function () {
  40752. return (this.apiKey === defaultApiKey);
  40753. };
  40754. return EtherscanProvider;
  40755. }(base_provider_1.BaseProvider));
  40756. exports.EtherscanProvider = EtherscanProvider;
  40757. },{"./_version":230,"./base-provider":232,"./formatter":238,"@ethersproject/bytes":199,"@ethersproject/logger":223,"@ethersproject/properties":229,"@ethersproject/transactions":269,"@ethersproject/web":276}],237:[function(_dereq_,module,exports){
  40758. "use strict";
  40759. var __extends = (this && this.__extends) || (function () {
  40760. var extendStatics = function (d, b) {
  40761. extendStatics = Object.setPrototypeOf ||
  40762. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  40763. function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
  40764. return extendStatics(d, b);
  40765. };
  40766. return function (d, b) {
  40767. if (typeof b !== "function" && b !== null)
  40768. throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
  40769. extendStatics(d, b);
  40770. function __() { this.constructor = d; }
  40771. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  40772. };
  40773. })();
  40774. var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
  40775. function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
  40776. return new (P || (P = Promise))(function (resolve, reject) {
  40777. function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
  40778. function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
  40779. function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
  40780. step((generator = generator.apply(thisArg, _arguments || [])).next());
  40781. });
  40782. };
  40783. var __generator = (this && this.__generator) || function (thisArg, body) {
  40784. var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
  40785. return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
  40786. function verb(n) { return function (v) { return step([n, v]); }; }
  40787. function step(op) {
  40788. if (f) throw new TypeError("Generator is already executing.");
  40789. while (_) try {
  40790. if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
  40791. if (y = 0, t) op = [op[0] & 2, t.value];
  40792. switch (op[0]) {
  40793. case 0: case 1: t = op; break;
  40794. case 4: _.label++; return { value: op[1], done: false };
  40795. case 5: _.label++; y = op[1]; op = [0]; continue;
  40796. case 7: op = _.ops.pop(); _.trys.pop(); continue;
  40797. default:
  40798. if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
  40799. if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
  40800. if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
  40801. if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
  40802. if (t[2]) _.ops.pop();
  40803. _.trys.pop(); continue;
  40804. }
  40805. op = body.call(thisArg, _);
  40806. } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
  40807. if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
  40808. }
  40809. };
  40810. Object.defineProperty(exports, "__esModule", { value: true });
  40811. exports.FallbackProvider = void 0;
  40812. var abstract_provider_1 = _dereq_("@ethersproject/abstract-provider");
  40813. var bignumber_1 = _dereq_("@ethersproject/bignumber");
  40814. var bytes_1 = _dereq_("@ethersproject/bytes");
  40815. var properties_1 = _dereq_("@ethersproject/properties");
  40816. var random_1 = _dereq_("@ethersproject/random");
  40817. var web_1 = _dereq_("@ethersproject/web");
  40818. var base_provider_1 = _dereq_("./base-provider");
  40819. var formatter_1 = _dereq_("./formatter");
  40820. var logger_1 = _dereq_("@ethersproject/logger");
  40821. var _version_1 = _dereq_("./_version");
  40822. var logger = new logger_1.Logger(_version_1.version);
  40823. function now() { return (new Date()).getTime(); }
  40824. // Returns to network as long as all agree, or null if any is null.
  40825. // Throws an error if any two networks do not match.
  40826. function checkNetworks(networks) {
  40827. var result = null;
  40828. for (var i = 0; i < networks.length; i++) {
  40829. var network = networks[i];
  40830. // Null! We do not know our network; bail.
  40831. if (network == null) {
  40832. return null;
  40833. }
  40834. if (result) {
  40835. // Make sure the network matches the previous networks
  40836. if (!(result.name === network.name && result.chainId === network.chainId &&
  40837. ((result.ensAddress === network.ensAddress) || (result.ensAddress == null && network.ensAddress == null)))) {
  40838. logger.throwArgumentError("provider mismatch", "networks", networks);
  40839. }
  40840. }
  40841. else {
  40842. result = network;
  40843. }
  40844. }
  40845. return result;
  40846. }
  40847. function median(values, maxDelta) {
  40848. values = values.slice().sort();
  40849. var middle = Math.floor(values.length / 2);
  40850. // Odd length; take the middle
  40851. if (values.length % 2) {
  40852. return values[middle];
  40853. }
  40854. // Even length; take the average of the two middle
  40855. var a = values[middle - 1], b = values[middle];
  40856. if (maxDelta != null && Math.abs(a - b) > maxDelta) {
  40857. return null;
  40858. }
  40859. return (a + b) / 2;
  40860. }
  40861. function serialize(value) {
  40862. if (value === null) {
  40863. return "null";
  40864. }
  40865. else if (typeof (value) === "number" || typeof (value) === "boolean") {
  40866. return JSON.stringify(value);
  40867. }
  40868. else if (typeof (value) === "string") {
  40869. return value;
  40870. }
  40871. else if (bignumber_1.BigNumber.isBigNumber(value)) {
  40872. return value.toString();
  40873. }
  40874. else if (Array.isArray(value)) {
  40875. return JSON.stringify(value.map(function (i) { return serialize(i); }));
  40876. }
  40877. else if (typeof (value) === "object") {
  40878. var keys = Object.keys(value);
  40879. keys.sort();
  40880. return "{" + keys.map(function (key) {
  40881. var v = value[key];
  40882. if (typeof (v) === "function") {
  40883. v = "[function]";
  40884. }
  40885. else {
  40886. v = serialize(v);
  40887. }
  40888. return JSON.stringify(key) + ":" + v;
  40889. }).join(",") + "}";
  40890. }
  40891. throw new Error("unknown value type: " + typeof (value));
  40892. }
  40893. // Next request ID to use for emitting debug info
  40894. var nextRid = 1;
  40895. ;
  40896. function stall(duration) {
  40897. var cancel = null;
  40898. var timer = null;
  40899. var promise = (new Promise(function (resolve) {
  40900. cancel = function () {
  40901. if (timer) {
  40902. clearTimeout(timer);
  40903. timer = null;
  40904. }
  40905. resolve();
  40906. };
  40907. timer = setTimeout(cancel, duration);
  40908. }));
  40909. var wait = function (func) {
  40910. promise = promise.then(func);
  40911. return promise;
  40912. };
  40913. function getPromise() {
  40914. return promise;
  40915. }
  40916. return { cancel: cancel, getPromise: getPromise, wait: wait };
  40917. }
  40918. var ForwardErrors = [
  40919. logger_1.Logger.errors.CALL_EXCEPTION,
  40920. logger_1.Logger.errors.INSUFFICIENT_FUNDS,
  40921. logger_1.Logger.errors.NONCE_EXPIRED,
  40922. logger_1.Logger.errors.REPLACEMENT_UNDERPRICED,
  40923. logger_1.Logger.errors.UNPREDICTABLE_GAS_LIMIT
  40924. ];
  40925. var ForwardProperties = [
  40926. "address",
  40927. "args",
  40928. "errorArgs",
  40929. "errorSignature",
  40930. "method",
  40931. "transaction",
  40932. ];
  40933. ;
  40934. function exposeDebugConfig(config, now) {
  40935. var result = {
  40936. weight: config.weight
  40937. };
  40938. Object.defineProperty(result, "provider", { get: function () { return config.provider; } });
  40939. if (config.start) {
  40940. result.start = config.start;
  40941. }
  40942. if (now) {
  40943. result.duration = (now - config.start);
  40944. }
  40945. if (config.done) {
  40946. if (config.error) {
  40947. result.error = config.error;
  40948. }
  40949. else {
  40950. result.result = config.result || null;
  40951. }
  40952. }
  40953. return result;
  40954. }
  40955. function normalizedTally(normalize, quorum) {
  40956. return function (configs) {
  40957. // Count the votes for each result
  40958. var tally = {};
  40959. configs.forEach(function (c) {
  40960. var value = normalize(c.result);
  40961. if (!tally[value]) {
  40962. tally[value] = { count: 0, result: c.result };
  40963. }
  40964. tally[value].count++;
  40965. });
  40966. // Check for a quorum on any given result
  40967. var keys = Object.keys(tally);
  40968. for (var i = 0; i < keys.length; i++) {
  40969. var check = tally[keys[i]];
  40970. if (check.count >= quorum) {
  40971. return check.result;
  40972. }
  40973. }
  40974. // No quroum
  40975. return undefined;
  40976. };
  40977. }
  40978. function getProcessFunc(provider, method, params) {
  40979. var normalize = serialize;
  40980. switch (method) {
  40981. case "getBlockNumber":
  40982. // Return the median value, unless there is (median + 1) is also
  40983. // present, in which case that is probably true and the median
  40984. // is going to be stale soon. In the event of a malicious node,
  40985. // the lie will be true soon enough.
  40986. return function (configs) {
  40987. var values = configs.map(function (c) { return c.result; });
  40988. // Get the median block number
  40989. var blockNumber = median(configs.map(function (c) { return c.result; }), 2);
  40990. if (blockNumber == null) {
  40991. return undefined;
  40992. }
  40993. blockNumber = Math.ceil(blockNumber);
  40994. // If the next block height is present, its prolly safe to use
  40995. if (values.indexOf(blockNumber + 1) >= 0) {
  40996. blockNumber++;
  40997. }
  40998. // Don't ever roll back the blockNumber
  40999. if (blockNumber >= provider._highestBlockNumber) {
  41000. provider._highestBlockNumber = blockNumber;
  41001. }
  41002. return provider._highestBlockNumber;
  41003. };
  41004. case "getGasPrice":
  41005. // Return the middle (round index up) value, similar to median
  41006. // but do not average even entries and choose the higher.
  41007. // Malicious actors must compromise 50% of the nodes to lie.
  41008. return function (configs) {
  41009. var values = configs.map(function (c) { return c.result; });
  41010. values.sort();
  41011. return values[Math.floor(values.length / 2)];
  41012. };
  41013. case "getEtherPrice":
  41014. // Returns the median price. Malicious actors must compromise at
  41015. // least 50% of the nodes to lie (in a meaningful way).
  41016. return function (configs) {
  41017. return median(configs.map(function (c) { return c.result; }));
  41018. };
  41019. // No additional normalizing required; serialize is enough
  41020. case "getBalance":
  41021. case "getTransactionCount":
  41022. case "getCode":
  41023. case "getStorageAt":
  41024. case "call":
  41025. case "estimateGas":
  41026. case "getLogs":
  41027. break;
  41028. // We drop the confirmations from transactions as it is approximate
  41029. case "getTransaction":
  41030. case "getTransactionReceipt":
  41031. normalize = function (tx) {
  41032. if (tx == null) {
  41033. return null;
  41034. }
  41035. tx = (0, properties_1.shallowCopy)(tx);
  41036. tx.confirmations = -1;
  41037. return serialize(tx);
  41038. };
  41039. break;
  41040. // We drop the confirmations from transactions as it is approximate
  41041. case "getBlock":
  41042. // We drop the confirmations from transactions as it is approximate
  41043. if (params.includeTransactions) {
  41044. normalize = function (block) {
  41045. if (block == null) {
  41046. return null;
  41047. }
  41048. block = (0, properties_1.shallowCopy)(block);
  41049. block.transactions = block.transactions.map(function (tx) {
  41050. tx = (0, properties_1.shallowCopy)(tx);
  41051. tx.confirmations = -1;
  41052. return tx;
  41053. });
  41054. return serialize(block);
  41055. };
  41056. }
  41057. else {
  41058. normalize = function (block) {
  41059. if (block == null) {
  41060. return null;
  41061. }
  41062. return serialize(block);
  41063. };
  41064. }
  41065. break;
  41066. default:
  41067. throw new Error("unknown method: " + method);
  41068. }
  41069. // Return the result if and only if the expected quorum is
  41070. // satisfied and agreed upon for the final result.
  41071. return normalizedTally(normalize, provider.quorum);
  41072. }
  41073. // If we are doing a blockTag query, we need to make sure the backend is
  41074. // caught up to the FallbackProvider, before sending a request to it.
  41075. function waitForSync(config, blockNumber) {
  41076. return __awaiter(this, void 0, void 0, function () {
  41077. var provider;
  41078. return __generator(this, function (_a) {
  41079. provider = (config.provider);
  41080. if ((provider.blockNumber != null && provider.blockNumber >= blockNumber) || blockNumber === -1) {
  41081. return [2 /*return*/, provider];
  41082. }
  41083. return [2 /*return*/, (0, web_1.poll)(function () {
  41084. return new Promise(function (resolve, reject) {
  41085. setTimeout(function () {
  41086. // We are synced
  41087. if (provider.blockNumber >= blockNumber) {
  41088. return resolve(provider);
  41089. }
  41090. // We're done; just quit
  41091. if (config.cancelled) {
  41092. return resolve(null);
  41093. }
  41094. // Try again, next block
  41095. return resolve(undefined);
  41096. }, 0);
  41097. });
  41098. }, { oncePoll: provider })];
  41099. });
  41100. });
  41101. }
  41102. function getRunner(config, currentBlockNumber, method, params) {
  41103. return __awaiter(this, void 0, void 0, function () {
  41104. var provider, _a, filter;
  41105. return __generator(this, function (_b) {
  41106. switch (_b.label) {
  41107. case 0:
  41108. provider = config.provider;
  41109. _a = method;
  41110. switch (_a) {
  41111. case "getBlockNumber": return [3 /*break*/, 1];
  41112. case "getGasPrice": return [3 /*break*/, 1];
  41113. case "getEtherPrice": return [3 /*break*/, 2];
  41114. case "getBalance": return [3 /*break*/, 3];
  41115. case "getTransactionCount": return [3 /*break*/, 3];
  41116. case "getCode": return [3 /*break*/, 3];
  41117. case "getStorageAt": return [3 /*break*/, 6];
  41118. case "getBlock": return [3 /*break*/, 9];
  41119. case "call": return [3 /*break*/, 12];
  41120. case "estimateGas": return [3 /*break*/, 12];
  41121. case "getTransaction": return [3 /*break*/, 15];
  41122. case "getTransactionReceipt": return [3 /*break*/, 15];
  41123. case "getLogs": return [3 /*break*/, 16];
  41124. }
  41125. return [3 /*break*/, 19];
  41126. case 1: return [2 /*return*/, provider[method]()];
  41127. case 2:
  41128. if (provider.getEtherPrice) {
  41129. return [2 /*return*/, provider.getEtherPrice()];
  41130. }
  41131. return [3 /*break*/, 19];
  41132. case 3:
  41133. if (!(params.blockTag && (0, bytes_1.isHexString)(params.blockTag))) return [3 /*break*/, 5];
  41134. return [4 /*yield*/, waitForSync(config, currentBlockNumber)];
  41135. case 4:
  41136. provider = _b.sent();
  41137. _b.label = 5;
  41138. case 5: return [2 /*return*/, provider[method](params.address, params.blockTag || "latest")];
  41139. case 6:
  41140. if (!(params.blockTag && (0, bytes_1.isHexString)(params.blockTag))) return [3 /*break*/, 8];
  41141. return [4 /*yield*/, waitForSync(config, currentBlockNumber)];
  41142. case 7:
  41143. provider = _b.sent();
  41144. _b.label = 8;
  41145. case 8: return [2 /*return*/, provider.getStorageAt(params.address, params.position, params.blockTag || "latest")];
  41146. case 9:
  41147. if (!(params.blockTag && (0, bytes_1.isHexString)(params.blockTag))) return [3 /*break*/, 11];
  41148. return [4 /*yield*/, waitForSync(config, currentBlockNumber)];
  41149. case 10:
  41150. provider = _b.sent();
  41151. _b.label = 11;
  41152. case 11: return [2 /*return*/, provider[(params.includeTransactions ? "getBlockWithTransactions" : "getBlock")](params.blockTag || params.blockHash)];
  41153. case 12:
  41154. if (!(params.blockTag && (0, bytes_1.isHexString)(params.blockTag))) return [3 /*break*/, 14];
  41155. return [4 /*yield*/, waitForSync(config, currentBlockNumber)];
  41156. case 13:
  41157. provider = _b.sent();
  41158. _b.label = 14;
  41159. case 14: return [2 /*return*/, provider[method](params.transaction)];
  41160. case 15: return [2 /*return*/, provider[method](params.transactionHash)];
  41161. case 16:
  41162. filter = params.filter;
  41163. if (!((filter.fromBlock && (0, bytes_1.isHexString)(filter.fromBlock)) || (filter.toBlock && (0, bytes_1.isHexString)(filter.toBlock)))) return [3 /*break*/, 18];
  41164. return [4 /*yield*/, waitForSync(config, currentBlockNumber)];
  41165. case 17:
  41166. provider = _b.sent();
  41167. _b.label = 18;
  41168. case 18: return [2 /*return*/, provider.getLogs(filter)];
  41169. case 19: return [2 /*return*/, logger.throwError("unknown method error", logger_1.Logger.errors.UNKNOWN_ERROR, {
  41170. method: method,
  41171. params: params
  41172. })];
  41173. }
  41174. });
  41175. });
  41176. }
  41177. var FallbackProvider = /** @class */ (function (_super) {
  41178. __extends(FallbackProvider, _super);
  41179. function FallbackProvider(providers, quorum) {
  41180. var _newTarget = this.constructor;
  41181. var _this = this;
  41182. logger.checkNew(_newTarget, FallbackProvider);
  41183. if (providers.length === 0) {
  41184. logger.throwArgumentError("missing providers", "providers", providers);
  41185. }
  41186. var providerConfigs = providers.map(function (configOrProvider, index) {
  41187. if (abstract_provider_1.Provider.isProvider(configOrProvider)) {
  41188. var stallTimeout = (0, formatter_1.isCommunityResource)(configOrProvider) ? 2000 : 750;
  41189. var priority = 1;
  41190. return Object.freeze({ provider: configOrProvider, weight: 1, stallTimeout: stallTimeout, priority: priority });
  41191. }
  41192. var config = (0, properties_1.shallowCopy)(configOrProvider);
  41193. if (config.priority == null) {
  41194. config.priority = 1;
  41195. }
  41196. if (config.stallTimeout == null) {
  41197. config.stallTimeout = (0, formatter_1.isCommunityResource)(configOrProvider) ? 2000 : 750;
  41198. }
  41199. if (config.weight == null) {
  41200. config.weight = 1;
  41201. }
  41202. var weight = config.weight;
  41203. if (weight % 1 || weight > 512 || weight < 1) {
  41204. logger.throwArgumentError("invalid weight; must be integer in [1, 512]", "providers[" + index + "].weight", weight);
  41205. }
  41206. return Object.freeze(config);
  41207. });
  41208. var total = providerConfigs.reduce(function (accum, c) { return (accum + c.weight); }, 0);
  41209. if (quorum == null) {
  41210. quorum = total / 2;
  41211. }
  41212. else if (quorum > total) {
  41213. logger.throwArgumentError("quorum will always fail; larger than total weight", "quorum", quorum);
  41214. }
  41215. // Are all providers' networks are known
  41216. var networkOrReady = checkNetworks(providerConfigs.map(function (c) { return (c.provider).network; }));
  41217. // Not all networks are known; we must stall
  41218. if (networkOrReady == null) {
  41219. networkOrReady = new Promise(function (resolve, reject) {
  41220. setTimeout(function () {
  41221. _this.detectNetwork().then(resolve, reject);
  41222. }, 0);
  41223. });
  41224. }
  41225. _this = _super.call(this, networkOrReady) || this;
  41226. // Preserve a copy, so we do not get mutated
  41227. (0, properties_1.defineReadOnly)(_this, "providerConfigs", Object.freeze(providerConfigs));
  41228. (0, properties_1.defineReadOnly)(_this, "quorum", quorum);
  41229. _this._highestBlockNumber = -1;
  41230. return _this;
  41231. }
  41232. FallbackProvider.prototype.detectNetwork = function () {
  41233. return __awaiter(this, void 0, void 0, function () {
  41234. var networks;
  41235. return __generator(this, function (_a) {
  41236. switch (_a.label) {
  41237. case 0: return [4 /*yield*/, Promise.all(this.providerConfigs.map(function (c) { return c.provider.getNetwork(); }))];
  41238. case 1:
  41239. networks = _a.sent();
  41240. return [2 /*return*/, checkNetworks(networks)];
  41241. }
  41242. });
  41243. });
  41244. };
  41245. FallbackProvider.prototype.perform = function (method, params) {
  41246. return __awaiter(this, void 0, void 0, function () {
  41247. var results, i_1, result, processFunc, configs, currentBlockNumber, i, first, _loop_1, this_1, state_1;
  41248. var _this = this;
  41249. return __generator(this, function (_a) {
  41250. switch (_a.label) {
  41251. case 0:
  41252. if (!(method === "sendTransaction")) return [3 /*break*/, 2];
  41253. return [4 /*yield*/, Promise.all(this.providerConfigs.map(function (c) {
  41254. return c.provider.sendTransaction(params.signedTransaction).then(function (result) {
  41255. return result.hash;
  41256. }, function (error) {
  41257. return error;
  41258. });
  41259. }))];
  41260. case 1:
  41261. results = _a.sent();
  41262. // Any success is good enough (other errors are likely "already seen" errors
  41263. for (i_1 = 0; i_1 < results.length; i_1++) {
  41264. result = results[i_1];
  41265. if (typeof (result) === "string") {
  41266. return [2 /*return*/, result];
  41267. }
  41268. }
  41269. // They were all an error; pick the first error
  41270. throw results[0];
  41271. case 2:
  41272. if (!(this._highestBlockNumber === -1 && method !== "getBlockNumber")) return [3 /*break*/, 4];
  41273. return [4 /*yield*/, this.getBlockNumber()];
  41274. case 3:
  41275. _a.sent();
  41276. _a.label = 4;
  41277. case 4:
  41278. processFunc = getProcessFunc(this, method, params);
  41279. configs = (0, random_1.shuffled)(this.providerConfigs.map(properties_1.shallowCopy));
  41280. configs.sort(function (a, b) { return (a.priority - b.priority); });
  41281. currentBlockNumber = this._highestBlockNumber;
  41282. i = 0;
  41283. first = true;
  41284. _loop_1 = function () {
  41285. var t0, inflightWeight, _loop_2, waiting, results, result, errors;
  41286. return __generator(this, function (_b) {
  41287. switch (_b.label) {
  41288. case 0:
  41289. t0 = now();
  41290. inflightWeight = configs.filter(function (c) { return (c.runner && ((t0 - c.start) < c.stallTimeout)); })
  41291. .reduce(function (accum, c) { return (accum + c.weight); }, 0);
  41292. _loop_2 = function () {
  41293. var config = configs[i++];
  41294. var rid = nextRid++;
  41295. config.start = now();
  41296. config.staller = stall(config.stallTimeout);
  41297. config.staller.wait(function () { config.staller = null; });
  41298. config.runner = getRunner(config, currentBlockNumber, method, params).then(function (result) {
  41299. config.done = true;
  41300. config.result = result;
  41301. if (_this.listenerCount("debug")) {
  41302. _this.emit("debug", {
  41303. action: "request",
  41304. rid: rid,
  41305. backend: exposeDebugConfig(config, now()),
  41306. request: { method: method, params: (0, properties_1.deepCopy)(params) },
  41307. provider: _this
  41308. });
  41309. }
  41310. }, function (error) {
  41311. config.done = true;
  41312. config.error = error;
  41313. if (_this.listenerCount("debug")) {
  41314. _this.emit("debug", {
  41315. action: "request",
  41316. rid: rid,
  41317. backend: exposeDebugConfig(config, now()),
  41318. request: { method: method, params: (0, properties_1.deepCopy)(params) },
  41319. provider: _this
  41320. });
  41321. }
  41322. });
  41323. if (this_1.listenerCount("debug")) {
  41324. this_1.emit("debug", {
  41325. action: "request",
  41326. rid: rid,
  41327. backend: exposeDebugConfig(config, null),
  41328. request: { method: method, params: (0, properties_1.deepCopy)(params) },
  41329. provider: this_1
  41330. });
  41331. }
  41332. inflightWeight += config.weight;
  41333. };
  41334. // Start running enough to meet quorum
  41335. while (inflightWeight < this_1.quorum && i < configs.length) {
  41336. _loop_2();
  41337. }
  41338. waiting = [];
  41339. configs.forEach(function (c) {
  41340. if (c.done || !c.runner) {
  41341. return;
  41342. }
  41343. waiting.push(c.runner);
  41344. if (c.staller) {
  41345. waiting.push(c.staller.getPromise());
  41346. }
  41347. });
  41348. if (!waiting.length) return [3 /*break*/, 2];
  41349. return [4 /*yield*/, Promise.race(waiting)];
  41350. case 1:
  41351. _b.sent();
  41352. _b.label = 2;
  41353. case 2:
  41354. results = configs.filter(function (c) { return (c.done && c.error == null); });
  41355. if (!(results.length >= this_1.quorum)) return [3 /*break*/, 5];
  41356. result = processFunc(results);
  41357. if (result !== undefined) {
  41358. // Shut down any stallers
  41359. configs.forEach(function (c) {
  41360. if (c.staller) {
  41361. c.staller.cancel();
  41362. }
  41363. c.cancelled = true;
  41364. });
  41365. return [2 /*return*/, { value: result }];
  41366. }
  41367. if (!!first) return [3 /*break*/, 4];
  41368. return [4 /*yield*/, stall(100).getPromise()];
  41369. case 3:
  41370. _b.sent();
  41371. _b.label = 4;
  41372. case 4:
  41373. first = false;
  41374. _b.label = 5;
  41375. case 5:
  41376. errors = configs.reduce(function (accum, c) {
  41377. if (!c.done || c.error == null) {
  41378. return accum;
  41379. }
  41380. var code = (c.error).code;
  41381. if (ForwardErrors.indexOf(code) >= 0) {
  41382. if (!accum[code]) {
  41383. accum[code] = { error: c.error, weight: 0 };
  41384. }
  41385. accum[code].weight += c.weight;
  41386. }
  41387. return accum;
  41388. }, ({}));
  41389. Object.keys(errors).forEach(function (errorCode) {
  41390. var tally = errors[errorCode];
  41391. if (tally.weight < _this.quorum) {
  41392. return;
  41393. }
  41394. // Shut down any stallers
  41395. configs.forEach(function (c) {
  41396. if (c.staller) {
  41397. c.staller.cancel();
  41398. }
  41399. c.cancelled = true;
  41400. });
  41401. var e = (tally.error);
  41402. var props = {};
  41403. ForwardProperties.forEach(function (name) {
  41404. if (e[name] == null) {
  41405. return;
  41406. }
  41407. props[name] = e[name];
  41408. });
  41409. logger.throwError(e.reason || e.message, errorCode, props);
  41410. });
  41411. // All configs have run to completion; we will never get more data
  41412. if (configs.filter(function (c) { return !c.done; }).length === 0) {
  41413. return [2 /*return*/, "break"];
  41414. }
  41415. return [2 /*return*/];
  41416. }
  41417. });
  41418. };
  41419. this_1 = this;
  41420. _a.label = 5;
  41421. case 5:
  41422. if (!true) return [3 /*break*/, 7];
  41423. return [5 /*yield**/, _loop_1()];
  41424. case 6:
  41425. state_1 = _a.sent();
  41426. if (typeof state_1 === "object")
  41427. return [2 /*return*/, state_1.value];
  41428. if (state_1 === "break")
  41429. return [3 /*break*/, 7];
  41430. return [3 /*break*/, 5];
  41431. case 7:
  41432. // Shut down any stallers; shouldn't be any
  41433. configs.forEach(function (c) {
  41434. if (c.staller) {
  41435. c.staller.cancel();
  41436. }
  41437. c.cancelled = true;
  41438. });
  41439. return [2 /*return*/, logger.throwError("failed to meet quorum", logger_1.Logger.errors.SERVER_ERROR, {
  41440. method: method,
  41441. params: params,
  41442. //results: configs.map((c) => c.result),
  41443. //errors: configs.map((c) => c.error),
  41444. results: configs.map(function (c) { return exposeDebugConfig(c); }),
  41445. provider: this
  41446. })];
  41447. }
  41448. });
  41449. });
  41450. };
  41451. return FallbackProvider;
  41452. }(base_provider_1.BaseProvider));
  41453. exports.FallbackProvider = FallbackProvider;
  41454. },{"./_version":230,"./base-provider":232,"./formatter":238,"@ethersproject/abstract-provider":185,"@ethersproject/bignumber":196,"@ethersproject/bytes":199,"@ethersproject/logger":223,"@ethersproject/properties":229,"@ethersproject/random":250,"@ethersproject/web":276}],238:[function(_dereq_,module,exports){
  41455. "use strict";
  41456. Object.defineProperty(exports, "__esModule", { value: true });
  41457. exports.showThrottleMessage = exports.isCommunityResource = exports.isCommunityResourcable = exports.Formatter = void 0;
  41458. var address_1 = _dereq_("@ethersproject/address");
  41459. var bignumber_1 = _dereq_("@ethersproject/bignumber");
  41460. var bytes_1 = _dereq_("@ethersproject/bytes");
  41461. var constants_1 = _dereq_("@ethersproject/constants");
  41462. var properties_1 = _dereq_("@ethersproject/properties");
  41463. var transactions_1 = _dereq_("@ethersproject/transactions");
  41464. var logger_1 = _dereq_("@ethersproject/logger");
  41465. var _version_1 = _dereq_("./_version");
  41466. var logger = new logger_1.Logger(_version_1.version);
  41467. var Formatter = /** @class */ (function () {
  41468. function Formatter() {
  41469. var _newTarget = this.constructor;
  41470. logger.checkNew(_newTarget, Formatter);
  41471. this.formats = this.getDefaultFormats();
  41472. }
  41473. Formatter.prototype.getDefaultFormats = function () {
  41474. var _this = this;
  41475. var formats = ({});
  41476. var address = this.address.bind(this);
  41477. var bigNumber = this.bigNumber.bind(this);
  41478. var blockTag = this.blockTag.bind(this);
  41479. var data = this.data.bind(this);
  41480. var hash = this.hash.bind(this);
  41481. var hex = this.hex.bind(this);
  41482. var number = this.number.bind(this);
  41483. var type = this.type.bind(this);
  41484. var strictData = function (v) { return _this.data(v, true); };
  41485. formats.transaction = {
  41486. hash: hash,
  41487. type: type,
  41488. accessList: Formatter.allowNull(this.accessList.bind(this), null),
  41489. blockHash: Formatter.allowNull(hash, null),
  41490. blockNumber: Formatter.allowNull(number, null),
  41491. transactionIndex: Formatter.allowNull(number, null),
  41492. confirmations: Formatter.allowNull(number, null),
  41493. from: address,
  41494. // either (gasPrice) or (maxPriorityFeePerGas + maxFeePerGas)
  41495. // must be set
  41496. gasPrice: Formatter.allowNull(bigNumber),
  41497. maxPriorityFeePerGas: Formatter.allowNull(bigNumber),
  41498. maxFeePerGas: Formatter.allowNull(bigNumber),
  41499. gasLimit: bigNumber,
  41500. to: Formatter.allowNull(address, null),
  41501. value: bigNumber,
  41502. nonce: number,
  41503. data: data,
  41504. r: Formatter.allowNull(this.uint256),
  41505. s: Formatter.allowNull(this.uint256),
  41506. v: Formatter.allowNull(number),
  41507. creates: Formatter.allowNull(address, null),
  41508. raw: Formatter.allowNull(data),
  41509. };
  41510. formats.transactionRequest = {
  41511. from: Formatter.allowNull(address),
  41512. nonce: Formatter.allowNull(number),
  41513. gasLimit: Formatter.allowNull(bigNumber),
  41514. gasPrice: Formatter.allowNull(bigNumber),
  41515. maxPriorityFeePerGas: Formatter.allowNull(bigNumber),
  41516. maxFeePerGas: Formatter.allowNull(bigNumber),
  41517. to: Formatter.allowNull(address),
  41518. value: Formatter.allowNull(bigNumber),
  41519. data: Formatter.allowNull(strictData),
  41520. type: Formatter.allowNull(number),
  41521. accessList: Formatter.allowNull(this.accessList.bind(this), null),
  41522. };
  41523. formats.receiptLog = {
  41524. transactionIndex: number,
  41525. blockNumber: number,
  41526. transactionHash: hash,
  41527. address: address,
  41528. topics: Formatter.arrayOf(hash),
  41529. data: data,
  41530. logIndex: number,
  41531. blockHash: hash,
  41532. };
  41533. formats.receipt = {
  41534. to: Formatter.allowNull(this.address, null),
  41535. from: Formatter.allowNull(this.address, null),
  41536. contractAddress: Formatter.allowNull(address, null),
  41537. transactionIndex: number,
  41538. // should be allowNull(hash), but broken-EIP-658 support is handled in receipt
  41539. root: Formatter.allowNull(hex),
  41540. gasUsed: bigNumber,
  41541. logsBloom: Formatter.allowNull(data),
  41542. blockHash: hash,
  41543. transactionHash: hash,
  41544. logs: Formatter.arrayOf(this.receiptLog.bind(this)),
  41545. blockNumber: number,
  41546. confirmations: Formatter.allowNull(number, null),
  41547. cumulativeGasUsed: bigNumber,
  41548. effectiveGasPrice: Formatter.allowNull(bigNumber),
  41549. status: Formatter.allowNull(number),
  41550. type: type
  41551. };
  41552. formats.block = {
  41553. hash: Formatter.allowNull(hash),
  41554. parentHash: hash,
  41555. number: number,
  41556. timestamp: number,
  41557. nonce: Formatter.allowNull(hex),
  41558. difficulty: this.difficulty.bind(this),
  41559. gasLimit: bigNumber,
  41560. gasUsed: bigNumber,
  41561. miner: Formatter.allowNull(address),
  41562. extraData: data,
  41563. transactions: Formatter.allowNull(Formatter.arrayOf(hash)),
  41564. baseFeePerGas: Formatter.allowNull(bigNumber)
  41565. };
  41566. formats.blockWithTransactions = (0, properties_1.shallowCopy)(formats.block);
  41567. formats.blockWithTransactions.transactions = Formatter.allowNull(Formatter.arrayOf(this.transactionResponse.bind(this)));
  41568. formats.filter = {
  41569. fromBlock: Formatter.allowNull(blockTag, undefined),
  41570. toBlock: Formatter.allowNull(blockTag, undefined),
  41571. blockHash: Formatter.allowNull(hash, undefined),
  41572. address: Formatter.allowNull(address, undefined),
  41573. topics: Formatter.allowNull(this.topics.bind(this), undefined),
  41574. };
  41575. formats.filterLog = {
  41576. blockNumber: Formatter.allowNull(number),
  41577. blockHash: Formatter.allowNull(hash),
  41578. transactionIndex: number,
  41579. removed: Formatter.allowNull(this.boolean.bind(this)),
  41580. address: address,
  41581. data: Formatter.allowFalsish(data, "0x"),
  41582. topics: Formatter.arrayOf(hash),
  41583. transactionHash: hash,
  41584. logIndex: number,
  41585. };
  41586. return formats;
  41587. };
  41588. Formatter.prototype.accessList = function (accessList) {
  41589. return (0, transactions_1.accessListify)(accessList || []);
  41590. };
  41591. // Requires a BigNumberish that is within the IEEE754 safe integer range; returns a number
  41592. // Strict! Used on input.
  41593. Formatter.prototype.number = function (number) {
  41594. if (number === "0x") {
  41595. return 0;
  41596. }
  41597. return bignumber_1.BigNumber.from(number).toNumber();
  41598. };
  41599. Formatter.prototype.type = function (number) {
  41600. if (number === "0x" || number == null) {
  41601. return 0;
  41602. }
  41603. return bignumber_1.BigNumber.from(number).toNumber();
  41604. };
  41605. // Strict! Used on input.
  41606. Formatter.prototype.bigNumber = function (value) {
  41607. return bignumber_1.BigNumber.from(value);
  41608. };
  41609. // Requires a boolean, "true" or "false"; returns a boolean
  41610. Formatter.prototype.boolean = function (value) {
  41611. if (typeof (value) === "boolean") {
  41612. return value;
  41613. }
  41614. if (typeof (value) === "string") {
  41615. value = value.toLowerCase();
  41616. if (value === "true") {
  41617. return true;
  41618. }
  41619. if (value === "false") {
  41620. return false;
  41621. }
  41622. }
  41623. throw new Error("invalid boolean - " + value);
  41624. };
  41625. Formatter.prototype.hex = function (value, strict) {
  41626. if (typeof (value) === "string") {
  41627. if (!strict && value.substring(0, 2) !== "0x") {
  41628. value = "0x" + value;
  41629. }
  41630. if ((0, bytes_1.isHexString)(value)) {
  41631. return value.toLowerCase();
  41632. }
  41633. }
  41634. return logger.throwArgumentError("invalid hash", "value", value);
  41635. };
  41636. Formatter.prototype.data = function (value, strict) {
  41637. var result = this.hex(value, strict);
  41638. if ((result.length % 2) !== 0) {
  41639. throw new Error("invalid data; odd-length - " + value);
  41640. }
  41641. return result;
  41642. };
  41643. // Requires an address
  41644. // Strict! Used on input.
  41645. Formatter.prototype.address = function (value) {
  41646. return (0, address_1.getAddress)(value);
  41647. };
  41648. Formatter.prototype.callAddress = function (value) {
  41649. if (!(0, bytes_1.isHexString)(value, 32)) {
  41650. return null;
  41651. }
  41652. var address = (0, address_1.getAddress)((0, bytes_1.hexDataSlice)(value, 12));
  41653. return (address === constants_1.AddressZero) ? null : address;
  41654. };
  41655. Formatter.prototype.contractAddress = function (value) {
  41656. return (0, address_1.getContractAddress)(value);
  41657. };
  41658. // Strict! Used on input.
  41659. Formatter.prototype.blockTag = function (blockTag) {
  41660. if (blockTag == null) {
  41661. return "latest";
  41662. }
  41663. if (blockTag === "earliest") {
  41664. return "0x0";
  41665. }
  41666. if (blockTag === "latest" || blockTag === "pending") {
  41667. return blockTag;
  41668. }
  41669. if (typeof (blockTag) === "number" || (0, bytes_1.isHexString)(blockTag)) {
  41670. return (0, bytes_1.hexValue)(blockTag);
  41671. }
  41672. throw new Error("invalid blockTag");
  41673. };
  41674. // Requires a hash, optionally requires 0x prefix; returns prefixed lowercase hash.
  41675. Formatter.prototype.hash = function (value, strict) {
  41676. var result = this.hex(value, strict);
  41677. if ((0, bytes_1.hexDataLength)(result) !== 32) {
  41678. return logger.throwArgumentError("invalid hash", "value", value);
  41679. }
  41680. return result;
  41681. };
  41682. // Returns the difficulty as a number, or if too large (i.e. PoA network) null
  41683. Formatter.prototype.difficulty = function (value) {
  41684. if (value == null) {
  41685. return null;
  41686. }
  41687. var v = bignumber_1.BigNumber.from(value);
  41688. try {
  41689. return v.toNumber();
  41690. }
  41691. catch (error) { }
  41692. return null;
  41693. };
  41694. Formatter.prototype.uint256 = function (value) {
  41695. if (!(0, bytes_1.isHexString)(value)) {
  41696. throw new Error("invalid uint256");
  41697. }
  41698. return (0, bytes_1.hexZeroPad)(value, 32);
  41699. };
  41700. Formatter.prototype._block = function (value, format) {
  41701. if (value.author != null && value.miner == null) {
  41702. value.miner = value.author;
  41703. }
  41704. // The difficulty may need to come from _difficulty in recursed blocks
  41705. var difficulty = (value._difficulty != null) ? value._difficulty : value.difficulty;
  41706. var result = Formatter.check(format, value);
  41707. result._difficulty = ((difficulty == null) ? null : bignumber_1.BigNumber.from(difficulty));
  41708. return result;
  41709. };
  41710. Formatter.prototype.block = function (value) {
  41711. return this._block(value, this.formats.block);
  41712. };
  41713. Formatter.prototype.blockWithTransactions = function (value) {
  41714. return this._block(value, this.formats.blockWithTransactions);
  41715. };
  41716. // Strict! Used on input.
  41717. Formatter.prototype.transactionRequest = function (value) {
  41718. return Formatter.check(this.formats.transactionRequest, value);
  41719. };
  41720. Formatter.prototype.transactionResponse = function (transaction) {
  41721. // Rename gas to gasLimit
  41722. if (transaction.gas != null && transaction.gasLimit == null) {
  41723. transaction.gasLimit = transaction.gas;
  41724. }
  41725. // Some clients (TestRPC) do strange things like return 0x0 for the
  41726. // 0 address; correct this to be a real address
  41727. if (transaction.to && bignumber_1.BigNumber.from(transaction.to).isZero()) {
  41728. transaction.to = "0x0000000000000000000000000000000000000000";
  41729. }
  41730. // Rename input to data
  41731. if (transaction.input != null && transaction.data == null) {
  41732. transaction.data = transaction.input;
  41733. }
  41734. // If to and creates are empty, populate the creates from the transaction
  41735. if (transaction.to == null && transaction.creates == null) {
  41736. transaction.creates = this.contractAddress(transaction);
  41737. }
  41738. if ((transaction.type === 1 || transaction.type === 2) && transaction.accessList == null) {
  41739. transaction.accessList = [];
  41740. }
  41741. var result = Formatter.check(this.formats.transaction, transaction);
  41742. if (transaction.chainId != null) {
  41743. var chainId = transaction.chainId;
  41744. if ((0, bytes_1.isHexString)(chainId)) {
  41745. chainId = bignumber_1.BigNumber.from(chainId).toNumber();
  41746. }
  41747. result.chainId = chainId;
  41748. }
  41749. else {
  41750. var chainId = transaction.networkId;
  41751. // geth-etc returns chainId
  41752. if (chainId == null && result.v == null) {
  41753. chainId = transaction.chainId;
  41754. }
  41755. if ((0, bytes_1.isHexString)(chainId)) {
  41756. chainId = bignumber_1.BigNumber.from(chainId).toNumber();
  41757. }
  41758. if (typeof (chainId) !== "number" && result.v != null) {
  41759. chainId = (result.v - 35) / 2;
  41760. if (chainId < 0) {
  41761. chainId = 0;
  41762. }
  41763. chainId = parseInt(chainId);
  41764. }
  41765. if (typeof (chainId) !== "number") {
  41766. chainId = 0;
  41767. }
  41768. result.chainId = chainId;
  41769. }
  41770. // 0x0000... should actually be null
  41771. if (result.blockHash && result.blockHash.replace(/0/g, "") === "x") {
  41772. result.blockHash = null;
  41773. }
  41774. return result;
  41775. };
  41776. Formatter.prototype.transaction = function (value) {
  41777. return (0, transactions_1.parse)(value);
  41778. };
  41779. Formatter.prototype.receiptLog = function (value) {
  41780. return Formatter.check(this.formats.receiptLog, value);
  41781. };
  41782. Formatter.prototype.receipt = function (value) {
  41783. var result = Formatter.check(this.formats.receipt, value);
  41784. // RSK incorrectly implemented EIP-658, so we munge things a bit here for it
  41785. if (result.root != null) {
  41786. if (result.root.length <= 4) {
  41787. // Could be 0x00, 0x0, 0x01 or 0x1
  41788. var value_1 = bignumber_1.BigNumber.from(result.root).toNumber();
  41789. if (value_1 === 0 || value_1 === 1) {
  41790. // Make sure if both are specified, they match
  41791. if (result.status != null && (result.status !== value_1)) {
  41792. logger.throwArgumentError("alt-root-status/status mismatch", "value", { root: result.root, status: result.status });
  41793. }
  41794. result.status = value_1;
  41795. delete result.root;
  41796. }
  41797. else {
  41798. logger.throwArgumentError("invalid alt-root-status", "value.root", result.root);
  41799. }
  41800. }
  41801. else if (result.root.length !== 66) {
  41802. // Must be a valid bytes32
  41803. logger.throwArgumentError("invalid root hash", "value.root", result.root);
  41804. }
  41805. }
  41806. if (result.status != null) {
  41807. result.byzantium = true;
  41808. }
  41809. return result;
  41810. };
  41811. Formatter.prototype.topics = function (value) {
  41812. var _this = this;
  41813. if (Array.isArray(value)) {
  41814. return value.map(function (v) { return _this.topics(v); });
  41815. }
  41816. else if (value != null) {
  41817. return this.hash(value, true);
  41818. }
  41819. return null;
  41820. };
  41821. Formatter.prototype.filter = function (value) {
  41822. return Formatter.check(this.formats.filter, value);
  41823. };
  41824. Formatter.prototype.filterLog = function (value) {
  41825. return Formatter.check(this.formats.filterLog, value);
  41826. };
  41827. Formatter.check = function (format, object) {
  41828. var result = {};
  41829. for (var key in format) {
  41830. try {
  41831. var value = format[key](object[key]);
  41832. if (value !== undefined) {
  41833. result[key] = value;
  41834. }
  41835. }
  41836. catch (error) {
  41837. error.checkKey = key;
  41838. error.checkValue = object[key];
  41839. throw error;
  41840. }
  41841. }
  41842. return result;
  41843. };
  41844. // if value is null-ish, nullValue is returned
  41845. Formatter.allowNull = function (format, nullValue) {
  41846. return (function (value) {
  41847. if (value == null) {
  41848. return nullValue;
  41849. }
  41850. return format(value);
  41851. });
  41852. };
  41853. // If value is false-ish, replaceValue is returned
  41854. Formatter.allowFalsish = function (format, replaceValue) {
  41855. return (function (value) {
  41856. if (!value) {
  41857. return replaceValue;
  41858. }
  41859. return format(value);
  41860. });
  41861. };
  41862. // Requires an Array satisfying check
  41863. Formatter.arrayOf = function (format) {
  41864. return (function (array) {
  41865. if (!Array.isArray(array)) {
  41866. throw new Error("not an array");
  41867. }
  41868. var result = [];
  41869. array.forEach(function (value) {
  41870. result.push(format(value));
  41871. });
  41872. return result;
  41873. });
  41874. };
  41875. return Formatter;
  41876. }());
  41877. exports.Formatter = Formatter;
  41878. function isCommunityResourcable(value) {
  41879. return (value && typeof (value.isCommunityResource) === "function");
  41880. }
  41881. exports.isCommunityResourcable = isCommunityResourcable;
  41882. function isCommunityResource(value) {
  41883. return (isCommunityResourcable(value) && value.isCommunityResource());
  41884. }
  41885. exports.isCommunityResource = isCommunityResource;
  41886. // Show the throttle message only once
  41887. var throttleMessage = false;
  41888. function showThrottleMessage() {
  41889. if (throttleMessage) {
  41890. return;
  41891. }
  41892. throttleMessage = true;
  41893. console.log("========= NOTICE =========");
  41894. console.log("Request-Rate Exceeded (this message will not be repeated)");
  41895. console.log("");
  41896. console.log("The default API keys for each service are provided as a highly-throttled,");
  41897. console.log("community resource for low-traffic projects and early prototyping.");
  41898. console.log("");
  41899. console.log("While your application will continue to function, we highly recommended");
  41900. console.log("signing up for your own API keys to improve performance, increase your");
  41901. console.log("request rate/limit and enable other perks, such as metrics and advanced APIs.");
  41902. console.log("");
  41903. console.log("For more details: https:/\/docs.ethers.io/api-keys/");
  41904. console.log("==========================");
  41905. }
  41906. exports.showThrottleMessage = showThrottleMessage;
  41907. },{"./_version":230,"@ethersproject/address":189,"@ethersproject/bignumber":196,"@ethersproject/bytes":199,"@ethersproject/constants":203,"@ethersproject/logger":223,"@ethersproject/properties":229,"@ethersproject/transactions":269}],239:[function(_dereq_,module,exports){
  41908. "use strict";
  41909. Object.defineProperty(exports, "__esModule", { value: true });
  41910. exports.Formatter = exports.showThrottleMessage = exports.isCommunityResourcable = exports.isCommunityResource = exports.getNetwork = exports.getDefaultProvider = exports.JsonRpcSigner = exports.IpcProvider = exports.WebSocketProvider = exports.Web3Provider = exports.StaticJsonRpcProvider = exports.PocketProvider = exports.NodesmithProvider = exports.JsonRpcBatchProvider = exports.JsonRpcProvider = exports.InfuraWebSocketProvider = exports.InfuraProvider = exports.EtherscanProvider = exports.CloudflareProvider = exports.AlchemyWebSocketProvider = exports.AlchemyProvider = exports.FallbackProvider = exports.UrlJsonRpcProvider = exports.Resolver = exports.BaseProvider = exports.Provider = void 0;
  41911. var abstract_provider_1 = _dereq_("@ethersproject/abstract-provider");
  41912. Object.defineProperty(exports, "Provider", { enumerable: true, get: function () { return abstract_provider_1.Provider; } });
  41913. var networks_1 = _dereq_("@ethersproject/networks");
  41914. Object.defineProperty(exports, "getNetwork", { enumerable: true, get: function () { return networks_1.getNetwork; } });
  41915. var base_provider_1 = _dereq_("./base-provider");
  41916. Object.defineProperty(exports, "BaseProvider", { enumerable: true, get: function () { return base_provider_1.BaseProvider; } });
  41917. Object.defineProperty(exports, "Resolver", { enumerable: true, get: function () { return base_provider_1.Resolver; } });
  41918. var alchemy_provider_1 = _dereq_("./alchemy-provider");
  41919. Object.defineProperty(exports, "AlchemyProvider", { enumerable: true, get: function () { return alchemy_provider_1.AlchemyProvider; } });
  41920. Object.defineProperty(exports, "AlchemyWebSocketProvider", { enumerable: true, get: function () { return alchemy_provider_1.AlchemyWebSocketProvider; } });
  41921. var cloudflare_provider_1 = _dereq_("./cloudflare-provider");
  41922. Object.defineProperty(exports, "CloudflareProvider", { enumerable: true, get: function () { return cloudflare_provider_1.CloudflareProvider; } });
  41923. var etherscan_provider_1 = _dereq_("./etherscan-provider");
  41924. Object.defineProperty(exports, "EtherscanProvider", { enumerable: true, get: function () { return etherscan_provider_1.EtherscanProvider; } });
  41925. var fallback_provider_1 = _dereq_("./fallback-provider");
  41926. Object.defineProperty(exports, "FallbackProvider", { enumerable: true, get: function () { return fallback_provider_1.FallbackProvider; } });
  41927. var ipc_provider_1 = _dereq_("./ipc-provider");
  41928. Object.defineProperty(exports, "IpcProvider", { enumerable: true, get: function () { return ipc_provider_1.IpcProvider; } });
  41929. var infura_provider_1 = _dereq_("./infura-provider");
  41930. Object.defineProperty(exports, "InfuraProvider", { enumerable: true, get: function () { return infura_provider_1.InfuraProvider; } });
  41931. Object.defineProperty(exports, "InfuraWebSocketProvider", { enumerable: true, get: function () { return infura_provider_1.InfuraWebSocketProvider; } });
  41932. var json_rpc_provider_1 = _dereq_("./json-rpc-provider");
  41933. Object.defineProperty(exports, "JsonRpcProvider", { enumerable: true, get: function () { return json_rpc_provider_1.JsonRpcProvider; } });
  41934. Object.defineProperty(exports, "JsonRpcSigner", { enumerable: true, get: function () { return json_rpc_provider_1.JsonRpcSigner; } });
  41935. var json_rpc_batch_provider_1 = _dereq_("./json-rpc-batch-provider");
  41936. Object.defineProperty(exports, "JsonRpcBatchProvider", { enumerable: true, get: function () { return json_rpc_batch_provider_1.JsonRpcBatchProvider; } });
  41937. var nodesmith_provider_1 = _dereq_("./nodesmith-provider");
  41938. Object.defineProperty(exports, "NodesmithProvider", { enumerable: true, get: function () { return nodesmith_provider_1.NodesmithProvider; } });
  41939. var pocket_provider_1 = _dereq_("./pocket-provider");
  41940. Object.defineProperty(exports, "PocketProvider", { enumerable: true, get: function () { return pocket_provider_1.PocketProvider; } });
  41941. var url_json_rpc_provider_1 = _dereq_("./url-json-rpc-provider");
  41942. Object.defineProperty(exports, "StaticJsonRpcProvider", { enumerable: true, get: function () { return url_json_rpc_provider_1.StaticJsonRpcProvider; } });
  41943. Object.defineProperty(exports, "UrlJsonRpcProvider", { enumerable: true, get: function () { return url_json_rpc_provider_1.UrlJsonRpcProvider; } });
  41944. var web3_provider_1 = _dereq_("./web3-provider");
  41945. Object.defineProperty(exports, "Web3Provider", { enumerable: true, get: function () { return web3_provider_1.Web3Provider; } });
  41946. var websocket_provider_1 = _dereq_("./websocket-provider");
  41947. Object.defineProperty(exports, "WebSocketProvider", { enumerable: true, get: function () { return websocket_provider_1.WebSocketProvider; } });
  41948. var formatter_1 = _dereq_("./formatter");
  41949. Object.defineProperty(exports, "Formatter", { enumerable: true, get: function () { return formatter_1.Formatter; } });
  41950. Object.defineProperty(exports, "isCommunityResourcable", { enumerable: true, get: function () { return formatter_1.isCommunityResourcable; } });
  41951. Object.defineProperty(exports, "isCommunityResource", { enumerable: true, get: function () { return formatter_1.isCommunityResource; } });
  41952. Object.defineProperty(exports, "showThrottleMessage", { enumerable: true, get: function () { return formatter_1.showThrottleMessage; } });
  41953. var logger_1 = _dereq_("@ethersproject/logger");
  41954. var _version_1 = _dereq_("./_version");
  41955. var logger = new logger_1.Logger(_version_1.version);
  41956. ////////////////////////
  41957. // Helper Functions
  41958. function getDefaultProvider(network, options) {
  41959. if (network == null) {
  41960. network = "homestead";
  41961. }
  41962. // If passed a URL, figure out the right type of provider based on the scheme
  41963. if (typeof (network) === "string") {
  41964. // @TODO: Add support for IpcProvider; maybe if it ends in ".ipc"?
  41965. // Handle http and ws (and their secure variants)
  41966. var match = network.match(/^(ws|http)s?:/i);
  41967. if (match) {
  41968. switch (match[1]) {
  41969. case "http":
  41970. return new json_rpc_provider_1.JsonRpcProvider(network);
  41971. case "ws":
  41972. return new websocket_provider_1.WebSocketProvider(network);
  41973. default:
  41974. logger.throwArgumentError("unsupported URL scheme", "network", network);
  41975. }
  41976. }
  41977. }
  41978. var n = (0, networks_1.getNetwork)(network);
  41979. if (!n || !n._defaultProvider) {
  41980. logger.throwError("unsupported getDefaultProvider network", logger_1.Logger.errors.NETWORK_ERROR, {
  41981. operation: "getDefaultProvider",
  41982. network: network
  41983. });
  41984. }
  41985. return n._defaultProvider({
  41986. FallbackProvider: fallback_provider_1.FallbackProvider,
  41987. AlchemyProvider: alchemy_provider_1.AlchemyProvider,
  41988. CloudflareProvider: cloudflare_provider_1.CloudflareProvider,
  41989. EtherscanProvider: etherscan_provider_1.EtherscanProvider,
  41990. InfuraProvider: infura_provider_1.InfuraProvider,
  41991. JsonRpcProvider: json_rpc_provider_1.JsonRpcProvider,
  41992. NodesmithProvider: nodesmith_provider_1.NodesmithProvider,
  41993. PocketProvider: pocket_provider_1.PocketProvider,
  41994. Web3Provider: web3_provider_1.Web3Provider,
  41995. IpcProvider: ipc_provider_1.IpcProvider,
  41996. }, options);
  41997. }
  41998. exports.getDefaultProvider = getDefaultProvider;
  41999. },{"./_version":230,"./alchemy-provider":231,"./base-provider":232,"./cloudflare-provider":235,"./etherscan-provider":236,"./fallback-provider":237,"./formatter":238,"./infura-provider":240,"./ipc-provider":233,"./json-rpc-batch-provider":241,"./json-rpc-provider":242,"./nodesmith-provider":243,"./pocket-provider":244,"./url-json-rpc-provider":245,"./web3-provider":246,"./websocket-provider":247,"@ethersproject/abstract-provider":185,"@ethersproject/logger":223,"@ethersproject/networks":225}],240:[function(_dereq_,module,exports){
  42000. "use strict";
  42001. var __extends = (this && this.__extends) || (function () {
  42002. var extendStatics = function (d, b) {
  42003. extendStatics = Object.setPrototypeOf ||
  42004. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  42005. function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
  42006. return extendStatics(d, b);
  42007. };
  42008. return function (d, b) {
  42009. if (typeof b !== "function" && b !== null)
  42010. throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
  42011. extendStatics(d, b);
  42012. function __() { this.constructor = d; }
  42013. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  42014. };
  42015. })();
  42016. Object.defineProperty(exports, "__esModule", { value: true });
  42017. exports.InfuraProvider = exports.InfuraWebSocketProvider = void 0;
  42018. var properties_1 = _dereq_("@ethersproject/properties");
  42019. var websocket_provider_1 = _dereq_("./websocket-provider");
  42020. var formatter_1 = _dereq_("./formatter");
  42021. var logger_1 = _dereq_("@ethersproject/logger");
  42022. var _version_1 = _dereq_("./_version");
  42023. var logger = new logger_1.Logger(_version_1.version);
  42024. var url_json_rpc_provider_1 = _dereq_("./url-json-rpc-provider");
  42025. var defaultProjectId = "84842078b09946638c03157f83405213";
  42026. var InfuraWebSocketProvider = /** @class */ (function (_super) {
  42027. __extends(InfuraWebSocketProvider, _super);
  42028. function InfuraWebSocketProvider(network, apiKey) {
  42029. var _this = this;
  42030. var provider = new InfuraProvider(network, apiKey);
  42031. var connection = provider.connection;
  42032. if (connection.password) {
  42033. logger.throwError("INFURA WebSocket project secrets unsupported", logger_1.Logger.errors.UNSUPPORTED_OPERATION, {
  42034. operation: "InfuraProvider.getWebSocketProvider()"
  42035. });
  42036. }
  42037. var url = connection.url.replace(/^http/i, "ws").replace("/v3/", "/ws/v3/");
  42038. _this = _super.call(this, url, network) || this;
  42039. (0, properties_1.defineReadOnly)(_this, "apiKey", provider.projectId);
  42040. (0, properties_1.defineReadOnly)(_this, "projectId", provider.projectId);
  42041. (0, properties_1.defineReadOnly)(_this, "projectSecret", provider.projectSecret);
  42042. return _this;
  42043. }
  42044. InfuraWebSocketProvider.prototype.isCommunityResource = function () {
  42045. return (this.projectId === defaultProjectId);
  42046. };
  42047. return InfuraWebSocketProvider;
  42048. }(websocket_provider_1.WebSocketProvider));
  42049. exports.InfuraWebSocketProvider = InfuraWebSocketProvider;
  42050. var InfuraProvider = /** @class */ (function (_super) {
  42051. __extends(InfuraProvider, _super);
  42052. function InfuraProvider() {
  42053. return _super !== null && _super.apply(this, arguments) || this;
  42054. }
  42055. InfuraProvider.getWebSocketProvider = function (network, apiKey) {
  42056. return new InfuraWebSocketProvider(network, apiKey);
  42057. };
  42058. InfuraProvider.getApiKey = function (apiKey) {
  42059. var apiKeyObj = {
  42060. apiKey: defaultProjectId,
  42061. projectId: defaultProjectId,
  42062. projectSecret: null
  42063. };
  42064. if (apiKey == null) {
  42065. return apiKeyObj;
  42066. }
  42067. if (typeof (apiKey) === "string") {
  42068. apiKeyObj.projectId = apiKey;
  42069. }
  42070. else if (apiKey.projectSecret != null) {
  42071. logger.assertArgument((typeof (apiKey.projectId) === "string"), "projectSecret requires a projectId", "projectId", apiKey.projectId);
  42072. logger.assertArgument((typeof (apiKey.projectSecret) === "string"), "invalid projectSecret", "projectSecret", "[REDACTED]");
  42073. apiKeyObj.projectId = apiKey.projectId;
  42074. apiKeyObj.projectSecret = apiKey.projectSecret;
  42075. }
  42076. else if (apiKey.projectId) {
  42077. apiKeyObj.projectId = apiKey.projectId;
  42078. }
  42079. apiKeyObj.apiKey = apiKeyObj.projectId;
  42080. return apiKeyObj;
  42081. };
  42082. InfuraProvider.getUrl = function (network, apiKey) {
  42083. var host = null;
  42084. switch (network ? network.name : "unknown") {
  42085. case "homestead":
  42086. host = "mainnet.infura.io";
  42087. break;
  42088. case "ropsten":
  42089. host = "ropsten.infura.io";
  42090. break;
  42091. case "rinkeby":
  42092. host = "rinkeby.infura.io";
  42093. break;
  42094. case "kovan":
  42095. host = "kovan.infura.io";
  42096. break;
  42097. case "goerli":
  42098. host = "goerli.infura.io";
  42099. break;
  42100. case "matic":
  42101. host = "polygon-mainnet.infura.io";
  42102. break;
  42103. case "maticmum":
  42104. host = "polygon-mumbai.infura.io";
  42105. break;
  42106. case "optimism":
  42107. host = "optimism-mainnet.infura.io";
  42108. break;
  42109. case "optimism-kovan":
  42110. host = "optimism-kovan.infura.io";
  42111. break;
  42112. case "arbitrum":
  42113. host = "arbitrum-mainnet.infura.io";
  42114. break;
  42115. case "arbitrum-rinkeby":
  42116. host = "arbitrum-rinkeby.infura.io";
  42117. break;
  42118. default:
  42119. logger.throwError("unsupported network", logger_1.Logger.errors.INVALID_ARGUMENT, {
  42120. argument: "network",
  42121. value: network
  42122. });
  42123. }
  42124. var connection = {
  42125. allowGzip: true,
  42126. url: ("https:/" + "/" + host + "/v3/" + apiKey.projectId),
  42127. throttleCallback: function (attempt, url) {
  42128. if (apiKey.projectId === defaultProjectId) {
  42129. (0, formatter_1.showThrottleMessage)();
  42130. }
  42131. return Promise.resolve(true);
  42132. }
  42133. };
  42134. if (apiKey.projectSecret != null) {
  42135. connection.user = "";
  42136. connection.password = apiKey.projectSecret;
  42137. }
  42138. return connection;
  42139. };
  42140. InfuraProvider.prototype.isCommunityResource = function () {
  42141. return (this.projectId === defaultProjectId);
  42142. };
  42143. return InfuraProvider;
  42144. }(url_json_rpc_provider_1.UrlJsonRpcProvider));
  42145. exports.InfuraProvider = InfuraProvider;
  42146. },{"./_version":230,"./formatter":238,"./url-json-rpc-provider":245,"./websocket-provider":247,"@ethersproject/logger":223,"@ethersproject/properties":229}],241:[function(_dereq_,module,exports){
  42147. "use strict";
  42148. var __extends = (this && this.__extends) || (function () {
  42149. var extendStatics = function (d, b) {
  42150. extendStatics = Object.setPrototypeOf ||
  42151. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  42152. function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
  42153. return extendStatics(d, b);
  42154. };
  42155. return function (d, b) {
  42156. if (typeof b !== "function" && b !== null)
  42157. throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
  42158. extendStatics(d, b);
  42159. function __() { this.constructor = d; }
  42160. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  42161. };
  42162. })();
  42163. Object.defineProperty(exports, "__esModule", { value: true });
  42164. exports.JsonRpcBatchProvider = void 0;
  42165. var properties_1 = _dereq_("@ethersproject/properties");
  42166. var web_1 = _dereq_("@ethersproject/web");
  42167. var json_rpc_provider_1 = _dereq_("./json-rpc-provider");
  42168. // Experimental
  42169. var JsonRpcBatchProvider = /** @class */ (function (_super) {
  42170. __extends(JsonRpcBatchProvider, _super);
  42171. function JsonRpcBatchProvider() {
  42172. return _super !== null && _super.apply(this, arguments) || this;
  42173. }
  42174. JsonRpcBatchProvider.prototype.send = function (method, params) {
  42175. var _this = this;
  42176. var request = {
  42177. method: method,
  42178. params: params,
  42179. id: (this._nextId++),
  42180. jsonrpc: "2.0"
  42181. };
  42182. if (this._pendingBatch == null) {
  42183. this._pendingBatch = [];
  42184. }
  42185. var inflightRequest = { request: request, resolve: null, reject: null };
  42186. var promise = new Promise(function (resolve, reject) {
  42187. inflightRequest.resolve = resolve;
  42188. inflightRequest.reject = reject;
  42189. });
  42190. this._pendingBatch.push(inflightRequest);
  42191. if (!this._pendingBatchAggregator) {
  42192. // Schedule batch for next event loop + short duration
  42193. this._pendingBatchAggregator = setTimeout(function () {
  42194. // Get teh current batch and clear it, so new requests
  42195. // go into the next batch
  42196. var batch = _this._pendingBatch;
  42197. _this._pendingBatch = null;
  42198. _this._pendingBatchAggregator = null;
  42199. // Get the request as an array of requests
  42200. var request = batch.map(function (inflight) { return inflight.request; });
  42201. _this.emit("debug", {
  42202. action: "requestBatch",
  42203. request: (0, properties_1.deepCopy)(request),
  42204. provider: _this
  42205. });
  42206. return (0, web_1.fetchJson)(_this.connection, JSON.stringify(request)).then(function (result) {
  42207. _this.emit("debug", {
  42208. action: "response",
  42209. request: request,
  42210. response: result,
  42211. provider: _this
  42212. });
  42213. // For each result, feed it to the correct Promise, depending
  42214. // on whether it was a success or error
  42215. batch.forEach(function (inflightRequest, index) {
  42216. var payload = result[index];
  42217. if (payload.error) {
  42218. var error = new Error(payload.error.message);
  42219. error.code = payload.error.code;
  42220. error.data = payload.error.data;
  42221. inflightRequest.reject(error);
  42222. }
  42223. else {
  42224. inflightRequest.resolve(payload.result);
  42225. }
  42226. });
  42227. }, function (error) {
  42228. _this.emit("debug", {
  42229. action: "response",
  42230. error: error,
  42231. request: request,
  42232. provider: _this
  42233. });
  42234. batch.forEach(function (inflightRequest) {
  42235. inflightRequest.reject(error);
  42236. });
  42237. });
  42238. }, 10);
  42239. }
  42240. return promise;
  42241. };
  42242. return JsonRpcBatchProvider;
  42243. }(json_rpc_provider_1.JsonRpcProvider));
  42244. exports.JsonRpcBatchProvider = JsonRpcBatchProvider;
  42245. },{"./json-rpc-provider":242,"@ethersproject/properties":229,"@ethersproject/web":276}],242:[function(_dereq_,module,exports){
  42246. "use strict";
  42247. var __extends = (this && this.__extends) || (function () {
  42248. var extendStatics = function (d, b) {
  42249. extendStatics = Object.setPrototypeOf ||
  42250. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  42251. function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
  42252. return extendStatics(d, b);
  42253. };
  42254. return function (d, b) {
  42255. if (typeof b !== "function" && b !== null)
  42256. throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
  42257. extendStatics(d, b);
  42258. function __() { this.constructor = d; }
  42259. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  42260. };
  42261. })();
  42262. var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
  42263. function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
  42264. return new (P || (P = Promise))(function (resolve, reject) {
  42265. function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
  42266. function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
  42267. function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
  42268. step((generator = generator.apply(thisArg, _arguments || [])).next());
  42269. });
  42270. };
  42271. var __generator = (this && this.__generator) || function (thisArg, body) {
  42272. var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
  42273. return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
  42274. function verb(n) { return function (v) { return step([n, v]); }; }
  42275. function step(op) {
  42276. if (f) throw new TypeError("Generator is already executing.");
  42277. while (_) try {
  42278. if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
  42279. if (y = 0, t) op = [op[0] & 2, t.value];
  42280. switch (op[0]) {
  42281. case 0: case 1: t = op; break;
  42282. case 4: _.label++; return { value: op[1], done: false };
  42283. case 5: _.label++; y = op[1]; op = [0]; continue;
  42284. case 7: op = _.ops.pop(); _.trys.pop(); continue;
  42285. default:
  42286. if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
  42287. if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
  42288. if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
  42289. if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
  42290. if (t[2]) _.ops.pop();
  42291. _.trys.pop(); continue;
  42292. }
  42293. op = body.call(thisArg, _);
  42294. } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
  42295. if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
  42296. }
  42297. };
  42298. Object.defineProperty(exports, "__esModule", { value: true });
  42299. exports.JsonRpcProvider = exports.JsonRpcSigner = void 0;
  42300. var abstract_signer_1 = _dereq_("@ethersproject/abstract-signer");
  42301. var bignumber_1 = _dereq_("@ethersproject/bignumber");
  42302. var bytes_1 = _dereq_("@ethersproject/bytes");
  42303. var hash_1 = _dereq_("@ethersproject/hash");
  42304. var properties_1 = _dereq_("@ethersproject/properties");
  42305. var strings_1 = _dereq_("@ethersproject/strings");
  42306. var transactions_1 = _dereq_("@ethersproject/transactions");
  42307. var web_1 = _dereq_("@ethersproject/web");
  42308. var logger_1 = _dereq_("@ethersproject/logger");
  42309. var _version_1 = _dereq_("./_version");
  42310. var logger = new logger_1.Logger(_version_1.version);
  42311. var base_provider_1 = _dereq_("./base-provider");
  42312. var errorGas = ["call", "estimateGas"];
  42313. function checkError(method, error, params) {
  42314. // Undo the "convenience" some nodes are attempting to prevent backwards
  42315. // incompatibility; maybe for v6 consider forwarding reverts as errors
  42316. if (method === "call" && error.code === logger_1.Logger.errors.SERVER_ERROR) {
  42317. var e = error.error;
  42318. if (e && e.message.match("reverted") && (0, bytes_1.isHexString)(e.data)) {
  42319. return e.data;
  42320. }
  42321. logger.throwError("missing revert data in call exception", logger_1.Logger.errors.CALL_EXCEPTION, {
  42322. error: error,
  42323. data: "0x"
  42324. });
  42325. }
  42326. var message = error.message;
  42327. if (error.code === logger_1.Logger.errors.SERVER_ERROR && error.error && typeof (error.error.message) === "string") {
  42328. message = error.error.message;
  42329. }
  42330. else if (typeof (error.body) === "string") {
  42331. message = error.body;
  42332. }
  42333. else if (typeof (error.responseText) === "string") {
  42334. message = error.responseText;
  42335. }
  42336. message = (message || "").toLowerCase();
  42337. var transaction = params.transaction || params.signedTransaction;
  42338. // "insufficient funds for gas * price + value + cost(data)"
  42339. if (message.match(/insufficient funds|base fee exceeds gas limit/)) {
  42340. logger.throwError("insufficient funds for intrinsic transaction cost", logger_1.Logger.errors.INSUFFICIENT_FUNDS, {
  42341. error: error,
  42342. method: method,
  42343. transaction: transaction
  42344. });
  42345. }
  42346. // "nonce too low"
  42347. if (message.match(/nonce too low/)) {
  42348. logger.throwError("nonce has already been used", logger_1.Logger.errors.NONCE_EXPIRED, {
  42349. error: error,
  42350. method: method,
  42351. transaction: transaction
  42352. });
  42353. }
  42354. // "replacement transaction underpriced"
  42355. if (message.match(/replacement transaction underpriced/)) {
  42356. logger.throwError("replacement fee too low", logger_1.Logger.errors.REPLACEMENT_UNDERPRICED, {
  42357. error: error,
  42358. method: method,
  42359. transaction: transaction
  42360. });
  42361. }
  42362. // "replacement transaction underpriced"
  42363. if (message.match(/only replay-protected/)) {
  42364. logger.throwError("legacy pre-eip-155 transactions not supported", logger_1.Logger.errors.UNSUPPORTED_OPERATION, {
  42365. error: error,
  42366. method: method,
  42367. transaction: transaction
  42368. });
  42369. }
  42370. if (errorGas.indexOf(method) >= 0 && message.match(/gas required exceeds allowance|always failing transaction|execution reverted/)) {
  42371. logger.throwError("cannot estimate gas; transaction may fail or may require manual gas limit", logger_1.Logger.errors.UNPREDICTABLE_GAS_LIMIT, {
  42372. error: error,
  42373. method: method,
  42374. transaction: transaction
  42375. });
  42376. }
  42377. throw error;
  42378. }
  42379. function timer(timeout) {
  42380. return new Promise(function (resolve) {
  42381. setTimeout(resolve, timeout);
  42382. });
  42383. }
  42384. function getResult(payload) {
  42385. if (payload.error) {
  42386. // @TODO: not any
  42387. var error = new Error(payload.error.message);
  42388. error.code = payload.error.code;
  42389. error.data = payload.error.data;
  42390. throw error;
  42391. }
  42392. return payload.result;
  42393. }
  42394. function getLowerCase(value) {
  42395. if (value) {
  42396. return value.toLowerCase();
  42397. }
  42398. return value;
  42399. }
  42400. var _constructorGuard = {};
  42401. var JsonRpcSigner = /** @class */ (function (_super) {
  42402. __extends(JsonRpcSigner, _super);
  42403. function JsonRpcSigner(constructorGuard, provider, addressOrIndex) {
  42404. var _newTarget = this.constructor;
  42405. var _this = this;
  42406. logger.checkNew(_newTarget, JsonRpcSigner);
  42407. _this = _super.call(this) || this;
  42408. if (constructorGuard !== _constructorGuard) {
  42409. throw new Error("do not call the JsonRpcSigner constructor directly; use provider.getSigner");
  42410. }
  42411. (0, properties_1.defineReadOnly)(_this, "provider", provider);
  42412. if (addressOrIndex == null) {
  42413. addressOrIndex = 0;
  42414. }
  42415. if (typeof (addressOrIndex) === "string") {
  42416. (0, properties_1.defineReadOnly)(_this, "_address", _this.provider.formatter.address(addressOrIndex));
  42417. (0, properties_1.defineReadOnly)(_this, "_index", null);
  42418. }
  42419. else if (typeof (addressOrIndex) === "number") {
  42420. (0, properties_1.defineReadOnly)(_this, "_index", addressOrIndex);
  42421. (0, properties_1.defineReadOnly)(_this, "_address", null);
  42422. }
  42423. else {
  42424. logger.throwArgumentError("invalid address or index", "addressOrIndex", addressOrIndex);
  42425. }
  42426. return _this;
  42427. }
  42428. JsonRpcSigner.prototype.connect = function (provider) {
  42429. return logger.throwError("cannot alter JSON-RPC Signer connection", logger_1.Logger.errors.UNSUPPORTED_OPERATION, {
  42430. operation: "connect"
  42431. });
  42432. };
  42433. JsonRpcSigner.prototype.connectUnchecked = function () {
  42434. return new UncheckedJsonRpcSigner(_constructorGuard, this.provider, this._address || this._index);
  42435. };
  42436. JsonRpcSigner.prototype.getAddress = function () {
  42437. var _this = this;
  42438. if (this._address) {
  42439. return Promise.resolve(this._address);
  42440. }
  42441. return this.provider.send("eth_accounts", []).then(function (accounts) {
  42442. if (accounts.length <= _this._index) {
  42443. logger.throwError("unknown account #" + _this._index, logger_1.Logger.errors.UNSUPPORTED_OPERATION, {
  42444. operation: "getAddress"
  42445. });
  42446. }
  42447. return _this.provider.formatter.address(accounts[_this._index]);
  42448. });
  42449. };
  42450. JsonRpcSigner.prototype.sendUncheckedTransaction = function (transaction) {
  42451. var _this = this;
  42452. transaction = (0, properties_1.shallowCopy)(transaction);
  42453. var fromAddress = this.getAddress().then(function (address) {
  42454. if (address) {
  42455. address = address.toLowerCase();
  42456. }
  42457. return address;
  42458. });
  42459. // The JSON-RPC for eth_sendTransaction uses 90000 gas; if the user
  42460. // wishes to use this, it is easy to specify explicitly, otherwise
  42461. // we look it up for them.
  42462. if (transaction.gasLimit == null) {
  42463. var estimate = (0, properties_1.shallowCopy)(transaction);
  42464. estimate.from = fromAddress;
  42465. transaction.gasLimit = this.provider.estimateGas(estimate);
  42466. }
  42467. if (transaction.to != null) {
  42468. transaction.to = Promise.resolve(transaction.to).then(function (to) { return __awaiter(_this, void 0, void 0, function () {
  42469. var address;
  42470. return __generator(this, function (_a) {
  42471. switch (_a.label) {
  42472. case 0:
  42473. if (to == null) {
  42474. return [2 /*return*/, null];
  42475. }
  42476. return [4 /*yield*/, this.provider.resolveName(to)];
  42477. case 1:
  42478. address = _a.sent();
  42479. if (address == null) {
  42480. logger.throwArgumentError("provided ENS name resolves to null", "tx.to", to);
  42481. }
  42482. return [2 /*return*/, address];
  42483. }
  42484. });
  42485. }); });
  42486. }
  42487. return (0, properties_1.resolveProperties)({
  42488. tx: (0, properties_1.resolveProperties)(transaction),
  42489. sender: fromAddress
  42490. }).then(function (_a) {
  42491. var tx = _a.tx, sender = _a.sender;
  42492. if (tx.from != null) {
  42493. if (tx.from.toLowerCase() !== sender) {
  42494. logger.throwArgumentError("from address mismatch", "transaction", transaction);
  42495. }
  42496. }
  42497. else {
  42498. tx.from = sender;
  42499. }
  42500. var hexTx = _this.provider.constructor.hexlifyTransaction(tx, { from: true });
  42501. return _this.provider.send("eth_sendTransaction", [hexTx]).then(function (hash) {
  42502. return hash;
  42503. }, function (error) {
  42504. return checkError("sendTransaction", error, hexTx);
  42505. });
  42506. });
  42507. };
  42508. JsonRpcSigner.prototype.signTransaction = function (transaction) {
  42509. return logger.throwError("signing transactions is unsupported", logger_1.Logger.errors.UNSUPPORTED_OPERATION, {
  42510. operation: "signTransaction"
  42511. });
  42512. };
  42513. JsonRpcSigner.prototype.sendTransaction = function (transaction) {
  42514. return __awaiter(this, void 0, void 0, function () {
  42515. var blockNumber, hash, error_1;
  42516. var _this = this;
  42517. return __generator(this, function (_a) {
  42518. switch (_a.label) {
  42519. case 0: return [4 /*yield*/, this.provider._getInternalBlockNumber(100 + 2 * this.provider.pollingInterval)];
  42520. case 1:
  42521. blockNumber = _a.sent();
  42522. return [4 /*yield*/, this.sendUncheckedTransaction(transaction)];
  42523. case 2:
  42524. hash = _a.sent();
  42525. _a.label = 3;
  42526. case 3:
  42527. _a.trys.push([3, 5, , 6]);
  42528. return [4 /*yield*/, (0, web_1.poll)(function () { return __awaiter(_this, void 0, void 0, function () {
  42529. var tx;
  42530. return __generator(this, function (_a) {
  42531. switch (_a.label) {
  42532. case 0: return [4 /*yield*/, this.provider.getTransaction(hash)];
  42533. case 1:
  42534. tx = _a.sent();
  42535. if (tx === null) {
  42536. return [2 /*return*/, undefined];
  42537. }
  42538. return [2 /*return*/, this.provider._wrapTransaction(tx, hash, blockNumber)];
  42539. }
  42540. });
  42541. }); }, { oncePoll: this.provider })];
  42542. case 4:
  42543. // Unfortunately, JSON-RPC only provides and opaque transaction hash
  42544. // for a response, and we need the actual transaction, so we poll
  42545. // for it; it should show up very quickly
  42546. return [2 /*return*/, _a.sent()];
  42547. case 5:
  42548. error_1 = _a.sent();
  42549. error_1.transactionHash = hash;
  42550. throw error_1;
  42551. case 6: return [2 /*return*/];
  42552. }
  42553. });
  42554. });
  42555. };
  42556. JsonRpcSigner.prototype.signMessage = function (message) {
  42557. return __awaiter(this, void 0, void 0, function () {
  42558. var data, address;
  42559. return __generator(this, function (_a) {
  42560. switch (_a.label) {
  42561. case 0:
  42562. data = ((typeof (message) === "string") ? (0, strings_1.toUtf8Bytes)(message) : message);
  42563. return [4 /*yield*/, this.getAddress()];
  42564. case 1:
  42565. address = _a.sent();
  42566. return [4 /*yield*/, this.provider.send("personal_sign", [(0, bytes_1.hexlify)(data), address.toLowerCase()])];
  42567. case 2: return [2 /*return*/, _a.sent()];
  42568. }
  42569. });
  42570. });
  42571. };
  42572. JsonRpcSigner.prototype._legacySignMessage = function (message) {
  42573. return __awaiter(this, void 0, void 0, function () {
  42574. var data, address;
  42575. return __generator(this, function (_a) {
  42576. switch (_a.label) {
  42577. case 0:
  42578. data = ((typeof (message) === "string") ? (0, strings_1.toUtf8Bytes)(message) : message);
  42579. return [4 /*yield*/, this.getAddress()];
  42580. case 1:
  42581. address = _a.sent();
  42582. return [4 /*yield*/, this.provider.send("eth_sign", [address.toLowerCase(), (0, bytes_1.hexlify)(data)])];
  42583. case 2:
  42584. // https://github.com/ethereum/wiki/wiki/JSON-RPC#eth_sign
  42585. return [2 /*return*/, _a.sent()];
  42586. }
  42587. });
  42588. });
  42589. };
  42590. JsonRpcSigner.prototype._signTypedData = function (domain, types, value) {
  42591. return __awaiter(this, void 0, void 0, function () {
  42592. var populated, address;
  42593. var _this = this;
  42594. return __generator(this, function (_a) {
  42595. switch (_a.label) {
  42596. case 0: return [4 /*yield*/, hash_1._TypedDataEncoder.resolveNames(domain, types, value, function (name) {
  42597. return _this.provider.resolveName(name);
  42598. })];
  42599. case 1:
  42600. populated = _a.sent();
  42601. return [4 /*yield*/, this.getAddress()];
  42602. case 2:
  42603. address = _a.sent();
  42604. return [4 /*yield*/, this.provider.send("eth_signTypedData_v4", [
  42605. address.toLowerCase(),
  42606. JSON.stringify(hash_1._TypedDataEncoder.getPayload(populated.domain, types, populated.value))
  42607. ])];
  42608. case 3: return [2 /*return*/, _a.sent()];
  42609. }
  42610. });
  42611. });
  42612. };
  42613. JsonRpcSigner.prototype.unlock = function (password) {
  42614. return __awaiter(this, void 0, void 0, function () {
  42615. var provider, address;
  42616. return __generator(this, function (_a) {
  42617. switch (_a.label) {
  42618. case 0:
  42619. provider = this.provider;
  42620. return [4 /*yield*/, this.getAddress()];
  42621. case 1:
  42622. address = _a.sent();
  42623. return [2 /*return*/, provider.send("personal_unlockAccount", [address.toLowerCase(), password, null])];
  42624. }
  42625. });
  42626. });
  42627. };
  42628. return JsonRpcSigner;
  42629. }(abstract_signer_1.Signer));
  42630. exports.JsonRpcSigner = JsonRpcSigner;
  42631. var UncheckedJsonRpcSigner = /** @class */ (function (_super) {
  42632. __extends(UncheckedJsonRpcSigner, _super);
  42633. function UncheckedJsonRpcSigner() {
  42634. return _super !== null && _super.apply(this, arguments) || this;
  42635. }
  42636. UncheckedJsonRpcSigner.prototype.sendTransaction = function (transaction) {
  42637. var _this = this;
  42638. return this.sendUncheckedTransaction(transaction).then(function (hash) {
  42639. return {
  42640. hash: hash,
  42641. nonce: null,
  42642. gasLimit: null,
  42643. gasPrice: null,
  42644. data: null,
  42645. value: null,
  42646. chainId: null,
  42647. confirmations: 0,
  42648. from: null,
  42649. wait: function (confirmations) { return _this.provider.waitForTransaction(hash, confirmations); }
  42650. };
  42651. });
  42652. };
  42653. return UncheckedJsonRpcSigner;
  42654. }(JsonRpcSigner));
  42655. var allowedTransactionKeys = {
  42656. chainId: true, data: true, gasLimit: true, gasPrice: true, nonce: true, to: true, value: true,
  42657. type: true, accessList: true,
  42658. maxFeePerGas: true, maxPriorityFeePerGas: true
  42659. };
  42660. var JsonRpcProvider = /** @class */ (function (_super) {
  42661. __extends(JsonRpcProvider, _super);
  42662. function JsonRpcProvider(url, network) {
  42663. var _newTarget = this.constructor;
  42664. var _this = this;
  42665. logger.checkNew(_newTarget, JsonRpcProvider);
  42666. var networkOrReady = network;
  42667. // The network is unknown, query the JSON-RPC for it
  42668. if (networkOrReady == null) {
  42669. networkOrReady = new Promise(function (resolve, reject) {
  42670. setTimeout(function () {
  42671. _this.detectNetwork().then(function (network) {
  42672. resolve(network);
  42673. }, function (error) {
  42674. reject(error);
  42675. });
  42676. }, 0);
  42677. });
  42678. }
  42679. _this = _super.call(this, networkOrReady) || this;
  42680. // Default URL
  42681. if (!url) {
  42682. url = (0, properties_1.getStatic)(_this.constructor, "defaultUrl")();
  42683. }
  42684. if (typeof (url) === "string") {
  42685. (0, properties_1.defineReadOnly)(_this, "connection", Object.freeze({
  42686. url: url
  42687. }));
  42688. }
  42689. else {
  42690. (0, properties_1.defineReadOnly)(_this, "connection", Object.freeze((0, properties_1.shallowCopy)(url)));
  42691. }
  42692. _this._nextId = 42;
  42693. return _this;
  42694. }
  42695. Object.defineProperty(JsonRpcProvider.prototype, "_cache", {
  42696. get: function () {
  42697. if (this._eventLoopCache == null) {
  42698. this._eventLoopCache = {};
  42699. }
  42700. return this._eventLoopCache;
  42701. },
  42702. enumerable: false,
  42703. configurable: true
  42704. });
  42705. JsonRpcProvider.defaultUrl = function () {
  42706. return "http:/\/localhost:8545";
  42707. };
  42708. JsonRpcProvider.prototype.detectNetwork = function () {
  42709. var _this = this;
  42710. if (!this._cache["detectNetwork"]) {
  42711. this._cache["detectNetwork"] = this._uncachedDetectNetwork();
  42712. // Clear this cache at the beginning of the next event loop
  42713. setTimeout(function () {
  42714. _this._cache["detectNetwork"] = null;
  42715. }, 0);
  42716. }
  42717. return this._cache["detectNetwork"];
  42718. };
  42719. JsonRpcProvider.prototype._uncachedDetectNetwork = function () {
  42720. return __awaiter(this, void 0, void 0, function () {
  42721. var chainId, error_2, error_3, getNetwork;
  42722. return __generator(this, function (_a) {
  42723. switch (_a.label) {
  42724. case 0: return [4 /*yield*/, timer(0)];
  42725. case 1:
  42726. _a.sent();
  42727. chainId = null;
  42728. _a.label = 2;
  42729. case 2:
  42730. _a.trys.push([2, 4, , 9]);
  42731. return [4 /*yield*/, this.send("eth_chainId", [])];
  42732. case 3:
  42733. chainId = _a.sent();
  42734. return [3 /*break*/, 9];
  42735. case 4:
  42736. error_2 = _a.sent();
  42737. _a.label = 5;
  42738. case 5:
  42739. _a.trys.push([5, 7, , 8]);
  42740. return [4 /*yield*/, this.send("net_version", [])];
  42741. case 6:
  42742. chainId = _a.sent();
  42743. return [3 /*break*/, 8];
  42744. case 7:
  42745. error_3 = _a.sent();
  42746. return [3 /*break*/, 8];
  42747. case 8: return [3 /*break*/, 9];
  42748. case 9:
  42749. if (chainId != null) {
  42750. getNetwork = (0, properties_1.getStatic)(this.constructor, "getNetwork");
  42751. try {
  42752. return [2 /*return*/, getNetwork(bignumber_1.BigNumber.from(chainId).toNumber())];
  42753. }
  42754. catch (error) {
  42755. return [2 /*return*/, logger.throwError("could not detect network", logger_1.Logger.errors.NETWORK_ERROR, {
  42756. chainId: chainId,
  42757. event: "invalidNetwork",
  42758. serverError: error
  42759. })];
  42760. }
  42761. }
  42762. return [2 /*return*/, logger.throwError("could not detect network", logger_1.Logger.errors.NETWORK_ERROR, {
  42763. event: "noNetwork"
  42764. })];
  42765. }
  42766. });
  42767. });
  42768. };
  42769. JsonRpcProvider.prototype.getSigner = function (addressOrIndex) {
  42770. return new JsonRpcSigner(_constructorGuard, this, addressOrIndex);
  42771. };
  42772. JsonRpcProvider.prototype.getUncheckedSigner = function (addressOrIndex) {
  42773. return this.getSigner(addressOrIndex).connectUnchecked();
  42774. };
  42775. JsonRpcProvider.prototype.listAccounts = function () {
  42776. var _this = this;
  42777. return this.send("eth_accounts", []).then(function (accounts) {
  42778. return accounts.map(function (a) { return _this.formatter.address(a); });
  42779. });
  42780. };
  42781. JsonRpcProvider.prototype.send = function (method, params) {
  42782. var _this = this;
  42783. var request = {
  42784. method: method,
  42785. params: params,
  42786. id: (this._nextId++),
  42787. jsonrpc: "2.0"
  42788. };
  42789. this.emit("debug", {
  42790. action: "request",
  42791. request: (0, properties_1.deepCopy)(request),
  42792. provider: this
  42793. });
  42794. // We can expand this in the future to any call, but for now these
  42795. // are the biggest wins and do not require any serializing parameters.
  42796. var cache = (["eth_chainId", "eth_blockNumber"].indexOf(method) >= 0);
  42797. if (cache && this._cache[method]) {
  42798. return this._cache[method];
  42799. }
  42800. var result = (0, web_1.fetchJson)(this.connection, JSON.stringify(request), getResult).then(function (result) {
  42801. _this.emit("debug", {
  42802. action: "response",
  42803. request: request,
  42804. response: result,
  42805. provider: _this
  42806. });
  42807. return result;
  42808. }, function (error) {
  42809. _this.emit("debug", {
  42810. action: "response",
  42811. error: error,
  42812. request: request,
  42813. provider: _this
  42814. });
  42815. throw error;
  42816. });
  42817. // Cache the fetch, but clear it on the next event loop
  42818. if (cache) {
  42819. this._cache[method] = result;
  42820. setTimeout(function () {
  42821. _this._cache[method] = null;
  42822. }, 0);
  42823. }
  42824. return result;
  42825. };
  42826. JsonRpcProvider.prototype.prepareRequest = function (method, params) {
  42827. switch (method) {
  42828. case "getBlockNumber":
  42829. return ["eth_blockNumber", []];
  42830. case "getGasPrice":
  42831. return ["eth_gasPrice", []];
  42832. case "getBalance":
  42833. return ["eth_getBalance", [getLowerCase(params.address), params.blockTag]];
  42834. case "getTransactionCount":
  42835. return ["eth_getTransactionCount", [getLowerCase(params.address), params.blockTag]];
  42836. case "getCode":
  42837. return ["eth_getCode", [getLowerCase(params.address), params.blockTag]];
  42838. case "getStorageAt":
  42839. return ["eth_getStorageAt", [getLowerCase(params.address), params.position, params.blockTag]];
  42840. case "sendTransaction":
  42841. return ["eth_sendRawTransaction", [params.signedTransaction]];
  42842. case "getBlock":
  42843. if (params.blockTag) {
  42844. return ["eth_getBlockByNumber", [params.blockTag, !!params.includeTransactions]];
  42845. }
  42846. else if (params.blockHash) {
  42847. return ["eth_getBlockByHash", [params.blockHash, !!params.includeTransactions]];
  42848. }
  42849. return null;
  42850. case "getTransaction":
  42851. return ["eth_getTransactionByHash", [params.transactionHash]];
  42852. case "getTransactionReceipt":
  42853. return ["eth_getTransactionReceipt", [params.transactionHash]];
  42854. case "call": {
  42855. var hexlifyTransaction = (0, properties_1.getStatic)(this.constructor, "hexlifyTransaction");
  42856. return ["eth_call", [hexlifyTransaction(params.transaction, { from: true }), params.blockTag]];
  42857. }
  42858. case "estimateGas": {
  42859. var hexlifyTransaction = (0, properties_1.getStatic)(this.constructor, "hexlifyTransaction");
  42860. return ["eth_estimateGas", [hexlifyTransaction(params.transaction, { from: true })]];
  42861. }
  42862. case "getLogs":
  42863. if (params.filter && params.filter.address != null) {
  42864. params.filter.address = getLowerCase(params.filter.address);
  42865. }
  42866. return ["eth_getLogs", [params.filter]];
  42867. default:
  42868. break;
  42869. }
  42870. return null;
  42871. };
  42872. JsonRpcProvider.prototype.perform = function (method, params) {
  42873. return __awaiter(this, void 0, void 0, function () {
  42874. var tx, feeData, args, error_4;
  42875. return __generator(this, function (_a) {
  42876. switch (_a.label) {
  42877. case 0:
  42878. if (!(method === "call" || method === "estimateGas")) return [3 /*break*/, 2];
  42879. tx = params.transaction;
  42880. if (!(tx && tx.type != null && bignumber_1.BigNumber.from(tx.type).isZero())) return [3 /*break*/, 2];
  42881. if (!(tx.maxFeePerGas == null && tx.maxPriorityFeePerGas == null)) return [3 /*break*/, 2];
  42882. return [4 /*yield*/, this.getFeeData()];
  42883. case 1:
  42884. feeData = _a.sent();
  42885. if (feeData.maxFeePerGas == null && feeData.maxPriorityFeePerGas == null) {
  42886. // Network doesn't know about EIP-1559 (and hence type)
  42887. params = (0, properties_1.shallowCopy)(params);
  42888. params.transaction = (0, properties_1.shallowCopy)(tx);
  42889. delete params.transaction.type;
  42890. }
  42891. _a.label = 2;
  42892. case 2:
  42893. args = this.prepareRequest(method, params);
  42894. if (args == null) {
  42895. logger.throwError(method + " not implemented", logger_1.Logger.errors.NOT_IMPLEMENTED, { operation: method });
  42896. }
  42897. _a.label = 3;
  42898. case 3:
  42899. _a.trys.push([3, 5, , 6]);
  42900. return [4 /*yield*/, this.send(args[0], args[1])];
  42901. case 4: return [2 /*return*/, _a.sent()];
  42902. case 5:
  42903. error_4 = _a.sent();
  42904. return [2 /*return*/, checkError(method, error_4, params)];
  42905. case 6: return [2 /*return*/];
  42906. }
  42907. });
  42908. });
  42909. };
  42910. JsonRpcProvider.prototype._startEvent = function (event) {
  42911. if (event.tag === "pending") {
  42912. this._startPending();
  42913. }
  42914. _super.prototype._startEvent.call(this, event);
  42915. };
  42916. JsonRpcProvider.prototype._startPending = function () {
  42917. if (this._pendingFilter != null) {
  42918. return;
  42919. }
  42920. var self = this;
  42921. var pendingFilter = this.send("eth_newPendingTransactionFilter", []);
  42922. this._pendingFilter = pendingFilter;
  42923. pendingFilter.then(function (filterId) {
  42924. function poll() {
  42925. self.send("eth_getFilterChanges", [filterId]).then(function (hashes) {
  42926. if (self._pendingFilter != pendingFilter) {
  42927. return null;
  42928. }
  42929. var seq = Promise.resolve();
  42930. hashes.forEach(function (hash) {
  42931. // @TODO: This should be garbage collected at some point... How? When?
  42932. self._emitted["t:" + hash.toLowerCase()] = "pending";
  42933. seq = seq.then(function () {
  42934. return self.getTransaction(hash).then(function (tx) {
  42935. self.emit("pending", tx);
  42936. return null;
  42937. });
  42938. });
  42939. });
  42940. return seq.then(function () {
  42941. return timer(1000);
  42942. });
  42943. }).then(function () {
  42944. if (self._pendingFilter != pendingFilter) {
  42945. self.send("eth_uninstallFilter", [filterId]);
  42946. return;
  42947. }
  42948. setTimeout(function () { poll(); }, 0);
  42949. return null;
  42950. }).catch(function (error) { });
  42951. }
  42952. poll();
  42953. return filterId;
  42954. }).catch(function (error) { });
  42955. };
  42956. JsonRpcProvider.prototype._stopEvent = function (event) {
  42957. if (event.tag === "pending" && this.listenerCount("pending") === 0) {
  42958. this._pendingFilter = null;
  42959. }
  42960. _super.prototype._stopEvent.call(this, event);
  42961. };
  42962. // Convert an ethers.js transaction into a JSON-RPC transaction
  42963. // - gasLimit => gas
  42964. // - All values hexlified
  42965. // - All numeric values zero-striped
  42966. // - All addresses are lowercased
  42967. // NOTE: This allows a TransactionRequest, but all values should be resolved
  42968. // before this is called
  42969. // @TODO: This will likely be removed in future versions and prepareRequest
  42970. // will be the preferred method for this.
  42971. JsonRpcProvider.hexlifyTransaction = function (transaction, allowExtra) {
  42972. // Check only allowed properties are given
  42973. var allowed = (0, properties_1.shallowCopy)(allowedTransactionKeys);
  42974. if (allowExtra) {
  42975. for (var key in allowExtra) {
  42976. if (allowExtra[key]) {
  42977. allowed[key] = true;
  42978. }
  42979. }
  42980. }
  42981. (0, properties_1.checkProperties)(transaction, allowed);
  42982. var result = {};
  42983. // JSON-RPC now requires numeric values to be "quantity" values
  42984. ["chainId", "gasLimit", "gasPrice", "type", "maxFeePerGas", "maxPriorityFeePerGas", "nonce", "value"].forEach(function (key) {
  42985. if (transaction[key] == null) {
  42986. return;
  42987. }
  42988. var value = (0, bytes_1.hexValue)(transaction[key]);
  42989. if (key === "gasLimit") {
  42990. key = "gas";
  42991. }
  42992. result[key] = value;
  42993. });
  42994. ["from", "to", "data"].forEach(function (key) {
  42995. if (transaction[key] == null) {
  42996. return;
  42997. }
  42998. result[key] = (0, bytes_1.hexlify)(transaction[key]);
  42999. });
  43000. if (transaction.accessList) {
  43001. result["accessList"] = (0, transactions_1.accessListify)(transaction.accessList);
  43002. }
  43003. return result;
  43004. };
  43005. return JsonRpcProvider;
  43006. }(base_provider_1.BaseProvider));
  43007. exports.JsonRpcProvider = JsonRpcProvider;
  43008. },{"./_version":230,"./base-provider":232,"@ethersproject/abstract-signer":187,"@ethersproject/bignumber":196,"@ethersproject/bytes":199,"@ethersproject/hash":209,"@ethersproject/logger":223,"@ethersproject/properties":229,"@ethersproject/strings":266,"@ethersproject/transactions":269,"@ethersproject/web":276}],243:[function(_dereq_,module,exports){
  43009. /* istanbul ignore file */
  43010. "use strict";
  43011. var __extends = (this && this.__extends) || (function () {
  43012. var extendStatics = function (d, b) {
  43013. extendStatics = Object.setPrototypeOf ||
  43014. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  43015. function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
  43016. return extendStatics(d, b);
  43017. };
  43018. return function (d, b) {
  43019. if (typeof b !== "function" && b !== null)
  43020. throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
  43021. extendStatics(d, b);
  43022. function __() { this.constructor = d; }
  43023. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  43024. };
  43025. })();
  43026. Object.defineProperty(exports, "__esModule", { value: true });
  43027. exports.NodesmithProvider = void 0;
  43028. var url_json_rpc_provider_1 = _dereq_("./url-json-rpc-provider");
  43029. var logger_1 = _dereq_("@ethersproject/logger");
  43030. var _version_1 = _dereq_("./_version");
  43031. var logger = new logger_1.Logger(_version_1.version);
  43032. // Special API key provided by Nodesmith for ethers.js
  43033. var defaultApiKey = "ETHERS_JS_SHARED";
  43034. var NodesmithProvider = /** @class */ (function (_super) {
  43035. __extends(NodesmithProvider, _super);
  43036. function NodesmithProvider() {
  43037. return _super !== null && _super.apply(this, arguments) || this;
  43038. }
  43039. NodesmithProvider.getApiKey = function (apiKey) {
  43040. if (apiKey && typeof (apiKey) !== "string") {
  43041. logger.throwArgumentError("invalid apiKey", "apiKey", apiKey);
  43042. }
  43043. return apiKey || defaultApiKey;
  43044. };
  43045. NodesmithProvider.getUrl = function (network, apiKey) {
  43046. logger.warn("NodeSmith will be discontinued on 2019-12-20; please migrate to another platform.");
  43047. var host = null;
  43048. switch (network.name) {
  43049. case "homestead":
  43050. host = "https://ethereum.api.nodesmith.io/v1/mainnet/jsonrpc";
  43051. break;
  43052. case "ropsten":
  43053. host = "https://ethereum.api.nodesmith.io/v1/ropsten/jsonrpc";
  43054. break;
  43055. case "rinkeby":
  43056. host = "https://ethereum.api.nodesmith.io/v1/rinkeby/jsonrpc";
  43057. break;
  43058. case "goerli":
  43059. host = "https://ethereum.api.nodesmith.io/v1/goerli/jsonrpc";
  43060. break;
  43061. case "kovan":
  43062. host = "https://ethereum.api.nodesmith.io/v1/kovan/jsonrpc";
  43063. break;
  43064. default:
  43065. logger.throwArgumentError("unsupported network", "network", arguments[0]);
  43066. }
  43067. return (host + "?apiKey=" + apiKey);
  43068. };
  43069. return NodesmithProvider;
  43070. }(url_json_rpc_provider_1.UrlJsonRpcProvider));
  43071. exports.NodesmithProvider = NodesmithProvider;
  43072. },{"./_version":230,"./url-json-rpc-provider":245,"@ethersproject/logger":223}],244:[function(_dereq_,module,exports){
  43073. "use strict";
  43074. var __extends = (this && this.__extends) || (function () {
  43075. var extendStatics = function (d, b) {
  43076. extendStatics = Object.setPrototypeOf ||
  43077. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  43078. function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
  43079. return extendStatics(d, b);
  43080. };
  43081. return function (d, b) {
  43082. if (typeof b !== "function" && b !== null)
  43083. throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
  43084. extendStatics(d, b);
  43085. function __() { this.constructor = d; }
  43086. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  43087. };
  43088. })();
  43089. Object.defineProperty(exports, "__esModule", { value: true });
  43090. exports.PocketProvider = void 0;
  43091. var properties_1 = _dereq_("@ethersproject/properties");
  43092. var logger_1 = _dereq_("@ethersproject/logger");
  43093. var _version_1 = _dereq_("./_version");
  43094. var logger = new logger_1.Logger(_version_1.version);
  43095. var url_json_rpc_provider_1 = _dereq_("./url-json-rpc-provider");
  43096. // These are load-balancer-based application IDs
  43097. var defaultApplicationIds = {
  43098. homestead: "6004bcd10040261633ade990",
  43099. ropsten: "6004bd4d0040261633ade991",
  43100. rinkeby: "6004bda20040261633ade994",
  43101. goerli: "6004bd860040261633ade992",
  43102. };
  43103. var PocketProvider = /** @class */ (function (_super) {
  43104. __extends(PocketProvider, _super);
  43105. function PocketProvider(network, apiKey) {
  43106. // We need a bit of creativity in the constructor because
  43107. // Pocket uses different default API keys based on the network
  43108. var _newTarget = this.constructor;
  43109. var _this = this;
  43110. if (apiKey == null) {
  43111. var n = (0, properties_1.getStatic)(_newTarget, "getNetwork")(network);
  43112. if (n) {
  43113. var applicationId = defaultApplicationIds[n.name];
  43114. if (applicationId) {
  43115. apiKey = {
  43116. applicationId: applicationId,
  43117. loadBalancer: true
  43118. };
  43119. }
  43120. }
  43121. // If there was any issue above, we don't know this network
  43122. if (apiKey == null) {
  43123. logger.throwError("unsupported network", logger_1.Logger.errors.INVALID_ARGUMENT, {
  43124. argument: "network",
  43125. value: network
  43126. });
  43127. }
  43128. }
  43129. _this = _super.call(this, network, apiKey) || this;
  43130. return _this;
  43131. }
  43132. PocketProvider.getApiKey = function (apiKey) {
  43133. // Most API Providers allow null to get the default configuration, but
  43134. // Pocket requires the network to decide the default provider, so we
  43135. // rely on hijacking the constructor to add a sensible default for us
  43136. if (apiKey == null) {
  43137. logger.throwArgumentError("PocketProvider.getApiKey does not support null apiKey", "apiKey", apiKey);
  43138. }
  43139. var apiKeyObj = {
  43140. applicationId: null,
  43141. loadBalancer: false,
  43142. applicationSecretKey: null
  43143. };
  43144. // Parse applicationId and applicationSecretKey
  43145. if (typeof (apiKey) === "string") {
  43146. apiKeyObj.applicationId = apiKey;
  43147. }
  43148. else if (apiKey.applicationSecretKey != null) {
  43149. logger.assertArgument((typeof (apiKey.applicationId) === "string"), "applicationSecretKey requires an applicationId", "applicationId", apiKey.applicationId);
  43150. logger.assertArgument((typeof (apiKey.applicationSecretKey) === "string"), "invalid applicationSecretKey", "applicationSecretKey", "[REDACTED]");
  43151. apiKeyObj.applicationId = apiKey.applicationId;
  43152. apiKeyObj.applicationSecretKey = apiKey.applicationSecretKey;
  43153. apiKeyObj.loadBalancer = !!apiKey.loadBalancer;
  43154. }
  43155. else if (apiKey.applicationId) {
  43156. logger.assertArgument((typeof (apiKey.applicationId) === "string"), "apiKey.applicationId must be a string", "apiKey.applicationId", apiKey.applicationId);
  43157. apiKeyObj.applicationId = apiKey.applicationId;
  43158. apiKeyObj.loadBalancer = !!apiKey.loadBalancer;
  43159. }
  43160. else {
  43161. logger.throwArgumentError("unsupported PocketProvider apiKey", "apiKey", apiKey);
  43162. }
  43163. return apiKeyObj;
  43164. };
  43165. PocketProvider.getUrl = function (network, apiKey) {
  43166. var host = null;
  43167. switch (network ? network.name : "unknown") {
  43168. case "homestead":
  43169. host = "eth-mainnet.gateway.pokt.network";
  43170. break;
  43171. case "ropsten":
  43172. host = "eth-ropsten.gateway.pokt.network";
  43173. break;
  43174. case "rinkeby":
  43175. host = "eth-rinkeby.gateway.pokt.network";
  43176. break;
  43177. case "goerli":
  43178. host = "eth-goerli.gateway.pokt.network";
  43179. break;
  43180. default:
  43181. logger.throwError("unsupported network", logger_1.Logger.errors.INVALID_ARGUMENT, {
  43182. argument: "network",
  43183. value: network
  43184. });
  43185. }
  43186. var url = null;
  43187. if (apiKey.loadBalancer) {
  43188. url = "https://" + host + "/v1/lb/" + apiKey.applicationId;
  43189. }
  43190. else {
  43191. url = "https://" + host + "/v1/" + apiKey.applicationId;
  43192. }
  43193. var connection = { url: url };
  43194. // Initialize empty headers
  43195. connection.headers = {};
  43196. // Apply application secret key
  43197. if (apiKey.applicationSecretKey != null) {
  43198. connection.user = "";
  43199. connection.password = apiKey.applicationSecretKey;
  43200. }
  43201. return connection;
  43202. };
  43203. PocketProvider.prototype.isCommunityResource = function () {
  43204. return (this.applicationId === defaultApplicationIds[this.network.name]);
  43205. };
  43206. return PocketProvider;
  43207. }(url_json_rpc_provider_1.UrlJsonRpcProvider));
  43208. exports.PocketProvider = PocketProvider;
  43209. },{"./_version":230,"./url-json-rpc-provider":245,"@ethersproject/logger":223,"@ethersproject/properties":229}],245:[function(_dereq_,module,exports){
  43210. "use strict";
  43211. var __extends = (this && this.__extends) || (function () {
  43212. var extendStatics = function (d, b) {
  43213. extendStatics = Object.setPrototypeOf ||
  43214. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  43215. function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
  43216. return extendStatics(d, b);
  43217. };
  43218. return function (d, b) {
  43219. if (typeof b !== "function" && b !== null)
  43220. throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
  43221. extendStatics(d, b);
  43222. function __() { this.constructor = d; }
  43223. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  43224. };
  43225. })();
  43226. var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
  43227. function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
  43228. return new (P || (P = Promise))(function (resolve, reject) {
  43229. function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
  43230. function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
  43231. function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
  43232. step((generator = generator.apply(thisArg, _arguments || [])).next());
  43233. });
  43234. };
  43235. var __generator = (this && this.__generator) || function (thisArg, body) {
  43236. var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
  43237. return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
  43238. function verb(n) { return function (v) { return step([n, v]); }; }
  43239. function step(op) {
  43240. if (f) throw new TypeError("Generator is already executing.");
  43241. while (_) try {
  43242. if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
  43243. if (y = 0, t) op = [op[0] & 2, t.value];
  43244. switch (op[0]) {
  43245. case 0: case 1: t = op; break;
  43246. case 4: _.label++; return { value: op[1], done: false };
  43247. case 5: _.label++; y = op[1]; op = [0]; continue;
  43248. case 7: op = _.ops.pop(); _.trys.pop(); continue;
  43249. default:
  43250. if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
  43251. if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
  43252. if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
  43253. if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
  43254. if (t[2]) _.ops.pop();
  43255. _.trys.pop(); continue;
  43256. }
  43257. op = body.call(thisArg, _);
  43258. } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
  43259. if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
  43260. }
  43261. };
  43262. Object.defineProperty(exports, "__esModule", { value: true });
  43263. exports.UrlJsonRpcProvider = exports.StaticJsonRpcProvider = void 0;
  43264. var properties_1 = _dereq_("@ethersproject/properties");
  43265. var logger_1 = _dereq_("@ethersproject/logger");
  43266. var _version_1 = _dereq_("./_version");
  43267. var logger = new logger_1.Logger(_version_1.version);
  43268. var json_rpc_provider_1 = _dereq_("./json-rpc-provider");
  43269. // A StaticJsonRpcProvider is useful when you *know* for certain that
  43270. // the backend will never change, as it never calls eth_chainId to
  43271. // verify its backend. However, if the backend does change, the effects
  43272. // are undefined and may include:
  43273. // - inconsistent results
  43274. // - locking up the UI
  43275. // - block skew warnings
  43276. // - wrong results
  43277. // If the network is not explicit (i.e. auto-detection is expected), the
  43278. // node MUST be running and available to respond to requests BEFORE this
  43279. // is instantiated.
  43280. var StaticJsonRpcProvider = /** @class */ (function (_super) {
  43281. __extends(StaticJsonRpcProvider, _super);
  43282. function StaticJsonRpcProvider() {
  43283. return _super !== null && _super.apply(this, arguments) || this;
  43284. }
  43285. StaticJsonRpcProvider.prototype.detectNetwork = function () {
  43286. return __awaiter(this, void 0, void 0, function () {
  43287. var network;
  43288. return __generator(this, function (_a) {
  43289. switch (_a.label) {
  43290. case 0:
  43291. network = this.network;
  43292. if (!(network == null)) return [3 /*break*/, 2];
  43293. return [4 /*yield*/, _super.prototype.detectNetwork.call(this)];
  43294. case 1:
  43295. network = _a.sent();
  43296. if (!network) {
  43297. logger.throwError("no network detected", logger_1.Logger.errors.UNKNOWN_ERROR, {});
  43298. }
  43299. // If still not set, set it
  43300. if (this._network == null) {
  43301. // A static network does not support "any"
  43302. (0, properties_1.defineReadOnly)(this, "_network", network);
  43303. this.emit("network", network, null);
  43304. }
  43305. _a.label = 2;
  43306. case 2: return [2 /*return*/, network];
  43307. }
  43308. });
  43309. });
  43310. };
  43311. return StaticJsonRpcProvider;
  43312. }(json_rpc_provider_1.JsonRpcProvider));
  43313. exports.StaticJsonRpcProvider = StaticJsonRpcProvider;
  43314. var UrlJsonRpcProvider = /** @class */ (function (_super) {
  43315. __extends(UrlJsonRpcProvider, _super);
  43316. function UrlJsonRpcProvider(network, apiKey) {
  43317. var _newTarget = this.constructor;
  43318. var _this = this;
  43319. logger.checkAbstract(_newTarget, UrlJsonRpcProvider);
  43320. // Normalize the Network and API Key
  43321. network = (0, properties_1.getStatic)(_newTarget, "getNetwork")(network);
  43322. apiKey = (0, properties_1.getStatic)(_newTarget, "getApiKey")(apiKey);
  43323. var connection = (0, properties_1.getStatic)(_newTarget, "getUrl")(network, apiKey);
  43324. _this = _super.call(this, connection, network) || this;
  43325. if (typeof (apiKey) === "string") {
  43326. (0, properties_1.defineReadOnly)(_this, "apiKey", apiKey);
  43327. }
  43328. else if (apiKey != null) {
  43329. Object.keys(apiKey).forEach(function (key) {
  43330. (0, properties_1.defineReadOnly)(_this, key, apiKey[key]);
  43331. });
  43332. }
  43333. return _this;
  43334. }
  43335. UrlJsonRpcProvider.prototype._startPending = function () {
  43336. logger.warn("WARNING: API provider does not support pending filters");
  43337. };
  43338. UrlJsonRpcProvider.prototype.isCommunityResource = function () {
  43339. return false;
  43340. };
  43341. UrlJsonRpcProvider.prototype.getSigner = function (address) {
  43342. return logger.throwError("API provider does not support signing", logger_1.Logger.errors.UNSUPPORTED_OPERATION, { operation: "getSigner" });
  43343. };
  43344. UrlJsonRpcProvider.prototype.listAccounts = function () {
  43345. return Promise.resolve([]);
  43346. };
  43347. // Return a defaultApiKey if null, otherwise validate the API key
  43348. UrlJsonRpcProvider.getApiKey = function (apiKey) {
  43349. return apiKey;
  43350. };
  43351. // Returns the url or connection for the given network and API key. The
  43352. // API key will have been sanitized by the getApiKey first, so any validation
  43353. // or transformations can be done there.
  43354. UrlJsonRpcProvider.getUrl = function (network, apiKey) {
  43355. return logger.throwError("not implemented; sub-classes must override getUrl", logger_1.Logger.errors.NOT_IMPLEMENTED, {
  43356. operation: "getUrl"
  43357. });
  43358. };
  43359. return UrlJsonRpcProvider;
  43360. }(StaticJsonRpcProvider));
  43361. exports.UrlJsonRpcProvider = UrlJsonRpcProvider;
  43362. },{"./_version":230,"./json-rpc-provider":242,"@ethersproject/logger":223,"@ethersproject/properties":229}],246:[function(_dereq_,module,exports){
  43363. "use strict";
  43364. var __extends = (this && this.__extends) || (function () {
  43365. var extendStatics = function (d, b) {
  43366. extendStatics = Object.setPrototypeOf ||
  43367. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  43368. function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
  43369. return extendStatics(d, b);
  43370. };
  43371. return function (d, b) {
  43372. if (typeof b !== "function" && b !== null)
  43373. throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
  43374. extendStatics(d, b);
  43375. function __() { this.constructor = d; }
  43376. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  43377. };
  43378. })();
  43379. Object.defineProperty(exports, "__esModule", { value: true });
  43380. exports.Web3Provider = void 0;
  43381. var properties_1 = _dereq_("@ethersproject/properties");
  43382. var logger_1 = _dereq_("@ethersproject/logger");
  43383. var _version_1 = _dereq_("./_version");
  43384. var logger = new logger_1.Logger(_version_1.version);
  43385. var json_rpc_provider_1 = _dereq_("./json-rpc-provider");
  43386. var _nextId = 1;
  43387. function buildWeb3LegacyFetcher(provider, sendFunc) {
  43388. var fetcher = "Web3LegacyFetcher";
  43389. return function (method, params) {
  43390. var _this = this;
  43391. var request = {
  43392. method: method,
  43393. params: params,
  43394. id: (_nextId++),
  43395. jsonrpc: "2.0"
  43396. };
  43397. return new Promise(function (resolve, reject) {
  43398. _this.emit("debug", {
  43399. action: "request",
  43400. fetcher: fetcher,
  43401. request: (0, properties_1.deepCopy)(request),
  43402. provider: _this
  43403. });
  43404. sendFunc(request, function (error, response) {
  43405. if (error) {
  43406. _this.emit("debug", {
  43407. action: "response",
  43408. fetcher: fetcher,
  43409. error: error,
  43410. request: request,
  43411. provider: _this
  43412. });
  43413. return reject(error);
  43414. }
  43415. _this.emit("debug", {
  43416. action: "response",
  43417. fetcher: fetcher,
  43418. request: request,
  43419. response: response,
  43420. provider: _this
  43421. });
  43422. if (response.error) {
  43423. var error_1 = new Error(response.error.message);
  43424. error_1.code = response.error.code;
  43425. error_1.data = response.error.data;
  43426. return reject(error_1);
  43427. }
  43428. resolve(response.result);
  43429. });
  43430. });
  43431. };
  43432. }
  43433. function buildEip1193Fetcher(provider) {
  43434. return function (method, params) {
  43435. var _this = this;
  43436. if (params == null) {
  43437. params = [];
  43438. }
  43439. var request = { method: method, params: params };
  43440. this.emit("debug", {
  43441. action: "request",
  43442. fetcher: "Eip1193Fetcher",
  43443. request: (0, properties_1.deepCopy)(request),
  43444. provider: this
  43445. });
  43446. return provider.request(request).then(function (response) {
  43447. _this.emit("debug", {
  43448. action: "response",
  43449. fetcher: "Eip1193Fetcher",
  43450. request: request,
  43451. response: response,
  43452. provider: _this
  43453. });
  43454. return response;
  43455. }, function (error) {
  43456. _this.emit("debug", {
  43457. action: "response",
  43458. fetcher: "Eip1193Fetcher",
  43459. request: request,
  43460. error: error,
  43461. provider: _this
  43462. });
  43463. throw error;
  43464. });
  43465. };
  43466. }
  43467. var Web3Provider = /** @class */ (function (_super) {
  43468. __extends(Web3Provider, _super);
  43469. function Web3Provider(provider, network) {
  43470. var _newTarget = this.constructor;
  43471. var _this = this;
  43472. logger.checkNew(_newTarget, Web3Provider);
  43473. if (provider == null) {
  43474. logger.throwArgumentError("missing provider", "provider", provider);
  43475. }
  43476. var path = null;
  43477. var jsonRpcFetchFunc = null;
  43478. var subprovider = null;
  43479. if (typeof (provider) === "function") {
  43480. path = "unknown:";
  43481. jsonRpcFetchFunc = provider;
  43482. }
  43483. else {
  43484. path = provider.host || provider.path || "";
  43485. if (!path && provider.isMetaMask) {
  43486. path = "metamask";
  43487. }
  43488. subprovider = provider;
  43489. if (provider.request) {
  43490. if (path === "") {
  43491. path = "eip-1193:";
  43492. }
  43493. jsonRpcFetchFunc = buildEip1193Fetcher(provider);
  43494. }
  43495. else if (provider.sendAsync) {
  43496. jsonRpcFetchFunc = buildWeb3LegacyFetcher(provider, provider.sendAsync.bind(provider));
  43497. }
  43498. else if (provider.send) {
  43499. jsonRpcFetchFunc = buildWeb3LegacyFetcher(provider, provider.send.bind(provider));
  43500. }
  43501. else {
  43502. logger.throwArgumentError("unsupported provider", "provider", provider);
  43503. }
  43504. if (!path) {
  43505. path = "unknown:";
  43506. }
  43507. }
  43508. _this = _super.call(this, path, network) || this;
  43509. (0, properties_1.defineReadOnly)(_this, "jsonRpcFetchFunc", jsonRpcFetchFunc);
  43510. (0, properties_1.defineReadOnly)(_this, "provider", subprovider);
  43511. return _this;
  43512. }
  43513. Web3Provider.prototype.send = function (method, params) {
  43514. return this.jsonRpcFetchFunc(method, params);
  43515. };
  43516. return Web3Provider;
  43517. }(json_rpc_provider_1.JsonRpcProvider));
  43518. exports.Web3Provider = Web3Provider;
  43519. },{"./_version":230,"./json-rpc-provider":242,"@ethersproject/logger":223,"@ethersproject/properties":229}],247:[function(_dereq_,module,exports){
  43520. "use strict";
  43521. var __extends = (this && this.__extends) || (function () {
  43522. var extendStatics = function (d, b) {
  43523. extendStatics = Object.setPrototypeOf ||
  43524. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  43525. function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
  43526. return extendStatics(d, b);
  43527. };
  43528. return function (d, b) {
  43529. if (typeof b !== "function" && b !== null)
  43530. throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
  43531. extendStatics(d, b);
  43532. function __() { this.constructor = d; }
  43533. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  43534. };
  43535. })();
  43536. var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
  43537. function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
  43538. return new (P || (P = Promise))(function (resolve, reject) {
  43539. function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
  43540. function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
  43541. function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
  43542. step((generator = generator.apply(thisArg, _arguments || [])).next());
  43543. });
  43544. };
  43545. var __generator = (this && this.__generator) || function (thisArg, body) {
  43546. var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
  43547. return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
  43548. function verb(n) { return function (v) { return step([n, v]); }; }
  43549. function step(op) {
  43550. if (f) throw new TypeError("Generator is already executing.");
  43551. while (_) try {
  43552. if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
  43553. if (y = 0, t) op = [op[0] & 2, t.value];
  43554. switch (op[0]) {
  43555. case 0: case 1: t = op; break;
  43556. case 4: _.label++; return { value: op[1], done: false };
  43557. case 5: _.label++; y = op[1]; op = [0]; continue;
  43558. case 7: op = _.ops.pop(); _.trys.pop(); continue;
  43559. default:
  43560. if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
  43561. if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
  43562. if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
  43563. if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
  43564. if (t[2]) _.ops.pop();
  43565. _.trys.pop(); continue;
  43566. }
  43567. op = body.call(thisArg, _);
  43568. } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
  43569. if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
  43570. }
  43571. };
  43572. Object.defineProperty(exports, "__esModule", { value: true });
  43573. exports.WebSocketProvider = void 0;
  43574. var bignumber_1 = _dereq_("@ethersproject/bignumber");
  43575. var properties_1 = _dereq_("@ethersproject/properties");
  43576. var json_rpc_provider_1 = _dereq_("./json-rpc-provider");
  43577. var ws_1 = _dereq_("./ws");
  43578. var logger_1 = _dereq_("@ethersproject/logger");
  43579. var _version_1 = _dereq_("./_version");
  43580. var logger = new logger_1.Logger(_version_1.version);
  43581. /**
  43582. * Notes:
  43583. *
  43584. * This provider differs a bit from the polling providers. One main
  43585. * difference is how it handles consistency. The polling providers
  43586. * will stall responses to ensure a consistent state, while this
  43587. * WebSocket provider assumes the connected backend will manage this.
  43588. *
  43589. * For example, if a polling provider emits an event which indicates
  43590. * the event occurred in blockhash XXX, a call to fetch that block by
  43591. * its hash XXX, if not present will retry until it is present. This
  43592. * can occur when querying a pool of nodes that are mildly out of sync
  43593. * with each other.
  43594. */
  43595. var NextId = 1;
  43596. // For more info about the Real-time Event API see:
  43597. // https://geth.ethereum.org/docs/rpc/pubsub
  43598. var WebSocketProvider = /** @class */ (function (_super) {
  43599. __extends(WebSocketProvider, _super);
  43600. function WebSocketProvider(url, network) {
  43601. var _this = this;
  43602. // This will be added in the future; please open an issue to expedite
  43603. if (network === "any") {
  43604. logger.throwError("WebSocketProvider does not support 'any' network yet", logger_1.Logger.errors.UNSUPPORTED_OPERATION, {
  43605. operation: "network:any"
  43606. });
  43607. }
  43608. if (typeof (url) === "string") {
  43609. _this = _super.call(this, url, network) || this;
  43610. }
  43611. else {
  43612. _this = _super.call(this, "_websocket", network) || this;
  43613. }
  43614. _this._pollingInterval = -1;
  43615. _this._wsReady = false;
  43616. if (typeof (url) === "string") {
  43617. (0, properties_1.defineReadOnly)(_this, "_websocket", new ws_1.WebSocket(_this.connection.url));
  43618. }
  43619. else {
  43620. (0, properties_1.defineReadOnly)(_this, "_websocket", url);
  43621. }
  43622. (0, properties_1.defineReadOnly)(_this, "_requests", {});
  43623. (0, properties_1.defineReadOnly)(_this, "_subs", {});
  43624. (0, properties_1.defineReadOnly)(_this, "_subIds", {});
  43625. (0, properties_1.defineReadOnly)(_this, "_detectNetwork", _super.prototype.detectNetwork.call(_this));
  43626. // Stall sending requests until the socket is open...
  43627. _this.websocket.onopen = function () {
  43628. _this._wsReady = true;
  43629. Object.keys(_this._requests).forEach(function (id) {
  43630. _this.websocket.send(_this._requests[id].payload);
  43631. });
  43632. };
  43633. _this.websocket.onmessage = function (messageEvent) {
  43634. var data = messageEvent.data;
  43635. var result = JSON.parse(data);
  43636. if (result.id != null) {
  43637. var id = String(result.id);
  43638. var request = _this._requests[id];
  43639. delete _this._requests[id];
  43640. if (result.result !== undefined) {
  43641. request.callback(null, result.result);
  43642. _this.emit("debug", {
  43643. action: "response",
  43644. request: JSON.parse(request.payload),
  43645. response: result.result,
  43646. provider: _this
  43647. });
  43648. }
  43649. else {
  43650. var error = null;
  43651. if (result.error) {
  43652. error = new Error(result.error.message || "unknown error");
  43653. (0, properties_1.defineReadOnly)(error, "code", result.error.code || null);
  43654. (0, properties_1.defineReadOnly)(error, "response", data);
  43655. }
  43656. else {
  43657. error = new Error("unknown error");
  43658. }
  43659. request.callback(error, undefined);
  43660. _this.emit("debug", {
  43661. action: "response",
  43662. error: error,
  43663. request: JSON.parse(request.payload),
  43664. provider: _this
  43665. });
  43666. }
  43667. }
  43668. else if (result.method === "eth_subscription") {
  43669. // Subscription...
  43670. var sub = _this._subs[result.params.subscription];
  43671. if (sub) {
  43672. //this.emit.apply(this, );
  43673. sub.processFunc(result.params.result);
  43674. }
  43675. }
  43676. else {
  43677. console.warn("this should not happen");
  43678. }
  43679. };
  43680. // This Provider does not actually poll, but we want to trigger
  43681. // poll events for things that depend on them (like stalling for
  43682. // block and transaction lookups)
  43683. var fauxPoll = setInterval(function () {
  43684. _this.emit("poll");
  43685. }, 1000);
  43686. if (fauxPoll.unref) {
  43687. fauxPoll.unref();
  43688. }
  43689. return _this;
  43690. }
  43691. Object.defineProperty(WebSocketProvider.prototype, "websocket", {
  43692. // Cannot narrow the type of _websocket, as that is not backwards compatible
  43693. // so we add a getter and let the WebSocket be a public API.
  43694. get: function () { return this._websocket; },
  43695. enumerable: false,
  43696. configurable: true
  43697. });
  43698. WebSocketProvider.prototype.detectNetwork = function () {
  43699. return this._detectNetwork;
  43700. };
  43701. Object.defineProperty(WebSocketProvider.prototype, "pollingInterval", {
  43702. get: function () {
  43703. return 0;
  43704. },
  43705. set: function (value) {
  43706. logger.throwError("cannot set polling interval on WebSocketProvider", logger_1.Logger.errors.UNSUPPORTED_OPERATION, {
  43707. operation: "setPollingInterval"
  43708. });
  43709. },
  43710. enumerable: false,
  43711. configurable: true
  43712. });
  43713. WebSocketProvider.prototype.resetEventsBlock = function (blockNumber) {
  43714. logger.throwError("cannot reset events block on WebSocketProvider", logger_1.Logger.errors.UNSUPPORTED_OPERATION, {
  43715. operation: "resetEventBlock"
  43716. });
  43717. };
  43718. WebSocketProvider.prototype.poll = function () {
  43719. return __awaiter(this, void 0, void 0, function () {
  43720. return __generator(this, function (_a) {
  43721. return [2 /*return*/, null];
  43722. });
  43723. });
  43724. };
  43725. Object.defineProperty(WebSocketProvider.prototype, "polling", {
  43726. set: function (value) {
  43727. if (!value) {
  43728. return;
  43729. }
  43730. logger.throwError("cannot set polling on WebSocketProvider", logger_1.Logger.errors.UNSUPPORTED_OPERATION, {
  43731. operation: "setPolling"
  43732. });
  43733. },
  43734. enumerable: false,
  43735. configurable: true
  43736. });
  43737. WebSocketProvider.prototype.send = function (method, params) {
  43738. var _this = this;
  43739. var rid = NextId++;
  43740. return new Promise(function (resolve, reject) {
  43741. function callback(error, result) {
  43742. if (error) {
  43743. return reject(error);
  43744. }
  43745. return resolve(result);
  43746. }
  43747. var payload = JSON.stringify({
  43748. method: method,
  43749. params: params,
  43750. id: rid,
  43751. jsonrpc: "2.0"
  43752. });
  43753. _this.emit("debug", {
  43754. action: "request",
  43755. request: JSON.parse(payload),
  43756. provider: _this
  43757. });
  43758. _this._requests[String(rid)] = { callback: callback, payload: payload };
  43759. if (_this._wsReady) {
  43760. _this.websocket.send(payload);
  43761. }
  43762. });
  43763. };
  43764. WebSocketProvider.defaultUrl = function () {
  43765. return "ws:/\/localhost:8546";
  43766. };
  43767. WebSocketProvider.prototype._subscribe = function (tag, param, processFunc) {
  43768. return __awaiter(this, void 0, void 0, function () {
  43769. var subIdPromise, subId;
  43770. var _this = this;
  43771. return __generator(this, function (_a) {
  43772. switch (_a.label) {
  43773. case 0:
  43774. subIdPromise = this._subIds[tag];
  43775. if (subIdPromise == null) {
  43776. subIdPromise = Promise.all(param).then(function (param) {
  43777. return _this.send("eth_subscribe", param);
  43778. });
  43779. this._subIds[tag] = subIdPromise;
  43780. }
  43781. return [4 /*yield*/, subIdPromise];
  43782. case 1:
  43783. subId = _a.sent();
  43784. this._subs[subId] = { tag: tag, processFunc: processFunc };
  43785. return [2 /*return*/];
  43786. }
  43787. });
  43788. });
  43789. };
  43790. WebSocketProvider.prototype._startEvent = function (event) {
  43791. var _this = this;
  43792. switch (event.type) {
  43793. case "block":
  43794. this._subscribe("block", ["newHeads"], function (result) {
  43795. var blockNumber = bignumber_1.BigNumber.from(result.number).toNumber();
  43796. _this._emitted.block = blockNumber;
  43797. _this.emit("block", blockNumber);
  43798. });
  43799. break;
  43800. case "pending":
  43801. this._subscribe("pending", ["newPendingTransactions"], function (result) {
  43802. _this.emit("pending", result);
  43803. });
  43804. break;
  43805. case "filter":
  43806. this._subscribe(event.tag, ["logs", this._getFilter(event.filter)], function (result) {
  43807. if (result.removed == null) {
  43808. result.removed = false;
  43809. }
  43810. _this.emit(event.filter, _this.formatter.filterLog(result));
  43811. });
  43812. break;
  43813. case "tx": {
  43814. var emitReceipt_1 = function (event) {
  43815. var hash = event.hash;
  43816. _this.getTransactionReceipt(hash).then(function (receipt) {
  43817. if (!receipt) {
  43818. return;
  43819. }
  43820. _this.emit(hash, receipt);
  43821. });
  43822. };
  43823. // In case it is already mined
  43824. emitReceipt_1(event);
  43825. // To keep things simple, we start up a single newHeads subscription
  43826. // to keep an eye out for transactions we are watching for.
  43827. // Starting a subscription for an event (i.e. "tx") that is already
  43828. // running is (basically) a nop.
  43829. this._subscribe("tx", ["newHeads"], function (result) {
  43830. _this._events.filter(function (e) { return (e.type === "tx"); }).forEach(emitReceipt_1);
  43831. });
  43832. break;
  43833. }
  43834. // Nothing is needed
  43835. case "debug":
  43836. case "poll":
  43837. case "willPoll":
  43838. case "didPoll":
  43839. case "error":
  43840. break;
  43841. default:
  43842. console.log("unhandled:", event);
  43843. break;
  43844. }
  43845. };
  43846. WebSocketProvider.prototype._stopEvent = function (event) {
  43847. var _this = this;
  43848. var tag = event.tag;
  43849. if (event.type === "tx") {
  43850. // There are remaining transaction event listeners
  43851. if (this._events.filter(function (e) { return (e.type === "tx"); }).length) {
  43852. return;
  43853. }
  43854. tag = "tx";
  43855. }
  43856. else if (this.listenerCount(event.event)) {
  43857. // There are remaining event listeners
  43858. return;
  43859. }
  43860. var subId = this._subIds[tag];
  43861. if (!subId) {
  43862. return;
  43863. }
  43864. delete this._subIds[tag];
  43865. subId.then(function (subId) {
  43866. if (!_this._subs[subId]) {
  43867. return;
  43868. }
  43869. delete _this._subs[subId];
  43870. _this.send("eth_unsubscribe", [subId]);
  43871. });
  43872. };
  43873. WebSocketProvider.prototype.destroy = function () {
  43874. return __awaiter(this, void 0, void 0, function () {
  43875. var _this = this;
  43876. return __generator(this, function (_a) {
  43877. switch (_a.label) {
  43878. case 0:
  43879. if (!(this.websocket.readyState === ws_1.WebSocket.CONNECTING)) return [3 /*break*/, 2];
  43880. return [4 /*yield*/, (new Promise(function (resolve) {
  43881. _this.websocket.onopen = function () {
  43882. resolve(true);
  43883. };
  43884. _this.websocket.onerror = function () {
  43885. resolve(false);
  43886. };
  43887. }))];
  43888. case 1:
  43889. _a.sent();
  43890. _a.label = 2;
  43891. case 2:
  43892. // Hangup
  43893. // See: https://developer.mozilla.org/en-US/docs/Web/API/CloseEvent#Status_codes
  43894. this.websocket.close(1000);
  43895. return [2 /*return*/];
  43896. }
  43897. });
  43898. });
  43899. };
  43900. return WebSocketProvider;
  43901. }(json_rpc_provider_1.JsonRpcProvider));
  43902. exports.WebSocketProvider = WebSocketProvider;
  43903. },{"./_version":230,"./json-rpc-provider":242,"./ws":234,"@ethersproject/bignumber":196,"@ethersproject/logger":223,"@ethersproject/properties":229}],248:[function(_dereq_,module,exports){
  43904. "use strict";
  43905. Object.defineProperty(exports, "__esModule", { value: true });
  43906. exports.version = void 0;
  43907. exports.version = "random/5.6.0";
  43908. },{}],249:[function(_dereq_,module,exports){
  43909. (function (global){(function (){
  43910. "use strict";
  43911. Object.defineProperty(exports, "__esModule", { value: true });
  43912. exports.randomBytes = void 0;
  43913. var bytes_1 = _dereq_("@ethersproject/bytes");
  43914. var logger_1 = _dereq_("@ethersproject/logger");
  43915. var _version_1 = _dereq_("./_version");
  43916. var logger = new logger_1.Logger(_version_1.version);
  43917. // Debugging line for testing browser lib in node
  43918. //const window = { crypto: { getRandomValues: () => { } } };
  43919. // https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/globalThis
  43920. function getGlobal() {
  43921. if (typeof self !== 'undefined') {
  43922. return self;
  43923. }
  43924. if (typeof window !== 'undefined') {
  43925. return window;
  43926. }
  43927. if (typeof global !== 'undefined') {
  43928. return global;
  43929. }
  43930. throw new Error('unable to locate global object');
  43931. }
  43932. ;
  43933. var anyGlobal = getGlobal();
  43934. var crypto = anyGlobal.crypto || anyGlobal.msCrypto;
  43935. if (!crypto || !crypto.getRandomValues) {
  43936. logger.warn("WARNING: Missing strong random number source");
  43937. crypto = {
  43938. getRandomValues: function (buffer) {
  43939. return logger.throwError("no secure random source avaialble", logger_1.Logger.errors.UNSUPPORTED_OPERATION, {
  43940. operation: "crypto.getRandomValues"
  43941. });
  43942. }
  43943. };
  43944. }
  43945. function randomBytes(length) {
  43946. if (length <= 0 || length > 1024 || (length % 1) || length != length) {
  43947. logger.throwArgumentError("invalid length", "length", length);
  43948. }
  43949. var result = new Uint8Array(length);
  43950. crypto.getRandomValues(result);
  43951. return (0, bytes_1.arrayify)(result);
  43952. }
  43953. exports.randomBytes = randomBytes;
  43954. ;
  43955. }).call(this)}).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {})
  43956. },{"./_version":248,"@ethersproject/bytes":199,"@ethersproject/logger":223}],250:[function(_dereq_,module,exports){
  43957. "use strict";
  43958. Object.defineProperty(exports, "__esModule", { value: true });
  43959. exports.shuffled = exports.randomBytes = void 0;
  43960. var random_1 = _dereq_("./random");
  43961. Object.defineProperty(exports, "randomBytes", { enumerable: true, get: function () { return random_1.randomBytes; } });
  43962. var shuffle_1 = _dereq_("./shuffle");
  43963. Object.defineProperty(exports, "shuffled", { enumerable: true, get: function () { return shuffle_1.shuffled; } });
  43964. },{"./random":249,"./shuffle":251}],251:[function(_dereq_,module,exports){
  43965. "use strict";
  43966. Object.defineProperty(exports, "__esModule", { value: true });
  43967. exports.shuffled = void 0;
  43968. function shuffled(array) {
  43969. array = array.slice();
  43970. for (var i = array.length - 1; i > 0; i--) {
  43971. var j = Math.floor(Math.random() * (i + 1));
  43972. var tmp = array[i];
  43973. array[i] = array[j];
  43974. array[j] = tmp;
  43975. }
  43976. return array;
  43977. }
  43978. exports.shuffled = shuffled;
  43979. },{}],252:[function(_dereq_,module,exports){
  43980. "use strict";
  43981. Object.defineProperty(exports, "__esModule", { value: true });
  43982. exports.version = void 0;
  43983. exports.version = "rlp/5.6.0";
  43984. },{}],253:[function(_dereq_,module,exports){
  43985. "use strict";
  43986. Object.defineProperty(exports, "__esModule", { value: true });
  43987. exports.decode = exports.encode = void 0;
  43988. //See: https://github.com/ethereum/wiki/wiki/RLP
  43989. var bytes_1 = _dereq_("@ethersproject/bytes");
  43990. var logger_1 = _dereq_("@ethersproject/logger");
  43991. var _version_1 = _dereq_("./_version");
  43992. var logger = new logger_1.Logger(_version_1.version);
  43993. function arrayifyInteger(value) {
  43994. var result = [];
  43995. while (value) {
  43996. result.unshift(value & 0xff);
  43997. value >>= 8;
  43998. }
  43999. return result;
  44000. }
  44001. function unarrayifyInteger(data, offset, length) {
  44002. var result = 0;
  44003. for (var i = 0; i < length; i++) {
  44004. result = (result * 256) + data[offset + i];
  44005. }
  44006. return result;
  44007. }
  44008. function _encode(object) {
  44009. if (Array.isArray(object)) {
  44010. var payload_1 = [];
  44011. object.forEach(function (child) {
  44012. payload_1 = payload_1.concat(_encode(child));
  44013. });
  44014. if (payload_1.length <= 55) {
  44015. payload_1.unshift(0xc0 + payload_1.length);
  44016. return payload_1;
  44017. }
  44018. var length_1 = arrayifyInteger(payload_1.length);
  44019. length_1.unshift(0xf7 + length_1.length);
  44020. return length_1.concat(payload_1);
  44021. }
  44022. if (!(0, bytes_1.isBytesLike)(object)) {
  44023. logger.throwArgumentError("RLP object must be BytesLike", "object", object);
  44024. }
  44025. var data = Array.prototype.slice.call((0, bytes_1.arrayify)(object));
  44026. if (data.length === 1 && data[0] <= 0x7f) {
  44027. return data;
  44028. }
  44029. else if (data.length <= 55) {
  44030. data.unshift(0x80 + data.length);
  44031. return data;
  44032. }
  44033. var length = arrayifyInteger(data.length);
  44034. length.unshift(0xb7 + length.length);
  44035. return length.concat(data);
  44036. }
  44037. function encode(object) {
  44038. return (0, bytes_1.hexlify)(_encode(object));
  44039. }
  44040. exports.encode = encode;
  44041. function _decodeChildren(data, offset, childOffset, length) {
  44042. var result = [];
  44043. while (childOffset < offset + 1 + length) {
  44044. var decoded = _decode(data, childOffset);
  44045. result.push(decoded.result);
  44046. childOffset += decoded.consumed;
  44047. if (childOffset > offset + 1 + length) {
  44048. logger.throwError("child data too short", logger_1.Logger.errors.BUFFER_OVERRUN, {});
  44049. }
  44050. }
  44051. return { consumed: (1 + length), result: result };
  44052. }
  44053. // returns { consumed: number, result: Object }
  44054. function _decode(data, offset) {
  44055. if (data.length === 0) {
  44056. logger.throwError("data too short", logger_1.Logger.errors.BUFFER_OVERRUN, {});
  44057. }
  44058. // Array with extra length prefix
  44059. if (data[offset] >= 0xf8) {
  44060. var lengthLength = data[offset] - 0xf7;
  44061. if (offset + 1 + lengthLength > data.length) {
  44062. logger.throwError("data short segment too short", logger_1.Logger.errors.BUFFER_OVERRUN, {});
  44063. }
  44064. var length_2 = unarrayifyInteger(data, offset + 1, lengthLength);
  44065. if (offset + 1 + lengthLength + length_2 > data.length) {
  44066. logger.throwError("data long segment too short", logger_1.Logger.errors.BUFFER_OVERRUN, {});
  44067. }
  44068. return _decodeChildren(data, offset, offset + 1 + lengthLength, lengthLength + length_2);
  44069. }
  44070. else if (data[offset] >= 0xc0) {
  44071. var length_3 = data[offset] - 0xc0;
  44072. if (offset + 1 + length_3 > data.length) {
  44073. logger.throwError("data array too short", logger_1.Logger.errors.BUFFER_OVERRUN, {});
  44074. }
  44075. return _decodeChildren(data, offset, offset + 1, length_3);
  44076. }
  44077. else if (data[offset] >= 0xb8) {
  44078. var lengthLength = data[offset] - 0xb7;
  44079. if (offset + 1 + lengthLength > data.length) {
  44080. logger.throwError("data array too short", logger_1.Logger.errors.BUFFER_OVERRUN, {});
  44081. }
  44082. var length_4 = unarrayifyInteger(data, offset + 1, lengthLength);
  44083. if (offset + 1 + lengthLength + length_4 > data.length) {
  44084. logger.throwError("data array too short", logger_1.Logger.errors.BUFFER_OVERRUN, {});
  44085. }
  44086. var result = (0, bytes_1.hexlify)(data.slice(offset + 1 + lengthLength, offset + 1 + lengthLength + length_4));
  44087. return { consumed: (1 + lengthLength + length_4), result: result };
  44088. }
  44089. else if (data[offset] >= 0x80) {
  44090. var length_5 = data[offset] - 0x80;
  44091. if (offset + 1 + length_5 > data.length) {
  44092. logger.throwError("data too short", logger_1.Logger.errors.BUFFER_OVERRUN, {});
  44093. }
  44094. var result = (0, bytes_1.hexlify)(data.slice(offset + 1, offset + 1 + length_5));
  44095. return { consumed: (1 + length_5), result: result };
  44096. }
  44097. return { consumed: 1, result: (0, bytes_1.hexlify)(data[offset]) };
  44098. }
  44099. function decode(data) {
  44100. var bytes = (0, bytes_1.arrayify)(data);
  44101. var decoded = _decode(bytes, 0);
  44102. if (decoded.consumed !== bytes.length) {
  44103. logger.throwArgumentError("invalid rlp data", "data", data);
  44104. }
  44105. return decoded.result;
  44106. }
  44107. exports.decode = decode;
  44108. },{"./_version":252,"@ethersproject/bytes":199,"@ethersproject/logger":223}],254:[function(_dereq_,module,exports){
  44109. "use strict";
  44110. Object.defineProperty(exports, "__esModule", { value: true });
  44111. exports.version = void 0;
  44112. exports.version = "sha2/5.6.0";
  44113. },{}],255:[function(_dereq_,module,exports){
  44114. "use strict";
  44115. var __importDefault = (this && this.__importDefault) || function (mod) {
  44116. return (mod && mod.__esModule) ? mod : { "default": mod };
  44117. };
  44118. Object.defineProperty(exports, "__esModule", { value: true });
  44119. exports.computeHmac = exports.sha512 = exports.sha256 = exports.ripemd160 = void 0;
  44120. var hash_js_1 = __importDefault(_dereq_("hash.js"));
  44121. //const _ripemd160 = _hash.ripemd160;
  44122. var bytes_1 = _dereq_("@ethersproject/bytes");
  44123. var types_1 = _dereq_("./types");
  44124. var logger_1 = _dereq_("@ethersproject/logger");
  44125. var _version_1 = _dereq_("./_version");
  44126. var logger = new logger_1.Logger(_version_1.version);
  44127. function ripemd160(data) {
  44128. return "0x" + (hash_js_1.default.ripemd160().update((0, bytes_1.arrayify)(data)).digest("hex"));
  44129. }
  44130. exports.ripemd160 = ripemd160;
  44131. function sha256(data) {
  44132. return "0x" + (hash_js_1.default.sha256().update((0, bytes_1.arrayify)(data)).digest("hex"));
  44133. }
  44134. exports.sha256 = sha256;
  44135. function sha512(data) {
  44136. return "0x" + (hash_js_1.default.sha512().update((0, bytes_1.arrayify)(data)).digest("hex"));
  44137. }
  44138. exports.sha512 = sha512;
  44139. function computeHmac(algorithm, key, data) {
  44140. if (!types_1.SupportedAlgorithm[algorithm]) {
  44141. logger.throwError("unsupported algorithm " + algorithm, logger_1.Logger.errors.UNSUPPORTED_OPERATION, {
  44142. operation: "hmac",
  44143. algorithm: algorithm
  44144. });
  44145. }
  44146. return "0x" + hash_js_1.default.hmac(hash_js_1.default[algorithm], (0, bytes_1.arrayify)(key)).update((0, bytes_1.arrayify)(data)).digest("hex");
  44147. }
  44148. exports.computeHmac = computeHmac;
  44149. },{"./_version":254,"./types":257,"@ethersproject/bytes":199,"@ethersproject/logger":223,"hash.js":776}],256:[function(_dereq_,module,exports){
  44150. "use strict";
  44151. Object.defineProperty(exports, "__esModule", { value: true });
  44152. exports.SupportedAlgorithm = exports.sha512 = exports.sha256 = exports.ripemd160 = exports.computeHmac = void 0;
  44153. var sha2_1 = _dereq_("./sha2");
  44154. Object.defineProperty(exports, "computeHmac", { enumerable: true, get: function () { return sha2_1.computeHmac; } });
  44155. Object.defineProperty(exports, "ripemd160", { enumerable: true, get: function () { return sha2_1.ripemd160; } });
  44156. Object.defineProperty(exports, "sha256", { enumerable: true, get: function () { return sha2_1.sha256; } });
  44157. Object.defineProperty(exports, "sha512", { enumerable: true, get: function () { return sha2_1.sha512; } });
  44158. var types_1 = _dereq_("./types");
  44159. Object.defineProperty(exports, "SupportedAlgorithm", { enumerable: true, get: function () { return types_1.SupportedAlgorithm; } });
  44160. },{"./sha2":255,"./types":257}],257:[function(_dereq_,module,exports){
  44161. "use strict";
  44162. Object.defineProperty(exports, "__esModule", { value: true });
  44163. exports.SupportedAlgorithm = void 0;
  44164. var SupportedAlgorithm;
  44165. (function (SupportedAlgorithm) {
  44166. SupportedAlgorithm["sha256"] = "sha256";
  44167. SupportedAlgorithm["sha512"] = "sha512";
  44168. })(SupportedAlgorithm = exports.SupportedAlgorithm || (exports.SupportedAlgorithm = {}));
  44169. ;
  44170. },{}],258:[function(_dereq_,module,exports){
  44171. "use strict";
  44172. Object.defineProperty(exports, "__esModule", { value: true });
  44173. exports.version = void 0;
  44174. exports.version = "signing-key/5.6.0";
  44175. },{}],259:[function(_dereq_,module,exports){
  44176. "use strict";
  44177. var __importDefault = (this && this.__importDefault) || function (mod) {
  44178. return (mod && mod.__esModule) ? mod : { "default": mod };
  44179. };
  44180. Object.defineProperty(exports, "__esModule", { value: true });
  44181. exports.EC = void 0;
  44182. var elliptic_1 = __importDefault(_dereq_("elliptic"));
  44183. var EC = elliptic_1.default.ec;
  44184. exports.EC = EC;
  44185. },{"elliptic":754}],260:[function(_dereq_,module,exports){
  44186. "use strict";
  44187. Object.defineProperty(exports, "__esModule", { value: true });
  44188. exports.computePublicKey = exports.recoverPublicKey = exports.SigningKey = void 0;
  44189. var elliptic_1 = _dereq_("./elliptic");
  44190. var bytes_1 = _dereq_("@ethersproject/bytes");
  44191. var properties_1 = _dereq_("@ethersproject/properties");
  44192. var logger_1 = _dereq_("@ethersproject/logger");
  44193. var _version_1 = _dereq_("./_version");
  44194. var logger = new logger_1.Logger(_version_1.version);
  44195. var _curve = null;
  44196. function getCurve() {
  44197. if (!_curve) {
  44198. _curve = new elliptic_1.EC("secp256k1");
  44199. }
  44200. return _curve;
  44201. }
  44202. var SigningKey = /** @class */ (function () {
  44203. function SigningKey(privateKey) {
  44204. (0, properties_1.defineReadOnly)(this, "curve", "secp256k1");
  44205. (0, properties_1.defineReadOnly)(this, "privateKey", (0, bytes_1.hexlify)(privateKey));
  44206. var keyPair = getCurve().keyFromPrivate((0, bytes_1.arrayify)(this.privateKey));
  44207. (0, properties_1.defineReadOnly)(this, "publicKey", "0x" + keyPair.getPublic(false, "hex"));
  44208. (0, properties_1.defineReadOnly)(this, "compressedPublicKey", "0x" + keyPair.getPublic(true, "hex"));
  44209. (0, properties_1.defineReadOnly)(this, "_isSigningKey", true);
  44210. }
  44211. SigningKey.prototype._addPoint = function (other) {
  44212. var p0 = getCurve().keyFromPublic((0, bytes_1.arrayify)(this.publicKey));
  44213. var p1 = getCurve().keyFromPublic((0, bytes_1.arrayify)(other));
  44214. return "0x" + p0.pub.add(p1.pub).encodeCompressed("hex");
  44215. };
  44216. SigningKey.prototype.signDigest = function (digest) {
  44217. var keyPair = getCurve().keyFromPrivate((0, bytes_1.arrayify)(this.privateKey));
  44218. var digestBytes = (0, bytes_1.arrayify)(digest);
  44219. if (digestBytes.length !== 32) {
  44220. logger.throwArgumentError("bad digest length", "digest", digest);
  44221. }
  44222. var signature = keyPair.sign(digestBytes, { canonical: true });
  44223. return (0, bytes_1.splitSignature)({
  44224. recoveryParam: signature.recoveryParam,
  44225. r: (0, bytes_1.hexZeroPad)("0x" + signature.r.toString(16), 32),
  44226. s: (0, bytes_1.hexZeroPad)("0x" + signature.s.toString(16), 32),
  44227. });
  44228. };
  44229. SigningKey.prototype.computeSharedSecret = function (otherKey) {
  44230. var keyPair = getCurve().keyFromPrivate((0, bytes_1.arrayify)(this.privateKey));
  44231. var otherKeyPair = getCurve().keyFromPublic((0, bytes_1.arrayify)(computePublicKey(otherKey)));
  44232. return (0, bytes_1.hexZeroPad)("0x" + keyPair.derive(otherKeyPair.getPublic()).toString(16), 32);
  44233. };
  44234. SigningKey.isSigningKey = function (value) {
  44235. return !!(value && value._isSigningKey);
  44236. };
  44237. return SigningKey;
  44238. }());
  44239. exports.SigningKey = SigningKey;
  44240. function recoverPublicKey(digest, signature) {
  44241. var sig = (0, bytes_1.splitSignature)(signature);
  44242. var rs = { r: (0, bytes_1.arrayify)(sig.r), s: (0, bytes_1.arrayify)(sig.s) };
  44243. return "0x" + getCurve().recoverPubKey((0, bytes_1.arrayify)(digest), rs, sig.recoveryParam).encode("hex", false);
  44244. }
  44245. exports.recoverPublicKey = recoverPublicKey;
  44246. function computePublicKey(key, compressed) {
  44247. var bytes = (0, bytes_1.arrayify)(key);
  44248. if (bytes.length === 32) {
  44249. var signingKey = new SigningKey(bytes);
  44250. if (compressed) {
  44251. return "0x" + getCurve().keyFromPrivate(bytes).getPublic(true, "hex");
  44252. }
  44253. return signingKey.publicKey;
  44254. }
  44255. else if (bytes.length === 33) {
  44256. if (compressed) {
  44257. return (0, bytes_1.hexlify)(bytes);
  44258. }
  44259. return "0x" + getCurve().keyFromPublic(bytes).getPublic(false, "hex");
  44260. }
  44261. else if (bytes.length === 65) {
  44262. if (!compressed) {
  44263. return (0, bytes_1.hexlify)(bytes);
  44264. }
  44265. return "0x" + getCurve().keyFromPublic(bytes).getPublic(true, "hex");
  44266. }
  44267. return logger.throwArgumentError("invalid public or private key", "key", "[REDACTED]");
  44268. }
  44269. exports.computePublicKey = computePublicKey;
  44270. },{"./_version":258,"./elliptic":259,"@ethersproject/bytes":199,"@ethersproject/logger":223,"@ethersproject/properties":229}],261:[function(_dereq_,module,exports){
  44271. "use strict";
  44272. Object.defineProperty(exports, "__esModule", { value: true });
  44273. exports.version = void 0;
  44274. exports.version = "solidity/5.6.0";
  44275. },{}],262:[function(_dereq_,module,exports){
  44276. "use strict";
  44277. Object.defineProperty(exports, "__esModule", { value: true });
  44278. exports.sha256 = exports.keccak256 = exports.pack = void 0;
  44279. var bignumber_1 = _dereq_("@ethersproject/bignumber");
  44280. var bytes_1 = _dereq_("@ethersproject/bytes");
  44281. var keccak256_1 = _dereq_("@ethersproject/keccak256");
  44282. var sha2_1 = _dereq_("@ethersproject/sha2");
  44283. var strings_1 = _dereq_("@ethersproject/strings");
  44284. var regexBytes = new RegExp("^bytes([0-9]+)$");
  44285. var regexNumber = new RegExp("^(u?int)([0-9]*)$");
  44286. var regexArray = new RegExp("^(.*)\\[([0-9]*)\\]$");
  44287. var Zeros = "0000000000000000000000000000000000000000000000000000000000000000";
  44288. var logger_1 = _dereq_("@ethersproject/logger");
  44289. var _version_1 = _dereq_("./_version");
  44290. var logger = new logger_1.Logger(_version_1.version);
  44291. function _pack(type, value, isArray) {
  44292. switch (type) {
  44293. case "address":
  44294. if (isArray) {
  44295. return (0, bytes_1.zeroPad)(value, 32);
  44296. }
  44297. return (0, bytes_1.arrayify)(value);
  44298. case "string":
  44299. return (0, strings_1.toUtf8Bytes)(value);
  44300. case "bytes":
  44301. return (0, bytes_1.arrayify)(value);
  44302. case "bool":
  44303. value = (value ? "0x01" : "0x00");
  44304. if (isArray) {
  44305. return (0, bytes_1.zeroPad)(value, 32);
  44306. }
  44307. return (0, bytes_1.arrayify)(value);
  44308. }
  44309. var match = type.match(regexNumber);
  44310. if (match) {
  44311. //let signed = (match[1] === "int")
  44312. var size = parseInt(match[2] || "256");
  44313. if ((match[2] && String(size) !== match[2]) || (size % 8 !== 0) || size === 0 || size > 256) {
  44314. logger.throwArgumentError("invalid number type", "type", type);
  44315. }
  44316. if (isArray) {
  44317. size = 256;
  44318. }
  44319. value = bignumber_1.BigNumber.from(value).toTwos(size);
  44320. return (0, bytes_1.zeroPad)(value, size / 8);
  44321. }
  44322. match = type.match(regexBytes);
  44323. if (match) {
  44324. var size = parseInt(match[1]);
  44325. if (String(size) !== match[1] || size === 0 || size > 32) {
  44326. logger.throwArgumentError("invalid bytes type", "type", type);
  44327. }
  44328. if ((0, bytes_1.arrayify)(value).byteLength !== size) {
  44329. logger.throwArgumentError("invalid value for " + type, "value", value);
  44330. }
  44331. if (isArray) {
  44332. return (0, bytes_1.arrayify)((value + Zeros).substring(0, 66));
  44333. }
  44334. return value;
  44335. }
  44336. match = type.match(regexArray);
  44337. if (match && Array.isArray(value)) {
  44338. var baseType_1 = match[1];
  44339. var count = parseInt(match[2] || String(value.length));
  44340. if (count != value.length) {
  44341. logger.throwArgumentError("invalid array length for " + type, "value", value);
  44342. }
  44343. var result_1 = [];
  44344. value.forEach(function (value) {
  44345. result_1.push(_pack(baseType_1, value, true));
  44346. });
  44347. return (0, bytes_1.concat)(result_1);
  44348. }
  44349. return logger.throwArgumentError("invalid type", "type", type);
  44350. }
  44351. // @TODO: Array Enum
  44352. function pack(types, values) {
  44353. if (types.length != values.length) {
  44354. logger.throwArgumentError("wrong number of values; expected ${ types.length }", "values", values);
  44355. }
  44356. var tight = [];
  44357. types.forEach(function (type, index) {
  44358. tight.push(_pack(type, values[index]));
  44359. });
  44360. return (0, bytes_1.hexlify)((0, bytes_1.concat)(tight));
  44361. }
  44362. exports.pack = pack;
  44363. function keccak256(types, values) {
  44364. return (0, keccak256_1.keccak256)(pack(types, values));
  44365. }
  44366. exports.keccak256 = keccak256;
  44367. function sha256(types, values) {
  44368. return (0, sha2_1.sha256)(pack(types, values));
  44369. }
  44370. exports.sha256 = sha256;
  44371. },{"./_version":261,"@ethersproject/bignumber":196,"@ethersproject/bytes":199,"@ethersproject/keccak256":221,"@ethersproject/logger":223,"@ethersproject/sha2":256,"@ethersproject/strings":266}],263:[function(_dereq_,module,exports){
  44372. "use strict";
  44373. Object.defineProperty(exports, "__esModule", { value: true });
  44374. exports.version = void 0;
  44375. exports.version = "strings/5.6.0";
  44376. },{}],264:[function(_dereq_,module,exports){
  44377. "use strict";
  44378. Object.defineProperty(exports, "__esModule", { value: true });
  44379. exports.parseBytes32String = exports.formatBytes32String = void 0;
  44380. var constants_1 = _dereq_("@ethersproject/constants");
  44381. var bytes_1 = _dereq_("@ethersproject/bytes");
  44382. var utf8_1 = _dereq_("./utf8");
  44383. function formatBytes32String(text) {
  44384. // Get the bytes
  44385. var bytes = (0, utf8_1.toUtf8Bytes)(text);
  44386. // Check we have room for null-termination
  44387. if (bytes.length > 31) {
  44388. throw new Error("bytes32 string must be less than 32 bytes");
  44389. }
  44390. // Zero-pad (implicitly null-terminates)
  44391. return (0, bytes_1.hexlify)((0, bytes_1.concat)([bytes, constants_1.HashZero]).slice(0, 32));
  44392. }
  44393. exports.formatBytes32String = formatBytes32String;
  44394. function parseBytes32String(bytes) {
  44395. var data = (0, bytes_1.arrayify)(bytes);
  44396. // Must be 32 bytes with a null-termination
  44397. if (data.length !== 32) {
  44398. throw new Error("invalid bytes32 - not 32 bytes long");
  44399. }
  44400. if (data[31] !== 0) {
  44401. throw new Error("invalid bytes32 string - no null terminator");
  44402. }
  44403. // Find the null termination
  44404. var length = 31;
  44405. while (data[length - 1] === 0) {
  44406. length--;
  44407. }
  44408. // Determine the string value
  44409. return (0, utf8_1.toUtf8String)(data.slice(0, length));
  44410. }
  44411. exports.parseBytes32String = parseBytes32String;
  44412. },{"./utf8":267,"@ethersproject/bytes":199,"@ethersproject/constants":203}],265:[function(_dereq_,module,exports){
  44413. "use strict";
  44414. Object.defineProperty(exports, "__esModule", { value: true });
  44415. exports.nameprep = exports._nameprepTableC = exports._nameprepTableB2 = exports._nameprepTableA1 = void 0;
  44416. var utf8_1 = _dereq_("./utf8");
  44417. function bytes2(data) {
  44418. if ((data.length % 4) !== 0) {
  44419. throw new Error("bad data");
  44420. }
  44421. var result = [];
  44422. for (var i = 0; i < data.length; i += 4) {
  44423. result.push(parseInt(data.substring(i, i + 4), 16));
  44424. }
  44425. return result;
  44426. }
  44427. function createTable(data, func) {
  44428. if (!func) {
  44429. func = function (value) { return [parseInt(value, 16)]; };
  44430. }
  44431. var lo = 0;
  44432. var result = {};
  44433. data.split(",").forEach(function (pair) {
  44434. var comps = pair.split(":");
  44435. lo += parseInt(comps[0], 16);
  44436. result[lo] = func(comps[1]);
  44437. });
  44438. return result;
  44439. }
  44440. function createRangeTable(data) {
  44441. var hi = 0;
  44442. return data.split(",").map(function (v) {
  44443. var comps = v.split("-");
  44444. if (comps.length === 1) {
  44445. comps[1] = "0";
  44446. }
  44447. else if (comps[1] === "") {
  44448. comps[1] = "1";
  44449. }
  44450. var lo = hi + parseInt(comps[0], 16);
  44451. hi = parseInt(comps[1], 16);
  44452. return { l: lo, h: hi };
  44453. });
  44454. }
  44455. function matchMap(value, ranges) {
  44456. var lo = 0;
  44457. for (var i = 0; i < ranges.length; i++) {
  44458. var range = ranges[i];
  44459. lo += range.l;
  44460. if (value >= lo && value <= lo + range.h && ((value - lo) % (range.d || 1)) === 0) {
  44461. if (range.e && range.e.indexOf(value - lo) !== -1) {
  44462. continue;
  44463. }
  44464. return range;
  44465. }
  44466. }
  44467. return null;
  44468. }
  44469. var Table_A_1_ranges = createRangeTable("221,13-1b,5f-,40-10,51-f,11-3,3-3,2-2,2-4,8,2,15,2d,28-8,88,48,27-,3-5,11-20,27-,8,28,3-5,12,18,b-a,1c-4,6-16,2-d,2-2,2,1b-4,17-9,8f-,10,f,1f-2,1c-34,33-14e,4,36-,13-,6-2,1a-f,4,9-,3-,17,8,2-2,5-,2,8-,3-,4-8,2-3,3,6-,16-6,2-,7-3,3-,17,8,3,3,3-,2,6-3,3-,4-a,5,2-6,10-b,4,8,2,4,17,8,3,6-,b,4,4-,2-e,2-4,b-10,4,9-,3-,17,8,3-,5-,9-2,3-,4-7,3-3,3,4-3,c-10,3,7-2,4,5-2,3,2,3-2,3-2,4-2,9,4-3,6-2,4,5-8,2-e,d-d,4,9,4,18,b,6-3,8,4,5-6,3-8,3-3,b-11,3,9,4,18,b,6-3,8,4,5-6,3-6,2,3-3,b-11,3,9,4,18,11-3,7-,4,5-8,2-7,3-3,b-11,3,13-2,19,a,2-,8-2,2-3,7,2,9-11,4-b,3b-3,1e-24,3,2-,3,2-,2-5,5,8,4,2,2-,3,e,4-,6,2,7-,b-,3-21,49,23-5,1c-3,9,25,10-,2-2f,23,6,3,8-2,5-5,1b-45,27-9,2a-,2-3,5b-4,45-4,53-5,8,40,2,5-,8,2,5-,28,2,5-,20,2,5-,8,2,5-,8,8,18,20,2,5-,8,28,14-5,1d-22,56-b,277-8,1e-2,52-e,e,8-a,18-8,15-b,e,4,3-b,5e-2,b-15,10,b-5,59-7,2b-555,9d-3,5b-5,17-,7-,27-,7-,9,2,2,2,20-,36,10,f-,7,14-,4,a,54-3,2-6,6-5,9-,1c-10,13-1d,1c-14,3c-,10-6,32-b,240-30,28-18,c-14,a0,115-,3,66-,b-76,5,5-,1d,24,2,5-2,2,8-,35-2,19,f-10,1d-3,311-37f,1b,5a-b,d7-19,d-3,41,57-,68-4,29-3,5f,29-37,2e-2,25-c,2c-2,4e-3,30,78-3,64-,20,19b7-49,51a7-59,48e-2,38-738,2ba5-5b,222f-,3c-94,8-b,6-4,1b,6,2,3,3,6d-20,16e-f,41-,37-7,2e-2,11-f,5-b,18-,b,14,5-3,6,88-,2,bf-2,7-,7-,7-,4-2,8,8-9,8-2ff,20,5-b,1c-b4,27-,27-cbb1,f7-9,28-2,b5-221,56,48,3-,2-,3-,5,d,2,5,3,42,5-,9,8,1d,5,6,2-2,8,153-3,123-3,33-27fd,a6da-5128,21f-5df,3-fffd,3-fffd,3-fffd,3-fffd,3-fffd,3-fffd,3-fffd,3-fffd,3-fffd,3-fffd,3-fffd,3,2-1d,61-ff7d");
  44470. // @TODO: Make this relative...
  44471. var Table_B_1_flags = "ad,34f,1806,180b,180c,180d,200b,200c,200d,2060,feff".split(",").map(function (v) { return parseInt(v, 16); });
  44472. var Table_B_2_ranges = [
  44473. { h: 25, s: 32, l: 65 },
  44474. { h: 30, s: 32, e: [23], l: 127 },
  44475. { h: 54, s: 1, e: [48], l: 64, d: 2 },
  44476. { h: 14, s: 1, l: 57, d: 2 },
  44477. { h: 44, s: 1, l: 17, d: 2 },
  44478. { h: 10, s: 1, e: [2, 6, 8], l: 61, d: 2 },
  44479. { h: 16, s: 1, l: 68, d: 2 },
  44480. { h: 84, s: 1, e: [18, 24, 66], l: 19, d: 2 },
  44481. { h: 26, s: 32, e: [17], l: 435 },
  44482. { h: 22, s: 1, l: 71, d: 2 },
  44483. { h: 15, s: 80, l: 40 },
  44484. { h: 31, s: 32, l: 16 },
  44485. { h: 32, s: 1, l: 80, d: 2 },
  44486. { h: 52, s: 1, l: 42, d: 2 },
  44487. { h: 12, s: 1, l: 55, d: 2 },
  44488. { h: 40, s: 1, e: [38], l: 15, d: 2 },
  44489. { h: 14, s: 1, l: 48, d: 2 },
  44490. { h: 37, s: 48, l: 49 },
  44491. { h: 148, s: 1, l: 6351, d: 2 },
  44492. { h: 88, s: 1, l: 160, d: 2 },
  44493. { h: 15, s: 16, l: 704 },
  44494. { h: 25, s: 26, l: 854 },
  44495. { h: 25, s: 32, l: 55915 },
  44496. { h: 37, s: 40, l: 1247 },
  44497. { h: 25, s: -119711, l: 53248 },
  44498. { h: 25, s: -119763, l: 52 },
  44499. { h: 25, s: -119815, l: 52 },
  44500. { h: 25, s: -119867, e: [1, 4, 5, 7, 8, 11, 12, 17], l: 52 },
  44501. { h: 25, s: -119919, l: 52 },
  44502. { h: 24, s: -119971, e: [2, 7, 8, 17], l: 52 },
  44503. { h: 24, s: -120023, e: [2, 7, 13, 15, 16, 17], l: 52 },
  44504. { h: 25, s: -120075, l: 52 },
  44505. { h: 25, s: -120127, l: 52 },
  44506. { h: 25, s: -120179, l: 52 },
  44507. { h: 25, s: -120231, l: 52 },
  44508. { h: 25, s: -120283, l: 52 },
  44509. { h: 25, s: -120335, l: 52 },
  44510. { h: 24, s: -119543, e: [17], l: 56 },
  44511. { h: 24, s: -119601, e: [17], l: 58 },
  44512. { h: 24, s: -119659, e: [17], l: 58 },
  44513. { h: 24, s: -119717, e: [17], l: 58 },
  44514. { h: 24, s: -119775, e: [17], l: 58 }
  44515. ];
  44516. var Table_B_2_lut_abs = createTable("b5:3bc,c3:ff,7:73,2:253,5:254,3:256,1:257,5:259,1:25b,3:260,1:263,2:269,1:268,5:26f,1:272,2:275,7:280,3:283,5:288,3:28a,1:28b,5:292,3f:195,1:1bf,29:19e,125:3b9,8b:3b2,1:3b8,1:3c5,3:3c6,1:3c0,1a:3ba,1:3c1,1:3c3,2:3b8,1:3b5,1bc9:3b9,1c:1f76,1:1f77,f:1f7a,1:1f7b,d:1f78,1:1f79,1:1f7c,1:1f7d,107:63,5:25b,4:68,1:68,1:68,3:69,1:69,1:6c,3:6e,4:70,1:71,1:72,1:72,1:72,7:7a,2:3c9,2:7a,2:6b,1:e5,1:62,1:63,3:65,1:66,2:6d,b:3b3,1:3c0,6:64,1b574:3b8,1a:3c3,20:3b8,1a:3c3,20:3b8,1a:3c3,20:3b8,1a:3c3,20:3b8,1a:3c3");
  44517. var Table_B_2_lut_rel = createTable("179:1,2:1,2:1,5:1,2:1,a:4f,a:1,8:1,2:1,2:1,3:1,5:1,3:1,4:1,2:1,3:1,4:1,8:2,1:1,2:2,1:1,2:2,27:2,195:26,2:25,1:25,1:25,2:40,2:3f,1:3f,33:1,11:-6,1:-9,1ac7:-3a,6d:-8,1:-8,1:-8,1:-8,1:-8,1:-8,1:-8,1:-8,9:-8,1:-8,1:-8,1:-8,1:-8,1:-8,b:-8,1:-8,1:-8,1:-8,1:-8,1:-8,1:-8,1:-8,9:-8,1:-8,1:-8,1:-8,1:-8,1:-8,1:-8,1:-8,9:-8,1:-8,1:-8,1:-8,1:-8,1:-8,c:-8,2:-8,2:-8,2:-8,9:-8,1:-8,1:-8,1:-8,1:-8,1:-8,1:-8,1:-8,49:-8,1:-8,1:-4a,1:-4a,d:-56,1:-56,1:-56,1:-56,d:-8,1:-8,f:-8,1:-8,3:-7");
  44518. var Table_B_2_complex = createTable("df:00730073,51:00690307,19:02BC006E,a7:006A030C,18a:002003B9,16:03B903080301,20:03C503080301,1d7:05650582,190f:00680331,1:00740308,1:0077030A,1:0079030A,1:006102BE,b6:03C50313,2:03C503130300,2:03C503130301,2:03C503130342,2a:1F0003B9,1:1F0103B9,1:1F0203B9,1:1F0303B9,1:1F0403B9,1:1F0503B9,1:1F0603B9,1:1F0703B9,1:1F0003B9,1:1F0103B9,1:1F0203B9,1:1F0303B9,1:1F0403B9,1:1F0503B9,1:1F0603B9,1:1F0703B9,1:1F2003B9,1:1F2103B9,1:1F2203B9,1:1F2303B9,1:1F2403B9,1:1F2503B9,1:1F2603B9,1:1F2703B9,1:1F2003B9,1:1F2103B9,1:1F2203B9,1:1F2303B9,1:1F2403B9,1:1F2503B9,1:1F2603B9,1:1F2703B9,1:1F6003B9,1:1F6103B9,1:1F6203B9,1:1F6303B9,1:1F6403B9,1:1F6503B9,1:1F6603B9,1:1F6703B9,1:1F6003B9,1:1F6103B9,1:1F6203B9,1:1F6303B9,1:1F6403B9,1:1F6503B9,1:1F6603B9,1:1F6703B9,3:1F7003B9,1:03B103B9,1:03AC03B9,2:03B10342,1:03B1034203B9,5:03B103B9,6:1F7403B9,1:03B703B9,1:03AE03B9,2:03B70342,1:03B7034203B9,5:03B703B9,6:03B903080300,1:03B903080301,3:03B90342,1:03B903080342,b:03C503080300,1:03C503080301,1:03C10313,2:03C50342,1:03C503080342,b:1F7C03B9,1:03C903B9,1:03CE03B9,2:03C90342,1:03C9034203B9,5:03C903B9,ac:00720073,5b:00B00063,6:00B00066,d:006E006F,a:0073006D,1:00740065006C,1:0074006D,124f:006800700061,2:00610075,2:006F0076,b:00700061,1:006E0061,1:03BC0061,1:006D0061,1:006B0061,1:006B0062,1:006D0062,1:00670062,3:00700066,1:006E0066,1:03BC0066,4:0068007A,1:006B0068007A,1:006D0068007A,1:00670068007A,1:00740068007A,15:00700061,1:006B00700061,1:006D00700061,1:006700700061,8:00700076,1:006E0076,1:03BC0076,1:006D0076,1:006B0076,1:006D0076,1:00700077,1:006E0077,1:03BC0077,1:006D0077,1:006B0077,1:006D0077,1:006B03C9,1:006D03C9,2:00620071,3:00632215006B0067,1:0063006F002E,1:00640062,1:00670079,2:00680070,2:006B006B,1:006B006D,9:00700068,2:00700070006D,1:00700072,2:00730076,1:00770062,c723:00660066,1:00660069,1:0066006C,1:006600660069,1:00660066006C,1:00730074,1:00730074,d:05740576,1:05740565,1:0574056B,1:057E0576,1:0574056D", bytes2);
  44519. var Table_C_ranges = createRangeTable("80-20,2a0-,39c,32,f71,18e,7f2-f,19-7,30-4,7-5,f81-b,5,a800-20ff,4d1-1f,110,fa-6,d174-7,2e84-,ffff-,ffff-,ffff-,ffff-,ffff-,ffff-,ffff-,ffff-,ffff-,ffff-,ffff-,ffff-,2,1f-5f,ff7f-20001");
  44520. function flatten(values) {
  44521. return values.reduce(function (accum, value) {
  44522. value.forEach(function (value) { accum.push(value); });
  44523. return accum;
  44524. }, []);
  44525. }
  44526. function _nameprepTableA1(codepoint) {
  44527. return !!matchMap(codepoint, Table_A_1_ranges);
  44528. }
  44529. exports._nameprepTableA1 = _nameprepTableA1;
  44530. function _nameprepTableB2(codepoint) {
  44531. var range = matchMap(codepoint, Table_B_2_ranges);
  44532. if (range) {
  44533. return [codepoint + range.s];
  44534. }
  44535. var codes = Table_B_2_lut_abs[codepoint];
  44536. if (codes) {
  44537. return codes;
  44538. }
  44539. var shift = Table_B_2_lut_rel[codepoint];
  44540. if (shift) {
  44541. return [codepoint + shift[0]];
  44542. }
  44543. var complex = Table_B_2_complex[codepoint];
  44544. if (complex) {
  44545. return complex;
  44546. }
  44547. return null;
  44548. }
  44549. exports._nameprepTableB2 = _nameprepTableB2;
  44550. function _nameprepTableC(codepoint) {
  44551. return !!matchMap(codepoint, Table_C_ranges);
  44552. }
  44553. exports._nameprepTableC = _nameprepTableC;
  44554. function nameprep(value) {
  44555. // This allows platforms with incomplete normalize to bypass
  44556. // it for very basic names which the built-in toLowerCase
  44557. // will certainly handle correctly
  44558. if (value.match(/^[a-z0-9-]*$/i) && value.length <= 59) {
  44559. return value.toLowerCase();
  44560. }
  44561. // Get the code points (keeping the current normalization)
  44562. var codes = (0, utf8_1.toUtf8CodePoints)(value);
  44563. codes = flatten(codes.map(function (code) {
  44564. // Substitute Table B.1 (Maps to Nothing)
  44565. if (Table_B_1_flags.indexOf(code) >= 0) {
  44566. return [];
  44567. }
  44568. if (code >= 0xfe00 && code <= 0xfe0f) {
  44569. return [];
  44570. }
  44571. // Substitute Table B.2 (Case Folding)
  44572. var codesTableB2 = _nameprepTableB2(code);
  44573. if (codesTableB2) {
  44574. return codesTableB2;
  44575. }
  44576. // No Substitution
  44577. return [code];
  44578. }));
  44579. // Normalize using form KC
  44580. codes = (0, utf8_1.toUtf8CodePoints)((0, utf8_1._toUtf8String)(codes), utf8_1.UnicodeNormalizationForm.NFKC);
  44581. // Prohibit Tables C.1.2, C.2.2, C.3, C.4, C.5, C.6, C.7, C.8, C.9
  44582. codes.forEach(function (code) {
  44583. if (_nameprepTableC(code)) {
  44584. throw new Error("STRINGPREP_CONTAINS_PROHIBITED");
  44585. }
  44586. });
  44587. // Prohibit Unassigned Code Points (Table A.1)
  44588. codes.forEach(function (code) {
  44589. if (_nameprepTableA1(code)) {
  44590. throw new Error("STRINGPREP_CONTAINS_UNASSIGNED");
  44591. }
  44592. });
  44593. // IDNA extras
  44594. var name = (0, utf8_1._toUtf8String)(codes);
  44595. // IDNA: 4.2.3.1
  44596. if (name.substring(0, 1) === "-" || name.substring(2, 4) === "--" || name.substring(name.length - 1) === "-") {
  44597. throw new Error("invalid hyphen");
  44598. }
  44599. // IDNA: 4.2.4
  44600. if (name.length > 63) {
  44601. throw new Error("too long");
  44602. }
  44603. return name;
  44604. }
  44605. exports.nameprep = nameprep;
  44606. },{"./utf8":267}],266:[function(_dereq_,module,exports){
  44607. "use strict";
  44608. Object.defineProperty(exports, "__esModule", { value: true });
  44609. exports.nameprep = exports.parseBytes32String = exports.formatBytes32String = exports.UnicodeNormalizationForm = exports.Utf8ErrorReason = exports.Utf8ErrorFuncs = exports.toUtf8String = exports.toUtf8CodePoints = exports.toUtf8Bytes = exports._toEscapedUtf8String = void 0;
  44610. var bytes32_1 = _dereq_("./bytes32");
  44611. Object.defineProperty(exports, "formatBytes32String", { enumerable: true, get: function () { return bytes32_1.formatBytes32String; } });
  44612. Object.defineProperty(exports, "parseBytes32String", { enumerable: true, get: function () { return bytes32_1.parseBytes32String; } });
  44613. var idna_1 = _dereq_("./idna");
  44614. Object.defineProperty(exports, "nameprep", { enumerable: true, get: function () { return idna_1.nameprep; } });
  44615. var utf8_1 = _dereq_("./utf8");
  44616. Object.defineProperty(exports, "_toEscapedUtf8String", { enumerable: true, get: function () { return utf8_1._toEscapedUtf8String; } });
  44617. Object.defineProperty(exports, "toUtf8Bytes", { enumerable: true, get: function () { return utf8_1.toUtf8Bytes; } });
  44618. Object.defineProperty(exports, "toUtf8CodePoints", { enumerable: true, get: function () { return utf8_1.toUtf8CodePoints; } });
  44619. Object.defineProperty(exports, "toUtf8String", { enumerable: true, get: function () { return utf8_1.toUtf8String; } });
  44620. Object.defineProperty(exports, "UnicodeNormalizationForm", { enumerable: true, get: function () { return utf8_1.UnicodeNormalizationForm; } });
  44621. Object.defineProperty(exports, "Utf8ErrorFuncs", { enumerable: true, get: function () { return utf8_1.Utf8ErrorFuncs; } });
  44622. Object.defineProperty(exports, "Utf8ErrorReason", { enumerable: true, get: function () { return utf8_1.Utf8ErrorReason; } });
  44623. },{"./bytes32":264,"./idna":265,"./utf8":267}],267:[function(_dereq_,module,exports){
  44624. "use strict";
  44625. Object.defineProperty(exports, "__esModule", { value: true });
  44626. exports.toUtf8CodePoints = exports.toUtf8String = exports._toUtf8String = exports._toEscapedUtf8String = exports.toUtf8Bytes = exports.Utf8ErrorFuncs = exports.Utf8ErrorReason = exports.UnicodeNormalizationForm = void 0;
  44627. var bytes_1 = _dereq_("@ethersproject/bytes");
  44628. var logger_1 = _dereq_("@ethersproject/logger");
  44629. var _version_1 = _dereq_("./_version");
  44630. var logger = new logger_1.Logger(_version_1.version);
  44631. ///////////////////////////////
  44632. var UnicodeNormalizationForm;
  44633. (function (UnicodeNormalizationForm) {
  44634. UnicodeNormalizationForm["current"] = "";
  44635. UnicodeNormalizationForm["NFC"] = "NFC";
  44636. UnicodeNormalizationForm["NFD"] = "NFD";
  44637. UnicodeNormalizationForm["NFKC"] = "NFKC";
  44638. UnicodeNormalizationForm["NFKD"] = "NFKD";
  44639. })(UnicodeNormalizationForm = exports.UnicodeNormalizationForm || (exports.UnicodeNormalizationForm = {}));
  44640. ;
  44641. var Utf8ErrorReason;
  44642. (function (Utf8ErrorReason) {
  44643. // A continuation byte was present where there was nothing to continue
  44644. // - offset = the index the codepoint began in
  44645. Utf8ErrorReason["UNEXPECTED_CONTINUE"] = "unexpected continuation byte";
  44646. // An invalid (non-continuation) byte to start a UTF-8 codepoint was found
  44647. // - offset = the index the codepoint began in
  44648. Utf8ErrorReason["BAD_PREFIX"] = "bad codepoint prefix";
  44649. // The string is too short to process the expected codepoint
  44650. // - offset = the index the codepoint began in
  44651. Utf8ErrorReason["OVERRUN"] = "string overrun";
  44652. // A missing continuation byte was expected but not found
  44653. // - offset = the index the continuation byte was expected at
  44654. Utf8ErrorReason["MISSING_CONTINUE"] = "missing continuation byte";
  44655. // The computed code point is outside the range for UTF-8
  44656. // - offset = start of this codepoint
  44657. // - badCodepoint = the computed codepoint; outside the UTF-8 range
  44658. Utf8ErrorReason["OUT_OF_RANGE"] = "out of UTF-8 range";
  44659. // UTF-8 strings may not contain UTF-16 surrogate pairs
  44660. // - offset = start of this codepoint
  44661. // - badCodepoint = the computed codepoint; inside the UTF-16 surrogate range
  44662. Utf8ErrorReason["UTF16_SURROGATE"] = "UTF-16 surrogate";
  44663. // The string is an overlong representation
  44664. // - offset = start of this codepoint
  44665. // - badCodepoint = the computed codepoint; already bounds checked
  44666. Utf8ErrorReason["OVERLONG"] = "overlong representation";
  44667. })(Utf8ErrorReason = exports.Utf8ErrorReason || (exports.Utf8ErrorReason = {}));
  44668. ;
  44669. function errorFunc(reason, offset, bytes, output, badCodepoint) {
  44670. return logger.throwArgumentError("invalid codepoint at offset " + offset + "; " + reason, "bytes", bytes);
  44671. }
  44672. function ignoreFunc(reason, offset, bytes, output, badCodepoint) {
  44673. // If there is an invalid prefix (including stray continuation), skip any additional continuation bytes
  44674. if (reason === Utf8ErrorReason.BAD_PREFIX || reason === Utf8ErrorReason.UNEXPECTED_CONTINUE) {
  44675. var i = 0;
  44676. for (var o = offset + 1; o < bytes.length; o++) {
  44677. if (bytes[o] >> 6 !== 0x02) {
  44678. break;
  44679. }
  44680. i++;
  44681. }
  44682. return i;
  44683. }
  44684. // This byte runs us past the end of the string, so just jump to the end
  44685. // (but the first byte was read already read and therefore skipped)
  44686. if (reason === Utf8ErrorReason.OVERRUN) {
  44687. return bytes.length - offset - 1;
  44688. }
  44689. // Nothing to skip
  44690. return 0;
  44691. }
  44692. function replaceFunc(reason, offset, bytes, output, badCodepoint) {
  44693. // Overlong representations are otherwise "valid" code points; just non-deistingtished
  44694. if (reason === Utf8ErrorReason.OVERLONG) {
  44695. output.push(badCodepoint);
  44696. return 0;
  44697. }
  44698. // Put the replacement character into the output
  44699. output.push(0xfffd);
  44700. // Otherwise, process as if ignoring errors
  44701. return ignoreFunc(reason, offset, bytes, output, badCodepoint);
  44702. }
  44703. // Common error handing strategies
  44704. exports.Utf8ErrorFuncs = Object.freeze({
  44705. error: errorFunc,
  44706. ignore: ignoreFunc,
  44707. replace: replaceFunc
  44708. });
  44709. // http://stackoverflow.com/questions/13356493/decode-utf-8-with-javascript#13691499
  44710. function getUtf8CodePoints(bytes, onError) {
  44711. if (onError == null) {
  44712. onError = exports.Utf8ErrorFuncs.error;
  44713. }
  44714. bytes = (0, bytes_1.arrayify)(bytes);
  44715. var result = [];
  44716. var i = 0;
  44717. // Invalid bytes are ignored
  44718. while (i < bytes.length) {
  44719. var c = bytes[i++];
  44720. // 0xxx xxxx
  44721. if (c >> 7 === 0) {
  44722. result.push(c);
  44723. continue;
  44724. }
  44725. // Multibyte; how many bytes left for this character?
  44726. var extraLength = null;
  44727. var overlongMask = null;
  44728. // 110x xxxx 10xx xxxx
  44729. if ((c & 0xe0) === 0xc0) {
  44730. extraLength = 1;
  44731. overlongMask = 0x7f;
  44732. // 1110 xxxx 10xx xxxx 10xx xxxx
  44733. }
  44734. else if ((c & 0xf0) === 0xe0) {
  44735. extraLength = 2;
  44736. overlongMask = 0x7ff;
  44737. // 1111 0xxx 10xx xxxx 10xx xxxx 10xx xxxx
  44738. }
  44739. else if ((c & 0xf8) === 0xf0) {
  44740. extraLength = 3;
  44741. overlongMask = 0xffff;
  44742. }
  44743. else {
  44744. if ((c & 0xc0) === 0x80) {
  44745. i += onError(Utf8ErrorReason.UNEXPECTED_CONTINUE, i - 1, bytes, result);
  44746. }
  44747. else {
  44748. i += onError(Utf8ErrorReason.BAD_PREFIX, i - 1, bytes, result);
  44749. }
  44750. continue;
  44751. }
  44752. // Do we have enough bytes in our data?
  44753. if (i - 1 + extraLength >= bytes.length) {
  44754. i += onError(Utf8ErrorReason.OVERRUN, i - 1, bytes, result);
  44755. continue;
  44756. }
  44757. // Remove the length prefix from the char
  44758. var res = c & ((1 << (8 - extraLength - 1)) - 1);
  44759. for (var j = 0; j < extraLength; j++) {
  44760. var nextChar = bytes[i];
  44761. // Invalid continuation byte
  44762. if ((nextChar & 0xc0) != 0x80) {
  44763. i += onError(Utf8ErrorReason.MISSING_CONTINUE, i, bytes, result);
  44764. res = null;
  44765. break;
  44766. }
  44767. ;
  44768. res = (res << 6) | (nextChar & 0x3f);
  44769. i++;
  44770. }
  44771. // See above loop for invalid continuation byte
  44772. if (res === null) {
  44773. continue;
  44774. }
  44775. // Maximum code point
  44776. if (res > 0x10ffff) {
  44777. i += onError(Utf8ErrorReason.OUT_OF_RANGE, i - 1 - extraLength, bytes, result, res);
  44778. continue;
  44779. }
  44780. // Reserved for UTF-16 surrogate halves
  44781. if (res >= 0xd800 && res <= 0xdfff) {
  44782. i += onError(Utf8ErrorReason.UTF16_SURROGATE, i - 1 - extraLength, bytes, result, res);
  44783. continue;
  44784. }
  44785. // Check for overlong sequences (more bytes than needed)
  44786. if (res <= overlongMask) {
  44787. i += onError(Utf8ErrorReason.OVERLONG, i - 1 - extraLength, bytes, result, res);
  44788. continue;
  44789. }
  44790. result.push(res);
  44791. }
  44792. return result;
  44793. }
  44794. // http://stackoverflow.com/questions/18729405/how-to-convert-utf8-string-to-byte-array
  44795. function toUtf8Bytes(str, form) {
  44796. if (form === void 0) { form = UnicodeNormalizationForm.current; }
  44797. if (form != UnicodeNormalizationForm.current) {
  44798. logger.checkNormalize();
  44799. str = str.normalize(form);
  44800. }
  44801. var result = [];
  44802. for (var i = 0; i < str.length; i++) {
  44803. var c = str.charCodeAt(i);
  44804. if (c < 0x80) {
  44805. result.push(c);
  44806. }
  44807. else if (c < 0x800) {
  44808. result.push((c >> 6) | 0xc0);
  44809. result.push((c & 0x3f) | 0x80);
  44810. }
  44811. else if ((c & 0xfc00) == 0xd800) {
  44812. i++;
  44813. var c2 = str.charCodeAt(i);
  44814. if (i >= str.length || (c2 & 0xfc00) !== 0xdc00) {
  44815. throw new Error("invalid utf-8 string");
  44816. }
  44817. // Surrogate Pair
  44818. var pair = 0x10000 + ((c & 0x03ff) << 10) + (c2 & 0x03ff);
  44819. result.push((pair >> 18) | 0xf0);
  44820. result.push(((pair >> 12) & 0x3f) | 0x80);
  44821. result.push(((pair >> 6) & 0x3f) | 0x80);
  44822. result.push((pair & 0x3f) | 0x80);
  44823. }
  44824. else {
  44825. result.push((c >> 12) | 0xe0);
  44826. result.push(((c >> 6) & 0x3f) | 0x80);
  44827. result.push((c & 0x3f) | 0x80);
  44828. }
  44829. }
  44830. return (0, bytes_1.arrayify)(result);
  44831. }
  44832. exports.toUtf8Bytes = toUtf8Bytes;
  44833. ;
  44834. function escapeChar(value) {
  44835. var hex = ("0000" + value.toString(16));
  44836. return "\\u" + hex.substring(hex.length - 4);
  44837. }
  44838. function _toEscapedUtf8String(bytes, onError) {
  44839. return '"' + getUtf8CodePoints(bytes, onError).map(function (codePoint) {
  44840. if (codePoint < 256) {
  44841. switch (codePoint) {
  44842. case 8: return "\\b";
  44843. case 9: return "\\t";
  44844. case 10: return "\\n";
  44845. case 13: return "\\r";
  44846. case 34: return "\\\"";
  44847. case 92: return "\\\\";
  44848. }
  44849. if (codePoint >= 32 && codePoint < 127) {
  44850. return String.fromCharCode(codePoint);
  44851. }
  44852. }
  44853. if (codePoint <= 0xffff) {
  44854. return escapeChar(codePoint);
  44855. }
  44856. codePoint -= 0x10000;
  44857. return escapeChar(((codePoint >> 10) & 0x3ff) + 0xd800) + escapeChar((codePoint & 0x3ff) + 0xdc00);
  44858. }).join("") + '"';
  44859. }
  44860. exports._toEscapedUtf8String = _toEscapedUtf8String;
  44861. function _toUtf8String(codePoints) {
  44862. return codePoints.map(function (codePoint) {
  44863. if (codePoint <= 0xffff) {
  44864. return String.fromCharCode(codePoint);
  44865. }
  44866. codePoint -= 0x10000;
  44867. return String.fromCharCode((((codePoint >> 10) & 0x3ff) + 0xd800), ((codePoint & 0x3ff) + 0xdc00));
  44868. }).join("");
  44869. }
  44870. exports._toUtf8String = _toUtf8String;
  44871. function toUtf8String(bytes, onError) {
  44872. return _toUtf8String(getUtf8CodePoints(bytes, onError));
  44873. }
  44874. exports.toUtf8String = toUtf8String;
  44875. function toUtf8CodePoints(str, form) {
  44876. if (form === void 0) { form = UnicodeNormalizationForm.current; }
  44877. return getUtf8CodePoints(toUtf8Bytes(str, form));
  44878. }
  44879. exports.toUtf8CodePoints = toUtf8CodePoints;
  44880. },{"./_version":263,"@ethersproject/bytes":199,"@ethersproject/logger":223}],268:[function(_dereq_,module,exports){
  44881. "use strict";
  44882. Object.defineProperty(exports, "__esModule", { value: true });
  44883. exports.version = void 0;
  44884. exports.version = "transactions/5.6.0";
  44885. },{}],269:[function(_dereq_,module,exports){
  44886. "use strict";
  44887. var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
  44888. if (k2 === undefined) k2 = k;
  44889. Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
  44890. }) : (function(o, m, k, k2) {
  44891. if (k2 === undefined) k2 = k;
  44892. o[k2] = m[k];
  44893. }));
  44894. var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
  44895. Object.defineProperty(o, "default", { enumerable: true, value: v });
  44896. }) : function(o, v) {
  44897. o["default"] = v;
  44898. });
  44899. var __importStar = (this && this.__importStar) || function (mod) {
  44900. if (mod && mod.__esModule) return mod;
  44901. var result = {};
  44902. if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
  44903. __setModuleDefault(result, mod);
  44904. return result;
  44905. };
  44906. Object.defineProperty(exports, "__esModule", { value: true });
  44907. exports.parse = exports.serialize = exports.accessListify = exports.recoverAddress = exports.computeAddress = exports.TransactionTypes = void 0;
  44908. var address_1 = _dereq_("@ethersproject/address");
  44909. var bignumber_1 = _dereq_("@ethersproject/bignumber");
  44910. var bytes_1 = _dereq_("@ethersproject/bytes");
  44911. var constants_1 = _dereq_("@ethersproject/constants");
  44912. var keccak256_1 = _dereq_("@ethersproject/keccak256");
  44913. var properties_1 = _dereq_("@ethersproject/properties");
  44914. var RLP = __importStar(_dereq_("@ethersproject/rlp"));
  44915. var signing_key_1 = _dereq_("@ethersproject/signing-key");
  44916. var logger_1 = _dereq_("@ethersproject/logger");
  44917. var _version_1 = _dereq_("./_version");
  44918. var logger = new logger_1.Logger(_version_1.version);
  44919. var TransactionTypes;
  44920. (function (TransactionTypes) {
  44921. TransactionTypes[TransactionTypes["legacy"] = 0] = "legacy";
  44922. TransactionTypes[TransactionTypes["eip2930"] = 1] = "eip2930";
  44923. TransactionTypes[TransactionTypes["eip1559"] = 2] = "eip1559";
  44924. })(TransactionTypes = exports.TransactionTypes || (exports.TransactionTypes = {}));
  44925. ;
  44926. ///////////////////////////////
  44927. function handleAddress(value) {
  44928. if (value === "0x") {
  44929. return null;
  44930. }
  44931. return (0, address_1.getAddress)(value);
  44932. }
  44933. function handleNumber(value) {
  44934. if (value === "0x") {
  44935. return constants_1.Zero;
  44936. }
  44937. return bignumber_1.BigNumber.from(value);
  44938. }
  44939. // Legacy Transaction Fields
  44940. var transactionFields = [
  44941. { name: "nonce", maxLength: 32, numeric: true },
  44942. { name: "gasPrice", maxLength: 32, numeric: true },
  44943. { name: "gasLimit", maxLength: 32, numeric: true },
  44944. { name: "to", length: 20 },
  44945. { name: "value", maxLength: 32, numeric: true },
  44946. { name: "data" },
  44947. ];
  44948. var allowedTransactionKeys = {
  44949. chainId: true, data: true, gasLimit: true, gasPrice: true, nonce: true, to: true, type: true, value: true
  44950. };
  44951. function computeAddress(key) {
  44952. var publicKey = (0, signing_key_1.computePublicKey)(key);
  44953. return (0, address_1.getAddress)((0, bytes_1.hexDataSlice)((0, keccak256_1.keccak256)((0, bytes_1.hexDataSlice)(publicKey, 1)), 12));
  44954. }
  44955. exports.computeAddress = computeAddress;
  44956. function recoverAddress(digest, signature) {
  44957. return computeAddress((0, signing_key_1.recoverPublicKey)((0, bytes_1.arrayify)(digest), signature));
  44958. }
  44959. exports.recoverAddress = recoverAddress;
  44960. function formatNumber(value, name) {
  44961. var result = (0, bytes_1.stripZeros)(bignumber_1.BigNumber.from(value).toHexString());
  44962. if (result.length > 32) {
  44963. logger.throwArgumentError("invalid length for " + name, ("transaction:" + name), value);
  44964. }
  44965. return result;
  44966. }
  44967. function accessSetify(addr, storageKeys) {
  44968. return {
  44969. address: (0, address_1.getAddress)(addr),
  44970. storageKeys: (storageKeys || []).map(function (storageKey, index) {
  44971. if ((0, bytes_1.hexDataLength)(storageKey) !== 32) {
  44972. logger.throwArgumentError("invalid access list storageKey", "accessList[" + addr + ":" + index + "]", storageKey);
  44973. }
  44974. return storageKey.toLowerCase();
  44975. })
  44976. };
  44977. }
  44978. function accessListify(value) {
  44979. if (Array.isArray(value)) {
  44980. return value.map(function (set, index) {
  44981. if (Array.isArray(set)) {
  44982. if (set.length > 2) {
  44983. logger.throwArgumentError("access list expected to be [ address, storageKeys[] ]", "value[" + index + "]", set);
  44984. }
  44985. return accessSetify(set[0], set[1]);
  44986. }
  44987. return accessSetify(set.address, set.storageKeys);
  44988. });
  44989. }
  44990. var result = Object.keys(value).map(function (addr) {
  44991. var storageKeys = value[addr].reduce(function (accum, storageKey) {
  44992. accum[storageKey] = true;
  44993. return accum;
  44994. }, {});
  44995. return accessSetify(addr, Object.keys(storageKeys).sort());
  44996. });
  44997. result.sort(function (a, b) { return (a.address.localeCompare(b.address)); });
  44998. return result;
  44999. }
  45000. exports.accessListify = accessListify;
  45001. function formatAccessList(value) {
  45002. return accessListify(value).map(function (set) { return [set.address, set.storageKeys]; });
  45003. }
  45004. function _serializeEip1559(transaction, signature) {
  45005. // If there is an explicit gasPrice, make sure it matches the
  45006. // EIP-1559 fees; otherwise they may not understand what they
  45007. // think they are setting in terms of fee.
  45008. if (transaction.gasPrice != null) {
  45009. var gasPrice = bignumber_1.BigNumber.from(transaction.gasPrice);
  45010. var maxFeePerGas = bignumber_1.BigNumber.from(transaction.maxFeePerGas || 0);
  45011. if (!gasPrice.eq(maxFeePerGas)) {
  45012. logger.throwArgumentError("mismatch EIP-1559 gasPrice != maxFeePerGas", "tx", {
  45013. gasPrice: gasPrice,
  45014. maxFeePerGas: maxFeePerGas
  45015. });
  45016. }
  45017. }
  45018. var fields = [
  45019. formatNumber(transaction.chainId || 0, "chainId"),
  45020. formatNumber(transaction.nonce || 0, "nonce"),
  45021. formatNumber(transaction.maxPriorityFeePerGas || 0, "maxPriorityFeePerGas"),
  45022. formatNumber(transaction.maxFeePerGas || 0, "maxFeePerGas"),
  45023. formatNumber(transaction.gasLimit || 0, "gasLimit"),
  45024. ((transaction.to != null) ? (0, address_1.getAddress)(transaction.to) : "0x"),
  45025. formatNumber(transaction.value || 0, "value"),
  45026. (transaction.data || "0x"),
  45027. (formatAccessList(transaction.accessList || []))
  45028. ];
  45029. if (signature) {
  45030. var sig = (0, bytes_1.splitSignature)(signature);
  45031. fields.push(formatNumber(sig.recoveryParam, "recoveryParam"));
  45032. fields.push((0, bytes_1.stripZeros)(sig.r));
  45033. fields.push((0, bytes_1.stripZeros)(sig.s));
  45034. }
  45035. return (0, bytes_1.hexConcat)(["0x02", RLP.encode(fields)]);
  45036. }
  45037. function _serializeEip2930(transaction, signature) {
  45038. var fields = [
  45039. formatNumber(transaction.chainId || 0, "chainId"),
  45040. formatNumber(transaction.nonce || 0, "nonce"),
  45041. formatNumber(transaction.gasPrice || 0, "gasPrice"),
  45042. formatNumber(transaction.gasLimit || 0, "gasLimit"),
  45043. ((transaction.to != null) ? (0, address_1.getAddress)(transaction.to) : "0x"),
  45044. formatNumber(transaction.value || 0, "value"),
  45045. (transaction.data || "0x"),
  45046. (formatAccessList(transaction.accessList || []))
  45047. ];
  45048. if (signature) {
  45049. var sig = (0, bytes_1.splitSignature)(signature);
  45050. fields.push(formatNumber(sig.recoveryParam, "recoveryParam"));
  45051. fields.push((0, bytes_1.stripZeros)(sig.r));
  45052. fields.push((0, bytes_1.stripZeros)(sig.s));
  45053. }
  45054. return (0, bytes_1.hexConcat)(["0x01", RLP.encode(fields)]);
  45055. }
  45056. // Legacy Transactions and EIP-155
  45057. function _serialize(transaction, signature) {
  45058. (0, properties_1.checkProperties)(transaction, allowedTransactionKeys);
  45059. var raw = [];
  45060. transactionFields.forEach(function (fieldInfo) {
  45061. var value = transaction[fieldInfo.name] || ([]);
  45062. var options = {};
  45063. if (fieldInfo.numeric) {
  45064. options.hexPad = "left";
  45065. }
  45066. value = (0, bytes_1.arrayify)((0, bytes_1.hexlify)(value, options));
  45067. // Fixed-width field
  45068. if (fieldInfo.length && value.length !== fieldInfo.length && value.length > 0) {
  45069. logger.throwArgumentError("invalid length for " + fieldInfo.name, ("transaction:" + fieldInfo.name), value);
  45070. }
  45071. // Variable-width (with a maximum)
  45072. if (fieldInfo.maxLength) {
  45073. value = (0, bytes_1.stripZeros)(value);
  45074. if (value.length > fieldInfo.maxLength) {
  45075. logger.throwArgumentError("invalid length for " + fieldInfo.name, ("transaction:" + fieldInfo.name), value);
  45076. }
  45077. }
  45078. raw.push((0, bytes_1.hexlify)(value));
  45079. });
  45080. var chainId = 0;
  45081. if (transaction.chainId != null) {
  45082. // A chainId was provided; if non-zero we'll use EIP-155
  45083. chainId = transaction.chainId;
  45084. if (typeof (chainId) !== "number") {
  45085. logger.throwArgumentError("invalid transaction.chainId", "transaction", transaction);
  45086. }
  45087. }
  45088. else if (signature && !(0, bytes_1.isBytesLike)(signature) && signature.v > 28) {
  45089. // No chainId provided, but the signature is signing with EIP-155; derive chainId
  45090. chainId = Math.floor((signature.v - 35) / 2);
  45091. }
  45092. // We have an EIP-155 transaction (chainId was specified and non-zero)
  45093. if (chainId !== 0) {
  45094. raw.push((0, bytes_1.hexlify)(chainId)); // @TODO: hexValue?
  45095. raw.push("0x");
  45096. raw.push("0x");
  45097. }
  45098. // Requesting an unsigned transaction
  45099. if (!signature) {
  45100. return RLP.encode(raw);
  45101. }
  45102. // The splitSignature will ensure the transaction has a recoveryParam in the
  45103. // case that the signTransaction function only adds a v.
  45104. var sig = (0, bytes_1.splitSignature)(signature);
  45105. // We pushed a chainId and null r, s on for hashing only; remove those
  45106. var v = 27 + sig.recoveryParam;
  45107. if (chainId !== 0) {
  45108. raw.pop();
  45109. raw.pop();
  45110. raw.pop();
  45111. v += chainId * 2 + 8;
  45112. // If an EIP-155 v (directly or indirectly; maybe _vs) was provided, check it!
  45113. if (sig.v > 28 && sig.v !== v) {
  45114. logger.throwArgumentError("transaction.chainId/signature.v mismatch", "signature", signature);
  45115. }
  45116. }
  45117. else if (sig.v !== v) {
  45118. logger.throwArgumentError("transaction.chainId/signature.v mismatch", "signature", signature);
  45119. }
  45120. raw.push((0, bytes_1.hexlify)(v));
  45121. raw.push((0, bytes_1.stripZeros)((0, bytes_1.arrayify)(sig.r)));
  45122. raw.push((0, bytes_1.stripZeros)((0, bytes_1.arrayify)(sig.s)));
  45123. return RLP.encode(raw);
  45124. }
  45125. function serialize(transaction, signature) {
  45126. // Legacy and EIP-155 Transactions
  45127. if (transaction.type == null || transaction.type === 0) {
  45128. if (transaction.accessList != null) {
  45129. logger.throwArgumentError("untyped transactions do not support accessList; include type: 1", "transaction", transaction);
  45130. }
  45131. return _serialize(transaction, signature);
  45132. }
  45133. // Typed Transactions (EIP-2718)
  45134. switch (transaction.type) {
  45135. case 1:
  45136. return _serializeEip2930(transaction, signature);
  45137. case 2:
  45138. return _serializeEip1559(transaction, signature);
  45139. default:
  45140. break;
  45141. }
  45142. return logger.throwError("unsupported transaction type: " + transaction.type, logger_1.Logger.errors.UNSUPPORTED_OPERATION, {
  45143. operation: "serializeTransaction",
  45144. transactionType: transaction.type
  45145. });
  45146. }
  45147. exports.serialize = serialize;
  45148. function _parseEipSignature(tx, fields, serialize) {
  45149. try {
  45150. var recid = handleNumber(fields[0]).toNumber();
  45151. if (recid !== 0 && recid !== 1) {
  45152. throw new Error("bad recid");
  45153. }
  45154. tx.v = recid;
  45155. }
  45156. catch (error) {
  45157. logger.throwArgumentError("invalid v for transaction type: 1", "v", fields[0]);
  45158. }
  45159. tx.r = (0, bytes_1.hexZeroPad)(fields[1], 32);
  45160. tx.s = (0, bytes_1.hexZeroPad)(fields[2], 32);
  45161. try {
  45162. var digest = (0, keccak256_1.keccak256)(serialize(tx));
  45163. tx.from = recoverAddress(digest, { r: tx.r, s: tx.s, recoveryParam: tx.v });
  45164. }
  45165. catch (error) {
  45166. console.log(error);
  45167. }
  45168. }
  45169. function _parseEip1559(payload) {
  45170. var transaction = RLP.decode(payload.slice(1));
  45171. if (transaction.length !== 9 && transaction.length !== 12) {
  45172. logger.throwArgumentError("invalid component count for transaction type: 2", "payload", (0, bytes_1.hexlify)(payload));
  45173. }
  45174. var maxPriorityFeePerGas = handleNumber(transaction[2]);
  45175. var maxFeePerGas = handleNumber(transaction[3]);
  45176. var tx = {
  45177. type: 2,
  45178. chainId: handleNumber(transaction[0]).toNumber(),
  45179. nonce: handleNumber(transaction[1]).toNumber(),
  45180. maxPriorityFeePerGas: maxPriorityFeePerGas,
  45181. maxFeePerGas: maxFeePerGas,
  45182. gasPrice: null,
  45183. gasLimit: handleNumber(transaction[4]),
  45184. to: handleAddress(transaction[5]),
  45185. value: handleNumber(transaction[6]),
  45186. data: transaction[7],
  45187. accessList: accessListify(transaction[8]),
  45188. };
  45189. // Unsigned EIP-1559 Transaction
  45190. if (transaction.length === 9) {
  45191. return tx;
  45192. }
  45193. tx.hash = (0, keccak256_1.keccak256)(payload);
  45194. _parseEipSignature(tx, transaction.slice(9), _serializeEip1559);
  45195. return tx;
  45196. }
  45197. function _parseEip2930(payload) {
  45198. var transaction = RLP.decode(payload.slice(1));
  45199. if (transaction.length !== 8 && transaction.length !== 11) {
  45200. logger.throwArgumentError("invalid component count for transaction type: 1", "payload", (0, bytes_1.hexlify)(payload));
  45201. }
  45202. var tx = {
  45203. type: 1,
  45204. chainId: handleNumber(transaction[0]).toNumber(),
  45205. nonce: handleNumber(transaction[1]).toNumber(),
  45206. gasPrice: handleNumber(transaction[2]),
  45207. gasLimit: handleNumber(transaction[3]),
  45208. to: handleAddress(transaction[4]),
  45209. value: handleNumber(transaction[5]),
  45210. data: transaction[6],
  45211. accessList: accessListify(transaction[7])
  45212. };
  45213. // Unsigned EIP-2930 Transaction
  45214. if (transaction.length === 8) {
  45215. return tx;
  45216. }
  45217. tx.hash = (0, keccak256_1.keccak256)(payload);
  45218. _parseEipSignature(tx, transaction.slice(8), _serializeEip2930);
  45219. return tx;
  45220. }
  45221. // Legacy Transactions and EIP-155
  45222. function _parse(rawTransaction) {
  45223. var transaction = RLP.decode(rawTransaction);
  45224. if (transaction.length !== 9 && transaction.length !== 6) {
  45225. logger.throwArgumentError("invalid raw transaction", "rawTransaction", rawTransaction);
  45226. }
  45227. var tx = {
  45228. nonce: handleNumber(transaction[0]).toNumber(),
  45229. gasPrice: handleNumber(transaction[1]),
  45230. gasLimit: handleNumber(transaction[2]),
  45231. to: handleAddress(transaction[3]),
  45232. value: handleNumber(transaction[4]),
  45233. data: transaction[5],
  45234. chainId: 0
  45235. };
  45236. // Legacy unsigned transaction
  45237. if (transaction.length === 6) {
  45238. return tx;
  45239. }
  45240. try {
  45241. tx.v = bignumber_1.BigNumber.from(transaction[6]).toNumber();
  45242. }
  45243. catch (error) {
  45244. console.log(error);
  45245. return tx;
  45246. }
  45247. tx.r = (0, bytes_1.hexZeroPad)(transaction[7], 32);
  45248. tx.s = (0, bytes_1.hexZeroPad)(transaction[8], 32);
  45249. if (bignumber_1.BigNumber.from(tx.r).isZero() && bignumber_1.BigNumber.from(tx.s).isZero()) {
  45250. // EIP-155 unsigned transaction
  45251. tx.chainId = tx.v;
  45252. tx.v = 0;
  45253. }
  45254. else {
  45255. // Signed Transaction
  45256. tx.chainId = Math.floor((tx.v - 35) / 2);
  45257. if (tx.chainId < 0) {
  45258. tx.chainId = 0;
  45259. }
  45260. var recoveryParam = tx.v - 27;
  45261. var raw = transaction.slice(0, 6);
  45262. if (tx.chainId !== 0) {
  45263. raw.push((0, bytes_1.hexlify)(tx.chainId));
  45264. raw.push("0x");
  45265. raw.push("0x");
  45266. recoveryParam -= tx.chainId * 2 + 8;
  45267. }
  45268. var digest = (0, keccak256_1.keccak256)(RLP.encode(raw));
  45269. try {
  45270. tx.from = recoverAddress(digest, { r: (0, bytes_1.hexlify)(tx.r), s: (0, bytes_1.hexlify)(tx.s), recoveryParam: recoveryParam });
  45271. }
  45272. catch (error) {
  45273. console.log(error);
  45274. }
  45275. tx.hash = (0, keccak256_1.keccak256)(rawTransaction);
  45276. }
  45277. tx.type = null;
  45278. return tx;
  45279. }
  45280. function parse(rawTransaction) {
  45281. var payload = (0, bytes_1.arrayify)(rawTransaction);
  45282. // Legacy and EIP-155 Transactions
  45283. if (payload[0] > 0x7f) {
  45284. return _parse(payload);
  45285. }
  45286. // Typed Transaction (EIP-2718)
  45287. switch (payload[0]) {
  45288. case 1:
  45289. return _parseEip2930(payload);
  45290. case 2:
  45291. return _parseEip1559(payload);
  45292. default:
  45293. break;
  45294. }
  45295. return logger.throwError("unsupported transaction type: " + payload[0], logger_1.Logger.errors.UNSUPPORTED_OPERATION, {
  45296. operation: "parseTransaction",
  45297. transactionType: payload[0]
  45298. });
  45299. }
  45300. exports.parse = parse;
  45301. },{"./_version":268,"@ethersproject/address":189,"@ethersproject/bignumber":196,"@ethersproject/bytes":199,"@ethersproject/constants":203,"@ethersproject/keccak256":221,"@ethersproject/logger":223,"@ethersproject/properties":229,"@ethersproject/rlp":253,"@ethersproject/signing-key":260}],270:[function(_dereq_,module,exports){
  45302. "use strict";
  45303. Object.defineProperty(exports, "__esModule", { value: true });
  45304. exports.version = void 0;
  45305. exports.version = "units/5.6.0";
  45306. },{}],271:[function(_dereq_,module,exports){
  45307. "use strict";
  45308. Object.defineProperty(exports, "__esModule", { value: true });
  45309. exports.parseEther = exports.formatEther = exports.parseUnits = exports.formatUnits = exports.commify = void 0;
  45310. var bignumber_1 = _dereq_("@ethersproject/bignumber");
  45311. var logger_1 = _dereq_("@ethersproject/logger");
  45312. var _version_1 = _dereq_("./_version");
  45313. var logger = new logger_1.Logger(_version_1.version);
  45314. var names = [
  45315. "wei",
  45316. "kwei",
  45317. "mwei",
  45318. "gwei",
  45319. "szabo",
  45320. "finney",
  45321. "ether",
  45322. ];
  45323. // Some environments have issues with RegEx that contain back-tracking, so we cannot
  45324. // use them.
  45325. function commify(value) {
  45326. var comps = String(value).split(".");
  45327. if (comps.length > 2 || !comps[0].match(/^-?[0-9]*$/) || (comps[1] && !comps[1].match(/^[0-9]*$/)) || value === "." || value === "-.") {
  45328. logger.throwArgumentError("invalid value", "value", value);
  45329. }
  45330. // Make sure we have at least one whole digit (0 if none)
  45331. var whole = comps[0];
  45332. var negative = "";
  45333. if (whole.substring(0, 1) === "-") {
  45334. negative = "-";
  45335. whole = whole.substring(1);
  45336. }
  45337. // Make sure we have at least 1 whole digit with no leading zeros
  45338. while (whole.substring(0, 1) === "0") {
  45339. whole = whole.substring(1);
  45340. }
  45341. if (whole === "") {
  45342. whole = "0";
  45343. }
  45344. var suffix = "";
  45345. if (comps.length === 2) {
  45346. suffix = "." + (comps[1] || "0");
  45347. }
  45348. while (suffix.length > 2 && suffix[suffix.length - 1] === "0") {
  45349. suffix = suffix.substring(0, suffix.length - 1);
  45350. }
  45351. var formatted = [];
  45352. while (whole.length) {
  45353. if (whole.length <= 3) {
  45354. formatted.unshift(whole);
  45355. break;
  45356. }
  45357. else {
  45358. var index = whole.length - 3;
  45359. formatted.unshift(whole.substring(index));
  45360. whole = whole.substring(0, index);
  45361. }
  45362. }
  45363. return negative + formatted.join(",") + suffix;
  45364. }
  45365. exports.commify = commify;
  45366. function formatUnits(value, unitName) {
  45367. if (typeof (unitName) === "string") {
  45368. var index = names.indexOf(unitName);
  45369. if (index !== -1) {
  45370. unitName = 3 * index;
  45371. }
  45372. }
  45373. return (0, bignumber_1.formatFixed)(value, (unitName != null) ? unitName : 18);
  45374. }
  45375. exports.formatUnits = formatUnits;
  45376. function parseUnits(value, unitName) {
  45377. if (typeof (value) !== "string") {
  45378. logger.throwArgumentError("value must be a string", "value", value);
  45379. }
  45380. if (typeof (unitName) === "string") {
  45381. var index = names.indexOf(unitName);
  45382. if (index !== -1) {
  45383. unitName = 3 * index;
  45384. }
  45385. }
  45386. return (0, bignumber_1.parseFixed)(value, (unitName != null) ? unitName : 18);
  45387. }
  45388. exports.parseUnits = parseUnits;
  45389. function formatEther(wei) {
  45390. return formatUnits(wei, 18);
  45391. }
  45392. exports.formatEther = formatEther;
  45393. function parseEther(ether) {
  45394. return parseUnits(ether, 18);
  45395. }
  45396. exports.parseEther = parseEther;
  45397. },{"./_version":270,"@ethersproject/bignumber":196,"@ethersproject/logger":223}],272:[function(_dereq_,module,exports){
  45398. "use strict";
  45399. Object.defineProperty(exports, "__esModule", { value: true });
  45400. exports.version = void 0;
  45401. exports.version = "wallet/5.6.0";
  45402. },{}],273:[function(_dereq_,module,exports){
  45403. "use strict";
  45404. var __extends = (this && this.__extends) || (function () {
  45405. var extendStatics = function (d, b) {
  45406. extendStatics = Object.setPrototypeOf ||
  45407. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  45408. function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
  45409. return extendStatics(d, b);
  45410. };
  45411. return function (d, b) {
  45412. if (typeof b !== "function" && b !== null)
  45413. throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
  45414. extendStatics(d, b);
  45415. function __() { this.constructor = d; }
  45416. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  45417. };
  45418. })();
  45419. var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
  45420. function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
  45421. return new (P || (P = Promise))(function (resolve, reject) {
  45422. function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
  45423. function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
  45424. function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
  45425. step((generator = generator.apply(thisArg, _arguments || [])).next());
  45426. });
  45427. };
  45428. var __generator = (this && this.__generator) || function (thisArg, body) {
  45429. var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
  45430. return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
  45431. function verb(n) { return function (v) { return step([n, v]); }; }
  45432. function step(op) {
  45433. if (f) throw new TypeError("Generator is already executing.");
  45434. while (_) try {
  45435. if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
  45436. if (y = 0, t) op = [op[0] & 2, t.value];
  45437. switch (op[0]) {
  45438. case 0: case 1: t = op; break;
  45439. case 4: _.label++; return { value: op[1], done: false };
  45440. case 5: _.label++; y = op[1]; op = [0]; continue;
  45441. case 7: op = _.ops.pop(); _.trys.pop(); continue;
  45442. default:
  45443. if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
  45444. if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
  45445. if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
  45446. if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
  45447. if (t[2]) _.ops.pop();
  45448. _.trys.pop(); continue;
  45449. }
  45450. op = body.call(thisArg, _);
  45451. } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
  45452. if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
  45453. }
  45454. };
  45455. Object.defineProperty(exports, "__esModule", { value: true });
  45456. exports.verifyTypedData = exports.verifyMessage = exports.Wallet = void 0;
  45457. var address_1 = _dereq_("@ethersproject/address");
  45458. var abstract_provider_1 = _dereq_("@ethersproject/abstract-provider");
  45459. var abstract_signer_1 = _dereq_("@ethersproject/abstract-signer");
  45460. var bytes_1 = _dereq_("@ethersproject/bytes");
  45461. var hash_1 = _dereq_("@ethersproject/hash");
  45462. var hdnode_1 = _dereq_("@ethersproject/hdnode");
  45463. var keccak256_1 = _dereq_("@ethersproject/keccak256");
  45464. var properties_1 = _dereq_("@ethersproject/properties");
  45465. var random_1 = _dereq_("@ethersproject/random");
  45466. var signing_key_1 = _dereq_("@ethersproject/signing-key");
  45467. var json_wallets_1 = _dereq_("@ethersproject/json-wallets");
  45468. var transactions_1 = _dereq_("@ethersproject/transactions");
  45469. var logger_1 = _dereq_("@ethersproject/logger");
  45470. var _version_1 = _dereq_("./_version");
  45471. var logger = new logger_1.Logger(_version_1.version);
  45472. function isAccount(value) {
  45473. return (value != null && (0, bytes_1.isHexString)(value.privateKey, 32) && value.address != null);
  45474. }
  45475. function hasMnemonic(value) {
  45476. var mnemonic = value.mnemonic;
  45477. return (mnemonic && mnemonic.phrase);
  45478. }
  45479. var Wallet = /** @class */ (function (_super) {
  45480. __extends(Wallet, _super);
  45481. function Wallet(privateKey, provider) {
  45482. var _newTarget = this.constructor;
  45483. var _this = this;
  45484. logger.checkNew(_newTarget, Wallet);
  45485. _this = _super.call(this) || this;
  45486. if (isAccount(privateKey)) {
  45487. var signingKey_1 = new signing_key_1.SigningKey(privateKey.privateKey);
  45488. (0, properties_1.defineReadOnly)(_this, "_signingKey", function () { return signingKey_1; });
  45489. (0, properties_1.defineReadOnly)(_this, "address", (0, transactions_1.computeAddress)(_this.publicKey));
  45490. if (_this.address !== (0, address_1.getAddress)(privateKey.address)) {
  45491. logger.throwArgumentError("privateKey/address mismatch", "privateKey", "[REDACTED]");
  45492. }
  45493. if (hasMnemonic(privateKey)) {
  45494. var srcMnemonic_1 = privateKey.mnemonic;
  45495. (0, properties_1.defineReadOnly)(_this, "_mnemonic", function () { return ({
  45496. phrase: srcMnemonic_1.phrase,
  45497. path: srcMnemonic_1.path || hdnode_1.defaultPath,
  45498. locale: srcMnemonic_1.locale || "en"
  45499. }); });
  45500. var mnemonic = _this.mnemonic;
  45501. var node = hdnode_1.HDNode.fromMnemonic(mnemonic.phrase, null, mnemonic.locale).derivePath(mnemonic.path);
  45502. if ((0, transactions_1.computeAddress)(node.privateKey) !== _this.address) {
  45503. logger.throwArgumentError("mnemonic/address mismatch", "privateKey", "[REDACTED]");
  45504. }
  45505. }
  45506. else {
  45507. (0, properties_1.defineReadOnly)(_this, "_mnemonic", function () { return null; });
  45508. }
  45509. }
  45510. else {
  45511. if (signing_key_1.SigningKey.isSigningKey(privateKey)) {
  45512. /* istanbul ignore if */
  45513. if (privateKey.curve !== "secp256k1") {
  45514. logger.throwArgumentError("unsupported curve; must be secp256k1", "privateKey", "[REDACTED]");
  45515. }
  45516. (0, properties_1.defineReadOnly)(_this, "_signingKey", function () { return privateKey; });
  45517. }
  45518. else {
  45519. // A lot of common tools do not prefix private keys with a 0x (see: #1166)
  45520. if (typeof (privateKey) === "string") {
  45521. if (privateKey.match(/^[0-9a-f]*$/i) && privateKey.length === 64) {
  45522. privateKey = "0x" + privateKey;
  45523. }
  45524. }
  45525. var signingKey_2 = new signing_key_1.SigningKey(privateKey);
  45526. (0, properties_1.defineReadOnly)(_this, "_signingKey", function () { return signingKey_2; });
  45527. }
  45528. (0, properties_1.defineReadOnly)(_this, "_mnemonic", function () { return null; });
  45529. (0, properties_1.defineReadOnly)(_this, "address", (0, transactions_1.computeAddress)(_this.publicKey));
  45530. }
  45531. /* istanbul ignore if */
  45532. if (provider && !abstract_provider_1.Provider.isProvider(provider)) {
  45533. logger.throwArgumentError("invalid provider", "provider", provider);
  45534. }
  45535. (0, properties_1.defineReadOnly)(_this, "provider", provider || null);
  45536. return _this;
  45537. }
  45538. Object.defineProperty(Wallet.prototype, "mnemonic", {
  45539. get: function () { return this._mnemonic(); },
  45540. enumerable: false,
  45541. configurable: true
  45542. });
  45543. Object.defineProperty(Wallet.prototype, "privateKey", {
  45544. get: function () { return this._signingKey().privateKey; },
  45545. enumerable: false,
  45546. configurable: true
  45547. });
  45548. Object.defineProperty(Wallet.prototype, "publicKey", {
  45549. get: function () { return this._signingKey().publicKey; },
  45550. enumerable: false,
  45551. configurable: true
  45552. });
  45553. Wallet.prototype.getAddress = function () {
  45554. return Promise.resolve(this.address);
  45555. };
  45556. Wallet.prototype.connect = function (provider) {
  45557. return new Wallet(this, provider);
  45558. };
  45559. Wallet.prototype.signTransaction = function (transaction) {
  45560. var _this = this;
  45561. return (0, properties_1.resolveProperties)(transaction).then(function (tx) {
  45562. if (tx.from != null) {
  45563. if ((0, address_1.getAddress)(tx.from) !== _this.address) {
  45564. logger.throwArgumentError("transaction from address mismatch", "transaction.from", transaction.from);
  45565. }
  45566. delete tx.from;
  45567. }
  45568. var signature = _this._signingKey().signDigest((0, keccak256_1.keccak256)((0, transactions_1.serialize)(tx)));
  45569. return (0, transactions_1.serialize)(tx, signature);
  45570. });
  45571. };
  45572. Wallet.prototype.signMessage = function (message) {
  45573. return __awaiter(this, void 0, void 0, function () {
  45574. return __generator(this, function (_a) {
  45575. return [2 /*return*/, (0, bytes_1.joinSignature)(this._signingKey().signDigest((0, hash_1.hashMessage)(message)))];
  45576. });
  45577. });
  45578. };
  45579. Wallet.prototype._signTypedData = function (domain, types, value) {
  45580. return __awaiter(this, void 0, void 0, function () {
  45581. var populated;
  45582. var _this = this;
  45583. return __generator(this, function (_a) {
  45584. switch (_a.label) {
  45585. case 0: return [4 /*yield*/, hash_1._TypedDataEncoder.resolveNames(domain, types, value, function (name) {
  45586. if (_this.provider == null) {
  45587. logger.throwError("cannot resolve ENS names without a provider", logger_1.Logger.errors.UNSUPPORTED_OPERATION, {
  45588. operation: "resolveName",
  45589. value: name
  45590. });
  45591. }
  45592. return _this.provider.resolveName(name);
  45593. })];
  45594. case 1:
  45595. populated = _a.sent();
  45596. return [2 /*return*/, (0, bytes_1.joinSignature)(this._signingKey().signDigest(hash_1._TypedDataEncoder.hash(populated.domain, types, populated.value)))];
  45597. }
  45598. });
  45599. });
  45600. };
  45601. Wallet.prototype.encrypt = function (password, options, progressCallback) {
  45602. if (typeof (options) === "function" && !progressCallback) {
  45603. progressCallback = options;
  45604. options = {};
  45605. }
  45606. if (progressCallback && typeof (progressCallback) !== "function") {
  45607. throw new Error("invalid callback");
  45608. }
  45609. if (!options) {
  45610. options = {};
  45611. }
  45612. return (0, json_wallets_1.encryptKeystore)(this, password, options, progressCallback);
  45613. };
  45614. /**
  45615. * Static methods to create Wallet instances.
  45616. */
  45617. Wallet.createRandom = function (options) {
  45618. var entropy = (0, random_1.randomBytes)(16);
  45619. if (!options) {
  45620. options = {};
  45621. }
  45622. if (options.extraEntropy) {
  45623. entropy = (0, bytes_1.arrayify)((0, bytes_1.hexDataSlice)((0, keccak256_1.keccak256)((0, bytes_1.concat)([entropy, options.extraEntropy])), 0, 16));
  45624. }
  45625. var mnemonic = (0, hdnode_1.entropyToMnemonic)(entropy, options.locale);
  45626. return Wallet.fromMnemonic(mnemonic, options.path, options.locale);
  45627. };
  45628. Wallet.fromEncryptedJson = function (json, password, progressCallback) {
  45629. return (0, json_wallets_1.decryptJsonWallet)(json, password, progressCallback).then(function (account) {
  45630. return new Wallet(account);
  45631. });
  45632. };
  45633. Wallet.fromEncryptedJsonSync = function (json, password) {
  45634. return new Wallet((0, json_wallets_1.decryptJsonWalletSync)(json, password));
  45635. };
  45636. Wallet.fromMnemonic = function (mnemonic, path, wordlist) {
  45637. if (!path) {
  45638. path = hdnode_1.defaultPath;
  45639. }
  45640. return new Wallet(hdnode_1.HDNode.fromMnemonic(mnemonic, null, wordlist).derivePath(path));
  45641. };
  45642. return Wallet;
  45643. }(abstract_signer_1.Signer));
  45644. exports.Wallet = Wallet;
  45645. function verifyMessage(message, signature) {
  45646. return (0, transactions_1.recoverAddress)((0, hash_1.hashMessage)(message), signature);
  45647. }
  45648. exports.verifyMessage = verifyMessage;
  45649. function verifyTypedData(domain, types, value, signature) {
  45650. return (0, transactions_1.recoverAddress)(hash_1._TypedDataEncoder.hash(domain, types, value), signature);
  45651. }
  45652. exports.verifyTypedData = verifyTypedData;
  45653. },{"./_version":272,"@ethersproject/abstract-provider":185,"@ethersproject/abstract-signer":187,"@ethersproject/address":189,"@ethersproject/bytes":199,"@ethersproject/hash":209,"@ethersproject/hdnode":214,"@ethersproject/json-wallets":217,"@ethersproject/keccak256":221,"@ethersproject/logger":223,"@ethersproject/properties":229,"@ethersproject/random":250,"@ethersproject/signing-key":260,"@ethersproject/transactions":269}],274:[function(_dereq_,module,exports){
  45654. "use strict";
  45655. Object.defineProperty(exports, "__esModule", { value: true });
  45656. exports.version = void 0;
  45657. exports.version = "web/5.6.0";
  45658. },{}],275:[function(_dereq_,module,exports){
  45659. "use strict";
  45660. var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
  45661. function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
  45662. return new (P || (P = Promise))(function (resolve, reject) {
  45663. function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
  45664. function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
  45665. function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
  45666. step((generator = generator.apply(thisArg, _arguments || [])).next());
  45667. });
  45668. };
  45669. var __generator = (this && this.__generator) || function (thisArg, body) {
  45670. var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
  45671. return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
  45672. function verb(n) { return function (v) { return step([n, v]); }; }
  45673. function step(op) {
  45674. if (f) throw new TypeError("Generator is already executing.");
  45675. while (_) try {
  45676. if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
  45677. if (y = 0, t) op = [op[0] & 2, t.value];
  45678. switch (op[0]) {
  45679. case 0: case 1: t = op; break;
  45680. case 4: _.label++; return { value: op[1], done: false };
  45681. case 5: _.label++; y = op[1]; op = [0]; continue;
  45682. case 7: op = _.ops.pop(); _.trys.pop(); continue;
  45683. default:
  45684. if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
  45685. if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
  45686. if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
  45687. if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
  45688. if (t[2]) _.ops.pop();
  45689. _.trys.pop(); continue;
  45690. }
  45691. op = body.call(thisArg, _);
  45692. } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
  45693. if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
  45694. }
  45695. };
  45696. Object.defineProperty(exports, "__esModule", { value: true });
  45697. exports.getUrl = void 0;
  45698. var bytes_1 = _dereq_("@ethersproject/bytes");
  45699. function getUrl(href, options) {
  45700. return __awaiter(this, void 0, void 0, function () {
  45701. var request, response, body, headers;
  45702. return __generator(this, function (_a) {
  45703. switch (_a.label) {
  45704. case 0:
  45705. if (options == null) {
  45706. options = {};
  45707. }
  45708. request = {
  45709. method: (options.method || "GET"),
  45710. headers: (options.headers || {}),
  45711. body: (options.body || undefined),
  45712. };
  45713. if (options.skipFetchSetup !== true) {
  45714. request.mode = "cors"; // no-cors, cors, *same-origin
  45715. request.cache = "no-cache"; // *default, no-cache, reload, force-cache, only-if-cached
  45716. request.credentials = "same-origin"; // include, *same-origin, omit
  45717. request.redirect = "follow"; // manual, *follow, error
  45718. request.referrer = "client"; // no-referrer, *client
  45719. }
  45720. ;
  45721. return [4 /*yield*/, fetch(href, request)];
  45722. case 1:
  45723. response = _a.sent();
  45724. return [4 /*yield*/, response.arrayBuffer()];
  45725. case 2:
  45726. body = _a.sent();
  45727. headers = {};
  45728. if (response.headers.forEach) {
  45729. response.headers.forEach(function (value, key) {
  45730. headers[key.toLowerCase()] = value;
  45731. });
  45732. }
  45733. else {
  45734. ((response.headers).keys)().forEach(function (key) {
  45735. headers[key.toLowerCase()] = response.headers.get(key);
  45736. });
  45737. }
  45738. return [2 /*return*/, {
  45739. headers: headers,
  45740. statusCode: response.status,
  45741. statusMessage: response.statusText,
  45742. body: (0, bytes_1.arrayify)(new Uint8Array(body)),
  45743. }];
  45744. }
  45745. });
  45746. });
  45747. }
  45748. exports.getUrl = getUrl;
  45749. },{"@ethersproject/bytes":199}],276:[function(_dereq_,module,exports){
  45750. "use strict";
  45751. var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
  45752. function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
  45753. return new (P || (P = Promise))(function (resolve, reject) {
  45754. function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
  45755. function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
  45756. function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
  45757. step((generator = generator.apply(thisArg, _arguments || [])).next());
  45758. });
  45759. };
  45760. var __generator = (this && this.__generator) || function (thisArg, body) {
  45761. var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
  45762. return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
  45763. function verb(n) { return function (v) { return step([n, v]); }; }
  45764. function step(op) {
  45765. if (f) throw new TypeError("Generator is already executing.");
  45766. while (_) try {
  45767. if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
  45768. if (y = 0, t) op = [op[0] & 2, t.value];
  45769. switch (op[0]) {
  45770. case 0: case 1: t = op; break;
  45771. case 4: _.label++; return { value: op[1], done: false };
  45772. case 5: _.label++; y = op[1]; op = [0]; continue;
  45773. case 7: op = _.ops.pop(); _.trys.pop(); continue;
  45774. default:
  45775. if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
  45776. if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
  45777. if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
  45778. if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
  45779. if (t[2]) _.ops.pop();
  45780. _.trys.pop(); continue;
  45781. }
  45782. op = body.call(thisArg, _);
  45783. } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
  45784. if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
  45785. }
  45786. };
  45787. Object.defineProperty(exports, "__esModule", { value: true });
  45788. exports.poll = exports.fetchJson = exports._fetchData = void 0;
  45789. var base64_1 = _dereq_("@ethersproject/base64");
  45790. var bytes_1 = _dereq_("@ethersproject/bytes");
  45791. var properties_1 = _dereq_("@ethersproject/properties");
  45792. var strings_1 = _dereq_("@ethersproject/strings");
  45793. var logger_1 = _dereq_("@ethersproject/logger");
  45794. var _version_1 = _dereq_("./_version");
  45795. var logger = new logger_1.Logger(_version_1.version);
  45796. var geturl_1 = _dereq_("./geturl");
  45797. function staller(duration) {
  45798. return new Promise(function (resolve) {
  45799. setTimeout(resolve, duration);
  45800. });
  45801. }
  45802. function bodyify(value, type) {
  45803. if (value == null) {
  45804. return null;
  45805. }
  45806. if (typeof (value) === "string") {
  45807. return value;
  45808. }
  45809. if ((0, bytes_1.isBytesLike)(value)) {
  45810. if (type && (type.split("/")[0] === "text" || type.split(";")[0].trim() === "application/json")) {
  45811. try {
  45812. return (0, strings_1.toUtf8String)(value);
  45813. }
  45814. catch (error) { }
  45815. ;
  45816. }
  45817. return (0, bytes_1.hexlify)(value);
  45818. }
  45819. return value;
  45820. }
  45821. // This API is still a work in progress; the future changes will likely be:
  45822. // - ConnectionInfo => FetchDataRequest<T = any>
  45823. // - FetchDataRequest.body? = string | Uint8Array | { contentType: string, data: string | Uint8Array }
  45824. // - If string => text/plain, Uint8Array => application/octet-stream (if content-type unspecified)
  45825. // - FetchDataRequest.processFunc = (body: Uint8Array, response: FetchDataResponse) => T
  45826. // For this reason, it should be considered internal until the API is finalized
  45827. function _fetchData(connection, body, processFunc) {
  45828. // How many times to retry in the event of a throttle
  45829. var attemptLimit = (typeof (connection) === "object" && connection.throttleLimit != null) ? connection.throttleLimit : 12;
  45830. logger.assertArgument((attemptLimit > 0 && (attemptLimit % 1) === 0), "invalid connection throttle limit", "connection.throttleLimit", attemptLimit);
  45831. var throttleCallback = ((typeof (connection) === "object") ? connection.throttleCallback : null);
  45832. var throttleSlotInterval = ((typeof (connection) === "object" && typeof (connection.throttleSlotInterval) === "number") ? connection.throttleSlotInterval : 100);
  45833. logger.assertArgument((throttleSlotInterval > 0 && (throttleSlotInterval % 1) === 0), "invalid connection throttle slot interval", "connection.throttleSlotInterval", throttleSlotInterval);
  45834. var errorPassThrough = ((typeof (connection) === "object") ? !!(connection.errorPassThrough) : false);
  45835. var headers = {};
  45836. var url = null;
  45837. // @TODO: Allow ConnectionInfo to override some of these values
  45838. var options = {
  45839. method: "GET",
  45840. };
  45841. var allow304 = false;
  45842. var timeout = 2 * 60 * 1000;
  45843. if (typeof (connection) === "string") {
  45844. url = connection;
  45845. }
  45846. else if (typeof (connection) === "object") {
  45847. if (connection == null || connection.url == null) {
  45848. logger.throwArgumentError("missing URL", "connection.url", connection);
  45849. }
  45850. url = connection.url;
  45851. if (typeof (connection.timeout) === "number" && connection.timeout > 0) {
  45852. timeout = connection.timeout;
  45853. }
  45854. if (connection.headers) {
  45855. for (var key in connection.headers) {
  45856. headers[key.toLowerCase()] = { key: key, value: String(connection.headers[key]) };
  45857. if (["if-none-match", "if-modified-since"].indexOf(key.toLowerCase()) >= 0) {
  45858. allow304 = true;
  45859. }
  45860. }
  45861. }
  45862. options.allowGzip = !!connection.allowGzip;
  45863. if (connection.user != null && connection.password != null) {
  45864. if (url.substring(0, 6) !== "https:" && connection.allowInsecureAuthentication !== true) {
  45865. logger.throwError("basic authentication requires a secure https url", logger_1.Logger.errors.INVALID_ARGUMENT, { argument: "url", url: url, user: connection.user, password: "[REDACTED]" });
  45866. }
  45867. var authorization = connection.user + ":" + connection.password;
  45868. headers["authorization"] = {
  45869. key: "Authorization",
  45870. value: "Basic " + (0, base64_1.encode)((0, strings_1.toUtf8Bytes)(authorization))
  45871. };
  45872. }
  45873. if (connection.skipFetchSetup != null) {
  45874. options.skipFetchSetup = !!connection.skipFetchSetup;
  45875. }
  45876. }
  45877. var reData = new RegExp("^data:([a-z0-9-]+/[a-z0-9-]+);base64,(.*)$", "i");
  45878. var dataMatch = ((url) ? url.match(reData) : null);
  45879. if (dataMatch) {
  45880. try {
  45881. var response = {
  45882. statusCode: 200,
  45883. statusMessage: "OK",
  45884. headers: { "content-type": dataMatch[1] },
  45885. body: (0, base64_1.decode)(dataMatch[2])
  45886. };
  45887. var result = response.body;
  45888. if (processFunc) {
  45889. result = processFunc(response.body, response);
  45890. }
  45891. return Promise.resolve(result);
  45892. }
  45893. catch (error) {
  45894. logger.throwError("processing response error", logger_1.Logger.errors.SERVER_ERROR, {
  45895. body: bodyify(dataMatch[1], dataMatch[2]),
  45896. error: error,
  45897. requestBody: null,
  45898. requestMethod: "GET",
  45899. url: url
  45900. });
  45901. }
  45902. }
  45903. if (body) {
  45904. options.method = "POST";
  45905. options.body = body;
  45906. if (headers["content-type"] == null) {
  45907. headers["content-type"] = { key: "Content-Type", value: "application/octet-stream" };
  45908. }
  45909. if (headers["content-length"] == null) {
  45910. headers["content-length"] = { key: "Content-Length", value: String(body.length) };
  45911. }
  45912. }
  45913. var flatHeaders = {};
  45914. Object.keys(headers).forEach(function (key) {
  45915. var header = headers[key];
  45916. flatHeaders[header.key] = header.value;
  45917. });
  45918. options.headers = flatHeaders;
  45919. var runningTimeout = (function () {
  45920. var timer = null;
  45921. var promise = new Promise(function (resolve, reject) {
  45922. if (timeout) {
  45923. timer = setTimeout(function () {
  45924. if (timer == null) {
  45925. return;
  45926. }
  45927. timer = null;
  45928. reject(logger.makeError("timeout", logger_1.Logger.errors.TIMEOUT, {
  45929. requestBody: bodyify(options.body, flatHeaders["content-type"]),
  45930. requestMethod: options.method,
  45931. timeout: timeout,
  45932. url: url
  45933. }));
  45934. }, timeout);
  45935. }
  45936. });
  45937. var cancel = function () {
  45938. if (timer == null) {
  45939. return;
  45940. }
  45941. clearTimeout(timer);
  45942. timer = null;
  45943. };
  45944. return { promise: promise, cancel: cancel };
  45945. })();
  45946. var runningFetch = (function () {
  45947. return __awaiter(this, void 0, void 0, function () {
  45948. var attempt, response, location_1, tryAgain, stall, retryAfter, error_1, body_1, result, error_2, tryAgain, timeout_1;
  45949. return __generator(this, function (_a) {
  45950. switch (_a.label) {
  45951. case 0:
  45952. attempt = 0;
  45953. _a.label = 1;
  45954. case 1:
  45955. if (!(attempt < attemptLimit)) return [3 /*break*/, 20];
  45956. response = null;
  45957. _a.label = 2;
  45958. case 2:
  45959. _a.trys.push([2, 9, , 10]);
  45960. return [4 /*yield*/, (0, geturl_1.getUrl)(url, options)];
  45961. case 3:
  45962. response = _a.sent();
  45963. if (!(attempt < attemptLimit)) return [3 /*break*/, 8];
  45964. if (!(response.statusCode === 301 || response.statusCode === 302)) return [3 /*break*/, 4];
  45965. location_1 = response.headers.location || "";
  45966. if (options.method === "GET" && location_1.match(/^https:/)) {
  45967. url = response.headers.location;
  45968. return [3 /*break*/, 19];
  45969. }
  45970. return [3 /*break*/, 8];
  45971. case 4:
  45972. if (!(response.statusCode === 429)) return [3 /*break*/, 8];
  45973. tryAgain = true;
  45974. if (!throttleCallback) return [3 /*break*/, 6];
  45975. return [4 /*yield*/, throttleCallback(attempt, url)];
  45976. case 5:
  45977. tryAgain = _a.sent();
  45978. _a.label = 6;
  45979. case 6:
  45980. if (!tryAgain) return [3 /*break*/, 8];
  45981. stall = 0;
  45982. retryAfter = response.headers["retry-after"];
  45983. if (typeof (retryAfter) === "string" && retryAfter.match(/^[1-9][0-9]*$/)) {
  45984. stall = parseInt(retryAfter) * 1000;
  45985. }
  45986. else {
  45987. stall = throttleSlotInterval * parseInt(String(Math.random() * Math.pow(2, attempt)));
  45988. }
  45989. //console.log("Stalling 429");
  45990. return [4 /*yield*/, staller(stall)];
  45991. case 7:
  45992. //console.log("Stalling 429");
  45993. _a.sent();
  45994. return [3 /*break*/, 19];
  45995. case 8: return [3 /*break*/, 10];
  45996. case 9:
  45997. error_1 = _a.sent();
  45998. response = error_1.response;
  45999. if (response == null) {
  46000. runningTimeout.cancel();
  46001. logger.throwError("missing response", logger_1.Logger.errors.SERVER_ERROR, {
  46002. requestBody: bodyify(options.body, flatHeaders["content-type"]),
  46003. requestMethod: options.method,
  46004. serverError: error_1,
  46005. url: url
  46006. });
  46007. }
  46008. return [3 /*break*/, 10];
  46009. case 10:
  46010. body_1 = response.body;
  46011. if (allow304 && response.statusCode === 304) {
  46012. body_1 = null;
  46013. }
  46014. else if (!errorPassThrough && (response.statusCode < 200 || response.statusCode >= 300)) {
  46015. runningTimeout.cancel();
  46016. logger.throwError("bad response", logger_1.Logger.errors.SERVER_ERROR, {
  46017. status: response.statusCode,
  46018. headers: response.headers,
  46019. body: bodyify(body_1, ((response.headers) ? response.headers["content-type"] : null)),
  46020. requestBody: bodyify(options.body, flatHeaders["content-type"]),
  46021. requestMethod: options.method,
  46022. url: url
  46023. });
  46024. }
  46025. if (!processFunc) return [3 /*break*/, 18];
  46026. _a.label = 11;
  46027. case 11:
  46028. _a.trys.push([11, 13, , 18]);
  46029. return [4 /*yield*/, processFunc(body_1, response)];
  46030. case 12:
  46031. result = _a.sent();
  46032. runningTimeout.cancel();
  46033. return [2 /*return*/, result];
  46034. case 13:
  46035. error_2 = _a.sent();
  46036. if (!(error_2.throttleRetry && attempt < attemptLimit)) return [3 /*break*/, 17];
  46037. tryAgain = true;
  46038. if (!throttleCallback) return [3 /*break*/, 15];
  46039. return [4 /*yield*/, throttleCallback(attempt, url)];
  46040. case 14:
  46041. tryAgain = _a.sent();
  46042. _a.label = 15;
  46043. case 15:
  46044. if (!tryAgain) return [3 /*break*/, 17];
  46045. timeout_1 = throttleSlotInterval * parseInt(String(Math.random() * Math.pow(2, attempt)));
  46046. //console.log("Stalling callback");
  46047. return [4 /*yield*/, staller(timeout_1)];
  46048. case 16:
  46049. //console.log("Stalling callback");
  46050. _a.sent();
  46051. return [3 /*break*/, 19];
  46052. case 17:
  46053. runningTimeout.cancel();
  46054. logger.throwError("processing response error", logger_1.Logger.errors.SERVER_ERROR, {
  46055. body: bodyify(body_1, ((response.headers) ? response.headers["content-type"] : null)),
  46056. error: error_2,
  46057. requestBody: bodyify(options.body, flatHeaders["content-type"]),
  46058. requestMethod: options.method,
  46059. url: url
  46060. });
  46061. return [3 /*break*/, 18];
  46062. case 18:
  46063. runningTimeout.cancel();
  46064. // If we had a processFunc, it either returned a T or threw above.
  46065. // The "body" is now a Uint8Array.
  46066. return [2 /*return*/, body_1];
  46067. case 19:
  46068. attempt++;
  46069. return [3 /*break*/, 1];
  46070. case 20: return [2 /*return*/, logger.throwError("failed response", logger_1.Logger.errors.SERVER_ERROR, {
  46071. requestBody: bodyify(options.body, flatHeaders["content-type"]),
  46072. requestMethod: options.method,
  46073. url: url
  46074. })];
  46075. }
  46076. });
  46077. });
  46078. })();
  46079. return Promise.race([runningTimeout.promise, runningFetch]);
  46080. }
  46081. exports._fetchData = _fetchData;
  46082. function fetchJson(connection, json, processFunc) {
  46083. var processJsonFunc = function (value, response) {
  46084. var result = null;
  46085. if (value != null) {
  46086. try {
  46087. result = JSON.parse((0, strings_1.toUtf8String)(value));
  46088. }
  46089. catch (error) {
  46090. logger.throwError("invalid JSON", logger_1.Logger.errors.SERVER_ERROR, {
  46091. body: value,
  46092. error: error
  46093. });
  46094. }
  46095. }
  46096. if (processFunc) {
  46097. result = processFunc(result, response);
  46098. }
  46099. return result;
  46100. };
  46101. // If we have json to send, we must
  46102. // - add content-type of application/json (unless already overridden)
  46103. // - convert the json to bytes
  46104. var body = null;
  46105. if (json != null) {
  46106. body = (0, strings_1.toUtf8Bytes)(json);
  46107. // Create a connection with the content-type set for JSON
  46108. var updated = (typeof (connection) === "string") ? ({ url: connection }) : (0, properties_1.shallowCopy)(connection);
  46109. if (updated.headers) {
  46110. var hasContentType = (Object.keys(updated.headers).filter(function (k) { return (k.toLowerCase() === "content-type"); }).length) !== 0;
  46111. if (!hasContentType) {
  46112. updated.headers = (0, properties_1.shallowCopy)(updated.headers);
  46113. updated.headers["content-type"] = "application/json";
  46114. }
  46115. }
  46116. else {
  46117. updated.headers = { "content-type": "application/json" };
  46118. }
  46119. connection = updated;
  46120. }
  46121. return _fetchData(connection, body, processJsonFunc);
  46122. }
  46123. exports.fetchJson = fetchJson;
  46124. function poll(func, options) {
  46125. if (!options) {
  46126. options = {};
  46127. }
  46128. options = (0, properties_1.shallowCopy)(options);
  46129. if (options.floor == null) {
  46130. options.floor = 0;
  46131. }
  46132. if (options.ceiling == null) {
  46133. options.ceiling = 10000;
  46134. }
  46135. if (options.interval == null) {
  46136. options.interval = 250;
  46137. }
  46138. return new Promise(function (resolve, reject) {
  46139. var timer = null;
  46140. var done = false;
  46141. // Returns true if cancel was successful. Unsuccessful cancel means we're already done.
  46142. var cancel = function () {
  46143. if (done) {
  46144. return false;
  46145. }
  46146. done = true;
  46147. if (timer) {
  46148. clearTimeout(timer);
  46149. }
  46150. return true;
  46151. };
  46152. if (options.timeout) {
  46153. timer = setTimeout(function () {
  46154. if (cancel()) {
  46155. reject(new Error("timeout"));
  46156. }
  46157. }, options.timeout);
  46158. }
  46159. var retryLimit = options.retryLimit;
  46160. var attempt = 0;
  46161. function check() {
  46162. return func().then(function (result) {
  46163. // If we have a result, or are allowed null then we're done
  46164. if (result !== undefined) {
  46165. if (cancel()) {
  46166. resolve(result);
  46167. }
  46168. }
  46169. else if (options.oncePoll) {
  46170. options.oncePoll.once("poll", check);
  46171. }
  46172. else if (options.onceBlock) {
  46173. options.onceBlock.once("block", check);
  46174. // Otherwise, exponential back-off (up to 10s) our next request
  46175. }
  46176. else if (!done) {
  46177. attempt++;
  46178. if (attempt > retryLimit) {
  46179. if (cancel()) {
  46180. reject(new Error("retry limit reached"));
  46181. }
  46182. return;
  46183. }
  46184. var timeout = options.interval * parseInt(String(Math.random() * Math.pow(2, attempt)));
  46185. if (timeout < options.floor) {
  46186. timeout = options.floor;
  46187. }
  46188. if (timeout > options.ceiling) {
  46189. timeout = options.ceiling;
  46190. }
  46191. setTimeout(check, timeout);
  46192. }
  46193. return null;
  46194. }, function (error) {
  46195. if (cancel()) {
  46196. reject(error);
  46197. }
  46198. });
  46199. }
  46200. check();
  46201. });
  46202. }
  46203. exports.poll = poll;
  46204. },{"./_version":274,"./geturl":275,"@ethersproject/base64":191,"@ethersproject/bytes":199,"@ethersproject/logger":223,"@ethersproject/properties":229,"@ethersproject/strings":266}],277:[function(_dereq_,module,exports){
  46205. "use strict";
  46206. Object.defineProperty(exports, "__esModule", { value: true });
  46207. exports.version = void 0;
  46208. exports.version = "wordlists/5.6.0";
  46209. },{}],278:[function(_dereq_,module,exports){
  46210. "use strict";
  46211. Object.defineProperty(exports, "__esModule", { value: true });
  46212. exports.wordlists = exports.Wordlist = exports.logger = void 0;
  46213. // Wordlists
  46214. // See: https://github.com/bitcoin/bips/blob/master/bip-0039/bip-0039-wordlists.md
  46215. var wordlist_1 = _dereq_("./wordlist");
  46216. Object.defineProperty(exports, "logger", { enumerable: true, get: function () { return wordlist_1.logger; } });
  46217. Object.defineProperty(exports, "Wordlist", { enumerable: true, get: function () { return wordlist_1.Wordlist; } });
  46218. var wordlists_1 = _dereq_("./wordlists");
  46219. Object.defineProperty(exports, "wordlists", { enumerable: true, get: function () { return wordlists_1.wordlists; } });
  46220. },{"./wordlist":287,"./wordlists":288}],279:[function(_dereq_,module,exports){
  46221. "use strict";
  46222. var __extends = (this && this.__extends) || (function () {
  46223. var extendStatics = function (d, b) {
  46224. extendStatics = Object.setPrototypeOf ||
  46225. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  46226. function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
  46227. return extendStatics(d, b);
  46228. };
  46229. return function (d, b) {
  46230. if (typeof b !== "function" && b !== null)
  46231. throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
  46232. extendStatics(d, b);
  46233. function __() { this.constructor = d; }
  46234. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  46235. };
  46236. })();
  46237. Object.defineProperty(exports, "__esModule", { value: true });
  46238. exports.langCz = void 0;
  46239. var wordlist_1 = _dereq_("./wordlist");
  46240. var words = "AbdikaceAbecedaAdresaAgreseAkceAktovkaAlejAlkoholAmputaceAnanasAndulkaAnekdotaAnketaAntikaAnulovatArchaAroganceAsfaltAsistentAspiraceAstmaAstronomAtlasAtletikaAtolAutobusAzylBabkaBachorBacilBaculkaBadatelBagetaBagrBahnoBakterieBaladaBaletkaBalkonBalonekBalvanBalzaBambusBankomatBarbarBaretBarmanBarokoBarvaBaterkaBatohBavlnaBazalkaBazilikaBazukaBednaBeranBesedaBestieBetonBezinkaBezmocBeztakBicyklBidloBiftekBikinyBilanceBiografBiologBitvaBizonBlahobytBlatouchBlechaBleduleBleskBlikatBliznaBlokovatBlouditBludBobekBobrBodlinaBodnoutBohatostBojkotBojovatBokorysBolestBorecBoroviceBotaBoubelBouchatBoudaBouleBouratBoxerBradavkaBramboraBrankaBratrBreptaBriketaBrkoBrlohBronzBroskevBrunetkaBrusinkaBrzdaBrzyBublinaBubnovatBuchtaBuditelBudkaBudovaBufetBujarostBukviceBuldokBulvaBundaBunkrBurzaButikBuvolBuzolaBydletBylinaBytovkaBzukotCapartCarevnaCedrCeduleCejchCejnCelaCelerCelkemCelniceCeninaCennostCenovkaCentrumCenzorCestopisCetkaChalupaChapadloCharitaChataChechtatChemieChichotChirurgChladChlebaChlubitChmelChmuraChobotChocholChodbaCholeraChomoutChopitChorobaChovChrapotChrlitChrtChrupChtivostChudinaChutnatChvatChvilkaChvostChybaChystatChytitCibuleCigaretaCihelnaCihlaCinkotCirkusCisternaCitaceCitrusCizinecCizostClonaCokolivCouvatCtitelCtnostCudnostCuketaCukrCupotCvaknoutCvalCvikCvrkotCyklistaDalekoDarebaDatelDatumDceraDebataDechovkaDecibelDeficitDeflaceDeklDekretDemokratDepreseDerbyDeskaDetektivDikobrazDiktovatDiodaDiplomDiskDisplejDivadloDivochDlahaDlouhoDluhopisDnesDobroDobytekDocentDochutitDodnesDohledDohodaDohraDojemDojniceDokladDokolaDoktorDokumentDolarDolevaDolinaDomaDominantDomluvitDomovDonutitDopadDopisDoplnitDoposudDoprovodDopustitDorazitDorostDortDosahDoslovDostatekDosudDosytaDotazDotekDotknoutDoufatDoutnatDovozceDozaduDoznatDozorceDrahotaDrakDramatikDravecDrazeDrdolDrobnostDrogerieDrozdDrsnostDrtitDrzostDubenDuchovnoDudekDuhaDuhovkaDusitDusnoDutostDvojiceDvorecDynamitEkologEkonomieElektronElipsaEmailEmiseEmoceEmpatieEpizodaEpochaEpopejEposEsejEsenceEskortaEskymoEtiketaEuforieEvoluceExekuceExkurzeExpediceExplozeExportExtraktFackaFajfkaFakultaFanatikFantazieFarmacieFavoritFazoleFederaceFejetonFenkaFialkaFigurantFilozofFiltrFinanceFintaFixaceFjordFlanelFlirtFlotilaFondFosforFotbalFotkaFotonFrakceFreskaFrontaFukarFunkceFyzikaGalejeGarantGenetikaGeologGilotinaGlazuraGlejtGolemGolfistaGotikaGrafGramofonGranuleGrepGrilGrogGroteskaGumaHadiceHadrHalaHalenkaHanbaHanopisHarfaHarpunaHavranHebkostHejkalHejnoHejtmanHektarHelmaHematomHerecHernaHesloHezkyHistorikHladovkaHlasivkyHlavaHledatHlenHlodavecHlohHloupostHltatHlubinaHluchotaHmatHmotaHmyzHnisHnojivoHnoutHoblinaHobojHochHodinyHodlatHodnotaHodovatHojnostHokejHolinkaHolkaHolubHomoleHonitbaHonoraceHoralHordaHorizontHorkoHorlivecHormonHorninaHoroskopHorstvoHospodaHostinaHotovostHoubaHoufHoupatHouskaHovorHradbaHraniceHravostHrazdaHrbolekHrdinaHrdloHrdostHrnekHrobkaHromadaHrotHroudaHrozenHrstkaHrubostHryzatHubenostHubnoutHudbaHukotHumrHusitaHustotaHvozdHybnostHydrantHygienaHymnaHysterikIdylkaIhnedIkonaIluzeImunitaInfekceInflaceInkasoInovaceInspekceInternetInvalidaInvestorInzerceIronieJablkoJachtaJahodaJakmileJakostJalovecJantarJarmarkJaroJasanJasnoJatkaJavorJazykJedinecJedleJednatelJehlanJekotJelenJelitoJemnostJenomJepiceJeseterJevitJezdecJezeroJinakJindyJinochJiskraJistotaJitrniceJizvaJmenovatJogurtJurtaKabaretKabelKabinetKachnaKadetKadidloKahanKajakKajutaKakaoKaktusKalamitaKalhotyKalibrKalnostKameraKamkolivKamnaKanibalKanoeKantorKapalinaKapelaKapitolaKapkaKapleKapotaKaprKapustaKapybaraKaramelKarotkaKartonKasaKatalogKatedraKauceKauzaKavalecKazajkaKazetaKazivostKdekolivKdesiKedlubenKempKeramikaKinoKlacekKladivoKlamKlapotKlasikaKlaunKlecKlenbaKlepatKlesnoutKlidKlimaKlisnaKloboukKlokanKlopaKloubKlubovnaKlusatKluzkostKmenKmitatKmotrKnihaKnotKoaliceKoberecKobkaKoblihaKobylaKocourKohoutKojenecKokosKoktejlKolapsKoledaKolizeKoloKomandoKometaKomikKomnataKomoraKompasKomunitaKonatKonceptKondiceKonecKonfeseKongresKoninaKonkursKontaktKonzervaKopanecKopieKopnoutKoprovkaKorbelKorektorKormidloKoroptevKorpusKorunaKorytoKorzetKosatecKostkaKotelKotletaKotoulKoukatKoupelnaKousekKouzloKovbojKozaKozorohKrabiceKrachKrajinaKralovatKrasopisKravataKreditKrejcarKresbaKrevetaKriketKritikKrizeKrkavecKrmelecKrmivoKrocanKrokKronikaKropitKroupaKrovkaKrtekKruhadloKrupiceKrutostKrvinkaKrychleKryptaKrystalKrytKudlankaKufrKujnostKuklaKulajdaKulichKulkaKulometKulturaKunaKupodivuKurtKurzorKutilKvalitaKvasinkaKvestorKynologKyselinaKytaraKyticeKytkaKytovecKyvadloLabradorLachtanLadnostLaikLakomecLamelaLampaLanovkaLasiceLasoLasturaLatinkaLavinaLebkaLeckdyLedenLedniceLedovkaLedvinaLegendaLegieLegraceLehceLehkostLehnoutLektvarLenochodLentilkaLepenkaLepidloLetadloLetecLetmoLetokruhLevhartLevitaceLevobokLibraLichotkaLidojedLidskostLihovinaLijavecLilekLimetkaLinieLinkaLinoleumListopadLitinaLitovatLobistaLodivodLogikaLogopedLokalitaLoketLomcovatLopataLopuchLordLososLotrLoudalLouhLoukaLouskatLovecLstivostLucernaLuciferLumpLuskLustraceLviceLyraLyrikaLysinaMadamMadloMagistrMahagonMajetekMajitelMajoritaMakakMakoviceMakrelaMalbaMalinaMalovatMalviceMaminkaMandleMankoMarnostMasakrMaskotMasopustMaticeMatrikaMaturitaMazanecMazivoMazlitMazurkaMdlobaMechanikMeditaceMedovinaMelasaMelounMentolkaMetlaMetodaMetrMezeraMigraceMihnoutMihuleMikinaMikrofonMilenecMilimetrMilostMimikaMincovnaMinibarMinometMinulostMiskaMistrMixovatMladostMlhaMlhovinaMlokMlsatMluvitMnichMnohemMobilMocnostModelkaModlitbaMohylaMokroMolekulaMomentkaMonarchaMonoklMonstrumMontovatMonzunMosazMoskytMostMotivaceMotorkaMotykaMouchaMoudrostMozaikaMozekMozolMramorMravenecMrkevMrtvolaMrzetMrzutostMstitelMudrcMuflonMulatMumieMuniceMusetMutaceMuzeumMuzikantMyslivecMzdaNabouratNachytatNadaceNadbytekNadhozNadobroNadpisNahlasNahnatNahodileNahraditNaivitaNajednouNajistoNajmoutNaklonitNakonecNakrmitNalevoNamazatNamluvitNanometrNaokoNaopakNaostroNapadatNapevnoNaplnitNapnoutNaposledNaprostoNaroditNarubyNarychloNasaditNasekatNaslepoNastatNatolikNavenekNavrchNavzdoryNazvatNebeNechatNeckyNedalekoNedbatNeduhNegaceNehetNehodaNejenNejprveNeklidNelibostNemilostNemocNeochotaNeonkaNepokojNerostNervNesmyslNesouladNetvorNeuronNevinaNezvykleNicotaNijakNikamNikdyNiklNikterakNitroNoclehNohaviceNominaceNoraNorekNositelNosnostNouzeNovinyNovotaNozdraNudaNudleNugetNutitNutnostNutrieNymfaObalObarvitObavaObdivObecObehnatObejmoutObezitaObhajobaObilniceObjasnitObjektObklopitOblastOblekOblibaOblohaObludaObnosObohatitObojekOboutObrazecObrnaObrubaObrysObsahObsluhaObstaratObuvObvazObvinitObvodObvykleObyvatelObzorOcasOcelOcenitOchladitOchotaOchranaOcitnoutOdbojOdbytOdchodOdcizitOdebratOdeslatOdevzdatOdezvaOdhadceOdhoditOdjetOdjinudOdkazOdkoupitOdlivOdlukaOdmlkaOdolnostOdpadOdpisOdploutOdporOdpustitOdpykatOdrazkaOdsouditOdstupOdsunOdtokOdtudOdvahaOdvetaOdvolatOdvracetOdznakOfinaOfsajdOhlasOhniskoOhradaOhrozitOhryzekOkapOkeniceOklikaOknoOkouzlitOkovyOkrasaOkresOkrsekOkruhOkupantOkurkaOkusitOlejninaOlizovatOmakOmeletaOmezitOmladinaOmlouvatOmluvaOmylOnehdyOpakovatOpasekOperaceOpiceOpilostOpisovatOporaOpoziceOpravduOprotiOrbitalOrchestrOrgieOrliceOrlojOrtelOsadaOschnoutOsikaOsivoOslavaOslepitOslnitOslovitOsnovaOsobaOsolitOspalecOstenOstrahaOstudaOstychOsvojitOteplitOtiskOtopOtrhatOtrlostOtrokOtrubyOtvorOvanoutOvarOvesOvlivnitOvoceOxidOzdobaPachatelPacientPadouchPahorekPaktPalandaPalecPalivoPalubaPamfletPamlsekPanenkaPanikaPannaPanovatPanstvoPantoflePaprikaParketaParodiePartaParukaParybaPasekaPasivitaPastelkaPatentPatronaPavoukPaznehtPazourekPeckaPedagogPejsekPekloPelotonPenaltaPendrekPenzePeriskopPeroPestrostPetardaPeticePetrolejPevninaPexesoPianistaPihaPijavicePiklePiknikPilinaPilnostPilulkaPinzetaPipetaPisatelPistolePitevnaPivnicePivovarPlacentaPlakatPlamenPlanetaPlastikaPlatitPlavidloPlazPlechPlemenoPlentaPlesPletivoPlevelPlivatPlnitPlnoPlochaPlodinaPlombaPloutPlukPlynPobavitPobytPochodPocitPoctivecPodatPodcenitPodepsatPodhledPodivitPodkladPodmanitPodnikPodobaPodporaPodrazPodstataPodvodPodzimPoeziePohankaPohnutkaPohovorPohromaPohybPointaPojistkaPojmoutPokazitPoklesPokojPokrokPokutaPokynPolednePolibekPolknoutPolohaPolynomPomaluPominoutPomlkaPomocPomstaPomysletPonechatPonorkaPonurostPopadatPopelPopisekPoplachPoprositPopsatPopudPoradcePorcePorodPoruchaPoryvPosaditPosedPosilaPoskokPoslanecPosouditPospoluPostavaPosudekPosypPotahPotkanPotleskPotomekPotravaPotupaPotvoraPoukazPoutoPouzdroPovahaPovidlaPovlakPovozPovrchPovstatPovykPovzdechPozdravPozemekPoznatekPozorPozvatPracovatPrahoryPraktikaPralesPraotecPraporekPrasePravdaPrincipPrknoProbuditProcentoProdejProfeseProhraProjektProlomitPromilePronikatPropadProrokProsbaProtonProutekProvazPrskavkaPrstenPrudkostPrutPrvekPrvohoryPsanecPsovodPstruhPtactvoPubertaPuchPudlPukavecPuklinaPukrlePultPumpaPuncPupenPusaPusinkaPustinaPutovatPutykaPyramidaPyskPytelRacekRachotRadiaceRadniceRadonRaftRagbyRaketaRakovinaRamenoRampouchRandeRarachRaritaRasovnaRastrRatolestRazanceRazidloReagovatReakceReceptRedaktorReferentReflexRejnokReklamaRekordRekrutRektorReputaceRevizeRevmaRevolverRezervaRiskovatRizikoRobotikaRodokmenRohovkaRokleRokokoRomanetoRopovodRopuchaRorejsRosolRostlinaRotmistrRotopedRotundaRoubenkaRouchoRoupRouraRovinaRovniceRozborRozchodRozdatRozeznatRozhodceRozinkaRozjezdRozkazRozlohaRozmarRozpadRozruchRozsahRoztokRozumRozvodRubrikaRuchadloRukaviceRukopisRybaRybolovRychlostRydloRypadloRytinaRyzostSadistaSahatSakoSamecSamizdatSamotaSanitkaSardinkaSasankaSatelitSazbaSazeniceSborSchovatSebrankaSeceseSedadloSedimentSedloSehnatSejmoutSekeraSektaSekundaSekvojeSemenoSenoServisSesaditSeshoraSeskokSeslatSestraSesuvSesypatSetbaSetinaSetkatSetnoutSetrvatSeverSeznamShodaShrnoutSifonSilniceSirkaSirotekSirupSituaceSkafandrSkaliskoSkanzenSkautSkeptikSkicaSkladbaSkleniceSkloSkluzSkobaSkokanSkoroSkriptaSkrzSkupinaSkvostSkvrnaSlabikaSladidloSlaninaSlastSlavnostSledovatSlepecSlevaSlezinaSlibSlinaSlizniceSlonSloupekSlovoSluchSluhaSlunceSlupkaSlzaSmaragdSmetanaSmilstvoSmlouvaSmogSmradSmrkSmrtkaSmutekSmyslSnadSnahaSnobSobotaSochaSodovkaSokolSopkaSotvaSoubojSoucitSoudceSouhlasSouladSoumrakSoupravaSousedSoutokSouvisetSpalovnaSpasitelSpisSplavSpodekSpojenecSpoluSponzorSpornostSpoustaSprchaSpustitSrandaSrazSrdceSrnaSrnecSrovnatSrpenSrstSrubStaniceStarostaStatikaStavbaStehnoStezkaStodolaStolekStopaStornoStoupatStrachStresStrhnoutStromStrunaStudnaStupniceStvolStykSubjektSubtropySucharSudostSuknoSundatSunoutSurikataSurovinaSvahSvalstvoSvetrSvatbaSvazekSvisleSvitekSvobodaSvodidloSvorkaSvrabSykavkaSykotSynekSynovecSypatSypkostSyrovostSyselSytostTabletkaTabuleTahounTajemnoTajfunTajgaTajitTajnostTaktikaTamhleTamponTancovatTanecTankerTapetaTaveninaTazatelTechnikaTehdyTekutinaTelefonTemnotaTendenceTenistaTenorTeplotaTepnaTeprveTerapieTermoskaTextilTichoTiskopisTitulekTkadlecTkaninaTlapkaTleskatTlukotTlupaTmelToaletaTopinkaTopolTorzoTouhaToulecTradiceTraktorTrampTrasaTraverzaTrefitTrestTrezorTrhavinaTrhlinaTrochuTrojiceTroskaTroubaTrpceTrpitelTrpkostTrubecTruchlitTruhliceTrusTrvatTudyTuhnoutTuhostTundraTuristaTurnajTuzemskoTvarohTvorbaTvrdostTvrzTygrTykevUbohostUbozeUbratUbrousekUbrusUbytovnaUchoUctivostUdivitUhraditUjednatUjistitUjmoutUkazatelUklidnitUklonitUkotvitUkrojitUliceUlitaUlovitUmyvadloUnavitUniformaUniknoutUpadnoutUplatnitUplynoutUpoutatUpravitUranUrazitUsednoutUsilovatUsmrtitUsnadnitUsnoutUsouditUstlatUstrnoutUtahovatUtkatUtlumitUtonoutUtopenecUtrousitUvalitUvolnitUvozovkaUzdravitUzelUzeninaUzlinaUznatVagonValchaValounVanaVandalVanilkaVaranVarhanyVarovatVcelkuVchodVdovaVedroVegetaceVejceVelbloudVeletrhVelitelVelmocVelrybaVenkovVerandaVerzeVeselkaVeskrzeVesniceVespoduVestaVeterinaVeverkaVibraceVichrVideohraVidinaVidleVilaViniceVisetVitalitaVizeVizitkaVjezdVkladVkusVlajkaVlakVlasecVlevoVlhkostVlivVlnovkaVloupatVnucovatVnukVodaVodivostVodoznakVodstvoVojenskyVojnaVojskoVolantVolbaVolitVolnoVoskovkaVozidloVozovnaVpravoVrabecVracetVrahVrataVrbaVrcholekVrhatVrstvaVrtuleVsaditVstoupitVstupVtipVybavitVybratVychovatVydatVydraVyfotitVyhledatVyhnoutVyhoditVyhraditVyhubitVyjasnitVyjetVyjmoutVyklopitVykonatVylekatVymazatVymezitVymizetVymysletVynechatVynikatVynutitVypadatVyplatitVypravitVypustitVyrazitVyrovnatVyrvatVyslovitVysokoVystavitVysunoutVysypatVytasitVytesatVytratitVyvinoutVyvolatVyvrhelVyzdobitVyznatVzaduVzbuditVzchopitVzdorVzduchVzdychatVzestupVzhledemVzkazVzlykatVznikVzorekVzpouraVztahVztekXylofonZabratZabydletZachovatZadarmoZadusitZafoukatZahltitZahoditZahradaZahynoutZajatecZajetZajistitZaklepatZakoupitZalepitZamezitZamotatZamysletZanechatZanikatZaplatitZapojitZapsatZarazitZastavitZasunoutZatajitZatemnitZatknoutZaujmoutZavalitZaveletZavinitZavolatZavrtatZazvonitZbavitZbrusuZbudovatZbytekZdalekaZdarmaZdatnostZdivoZdobitZdrojZdvihZdymadloZeleninaZemanZeminaZeptatZezaduZezdolaZhatitZhltnoutZhlubokaZhotovitZhrubaZimaZimniceZjemnitZklamatZkoumatZkratkaZkumavkaZlatoZlehkaZlobaZlomZlostZlozvykZmapovatZmarZmatekZmijeZmizetZmocnitZmodratZmrzlinaZmutovatZnakZnalostZnamenatZnovuZobrazitZotavitZoubekZoufaleZploditZpomalitZpravaZprostitZprudkaZprvuZradaZranitZrcadloZrnitostZrnoZrovnaZrychlitZrzavostZtichaZtratitZubovinaZubrZvednoutZvenkuZveselaZvonZvratZvukovodZvyk";
  46241. var wordlist = null;
  46242. function loadWords(lang) {
  46243. if (wordlist != null) {
  46244. return;
  46245. }
  46246. wordlist = words.replace(/([A-Z])/g, " $1").toLowerCase().substring(1).split(" ");
  46247. // Verify the computed list matches the official list
  46248. /* istanbul ignore if */
  46249. if (wordlist_1.Wordlist.check(lang) !== "0x25f44555f4af25b51a711136e1c7d6e50ce9f8917d39d6b1f076b2bb4d2fac1a") {
  46250. wordlist = null;
  46251. throw new Error("BIP39 Wordlist for en (English) FAILED");
  46252. }
  46253. }
  46254. var LangCz = /** @class */ (function (_super) {
  46255. __extends(LangCz, _super);
  46256. function LangCz() {
  46257. return _super.call(this, "cz") || this;
  46258. }
  46259. LangCz.prototype.getWord = function (index) {
  46260. loadWords(this);
  46261. return wordlist[index];
  46262. };
  46263. LangCz.prototype.getWordIndex = function (word) {
  46264. loadWords(this);
  46265. return wordlist.indexOf(word);
  46266. };
  46267. return LangCz;
  46268. }(wordlist_1.Wordlist));
  46269. var langCz = new LangCz();
  46270. exports.langCz = langCz;
  46271. wordlist_1.Wordlist.register(langCz);
  46272. },{"./wordlist":287}],280:[function(_dereq_,module,exports){
  46273. "use strict";
  46274. var __extends = (this && this.__extends) || (function () {
  46275. var extendStatics = function (d, b) {
  46276. extendStatics = Object.setPrototypeOf ||
  46277. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  46278. function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
  46279. return extendStatics(d, b);
  46280. };
  46281. return function (d, b) {
  46282. if (typeof b !== "function" && b !== null)
  46283. throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
  46284. extendStatics(d, b);
  46285. function __() { this.constructor = d; }
  46286. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  46287. };
  46288. })();
  46289. Object.defineProperty(exports, "__esModule", { value: true });
  46290. exports.langEn = void 0;
  46291. var wordlist_1 = _dereq_("./wordlist");
  46292. var words = "AbandonAbilityAbleAboutAboveAbsentAbsorbAbstractAbsurdAbuseAccessAccidentAccountAccuseAchieveAcidAcousticAcquireAcrossActActionActorActressActualAdaptAddAddictAddressAdjustAdmitAdultAdvanceAdviceAerobicAffairAffordAfraidAgainAgeAgentAgreeAheadAimAirAirportAisleAlarmAlbumAlcoholAlertAlienAllAlleyAllowAlmostAloneAlphaAlreadyAlsoAlterAlwaysAmateurAmazingAmongAmountAmusedAnalystAnchorAncientAngerAngleAngryAnimalAnkleAnnounceAnnualAnotherAnswerAntennaAntiqueAnxietyAnyApartApologyAppearAppleApproveAprilArchArcticAreaArenaArgueArmArmedArmorArmyAroundArrangeArrestArriveArrowArtArtefactArtistArtworkAskAspectAssaultAssetAssistAssumeAsthmaAthleteAtomAttackAttendAttitudeAttractAuctionAuditAugustAuntAuthorAutoAutumnAverageAvocadoAvoidAwakeAwareAwayAwesomeAwfulAwkwardAxisBabyBachelorBaconBadgeBagBalanceBalconyBallBambooBananaBannerBarBarelyBargainBarrelBaseBasicBasketBattleBeachBeanBeautyBecauseBecomeBeefBeforeBeginBehaveBehindBelieveBelowBeltBenchBenefitBestBetrayBetterBetweenBeyondBicycleBidBikeBindBiologyBirdBirthBitterBlackBladeBlameBlanketBlastBleakBlessBlindBloodBlossomBlouseBlueBlurBlushBoardBoatBodyBoilBombBoneBonusBookBoostBorderBoringBorrowBossBottomBounceBoxBoyBracketBrainBrandBrassBraveBreadBreezeBrickBridgeBriefBrightBringBriskBroccoliBrokenBronzeBroomBrotherBrownBrushBubbleBuddyBudgetBuffaloBuildBulbBulkBulletBundleBunkerBurdenBurgerBurstBusBusinessBusyButterBuyerBuzzCabbageCabinCableCactusCageCakeCallCalmCameraCampCanCanalCancelCandyCannonCanoeCanvasCanyonCapableCapitalCaptainCarCarbonCardCargoCarpetCarryCartCaseCashCasinoCastleCasualCatCatalogCatchCategoryCattleCaughtCauseCautionCaveCeilingCeleryCementCensusCenturyCerealCertainChairChalkChampionChangeChaosChapterChargeChaseChatCheapCheckCheeseChefCherryChestChickenChiefChildChimneyChoiceChooseChronicChuckleChunkChurnCigarCinnamonCircleCitizenCityCivilClaimClapClarifyClawClayCleanClerkCleverClickClientCliffClimbClinicClipClockClogCloseClothCloudClownClubClumpClusterClutchCoachCoastCoconutCodeCoffeeCoilCoinCollectColorColumnCombineComeComfortComicCommonCompanyConcertConductConfirmCongressConnectConsiderControlConvinceCookCoolCopperCopyCoralCoreCornCorrectCostCottonCouchCountryCoupleCourseCousinCoverCoyoteCrackCradleCraftCramCraneCrashCraterCrawlCrazyCreamCreditCreekCrewCricketCrimeCrispCriticCropCrossCrouchCrowdCrucialCruelCruiseCrumbleCrunchCrushCryCrystalCubeCultureCupCupboardCuriousCurrentCurtainCurveCushionCustomCuteCycleDadDamageDampDanceDangerDaringDashDaughterDawnDayDealDebateDebrisDecadeDecemberDecideDeclineDecorateDecreaseDeerDefenseDefineDefyDegreeDelayDeliverDemandDemiseDenialDentistDenyDepartDependDepositDepthDeputyDeriveDescribeDesertDesignDeskDespairDestroyDetailDetectDevelopDeviceDevoteDiagramDialDiamondDiaryDiceDieselDietDifferDigitalDignityDilemmaDinnerDinosaurDirectDirtDisagreeDiscoverDiseaseDishDismissDisorderDisplayDistanceDivertDivideDivorceDizzyDoctorDocumentDogDollDolphinDomainDonateDonkeyDonorDoorDoseDoubleDoveDraftDragonDramaDrasticDrawDreamDressDriftDrillDrinkDripDriveDropDrumDryDuckDumbDuneDuringDustDutchDutyDwarfDynamicEagerEagleEarlyEarnEarthEasilyEastEasyEchoEcologyEconomyEdgeEditEducateEffortEggEightEitherElbowElderElectricElegantElementElephantElevatorEliteElseEmbarkEmbodyEmbraceEmergeEmotionEmployEmpowerEmptyEnableEnactEndEndlessEndorseEnemyEnergyEnforceEngageEngineEnhanceEnjoyEnlistEnoughEnrichEnrollEnsureEnterEntireEntryEnvelopeEpisodeEqualEquipEraEraseErodeErosionErrorEruptEscapeEssayEssenceEstateEternalEthicsEvidenceEvilEvokeEvolveExactExampleExcessExchangeExciteExcludeExcuseExecuteExerciseExhaustExhibitExileExistExitExoticExpandExpectExpireExplainExposeExpressExtendExtraEyeEyebrowFabricFaceFacultyFadeFaintFaithFallFalseFameFamilyFamousFanFancyFantasyFarmFashionFatFatalFatherFatigueFaultFavoriteFeatureFebruaryFederalFeeFeedFeelFemaleFenceFestivalFetchFeverFewFiberFictionFieldFigureFileFilmFilterFinalFindFineFingerFinishFireFirmFirstFiscalFishFitFitnessFixFlagFlameFlashFlatFlavorFleeFlightFlipFloatFlockFloorFlowerFluidFlushFlyFoamFocusFogFoilFoldFollowFoodFootForceForestForgetForkFortuneForumForwardFossilFosterFoundFoxFragileFrameFrequentFreshFriendFringeFrogFrontFrostFrownFrozenFruitFuelFunFunnyFurnaceFuryFutureGadgetGainGalaxyGalleryGameGapGarageGarbageGardenGarlicGarmentGasGaspGateGatherGaugeGazeGeneralGeniusGenreGentleGenuineGestureGhostGiantGiftGiggleGingerGiraffeGirlGiveGladGlanceGlareGlassGlideGlimpseGlobeGloomGloryGloveGlowGlueGoatGoddessGoldGoodGooseGorillaGospelGossipGovernGownGrabGraceGrainGrantGrapeGrassGravityGreatGreenGridGriefGritGroceryGroupGrowGruntGuardGuessGuideGuiltGuitarGunGymHabitHairHalfHammerHamsterHandHappyHarborHardHarshHarvestHatHaveHawkHazardHeadHealthHeartHeavyHedgehogHeightHelloHelmetHelpHenHeroHiddenHighHillHintHipHireHistoryHobbyHockeyHoldHoleHolidayHollowHomeHoneyHoodHopeHornHorrorHorseHospitalHostHotelHourHoverHubHugeHumanHumbleHumorHundredHungryHuntHurdleHurryHurtHusbandHybridIceIconIdeaIdentifyIdleIgnoreIllIllegalIllnessImageImitateImmenseImmuneImpactImposeImproveImpulseInchIncludeIncomeIncreaseIndexIndicateIndoorIndustryInfantInflictInformInhaleInheritInitialInjectInjuryInmateInnerInnocentInputInquiryInsaneInsectInsideInspireInstallIntactInterestIntoInvestInviteInvolveIronIslandIsolateIssueItemIvoryJacketJaguarJarJazzJealousJeansJellyJewelJobJoinJokeJourneyJoyJudgeJuiceJumpJungleJuniorJunkJustKangarooKeenKeepKetchupKeyKickKidKidneyKindKingdomKissKitKitchenKiteKittenKiwiKneeKnifeKnockKnowLabLabelLaborLadderLadyLakeLampLanguageLaptopLargeLaterLatinLaughLaundryLavaLawLawnLawsuitLayerLazyLeaderLeafLearnLeaveLectureLeftLegLegalLegendLeisureLemonLendLengthLensLeopardLessonLetterLevelLiarLibertyLibraryLicenseLifeLiftLightLikeLimbLimitLinkLionLiquidListLittleLiveLizardLoadLoanLobsterLocalLockLogicLonelyLongLoopLotteryLoudLoungeLoveLoyalLuckyLuggageLumberLunarLunchLuxuryLyricsMachineMadMagicMagnetMaidMailMainMajorMakeMammalManManageMandateMangoMansionManualMapleMarbleMarchMarginMarineMarketMarriageMaskMassMasterMatchMaterialMathMatrixMatterMaximumMazeMeadowMeanMeasureMeatMechanicMedalMediaMelodyMeltMemberMemoryMentionMenuMercyMergeMeritMerryMeshMessageMetalMethodMiddleMidnightMilkMillionMimicMindMinimumMinorMinuteMiracleMirrorMiseryMissMistakeMixMixedMixtureMobileModelModifyMomMomentMonitorMonkeyMonsterMonthMoonMoralMoreMorningMosquitoMotherMotionMotorMountainMouseMoveMovieMuchMuffinMuleMultiplyMuscleMuseumMushroomMusicMustMutualMyselfMysteryMythNaiveNameNapkinNarrowNastyNationNatureNearNeckNeedNegativeNeglectNeitherNephewNerveNestNetNetworkNeutralNeverNewsNextNiceNightNobleNoiseNomineeNoodleNormalNorthNoseNotableNoteNothingNoticeNovelNowNuclearNumberNurseNutOakObeyObjectObligeObscureObserveObtainObviousOccurOceanOctoberOdorOffOfferOfficeOftenOilOkayOldOliveOlympicOmitOnceOneOnionOnlineOnlyOpenOperaOpinionOpposeOptionOrangeOrbitOrchardOrderOrdinaryOrganOrientOriginalOrphanOstrichOtherOutdoorOuterOutputOutsideOvalOvenOverOwnOwnerOxygenOysterOzonePactPaddlePagePairPalacePalmPandaPanelPanicPantherPaperParadeParentParkParrotPartyPassPatchPathPatientPatrolPatternPausePavePaymentPeacePeanutPearPeasantPelicanPenPenaltyPencilPeoplePepperPerfectPermitPersonPetPhonePhotoPhrasePhysicalPianoPicnicPicturePiecePigPigeonPillPilotPinkPioneerPipePistolPitchPizzaPlacePlanetPlasticPlatePlayPleasePledgePluckPlugPlungePoemPoetPointPolarPolePolicePondPonyPoolPopularPortionPositionPossiblePostPotatoPotteryPovertyPowderPowerPracticePraisePredictPreferPreparePresentPrettyPreventPricePridePrimaryPrintPriorityPrisonPrivatePrizeProblemProcessProduceProfitProgramProjectPromoteProofPropertyProsperProtectProudProvidePublicPuddingPullPulpPulsePumpkinPunchPupilPuppyPurchasePurityPurposePursePushPutPuzzlePyramidQualityQuantumQuarterQuestionQuickQuitQuizQuoteRabbitRaccoonRaceRackRadarRadioRailRainRaiseRallyRampRanchRandomRangeRapidRareRateRatherRavenRawRazorReadyRealReasonRebelRebuildRecallReceiveRecipeRecordRecycleReduceReflectReformRefuseRegionRegretRegularRejectRelaxReleaseReliefRelyRemainRememberRemindRemoveRenderRenewRentReopenRepairRepeatReplaceReportRequireRescueResembleResistResourceResponseResultRetireRetreatReturnReunionRevealReviewRewardRhythmRibRibbonRiceRichRideRidgeRifleRightRigidRingRiotRippleRiskRitualRivalRiverRoadRoastRobotRobustRocketRomanceRoofRookieRoomRoseRotateRoughRoundRouteRoyalRubberRudeRugRuleRunRunwayRuralSadSaddleSadnessSafeSailSaladSalmonSalonSaltSaluteSameSampleSandSatisfySatoshiSauceSausageSaveSayScaleScanScareScatterSceneSchemeSchoolScienceScissorsScorpionScoutScrapScreenScriptScrubSeaSearchSeasonSeatSecondSecretSectionSecuritySeedSeekSegmentSelectSellSeminarSeniorSenseSentenceSeriesServiceSessionSettleSetupSevenShadowShaftShallowShareShedShellSheriffShieldShiftShineShipShiverShockShoeShootShopShortShoulderShoveShrimpShrugShuffleShySiblingSickSideSiegeSightSignSilentSilkSillySilverSimilarSimpleSinceSingSirenSisterSituateSixSizeSkateSketchSkiSkillSkinSkirtSkullSlabSlamSleepSlenderSliceSlideSlightSlimSloganSlotSlowSlushSmallSmartSmileSmokeSmoothSnackSnakeSnapSniffSnowSoapSoccerSocialSockSodaSoftSolarSoldierSolidSolutionSolveSomeoneSongSoonSorrySortSoulSoundSoupSourceSouthSpaceSpareSpatialSpawnSpeakSpecialSpeedSpellSpendSphereSpiceSpiderSpikeSpinSpiritSplitSpoilSponsorSpoonSportSpotSpraySpreadSpringSpySquareSqueezeSquirrelStableStadiumStaffStageStairsStampStandStartStateStaySteakSteelStemStepStereoStickStillStingStockStomachStoneStoolStoryStoveStrategyStreetStrikeStrongStruggleStudentStuffStumbleStyleSubjectSubmitSubwaySuccessSuchSuddenSufferSugarSuggestSuitSummerSunSunnySunsetSuperSupplySupremeSureSurfaceSurgeSurpriseSurroundSurveySuspectSustainSwallowSwampSwapSwarmSwearSweetSwiftSwimSwingSwitchSwordSymbolSymptomSyrupSystemTableTackleTagTailTalentTalkTankTapeTargetTaskTasteTattooTaxiTeachTeamTellTenTenantTennisTentTermTestTextThankThatThemeThenTheoryThereTheyThingThisThoughtThreeThriveThrowThumbThunderTicketTideTigerTiltTimberTimeTinyTipTiredTissueTitleToastTobaccoTodayToddlerToeTogetherToiletTokenTomatoTomorrowToneTongueTonightToolToothTopTopicToppleTorchTornadoTortoiseTossTotalTouristTowardTowerTownToyTrackTradeTrafficTragicTrainTransferTrapTrashTravelTrayTreatTreeTrendTrialTribeTrickTriggerTrimTripTrophyTroubleTruckTrueTrulyTrumpetTrustTruthTryTubeTuitionTumbleTunaTunnelTurkeyTurnTurtleTwelveTwentyTwiceTwinTwistTwoTypeTypicalUglyUmbrellaUnableUnawareUncleUncoverUnderUndoUnfairUnfoldUnhappyUniformUniqueUnitUniverseUnknownUnlockUntilUnusualUnveilUpdateUpgradeUpholdUponUpperUpsetUrbanUrgeUsageUseUsedUsefulUselessUsualUtilityVacantVacuumVagueValidValleyValveVanVanishVaporVariousVastVaultVehicleVelvetVendorVentureVenueVerbVerifyVersionVeryVesselVeteranViableVibrantViciousVictoryVideoViewVillageVintageViolinVirtualVirusVisaVisitVisualVitalVividVocalVoiceVoidVolcanoVolumeVoteVoyageWageWagonWaitWalkWallWalnutWantWarfareWarmWarriorWashWaspWasteWaterWaveWayWealthWeaponWearWeaselWeatherWebWeddingWeekendWeirdWelcomeWestWetWhaleWhatWheatWheelWhenWhereWhipWhisperWideWidthWifeWildWillWinWindowWineWingWinkWinnerWinterWireWisdomWiseWishWitnessWolfWomanWonderWoodWoolWordWorkWorldWorryWorthWrapWreckWrestleWristWriteWrongYardYearYellowYouYoungYouthZebraZeroZoneZoo";
  46293. var wordlist = null;
  46294. function loadWords(lang) {
  46295. if (wordlist != null) {
  46296. return;
  46297. }
  46298. wordlist = words.replace(/([A-Z])/g, " $1").toLowerCase().substring(1).split(" ");
  46299. // Verify the computed list matches the official list
  46300. /* istanbul ignore if */
  46301. if (wordlist_1.Wordlist.check(lang) !== "0x3c8acc1e7b08d8e76f9fda015ef48dc8c710a73cb7e0f77b2c18a9b5a7adde60") {
  46302. wordlist = null;
  46303. throw new Error("BIP39 Wordlist for en (English) FAILED");
  46304. }
  46305. }
  46306. var LangEn = /** @class */ (function (_super) {
  46307. __extends(LangEn, _super);
  46308. function LangEn() {
  46309. return _super.call(this, "en") || this;
  46310. }
  46311. LangEn.prototype.getWord = function (index) {
  46312. loadWords(this);
  46313. return wordlist[index];
  46314. };
  46315. LangEn.prototype.getWordIndex = function (word) {
  46316. loadWords(this);
  46317. return wordlist.indexOf(word);
  46318. };
  46319. return LangEn;
  46320. }(wordlist_1.Wordlist));
  46321. var langEn = new LangEn();
  46322. exports.langEn = langEn;
  46323. wordlist_1.Wordlist.register(langEn);
  46324. },{"./wordlist":287}],281:[function(_dereq_,module,exports){
  46325. "use strict";
  46326. var __extends = (this && this.__extends) || (function () {
  46327. var extendStatics = function (d, b) {
  46328. extendStatics = Object.setPrototypeOf ||
  46329. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  46330. function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
  46331. return extendStatics(d, b);
  46332. };
  46333. return function (d, b) {
  46334. if (typeof b !== "function" && b !== null)
  46335. throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
  46336. extendStatics(d, b);
  46337. function __() { this.constructor = d; }
  46338. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  46339. };
  46340. })();
  46341. Object.defineProperty(exports, "__esModule", { value: true });
  46342. exports.langEs = void 0;
  46343. var strings_1 = _dereq_("@ethersproject/strings");
  46344. var wordlist_1 = _dereq_("./wordlist");
  46345. var words = "A/bacoAbdomenAbejaAbiertoAbogadoAbonoAbortoAbrazoAbrirAbueloAbusoAcabarAcademiaAccesoAccio/nAceiteAcelgaAcentoAceptarA/cidoAclararAcne/AcogerAcosoActivoActoActrizActuarAcudirAcuerdoAcusarAdictoAdmitirAdoptarAdornoAduanaAdultoAe/reoAfectarAficio/nAfinarAfirmarA/gilAgitarAgoni/aAgostoAgotarAgregarAgrioAguaAgudoA/guilaAgujaAhogoAhorroAireAislarAjedrezAjenoAjusteAlacra/nAlambreAlarmaAlbaA/lbumAlcaldeAldeaAlegreAlejarAlertaAletaAlfilerAlgaAlgodo/nAliadoAlientoAlivioAlmaAlmejaAlmi/barAltarAltezaAltivoAltoAlturaAlumnoAlzarAmableAmanteAmapolaAmargoAmasarA/mbarA/mbitoAmenoAmigoAmistadAmorAmparoAmplioAnchoAncianoAnclaAndarAnde/nAnemiaA/nguloAnilloA/nimoAni/sAnotarAntenaAntiguoAntojoAnualAnularAnuncioA~adirA~ejoA~oApagarAparatoApetitoApioAplicarApodoAporteApoyoAprenderAprobarApuestaApuroAradoAra~aArarA/rbitroA/rbolArbustoArchivoArcoArderArdillaArduoA/reaA/ridoAriesArmoni/aArne/sAromaArpaArpo/nArregloArrozArrugaArteArtistaAsaAsadoAsaltoAscensoAsegurarAseoAsesorAsientoAsiloAsistirAsnoAsombroA/speroAstillaAstroAstutoAsumirAsuntoAtajoAtaqueAtarAtentoAteoA/ticoAtletaA/tomoAtraerAtrozAtu/nAudazAudioAugeAulaAumentoAusenteAutorAvalAvanceAvaroAveAvellanaAvenaAvestruzAvio/nAvisoAyerAyudaAyunoAzafra/nAzarAzoteAzu/carAzufreAzulBabaBaborBacheBahi/aBaileBajarBalanzaBalco/nBaldeBambu/BancoBandaBa~oBarbaBarcoBarnizBarroBa/sculaBasto/nBasuraBatallaBateri/aBatirBatutaBau/lBazarBebe/BebidaBelloBesarBesoBestiaBichoBienBingoBlancoBloqueBlusaBoaBobinaBoboBocaBocinaBodaBodegaBoinaBolaBoleroBolsaBombaBondadBonitoBonoBonsa/iBordeBorrarBosqueBoteBoti/nBo/vedaBozalBravoBrazoBrechaBreveBrilloBrincoBrisaBrocaBromaBronceBroteBrujaBruscoBrutoBuceoBucleBuenoBueyBufandaBufo/nBu/hoBuitreBultoBurbujaBurlaBurroBuscarButacaBuzo/nCaballoCabezaCabinaCabraCacaoCada/verCadenaCaerCafe/Cai/daCaima/nCajaCajo/nCalCalamarCalcioCaldoCalidadCalleCalmaCalorCalvoCamaCambioCamelloCaminoCampoCa/ncerCandilCanelaCanguroCanicaCantoCa~aCa~o/nCaobaCaosCapazCapita/nCapoteCaptarCapuchaCaraCarbo/nCa/rcelCaretaCargaCari~oCarneCarpetaCarroCartaCasaCascoCaseroCaspaCastorCatorceCatreCaudalCausaCazoCebollaCederCedroCeldaCe/lebreCelosoCe/lulaCementoCenizaCentroCercaCerdoCerezaCeroCerrarCertezaCe/spedCetroChacalChalecoChampu/ChanclaChapaCharlaChicoChisteChivoChoqueChozaChuletaChuparCiclo/nCiegoCieloCienCiertoCifraCigarroCimaCincoCineCintaCipre/sCircoCiruelaCisneCitaCiudadClamorClanClaroClaseClaveClienteClimaCli/nicaCobreCoccio/nCochinoCocinaCocoCo/digoCodoCofreCogerCoheteCoji/nCojoColaColchaColegioColgarColinaCollarColmoColumnaCombateComerComidaCo/modoCompraCondeConejoCongaConocerConsejoContarCopaCopiaCorazo/nCorbataCorchoCordo/nCoronaCorrerCoserCosmosCostaCra/neoCra/terCrearCrecerCrei/doCremaCri/aCrimenCriptaCrisisCromoCro/nicaCroquetaCrudoCruzCuadroCuartoCuatroCuboCubrirCucharaCuelloCuentoCuerdaCuestaCuevaCuidarCulebraCulpaCultoCumbreCumplirCunaCunetaCuotaCupo/nCu/pulaCurarCuriosoCursoCurvaCutisDamaDanzaDarDardoDa/tilDeberDe/bilDe/cadaDecirDedoDefensaDefinirDejarDelfi/nDelgadoDelitoDemoraDensoDentalDeporteDerechoDerrotaDesayunoDeseoDesfileDesnudoDestinoDesvi/oDetalleDetenerDeudaDi/aDiabloDiademaDiamanteDianaDiarioDibujoDictarDienteDietaDiezDifi/cilDignoDilemaDiluirDineroDirectoDirigirDiscoDise~oDisfrazDivaDivinoDobleDoceDolorDomingoDonDonarDoradoDormirDorsoDosDosisDrago/nDrogaDuchaDudaDueloDue~oDulceDu/oDuqueDurarDurezaDuroE/banoEbrioEcharEcoEcuadorEdadEdicio/nEdificioEditorEducarEfectoEficazEjeEjemploElefanteElegirElementoElevarElipseE/liteElixirElogioEludirEmbudoEmitirEmocio/nEmpateEmpe~oEmpleoEmpresaEnanoEncargoEnchufeEnci/aEnemigoEneroEnfadoEnfermoEnga~oEnigmaEnlaceEnormeEnredoEnsayoEnse~arEnteroEntrarEnvaseEnvi/oE/pocaEquipoErizoEscalaEscenaEscolarEscribirEscudoEsenciaEsferaEsfuerzoEspadaEspejoEspi/aEsposaEspumaEsqui/EstarEsteEstiloEstufaEtapaEternoE/ticaEtniaEvadirEvaluarEventoEvitarExactoExamenExcesoExcusaExentoExigirExilioExistirE/xitoExpertoExplicarExponerExtremoFa/bricaFa/bulaFachadaFa/cilFactorFaenaFajaFaldaFalloFalsoFaltarFamaFamiliaFamosoFarao/nFarmaciaFarolFarsaFaseFatigaFaunaFavorFaxFebreroFechaFelizFeoFeriaFerozFe/rtilFervorFesti/nFiableFianzaFiarFibraFiccio/nFichaFideoFiebreFielFieraFiestaFiguraFijarFijoFilaFileteFilialFiltroFinFincaFingirFinitoFirmaFlacoFlautaFlechaFlorFlotaFluirFlujoFlu/orFobiaFocaFogataFogo/nFolioFolletoFondoFormaForroFortunaForzarFosaFotoFracasoFra/gilFranjaFraseFraudeFrei/rFrenoFresaFri/oFritoFrutaFuegoFuenteFuerzaFugaFumarFuncio/nFundaFurgo/nFuriaFusilFu/tbolFuturoGacelaGafasGaitaGajoGalaGaleri/aGalloGambaGanarGanchoGangaGansoGarajeGarzaGasolinaGastarGatoGavila/nGemeloGemirGenGe/neroGenioGenteGeranioGerenteGermenGestoGiganteGimnasioGirarGiroGlaciarGloboGloriaGolGolfoGolosoGolpeGomaGordoGorilaGorraGotaGoteoGozarGradaGra/ficoGranoGrasaGratisGraveGrietaGrilloGripeGrisGritoGrosorGru/aGruesoGrumoGrupoGuanteGuapoGuardiaGuerraGui/aGui~oGuionGuisoGuitarraGusanoGustarHaberHa/bilHablarHacerHachaHadaHallarHamacaHarinaHazHaza~aHebillaHebraHechoHeladoHelioHembraHerirHermanoHe/roeHervirHieloHierroHi/gadoHigieneHijoHimnoHistoriaHocicoHogarHogueraHojaHombreHongoHonorHonraHoraHormigaHornoHostilHoyoHuecoHuelgaHuertaHuesoHuevoHuidaHuirHumanoHu/medoHumildeHumoHundirHuraca/nHurtoIconoIdealIdiomaI/doloIglesiaIglu/IgualIlegalIlusio/nImagenIma/nImitarImparImperioImponerImpulsoIncapazI/ndiceInerteInfielInformeIngenioInicioInmensoInmuneInnatoInsectoInstanteIntere/sI/ntimoIntuirInu/tilInviernoIraIrisIroni/aIslaIsloteJabali/Jabo/nJamo/nJarabeJardi/nJarraJaulaJazmi/nJefeJeringaJineteJornadaJorobaJovenJoyaJuergaJuevesJuezJugadorJugoJugueteJuicioJuncoJunglaJunioJuntarJu/piterJurarJustoJuvenilJuzgarKiloKoalaLabioLacioLacraLadoLadro/nLagartoLa/grimaLagunaLaicoLamerLa/minaLa/mparaLanaLanchaLangostaLanzaLa/pizLargoLarvaLa/stimaLataLa/texLatirLaurelLavarLazoLealLeccio/nLecheLectorLeerLegio/nLegumbreLejanoLenguaLentoLe~aLeo/nLeopardoLesio/nLetalLetraLeveLeyendaLibertadLibroLicorLi/derLidiarLienzoLigaLigeroLimaLi/miteLimo/nLimpioLinceLindoLi/neaLingoteLinoLinternaLi/quidoLisoListaLiteraLitioLitroLlagaLlamaLlantoLlaveLlegarLlenarLlevarLlorarLloverLluviaLoboLocio/nLocoLocuraLo/gicaLogroLombrizLomoLonjaLoteLuchaLucirLugarLujoLunaLunesLupaLustroLutoLuzMacetaMachoMaderaMadreMaduroMaestroMafiaMagiaMagoMai/zMaldadMaletaMallaMaloMama/MamboMamutMancoMandoManejarMangaManiqui/ManjarManoMansoMantaMa~anaMapaMa/quinaMarMarcoMareaMarfilMargenMaridoMa/rmolMarro/nMartesMarzoMasaMa/scaraMasivoMatarMateriaMatizMatrizMa/ximoMayorMazorcaMechaMedallaMedioMe/dulaMejillaMejorMelenaMelo/nMemoriaMenorMensajeMenteMenu/MercadoMerengueMe/ritoMesMeso/nMetaMeterMe/todoMetroMezclaMiedoMielMiembroMigaMilMilagroMilitarMillo/nMimoMinaMineroMi/nimoMinutoMiopeMirarMisaMiseriaMisilMismoMitadMitoMochilaMocio/nModaModeloMohoMojarMoldeMolerMolinoMomentoMomiaMonarcaMonedaMonjaMontoMo~oMoradaMorderMorenoMorirMorroMorsaMortalMoscaMostrarMotivoMoverMo/vilMozoMuchoMudarMuebleMuelaMuerteMuestraMugreMujerMulaMuletaMultaMundoMu~ecaMuralMuroMu/sculoMuseoMusgoMu/sicaMusloNa/carNacio/nNadarNaipeNaranjaNarizNarrarNasalNatalNativoNaturalNa/useaNavalNaveNavidadNecioNe/ctarNegarNegocioNegroNeo/nNervioNetoNeutroNevarNeveraNichoNidoNieblaNietoNi~ezNi~oNi/tidoNivelNoblezaNocheNo/minaNoriaNormaNorteNotaNoticiaNovatoNovelaNovioNubeNucaNu/cleoNudilloNudoNueraNueveNuezNuloNu/meroNutriaOasisObesoObispoObjetoObraObreroObservarObtenerObvioOcaOcasoOce/anoOchentaOchoOcioOcreOctavoOctubreOcultoOcuparOcurrirOdiarOdioOdiseaOesteOfensaOfertaOficioOfrecerOgroOi/doOi/rOjoOlaOleadaOlfatoOlivoOllaOlmoOlorOlvidoOmbligoOndaOnzaOpacoOpcio/nO/peraOpinarOponerOptarO/pticaOpuestoOracio/nOradorOralO/rbitaOrcaOrdenOrejaO/rganoOrgi/aOrgulloOrienteOrigenOrillaOroOrquestaOrugaOsadi/aOscuroOseznoOsoOstraOto~oOtroOvejaO/vuloO/xidoOxi/genoOyenteOzonoPactoPadrePaellaPa/ginaPagoPai/sPa/jaroPalabraPalcoPaletaPa/lidoPalmaPalomaPalparPanPanalPa/nicoPanteraPa~ueloPapa/PapelPapillaPaquetePararParcelaParedParirParoPa/rpadoParquePa/rrafoPartePasarPaseoPasio/nPasoPastaPataPatioPatriaPausaPautaPavoPayasoPeato/nPecadoPeceraPechoPedalPedirPegarPeinePelarPelda~oPeleaPeligroPellejoPeloPelucaPenaPensarPe~o/nPeo/nPeorPepinoPeque~oPeraPerchaPerderPerezaPerfilPericoPerlaPermisoPerroPersonaPesaPescaPe/simoPesta~aPe/taloPetro/leoPezPezu~aPicarPicho/nPiePiedraPiernaPiezaPijamaPilarPilotoPimientaPinoPintorPinzaPi~aPiojoPipaPirataPisarPiscinaPisoPistaPito/nPizcaPlacaPlanPlataPlayaPlazaPleitoPlenoPlomoPlumaPluralPobrePocoPoderPodioPoemaPoesi/aPoetaPolenPolici/aPolloPolvoPomadaPomeloPomoPompaPonerPorcio/nPortalPosadaPoseerPosiblePostePotenciaPotroPozoPradoPrecozPreguntaPremioPrensaPresoPrevioPrimoPri/ncipePrisio/nPrivarProaProbarProcesoProductoProezaProfesorProgramaProlePromesaProntoPropioPro/ximoPruebaPu/blicoPucheroPudorPuebloPuertaPuestoPulgaPulirPulmo/nPulpoPulsoPumaPuntoPu~alPu~oPupaPupilaPure/QuedarQuejaQuemarQuererQuesoQuietoQui/micaQuinceQuitarRa/banoRabiaRaboRacio/nRadicalRai/zRamaRampaRanchoRangoRapazRa/pidoRaptoRasgoRaspaRatoRayoRazaRazo/nReaccio/nRealidadReba~oReboteRecaerRecetaRechazoRecogerRecreoRectoRecursoRedRedondoReducirReflejoReformaRefra/nRefugioRegaloRegirReglaRegresoRehe/nReinoRei/rRejaRelatoRelevoRelieveRellenoRelojRemarRemedioRemoRencorRendirRentaRepartoRepetirReposoReptilResRescateResinaRespetoRestoResumenRetiroRetornoRetratoReunirReve/sRevistaReyRezarRicoRiegoRiendaRiesgoRifaRi/gidoRigorRinco/nRi~o/nRi/oRiquezaRisaRitmoRitoRizoRobleRoceRociarRodarRodeoRodillaRoerRojizoRojoRomeroRomperRonRoncoRondaRopaRoperoRosaRoscaRostroRotarRubi/RuborRudoRuedaRugirRuidoRuinaRuletaRuloRumboRumorRupturaRutaRutinaSa/badoSaberSabioSableSacarSagazSagradoSalaSaldoSaleroSalirSalmo/nSalo/nSalsaSaltoSaludSalvarSambaSancio/nSandi/aSanearSangreSanidadSanoSantoSapoSaqueSardinaSarte/nSastreSata/nSaunaSaxofo/nSeccio/nSecoSecretoSectaSedSeguirSeisSelloSelvaSemanaSemillaSendaSensorSe~alSe~orSepararSepiaSequi/aSerSerieSermo/nServirSesentaSesio/nSetaSetentaSeveroSexoSextoSidraSiestaSieteSigloSignoSi/labaSilbarSilencioSillaSi/mboloSimioSirenaSistemaSitioSituarSobreSocioSodioSolSolapaSoldadoSoledadSo/lidoSoltarSolucio/nSombraSondeoSonidoSonoroSonrisaSopaSoplarSoporteSordoSorpresaSorteoSoste/nSo/tanoSuaveSubirSucesoSudorSuegraSueloSue~oSuerteSufrirSujetoSulta/nSumarSuperarSuplirSuponerSupremoSurSurcoSure~oSurgirSustoSutilTabacoTabiqueTablaTabu/TacoTactoTajoTalarTalcoTalentoTallaTalo/nTama~oTamborTangoTanqueTapaTapeteTapiaTapo/nTaquillaTardeTareaTarifaTarjetaTarotTarroTartaTatuajeTauroTazaTazo/nTeatroTechoTeclaTe/cnicaTejadoTejerTejidoTelaTele/fonoTemaTemorTemploTenazTenderTenerTenisTensoTeori/aTerapiaTercoTe/rminoTernuraTerrorTesisTesoroTestigoTeteraTextoTezTibioTiburo/nTiempoTiendaTierraTiesoTigreTijeraTildeTimbreTi/midoTimoTintaTi/oTi/picoTipoTiraTiro/nTita/nTi/tereTi/tuloTizaToallaTobilloTocarTocinoTodoTogaToldoTomarTonoTontoToparTopeToqueTo/raxToreroTormentaTorneoToroTorpedoTorreTorsoTortugaTosToscoToserTo/xicoTrabajoTractorTraerTra/ficoTragoTrajeTramoTranceTratoTraumaTrazarTre/bolTreguaTreintaTrenTreparTresTribuTrigoTripaTristeTriunfoTrofeoTrompaTroncoTropaTroteTrozoTrucoTruenoTrufaTuberi/aTuboTuertoTumbaTumorTu/nelTu/nicaTurbinaTurismoTurnoTutorUbicarU/lceraUmbralUnidadUnirUniversoUnoUntarU~aUrbanoUrbeUrgenteUrnaUsarUsuarioU/tilUtopi/aUvaVacaVaci/oVacunaVagarVagoVainaVajillaValeVa/lidoValleValorVa/lvulaVampiroVaraVariarVaro/nVasoVecinoVectorVehi/culoVeinteVejezVelaVeleroVelozVenaVencerVendaVenenoVengarVenirVentaVenusVerVeranoVerboVerdeVeredaVerjaVersoVerterVi/aViajeVibrarVicioVi/ctimaVidaVi/deoVidrioViejoViernesVigorVilVillaVinagreVinoVi~edoVioli/nViralVirgoVirtudVisorVi/speraVistaVitaminaViudoVivazViveroVivirVivoVolca/nVolumenVolverVorazVotarVotoVozVueloVulgarYacerYateYeguaYemaYernoYesoYodoYogaYogurZafiroZanjaZapatoZarzaZonaZorroZumoZurdo";
  46346. var lookup = {};
  46347. var wordlist = null;
  46348. function dropDiacritic(word) {
  46349. wordlist_1.logger.checkNormalize();
  46350. return (0, strings_1.toUtf8String)(Array.prototype.filter.call((0, strings_1.toUtf8Bytes)(word.normalize("NFD").toLowerCase()), function (c) {
  46351. return ((c >= 65 && c <= 90) || (c >= 97 && c <= 123));
  46352. }));
  46353. }
  46354. function expand(word) {
  46355. var output = [];
  46356. Array.prototype.forEach.call((0, strings_1.toUtf8Bytes)(word), function (c) {
  46357. // Acute accent
  46358. if (c === 47) {
  46359. output.push(204);
  46360. output.push(129);
  46361. // n-tilde
  46362. }
  46363. else if (c === 126) {
  46364. output.push(110);
  46365. output.push(204);
  46366. output.push(131);
  46367. }
  46368. else {
  46369. output.push(c);
  46370. }
  46371. });
  46372. return (0, strings_1.toUtf8String)(output);
  46373. }
  46374. function loadWords(lang) {
  46375. if (wordlist != null) {
  46376. return;
  46377. }
  46378. wordlist = words.replace(/([A-Z])/g, " $1").toLowerCase().substring(1).split(" ").map(function (w) { return expand(w); });
  46379. wordlist.forEach(function (word, index) {
  46380. lookup[dropDiacritic(word)] = index;
  46381. });
  46382. // Verify the computed list matches the official list
  46383. /* istanbul ignore if */
  46384. if (wordlist_1.Wordlist.check(lang) !== "0xf74fb7092aeacdfbf8959557de22098da512207fb9f109cb526994938cf40300") {
  46385. wordlist = null;
  46386. throw new Error("BIP39 Wordlist for es (Spanish) FAILED");
  46387. }
  46388. }
  46389. var LangEs = /** @class */ (function (_super) {
  46390. __extends(LangEs, _super);
  46391. function LangEs() {
  46392. return _super.call(this, "es") || this;
  46393. }
  46394. LangEs.prototype.getWord = function (index) {
  46395. loadWords(this);
  46396. return wordlist[index];
  46397. };
  46398. LangEs.prototype.getWordIndex = function (word) {
  46399. loadWords(this);
  46400. return lookup[dropDiacritic(word)];
  46401. };
  46402. return LangEs;
  46403. }(wordlist_1.Wordlist));
  46404. var langEs = new LangEs();
  46405. exports.langEs = langEs;
  46406. wordlist_1.Wordlist.register(langEs);
  46407. },{"./wordlist":287,"@ethersproject/strings":266}],282:[function(_dereq_,module,exports){
  46408. "use strict";
  46409. var __extends = (this && this.__extends) || (function () {
  46410. var extendStatics = function (d, b) {
  46411. extendStatics = Object.setPrototypeOf ||
  46412. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  46413. function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
  46414. return extendStatics(d, b);
  46415. };
  46416. return function (d, b) {
  46417. if (typeof b !== "function" && b !== null)
  46418. throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
  46419. extendStatics(d, b);
  46420. function __() { this.constructor = d; }
  46421. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  46422. };
  46423. })();
  46424. Object.defineProperty(exports, "__esModule", { value: true });
  46425. exports.langFr = void 0;
  46426. var strings_1 = _dereq_("@ethersproject/strings");
  46427. var wordlist_1 = _dereq_("./wordlist");
  46428. var words = "AbaisserAbandonAbdiquerAbeilleAbolirAborderAboutirAboyerAbrasifAbreuverAbriterAbrogerAbruptAbsenceAbsoluAbsurdeAbusifAbyssalAcade/mieAcajouAcarienAccablerAccepterAcclamerAccoladeAccrocheAccuserAcerbeAchatAcheterAcidulerAcierAcompteAcque/rirAcronymeActeurActifActuelAdepteAde/quatAdhe/sifAdjectifAdjugerAdmettreAdmirerAdopterAdorerAdoucirAdresseAdroitAdulteAdverbeAe/rerAe/ronefAffaireAffecterAfficheAffreuxAffublerAgacerAgencerAgileAgiterAgraferAgre/ableAgrumeAiderAiguilleAilierAimableAisanceAjouterAjusterAlarmerAlchimieAlerteAlge-breAlgueAlie/nerAlimentAlle/gerAlliageAllouerAllumerAlourdirAlpagaAltesseAlve/oleAmateurAmbiguAmbreAme/nagerAmertumeAmidonAmiralAmorcerAmourAmovibleAmphibieAmpleurAmusantAnalyseAnaphoreAnarchieAnatomieAncienAne/antirAngleAngoisseAnguleuxAnimalAnnexerAnnonceAnnuelAnodinAnomalieAnonymeAnormalAntenneAntidoteAnxieuxApaiserApe/ritifAplanirApologieAppareilAppelerApporterAppuyerAquariumAqueducArbitreArbusteArdeurArdoiseArgentArlequinArmatureArmementArmoireArmureArpenterArracherArriverArroserArsenicArte/rielArticleAspectAsphalteAspirerAssautAsservirAssietteAssocierAssurerAsticotAstreAstuceAtelierAtomeAtriumAtroceAttaqueAttentifAttirerAttraperAubaineAubergeAudaceAudibleAugurerAuroreAutomneAutrucheAvalerAvancerAvariceAvenirAverseAveugleAviateurAvideAvionAviserAvoineAvouerAvrilAxialAxiomeBadgeBafouerBagageBaguetteBaignadeBalancerBalconBaleineBalisageBambinBancaireBandageBanlieueBannie-reBanquierBarbierBarilBaronBarqueBarrageBassinBastionBatailleBateauBatterieBaudrierBavarderBeletteBe/lierBeloteBe/ne/ficeBerceauBergerBerlineBermudaBesaceBesogneBe/tailBeurreBiberonBicycleBiduleBijouBilanBilingueBillardBinaireBiologieBiopsieBiotypeBiscuitBisonBistouriBitumeBizarreBlafardBlagueBlanchirBlessantBlinderBlondBloquerBlousonBobardBobineBoireBoiserBolideBonbonBondirBonheurBonifierBonusBordureBorneBotteBoucleBoueuxBougieBoulonBouquinBourseBoussoleBoutiqueBoxeurBrancheBrasierBraveBrebisBre-cheBreuvageBricolerBrigadeBrillantBriocheBriqueBrochureBroderBronzerBrousseBroyeurBrumeBrusqueBrutalBruyantBuffleBuissonBulletinBureauBurinBustierButinerButoirBuvableBuvetteCabanonCabineCachetteCadeauCadreCafe/ineCaillouCaissonCalculerCalepinCalibreCalmerCalomnieCalvaireCamaradeCame/raCamionCampagneCanalCanetonCanonCantineCanularCapableCaporalCapriceCapsuleCapterCapucheCarabineCarboneCaresserCaribouCarnageCarotteCarreauCartonCascadeCasierCasqueCassureCauserCautionCavalierCaverneCaviarCe/dilleCeintureCe/lesteCelluleCendrierCensurerCentralCercleCe/re/bralCeriseCernerCerveauCesserChagrinChaiseChaleurChambreChanceChapitreCharbonChasseurChatonChaussonChavirerChemiseChenilleChe/quierChercherChevalChienChiffreChignonChime-reChiotChlorureChocolatChoisirChoseChouetteChromeChuteCigareCigogneCimenterCine/maCintrerCirculerCirerCirqueCiterneCitoyenCitronCivilClaironClameurClaquerClasseClavierClientClignerClimatClivageClocheClonageCloporteCobaltCobraCocasseCocotierCoderCodifierCoffreCognerCohe/sionCoifferCoincerCole-reColibriCollineColmaterColonelCombatCome/dieCommandeCompactConcertConduireConfierCongelerConnoterConsonneContactConvexeCopainCopieCorailCorbeauCordageCornicheCorpusCorrectCorte-geCosmiqueCostumeCotonCoudeCoupureCourageCouteauCouvrirCoyoteCrabeCrainteCravateCrayonCre/atureCre/diterCre/meuxCreuserCrevetteCriblerCrierCristalCrite-reCroireCroquerCrotaleCrucialCruelCrypterCubiqueCueillirCuille-reCuisineCuivreCulminerCultiverCumulerCupideCuratifCurseurCyanureCycleCylindreCyniqueDaignerDamierDangerDanseurDauphinDe/battreDe/biterDe/borderDe/briderDe/butantDe/calerDe/cembreDe/chirerDe/ciderDe/clarerDe/corerDe/crireDe/cuplerDe/daleDe/ductifDe/esseDe/fensifDe/filerDe/frayerDe/gagerDe/givrerDe/glutirDe/graferDe/jeunerDe/liceDe/logerDemanderDemeurerDe/molirDe/nicherDe/nouerDentelleDe/nuderDe/partDe/penserDe/phaserDe/placerDe/poserDe/rangerDe/roberDe/sastreDescenteDe/sertDe/signerDe/sobe/irDessinerDestrierDe/tacherDe/testerDe/tourerDe/tresseDevancerDevenirDevinerDevoirDiableDialogueDiamantDicterDiffe/rerDige/rerDigitalDigneDiluerDimancheDiminuerDioxydeDirectifDirigerDiscuterDisposerDissiperDistanceDivertirDiviserDocileDocteurDogmeDoigtDomaineDomicileDompterDonateurDonjonDonnerDopamineDortoirDorureDosageDoseurDossierDotationDouanierDoubleDouceurDouterDoyenDragonDraperDresserDribblerDroitureDuperieDuplexeDurableDurcirDynastieE/blouirE/carterE/charpeE/chelleE/clairerE/clipseE/cloreE/cluseE/coleE/conomieE/corceE/couterE/craserE/cre/merE/crivainE/crouE/cumeE/cureuilE/difierE/duquerEffacerEffectifEffigieEffortEffrayerEffusionE/galiserE/garerE/jecterE/laborerE/largirE/lectronE/le/gantE/le/phantE/le-veE/ligibleE/litismeE/logeE/luciderE/luderEmballerEmbellirEmbryonE/meraudeE/missionEmmenerE/motionE/mouvoirEmpereurEmployerEmporterEmpriseE/mulsionEncadrerEnche-reEnclaveEncocheEndiguerEndosserEndroitEnduireE/nergieEnfanceEnfermerEnfouirEngagerEnginEngloberE/nigmeEnjamberEnjeuEnleverEnnemiEnnuyeuxEnrichirEnrobageEnseigneEntasserEntendreEntierEntourerEntraverE/nume/rerEnvahirEnviableEnvoyerEnzymeE/olienE/paissirE/pargneE/patantE/pauleE/picerieE/pide/mieE/pierE/pilogueE/pineE/pisodeE/pitapheE/poqueE/preuveE/prouverE/puisantE/querreE/quipeE/rigerE/rosionErreurE/ruptionEscalierEspadonEspe-ceEspie-gleEspoirEspritEsquiverEssayerEssenceEssieuEssorerEstimeEstomacEstradeE/tage-reE/talerE/tancheE/tatiqueE/teindreE/tendoirE/ternelE/thanolE/thiqueEthnieE/tirerE/tofferE/toileE/tonnantE/tourdirE/trangeE/troitE/tudeEuphorieE/valuerE/vasionE/ventailE/videnceE/viterE/volutifE/voquerExactExage/rerExaucerExcellerExcitantExclusifExcuseExe/cuterExempleExercerExhalerExhorterExigenceExilerExisterExotiqueExpe/dierExplorerExposerExprimerExquisExtensifExtraireExulterFableFabuleuxFacetteFacileFactureFaiblirFalaiseFameuxFamilleFarceurFarfeluFarineFaroucheFascinerFatalFatigueFauconFautifFaveurFavoriFe/brileFe/conderFe/de/rerFe/linFemmeFe/murFendoirFe/odalFermerFe/roceFerveurFestivalFeuilleFeutreFe/vrierFiascoFicelerFictifFide-leFigureFilatureFiletageFilie-reFilleulFilmerFilouFiltrerFinancerFinirFioleFirmeFissureFixerFlairerFlammeFlasqueFlatteurFle/auFle-cheFleurFlexionFloconFloreFluctuerFluideFluvialFolieFonderieFongibleFontaineForcerForgeronFormulerFortuneFossileFoudreFouge-reFouillerFoulureFourmiFragileFraiseFranchirFrapperFrayeurFre/gateFreinerFrelonFre/mirFre/ne/sieFre-reFriableFrictionFrissonFrivoleFroidFromageFrontalFrotterFruitFugitifFuiteFureurFurieuxFurtifFusionFuturGagnerGalaxieGalerieGambaderGarantirGardienGarnirGarrigueGazelleGazonGe/antGe/latineGe/luleGendarmeGe/ne/ralGe/nieGenouGentilGe/ologieGe/ome-treGe/raniumGermeGestuelGeyserGibierGiclerGirafeGivreGlaceGlaiveGlisserGlobeGloireGlorieuxGolfeurGommeGonflerGorgeGorilleGoudronGouffreGoulotGoupilleGourmandGoutteGraduelGraffitiGraineGrandGrappinGratuitGravirGrenatGriffureGrillerGrimperGrognerGronderGrotteGroupeGrugerGrutierGruye-reGue/pardGuerrierGuideGuimauveGuitareGustatifGymnasteGyrostatHabitudeHachoirHalteHameauHangarHannetonHaricotHarmonieHarponHasardHe/liumHe/matomeHerbeHe/rissonHermineHe/ronHe/siterHeureuxHibernerHibouHilarantHistoireHiverHomardHommageHomoge-neHonneurHonorerHonteuxHordeHorizonHorlogeHormoneHorribleHouleuxHousseHublotHuileuxHumainHumbleHumideHumourHurlerHydromelHygie-neHymneHypnoseIdylleIgnorerIguaneIlliciteIllusionImageImbiberImiterImmenseImmobileImmuableImpactImpe/rialImplorerImposerImprimerImputerIncarnerIncendieIncidentInclinerIncoloreIndexerIndiceInductifIne/ditIneptieInexactInfiniInfligerInformerInfusionInge/rerInhalerInhiberInjecterInjureInnocentInoculerInonderInscrireInsecteInsigneInsoliteInspirerInstinctInsulterIntactIntenseIntimeIntrigueIntuitifInutileInvasionInventerInviterInvoquerIroniqueIrradierIrre/elIrriterIsolerIvoireIvresseJaguarJaillirJambeJanvierJardinJaugerJauneJavelotJetableJetonJeudiJeunesseJoindreJoncherJonglerJoueurJouissifJournalJovialJoyauJoyeuxJubilerJugementJuniorJuponJuristeJusticeJuteuxJuve/nileKayakKimonoKiosqueLabelLabialLabourerLace/rerLactoseLaguneLaineLaisserLaitierLambeauLamelleLampeLanceurLangageLanterneLapinLargeurLarmeLaurierLavaboLavoirLectureLe/galLe/gerLe/gumeLessiveLettreLevierLexiqueLe/zardLiasseLibe/rerLibreLicenceLicorneLie-geLie-vreLigatureLigoterLigueLimerLimiteLimonadeLimpideLine/aireLingotLionceauLiquideLisie-reListerLithiumLitigeLittoralLivreurLogiqueLointainLoisirLombricLoterieLouerLourdLoutreLouveLoyalLubieLucideLucratifLueurLugubreLuisantLumie-reLunaireLundiLuronLutterLuxueuxMachineMagasinMagentaMagiqueMaigreMaillonMaintienMairieMaisonMajorerMalaxerMale/ficeMalheurMaliceMalletteMammouthMandaterManiableManquantManteauManuelMarathonMarbreMarchandMardiMaritimeMarqueurMarronMartelerMascotteMassifMate/rielMatie-reMatraqueMaudireMaussadeMauveMaximalMe/chantMe/connuMe/dailleMe/decinMe/diterMe/duseMeilleurMe/langeMe/lodieMembreMe/moireMenacerMenerMenhirMensongeMentorMercrediMe/riteMerleMessagerMesureMe/talMe/te/oreMe/thodeMe/tierMeubleMiaulerMicrobeMietteMignonMigrerMilieuMillionMimiqueMinceMine/ralMinimalMinorerMinuteMiracleMiroiterMissileMixteMobileModerneMoelleuxMondialMoniteurMonnaieMonotoneMonstreMontagneMonumentMoqueurMorceauMorsureMortierMoteurMotifMoucheMoufleMoulinMoussonMoutonMouvantMultipleMunitionMurailleMure-neMurmureMuscleMuse/umMusicienMutationMuterMutuelMyriadeMyrtilleMyste-reMythiqueNageurNappeNarquoisNarrerNatationNationNatureNaufrageNautiqueNavireNe/buleuxNectarNe/fasteNe/gationNe/gligerNe/gocierNeigeNerveuxNettoyerNeuroneNeutronNeveuNicheNickelNitrateNiveauNobleNocifNocturneNoirceurNoisetteNomadeNombreuxNommerNormatifNotableNotifierNotoireNourrirNouveauNovateurNovembreNoviceNuageNuancerNuireNuisibleNume/roNuptialNuqueNutritifObe/irObjectifObligerObscurObserverObstacleObtenirObturerOccasionOccuperOce/anOctobreOctroyerOctuplerOculaireOdeurOdorantOffenserOfficierOffrirOgiveOiseauOisillonOlfactifOlivierOmbrageOmettreOnctueuxOndulerOne/reuxOniriqueOpaleOpaqueOpe/rerOpinionOpportunOpprimerOpterOptiqueOrageuxOrangeOrbiteOrdonnerOreilleOrganeOrgueilOrificeOrnementOrqueOrtieOscillerOsmoseOssatureOtarieOuraganOursonOutilOutragerOuvrageOvationOxydeOxyge-neOzonePaisiblePalacePalmare-sPalourdePalperPanachePandaPangolinPaniquerPanneauPanoramaPantalonPapayePapierPapoterPapyrusParadoxeParcelleParesseParfumerParlerParoleParrainParsemerPartagerParureParvenirPassionPaste-quePaternelPatiencePatronPavillonPavoiserPayerPaysagePeignePeintrePelagePe/licanPellePelousePeluchePendulePe/ne/trerPe/niblePensifPe/nuriePe/pitePe/plumPerdrixPerforerPe/riodePermuterPerplexePersilPertePeserPe/talePetitPe/trirPeuplePharaonPhobiePhoquePhotonPhrasePhysiquePianoPicturalPie-cePierrePieuvrePilotePinceauPipettePiquerPiroguePiscinePistonPivoterPixelPizzaPlacardPlafondPlaisirPlanerPlaquePlastronPlateauPleurerPlexusPliagePlombPlongerPluiePlumagePochettePoe/siePoe-tePointePoirierPoissonPoivrePolairePolicierPollenPolygonePommadePompierPonctuelPonde/rerPoneyPortiquePositionPosse/derPosturePotagerPoteauPotionPoucePoulainPoumonPourprePoussinPouvoirPrairiePratiquePre/cieuxPre/direPre/fixePre/ludePre/nomPre/sencePre/textePre/voirPrimitifPrincePrisonPriverProble-meProce/derProdigeProfondProgre-sProieProjeterProloguePromenerPropreProspe-reProte/gerProuesseProverbePrudencePruneauPsychosePublicPuceronPuiserPulpePulsarPunaisePunitifPupitrePurifierPuzzlePyramideQuasarQuerelleQuestionQuie/tudeQuitterQuotientRacineRaconterRadieuxRagondinRaideurRaisinRalentirRallongeRamasserRapideRasageRatisserRavagerRavinRayonnerRe/actifRe/agirRe/aliserRe/animerRecevoirRe/citerRe/clamerRe/colterRecruterReculerRecyclerRe/digerRedouterRefaireRe/flexeRe/formerRefrainRefugeRe/galienRe/gionRe/glageRe/gulierRe/ite/rerRejeterRejouerRelatifReleverReliefRemarqueReme-deRemiseRemonterRemplirRemuerRenardRenfortReniflerRenoncerRentrerRenvoiReplierReporterRepriseReptileRequinRe/serveRe/sineuxRe/soudreRespectResterRe/sultatRe/tablirRetenirRe/ticuleRetomberRetracerRe/unionRe/ussirRevancheRevivreRe/volteRe/vulsifRichesseRideauRieurRigideRigolerRincerRiposterRisibleRisqueRituelRivalRivie-reRocheuxRomanceRompreRonceRondinRoseauRosierRotatifRotorRotuleRougeRouilleRouleauRoutineRoyaumeRubanRubisRucheRuelleRugueuxRuinerRuisseauRuserRustiqueRythmeSablerSaboterSabreSacocheSafariSagesseSaisirSaladeSaliveSalonSaluerSamediSanctionSanglierSarcasmeSardineSaturerSaugrenuSaumonSauterSauvageSavantSavonnerScalpelScandaleSce/le/ratSce/narioSceptreSche/maScienceScinderScoreScrutinSculpterSe/anceSe/cableSe/cherSecouerSe/cre/terSe/datifSe/duireSeigneurSe/jourSe/lectifSemaineSemblerSemenceSe/minalSe/nateurSensibleSentenceSe/parerSe/quenceSereinSergentSe/rieuxSerrureSe/rumServiceSe/sameSe/virSevrageSextupleSide/ralSie-cleSie/gerSifflerSigleSignalSilenceSiliciumSimpleSince-reSinistreSiphonSiropSismiqueSituerSkierSocialSocleSodiumSoigneuxSoldatSoleilSolitudeSolubleSombreSommeilSomnolerSondeSongeurSonnetteSonoreSorcierSortirSosieSottiseSoucieuxSoudureSouffleSouleverSoupapeSourceSoutirerSouvenirSpacieuxSpatialSpe/cialSphe-reSpiralStableStationSternumStimulusStipulerStrictStudieuxStupeurStylisteSublimeSubstratSubtilSubvenirSucce-sSucreSuffixeSugge/rerSuiveurSulfateSuperbeSupplierSurfaceSuricateSurmenerSurpriseSursautSurvieSuspectSyllabeSymboleSyme/trieSynapseSyntaxeSyste-meTabacTablierTactileTaillerTalentTalismanTalonnerTambourTamiserTangibleTapisTaquinerTarderTarifTartineTasseTatamiTatouageTaupeTaureauTaxerTe/moinTemporelTenailleTendreTeneurTenirTensionTerminerTerneTerribleTe/tineTexteThe-meThe/orieThe/rapieThoraxTibiaTie-deTimideTirelireTiroirTissuTitaneTitreTituberTobogganTole/rantTomateToniqueTonneauToponymeTorcheTordreTornadeTorpilleTorrentTorseTortueTotemToucherTournageTousserToxineTractionTraficTragiqueTrahirTrainTrancherTravailTre-fleTremperTre/sorTreuilTriageTribunalTricoterTrilogieTriompheTriplerTriturerTrivialTromboneTroncTropicalTroupeauTuileTulipeTumulteTunnelTurbineTuteurTutoyerTuyauTympanTyphonTypiqueTyranUbuesqueUltimeUltrasonUnanimeUnifierUnionUniqueUnitaireUniversUraniumUrbainUrticantUsageUsineUsuelUsureUtileUtopieVacarmeVaccinVagabondVagueVaillantVaincreVaisseauValableValiseVallonValveVampireVanilleVapeurVarierVaseuxVassalVasteVecteurVedetteVe/ge/talVe/hiculeVeinardVe/loceVendrediVe/ne/rerVengerVenimeuxVentouseVerdureVe/rinVernirVerrouVerserVertuVestonVe/te/ranVe/tusteVexantVexerViaducViandeVictoireVidangeVide/oVignetteVigueurVilainVillageVinaigreViolonVipe-reVirementVirtuoseVirusVisageViseurVisionVisqueuxVisuelVitalVitesseViticoleVitrineVivaceVivipareVocationVoguerVoileVoisinVoitureVolailleVolcanVoltigerVolumeVoraceVortexVoterVouloirVoyageVoyelleWagonXe/nonYachtZe-breZe/nithZesteZoologie";
  46429. var wordlist = null;
  46430. var lookup = {};
  46431. function dropDiacritic(word) {
  46432. wordlist_1.logger.checkNormalize();
  46433. return (0, strings_1.toUtf8String)(Array.prototype.filter.call((0, strings_1.toUtf8Bytes)(word.normalize("NFD").toLowerCase()), function (c) {
  46434. return ((c >= 65 && c <= 90) || (c >= 97 && c <= 123));
  46435. }));
  46436. }
  46437. function expand(word) {
  46438. var output = [];
  46439. Array.prototype.forEach.call((0, strings_1.toUtf8Bytes)(word), function (c) {
  46440. // Acute accent
  46441. if (c === 47) {
  46442. output.push(204);
  46443. output.push(129);
  46444. // Grave accent
  46445. }
  46446. else if (c === 45) {
  46447. output.push(204);
  46448. output.push(128);
  46449. }
  46450. else {
  46451. output.push(c);
  46452. }
  46453. });
  46454. return (0, strings_1.toUtf8String)(output);
  46455. }
  46456. function loadWords(lang) {
  46457. if (wordlist != null) {
  46458. return;
  46459. }
  46460. wordlist = words.replace(/([A-Z])/g, " $1").toLowerCase().substring(1).split(" ").map(function (w) { return expand(w); });
  46461. wordlist.forEach(function (word, index) {
  46462. lookup[dropDiacritic(word)] = index;
  46463. });
  46464. // Verify the computed list matches the official list
  46465. /* istanbul ignore if */
  46466. if (wordlist_1.Wordlist.check(lang) !== "0x51deb7ae009149dc61a6bd18a918eb7ac78d2775726c68e598b92d002519b045") {
  46467. wordlist = null;
  46468. throw new Error("BIP39 Wordlist for fr (French) FAILED");
  46469. }
  46470. }
  46471. var LangFr = /** @class */ (function (_super) {
  46472. __extends(LangFr, _super);
  46473. function LangFr() {
  46474. return _super.call(this, "fr") || this;
  46475. }
  46476. LangFr.prototype.getWord = function (index) {
  46477. loadWords(this);
  46478. return wordlist[index];
  46479. };
  46480. LangFr.prototype.getWordIndex = function (word) {
  46481. loadWords(this);
  46482. return lookup[dropDiacritic(word)];
  46483. };
  46484. return LangFr;
  46485. }(wordlist_1.Wordlist));
  46486. var langFr = new LangFr();
  46487. exports.langFr = langFr;
  46488. wordlist_1.Wordlist.register(langFr);
  46489. },{"./wordlist":287,"@ethersproject/strings":266}],283:[function(_dereq_,module,exports){
  46490. "use strict";
  46491. var __extends = (this && this.__extends) || (function () {
  46492. var extendStatics = function (d, b) {
  46493. extendStatics = Object.setPrototypeOf ||
  46494. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  46495. function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
  46496. return extendStatics(d, b);
  46497. };
  46498. return function (d, b) {
  46499. if (typeof b !== "function" && b !== null)
  46500. throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
  46501. extendStatics(d, b);
  46502. function __() { this.constructor = d; }
  46503. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  46504. };
  46505. })();
  46506. Object.defineProperty(exports, "__esModule", { value: true });
  46507. exports.langIt = void 0;
  46508. var wordlist_1 = _dereq_("./wordlist");
  46509. var words = "AbacoAbbaglioAbbinatoAbeteAbissoAbolireAbrasivoAbrogatoAccadereAccennoAccusatoAcetoneAchilleAcidoAcquaAcreAcrilicoAcrobataAcutoAdagioAddebitoAddomeAdeguatoAderireAdipeAdottareAdulareAffabileAffettoAffissoAffrantoAforismaAfosoAfricanoAgaveAgenteAgevoleAggancioAgireAgitareAgonismoAgricoloAgrumetoAguzzoAlabardaAlatoAlbatroAlberatoAlboAlbumeAlceAlcolicoAlettoneAlfaAlgebraAlianteAlibiAlimentoAllagatoAllegroAllievoAllodolaAllusivoAlmenoAlogenoAlpacaAlpestreAltalenaAlternoAlticcioAltroveAlunnoAlveoloAlzareAmalgamaAmanitaAmarenaAmbitoAmbratoAmebaAmericaAmetistaAmicoAmmassoAmmendaAmmirareAmmonitoAmoreAmpioAmpliareAmuletoAnacardoAnagrafeAnalistaAnarchiaAnatraAncaAncellaAncoraAndareAndreaAnelloAngeloAngolareAngustoAnimaAnnegareAnnidatoAnnoAnnuncioAnonimoAnticipoAnziApaticoAperturaApodeApparireAppetitoAppoggioApprodoAppuntoAprileArabicaArachideAragostaAraldicaArancioAraturaArazzoArbitroArchivioArditoArenileArgentoArgineArgutoAriaArmoniaArneseArredatoArringaArrostoArsenicoArsoArteficeArzilloAsciuttoAscoltoAsepsiAsetticoAsfaltoAsinoAsolaAspiratoAsproAssaggioAsseAssolutoAssurdoAstaAstenutoAsticeAstrattoAtavicoAteismoAtomicoAtonoAttesaAttivareAttornoAttritoAttualeAusilioAustriaAutistaAutonomoAutunnoAvanzatoAvereAvvenireAvvisoAvvolgereAzioneAzotoAzzimoAzzurroBabeleBaccanoBacinoBacoBadessaBadilataBagnatoBaitaBalconeBaldoBalenaBallataBalzanoBambinoBandireBaraondaBarbaroBarcaBaritonoBarlumeBaroccoBasilicoBassoBatostaBattutoBauleBavaBavosaBeccoBeffaBelgioBelvaBendaBenevoleBenignoBenzinaBereBerlinaBetaBibitaBiciBidoneBifidoBigaBilanciaBimboBinocoloBiologoBipedeBipolareBirbanteBirraBiscottoBisestoBisnonnoBisonteBisturiBizzarroBlandoBlattaBollitoBonificoBordoBoscoBotanicoBottinoBozzoloBraccioBradipoBramaBrancaBravuraBretellaBrevettoBrezzaBrigliaBrillanteBrindareBroccoloBrodoBronzinaBrulloBrunoBubboneBucaBudinoBuffoneBuioBulboBuonoBurloneBurrascaBussolaBustaCadettoCaducoCalamaroCalcoloCalesseCalibroCalmoCaloriaCambusaCamerataCamiciaCamminoCamolaCampaleCanapaCandelaCaneCaninoCanottoCantinaCapaceCapelloCapitoloCapogiroCapperoCapraCapsulaCarapaceCarcassaCardoCarismaCarovanaCarrettoCartolinaCasaccioCascataCasermaCasoCassoneCastelloCasualeCatastaCatenaCatrameCautoCavilloCedibileCedrataCefaloCelebreCellulareCenaCenoneCentesimoCeramicaCercareCertoCerumeCervelloCesoiaCespoCetoChelaChiaroChiccaChiedereChimeraChinaChirurgoChitarraCiaoCiclismoCifrareCignoCilindroCiottoloCircaCirrosiCitricoCittadinoCiuffoCivettaCivileClassicoClinicaCloroCoccoCodardoCodiceCoerenteCognomeCollareColmatoColoreColposoColtivatoColzaComaCometaCommandoComodoComputerComuneConcisoCondurreConfermaCongelareConiugeConnessoConoscereConsumoContinuoConvegnoCopertoCopioneCoppiaCopricapoCorazzaCordataCoricatoCorniceCorollaCorpoCorredoCorsiaCorteseCosmicoCostanteCotturaCovatoCratereCravattaCreatoCredereCremosoCrescitaCretaCricetoCrinaleCrisiCriticoCroceCronacaCrostataCrucialeCruscaCucireCuculoCuginoCullatoCupolaCuratoreCursoreCurvoCuscinoCustodeDadoDainoDalmataDamerinoDanielaDannosoDanzareDatatoDavantiDavveroDebuttoDecennioDecisoDeclinoDecolloDecretoDedicatoDefinitoDeformeDegnoDelegareDelfinoDelirioDeltaDemenzaDenotatoDentroDepositoDerapataDerivareDerogaDescrittoDesertoDesiderioDesumereDetersivoDevotoDiametroDicembreDiedroDifesoDiffusoDigerireDigitaleDiluvioDinamicoDinnanziDipintoDiplomaDipoloDiradareDireDirottoDirupoDisagioDiscretoDisfareDisgeloDispostoDistanzaDisumanoDitoDivanoDiveltoDividereDivoratoDobloneDocenteDoganaleDogmaDolceDomatoDomenicaDominareDondoloDonoDormireDoteDottoreDovutoDozzinaDragoDruidoDubbioDubitareDucaleDunaDuomoDupliceDuraturoEbanoEccessoEccoEclissiEconomiaEderaEdicolaEdileEditoriaEducareEgemoniaEgliEgoismoEgregioElaboratoElargireEleganteElencatoElettoElevareElficoElicaElmoElsaElusoEmanatoEmblemaEmessoEmiroEmotivoEmozioneEmpiricoEmuloEndemicoEnduroEnergiaEnfasiEnotecaEntrareEnzimaEpatiteEpilogoEpisodioEpocaleEppureEquatoreErarioErbaErbosoEredeEremitaErigereErmeticoEroeErosivoErranteEsagonoEsameEsanimeEsaudireEscaEsempioEsercitoEsibitoEsigenteEsistereEsitoEsofagoEsortatoEsosoEspansoEspressoEssenzaEssoEstesoEstimareEstoniaEstrosoEsultareEtilicoEtnicoEtruscoEttoEuclideoEuropaEvasoEvidenzaEvitatoEvolutoEvvivaFabbricaFaccendaFachiroFalcoFamigliaFanaleFanfaraFangoFantasmaFareFarfallaFarinosoFarmacoFasciaFastosoFasulloFaticareFatoFavolosoFebbreFecolaFedeFegatoFelpaFeltroFemminaFendereFenomenoFermentoFerroFertileFessuraFestivoFettaFeudoFiabaFiduciaFifaFiguratoFiloFinanzaFinestraFinireFioreFiscaleFisicoFiumeFlaconeFlamencoFleboFlemmaFloridoFluenteFluoroFobicoFocacciaFocosoFoderatoFoglioFolataFolcloreFolgoreFondenteFoneticoFoniaFontanaForbitoForchettaForestaFormicaFornaioForoFortezzaForzareFosfatoFossoFracassoFranaFrassinoFratelloFreccettaFrenataFrescoFrigoFrollinoFrondeFrugaleFruttaFucilataFucsiaFuggenteFulmineFulvoFumanteFumettoFumosoFuneFunzioneFuocoFurboFurgoneFuroreFusoFutileGabbianoGaffeGalateoGallinaGaloppoGamberoGammaGaranziaGarboGarofanoGarzoneGasdottoGasolioGastricoGattoGaudioGazeboGazzellaGecoGelatinaGelsoGemelloGemmatoGeneGenitoreGennaioGenotipoGergoGhepardoGhiaccioGhisaGialloGildaGineproGiocareGioielloGiornoGioveGiratoGironeGittataGiudizioGiuratoGiustoGlobuloGlutineGnomoGobbaGolfGomitoGommoneGonfioGonnaGovernoGracileGradoGraficoGrammoGrandeGrattareGravosoGraziaGrecaGreggeGrifoneGrigioGrinzaGrottaGruppoGuadagnoGuaioGuantoGuardareGufoGuidareIbernatoIconaIdenticoIdillioIdoloIdraIdricoIdrogenoIgieneIgnaroIgnoratoIlareIllesoIllogicoIlludereImballoImbevutoImboccoImbutoImmaneImmersoImmolatoImpaccoImpetoImpiegoImportoImprontaInalareInarcareInattivoIncantoIncendioInchinoIncisivoInclusoIncontroIncrocioIncuboIndagineIndiaIndoleIneditoInfattiInfilareInflittoIngaggioIngegnoIngleseIngordoIngrossoInnescoInodoreInoltrareInondatoInsanoInsettoInsiemeInsonniaInsulinaIntasatoInteroIntonacoIntuitoInumidireInvalidoInveceInvitoIperboleIpnoticoIpotesiIppicaIrideIrlandaIronicoIrrigatoIrrorareIsolatoIsotopoIstericoIstitutoIstriceItaliaIterareLabbroLabirintoLaccaLaceratoLacrimaLacunaLaddoveLagoLampoLancettaLanternaLardosoLargaLaringeLastraLatenzaLatinoLattugaLavagnaLavoroLegaleLeggeroLemboLentezzaLenzaLeoneLepreLesivoLessatoLestoLetteraleLevaLevigatoLiberoLidoLievitoLillaLimaturaLimitareLimpidoLineareLinguaLiquidoLiraLiricaLiscaLiteLitigioLivreaLocandaLodeLogicaLombareLondraLongevoLoquaceLorenzoLotoLotteriaLuceLucidatoLumacaLuminosoLungoLupoLuppoloLusingaLussoLuttoMacabroMacchinaMaceroMacinatoMadamaMagicoMagliaMagneteMagroMaiolicaMalafedeMalgradoMalintesoMalsanoMaltoMalumoreManaManciaMandorlaMangiareManifestoMannaroManovraMansardaMantideManubrioMappaMaratonaMarcireMarettaMarmoMarsupioMascheraMassaiaMastinoMaterassoMatricolaMattoneMaturoMazurcaMeandroMeccanicoMecenateMedesimoMeditareMegaMelassaMelisMelodiaMeningeMenoMensolaMercurioMerendaMerloMeschinoMeseMessereMestoloMetalloMetodoMettereMiagolareMicaMicelioMicheleMicroboMidolloMieleMiglioreMilanoMiliteMimosaMineraleMiniMinoreMirinoMirtilloMiscelaMissivaMistoMisurareMitezzaMitigareMitraMittenteMnemonicoModelloModificaModuloMoganoMogioMoleMolossoMonasteroMoncoMondinaMonetarioMonileMonotonoMonsoneMontatoMonvisoMoraMordereMorsicatoMostroMotivatoMotosegaMottoMovenzaMovimentoMozzoMuccaMucosaMuffaMughettoMugnaioMulattoMulinelloMultiploMummiaMuntoMuovereMuraleMusaMuscoloMusicaMutevoleMutoNababboNaftaNanometroNarcisoNariceNarratoNascereNastrareNaturaleNauticaNaviglioNebulosaNecrosiNegativoNegozioNemmenoNeofitaNerettoNervoNessunoNettunoNeutraleNeveNevroticoNicchiaNinfaNitidoNobileNocivoNodoNomeNominaNordicoNormaleNorvegeseNostranoNotareNotiziaNotturnoNovellaNucleoNullaNumeroNuovoNutrireNuvolaNuzialeOasiObbedireObbligoObeliscoOblioOboloObsoletoOccasioneOcchioOccidenteOccorrereOccultareOcraOculatoOdiernoOdorareOffertaOffrireOffuscatoOggettoOggiOgnunoOlandeseOlfattoOliatoOlivaOlogrammaOltreOmaggioOmbelicoOmbraOmegaOmissioneOndosoOnereOniceOnnivoroOnorevoleOntaOperatoOpinioneOppostoOracoloOrafoOrdineOrecchinoOreficeOrfanoOrganicoOrigineOrizzonteOrmaOrmeggioOrnativoOrologioOrrendoOrribileOrtensiaOrticaOrzataOrzoOsareOscurareOsmosiOspedaleOspiteOssaOssidareOstacoloOsteOtiteOtreOttagonoOttimoOttobreOvaleOvestOvinoOviparoOvocitoOvunqueOvviareOzioPacchettoPacePacificoPadellaPadronePaesePagaPaginaPalazzinaPalesarePallidoPaloPaludePandoroPannelloPaoloPaonazzoPapricaParabolaParcellaParerePargoloPariParlatoParolaPartireParvenzaParzialePassivoPasticcaPataccaPatologiaPattumePavonePeccatoPedalarePedonalePeggioPelosoPenarePendicePenisolaPennutoPenombraPensarePentolaPepePepitaPerbenePercorsoPerdonatoPerforarePergamenaPeriodoPermessoPernoPerplessoPersuasoPertugioPervasoPesatorePesistaPesoPestiferoPetaloPettinePetulantePezzoPiacerePiantaPiattinoPiccinoPicozzaPiegaPietraPifferoPigiamaPigolioPigroPilaPiliferoPillolaPilotaPimpantePinetaPinnaPinoloPioggiaPiomboPiramidePireticoPiritePirolisiPitonePizzicoPlaceboPlanarePlasmaPlatanoPlenarioPochezzaPoderosoPodismoPoesiaPoggiarePolentaPoligonoPollicePolmonitePolpettaPolsoPoltronaPolverePomicePomodoroPontePopolosoPorfidoPorosoPorporaPorrePortataPosaPositivoPossessoPostulatoPotassioPoterePranzoPrassiPraticaPreclusoPredicaPrefissoPregiatoPrelievoPremerePrenotarePreparatoPresenzaPretestoPrevalsoPrimaPrincipePrivatoProblemaProcuraProdurreProfumoProgettoProlungaPromessaPronomePropostaProrogaProtesoProvaPrudentePrugnaPruritoPsichePubblicoPudicaPugilatoPugnoPulcePulitoPulsantePuntarePupazzoPupillaPuroQuadroQualcosaQuasiQuerelaQuotaRaccoltoRaddoppioRadicaleRadunatoRafficaRagazzoRagioneRagnoRamarroRamingoRamoRandagioRantolareRapatoRapinaRappresoRasaturaRaschiatoRasenteRassegnaRastrelloRataRavvedutoRealeRecepireRecintoReclutaReconditoRecuperoRedditoRedimereRegalatoRegistroRegolaRegressoRelazioneRemareRemotoRennaReplicaReprimereReputareResaResidenteResponsoRestauroReteRetinaRetoricaRettificaRevocatoRiassuntoRibadireRibelleRibrezzoRicaricaRiccoRicevereRiciclatoRicordoRicredutoRidicoloRidurreRifasareRiflessoRiformaRifugioRigareRigettatoRighelloRilassatoRilevatoRimanereRimbalzoRimedioRimorchioRinascitaRincaroRinforzoRinnovoRinomatoRinsavitoRintoccoRinunciaRinvenireRiparatoRipetutoRipienoRiportareRipresaRipulireRisataRischioRiservaRisibileRisoRispettoRistoroRisultatoRisvoltoRitardoRitegnoRitmicoRitrovoRiunioneRivaRiversoRivincitaRivoltoRizomaRobaRoboticoRobustoRocciaRocoRodaggioRodereRoditoreRogitoRollioRomanticoRompereRonzioRosolareRospoRotanteRotondoRotulaRovescioRubizzoRubricaRugaRullinoRumineRumorosoRuoloRupeRussareRusticoSabatoSabbiareSabotatoSagomaSalassoSaldaturaSalgemmaSalivareSalmoneSaloneSaltareSalutoSalvoSapereSapidoSaporitoSaracenoSarcasmoSartoSassosoSatelliteSatiraSatolloSaturnoSavanaSavioSaziatoSbadiglioSbalzoSbancatoSbarraSbattereSbavareSbendareSbirciareSbloccatoSbocciatoSbrinareSbruffoneSbuffareScabrosoScadenzaScalaScambiareScandaloScapolaScarsoScatenareScavatoSceltoScenicoScettroSchedaSchienaSciarpaScienzaScindereScippoSciroppoScivoloSclerareScodellaScolpitoScompartoSconfortoScoprireScortaScossoneScozzeseScribaScrollareScrutinioScuderiaScultoreScuolaScuroScusareSdebitareSdoganareSeccaturaSecondoSedanoSeggiolaSegnalatoSegregatoSeguitoSelciatoSelettivoSellaSelvaggioSemaforoSembrareSemeSeminatoSempreSensoSentireSepoltoSequenzaSerataSerbatoSerenoSerioSerpenteSerraglioServireSestinaSetolaSettimanaSfaceloSfaldareSfamatoSfarzosoSfaticatoSferaSfidaSfilatoSfingeSfocatoSfoderareSfogoSfoltireSforzatoSfrattoSfruttatoSfuggitoSfumareSfusoSgabelloSgarbatoSgonfiareSgorbioSgrassatoSguardoSibiloSiccomeSierraSiglaSignoreSilenzioSillabaSimboloSimpaticoSimulatoSinfoniaSingoloSinistroSinoSintesiSinusoideSiparioSismaSistoleSituatoSlittaSlogaturaSlovenoSmarritoSmemoratoSmentitoSmeraldoSmilzoSmontareSmottatoSmussatoSnellireSnervatoSnodoSobbalzoSobrioSoccorsoSocialeSodaleSoffittoSognoSoldatoSolenneSolidoSollazzoSoloSolubileSolventeSomaticoSommaSondaSonettoSonniferoSopireSoppesoSopraSorgereSorpassoSorrisoSorsoSorteggioSorvolatoSospiroSostaSottileSpadaSpallaSpargereSpatolaSpaventoSpazzolaSpecieSpedireSpegnereSpelaturaSperanzaSpessoreSpettraleSpezzatoSpiaSpigolosoSpillatoSpinosoSpiraleSplendidoSportivoSposoSprangaSprecareSpronatoSpruzzoSpuntinoSquilloSradicareSrotolatoStabileStaccoStaffaStagnareStampatoStantioStarnutoStaseraStatutoSteloSteppaSterzoStilettoStimaStirpeStivaleStizzosoStonatoStoricoStrappoStregatoStriduloStrozzareStruttoStuccareStufoStupendoSubentroSuccosoSudoreSuggeritoSugoSultanoSuonareSuperboSupportoSurgelatoSurrogatoSussurroSuturaSvagareSvedeseSveglioSvelareSvenutoSveziaSviluppoSvistaSvizzeraSvoltaSvuotareTabaccoTabulatoTacciareTaciturnoTaleTalismanoTamponeTanninoTaraTardivoTargatoTariffaTarpareTartarugaTastoTatticoTavernaTavolataTazzaTecaTecnicoTelefonoTemerarioTempoTemutoTendoneTeneroTensioneTentacoloTeoremaTermeTerrazzoTerzettoTesiTesseratoTestatoTetroTettoiaTifareTigellaTimbroTintoTipicoTipografoTiraggioTiroTitanioTitoloTitubanteTizioTizzoneToccareTollerareToltoTombolaTomoTonfoTonsillaTopazioTopologiaToppaTorbaTornareTorroneTortoraToscanoTossireTostaturaTotanoTraboccoTracheaTrafilaTragediaTralcioTramontoTransitoTrapanoTrarreTraslocoTrattatoTraveTrecciaTremolioTrespoloTributoTrichecoTrifoglioTrilloTrinceaTrioTristezzaTrituratoTrivellaTrombaTronoTroppoTrottolaTrovareTruccatoTubaturaTuffatoTulipanoTumultoTunisiaTurbareTurchinoTutaTutelaUbicatoUccelloUccisoreUdireUditivoUffaUfficioUgualeUlisseUltimatoUmanoUmileUmorismoUncinettoUngereUnghereseUnicornoUnificatoUnisonoUnitarioUnteUovoUpupaUraganoUrgenzaUrloUsanzaUsatoUscitoUsignoloUsuraioUtensileUtilizzoUtopiaVacanteVaccinatoVagabondoVagliatoValangaValgoValicoVallettaValorosoValutareValvolaVampataVangareVanitosoVanoVantaggioVanveraVaporeVaranoVarcatoVarianteVascaVedettaVedovaVedutoVegetaleVeicoloVelcroVelinaVellutoVeloceVenatoVendemmiaVentoVeraceVerbaleVergognaVerificaVeroVerrucaVerticaleVescicaVessilloVestaleVeteranoVetrinaVetustoViandanteVibranteVicendaVichingoVicinanzaVidimareVigiliaVignetoVigoreVileVillanoViminiVincitoreViolaViperaVirgolaVirologoVirulentoViscosoVisioneVispoVissutoVisuraVitaVitelloVittimaVivandaVividoViziareVoceVogaVolatileVolereVolpeVoragineVulcanoZampognaZannaZappatoZatteraZavorraZefiroZelanteZeloZenzeroZerbinoZibettoZincoZirconeZittoZollaZoticoZuccheroZufoloZuluZuppa";
  46510. var wordlist = null;
  46511. function loadWords(lang) {
  46512. if (wordlist != null) {
  46513. return;
  46514. }
  46515. wordlist = words.replace(/([A-Z])/g, " $1").toLowerCase().substring(1).split(" ");
  46516. // Verify the computed list matches the official list
  46517. /* istanbul ignore if */
  46518. if (wordlist_1.Wordlist.check(lang) !== "0x5c1362d88fd4cf614a96f3234941d29f7d37c08c5292fde03bf62c2db6ff7620") {
  46519. wordlist = null;
  46520. throw new Error("BIP39 Wordlist for it (Italian) FAILED");
  46521. }
  46522. }
  46523. var LangIt = /** @class */ (function (_super) {
  46524. __extends(LangIt, _super);
  46525. function LangIt() {
  46526. return _super.call(this, "it") || this;
  46527. }
  46528. LangIt.prototype.getWord = function (index) {
  46529. loadWords(this);
  46530. return wordlist[index];
  46531. };
  46532. LangIt.prototype.getWordIndex = function (word) {
  46533. loadWords(this);
  46534. return wordlist.indexOf(word);
  46535. };
  46536. return LangIt;
  46537. }(wordlist_1.Wordlist));
  46538. var langIt = new LangIt();
  46539. exports.langIt = langIt;
  46540. wordlist_1.Wordlist.register(langIt);
  46541. },{"./wordlist":287}],284:[function(_dereq_,module,exports){
  46542. "use strict";
  46543. var __extends = (this && this.__extends) || (function () {
  46544. var extendStatics = function (d, b) {
  46545. extendStatics = Object.setPrototypeOf ||
  46546. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  46547. function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
  46548. return extendStatics(d, b);
  46549. };
  46550. return function (d, b) {
  46551. if (typeof b !== "function" && b !== null)
  46552. throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
  46553. extendStatics(d, b);
  46554. function __() { this.constructor = d; }
  46555. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  46556. };
  46557. })();
  46558. Object.defineProperty(exports, "__esModule", { value: true });
  46559. exports.langJa = void 0;
  46560. var bytes_1 = _dereq_("@ethersproject/bytes");
  46561. var strings_1 = _dereq_("@ethersproject/strings");
  46562. var wordlist_1 = _dereq_("./wordlist");
  46563. var data = [
  46564. // 4-kana words
  46565. "AQRASRAGBAGUAIRAHBAghAURAdBAdcAnoAMEAFBAFCBKFBQRBSFBCXBCDBCHBGFBEQBpBBpQBIkBHNBeOBgFBVCBhBBhNBmOBmRBiHBiFBUFBZDBvFBsXBkFBlcBjYBwDBMBBTBBTRBWBBWXXaQXaRXQWXSRXCFXYBXpHXOQXHRXhRXuRXmXXbRXlXXwDXTRXrCXWQXWGaBWaKcaYgasFadQalmaMBacAKaRKKBKKXKKjKQRKDRKCYKCRKIDKeVKHcKlXKjHKrYNAHNBWNaRNKcNIBNIONmXNsXNdXNnBNMBNRBNrXNWDNWMNFOQABQAHQBrQXBQXFQaRQKXQKDQKOQKFQNBQNDQQgQCXQCDQGBQGDQGdQYXQpBQpQQpHQLXQHuQgBQhBQhCQuFQmXQiDQUFQZDQsFQdRQkHQbRQlOQlmQPDQjDQwXQMBQMDQcFQTBQTHQrDDXQDNFDGBDGQDGRDpFDhFDmXDZXDbRDMYDRdDTRDrXSAhSBCSBrSGQSEQSHBSVRShYShkSyQSuFSiBSdcSoESocSlmSMBSFBSFKSFNSFdSFcCByCaRCKcCSBCSRCCrCGbCEHCYXCpBCpQCIBCIHCeNCgBCgFCVECVcCmkCmwCZXCZFCdRClOClmClFCjDCjdCnXCwBCwXCcRCFQCFjGXhGNhGDEGDMGCDGCHGIFGgBGVXGVEGVRGmXGsXGdYGoSGbRGnXGwXGwDGWRGFNGFLGFOGFdGFkEABEBDEBFEXOEaBEKSENBENDEYXEIgEIkEgBEgQEgHEhFEudEuFEiBEiHEiFEZDEvBEsXEsFEdXEdREkFEbBEbRElFEPCEfkEFNYAEYAhYBNYQdYDXYSRYCEYYoYgQYgRYuRYmCYZTYdBYbEYlXYjQYRbYWRpKXpQopQnpSFpCXpIBpISphNpdBpdRpbRpcZpFBpFNpFDpFopFrLADLBuLXQLXcLaFLCXLEhLpBLpFLHXLeVLhILdHLdRLoDLbRLrXIABIBQIBCIBsIBoIBMIBRIXaIaRIKYIKRINBINuICDIGBIIDIIkIgRIxFIyQIiHIdRIbYIbRIlHIwRIMYIcRIRVITRIFBIFNIFQOABOAFOBQOaFONBONMOQFOSFOCDOGBOEQOpBOLXOIBOIFOgQOgFOyQOycOmXOsXOdIOkHOMEOMkOWWHBNHXNHXWHNXHDuHDRHSuHSRHHoHhkHmRHdRHkQHlcHlRHwBHWcgAEgAggAkgBNgBQgBEgXOgYcgLXgHjgyQgiBgsFgdagMYgWSgFQgFEVBTVXEVKBVKNVKDVKYVKRVNBVNYVDBVDxVSBVSRVCjVGNVLXVIFVhBVhcVsXVdRVbRVlRhBYhKYhDYhGShxWhmNhdahdkhbRhjohMXhTRxAXxXSxKBxNBxEQxeNxeQxhXxsFxdbxlHxjcxFBxFNxFQxFOxFoyNYyYoybcyMYuBQuBRuBruDMuCouHBudQukkuoBulVuMXuFEmCYmCRmpRmeDmiMmjdmTFmFQiADiBOiaRiKRiNBiNRiSFiGkiGFiERipRiLFiIFihYibHijBijEiMXiWBiFBiFCUBQUXFUaRUNDUNcUNRUNFUDBUSHUCDUGBUGFUEqULNULoUIRUeEUeYUgBUhFUuRUiFUsXUdFUkHUbBUjSUjYUwXUMDUcHURdUTBUrBUrXUrQZAFZXZZaRZKFZNBZQFZCXZGBZYdZpBZLDZIFZHXZHNZeQZVRZVFZmXZiBZvFZdFZkFZbHZbFZwXZcCZcRZRBvBQvBGvBLvBWvCovMYsAFsBDsaRsKFsNFsDrsSHsSFsCXsCRsEBsEHsEfspBsLBsLDsIgsIRseGsbRsFBsFQsFSdNBdSRdCVdGHdYDdHcdVbdySduDdsXdlRdwXdWYdWcdWRkBMkXOkaRkNIkNFkSFkCFkYBkpRkeNkgBkhVkmXksFklVkMBkWDkFNoBNoaQoaFoNBoNXoNaoNEoSRoEroYXoYCoYbopRopFomXojkowXorFbBEbEIbdBbjYlaRlDElMXlFDjKjjSRjGBjYBjYkjpRjLXjIBjOFjeVjbRjwBnXQnSHnpFnLXnINnMBnTRwXBwXNwXYwNFwQFwSBwGFwLXwLDweNwgBwuHwjDwnXMBXMpFMIBMeNMTHcaQcNBcDHcSFcCXcpBcLXcLDcgFcuFcnXcwXccDcTQcrFTQErXNrCHrpFrgFrbFrTHrFcWNYWNbWEHWMXWTR",
  46566. // 5-kana words
  46567. "ABGHABIJAEAVAYJQALZJAIaRAHNXAHdcAHbRAZJMAZJRAZTRAdVJAklmAbcNAjdRAMnRAMWYAWpRAWgRAFgBAFhBAFdcBNJBBNJDBQKBBQhcBQlmBDEJBYJkBYJTBpNBBpJFBIJBBIJDBIcABOKXBOEJBOVJBOiJBOZJBepBBeLXBeIFBegBBgGJBVJXBuocBiJRBUJQBlXVBlITBwNFBMYVBcqXBTlmBWNFBWiJBWnRBFGHBFwXXKGJXNJBXNZJXDTTXSHSXSVRXSlHXCJDXGQJXEhXXYQJXYbRXOfXXeNcXVJFXhQJXhEJXdTRXjdXXMhBXcQTXRGBXTEBXTnQXFCXXFOFXFgFaBaFaBNJaBCJaBpBaBwXaNJKaNJDaQIBaDpRaEPDaHMFamDJalEJaMZJaFaFaFNBaFQJaFLDaFVHKBCYKBEBKBHDKXaFKXGdKXEJKXpHKXIBKXZDKXwXKKwLKNacKNYJKNJoKNWcKDGdKDTRKChXKGaRKGhBKGbRKEBTKEaRKEPTKLMDKLWRKOHDKVJcKdBcKlIBKlOPKFSBKFEPKFpFNBNJNJBQNBGHNBEPNBHXNBgFNBVXNBZDNBsXNBwXNNaRNNJDNNJENNJkNDCJNDVDNGJRNJiDNZJNNsCJNJFNNFSBNFCXNFEPNFLXNFIFQJBFQCaRQJEQQLJDQLJFQIaRQOqXQHaFQHHQQVJXQVJDQhNJQmEIQZJFQsJXQJrFQWbRDJABDBYJDXNFDXCXDXLXDXZDDXsJDQqXDSJFDJCXDEPkDEqXDYmQDpSJDOCkDOGQDHEIDVJDDuDuDWEBDJFgSBNDSBSFSBGHSBIBSBTQSKVYSJQNSJQiSJCXSEqXSJYVSIiJSOMYSHAHSHaQSeCFSepQSegBSHdHSHrFShSJSJuHSJUFSkNRSrSrSWEBSFaHSJFQSFCXSFGDSFYXSFODSFgBSFVXSFhBSFxFSFkFSFbBSFMFCADdCJXBCXaFCXKFCXNFCXCXCXGBCXEJCXYBCXLDCXIBCXOPCXHXCXgBCXhBCXiBCXlDCXcHCJNBCJNFCDCJCDGBCDVXCDhBCDiDCDJdCCmNCpJFCIaRCOqXCHCHCHZJCViJCuCuCmddCJiFCdNBCdHhClEJCnUJCreSCWlgCWTRCFBFCFNBCFYBCFVFCFhFCFdSCFTBCFWDGBNBGBQFGJBCGBEqGBpBGBgQGNBEGNJYGNkOGNJRGDUFGJpQGHaBGJeNGJeEGVBlGVKjGiJDGvJHGsVJGkEBGMIJGWjNGFBFGFCXGFGBGFYXGFpBGFMFEASJEAWpEJNFECJVEIXSEIQJEOqXEOcFEeNcEHEJEHlFEJgFEhlmEmDJEmZJEiMBEUqXEoSREPBFEPXFEPKFEPSFEPEFEPpFEPLXEPIBEJPdEPcFEPTBEJnXEqlHEMpREFCXEFODEFcFYASJYJAFYBaBYBVXYXpFYDhBYCJBYJGFYYbRYeNcYJeVYiIJYZJcYvJgYvJRYJsXYsJFYMYMYreVpBNHpBEJpBwXpQxFpYEJpeNDpJeDpeSFpeCHpHUJpHbBpHcHpmUJpiiJpUJrpsJuplITpFaBpFQqpFGBpFEfpFYBpFpBpFLJpFIDpFgBpFVXpFyQpFuFpFlFpFjDpFnXpFwXpJFMpFTBLXCJLXEFLXhFLXUJLXbFLalmLNJBLSJQLCLCLGJBLLDJLHaFLeNFLeSHLeCXLepFLhaRLZsJLsJDLsJrLocaLlLlLMdbLFNBLFSBLFEHLFkFIBBFIBXFIBaQIBKXIBSFIBpHIBLXIBgBIBhBIBuHIBmXIBiFIBZXIBvFIBbFIBjQIBwXIBWFIKTRIQUJIDGFICjQIYSRIINXIJeCIVaRImEkIZJFIvJRIsJXIdCJIJoRIbBQIjYBIcqXITFVIreVIFKFIFSFIFCJIFGFIFLDIFIBIJFOIFgBIFVXIJFhIFxFIFmXIFdHIFbBIJFrIJFWOBGBOQfXOOKjOUqXOfXBOqXEOcqXORVJOFIBOFlDHBIOHXiFHNTRHCJXHIaRHHJDHHEJHVbRHZJYHbIBHRsJHRkDHWlmgBKFgBSBgBCDgBGHgBpBgBIBgBVJgBuBgBvFgKDTgQVXgDUJgGSJgOqXgmUMgZIJgTUJgWIEgFBFgFNBgFDJgFSFgFGBgFYXgJFOgFgQgFVXgFhBgFbHgJFWVJABVQKcVDgFVOfXVeDFVhaRVmGdViJYVMaRVFNHhBNDhBCXhBEqhBpFhBLXhNJBhSJRheVXhhKEhxlmhZIJhdBQhkIJhbMNhMUJhMZJxNJgxQUJxDEkxDdFxSJRxplmxeSBxeCXxeGFxeYXxepQxegBxWVcxFEQxFLXxFIBxFgBxFxDxFZtxFdcxFbBxFwXyDJXyDlcuASJuDJpuDIBuCpJuGSJuIJFueEFuZIJusJXudWEuoIBuWGJuFBcuFKEuFNFuFQFuFDJuFGJuFVJuFUtuFdHuFTBmBYJmNJYmQhkmLJDmLJomIdXmiJYmvJRmsJRmklmmMBymMuCmclmmcnQiJABiJBNiJBDiBSFiBCJiBEFiBYBiBpFiBLXiBTHiJNciDEfiCZJiECJiJEqiOkHiHKFieNDiHJQieQcieDHieSFieCXieGFieEFieIHiegFihUJixNoioNXiFaBiFKFiFNDiFEPiFYXitFOitFHiFgBiFVEiFmXiFitiFbBiFMFiFrFUCXQUIoQUIJcUHQJUeCEUHwXUUJDUUqXUdWcUcqXUrnQUFNDUFSHUFCFUFEfUFLXUtFOZBXOZXSBZXpFZXVXZEQJZEJkZpDJZOqXZeNHZeCDZUqXZFBQZFEHZFLXvBAFvBKFvBCXvBEPvBpHvBIDvBgFvBuHvQNJvFNFvFGBvFIBvJFcsXCDsXLXsXsXsXlFsXcHsQqXsJQFsEqXseIFsFEHsFjDdBxOdNpRdNJRdEJbdpJRdhZJdnSJdrjNdFNJdFQHdFhNkNJDkYaRkHNRkHSRkVbRkuMRkjSJkcqDoSJFoEiJoYZJoOfXohEBoMGQocqXbBAFbBXFbBaFbBNDbBGBbBLXbBTBbBWDbGJYbIJHbFQqbFpQlDgQlOrFlVJRjGEBjZJRnXvJnXbBnEfHnOPDngJRnxfXnUJWwXEJwNpJwDpBwEfXwrEBMDCJMDGHMDIJMLJDcQGDcQpHcqXccqNFcqCXcFCJRBSBRBGBRBEJRBpQTBNFTBQJTBpBTBVXTFABTFSBTFCFTFGBTFMDrXCJrXLDrDNJrEfHrFQJrFitWNjdWNTR",
  46568. // 6-kana words
  46569. "AKLJMANOPFASNJIAEJWXAYJNRAIIbRAIcdaAeEfDAgidRAdjNYAMYEJAMIbRAFNJBAFpJFBBIJYBDZJFBSiJhBGdEBBEJfXBEJqXBEJWRBpaUJBLXrXBIYJMBOcfXBeEfFBestXBjNJRBcDJOBFEqXXNvJRXDMBhXCJNYXOAWpXONJWXHDEBXeIaRXhYJDXZJSJXMDJOXcASJXFVJXaBQqXaBZJFasXdQaFSJQaFEfXaFpJHaFOqXKBNSRKXvJBKQJhXKEJQJKEJGFKINJBKIJjNKgJNSKVElmKVhEBKiJGFKlBgJKjnUJKwsJYKMFIJKFNJDKFIJFKFOfXNJBSFNJBCXNBpJFNJBvQNJBMBNJLJXNJOqXNJeCXNJeGFNdsJCNbTKFNwXUJQNFEPQDiJcQDMSJQSFpBQGMQJQJeOcQyCJEQUJEBQJFBrQFEJqDXDJFDJXpBDJXIMDGiJhDIJGRDJeYcDHrDJDVXgFDkAWpDkIgRDjDEqDMvJRDJFNFDJFIBSKclmSJQOFSJQVHSJQjDSJGJBSJGJFSECJoSHEJqSJHTBSJVJDSViJYSZJNBSJsJDSFSJFSFEfXSJFLXCBUJVCJXSBCJXpBCXVJXCJXsXCJXdFCJNJHCLIJgCHiJFCVNJMChCJhCUHEJCsJTRCJdYcCoQJCCFEfXCFIJgCFUJxCFstFGJBaQGJBIDGQJqXGYJNRGJHKFGeQqDGHEJFGJeLXGHIiJGHdBlGUJEBGkIJTGFQPDGJFEqEAGegEJIJBEJVJXEhQJTEiJNcEJZJFEJoEqEjDEqEPDsXEPGJBEPOqXEPeQFEfDiDEJfEFEfepQEfMiJEqXNBEqDIDEqeSFEqVJXEMvJRYXNJDYXEJHYKVJcYYJEBYJeEcYJUqXYFpJFYFstXpAZJMpBSJFpNBNFpeQPDpHLJDpHIJFpHgJFpeitFpHZJFpJFADpFSJFpJFCJpFOqXpFitBpJFZJLXIJFLIJgRLVNJWLVHJMLwNpJLFGJBLFLJDLFOqXLJFUJIBDJXIBGJBIJBYQIJBIBIBOqXIBcqDIEGJFILNJTIIJEBIOiJhIJeNBIJeIBIhiJIIWoTRIJFAHIJFpBIJFuHIFUtFIJFTHOSBYJOEcqXOHEJqOvBpFOkVJrObBVJOncqDOcNJkHhNJRHuHJuHdMhBgBUqXgBsJXgONJBgHNJDgHHJQgJeitgHsJXgJyNagyDJBgZJDrgsVJQgkEJNgkjSJgJFAHgFCJDgFZtMVJXNFVXQfXVJXDJVXoQJVQVJQVDEfXVDvJHVEqNFVeQfXVHpJFVHxfXVVJSRVVmaRVlIJOhCXVJhHjYkhxCJVhWVUJhWiJcxBNJIxeEqDxfXBFxcFEPxFSJFxFYJXyBDQJydaUJyFOPDuYCJYuLvJRuHLJXuZJLDuFOPDuFZJHuFcqXmKHJdmCQJcmOsVJiJAGFitLCFieOfXiestXiZJMEikNJQirXzFiFQqXiFIJFiFZJFiFvtFUHpJFUteIcUteOcUVCJkUhdHcUbEJEUJqXQUMNJhURjYkUFitFZDGJHZJIxDZJVJXZJFDJZJFpQvBNJBvBSJFvJxBrseQqDsVFVJdFLJDkEJNBkmNJYkFLJDoQJOPoGsJRoEAHBoEJfFbBQqDbBZJHbFVJXlFIJBjYIrXjeitcjjCEBjWMNBwXQfXwXOaFwDsJXwCJTRwrCZJMDNJQcDDJFcqDOPRYiJFTBsJXTQIJBTFEfXTFLJDrXEJFrEJXMrFZJFWEJdEWYTlm",
  46570. // 7-kana words
  46571. "ABCDEFACNJTRAMBDJdAcNJVXBLNJEBXSIdWRXErNJkXYDJMBXZJCJaXMNJaYKKVJKcKDEJqXKDcNJhKVJrNYKbgJVXKFVJSBNBYBwDNJeQfXNJeEqXNhGJWENJFiJRQlIJbEQJfXxDQqXcfXQFNDEJQFwXUJDYcnUJDJIBgQDIUJTRDJFEqDSJQSJFSJQIJFSOPeZtSJFZJHCJXQfXCTDEqFGJBSJFGJBOfXGJBcqXGJHNJDGJRLiJEJfXEqEJFEJPEFpBEJYJBZJFYBwXUJYiJMEBYJZJyTYTONJXpQMFXFpeGIDdpJFstXpJFcPDLBVSJRLHQJqXLJFZJFIJBNJDIJBUqXIBkFDJIJEJPTIYJGWRIJeQPDIJeEfHIJFsJXOqGDSFHXEJqXgJCsJCgGQJqXgdQYJEgFMFNBgJFcqDVJwXUJVJFZJchIgJCCxOEJqXxOwXUJyDJBVRuscisciJBiJBieUtqXiJFDJkiFsJXQUGEZJcUJFsJXZtXIrXZDZJDrZJFNJDZJFstXvJFQqXvJFCJEsJXQJqkhkNGBbDJdTRbYJMEBlDwXUJMEFiJFcfXNJDRcNJWMTBLJXC",
  46572. // 8-kana words
  46573. "BraFUtHBFSJFdbNBLJXVJQoYJNEBSJBEJfHSJHwXUJCJdAZJMGjaFVJXEJPNJBlEJfFiJFpFbFEJqIJBVJCrIBdHiJhOPFChvJVJZJNJWxGFNIFLueIBQJqUHEJfUFstOZJDrlXEASJRlXVJXSFwVJNJWD",
  46574. // 9-kana words
  46575. "QJEJNNJDQJEJIBSFQJEJxegBQJEJfHEPSJBmXEJFSJCDEJqXLXNJFQqXIcQsFNJFIFEJqXUJgFsJXIJBUJEJfHNFvJxEqXNJnXUJFQqD",
  46576. // 10-kana words
  46577. "IJBEJqXZJ"
  46578. ];
  46579. // Maps each character into its kana value (the index)
  46580. var mapping = "~~AzB~X~a~KN~Q~D~S~C~G~E~Y~p~L~I~O~eH~g~V~hxyumi~~U~~Z~~v~~s~~dkoblPjfnqwMcRTr~W~~~F~~~~~Jt";
  46581. var wordlist = null;
  46582. function hex(word) {
  46583. return (0, bytes_1.hexlify)((0, strings_1.toUtf8Bytes)(word));
  46584. }
  46585. var KiYoKu = "0xe3818de38284e3818f";
  46586. var KyoKu = "0xe3818de38283e3818f";
  46587. function loadWords(lang) {
  46588. if (wordlist !== null) {
  46589. return;
  46590. }
  46591. wordlist = [];
  46592. // Transforms for normalizing (sort is a not quite UTF-8)
  46593. var transform = {};
  46594. // Delete the diacritic marks
  46595. transform[(0, strings_1.toUtf8String)([227, 130, 154])] = false;
  46596. transform[(0, strings_1.toUtf8String)([227, 130, 153])] = false;
  46597. // Some simple transforms that sort out most of the order
  46598. transform[(0, strings_1.toUtf8String)([227, 130, 133])] = (0, strings_1.toUtf8String)([227, 130, 134]);
  46599. transform[(0, strings_1.toUtf8String)([227, 129, 163])] = (0, strings_1.toUtf8String)([227, 129, 164]);
  46600. transform[(0, strings_1.toUtf8String)([227, 130, 131])] = (0, strings_1.toUtf8String)([227, 130, 132]);
  46601. transform[(0, strings_1.toUtf8String)([227, 130, 135])] = (0, strings_1.toUtf8String)([227, 130, 136]);
  46602. // Normalize words using the transform
  46603. function normalize(word) {
  46604. var result = "";
  46605. for (var i = 0; i < word.length; i++) {
  46606. var kana = word[i];
  46607. var target = transform[kana];
  46608. if (target === false) {
  46609. continue;
  46610. }
  46611. if (target) {
  46612. kana = target;
  46613. }
  46614. result += kana;
  46615. }
  46616. return result;
  46617. }
  46618. // Sort how the Japanese list is sorted
  46619. function sortJapanese(a, b) {
  46620. a = normalize(a);
  46621. b = normalize(b);
  46622. if (a < b) {
  46623. return -1;
  46624. }
  46625. if (a > b) {
  46626. return 1;
  46627. }
  46628. return 0;
  46629. }
  46630. // Load all the words
  46631. for (var length_1 = 3; length_1 <= 9; length_1++) {
  46632. var d = data[length_1 - 3];
  46633. for (var offset = 0; offset < d.length; offset += length_1) {
  46634. var word = [];
  46635. for (var i = 0; i < length_1; i++) {
  46636. var k = mapping.indexOf(d[offset + i]);
  46637. word.push(227);
  46638. word.push((k & 0x40) ? 130 : 129);
  46639. word.push((k & 0x3f) + 128);
  46640. }
  46641. wordlist.push((0, strings_1.toUtf8String)(word));
  46642. }
  46643. }
  46644. wordlist.sort(sortJapanese);
  46645. // For some reason kyoku and kiyoku are flipped in node (!!).
  46646. // The order SHOULD be:
  46647. // - kyoku
  46648. // - kiyoku
  46649. // This should ignore "if", but that doesn't work here??
  46650. /* istanbul ignore next */
  46651. if (hex(wordlist[442]) === KiYoKu && hex(wordlist[443]) === KyoKu) {
  46652. var tmp = wordlist[442];
  46653. wordlist[442] = wordlist[443];
  46654. wordlist[443] = tmp;
  46655. }
  46656. // Verify the computed list matches the official list
  46657. /* istanbul ignore if */
  46658. if (wordlist_1.Wordlist.check(lang) !== "0xcb36b09e6baa935787fd762ce65e80b0c6a8dabdfbc3a7f86ac0e2c4fd111600") {
  46659. wordlist = null;
  46660. throw new Error("BIP39 Wordlist for ja (Japanese) FAILED");
  46661. }
  46662. }
  46663. var LangJa = /** @class */ (function (_super) {
  46664. __extends(LangJa, _super);
  46665. function LangJa() {
  46666. return _super.call(this, "ja") || this;
  46667. }
  46668. LangJa.prototype.getWord = function (index) {
  46669. loadWords(this);
  46670. return wordlist[index];
  46671. };
  46672. LangJa.prototype.getWordIndex = function (word) {
  46673. loadWords(this);
  46674. return wordlist.indexOf(word);
  46675. };
  46676. LangJa.prototype.split = function (mnemonic) {
  46677. wordlist_1.logger.checkNormalize();
  46678. return mnemonic.split(/(?:\u3000| )+/g);
  46679. };
  46680. LangJa.prototype.join = function (words) {
  46681. return words.join("\u3000");
  46682. };
  46683. return LangJa;
  46684. }(wordlist_1.Wordlist));
  46685. var langJa = new LangJa();
  46686. exports.langJa = langJa;
  46687. wordlist_1.Wordlist.register(langJa);
  46688. },{"./wordlist":287,"@ethersproject/bytes":199,"@ethersproject/strings":266}],285:[function(_dereq_,module,exports){
  46689. "use strict";
  46690. var __extends = (this && this.__extends) || (function () {
  46691. var extendStatics = function (d, b) {
  46692. extendStatics = Object.setPrototypeOf ||
  46693. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  46694. function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
  46695. return extendStatics(d, b);
  46696. };
  46697. return function (d, b) {
  46698. if (typeof b !== "function" && b !== null)
  46699. throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
  46700. extendStatics(d, b);
  46701. function __() { this.constructor = d; }
  46702. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  46703. };
  46704. })();
  46705. Object.defineProperty(exports, "__esModule", { value: true });
  46706. exports.langKo = void 0;
  46707. var strings_1 = _dereq_("@ethersproject/strings");
  46708. var wordlist_1 = _dereq_("./wordlist");
  46709. var data = [
  46710. "OYAa",
  46711. "ATAZoATBl3ATCTrATCl8ATDloATGg3ATHT8ATJT8ATJl3ATLlvATLn4ATMT8ATMX8ATMboATMgoAToLbAToMTATrHgATvHnAT3AnAT3JbAT3MTAT8DbAT8JTAT8LmAT8MYAT8MbAT#LnAUHT8AUHZvAUJXrAUJX8AULnrAXJnvAXLUoAXLgvAXMn6AXRg3AXrMbAX3JTAX3QbAYLn3AZLgvAZrSUAZvAcAZ8AaAZ8AbAZ8AnAZ8HnAZ8LgAZ8MYAZ8MgAZ8OnAaAboAaDTrAaFTrAaJTrAaJboAaLVoAaMXvAaOl8AaSeoAbAUoAbAg8AbAl4AbGnrAbMT8AbMXrAbMn4AbQb8AbSV8AbvRlAb8AUAb8AnAb8HgAb8JTAb8NTAb8RbAcGboAcLnvAcMT8AcMX8AcSToAcrAaAcrFnAc8AbAc8MgAfGgrAfHboAfJnvAfLV8AfLkoAfMT8AfMnoAfQb8AfScrAfSgrAgAZ8AgFl3AgGX8AgHZvAgHgrAgJXoAgJX8AgJboAgLZoAgLn4AgOX8AgoATAgoAnAgoCUAgoJgAgoLXAgoMYAgoSeAgrDUAgrJTAhrFnAhrLjAhrQgAjAgoAjJnrAkMX8AkOnoAlCTvAlCV8AlClvAlFg4AlFl6AlFn3AloSnAlrAXAlrAfAlrFUAlrFbAlrGgAlrOXAlvKnAlvMTAl3AbAl3MnAnATrAnAcrAnCZ3AnCl8AnDg8AnFboAnFl3AnHX4AnHbrAnHgrAnIl3AnJgvAnLXoAnLX4AnLbrAnLgrAnLhrAnMXoAnMgrAnOn3AnSbrAnSeoAnvLnAn3OnCTGgvCTSlvCTvAUCTvKnCTvNTCT3CZCT3GUCT3MTCT8HnCUCZrCULf8CULnvCU3HnCU3JUCY6NUCbDb8CbFZoCbLnrCboOTCboScCbrFnCbvLnCb8AgCb8HgCb$LnCkLfoClBn3CloDUDTHT8DTLl3DTSU8DTrAaDTrLXDTrLjDTrOYDTrOgDTvFXDTvFnDT3HUDT3LfDUCT9DUDT4DUFVoDUFV8DUFkoDUGgrDUJnrDULl8DUMT8DUMXrDUMX4DUMg8DUOUoDUOgvDUOg8DUSToDUSZ8DbDXoDbDgoDbGT8DbJn3DbLg3DbLn4DbMXrDbMg8DbOToDboJXGTClvGTDT8GTFZrGTLVoGTLlvGTLl3GTMg8GTOTvGTSlrGToCUGTrDgGTrJYGTrScGTtLnGTvAnGTvQgGUCZrGUDTvGUFZoGUHXrGULnvGUMT8GUoMgGXoLnGXrMXGXrMnGXvFnGYLnvGZOnvGZvOnGZ8LaGZ8LmGbAl3GbDYvGbDlrGbHX3GbJl4GbLV8GbLn3GbMn4GboJTGboRfGbvFUGb3GUGb4JnGgDX3GgFl$GgJlrGgLX6GgLZoGgLf8GgOXoGgrAgGgrJXGgrMYGgrScGgvATGgvOYGnAgoGnJgvGnLZoGnLg3GnLnrGnQn8GnSbrGnrMgHTClvHTDToHTFT3HTQT8HToJTHToJgHTrDUHTrMnHTvFYHTvRfHT8MnHT8SUHUAZ8HUBb4HUDTvHUoMYHXFl6HXJX6HXQlrHXrAUHXrMnHXrSbHXvFYHXvKXHX3LjHX3MeHYvQlHZrScHZvDbHbAcrHbFT3HbFl3HbJT8HbLTrHbMT8HbMXrHbMbrHbQb8HbSX3HboDbHboJTHbrFUHbrHgHbrJTHb8JTHb8MnHb8QgHgAlrHgDT3HgGgrHgHgrHgJTrHgJT8HgLX@HgLnrHgMT8HgMX8HgMboHgOnrHgQToHgRg3HgoHgHgrCbHgrFnHgrLVHgvAcHgvAfHnAloHnCTrHnCnvHnGTrHnGZ8HnGnvHnJT8HnLf8HnLkvHnMg8HnRTrITvFUITvFnJTAXrJTCV8JTFT3JTFT8JTFn4JTGgvJTHT8JTJT8JTJXvJTJl3JTJnvJTLX4JTLf8JTLhvJTMT8JTMXrJTMnrJTObrJTQT8JTSlvJT8DUJT8FkJT8MTJT8OXJT8OgJT8QUJT8RfJUHZoJXFT4JXFlrJXGZ8JXGnrJXLV8JXLgvJXMXoJXMX3JXNboJXPlvJXoJTJXoLkJXrAXJXrHUJXrJgJXvJTJXvOnJX4KnJYAl3JYJT8JYLhvJYQToJYrQXJY6NUJbAl3JbCZrJbDloJbGT8JbGgrJbJXvJbJboJbLf8JbLhrJbLl3JbMnvJbRg8JbSZ8JboDbJbrCZJbrSUJb3KnJb8LnJfRn8JgAXrJgCZrJgDTrJgGZrJgGZ8JgHToJgJT8JgJXoJgJgvJgLX4JgLZ3JgLZ8JgLn4JgMgrJgMn4JgOgvJgPX6JgRnvJgSToJgoCZJgoJbJgoMYJgrJXJgrJgJgrLjJg6MTJlCn3JlGgvJlJl8Jl4AnJl8FnJl8HgJnAToJnATrJnAbvJnDUoJnGnrJnJXrJnJXvJnLhvJnLnrJnLnvJnMToJnMT8JnMXvJnMX3JnMg8JnMlrJnMn4JnOX8JnST4JnSX3JnoAgJnoAnJnoJTJnoObJnrAbJnrAkJnrHnJnrJTJnrJYJnrOYJnrScJnvCUJnvFaJnvJgJnvJnJnvOYJnvQUJnvRUJn3FnJn3JTKnFl3KnLT6LTDlvLTMnoLTOn3LTRl3LTSb4LTSlrLToAnLToJgLTrAULTrAcLTrCULTrHgLTrMgLT3JnLULnrLUMX8LUoJgLVATrLVDTrLVLb8LVoJgLV8MgLV8RTLXDg3LXFlrLXrCnLXrLXLX3GTLX4GgLX4OYLZAXrLZAcrLZAgrLZAhrLZDXyLZDlrLZFbrLZFl3LZJX6LZJX8LZLc8LZLnrLZSU8LZoJTLZoJnLZrAgLZrAnLZrJYLZrLULZrMgLZrSkLZvAnLZvGULZvJeLZvOTLZ3FZLZ4JXLZ8STLZ8ScLaAT3LaAl3LaHT8LaJTrLaJT8LaJXrLaJgvLaJl4LaLVoLaMXrLaMXvLaMX8LbClvLbFToLbHlrLbJn4LbLZ3LbLhvLbMXrLbMnoLbvSULcLnrLc8HnLc8MTLdrMnLeAgoLeOgvLeOn3LfAl3LfLnvLfMl3LfOX8Lf8AnLf8JXLf8LXLgJTrLgJXrLgJl8LgMX8LgRZrLhCToLhrAbLhrFULhrJXLhvJYLjHTrLjHX4LjJX8LjLhrLjSX3LjSZ4LkFX4LkGZ8LkGgvLkJTrLkMXoLkSToLkSU8LkSZ8LkoOYLl3FfLl3MgLmAZrLmCbrLmGgrLmHboLmJnoLmJn3LmLfoLmLhrLmSToLnAX6LnAb6LnCZ3LnCb3LnDTvLnDb8LnFl3LnGnrLnHZvLnHgvLnITvLnJT8LnJX8LnJlvLnLf8LnLg6LnLhvLnLnoLnMXrLnMg8LnQlvLnSbrLnrAgLnrAnLnrDbLnrFkLnrJdLnrMULnrOYLnrSTLnvAnLnvDULnvHgLnvOYLnvOnLn3GgLn4DULn4JTLn4JnMTAZoMTAloMTDb8MTFT8MTJnoMTJnrMTLZrMTLhrMTLkvMTMX8MTRTrMToATMTrDnMTrOnMT3JnMT4MnMT8FUMT8FaMT8FlMT8GTMT8GbMT8GnMT8HnMT8JTMT8JbMT8OTMUCl8MUJTrMUJU8MUMX8MURTrMUSToMXAX6MXAb6MXCZoMXFXrMXHXrMXLgvMXOgoMXrAUMXrAnMXrHgMXrJYMXrJnMXrMTMXrMgMXrOYMXrSZMXrSgMXvDUMXvOTMX3JgMX3OTMX4JnMX8DbMX8FnMX8HbMX8HgMX8HnMX8LbMX8MnMX8OnMYAb8MYGboMYHTvMYHX4MYLTrMYLnvMYMToMYOgvMYRg3MYSTrMbAToMbAXrMbAl3MbAn8MbGZ8MbJT8MbJXrMbMXvMbMX8MbMnoMbrMUMb8AfMb8FbMb8FkMcJXoMeLnrMgFl3MgGTvMgGXoMgGgrMgGnrMgHT8MgHZrMgJnoMgLnrMgLnvMgMT8MgQUoMgrHnMgvAnMg8HgMg8JYMg8LfMloJnMl8ATMl8AXMl8JYMnAToMnAT4MnAZ8MnAl3MnAl4MnCl8MnHT8MnHg8MnJnoMnLZoMnLhrMnMXoMnMX3MnMnrMnOgvMnrFbMnrFfMnrFnMnrNTMnvJXNTMl8OTCT3OTFV8OTFn3OTHZvOTJXrOTOl3OT3ATOT3JUOT3LZOT3LeOT3MbOT8ATOT8AbOT8AgOT8MbOUCXvOUMX3OXHXvOXLl3OXrMUOXvDbOX6NUOX8JbOYFZoOYLbrOYLkoOYMg8OYSX3ObHTrObHT4ObJgrObLhrObMX3ObOX8Ob8FnOeAlrOeJT8OeJXrOeJnrOeLToOeMb8OgJXoOgLXoOgMnrOgOXrOgOloOgoAgOgoJbOgoMYOgoSTOg8AbOjLX4OjMnoOjSV8OnLVoOnrAgOn3DUPXQlrPXvFXPbvFTPdAT3PlFn3PnvFbQTLn4QToAgQToMTQULV8QURg8QUoJnQXCXvQbFbrQb8AaQb8AcQb8FbQb8MYQb8ScQeAlrQeLhrQjAn3QlFXoQloJgQloSnRTLnvRTrGURTrJTRUJZrRUoJlRUrQnRZrLmRZrMnRZrSnRZ8ATRZ8JbRZ8ScRbMT8RbST3RfGZrRfMX8RfMgrRfSZrRnAbrRnGT8RnvJgRnvLfRnvMTRn8AaSTClvSTJgrSTOXrSTRg3STRnvSToAcSToAfSToAnSToHnSToLjSToMTSTrAaSTrEUST3BYST8AgST8LmSUAZvSUAgrSUDT4SUDT8SUGgvSUJXoSUJXvSULTrSU8JTSU8LjSV8AnSV8JgSXFToSXLf8SYvAnSZrDUSZrMUSZrMnSZ8HgSZ8JTSZ8JgSZ8MYSZ8QUSaQUoSbCT3SbHToSbQYvSbSl4SboJnSbvFbSb8HbSb8JgSb8OTScGZrScHgrScJTvScMT8ScSToScoHbScrMTScvAnSeAZrSeAcrSeHboSeJUoSeLhrSeMT8SeMXrSe6JgSgHTrSkJnoSkLnvSk8CUSlFl3SlrSnSl8GnSmAboSmGT8SmJU8",
  46712. "ATLnDlATrAZoATrJX4ATrMT8ATrMX4ATrRTrATvDl8ATvJUoATvMl8AT3AToAT3MX8AT8CT3AT8DT8AT8HZrAT8HgoAUAgFnAUCTFnAXoMX8AXrAT8AXrGgvAXrJXvAXrOgoAXvLl3AZvAgoAZvFbrAZvJXoAZvJl8AZvJn3AZvMX8AZvSbrAZ8FZoAZ8LZ8AZ8MU8AZ8OTvAZ8SV8AZ8SX3AbAgFZAboJnoAbvGboAb8ATrAb8AZoAb8AgrAb8Al4Ab8Db8Ab8JnoAb8LX4Ab8LZrAb8LhrAb8MT8Ab8OUoAb8Qb8Ab8ST8AcrAUoAcrAc8AcrCZ3AcrFT3AcrFZrAcrJl4AcrJn3AcrMX3AcrOTvAc8AZ8Ac8MT8AfAcJXAgoFn4AgoGgvAgoGnrAgoLc8AgoMXoAgrLnrAkrSZ8AlFXCTAloHboAlrHbrAlrLhrAlrLkoAl3CZrAl3LUoAl3LZrAnrAl4AnrMT8An3HT4BT3IToBX4MnvBb!Ln$CTGXMnCToLZ4CTrHT8CT3JTrCT3RZrCT#GTvCU6GgvCU8Db8CU8GZrCU8HT8CboLl3CbrGgrCbrMU8Cb8DT3Cb8GnrCb8LX4Cb8MT8Cb8ObrCgrGgvCgrKX4Cl8FZoDTrAbvDTrDboDTrGT6DTrJgrDTrMX3DTrRZrDTrRg8DTvAVvDTvFZoDT3DT8DT3Ln3DT4HZrDT4MT8DT8AlrDT8MT8DUAkGbDUDbJnDYLnQlDbDUOYDbMTAnDbMXSnDboAT3DboFn4DboLnvDj6JTrGTCgFTGTGgFnGTJTMnGTLnPlGToJT8GTrCT3GTrLVoGTrLnvGTrMX3GTrMboGTvKl3GZClFnGZrDT3GZ8DTrGZ8FZ8GZ8MXvGZ8On8GZ8ST3GbCnQXGbMbFnGboFboGboJg3GboMXoGb3JTvGb3JboGb3Mn6Gb3Qb8GgDXLjGgMnAUGgrDloGgrHX4GgrSToGgvAXrGgvAZvGgvFbrGgvLl3GgvMnvGnDnLXGnrATrGnrMboGnuLl3HTATMnHTAgCnHTCTCTHTrGTvHTrHTvHTrJX8HTrLl8HTrMT8HTrMgoHTrOTrHTuOn3HTvAZrHTvDTvHTvGboHTvJU8HTvLl3HTvMXrHTvQb4HT4GT6HT4JT8HT4Jb#HT8Al3HT8GZrHT8GgrHT8HX4HT8Jb8HT8JnoHT8LTrHT8LgvHT8SToHT8SV8HUoJUoHUoJX8HUoLnrHXrLZoHXvAl3HX3LnrHX4FkvHX4LhrHX4MXoHX4OnoHZrAZ8HZrDb8HZrGZ8HZrJnrHZvGZ8HZvLnvHZ8JnvHZ8LhrHbCXJlHbMTAnHboJl4HbpLl3HbrJX8HbrLnrHbrMnvHbvRYrHgoSTrHgrFV8HgrGZ8HgrJXoHgrRnvHgvBb!HgvGTrHgvHX4HgvHn!HgvLTrHgvSU8HnDnLbHnFbJbHnvDn8Hn6GgvHn!BTvJTCTLnJTQgFnJTrAnvJTrLX4JTrOUoJTvFn3JTvLnrJTvNToJT3AgoJT3Jn4JT3LhvJT3ObrJT8AcrJT8Al3JT8JT8JT8JnoJT8LX4JT8LnrJT8MX3JT8Rg3JT8Sc8JUoBTvJU8AToJU8GZ8JU8GgvJU8JTrJU8JXrJU8JnrJU8LnvJU8ScvJXHnJlJXrGgvJXrJU8JXrLhrJXrMT8JXrMXrJXrQUoJXvCTvJXvGZ8JXvGgrJXvQT8JX8Ab8JX8DT8JX8GZ8JX8HZvJX8LnrJX8MT8JX8MXoJX8MnvJX8ST3JYGnCTJbAkGbJbCTAnJbLTAcJboDT3JboLb6JbrAnvJbrCn3JbrDl8JbrGboJbrIZoJbrJnvJbrMnvJbrQb4Jb8RZrJeAbAnJgJnFbJgScAnJgrATrJgvHZ8JgvMn4JlJlFbJlLiQXJlLjOnJlRbOlJlvNXoJlvRl3Jl4AcrJl8AUoJl8MnrJnFnMlJnHgGbJnoDT8JnoFV8JnoGgvJnoIT8JnoQToJnoRg3JnrCZ3JnrGgrJnrHTvJnrLf8JnrOX8JnvAT3JnvFZoJnvGT8JnvJl4JnvMT8JnvMX8JnvOXrJnvPX6JnvSX3JnvSZrJn3MT8Jn3MX8Jn3RTrLTATKnLTJnLTLTMXKnLTRTQlLToGb8LTrAZ8LTrCZ8LTrDb8LTrHT8LT3PX6LT4FZoLT$CTvLT$GgrLUvHX3LVoATrLVoAgoLVoJboLVoMX3LVoRg3LV8CZ3LV8FZoLV8GTvLXrDXoLXrFbrLXvAgvLXvFlrLXvLl3LXvRn6LX4Mb8LX8GT8LYCXMnLYrMnrLZoSTvLZrAZvLZrAloLZrFToLZrJXvLZrJboLZrJl4LZrLnrLZrMT8LZrOgvLZrRnvLZrST4LZvMX8LZvSlvLZ8AgoLZ8CT3LZ8JT8LZ8LV8LZ8LZoLZ8Lg8LZ8SV8LZ8SbrLZ$HT8LZ$Mn4La6CTvLbFbMnLbRYFTLbSnFZLboJT8LbrAT9LbrGb3LbrQb8LcrJX8LcrMXrLerHTvLerJbrLerNboLgrDb8LgrGZ8LgrHTrLgrMXrLgrSU8LgvJTrLgvLl3Lg6Ll3LhrLnrLhrMT8LhvAl4LiLnQXLkoAgrLkoJT8LkoJn4LlrSU8Ll3FZoLl3HTrLl3JX8Ll3JnoLl3LToLmLeFbLnDUFbLnLVAnLnrATrLnrAZoLnrAb8LnrAlrLnrGgvLnrJU8LnrLZrLnrLhrLnrMb8LnrOXrLnrSZ8LnvAb4LnvDTrLnvDl8LnvHTrLnvHbrLnvJT8LnvJU8LnvJbrLnvLhvLnvMX8LnvMb8LnvNnoLnvSU8Ln3Al3Ln4FZoLn4GT6Ln4JgvLn4LhrLn4MT8Ln4SToMToCZrMToJX8MToLX4MToLf8MToRg3MTrEloMTvGb6MT3BTrMT3Lb6MT8AcrMT8AgrMT8GZrMT8JnoMT8LnrMT8MX3MUOUAnMXAbFnMXoAloMXoJX8MXoLf8MXoLl8MXrAb8MXrDTvMXrGT8MXrGgrMXrHTrMXrLf8MXrMU8MXrOXvMXrQb8MXvGT8MXvHTrMXvLVoMX3AX3MX3Jn3MX3LhrMX3MX3MX4AlrMX4OboMX8GTvMX8GZrMX8GgrMX8JT8MX8JX8MX8LhrMX8MT8MYDUFbMYMgDbMbGnFfMbvLX4MbvLl3Mb8Mb8Mb8ST4MgGXCnMg8ATrMg8AgoMg8CZrMg8DTrMg8DboMg8HTrMg8JgrMg8LT8MloJXoMl8AhrMl8JT8MnLgAUMnoJXrMnoLX4MnoLhrMnoMT8MnrAl4MnrDb8MnrOTvMnrOgvMnrQb8MnrSU8MnvGgrMnvHZ8Mn3MToMn4DTrMn4LTrMn4Mg8NnBXAnOTFTFnOToAToOTrGgvOTrJX8OT3JXoOT6MTrOT8GgrOT8HTpOT8MToOUoHT8OUoJT8OUoLn3OXrAgoOXrDg8OXrMT8OXvSToOX6CTvOX8CZrOX8OgrOb6HgvOb8AToOb8MT8OcvLZ8OgvAlrOgvHTvOgvJTrOgvJnrOgvLZrOgvLn4OgvMT8OgvRTrOg8AZoOg8DbvOnrOXoOnvJn4OnvLhvOnvRTrOn3GgoOn3JnvOn6JbvOn8OTrPTGYFTPbBnFnPbGnDnPgDYQTPlrAnvPlrETvPlrLnvPlrMXvPlvFX4QTMTAnQTrJU8QYCnJlQYJlQlQbGTQbQb8JnrQb8LZoQb8LnvQb8MT8Qb8Ml8Qb8ST4QloAl4QloHZvQloJX8QloMn8QnJZOlRTrAZvRTrDTrRTvJn4RTvLhvRT4Jb8RZrAZrRZ8AkrRZ8JU8RZ8LV8RZ8LnvRbJlQXRg3GboRg3MnvRg8AZ8Rg8JboRg8Jl4RnLTCbRnvFl3RnvQb8SToAl4SToCZrSToFZoSToHXrSToJU8SToJgvSToJl4SToLhrSToMX3STrAlvSTrCT9STrCgrSTrGgrSTrHXrSTrHboSTrJnoSTrNboSTvLnrST4AZoST8Ab8ST8JT8SUoJn3SU6HZ#SU6JTvSU8Db8SU8HboSU8LgrSV8JT8SZrAcrSZrAl3SZrJT8SZrJnvSZrMT8SZvLUoSZ4FZoSZ8JnoSZ8RZrScoLnrScoMT8ScoMX8ScrAT4ScrAZ8ScrLZ8ScrLkvScvDb8ScvLf8ScvNToSgrFZrShvKnrSloHUoSloLnrSlrMXoSl8HgrSmrJUoSn3BX6",
  46713. "ATFlOn3ATLgrDYAT4MTAnAT8LTMnAYJnRTrAbGgJnrAbLV8LnAbvNTAnAeFbLg3AgOYMXoAlQbFboAnDboAfAnJgoJTBToDgAnBUJbAl3BboDUAnCTDlvLnCTFTrSnCYoQTLnDTwAbAnDUDTrSnDUHgHgrDX8LXFnDbJXAcrETvLTLnGTFTQbrGTMnGToGT3DUFbGUJlPX3GbQg8LnGboJbFnGb3GgAYGgAg8ScGgMbAXrGgvAbAnGnJTLnvGnvATFgHTDT6ATHTrDlJnHYLnMn8HZrSbJTHZ8LTFnHbFTJUoHgSeMT8HgrLjAnHgvAbAnHlFUrDlHnDgvAnHnHTFT3HnQTGnrJTAaMXvJTGbCn3JTOgrAnJXvAXMnJbMg8SnJbMnRg3Jb8LTMnJnAl3OnJnGYrQlJnJlQY3LTDlCn3LTJjLg3LTLgvFXLTMg3GTLV8HUOgLXFZLg3LXNXrMnLX8QXFnLX9AlMYLYLXPXrLZAbJU8LZDUJU8LZMXrSnLZ$AgFnLaPXrDULbFYrMnLbMn8LXLboJgJgLeFbLg3LgLZrSnLgOYAgoLhrRnJlLkCTrSnLkOnLhrLnFX%AYLnFZoJXLnHTvJbLnLloAbMTATLf8MTHgJn3MTMXrAXMT3MTFnMUITvFnMXFX%AYMXMXvFbMXrFTDbMYAcMX3MbLf8SnMb8JbFnMgMXrMTMgvAXFnMgvGgCmMnAloSnMnFnJTrOXvMXSnOX8HTMnObJT8ScObLZFl3ObMXCZoPTLgrQXPUFnoQXPU3RXJlPX3RkQXPbrJXQlPlrJbFnQUAhrDbQXGnCXvQYLnHlvQbLfLnvRTOgvJbRXJYrQlRYLnrQlRbLnrQlRlFT8JlRlFnrQXSTClCn3STHTrAnSTLZQlrSTMnGTrSToHgGbSTrGTDnSTvGXCnST3HgFbSU3HXAXSbAnJn3SbFT8LnScLfLnv",
  46714. "AT3JgJX8AT8FZoSnAT8JgFV8AT8LhrDbAZ8JT8DbAb8GgLhrAb8SkLnvAe8MT8SnAlMYJXLVAl3GYDTvAl3LfLnvBUDTvLl3CTOn3HTrCT3DUGgrCU8MT8AbCbFTrJUoCgrDb8MTDTLV8JX8DTLnLXQlDT8LZrSnDUQb8FZ8DUST4JnvDb8ScOUoDj6GbJl4GTLfCYMlGToAXvFnGboAXvLnGgAcrJn3GgvFnSToGnLf8JnvGn#HTDToHTLnFXJlHTvATFToHTvHTDToHTvMTAgoHT3STClvHT4AlFl6HT8HTDToHUoDgJTrHUoScMX3HbRZrMXoHboJg8LTHgDb8JTrHgMToLf8HgvLnLnoHnHn3HT4Hn6MgvAnJTJU8ScvJT3AaQT8JT8HTrAnJXrRg8AnJbAloMXoJbrATFToJbvMnoSnJgDb6GgvJgDb8MXoJgSX3JU8JguATFToJlPYLnQlJlQkDnLbJlQlFYJlJl8Lf8OTJnCTFnLbJnLTHXMnJnLXGXCnJnoFfRg3JnrMYRg3Jn3HgFl3KT8Dg8LnLTRlFnPTLTvPbLbvLVoSbrCZLXMY6HT3LXNU7DlrLXNXDTATLX8DX8LnLZDb8JU8LZMnoLhrLZSToJU8LZrLaLnrLZvJn3SnLZ8LhrSnLaJnoMT8LbFlrHTvLbrFTLnrLbvATLlvLb6OTFn3LcLnJZOlLeAT6Mn4LeJT3ObrLg6LXFlrLhrJg8LnLhvDlPX4LhvLfLnvLj6JTFT3LnFbrMXoLnQluCTvLnrQXCY6LnvLfLnvLnvMgLnvLnvSeLf8MTMbrJn3MT3JgST3MT8AnATrMT8LULnrMUMToCZrMUScvLf8MXoDT8SnMX6ATFToMX8AXMT8MX8FkMT8MX8HTrDUMX8ScoSnMYJT6CTvMgAcrMXoMg8SToAfMlvAXLg3MnFl3AnvOT3AnFl3OUoATHT8OU3RnLXrOXrOXrSnObPbvFn6Og8HgrSnOg8OX8DbPTvAgoJgPU3RYLnrPXrDnJZrPb8CTGgvPlrLTDlvPlvFUJnoQUvFXrQlQeMnoAl3QlrQlrSnRTFTrJUoSTDlLiLXSTFg6HT3STJgoMn4STrFTJTrSTrLZFl3ST4FnMXoSUrDlHUoScvHTvSnSfLkvMXo",
  46715. "AUoAcrMXoAZ8HboAg8AbOg6ATFgAg8AloMXoAl3AT8JTrAl8MX8MXoCT3SToJU8Cl8Db8MXoDT8HgrATrDboOT8MXoGTOTrATMnGT8LhrAZ8GnvFnGnQXHToGgvAcrHTvAXvLl3HbrAZoMXoHgBlFXLg3HgMnFXrSnHgrSb8JUoHn6HT8LgvITvATrJUoJUoLZrRnvJU8HT8Jb8JXvFX8QT8JXvLToJTrJYrQnGnQXJgrJnoATrJnoJU8ScvJnvMnvMXoLTCTLgrJXLTJlRTvQlLbRnJlQYvLbrMb8LnvLbvFn3RnoLdCVSTGZrLeSTvGXCnLg3MnoLn3MToLlrETvMT8SToAl3MbrDU6GTvMb8LX4LhrPlrLXGXCnSToLf8Rg3STrDb8LTrSTvLTHXMnSb3RYLnMnSgOg6ATFg",
  46716. "HUDlGnrQXrJTrHgLnrAcJYMb8DULc8LTvFgGnCk3Mg8JbAnLX4QYvFYHnMXrRUoJnGnvFnRlvFTJlQnoSTrBXHXrLYSUJgLfoMT8Se8DTrHbDb",
  46717. "AbDl8SToJU8An3RbAb8ST8DUSTrGnrAgoLbFU6Db8LTrMg8AaHT8Jb8ObDl8SToJU8Pb3RlvFYoJl"
  46718. ];
  46719. var codes = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789!@#$%^&*";
  46720. function getHangul(code) {
  46721. if (code >= 40) {
  46722. code = code + 168 - 40;
  46723. }
  46724. else if (code >= 19) {
  46725. code = code + 97 - 19;
  46726. }
  46727. return (0, strings_1.toUtf8String)([225, (code >> 6) + 132, (code & 0x3f) + 128]);
  46728. }
  46729. var wordlist = null;
  46730. function loadWords(lang) {
  46731. if (wordlist != null) {
  46732. return;
  46733. }
  46734. wordlist = [];
  46735. data.forEach(function (data, length) {
  46736. length += 4;
  46737. for (var i = 0; i < data.length; i += length) {
  46738. var word = "";
  46739. for (var j = 0; j < length; j++) {
  46740. word += getHangul(codes.indexOf(data[i + j]));
  46741. }
  46742. wordlist.push(word);
  46743. }
  46744. });
  46745. wordlist.sort();
  46746. // Verify the computed list matches the official list
  46747. /* istanbul ignore if */
  46748. if (wordlist_1.Wordlist.check(lang) !== "0xf9eddeace9c5d3da9c93cf7d3cd38f6a13ed3affb933259ae865714e8a3ae71a") {
  46749. wordlist = null;
  46750. throw new Error("BIP39 Wordlist for ko (Korean) FAILED");
  46751. }
  46752. }
  46753. var LangKo = /** @class */ (function (_super) {
  46754. __extends(LangKo, _super);
  46755. function LangKo() {
  46756. return _super.call(this, "ko") || this;
  46757. }
  46758. LangKo.prototype.getWord = function (index) {
  46759. loadWords(this);
  46760. return wordlist[index];
  46761. };
  46762. LangKo.prototype.getWordIndex = function (word) {
  46763. loadWords(this);
  46764. return wordlist.indexOf(word);
  46765. };
  46766. return LangKo;
  46767. }(wordlist_1.Wordlist));
  46768. var langKo = new LangKo();
  46769. exports.langKo = langKo;
  46770. wordlist_1.Wordlist.register(langKo);
  46771. },{"./wordlist":287,"@ethersproject/strings":266}],286:[function(_dereq_,module,exports){
  46772. "use strict";
  46773. var __extends = (this && this.__extends) || (function () {
  46774. var extendStatics = function (d, b) {
  46775. extendStatics = Object.setPrototypeOf ||
  46776. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  46777. function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
  46778. return extendStatics(d, b);
  46779. };
  46780. return function (d, b) {
  46781. if (typeof b !== "function" && b !== null)
  46782. throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
  46783. extendStatics(d, b);
  46784. function __() { this.constructor = d; }
  46785. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  46786. };
  46787. })();
  46788. Object.defineProperty(exports, "__esModule", { value: true });
  46789. exports.langZhTw = exports.langZhCn = void 0;
  46790. var strings_1 = _dereq_("@ethersproject/strings");
  46791. var wordlist_1 = _dereq_("./wordlist");
  46792. var data = "}aE#4A=Yv&co#4N#6G=cJ&SM#66|/Z#4t&kn~46#4K~4q%b9=IR#7l,mB#7W_X2*dl}Uo~7s}Uf&Iw#9c&cw~6O&H6&wx&IG%v5=IQ~8a&Pv#47$PR&50%Ko&QM&3l#5f,D9#4L|/H&tQ;v0~6n]nN<di,AM=W5%QO&ka&ua,hM^tm=zV=JA=wR&+X]7P&NB#4J#5L|/b[dA}tJ<Do&6m&u2[U1&Kb.HM&mC=w0&MW<rY,Hq#6M}QG,13&wP}Jp]Ow%ue&Kg<HP<D9~4k~9T&I2_c6$9T#9/[C5~7O~4a=cs&O7=KK=An&l9$6U$8A&uD&QI|/Y&bg}Ux&F2#6b}E2&JN&kW&kp=U/&bb=Xl<Cj}k+~5J#6L&5z&9i}b4&Fo,ho(X0_g3~4O$Fz&QE<HN=Ww]6/%GF-Vw=tj&/D&PN#9g=YO}cL&Of&PI~5I&Ip=vU=IW#9G;0o-wU}ss&QR<BT&R9=tk$PY_dh&Pq-yh]7T,nj.Xu=EP&76=cI&Fs*Xg}z7$Gb&+I=DF,AF=cA}rL#7j=Dz&3y<Aa$52=PQ}b0(iY$Fa}oL&xV#6U=ec=WZ,xh%RY<dp#9N&Fl&44=WH*A7=sh&TB&8P=07;u+&PK}uh}J5#72)V/=xC,AB$k0&f6;1E|+5=1B,3v]6n&wR%b+&xx]7f=Ol}fl;+D^wG]7E;nB;uh^Ir&l5=JL,nS=cf=g5;u6|/Q$Gc=MH%Hg#5d%M6^86=U+$Gz,l/,ir^5y&Ba&/F-IY&FI&be%IZ#77&PW_Nu$kE(Yf&NX]7Z,Jy&FJ(Xo&Nz#/d=y7&MX<Ag}Z+;nE]Dt(iG#4D=13&Pj~4c%v8&Zo%OL&/X#4W<HR&ie~6J_1O(Y2=y5=Ad*cv_eB#6k&PX:BU#7A;uk&Ft&Fx_dD=U2;vB=U5=4F}+O&GN.HH:9s=b0%NV(jO&IH=JT}Z9=VZ<Af,Kx^4m&uJ%c6,6r;9m#+L}cf%Kh&F3~4H=vP}bu,Hz|++,1w]nv}k6;uu$jw*Kl*WX&uM[x7&Fr[m7$NO&QN]hu=JN}nR^8g#/h(ps|KC;vd}xz=V0}p6&FD$G1#7K<bG_4p~8g&cf;u4=tl}+k%5/}fz;uw<cA=u1}gU}VM=LJ=eX&+L&Pr#4U}p2:nC,2K]7H:jF&9x}uX#9O=MB<fz~8X~5m&4D&kN&u5%E/(h7(ZF&VG<de(qM|/e-Wt=3x(a+,/R]f/&ND$Ro&nU}0g=KA%kH&NK$Ke<dS}cB&IX~5g$TN]6m=Uv,Is&Py=Ef%Kz#+/%bi&+A<F4$OG&4C&FL#9V<Zk=2I_eE&6c]nw&kq$HG}y+&A8$P3}OH=XP]70%IS(AJ_gH%GZ&tY&AZ=vb~6y&/r=VI=Wv<Zi=fl=xf&eL}c8}OL=MJ=g8$F7=YT}9u=0+^xC}JH&nL^N0~4T]K2,Cy%OC#6s;vG(AC^xe^cG&MF}Br#9P;wD-7h$O/&xA}Fn^PC]6i]7G&8V$Qs;vl(TB~73~4l<mW&6V=2y&uY&+3)aP}XF;LP&kx$wU=t7;uy<FN&lz)7E=Oo*Y+;wI}9q}le;J6&Ri&4t&Qr#8B=cb&vG=J5|Ql(h5<Yy~4+}QD,Lx=wn%K/&RK=dO&Pw,Q9=co%4u;9u}g0@6a^4I%b0=zo|/c&tX=dQ=OS#+b=yz_AB&wB&Pm=W9$HP_gR=62=AO=ti=hI,oA&jr&dH=tm&b6$P2(x8=zi;nG~7F;05]0n[Ix&3m}rg=Xp=cd&uz]7t;97=cN;vV<jf&FF&F1=6Q&Ik*Kk&P4,2z=fQ]7D&3u,H0=d/}Uw<ZN<7R}Kv;0f$H7,MD]7n$F0#88~9Z%da=by;+T#/u=VF&fO&kr^kf<AB]sU,I5$Ng&Pz;0i&QD&vM=Yl:BM;nJ_xJ]U7&Kf&30,3f|Z9*dC)je_jA&Q4&Kp$NH(Yz#6S&Id%Ib=KX,AD=KV%dP}tW&Pk^+E_Ni=cq,3R}VZ(Si=b+}rv;0j}rZ]uA,/w(Sx&Jv$w9&4d&wE,NJ$Gy=J/]Ls#7k<ZQ<Y/&uj]Ov$PM;v3,2F&+u:up=On&3e,Jv;90=J+&Qm]6q}bK#+d~8Y(h2]hA;99&AS=I/}qB&dQ}yJ-VM}Vl&ui,iB&G3|Dc]7d=eQ%dX%JC_1L~4d^NP;vJ&/1)ZI#7N]9X[bQ&PL=0L(UZ,Lm&kc&IR}n7(iR<AQ<dg=33=vN}ft}au]7I,Ba=x9=dR~6R&Tq=Xi,3d$Nr&Bc}DI&ku&vf]Dn,/F&iD,Ll&Nw=0y&I7=Ls=/A&tU=Qe}Ua&uk&+F=g4=gh=Vj#+1&Qn}Uy*44#5F,Pc&Rz*Xn=oh=5W;0n_Nf(iE<Y7=vr=Zu]oz#5Z%mI=kN=Bv_Jp(T2;vt_Ml<FS&uI=L/&6P]64$M7}86<bo%QX(SI%IY&VK=Al&Ux;vv;ut*E/%uh<ZE|O3,M2(yc]yu=Wk&tp:Ex}hr,Cl&WE)+Z=8U}I2_4Q,hA_si=iw=OM=tM=yZ%Ia=U7;wT}b+;uo=Za}yS!5x}HD}fb#5O_dA;Nv%uB(yB;01(Sf}Fk;v7}Pt#8v<mZ#7L,/r&Pl~4w&f5=Ph$Fw_LF&8m,bL=yJ&BH}p/*Jn}tU~5Q;wB(h6]Df]8p^+B;E4&Wc=d+;Ea&bw$8C&FN,DM=Yf}mP~5w=fT#6V=mC=Fi=AV}jB&AN}lW}aH#/D)dZ;hl;vE}/7,CJ;31&w8,hj%u9_Js=jJ&4M~8k=TN&eC}nL&uc-wi&lX}dj=Mv=e2#6u=cr$uq$6G]8W}Jb:nm=Yg<b3(UA;vX&6n&xF=KT,jC,De&R8&oY=Zv&oB]7/=Z2&Oa}bf,hh(4h^tZ&72&Nx;D2&xL~5h~40)ZG)h+=OJ&RA]Bv$yB=Oq=df,AQ%Jn}OJ;11,3z&Tl&tj;v+^Hv,Dh(id=s+]7N&N3)9Q~8f,S4=uW=w4&uX,LX&3d]CJ&yp&8x<b2_do&lP=y/<cy_dG=Oi=7R(VH(lt_1T,Iq_AA;12^6T%k6#8K[B1{oO<AU[Bt;1b$9S&Ps<8T=St{bY,jB(Zp&63&Uv$9V,PM]6v&Af}zW[bW_oq}sm}nB&Kq&gC&ff_eq_2m&5F&TI}rf}Gf;Zr_z9;ER&jk}iz_sn<BN~+n&vo=Vi%97|ZR=Wc,WE&6t]6z%85(ly#84=KY)6m_5/=aX,N3}Tm&he&6K]tR_B2-I3;u/&hU&lH<AP=iB&IA=XL;/5&Nh=wv<BH#79=vS=zl<AA=0X_RG}Bw&9p$NW,AX&kP_Lp&/Z(Tc]Mu}hs#6I}5B&cI<bq&H9#6m=K9}vH(Y1(Y0#4B&w6,/9&gG<bE,/O=zb}I4_l8<B/;wL%Qo<HO[Mq=XX}0v&BP&F4(mG}0i}nm,EC=9u{I3,xG&/9=JY*DK&hR)BX=EI=cx=b/{6k}yX%A+&wa}Xb=la;wi^lL;0t}jo&Qb=xg=XB}iO<qo{bR=NV&8f=a0&Jy;0v=uK)HK;vN#6h&jB(h/%ud&NI%wY.X7=Pt}Cu-uL&Gs_hl%mH,tm]78=Lb^Q0#7Y=1u<Bt&+Q=Co_RH,w3;1e}ux<aU;ui}U3&Q5%bt]63&UQ|0l&uL}O7&3o,AV&dm|Nj(Xt*5+(Uu&Hh(p7(UF=VR=Bp^Jl&Hd[ix)9/=Iq]C8<67]66}mB%6f}bb}JI]8T$HA}db=YM&pa=2J}tS&Y0=PS&y4=cX$6E,hX,XP&nR;04,FQ&l0&Vm_Dv#5Y~8Z=Bi%MA]6x=JO:+p,Az&9q,Hj~6/}SD=K1:EJ}nA;Qo#/E]9R,Ie&6X%W3]61&v4=xX_MC=0q;06(Xq=fs}IG}Dv=0l}o7$iZ;9v&LH&DP-7a&OY,SZ,Kz,Cv&dh=fx|Nh,F/~7q=XF&w+;9n&Gw;0h}Z7<7O&JK(S7&LS<AD<ac=wo<Dt&zw%4B=4v#8P;9o~6p*vV=Tm,Or&I6=1q}nY=P0=gq&Bl&Uu,Ch%yb}UY=zh}dh}rl(T4_xk(YA#8R*xH,IN}Jn]7V}C4&Ty}j3]7p=cL=3h&wW%Qv<Z3=f0&RI&+S(ic_zq}oN&/Y=z1;Td=LW=0e=OI(Vc,+b^ju(UL;0r:Za%8v=Rp=zw&58&73&wK}qX]6y&8E)a2}WR=wP^ur&nQ<cH}Re=Aq&wk}Q0&+q=PP,Gc|/d^k5,Fw]8Y}Pg]p3=ju=ed}r5_yf&Cs]7z$/G<Cm&Jp&54_1G_gP_Ll}JZ;0u]k8_7k(Sg]65{9i=LN&Sx&WK,iW&fD&Lk{9a}Em-9c#8N&io=sy]8d&nT&IK(lx#7/$lW(Td<s8~49,3o<7Y=MW(T+_Jr&Wd,iL}Ct=xh&5V;v4&8n%Kx=iF&l2_0B{B+,If(J0,Lv;u8=Kx-vB=HC&vS=Z6&fU&vE^xK;3D=4h=MR#45:Jw;0d}iw=LU}I5=I0]gB*im,K9}GU,1k_4U&Tt=Vs(iX&lU(TF#7y,ZO}oA&m5#5P}PN}Uz=hM<B1&FB<aG,e6~7T<tP(UQ_ZT=wu&F8)aQ]iN,1r_Lo&/g:CD}84{J1_Ki&Na&3n$jz&FE=dc;uv;va}in}ll=fv(h1&3h}fp=Cy}BM(+E~8m}lo%v7=hC(T6$cj=BQ=Bw(DR,2j=Ks,NS|F+;00=fU=70}Mb(YU;+G&m7&hr=Sk%Co]t+(X5_Jw}0r}gC(AS-IP&QK<Z2#8Q$WC]WX}T2&pG_Ka,HC=R4&/N;Z+;ch(C7,D4$3p_Mk&B2$8D=n9%Ky#5z(CT&QJ#7B]DC]gW}nf~5M;Iw#80}Tc_1F#4Z-aC}Hl=ph=fz,/3=aW}JM}nn;DG;vm}wn,4P}T3;wx&RG$u+}zK=0b;+J_Ek{re<aZ=AS}yY#5D]7q,Cp}xN=VP*2C}GZ}aG~+m_Cs=OY#6r]6g<GS}LC(UB=3A=Bo}Jy<c4}Is;1P<AG}Op<Z1}ld}nS=1Z,yM&95&98=CJ(4t:2L$Hk=Zo}Vc;+I}np&N1}9y=iv}CO*7p=jL)px]tb^zh&GS&Vl%v/;vR=14=zJ&49|/f]hF}WG;03=8P}o/&Gg&rp;DB,Kv}Ji&Pb;aA^ll(4j%yt}+K$Ht#4y&hY]7Y<F1,eN}bG(Uh%6Z]t5%G7;+F_RE;it}tL=LS&Da=Xx(S+(4f=8G=yI}cJ}WP=37=jS}pX}hd)fp<A8=Jt~+o$HJ=M6}iX=g9}CS=dv=Cj(mP%Kd,xq|+9&LD(4/=Xm&QP=Lc}LX&fL;+K=Op(lu=Qs.qC:+e&L+=Jj#8w;SL]7S(b+#4I=c1&nG_Lf&uH;+R)ZV<bV%B/,TE&0H&Jq&Ah%OF&Ss(p2,Wv&I3=Wl}Vq;1L&lJ#9b_1H=8r=b8=JH(SZ=hD=J2#7U,/U#/X~6P,FU<eL=jx,mG=hG=CE&PU=Se(qX&LY=X6=y4&tk&QQ&tf=4g&xI}W+&mZ=Dc#7w}Lg;DA;wQ_Kb(cJ=hR%yX&Yb,hw{bX_4X;EP;1W_2M}Uc=b5(YF,CM&Tp^OJ{DD]6s=vF=Yo~8q}XH}Fu%P5(SJ=Qt;MO]s8<F3&B3&8T(Ul-BS*dw&dR<87}/8]62$PZ]Lx<Au}9Q]7c=ja=KR,Go,Us&v6(qk}pG&G2=ev^GM%w4&H4]7F&dv]J6}Ew:9w=sj-ZL}Ym$+h(Ut(Um~4n=Xs(U7%eE=Qc_JR<CA#6t<Fv|/I,IS,EG<F2(Xy$/n<Fa(h9}+9_2o&N4#7X<Zq|+f_Dp=dt&na,Ca=NJ)jY=8C=YG=s6&Q+<DO}D3=xB&R1(lw;Qn<bF(Cu|/B}HV=SS&n7,10&u0]Dm%A6^4Q=WR(TD=Xo<GH,Rj(l8)bP&n/=LM&CF,F5&ml=PJ;0k=LG=tq,Rh,D6@4i=1p&+9=YC%er_Mh;nI;0q=Fw]80=xq=FM$Gv;v6&nc;wK%H2&Kj;vs,AA=YP,66}bI(qR~5U=6q~4b$Ni=K5.X3$So&Iu(p+]8G=Cf=RY(TS_O3(iH&57=fE=Dg_Do#9z#7H;FK{qd_2k%JR}en&gh_z8;Rx}9p<cN_Ne,DO;LN_7o~/p=NF=5Y}gN<ce<C1,QE]Wv=3u<BC}GK]yq}DY&u/_hj=II(pz&rC,jV&+Z}ut=NQ;Cg-SR_ZS,+o=u/;Oy_RK_QF(Fx&xP}Wr&TA,Uh&g1=yr{ax[VF$Pg(YB;Ox=Vy;+W(Sp}XV%dd&33(l/]l4#4Y}OE=6c=bw(A7&9t%wd&N/&mo,JH&Qe)fm=Ao}fu=tH";
  46793. var deltaData = "FAZDC6BALcLZCA+GBARCW8wNCcDDZ8LVFBOqqDUiou+M42TFAyERXFb7EjhP+vmBFpFrUpfDV2F7eB+eCltCHJFWLFCED+pWTojEIHFXc3aFn4F68zqjEuKidS1QBVPDEhE7NA4mhMF7oThD49ot3FgtzHFCK0acW1x8DH1EmLoIlrWFBLE+y5+NA3Cx65wJHTaEZVaK1mWAmPGxgYCdxwOjTDIt/faOEhTl1vqNsKtJCOhJWuio2g07KLZEQsFBUpNtwEByBgxFslFheFbiEPvi61msDvApxCzB6rBCzox7joYA5UdDc+Cb4FSgIabpXFAj3bjkmFAxCZE+mD/SFf/0ELecYCt3nLoxC6WEZf2tKDB4oZvrEmqFkKk7BwILA7gtYBpsTq//D4jD0F0wEB9pyQ1BD5Ba0oYHDI+sbDFhvrHXdDHfgFEIJLi5r8qercNFBgFLC4bo5ERJtamWBDFy73KCEb6M8VpmEt330ygCTK58EIIFkYgF84gtGA9Uyh3m68iVrFbWFbcbqiCYHZ9J1jeRPbL8yswhMiDbhEhdNoSwFbZrLT740ABEqgCkO8J1BLd1VhKKR4sD1yUo0z+FF59Mvg71CFbyEhbHSFBKEIKyoQNgQppq9T0KAqePu0ZFGrXOHdKJqkoTFhYvpDNyuuznrN84thJbsCoO6Cu6Xlvntvy0QYuAExQEYtTUBf3CoCqwgGFZ4u1HJFzDVwEy3cjcpV4QvsPaBC3rCGyCF23o4K3pp2gberGgFEJEHo4nHICtyKH2ZqyxhN05KBBJIQlKh/Oujv/DH32VrlqFdIFC7Fz9Ct4kaqFME0UETLprnN9kfy+kFmtQBB0+5CFu0N9Ij8l/VvJDh2oq3hT6EzjTHKFN7ZjZwoTsAZ4Exsko6Fpa6WC+sduz8jyrLpegTv2h1EBeYpLpm2czQW0KoCcS0bCVXCmuWJDBjN1nQNLdF58SFJ0h7i3pC3oEOKy/FjBklL70XvBEEIWp2yZ04xObzAWDDJG7f+DbqBEA7LyiR95j7MDVdDViz2RE5vWlBMv5e4+VfhP3aXNPhvLSynb9O2x4uFBV+3jqu6d5pCG28/sETByvmu/+IJ0L3wb4rj9DNOLBF6XPIODr4L19U9RRofAG6Nxydi8Bki8BhGJbBAJKzbJxkZSlF9Q2Cu8oKqggB9hBArwLLqEBWEtFowy8XK8bEyw9snT+BeyFk1ZCSrdmgfEwFePTgCjELBEnIbjaDDPJm36rG9pztcEzT8dGk23SBhXBB1H4z+OWze0ooFzz8pDBYFvp9j9tvFByf9y4EFdVnz026CGR5qMr7fxMHN8UUdlyJAzlTBDRC28k+L4FB8078ljyD91tUj1ocnTs8vdEf7znbzm+GIjEZnoZE5rnLL700Xc7yHfz05nWxy03vBB9YGHYOWxgMQGBCR24CVYNE1hpfKxN0zKnfJDmmMgMmBWqNbjfSyFCBWSCGCgR8yFXiHyEj+VtD1FB3FpC1zI0kFbzifiKTLm9yq5zFmur+q8FHqjoOBWsBPiDbnCC2ErunV6cJ6TygXFYHYp7MKN9RUlSIS8/xBAGYLzeqUnBF4QbsTuUkUqGs6CaiDWKWjQK9EJkjpkTmNCPYXL";
  46794. // @TODO: Load lazily
  46795. var wordlist = {
  46796. zh_cn: null,
  46797. zh_tw: null
  46798. };
  46799. var Checks = {
  46800. zh_cn: "0x17bcc4d8547e5a7135e365d1ab443aaae95e76d8230c2782c67305d4f21497a1",
  46801. zh_tw: "0x51e720e90c7b87bec1d70eb6e74a21a449bd3ec9c020b01d3a40ed991b60ce5d"
  46802. };
  46803. var codes = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
  46804. var style = "~!@#$%^&*_-=[]{}|;:,.()<>?";
  46805. function loadWords(lang) {
  46806. if (wordlist[lang.locale] !== null) {
  46807. return;
  46808. }
  46809. wordlist[lang.locale] = [];
  46810. var deltaOffset = 0;
  46811. for (var i = 0; i < 2048; i++) {
  46812. var s = style.indexOf(data[i * 3]);
  46813. var bytes = [
  46814. 228 + (s >> 2),
  46815. 128 + codes.indexOf(data[i * 3 + 1]),
  46816. 128 + codes.indexOf(data[i * 3 + 2]),
  46817. ];
  46818. if (lang.locale === "zh_tw") {
  46819. var common = s % 4;
  46820. for (var i_1 = common; i_1 < 3; i_1++) {
  46821. bytes[i_1] = codes.indexOf(deltaData[deltaOffset++]) + ((i_1 == 0) ? 228 : 128);
  46822. }
  46823. }
  46824. wordlist[lang.locale].push((0, strings_1.toUtf8String)(bytes));
  46825. }
  46826. // Verify the computed list matches the official list
  46827. /* istanbul ignore if */
  46828. if (wordlist_1.Wordlist.check(lang) !== Checks[lang.locale]) {
  46829. wordlist[lang.locale] = null;
  46830. throw new Error("BIP39 Wordlist for " + lang.locale + " (Chinese) FAILED");
  46831. }
  46832. }
  46833. var LangZh = /** @class */ (function (_super) {
  46834. __extends(LangZh, _super);
  46835. function LangZh(country) {
  46836. return _super.call(this, "zh_" + country) || this;
  46837. }
  46838. LangZh.prototype.getWord = function (index) {
  46839. loadWords(this);
  46840. return wordlist[this.locale][index];
  46841. };
  46842. LangZh.prototype.getWordIndex = function (word) {
  46843. loadWords(this);
  46844. return wordlist[this.locale].indexOf(word);
  46845. };
  46846. LangZh.prototype.split = function (mnemonic) {
  46847. mnemonic = mnemonic.replace(/(?:\u3000| )+/g, "");
  46848. return mnemonic.split("");
  46849. };
  46850. return LangZh;
  46851. }(wordlist_1.Wordlist));
  46852. var langZhCn = new LangZh("cn");
  46853. exports.langZhCn = langZhCn;
  46854. wordlist_1.Wordlist.register(langZhCn);
  46855. wordlist_1.Wordlist.register(langZhCn, "zh");
  46856. var langZhTw = new LangZh("tw");
  46857. exports.langZhTw = langZhTw;
  46858. wordlist_1.Wordlist.register(langZhTw);
  46859. },{"./wordlist":287,"@ethersproject/strings":266}],287:[function(_dereq_,module,exports){
  46860. "use strict";
  46861. Object.defineProperty(exports, "__esModule", { value: true });
  46862. exports.Wordlist = exports.logger = void 0;
  46863. // This gets overridden by rollup
  46864. var exportWordlist = false;
  46865. var hash_1 = _dereq_("@ethersproject/hash");
  46866. var properties_1 = _dereq_("@ethersproject/properties");
  46867. var logger_1 = _dereq_("@ethersproject/logger");
  46868. var _version_1 = _dereq_("./_version");
  46869. exports.logger = new logger_1.Logger(_version_1.version);
  46870. var Wordlist = /** @class */ (function () {
  46871. function Wordlist(locale) {
  46872. var _newTarget = this.constructor;
  46873. exports.logger.checkAbstract(_newTarget, Wordlist);
  46874. (0, properties_1.defineReadOnly)(this, "locale", locale);
  46875. }
  46876. // Subclasses may override this
  46877. Wordlist.prototype.split = function (mnemonic) {
  46878. return mnemonic.toLowerCase().split(/ +/g);
  46879. };
  46880. // Subclasses may override this
  46881. Wordlist.prototype.join = function (words) {
  46882. return words.join(" ");
  46883. };
  46884. Wordlist.check = function (wordlist) {
  46885. var words = [];
  46886. for (var i = 0; i < 2048; i++) {
  46887. var word = wordlist.getWord(i);
  46888. /* istanbul ignore if */
  46889. if (i !== wordlist.getWordIndex(word)) {
  46890. return "0x";
  46891. }
  46892. words.push(word);
  46893. }
  46894. return (0, hash_1.id)(words.join("\n") + "\n");
  46895. };
  46896. Wordlist.register = function (lang, name) {
  46897. if (!name) {
  46898. name = lang.locale;
  46899. }
  46900. /* istanbul ignore if */
  46901. if (exportWordlist) {
  46902. try {
  46903. var anyGlobal = window;
  46904. if (anyGlobal._ethers && anyGlobal._ethers.wordlists) {
  46905. if (!anyGlobal._ethers.wordlists[name]) {
  46906. (0, properties_1.defineReadOnly)(anyGlobal._ethers.wordlists, name, lang);
  46907. }
  46908. }
  46909. }
  46910. catch (error) { }
  46911. }
  46912. };
  46913. return Wordlist;
  46914. }());
  46915. exports.Wordlist = Wordlist;
  46916. },{"./_version":277,"@ethersproject/hash":209,"@ethersproject/logger":223,"@ethersproject/properties":229}],288:[function(_dereq_,module,exports){
  46917. "use strict";
  46918. Object.defineProperty(exports, "__esModule", { value: true });
  46919. exports.wordlists = void 0;
  46920. var lang_cz_1 = _dereq_("./lang-cz");
  46921. var lang_en_1 = _dereq_("./lang-en");
  46922. var lang_es_1 = _dereq_("./lang-es");
  46923. var lang_fr_1 = _dereq_("./lang-fr");
  46924. var lang_ja_1 = _dereq_("./lang-ja");
  46925. var lang_ko_1 = _dereq_("./lang-ko");
  46926. var lang_it_1 = _dereq_("./lang-it");
  46927. var lang_zh_1 = _dereq_("./lang-zh");
  46928. exports.wordlists = {
  46929. cz: lang_cz_1.langCz,
  46930. en: lang_en_1.langEn,
  46931. es: lang_es_1.langEs,
  46932. fr: lang_fr_1.langFr,
  46933. it: lang_it_1.langIt,
  46934. ja: lang_ja_1.langJa,
  46935. ko: lang_ko_1.langKo,
  46936. zh: lang_zh_1.langZhCn,
  46937. zh_cn: lang_zh_1.langZhCn,
  46938. zh_tw: lang_zh_1.langZhTw
  46939. };
  46940. },{"./lang-cz":279,"./lang-en":280,"./lang-es":281,"./lang-fr":282,"./lang-it":283,"./lang-ja":284,"./lang-ko":285,"./lang-zh":286}],289:[function(_dereq_,module,exports){
  46941. "use strict";
  46942. /**
  46943. * Returns a Promise that resolves to the value of window.ethereum if it is
  46944. * set within the given timeout, or null.
  46945. * The Promise will not reject, but an error will be thrown if invalid options
  46946. * are provided.
  46947. *
  46948. * @param options - Options bag.
  46949. * @param options.mustBeMetaMask - Whether to only look for MetaMask providers.
  46950. * Default: false
  46951. * @param options.silent - Whether to silence console errors. Does not affect
  46952. * thrown errors. Default: false
  46953. * @param options.timeout - Milliseconds to wait for 'ethereum#initialized' to
  46954. * be dispatched. Default: 3000
  46955. * @returns A Promise that resolves with the Provider if it is detected within
  46956. * given timeout, otherwise null.
  46957. */
  46958. function detectEthereumProvider({ mustBeMetaMask = false, silent = false, timeout = 3000, } = {}) {
  46959. _validateInputs();
  46960. let handled = false;
  46961. return new Promise((resolve) => {
  46962. if (window.ethereum) {
  46963. handleEthereum();
  46964. }
  46965. else {
  46966. window.addEventListener('ethereum#initialized', handleEthereum, { once: true });
  46967. setTimeout(() => {
  46968. handleEthereum();
  46969. }, timeout);
  46970. }
  46971. function handleEthereum() {
  46972. if (handled) {
  46973. return;
  46974. }
  46975. handled = true;
  46976. window.removeEventListener('ethereum#initialized', handleEthereum);
  46977. const { ethereum } = window;
  46978. if (ethereum && (!mustBeMetaMask || ethereum.isMetaMask)) {
  46979. resolve(ethereum);
  46980. }
  46981. else {
  46982. const message = mustBeMetaMask && ethereum
  46983. ? 'Non-MetaMask window.ethereum detected.'
  46984. : 'Unable to detect window.ethereum.';
  46985. !silent && console.error('@metamask/detect-provider:', message);
  46986. resolve(null);
  46987. }
  46988. }
  46989. });
  46990. function _validateInputs() {
  46991. if (typeof mustBeMetaMask !== 'boolean') {
  46992. throw new Error(`@metamask/detect-provider: Expected option 'mustBeMetaMask' to be a boolean.`);
  46993. }
  46994. if (typeof silent !== 'boolean') {
  46995. throw new Error(`@metamask/detect-provider: Expected option 'silent' to be a boolean.`);
  46996. }
  46997. if (typeof timeout !== 'number') {
  46998. throw new Error(`@metamask/detect-provider: Expected option 'timeout' to be a number.`);
  46999. }
  47000. }
  47001. }
  47002. module.exports = detectEthereumProvider;
  47003. },{}],290:[function(_dereq_,module,exports){
  47004. "use strict";
  47005. (function(root) {
  47006. function checkInt(value) {
  47007. return (parseInt(value) === value);
  47008. }
  47009. function checkInts(arrayish) {
  47010. if (!checkInt(arrayish.length)) { return false; }
  47011. for (var i = 0; i < arrayish.length; i++) {
  47012. if (!checkInt(arrayish[i]) || arrayish[i] < 0 || arrayish[i] > 255) {
  47013. return false;
  47014. }
  47015. }
  47016. return true;
  47017. }
  47018. function coerceArray(arg, copy) {
  47019. // ArrayBuffer view
  47020. if (arg.buffer && ArrayBuffer.isView(arg) && arg.name === 'Uint8Array') {
  47021. if (copy) {
  47022. if (arg.slice) {
  47023. arg = arg.slice();
  47024. } else {
  47025. arg = Array.prototype.slice.call(arg);
  47026. }
  47027. }
  47028. return arg;
  47029. }
  47030. // It's an array; check it is a valid representation of a byte
  47031. if (Array.isArray(arg)) {
  47032. if (!checkInts(arg)) {
  47033. throw new Error('Array contains invalid value: ' + arg);
  47034. }
  47035. return new Uint8Array(arg);
  47036. }
  47037. // Something else, but behaves like an array (maybe a Buffer? Arguments?)
  47038. if (checkInt(arg.length) && checkInts(arg)) {
  47039. return new Uint8Array(arg);
  47040. }
  47041. throw new Error('unsupported array-like object');
  47042. }
  47043. function createArray(length) {
  47044. return new Uint8Array(length);
  47045. }
  47046. function copyArray(sourceArray, targetArray, targetStart, sourceStart, sourceEnd) {
  47047. if (sourceStart != null || sourceEnd != null) {
  47048. if (sourceArray.slice) {
  47049. sourceArray = sourceArray.slice(sourceStart, sourceEnd);
  47050. } else {
  47051. sourceArray = Array.prototype.slice.call(sourceArray, sourceStart, sourceEnd);
  47052. }
  47053. }
  47054. targetArray.set(sourceArray, targetStart);
  47055. }
  47056. var convertUtf8 = (function() {
  47057. function toBytes(text) {
  47058. var result = [], i = 0;
  47059. text = encodeURI(text);
  47060. while (i < text.length) {
  47061. var c = text.charCodeAt(i++);
  47062. // if it is a % sign, encode the following 2 bytes as a hex value
  47063. if (c === 37) {
  47064. result.push(parseInt(text.substr(i, 2), 16))
  47065. i += 2;
  47066. // otherwise, just the actual byte
  47067. } else {
  47068. result.push(c)
  47069. }
  47070. }
  47071. return coerceArray(result);
  47072. }
  47073. function fromBytes(bytes) {
  47074. var result = [], i = 0;
  47075. while (i < bytes.length) {
  47076. var c = bytes[i];
  47077. if (c < 128) {
  47078. result.push(String.fromCharCode(c));
  47079. i++;
  47080. } else if (c > 191 && c < 224) {
  47081. result.push(String.fromCharCode(((c & 0x1f) << 6) | (bytes[i + 1] & 0x3f)));
  47082. i += 2;
  47083. } else {
  47084. result.push(String.fromCharCode(((c & 0x0f) << 12) | ((bytes[i + 1] & 0x3f) << 6) | (bytes[i + 2] & 0x3f)));
  47085. i += 3;
  47086. }
  47087. }
  47088. return result.join('');
  47089. }
  47090. return {
  47091. toBytes: toBytes,
  47092. fromBytes: fromBytes,
  47093. }
  47094. })();
  47095. var convertHex = (function() {
  47096. function toBytes(text) {
  47097. var result = [];
  47098. for (var i = 0; i < text.length; i += 2) {
  47099. result.push(parseInt(text.substr(i, 2), 16));
  47100. }
  47101. return result;
  47102. }
  47103. // http://ixti.net/development/javascript/2011/11/11/base64-encodedecode-of-utf8-in-browser-with-js.html
  47104. var Hex = '0123456789abcdef';
  47105. function fromBytes(bytes) {
  47106. var result = [];
  47107. for (var i = 0; i < bytes.length; i++) {
  47108. var v = bytes[i];
  47109. result.push(Hex[(v & 0xf0) >> 4] + Hex[v & 0x0f]);
  47110. }
  47111. return result.join('');
  47112. }
  47113. return {
  47114. toBytes: toBytes,
  47115. fromBytes: fromBytes,
  47116. }
  47117. })();
  47118. // Number of rounds by keysize
  47119. var numberOfRounds = {16: 10, 24: 12, 32: 14}
  47120. // Round constant words
  47121. var rcon = [0x01, 0x02, 0x04, 0x08, 0x10, 0x20, 0x40, 0x80, 0x1b, 0x36, 0x6c, 0xd8, 0xab, 0x4d, 0x9a, 0x2f, 0x5e, 0xbc, 0x63, 0xc6, 0x97, 0x35, 0x6a, 0xd4, 0xb3, 0x7d, 0xfa, 0xef, 0xc5, 0x91];
  47122. // S-box and Inverse S-box (S is for Substitution)
  47123. var S = [0x63, 0x7c, 0x77, 0x7b, 0xf2, 0x6b, 0x6f, 0xc5, 0x30, 0x01, 0x67, 0x2b, 0xfe, 0xd7, 0xab, 0x76, 0xca, 0x82, 0xc9, 0x7d, 0xfa, 0x59, 0x47, 0xf0, 0xad, 0xd4, 0xa2, 0xaf, 0x9c, 0xa4, 0x72, 0xc0, 0xb7, 0xfd, 0x93, 0x26, 0x36, 0x3f, 0xf7, 0xcc, 0x34, 0xa5, 0xe5, 0xf1, 0x71, 0xd8, 0x31, 0x15, 0x04, 0xc7, 0x23, 0xc3, 0x18, 0x96, 0x05, 0x9a, 0x07, 0x12, 0x80, 0xe2, 0xeb, 0x27, 0xb2, 0x75, 0x09, 0x83, 0x2c, 0x1a, 0x1b, 0x6e, 0x5a, 0xa0, 0x52, 0x3b, 0xd6, 0xb3, 0x29, 0xe3, 0x2f, 0x84, 0x53, 0xd1, 0x00, 0xed, 0x20, 0xfc, 0xb1, 0x5b, 0x6a, 0xcb, 0xbe, 0x39, 0x4a, 0x4c, 0x58, 0xcf, 0xd0, 0xef, 0xaa, 0xfb, 0x43, 0x4d, 0x33, 0x85, 0x45, 0xf9, 0x02, 0x7f, 0x50, 0x3c, 0x9f, 0xa8, 0x51, 0xa3, 0x40, 0x8f, 0x92, 0x9d, 0x38, 0xf5, 0xbc, 0xb6, 0xda, 0x21, 0x10, 0xff, 0xf3, 0xd2, 0xcd, 0x0c, 0x13, 0xec, 0x5f, 0x97, 0x44, 0x17, 0xc4, 0xa7, 0x7e, 0x3d, 0x64, 0x5d, 0x19, 0x73, 0x60, 0x81, 0x4f, 0xdc, 0x22, 0x2a, 0x90, 0x88, 0x46, 0xee, 0xb8, 0x14, 0xde, 0x5e, 0x0b, 0xdb, 0xe0, 0x32, 0x3a, 0x0a, 0x49, 0x06, 0x24, 0x5c, 0xc2, 0xd3, 0xac, 0x62, 0x91, 0x95, 0xe4, 0x79, 0xe7, 0xc8, 0x37, 0x6d, 0x8d, 0xd5, 0x4e, 0xa9, 0x6c, 0x56, 0xf4, 0xea, 0x65, 0x7a, 0xae, 0x08, 0xba, 0x78, 0x25, 0x2e, 0x1c, 0xa6, 0xb4, 0xc6, 0xe8, 0xdd, 0x74, 0x1f, 0x4b, 0xbd, 0x8b, 0x8a, 0x70, 0x3e, 0xb5, 0x66, 0x48, 0x03, 0xf6, 0x0e, 0x61, 0x35, 0x57, 0xb9, 0x86, 0xc1, 0x1d, 0x9e, 0xe1, 0xf8, 0x98, 0x11, 0x69, 0xd9, 0x8e, 0x94, 0x9b, 0x1e, 0x87, 0xe9, 0xce, 0x55, 0x28, 0xdf, 0x8c, 0xa1, 0x89, 0x0d, 0xbf, 0xe6, 0x42, 0x68, 0x41, 0x99, 0x2d, 0x0f, 0xb0, 0x54, 0xbb, 0x16];
  47124. var Si =[0x52, 0x09, 0x6a, 0xd5, 0x30, 0x36, 0xa5, 0x38, 0xbf, 0x40, 0xa3, 0x9e, 0x81, 0xf3, 0xd7, 0xfb, 0x7c, 0xe3, 0x39, 0x82, 0x9b, 0x2f, 0xff, 0x87, 0x34, 0x8e, 0x43, 0x44, 0xc4, 0xde, 0xe9, 0xcb, 0x54, 0x7b, 0x94, 0x32, 0xa6, 0xc2, 0x23, 0x3d, 0xee, 0x4c, 0x95, 0x0b, 0x42, 0xfa, 0xc3, 0x4e, 0x08, 0x2e, 0xa1, 0x66, 0x28, 0xd9, 0x24, 0xb2, 0x76, 0x5b, 0xa2, 0x49, 0x6d, 0x8b, 0xd1, 0x25, 0x72, 0xf8, 0xf6, 0x64, 0x86, 0x68, 0x98, 0x16, 0xd4, 0xa4, 0x5c, 0xcc, 0x5d, 0x65, 0xb6, 0x92, 0x6c, 0x70, 0x48, 0x50, 0xfd, 0xed, 0xb9, 0xda, 0x5e, 0x15, 0x46, 0x57, 0xa7, 0x8d, 0x9d, 0x84, 0x90, 0xd8, 0xab, 0x00, 0x8c, 0xbc, 0xd3, 0x0a, 0xf7, 0xe4, 0x58, 0x05, 0xb8, 0xb3, 0x45, 0x06, 0xd0, 0x2c, 0x1e, 0x8f, 0xca, 0x3f, 0x0f, 0x02, 0xc1, 0xaf, 0xbd, 0x03, 0x01, 0x13, 0x8a, 0x6b, 0x3a, 0x91, 0x11, 0x41, 0x4f, 0x67, 0xdc, 0xea, 0x97, 0xf2, 0xcf, 0xce, 0xf0, 0xb4, 0xe6, 0x73, 0x96, 0xac, 0x74, 0x22, 0xe7, 0xad, 0x35, 0x85, 0xe2, 0xf9, 0x37, 0xe8, 0x1c, 0x75, 0xdf, 0x6e, 0x47, 0xf1, 0x1a, 0x71, 0x1d, 0x29, 0xc5, 0x89, 0x6f, 0xb7, 0x62, 0x0e, 0xaa, 0x18, 0xbe, 0x1b, 0xfc, 0x56, 0x3e, 0x4b, 0xc6, 0xd2, 0x79, 0x20, 0x9a, 0xdb, 0xc0, 0xfe, 0x78, 0xcd, 0x5a, 0xf4, 0x1f, 0xdd, 0xa8, 0x33, 0x88, 0x07, 0xc7, 0x31, 0xb1, 0x12, 0x10, 0x59, 0x27, 0x80, 0xec, 0x5f, 0x60, 0x51, 0x7f, 0xa9, 0x19, 0xb5, 0x4a, 0x0d, 0x2d, 0xe5, 0x7a, 0x9f, 0x93, 0xc9, 0x9c, 0xef, 0xa0, 0xe0, 0x3b, 0x4d, 0xae, 0x2a, 0xf5, 0xb0, 0xc8, 0xeb, 0xbb, 0x3c, 0x83, 0x53, 0x99, 0x61, 0x17, 0x2b, 0x04, 0x7e, 0xba, 0x77, 0xd6, 0x26, 0xe1, 0x69, 0x14, 0x63, 0x55, 0x21, 0x0c, 0x7d];
  47125. // Transformations for encryption
  47126. var T1 = [0xc66363a5, 0xf87c7c84, 0xee777799, 0xf67b7b8d, 0xfff2f20d, 0xd66b6bbd, 0xde6f6fb1, 0x91c5c554, 0x60303050, 0x02010103, 0xce6767a9, 0x562b2b7d, 0xe7fefe19, 0xb5d7d762, 0x4dababe6, 0xec76769a, 0x8fcaca45, 0x1f82829d, 0x89c9c940, 0xfa7d7d87, 0xeffafa15, 0xb25959eb, 0x8e4747c9, 0xfbf0f00b, 0x41adadec, 0xb3d4d467, 0x5fa2a2fd, 0x45afafea, 0x239c9cbf, 0x53a4a4f7, 0xe4727296, 0x9bc0c05b, 0x75b7b7c2, 0xe1fdfd1c, 0x3d9393ae, 0x4c26266a, 0x6c36365a, 0x7e3f3f41, 0xf5f7f702, 0x83cccc4f, 0x6834345c, 0x51a5a5f4, 0xd1e5e534, 0xf9f1f108, 0xe2717193, 0xabd8d873, 0x62313153, 0x2a15153f, 0x0804040c, 0x95c7c752, 0x46232365, 0x9dc3c35e, 0x30181828, 0x379696a1, 0x0a05050f, 0x2f9a9ab5, 0x0e070709, 0x24121236, 0x1b80809b, 0xdfe2e23d, 0xcdebeb26, 0x4e272769, 0x7fb2b2cd, 0xea75759f, 0x1209091b, 0x1d83839e, 0x582c2c74, 0x341a1a2e, 0x361b1b2d, 0xdc6e6eb2, 0xb45a5aee, 0x5ba0a0fb, 0xa45252f6, 0x763b3b4d, 0xb7d6d661, 0x7db3b3ce, 0x5229297b, 0xdde3e33e, 0x5e2f2f71, 0x13848497, 0xa65353f5, 0xb9d1d168, 0x00000000, 0xc1eded2c, 0x40202060, 0xe3fcfc1f, 0x79b1b1c8, 0xb65b5bed, 0xd46a6abe, 0x8dcbcb46, 0x67bebed9, 0x7239394b, 0x944a4ade, 0x984c4cd4, 0xb05858e8, 0x85cfcf4a, 0xbbd0d06b, 0xc5efef2a, 0x4faaaae5, 0xedfbfb16, 0x864343c5, 0x9a4d4dd7, 0x66333355, 0x11858594, 0x8a4545cf, 0xe9f9f910, 0x04020206, 0xfe7f7f81, 0xa05050f0, 0x783c3c44, 0x259f9fba, 0x4ba8a8e3, 0xa25151f3, 0x5da3a3fe, 0x804040c0, 0x058f8f8a, 0x3f9292ad, 0x219d9dbc, 0x70383848, 0xf1f5f504, 0x63bcbcdf, 0x77b6b6c1, 0xafdada75, 0x42212163, 0x20101030, 0xe5ffff1a, 0xfdf3f30e, 0xbfd2d26d, 0x81cdcd4c, 0x180c0c14, 0x26131335, 0xc3ecec2f, 0xbe5f5fe1, 0x359797a2, 0x884444cc, 0x2e171739, 0x93c4c457, 0x55a7a7f2, 0xfc7e7e82, 0x7a3d3d47, 0xc86464ac, 0xba5d5de7, 0x3219192b, 0xe6737395, 0xc06060a0, 0x19818198, 0x9e4f4fd1, 0xa3dcdc7f, 0x44222266, 0x542a2a7e, 0x3b9090ab, 0x0b888883, 0x8c4646ca, 0xc7eeee29, 0x6bb8b8d3, 0x2814143c, 0xa7dede79, 0xbc5e5ee2, 0x160b0b1d, 0xaddbdb76, 0xdbe0e03b, 0x64323256, 0x743a3a4e, 0x140a0a1e, 0x924949db, 0x0c06060a, 0x4824246c, 0xb85c5ce4, 0x9fc2c25d, 0xbdd3d36e, 0x43acacef, 0xc46262a6, 0x399191a8, 0x319595a4, 0xd3e4e437, 0xf279798b, 0xd5e7e732, 0x8bc8c843, 0x6e373759, 0xda6d6db7, 0x018d8d8c, 0xb1d5d564, 0x9c4e4ed2, 0x49a9a9e0, 0xd86c6cb4, 0xac5656fa, 0xf3f4f407, 0xcfeaea25, 0xca6565af, 0xf47a7a8e, 0x47aeaee9, 0x10080818, 0x6fbabad5, 0xf0787888, 0x4a25256f, 0x5c2e2e72, 0x381c1c24, 0x57a6a6f1, 0x73b4b4c7, 0x97c6c651, 0xcbe8e823, 0xa1dddd7c, 0xe874749c, 0x3e1f1f21, 0x964b4bdd, 0x61bdbddc, 0x0d8b8b86, 0x0f8a8a85, 0xe0707090, 0x7c3e3e42, 0x71b5b5c4, 0xcc6666aa, 0x904848d8, 0x06030305, 0xf7f6f601, 0x1c0e0e12, 0xc26161a3, 0x6a35355f, 0xae5757f9, 0x69b9b9d0, 0x17868691, 0x99c1c158, 0x3a1d1d27, 0x279e9eb9, 0xd9e1e138, 0xebf8f813, 0x2b9898b3, 0x22111133, 0xd26969bb, 0xa9d9d970, 0x078e8e89, 0x339494a7, 0x2d9b9bb6, 0x3c1e1e22, 0x15878792, 0xc9e9e920, 0x87cece49, 0xaa5555ff, 0x50282878, 0xa5dfdf7a, 0x038c8c8f, 0x59a1a1f8, 0x09898980, 0x1a0d0d17, 0x65bfbfda, 0xd7e6e631, 0x844242c6, 0xd06868b8, 0x824141c3, 0x299999b0, 0x5a2d2d77, 0x1e0f0f11, 0x7bb0b0cb, 0xa85454fc, 0x6dbbbbd6, 0x2c16163a];
  47127. var T2 = [0xa5c66363, 0x84f87c7c, 0x99ee7777, 0x8df67b7b, 0x0dfff2f2, 0xbdd66b6b, 0xb1de6f6f, 0x5491c5c5, 0x50603030, 0x03020101, 0xa9ce6767, 0x7d562b2b, 0x19e7fefe, 0x62b5d7d7, 0xe64dabab, 0x9aec7676, 0x458fcaca, 0x9d1f8282, 0x4089c9c9, 0x87fa7d7d, 0x15effafa, 0xebb25959, 0xc98e4747, 0x0bfbf0f0, 0xec41adad, 0x67b3d4d4, 0xfd5fa2a2, 0xea45afaf, 0xbf239c9c, 0xf753a4a4, 0x96e47272, 0x5b9bc0c0, 0xc275b7b7, 0x1ce1fdfd, 0xae3d9393, 0x6a4c2626, 0x5a6c3636, 0x417e3f3f, 0x02f5f7f7, 0x4f83cccc, 0x5c683434, 0xf451a5a5, 0x34d1e5e5, 0x08f9f1f1, 0x93e27171, 0x73abd8d8, 0x53623131, 0x3f2a1515, 0x0c080404, 0x5295c7c7, 0x65462323, 0x5e9dc3c3, 0x28301818, 0xa1379696, 0x0f0a0505, 0xb52f9a9a, 0x090e0707, 0x36241212, 0x9b1b8080, 0x3ddfe2e2, 0x26cdebeb, 0x694e2727, 0xcd7fb2b2, 0x9fea7575, 0x1b120909, 0x9e1d8383, 0x74582c2c, 0x2e341a1a, 0x2d361b1b, 0xb2dc6e6e, 0xeeb45a5a, 0xfb5ba0a0, 0xf6a45252, 0x4d763b3b, 0x61b7d6d6, 0xce7db3b3, 0x7b522929, 0x3edde3e3, 0x715e2f2f, 0x97138484, 0xf5a65353, 0x68b9d1d1, 0x00000000, 0x2cc1eded, 0x60402020, 0x1fe3fcfc, 0xc879b1b1, 0xedb65b5b, 0xbed46a6a, 0x468dcbcb, 0xd967bebe, 0x4b723939, 0xde944a4a, 0xd4984c4c, 0xe8b05858, 0x4a85cfcf, 0x6bbbd0d0, 0x2ac5efef, 0xe54faaaa, 0x16edfbfb, 0xc5864343, 0xd79a4d4d, 0x55663333, 0x94118585, 0xcf8a4545, 0x10e9f9f9, 0x06040202, 0x81fe7f7f, 0xf0a05050, 0x44783c3c, 0xba259f9f, 0xe34ba8a8, 0xf3a25151, 0xfe5da3a3, 0xc0804040, 0x8a058f8f, 0xad3f9292, 0xbc219d9d, 0x48703838, 0x04f1f5f5, 0xdf63bcbc, 0xc177b6b6, 0x75afdada, 0x63422121, 0x30201010, 0x1ae5ffff, 0x0efdf3f3, 0x6dbfd2d2, 0x4c81cdcd, 0x14180c0c, 0x35261313, 0x2fc3ecec, 0xe1be5f5f, 0xa2359797, 0xcc884444, 0x392e1717, 0x5793c4c4, 0xf255a7a7, 0x82fc7e7e, 0x477a3d3d, 0xacc86464, 0xe7ba5d5d, 0x2b321919, 0x95e67373, 0xa0c06060, 0x98198181, 0xd19e4f4f, 0x7fa3dcdc, 0x66442222, 0x7e542a2a, 0xab3b9090, 0x830b8888, 0xca8c4646, 0x29c7eeee, 0xd36bb8b8, 0x3c281414, 0x79a7dede, 0xe2bc5e5e, 0x1d160b0b, 0x76addbdb, 0x3bdbe0e0, 0x56643232, 0x4e743a3a, 0x1e140a0a, 0xdb924949, 0x0a0c0606, 0x6c482424, 0xe4b85c5c, 0x5d9fc2c2, 0x6ebdd3d3, 0xef43acac, 0xa6c46262, 0xa8399191, 0xa4319595, 0x37d3e4e4, 0x8bf27979, 0x32d5e7e7, 0x438bc8c8, 0x596e3737, 0xb7da6d6d, 0x8c018d8d, 0x64b1d5d5, 0xd29c4e4e, 0xe049a9a9, 0xb4d86c6c, 0xfaac5656, 0x07f3f4f4, 0x25cfeaea, 0xafca6565, 0x8ef47a7a, 0xe947aeae, 0x18100808, 0xd56fbaba, 0x88f07878, 0x6f4a2525, 0x725c2e2e, 0x24381c1c, 0xf157a6a6, 0xc773b4b4, 0x5197c6c6, 0x23cbe8e8, 0x7ca1dddd, 0x9ce87474, 0x213e1f1f, 0xdd964b4b, 0xdc61bdbd, 0x860d8b8b, 0x850f8a8a, 0x90e07070, 0x427c3e3e, 0xc471b5b5, 0xaacc6666, 0xd8904848, 0x05060303, 0x01f7f6f6, 0x121c0e0e, 0xa3c26161, 0x5f6a3535, 0xf9ae5757, 0xd069b9b9, 0x91178686, 0x5899c1c1, 0x273a1d1d, 0xb9279e9e, 0x38d9e1e1, 0x13ebf8f8, 0xb32b9898, 0x33221111, 0xbbd26969, 0x70a9d9d9, 0x89078e8e, 0xa7339494, 0xb62d9b9b, 0x223c1e1e, 0x92158787, 0x20c9e9e9, 0x4987cece, 0xffaa5555, 0x78502828, 0x7aa5dfdf, 0x8f038c8c, 0xf859a1a1, 0x80098989, 0x171a0d0d, 0xda65bfbf, 0x31d7e6e6, 0xc6844242, 0xb8d06868, 0xc3824141, 0xb0299999, 0x775a2d2d, 0x111e0f0f, 0xcb7bb0b0, 0xfca85454, 0xd66dbbbb, 0x3a2c1616];
  47128. var T3 = [0x63a5c663, 0x7c84f87c, 0x7799ee77, 0x7b8df67b, 0xf20dfff2, 0x6bbdd66b, 0x6fb1de6f, 0xc55491c5, 0x30506030, 0x01030201, 0x67a9ce67, 0x2b7d562b, 0xfe19e7fe, 0xd762b5d7, 0xabe64dab, 0x769aec76, 0xca458fca, 0x829d1f82, 0xc94089c9, 0x7d87fa7d, 0xfa15effa, 0x59ebb259, 0x47c98e47, 0xf00bfbf0, 0xadec41ad, 0xd467b3d4, 0xa2fd5fa2, 0xafea45af, 0x9cbf239c, 0xa4f753a4, 0x7296e472, 0xc05b9bc0, 0xb7c275b7, 0xfd1ce1fd, 0x93ae3d93, 0x266a4c26, 0x365a6c36, 0x3f417e3f, 0xf702f5f7, 0xcc4f83cc, 0x345c6834, 0xa5f451a5, 0xe534d1e5, 0xf108f9f1, 0x7193e271, 0xd873abd8, 0x31536231, 0x153f2a15, 0x040c0804, 0xc75295c7, 0x23654623, 0xc35e9dc3, 0x18283018, 0x96a13796, 0x050f0a05, 0x9ab52f9a, 0x07090e07, 0x12362412, 0x809b1b80, 0xe23ddfe2, 0xeb26cdeb, 0x27694e27, 0xb2cd7fb2, 0x759fea75, 0x091b1209, 0x839e1d83, 0x2c74582c, 0x1a2e341a, 0x1b2d361b, 0x6eb2dc6e, 0x5aeeb45a, 0xa0fb5ba0, 0x52f6a452, 0x3b4d763b, 0xd661b7d6, 0xb3ce7db3, 0x297b5229, 0xe33edde3, 0x2f715e2f, 0x84971384, 0x53f5a653, 0xd168b9d1, 0x00000000, 0xed2cc1ed, 0x20604020, 0xfc1fe3fc, 0xb1c879b1, 0x5bedb65b, 0x6abed46a, 0xcb468dcb, 0xbed967be, 0x394b7239, 0x4ade944a, 0x4cd4984c, 0x58e8b058, 0xcf4a85cf, 0xd06bbbd0, 0xef2ac5ef, 0xaae54faa, 0xfb16edfb, 0x43c58643, 0x4dd79a4d, 0x33556633, 0x85941185, 0x45cf8a45, 0xf910e9f9, 0x02060402, 0x7f81fe7f, 0x50f0a050, 0x3c44783c, 0x9fba259f, 0xa8e34ba8, 0x51f3a251, 0xa3fe5da3, 0x40c08040, 0x8f8a058f, 0x92ad3f92, 0x9dbc219d, 0x38487038, 0xf504f1f5, 0xbcdf63bc, 0xb6c177b6, 0xda75afda, 0x21634221, 0x10302010, 0xff1ae5ff, 0xf30efdf3, 0xd26dbfd2, 0xcd4c81cd, 0x0c14180c, 0x13352613, 0xec2fc3ec, 0x5fe1be5f, 0x97a23597, 0x44cc8844, 0x17392e17, 0xc45793c4, 0xa7f255a7, 0x7e82fc7e, 0x3d477a3d, 0x64acc864, 0x5de7ba5d, 0x192b3219, 0x7395e673, 0x60a0c060, 0x81981981, 0x4fd19e4f, 0xdc7fa3dc, 0x22664422, 0x2a7e542a, 0x90ab3b90, 0x88830b88, 0x46ca8c46, 0xee29c7ee, 0xb8d36bb8, 0x143c2814, 0xde79a7de, 0x5ee2bc5e, 0x0b1d160b, 0xdb76addb, 0xe03bdbe0, 0x32566432, 0x3a4e743a, 0x0a1e140a, 0x49db9249, 0x060a0c06, 0x246c4824, 0x5ce4b85c, 0xc25d9fc2, 0xd36ebdd3, 0xacef43ac, 0x62a6c462, 0x91a83991, 0x95a43195, 0xe437d3e4, 0x798bf279, 0xe732d5e7, 0xc8438bc8, 0x37596e37, 0x6db7da6d, 0x8d8c018d, 0xd564b1d5, 0x4ed29c4e, 0xa9e049a9, 0x6cb4d86c, 0x56faac56, 0xf407f3f4, 0xea25cfea, 0x65afca65, 0x7a8ef47a, 0xaee947ae, 0x08181008, 0xbad56fba, 0x7888f078, 0x256f4a25, 0x2e725c2e, 0x1c24381c, 0xa6f157a6, 0xb4c773b4, 0xc65197c6, 0xe823cbe8, 0xdd7ca1dd, 0x749ce874, 0x1f213e1f, 0x4bdd964b, 0xbddc61bd, 0x8b860d8b, 0x8a850f8a, 0x7090e070, 0x3e427c3e, 0xb5c471b5, 0x66aacc66, 0x48d89048, 0x03050603, 0xf601f7f6, 0x0e121c0e, 0x61a3c261, 0x355f6a35, 0x57f9ae57, 0xb9d069b9, 0x86911786, 0xc15899c1, 0x1d273a1d, 0x9eb9279e, 0xe138d9e1, 0xf813ebf8, 0x98b32b98, 0x11332211, 0x69bbd269, 0xd970a9d9, 0x8e89078e, 0x94a73394, 0x9bb62d9b, 0x1e223c1e, 0x87921587, 0xe920c9e9, 0xce4987ce, 0x55ffaa55, 0x28785028, 0xdf7aa5df, 0x8c8f038c, 0xa1f859a1, 0x89800989, 0x0d171a0d, 0xbfda65bf, 0xe631d7e6, 0x42c68442, 0x68b8d068, 0x41c38241, 0x99b02999, 0x2d775a2d, 0x0f111e0f, 0xb0cb7bb0, 0x54fca854, 0xbbd66dbb, 0x163a2c16];
  47129. var T4 = [0x6363a5c6, 0x7c7c84f8, 0x777799ee, 0x7b7b8df6, 0xf2f20dff, 0x6b6bbdd6, 0x6f6fb1de, 0xc5c55491, 0x30305060, 0x01010302, 0x6767a9ce, 0x2b2b7d56, 0xfefe19e7, 0xd7d762b5, 0xababe64d, 0x76769aec, 0xcaca458f, 0x82829d1f, 0xc9c94089, 0x7d7d87fa, 0xfafa15ef, 0x5959ebb2, 0x4747c98e, 0xf0f00bfb, 0xadadec41, 0xd4d467b3, 0xa2a2fd5f, 0xafafea45, 0x9c9cbf23, 0xa4a4f753, 0x727296e4, 0xc0c05b9b, 0xb7b7c275, 0xfdfd1ce1, 0x9393ae3d, 0x26266a4c, 0x36365a6c, 0x3f3f417e, 0xf7f702f5, 0xcccc4f83, 0x34345c68, 0xa5a5f451, 0xe5e534d1, 0xf1f108f9, 0x717193e2, 0xd8d873ab, 0x31315362, 0x15153f2a, 0x04040c08, 0xc7c75295, 0x23236546, 0xc3c35e9d, 0x18182830, 0x9696a137, 0x05050f0a, 0x9a9ab52f, 0x0707090e, 0x12123624, 0x80809b1b, 0xe2e23ddf, 0xebeb26cd, 0x2727694e, 0xb2b2cd7f, 0x75759fea, 0x09091b12, 0x83839e1d, 0x2c2c7458, 0x1a1a2e34, 0x1b1b2d36, 0x6e6eb2dc, 0x5a5aeeb4, 0xa0a0fb5b, 0x5252f6a4, 0x3b3b4d76, 0xd6d661b7, 0xb3b3ce7d, 0x29297b52, 0xe3e33edd, 0x2f2f715e, 0x84849713, 0x5353f5a6, 0xd1d168b9, 0x00000000, 0xeded2cc1, 0x20206040, 0xfcfc1fe3, 0xb1b1c879, 0x5b5bedb6, 0x6a6abed4, 0xcbcb468d, 0xbebed967, 0x39394b72, 0x4a4ade94, 0x4c4cd498, 0x5858e8b0, 0xcfcf4a85, 0xd0d06bbb, 0xefef2ac5, 0xaaaae54f, 0xfbfb16ed, 0x4343c586, 0x4d4dd79a, 0x33335566, 0x85859411, 0x4545cf8a, 0xf9f910e9, 0x02020604, 0x7f7f81fe, 0x5050f0a0, 0x3c3c4478, 0x9f9fba25, 0xa8a8e34b, 0x5151f3a2, 0xa3a3fe5d, 0x4040c080, 0x8f8f8a05, 0x9292ad3f, 0x9d9dbc21, 0x38384870, 0xf5f504f1, 0xbcbcdf63, 0xb6b6c177, 0xdada75af, 0x21216342, 0x10103020, 0xffff1ae5, 0xf3f30efd, 0xd2d26dbf, 0xcdcd4c81, 0x0c0c1418, 0x13133526, 0xecec2fc3, 0x5f5fe1be, 0x9797a235, 0x4444cc88, 0x1717392e, 0xc4c45793, 0xa7a7f255, 0x7e7e82fc, 0x3d3d477a, 0x6464acc8, 0x5d5de7ba, 0x19192b32, 0x737395e6, 0x6060a0c0, 0x81819819, 0x4f4fd19e, 0xdcdc7fa3, 0x22226644, 0x2a2a7e54, 0x9090ab3b, 0x8888830b, 0x4646ca8c, 0xeeee29c7, 0xb8b8d36b, 0x14143c28, 0xdede79a7, 0x5e5ee2bc, 0x0b0b1d16, 0xdbdb76ad, 0xe0e03bdb, 0x32325664, 0x3a3a4e74, 0x0a0a1e14, 0x4949db92, 0x06060a0c, 0x24246c48, 0x5c5ce4b8, 0xc2c25d9f, 0xd3d36ebd, 0xacacef43, 0x6262a6c4, 0x9191a839, 0x9595a431, 0xe4e437d3, 0x79798bf2, 0xe7e732d5, 0xc8c8438b, 0x3737596e, 0x6d6db7da, 0x8d8d8c01, 0xd5d564b1, 0x4e4ed29c, 0xa9a9e049, 0x6c6cb4d8, 0x5656faac, 0xf4f407f3, 0xeaea25cf, 0x6565afca, 0x7a7a8ef4, 0xaeaee947, 0x08081810, 0xbabad56f, 0x787888f0, 0x25256f4a, 0x2e2e725c, 0x1c1c2438, 0xa6a6f157, 0xb4b4c773, 0xc6c65197, 0xe8e823cb, 0xdddd7ca1, 0x74749ce8, 0x1f1f213e, 0x4b4bdd96, 0xbdbddc61, 0x8b8b860d, 0x8a8a850f, 0x707090e0, 0x3e3e427c, 0xb5b5c471, 0x6666aacc, 0x4848d890, 0x03030506, 0xf6f601f7, 0x0e0e121c, 0x6161a3c2, 0x35355f6a, 0x5757f9ae, 0xb9b9d069, 0x86869117, 0xc1c15899, 0x1d1d273a, 0x9e9eb927, 0xe1e138d9, 0xf8f813eb, 0x9898b32b, 0x11113322, 0x6969bbd2, 0xd9d970a9, 0x8e8e8907, 0x9494a733, 0x9b9bb62d, 0x1e1e223c, 0x87879215, 0xe9e920c9, 0xcece4987, 0x5555ffaa, 0x28287850, 0xdfdf7aa5, 0x8c8c8f03, 0xa1a1f859, 0x89898009, 0x0d0d171a, 0xbfbfda65, 0xe6e631d7, 0x4242c684, 0x6868b8d0, 0x4141c382, 0x9999b029, 0x2d2d775a, 0x0f0f111e, 0xb0b0cb7b, 0x5454fca8, 0xbbbbd66d, 0x16163a2c];
  47130. // Transformations for decryption
  47131. var T5 = [0x51f4a750, 0x7e416553, 0x1a17a4c3, 0x3a275e96, 0x3bab6bcb, 0x1f9d45f1, 0xacfa58ab, 0x4be30393, 0x2030fa55, 0xad766df6, 0x88cc7691, 0xf5024c25, 0x4fe5d7fc, 0xc52acbd7, 0x26354480, 0xb562a38f, 0xdeb15a49, 0x25ba1b67, 0x45ea0e98, 0x5dfec0e1, 0xc32f7502, 0x814cf012, 0x8d4697a3, 0x6bd3f9c6, 0x038f5fe7, 0x15929c95, 0xbf6d7aeb, 0x955259da, 0xd4be832d, 0x587421d3, 0x49e06929, 0x8ec9c844, 0x75c2896a, 0xf48e7978, 0x99583e6b, 0x27b971dd, 0xbee14fb6, 0xf088ad17, 0xc920ac66, 0x7dce3ab4, 0x63df4a18, 0xe51a3182, 0x97513360, 0x62537f45, 0xb16477e0, 0xbb6bae84, 0xfe81a01c, 0xf9082b94, 0x70486858, 0x8f45fd19, 0x94de6c87, 0x527bf8b7, 0xab73d323, 0x724b02e2, 0xe31f8f57, 0x6655ab2a, 0xb2eb2807, 0x2fb5c203, 0x86c57b9a, 0xd33708a5, 0x302887f2, 0x23bfa5b2, 0x02036aba, 0xed16825c, 0x8acf1c2b, 0xa779b492, 0xf307f2f0, 0x4e69e2a1, 0x65daf4cd, 0x0605bed5, 0xd134621f, 0xc4a6fe8a, 0x342e539d, 0xa2f355a0, 0x058ae132, 0xa4f6eb75, 0x0b83ec39, 0x4060efaa, 0x5e719f06, 0xbd6e1051, 0x3e218af9, 0x96dd063d, 0xdd3e05ae, 0x4de6bd46, 0x91548db5, 0x71c45d05, 0x0406d46f, 0x605015ff, 0x1998fb24, 0xd6bde997, 0x894043cc, 0x67d99e77, 0xb0e842bd, 0x07898b88, 0xe7195b38, 0x79c8eedb, 0xa17c0a47, 0x7c420fe9, 0xf8841ec9, 0x00000000, 0x09808683, 0x322bed48, 0x1e1170ac, 0x6c5a724e, 0xfd0efffb, 0x0f853856, 0x3daed51e, 0x362d3927, 0x0a0fd964, 0x685ca621, 0x9b5b54d1, 0x24362e3a, 0x0c0a67b1, 0x9357e70f, 0xb4ee96d2, 0x1b9b919e, 0x80c0c54f, 0x61dc20a2, 0x5a774b69, 0x1c121a16, 0xe293ba0a, 0xc0a02ae5, 0x3c22e043, 0x121b171d, 0x0e090d0b, 0xf28bc7ad, 0x2db6a8b9, 0x141ea9c8, 0x57f11985, 0xaf75074c, 0xee99ddbb, 0xa37f60fd, 0xf701269f, 0x5c72f5bc, 0x44663bc5, 0x5bfb7e34, 0x8b432976, 0xcb23c6dc, 0xb6edfc68, 0xb8e4f163, 0xd731dcca, 0x42638510, 0x13972240, 0x84c61120, 0x854a247d, 0xd2bb3df8, 0xaef93211, 0xc729a16d, 0x1d9e2f4b, 0xdcb230f3, 0x0d8652ec, 0x77c1e3d0, 0x2bb3166c, 0xa970b999, 0x119448fa, 0x47e96422, 0xa8fc8cc4, 0xa0f03f1a, 0x567d2cd8, 0x223390ef, 0x87494ec7, 0xd938d1c1, 0x8ccaa2fe, 0x98d40b36, 0xa6f581cf, 0xa57ade28, 0xdab78e26, 0x3fadbfa4, 0x2c3a9de4, 0x5078920d, 0x6a5fcc9b, 0x547e4662, 0xf68d13c2, 0x90d8b8e8, 0x2e39f75e, 0x82c3aff5, 0x9f5d80be, 0x69d0937c, 0x6fd52da9, 0xcf2512b3, 0xc8ac993b, 0x10187da7, 0xe89c636e, 0xdb3bbb7b, 0xcd267809, 0x6e5918f4, 0xec9ab701, 0x834f9aa8, 0xe6956e65, 0xaaffe67e, 0x21bccf08, 0xef15e8e6, 0xbae79bd9, 0x4a6f36ce, 0xea9f09d4, 0x29b07cd6, 0x31a4b2af, 0x2a3f2331, 0xc6a59430, 0x35a266c0, 0x744ebc37, 0xfc82caa6, 0xe090d0b0, 0x33a7d815, 0xf104984a, 0x41ecdaf7, 0x7fcd500e, 0x1791f62f, 0x764dd68d, 0x43efb04d, 0xccaa4d54, 0xe49604df, 0x9ed1b5e3, 0x4c6a881b, 0xc12c1fb8, 0x4665517f, 0x9d5eea04, 0x018c355d, 0xfa877473, 0xfb0b412e, 0xb3671d5a, 0x92dbd252, 0xe9105633, 0x6dd64713, 0x9ad7618c, 0x37a10c7a, 0x59f8148e, 0xeb133c89, 0xcea927ee, 0xb761c935, 0xe11ce5ed, 0x7a47b13c, 0x9cd2df59, 0x55f2733f, 0x1814ce79, 0x73c737bf, 0x53f7cdea, 0x5ffdaa5b, 0xdf3d6f14, 0x7844db86, 0xcaaff381, 0xb968c43e, 0x3824342c, 0xc2a3405f, 0x161dc372, 0xbce2250c, 0x283c498b, 0xff0d9541, 0x39a80171, 0x080cb3de, 0xd8b4e49c, 0x6456c190, 0x7bcb8461, 0xd532b670, 0x486c5c74, 0xd0b85742];
  47132. var T6 = [0x5051f4a7, 0x537e4165, 0xc31a17a4, 0x963a275e, 0xcb3bab6b, 0xf11f9d45, 0xabacfa58, 0x934be303, 0x552030fa, 0xf6ad766d, 0x9188cc76, 0x25f5024c, 0xfc4fe5d7, 0xd7c52acb, 0x80263544, 0x8fb562a3, 0x49deb15a, 0x6725ba1b, 0x9845ea0e, 0xe15dfec0, 0x02c32f75, 0x12814cf0, 0xa38d4697, 0xc66bd3f9, 0xe7038f5f, 0x9515929c, 0xebbf6d7a, 0xda955259, 0x2dd4be83, 0xd3587421, 0x2949e069, 0x448ec9c8, 0x6a75c289, 0x78f48e79, 0x6b99583e, 0xdd27b971, 0xb6bee14f, 0x17f088ad, 0x66c920ac, 0xb47dce3a, 0x1863df4a, 0x82e51a31, 0x60975133, 0x4562537f, 0xe0b16477, 0x84bb6bae, 0x1cfe81a0, 0x94f9082b, 0x58704868, 0x198f45fd, 0x8794de6c, 0xb7527bf8, 0x23ab73d3, 0xe2724b02, 0x57e31f8f, 0x2a6655ab, 0x07b2eb28, 0x032fb5c2, 0x9a86c57b, 0xa5d33708, 0xf2302887, 0xb223bfa5, 0xba02036a, 0x5ced1682, 0x2b8acf1c, 0x92a779b4, 0xf0f307f2, 0xa14e69e2, 0xcd65daf4, 0xd50605be, 0x1fd13462, 0x8ac4a6fe, 0x9d342e53, 0xa0a2f355, 0x32058ae1, 0x75a4f6eb, 0x390b83ec, 0xaa4060ef, 0x065e719f, 0x51bd6e10, 0xf93e218a, 0x3d96dd06, 0xaedd3e05, 0x464de6bd, 0xb591548d, 0x0571c45d, 0x6f0406d4, 0xff605015, 0x241998fb, 0x97d6bde9, 0xcc894043, 0x7767d99e, 0xbdb0e842, 0x8807898b, 0x38e7195b, 0xdb79c8ee, 0x47a17c0a, 0xe97c420f, 0xc9f8841e, 0x00000000, 0x83098086, 0x48322bed, 0xac1e1170, 0x4e6c5a72, 0xfbfd0eff, 0x560f8538, 0x1e3daed5, 0x27362d39, 0x640a0fd9, 0x21685ca6, 0xd19b5b54, 0x3a24362e, 0xb10c0a67, 0x0f9357e7, 0xd2b4ee96, 0x9e1b9b91, 0x4f80c0c5, 0xa261dc20, 0x695a774b, 0x161c121a, 0x0ae293ba, 0xe5c0a02a, 0x433c22e0, 0x1d121b17, 0x0b0e090d, 0xadf28bc7, 0xb92db6a8, 0xc8141ea9, 0x8557f119, 0x4caf7507, 0xbbee99dd, 0xfda37f60, 0x9ff70126, 0xbc5c72f5, 0xc544663b, 0x345bfb7e, 0x768b4329, 0xdccb23c6, 0x68b6edfc, 0x63b8e4f1, 0xcad731dc, 0x10426385, 0x40139722, 0x2084c611, 0x7d854a24, 0xf8d2bb3d, 0x11aef932, 0x6dc729a1, 0x4b1d9e2f, 0xf3dcb230, 0xec0d8652, 0xd077c1e3, 0x6c2bb316, 0x99a970b9, 0xfa119448, 0x2247e964, 0xc4a8fc8c, 0x1aa0f03f, 0xd8567d2c, 0xef223390, 0xc787494e, 0xc1d938d1, 0xfe8ccaa2, 0x3698d40b, 0xcfa6f581, 0x28a57ade, 0x26dab78e, 0xa43fadbf, 0xe42c3a9d, 0x0d507892, 0x9b6a5fcc, 0x62547e46, 0xc2f68d13, 0xe890d8b8, 0x5e2e39f7, 0xf582c3af, 0xbe9f5d80, 0x7c69d093, 0xa96fd52d, 0xb3cf2512, 0x3bc8ac99, 0xa710187d, 0x6ee89c63, 0x7bdb3bbb, 0x09cd2678, 0xf46e5918, 0x01ec9ab7, 0xa8834f9a, 0x65e6956e, 0x7eaaffe6, 0x0821bccf, 0xe6ef15e8, 0xd9bae79b, 0xce4a6f36, 0xd4ea9f09, 0xd629b07c, 0xaf31a4b2, 0x312a3f23, 0x30c6a594, 0xc035a266, 0x37744ebc, 0xa6fc82ca, 0xb0e090d0, 0x1533a7d8, 0x4af10498, 0xf741ecda, 0x0e7fcd50, 0x2f1791f6, 0x8d764dd6, 0x4d43efb0, 0x54ccaa4d, 0xdfe49604, 0xe39ed1b5, 0x1b4c6a88, 0xb8c12c1f, 0x7f466551, 0x049d5eea, 0x5d018c35, 0x73fa8774, 0x2efb0b41, 0x5ab3671d, 0x5292dbd2, 0x33e91056, 0x136dd647, 0x8c9ad761, 0x7a37a10c, 0x8e59f814, 0x89eb133c, 0xeecea927, 0x35b761c9, 0xede11ce5, 0x3c7a47b1, 0x599cd2df, 0x3f55f273, 0x791814ce, 0xbf73c737, 0xea53f7cd, 0x5b5ffdaa, 0x14df3d6f, 0x867844db, 0x81caaff3, 0x3eb968c4, 0x2c382434, 0x5fc2a340, 0x72161dc3, 0x0cbce225, 0x8b283c49, 0x41ff0d95, 0x7139a801, 0xde080cb3, 0x9cd8b4e4, 0x906456c1, 0x617bcb84, 0x70d532b6, 0x74486c5c, 0x42d0b857];
  47133. var T7 = [0xa75051f4, 0x65537e41, 0xa4c31a17, 0x5e963a27, 0x6bcb3bab, 0x45f11f9d, 0x58abacfa, 0x03934be3, 0xfa552030, 0x6df6ad76, 0x769188cc, 0x4c25f502, 0xd7fc4fe5, 0xcbd7c52a, 0x44802635, 0xa38fb562, 0x5a49deb1, 0x1b6725ba, 0x0e9845ea, 0xc0e15dfe, 0x7502c32f, 0xf012814c, 0x97a38d46, 0xf9c66bd3, 0x5fe7038f, 0x9c951592, 0x7aebbf6d, 0x59da9552, 0x832dd4be, 0x21d35874, 0x692949e0, 0xc8448ec9, 0x896a75c2, 0x7978f48e, 0x3e6b9958, 0x71dd27b9, 0x4fb6bee1, 0xad17f088, 0xac66c920, 0x3ab47dce, 0x4a1863df, 0x3182e51a, 0x33609751, 0x7f456253, 0x77e0b164, 0xae84bb6b, 0xa01cfe81, 0x2b94f908, 0x68587048, 0xfd198f45, 0x6c8794de, 0xf8b7527b, 0xd323ab73, 0x02e2724b, 0x8f57e31f, 0xab2a6655, 0x2807b2eb, 0xc2032fb5, 0x7b9a86c5, 0x08a5d337, 0x87f23028, 0xa5b223bf, 0x6aba0203, 0x825ced16, 0x1c2b8acf, 0xb492a779, 0xf2f0f307, 0xe2a14e69, 0xf4cd65da, 0xbed50605, 0x621fd134, 0xfe8ac4a6, 0x539d342e, 0x55a0a2f3, 0xe132058a, 0xeb75a4f6, 0xec390b83, 0xefaa4060, 0x9f065e71, 0x1051bd6e, 0x8af93e21, 0x063d96dd, 0x05aedd3e, 0xbd464de6, 0x8db59154, 0x5d0571c4, 0xd46f0406, 0x15ff6050, 0xfb241998, 0xe997d6bd, 0x43cc8940, 0x9e7767d9, 0x42bdb0e8, 0x8b880789, 0x5b38e719, 0xeedb79c8, 0x0a47a17c, 0x0fe97c42, 0x1ec9f884, 0x00000000, 0x86830980, 0xed48322b, 0x70ac1e11, 0x724e6c5a, 0xfffbfd0e, 0x38560f85, 0xd51e3dae, 0x3927362d, 0xd9640a0f, 0xa621685c, 0x54d19b5b, 0x2e3a2436, 0x67b10c0a, 0xe70f9357, 0x96d2b4ee, 0x919e1b9b, 0xc54f80c0, 0x20a261dc, 0x4b695a77, 0x1a161c12, 0xba0ae293, 0x2ae5c0a0, 0xe0433c22, 0x171d121b, 0x0d0b0e09, 0xc7adf28b, 0xa8b92db6, 0xa9c8141e, 0x198557f1, 0x074caf75, 0xddbbee99, 0x60fda37f, 0x269ff701, 0xf5bc5c72, 0x3bc54466, 0x7e345bfb, 0x29768b43, 0xc6dccb23, 0xfc68b6ed, 0xf163b8e4, 0xdccad731, 0x85104263, 0x22401397, 0x112084c6, 0x247d854a, 0x3df8d2bb, 0x3211aef9, 0xa16dc729, 0x2f4b1d9e, 0x30f3dcb2, 0x52ec0d86, 0xe3d077c1, 0x166c2bb3, 0xb999a970, 0x48fa1194, 0x642247e9, 0x8cc4a8fc, 0x3f1aa0f0, 0x2cd8567d, 0x90ef2233, 0x4ec78749, 0xd1c1d938, 0xa2fe8cca, 0x0b3698d4, 0x81cfa6f5, 0xde28a57a, 0x8e26dab7, 0xbfa43fad, 0x9de42c3a, 0x920d5078, 0xcc9b6a5f, 0x4662547e, 0x13c2f68d, 0xb8e890d8, 0xf75e2e39, 0xaff582c3, 0x80be9f5d, 0x937c69d0, 0x2da96fd5, 0x12b3cf25, 0x993bc8ac, 0x7da71018, 0x636ee89c, 0xbb7bdb3b, 0x7809cd26, 0x18f46e59, 0xb701ec9a, 0x9aa8834f, 0x6e65e695, 0xe67eaaff, 0xcf0821bc, 0xe8e6ef15, 0x9bd9bae7, 0x36ce4a6f, 0x09d4ea9f, 0x7cd629b0, 0xb2af31a4, 0x23312a3f, 0x9430c6a5, 0x66c035a2, 0xbc37744e, 0xcaa6fc82, 0xd0b0e090, 0xd81533a7, 0x984af104, 0xdaf741ec, 0x500e7fcd, 0xf62f1791, 0xd68d764d, 0xb04d43ef, 0x4d54ccaa, 0x04dfe496, 0xb5e39ed1, 0x881b4c6a, 0x1fb8c12c, 0x517f4665, 0xea049d5e, 0x355d018c, 0x7473fa87, 0x412efb0b, 0x1d5ab367, 0xd25292db, 0x5633e910, 0x47136dd6, 0x618c9ad7, 0x0c7a37a1, 0x148e59f8, 0x3c89eb13, 0x27eecea9, 0xc935b761, 0xe5ede11c, 0xb13c7a47, 0xdf599cd2, 0x733f55f2, 0xce791814, 0x37bf73c7, 0xcdea53f7, 0xaa5b5ffd, 0x6f14df3d, 0xdb867844, 0xf381caaf, 0xc43eb968, 0x342c3824, 0x405fc2a3, 0xc372161d, 0x250cbce2, 0x498b283c, 0x9541ff0d, 0x017139a8, 0xb3de080c, 0xe49cd8b4, 0xc1906456, 0x84617bcb, 0xb670d532, 0x5c74486c, 0x5742d0b8];
  47134. var T8 = [0xf4a75051, 0x4165537e, 0x17a4c31a, 0x275e963a, 0xab6bcb3b, 0x9d45f11f, 0xfa58abac, 0xe303934b, 0x30fa5520, 0x766df6ad, 0xcc769188, 0x024c25f5, 0xe5d7fc4f, 0x2acbd7c5, 0x35448026, 0x62a38fb5, 0xb15a49de, 0xba1b6725, 0xea0e9845, 0xfec0e15d, 0x2f7502c3, 0x4cf01281, 0x4697a38d, 0xd3f9c66b, 0x8f5fe703, 0x929c9515, 0x6d7aebbf, 0x5259da95, 0xbe832dd4, 0x7421d358, 0xe0692949, 0xc9c8448e, 0xc2896a75, 0x8e7978f4, 0x583e6b99, 0xb971dd27, 0xe14fb6be, 0x88ad17f0, 0x20ac66c9, 0xce3ab47d, 0xdf4a1863, 0x1a3182e5, 0x51336097, 0x537f4562, 0x6477e0b1, 0x6bae84bb, 0x81a01cfe, 0x082b94f9, 0x48685870, 0x45fd198f, 0xde6c8794, 0x7bf8b752, 0x73d323ab, 0x4b02e272, 0x1f8f57e3, 0x55ab2a66, 0xeb2807b2, 0xb5c2032f, 0xc57b9a86, 0x3708a5d3, 0x2887f230, 0xbfa5b223, 0x036aba02, 0x16825ced, 0xcf1c2b8a, 0x79b492a7, 0x07f2f0f3, 0x69e2a14e, 0xdaf4cd65, 0x05bed506, 0x34621fd1, 0xa6fe8ac4, 0x2e539d34, 0xf355a0a2, 0x8ae13205, 0xf6eb75a4, 0x83ec390b, 0x60efaa40, 0x719f065e, 0x6e1051bd, 0x218af93e, 0xdd063d96, 0x3e05aedd, 0xe6bd464d, 0x548db591, 0xc45d0571, 0x06d46f04, 0x5015ff60, 0x98fb2419, 0xbde997d6, 0x4043cc89, 0xd99e7767, 0xe842bdb0, 0x898b8807, 0x195b38e7, 0xc8eedb79, 0x7c0a47a1, 0x420fe97c, 0x841ec9f8, 0x00000000, 0x80868309, 0x2bed4832, 0x1170ac1e, 0x5a724e6c, 0x0efffbfd, 0x8538560f, 0xaed51e3d, 0x2d392736, 0x0fd9640a, 0x5ca62168, 0x5b54d19b, 0x362e3a24, 0x0a67b10c, 0x57e70f93, 0xee96d2b4, 0x9b919e1b, 0xc0c54f80, 0xdc20a261, 0x774b695a, 0x121a161c, 0x93ba0ae2, 0xa02ae5c0, 0x22e0433c, 0x1b171d12, 0x090d0b0e, 0x8bc7adf2, 0xb6a8b92d, 0x1ea9c814, 0xf1198557, 0x75074caf, 0x99ddbbee, 0x7f60fda3, 0x01269ff7, 0x72f5bc5c, 0x663bc544, 0xfb7e345b, 0x4329768b, 0x23c6dccb, 0xedfc68b6, 0xe4f163b8, 0x31dccad7, 0x63851042, 0x97224013, 0xc6112084, 0x4a247d85, 0xbb3df8d2, 0xf93211ae, 0x29a16dc7, 0x9e2f4b1d, 0xb230f3dc, 0x8652ec0d, 0xc1e3d077, 0xb3166c2b, 0x70b999a9, 0x9448fa11, 0xe9642247, 0xfc8cc4a8, 0xf03f1aa0, 0x7d2cd856, 0x3390ef22, 0x494ec787, 0x38d1c1d9, 0xcaa2fe8c, 0xd40b3698, 0xf581cfa6, 0x7ade28a5, 0xb78e26da, 0xadbfa43f, 0x3a9de42c, 0x78920d50, 0x5fcc9b6a, 0x7e466254, 0x8d13c2f6, 0xd8b8e890, 0x39f75e2e, 0xc3aff582, 0x5d80be9f, 0xd0937c69, 0xd52da96f, 0x2512b3cf, 0xac993bc8, 0x187da710, 0x9c636ee8, 0x3bbb7bdb, 0x267809cd, 0x5918f46e, 0x9ab701ec, 0x4f9aa883, 0x956e65e6, 0xffe67eaa, 0xbccf0821, 0x15e8e6ef, 0xe79bd9ba, 0x6f36ce4a, 0x9f09d4ea, 0xb07cd629, 0xa4b2af31, 0x3f23312a, 0xa59430c6, 0xa266c035, 0x4ebc3774, 0x82caa6fc, 0x90d0b0e0, 0xa7d81533, 0x04984af1, 0xecdaf741, 0xcd500e7f, 0x91f62f17, 0x4dd68d76, 0xefb04d43, 0xaa4d54cc, 0x9604dfe4, 0xd1b5e39e, 0x6a881b4c, 0x2c1fb8c1, 0x65517f46, 0x5eea049d, 0x8c355d01, 0x877473fa, 0x0b412efb, 0x671d5ab3, 0xdbd25292, 0x105633e9, 0xd647136d, 0xd7618c9a, 0xa10c7a37, 0xf8148e59, 0x133c89eb, 0xa927eece, 0x61c935b7, 0x1ce5ede1, 0x47b13c7a, 0xd2df599c, 0xf2733f55, 0x14ce7918, 0xc737bf73, 0xf7cdea53, 0xfdaa5b5f, 0x3d6f14df, 0x44db8678, 0xaff381ca, 0x68c43eb9, 0x24342c38, 0xa3405fc2, 0x1dc37216, 0xe2250cbc, 0x3c498b28, 0x0d9541ff, 0xa8017139, 0x0cb3de08, 0xb4e49cd8, 0x56c19064, 0xcb84617b, 0x32b670d5, 0x6c5c7448, 0xb85742d0];
  47135. // Transformations for decryption key expansion
  47136. var U1 = [0x00000000, 0x0e090d0b, 0x1c121a16, 0x121b171d, 0x3824342c, 0x362d3927, 0x24362e3a, 0x2a3f2331, 0x70486858, 0x7e416553, 0x6c5a724e, 0x62537f45, 0x486c5c74, 0x4665517f, 0x547e4662, 0x5a774b69, 0xe090d0b0, 0xee99ddbb, 0xfc82caa6, 0xf28bc7ad, 0xd8b4e49c, 0xd6bde997, 0xc4a6fe8a, 0xcaaff381, 0x90d8b8e8, 0x9ed1b5e3, 0x8ccaa2fe, 0x82c3aff5, 0xa8fc8cc4, 0xa6f581cf, 0xb4ee96d2, 0xbae79bd9, 0xdb3bbb7b, 0xd532b670, 0xc729a16d, 0xc920ac66, 0xe31f8f57, 0xed16825c, 0xff0d9541, 0xf104984a, 0xab73d323, 0xa57ade28, 0xb761c935, 0xb968c43e, 0x9357e70f, 0x9d5eea04, 0x8f45fd19, 0x814cf012, 0x3bab6bcb, 0x35a266c0, 0x27b971dd, 0x29b07cd6, 0x038f5fe7, 0x0d8652ec, 0x1f9d45f1, 0x119448fa, 0x4be30393, 0x45ea0e98, 0x57f11985, 0x59f8148e, 0x73c737bf, 0x7dce3ab4, 0x6fd52da9, 0x61dc20a2, 0xad766df6, 0xa37f60fd, 0xb16477e0, 0xbf6d7aeb, 0x955259da, 0x9b5b54d1, 0x894043cc, 0x87494ec7, 0xdd3e05ae, 0xd33708a5, 0xc12c1fb8, 0xcf2512b3, 0xe51a3182, 0xeb133c89, 0xf9082b94, 0xf701269f, 0x4de6bd46, 0x43efb04d, 0x51f4a750, 0x5ffdaa5b, 0x75c2896a, 0x7bcb8461, 0x69d0937c, 0x67d99e77, 0x3daed51e, 0x33a7d815, 0x21bccf08, 0x2fb5c203, 0x058ae132, 0x0b83ec39, 0x1998fb24, 0x1791f62f, 0x764dd68d, 0x7844db86, 0x6a5fcc9b, 0x6456c190, 0x4e69e2a1, 0x4060efaa, 0x527bf8b7, 0x5c72f5bc, 0x0605bed5, 0x080cb3de, 0x1a17a4c3, 0x141ea9c8, 0x3e218af9, 0x302887f2, 0x223390ef, 0x2c3a9de4, 0x96dd063d, 0x98d40b36, 0x8acf1c2b, 0x84c61120, 0xaef93211, 0xa0f03f1a, 0xb2eb2807, 0xbce2250c, 0xe6956e65, 0xe89c636e, 0xfa877473, 0xf48e7978, 0xdeb15a49, 0xd0b85742, 0xc2a3405f, 0xccaa4d54, 0x41ecdaf7, 0x4fe5d7fc, 0x5dfec0e1, 0x53f7cdea, 0x79c8eedb, 0x77c1e3d0, 0x65daf4cd, 0x6bd3f9c6, 0x31a4b2af, 0x3fadbfa4, 0x2db6a8b9, 0x23bfa5b2, 0x09808683, 0x07898b88, 0x15929c95, 0x1b9b919e, 0xa17c0a47, 0xaf75074c, 0xbd6e1051, 0xb3671d5a, 0x99583e6b, 0x97513360, 0x854a247d, 0x8b432976, 0xd134621f, 0xdf3d6f14, 0xcd267809, 0xc32f7502, 0xe9105633, 0xe7195b38, 0xf5024c25, 0xfb0b412e, 0x9ad7618c, 0x94de6c87, 0x86c57b9a, 0x88cc7691, 0xa2f355a0, 0xacfa58ab, 0xbee14fb6, 0xb0e842bd, 0xea9f09d4, 0xe49604df, 0xf68d13c2, 0xf8841ec9, 0xd2bb3df8, 0xdcb230f3, 0xcea927ee, 0xc0a02ae5, 0x7a47b13c, 0x744ebc37, 0x6655ab2a, 0x685ca621, 0x42638510, 0x4c6a881b, 0x5e719f06, 0x5078920d, 0x0a0fd964, 0x0406d46f, 0x161dc372, 0x1814ce79, 0x322bed48, 0x3c22e043, 0x2e39f75e, 0x2030fa55, 0xec9ab701, 0xe293ba0a, 0xf088ad17, 0xfe81a01c, 0xd4be832d, 0xdab78e26, 0xc8ac993b, 0xc6a59430, 0x9cd2df59, 0x92dbd252, 0x80c0c54f, 0x8ec9c844, 0xa4f6eb75, 0xaaffe67e, 0xb8e4f163, 0xb6edfc68, 0x0c0a67b1, 0x02036aba, 0x10187da7, 0x1e1170ac, 0x342e539d, 0x3a275e96, 0x283c498b, 0x26354480, 0x7c420fe9, 0x724b02e2, 0x605015ff, 0x6e5918f4, 0x44663bc5, 0x4a6f36ce, 0x587421d3, 0x567d2cd8, 0x37a10c7a, 0x39a80171, 0x2bb3166c, 0x25ba1b67, 0x0f853856, 0x018c355d, 0x13972240, 0x1d9e2f4b, 0x47e96422, 0x49e06929, 0x5bfb7e34, 0x55f2733f, 0x7fcd500e, 0x71c45d05, 0x63df4a18, 0x6dd64713, 0xd731dcca, 0xd938d1c1, 0xcb23c6dc, 0xc52acbd7, 0xef15e8e6, 0xe11ce5ed, 0xf307f2f0, 0xfd0efffb, 0xa779b492, 0xa970b999, 0xbb6bae84, 0xb562a38f, 0x9f5d80be, 0x91548db5, 0x834f9aa8, 0x8d4697a3];
  47137. var U2 = [0x00000000, 0x0b0e090d, 0x161c121a, 0x1d121b17, 0x2c382434, 0x27362d39, 0x3a24362e, 0x312a3f23, 0x58704868, 0x537e4165, 0x4e6c5a72, 0x4562537f, 0x74486c5c, 0x7f466551, 0x62547e46, 0x695a774b, 0xb0e090d0, 0xbbee99dd, 0xa6fc82ca, 0xadf28bc7, 0x9cd8b4e4, 0x97d6bde9, 0x8ac4a6fe, 0x81caaff3, 0xe890d8b8, 0xe39ed1b5, 0xfe8ccaa2, 0xf582c3af, 0xc4a8fc8c, 0xcfa6f581, 0xd2b4ee96, 0xd9bae79b, 0x7bdb3bbb, 0x70d532b6, 0x6dc729a1, 0x66c920ac, 0x57e31f8f, 0x5ced1682, 0x41ff0d95, 0x4af10498, 0x23ab73d3, 0x28a57ade, 0x35b761c9, 0x3eb968c4, 0x0f9357e7, 0x049d5eea, 0x198f45fd, 0x12814cf0, 0xcb3bab6b, 0xc035a266, 0xdd27b971, 0xd629b07c, 0xe7038f5f, 0xec0d8652, 0xf11f9d45, 0xfa119448, 0x934be303, 0x9845ea0e, 0x8557f119, 0x8e59f814, 0xbf73c737, 0xb47dce3a, 0xa96fd52d, 0xa261dc20, 0xf6ad766d, 0xfda37f60, 0xe0b16477, 0xebbf6d7a, 0xda955259, 0xd19b5b54, 0xcc894043, 0xc787494e, 0xaedd3e05, 0xa5d33708, 0xb8c12c1f, 0xb3cf2512, 0x82e51a31, 0x89eb133c, 0x94f9082b, 0x9ff70126, 0x464de6bd, 0x4d43efb0, 0x5051f4a7, 0x5b5ffdaa, 0x6a75c289, 0x617bcb84, 0x7c69d093, 0x7767d99e, 0x1e3daed5, 0x1533a7d8, 0x0821bccf, 0x032fb5c2, 0x32058ae1, 0x390b83ec, 0x241998fb, 0x2f1791f6, 0x8d764dd6, 0x867844db, 0x9b6a5fcc, 0x906456c1, 0xa14e69e2, 0xaa4060ef, 0xb7527bf8, 0xbc5c72f5, 0xd50605be, 0xde080cb3, 0xc31a17a4, 0xc8141ea9, 0xf93e218a, 0xf2302887, 0xef223390, 0xe42c3a9d, 0x3d96dd06, 0x3698d40b, 0x2b8acf1c, 0x2084c611, 0x11aef932, 0x1aa0f03f, 0x07b2eb28, 0x0cbce225, 0x65e6956e, 0x6ee89c63, 0x73fa8774, 0x78f48e79, 0x49deb15a, 0x42d0b857, 0x5fc2a340, 0x54ccaa4d, 0xf741ecda, 0xfc4fe5d7, 0xe15dfec0, 0xea53f7cd, 0xdb79c8ee, 0xd077c1e3, 0xcd65daf4, 0xc66bd3f9, 0xaf31a4b2, 0xa43fadbf, 0xb92db6a8, 0xb223bfa5, 0x83098086, 0x8807898b, 0x9515929c, 0x9e1b9b91, 0x47a17c0a, 0x4caf7507, 0x51bd6e10, 0x5ab3671d, 0x6b99583e, 0x60975133, 0x7d854a24, 0x768b4329, 0x1fd13462, 0x14df3d6f, 0x09cd2678, 0x02c32f75, 0x33e91056, 0x38e7195b, 0x25f5024c, 0x2efb0b41, 0x8c9ad761, 0x8794de6c, 0x9a86c57b, 0x9188cc76, 0xa0a2f355, 0xabacfa58, 0xb6bee14f, 0xbdb0e842, 0xd4ea9f09, 0xdfe49604, 0xc2f68d13, 0xc9f8841e, 0xf8d2bb3d, 0xf3dcb230, 0xeecea927, 0xe5c0a02a, 0x3c7a47b1, 0x37744ebc, 0x2a6655ab, 0x21685ca6, 0x10426385, 0x1b4c6a88, 0x065e719f, 0x0d507892, 0x640a0fd9, 0x6f0406d4, 0x72161dc3, 0x791814ce, 0x48322bed, 0x433c22e0, 0x5e2e39f7, 0x552030fa, 0x01ec9ab7, 0x0ae293ba, 0x17f088ad, 0x1cfe81a0, 0x2dd4be83, 0x26dab78e, 0x3bc8ac99, 0x30c6a594, 0x599cd2df, 0x5292dbd2, 0x4f80c0c5, 0x448ec9c8, 0x75a4f6eb, 0x7eaaffe6, 0x63b8e4f1, 0x68b6edfc, 0xb10c0a67, 0xba02036a, 0xa710187d, 0xac1e1170, 0x9d342e53, 0x963a275e, 0x8b283c49, 0x80263544, 0xe97c420f, 0xe2724b02, 0xff605015, 0xf46e5918, 0xc544663b, 0xce4a6f36, 0xd3587421, 0xd8567d2c, 0x7a37a10c, 0x7139a801, 0x6c2bb316, 0x6725ba1b, 0x560f8538, 0x5d018c35, 0x40139722, 0x4b1d9e2f, 0x2247e964, 0x2949e069, 0x345bfb7e, 0x3f55f273, 0x0e7fcd50, 0x0571c45d, 0x1863df4a, 0x136dd647, 0xcad731dc, 0xc1d938d1, 0xdccb23c6, 0xd7c52acb, 0xe6ef15e8, 0xede11ce5, 0xf0f307f2, 0xfbfd0eff, 0x92a779b4, 0x99a970b9, 0x84bb6bae, 0x8fb562a3, 0xbe9f5d80, 0xb591548d, 0xa8834f9a, 0xa38d4697];
  47138. var U3 = [0x00000000, 0x0d0b0e09, 0x1a161c12, 0x171d121b, 0x342c3824, 0x3927362d, 0x2e3a2436, 0x23312a3f, 0x68587048, 0x65537e41, 0x724e6c5a, 0x7f456253, 0x5c74486c, 0x517f4665, 0x4662547e, 0x4b695a77, 0xd0b0e090, 0xddbbee99, 0xcaa6fc82, 0xc7adf28b, 0xe49cd8b4, 0xe997d6bd, 0xfe8ac4a6, 0xf381caaf, 0xb8e890d8, 0xb5e39ed1, 0xa2fe8cca, 0xaff582c3, 0x8cc4a8fc, 0x81cfa6f5, 0x96d2b4ee, 0x9bd9bae7, 0xbb7bdb3b, 0xb670d532, 0xa16dc729, 0xac66c920, 0x8f57e31f, 0x825ced16, 0x9541ff0d, 0x984af104, 0xd323ab73, 0xde28a57a, 0xc935b761, 0xc43eb968, 0xe70f9357, 0xea049d5e, 0xfd198f45, 0xf012814c, 0x6bcb3bab, 0x66c035a2, 0x71dd27b9, 0x7cd629b0, 0x5fe7038f, 0x52ec0d86, 0x45f11f9d, 0x48fa1194, 0x03934be3, 0x0e9845ea, 0x198557f1, 0x148e59f8, 0x37bf73c7, 0x3ab47dce, 0x2da96fd5, 0x20a261dc, 0x6df6ad76, 0x60fda37f, 0x77e0b164, 0x7aebbf6d, 0x59da9552, 0x54d19b5b, 0x43cc8940, 0x4ec78749, 0x05aedd3e, 0x08a5d337, 0x1fb8c12c, 0x12b3cf25, 0x3182e51a, 0x3c89eb13, 0x2b94f908, 0x269ff701, 0xbd464de6, 0xb04d43ef, 0xa75051f4, 0xaa5b5ffd, 0x896a75c2, 0x84617bcb, 0x937c69d0, 0x9e7767d9, 0xd51e3dae, 0xd81533a7, 0xcf0821bc, 0xc2032fb5, 0xe132058a, 0xec390b83, 0xfb241998, 0xf62f1791, 0xd68d764d, 0xdb867844, 0xcc9b6a5f, 0xc1906456, 0xe2a14e69, 0xefaa4060, 0xf8b7527b, 0xf5bc5c72, 0xbed50605, 0xb3de080c, 0xa4c31a17, 0xa9c8141e, 0x8af93e21, 0x87f23028, 0x90ef2233, 0x9de42c3a, 0x063d96dd, 0x0b3698d4, 0x1c2b8acf, 0x112084c6, 0x3211aef9, 0x3f1aa0f0, 0x2807b2eb, 0x250cbce2, 0x6e65e695, 0x636ee89c, 0x7473fa87, 0x7978f48e, 0x5a49deb1, 0x5742d0b8, 0x405fc2a3, 0x4d54ccaa, 0xdaf741ec, 0xd7fc4fe5, 0xc0e15dfe, 0xcdea53f7, 0xeedb79c8, 0xe3d077c1, 0xf4cd65da, 0xf9c66bd3, 0xb2af31a4, 0xbfa43fad, 0xa8b92db6, 0xa5b223bf, 0x86830980, 0x8b880789, 0x9c951592, 0x919e1b9b, 0x0a47a17c, 0x074caf75, 0x1051bd6e, 0x1d5ab367, 0x3e6b9958, 0x33609751, 0x247d854a, 0x29768b43, 0x621fd134, 0x6f14df3d, 0x7809cd26, 0x7502c32f, 0x5633e910, 0x5b38e719, 0x4c25f502, 0x412efb0b, 0x618c9ad7, 0x6c8794de, 0x7b9a86c5, 0x769188cc, 0x55a0a2f3, 0x58abacfa, 0x4fb6bee1, 0x42bdb0e8, 0x09d4ea9f, 0x04dfe496, 0x13c2f68d, 0x1ec9f884, 0x3df8d2bb, 0x30f3dcb2, 0x27eecea9, 0x2ae5c0a0, 0xb13c7a47, 0xbc37744e, 0xab2a6655, 0xa621685c, 0x85104263, 0x881b4c6a, 0x9f065e71, 0x920d5078, 0xd9640a0f, 0xd46f0406, 0xc372161d, 0xce791814, 0xed48322b, 0xe0433c22, 0xf75e2e39, 0xfa552030, 0xb701ec9a, 0xba0ae293, 0xad17f088, 0xa01cfe81, 0x832dd4be, 0x8e26dab7, 0x993bc8ac, 0x9430c6a5, 0xdf599cd2, 0xd25292db, 0xc54f80c0, 0xc8448ec9, 0xeb75a4f6, 0xe67eaaff, 0xf163b8e4, 0xfc68b6ed, 0x67b10c0a, 0x6aba0203, 0x7da71018, 0x70ac1e11, 0x539d342e, 0x5e963a27, 0x498b283c, 0x44802635, 0x0fe97c42, 0x02e2724b, 0x15ff6050, 0x18f46e59, 0x3bc54466, 0x36ce4a6f, 0x21d35874, 0x2cd8567d, 0x0c7a37a1, 0x017139a8, 0x166c2bb3, 0x1b6725ba, 0x38560f85, 0x355d018c, 0x22401397, 0x2f4b1d9e, 0x642247e9, 0x692949e0, 0x7e345bfb, 0x733f55f2, 0x500e7fcd, 0x5d0571c4, 0x4a1863df, 0x47136dd6, 0xdccad731, 0xd1c1d938, 0xc6dccb23, 0xcbd7c52a, 0xe8e6ef15, 0xe5ede11c, 0xf2f0f307, 0xfffbfd0e, 0xb492a779, 0xb999a970, 0xae84bb6b, 0xa38fb562, 0x80be9f5d, 0x8db59154, 0x9aa8834f, 0x97a38d46];
  47139. var U4 = [0x00000000, 0x090d0b0e, 0x121a161c, 0x1b171d12, 0x24342c38, 0x2d392736, 0x362e3a24, 0x3f23312a, 0x48685870, 0x4165537e, 0x5a724e6c, 0x537f4562, 0x6c5c7448, 0x65517f46, 0x7e466254, 0x774b695a, 0x90d0b0e0, 0x99ddbbee, 0x82caa6fc, 0x8bc7adf2, 0xb4e49cd8, 0xbde997d6, 0xa6fe8ac4, 0xaff381ca, 0xd8b8e890, 0xd1b5e39e, 0xcaa2fe8c, 0xc3aff582, 0xfc8cc4a8, 0xf581cfa6, 0xee96d2b4, 0xe79bd9ba, 0x3bbb7bdb, 0x32b670d5, 0x29a16dc7, 0x20ac66c9, 0x1f8f57e3, 0x16825ced, 0x0d9541ff, 0x04984af1, 0x73d323ab, 0x7ade28a5, 0x61c935b7, 0x68c43eb9, 0x57e70f93, 0x5eea049d, 0x45fd198f, 0x4cf01281, 0xab6bcb3b, 0xa266c035, 0xb971dd27, 0xb07cd629, 0x8f5fe703, 0x8652ec0d, 0x9d45f11f, 0x9448fa11, 0xe303934b, 0xea0e9845, 0xf1198557, 0xf8148e59, 0xc737bf73, 0xce3ab47d, 0xd52da96f, 0xdc20a261, 0x766df6ad, 0x7f60fda3, 0x6477e0b1, 0x6d7aebbf, 0x5259da95, 0x5b54d19b, 0x4043cc89, 0x494ec787, 0x3e05aedd, 0x3708a5d3, 0x2c1fb8c1, 0x2512b3cf, 0x1a3182e5, 0x133c89eb, 0x082b94f9, 0x01269ff7, 0xe6bd464d, 0xefb04d43, 0xf4a75051, 0xfdaa5b5f, 0xc2896a75, 0xcb84617b, 0xd0937c69, 0xd99e7767, 0xaed51e3d, 0xa7d81533, 0xbccf0821, 0xb5c2032f, 0x8ae13205, 0x83ec390b, 0x98fb2419, 0x91f62f17, 0x4dd68d76, 0x44db8678, 0x5fcc9b6a, 0x56c19064, 0x69e2a14e, 0x60efaa40, 0x7bf8b752, 0x72f5bc5c, 0x05bed506, 0x0cb3de08, 0x17a4c31a, 0x1ea9c814, 0x218af93e, 0x2887f230, 0x3390ef22, 0x3a9de42c, 0xdd063d96, 0xd40b3698, 0xcf1c2b8a, 0xc6112084, 0xf93211ae, 0xf03f1aa0, 0xeb2807b2, 0xe2250cbc, 0x956e65e6, 0x9c636ee8, 0x877473fa, 0x8e7978f4, 0xb15a49de, 0xb85742d0, 0xa3405fc2, 0xaa4d54cc, 0xecdaf741, 0xe5d7fc4f, 0xfec0e15d, 0xf7cdea53, 0xc8eedb79, 0xc1e3d077, 0xdaf4cd65, 0xd3f9c66b, 0xa4b2af31, 0xadbfa43f, 0xb6a8b92d, 0xbfa5b223, 0x80868309, 0x898b8807, 0x929c9515, 0x9b919e1b, 0x7c0a47a1, 0x75074caf, 0x6e1051bd, 0x671d5ab3, 0x583e6b99, 0x51336097, 0x4a247d85, 0x4329768b, 0x34621fd1, 0x3d6f14df, 0x267809cd, 0x2f7502c3, 0x105633e9, 0x195b38e7, 0x024c25f5, 0x0b412efb, 0xd7618c9a, 0xde6c8794, 0xc57b9a86, 0xcc769188, 0xf355a0a2, 0xfa58abac, 0xe14fb6be, 0xe842bdb0, 0x9f09d4ea, 0x9604dfe4, 0x8d13c2f6, 0x841ec9f8, 0xbb3df8d2, 0xb230f3dc, 0xa927eece, 0xa02ae5c0, 0x47b13c7a, 0x4ebc3774, 0x55ab2a66, 0x5ca62168, 0x63851042, 0x6a881b4c, 0x719f065e, 0x78920d50, 0x0fd9640a, 0x06d46f04, 0x1dc37216, 0x14ce7918, 0x2bed4832, 0x22e0433c, 0x39f75e2e, 0x30fa5520, 0x9ab701ec, 0x93ba0ae2, 0x88ad17f0, 0x81a01cfe, 0xbe832dd4, 0xb78e26da, 0xac993bc8, 0xa59430c6, 0xd2df599c, 0xdbd25292, 0xc0c54f80, 0xc9c8448e, 0xf6eb75a4, 0xffe67eaa, 0xe4f163b8, 0xedfc68b6, 0x0a67b10c, 0x036aba02, 0x187da710, 0x1170ac1e, 0x2e539d34, 0x275e963a, 0x3c498b28, 0x35448026, 0x420fe97c, 0x4b02e272, 0x5015ff60, 0x5918f46e, 0x663bc544, 0x6f36ce4a, 0x7421d358, 0x7d2cd856, 0xa10c7a37, 0xa8017139, 0xb3166c2b, 0xba1b6725, 0x8538560f, 0x8c355d01, 0x97224013, 0x9e2f4b1d, 0xe9642247, 0xe0692949, 0xfb7e345b, 0xf2733f55, 0xcd500e7f, 0xc45d0571, 0xdf4a1863, 0xd647136d, 0x31dccad7, 0x38d1c1d9, 0x23c6dccb, 0x2acbd7c5, 0x15e8e6ef, 0x1ce5ede1, 0x07f2f0f3, 0x0efffbfd, 0x79b492a7, 0x70b999a9, 0x6bae84bb, 0x62a38fb5, 0x5d80be9f, 0x548db591, 0x4f9aa883, 0x4697a38d];
  47140. function convertToInt32(bytes) {
  47141. var result = [];
  47142. for (var i = 0; i < bytes.length; i += 4) {
  47143. result.push(
  47144. (bytes[i ] << 24) |
  47145. (bytes[i + 1] << 16) |
  47146. (bytes[i + 2] << 8) |
  47147. bytes[i + 3]
  47148. );
  47149. }
  47150. return result;
  47151. }
  47152. var AES = function(key) {
  47153. if (!(this instanceof AES)) {
  47154. throw Error('AES must be instanitated with `new`');
  47155. }
  47156. Object.defineProperty(this, 'key', {
  47157. value: coerceArray(key, true)
  47158. });
  47159. this._prepare();
  47160. }
  47161. AES.prototype._prepare = function() {
  47162. var rounds = numberOfRounds[this.key.length];
  47163. if (rounds == null) {
  47164. throw new Error('invalid key size (must be 16, 24 or 32 bytes)');
  47165. }
  47166. // encryption round keys
  47167. this._Ke = [];
  47168. // decryption round keys
  47169. this._Kd = [];
  47170. for (var i = 0; i <= rounds; i++) {
  47171. this._Ke.push([0, 0, 0, 0]);
  47172. this._Kd.push([0, 0, 0, 0]);
  47173. }
  47174. var roundKeyCount = (rounds + 1) * 4;
  47175. var KC = this.key.length / 4;
  47176. // convert the key into ints
  47177. var tk = convertToInt32(this.key);
  47178. // copy values into round key arrays
  47179. var index;
  47180. for (var i = 0; i < KC; i++) {
  47181. index = i >> 2;
  47182. this._Ke[index][i % 4] = tk[i];
  47183. this._Kd[rounds - index][i % 4] = tk[i];
  47184. }
  47185. // key expansion (fips-197 section 5.2)
  47186. var rconpointer = 0;
  47187. var t = KC, tt;
  47188. while (t < roundKeyCount) {
  47189. tt = tk[KC - 1];
  47190. tk[0] ^= ((S[(tt >> 16) & 0xFF] << 24) ^
  47191. (S[(tt >> 8) & 0xFF] << 16) ^
  47192. (S[ tt & 0xFF] << 8) ^
  47193. S[(tt >> 24) & 0xFF] ^
  47194. (rcon[rconpointer] << 24));
  47195. rconpointer += 1;
  47196. // key expansion (for non-256 bit)
  47197. if (KC != 8) {
  47198. for (var i = 1; i < KC; i++) {
  47199. tk[i] ^= tk[i - 1];
  47200. }
  47201. // key expansion for 256-bit keys is "slightly different" (fips-197)
  47202. } else {
  47203. for (var i = 1; i < (KC / 2); i++) {
  47204. tk[i] ^= tk[i - 1];
  47205. }
  47206. tt = tk[(KC / 2) - 1];
  47207. tk[KC / 2] ^= (S[ tt & 0xFF] ^
  47208. (S[(tt >> 8) & 0xFF] << 8) ^
  47209. (S[(tt >> 16) & 0xFF] << 16) ^
  47210. (S[(tt >> 24) & 0xFF] << 24));
  47211. for (var i = (KC / 2) + 1; i < KC; i++) {
  47212. tk[i] ^= tk[i - 1];
  47213. }
  47214. }
  47215. // copy values into round key arrays
  47216. var i = 0, r, c;
  47217. while (i < KC && t < roundKeyCount) {
  47218. r = t >> 2;
  47219. c = t % 4;
  47220. this._Ke[r][c] = tk[i];
  47221. this._Kd[rounds - r][c] = tk[i++];
  47222. t++;
  47223. }
  47224. }
  47225. // inverse-cipher-ify the decryption round key (fips-197 section 5.3)
  47226. for (var r = 1; r < rounds; r++) {
  47227. for (var c = 0; c < 4; c++) {
  47228. tt = this._Kd[r][c];
  47229. this._Kd[r][c] = (U1[(tt >> 24) & 0xFF] ^
  47230. U2[(tt >> 16) & 0xFF] ^
  47231. U3[(tt >> 8) & 0xFF] ^
  47232. U4[ tt & 0xFF]);
  47233. }
  47234. }
  47235. }
  47236. AES.prototype.encrypt = function(plaintext) {
  47237. if (plaintext.length != 16) {
  47238. throw new Error('invalid plaintext size (must be 16 bytes)');
  47239. }
  47240. var rounds = this._Ke.length - 1;
  47241. var a = [0, 0, 0, 0];
  47242. // convert plaintext to (ints ^ key)
  47243. var t = convertToInt32(plaintext);
  47244. for (var i = 0; i < 4; i++) {
  47245. t[i] ^= this._Ke[0][i];
  47246. }
  47247. // apply round transforms
  47248. for (var r = 1; r < rounds; r++) {
  47249. for (var i = 0; i < 4; i++) {
  47250. a[i] = (T1[(t[ i ] >> 24) & 0xff] ^
  47251. T2[(t[(i + 1) % 4] >> 16) & 0xff] ^
  47252. T3[(t[(i + 2) % 4] >> 8) & 0xff] ^
  47253. T4[ t[(i + 3) % 4] & 0xff] ^
  47254. this._Ke[r][i]);
  47255. }
  47256. t = a.slice();
  47257. }
  47258. // the last round is special
  47259. var result = createArray(16), tt;
  47260. for (var i = 0; i < 4; i++) {
  47261. tt = this._Ke[rounds][i];
  47262. result[4 * i ] = (S[(t[ i ] >> 24) & 0xff] ^ (tt >> 24)) & 0xff;
  47263. result[4 * i + 1] = (S[(t[(i + 1) % 4] >> 16) & 0xff] ^ (tt >> 16)) & 0xff;
  47264. result[4 * i + 2] = (S[(t[(i + 2) % 4] >> 8) & 0xff] ^ (tt >> 8)) & 0xff;
  47265. result[4 * i + 3] = (S[ t[(i + 3) % 4] & 0xff] ^ tt ) & 0xff;
  47266. }
  47267. return result;
  47268. }
  47269. AES.prototype.decrypt = function(ciphertext) {
  47270. if (ciphertext.length != 16) {
  47271. throw new Error('invalid ciphertext size (must be 16 bytes)');
  47272. }
  47273. var rounds = this._Kd.length - 1;
  47274. var a = [0, 0, 0, 0];
  47275. // convert plaintext to (ints ^ key)
  47276. var t = convertToInt32(ciphertext);
  47277. for (var i = 0; i < 4; i++) {
  47278. t[i] ^= this._Kd[0][i];
  47279. }
  47280. // apply round transforms
  47281. for (var r = 1; r < rounds; r++) {
  47282. for (var i = 0; i < 4; i++) {
  47283. a[i] = (T5[(t[ i ] >> 24) & 0xff] ^
  47284. T6[(t[(i + 3) % 4] >> 16) & 0xff] ^
  47285. T7[(t[(i + 2) % 4] >> 8) & 0xff] ^
  47286. T8[ t[(i + 1) % 4] & 0xff] ^
  47287. this._Kd[r][i]);
  47288. }
  47289. t = a.slice();
  47290. }
  47291. // the last round is special
  47292. var result = createArray(16), tt;
  47293. for (var i = 0; i < 4; i++) {
  47294. tt = this._Kd[rounds][i];
  47295. result[4 * i ] = (Si[(t[ i ] >> 24) & 0xff] ^ (tt >> 24)) & 0xff;
  47296. result[4 * i + 1] = (Si[(t[(i + 3) % 4] >> 16) & 0xff] ^ (tt >> 16)) & 0xff;
  47297. result[4 * i + 2] = (Si[(t[(i + 2) % 4] >> 8) & 0xff] ^ (tt >> 8)) & 0xff;
  47298. result[4 * i + 3] = (Si[ t[(i + 1) % 4] & 0xff] ^ tt ) & 0xff;
  47299. }
  47300. return result;
  47301. }
  47302. /**
  47303. * Mode Of Operation - Electonic Codebook (ECB)
  47304. */
  47305. var ModeOfOperationECB = function(key) {
  47306. if (!(this instanceof ModeOfOperationECB)) {
  47307. throw Error('AES must be instanitated with `new`');
  47308. }
  47309. this.description = "Electronic Code Block";
  47310. this.name = "ecb";
  47311. this._aes = new AES(key);
  47312. }
  47313. ModeOfOperationECB.prototype.encrypt = function(plaintext) {
  47314. plaintext = coerceArray(plaintext);
  47315. if ((plaintext.length % 16) !== 0) {
  47316. throw new Error('invalid plaintext size (must be multiple of 16 bytes)');
  47317. }
  47318. var ciphertext = createArray(plaintext.length);
  47319. var block = createArray(16);
  47320. for (var i = 0; i < plaintext.length; i += 16) {
  47321. copyArray(plaintext, block, 0, i, i + 16);
  47322. block = this._aes.encrypt(block);
  47323. copyArray(block, ciphertext, i);
  47324. }
  47325. return ciphertext;
  47326. }
  47327. ModeOfOperationECB.prototype.decrypt = function(ciphertext) {
  47328. ciphertext = coerceArray(ciphertext);
  47329. if ((ciphertext.length % 16) !== 0) {
  47330. throw new Error('invalid ciphertext size (must be multiple of 16 bytes)');
  47331. }
  47332. var plaintext = createArray(ciphertext.length);
  47333. var block = createArray(16);
  47334. for (var i = 0; i < ciphertext.length; i += 16) {
  47335. copyArray(ciphertext, block, 0, i, i + 16);
  47336. block = this._aes.decrypt(block);
  47337. copyArray(block, plaintext, i);
  47338. }
  47339. return plaintext;
  47340. }
  47341. /**
  47342. * Mode Of Operation - Cipher Block Chaining (CBC)
  47343. */
  47344. var ModeOfOperationCBC = function(key, iv) {
  47345. if (!(this instanceof ModeOfOperationCBC)) {
  47346. throw Error('AES must be instanitated with `new`');
  47347. }
  47348. this.description = "Cipher Block Chaining";
  47349. this.name = "cbc";
  47350. if (!iv) {
  47351. iv = createArray(16);
  47352. } else if (iv.length != 16) {
  47353. throw new Error('invalid initialation vector size (must be 16 bytes)');
  47354. }
  47355. this._lastCipherblock = coerceArray(iv, true);
  47356. this._aes = new AES(key);
  47357. }
  47358. ModeOfOperationCBC.prototype.encrypt = function(plaintext) {
  47359. plaintext = coerceArray(plaintext);
  47360. if ((plaintext.length % 16) !== 0) {
  47361. throw new Error('invalid plaintext size (must be multiple of 16 bytes)');
  47362. }
  47363. var ciphertext = createArray(plaintext.length);
  47364. var block = createArray(16);
  47365. for (var i = 0; i < plaintext.length; i += 16) {
  47366. copyArray(plaintext, block, 0, i, i + 16);
  47367. for (var j = 0; j < 16; j++) {
  47368. block[j] ^= this._lastCipherblock[j];
  47369. }
  47370. this._lastCipherblock = this._aes.encrypt(block);
  47371. copyArray(this._lastCipherblock, ciphertext, i);
  47372. }
  47373. return ciphertext;
  47374. }
  47375. ModeOfOperationCBC.prototype.decrypt = function(ciphertext) {
  47376. ciphertext = coerceArray(ciphertext);
  47377. if ((ciphertext.length % 16) !== 0) {
  47378. throw new Error('invalid ciphertext size (must be multiple of 16 bytes)');
  47379. }
  47380. var plaintext = createArray(ciphertext.length);
  47381. var block = createArray(16);
  47382. for (var i = 0; i < ciphertext.length; i += 16) {
  47383. copyArray(ciphertext, block, 0, i, i + 16);
  47384. block = this._aes.decrypt(block);
  47385. for (var j = 0; j < 16; j++) {
  47386. plaintext[i + j] = block[j] ^ this._lastCipherblock[j];
  47387. }
  47388. copyArray(ciphertext, this._lastCipherblock, 0, i, i + 16);
  47389. }
  47390. return plaintext;
  47391. }
  47392. /**
  47393. * Mode Of Operation - Cipher Feedback (CFB)
  47394. */
  47395. var ModeOfOperationCFB = function(key, iv, segmentSize) {
  47396. if (!(this instanceof ModeOfOperationCFB)) {
  47397. throw Error('AES must be instanitated with `new`');
  47398. }
  47399. this.description = "Cipher Feedback";
  47400. this.name = "cfb";
  47401. if (!iv) {
  47402. iv = createArray(16);
  47403. } else if (iv.length != 16) {
  47404. throw new Error('invalid initialation vector size (must be 16 size)');
  47405. }
  47406. if (!segmentSize) { segmentSize = 1; }
  47407. this.segmentSize = segmentSize;
  47408. this._shiftRegister = coerceArray(iv, true);
  47409. this._aes = new AES(key);
  47410. }
  47411. ModeOfOperationCFB.prototype.encrypt = function(plaintext) {
  47412. if ((plaintext.length % this.segmentSize) != 0) {
  47413. throw new Error('invalid plaintext size (must be segmentSize bytes)');
  47414. }
  47415. var encrypted = coerceArray(plaintext, true);
  47416. var xorSegment;
  47417. for (var i = 0; i < encrypted.length; i += this.segmentSize) {
  47418. xorSegment = this._aes.encrypt(this._shiftRegister);
  47419. for (var j = 0; j < this.segmentSize; j++) {
  47420. encrypted[i + j] ^= xorSegment[j];
  47421. }
  47422. // Shift the register
  47423. copyArray(this._shiftRegister, this._shiftRegister, 0, this.segmentSize);
  47424. copyArray(encrypted, this._shiftRegister, 16 - this.segmentSize, i, i + this.segmentSize);
  47425. }
  47426. return encrypted;
  47427. }
  47428. ModeOfOperationCFB.prototype.decrypt = function(ciphertext) {
  47429. if ((ciphertext.length % this.segmentSize) != 0) {
  47430. throw new Error('invalid ciphertext size (must be segmentSize bytes)');
  47431. }
  47432. var plaintext = coerceArray(ciphertext, true);
  47433. var xorSegment;
  47434. for (var i = 0; i < plaintext.length; i += this.segmentSize) {
  47435. xorSegment = this._aes.encrypt(this._shiftRegister);
  47436. for (var j = 0; j < this.segmentSize; j++) {
  47437. plaintext[i + j] ^= xorSegment[j];
  47438. }
  47439. // Shift the register
  47440. copyArray(this._shiftRegister, this._shiftRegister, 0, this.segmentSize);
  47441. copyArray(ciphertext, this._shiftRegister, 16 - this.segmentSize, i, i + this.segmentSize);
  47442. }
  47443. return plaintext;
  47444. }
  47445. /**
  47446. * Mode Of Operation - Output Feedback (OFB)
  47447. */
  47448. var ModeOfOperationOFB = function(key, iv) {
  47449. if (!(this instanceof ModeOfOperationOFB)) {
  47450. throw Error('AES must be instanitated with `new`');
  47451. }
  47452. this.description = "Output Feedback";
  47453. this.name = "ofb";
  47454. if (!iv) {
  47455. iv = createArray(16);
  47456. } else if (iv.length != 16) {
  47457. throw new Error('invalid initialation vector size (must be 16 bytes)');
  47458. }
  47459. this._lastPrecipher = coerceArray(iv, true);
  47460. this._lastPrecipherIndex = 16;
  47461. this._aes = new AES(key);
  47462. }
  47463. ModeOfOperationOFB.prototype.encrypt = function(plaintext) {
  47464. var encrypted = coerceArray(plaintext, true);
  47465. for (var i = 0; i < encrypted.length; i++) {
  47466. if (this._lastPrecipherIndex === 16) {
  47467. this._lastPrecipher = this._aes.encrypt(this._lastPrecipher);
  47468. this._lastPrecipherIndex = 0;
  47469. }
  47470. encrypted[i] ^= this._lastPrecipher[this._lastPrecipherIndex++];
  47471. }
  47472. return encrypted;
  47473. }
  47474. // Decryption is symetric
  47475. ModeOfOperationOFB.prototype.decrypt = ModeOfOperationOFB.prototype.encrypt;
  47476. /**
  47477. * Counter object for CTR common mode of operation
  47478. */
  47479. var Counter = function(initialValue) {
  47480. if (!(this instanceof Counter)) {
  47481. throw Error('Counter must be instanitated with `new`');
  47482. }
  47483. // We allow 0, but anything false-ish uses the default 1
  47484. if (initialValue !== 0 && !initialValue) { initialValue = 1; }
  47485. if (typeof(initialValue) === 'number') {
  47486. this._counter = createArray(16);
  47487. this.setValue(initialValue);
  47488. } else {
  47489. this.setBytes(initialValue);
  47490. }
  47491. }
  47492. Counter.prototype.setValue = function(value) {
  47493. if (typeof(value) !== 'number' || parseInt(value) != value) {
  47494. throw new Error('invalid counter value (must be an integer)');
  47495. }
  47496. for (var index = 15; index >= 0; --index) {
  47497. this._counter[index] = value % 256;
  47498. value = value >> 8;
  47499. }
  47500. }
  47501. Counter.prototype.setBytes = function(bytes) {
  47502. bytes = coerceArray(bytes, true);
  47503. if (bytes.length != 16) {
  47504. throw new Error('invalid counter bytes size (must be 16 bytes)');
  47505. }
  47506. this._counter = bytes;
  47507. };
  47508. Counter.prototype.increment = function() {
  47509. for (var i = 15; i >= 0; i--) {
  47510. if (this._counter[i] === 255) {
  47511. this._counter[i] = 0;
  47512. } else {
  47513. this._counter[i]++;
  47514. break;
  47515. }
  47516. }
  47517. }
  47518. /**
  47519. * Mode Of Operation - Counter (CTR)
  47520. */
  47521. var ModeOfOperationCTR = function(key, counter) {
  47522. if (!(this instanceof ModeOfOperationCTR)) {
  47523. throw Error('AES must be instanitated with `new`');
  47524. }
  47525. this.description = "Counter";
  47526. this.name = "ctr";
  47527. if (!(counter instanceof Counter)) {
  47528. counter = new Counter(counter)
  47529. }
  47530. this._counter = counter;
  47531. this._remainingCounter = null;
  47532. this._remainingCounterIndex = 16;
  47533. this._aes = new AES(key);
  47534. }
  47535. ModeOfOperationCTR.prototype.encrypt = function(plaintext) {
  47536. var encrypted = coerceArray(plaintext, true);
  47537. for (var i = 0; i < encrypted.length; i++) {
  47538. if (this._remainingCounterIndex === 16) {
  47539. this._remainingCounter = this._aes.encrypt(this._counter._counter);
  47540. this._remainingCounterIndex = 0;
  47541. this._counter.increment();
  47542. }
  47543. encrypted[i] ^= this._remainingCounter[this._remainingCounterIndex++];
  47544. }
  47545. return encrypted;
  47546. }
  47547. // Decryption is symetric
  47548. ModeOfOperationCTR.prototype.decrypt = ModeOfOperationCTR.prototype.encrypt;
  47549. ///////////////////////
  47550. // Padding
  47551. // See:https://tools.ietf.org/html/rfc2315
  47552. function pkcs7pad(data) {
  47553. data = coerceArray(data, true);
  47554. var padder = 16 - (data.length % 16);
  47555. var result = createArray(data.length + padder);
  47556. copyArray(data, result);
  47557. for (var i = data.length; i < result.length; i++) {
  47558. result[i] = padder;
  47559. }
  47560. return result;
  47561. }
  47562. function pkcs7strip(data) {
  47563. data = coerceArray(data, true);
  47564. if (data.length < 16) { throw new Error('PKCS#7 invalid length'); }
  47565. var padder = data[data.length - 1];
  47566. if (padder > 16) { throw new Error('PKCS#7 padding byte out of range'); }
  47567. var length = data.length - padder;
  47568. for (var i = 0; i < padder; i++) {
  47569. if (data[length + i] !== padder) {
  47570. throw new Error('PKCS#7 invalid padding byte');
  47571. }
  47572. }
  47573. var result = createArray(length);
  47574. copyArray(data, result, 0, 0, length);
  47575. return result;
  47576. }
  47577. ///////////////////////
  47578. // Exporting
  47579. // The block cipher
  47580. var aesjs = {
  47581. AES: AES,
  47582. Counter: Counter,
  47583. ModeOfOperation: {
  47584. ecb: ModeOfOperationECB,
  47585. cbc: ModeOfOperationCBC,
  47586. cfb: ModeOfOperationCFB,
  47587. ofb: ModeOfOperationOFB,
  47588. ctr: ModeOfOperationCTR
  47589. },
  47590. utils: {
  47591. hex: convertHex,
  47592. utf8: convertUtf8
  47593. },
  47594. padding: {
  47595. pkcs7: {
  47596. pad: pkcs7pad,
  47597. strip: pkcs7strip
  47598. }
  47599. },
  47600. _arrayTest: {
  47601. coerceArray: coerceArray,
  47602. createArray: createArray,
  47603. copyArray: copyArray,
  47604. }
  47605. };
  47606. // node.js
  47607. if (typeof exports !== 'undefined') {
  47608. module.exports = aesjs
  47609. // RequireJS/AMD
  47610. // http://www.requirejs.org/docs/api.html
  47611. // https://github.com/amdjs/amdjs-api/wiki/AMD
  47612. } else if (typeof(define) === 'function' && define.amd) {
  47613. define(aesjs);
  47614. // Web Browsers
  47615. } else {
  47616. // If there was an existing library at "aesjs" make sure it's still available
  47617. if (root.aesjs) {
  47618. aesjs._aesjs = root.aesjs;
  47619. }
  47620. root.aesjs = aesjs;
  47621. }
  47622. })(this);
  47623. },{}],291:[function(_dereq_,module,exports){
  47624. module.exports = _dereq_('./lib/axios');
  47625. },{"./lib/axios":293}],292:[function(_dereq_,module,exports){
  47626. 'use strict';
  47627. var utils = _dereq_('./../utils');
  47628. var settle = _dereq_('./../core/settle');
  47629. var cookies = _dereq_('./../helpers/cookies');
  47630. var buildURL = _dereq_('./../helpers/buildURL');
  47631. var buildFullPath = _dereq_('../core/buildFullPath');
  47632. var parseHeaders = _dereq_('./../helpers/parseHeaders');
  47633. var isURLSameOrigin = _dereq_('./../helpers/isURLSameOrigin');
  47634. var createError = _dereq_('../core/createError');
  47635. var transitionalDefaults = _dereq_('../defaults/transitional');
  47636. var Cancel = _dereq_('../cancel/Cancel');
  47637. module.exports = function xhrAdapter(config) {
  47638. return new Promise(function dispatchXhrRequest(resolve, reject) {
  47639. var requestData = config.data;
  47640. var requestHeaders = config.headers;
  47641. var responseType = config.responseType;
  47642. var onCanceled;
  47643. function done() {
  47644. if (config.cancelToken) {
  47645. config.cancelToken.unsubscribe(onCanceled);
  47646. }
  47647. if (config.signal) {
  47648. config.signal.removeEventListener('abort', onCanceled);
  47649. }
  47650. }
  47651. if (utils.isFormData(requestData)) {
  47652. delete requestHeaders['Content-Type']; // Let the browser set it
  47653. }
  47654. var request = new XMLHttpRequest();
  47655. // HTTP basic authentication
  47656. if (config.auth) {
  47657. var username = config.auth.username || '';
  47658. var password = config.auth.password ? unescape(encodeURIComponent(config.auth.password)) : '';
  47659. requestHeaders.Authorization = 'Basic ' + btoa(username + ':' + password);
  47660. }
  47661. var fullPath = buildFullPath(config.baseURL, config.url);
  47662. request.open(config.method.toUpperCase(), buildURL(fullPath, config.params, config.paramsSerializer), true);
  47663. // Set the request timeout in MS
  47664. request.timeout = config.timeout;
  47665. function onloadend() {
  47666. if (!request) {
  47667. return;
  47668. }
  47669. // Prepare the response
  47670. var responseHeaders = 'getAllResponseHeaders' in request ? parseHeaders(request.getAllResponseHeaders()) : null;
  47671. var responseData = !responseType || responseType === 'text' || responseType === 'json' ?
  47672. request.responseText : request.response;
  47673. var response = {
  47674. data: responseData,
  47675. status: request.status,
  47676. statusText: request.statusText,
  47677. headers: responseHeaders,
  47678. config: config,
  47679. request: request
  47680. };
  47681. settle(function _resolve(value) {
  47682. resolve(value);
  47683. done();
  47684. }, function _reject(err) {
  47685. reject(err);
  47686. done();
  47687. }, response);
  47688. // Clean up request
  47689. request = null;
  47690. }
  47691. if ('onloadend' in request) {
  47692. // Use onloadend if available
  47693. request.onloadend = onloadend;
  47694. } else {
  47695. // Listen for ready state to emulate onloadend
  47696. request.onreadystatechange = function handleLoad() {
  47697. if (!request || request.readyState !== 4) {
  47698. return;
  47699. }
  47700. // The request errored out and we didn't get a response, this will be
  47701. // handled by onerror instead
  47702. // With one exception: request that using file: protocol, most browsers
  47703. // will return status as 0 even though it's a successful request
  47704. if (request.status === 0 && !(request.responseURL && request.responseURL.indexOf('file:') === 0)) {
  47705. return;
  47706. }
  47707. // readystate handler is calling before onerror or ontimeout handlers,
  47708. // so we should call onloadend on the next 'tick'
  47709. setTimeout(onloadend);
  47710. };
  47711. }
  47712. // Handle browser request cancellation (as opposed to a manual cancellation)
  47713. request.onabort = function handleAbort() {
  47714. if (!request) {
  47715. return;
  47716. }
  47717. reject(createError('Request aborted', config, 'ECONNABORTED', request));
  47718. // Clean up request
  47719. request = null;
  47720. };
  47721. // Handle low level network errors
  47722. request.onerror = function handleError() {
  47723. // Real errors are hidden from us by the browser
  47724. // onerror should only fire if it's a network error
  47725. reject(createError('Network Error', config, null, request));
  47726. // Clean up request
  47727. request = null;
  47728. };
  47729. // Handle timeout
  47730. request.ontimeout = function handleTimeout() {
  47731. var timeoutErrorMessage = config.timeout ? 'timeout of ' + config.timeout + 'ms exceeded' : 'timeout exceeded';
  47732. var transitional = config.transitional || transitionalDefaults;
  47733. if (config.timeoutErrorMessage) {
  47734. timeoutErrorMessage = config.timeoutErrorMessage;
  47735. }
  47736. reject(createError(
  47737. timeoutErrorMessage,
  47738. config,
  47739. transitional.clarifyTimeoutError ? 'ETIMEDOUT' : 'ECONNABORTED',
  47740. request));
  47741. // Clean up request
  47742. request = null;
  47743. };
  47744. // Add xsrf header
  47745. // This is only done if running in a standard browser environment.
  47746. // Specifically not if we're in a web worker, or react-native.
  47747. if (utils.isStandardBrowserEnv()) {
  47748. // Add xsrf header
  47749. var xsrfValue = (config.withCredentials || isURLSameOrigin(fullPath)) && config.xsrfCookieName ?
  47750. cookies.read(config.xsrfCookieName) :
  47751. undefined;
  47752. if (xsrfValue) {
  47753. requestHeaders[config.xsrfHeaderName] = xsrfValue;
  47754. }
  47755. }
  47756. // Add headers to the request
  47757. if ('setRequestHeader' in request) {
  47758. utils.forEach(requestHeaders, function setRequestHeader(val, key) {
  47759. if (typeof requestData === 'undefined' && key.toLowerCase() === 'content-type') {
  47760. // Remove Content-Type if data is undefined
  47761. delete requestHeaders[key];
  47762. } else {
  47763. // Otherwise add header to the request
  47764. request.setRequestHeader(key, val);
  47765. }
  47766. });
  47767. }
  47768. // Add withCredentials to request if needed
  47769. if (!utils.isUndefined(config.withCredentials)) {
  47770. request.withCredentials = !!config.withCredentials;
  47771. }
  47772. // Add responseType to request if needed
  47773. if (responseType && responseType !== 'json') {
  47774. request.responseType = config.responseType;
  47775. }
  47776. // Handle progress if needed
  47777. if (typeof config.onDownloadProgress === 'function') {
  47778. request.addEventListener('progress', config.onDownloadProgress);
  47779. }
  47780. // Not all browsers support upload events
  47781. if (typeof config.onUploadProgress === 'function' && request.upload) {
  47782. request.upload.addEventListener('progress', config.onUploadProgress);
  47783. }
  47784. if (config.cancelToken || config.signal) {
  47785. // Handle cancellation
  47786. // eslint-disable-next-line func-names
  47787. onCanceled = function(cancel) {
  47788. if (!request) {
  47789. return;
  47790. }
  47791. reject(!cancel || (cancel && cancel.type) ? new Cancel('canceled') : cancel);
  47792. request.abort();
  47793. request = null;
  47794. };
  47795. config.cancelToken && config.cancelToken.subscribe(onCanceled);
  47796. if (config.signal) {
  47797. config.signal.aborted ? onCanceled() : config.signal.addEventListener('abort', onCanceled);
  47798. }
  47799. }
  47800. if (!requestData) {
  47801. requestData = null;
  47802. }
  47803. // Send the request
  47804. request.send(requestData);
  47805. });
  47806. };
  47807. },{"../cancel/Cancel":294,"../core/buildFullPath":299,"../core/createError":300,"../defaults/transitional":307,"./../core/settle":304,"./../helpers/buildURL":310,"./../helpers/cookies":312,"./../helpers/isURLSameOrigin":315,"./../helpers/parseHeaders":317,"./../utils":320}],293:[function(_dereq_,module,exports){
  47808. 'use strict';
  47809. var utils = _dereq_('./utils');
  47810. var bind = _dereq_('./helpers/bind');
  47811. var Axios = _dereq_('./core/Axios');
  47812. var mergeConfig = _dereq_('./core/mergeConfig');
  47813. var defaults = _dereq_('./defaults');
  47814. /**
  47815. * Create an instance of Axios
  47816. *
  47817. * @param {Object} defaultConfig The default config for the instance
  47818. * @return {Axios} A new instance of Axios
  47819. */
  47820. function createInstance(defaultConfig) {
  47821. var context = new Axios(defaultConfig);
  47822. var instance = bind(Axios.prototype.request, context);
  47823. // Copy axios.prototype to instance
  47824. utils.extend(instance, Axios.prototype, context);
  47825. // Copy context to instance
  47826. utils.extend(instance, context);
  47827. // Factory for creating new instances
  47828. instance.create = function create(instanceConfig) {
  47829. return createInstance(mergeConfig(defaultConfig, instanceConfig));
  47830. };
  47831. return instance;
  47832. }
  47833. // Create the default instance to be exported
  47834. var axios = createInstance(defaults);
  47835. // Expose Axios class to allow class inheritance
  47836. axios.Axios = Axios;
  47837. // Expose Cancel & CancelToken
  47838. axios.Cancel = _dereq_('./cancel/Cancel');
  47839. axios.CancelToken = _dereq_('./cancel/CancelToken');
  47840. axios.isCancel = _dereq_('./cancel/isCancel');
  47841. axios.VERSION = _dereq_('./env/data').version;
  47842. // Expose all/spread
  47843. axios.all = function all(promises) {
  47844. return Promise.all(promises);
  47845. };
  47846. axios.spread = _dereq_('./helpers/spread');
  47847. // Expose isAxiosError
  47848. axios.isAxiosError = _dereq_('./helpers/isAxiosError');
  47849. module.exports = axios;
  47850. // Allow use of default import syntax in TypeScript
  47851. module.exports.default = axios;
  47852. },{"./cancel/Cancel":294,"./cancel/CancelToken":295,"./cancel/isCancel":296,"./core/Axios":297,"./core/mergeConfig":303,"./defaults":306,"./env/data":308,"./helpers/bind":309,"./helpers/isAxiosError":314,"./helpers/spread":318,"./utils":320}],294:[function(_dereq_,module,exports){
  47853. 'use strict';
  47854. /**
  47855. * A `Cancel` is an object that is thrown when an operation is canceled.
  47856. *
  47857. * @class
  47858. * @param {string=} message The message.
  47859. */
  47860. function Cancel(message) {
  47861. this.message = message;
  47862. }
  47863. Cancel.prototype.toString = function toString() {
  47864. return 'Cancel' + (this.message ? ': ' + this.message : '');
  47865. };
  47866. Cancel.prototype.__CANCEL__ = true;
  47867. module.exports = Cancel;
  47868. },{}],295:[function(_dereq_,module,exports){
  47869. 'use strict';
  47870. var Cancel = _dereq_('./Cancel');
  47871. /**
  47872. * A `CancelToken` is an object that can be used to request cancellation of an operation.
  47873. *
  47874. * @class
  47875. * @param {Function} executor The executor function.
  47876. */
  47877. function CancelToken(executor) {
  47878. if (typeof executor !== 'function') {
  47879. throw new TypeError('executor must be a function.');
  47880. }
  47881. var resolvePromise;
  47882. this.promise = new Promise(function promiseExecutor(resolve) {
  47883. resolvePromise = resolve;
  47884. });
  47885. var token = this;
  47886. // eslint-disable-next-line func-names
  47887. this.promise.then(function(cancel) {
  47888. if (!token._listeners) return;
  47889. var i;
  47890. var l = token._listeners.length;
  47891. for (i = 0; i < l; i++) {
  47892. token._listeners[i](cancel);
  47893. }
  47894. token._listeners = null;
  47895. });
  47896. // eslint-disable-next-line func-names
  47897. this.promise.then = function(onfulfilled) {
  47898. var _resolve;
  47899. // eslint-disable-next-line func-names
  47900. var promise = new Promise(function(resolve) {
  47901. token.subscribe(resolve);
  47902. _resolve = resolve;
  47903. }).then(onfulfilled);
  47904. promise.cancel = function reject() {
  47905. token.unsubscribe(_resolve);
  47906. };
  47907. return promise;
  47908. };
  47909. executor(function cancel(message) {
  47910. if (token.reason) {
  47911. // Cancellation has already been requested
  47912. return;
  47913. }
  47914. token.reason = new Cancel(message);
  47915. resolvePromise(token.reason);
  47916. });
  47917. }
  47918. /**
  47919. * Throws a `Cancel` if cancellation has been requested.
  47920. */
  47921. CancelToken.prototype.throwIfRequested = function throwIfRequested() {
  47922. if (this.reason) {
  47923. throw this.reason;
  47924. }
  47925. };
  47926. /**
  47927. * Subscribe to the cancel signal
  47928. */
  47929. CancelToken.prototype.subscribe = function subscribe(listener) {
  47930. if (this.reason) {
  47931. listener(this.reason);
  47932. return;
  47933. }
  47934. if (this._listeners) {
  47935. this._listeners.push(listener);
  47936. } else {
  47937. this._listeners = [listener];
  47938. }
  47939. };
  47940. /**
  47941. * Unsubscribe from the cancel signal
  47942. */
  47943. CancelToken.prototype.unsubscribe = function unsubscribe(listener) {
  47944. if (!this._listeners) {
  47945. return;
  47946. }
  47947. var index = this._listeners.indexOf(listener);
  47948. if (index !== -1) {
  47949. this._listeners.splice(index, 1);
  47950. }
  47951. };
  47952. /**
  47953. * Returns an object that contains a new `CancelToken` and a function that, when called,
  47954. * cancels the `CancelToken`.
  47955. */
  47956. CancelToken.source = function source() {
  47957. var cancel;
  47958. var token = new CancelToken(function executor(c) {
  47959. cancel = c;
  47960. });
  47961. return {
  47962. token: token,
  47963. cancel: cancel
  47964. };
  47965. };
  47966. module.exports = CancelToken;
  47967. },{"./Cancel":294}],296:[function(_dereq_,module,exports){
  47968. 'use strict';
  47969. module.exports = function isCancel(value) {
  47970. return !!(value && value.__CANCEL__);
  47971. };
  47972. },{}],297:[function(_dereq_,module,exports){
  47973. 'use strict';
  47974. var utils = _dereq_('./../utils');
  47975. var buildURL = _dereq_('../helpers/buildURL');
  47976. var InterceptorManager = _dereq_('./InterceptorManager');
  47977. var dispatchRequest = _dereq_('./dispatchRequest');
  47978. var mergeConfig = _dereq_('./mergeConfig');
  47979. var validator = _dereq_('../helpers/validator');
  47980. var validators = validator.validators;
  47981. /**
  47982. * Create a new instance of Axios
  47983. *
  47984. * @param {Object} instanceConfig The default config for the instance
  47985. */
  47986. function Axios(instanceConfig) {
  47987. this.defaults = instanceConfig;
  47988. this.interceptors = {
  47989. request: new InterceptorManager(),
  47990. response: new InterceptorManager()
  47991. };
  47992. }
  47993. /**
  47994. * Dispatch a request
  47995. *
  47996. * @param {Object} config The config specific for this request (merged with this.defaults)
  47997. */
  47998. Axios.prototype.request = function request(configOrUrl, config) {
  47999. /*eslint no-param-reassign:0*/
  48000. // Allow for axios('example/url'[, config]) a la fetch API
  48001. if (typeof configOrUrl === 'string') {
  48002. config = config || {};
  48003. config.url = configOrUrl;
  48004. } else {
  48005. config = configOrUrl || {};
  48006. }
  48007. config = mergeConfig(this.defaults, config);
  48008. // Set config.method
  48009. if (config.method) {
  48010. config.method = config.method.toLowerCase();
  48011. } else if (this.defaults.method) {
  48012. config.method = this.defaults.method.toLowerCase();
  48013. } else {
  48014. config.method = 'get';
  48015. }
  48016. var transitional = config.transitional;
  48017. if (transitional !== undefined) {
  48018. validator.assertOptions(transitional, {
  48019. silentJSONParsing: validators.transitional(validators.boolean),
  48020. forcedJSONParsing: validators.transitional(validators.boolean),
  48021. clarifyTimeoutError: validators.transitional(validators.boolean)
  48022. }, false);
  48023. }
  48024. // filter out skipped interceptors
  48025. var requestInterceptorChain = [];
  48026. var synchronousRequestInterceptors = true;
  48027. this.interceptors.request.forEach(function unshiftRequestInterceptors(interceptor) {
  48028. if (typeof interceptor.runWhen === 'function' && interceptor.runWhen(config) === false) {
  48029. return;
  48030. }
  48031. synchronousRequestInterceptors = synchronousRequestInterceptors && interceptor.synchronous;
  48032. requestInterceptorChain.unshift(interceptor.fulfilled, interceptor.rejected);
  48033. });
  48034. var responseInterceptorChain = [];
  48035. this.interceptors.response.forEach(function pushResponseInterceptors(interceptor) {
  48036. responseInterceptorChain.push(interceptor.fulfilled, interceptor.rejected);
  48037. });
  48038. var promise;
  48039. if (!synchronousRequestInterceptors) {
  48040. var chain = [dispatchRequest, undefined];
  48041. Array.prototype.unshift.apply(chain, requestInterceptorChain);
  48042. chain = chain.concat(responseInterceptorChain);
  48043. promise = Promise.resolve(config);
  48044. while (chain.length) {
  48045. promise = promise.then(chain.shift(), chain.shift());
  48046. }
  48047. return promise;
  48048. }
  48049. var newConfig = config;
  48050. while (requestInterceptorChain.length) {
  48051. var onFulfilled = requestInterceptorChain.shift();
  48052. var onRejected = requestInterceptorChain.shift();
  48053. try {
  48054. newConfig = onFulfilled(newConfig);
  48055. } catch (error) {
  48056. onRejected(error);
  48057. break;
  48058. }
  48059. }
  48060. try {
  48061. promise = dispatchRequest(newConfig);
  48062. } catch (error) {
  48063. return Promise.reject(error);
  48064. }
  48065. while (responseInterceptorChain.length) {
  48066. promise = promise.then(responseInterceptorChain.shift(), responseInterceptorChain.shift());
  48067. }
  48068. return promise;
  48069. };
  48070. Axios.prototype.getUri = function getUri(config) {
  48071. config = mergeConfig(this.defaults, config);
  48072. return buildURL(config.url, config.params, config.paramsSerializer).replace(/^\?/, '');
  48073. };
  48074. // Provide aliases for supported request methods
  48075. utils.forEach(['delete', 'get', 'head', 'options'], function forEachMethodNoData(method) {
  48076. /*eslint func-names:0*/
  48077. Axios.prototype[method] = function(url, config) {
  48078. return this.request(mergeConfig(config || {}, {
  48079. method: method,
  48080. url: url,
  48081. data: (config || {}).data
  48082. }));
  48083. };
  48084. });
  48085. utils.forEach(['post', 'put', 'patch'], function forEachMethodWithData(method) {
  48086. /*eslint func-names:0*/
  48087. Axios.prototype[method] = function(url, data, config) {
  48088. return this.request(mergeConfig(config || {}, {
  48089. method: method,
  48090. url: url,
  48091. data: data
  48092. }));
  48093. };
  48094. });
  48095. module.exports = Axios;
  48096. },{"../helpers/buildURL":310,"../helpers/validator":319,"./../utils":320,"./InterceptorManager":298,"./dispatchRequest":301,"./mergeConfig":303}],298:[function(_dereq_,module,exports){
  48097. 'use strict';
  48098. var utils = _dereq_('./../utils');
  48099. function InterceptorManager() {
  48100. this.handlers = [];
  48101. }
  48102. /**
  48103. * Add a new interceptor to the stack
  48104. *
  48105. * @param {Function} fulfilled The function to handle `then` for a `Promise`
  48106. * @param {Function} rejected The function to handle `reject` for a `Promise`
  48107. *
  48108. * @return {Number} An ID used to remove interceptor later
  48109. */
  48110. InterceptorManager.prototype.use = function use(fulfilled, rejected, options) {
  48111. this.handlers.push({
  48112. fulfilled: fulfilled,
  48113. rejected: rejected,
  48114. synchronous: options ? options.synchronous : false,
  48115. runWhen: options ? options.runWhen : null
  48116. });
  48117. return this.handlers.length - 1;
  48118. };
  48119. /**
  48120. * Remove an interceptor from the stack
  48121. *
  48122. * @param {Number} id The ID that was returned by `use`
  48123. */
  48124. InterceptorManager.prototype.eject = function eject(id) {
  48125. if (this.handlers[id]) {
  48126. this.handlers[id] = null;
  48127. }
  48128. };
  48129. /**
  48130. * Iterate over all the registered interceptors
  48131. *
  48132. * This method is particularly useful for skipping over any
  48133. * interceptors that may have become `null` calling `eject`.
  48134. *
  48135. * @param {Function} fn The function to call for each interceptor
  48136. */
  48137. InterceptorManager.prototype.forEach = function forEach(fn) {
  48138. utils.forEach(this.handlers, function forEachHandler(h) {
  48139. if (h !== null) {
  48140. fn(h);
  48141. }
  48142. });
  48143. };
  48144. module.exports = InterceptorManager;
  48145. },{"./../utils":320}],299:[function(_dereq_,module,exports){
  48146. 'use strict';
  48147. var isAbsoluteURL = _dereq_('../helpers/isAbsoluteURL');
  48148. var combineURLs = _dereq_('../helpers/combineURLs');
  48149. /**
  48150. * Creates a new URL by combining the baseURL with the requestedURL,
  48151. * only when the requestedURL is not already an absolute URL.
  48152. * If the requestURL is absolute, this function returns the requestedURL untouched.
  48153. *
  48154. * @param {string} baseURL The base URL
  48155. * @param {string} requestedURL Absolute or relative URL to combine
  48156. * @returns {string} The combined full path
  48157. */
  48158. module.exports = function buildFullPath(baseURL, requestedURL) {
  48159. if (baseURL && !isAbsoluteURL(requestedURL)) {
  48160. return combineURLs(baseURL, requestedURL);
  48161. }
  48162. return requestedURL;
  48163. };
  48164. },{"../helpers/combineURLs":311,"../helpers/isAbsoluteURL":313}],300:[function(_dereq_,module,exports){
  48165. 'use strict';
  48166. var enhanceError = _dereq_('./enhanceError');
  48167. /**
  48168. * Create an Error with the specified message, config, error code, request and response.
  48169. *
  48170. * @param {string} message The error message.
  48171. * @param {Object} config The config.
  48172. * @param {string} [code] The error code (for example, 'ECONNABORTED').
  48173. * @param {Object} [request] The request.
  48174. * @param {Object} [response] The response.
  48175. * @returns {Error} The created error.
  48176. */
  48177. module.exports = function createError(message, config, code, request, response) {
  48178. var error = new Error(message);
  48179. return enhanceError(error, config, code, request, response);
  48180. };
  48181. },{"./enhanceError":302}],301:[function(_dereq_,module,exports){
  48182. 'use strict';
  48183. var utils = _dereq_('./../utils');
  48184. var transformData = _dereq_('./transformData');
  48185. var isCancel = _dereq_('../cancel/isCancel');
  48186. var defaults = _dereq_('../defaults');
  48187. var Cancel = _dereq_('../cancel/Cancel');
  48188. /**
  48189. * Throws a `Cancel` if cancellation has been requested.
  48190. */
  48191. function throwIfCancellationRequested(config) {
  48192. if (config.cancelToken) {
  48193. config.cancelToken.throwIfRequested();
  48194. }
  48195. if (config.signal && config.signal.aborted) {
  48196. throw new Cancel('canceled');
  48197. }
  48198. }
  48199. /**
  48200. * Dispatch a request to the server using the configured adapter.
  48201. *
  48202. * @param {object} config The config that is to be used for the request
  48203. * @returns {Promise} The Promise to be fulfilled
  48204. */
  48205. module.exports = function dispatchRequest(config) {
  48206. throwIfCancellationRequested(config);
  48207. // Ensure headers exist
  48208. config.headers = config.headers || {};
  48209. // Transform request data
  48210. config.data = transformData.call(
  48211. config,
  48212. config.data,
  48213. config.headers,
  48214. config.transformRequest
  48215. );
  48216. // Flatten headers
  48217. config.headers = utils.merge(
  48218. config.headers.common || {},
  48219. config.headers[config.method] || {},
  48220. config.headers
  48221. );
  48222. utils.forEach(
  48223. ['delete', 'get', 'head', 'post', 'put', 'patch', 'common'],
  48224. function cleanHeaderConfig(method) {
  48225. delete config.headers[method];
  48226. }
  48227. );
  48228. var adapter = config.adapter || defaults.adapter;
  48229. return adapter(config).then(function onAdapterResolution(response) {
  48230. throwIfCancellationRequested(config);
  48231. // Transform response data
  48232. response.data = transformData.call(
  48233. config,
  48234. response.data,
  48235. response.headers,
  48236. config.transformResponse
  48237. );
  48238. return response;
  48239. }, function onAdapterRejection(reason) {
  48240. if (!isCancel(reason)) {
  48241. throwIfCancellationRequested(config);
  48242. // Transform response data
  48243. if (reason && reason.response) {
  48244. reason.response.data = transformData.call(
  48245. config,
  48246. reason.response.data,
  48247. reason.response.headers,
  48248. config.transformResponse
  48249. );
  48250. }
  48251. }
  48252. return Promise.reject(reason);
  48253. });
  48254. };
  48255. },{"../cancel/Cancel":294,"../cancel/isCancel":296,"../defaults":306,"./../utils":320,"./transformData":305}],302:[function(_dereq_,module,exports){
  48256. 'use strict';
  48257. /**
  48258. * Update an Error with the specified config, error code, and response.
  48259. *
  48260. * @param {Error} error The error to update.
  48261. * @param {Object} config The config.
  48262. * @param {string} [code] The error code (for example, 'ECONNABORTED').
  48263. * @param {Object} [request] The request.
  48264. * @param {Object} [response] The response.
  48265. * @returns {Error} The error.
  48266. */
  48267. module.exports = function enhanceError(error, config, code, request, response) {
  48268. error.config = config;
  48269. if (code) {
  48270. error.code = code;
  48271. }
  48272. error.request = request;
  48273. error.response = response;
  48274. error.isAxiosError = true;
  48275. error.toJSON = function toJSON() {
  48276. return {
  48277. // Standard
  48278. message: this.message,
  48279. name: this.name,
  48280. // Microsoft
  48281. description: this.description,
  48282. number: this.number,
  48283. // Mozilla
  48284. fileName: this.fileName,
  48285. lineNumber: this.lineNumber,
  48286. columnNumber: this.columnNumber,
  48287. stack: this.stack,
  48288. // Axios
  48289. config: this.config,
  48290. code: this.code,
  48291. status: this.response && this.response.status ? this.response.status : null
  48292. };
  48293. };
  48294. return error;
  48295. };
  48296. },{}],303:[function(_dereq_,module,exports){
  48297. 'use strict';
  48298. var utils = _dereq_('../utils');
  48299. /**
  48300. * Config-specific merge-function which creates a new config-object
  48301. * by merging two configuration objects together.
  48302. *
  48303. * @param {Object} config1
  48304. * @param {Object} config2
  48305. * @returns {Object} New object resulting from merging config2 to config1
  48306. */
  48307. module.exports = function mergeConfig(config1, config2) {
  48308. // eslint-disable-next-line no-param-reassign
  48309. config2 = config2 || {};
  48310. var config = {};
  48311. function getMergedValue(target, source) {
  48312. if (utils.isPlainObject(target) && utils.isPlainObject(source)) {
  48313. return utils.merge(target, source);
  48314. } else if (utils.isPlainObject(source)) {
  48315. return utils.merge({}, source);
  48316. } else if (utils.isArray(source)) {
  48317. return source.slice();
  48318. }
  48319. return source;
  48320. }
  48321. // eslint-disable-next-line consistent-return
  48322. function mergeDeepProperties(prop) {
  48323. if (!utils.isUndefined(config2[prop])) {
  48324. return getMergedValue(config1[prop], config2[prop]);
  48325. } else if (!utils.isUndefined(config1[prop])) {
  48326. return getMergedValue(undefined, config1[prop]);
  48327. }
  48328. }
  48329. // eslint-disable-next-line consistent-return
  48330. function valueFromConfig2(prop) {
  48331. if (!utils.isUndefined(config2[prop])) {
  48332. return getMergedValue(undefined, config2[prop]);
  48333. }
  48334. }
  48335. // eslint-disable-next-line consistent-return
  48336. function defaultToConfig2(prop) {
  48337. if (!utils.isUndefined(config2[prop])) {
  48338. return getMergedValue(undefined, config2[prop]);
  48339. } else if (!utils.isUndefined(config1[prop])) {
  48340. return getMergedValue(undefined, config1[prop]);
  48341. }
  48342. }
  48343. // eslint-disable-next-line consistent-return
  48344. function mergeDirectKeys(prop) {
  48345. if (prop in config2) {
  48346. return getMergedValue(config1[prop], config2[prop]);
  48347. } else if (prop in config1) {
  48348. return getMergedValue(undefined, config1[prop]);
  48349. }
  48350. }
  48351. var mergeMap = {
  48352. 'url': valueFromConfig2,
  48353. 'method': valueFromConfig2,
  48354. 'data': valueFromConfig2,
  48355. 'baseURL': defaultToConfig2,
  48356. 'transformRequest': defaultToConfig2,
  48357. 'transformResponse': defaultToConfig2,
  48358. 'paramsSerializer': defaultToConfig2,
  48359. 'timeout': defaultToConfig2,
  48360. 'timeoutMessage': defaultToConfig2,
  48361. 'withCredentials': defaultToConfig2,
  48362. 'adapter': defaultToConfig2,
  48363. 'responseType': defaultToConfig2,
  48364. 'xsrfCookieName': defaultToConfig2,
  48365. 'xsrfHeaderName': defaultToConfig2,
  48366. 'onUploadProgress': defaultToConfig2,
  48367. 'onDownloadProgress': defaultToConfig2,
  48368. 'decompress': defaultToConfig2,
  48369. 'maxContentLength': defaultToConfig2,
  48370. 'maxBodyLength': defaultToConfig2,
  48371. 'transport': defaultToConfig2,
  48372. 'httpAgent': defaultToConfig2,
  48373. 'httpsAgent': defaultToConfig2,
  48374. 'cancelToken': defaultToConfig2,
  48375. 'socketPath': defaultToConfig2,
  48376. 'responseEncoding': defaultToConfig2,
  48377. 'validateStatus': mergeDirectKeys
  48378. };
  48379. utils.forEach(Object.keys(config1).concat(Object.keys(config2)), function computeConfigValue(prop) {
  48380. var merge = mergeMap[prop] || mergeDeepProperties;
  48381. var configValue = merge(prop);
  48382. (utils.isUndefined(configValue) && merge !== mergeDirectKeys) || (config[prop] = configValue);
  48383. });
  48384. return config;
  48385. };
  48386. },{"../utils":320}],304:[function(_dereq_,module,exports){
  48387. 'use strict';
  48388. var createError = _dereq_('./createError');
  48389. /**
  48390. * Resolve or reject a Promise based on response status.
  48391. *
  48392. * @param {Function} resolve A function that resolves the promise.
  48393. * @param {Function} reject A function that rejects the promise.
  48394. * @param {object} response The response.
  48395. */
  48396. module.exports = function settle(resolve, reject, response) {
  48397. var validateStatus = response.config.validateStatus;
  48398. if (!response.status || !validateStatus || validateStatus(response.status)) {
  48399. resolve(response);
  48400. } else {
  48401. reject(createError(
  48402. 'Request failed with status code ' + response.status,
  48403. response.config,
  48404. null,
  48405. response.request,
  48406. response
  48407. ));
  48408. }
  48409. };
  48410. },{"./createError":300}],305:[function(_dereq_,module,exports){
  48411. 'use strict';
  48412. var utils = _dereq_('./../utils');
  48413. var defaults = _dereq_('../defaults');
  48414. /**
  48415. * Transform the data for a request or a response
  48416. *
  48417. * @param {Object|String} data The data to be transformed
  48418. * @param {Array} headers The headers for the request or response
  48419. * @param {Array|Function} fns A single function or Array of functions
  48420. * @returns {*} The resulting transformed data
  48421. */
  48422. module.exports = function transformData(data, headers, fns) {
  48423. var context = this || defaults;
  48424. /*eslint no-param-reassign:0*/
  48425. utils.forEach(fns, function transform(fn) {
  48426. data = fn.call(context, data, headers);
  48427. });
  48428. return data;
  48429. };
  48430. },{"../defaults":306,"./../utils":320}],306:[function(_dereq_,module,exports){
  48431. (function (process){(function (){
  48432. 'use strict';
  48433. var utils = _dereq_('../utils');
  48434. var normalizeHeaderName = _dereq_('../helpers/normalizeHeaderName');
  48435. var enhanceError = _dereq_('../core/enhanceError');
  48436. var transitionalDefaults = _dereq_('./transitional');
  48437. var DEFAULT_CONTENT_TYPE = {
  48438. 'Content-Type': 'application/x-www-form-urlencoded'
  48439. };
  48440. function setContentTypeIfUnset(headers, value) {
  48441. if (!utils.isUndefined(headers) && utils.isUndefined(headers['Content-Type'])) {
  48442. headers['Content-Type'] = value;
  48443. }
  48444. }
  48445. function getDefaultAdapter() {
  48446. var adapter;
  48447. if (typeof XMLHttpRequest !== 'undefined') {
  48448. // For browsers use XHR adapter
  48449. adapter = _dereq_('../adapters/xhr');
  48450. } else if (typeof process !== 'undefined' && Object.prototype.toString.call(process) === '[object process]') {
  48451. // For node use HTTP adapter
  48452. adapter = _dereq_('../adapters/http');
  48453. }
  48454. return adapter;
  48455. }
  48456. function stringifySafely(rawValue, parser, encoder) {
  48457. if (utils.isString(rawValue)) {
  48458. try {
  48459. (parser || JSON.parse)(rawValue);
  48460. return utils.trim(rawValue);
  48461. } catch (e) {
  48462. if (e.name !== 'SyntaxError') {
  48463. throw e;
  48464. }
  48465. }
  48466. }
  48467. return (encoder || JSON.stringify)(rawValue);
  48468. }
  48469. var defaults = {
  48470. transitional: transitionalDefaults,
  48471. adapter: getDefaultAdapter(),
  48472. transformRequest: [function transformRequest(data, headers) {
  48473. normalizeHeaderName(headers, 'Accept');
  48474. normalizeHeaderName(headers, 'Content-Type');
  48475. if (utils.isFormData(data) ||
  48476. utils.isArrayBuffer(data) ||
  48477. utils.isBuffer(data) ||
  48478. utils.isStream(data) ||
  48479. utils.isFile(data) ||
  48480. utils.isBlob(data)
  48481. ) {
  48482. return data;
  48483. }
  48484. if (utils.isArrayBufferView(data)) {
  48485. return data.buffer;
  48486. }
  48487. if (utils.isURLSearchParams(data)) {
  48488. setContentTypeIfUnset(headers, 'application/x-www-form-urlencoded;charset=utf-8');
  48489. return data.toString();
  48490. }
  48491. if (utils.isObject(data) || (headers && headers['Content-Type'] === 'application/json')) {
  48492. setContentTypeIfUnset(headers, 'application/json');
  48493. return stringifySafely(data);
  48494. }
  48495. return data;
  48496. }],
  48497. transformResponse: [function transformResponse(data) {
  48498. var transitional = this.transitional || defaults.transitional;
  48499. var silentJSONParsing = transitional && transitional.silentJSONParsing;
  48500. var forcedJSONParsing = transitional && transitional.forcedJSONParsing;
  48501. var strictJSONParsing = !silentJSONParsing && this.responseType === 'json';
  48502. if (strictJSONParsing || (forcedJSONParsing && utils.isString(data) && data.length)) {
  48503. try {
  48504. return JSON.parse(data);
  48505. } catch (e) {
  48506. if (strictJSONParsing) {
  48507. if (e.name === 'SyntaxError') {
  48508. throw enhanceError(e, this, 'E_JSON_PARSE');
  48509. }
  48510. throw e;
  48511. }
  48512. }
  48513. }
  48514. return data;
  48515. }],
  48516. /**
  48517. * A timeout in milliseconds to abort a request. If set to 0 (default) a
  48518. * timeout is not created.
  48519. */
  48520. timeout: 0,
  48521. xsrfCookieName: 'XSRF-TOKEN',
  48522. xsrfHeaderName: 'X-XSRF-TOKEN',
  48523. maxContentLength: -1,
  48524. maxBodyLength: -1,
  48525. validateStatus: function validateStatus(status) {
  48526. return status >= 200 && status < 300;
  48527. },
  48528. headers: {
  48529. common: {
  48530. 'Accept': 'application/json, text/plain, */*'
  48531. }
  48532. }
  48533. };
  48534. utils.forEach(['delete', 'get', 'head'], function forEachMethodNoData(method) {
  48535. defaults.headers[method] = {};
  48536. });
  48537. utils.forEach(['post', 'put', 'patch'], function forEachMethodWithData(method) {
  48538. defaults.headers[method] = utils.merge(DEFAULT_CONTENT_TYPE);
  48539. });
  48540. module.exports = defaults;
  48541. }).call(this)}).call(this,_dereq_('_process'))
  48542. },{"../adapters/http":292,"../adapters/xhr":292,"../core/enhanceError":302,"../helpers/normalizeHeaderName":316,"../utils":320,"./transitional":307,"_process":323}],307:[function(_dereq_,module,exports){
  48543. 'use strict';
  48544. module.exports = {
  48545. silentJSONParsing: true,
  48546. forcedJSONParsing: true,
  48547. clarifyTimeoutError: false
  48548. };
  48549. },{}],308:[function(_dereq_,module,exports){
  48550. module.exports = {
  48551. "version": "0.26.1"
  48552. };
  48553. },{}],309:[function(_dereq_,module,exports){
  48554. 'use strict';
  48555. module.exports = function bind(fn, thisArg) {
  48556. return function wrap() {
  48557. var args = new Array(arguments.length);
  48558. for (var i = 0; i < args.length; i++) {
  48559. args[i] = arguments[i];
  48560. }
  48561. return fn.apply(thisArg, args);
  48562. };
  48563. };
  48564. },{}],310:[function(_dereq_,module,exports){
  48565. 'use strict';
  48566. var utils = _dereq_('./../utils');
  48567. function encode(val) {
  48568. return encodeURIComponent(val).
  48569. replace(/%3A/gi, ':').
  48570. replace(/%24/g, '$').
  48571. replace(/%2C/gi, ',').
  48572. replace(/%20/g, '+').
  48573. replace(/%5B/gi, '[').
  48574. replace(/%5D/gi, ']');
  48575. }
  48576. /**
  48577. * Build a URL by appending params to the end
  48578. *
  48579. * @param {string} url The base of the url (e.g., http://www.google.com)
  48580. * @param {object} [params] The params to be appended
  48581. * @returns {string} The formatted url
  48582. */
  48583. module.exports = function buildURL(url, params, paramsSerializer) {
  48584. /*eslint no-param-reassign:0*/
  48585. if (!params) {
  48586. return url;
  48587. }
  48588. var serializedParams;
  48589. if (paramsSerializer) {
  48590. serializedParams = paramsSerializer(params);
  48591. } else if (utils.isURLSearchParams(params)) {
  48592. serializedParams = params.toString();
  48593. } else {
  48594. var parts = [];
  48595. utils.forEach(params, function serialize(val, key) {
  48596. if (val === null || typeof val === 'undefined') {
  48597. return;
  48598. }
  48599. if (utils.isArray(val)) {
  48600. key = key + '[]';
  48601. } else {
  48602. val = [val];
  48603. }
  48604. utils.forEach(val, function parseValue(v) {
  48605. if (utils.isDate(v)) {
  48606. v = v.toISOString();
  48607. } else if (utils.isObject(v)) {
  48608. v = JSON.stringify(v);
  48609. }
  48610. parts.push(encode(key) + '=' + encode(v));
  48611. });
  48612. });
  48613. serializedParams = parts.join('&');
  48614. }
  48615. if (serializedParams) {
  48616. var hashmarkIndex = url.indexOf('#');
  48617. if (hashmarkIndex !== -1) {
  48618. url = url.slice(0, hashmarkIndex);
  48619. }
  48620. url += (url.indexOf('?') === -1 ? '?' : '&') + serializedParams;
  48621. }
  48622. return url;
  48623. };
  48624. },{"./../utils":320}],311:[function(_dereq_,module,exports){
  48625. 'use strict';
  48626. /**
  48627. * Creates a new URL by combining the specified URLs
  48628. *
  48629. * @param {string} baseURL The base URL
  48630. * @param {string} relativeURL The relative URL
  48631. * @returns {string} The combined URL
  48632. */
  48633. module.exports = function combineURLs(baseURL, relativeURL) {
  48634. return relativeURL
  48635. ? baseURL.replace(/\/+$/, '') + '/' + relativeURL.replace(/^\/+/, '')
  48636. : baseURL;
  48637. };
  48638. },{}],312:[function(_dereq_,module,exports){
  48639. 'use strict';
  48640. var utils = _dereq_('./../utils');
  48641. module.exports = (
  48642. utils.isStandardBrowserEnv() ?
  48643. // Standard browser envs support document.cookie
  48644. (function standardBrowserEnv() {
  48645. return {
  48646. write: function write(name, value, expires, path, domain, secure) {
  48647. var cookie = [];
  48648. cookie.push(name + '=' + encodeURIComponent(value));
  48649. if (utils.isNumber(expires)) {
  48650. cookie.push('expires=' + new Date(expires).toGMTString());
  48651. }
  48652. if (utils.isString(path)) {
  48653. cookie.push('path=' + path);
  48654. }
  48655. if (utils.isString(domain)) {
  48656. cookie.push('domain=' + domain);
  48657. }
  48658. if (secure === true) {
  48659. cookie.push('secure');
  48660. }
  48661. document.cookie = cookie.join('; ');
  48662. },
  48663. read: function read(name) {
  48664. var match = document.cookie.match(new RegExp('(^|;\\s*)(' + name + ')=([^;]*)'));
  48665. return (match ? decodeURIComponent(match[3]) : null);
  48666. },
  48667. remove: function remove(name) {
  48668. this.write(name, '', Date.now() - 86400000);
  48669. }
  48670. };
  48671. })() :
  48672. // Non standard browser env (web workers, react-native) lack needed support.
  48673. (function nonStandardBrowserEnv() {
  48674. return {
  48675. write: function write() {},
  48676. read: function read() { return null; },
  48677. remove: function remove() {}
  48678. };
  48679. })()
  48680. );
  48681. },{"./../utils":320}],313:[function(_dereq_,module,exports){
  48682. 'use strict';
  48683. /**
  48684. * Determines whether the specified URL is absolute
  48685. *
  48686. * @param {string} url The URL to test
  48687. * @returns {boolean} True if the specified URL is absolute, otherwise false
  48688. */
  48689. module.exports = function isAbsoluteURL(url) {
  48690. // A URL is considered absolute if it begins with "<scheme>://" or "//" (protocol-relative URL).
  48691. // RFC 3986 defines scheme name as a sequence of characters beginning with a letter and followed
  48692. // by any combination of letters, digits, plus, period, or hyphen.
  48693. return /^([a-z][a-z\d+\-.]*:)?\/\//i.test(url);
  48694. };
  48695. },{}],314:[function(_dereq_,module,exports){
  48696. 'use strict';
  48697. var utils = _dereq_('./../utils');
  48698. /**
  48699. * Determines whether the payload is an error thrown by Axios
  48700. *
  48701. * @param {*} payload The value to test
  48702. * @returns {boolean} True if the payload is an error thrown by Axios, otherwise false
  48703. */
  48704. module.exports = function isAxiosError(payload) {
  48705. return utils.isObject(payload) && (payload.isAxiosError === true);
  48706. };
  48707. },{"./../utils":320}],315:[function(_dereq_,module,exports){
  48708. 'use strict';
  48709. var utils = _dereq_('./../utils');
  48710. module.exports = (
  48711. utils.isStandardBrowserEnv() ?
  48712. // Standard browser envs have full support of the APIs needed to test
  48713. // whether the request URL is of the same origin as current location.
  48714. (function standardBrowserEnv() {
  48715. var msie = /(msie|trident)/i.test(navigator.userAgent);
  48716. var urlParsingNode = document.createElement('a');
  48717. var originURL;
  48718. /**
  48719. * Parse a URL to discover it's components
  48720. *
  48721. * @param {String} url The URL to be parsed
  48722. * @returns {Object}
  48723. */
  48724. function resolveURL(url) {
  48725. var href = url;
  48726. if (msie) {
  48727. // IE needs attribute set twice to normalize properties
  48728. urlParsingNode.setAttribute('href', href);
  48729. href = urlParsingNode.href;
  48730. }
  48731. urlParsingNode.setAttribute('href', href);
  48732. // urlParsingNode provides the UrlUtils interface - http://url.spec.whatwg.org/#urlutils
  48733. return {
  48734. href: urlParsingNode.href,
  48735. protocol: urlParsingNode.protocol ? urlParsingNode.protocol.replace(/:$/, '') : '',
  48736. host: urlParsingNode.host,
  48737. search: urlParsingNode.search ? urlParsingNode.search.replace(/^\?/, '') : '',
  48738. hash: urlParsingNode.hash ? urlParsingNode.hash.replace(/^#/, '') : '',
  48739. hostname: urlParsingNode.hostname,
  48740. port: urlParsingNode.port,
  48741. pathname: (urlParsingNode.pathname.charAt(0) === '/') ?
  48742. urlParsingNode.pathname :
  48743. '/' + urlParsingNode.pathname
  48744. };
  48745. }
  48746. originURL = resolveURL(window.location.href);
  48747. /**
  48748. * Determine if a URL shares the same origin as the current location
  48749. *
  48750. * @param {String} requestURL The URL to test
  48751. * @returns {boolean} True if URL shares the same origin, otherwise false
  48752. */
  48753. return function isURLSameOrigin(requestURL) {
  48754. var parsed = (utils.isString(requestURL)) ? resolveURL(requestURL) : requestURL;
  48755. return (parsed.protocol === originURL.protocol &&
  48756. parsed.host === originURL.host);
  48757. };
  48758. })() :
  48759. // Non standard browser envs (web workers, react-native) lack needed support.
  48760. (function nonStandardBrowserEnv() {
  48761. return function isURLSameOrigin() {
  48762. return true;
  48763. };
  48764. })()
  48765. );
  48766. },{"./../utils":320}],316:[function(_dereq_,module,exports){
  48767. 'use strict';
  48768. var utils = _dereq_('../utils');
  48769. module.exports = function normalizeHeaderName(headers, normalizedName) {
  48770. utils.forEach(headers, function processHeader(value, name) {
  48771. if (name !== normalizedName && name.toUpperCase() === normalizedName.toUpperCase()) {
  48772. headers[normalizedName] = value;
  48773. delete headers[name];
  48774. }
  48775. });
  48776. };
  48777. },{"../utils":320}],317:[function(_dereq_,module,exports){
  48778. 'use strict';
  48779. var utils = _dereq_('./../utils');
  48780. // Headers whose duplicates are ignored by node
  48781. // c.f. https://nodejs.org/api/http.html#http_message_headers
  48782. var ignoreDuplicateOf = [
  48783. 'age', 'authorization', 'content-length', 'content-type', 'etag',
  48784. 'expires', 'from', 'host', 'if-modified-since', 'if-unmodified-since',
  48785. 'last-modified', 'location', 'max-forwards', 'proxy-authorization',
  48786. 'referer', 'retry-after', 'user-agent'
  48787. ];
  48788. /**
  48789. * Parse headers into an object
  48790. *
  48791. * ```
  48792. * Date: Wed, 27 Aug 2014 08:58:49 GMT
  48793. * Content-Type: application/json
  48794. * Connection: keep-alive
  48795. * Transfer-Encoding: chunked
  48796. * ```
  48797. *
  48798. * @param {String} headers Headers needing to be parsed
  48799. * @returns {Object} Headers parsed into an object
  48800. */
  48801. module.exports = function parseHeaders(headers) {
  48802. var parsed = {};
  48803. var key;
  48804. var val;
  48805. var i;
  48806. if (!headers) { return parsed; }
  48807. utils.forEach(headers.split('\n'), function parser(line) {
  48808. i = line.indexOf(':');
  48809. key = utils.trim(line.substr(0, i)).toLowerCase();
  48810. val = utils.trim(line.substr(i + 1));
  48811. if (key) {
  48812. if (parsed[key] && ignoreDuplicateOf.indexOf(key) >= 0) {
  48813. return;
  48814. }
  48815. if (key === 'set-cookie') {
  48816. parsed[key] = (parsed[key] ? parsed[key] : []).concat([val]);
  48817. } else {
  48818. parsed[key] = parsed[key] ? parsed[key] + ', ' + val : val;
  48819. }
  48820. }
  48821. });
  48822. return parsed;
  48823. };
  48824. },{"./../utils":320}],318:[function(_dereq_,module,exports){
  48825. 'use strict';
  48826. /**
  48827. * Syntactic sugar for invoking a function and expanding an array for arguments.
  48828. *
  48829. * Common use case would be to use `Function.prototype.apply`.
  48830. *
  48831. * ```js
  48832. * function f(x, y, z) {}
  48833. * var args = [1, 2, 3];
  48834. * f.apply(null, args);
  48835. * ```
  48836. *
  48837. * With `spread` this example can be re-written.
  48838. *
  48839. * ```js
  48840. * spread(function(x, y, z) {})([1, 2, 3]);
  48841. * ```
  48842. *
  48843. * @param {Function} callback
  48844. * @returns {Function}
  48845. */
  48846. module.exports = function spread(callback) {
  48847. return function wrap(arr) {
  48848. return callback.apply(null, arr);
  48849. };
  48850. };
  48851. },{}],319:[function(_dereq_,module,exports){
  48852. 'use strict';
  48853. var VERSION = _dereq_('../env/data').version;
  48854. var validators = {};
  48855. // eslint-disable-next-line func-names
  48856. ['object', 'boolean', 'number', 'function', 'string', 'symbol'].forEach(function(type, i) {
  48857. validators[type] = function validator(thing) {
  48858. return typeof thing === type || 'a' + (i < 1 ? 'n ' : ' ') + type;
  48859. };
  48860. });
  48861. var deprecatedWarnings = {};
  48862. /**
  48863. * Transitional option validator
  48864. * @param {function|boolean?} validator - set to false if the transitional option has been removed
  48865. * @param {string?} version - deprecated version / removed since version
  48866. * @param {string?} message - some message with additional info
  48867. * @returns {function}
  48868. */
  48869. validators.transitional = function transitional(validator, version, message) {
  48870. function formatMessage(opt, desc) {
  48871. return '[Axios v' + VERSION + '] Transitional option \'' + opt + '\'' + desc + (message ? '. ' + message : '');
  48872. }
  48873. // eslint-disable-next-line func-names
  48874. return function(value, opt, opts) {
  48875. if (validator === false) {
  48876. throw new Error(formatMessage(opt, ' has been removed' + (version ? ' in ' + version : '')));
  48877. }
  48878. if (version && !deprecatedWarnings[opt]) {
  48879. deprecatedWarnings[opt] = true;
  48880. // eslint-disable-next-line no-console
  48881. console.warn(
  48882. formatMessage(
  48883. opt,
  48884. ' has been deprecated since v' + version + ' and will be removed in the near future'
  48885. )
  48886. );
  48887. }
  48888. return validator ? validator(value, opt, opts) : true;
  48889. };
  48890. };
  48891. /**
  48892. * Assert object's properties type
  48893. * @param {object} options
  48894. * @param {object} schema
  48895. * @param {boolean?} allowUnknown
  48896. */
  48897. function assertOptions(options, schema, allowUnknown) {
  48898. if (typeof options !== 'object') {
  48899. throw new TypeError('options must be an object');
  48900. }
  48901. var keys = Object.keys(options);
  48902. var i = keys.length;
  48903. while (i-- > 0) {
  48904. var opt = keys[i];
  48905. var validator = schema[opt];
  48906. if (validator) {
  48907. var value = options[opt];
  48908. var result = value === undefined || validator(value, opt, options);
  48909. if (result !== true) {
  48910. throw new TypeError('option ' + opt + ' must be ' + result);
  48911. }
  48912. continue;
  48913. }
  48914. if (allowUnknown !== true) {
  48915. throw Error('Unknown option ' + opt);
  48916. }
  48917. }
  48918. }
  48919. module.exports = {
  48920. assertOptions: assertOptions,
  48921. validators: validators
  48922. };
  48923. },{"../env/data":308}],320:[function(_dereq_,module,exports){
  48924. 'use strict';
  48925. var bind = _dereq_('./helpers/bind');
  48926. // utils is a library of generic helper functions non-specific to axios
  48927. var toString = Object.prototype.toString;
  48928. /**
  48929. * Determine if a value is an Array
  48930. *
  48931. * @param {Object} val The value to test
  48932. * @returns {boolean} True if value is an Array, otherwise false
  48933. */
  48934. function isArray(val) {
  48935. return Array.isArray(val);
  48936. }
  48937. /**
  48938. * Determine if a value is undefined
  48939. *
  48940. * @param {Object} val The value to test
  48941. * @returns {boolean} True if the value is undefined, otherwise false
  48942. */
  48943. function isUndefined(val) {
  48944. return typeof val === 'undefined';
  48945. }
  48946. /**
  48947. * Determine if a value is a Buffer
  48948. *
  48949. * @param {Object} val The value to test
  48950. * @returns {boolean} True if value is a Buffer, otherwise false
  48951. */
  48952. function isBuffer(val) {
  48953. return val !== null && !isUndefined(val) && val.constructor !== null && !isUndefined(val.constructor)
  48954. && typeof val.constructor.isBuffer === 'function' && val.constructor.isBuffer(val);
  48955. }
  48956. /**
  48957. * Determine if a value is an ArrayBuffer
  48958. *
  48959. * @param {Object} val The value to test
  48960. * @returns {boolean} True if value is an ArrayBuffer, otherwise false
  48961. */
  48962. function isArrayBuffer(val) {
  48963. return toString.call(val) === '[object ArrayBuffer]';
  48964. }
  48965. /**
  48966. * Determine if a value is a FormData
  48967. *
  48968. * @param {Object} val The value to test
  48969. * @returns {boolean} True if value is an FormData, otherwise false
  48970. */
  48971. function isFormData(val) {
  48972. return toString.call(val) === '[object FormData]';
  48973. }
  48974. /**
  48975. * Determine if a value is a view on an ArrayBuffer
  48976. *
  48977. * @param {Object} val The value to test
  48978. * @returns {boolean} True if value is a view on an ArrayBuffer, otherwise false
  48979. */
  48980. function isArrayBufferView(val) {
  48981. var result;
  48982. if ((typeof ArrayBuffer !== 'undefined') && (ArrayBuffer.isView)) {
  48983. result = ArrayBuffer.isView(val);
  48984. } else {
  48985. result = (val) && (val.buffer) && (isArrayBuffer(val.buffer));
  48986. }
  48987. return result;
  48988. }
  48989. /**
  48990. * Determine if a value is a String
  48991. *
  48992. * @param {Object} val The value to test
  48993. * @returns {boolean} True if value is a String, otherwise false
  48994. */
  48995. function isString(val) {
  48996. return typeof val === 'string';
  48997. }
  48998. /**
  48999. * Determine if a value is a Number
  49000. *
  49001. * @param {Object} val The value to test
  49002. * @returns {boolean} True if value is a Number, otherwise false
  49003. */
  49004. function isNumber(val) {
  49005. return typeof val === 'number';
  49006. }
  49007. /**
  49008. * Determine if a value is an Object
  49009. *
  49010. * @param {Object} val The value to test
  49011. * @returns {boolean} True if value is an Object, otherwise false
  49012. */
  49013. function isObject(val) {
  49014. return val !== null && typeof val === 'object';
  49015. }
  49016. /**
  49017. * Determine if a value is a plain Object
  49018. *
  49019. * @param {Object} val The value to test
  49020. * @return {boolean} True if value is a plain Object, otherwise false
  49021. */
  49022. function isPlainObject(val) {
  49023. if (toString.call(val) !== '[object Object]') {
  49024. return false;
  49025. }
  49026. var prototype = Object.getPrototypeOf(val);
  49027. return prototype === null || prototype === Object.prototype;
  49028. }
  49029. /**
  49030. * Determine if a value is a Date
  49031. *
  49032. * @param {Object} val The value to test
  49033. * @returns {boolean} True if value is a Date, otherwise false
  49034. */
  49035. function isDate(val) {
  49036. return toString.call(val) === '[object Date]';
  49037. }
  49038. /**
  49039. * Determine if a value is a File
  49040. *
  49041. * @param {Object} val The value to test
  49042. * @returns {boolean} True if value is a File, otherwise false
  49043. */
  49044. function isFile(val) {
  49045. return toString.call(val) === '[object File]';
  49046. }
  49047. /**
  49048. * Determine if a value is a Blob
  49049. *
  49050. * @param {Object} val The value to test
  49051. * @returns {boolean} True if value is a Blob, otherwise false
  49052. */
  49053. function isBlob(val) {
  49054. return toString.call(val) === '[object Blob]';
  49055. }
  49056. /**
  49057. * Determine if a value is a Function
  49058. *
  49059. * @param {Object} val The value to test
  49060. * @returns {boolean} True if value is a Function, otherwise false
  49061. */
  49062. function isFunction(val) {
  49063. return toString.call(val) === '[object Function]';
  49064. }
  49065. /**
  49066. * Determine if a value is a Stream
  49067. *
  49068. * @param {Object} val The value to test
  49069. * @returns {boolean} True if value is a Stream, otherwise false
  49070. */
  49071. function isStream(val) {
  49072. return isObject(val) && isFunction(val.pipe);
  49073. }
  49074. /**
  49075. * Determine if a value is a URLSearchParams object
  49076. *
  49077. * @param {Object} val The value to test
  49078. * @returns {boolean} True if value is a URLSearchParams object, otherwise false
  49079. */
  49080. function isURLSearchParams(val) {
  49081. return toString.call(val) === '[object URLSearchParams]';
  49082. }
  49083. /**
  49084. * Trim excess whitespace off the beginning and end of a string
  49085. *
  49086. * @param {String} str The String to trim
  49087. * @returns {String} The String freed of excess whitespace
  49088. */
  49089. function trim(str) {
  49090. return str.trim ? str.trim() : str.replace(/^\s+|\s+$/g, '');
  49091. }
  49092. /**
  49093. * Determine if we're running in a standard browser environment
  49094. *
  49095. * This allows axios to run in a web worker, and react-native.
  49096. * Both environments support XMLHttpRequest, but not fully standard globals.
  49097. *
  49098. * web workers:
  49099. * typeof window -> undefined
  49100. * typeof document -> undefined
  49101. *
  49102. * react-native:
  49103. * navigator.product -> 'ReactNative'
  49104. * nativescript
  49105. * navigator.product -> 'NativeScript' or 'NS'
  49106. */
  49107. function isStandardBrowserEnv() {
  49108. if (typeof navigator !== 'undefined' && (navigator.product === 'ReactNative' ||
  49109. navigator.product === 'NativeScript' ||
  49110. navigator.product === 'NS')) {
  49111. return false;
  49112. }
  49113. return (
  49114. typeof window !== 'undefined' &&
  49115. typeof document !== 'undefined'
  49116. );
  49117. }
  49118. /**
  49119. * Iterate over an Array or an Object invoking a function for each item.
  49120. *
  49121. * If `obj` is an Array callback will be called passing
  49122. * the value, index, and complete array for each item.
  49123. *
  49124. * If 'obj' is an Object callback will be called passing
  49125. * the value, key, and complete object for each property.
  49126. *
  49127. * @param {Object|Array} obj The object to iterate
  49128. * @param {Function} fn The callback to invoke for each item
  49129. */
  49130. function forEach(obj, fn) {
  49131. // Don't bother if no value provided
  49132. if (obj === null || typeof obj === 'undefined') {
  49133. return;
  49134. }
  49135. // Force an array if not already something iterable
  49136. if (typeof obj !== 'object') {
  49137. /*eslint no-param-reassign:0*/
  49138. obj = [obj];
  49139. }
  49140. if (isArray(obj)) {
  49141. // Iterate over array values
  49142. for (var i = 0, l = obj.length; i < l; i++) {
  49143. fn.call(null, obj[i], i, obj);
  49144. }
  49145. } else {
  49146. // Iterate over object keys
  49147. for (var key in obj) {
  49148. if (Object.prototype.hasOwnProperty.call(obj, key)) {
  49149. fn.call(null, obj[key], key, obj);
  49150. }
  49151. }
  49152. }
  49153. }
  49154. /**
  49155. * Accepts varargs expecting each argument to be an object, then
  49156. * immutably merges the properties of each object and returns result.
  49157. *
  49158. * When multiple objects contain the same key the later object in
  49159. * the arguments list will take precedence.
  49160. *
  49161. * Example:
  49162. *
  49163. * ```js
  49164. * var result = merge({foo: 123}, {foo: 456});
  49165. * console.log(result.foo); // outputs 456
  49166. * ```
  49167. *
  49168. * @param {Object} obj1 Object to merge
  49169. * @returns {Object} Result of all merge properties
  49170. */
  49171. function merge(/* obj1, obj2, obj3, ... */) {
  49172. var result = {};
  49173. function assignValue(val, key) {
  49174. if (isPlainObject(result[key]) && isPlainObject(val)) {
  49175. result[key] = merge(result[key], val);
  49176. } else if (isPlainObject(val)) {
  49177. result[key] = merge({}, val);
  49178. } else if (isArray(val)) {
  49179. result[key] = val.slice();
  49180. } else {
  49181. result[key] = val;
  49182. }
  49183. }
  49184. for (var i = 0, l = arguments.length; i < l; i++) {
  49185. forEach(arguments[i], assignValue);
  49186. }
  49187. return result;
  49188. }
  49189. /**
  49190. * Extends object a by mutably adding to it the properties of object b.
  49191. *
  49192. * @param {Object} a The object to be extended
  49193. * @param {Object} b The object to copy properties from
  49194. * @param {Object} thisArg The object to bind function to
  49195. * @return {Object} The resulting value of object a
  49196. */
  49197. function extend(a, b, thisArg) {
  49198. forEach(b, function assignValue(val, key) {
  49199. if (thisArg && typeof val === 'function') {
  49200. a[key] = bind(val, thisArg);
  49201. } else {
  49202. a[key] = val;
  49203. }
  49204. });
  49205. return a;
  49206. }
  49207. /**
  49208. * Remove byte order marker. This catches EF BB BF (the UTF-8 BOM)
  49209. *
  49210. * @param {string} content with BOM
  49211. * @return {string} content value without BOM
  49212. */
  49213. function stripBOM(content) {
  49214. if (content.charCodeAt(0) === 0xFEFF) {
  49215. content = content.slice(1);
  49216. }
  49217. return content;
  49218. }
  49219. module.exports = {
  49220. isArray: isArray,
  49221. isArrayBuffer: isArrayBuffer,
  49222. isBuffer: isBuffer,
  49223. isFormData: isFormData,
  49224. isArrayBufferView: isArrayBufferView,
  49225. isString: isString,
  49226. isNumber: isNumber,
  49227. isObject: isObject,
  49228. isPlainObject: isPlainObject,
  49229. isUndefined: isUndefined,
  49230. isDate: isDate,
  49231. isFile: isFile,
  49232. isBlob: isBlob,
  49233. isFunction: isFunction,
  49234. isStream: isStream,
  49235. isURLSearchParams: isURLSearchParams,
  49236. isStandardBrowserEnv: isStandardBrowserEnv,
  49237. forEach: forEach,
  49238. merge: merge,
  49239. extend: extend,
  49240. trim: trim,
  49241. stripBOM: stripBOM
  49242. };
  49243. },{"./helpers/bind":309}],321:[function(_dereq_,module,exports){
  49244. 'use strict'
  49245. var ALPHABET = 'qpzry9x8gf2tvdw0s3jn54khce6mua7l'
  49246. // pre-compute lookup table
  49247. var ALPHABET_MAP = {}
  49248. for (var z = 0; z < ALPHABET.length; z++) {
  49249. var x = ALPHABET.charAt(z)
  49250. if (ALPHABET_MAP[x] !== undefined) throw new TypeError(x + ' is ambiguous')
  49251. ALPHABET_MAP[x] = z
  49252. }
  49253. function polymodStep (pre) {
  49254. var b = pre >> 25
  49255. return ((pre & 0x1FFFFFF) << 5) ^
  49256. (-((b >> 0) & 1) & 0x3b6a57b2) ^
  49257. (-((b >> 1) & 1) & 0x26508e6d) ^
  49258. (-((b >> 2) & 1) & 0x1ea119fa) ^
  49259. (-((b >> 3) & 1) & 0x3d4233dd) ^
  49260. (-((b >> 4) & 1) & 0x2a1462b3)
  49261. }
  49262. function prefixChk (prefix) {
  49263. var chk = 1
  49264. for (var i = 0; i < prefix.length; ++i) {
  49265. var c = prefix.charCodeAt(i)
  49266. if (c < 33 || c > 126) return 'Invalid prefix (' + prefix + ')'
  49267. chk = polymodStep(chk) ^ (c >> 5)
  49268. }
  49269. chk = polymodStep(chk)
  49270. for (i = 0; i < prefix.length; ++i) {
  49271. var v = prefix.charCodeAt(i)
  49272. chk = polymodStep(chk) ^ (v & 0x1f)
  49273. }
  49274. return chk
  49275. }
  49276. function encode (prefix, words, LIMIT) {
  49277. LIMIT = LIMIT || 90
  49278. if ((prefix.length + 7 + words.length) > LIMIT) throw new TypeError('Exceeds length limit')
  49279. prefix = prefix.toLowerCase()
  49280. // determine chk mod
  49281. var chk = prefixChk(prefix)
  49282. if (typeof chk === 'string') throw new Error(chk)
  49283. var result = prefix + '1'
  49284. for (var i = 0; i < words.length; ++i) {
  49285. var x = words[i]
  49286. if ((x >> 5) !== 0) throw new Error('Non 5-bit word')
  49287. chk = polymodStep(chk) ^ x
  49288. result += ALPHABET.charAt(x)
  49289. }
  49290. for (i = 0; i < 6; ++i) {
  49291. chk = polymodStep(chk)
  49292. }
  49293. chk ^= 1
  49294. for (i = 0; i < 6; ++i) {
  49295. var v = (chk >> ((5 - i) * 5)) & 0x1f
  49296. result += ALPHABET.charAt(v)
  49297. }
  49298. return result
  49299. }
  49300. function __decode (str, LIMIT) {
  49301. LIMIT = LIMIT || 90
  49302. if (str.length < 8) return str + ' too short'
  49303. if (str.length > LIMIT) return 'Exceeds length limit'
  49304. // don't allow mixed case
  49305. var lowered = str.toLowerCase()
  49306. var uppered = str.toUpperCase()
  49307. if (str !== lowered && str !== uppered) return 'Mixed-case string ' + str
  49308. str = lowered
  49309. var split = str.lastIndexOf('1')
  49310. if (split === -1) return 'No separator character for ' + str
  49311. if (split === 0) return 'Missing prefix for ' + str
  49312. var prefix = str.slice(0, split)
  49313. var wordChars = str.slice(split + 1)
  49314. if (wordChars.length < 6) return 'Data too short'
  49315. var chk = prefixChk(prefix)
  49316. if (typeof chk === 'string') return chk
  49317. var words = []
  49318. for (var i = 0; i < wordChars.length; ++i) {
  49319. var c = wordChars.charAt(i)
  49320. var v = ALPHABET_MAP[c]
  49321. if (v === undefined) return 'Unknown character ' + c
  49322. chk = polymodStep(chk) ^ v
  49323. // not in the checksum?
  49324. if (i + 6 >= wordChars.length) continue
  49325. words.push(v)
  49326. }
  49327. if (chk !== 1) return 'Invalid checksum for ' + str
  49328. return { prefix: prefix, words: words }
  49329. }
  49330. function decodeUnsafe () {
  49331. var res = __decode.apply(null, arguments)
  49332. if (typeof res === 'object') return res
  49333. }
  49334. function decode (str) {
  49335. var res = __decode.apply(null, arguments)
  49336. if (typeof res === 'object') return res
  49337. throw new Error(res)
  49338. }
  49339. function convert (data, inBits, outBits, pad) {
  49340. var value = 0
  49341. var bits = 0
  49342. var maxV = (1 << outBits) - 1
  49343. var result = []
  49344. for (var i = 0; i < data.length; ++i) {
  49345. value = (value << inBits) | data[i]
  49346. bits += inBits
  49347. while (bits >= outBits) {
  49348. bits -= outBits
  49349. result.push((value >> bits) & maxV)
  49350. }
  49351. }
  49352. if (pad) {
  49353. if (bits > 0) {
  49354. result.push((value << (outBits - bits)) & maxV)
  49355. }
  49356. } else {
  49357. if (bits >= inBits) return 'Excess padding'
  49358. if ((value << (outBits - bits)) & maxV) return 'Non-zero padding'
  49359. }
  49360. return result
  49361. }
  49362. function toWordsUnsafe (bytes) {
  49363. var res = convert(bytes, 8, 5, true)
  49364. if (Array.isArray(res)) return res
  49365. }
  49366. function toWords (bytes) {
  49367. var res = convert(bytes, 8, 5, true)
  49368. if (Array.isArray(res)) return res
  49369. throw new Error(res)
  49370. }
  49371. function fromWordsUnsafe (words) {
  49372. var res = convert(words, 5, 8, false)
  49373. if (Array.isArray(res)) return res
  49374. }
  49375. function fromWords (words) {
  49376. var res = convert(words, 5, 8, false)
  49377. if (Array.isArray(res)) return res
  49378. throw new Error(res)
  49379. }
  49380. module.exports = {
  49381. decodeUnsafe: decodeUnsafe,
  49382. decode: decode,
  49383. encode: encode,
  49384. toWordsUnsafe: toWordsUnsafe,
  49385. toWords: toWords,
  49386. fromWordsUnsafe: fromWordsUnsafe,
  49387. fromWords: fromWords
  49388. }
  49389. },{}],322:[function(_dereq_,module,exports){
  49390. var r;
  49391. module.exports = function rand(len) {
  49392. if (!r)
  49393. r = new Rand(null);
  49394. return r.generate(len);
  49395. };
  49396. function Rand(rand) {
  49397. this.rand = rand;
  49398. }
  49399. module.exports.Rand = Rand;
  49400. Rand.prototype.generate = function generate(len) {
  49401. return this._rand(len);
  49402. };
  49403. // Emulate crypto API using randy
  49404. Rand.prototype._rand = function _rand(n) {
  49405. if (this.rand.getBytes)
  49406. return this.rand.getBytes(n);
  49407. var res = new Uint8Array(n);
  49408. for (var i = 0; i < res.length; i++)
  49409. res[i] = this.rand.getByte();
  49410. return res;
  49411. };
  49412. if (typeof self === 'object') {
  49413. if (self.crypto && self.crypto.getRandomValues) {
  49414. // Modern browsers
  49415. Rand.prototype._rand = function _rand(n) {
  49416. var arr = new Uint8Array(n);
  49417. self.crypto.getRandomValues(arr);
  49418. return arr;
  49419. };
  49420. } else if (self.msCrypto && self.msCrypto.getRandomValues) {
  49421. // IE
  49422. Rand.prototype._rand = function _rand(n) {
  49423. var arr = new Uint8Array(n);
  49424. self.msCrypto.getRandomValues(arr);
  49425. return arr;
  49426. };
  49427. // Safari's WebWorkers do not have `crypto`
  49428. } else if (typeof window === 'object') {
  49429. // Old junk
  49430. Rand.prototype._rand = function() {
  49431. throw new Error('Not implemented yet');
  49432. };
  49433. }
  49434. } else {
  49435. // Node.js or Web worker with no crypto support
  49436. try {
  49437. var crypto = _dereq_('crypto');
  49438. if (typeof crypto.randomBytes !== 'function')
  49439. throw new Error('Not supported');
  49440. Rand.prototype._rand = function _rand(n) {
  49441. return crypto.randomBytes(n);
  49442. };
  49443. } catch (e) {
  49444. }
  49445. }
  49446. },{"crypto":undefined}],323:[function(_dereq_,module,exports){
  49447. },{}],324:[function(_dereq_,module,exports){
  49448. var parent = _dereq_('../../stable/array/from');
  49449. module.exports = parent;
  49450. },{"../../stable/array/from":691}],325:[function(_dereq_,module,exports){
  49451. var parent = _dereq_('../../stable/array/is-array');
  49452. module.exports = parent;
  49453. },{"../../stable/array/is-array":692}],326:[function(_dereq_,module,exports){
  49454. var parent = _dereq_('../stable/get-iterator-method');
  49455. module.exports = parent;
  49456. },{"../stable/get-iterator-method":697}],327:[function(_dereq_,module,exports){
  49457. var parent = _dereq_('../../stable/instance/bind');
  49458. module.exports = parent;
  49459. },{"../../stable/instance/bind":698}],328:[function(_dereq_,module,exports){
  49460. var parent = _dereq_('../../stable/instance/index-of');
  49461. module.exports = parent;
  49462. },{"../../stable/instance/index-of":706}],329:[function(_dereq_,module,exports){
  49463. var parent = _dereq_('../../stable/instance/slice');
  49464. module.exports = parent;
  49465. },{"../../stable/instance/slice":711}],330:[function(_dereq_,module,exports){
  49466. var parent = _dereq_('../../stable/map');
  49467. module.exports = parent;
  49468. },{"../../stable/map":718}],331:[function(_dereq_,module,exports){
  49469. var parent = _dereq_('../../stable/object/create');
  49470. module.exports = parent;
  49471. },{"../../stable/object/create":721}],332:[function(_dereq_,module,exports){
  49472. var parent = _dereq_('../../stable/object/define-property');
  49473. module.exports = parent;
  49474. },{"../../stable/object/define-property":723}],333:[function(_dereq_,module,exports){
  49475. var parent = _dereq_('../../stable/object/get-own-property-descriptor');
  49476. module.exports = parent;
  49477. },{"../../stable/object/get-own-property-descriptor":726}],334:[function(_dereq_,module,exports){
  49478. var parent = _dereq_('../../stable/object/get-prototype-of');
  49479. module.exports = parent;
  49480. },{"../../stable/object/get-prototype-of":729}],335:[function(_dereq_,module,exports){
  49481. var parent = _dereq_('../../stable/object/set-prototype-of');
  49482. module.exports = parent;
  49483. },{"../../stable/object/set-prototype-of":731}],336:[function(_dereq_,module,exports){
  49484. var parent = _dereq_('../../stable/promise');
  49485. module.exports = parent;
  49486. },{"../../stable/promise":734}],337:[function(_dereq_,module,exports){
  49487. var parent = _dereq_('../../stable/reflect/construct');
  49488. module.exports = parent;
  49489. },{"../../stable/reflect/construct":735}],338:[function(_dereq_,module,exports){
  49490. var parent = _dereq_('../../stable/reflect/get');
  49491. module.exports = parent;
  49492. },{"../../stable/reflect/get":736}],339:[function(_dereq_,module,exports){
  49493. var parent = _dereq_('../../stable/symbol');
  49494. module.exports = parent;
  49495. },{"../../stable/symbol":739}],340:[function(_dereq_,module,exports){
  49496. var parent = _dereq_('../../stable/symbol/iterator');
  49497. module.exports = parent;
  49498. },{"../../stable/symbol/iterator":740}],341:[function(_dereq_,module,exports){
  49499. _dereq_('../../modules/es.string.iterator');
  49500. _dereq_('../../modules/es.array.from');
  49501. var path = _dereq_('../../internals/path');
  49502. module.exports = path.Array.from;
  49503. },{"../../internals/path":548,"../../modules/es.array.from":594,"../../modules/es.string.iterator":634}],342:[function(_dereq_,module,exports){
  49504. _dereq_('../../modules/es.array.is-array');
  49505. var path = _dereq_('../../internals/path');
  49506. module.exports = path.Array.isArray;
  49507. },{"../../internals/path":548,"../../modules/es.array.is-array":597}],343:[function(_dereq_,module,exports){
  49508. _dereq_('../../../modules/es.array.concat');
  49509. var entryVirtual = _dereq_('../../../internals/entry-virtual');
  49510. module.exports = entryVirtual('Array').concat;
  49511. },{"../../../internals/entry-virtual":473,"../../../modules/es.array.concat":589}],344:[function(_dereq_,module,exports){
  49512. _dereq_('../../../modules/es.array.iterator');
  49513. _dereq_('../../../modules/es.object.to-string');
  49514. var entryVirtual = _dereq_('../../../internals/entry-virtual');
  49515. module.exports = entryVirtual('Array').entries;
  49516. },{"../../../internals/entry-virtual":473,"../../../modules/es.array.iterator":598,"../../../modules/es.object.to-string":621}],345:[function(_dereq_,module,exports){
  49517. _dereq_('../../../modules/es.array.every');
  49518. var entryVirtual = _dereq_('../../../internals/entry-virtual');
  49519. module.exports = entryVirtual('Array').every;
  49520. },{"../../../internals/entry-virtual":473,"../../../modules/es.array.every":590}],346:[function(_dereq_,module,exports){
  49521. _dereq_('../../../modules/es.array.filter');
  49522. var entryVirtual = _dereq_('../../../internals/entry-virtual');
  49523. module.exports = entryVirtual('Array').filter;
  49524. },{"../../../internals/entry-virtual":473,"../../../modules/es.array.filter":591}],347:[function(_dereq_,module,exports){
  49525. _dereq_('../../../modules/es.array.find');
  49526. var entryVirtual = _dereq_('../../../internals/entry-virtual');
  49527. module.exports = entryVirtual('Array').find;
  49528. },{"../../../internals/entry-virtual":473,"../../../modules/es.array.find":592}],348:[function(_dereq_,module,exports){
  49529. _dereq_('../../../modules/es.array.for-each');
  49530. var entryVirtual = _dereq_('../../../internals/entry-virtual');
  49531. module.exports = entryVirtual('Array').forEach;
  49532. },{"../../../internals/entry-virtual":473,"../../../modules/es.array.for-each":593}],349:[function(_dereq_,module,exports){
  49533. _dereq_('../../../modules/es.array.includes');
  49534. var entryVirtual = _dereq_('../../../internals/entry-virtual');
  49535. module.exports = entryVirtual('Array').includes;
  49536. },{"../../../internals/entry-virtual":473,"../../../modules/es.array.includes":595}],350:[function(_dereq_,module,exports){
  49537. _dereq_('../../../modules/es.array.index-of');
  49538. var entryVirtual = _dereq_('../../../internals/entry-virtual');
  49539. module.exports = entryVirtual('Array').indexOf;
  49540. },{"../../../internals/entry-virtual":473,"../../../modules/es.array.index-of":596}],351:[function(_dereq_,module,exports){
  49541. _dereq_('../../../modules/es.array.iterator');
  49542. _dereq_('../../../modules/es.object.to-string');
  49543. var entryVirtual = _dereq_('../../../internals/entry-virtual');
  49544. module.exports = entryVirtual('Array').keys;
  49545. },{"../../../internals/entry-virtual":473,"../../../modules/es.array.iterator":598,"../../../modules/es.object.to-string":621}],352:[function(_dereq_,module,exports){
  49546. _dereq_('../../../modules/es.array.map');
  49547. var entryVirtual = _dereq_('../../../internals/entry-virtual');
  49548. module.exports = entryVirtual('Array').map;
  49549. },{"../../../internals/entry-virtual":473,"../../../modules/es.array.map":599}],353:[function(_dereq_,module,exports){
  49550. _dereq_('../../../modules/es.array.reduce');
  49551. var entryVirtual = _dereq_('../../../internals/entry-virtual');
  49552. module.exports = entryVirtual('Array').reduce;
  49553. },{"../../../internals/entry-virtual":473,"../../../modules/es.array.reduce":600}],354:[function(_dereq_,module,exports){
  49554. _dereq_('../../../modules/es.array.slice');
  49555. var entryVirtual = _dereq_('../../../internals/entry-virtual');
  49556. module.exports = entryVirtual('Array').slice;
  49557. },{"../../../internals/entry-virtual":473,"../../../modules/es.array.slice":601}],355:[function(_dereq_,module,exports){
  49558. _dereq_('../../../modules/es.array.sort');
  49559. var entryVirtual = _dereq_('../../../internals/entry-virtual');
  49560. module.exports = entryVirtual('Array').sort;
  49561. },{"../../../internals/entry-virtual":473,"../../../modules/es.array.sort":602}],356:[function(_dereq_,module,exports){
  49562. _dereq_('../../../modules/es.array.splice');
  49563. var entryVirtual = _dereq_('../../../internals/entry-virtual');
  49564. module.exports = entryVirtual('Array').splice;
  49565. },{"../../../internals/entry-virtual":473,"../../../modules/es.array.splice":603}],357:[function(_dereq_,module,exports){
  49566. _dereq_('../../../modules/es.array.iterator');
  49567. _dereq_('../../../modules/es.object.to-string');
  49568. var entryVirtual = _dereq_('../../../internals/entry-virtual');
  49569. module.exports = entryVirtual('Array').values;
  49570. },{"../../../internals/entry-virtual":473,"../../../modules/es.array.iterator":598,"../../../modules/es.object.to-string":621}],358:[function(_dereq_,module,exports){
  49571. _dereq_('../../../modules/es.function.bind');
  49572. var entryVirtual = _dereq_('../../../internals/entry-virtual');
  49573. module.exports = entryVirtual('Function').bind;
  49574. },{"../../../internals/entry-virtual":473,"../../../modules/es.function.bind":604}],359:[function(_dereq_,module,exports){
  49575. _dereq_('../modules/es.array.iterator');
  49576. _dereq_('../modules/es.string.iterator');
  49577. var getIteratorMethod = _dereq_('../internals/get-iterator-method');
  49578. module.exports = getIteratorMethod;
  49579. },{"../internals/get-iterator-method":487,"../modules/es.array.iterator":598,"../modules/es.string.iterator":634}],360:[function(_dereq_,module,exports){
  49580. var isPrototypeOf = _dereq_('../../internals/object-is-prototype-of');
  49581. var method = _dereq_('../function/virtual/bind');
  49582. var FunctionPrototype = Function.prototype;
  49583. module.exports = function (it) {
  49584. var own = it.bind;
  49585. return it === FunctionPrototype || (isPrototypeOf(FunctionPrototype, it) && own === FunctionPrototype.bind) ? method : own;
  49586. };
  49587. },{"../../internals/object-is-prototype-of":539,"../function/virtual/bind":358}],361:[function(_dereq_,module,exports){
  49588. var isPrototypeOf = _dereq_('../../internals/object-is-prototype-of');
  49589. var method = _dereq_('../array/virtual/concat');
  49590. var ArrayPrototype = Array.prototype;
  49591. module.exports = function (it) {
  49592. var own = it.concat;
  49593. return it === ArrayPrototype || (isPrototypeOf(ArrayPrototype, it) && own === ArrayPrototype.concat) ? method : own;
  49594. };
  49595. },{"../../internals/object-is-prototype-of":539,"../array/virtual/concat":343}],362:[function(_dereq_,module,exports){
  49596. var isPrototypeOf = _dereq_('../../internals/object-is-prototype-of');
  49597. var method = _dereq_('../array/virtual/every');
  49598. var ArrayPrototype = Array.prototype;
  49599. module.exports = function (it) {
  49600. var own = it.every;
  49601. return it === ArrayPrototype || (isPrototypeOf(ArrayPrototype, it) && own === ArrayPrototype.every) ? method : own;
  49602. };
  49603. },{"../../internals/object-is-prototype-of":539,"../array/virtual/every":345}],363:[function(_dereq_,module,exports){
  49604. var isPrototypeOf = _dereq_('../../internals/object-is-prototype-of');
  49605. var method = _dereq_('../array/virtual/filter');
  49606. var ArrayPrototype = Array.prototype;
  49607. module.exports = function (it) {
  49608. var own = it.filter;
  49609. return it === ArrayPrototype || (isPrototypeOf(ArrayPrototype, it) && own === ArrayPrototype.filter) ? method : own;
  49610. };
  49611. },{"../../internals/object-is-prototype-of":539,"../array/virtual/filter":346}],364:[function(_dereq_,module,exports){
  49612. var isPrototypeOf = _dereq_('../../internals/object-is-prototype-of');
  49613. var method = _dereq_('../array/virtual/find');
  49614. var ArrayPrototype = Array.prototype;
  49615. module.exports = function (it) {
  49616. var own = it.find;
  49617. return it === ArrayPrototype || (isPrototypeOf(ArrayPrototype, it) && own === ArrayPrototype.find) ? method : own;
  49618. };
  49619. },{"../../internals/object-is-prototype-of":539,"../array/virtual/find":347}],365:[function(_dereq_,module,exports){
  49620. var isPrototypeOf = _dereq_('../../internals/object-is-prototype-of');
  49621. var arrayMethod = _dereq_('../array/virtual/includes');
  49622. var stringMethod = _dereq_('../string/virtual/includes');
  49623. var ArrayPrototype = Array.prototype;
  49624. var StringPrototype = String.prototype;
  49625. module.exports = function (it) {
  49626. var own = it.includes;
  49627. if (it === ArrayPrototype || (isPrototypeOf(ArrayPrototype, it) && own === ArrayPrototype.includes)) return arrayMethod;
  49628. if (typeof it == 'string' || it === StringPrototype || (isPrototypeOf(StringPrototype, it) && own === StringPrototype.includes)) {
  49629. return stringMethod;
  49630. } return own;
  49631. };
  49632. },{"../../internals/object-is-prototype-of":539,"../array/virtual/includes":349,"../string/virtual/includes":396}],366:[function(_dereq_,module,exports){
  49633. var isPrototypeOf = _dereq_('../../internals/object-is-prototype-of');
  49634. var method = _dereq_('../array/virtual/index-of');
  49635. var ArrayPrototype = Array.prototype;
  49636. module.exports = function (it) {
  49637. var own = it.indexOf;
  49638. return it === ArrayPrototype || (isPrototypeOf(ArrayPrototype, it) && own === ArrayPrototype.indexOf) ? method : own;
  49639. };
  49640. },{"../../internals/object-is-prototype-of":539,"../array/virtual/index-of":350}],367:[function(_dereq_,module,exports){
  49641. var isPrototypeOf = _dereq_('../../internals/object-is-prototype-of');
  49642. var method = _dereq_('../array/virtual/map');
  49643. var ArrayPrototype = Array.prototype;
  49644. module.exports = function (it) {
  49645. var own = it.map;
  49646. return it === ArrayPrototype || (isPrototypeOf(ArrayPrototype, it) && own === ArrayPrototype.map) ? method : own;
  49647. };
  49648. },{"../../internals/object-is-prototype-of":539,"../array/virtual/map":352}],368:[function(_dereq_,module,exports){
  49649. var isPrototypeOf = _dereq_('../../internals/object-is-prototype-of');
  49650. var method = _dereq_('../string/virtual/pad-start');
  49651. var StringPrototype = String.prototype;
  49652. module.exports = function (it) {
  49653. var own = it.padStart;
  49654. return typeof it == 'string' || it === StringPrototype
  49655. || (isPrototypeOf(StringPrototype, it) && own === StringPrototype.padStart) ? method : own;
  49656. };
  49657. },{"../../internals/object-is-prototype-of":539,"../string/virtual/pad-start":397}],369:[function(_dereq_,module,exports){
  49658. var isPrototypeOf = _dereq_('../../internals/object-is-prototype-of');
  49659. var method = _dereq_('../array/virtual/reduce');
  49660. var ArrayPrototype = Array.prototype;
  49661. module.exports = function (it) {
  49662. var own = it.reduce;
  49663. return it === ArrayPrototype || (isPrototypeOf(ArrayPrototype, it) && own === ArrayPrototype.reduce) ? method : own;
  49664. };
  49665. },{"../../internals/object-is-prototype-of":539,"../array/virtual/reduce":353}],370:[function(_dereq_,module,exports){
  49666. var isPrototypeOf = _dereq_('../../internals/object-is-prototype-of');
  49667. var method = _dereq_('../array/virtual/slice');
  49668. var ArrayPrototype = Array.prototype;
  49669. module.exports = function (it) {
  49670. var own = it.slice;
  49671. return it === ArrayPrototype || (isPrototypeOf(ArrayPrototype, it) && own === ArrayPrototype.slice) ? method : own;
  49672. };
  49673. },{"../../internals/object-is-prototype-of":539,"../array/virtual/slice":354}],371:[function(_dereq_,module,exports){
  49674. var isPrototypeOf = _dereq_('../../internals/object-is-prototype-of');
  49675. var method = _dereq_('../array/virtual/sort');
  49676. var ArrayPrototype = Array.prototype;
  49677. module.exports = function (it) {
  49678. var own = it.sort;
  49679. return it === ArrayPrototype || (isPrototypeOf(ArrayPrototype, it) && own === ArrayPrototype.sort) ? method : own;
  49680. };
  49681. },{"../../internals/object-is-prototype-of":539,"../array/virtual/sort":355}],372:[function(_dereq_,module,exports){
  49682. var isPrototypeOf = _dereq_('../../internals/object-is-prototype-of');
  49683. var method = _dereq_('../array/virtual/splice');
  49684. var ArrayPrototype = Array.prototype;
  49685. module.exports = function (it) {
  49686. var own = it.splice;
  49687. return it === ArrayPrototype || (isPrototypeOf(ArrayPrototype, it) && own === ArrayPrototype.splice) ? method : own;
  49688. };
  49689. },{"../../internals/object-is-prototype-of":539,"../array/virtual/splice":356}],373:[function(_dereq_,module,exports){
  49690. var isPrototypeOf = _dereq_('../../internals/object-is-prototype-of');
  49691. var method = _dereq_('../string/virtual/starts-with');
  49692. var StringPrototype = String.prototype;
  49693. module.exports = function (it) {
  49694. var own = it.startsWith;
  49695. return typeof it == 'string' || it === StringPrototype
  49696. || (isPrototypeOf(StringPrototype, it) && own === StringPrototype.startsWith) ? method : own;
  49697. };
  49698. },{"../../internals/object-is-prototype-of":539,"../string/virtual/starts-with":398}],374:[function(_dereq_,module,exports){
  49699. var isPrototypeOf = _dereq_('../../internals/object-is-prototype-of');
  49700. var method = _dereq_('../string/virtual/trim');
  49701. var StringPrototype = String.prototype;
  49702. module.exports = function (it) {
  49703. var own = it.trim;
  49704. return typeof it == 'string' || it === StringPrototype
  49705. || (isPrototypeOf(StringPrototype, it) && own === StringPrototype.trim) ? method : own;
  49706. };
  49707. },{"../../internals/object-is-prototype-of":539,"../string/virtual/trim":399}],375:[function(_dereq_,module,exports){
  49708. _dereq_('../../modules/es.json.stringify');
  49709. var path = _dereq_('../../internals/path');
  49710. var apply = _dereq_('../../internals/function-apply');
  49711. // eslint-disable-next-line es/no-json -- safe
  49712. if (!path.JSON) path.JSON = { stringify: JSON.stringify };
  49713. // eslint-disable-next-line no-unused-vars -- required for `.length`
  49714. module.exports = function stringify(it, replacer, space) {
  49715. return apply(path.JSON.stringify, null, arguments);
  49716. };
  49717. },{"../../internals/function-apply":479,"../../internals/path":548,"../../modules/es.json.stringify":605}],376:[function(_dereq_,module,exports){
  49718. _dereq_('../../modules/es.array.iterator');
  49719. _dereq_('../../modules/es.map');
  49720. _dereq_('../../modules/es.object.to-string');
  49721. _dereq_('../../modules/es.string.iterator');
  49722. var path = _dereq_('../../internals/path');
  49723. module.exports = path.Map;
  49724. },{"../../internals/path":548,"../../modules/es.array.iterator":598,"../../modules/es.map":607,"../../modules/es.object.to-string":621,"../../modules/es.string.iterator":634}],377:[function(_dereq_,module,exports){
  49725. _dereq_('../../modules/es.number.is-integer');
  49726. var path = _dereq_('../../internals/path');
  49727. module.exports = path.Number.isInteger;
  49728. },{"../../internals/path":548,"../../modules/es.number.is-integer":609}],378:[function(_dereq_,module,exports){
  49729. _dereq_('../../modules/es.number.is-nan');
  49730. var path = _dereq_('../../internals/path');
  49731. module.exports = path.Number.isNaN;
  49732. },{"../../internals/path":548,"../../modules/es.number.is-nan":610}],379:[function(_dereq_,module,exports){
  49733. _dereq_('../../modules/es.object.create');
  49734. var path = _dereq_('../../internals/path');
  49735. var Object = path.Object;
  49736. module.exports = function create(P, D) {
  49737. return Object.create(P, D);
  49738. };
  49739. },{"../../internals/path":548,"../../modules/es.object.create":611}],380:[function(_dereq_,module,exports){
  49740. _dereq_('../../modules/es.object.define-properties');
  49741. var path = _dereq_('../../internals/path');
  49742. var Object = path.Object;
  49743. var defineProperties = module.exports = function defineProperties(T, D) {
  49744. return Object.defineProperties(T, D);
  49745. };
  49746. if (Object.defineProperties.sham) defineProperties.sham = true;
  49747. },{"../../internals/path":548,"../../modules/es.object.define-properties":612}],381:[function(_dereq_,module,exports){
  49748. _dereq_('../../modules/es.object.define-property');
  49749. var path = _dereq_('../../internals/path');
  49750. var Object = path.Object;
  49751. var defineProperty = module.exports = function defineProperty(it, key, desc) {
  49752. return Object.defineProperty(it, key, desc);
  49753. };
  49754. if (Object.defineProperty.sham) defineProperty.sham = true;
  49755. },{"../../internals/path":548,"../../modules/es.object.define-property":613}],382:[function(_dereq_,module,exports){
  49756. _dereq_('../../modules/es.object.entries');
  49757. var path = _dereq_('../../internals/path');
  49758. module.exports = path.Object.entries;
  49759. },{"../../internals/path":548,"../../modules/es.object.entries":614}],383:[function(_dereq_,module,exports){
  49760. _dereq_('../../modules/es.object.freeze');
  49761. var path = _dereq_('../../internals/path');
  49762. module.exports = path.Object.freeze;
  49763. },{"../../internals/path":548,"../../modules/es.object.freeze":615}],384:[function(_dereq_,module,exports){
  49764. _dereq_('../../modules/es.object.get-own-property-descriptor');
  49765. var path = _dereq_('../../internals/path');
  49766. var Object = path.Object;
  49767. var getOwnPropertyDescriptor = module.exports = function getOwnPropertyDescriptor(it, key) {
  49768. return Object.getOwnPropertyDescriptor(it, key);
  49769. };
  49770. if (Object.getOwnPropertyDescriptor.sham) getOwnPropertyDescriptor.sham = true;
  49771. },{"../../internals/path":548,"../../modules/es.object.get-own-property-descriptor":616}],385:[function(_dereq_,module,exports){
  49772. _dereq_('../../modules/es.object.get-own-property-descriptors');
  49773. var path = _dereq_('../../internals/path');
  49774. module.exports = path.Object.getOwnPropertyDescriptors;
  49775. },{"../../internals/path":548,"../../modules/es.object.get-own-property-descriptors":617}],386:[function(_dereq_,module,exports){
  49776. _dereq_('../../modules/es.symbol');
  49777. var path = _dereq_('../../internals/path');
  49778. module.exports = path.Object.getOwnPropertySymbols;
  49779. },{"../../internals/path":548,"../../modules/es.symbol":644}],387:[function(_dereq_,module,exports){
  49780. _dereq_('../../modules/es.object.get-prototype-of');
  49781. var path = _dereq_('../../internals/path');
  49782. module.exports = path.Object.getPrototypeOf;
  49783. },{"../../internals/path":548,"../../modules/es.object.get-prototype-of":618}],388:[function(_dereq_,module,exports){
  49784. _dereq_('../../modules/es.object.keys');
  49785. var path = _dereq_('../../internals/path');
  49786. module.exports = path.Object.keys;
  49787. },{"../../internals/path":548,"../../modules/es.object.keys":619}],389:[function(_dereq_,module,exports){
  49788. _dereq_('../../modules/es.object.set-prototype-of');
  49789. var path = _dereq_('../../internals/path');
  49790. module.exports = path.Object.setPrototypeOf;
  49791. },{"../../internals/path":548,"../../modules/es.object.set-prototype-of":620}],390:[function(_dereq_,module,exports){
  49792. _dereq_('../../modules/es.object.values');
  49793. var path = _dereq_('../../internals/path');
  49794. module.exports = path.Object.values;
  49795. },{"../../internals/path":548,"../../modules/es.object.values":622}],391:[function(_dereq_,module,exports){
  49796. _dereq_('../modules/es.parse-int');
  49797. var path = _dereq_('../internals/path');
  49798. module.exports = path.parseInt;
  49799. },{"../internals/path":548,"../modules/es.parse-int":623}],392:[function(_dereq_,module,exports){
  49800. _dereq_('../../modules/es.aggregate-error');
  49801. _dereq_('../../modules/es.array.iterator');
  49802. _dereq_('../../modules/es.object.to-string');
  49803. _dereq_('../../modules/es.promise');
  49804. _dereq_('../../modules/es.promise.all-settled');
  49805. _dereq_('../../modules/es.promise.any');
  49806. _dereq_('../../modules/es.promise.finally');
  49807. _dereq_('../../modules/es.string.iterator');
  49808. var path = _dereq_('../../internals/path');
  49809. module.exports = path.Promise;
  49810. },{"../../internals/path":548,"../../modules/es.aggregate-error":588,"../../modules/es.array.iterator":598,"../../modules/es.object.to-string":621,"../../modules/es.promise":627,"../../modules/es.promise.all-settled":624,"../../modules/es.promise.any":625,"../../modules/es.promise.finally":626,"../../modules/es.string.iterator":634}],393:[function(_dereq_,module,exports){
  49811. _dereq_('../../modules/es.reflect.construct');
  49812. var path = _dereq_('../../internals/path');
  49813. module.exports = path.Reflect.construct;
  49814. },{"../../internals/path":548,"../../modules/es.reflect.construct":628}],394:[function(_dereq_,module,exports){
  49815. _dereq_('../../modules/es.reflect.get');
  49816. var path = _dereq_('../../internals/path');
  49817. module.exports = path.Reflect.get;
  49818. },{"../../internals/path":548,"../../modules/es.reflect.get":629}],395:[function(_dereq_,module,exports){
  49819. _dereq_('../../modules/es.array.iterator');
  49820. _dereq_('../../modules/es.object.to-string');
  49821. _dereq_('../../modules/es.set');
  49822. _dereq_('../../modules/es.string.iterator');
  49823. var path = _dereq_('../../internals/path');
  49824. module.exports = path.Set;
  49825. },{"../../internals/path":548,"../../modules/es.array.iterator":598,"../../modules/es.object.to-string":621,"../../modules/es.set":632,"../../modules/es.string.iterator":634}],396:[function(_dereq_,module,exports){
  49826. _dereq_('../../../modules/es.string.includes');
  49827. var entryVirtual = _dereq_('../../../internals/entry-virtual');
  49828. module.exports = entryVirtual('String').includes;
  49829. },{"../../../internals/entry-virtual":473,"../../../modules/es.string.includes":633}],397:[function(_dereq_,module,exports){
  49830. _dereq_('../../../modules/es.string.pad-start');
  49831. var entryVirtual = _dereq_('../../../internals/entry-virtual');
  49832. module.exports = entryVirtual('String').padStart;
  49833. },{"../../../internals/entry-virtual":473,"../../../modules/es.string.pad-start":635}],398:[function(_dereq_,module,exports){
  49834. _dereq_('../../../modules/es.string.starts-with');
  49835. var entryVirtual = _dereq_('../../../internals/entry-virtual');
  49836. module.exports = entryVirtual('String').startsWith;
  49837. },{"../../../internals/entry-virtual":473,"../../../modules/es.string.starts-with":637}],399:[function(_dereq_,module,exports){
  49838. _dereq_('../../../modules/es.string.trim');
  49839. var entryVirtual = _dereq_('../../../internals/entry-virtual');
  49840. module.exports = entryVirtual('String').trim;
  49841. },{"../../../internals/entry-virtual":473,"../../../modules/es.string.trim":638}],400:[function(_dereq_,module,exports){
  49842. _dereq_('../../modules/es.array.concat');
  49843. _dereq_('../../modules/es.object.to-string');
  49844. _dereq_('../../modules/es.symbol');
  49845. _dereq_('../../modules/es.symbol.async-iterator');
  49846. _dereq_('../../modules/es.symbol.description');
  49847. _dereq_('../../modules/es.symbol.has-instance');
  49848. _dereq_('../../modules/es.symbol.is-concat-spreadable');
  49849. _dereq_('../../modules/es.symbol.iterator');
  49850. _dereq_('../../modules/es.symbol.match');
  49851. _dereq_('../../modules/es.symbol.match-all');
  49852. _dereq_('../../modules/es.symbol.replace');
  49853. _dereq_('../../modules/es.symbol.search');
  49854. _dereq_('../../modules/es.symbol.species');
  49855. _dereq_('../../modules/es.symbol.split');
  49856. _dereq_('../../modules/es.symbol.to-primitive');
  49857. _dereq_('../../modules/es.symbol.to-string-tag');
  49858. _dereq_('../../modules/es.symbol.unscopables');
  49859. _dereq_('../../modules/es.json.to-string-tag');
  49860. _dereq_('../../modules/es.math.to-string-tag');
  49861. _dereq_('../../modules/es.reflect.to-string-tag');
  49862. var path = _dereq_('../../internals/path');
  49863. module.exports = path.Symbol;
  49864. },{"../../internals/path":548,"../../modules/es.array.concat":589,"../../modules/es.json.to-string-tag":606,"../../modules/es.math.to-string-tag":608,"../../modules/es.object.to-string":621,"../../modules/es.reflect.to-string-tag":630,"../../modules/es.symbol":644,"../../modules/es.symbol.async-iterator":639,"../../modules/es.symbol.description":640,"../../modules/es.symbol.has-instance":641,"../../modules/es.symbol.is-concat-spreadable":642,"../../modules/es.symbol.iterator":643,"../../modules/es.symbol.match":646,"../../modules/es.symbol.match-all":645,"../../modules/es.symbol.replace":647,"../../modules/es.symbol.search":648,"../../modules/es.symbol.species":649,"../../modules/es.symbol.split":650,"../../modules/es.symbol.to-primitive":651,"../../modules/es.symbol.to-string-tag":652,"../../modules/es.symbol.unscopables":653}],401:[function(_dereq_,module,exports){
  49865. _dereq_('../../modules/es.array.iterator');
  49866. _dereq_('../../modules/es.object.to-string');
  49867. _dereq_('../../modules/es.string.iterator');
  49868. _dereq_('../../modules/es.symbol.iterator');
  49869. var WrappedWellKnownSymbolModule = _dereq_('../../internals/well-known-symbol-wrapped');
  49870. module.exports = WrappedWellKnownSymbolModule.f('iterator');
  49871. },{"../../internals/well-known-symbol-wrapped":585,"../../modules/es.array.iterator":598,"../../modules/es.object.to-string":621,"../../modules/es.string.iterator":634,"../../modules/es.symbol.iterator":643}],402:[function(_dereq_,module,exports){
  49872. _dereq_('../../modules/es.regexp.exec');
  49873. _dereq_('../../modules/es.symbol.replace');
  49874. _dereq_('../../modules/es.string.replace');
  49875. var WrappedWellKnownSymbolModule = _dereq_('../../internals/well-known-symbol-wrapped');
  49876. module.exports = WrappedWellKnownSymbolModule.f('replace');
  49877. },{"../../internals/well-known-symbol-wrapped":585,"../../modules/es.regexp.exec":631,"../../modules/es.string.replace":636,"../../modules/es.symbol.replace":647}],403:[function(_dereq_,module,exports){
  49878. _dereq_('../../modules/es.array.iterator');
  49879. _dereq_('../../modules/es.object.to-string');
  49880. _dereq_('../../modules/es.weak-map');
  49881. var path = _dereq_('../../internals/path');
  49882. module.exports = path.WeakMap;
  49883. },{"../../internals/path":548,"../../modules/es.array.iterator":598,"../../modules/es.object.to-string":621,"../../modules/es.weak-map":654}],404:[function(_dereq_,module,exports){
  49884. var parent = _dereq_('../../actual/array/from');
  49885. module.exports = parent;
  49886. },{"../../actual/array/from":324}],405:[function(_dereq_,module,exports){
  49887. var parent = _dereq_('../../actual/array/is-array');
  49888. module.exports = parent;
  49889. },{"../../actual/array/is-array":325}],406:[function(_dereq_,module,exports){
  49890. var parent = _dereq_('../actual/get-iterator-method');
  49891. module.exports = parent;
  49892. },{"../actual/get-iterator-method":326}],407:[function(_dereq_,module,exports){
  49893. var parent = _dereq_('../../actual/instance/bind');
  49894. module.exports = parent;
  49895. },{"../../actual/instance/bind":327}],408:[function(_dereq_,module,exports){
  49896. var parent = _dereq_('../../actual/instance/index-of');
  49897. module.exports = parent;
  49898. },{"../../actual/instance/index-of":328}],409:[function(_dereq_,module,exports){
  49899. var parent = _dereq_('../../actual/instance/slice');
  49900. module.exports = parent;
  49901. },{"../../actual/instance/slice":329}],410:[function(_dereq_,module,exports){
  49902. var parent = _dereq_('../../actual/map');
  49903. _dereq_('../../modules/esnext.map.from');
  49904. _dereq_('../../modules/esnext.map.of');
  49905. _dereq_('../../modules/esnext.map.delete-all');
  49906. _dereq_('../../modules/esnext.map.emplace');
  49907. _dereq_('../../modules/esnext.map.every');
  49908. _dereq_('../../modules/esnext.map.filter');
  49909. _dereq_('../../modules/esnext.map.find');
  49910. _dereq_('../../modules/esnext.map.find-key');
  49911. _dereq_('../../modules/esnext.map.group-by');
  49912. _dereq_('../../modules/esnext.map.includes');
  49913. _dereq_('../../modules/esnext.map.key-by');
  49914. _dereq_('../../modules/esnext.map.key-of');
  49915. _dereq_('../../modules/esnext.map.map-keys');
  49916. _dereq_('../../modules/esnext.map.map-values');
  49917. _dereq_('../../modules/esnext.map.merge');
  49918. _dereq_('../../modules/esnext.map.reduce');
  49919. _dereq_('../../modules/esnext.map.some');
  49920. _dereq_('../../modules/esnext.map.update');
  49921. // TODO: remove from `core-js@4`
  49922. _dereq_('../../modules/esnext.map.upsert');
  49923. // TODO: remove from `core-js@4`
  49924. _dereq_('../../modules/esnext.map.update-or-insert');
  49925. module.exports = parent;
  49926. },{"../../actual/map":330,"../../modules/esnext.map.delete-all":656,"../../modules/esnext.map.emplace":657,"../../modules/esnext.map.every":658,"../../modules/esnext.map.filter":659,"../../modules/esnext.map.find":661,"../../modules/esnext.map.find-key":660,"../../modules/esnext.map.from":662,"../../modules/esnext.map.group-by":663,"../../modules/esnext.map.includes":664,"../../modules/esnext.map.key-by":665,"../../modules/esnext.map.key-of":666,"../../modules/esnext.map.map-keys":667,"../../modules/esnext.map.map-values":668,"../../modules/esnext.map.merge":669,"../../modules/esnext.map.of":670,"../../modules/esnext.map.reduce":671,"../../modules/esnext.map.some":672,"../../modules/esnext.map.update":674,"../../modules/esnext.map.update-or-insert":673,"../../modules/esnext.map.upsert":675}],411:[function(_dereq_,module,exports){
  49927. var parent = _dereq_('../../actual/object/create');
  49928. module.exports = parent;
  49929. },{"../../actual/object/create":331}],412:[function(_dereq_,module,exports){
  49930. var parent = _dereq_('../../actual/object/define-property');
  49931. module.exports = parent;
  49932. },{"../../actual/object/define-property":332}],413:[function(_dereq_,module,exports){
  49933. var parent = _dereq_('../../actual/object/get-own-property-descriptor');
  49934. module.exports = parent;
  49935. },{"../../actual/object/get-own-property-descriptor":333}],414:[function(_dereq_,module,exports){
  49936. var parent = _dereq_('../../actual/object/get-prototype-of');
  49937. module.exports = parent;
  49938. },{"../../actual/object/get-prototype-of":334}],415:[function(_dereq_,module,exports){
  49939. var parent = _dereq_('../../actual/object/set-prototype-of');
  49940. module.exports = parent;
  49941. },{"../../actual/object/set-prototype-of":335}],416:[function(_dereq_,module,exports){
  49942. var parent = _dereq_('../../actual/promise');
  49943. _dereq_('../../modules/esnext.aggregate-error');
  49944. // TODO: Remove from `core-js@4`
  49945. _dereq_('../../modules/esnext.promise.all-settled');
  49946. _dereq_('../../modules/esnext.promise.try');
  49947. _dereq_('../../modules/esnext.promise.any');
  49948. module.exports = parent;
  49949. },{"../../actual/promise":336,"../../modules/esnext.aggregate-error":655,"../../modules/esnext.promise.all-settled":676,"../../modules/esnext.promise.any":677,"../../modules/esnext.promise.try":678}],417:[function(_dereq_,module,exports){
  49950. var parent = _dereq_('../../actual/reflect/construct');
  49951. module.exports = parent;
  49952. },{"../../actual/reflect/construct":337}],418:[function(_dereq_,module,exports){
  49953. var parent = _dereq_('../../actual/reflect/get');
  49954. module.exports = parent;
  49955. },{"../../actual/reflect/get":338}],419:[function(_dereq_,module,exports){
  49956. var parent = _dereq_('../../actual/symbol');
  49957. _dereq_('../../modules/esnext.symbol.async-dispose');
  49958. _dereq_('../../modules/esnext.symbol.dispose');
  49959. _dereq_('../../modules/esnext.symbol.matcher');
  49960. _dereq_('../../modules/esnext.symbol.metadata');
  49961. _dereq_('../../modules/esnext.symbol.observable');
  49962. // TODO: Remove from `core-js@4`
  49963. _dereq_('../../modules/esnext.symbol.pattern-match');
  49964. // TODO: Remove from `core-js@4`
  49965. _dereq_('../../modules/esnext.symbol.replace-all');
  49966. module.exports = parent;
  49967. },{"../../actual/symbol":339,"../../modules/esnext.symbol.async-dispose":679,"../../modules/esnext.symbol.dispose":680,"../../modules/esnext.symbol.matcher":681,"../../modules/esnext.symbol.metadata":682,"../../modules/esnext.symbol.observable":683,"../../modules/esnext.symbol.pattern-match":684,"../../modules/esnext.symbol.replace-all":685}],420:[function(_dereq_,module,exports){
  49968. var parent = _dereq_('../../actual/symbol/iterator');
  49969. module.exports = parent;
  49970. },{"../../actual/symbol/iterator":340}],421:[function(_dereq_,module,exports){
  49971. var global = _dereq_('../internals/global');
  49972. var isCallable = _dereq_('../internals/is-callable');
  49973. var tryToString = _dereq_('../internals/try-to-string');
  49974. var TypeError = global.TypeError;
  49975. // `Assert: IsCallable(argument) is true`
  49976. module.exports = function (argument) {
  49977. if (isCallable(argument)) return argument;
  49978. throw TypeError(tryToString(argument) + ' is not a function');
  49979. };
  49980. },{"../internals/global":491,"../internals/is-callable":504,"../internals/try-to-string":580}],422:[function(_dereq_,module,exports){
  49981. var global = _dereq_('../internals/global');
  49982. var isConstructor = _dereq_('../internals/is-constructor');
  49983. var tryToString = _dereq_('../internals/try-to-string');
  49984. var TypeError = global.TypeError;
  49985. // `Assert: IsConstructor(argument) is true`
  49986. module.exports = function (argument) {
  49987. if (isConstructor(argument)) return argument;
  49988. throw TypeError(tryToString(argument) + ' is not a constructor');
  49989. };
  49990. },{"../internals/global":491,"../internals/is-constructor":505,"../internals/try-to-string":580}],423:[function(_dereq_,module,exports){
  49991. var global = _dereq_('../internals/global');
  49992. var isCallable = _dereq_('../internals/is-callable');
  49993. var String = global.String;
  49994. var TypeError = global.TypeError;
  49995. module.exports = function (argument) {
  49996. if (typeof argument == 'object' || isCallable(argument)) return argument;
  49997. throw TypeError("Can't set " + String(argument) + ' as a prototype');
  49998. };
  49999. },{"../internals/global":491,"../internals/is-callable":504}],424:[function(_dereq_,module,exports){
  50000. module.exports = function () { /* empty */ };
  50001. },{}],425:[function(_dereq_,module,exports){
  50002. var global = _dereq_('../internals/global');
  50003. var isPrototypeOf = _dereq_('../internals/object-is-prototype-of');
  50004. var TypeError = global.TypeError;
  50005. module.exports = function (it, Prototype) {
  50006. if (isPrototypeOf(Prototype, it)) return it;
  50007. throw TypeError('Incorrect invocation');
  50008. };
  50009. },{"../internals/global":491,"../internals/object-is-prototype-of":539}],426:[function(_dereq_,module,exports){
  50010. var global = _dereq_('../internals/global');
  50011. var isObject = _dereq_('../internals/is-object');
  50012. var String = global.String;
  50013. var TypeError = global.TypeError;
  50014. // `Assert: Type(argument) is Object`
  50015. module.exports = function (argument) {
  50016. if (isObject(argument)) return argument;
  50017. throw TypeError(String(argument) + ' is not an object');
  50018. };
  50019. },{"../internals/global":491,"../internals/is-object":509}],427:[function(_dereq_,module,exports){
  50020. // FF26- bug: ArrayBuffers are non-extensible, but Object.isExtensible does not report it
  50021. var fails = _dereq_('../internals/fails');
  50022. module.exports = fails(function () {
  50023. if (typeof ArrayBuffer == 'function') {
  50024. var buffer = new ArrayBuffer(8);
  50025. // eslint-disable-next-line es/no-object-isextensible, es/no-object-defineproperty -- safe
  50026. if (Object.isExtensible(buffer)) Object.defineProperty(buffer, 'a', { value: 8 });
  50027. }
  50028. });
  50029. },{"../internals/fails":477}],428:[function(_dereq_,module,exports){
  50030. 'use strict';
  50031. var $forEach = _dereq_('../internals/array-iteration').forEach;
  50032. var arrayMethodIsStrict = _dereq_('../internals/array-method-is-strict');
  50033. var STRICT_METHOD = arrayMethodIsStrict('forEach');
  50034. // `Array.prototype.forEach` method implementation
  50035. // https://tc39.es/ecma262/#sec-array.prototype.foreach
  50036. module.exports = !STRICT_METHOD ? function forEach(callbackfn /* , thisArg */) {
  50037. return $forEach(this, callbackfn, arguments.length > 1 ? arguments[1] : undefined);
  50038. // eslint-disable-next-line es/no-array-prototype-foreach -- safe
  50039. } : [].forEach;
  50040. },{"../internals/array-iteration":431,"../internals/array-method-is-strict":433}],429:[function(_dereq_,module,exports){
  50041. 'use strict';
  50042. var global = _dereq_('../internals/global');
  50043. var bind = _dereq_('../internals/function-bind-context');
  50044. var call = _dereq_('../internals/function-call');
  50045. var toObject = _dereq_('../internals/to-object');
  50046. var callWithSafeIterationClosing = _dereq_('../internals/call-with-safe-iteration-closing');
  50047. var isArrayIteratorMethod = _dereq_('../internals/is-array-iterator-method');
  50048. var isConstructor = _dereq_('../internals/is-constructor');
  50049. var lengthOfArrayLike = _dereq_('../internals/length-of-array-like');
  50050. var createProperty = _dereq_('../internals/create-property');
  50051. var getIterator = _dereq_('../internals/get-iterator');
  50052. var getIteratorMethod = _dereq_('../internals/get-iterator-method');
  50053. var Array = global.Array;
  50054. // `Array.from` method implementation
  50055. // https://tc39.es/ecma262/#sec-array.from
  50056. module.exports = function from(arrayLike /* , mapfn = undefined, thisArg = undefined */) {
  50057. var O = toObject(arrayLike);
  50058. var IS_CONSTRUCTOR = isConstructor(this);
  50059. var argumentsLength = arguments.length;
  50060. var mapfn = argumentsLength > 1 ? arguments[1] : undefined;
  50061. var mapping = mapfn !== undefined;
  50062. if (mapping) mapfn = bind(mapfn, argumentsLength > 2 ? arguments[2] : undefined);
  50063. var iteratorMethod = getIteratorMethod(O);
  50064. var index = 0;
  50065. var length, result, step, iterator, next, value;
  50066. // if the target is not iterable or it's an array with the default iterator - use a simple case
  50067. if (iteratorMethod && !(this == Array && isArrayIteratorMethod(iteratorMethod))) {
  50068. iterator = getIterator(O, iteratorMethod);
  50069. next = iterator.next;
  50070. result = IS_CONSTRUCTOR ? new this() : [];
  50071. for (;!(step = call(next, iterator)).done; index++) {
  50072. value = mapping ? callWithSafeIterationClosing(iterator, mapfn, [step.value, index], true) : step.value;
  50073. createProperty(result, index, value);
  50074. }
  50075. } else {
  50076. length = lengthOfArrayLike(O);
  50077. result = IS_CONSTRUCTOR ? new this(length) : Array(length);
  50078. for (;length > index; index++) {
  50079. value = mapping ? mapfn(O[index], index) : O[index];
  50080. createProperty(result, index, value);
  50081. }
  50082. }
  50083. result.length = index;
  50084. return result;
  50085. };
  50086. },{"../internals/call-with-safe-iteration-closing":440,"../internals/create-property":457,"../internals/function-bind-context":480,"../internals/function-call":483,"../internals/get-iterator":488,"../internals/get-iterator-method":487,"../internals/global":491,"../internals/is-array-iterator-method":502,"../internals/is-constructor":505,"../internals/length-of-array-like":517,"../internals/to-object":575}],430:[function(_dereq_,module,exports){
  50087. var toIndexedObject = _dereq_('../internals/to-indexed-object');
  50088. var toAbsoluteIndex = _dereq_('../internals/to-absolute-index');
  50089. var lengthOfArrayLike = _dereq_('../internals/length-of-array-like');
  50090. // `Array.prototype.{ indexOf, includes }` methods implementation
  50091. var createMethod = function (IS_INCLUDES) {
  50092. return function ($this, el, fromIndex) {
  50093. var O = toIndexedObject($this);
  50094. var length = lengthOfArrayLike(O);
  50095. var index = toAbsoluteIndex(fromIndex, length);
  50096. var value;
  50097. // Array#includes uses SameValueZero equality algorithm
  50098. // eslint-disable-next-line no-self-compare -- NaN check
  50099. if (IS_INCLUDES && el != el) while (length > index) {
  50100. value = O[index++];
  50101. // eslint-disable-next-line no-self-compare -- NaN check
  50102. if (value != value) return true;
  50103. // Array#indexOf ignores holes, Array#includes - not
  50104. } else for (;length > index; index++) {
  50105. if ((IS_INCLUDES || index in O) && O[index] === el) return IS_INCLUDES || index || 0;
  50106. } return !IS_INCLUDES && -1;
  50107. };
  50108. };
  50109. module.exports = {
  50110. // `Array.prototype.includes` method
  50111. // https://tc39.es/ecma262/#sec-array.prototype.includes
  50112. includes: createMethod(true),
  50113. // `Array.prototype.indexOf` method
  50114. // https://tc39.es/ecma262/#sec-array.prototype.indexof
  50115. indexOf: createMethod(false)
  50116. };
  50117. },{"../internals/length-of-array-like":517,"../internals/to-absolute-index":571,"../internals/to-indexed-object":572}],431:[function(_dereq_,module,exports){
  50118. var bind = _dereq_('../internals/function-bind-context');
  50119. var uncurryThis = _dereq_('../internals/function-uncurry-this');
  50120. var IndexedObject = _dereq_('../internals/indexed-object');
  50121. var toObject = _dereq_('../internals/to-object');
  50122. var lengthOfArrayLike = _dereq_('../internals/length-of-array-like');
  50123. var arraySpeciesCreate = _dereq_('../internals/array-species-create');
  50124. var push = uncurryThis([].push);
  50125. // `Array.prototype.{ forEach, map, filter, some, every, find, findIndex, filterReject }` methods implementation
  50126. var createMethod = function (TYPE) {
  50127. var IS_MAP = TYPE == 1;
  50128. var IS_FILTER = TYPE == 2;
  50129. var IS_SOME = TYPE == 3;
  50130. var IS_EVERY = TYPE == 4;
  50131. var IS_FIND_INDEX = TYPE == 6;
  50132. var IS_FILTER_REJECT = TYPE == 7;
  50133. var NO_HOLES = TYPE == 5 || IS_FIND_INDEX;
  50134. return function ($this, callbackfn, that, specificCreate) {
  50135. var O = toObject($this);
  50136. var self = IndexedObject(O);
  50137. var boundFunction = bind(callbackfn, that);
  50138. var length = lengthOfArrayLike(self);
  50139. var index = 0;
  50140. var create = specificCreate || arraySpeciesCreate;
  50141. var target = IS_MAP ? create($this, length) : IS_FILTER || IS_FILTER_REJECT ? create($this, 0) : undefined;
  50142. var value, result;
  50143. for (;length > index; index++) if (NO_HOLES || index in self) {
  50144. value = self[index];
  50145. result = boundFunction(value, index, O);
  50146. if (TYPE) {
  50147. if (IS_MAP) target[index] = result; // map
  50148. else if (result) switch (TYPE) {
  50149. case 3: return true; // some
  50150. case 5: return value; // find
  50151. case 6: return index; // findIndex
  50152. case 2: push(target, value); // filter
  50153. } else switch (TYPE) {
  50154. case 4: return false; // every
  50155. case 7: push(target, value); // filterReject
  50156. }
  50157. }
  50158. }
  50159. return IS_FIND_INDEX ? -1 : IS_SOME || IS_EVERY ? IS_EVERY : target;
  50160. };
  50161. };
  50162. module.exports = {
  50163. // `Array.prototype.forEach` method
  50164. // https://tc39.es/ecma262/#sec-array.prototype.foreach
  50165. forEach: createMethod(0),
  50166. // `Array.prototype.map` method
  50167. // https://tc39.es/ecma262/#sec-array.prototype.map
  50168. map: createMethod(1),
  50169. // `Array.prototype.filter` method
  50170. // https://tc39.es/ecma262/#sec-array.prototype.filter
  50171. filter: createMethod(2),
  50172. // `Array.prototype.some` method
  50173. // https://tc39.es/ecma262/#sec-array.prototype.some
  50174. some: createMethod(3),
  50175. // `Array.prototype.every` method
  50176. // https://tc39.es/ecma262/#sec-array.prototype.every
  50177. every: createMethod(4),
  50178. // `Array.prototype.find` method
  50179. // https://tc39.es/ecma262/#sec-array.prototype.find
  50180. find: createMethod(5),
  50181. // `Array.prototype.findIndex` method
  50182. // https://tc39.es/ecma262/#sec-array.prototype.findIndex
  50183. findIndex: createMethod(6),
  50184. // `Array.prototype.filterReject` method
  50185. // https://github.com/tc39/proposal-array-filtering
  50186. filterReject: createMethod(7)
  50187. };
  50188. },{"../internals/array-species-create":439,"../internals/function-bind-context":480,"../internals/function-uncurry-this":485,"../internals/indexed-object":497,"../internals/length-of-array-like":517,"../internals/to-object":575}],432:[function(_dereq_,module,exports){
  50189. var fails = _dereq_('../internals/fails');
  50190. var wellKnownSymbol = _dereq_('../internals/well-known-symbol');
  50191. var V8_VERSION = _dereq_('../internals/engine-v8-version');
  50192. var SPECIES = wellKnownSymbol('species');
  50193. module.exports = function (METHOD_NAME) {
  50194. // We can't use this feature detection in V8 since it causes
  50195. // deoptimization and serious performance degradation
  50196. // https://github.com/zloirock/core-js/issues/677
  50197. return V8_VERSION >= 51 || !fails(function () {
  50198. var array = [];
  50199. var constructor = array.constructor = {};
  50200. constructor[SPECIES] = function () {
  50201. return { foo: 1 };
  50202. };
  50203. return array[METHOD_NAME](Boolean).foo !== 1;
  50204. });
  50205. };
  50206. },{"../internals/engine-v8-version":471,"../internals/fails":477,"../internals/well-known-symbol":586}],433:[function(_dereq_,module,exports){
  50207. 'use strict';
  50208. var fails = _dereq_('../internals/fails');
  50209. module.exports = function (METHOD_NAME, argument) {
  50210. var method = [][METHOD_NAME];
  50211. return !!method && fails(function () {
  50212. // eslint-disable-next-line no-useless-call,no-throw-literal -- required for testing
  50213. method.call(null, argument || function () { throw 1; }, 1);
  50214. });
  50215. };
  50216. },{"../internals/fails":477}],434:[function(_dereq_,module,exports){
  50217. var global = _dereq_('../internals/global');
  50218. var aCallable = _dereq_('../internals/a-callable');
  50219. var toObject = _dereq_('../internals/to-object');
  50220. var IndexedObject = _dereq_('../internals/indexed-object');
  50221. var lengthOfArrayLike = _dereq_('../internals/length-of-array-like');
  50222. var TypeError = global.TypeError;
  50223. // `Array.prototype.{ reduce, reduceRight }` methods implementation
  50224. var createMethod = function (IS_RIGHT) {
  50225. return function (that, callbackfn, argumentsLength, memo) {
  50226. aCallable(callbackfn);
  50227. var O = toObject(that);
  50228. var self = IndexedObject(O);
  50229. var length = lengthOfArrayLike(O);
  50230. var index = IS_RIGHT ? length - 1 : 0;
  50231. var i = IS_RIGHT ? -1 : 1;
  50232. if (argumentsLength < 2) while (true) {
  50233. if (index in self) {
  50234. memo = self[index];
  50235. index += i;
  50236. break;
  50237. }
  50238. index += i;
  50239. if (IS_RIGHT ? index < 0 : length <= index) {
  50240. throw TypeError('Reduce of empty array with no initial value');
  50241. }
  50242. }
  50243. for (;IS_RIGHT ? index >= 0 : length > index; index += i) if (index in self) {
  50244. memo = callbackfn(memo, self[index], index, O);
  50245. }
  50246. return memo;
  50247. };
  50248. };
  50249. module.exports = {
  50250. // `Array.prototype.reduce` method
  50251. // https://tc39.es/ecma262/#sec-array.prototype.reduce
  50252. left: createMethod(false),
  50253. // `Array.prototype.reduceRight` method
  50254. // https://tc39.es/ecma262/#sec-array.prototype.reduceright
  50255. right: createMethod(true)
  50256. };
  50257. },{"../internals/a-callable":421,"../internals/global":491,"../internals/indexed-object":497,"../internals/length-of-array-like":517,"../internals/to-object":575}],435:[function(_dereq_,module,exports){
  50258. var global = _dereq_('../internals/global');
  50259. var toAbsoluteIndex = _dereq_('../internals/to-absolute-index');
  50260. var lengthOfArrayLike = _dereq_('../internals/length-of-array-like');
  50261. var createProperty = _dereq_('../internals/create-property');
  50262. var Array = global.Array;
  50263. var max = Math.max;
  50264. module.exports = function (O, start, end) {
  50265. var length = lengthOfArrayLike(O);
  50266. var k = toAbsoluteIndex(start, length);
  50267. var fin = toAbsoluteIndex(end === undefined ? length : end, length);
  50268. var result = Array(max(fin - k, 0));
  50269. for (var n = 0; k < fin; k++, n++) createProperty(result, n, O[k]);
  50270. result.length = n;
  50271. return result;
  50272. };
  50273. },{"../internals/create-property":457,"../internals/global":491,"../internals/length-of-array-like":517,"../internals/to-absolute-index":571}],436:[function(_dereq_,module,exports){
  50274. var uncurryThis = _dereq_('../internals/function-uncurry-this');
  50275. module.exports = uncurryThis([].slice);
  50276. },{"../internals/function-uncurry-this":485}],437:[function(_dereq_,module,exports){
  50277. var arraySlice = _dereq_('../internals/array-slice-simple');
  50278. var floor = Math.floor;
  50279. var mergeSort = function (array, comparefn) {
  50280. var length = array.length;
  50281. var middle = floor(length / 2);
  50282. return length < 8 ? insertionSort(array, comparefn) : merge(
  50283. array,
  50284. mergeSort(arraySlice(array, 0, middle), comparefn),
  50285. mergeSort(arraySlice(array, middle), comparefn),
  50286. comparefn
  50287. );
  50288. };
  50289. var insertionSort = function (array, comparefn) {
  50290. var length = array.length;
  50291. var i = 1;
  50292. var element, j;
  50293. while (i < length) {
  50294. j = i;
  50295. element = array[i];
  50296. while (j && comparefn(array[j - 1], element) > 0) {
  50297. array[j] = array[--j];
  50298. }
  50299. if (j !== i++) array[j] = element;
  50300. } return array;
  50301. };
  50302. var merge = function (array, left, right, comparefn) {
  50303. var llength = left.length;
  50304. var rlength = right.length;
  50305. var lindex = 0;
  50306. var rindex = 0;
  50307. while (lindex < llength || rindex < rlength) {
  50308. array[lindex + rindex] = (lindex < llength && rindex < rlength)
  50309. ? comparefn(left[lindex], right[rindex]) <= 0 ? left[lindex++] : right[rindex++]
  50310. : lindex < llength ? left[lindex++] : right[rindex++];
  50311. } return array;
  50312. };
  50313. module.exports = mergeSort;
  50314. },{"../internals/array-slice-simple":435}],438:[function(_dereq_,module,exports){
  50315. var global = _dereq_('../internals/global');
  50316. var isArray = _dereq_('../internals/is-array');
  50317. var isConstructor = _dereq_('../internals/is-constructor');
  50318. var isObject = _dereq_('../internals/is-object');
  50319. var wellKnownSymbol = _dereq_('../internals/well-known-symbol');
  50320. var SPECIES = wellKnownSymbol('species');
  50321. var Array = global.Array;
  50322. // a part of `ArraySpeciesCreate` abstract operation
  50323. // https://tc39.es/ecma262/#sec-arrayspeciescreate
  50324. module.exports = function (originalArray) {
  50325. var C;
  50326. if (isArray(originalArray)) {
  50327. C = originalArray.constructor;
  50328. // cross-realm fallback
  50329. if (isConstructor(C) && (C === Array || isArray(C.prototype))) C = undefined;
  50330. else if (isObject(C)) {
  50331. C = C[SPECIES];
  50332. if (C === null) C = undefined;
  50333. }
  50334. } return C === undefined ? Array : C;
  50335. };
  50336. },{"../internals/global":491,"../internals/is-array":503,"../internals/is-constructor":505,"../internals/is-object":509,"../internals/well-known-symbol":586}],439:[function(_dereq_,module,exports){
  50337. var arraySpeciesConstructor = _dereq_('../internals/array-species-constructor');
  50338. // `ArraySpeciesCreate` abstract operation
  50339. // https://tc39.es/ecma262/#sec-arrayspeciescreate
  50340. module.exports = function (originalArray, length) {
  50341. return new (arraySpeciesConstructor(originalArray))(length === 0 ? 0 : length);
  50342. };
  50343. },{"../internals/array-species-constructor":438}],440:[function(_dereq_,module,exports){
  50344. var anObject = _dereq_('../internals/an-object');
  50345. var iteratorClose = _dereq_('../internals/iterator-close');
  50346. // call something on iterator step with safe closing on error
  50347. module.exports = function (iterator, fn, value, ENTRIES) {
  50348. try {
  50349. return ENTRIES ? fn(anObject(value)[0], value[1]) : fn(value);
  50350. } catch (error) {
  50351. iteratorClose(iterator, 'throw', error);
  50352. }
  50353. };
  50354. },{"../internals/an-object":426,"../internals/iterator-close":514}],441:[function(_dereq_,module,exports){
  50355. var wellKnownSymbol = _dereq_('../internals/well-known-symbol');
  50356. var ITERATOR = wellKnownSymbol('iterator');
  50357. var SAFE_CLOSING = false;
  50358. try {
  50359. var called = 0;
  50360. var iteratorWithReturn = {
  50361. next: function () {
  50362. return { done: !!called++ };
  50363. },
  50364. 'return': function () {
  50365. SAFE_CLOSING = true;
  50366. }
  50367. };
  50368. iteratorWithReturn[ITERATOR] = function () {
  50369. return this;
  50370. };
  50371. // eslint-disable-next-line es/no-array-from, no-throw-literal -- required for testing
  50372. Array.from(iteratorWithReturn, function () { throw 2; });
  50373. } catch (error) { /* empty */ }
  50374. module.exports = function (exec, SKIP_CLOSING) {
  50375. if (!SKIP_CLOSING && !SAFE_CLOSING) return false;
  50376. var ITERATION_SUPPORT = false;
  50377. try {
  50378. var object = {};
  50379. object[ITERATOR] = function () {
  50380. return {
  50381. next: function () {
  50382. return { done: ITERATION_SUPPORT = true };
  50383. }
  50384. };
  50385. };
  50386. exec(object);
  50387. } catch (error) { /* empty */ }
  50388. return ITERATION_SUPPORT;
  50389. };
  50390. },{"../internals/well-known-symbol":586}],442:[function(_dereq_,module,exports){
  50391. var uncurryThis = _dereq_('../internals/function-uncurry-this');
  50392. var toString = uncurryThis({}.toString);
  50393. var stringSlice = uncurryThis(''.slice);
  50394. module.exports = function (it) {
  50395. return stringSlice(toString(it), 8, -1);
  50396. };
  50397. },{"../internals/function-uncurry-this":485}],443:[function(_dereq_,module,exports){
  50398. var global = _dereq_('../internals/global');
  50399. var TO_STRING_TAG_SUPPORT = _dereq_('../internals/to-string-tag-support');
  50400. var isCallable = _dereq_('../internals/is-callable');
  50401. var classofRaw = _dereq_('../internals/classof-raw');
  50402. var wellKnownSymbol = _dereq_('../internals/well-known-symbol');
  50403. var TO_STRING_TAG = wellKnownSymbol('toStringTag');
  50404. var Object = global.Object;
  50405. // ES3 wrong here
  50406. var CORRECT_ARGUMENTS = classofRaw(function () { return arguments; }()) == 'Arguments';
  50407. // fallback for IE11 Script Access Denied error
  50408. var tryGet = function (it, key) {
  50409. try {
  50410. return it[key];
  50411. } catch (error) { /* empty */ }
  50412. };
  50413. // getting tag from ES6+ `Object.prototype.toString`
  50414. module.exports = TO_STRING_TAG_SUPPORT ? classofRaw : function (it) {
  50415. var O, tag, result;
  50416. return it === undefined ? 'Undefined' : it === null ? 'Null'
  50417. // @@toStringTag case
  50418. : typeof (tag = tryGet(O = Object(it), TO_STRING_TAG)) == 'string' ? tag
  50419. // builtinTag case
  50420. : CORRECT_ARGUMENTS ? classofRaw(O)
  50421. // ES3 arguments fallback
  50422. : (result = classofRaw(O)) == 'Object' && isCallable(O.callee) ? 'Arguments' : result;
  50423. };
  50424. },{"../internals/classof-raw":442,"../internals/global":491,"../internals/is-callable":504,"../internals/to-string-tag-support":578,"../internals/well-known-symbol":586}],444:[function(_dereq_,module,exports){
  50425. var uncurryThis = _dereq_('../internals/function-uncurry-this');
  50426. var replace = uncurryThis(''.replace);
  50427. var TEST = (function (arg) { return String(Error(arg).stack); })('zxcasd');
  50428. var V8_OR_CHAKRA_STACK_ENTRY = /\n\s*at [^:]*:[^\n]*/;
  50429. var IS_V8_OR_CHAKRA_STACK = V8_OR_CHAKRA_STACK_ENTRY.test(TEST);
  50430. module.exports = function (stack, dropEntries) {
  50431. if (IS_V8_OR_CHAKRA_STACK && typeof stack == 'string') {
  50432. while (dropEntries--) stack = replace(stack, V8_OR_CHAKRA_STACK_ENTRY, '');
  50433. } return stack;
  50434. };
  50435. },{"../internals/function-uncurry-this":485}],445:[function(_dereq_,module,exports){
  50436. 'use strict';
  50437. var call = _dereq_('../internals/function-call');
  50438. var aCallable = _dereq_('../internals/a-callable');
  50439. var anObject = _dereq_('../internals/an-object');
  50440. // https://github.com/tc39/collection-methods
  50441. module.exports = function deleteAll(/* ...elements */) {
  50442. var collection = anObject(this);
  50443. var remover = aCallable(collection['delete']);
  50444. var allDeleted = true;
  50445. var wasDeleted;
  50446. for (var k = 0, len = arguments.length; k < len; k++) {
  50447. wasDeleted = call(remover, collection, arguments[k]);
  50448. allDeleted = allDeleted && wasDeleted;
  50449. }
  50450. return !!allDeleted;
  50451. };
  50452. },{"../internals/a-callable":421,"../internals/an-object":426,"../internals/function-call":483}],446:[function(_dereq_,module,exports){
  50453. 'use strict';
  50454. // https://tc39.github.io/proposal-setmap-offrom/
  50455. var bind = _dereq_('../internals/function-bind-context');
  50456. var call = _dereq_('../internals/function-call');
  50457. var aCallable = _dereq_('../internals/a-callable');
  50458. var aConstructor = _dereq_('../internals/a-constructor');
  50459. var iterate = _dereq_('../internals/iterate');
  50460. var push = [].push;
  50461. module.exports = function from(source /* , mapFn, thisArg */) {
  50462. var length = arguments.length;
  50463. var mapFn = length > 1 ? arguments[1] : undefined;
  50464. var mapping, array, n, boundFunction;
  50465. aConstructor(this);
  50466. mapping = mapFn !== undefined;
  50467. if (mapping) aCallable(mapFn);
  50468. if (source == undefined) return new this();
  50469. array = [];
  50470. if (mapping) {
  50471. n = 0;
  50472. boundFunction = bind(mapFn, length > 2 ? arguments[2] : undefined);
  50473. iterate(source, function (nextItem) {
  50474. call(push, array, boundFunction(nextItem, n++));
  50475. });
  50476. } else {
  50477. iterate(source, push, { that: array });
  50478. }
  50479. return new this(array);
  50480. };
  50481. },{"../internals/a-callable":421,"../internals/a-constructor":422,"../internals/function-bind-context":480,"../internals/function-call":483,"../internals/iterate":513}],447:[function(_dereq_,module,exports){
  50482. 'use strict';
  50483. var arraySlice = _dereq_('../internals/array-slice');
  50484. // https://tc39.github.io/proposal-setmap-offrom/
  50485. module.exports = function of() {
  50486. return new this(arraySlice(arguments));
  50487. };
  50488. },{"../internals/array-slice":436}],448:[function(_dereq_,module,exports){
  50489. 'use strict';
  50490. var defineProperty = _dereq_('../internals/object-define-property').f;
  50491. var create = _dereq_('../internals/object-create');
  50492. var redefineAll = _dereq_('../internals/redefine-all');
  50493. var bind = _dereq_('../internals/function-bind-context');
  50494. var anInstance = _dereq_('../internals/an-instance');
  50495. var iterate = _dereq_('../internals/iterate');
  50496. var defineIterator = _dereq_('../internals/define-iterator');
  50497. var setSpecies = _dereq_('../internals/set-species');
  50498. var DESCRIPTORS = _dereq_('../internals/descriptors');
  50499. var fastKey = _dereq_('../internals/internal-metadata').fastKey;
  50500. var InternalStateModule = _dereq_('../internals/internal-state');
  50501. var setInternalState = InternalStateModule.set;
  50502. var internalStateGetterFor = InternalStateModule.getterFor;
  50503. module.exports = {
  50504. getConstructor: function (wrapper, CONSTRUCTOR_NAME, IS_MAP, ADDER) {
  50505. var Constructor = wrapper(function (that, iterable) {
  50506. anInstance(that, Prototype);
  50507. setInternalState(that, {
  50508. type: CONSTRUCTOR_NAME,
  50509. index: create(null),
  50510. first: undefined,
  50511. last: undefined,
  50512. size: 0
  50513. });
  50514. if (!DESCRIPTORS) that.size = 0;
  50515. if (iterable != undefined) iterate(iterable, that[ADDER], { that: that, AS_ENTRIES: IS_MAP });
  50516. });
  50517. var Prototype = Constructor.prototype;
  50518. var getInternalState = internalStateGetterFor(CONSTRUCTOR_NAME);
  50519. var define = function (that, key, value) {
  50520. var state = getInternalState(that);
  50521. var entry = getEntry(that, key);
  50522. var previous, index;
  50523. // change existing entry
  50524. if (entry) {
  50525. entry.value = value;
  50526. // create new entry
  50527. } else {
  50528. state.last = entry = {
  50529. index: index = fastKey(key, true),
  50530. key: key,
  50531. value: value,
  50532. previous: previous = state.last,
  50533. next: undefined,
  50534. removed: false
  50535. };
  50536. if (!state.first) state.first = entry;
  50537. if (previous) previous.next = entry;
  50538. if (DESCRIPTORS) state.size++;
  50539. else that.size++;
  50540. // add to index
  50541. if (index !== 'F') state.index[index] = entry;
  50542. } return that;
  50543. };
  50544. var getEntry = function (that, key) {
  50545. var state = getInternalState(that);
  50546. // fast case
  50547. var index = fastKey(key);
  50548. var entry;
  50549. if (index !== 'F') return state.index[index];
  50550. // frozen object case
  50551. for (entry = state.first; entry; entry = entry.next) {
  50552. if (entry.key == key) return entry;
  50553. }
  50554. };
  50555. redefineAll(Prototype, {
  50556. // `{ Map, Set }.prototype.clear()` methods
  50557. // https://tc39.es/ecma262/#sec-map.prototype.clear
  50558. // https://tc39.es/ecma262/#sec-set.prototype.clear
  50559. clear: function clear() {
  50560. var that = this;
  50561. var state = getInternalState(that);
  50562. var data = state.index;
  50563. var entry = state.first;
  50564. while (entry) {
  50565. entry.removed = true;
  50566. if (entry.previous) entry.previous = entry.previous.next = undefined;
  50567. delete data[entry.index];
  50568. entry = entry.next;
  50569. }
  50570. state.first = state.last = undefined;
  50571. if (DESCRIPTORS) state.size = 0;
  50572. else that.size = 0;
  50573. },
  50574. // `{ Map, Set }.prototype.delete(key)` methods
  50575. // https://tc39.es/ecma262/#sec-map.prototype.delete
  50576. // https://tc39.es/ecma262/#sec-set.prototype.delete
  50577. 'delete': function (key) {
  50578. var that = this;
  50579. var state = getInternalState(that);
  50580. var entry = getEntry(that, key);
  50581. if (entry) {
  50582. var next = entry.next;
  50583. var prev = entry.previous;
  50584. delete state.index[entry.index];
  50585. entry.removed = true;
  50586. if (prev) prev.next = next;
  50587. if (next) next.previous = prev;
  50588. if (state.first == entry) state.first = next;
  50589. if (state.last == entry) state.last = prev;
  50590. if (DESCRIPTORS) state.size--;
  50591. else that.size--;
  50592. } return !!entry;
  50593. },
  50594. // `{ Map, Set }.prototype.forEach(callbackfn, thisArg = undefined)` methods
  50595. // https://tc39.es/ecma262/#sec-map.prototype.foreach
  50596. // https://tc39.es/ecma262/#sec-set.prototype.foreach
  50597. forEach: function forEach(callbackfn /* , that = undefined */) {
  50598. var state = getInternalState(this);
  50599. var boundFunction = bind(callbackfn, arguments.length > 1 ? arguments[1] : undefined);
  50600. var entry;
  50601. while (entry = entry ? entry.next : state.first) {
  50602. boundFunction(entry.value, entry.key, this);
  50603. // revert to the last existing entry
  50604. while (entry && entry.removed) entry = entry.previous;
  50605. }
  50606. },
  50607. // `{ Map, Set}.prototype.has(key)` methods
  50608. // https://tc39.es/ecma262/#sec-map.prototype.has
  50609. // https://tc39.es/ecma262/#sec-set.prototype.has
  50610. has: function has(key) {
  50611. return !!getEntry(this, key);
  50612. }
  50613. });
  50614. redefineAll(Prototype, IS_MAP ? {
  50615. // `Map.prototype.get(key)` method
  50616. // https://tc39.es/ecma262/#sec-map.prototype.get
  50617. get: function get(key) {
  50618. var entry = getEntry(this, key);
  50619. return entry && entry.value;
  50620. },
  50621. // `Map.prototype.set(key, value)` method
  50622. // https://tc39.es/ecma262/#sec-map.prototype.set
  50623. set: function set(key, value) {
  50624. return define(this, key === 0 ? 0 : key, value);
  50625. }
  50626. } : {
  50627. // `Set.prototype.add(value)` method
  50628. // https://tc39.es/ecma262/#sec-set.prototype.add
  50629. add: function add(value) {
  50630. return define(this, value = value === 0 ? 0 : value, value);
  50631. }
  50632. });
  50633. if (DESCRIPTORS) defineProperty(Prototype, 'size', {
  50634. get: function () {
  50635. return getInternalState(this).size;
  50636. }
  50637. });
  50638. return Constructor;
  50639. },
  50640. setStrong: function (Constructor, CONSTRUCTOR_NAME, IS_MAP) {
  50641. var ITERATOR_NAME = CONSTRUCTOR_NAME + ' Iterator';
  50642. var getInternalCollectionState = internalStateGetterFor(CONSTRUCTOR_NAME);
  50643. var getInternalIteratorState = internalStateGetterFor(ITERATOR_NAME);
  50644. // `{ Map, Set }.prototype.{ keys, values, entries, @@iterator }()` methods
  50645. // https://tc39.es/ecma262/#sec-map.prototype.entries
  50646. // https://tc39.es/ecma262/#sec-map.prototype.keys
  50647. // https://tc39.es/ecma262/#sec-map.prototype.values
  50648. // https://tc39.es/ecma262/#sec-map.prototype-@@iterator
  50649. // https://tc39.es/ecma262/#sec-set.prototype.entries
  50650. // https://tc39.es/ecma262/#sec-set.prototype.keys
  50651. // https://tc39.es/ecma262/#sec-set.prototype.values
  50652. // https://tc39.es/ecma262/#sec-set.prototype-@@iterator
  50653. defineIterator(Constructor, CONSTRUCTOR_NAME, function (iterated, kind) {
  50654. setInternalState(this, {
  50655. type: ITERATOR_NAME,
  50656. target: iterated,
  50657. state: getInternalCollectionState(iterated),
  50658. kind: kind,
  50659. last: undefined
  50660. });
  50661. }, function () {
  50662. var state = getInternalIteratorState(this);
  50663. var kind = state.kind;
  50664. var entry = state.last;
  50665. // revert to the last existing entry
  50666. while (entry && entry.removed) entry = entry.previous;
  50667. // get next entry
  50668. if (!state.target || !(state.last = entry = entry ? entry.next : state.state.first)) {
  50669. // or finish the iteration
  50670. state.target = undefined;
  50671. return { value: undefined, done: true };
  50672. }
  50673. // return step by kind
  50674. if (kind == 'keys') return { value: entry.key, done: false };
  50675. if (kind == 'values') return { value: entry.value, done: false };
  50676. return { value: [entry.key, entry.value], done: false };
  50677. }, IS_MAP ? 'entries' : 'values', !IS_MAP, true);
  50678. // `{ Map, Set }.prototype[@@species]` accessors
  50679. // https://tc39.es/ecma262/#sec-get-map-@@species
  50680. // https://tc39.es/ecma262/#sec-get-set-@@species
  50681. setSpecies(CONSTRUCTOR_NAME);
  50682. }
  50683. };
  50684. },{"../internals/an-instance":425,"../internals/define-iterator":458,"../internals/descriptors":460,"../internals/function-bind-context":480,"../internals/internal-metadata":500,"../internals/internal-state":501,"../internals/iterate":513,"../internals/object-create":530,"../internals/object-define-property":532,"../internals/redefine-all":552,"../internals/set-species":557}],449:[function(_dereq_,module,exports){
  50685. 'use strict';
  50686. var uncurryThis = _dereq_('../internals/function-uncurry-this');
  50687. var redefineAll = _dereq_('../internals/redefine-all');
  50688. var getWeakData = _dereq_('../internals/internal-metadata').getWeakData;
  50689. var anObject = _dereq_('../internals/an-object');
  50690. var isObject = _dereq_('../internals/is-object');
  50691. var anInstance = _dereq_('../internals/an-instance');
  50692. var iterate = _dereq_('../internals/iterate');
  50693. var ArrayIterationModule = _dereq_('../internals/array-iteration');
  50694. var hasOwn = _dereq_('../internals/has-own-property');
  50695. var InternalStateModule = _dereq_('../internals/internal-state');
  50696. var setInternalState = InternalStateModule.set;
  50697. var internalStateGetterFor = InternalStateModule.getterFor;
  50698. var find = ArrayIterationModule.find;
  50699. var findIndex = ArrayIterationModule.findIndex;
  50700. var splice = uncurryThis([].splice);
  50701. var id = 0;
  50702. // fallback for uncaught frozen keys
  50703. var uncaughtFrozenStore = function (store) {
  50704. return store.frozen || (store.frozen = new UncaughtFrozenStore());
  50705. };
  50706. var UncaughtFrozenStore = function () {
  50707. this.entries = [];
  50708. };
  50709. var findUncaughtFrozen = function (store, key) {
  50710. return find(store.entries, function (it) {
  50711. return it[0] === key;
  50712. });
  50713. };
  50714. UncaughtFrozenStore.prototype = {
  50715. get: function (key) {
  50716. var entry = findUncaughtFrozen(this, key);
  50717. if (entry) return entry[1];
  50718. },
  50719. has: function (key) {
  50720. return !!findUncaughtFrozen(this, key);
  50721. },
  50722. set: function (key, value) {
  50723. var entry = findUncaughtFrozen(this, key);
  50724. if (entry) entry[1] = value;
  50725. else this.entries.push([key, value]);
  50726. },
  50727. 'delete': function (key) {
  50728. var index = findIndex(this.entries, function (it) {
  50729. return it[0] === key;
  50730. });
  50731. if (~index) splice(this.entries, index, 1);
  50732. return !!~index;
  50733. }
  50734. };
  50735. module.exports = {
  50736. getConstructor: function (wrapper, CONSTRUCTOR_NAME, IS_MAP, ADDER) {
  50737. var Constructor = wrapper(function (that, iterable) {
  50738. anInstance(that, Prototype);
  50739. setInternalState(that, {
  50740. type: CONSTRUCTOR_NAME,
  50741. id: id++,
  50742. frozen: undefined
  50743. });
  50744. if (iterable != undefined) iterate(iterable, that[ADDER], { that: that, AS_ENTRIES: IS_MAP });
  50745. });
  50746. var Prototype = Constructor.prototype;
  50747. var getInternalState = internalStateGetterFor(CONSTRUCTOR_NAME);
  50748. var define = function (that, key, value) {
  50749. var state = getInternalState(that);
  50750. var data = getWeakData(anObject(key), true);
  50751. if (data === true) uncaughtFrozenStore(state).set(key, value);
  50752. else data[state.id] = value;
  50753. return that;
  50754. };
  50755. redefineAll(Prototype, {
  50756. // `{ WeakMap, WeakSet }.prototype.delete(key)` methods
  50757. // https://tc39.es/ecma262/#sec-weakmap.prototype.delete
  50758. // https://tc39.es/ecma262/#sec-weakset.prototype.delete
  50759. 'delete': function (key) {
  50760. var state = getInternalState(this);
  50761. if (!isObject(key)) return false;
  50762. var data = getWeakData(key);
  50763. if (data === true) return uncaughtFrozenStore(state)['delete'](key);
  50764. return data && hasOwn(data, state.id) && delete data[state.id];
  50765. },
  50766. // `{ WeakMap, WeakSet }.prototype.has(key)` methods
  50767. // https://tc39.es/ecma262/#sec-weakmap.prototype.has
  50768. // https://tc39.es/ecma262/#sec-weakset.prototype.has
  50769. has: function has(key) {
  50770. var state = getInternalState(this);
  50771. if (!isObject(key)) return false;
  50772. var data = getWeakData(key);
  50773. if (data === true) return uncaughtFrozenStore(state).has(key);
  50774. return data && hasOwn(data, state.id);
  50775. }
  50776. });
  50777. redefineAll(Prototype, IS_MAP ? {
  50778. // `WeakMap.prototype.get(key)` method
  50779. // https://tc39.es/ecma262/#sec-weakmap.prototype.get
  50780. get: function get(key) {
  50781. var state = getInternalState(this);
  50782. if (isObject(key)) {
  50783. var data = getWeakData(key);
  50784. if (data === true) return uncaughtFrozenStore(state).get(key);
  50785. return data ? data[state.id] : undefined;
  50786. }
  50787. },
  50788. // `WeakMap.prototype.set(key, value)` method
  50789. // https://tc39.es/ecma262/#sec-weakmap.prototype.set
  50790. set: function set(key, value) {
  50791. return define(this, key, value);
  50792. }
  50793. } : {
  50794. // `WeakSet.prototype.add(value)` method
  50795. // https://tc39.es/ecma262/#sec-weakset.prototype.add
  50796. add: function add(value) {
  50797. return define(this, value, true);
  50798. }
  50799. });
  50800. return Constructor;
  50801. }
  50802. };
  50803. },{"../internals/an-instance":425,"../internals/an-object":426,"../internals/array-iteration":431,"../internals/function-uncurry-this":485,"../internals/has-own-property":492,"../internals/internal-metadata":500,"../internals/internal-state":501,"../internals/is-object":509,"../internals/iterate":513,"../internals/redefine-all":552}],450:[function(_dereq_,module,exports){
  50804. 'use strict';
  50805. var $ = _dereq_('../internals/export');
  50806. var global = _dereq_('../internals/global');
  50807. var InternalMetadataModule = _dereq_('../internals/internal-metadata');
  50808. var fails = _dereq_('../internals/fails');
  50809. var createNonEnumerableProperty = _dereq_('../internals/create-non-enumerable-property');
  50810. var iterate = _dereq_('../internals/iterate');
  50811. var anInstance = _dereq_('../internals/an-instance');
  50812. var isCallable = _dereq_('../internals/is-callable');
  50813. var isObject = _dereq_('../internals/is-object');
  50814. var setToStringTag = _dereq_('../internals/set-to-string-tag');
  50815. var defineProperty = _dereq_('../internals/object-define-property').f;
  50816. var forEach = _dereq_('../internals/array-iteration').forEach;
  50817. var DESCRIPTORS = _dereq_('../internals/descriptors');
  50818. var InternalStateModule = _dereq_('../internals/internal-state');
  50819. var setInternalState = InternalStateModule.set;
  50820. var internalStateGetterFor = InternalStateModule.getterFor;
  50821. module.exports = function (CONSTRUCTOR_NAME, wrapper, common) {
  50822. var IS_MAP = CONSTRUCTOR_NAME.indexOf('Map') !== -1;
  50823. var IS_WEAK = CONSTRUCTOR_NAME.indexOf('Weak') !== -1;
  50824. var ADDER = IS_MAP ? 'set' : 'add';
  50825. var NativeConstructor = global[CONSTRUCTOR_NAME];
  50826. var NativePrototype = NativeConstructor && NativeConstructor.prototype;
  50827. var exported = {};
  50828. var Constructor;
  50829. if (!DESCRIPTORS || !isCallable(NativeConstructor)
  50830. || !(IS_WEAK || NativePrototype.forEach && !fails(function () { new NativeConstructor().entries().next(); }))
  50831. ) {
  50832. // create collection constructor
  50833. Constructor = common.getConstructor(wrapper, CONSTRUCTOR_NAME, IS_MAP, ADDER);
  50834. InternalMetadataModule.enable();
  50835. } else {
  50836. Constructor = wrapper(function (target, iterable) {
  50837. setInternalState(anInstance(target, Prototype), {
  50838. type: CONSTRUCTOR_NAME,
  50839. collection: new NativeConstructor()
  50840. });
  50841. if (iterable != undefined) iterate(iterable, target[ADDER], { that: target, AS_ENTRIES: IS_MAP });
  50842. });
  50843. var Prototype = Constructor.prototype;
  50844. var getInternalState = internalStateGetterFor(CONSTRUCTOR_NAME);
  50845. forEach(['add', 'clear', 'delete', 'forEach', 'get', 'has', 'set', 'keys', 'values', 'entries'], function (KEY) {
  50846. var IS_ADDER = KEY == 'add' || KEY == 'set';
  50847. if (KEY in NativePrototype && !(IS_WEAK && KEY == 'clear')) {
  50848. createNonEnumerableProperty(Prototype, KEY, function (a, b) {
  50849. var collection = getInternalState(this).collection;
  50850. if (!IS_ADDER && IS_WEAK && !isObject(a)) return KEY == 'get' ? undefined : false;
  50851. var result = collection[KEY](a === 0 ? 0 : a, b);
  50852. return IS_ADDER ? this : result;
  50853. });
  50854. }
  50855. });
  50856. IS_WEAK || defineProperty(Prototype, 'size', {
  50857. configurable: true,
  50858. get: function () {
  50859. return getInternalState(this).collection.size;
  50860. }
  50861. });
  50862. }
  50863. setToStringTag(Constructor, CONSTRUCTOR_NAME, false, true);
  50864. exported[CONSTRUCTOR_NAME] = Constructor;
  50865. $({ global: true, forced: true }, exported);
  50866. if (!IS_WEAK) common.setStrong(Constructor, CONSTRUCTOR_NAME, IS_MAP);
  50867. return Constructor;
  50868. };
  50869. },{"../internals/an-instance":425,"../internals/array-iteration":431,"../internals/create-non-enumerable-property":455,"../internals/descriptors":460,"../internals/export":476,"../internals/fails":477,"../internals/global":491,"../internals/internal-metadata":500,"../internals/internal-state":501,"../internals/is-callable":504,"../internals/is-object":509,"../internals/iterate":513,"../internals/object-define-property":532,"../internals/set-to-string-tag":558}],451:[function(_dereq_,module,exports){
  50870. var hasOwn = _dereq_('../internals/has-own-property');
  50871. var ownKeys = _dereq_('../internals/own-keys');
  50872. var getOwnPropertyDescriptorModule = _dereq_('../internals/object-get-own-property-descriptor');
  50873. var definePropertyModule = _dereq_('../internals/object-define-property');
  50874. module.exports = function (target, source, exceptions) {
  50875. var keys = ownKeys(source);
  50876. var defineProperty = definePropertyModule.f;
  50877. var getOwnPropertyDescriptor = getOwnPropertyDescriptorModule.f;
  50878. for (var i = 0; i < keys.length; i++) {
  50879. var key = keys[i];
  50880. if (!hasOwn(target, key) && !(exceptions && hasOwn(exceptions, key))) {
  50881. defineProperty(target, key, getOwnPropertyDescriptor(source, key));
  50882. }
  50883. }
  50884. };
  50885. },{"../internals/has-own-property":492,"../internals/object-define-property":532,"../internals/object-get-own-property-descriptor":533,"../internals/own-keys":547}],452:[function(_dereq_,module,exports){
  50886. var wellKnownSymbol = _dereq_('../internals/well-known-symbol');
  50887. var MATCH = wellKnownSymbol('match');
  50888. module.exports = function (METHOD_NAME) {
  50889. var regexp = /./;
  50890. try {
  50891. '/./'[METHOD_NAME](regexp);
  50892. } catch (error1) {
  50893. try {
  50894. regexp[MATCH] = false;
  50895. return '/./'[METHOD_NAME](regexp);
  50896. } catch (error2) { /* empty */ }
  50897. } return false;
  50898. };
  50899. },{"../internals/well-known-symbol":586}],453:[function(_dereq_,module,exports){
  50900. var fails = _dereq_('../internals/fails');
  50901. module.exports = !fails(function () {
  50902. function F() { /* empty */ }
  50903. F.prototype.constructor = null;
  50904. // eslint-disable-next-line es/no-object-getprototypeof -- required for testing
  50905. return Object.getPrototypeOf(new F()) !== F.prototype;
  50906. });
  50907. },{"../internals/fails":477}],454:[function(_dereq_,module,exports){
  50908. 'use strict';
  50909. var IteratorPrototype = _dereq_('../internals/iterators-core').IteratorPrototype;
  50910. var create = _dereq_('../internals/object-create');
  50911. var createPropertyDescriptor = _dereq_('../internals/create-property-descriptor');
  50912. var setToStringTag = _dereq_('../internals/set-to-string-tag');
  50913. var Iterators = _dereq_('../internals/iterators');
  50914. var returnThis = function () { return this; };
  50915. module.exports = function (IteratorConstructor, NAME, next, ENUMERABLE_NEXT) {
  50916. var TO_STRING_TAG = NAME + ' Iterator';
  50917. IteratorConstructor.prototype = create(IteratorPrototype, { next: createPropertyDescriptor(+!ENUMERABLE_NEXT, next) });
  50918. setToStringTag(IteratorConstructor, TO_STRING_TAG, false, true);
  50919. Iterators[TO_STRING_TAG] = returnThis;
  50920. return IteratorConstructor;
  50921. };
  50922. },{"../internals/create-property-descriptor":456,"../internals/iterators":516,"../internals/iterators-core":515,"../internals/object-create":530,"../internals/set-to-string-tag":558}],455:[function(_dereq_,module,exports){
  50923. var DESCRIPTORS = _dereq_('../internals/descriptors');
  50924. var definePropertyModule = _dereq_('../internals/object-define-property');
  50925. var createPropertyDescriptor = _dereq_('../internals/create-property-descriptor');
  50926. module.exports = DESCRIPTORS ? function (object, key, value) {
  50927. return definePropertyModule.f(object, key, createPropertyDescriptor(1, value));
  50928. } : function (object, key, value) {
  50929. object[key] = value;
  50930. return object;
  50931. };
  50932. },{"../internals/create-property-descriptor":456,"../internals/descriptors":460,"../internals/object-define-property":532}],456:[function(_dereq_,module,exports){
  50933. module.exports = function (bitmap, value) {
  50934. return {
  50935. enumerable: !(bitmap & 1),
  50936. configurable: !(bitmap & 2),
  50937. writable: !(bitmap & 4),
  50938. value: value
  50939. };
  50940. };
  50941. },{}],457:[function(_dereq_,module,exports){
  50942. 'use strict';
  50943. var toPropertyKey = _dereq_('../internals/to-property-key');
  50944. var definePropertyModule = _dereq_('../internals/object-define-property');
  50945. var createPropertyDescriptor = _dereq_('../internals/create-property-descriptor');
  50946. module.exports = function (object, key, value) {
  50947. var propertyKey = toPropertyKey(key);
  50948. if (propertyKey in object) definePropertyModule.f(object, propertyKey, createPropertyDescriptor(0, value));
  50949. else object[propertyKey] = value;
  50950. };
  50951. },{"../internals/create-property-descriptor":456,"../internals/object-define-property":532,"../internals/to-property-key":577}],458:[function(_dereq_,module,exports){
  50952. 'use strict';
  50953. var $ = _dereq_('../internals/export');
  50954. var call = _dereq_('../internals/function-call');
  50955. var IS_PURE = _dereq_('../internals/is-pure');
  50956. var FunctionName = _dereq_('../internals/function-name');
  50957. var isCallable = _dereq_('../internals/is-callable');
  50958. var createIteratorConstructor = _dereq_('../internals/create-iterator-constructor');
  50959. var getPrototypeOf = _dereq_('../internals/object-get-prototype-of');
  50960. var setPrototypeOf = _dereq_('../internals/object-set-prototype-of');
  50961. var setToStringTag = _dereq_('../internals/set-to-string-tag');
  50962. var createNonEnumerableProperty = _dereq_('../internals/create-non-enumerable-property');
  50963. var redefine = _dereq_('../internals/redefine');
  50964. var wellKnownSymbol = _dereq_('../internals/well-known-symbol');
  50965. var Iterators = _dereq_('../internals/iterators');
  50966. var IteratorsCore = _dereq_('../internals/iterators-core');
  50967. var PROPER_FUNCTION_NAME = FunctionName.PROPER;
  50968. var CONFIGURABLE_FUNCTION_NAME = FunctionName.CONFIGURABLE;
  50969. var IteratorPrototype = IteratorsCore.IteratorPrototype;
  50970. var BUGGY_SAFARI_ITERATORS = IteratorsCore.BUGGY_SAFARI_ITERATORS;
  50971. var ITERATOR = wellKnownSymbol('iterator');
  50972. var KEYS = 'keys';
  50973. var VALUES = 'values';
  50974. var ENTRIES = 'entries';
  50975. var returnThis = function () { return this; };
  50976. module.exports = function (Iterable, NAME, IteratorConstructor, next, DEFAULT, IS_SET, FORCED) {
  50977. createIteratorConstructor(IteratorConstructor, NAME, next);
  50978. var getIterationMethod = function (KIND) {
  50979. if (KIND === DEFAULT && defaultIterator) return defaultIterator;
  50980. if (!BUGGY_SAFARI_ITERATORS && KIND in IterablePrototype) return IterablePrototype[KIND];
  50981. switch (KIND) {
  50982. case KEYS: return function keys() { return new IteratorConstructor(this, KIND); };
  50983. case VALUES: return function values() { return new IteratorConstructor(this, KIND); };
  50984. case ENTRIES: return function entries() { return new IteratorConstructor(this, KIND); };
  50985. } return function () { return new IteratorConstructor(this); };
  50986. };
  50987. var TO_STRING_TAG = NAME + ' Iterator';
  50988. var INCORRECT_VALUES_NAME = false;
  50989. var IterablePrototype = Iterable.prototype;
  50990. var nativeIterator = IterablePrototype[ITERATOR]
  50991. || IterablePrototype['@@iterator']
  50992. || DEFAULT && IterablePrototype[DEFAULT];
  50993. var defaultIterator = !BUGGY_SAFARI_ITERATORS && nativeIterator || getIterationMethod(DEFAULT);
  50994. var anyNativeIterator = NAME == 'Array' ? IterablePrototype.entries || nativeIterator : nativeIterator;
  50995. var CurrentIteratorPrototype, methods, KEY;
  50996. // fix native
  50997. if (anyNativeIterator) {
  50998. CurrentIteratorPrototype = getPrototypeOf(anyNativeIterator.call(new Iterable()));
  50999. if (CurrentIteratorPrototype !== Object.prototype && CurrentIteratorPrototype.next) {
  51000. if (!IS_PURE && getPrototypeOf(CurrentIteratorPrototype) !== IteratorPrototype) {
  51001. if (setPrototypeOf) {
  51002. setPrototypeOf(CurrentIteratorPrototype, IteratorPrototype);
  51003. } else if (!isCallable(CurrentIteratorPrototype[ITERATOR])) {
  51004. redefine(CurrentIteratorPrototype, ITERATOR, returnThis);
  51005. }
  51006. }
  51007. // Set @@toStringTag to native iterators
  51008. setToStringTag(CurrentIteratorPrototype, TO_STRING_TAG, true, true);
  51009. if (IS_PURE) Iterators[TO_STRING_TAG] = returnThis;
  51010. }
  51011. }
  51012. // fix Array.prototype.{ values, @@iterator }.name in V8 / FF
  51013. if (PROPER_FUNCTION_NAME && DEFAULT == VALUES && nativeIterator && nativeIterator.name !== VALUES) {
  51014. if (!IS_PURE && CONFIGURABLE_FUNCTION_NAME) {
  51015. createNonEnumerableProperty(IterablePrototype, 'name', VALUES);
  51016. } else {
  51017. INCORRECT_VALUES_NAME = true;
  51018. defaultIterator = function values() { return call(nativeIterator, this); };
  51019. }
  51020. }
  51021. // export additional methods
  51022. if (DEFAULT) {
  51023. methods = {
  51024. values: getIterationMethod(VALUES),
  51025. keys: IS_SET ? defaultIterator : getIterationMethod(KEYS),
  51026. entries: getIterationMethod(ENTRIES)
  51027. };
  51028. if (FORCED) for (KEY in methods) {
  51029. if (BUGGY_SAFARI_ITERATORS || INCORRECT_VALUES_NAME || !(KEY in IterablePrototype)) {
  51030. redefine(IterablePrototype, KEY, methods[KEY]);
  51031. }
  51032. } else $({ target: NAME, proto: true, forced: BUGGY_SAFARI_ITERATORS || INCORRECT_VALUES_NAME }, methods);
  51033. }
  51034. // define iterator
  51035. if ((!IS_PURE || FORCED) && IterablePrototype[ITERATOR] !== defaultIterator) {
  51036. redefine(IterablePrototype, ITERATOR, defaultIterator, { name: DEFAULT });
  51037. }
  51038. Iterators[NAME] = defaultIterator;
  51039. return methods;
  51040. };
  51041. },{"../internals/create-iterator-constructor":454,"../internals/create-non-enumerable-property":455,"../internals/export":476,"../internals/function-call":483,"../internals/function-name":484,"../internals/is-callable":504,"../internals/is-pure":510,"../internals/iterators":516,"../internals/iterators-core":515,"../internals/object-get-prototype-of":537,"../internals/object-set-prototype-of":543,"../internals/redefine":553,"../internals/set-to-string-tag":558,"../internals/well-known-symbol":586}],459:[function(_dereq_,module,exports){
  51042. var path = _dereq_('../internals/path');
  51043. var hasOwn = _dereq_('../internals/has-own-property');
  51044. var wrappedWellKnownSymbolModule = _dereq_('../internals/well-known-symbol-wrapped');
  51045. var defineProperty = _dereq_('../internals/object-define-property').f;
  51046. module.exports = function (NAME) {
  51047. var Symbol = path.Symbol || (path.Symbol = {});
  51048. if (!hasOwn(Symbol, NAME)) defineProperty(Symbol, NAME, {
  51049. value: wrappedWellKnownSymbolModule.f(NAME)
  51050. });
  51051. };
  51052. },{"../internals/has-own-property":492,"../internals/object-define-property":532,"../internals/path":548,"../internals/well-known-symbol-wrapped":585}],460:[function(_dereq_,module,exports){
  51053. var fails = _dereq_('../internals/fails');
  51054. // Detect IE8's incomplete defineProperty implementation
  51055. module.exports = !fails(function () {
  51056. // eslint-disable-next-line es/no-object-defineproperty -- required for testing
  51057. return Object.defineProperty({}, 1, { get: function () { return 7; } })[1] != 7;
  51058. });
  51059. },{"../internals/fails":477}],461:[function(_dereq_,module,exports){
  51060. var global = _dereq_('../internals/global');
  51061. var isObject = _dereq_('../internals/is-object');
  51062. var document = global.document;
  51063. // typeof document.createElement is 'object' in old IE
  51064. var EXISTS = isObject(document) && isObject(document.createElement);
  51065. module.exports = function (it) {
  51066. return EXISTS ? document.createElement(it) : {};
  51067. };
  51068. },{"../internals/global":491,"../internals/is-object":509}],462:[function(_dereq_,module,exports){
  51069. // iterable DOM collections
  51070. // flag - `iterable` interface - 'entries', 'keys', 'values', 'forEach' methods
  51071. module.exports = {
  51072. CSSRuleList: 0,
  51073. CSSStyleDeclaration: 0,
  51074. CSSValueList: 0,
  51075. ClientRectList: 0,
  51076. DOMRectList: 0,
  51077. DOMStringList: 0,
  51078. DOMTokenList: 1,
  51079. DataTransferItemList: 0,
  51080. FileList: 0,
  51081. HTMLAllCollection: 0,
  51082. HTMLCollection: 0,
  51083. HTMLFormElement: 0,
  51084. HTMLSelectElement: 0,
  51085. MediaList: 0,
  51086. MimeTypeArray: 0,
  51087. NamedNodeMap: 0,
  51088. NodeList: 1,
  51089. PaintRequestList: 0,
  51090. Plugin: 0,
  51091. PluginArray: 0,
  51092. SVGLengthList: 0,
  51093. SVGNumberList: 0,
  51094. SVGPathSegList: 0,
  51095. SVGPointList: 0,
  51096. SVGStringList: 0,
  51097. SVGTransformList: 0,
  51098. SourceBufferList: 0,
  51099. StyleSheetList: 0,
  51100. TextTrackCueList: 0,
  51101. TextTrackList: 0,
  51102. TouchList: 0
  51103. };
  51104. },{}],463:[function(_dereq_,module,exports){
  51105. var userAgent = _dereq_('../internals/engine-user-agent');
  51106. var firefox = userAgent.match(/firefox\/(\d+)/i);
  51107. module.exports = !!firefox && +firefox[1];
  51108. },{"../internals/engine-user-agent":470}],464:[function(_dereq_,module,exports){
  51109. module.exports = typeof window == 'object';
  51110. },{}],465:[function(_dereq_,module,exports){
  51111. var UA = _dereq_('../internals/engine-user-agent');
  51112. module.exports = /MSIE|Trident/.test(UA);
  51113. },{"../internals/engine-user-agent":470}],466:[function(_dereq_,module,exports){
  51114. var userAgent = _dereq_('../internals/engine-user-agent');
  51115. var global = _dereq_('../internals/global');
  51116. module.exports = /ipad|iphone|ipod/i.test(userAgent) && global.Pebble !== undefined;
  51117. },{"../internals/engine-user-agent":470,"../internals/global":491}],467:[function(_dereq_,module,exports){
  51118. var userAgent = _dereq_('../internals/engine-user-agent');
  51119. module.exports = /(?:ipad|iphone|ipod).*applewebkit/i.test(userAgent);
  51120. },{"../internals/engine-user-agent":470}],468:[function(_dereq_,module,exports){
  51121. var classof = _dereq_('../internals/classof-raw');
  51122. var global = _dereq_('../internals/global');
  51123. module.exports = classof(global.process) == 'process';
  51124. },{"../internals/classof-raw":442,"../internals/global":491}],469:[function(_dereq_,module,exports){
  51125. var userAgent = _dereq_('../internals/engine-user-agent');
  51126. module.exports = /web0s(?!.*chrome)/i.test(userAgent);
  51127. },{"../internals/engine-user-agent":470}],470:[function(_dereq_,module,exports){
  51128. var getBuiltIn = _dereq_('../internals/get-built-in');
  51129. module.exports = getBuiltIn('navigator', 'userAgent') || '';
  51130. },{"../internals/get-built-in":486}],471:[function(_dereq_,module,exports){
  51131. var global = _dereq_('../internals/global');
  51132. var userAgent = _dereq_('../internals/engine-user-agent');
  51133. var process = global.process;
  51134. var Deno = global.Deno;
  51135. var versions = process && process.versions || Deno && Deno.version;
  51136. var v8 = versions && versions.v8;
  51137. var match, version;
  51138. if (v8) {
  51139. match = v8.split('.');
  51140. // in old Chrome, versions of V8 isn't V8 = Chrome / 10
  51141. // but their correct versions are not interesting for us
  51142. version = match[0] > 0 && match[0] < 4 ? 1 : +(match[0] + match[1]);
  51143. }
  51144. // BrowserFS NodeJS `process` polyfill incorrectly set `.v8` to `0.0`
  51145. // so check `userAgent` even if `.v8` exists, but 0
  51146. if (!version && userAgent) {
  51147. match = userAgent.match(/Edge\/(\d+)/);
  51148. if (!match || match[1] >= 74) {
  51149. match = userAgent.match(/Chrome\/(\d+)/);
  51150. if (match) version = +match[1];
  51151. }
  51152. }
  51153. module.exports = version;
  51154. },{"../internals/engine-user-agent":470,"../internals/global":491}],472:[function(_dereq_,module,exports){
  51155. var userAgent = _dereq_('../internals/engine-user-agent');
  51156. var webkit = userAgent.match(/AppleWebKit\/(\d+)\./);
  51157. module.exports = !!webkit && +webkit[1];
  51158. },{"../internals/engine-user-agent":470}],473:[function(_dereq_,module,exports){
  51159. var path = _dereq_('../internals/path');
  51160. module.exports = function (CONSTRUCTOR) {
  51161. return path[CONSTRUCTOR + 'Prototype'];
  51162. };
  51163. },{"../internals/path":548}],474:[function(_dereq_,module,exports){
  51164. // IE8- don't enum bug keys
  51165. module.exports = [
  51166. 'constructor',
  51167. 'hasOwnProperty',
  51168. 'isPrototypeOf',
  51169. 'propertyIsEnumerable',
  51170. 'toLocaleString',
  51171. 'toString',
  51172. 'valueOf'
  51173. ];
  51174. },{}],475:[function(_dereq_,module,exports){
  51175. var fails = _dereq_('../internals/fails');
  51176. var createPropertyDescriptor = _dereq_('../internals/create-property-descriptor');
  51177. module.exports = !fails(function () {
  51178. var error = Error('a');
  51179. if (!('stack' in error)) return true;
  51180. // eslint-disable-next-line es/no-object-defineproperty -- safe
  51181. Object.defineProperty(error, 'stack', createPropertyDescriptor(1, 7));
  51182. return error.stack !== 7;
  51183. });
  51184. },{"../internals/create-property-descriptor":456,"../internals/fails":477}],476:[function(_dereq_,module,exports){
  51185. 'use strict';
  51186. var global = _dereq_('../internals/global');
  51187. var apply = _dereq_('../internals/function-apply');
  51188. var uncurryThis = _dereq_('../internals/function-uncurry-this');
  51189. var isCallable = _dereq_('../internals/is-callable');
  51190. var getOwnPropertyDescriptor = _dereq_('../internals/object-get-own-property-descriptor').f;
  51191. var isForced = _dereq_('../internals/is-forced');
  51192. var path = _dereq_('../internals/path');
  51193. var bind = _dereq_('../internals/function-bind-context');
  51194. var createNonEnumerableProperty = _dereq_('../internals/create-non-enumerable-property');
  51195. var hasOwn = _dereq_('../internals/has-own-property');
  51196. var wrapConstructor = function (NativeConstructor) {
  51197. var Wrapper = function (a, b, c) {
  51198. if (this instanceof Wrapper) {
  51199. switch (arguments.length) {
  51200. case 0: return new NativeConstructor();
  51201. case 1: return new NativeConstructor(a);
  51202. case 2: return new NativeConstructor(a, b);
  51203. } return new NativeConstructor(a, b, c);
  51204. } return apply(NativeConstructor, this, arguments);
  51205. };
  51206. Wrapper.prototype = NativeConstructor.prototype;
  51207. return Wrapper;
  51208. };
  51209. /*
  51210. options.target - name of the target object
  51211. options.global - target is the global object
  51212. options.stat - export as static methods of target
  51213. options.proto - export as prototype methods of target
  51214. options.real - real prototype method for the `pure` version
  51215. options.forced - export even if the native feature is available
  51216. options.bind - bind methods to the target, required for the `pure` version
  51217. options.wrap - wrap constructors to preventing global pollution, required for the `pure` version
  51218. options.unsafe - use the simple assignment of property instead of delete + defineProperty
  51219. options.sham - add a flag to not completely full polyfills
  51220. options.enumerable - export as enumerable property
  51221. options.noTargetGet - prevent calling a getter on target
  51222. options.name - the .name of the function if it does not match the key
  51223. */
  51224. module.exports = function (options, source) {
  51225. var TARGET = options.target;
  51226. var GLOBAL = options.global;
  51227. var STATIC = options.stat;
  51228. var PROTO = options.proto;
  51229. var nativeSource = GLOBAL ? global : STATIC ? global[TARGET] : (global[TARGET] || {}).prototype;
  51230. var target = GLOBAL ? path : path[TARGET] || createNonEnumerableProperty(path, TARGET, {})[TARGET];
  51231. var targetPrototype = target.prototype;
  51232. var FORCED, USE_NATIVE, VIRTUAL_PROTOTYPE;
  51233. var key, sourceProperty, targetProperty, nativeProperty, resultProperty, descriptor;
  51234. for (key in source) {
  51235. FORCED = isForced(GLOBAL ? key : TARGET + (STATIC ? '.' : '#') + key, options.forced);
  51236. // contains in native
  51237. USE_NATIVE = !FORCED && nativeSource && hasOwn(nativeSource, key);
  51238. targetProperty = target[key];
  51239. if (USE_NATIVE) if (options.noTargetGet) {
  51240. descriptor = getOwnPropertyDescriptor(nativeSource, key);
  51241. nativeProperty = descriptor && descriptor.value;
  51242. } else nativeProperty = nativeSource[key];
  51243. // export native or implementation
  51244. sourceProperty = (USE_NATIVE && nativeProperty) ? nativeProperty : source[key];
  51245. if (USE_NATIVE && typeof targetProperty == typeof sourceProperty) continue;
  51246. // bind timers to global for call from export context
  51247. if (options.bind && USE_NATIVE) resultProperty = bind(sourceProperty, global);
  51248. // wrap global constructors for prevent changs in this version
  51249. else if (options.wrap && USE_NATIVE) resultProperty = wrapConstructor(sourceProperty);
  51250. // make static versions for prototype methods
  51251. else if (PROTO && isCallable(sourceProperty)) resultProperty = uncurryThis(sourceProperty);
  51252. // default case
  51253. else resultProperty = sourceProperty;
  51254. // add a flag to not completely full polyfills
  51255. if (options.sham || (sourceProperty && sourceProperty.sham) || (targetProperty && targetProperty.sham)) {
  51256. createNonEnumerableProperty(resultProperty, 'sham', true);
  51257. }
  51258. createNonEnumerableProperty(target, key, resultProperty);
  51259. if (PROTO) {
  51260. VIRTUAL_PROTOTYPE = TARGET + 'Prototype';
  51261. if (!hasOwn(path, VIRTUAL_PROTOTYPE)) {
  51262. createNonEnumerableProperty(path, VIRTUAL_PROTOTYPE, {});
  51263. }
  51264. // export virtual prototype methods
  51265. createNonEnumerableProperty(path[VIRTUAL_PROTOTYPE], key, sourceProperty);
  51266. // export real prototype methods
  51267. if (options.real && targetPrototype && !targetPrototype[key]) {
  51268. createNonEnumerableProperty(targetPrototype, key, sourceProperty);
  51269. }
  51270. }
  51271. }
  51272. };
  51273. },{"../internals/create-non-enumerable-property":455,"../internals/function-apply":479,"../internals/function-bind-context":480,"../internals/function-uncurry-this":485,"../internals/global":491,"../internals/has-own-property":492,"../internals/is-callable":504,"../internals/is-forced":507,"../internals/object-get-own-property-descriptor":533,"../internals/path":548}],477:[function(_dereq_,module,exports){
  51274. module.exports = function (exec) {
  51275. try {
  51276. return !!exec();
  51277. } catch (error) {
  51278. return true;
  51279. }
  51280. };
  51281. },{}],478:[function(_dereq_,module,exports){
  51282. var fails = _dereq_('../internals/fails');
  51283. module.exports = !fails(function () {
  51284. // eslint-disable-next-line es/no-object-isextensible, es/no-object-preventextensions -- required for testing
  51285. return Object.isExtensible(Object.preventExtensions({}));
  51286. });
  51287. },{"../internals/fails":477}],479:[function(_dereq_,module,exports){
  51288. var NATIVE_BIND = _dereq_('../internals/function-bind-native');
  51289. var FunctionPrototype = Function.prototype;
  51290. var apply = FunctionPrototype.apply;
  51291. var call = FunctionPrototype.call;
  51292. // eslint-disable-next-line es/no-reflect -- safe
  51293. module.exports = typeof Reflect == 'object' && Reflect.apply || (NATIVE_BIND ? call.bind(apply) : function () {
  51294. return call.apply(apply, arguments);
  51295. });
  51296. },{"../internals/function-bind-native":481}],480:[function(_dereq_,module,exports){
  51297. var uncurryThis = _dereq_('../internals/function-uncurry-this');
  51298. var aCallable = _dereq_('../internals/a-callable');
  51299. var NATIVE_BIND = _dereq_('../internals/function-bind-native');
  51300. var bind = uncurryThis(uncurryThis.bind);
  51301. // optional / simple context binding
  51302. module.exports = function (fn, that) {
  51303. aCallable(fn);
  51304. return that === undefined ? fn : NATIVE_BIND ? bind(fn, that) : function (/* ...args */) {
  51305. return fn.apply(that, arguments);
  51306. };
  51307. };
  51308. },{"../internals/a-callable":421,"../internals/function-bind-native":481,"../internals/function-uncurry-this":485}],481:[function(_dereq_,module,exports){
  51309. var fails = _dereq_('../internals/fails');
  51310. module.exports = !fails(function () {
  51311. var test = (function () { /* empty */ }).bind();
  51312. // eslint-disable-next-line no-prototype-builtins -- safe
  51313. return typeof test != 'function' || test.hasOwnProperty('prototype');
  51314. });
  51315. },{"../internals/fails":477}],482:[function(_dereq_,module,exports){
  51316. 'use strict';
  51317. var global = _dereq_('../internals/global');
  51318. var uncurryThis = _dereq_('../internals/function-uncurry-this');
  51319. var aCallable = _dereq_('../internals/a-callable');
  51320. var isObject = _dereq_('../internals/is-object');
  51321. var hasOwn = _dereq_('../internals/has-own-property');
  51322. var arraySlice = _dereq_('../internals/array-slice');
  51323. var NATIVE_BIND = _dereq_('../internals/function-bind-native');
  51324. var Function = global.Function;
  51325. var concat = uncurryThis([].concat);
  51326. var join = uncurryThis([].join);
  51327. var factories = {};
  51328. var construct = function (C, argsLength, args) {
  51329. if (!hasOwn(factories, argsLength)) {
  51330. for (var list = [], i = 0; i < argsLength; i++) list[i] = 'a[' + i + ']';
  51331. factories[argsLength] = Function('C,a', 'return new C(' + join(list, ',') + ')');
  51332. } return factories[argsLength](C, args);
  51333. };
  51334. // `Function.prototype.bind` method implementation
  51335. // https://tc39.es/ecma262/#sec-function.prototype.bind
  51336. module.exports = NATIVE_BIND ? Function.bind : function bind(that /* , ...args */) {
  51337. var F = aCallable(this);
  51338. var Prototype = F.prototype;
  51339. var partArgs = arraySlice(arguments, 1);
  51340. var boundFunction = function bound(/* args... */) {
  51341. var args = concat(partArgs, arraySlice(arguments));
  51342. return this instanceof boundFunction ? construct(F, args.length, args) : F.apply(that, args);
  51343. };
  51344. if (isObject(Prototype)) boundFunction.prototype = Prototype;
  51345. return boundFunction;
  51346. };
  51347. },{"../internals/a-callable":421,"../internals/array-slice":436,"../internals/function-bind-native":481,"../internals/function-uncurry-this":485,"../internals/global":491,"../internals/has-own-property":492,"../internals/is-object":509}],483:[function(_dereq_,module,exports){
  51348. var NATIVE_BIND = _dereq_('../internals/function-bind-native');
  51349. var call = Function.prototype.call;
  51350. module.exports = NATIVE_BIND ? call.bind(call) : function () {
  51351. return call.apply(call, arguments);
  51352. };
  51353. },{"../internals/function-bind-native":481}],484:[function(_dereq_,module,exports){
  51354. var DESCRIPTORS = _dereq_('../internals/descriptors');
  51355. var hasOwn = _dereq_('../internals/has-own-property');
  51356. var FunctionPrototype = Function.prototype;
  51357. // eslint-disable-next-line es/no-object-getownpropertydescriptor -- safe
  51358. var getDescriptor = DESCRIPTORS && Object.getOwnPropertyDescriptor;
  51359. var EXISTS = hasOwn(FunctionPrototype, 'name');
  51360. // additional protection from minified / mangled / dropped function names
  51361. var PROPER = EXISTS && (function something() { /* empty */ }).name === 'something';
  51362. var CONFIGURABLE = EXISTS && (!DESCRIPTORS || (DESCRIPTORS && getDescriptor(FunctionPrototype, 'name').configurable));
  51363. module.exports = {
  51364. EXISTS: EXISTS,
  51365. PROPER: PROPER,
  51366. CONFIGURABLE: CONFIGURABLE
  51367. };
  51368. },{"../internals/descriptors":460,"../internals/has-own-property":492}],485:[function(_dereq_,module,exports){
  51369. var NATIVE_BIND = _dereq_('../internals/function-bind-native');
  51370. var FunctionPrototype = Function.prototype;
  51371. var bind = FunctionPrototype.bind;
  51372. var call = FunctionPrototype.call;
  51373. var uncurryThis = NATIVE_BIND && bind.bind(call, call);
  51374. module.exports = NATIVE_BIND ? function (fn) {
  51375. return fn && uncurryThis(fn);
  51376. } : function (fn) {
  51377. return fn && function () {
  51378. return call.apply(fn, arguments);
  51379. };
  51380. };
  51381. },{"../internals/function-bind-native":481}],486:[function(_dereq_,module,exports){
  51382. var path = _dereq_('../internals/path');
  51383. var global = _dereq_('../internals/global');
  51384. var isCallable = _dereq_('../internals/is-callable');
  51385. var aFunction = function (variable) {
  51386. return isCallable(variable) ? variable : undefined;
  51387. };
  51388. module.exports = function (namespace, method) {
  51389. return arguments.length < 2 ? aFunction(path[namespace]) || aFunction(global[namespace])
  51390. : path[namespace] && path[namespace][method] || global[namespace] && global[namespace][method];
  51391. };
  51392. },{"../internals/global":491,"../internals/is-callable":504,"../internals/path":548}],487:[function(_dereq_,module,exports){
  51393. var classof = _dereq_('../internals/classof');
  51394. var getMethod = _dereq_('../internals/get-method');
  51395. var Iterators = _dereq_('../internals/iterators');
  51396. var wellKnownSymbol = _dereq_('../internals/well-known-symbol');
  51397. var ITERATOR = wellKnownSymbol('iterator');
  51398. module.exports = function (it) {
  51399. if (it != undefined) return getMethod(it, ITERATOR)
  51400. || getMethod(it, '@@iterator')
  51401. || Iterators[classof(it)];
  51402. };
  51403. },{"../internals/classof":443,"../internals/get-method":490,"../internals/iterators":516,"../internals/well-known-symbol":586}],488:[function(_dereq_,module,exports){
  51404. var global = _dereq_('../internals/global');
  51405. var call = _dereq_('../internals/function-call');
  51406. var aCallable = _dereq_('../internals/a-callable');
  51407. var anObject = _dereq_('../internals/an-object');
  51408. var tryToString = _dereq_('../internals/try-to-string');
  51409. var getIteratorMethod = _dereq_('../internals/get-iterator-method');
  51410. var TypeError = global.TypeError;
  51411. module.exports = function (argument, usingIterator) {
  51412. var iteratorMethod = arguments.length < 2 ? getIteratorMethod(argument) : usingIterator;
  51413. if (aCallable(iteratorMethod)) return anObject(call(iteratorMethod, argument));
  51414. throw TypeError(tryToString(argument) + ' is not iterable');
  51415. };
  51416. },{"../internals/a-callable":421,"../internals/an-object":426,"../internals/function-call":483,"../internals/get-iterator-method":487,"../internals/global":491,"../internals/try-to-string":580}],489:[function(_dereq_,module,exports){
  51417. var getIterator = _dereq_('../internals/get-iterator');
  51418. module.exports = getIterator;
  51419. },{"../internals/get-iterator":488}],490:[function(_dereq_,module,exports){
  51420. var aCallable = _dereq_('../internals/a-callable');
  51421. // `GetMethod` abstract operation
  51422. // https://tc39.es/ecma262/#sec-getmethod
  51423. module.exports = function (V, P) {
  51424. var func = V[P];
  51425. return func == null ? undefined : aCallable(func);
  51426. };
  51427. },{"../internals/a-callable":421}],491:[function(_dereq_,module,exports){
  51428. (function (global){(function (){
  51429. var check = function (it) {
  51430. return it && it.Math == Math && it;
  51431. };
  51432. // https://github.com/zloirock/core-js/issues/86#issuecomment-115759028
  51433. module.exports =
  51434. // eslint-disable-next-line es/no-global-this -- safe
  51435. check(typeof globalThis == 'object' && globalThis) ||
  51436. check(typeof window == 'object' && window) ||
  51437. // eslint-disable-next-line no-restricted-globals -- safe
  51438. check(typeof self == 'object' && self) ||
  51439. check(typeof global == 'object' && global) ||
  51440. // eslint-disable-next-line no-new-func -- fallback
  51441. (function () { return this; })() || Function('return this')();
  51442. }).call(this)}).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {})
  51443. },{}],492:[function(_dereq_,module,exports){
  51444. var uncurryThis = _dereq_('../internals/function-uncurry-this');
  51445. var toObject = _dereq_('../internals/to-object');
  51446. var hasOwnProperty = uncurryThis({}.hasOwnProperty);
  51447. // `HasOwnProperty` abstract operation
  51448. // https://tc39.es/ecma262/#sec-hasownproperty
  51449. module.exports = Object.hasOwn || function hasOwn(it, key) {
  51450. return hasOwnProperty(toObject(it), key);
  51451. };
  51452. },{"../internals/function-uncurry-this":485,"../internals/to-object":575}],493:[function(_dereq_,module,exports){
  51453. module.exports = {};
  51454. },{}],494:[function(_dereq_,module,exports){
  51455. var global = _dereq_('../internals/global');
  51456. module.exports = function (a, b) {
  51457. var console = global.console;
  51458. if (console && console.error) {
  51459. arguments.length == 1 ? console.error(a) : console.error(a, b);
  51460. }
  51461. };
  51462. },{"../internals/global":491}],495:[function(_dereq_,module,exports){
  51463. var getBuiltIn = _dereq_('../internals/get-built-in');
  51464. module.exports = getBuiltIn('document', 'documentElement');
  51465. },{"../internals/get-built-in":486}],496:[function(_dereq_,module,exports){
  51466. var DESCRIPTORS = _dereq_('../internals/descriptors');
  51467. var fails = _dereq_('../internals/fails');
  51468. var createElement = _dereq_('../internals/document-create-element');
  51469. // Thanks to IE8 for its funny defineProperty
  51470. module.exports = !DESCRIPTORS && !fails(function () {
  51471. // eslint-disable-next-line es/no-object-defineproperty -- required for testing
  51472. return Object.defineProperty(createElement('div'), 'a', {
  51473. get: function () { return 7; }
  51474. }).a != 7;
  51475. });
  51476. },{"../internals/descriptors":460,"../internals/document-create-element":461,"../internals/fails":477}],497:[function(_dereq_,module,exports){
  51477. var global = _dereq_('../internals/global');
  51478. var uncurryThis = _dereq_('../internals/function-uncurry-this');
  51479. var fails = _dereq_('../internals/fails');
  51480. var classof = _dereq_('../internals/classof-raw');
  51481. var Object = global.Object;
  51482. var split = uncurryThis(''.split);
  51483. // fallback for non-array-like ES3 and non-enumerable old V8 strings
  51484. module.exports = fails(function () {
  51485. // throws an error in rhino, see https://github.com/mozilla/rhino/issues/346
  51486. // eslint-disable-next-line no-prototype-builtins -- safe
  51487. return !Object('z').propertyIsEnumerable(0);
  51488. }) ? function (it) {
  51489. return classof(it) == 'String' ? split(it, '') : Object(it);
  51490. } : Object;
  51491. },{"../internals/classof-raw":442,"../internals/fails":477,"../internals/function-uncurry-this":485,"../internals/global":491}],498:[function(_dereq_,module,exports){
  51492. var uncurryThis = _dereq_('../internals/function-uncurry-this');
  51493. var isCallable = _dereq_('../internals/is-callable');
  51494. var store = _dereq_('../internals/shared-store');
  51495. var functionToString = uncurryThis(Function.toString);
  51496. // this helper broken in `core-js@3.4.1-3.4.4`, so we can't use `shared` helper
  51497. if (!isCallable(store.inspectSource)) {
  51498. store.inspectSource = function (it) {
  51499. return functionToString(it);
  51500. };
  51501. }
  51502. module.exports = store.inspectSource;
  51503. },{"../internals/function-uncurry-this":485,"../internals/is-callable":504,"../internals/shared-store":560}],499:[function(_dereq_,module,exports){
  51504. var isObject = _dereq_('../internals/is-object');
  51505. var createNonEnumerableProperty = _dereq_('../internals/create-non-enumerable-property');
  51506. // `InstallErrorCause` abstract operation
  51507. // https://tc39.es/proposal-error-cause/#sec-errorobjects-install-error-cause
  51508. module.exports = function (O, options) {
  51509. if (isObject(options) && 'cause' in options) {
  51510. createNonEnumerableProperty(O, 'cause', options.cause);
  51511. }
  51512. };
  51513. },{"../internals/create-non-enumerable-property":455,"../internals/is-object":509}],500:[function(_dereq_,module,exports){
  51514. var $ = _dereq_('../internals/export');
  51515. var uncurryThis = _dereq_('../internals/function-uncurry-this');
  51516. var hiddenKeys = _dereq_('../internals/hidden-keys');
  51517. var isObject = _dereq_('../internals/is-object');
  51518. var hasOwn = _dereq_('../internals/has-own-property');
  51519. var defineProperty = _dereq_('../internals/object-define-property').f;
  51520. var getOwnPropertyNamesModule = _dereq_('../internals/object-get-own-property-names');
  51521. var getOwnPropertyNamesExternalModule = _dereq_('../internals/object-get-own-property-names-external');
  51522. var isExtensible = _dereq_('../internals/object-is-extensible');
  51523. var uid = _dereq_('../internals/uid');
  51524. var FREEZING = _dereq_('../internals/freezing');
  51525. var REQUIRED = false;
  51526. var METADATA = uid('meta');
  51527. var id = 0;
  51528. var setMetadata = function (it) {
  51529. defineProperty(it, METADATA, { value: {
  51530. objectID: 'O' + id++, // object ID
  51531. weakData: {} // weak collections IDs
  51532. } });
  51533. };
  51534. var fastKey = function (it, create) {
  51535. // return a primitive with prefix
  51536. if (!isObject(it)) return typeof it == 'symbol' ? it : (typeof it == 'string' ? 'S' : 'P') + it;
  51537. if (!hasOwn(it, METADATA)) {
  51538. // can't set metadata to uncaught frozen object
  51539. if (!isExtensible(it)) return 'F';
  51540. // not necessary to add metadata
  51541. if (!create) return 'E';
  51542. // add missing metadata
  51543. setMetadata(it);
  51544. // return object ID
  51545. } return it[METADATA].objectID;
  51546. };
  51547. var getWeakData = function (it, create) {
  51548. if (!hasOwn(it, METADATA)) {
  51549. // can't set metadata to uncaught frozen object
  51550. if (!isExtensible(it)) return true;
  51551. // not necessary to add metadata
  51552. if (!create) return false;
  51553. // add missing metadata
  51554. setMetadata(it);
  51555. // return the store of weak collections IDs
  51556. } return it[METADATA].weakData;
  51557. };
  51558. // add metadata on freeze-family methods calling
  51559. var onFreeze = function (it) {
  51560. if (FREEZING && REQUIRED && isExtensible(it) && !hasOwn(it, METADATA)) setMetadata(it);
  51561. return it;
  51562. };
  51563. var enable = function () {
  51564. meta.enable = function () { /* empty */ };
  51565. REQUIRED = true;
  51566. var getOwnPropertyNames = getOwnPropertyNamesModule.f;
  51567. var splice = uncurryThis([].splice);
  51568. var test = {};
  51569. test[METADATA] = 1;
  51570. // prevent exposing of metadata key
  51571. if (getOwnPropertyNames(test).length) {
  51572. getOwnPropertyNamesModule.f = function (it) {
  51573. var result = getOwnPropertyNames(it);
  51574. for (var i = 0, length = result.length; i < length; i++) {
  51575. if (result[i] === METADATA) {
  51576. splice(result, i, 1);
  51577. break;
  51578. }
  51579. } return result;
  51580. };
  51581. $({ target: 'Object', stat: true, forced: true }, {
  51582. getOwnPropertyNames: getOwnPropertyNamesExternalModule.f
  51583. });
  51584. }
  51585. };
  51586. var meta = module.exports = {
  51587. enable: enable,
  51588. fastKey: fastKey,
  51589. getWeakData: getWeakData,
  51590. onFreeze: onFreeze
  51591. };
  51592. hiddenKeys[METADATA] = true;
  51593. },{"../internals/export":476,"../internals/freezing":478,"../internals/function-uncurry-this":485,"../internals/has-own-property":492,"../internals/hidden-keys":493,"../internals/is-object":509,"../internals/object-define-property":532,"../internals/object-get-own-property-names":535,"../internals/object-get-own-property-names-external":534,"../internals/object-is-extensible":538,"../internals/uid":581}],501:[function(_dereq_,module,exports){
  51594. var NATIVE_WEAK_MAP = _dereq_('../internals/native-weak-map');
  51595. var global = _dereq_('../internals/global');
  51596. var uncurryThis = _dereq_('../internals/function-uncurry-this');
  51597. var isObject = _dereq_('../internals/is-object');
  51598. var createNonEnumerableProperty = _dereq_('../internals/create-non-enumerable-property');
  51599. var hasOwn = _dereq_('../internals/has-own-property');
  51600. var shared = _dereq_('../internals/shared-store');
  51601. var sharedKey = _dereq_('../internals/shared-key');
  51602. var hiddenKeys = _dereq_('../internals/hidden-keys');
  51603. var OBJECT_ALREADY_INITIALIZED = 'Object already initialized';
  51604. var TypeError = global.TypeError;
  51605. var WeakMap = global.WeakMap;
  51606. var set, get, has;
  51607. var enforce = function (it) {
  51608. return has(it) ? get(it) : set(it, {});
  51609. };
  51610. var getterFor = function (TYPE) {
  51611. return function (it) {
  51612. var state;
  51613. if (!isObject(it) || (state = get(it)).type !== TYPE) {
  51614. throw TypeError('Incompatible receiver, ' + TYPE + ' required');
  51615. } return state;
  51616. };
  51617. };
  51618. if (NATIVE_WEAK_MAP || shared.state) {
  51619. var store = shared.state || (shared.state = new WeakMap());
  51620. var wmget = uncurryThis(store.get);
  51621. var wmhas = uncurryThis(store.has);
  51622. var wmset = uncurryThis(store.set);
  51623. set = function (it, metadata) {
  51624. if (wmhas(store, it)) throw new TypeError(OBJECT_ALREADY_INITIALIZED);
  51625. metadata.facade = it;
  51626. wmset(store, it, metadata);
  51627. return metadata;
  51628. };
  51629. get = function (it) {
  51630. return wmget(store, it) || {};
  51631. };
  51632. has = function (it) {
  51633. return wmhas(store, it);
  51634. };
  51635. } else {
  51636. var STATE = sharedKey('state');
  51637. hiddenKeys[STATE] = true;
  51638. set = function (it, metadata) {
  51639. if (hasOwn(it, STATE)) throw new TypeError(OBJECT_ALREADY_INITIALIZED);
  51640. metadata.facade = it;
  51641. createNonEnumerableProperty(it, STATE, metadata);
  51642. return metadata;
  51643. };
  51644. get = function (it) {
  51645. return hasOwn(it, STATE) ? it[STATE] : {};
  51646. };
  51647. has = function (it) {
  51648. return hasOwn(it, STATE);
  51649. };
  51650. }
  51651. module.exports = {
  51652. set: set,
  51653. get: get,
  51654. has: has,
  51655. enforce: enforce,
  51656. getterFor: getterFor
  51657. };
  51658. },{"../internals/create-non-enumerable-property":455,"../internals/function-uncurry-this":485,"../internals/global":491,"../internals/has-own-property":492,"../internals/hidden-keys":493,"../internals/is-object":509,"../internals/native-weak-map":524,"../internals/shared-key":559,"../internals/shared-store":560}],502:[function(_dereq_,module,exports){
  51659. var wellKnownSymbol = _dereq_('../internals/well-known-symbol');
  51660. var Iterators = _dereq_('../internals/iterators');
  51661. var ITERATOR = wellKnownSymbol('iterator');
  51662. var ArrayPrototype = Array.prototype;
  51663. // check on default Array iterator
  51664. module.exports = function (it) {
  51665. return it !== undefined && (Iterators.Array === it || ArrayPrototype[ITERATOR] === it);
  51666. };
  51667. },{"../internals/iterators":516,"../internals/well-known-symbol":586}],503:[function(_dereq_,module,exports){
  51668. var classof = _dereq_('../internals/classof-raw');
  51669. // `IsArray` abstract operation
  51670. // https://tc39.es/ecma262/#sec-isarray
  51671. // eslint-disable-next-line es/no-array-isarray -- safe
  51672. module.exports = Array.isArray || function isArray(argument) {
  51673. return classof(argument) == 'Array';
  51674. };
  51675. },{"../internals/classof-raw":442}],504:[function(_dereq_,module,exports){
  51676. // `IsCallable` abstract operation
  51677. // https://tc39.es/ecma262/#sec-iscallable
  51678. module.exports = function (argument) {
  51679. return typeof argument == 'function';
  51680. };
  51681. },{}],505:[function(_dereq_,module,exports){
  51682. var uncurryThis = _dereq_('../internals/function-uncurry-this');
  51683. var fails = _dereq_('../internals/fails');
  51684. var isCallable = _dereq_('../internals/is-callable');
  51685. var classof = _dereq_('../internals/classof');
  51686. var getBuiltIn = _dereq_('../internals/get-built-in');
  51687. var inspectSource = _dereq_('../internals/inspect-source');
  51688. var noop = function () { /* empty */ };
  51689. var empty = [];
  51690. var construct = getBuiltIn('Reflect', 'construct');
  51691. var constructorRegExp = /^\s*(?:class|function)\b/;
  51692. var exec = uncurryThis(constructorRegExp.exec);
  51693. var INCORRECT_TO_STRING = !constructorRegExp.exec(noop);
  51694. var isConstructorModern = function isConstructor(argument) {
  51695. if (!isCallable(argument)) return false;
  51696. try {
  51697. construct(noop, empty, argument);
  51698. return true;
  51699. } catch (error) {
  51700. return false;
  51701. }
  51702. };
  51703. var isConstructorLegacy = function isConstructor(argument) {
  51704. if (!isCallable(argument)) return false;
  51705. switch (classof(argument)) {
  51706. case 'AsyncFunction':
  51707. case 'GeneratorFunction':
  51708. case 'AsyncGeneratorFunction': return false;
  51709. }
  51710. try {
  51711. // we can't check .prototype since constructors produced by .bind haven't it
  51712. // `Function#toString` throws on some built-it function in some legacy engines
  51713. // (for example, `DOMQuad` and similar in FF41-)
  51714. return INCORRECT_TO_STRING || !!exec(constructorRegExp, inspectSource(argument));
  51715. } catch (error) {
  51716. return true;
  51717. }
  51718. };
  51719. isConstructorLegacy.sham = true;
  51720. // `IsConstructor` abstract operation
  51721. // https://tc39.es/ecma262/#sec-isconstructor
  51722. module.exports = !construct || fails(function () {
  51723. var called;
  51724. return isConstructorModern(isConstructorModern.call)
  51725. || !isConstructorModern(Object)
  51726. || !isConstructorModern(function () { called = true; })
  51727. || called;
  51728. }) ? isConstructorLegacy : isConstructorModern;
  51729. },{"../internals/classof":443,"../internals/fails":477,"../internals/function-uncurry-this":485,"../internals/get-built-in":486,"../internals/inspect-source":498,"../internals/is-callable":504}],506:[function(_dereq_,module,exports){
  51730. var hasOwn = _dereq_('../internals/has-own-property');
  51731. module.exports = function (descriptor) {
  51732. return descriptor !== undefined && (hasOwn(descriptor, 'value') || hasOwn(descriptor, 'writable'));
  51733. };
  51734. },{"../internals/has-own-property":492}],507:[function(_dereq_,module,exports){
  51735. var fails = _dereq_('../internals/fails');
  51736. var isCallable = _dereq_('../internals/is-callable');
  51737. var replacement = /#|\.prototype\./;
  51738. var isForced = function (feature, detection) {
  51739. var value = data[normalize(feature)];
  51740. return value == POLYFILL ? true
  51741. : value == NATIVE ? false
  51742. : isCallable(detection) ? fails(detection)
  51743. : !!detection;
  51744. };
  51745. var normalize = isForced.normalize = function (string) {
  51746. return String(string).replace(replacement, '.').toLowerCase();
  51747. };
  51748. var data = isForced.data = {};
  51749. var NATIVE = isForced.NATIVE = 'N';
  51750. var POLYFILL = isForced.POLYFILL = 'P';
  51751. module.exports = isForced;
  51752. },{"../internals/fails":477,"../internals/is-callable":504}],508:[function(_dereq_,module,exports){
  51753. var isObject = _dereq_('../internals/is-object');
  51754. var floor = Math.floor;
  51755. // `IsIntegralNumber` abstract operation
  51756. // https://tc39.es/ecma262/#sec-isintegralnumber
  51757. // eslint-disable-next-line es/no-number-isinteger -- safe
  51758. module.exports = Number.isInteger || function isInteger(it) {
  51759. return !isObject(it) && isFinite(it) && floor(it) === it;
  51760. };
  51761. },{"../internals/is-object":509}],509:[function(_dereq_,module,exports){
  51762. var isCallable = _dereq_('../internals/is-callable');
  51763. module.exports = function (it) {
  51764. return typeof it == 'object' ? it !== null : isCallable(it);
  51765. };
  51766. },{"../internals/is-callable":504}],510:[function(_dereq_,module,exports){
  51767. module.exports = true;
  51768. },{}],511:[function(_dereq_,module,exports){
  51769. var isObject = _dereq_('../internals/is-object');
  51770. var classof = _dereq_('../internals/classof-raw');
  51771. var wellKnownSymbol = _dereq_('../internals/well-known-symbol');
  51772. var MATCH = wellKnownSymbol('match');
  51773. // `IsRegExp` abstract operation
  51774. // https://tc39.es/ecma262/#sec-isregexp
  51775. module.exports = function (it) {
  51776. var isRegExp;
  51777. return isObject(it) && ((isRegExp = it[MATCH]) !== undefined ? !!isRegExp : classof(it) == 'RegExp');
  51778. };
  51779. },{"../internals/classof-raw":442,"../internals/is-object":509,"../internals/well-known-symbol":586}],512:[function(_dereq_,module,exports){
  51780. var global = _dereq_('../internals/global');
  51781. var getBuiltIn = _dereq_('../internals/get-built-in');
  51782. var isCallable = _dereq_('../internals/is-callable');
  51783. var isPrototypeOf = _dereq_('../internals/object-is-prototype-of');
  51784. var USE_SYMBOL_AS_UID = _dereq_('../internals/use-symbol-as-uid');
  51785. var Object = global.Object;
  51786. module.exports = USE_SYMBOL_AS_UID ? function (it) {
  51787. return typeof it == 'symbol';
  51788. } : function (it) {
  51789. var $Symbol = getBuiltIn('Symbol');
  51790. return isCallable($Symbol) && isPrototypeOf($Symbol.prototype, Object(it));
  51791. };
  51792. },{"../internals/get-built-in":486,"../internals/global":491,"../internals/is-callable":504,"../internals/object-is-prototype-of":539,"../internals/use-symbol-as-uid":582}],513:[function(_dereq_,module,exports){
  51793. var global = _dereq_('../internals/global');
  51794. var bind = _dereq_('../internals/function-bind-context');
  51795. var call = _dereq_('../internals/function-call');
  51796. var anObject = _dereq_('../internals/an-object');
  51797. var tryToString = _dereq_('../internals/try-to-string');
  51798. var isArrayIteratorMethod = _dereq_('../internals/is-array-iterator-method');
  51799. var lengthOfArrayLike = _dereq_('../internals/length-of-array-like');
  51800. var isPrototypeOf = _dereq_('../internals/object-is-prototype-of');
  51801. var getIterator = _dereq_('../internals/get-iterator');
  51802. var getIteratorMethod = _dereq_('../internals/get-iterator-method');
  51803. var iteratorClose = _dereq_('../internals/iterator-close');
  51804. var TypeError = global.TypeError;
  51805. var Result = function (stopped, result) {
  51806. this.stopped = stopped;
  51807. this.result = result;
  51808. };
  51809. var ResultPrototype = Result.prototype;
  51810. module.exports = function (iterable, unboundFunction, options) {
  51811. var that = options && options.that;
  51812. var AS_ENTRIES = !!(options && options.AS_ENTRIES);
  51813. var IS_ITERATOR = !!(options && options.IS_ITERATOR);
  51814. var INTERRUPTED = !!(options && options.INTERRUPTED);
  51815. var fn = bind(unboundFunction, that);
  51816. var iterator, iterFn, index, length, result, next, step;
  51817. var stop = function (condition) {
  51818. if (iterator) iteratorClose(iterator, 'normal', condition);
  51819. return new Result(true, condition);
  51820. };
  51821. var callFn = function (value) {
  51822. if (AS_ENTRIES) {
  51823. anObject(value);
  51824. return INTERRUPTED ? fn(value[0], value[1], stop) : fn(value[0], value[1]);
  51825. } return INTERRUPTED ? fn(value, stop) : fn(value);
  51826. };
  51827. if (IS_ITERATOR) {
  51828. iterator = iterable;
  51829. } else {
  51830. iterFn = getIteratorMethod(iterable);
  51831. if (!iterFn) throw TypeError(tryToString(iterable) + ' is not iterable');
  51832. // optimisation for array iterators
  51833. if (isArrayIteratorMethod(iterFn)) {
  51834. for (index = 0, length = lengthOfArrayLike(iterable); length > index; index++) {
  51835. result = callFn(iterable[index]);
  51836. if (result && isPrototypeOf(ResultPrototype, result)) return result;
  51837. } return new Result(false);
  51838. }
  51839. iterator = getIterator(iterable, iterFn);
  51840. }
  51841. next = iterator.next;
  51842. while (!(step = call(next, iterator)).done) {
  51843. try {
  51844. result = callFn(step.value);
  51845. } catch (error) {
  51846. iteratorClose(iterator, 'throw', error);
  51847. }
  51848. if (typeof result == 'object' && result && isPrototypeOf(ResultPrototype, result)) return result;
  51849. } return new Result(false);
  51850. };
  51851. },{"../internals/an-object":426,"../internals/function-bind-context":480,"../internals/function-call":483,"../internals/get-iterator":488,"../internals/get-iterator-method":487,"../internals/global":491,"../internals/is-array-iterator-method":502,"../internals/iterator-close":514,"../internals/length-of-array-like":517,"../internals/object-is-prototype-of":539,"../internals/try-to-string":580}],514:[function(_dereq_,module,exports){
  51852. var call = _dereq_('../internals/function-call');
  51853. var anObject = _dereq_('../internals/an-object');
  51854. var getMethod = _dereq_('../internals/get-method');
  51855. module.exports = function (iterator, kind, value) {
  51856. var innerResult, innerError;
  51857. anObject(iterator);
  51858. try {
  51859. innerResult = getMethod(iterator, 'return');
  51860. if (!innerResult) {
  51861. if (kind === 'throw') throw value;
  51862. return value;
  51863. }
  51864. innerResult = call(innerResult, iterator);
  51865. } catch (error) {
  51866. innerError = true;
  51867. innerResult = error;
  51868. }
  51869. if (kind === 'throw') throw value;
  51870. if (innerError) throw innerResult;
  51871. anObject(innerResult);
  51872. return value;
  51873. };
  51874. },{"../internals/an-object":426,"../internals/function-call":483,"../internals/get-method":490}],515:[function(_dereq_,module,exports){
  51875. 'use strict';
  51876. var fails = _dereq_('../internals/fails');
  51877. var isCallable = _dereq_('../internals/is-callable');
  51878. var create = _dereq_('../internals/object-create');
  51879. var getPrototypeOf = _dereq_('../internals/object-get-prototype-of');
  51880. var redefine = _dereq_('../internals/redefine');
  51881. var wellKnownSymbol = _dereq_('../internals/well-known-symbol');
  51882. var IS_PURE = _dereq_('../internals/is-pure');
  51883. var ITERATOR = wellKnownSymbol('iterator');
  51884. var BUGGY_SAFARI_ITERATORS = false;
  51885. // `%IteratorPrototype%` object
  51886. // https://tc39.es/ecma262/#sec-%iteratorprototype%-object
  51887. var IteratorPrototype, PrototypeOfArrayIteratorPrototype, arrayIterator;
  51888. /* eslint-disable es/no-array-prototype-keys -- safe */
  51889. if ([].keys) {
  51890. arrayIterator = [].keys();
  51891. // Safari 8 has buggy iterators w/o `next`
  51892. if (!('next' in arrayIterator)) BUGGY_SAFARI_ITERATORS = true;
  51893. else {
  51894. PrototypeOfArrayIteratorPrototype = getPrototypeOf(getPrototypeOf(arrayIterator));
  51895. if (PrototypeOfArrayIteratorPrototype !== Object.prototype) IteratorPrototype = PrototypeOfArrayIteratorPrototype;
  51896. }
  51897. }
  51898. var NEW_ITERATOR_PROTOTYPE = IteratorPrototype == undefined || fails(function () {
  51899. var test = {};
  51900. // FF44- legacy iterators case
  51901. return IteratorPrototype[ITERATOR].call(test) !== test;
  51902. });
  51903. if (NEW_ITERATOR_PROTOTYPE) IteratorPrototype = {};
  51904. else if (IS_PURE) IteratorPrototype = create(IteratorPrototype);
  51905. // `%IteratorPrototype%[@@iterator]()` method
  51906. // https://tc39.es/ecma262/#sec-%iteratorprototype%-@@iterator
  51907. if (!isCallable(IteratorPrototype[ITERATOR])) {
  51908. redefine(IteratorPrototype, ITERATOR, function () {
  51909. return this;
  51910. });
  51911. }
  51912. module.exports = {
  51913. IteratorPrototype: IteratorPrototype,
  51914. BUGGY_SAFARI_ITERATORS: BUGGY_SAFARI_ITERATORS
  51915. };
  51916. },{"../internals/fails":477,"../internals/is-callable":504,"../internals/is-pure":510,"../internals/object-create":530,"../internals/object-get-prototype-of":537,"../internals/redefine":553,"../internals/well-known-symbol":586}],516:[function(_dereq_,module,exports){
  51917. arguments[4][493][0].apply(exports,arguments)
  51918. },{"dup":493}],517:[function(_dereq_,module,exports){
  51919. var toLength = _dereq_('../internals/to-length');
  51920. // `LengthOfArrayLike` abstract operation
  51921. // https://tc39.es/ecma262/#sec-lengthofarraylike
  51922. module.exports = function (obj) {
  51923. return toLength(obj.length);
  51924. };
  51925. },{"../internals/to-length":574}],518:[function(_dereq_,module,exports){
  51926. 'use strict';
  51927. var call = _dereq_('../internals/function-call');
  51928. var aCallable = _dereq_('../internals/a-callable');
  51929. var anObject = _dereq_('../internals/an-object');
  51930. // `Map.prototype.emplace` method
  51931. // https://github.com/thumbsupep/proposal-upsert
  51932. module.exports = function emplace(key, handler) {
  51933. var map = anObject(this);
  51934. var get = aCallable(map.get);
  51935. var has = aCallable(map.has);
  51936. var set = aCallable(map.set);
  51937. var value = (call(has, map, key) && 'update' in handler)
  51938. ? handler.update(call(get, map, key), key, map)
  51939. : handler.insert(key, map);
  51940. call(set, map, key, value);
  51941. return value;
  51942. };
  51943. },{"../internals/a-callable":421,"../internals/an-object":426,"../internals/function-call":483}],519:[function(_dereq_,module,exports){
  51944. 'use strict';
  51945. var global = _dereq_('../internals/global');
  51946. var call = _dereq_('../internals/function-call');
  51947. var aCallable = _dereq_('../internals/a-callable');
  51948. var isCallable = _dereq_('../internals/is-callable');
  51949. var anObject = _dereq_('../internals/an-object');
  51950. var TypeError = global.TypeError;
  51951. // `Map.prototype.upsert` method
  51952. // https://github.com/thumbsupep/proposal-upsert
  51953. module.exports = function upsert(key, updateFn /* , insertFn */) {
  51954. var map = anObject(this);
  51955. var get = aCallable(map.get);
  51956. var has = aCallable(map.has);
  51957. var set = aCallable(map.set);
  51958. var insertFn = arguments.length > 2 ? arguments[2] : undefined;
  51959. var value;
  51960. if (!isCallable(updateFn) && !isCallable(insertFn)) {
  51961. throw TypeError('At least one callback required');
  51962. }
  51963. if (call(has, map, key)) {
  51964. value = call(get, map, key);
  51965. if (isCallable(updateFn)) {
  51966. value = updateFn(value);
  51967. call(set, map, key, value);
  51968. }
  51969. } else if (isCallable(insertFn)) {
  51970. value = insertFn();
  51971. call(set, map, key, value);
  51972. } return value;
  51973. };
  51974. },{"../internals/a-callable":421,"../internals/an-object":426,"../internals/function-call":483,"../internals/global":491,"../internals/is-callable":504}],520:[function(_dereq_,module,exports){
  51975. var global = _dereq_('../internals/global');
  51976. var bind = _dereq_('../internals/function-bind-context');
  51977. var getOwnPropertyDescriptor = _dereq_('../internals/object-get-own-property-descriptor').f;
  51978. var macrotask = _dereq_('../internals/task').set;
  51979. var IS_IOS = _dereq_('../internals/engine-is-ios');
  51980. var IS_IOS_PEBBLE = _dereq_('../internals/engine-is-ios-pebble');
  51981. var IS_WEBOS_WEBKIT = _dereq_('../internals/engine-is-webos-webkit');
  51982. var IS_NODE = _dereq_('../internals/engine-is-node');
  51983. var MutationObserver = global.MutationObserver || global.WebKitMutationObserver;
  51984. var document = global.document;
  51985. var process = global.process;
  51986. var Promise = global.Promise;
  51987. // Node.js 11 shows ExperimentalWarning on getting `queueMicrotask`
  51988. var queueMicrotaskDescriptor = getOwnPropertyDescriptor(global, 'queueMicrotask');
  51989. var queueMicrotask = queueMicrotaskDescriptor && queueMicrotaskDescriptor.value;
  51990. var flush, head, last, notify, toggle, node, promise, then;
  51991. // modern engines have queueMicrotask method
  51992. if (!queueMicrotask) {
  51993. flush = function () {
  51994. var parent, fn;
  51995. if (IS_NODE && (parent = process.domain)) parent.exit();
  51996. while (head) {
  51997. fn = head.fn;
  51998. head = head.next;
  51999. try {
  52000. fn();
  52001. } catch (error) {
  52002. if (head) notify();
  52003. else last = undefined;
  52004. throw error;
  52005. }
  52006. } last = undefined;
  52007. if (parent) parent.enter();
  52008. };
  52009. // browsers with MutationObserver, except iOS - https://github.com/zloirock/core-js/issues/339
  52010. // also except WebOS Webkit https://github.com/zloirock/core-js/issues/898
  52011. if (!IS_IOS && !IS_NODE && !IS_WEBOS_WEBKIT && MutationObserver && document) {
  52012. toggle = true;
  52013. node = document.createTextNode('');
  52014. new MutationObserver(flush).observe(node, { characterData: true });
  52015. notify = function () {
  52016. node.data = toggle = !toggle;
  52017. };
  52018. // environments with maybe non-completely correct, but existent Promise
  52019. } else if (!IS_IOS_PEBBLE && Promise && Promise.resolve) {
  52020. // Promise.resolve without an argument throws an error in LG WebOS 2
  52021. promise = Promise.resolve(undefined);
  52022. // workaround of WebKit ~ iOS Safari 10.1 bug
  52023. promise.constructor = Promise;
  52024. then = bind(promise.then, promise);
  52025. notify = function () {
  52026. then(flush);
  52027. };
  52028. // Node.js without promises
  52029. } else if (IS_NODE) {
  52030. notify = function () {
  52031. process.nextTick(flush);
  52032. };
  52033. // for other environments - macrotask based on:
  52034. // - setImmediate
  52035. // - MessageChannel
  52036. // - window.postMessag
  52037. // - onreadystatechange
  52038. // - setTimeout
  52039. } else {
  52040. // strange IE + webpack dev server bug - use .bind(global)
  52041. macrotask = bind(macrotask, global);
  52042. notify = function () {
  52043. macrotask(flush);
  52044. };
  52045. }
  52046. }
  52047. module.exports = queueMicrotask || function (fn) {
  52048. var task = { fn: fn, next: undefined };
  52049. if (last) last.next = task;
  52050. if (!head) {
  52051. head = task;
  52052. notify();
  52053. } last = task;
  52054. };
  52055. },{"../internals/engine-is-ios":467,"../internals/engine-is-ios-pebble":466,"../internals/engine-is-node":468,"../internals/engine-is-webos-webkit":469,"../internals/function-bind-context":480,"../internals/global":491,"../internals/object-get-own-property-descriptor":533,"../internals/task":570}],521:[function(_dereq_,module,exports){
  52056. var global = _dereq_('../internals/global');
  52057. module.exports = global.Promise;
  52058. },{"../internals/global":491}],522:[function(_dereq_,module,exports){
  52059. /* eslint-disable es/no-symbol -- required for testing */
  52060. var V8_VERSION = _dereq_('../internals/engine-v8-version');
  52061. var fails = _dereq_('../internals/fails');
  52062. // eslint-disable-next-line es/no-object-getownpropertysymbols -- required for testing
  52063. module.exports = !!Object.getOwnPropertySymbols && !fails(function () {
  52064. var symbol = Symbol();
  52065. // Chrome 38 Symbol has incorrect toString conversion
  52066. // `get-own-property-symbols` polyfill symbols converted to object are not Symbol instances
  52067. return !String(symbol) || !(Object(symbol) instanceof Symbol) ||
  52068. // Chrome 38-40 symbols are not inherited from DOM collections prototypes to instances
  52069. !Symbol.sham && V8_VERSION && V8_VERSION < 41;
  52070. });
  52071. },{"../internals/engine-v8-version":471,"../internals/fails":477}],523:[function(_dereq_,module,exports){
  52072. var fails = _dereq_('../internals/fails');
  52073. var wellKnownSymbol = _dereq_('../internals/well-known-symbol');
  52074. var IS_PURE = _dereq_('../internals/is-pure');
  52075. var ITERATOR = wellKnownSymbol('iterator');
  52076. module.exports = !fails(function () {
  52077. // eslint-disable-next-line unicorn/relative-url-style -- required for testing
  52078. var url = new URL('b?a=1&b=2&c=3', 'http://a');
  52079. var searchParams = url.searchParams;
  52080. var result = '';
  52081. url.pathname = 'c%20d';
  52082. searchParams.forEach(function (value, key) {
  52083. searchParams['delete']('b');
  52084. result += key + value;
  52085. });
  52086. return (IS_PURE && !url.toJSON)
  52087. || !searchParams.sort
  52088. || url.href !== 'http://a/c%20d?a=1&c=3'
  52089. || searchParams.get('c') !== '3'
  52090. || String(new URLSearchParams('?a=1')) !== 'a=1'
  52091. || !searchParams[ITERATOR]
  52092. // throws in Edge
  52093. || new URL('https://a@b').username !== 'a'
  52094. || new URLSearchParams(new URLSearchParams('a=b')).get('a') !== 'b'
  52095. // not punycoded in Edge
  52096. || new URL('http://тест').host !== 'xn--e1aybc'
  52097. // not escaped in Chrome 62-
  52098. || new URL('http://a#б').hash !== '#%D0%B1'
  52099. // fails in Chrome 66-
  52100. || result !== 'a1c3'
  52101. // throws in Safari
  52102. || new URL('http://x', undefined).host !== 'x';
  52103. });
  52104. },{"../internals/fails":477,"../internals/is-pure":510,"../internals/well-known-symbol":586}],524:[function(_dereq_,module,exports){
  52105. var global = _dereq_('../internals/global');
  52106. var isCallable = _dereq_('../internals/is-callable');
  52107. var inspectSource = _dereq_('../internals/inspect-source');
  52108. var WeakMap = global.WeakMap;
  52109. module.exports = isCallable(WeakMap) && /native code/.test(inspectSource(WeakMap));
  52110. },{"../internals/global":491,"../internals/inspect-source":498,"../internals/is-callable":504}],525:[function(_dereq_,module,exports){
  52111. 'use strict';
  52112. var aCallable = _dereq_('../internals/a-callable');
  52113. var PromiseCapability = function (C) {
  52114. var resolve, reject;
  52115. this.promise = new C(function ($$resolve, $$reject) {
  52116. if (resolve !== undefined || reject !== undefined) throw TypeError('Bad Promise constructor');
  52117. resolve = $$resolve;
  52118. reject = $$reject;
  52119. });
  52120. this.resolve = aCallable(resolve);
  52121. this.reject = aCallable(reject);
  52122. };
  52123. // `NewPromiseCapability` abstract operation
  52124. // https://tc39.es/ecma262/#sec-newpromisecapability
  52125. module.exports.f = function (C) {
  52126. return new PromiseCapability(C);
  52127. };
  52128. },{"../internals/a-callable":421}],526:[function(_dereq_,module,exports){
  52129. var toString = _dereq_('../internals/to-string');
  52130. module.exports = function (argument, $default) {
  52131. return argument === undefined ? arguments.length < 2 ? '' : $default : toString(argument);
  52132. };
  52133. },{"../internals/to-string":579}],527:[function(_dereq_,module,exports){
  52134. var global = _dereq_('../internals/global');
  52135. var isRegExp = _dereq_('../internals/is-regexp');
  52136. var TypeError = global.TypeError;
  52137. module.exports = function (it) {
  52138. if (isRegExp(it)) {
  52139. throw TypeError("The method doesn't accept regular expressions");
  52140. } return it;
  52141. };
  52142. },{"../internals/global":491,"../internals/is-regexp":511}],528:[function(_dereq_,module,exports){
  52143. var global = _dereq_('../internals/global');
  52144. var fails = _dereq_('../internals/fails');
  52145. var uncurryThis = _dereq_('../internals/function-uncurry-this');
  52146. var toString = _dereq_('../internals/to-string');
  52147. var trim = _dereq_('../internals/string-trim').trim;
  52148. var whitespaces = _dereq_('../internals/whitespaces');
  52149. var $parseInt = global.parseInt;
  52150. var Symbol = global.Symbol;
  52151. var ITERATOR = Symbol && Symbol.iterator;
  52152. var hex = /^[+-]?0x/i;
  52153. var exec = uncurryThis(hex.exec);
  52154. var FORCED = $parseInt(whitespaces + '08') !== 8 || $parseInt(whitespaces + '0x16') !== 22
  52155. // MS Edge 18- broken with boxed symbols
  52156. || (ITERATOR && !fails(function () { $parseInt(Object(ITERATOR)); }));
  52157. // `parseInt` method
  52158. // https://tc39.es/ecma262/#sec-parseint-string-radix
  52159. module.exports = FORCED ? function parseInt(string, radix) {
  52160. var S = trim(toString(string));
  52161. return $parseInt(S, (radix >>> 0) || (exec(hex, S) ? 16 : 10));
  52162. } : $parseInt;
  52163. },{"../internals/fails":477,"../internals/function-uncurry-this":485,"../internals/global":491,"../internals/string-trim":569,"../internals/to-string":579,"../internals/whitespaces":587}],529:[function(_dereq_,module,exports){
  52164. 'use strict';
  52165. var DESCRIPTORS = _dereq_('../internals/descriptors');
  52166. var uncurryThis = _dereq_('../internals/function-uncurry-this');
  52167. var call = _dereq_('../internals/function-call');
  52168. var fails = _dereq_('../internals/fails');
  52169. var objectKeys = _dereq_('../internals/object-keys');
  52170. var getOwnPropertySymbolsModule = _dereq_('../internals/object-get-own-property-symbols');
  52171. var propertyIsEnumerableModule = _dereq_('../internals/object-property-is-enumerable');
  52172. var toObject = _dereq_('../internals/to-object');
  52173. var IndexedObject = _dereq_('../internals/indexed-object');
  52174. // eslint-disable-next-line es/no-object-assign -- safe
  52175. var $assign = Object.assign;
  52176. // eslint-disable-next-line es/no-object-defineproperty -- required for testing
  52177. var defineProperty = Object.defineProperty;
  52178. var concat = uncurryThis([].concat);
  52179. // `Object.assign` method
  52180. // https://tc39.es/ecma262/#sec-object.assign
  52181. module.exports = !$assign || fails(function () {
  52182. // should have correct order of operations (Edge bug)
  52183. if (DESCRIPTORS && $assign({ b: 1 }, $assign(defineProperty({}, 'a', {
  52184. enumerable: true,
  52185. get: function () {
  52186. defineProperty(this, 'b', {
  52187. value: 3,
  52188. enumerable: false
  52189. });
  52190. }
  52191. }), { b: 2 })).b !== 1) return true;
  52192. // should work with symbols and should have deterministic property order (V8 bug)
  52193. var A = {};
  52194. var B = {};
  52195. // eslint-disable-next-line es/no-symbol -- safe
  52196. var symbol = Symbol();
  52197. var alphabet = 'abcdefghijklmnopqrst';
  52198. A[symbol] = 7;
  52199. alphabet.split('').forEach(function (chr) { B[chr] = chr; });
  52200. return $assign({}, A)[symbol] != 7 || objectKeys($assign({}, B)).join('') != alphabet;
  52201. }) ? function assign(target, source) { // eslint-disable-line no-unused-vars -- required for `.length`
  52202. var T = toObject(target);
  52203. var argumentsLength = arguments.length;
  52204. var index = 1;
  52205. var getOwnPropertySymbols = getOwnPropertySymbolsModule.f;
  52206. var propertyIsEnumerable = propertyIsEnumerableModule.f;
  52207. while (argumentsLength > index) {
  52208. var S = IndexedObject(arguments[index++]);
  52209. var keys = getOwnPropertySymbols ? concat(objectKeys(S), getOwnPropertySymbols(S)) : objectKeys(S);
  52210. var length = keys.length;
  52211. var j = 0;
  52212. var key;
  52213. while (length > j) {
  52214. key = keys[j++];
  52215. if (!DESCRIPTORS || call(propertyIsEnumerable, S, key)) T[key] = S[key];
  52216. }
  52217. } return T;
  52218. } : $assign;
  52219. },{"../internals/descriptors":460,"../internals/fails":477,"../internals/function-call":483,"../internals/function-uncurry-this":485,"../internals/indexed-object":497,"../internals/object-get-own-property-symbols":536,"../internals/object-keys":541,"../internals/object-property-is-enumerable":542,"../internals/to-object":575}],530:[function(_dereq_,module,exports){
  52220. /* global ActiveXObject -- old IE, WSH */
  52221. var anObject = _dereq_('../internals/an-object');
  52222. var definePropertiesModule = _dereq_('../internals/object-define-properties');
  52223. var enumBugKeys = _dereq_('../internals/enum-bug-keys');
  52224. var hiddenKeys = _dereq_('../internals/hidden-keys');
  52225. var html = _dereq_('../internals/html');
  52226. var documentCreateElement = _dereq_('../internals/document-create-element');
  52227. var sharedKey = _dereq_('../internals/shared-key');
  52228. var GT = '>';
  52229. var LT = '<';
  52230. var PROTOTYPE = 'prototype';
  52231. var SCRIPT = 'script';
  52232. var IE_PROTO = sharedKey('IE_PROTO');
  52233. var EmptyConstructor = function () { /* empty */ };
  52234. var scriptTag = function (content) {
  52235. return LT + SCRIPT + GT + content + LT + '/' + SCRIPT + GT;
  52236. };
  52237. // Create object with fake `null` prototype: use ActiveX Object with cleared prototype
  52238. var NullProtoObjectViaActiveX = function (activeXDocument) {
  52239. activeXDocument.write(scriptTag(''));
  52240. activeXDocument.close();
  52241. var temp = activeXDocument.parentWindow.Object;
  52242. activeXDocument = null; // avoid memory leak
  52243. return temp;
  52244. };
  52245. // Create object with fake `null` prototype: use iframe Object with cleared prototype
  52246. var NullProtoObjectViaIFrame = function () {
  52247. // Thrash, waste and sodomy: IE GC bug
  52248. var iframe = documentCreateElement('iframe');
  52249. var JS = 'java' + SCRIPT + ':';
  52250. var iframeDocument;
  52251. iframe.style.display = 'none';
  52252. html.appendChild(iframe);
  52253. // https://github.com/zloirock/core-js/issues/475
  52254. iframe.src = String(JS);
  52255. iframeDocument = iframe.contentWindow.document;
  52256. iframeDocument.open();
  52257. iframeDocument.write(scriptTag('document.F=Object'));
  52258. iframeDocument.close();
  52259. return iframeDocument.F;
  52260. };
  52261. // Check for document.domain and active x support
  52262. // No need to use active x approach when document.domain is not set
  52263. // see https://github.com/es-shims/es5-shim/issues/150
  52264. // variation of https://github.com/kitcambridge/es5-shim/commit/4f738ac066346
  52265. // avoid IE GC bug
  52266. var activeXDocument;
  52267. var NullProtoObject = function () {
  52268. try {
  52269. activeXDocument = new ActiveXObject('htmlfile');
  52270. } catch (error) { /* ignore */ }
  52271. NullProtoObject = typeof document != 'undefined'
  52272. ? document.domain && activeXDocument
  52273. ? NullProtoObjectViaActiveX(activeXDocument) // old IE
  52274. : NullProtoObjectViaIFrame()
  52275. : NullProtoObjectViaActiveX(activeXDocument); // WSH
  52276. var length = enumBugKeys.length;
  52277. while (length--) delete NullProtoObject[PROTOTYPE][enumBugKeys[length]];
  52278. return NullProtoObject();
  52279. };
  52280. hiddenKeys[IE_PROTO] = true;
  52281. // `Object.create` method
  52282. // https://tc39.es/ecma262/#sec-object.create
  52283. module.exports = Object.create || function create(O, Properties) {
  52284. var result;
  52285. if (O !== null) {
  52286. EmptyConstructor[PROTOTYPE] = anObject(O);
  52287. result = new EmptyConstructor();
  52288. EmptyConstructor[PROTOTYPE] = null;
  52289. // add "__proto__" for Object.getPrototypeOf polyfill
  52290. result[IE_PROTO] = O;
  52291. } else result = NullProtoObject();
  52292. return Properties === undefined ? result : definePropertiesModule.f(result, Properties);
  52293. };
  52294. },{"../internals/an-object":426,"../internals/document-create-element":461,"../internals/enum-bug-keys":474,"../internals/hidden-keys":493,"../internals/html":495,"../internals/object-define-properties":531,"../internals/shared-key":559}],531:[function(_dereq_,module,exports){
  52295. var DESCRIPTORS = _dereq_('../internals/descriptors');
  52296. var V8_PROTOTYPE_DEFINE_BUG = _dereq_('../internals/v8-prototype-define-bug');
  52297. var definePropertyModule = _dereq_('../internals/object-define-property');
  52298. var anObject = _dereq_('../internals/an-object');
  52299. var toIndexedObject = _dereq_('../internals/to-indexed-object');
  52300. var objectKeys = _dereq_('../internals/object-keys');
  52301. // `Object.defineProperties` method
  52302. // https://tc39.es/ecma262/#sec-object.defineproperties
  52303. // eslint-disable-next-line es/no-object-defineproperties -- safe
  52304. exports.f = DESCRIPTORS && !V8_PROTOTYPE_DEFINE_BUG ? Object.defineProperties : function defineProperties(O, Properties) {
  52305. anObject(O);
  52306. var props = toIndexedObject(Properties);
  52307. var keys = objectKeys(Properties);
  52308. var length = keys.length;
  52309. var index = 0;
  52310. var key;
  52311. while (length > index) definePropertyModule.f(O, key = keys[index++], props[key]);
  52312. return O;
  52313. };
  52314. },{"../internals/an-object":426,"../internals/descriptors":460,"../internals/object-define-property":532,"../internals/object-keys":541,"../internals/to-indexed-object":572,"../internals/v8-prototype-define-bug":583}],532:[function(_dereq_,module,exports){
  52315. var global = _dereq_('../internals/global');
  52316. var DESCRIPTORS = _dereq_('../internals/descriptors');
  52317. var IE8_DOM_DEFINE = _dereq_('../internals/ie8-dom-define');
  52318. var V8_PROTOTYPE_DEFINE_BUG = _dereq_('../internals/v8-prototype-define-bug');
  52319. var anObject = _dereq_('../internals/an-object');
  52320. var toPropertyKey = _dereq_('../internals/to-property-key');
  52321. var TypeError = global.TypeError;
  52322. // eslint-disable-next-line es/no-object-defineproperty -- safe
  52323. var $defineProperty = Object.defineProperty;
  52324. // eslint-disable-next-line es/no-object-getownpropertydescriptor -- safe
  52325. var $getOwnPropertyDescriptor = Object.getOwnPropertyDescriptor;
  52326. var ENUMERABLE = 'enumerable';
  52327. var CONFIGURABLE = 'configurable';
  52328. var WRITABLE = 'writable';
  52329. // `Object.defineProperty` method
  52330. // https://tc39.es/ecma262/#sec-object.defineproperty
  52331. exports.f = DESCRIPTORS ? V8_PROTOTYPE_DEFINE_BUG ? function defineProperty(O, P, Attributes) {
  52332. anObject(O);
  52333. P = toPropertyKey(P);
  52334. anObject(Attributes);
  52335. if (typeof O === 'function' && P === 'prototype' && 'value' in Attributes && WRITABLE in Attributes && !Attributes[WRITABLE]) {
  52336. var current = $getOwnPropertyDescriptor(O, P);
  52337. if (current && current[WRITABLE]) {
  52338. O[P] = Attributes.value;
  52339. Attributes = {
  52340. configurable: CONFIGURABLE in Attributes ? Attributes[CONFIGURABLE] : current[CONFIGURABLE],
  52341. enumerable: ENUMERABLE in Attributes ? Attributes[ENUMERABLE] : current[ENUMERABLE],
  52342. writable: false
  52343. };
  52344. }
  52345. } return $defineProperty(O, P, Attributes);
  52346. } : $defineProperty : function defineProperty(O, P, Attributes) {
  52347. anObject(O);
  52348. P = toPropertyKey(P);
  52349. anObject(Attributes);
  52350. if (IE8_DOM_DEFINE) try {
  52351. return $defineProperty(O, P, Attributes);
  52352. } catch (error) { /* empty */ }
  52353. if ('get' in Attributes || 'set' in Attributes) throw TypeError('Accessors not supported');
  52354. if ('value' in Attributes) O[P] = Attributes.value;
  52355. return O;
  52356. };
  52357. },{"../internals/an-object":426,"../internals/descriptors":460,"../internals/global":491,"../internals/ie8-dom-define":496,"../internals/to-property-key":577,"../internals/v8-prototype-define-bug":583}],533:[function(_dereq_,module,exports){
  52358. var DESCRIPTORS = _dereq_('../internals/descriptors');
  52359. var call = _dereq_('../internals/function-call');
  52360. var propertyIsEnumerableModule = _dereq_('../internals/object-property-is-enumerable');
  52361. var createPropertyDescriptor = _dereq_('../internals/create-property-descriptor');
  52362. var toIndexedObject = _dereq_('../internals/to-indexed-object');
  52363. var toPropertyKey = _dereq_('../internals/to-property-key');
  52364. var hasOwn = _dereq_('../internals/has-own-property');
  52365. var IE8_DOM_DEFINE = _dereq_('../internals/ie8-dom-define');
  52366. // eslint-disable-next-line es/no-object-getownpropertydescriptor -- safe
  52367. var $getOwnPropertyDescriptor = Object.getOwnPropertyDescriptor;
  52368. // `Object.getOwnPropertyDescriptor` method
  52369. // https://tc39.es/ecma262/#sec-object.getownpropertydescriptor
  52370. exports.f = DESCRIPTORS ? $getOwnPropertyDescriptor : function getOwnPropertyDescriptor(O, P) {
  52371. O = toIndexedObject(O);
  52372. P = toPropertyKey(P);
  52373. if (IE8_DOM_DEFINE) try {
  52374. return $getOwnPropertyDescriptor(O, P);
  52375. } catch (error) { /* empty */ }
  52376. if (hasOwn(O, P)) return createPropertyDescriptor(!call(propertyIsEnumerableModule.f, O, P), O[P]);
  52377. };
  52378. },{"../internals/create-property-descriptor":456,"../internals/descriptors":460,"../internals/function-call":483,"../internals/has-own-property":492,"../internals/ie8-dom-define":496,"../internals/object-property-is-enumerable":542,"../internals/to-indexed-object":572,"../internals/to-property-key":577}],534:[function(_dereq_,module,exports){
  52379. /* eslint-disable es/no-object-getownpropertynames -- safe */
  52380. var classof = _dereq_('../internals/classof-raw');
  52381. var toIndexedObject = _dereq_('../internals/to-indexed-object');
  52382. var $getOwnPropertyNames = _dereq_('../internals/object-get-own-property-names').f;
  52383. var arraySlice = _dereq_('../internals/array-slice-simple');
  52384. var windowNames = typeof window == 'object' && window && Object.getOwnPropertyNames
  52385. ? Object.getOwnPropertyNames(window) : [];
  52386. var getWindowNames = function (it) {
  52387. try {
  52388. return $getOwnPropertyNames(it);
  52389. } catch (error) {
  52390. return arraySlice(windowNames);
  52391. }
  52392. };
  52393. // fallback for IE11 buggy Object.getOwnPropertyNames with iframe and window
  52394. module.exports.f = function getOwnPropertyNames(it) {
  52395. return windowNames && classof(it) == 'Window'
  52396. ? getWindowNames(it)
  52397. : $getOwnPropertyNames(toIndexedObject(it));
  52398. };
  52399. },{"../internals/array-slice-simple":435,"../internals/classof-raw":442,"../internals/object-get-own-property-names":535,"../internals/to-indexed-object":572}],535:[function(_dereq_,module,exports){
  52400. var internalObjectKeys = _dereq_('../internals/object-keys-internal');
  52401. var enumBugKeys = _dereq_('../internals/enum-bug-keys');
  52402. var hiddenKeys = enumBugKeys.concat('length', 'prototype');
  52403. // `Object.getOwnPropertyNames` method
  52404. // https://tc39.es/ecma262/#sec-object.getownpropertynames
  52405. // eslint-disable-next-line es/no-object-getownpropertynames -- safe
  52406. exports.f = Object.getOwnPropertyNames || function getOwnPropertyNames(O) {
  52407. return internalObjectKeys(O, hiddenKeys);
  52408. };
  52409. },{"../internals/enum-bug-keys":474,"../internals/object-keys-internal":540}],536:[function(_dereq_,module,exports){
  52410. // eslint-disable-next-line es/no-object-getownpropertysymbols -- safe
  52411. exports.f = Object.getOwnPropertySymbols;
  52412. },{}],537:[function(_dereq_,module,exports){
  52413. var global = _dereq_('../internals/global');
  52414. var hasOwn = _dereq_('../internals/has-own-property');
  52415. var isCallable = _dereq_('../internals/is-callable');
  52416. var toObject = _dereq_('../internals/to-object');
  52417. var sharedKey = _dereq_('../internals/shared-key');
  52418. var CORRECT_PROTOTYPE_GETTER = _dereq_('../internals/correct-prototype-getter');
  52419. var IE_PROTO = sharedKey('IE_PROTO');
  52420. var Object = global.Object;
  52421. var ObjectPrototype = Object.prototype;
  52422. // `Object.getPrototypeOf` method
  52423. // https://tc39.es/ecma262/#sec-object.getprototypeof
  52424. module.exports = CORRECT_PROTOTYPE_GETTER ? Object.getPrototypeOf : function (O) {
  52425. var object = toObject(O);
  52426. if (hasOwn(object, IE_PROTO)) return object[IE_PROTO];
  52427. var constructor = object.constructor;
  52428. if (isCallable(constructor) && object instanceof constructor) {
  52429. return constructor.prototype;
  52430. } return object instanceof Object ? ObjectPrototype : null;
  52431. };
  52432. },{"../internals/correct-prototype-getter":453,"../internals/global":491,"../internals/has-own-property":492,"../internals/is-callable":504,"../internals/shared-key":559,"../internals/to-object":575}],538:[function(_dereq_,module,exports){
  52433. var fails = _dereq_('../internals/fails');
  52434. var isObject = _dereq_('../internals/is-object');
  52435. var classof = _dereq_('../internals/classof-raw');
  52436. var ARRAY_BUFFER_NON_EXTENSIBLE = _dereq_('../internals/array-buffer-non-extensible');
  52437. // eslint-disable-next-line es/no-object-isextensible -- safe
  52438. var $isExtensible = Object.isExtensible;
  52439. var FAILS_ON_PRIMITIVES = fails(function () { $isExtensible(1); });
  52440. // `Object.isExtensible` method
  52441. // https://tc39.es/ecma262/#sec-object.isextensible
  52442. module.exports = (FAILS_ON_PRIMITIVES || ARRAY_BUFFER_NON_EXTENSIBLE) ? function isExtensible(it) {
  52443. if (!isObject(it)) return false;
  52444. if (ARRAY_BUFFER_NON_EXTENSIBLE && classof(it) == 'ArrayBuffer') return false;
  52445. return $isExtensible ? $isExtensible(it) : true;
  52446. } : $isExtensible;
  52447. },{"../internals/array-buffer-non-extensible":427,"../internals/classof-raw":442,"../internals/fails":477,"../internals/is-object":509}],539:[function(_dereq_,module,exports){
  52448. var uncurryThis = _dereq_('../internals/function-uncurry-this');
  52449. module.exports = uncurryThis({}.isPrototypeOf);
  52450. },{"../internals/function-uncurry-this":485}],540:[function(_dereq_,module,exports){
  52451. var uncurryThis = _dereq_('../internals/function-uncurry-this');
  52452. var hasOwn = _dereq_('../internals/has-own-property');
  52453. var toIndexedObject = _dereq_('../internals/to-indexed-object');
  52454. var indexOf = _dereq_('../internals/array-includes').indexOf;
  52455. var hiddenKeys = _dereq_('../internals/hidden-keys');
  52456. var push = uncurryThis([].push);
  52457. module.exports = function (object, names) {
  52458. var O = toIndexedObject(object);
  52459. var i = 0;
  52460. var result = [];
  52461. var key;
  52462. for (key in O) !hasOwn(hiddenKeys, key) && hasOwn(O, key) && push(result, key);
  52463. // Don't enum bug & hidden keys
  52464. while (names.length > i) if (hasOwn(O, key = names[i++])) {
  52465. ~indexOf(result, key) || push(result, key);
  52466. }
  52467. return result;
  52468. };
  52469. },{"../internals/array-includes":430,"../internals/function-uncurry-this":485,"../internals/has-own-property":492,"../internals/hidden-keys":493,"../internals/to-indexed-object":572}],541:[function(_dereq_,module,exports){
  52470. var internalObjectKeys = _dereq_('../internals/object-keys-internal');
  52471. var enumBugKeys = _dereq_('../internals/enum-bug-keys');
  52472. // `Object.keys` method
  52473. // https://tc39.es/ecma262/#sec-object.keys
  52474. // eslint-disable-next-line es/no-object-keys -- safe
  52475. module.exports = Object.keys || function keys(O) {
  52476. return internalObjectKeys(O, enumBugKeys);
  52477. };
  52478. },{"../internals/enum-bug-keys":474,"../internals/object-keys-internal":540}],542:[function(_dereq_,module,exports){
  52479. 'use strict';
  52480. var $propertyIsEnumerable = {}.propertyIsEnumerable;
  52481. // eslint-disable-next-line es/no-object-getownpropertydescriptor -- safe
  52482. var getOwnPropertyDescriptor = Object.getOwnPropertyDescriptor;
  52483. // Nashorn ~ JDK8 bug
  52484. var NASHORN_BUG = getOwnPropertyDescriptor && !$propertyIsEnumerable.call({ 1: 2 }, 1);
  52485. // `Object.prototype.propertyIsEnumerable` method implementation
  52486. // https://tc39.es/ecma262/#sec-object.prototype.propertyisenumerable
  52487. exports.f = NASHORN_BUG ? function propertyIsEnumerable(V) {
  52488. var descriptor = getOwnPropertyDescriptor(this, V);
  52489. return !!descriptor && descriptor.enumerable;
  52490. } : $propertyIsEnumerable;
  52491. },{}],543:[function(_dereq_,module,exports){
  52492. /* eslint-disable no-proto -- safe */
  52493. var uncurryThis = _dereq_('../internals/function-uncurry-this');
  52494. var anObject = _dereq_('../internals/an-object');
  52495. var aPossiblePrototype = _dereq_('../internals/a-possible-prototype');
  52496. // `Object.setPrototypeOf` method
  52497. // https://tc39.es/ecma262/#sec-object.setprototypeof
  52498. // Works with __proto__ only. Old v8 can't work with null proto objects.
  52499. // eslint-disable-next-line es/no-object-setprototypeof -- safe
  52500. module.exports = Object.setPrototypeOf || ('__proto__' in {} ? function () {
  52501. var CORRECT_SETTER = false;
  52502. var test = {};
  52503. var setter;
  52504. try {
  52505. // eslint-disable-next-line es/no-object-getownpropertydescriptor -- safe
  52506. setter = uncurryThis(Object.getOwnPropertyDescriptor(Object.prototype, '__proto__').set);
  52507. setter(test, []);
  52508. CORRECT_SETTER = test instanceof Array;
  52509. } catch (error) { /* empty */ }
  52510. return function setPrototypeOf(O, proto) {
  52511. anObject(O);
  52512. aPossiblePrototype(proto);
  52513. if (CORRECT_SETTER) setter(O, proto);
  52514. else O.__proto__ = proto;
  52515. return O;
  52516. };
  52517. }() : undefined);
  52518. },{"../internals/a-possible-prototype":423,"../internals/an-object":426,"../internals/function-uncurry-this":485}],544:[function(_dereq_,module,exports){
  52519. var DESCRIPTORS = _dereq_('../internals/descriptors');
  52520. var uncurryThis = _dereq_('../internals/function-uncurry-this');
  52521. var objectKeys = _dereq_('../internals/object-keys');
  52522. var toIndexedObject = _dereq_('../internals/to-indexed-object');
  52523. var $propertyIsEnumerable = _dereq_('../internals/object-property-is-enumerable').f;
  52524. var propertyIsEnumerable = uncurryThis($propertyIsEnumerable);
  52525. var push = uncurryThis([].push);
  52526. // `Object.{ entries, values }` methods implementation
  52527. var createMethod = function (TO_ENTRIES) {
  52528. return function (it) {
  52529. var O = toIndexedObject(it);
  52530. var keys = objectKeys(O);
  52531. var length = keys.length;
  52532. var i = 0;
  52533. var result = [];
  52534. var key;
  52535. while (length > i) {
  52536. key = keys[i++];
  52537. if (!DESCRIPTORS || propertyIsEnumerable(O, key)) {
  52538. push(result, TO_ENTRIES ? [key, O[key]] : O[key]);
  52539. }
  52540. }
  52541. return result;
  52542. };
  52543. };
  52544. module.exports = {
  52545. // `Object.entries` method
  52546. // https://tc39.es/ecma262/#sec-object.entries
  52547. entries: createMethod(true),
  52548. // `Object.values` method
  52549. // https://tc39.es/ecma262/#sec-object.values
  52550. values: createMethod(false)
  52551. };
  52552. },{"../internals/descriptors":460,"../internals/function-uncurry-this":485,"../internals/object-keys":541,"../internals/object-property-is-enumerable":542,"../internals/to-indexed-object":572}],545:[function(_dereq_,module,exports){
  52553. 'use strict';
  52554. var TO_STRING_TAG_SUPPORT = _dereq_('../internals/to-string-tag-support');
  52555. var classof = _dereq_('../internals/classof');
  52556. // `Object.prototype.toString` method implementation
  52557. // https://tc39.es/ecma262/#sec-object.prototype.tostring
  52558. module.exports = TO_STRING_TAG_SUPPORT ? {}.toString : function toString() {
  52559. return '[object ' + classof(this) + ']';
  52560. };
  52561. },{"../internals/classof":443,"../internals/to-string-tag-support":578}],546:[function(_dereq_,module,exports){
  52562. var global = _dereq_('../internals/global');
  52563. var call = _dereq_('../internals/function-call');
  52564. var isCallable = _dereq_('../internals/is-callable');
  52565. var isObject = _dereq_('../internals/is-object');
  52566. var TypeError = global.TypeError;
  52567. // `OrdinaryToPrimitive` abstract operation
  52568. // https://tc39.es/ecma262/#sec-ordinarytoprimitive
  52569. module.exports = function (input, pref) {
  52570. var fn, val;
  52571. if (pref === 'string' && isCallable(fn = input.toString) && !isObject(val = call(fn, input))) return val;
  52572. if (isCallable(fn = input.valueOf) && !isObject(val = call(fn, input))) return val;
  52573. if (pref !== 'string' && isCallable(fn = input.toString) && !isObject(val = call(fn, input))) return val;
  52574. throw TypeError("Can't convert object to primitive value");
  52575. };
  52576. },{"../internals/function-call":483,"../internals/global":491,"../internals/is-callable":504,"../internals/is-object":509}],547:[function(_dereq_,module,exports){
  52577. var getBuiltIn = _dereq_('../internals/get-built-in');
  52578. var uncurryThis = _dereq_('../internals/function-uncurry-this');
  52579. var getOwnPropertyNamesModule = _dereq_('../internals/object-get-own-property-names');
  52580. var getOwnPropertySymbolsModule = _dereq_('../internals/object-get-own-property-symbols');
  52581. var anObject = _dereq_('../internals/an-object');
  52582. var concat = uncurryThis([].concat);
  52583. // all object keys, includes non-enumerable and symbols
  52584. module.exports = getBuiltIn('Reflect', 'ownKeys') || function ownKeys(it) {
  52585. var keys = getOwnPropertyNamesModule.f(anObject(it));
  52586. var getOwnPropertySymbols = getOwnPropertySymbolsModule.f;
  52587. return getOwnPropertySymbols ? concat(keys, getOwnPropertySymbols(it)) : keys;
  52588. };
  52589. },{"../internals/an-object":426,"../internals/function-uncurry-this":485,"../internals/get-built-in":486,"../internals/object-get-own-property-names":535,"../internals/object-get-own-property-symbols":536}],548:[function(_dereq_,module,exports){
  52590. arguments[4][493][0].apply(exports,arguments)
  52591. },{"dup":493}],549:[function(_dereq_,module,exports){
  52592. module.exports = function (exec) {
  52593. try {
  52594. return { error: false, value: exec() };
  52595. } catch (error) {
  52596. return { error: true, value: error };
  52597. }
  52598. };
  52599. },{}],550:[function(_dereq_,module,exports){
  52600. var anObject = _dereq_('../internals/an-object');
  52601. var isObject = _dereq_('../internals/is-object');
  52602. var newPromiseCapability = _dereq_('../internals/new-promise-capability');
  52603. module.exports = function (C, x) {
  52604. anObject(C);
  52605. if (isObject(x) && x.constructor === C) return x;
  52606. var promiseCapability = newPromiseCapability.f(C);
  52607. var resolve = promiseCapability.resolve;
  52608. resolve(x);
  52609. return promiseCapability.promise;
  52610. };
  52611. },{"../internals/an-object":426,"../internals/is-object":509,"../internals/new-promise-capability":525}],551:[function(_dereq_,module,exports){
  52612. var Queue = function () {
  52613. this.head = null;
  52614. this.tail = null;
  52615. };
  52616. Queue.prototype = {
  52617. add: function (item) {
  52618. var entry = { item: item, next: null };
  52619. if (this.head) this.tail.next = entry;
  52620. else this.head = entry;
  52621. this.tail = entry;
  52622. },
  52623. get: function () {
  52624. var entry = this.head;
  52625. if (entry) {
  52626. this.head = entry.next;
  52627. if (this.tail === entry) this.tail = null;
  52628. return entry.item;
  52629. }
  52630. }
  52631. };
  52632. module.exports = Queue;
  52633. },{}],552:[function(_dereq_,module,exports){
  52634. var redefine = _dereq_('../internals/redefine');
  52635. module.exports = function (target, src, options) {
  52636. for (var key in src) {
  52637. if (options && options.unsafe && target[key]) target[key] = src[key];
  52638. else redefine(target, key, src[key], options);
  52639. } return target;
  52640. };
  52641. },{"../internals/redefine":553}],553:[function(_dereq_,module,exports){
  52642. var createNonEnumerableProperty = _dereq_('../internals/create-non-enumerable-property');
  52643. module.exports = function (target, key, value, options) {
  52644. if (options && options.enumerable) target[key] = value;
  52645. else createNonEnumerableProperty(target, key, value);
  52646. };
  52647. },{"../internals/create-non-enumerable-property":455}],554:[function(_dereq_,module,exports){
  52648. var global = _dereq_('../internals/global');
  52649. var TypeError = global.TypeError;
  52650. // `RequireObjectCoercible` abstract operation
  52651. // https://tc39.es/ecma262/#sec-requireobjectcoercible
  52652. module.exports = function (it) {
  52653. if (it == undefined) throw TypeError("Can't call method on " + it);
  52654. return it;
  52655. };
  52656. },{"../internals/global":491}],555:[function(_dereq_,module,exports){
  52657. // `SameValueZero` abstract operation
  52658. // https://tc39.es/ecma262/#sec-samevaluezero
  52659. module.exports = function (x, y) {
  52660. // eslint-disable-next-line no-self-compare -- NaN check
  52661. return x === y || x != x && y != y;
  52662. };
  52663. },{}],556:[function(_dereq_,module,exports){
  52664. var global = _dereq_('../internals/global');
  52665. // eslint-disable-next-line es/no-object-defineproperty -- safe
  52666. var defineProperty = Object.defineProperty;
  52667. module.exports = function (key, value) {
  52668. try {
  52669. defineProperty(global, key, { value: value, configurable: true, writable: true });
  52670. } catch (error) {
  52671. global[key] = value;
  52672. } return value;
  52673. };
  52674. },{"../internals/global":491}],557:[function(_dereq_,module,exports){
  52675. 'use strict';
  52676. var getBuiltIn = _dereq_('../internals/get-built-in');
  52677. var definePropertyModule = _dereq_('../internals/object-define-property');
  52678. var wellKnownSymbol = _dereq_('../internals/well-known-symbol');
  52679. var DESCRIPTORS = _dereq_('../internals/descriptors');
  52680. var SPECIES = wellKnownSymbol('species');
  52681. module.exports = function (CONSTRUCTOR_NAME) {
  52682. var Constructor = getBuiltIn(CONSTRUCTOR_NAME);
  52683. var defineProperty = definePropertyModule.f;
  52684. if (DESCRIPTORS && Constructor && !Constructor[SPECIES]) {
  52685. defineProperty(Constructor, SPECIES, {
  52686. configurable: true,
  52687. get: function () { return this; }
  52688. });
  52689. }
  52690. };
  52691. },{"../internals/descriptors":460,"../internals/get-built-in":486,"../internals/object-define-property":532,"../internals/well-known-symbol":586}],558:[function(_dereq_,module,exports){
  52692. var TO_STRING_TAG_SUPPORT = _dereq_('../internals/to-string-tag-support');
  52693. var defineProperty = _dereq_('../internals/object-define-property').f;
  52694. var createNonEnumerableProperty = _dereq_('../internals/create-non-enumerable-property');
  52695. var hasOwn = _dereq_('../internals/has-own-property');
  52696. var toString = _dereq_('../internals/object-to-string');
  52697. var wellKnownSymbol = _dereq_('../internals/well-known-symbol');
  52698. var TO_STRING_TAG = wellKnownSymbol('toStringTag');
  52699. module.exports = function (it, TAG, STATIC, SET_METHOD) {
  52700. if (it) {
  52701. var target = STATIC ? it : it.prototype;
  52702. if (!hasOwn(target, TO_STRING_TAG)) {
  52703. defineProperty(target, TO_STRING_TAG, { configurable: true, value: TAG });
  52704. }
  52705. if (SET_METHOD && !TO_STRING_TAG_SUPPORT) {
  52706. createNonEnumerableProperty(target, 'toString', toString);
  52707. }
  52708. }
  52709. };
  52710. },{"../internals/create-non-enumerable-property":455,"../internals/has-own-property":492,"../internals/object-define-property":532,"../internals/object-to-string":545,"../internals/to-string-tag-support":578,"../internals/well-known-symbol":586}],559:[function(_dereq_,module,exports){
  52711. var shared = _dereq_('../internals/shared');
  52712. var uid = _dereq_('../internals/uid');
  52713. var keys = shared('keys');
  52714. module.exports = function (key) {
  52715. return keys[key] || (keys[key] = uid(key));
  52716. };
  52717. },{"../internals/shared":561,"../internals/uid":581}],560:[function(_dereq_,module,exports){
  52718. var global = _dereq_('../internals/global');
  52719. var setGlobal = _dereq_('../internals/set-global');
  52720. var SHARED = '__core-js_shared__';
  52721. var store = global[SHARED] || setGlobal(SHARED, {});
  52722. module.exports = store;
  52723. },{"../internals/global":491,"../internals/set-global":556}],561:[function(_dereq_,module,exports){
  52724. var IS_PURE = _dereq_('../internals/is-pure');
  52725. var store = _dereq_('../internals/shared-store');
  52726. (module.exports = function (key, value) {
  52727. return store[key] || (store[key] = value !== undefined ? value : {});
  52728. })('versions', []).push({
  52729. version: '3.20.3',
  52730. mode: IS_PURE ? 'pure' : 'global',
  52731. copyright: '© 2014-2022 Denis Pushkarev (zloirock.ru)',
  52732. license: 'https://github.com/zloirock/core-js/blob/v3.20.3/LICENSE',
  52733. source: 'https://github.com/zloirock/core-js'
  52734. });
  52735. },{"../internals/is-pure":510,"../internals/shared-store":560}],562:[function(_dereq_,module,exports){
  52736. var anObject = _dereq_('../internals/an-object');
  52737. var aConstructor = _dereq_('../internals/a-constructor');
  52738. var wellKnownSymbol = _dereq_('../internals/well-known-symbol');
  52739. var SPECIES = wellKnownSymbol('species');
  52740. // `SpeciesConstructor` abstract operation
  52741. // https://tc39.es/ecma262/#sec-speciesconstructor
  52742. module.exports = function (O, defaultConstructor) {
  52743. var C = anObject(O).constructor;
  52744. var S;
  52745. return C === undefined || (S = anObject(C)[SPECIES]) == undefined ? defaultConstructor : aConstructor(S);
  52746. };
  52747. },{"../internals/a-constructor":422,"../internals/an-object":426,"../internals/well-known-symbol":586}],563:[function(_dereq_,module,exports){
  52748. var uncurryThis = _dereq_('../internals/function-uncurry-this');
  52749. var toIntegerOrInfinity = _dereq_('../internals/to-integer-or-infinity');
  52750. var toString = _dereq_('../internals/to-string');
  52751. var requireObjectCoercible = _dereq_('../internals/require-object-coercible');
  52752. var charAt = uncurryThis(''.charAt);
  52753. var charCodeAt = uncurryThis(''.charCodeAt);
  52754. var stringSlice = uncurryThis(''.slice);
  52755. var createMethod = function (CONVERT_TO_STRING) {
  52756. return function ($this, pos) {
  52757. var S = toString(requireObjectCoercible($this));
  52758. var position = toIntegerOrInfinity(pos);
  52759. var size = S.length;
  52760. var first, second;
  52761. if (position < 0 || position >= size) return CONVERT_TO_STRING ? '' : undefined;
  52762. first = charCodeAt(S, position);
  52763. return first < 0xD800 || first > 0xDBFF || position + 1 === size
  52764. || (second = charCodeAt(S, position + 1)) < 0xDC00 || second > 0xDFFF
  52765. ? CONVERT_TO_STRING
  52766. ? charAt(S, position)
  52767. : first
  52768. : CONVERT_TO_STRING
  52769. ? stringSlice(S, position, position + 2)
  52770. : (first - 0xD800 << 10) + (second - 0xDC00) + 0x10000;
  52771. };
  52772. };
  52773. module.exports = {
  52774. // `String.prototype.codePointAt` method
  52775. // https://tc39.es/ecma262/#sec-string.prototype.codepointat
  52776. codeAt: createMethod(false),
  52777. // `String.prototype.at` method
  52778. // https://github.com/mathiasbynens/String.prototype.at
  52779. charAt: createMethod(true)
  52780. };
  52781. },{"../internals/function-uncurry-this":485,"../internals/require-object-coercible":554,"../internals/to-integer-or-infinity":573,"../internals/to-string":579}],564:[function(_dereq_,module,exports){
  52782. // https://github.com/zloirock/core-js/issues/280
  52783. var userAgent = _dereq_('../internals/engine-user-agent');
  52784. module.exports = /Version\/10(?:\.\d+){1,2}(?: [\w./]+)?(?: Mobile\/\w+)? Safari\//.test(userAgent);
  52785. },{"../internals/engine-user-agent":470}],565:[function(_dereq_,module,exports){
  52786. // https://github.com/tc39/proposal-string-pad-start-end
  52787. var uncurryThis = _dereq_('../internals/function-uncurry-this');
  52788. var toLength = _dereq_('../internals/to-length');
  52789. var toString = _dereq_('../internals/to-string');
  52790. var $repeat = _dereq_('../internals/string-repeat');
  52791. var requireObjectCoercible = _dereq_('../internals/require-object-coercible');
  52792. var repeat = uncurryThis($repeat);
  52793. var stringSlice = uncurryThis(''.slice);
  52794. var ceil = Math.ceil;
  52795. // `String.prototype.{ padStart, padEnd }` methods implementation
  52796. var createMethod = function (IS_END) {
  52797. return function ($this, maxLength, fillString) {
  52798. var S = toString(requireObjectCoercible($this));
  52799. var intMaxLength = toLength(maxLength);
  52800. var stringLength = S.length;
  52801. var fillStr = fillString === undefined ? ' ' : toString(fillString);
  52802. var fillLen, stringFiller;
  52803. if (intMaxLength <= stringLength || fillStr == '') return S;
  52804. fillLen = intMaxLength - stringLength;
  52805. stringFiller = repeat(fillStr, ceil(fillLen / fillStr.length));
  52806. if (stringFiller.length > fillLen) stringFiller = stringSlice(stringFiller, 0, fillLen);
  52807. return IS_END ? S + stringFiller : stringFiller + S;
  52808. };
  52809. };
  52810. module.exports = {
  52811. // `String.prototype.padStart` method
  52812. // https://tc39.es/ecma262/#sec-string.prototype.padstart
  52813. start: createMethod(false),
  52814. // `String.prototype.padEnd` method
  52815. // https://tc39.es/ecma262/#sec-string.prototype.padend
  52816. end: createMethod(true)
  52817. };
  52818. },{"../internals/function-uncurry-this":485,"../internals/require-object-coercible":554,"../internals/string-repeat":567,"../internals/to-length":574,"../internals/to-string":579}],566:[function(_dereq_,module,exports){
  52819. 'use strict';
  52820. // based on https://github.com/bestiejs/punycode.js/blob/master/punycode.js
  52821. var global = _dereq_('../internals/global');
  52822. var uncurryThis = _dereq_('../internals/function-uncurry-this');
  52823. var maxInt = 2147483647; // aka. 0x7FFFFFFF or 2^31-1
  52824. var base = 36;
  52825. var tMin = 1;
  52826. var tMax = 26;
  52827. var skew = 38;
  52828. var damp = 700;
  52829. var initialBias = 72;
  52830. var initialN = 128; // 0x80
  52831. var delimiter = '-'; // '\x2D'
  52832. var regexNonASCII = /[^\0-\u007E]/; // non-ASCII chars
  52833. var regexSeparators = /[.\u3002\uFF0E\uFF61]/g; // RFC 3490 separators
  52834. var OVERFLOW_ERROR = 'Overflow: input needs wider integers to process';
  52835. var baseMinusTMin = base - tMin;
  52836. var RangeError = global.RangeError;
  52837. var exec = uncurryThis(regexSeparators.exec);
  52838. var floor = Math.floor;
  52839. var fromCharCode = String.fromCharCode;
  52840. var charCodeAt = uncurryThis(''.charCodeAt);
  52841. var join = uncurryThis([].join);
  52842. var push = uncurryThis([].push);
  52843. var replace = uncurryThis(''.replace);
  52844. var split = uncurryThis(''.split);
  52845. var toLowerCase = uncurryThis(''.toLowerCase);
  52846. /**
  52847. * Creates an array containing the numeric code points of each Unicode
  52848. * character in the string. While JavaScript uses UCS-2 internally,
  52849. * this function will convert a pair of surrogate halves (each of which
  52850. * UCS-2 exposes as separate characters) into a single code point,
  52851. * matching UTF-16.
  52852. */
  52853. var ucs2decode = function (string) {
  52854. var output = [];
  52855. var counter = 0;
  52856. var length = string.length;
  52857. while (counter < length) {
  52858. var value = charCodeAt(string, counter++);
  52859. if (value >= 0xD800 && value <= 0xDBFF && counter < length) {
  52860. // It's a high surrogate, and there is a next character.
  52861. var extra = charCodeAt(string, counter++);
  52862. if ((extra & 0xFC00) == 0xDC00) { // Low surrogate.
  52863. push(output, ((value & 0x3FF) << 10) + (extra & 0x3FF) + 0x10000);
  52864. } else {
  52865. // It's an unmatched surrogate; only append this code unit, in case the
  52866. // next code unit is the high surrogate of a surrogate pair.
  52867. push(output, value);
  52868. counter--;
  52869. }
  52870. } else {
  52871. push(output, value);
  52872. }
  52873. }
  52874. return output;
  52875. };
  52876. /**
  52877. * Converts a digit/integer into a basic code point.
  52878. */
  52879. var digitToBasic = function (digit) {
  52880. // 0..25 map to ASCII a..z or A..Z
  52881. // 26..35 map to ASCII 0..9
  52882. return digit + 22 + 75 * (digit < 26);
  52883. };
  52884. /**
  52885. * Bias adaptation function as per section 3.4 of RFC 3492.
  52886. * https://tools.ietf.org/html/rfc3492#section-3.4
  52887. */
  52888. var adapt = function (delta, numPoints, firstTime) {
  52889. var k = 0;
  52890. delta = firstTime ? floor(delta / damp) : delta >> 1;
  52891. delta += floor(delta / numPoints);
  52892. while (delta > baseMinusTMin * tMax >> 1) {
  52893. delta = floor(delta / baseMinusTMin);
  52894. k += base;
  52895. }
  52896. return floor(k + (baseMinusTMin + 1) * delta / (delta + skew));
  52897. };
  52898. /**
  52899. * Converts a string of Unicode symbols (e.g. a domain name label) to a
  52900. * Punycode string of ASCII-only symbols.
  52901. */
  52902. var encode = function (input) {
  52903. var output = [];
  52904. // Convert the input in UCS-2 to an array of Unicode code points.
  52905. input = ucs2decode(input);
  52906. // Cache the length.
  52907. var inputLength = input.length;
  52908. // Initialize the state.
  52909. var n = initialN;
  52910. var delta = 0;
  52911. var bias = initialBias;
  52912. var i, currentValue;
  52913. // Handle the basic code points.
  52914. for (i = 0; i < input.length; i++) {
  52915. currentValue = input[i];
  52916. if (currentValue < 0x80) {
  52917. push(output, fromCharCode(currentValue));
  52918. }
  52919. }
  52920. var basicLength = output.length; // number of basic code points.
  52921. var handledCPCount = basicLength; // number of code points that have been handled;
  52922. // Finish the basic string with a delimiter unless it's empty.
  52923. if (basicLength) {
  52924. push(output, delimiter);
  52925. }
  52926. // Main encoding loop:
  52927. while (handledCPCount < inputLength) {
  52928. // All non-basic code points < n have been handled already. Find the next larger one:
  52929. var m = maxInt;
  52930. for (i = 0; i < input.length; i++) {
  52931. currentValue = input[i];
  52932. if (currentValue >= n && currentValue < m) {
  52933. m = currentValue;
  52934. }
  52935. }
  52936. // Increase `delta` enough to advance the decoder's <n,i> state to <m,0>, but guard against overflow.
  52937. var handledCPCountPlusOne = handledCPCount + 1;
  52938. if (m - n > floor((maxInt - delta) / handledCPCountPlusOne)) {
  52939. throw RangeError(OVERFLOW_ERROR);
  52940. }
  52941. delta += (m - n) * handledCPCountPlusOne;
  52942. n = m;
  52943. for (i = 0; i < input.length; i++) {
  52944. currentValue = input[i];
  52945. if (currentValue < n && ++delta > maxInt) {
  52946. throw RangeError(OVERFLOW_ERROR);
  52947. }
  52948. if (currentValue == n) {
  52949. // Represent delta as a generalized variable-length integer.
  52950. var q = delta;
  52951. var k = base;
  52952. while (true) {
  52953. var t = k <= bias ? tMin : (k >= bias + tMax ? tMax : k - bias);
  52954. if (q < t) break;
  52955. var qMinusT = q - t;
  52956. var baseMinusT = base - t;
  52957. push(output, fromCharCode(digitToBasic(t + qMinusT % baseMinusT)));
  52958. q = floor(qMinusT / baseMinusT);
  52959. k += base;
  52960. }
  52961. push(output, fromCharCode(digitToBasic(q)));
  52962. bias = adapt(delta, handledCPCountPlusOne, handledCPCount == basicLength);
  52963. delta = 0;
  52964. handledCPCount++;
  52965. }
  52966. }
  52967. delta++;
  52968. n++;
  52969. }
  52970. return join(output, '');
  52971. };
  52972. module.exports = function (input) {
  52973. var encoded = [];
  52974. var labels = split(replace(toLowerCase(input), regexSeparators, '\u002E'), '.');
  52975. var i, label;
  52976. for (i = 0; i < labels.length; i++) {
  52977. label = labels[i];
  52978. push(encoded, exec(regexNonASCII, label) ? 'xn--' + encode(label) : label);
  52979. }
  52980. return join(encoded, '.');
  52981. };
  52982. },{"../internals/function-uncurry-this":485,"../internals/global":491}],567:[function(_dereq_,module,exports){
  52983. 'use strict';
  52984. var global = _dereq_('../internals/global');
  52985. var toIntegerOrInfinity = _dereq_('../internals/to-integer-or-infinity');
  52986. var toString = _dereq_('../internals/to-string');
  52987. var requireObjectCoercible = _dereq_('../internals/require-object-coercible');
  52988. var RangeError = global.RangeError;
  52989. // `String.prototype.repeat` method implementation
  52990. // https://tc39.es/ecma262/#sec-string.prototype.repeat
  52991. module.exports = function repeat(count) {
  52992. var str = toString(requireObjectCoercible(this));
  52993. var result = '';
  52994. var n = toIntegerOrInfinity(count);
  52995. if (n < 0 || n == Infinity) throw RangeError('Wrong number of repetitions');
  52996. for (;n > 0; (n >>>= 1) && (str += str)) if (n & 1) result += str;
  52997. return result;
  52998. };
  52999. },{"../internals/global":491,"../internals/require-object-coercible":554,"../internals/to-integer-or-infinity":573,"../internals/to-string":579}],568:[function(_dereq_,module,exports){
  53000. var PROPER_FUNCTION_NAME = _dereq_('../internals/function-name').PROPER;
  53001. var fails = _dereq_('../internals/fails');
  53002. var whitespaces = _dereq_('../internals/whitespaces');
  53003. var non = '\u200B\u0085\u180E';
  53004. // check that a method works with the correct list
  53005. // of whitespaces and has a correct name
  53006. module.exports = function (METHOD_NAME) {
  53007. return fails(function () {
  53008. return !!whitespaces[METHOD_NAME]()
  53009. || non[METHOD_NAME]() !== non
  53010. || (PROPER_FUNCTION_NAME && whitespaces[METHOD_NAME].name !== METHOD_NAME);
  53011. });
  53012. };
  53013. },{"../internals/fails":477,"../internals/function-name":484,"../internals/whitespaces":587}],569:[function(_dereq_,module,exports){
  53014. var uncurryThis = _dereq_('../internals/function-uncurry-this');
  53015. var requireObjectCoercible = _dereq_('../internals/require-object-coercible');
  53016. var toString = _dereq_('../internals/to-string');
  53017. var whitespaces = _dereq_('../internals/whitespaces');
  53018. var replace = uncurryThis(''.replace);
  53019. var whitespace = '[' + whitespaces + ']';
  53020. var ltrim = RegExp('^' + whitespace + whitespace + '*');
  53021. var rtrim = RegExp(whitespace + whitespace + '*$');
  53022. // `String.prototype.{ trim, trimStart, trimEnd, trimLeft, trimRight }` methods implementation
  53023. var createMethod = function (TYPE) {
  53024. return function ($this) {
  53025. var string = toString(requireObjectCoercible($this));
  53026. if (TYPE & 1) string = replace(string, ltrim, '');
  53027. if (TYPE & 2) string = replace(string, rtrim, '');
  53028. return string;
  53029. };
  53030. };
  53031. module.exports = {
  53032. // `String.prototype.{ trimLeft, trimStart }` methods
  53033. // https://tc39.es/ecma262/#sec-string.prototype.trimstart
  53034. start: createMethod(1),
  53035. // `String.prototype.{ trimRight, trimEnd }` methods
  53036. // https://tc39.es/ecma262/#sec-string.prototype.trimend
  53037. end: createMethod(2),
  53038. // `String.prototype.trim` method
  53039. // https://tc39.es/ecma262/#sec-string.prototype.trim
  53040. trim: createMethod(3)
  53041. };
  53042. },{"../internals/function-uncurry-this":485,"../internals/require-object-coercible":554,"../internals/to-string":579,"../internals/whitespaces":587}],570:[function(_dereq_,module,exports){
  53043. var global = _dereq_('../internals/global');
  53044. var apply = _dereq_('../internals/function-apply');
  53045. var bind = _dereq_('../internals/function-bind-context');
  53046. var isCallable = _dereq_('../internals/is-callable');
  53047. var hasOwn = _dereq_('../internals/has-own-property');
  53048. var fails = _dereq_('../internals/fails');
  53049. var html = _dereq_('../internals/html');
  53050. var arraySlice = _dereq_('../internals/array-slice');
  53051. var createElement = _dereq_('../internals/document-create-element');
  53052. var IS_IOS = _dereq_('../internals/engine-is-ios');
  53053. var IS_NODE = _dereq_('../internals/engine-is-node');
  53054. var set = global.setImmediate;
  53055. var clear = global.clearImmediate;
  53056. var process = global.process;
  53057. var Dispatch = global.Dispatch;
  53058. var Function = global.Function;
  53059. var MessageChannel = global.MessageChannel;
  53060. var String = global.String;
  53061. var counter = 0;
  53062. var queue = {};
  53063. var ONREADYSTATECHANGE = 'onreadystatechange';
  53064. var location, defer, channel, port;
  53065. try {
  53066. // Deno throws a ReferenceError on `location` access without `--location` flag
  53067. location = global.location;
  53068. } catch (error) { /* empty */ }
  53069. var run = function (id) {
  53070. if (hasOwn(queue, id)) {
  53071. var fn = queue[id];
  53072. delete queue[id];
  53073. fn();
  53074. }
  53075. };
  53076. var runner = function (id) {
  53077. return function () {
  53078. run(id);
  53079. };
  53080. };
  53081. var listener = function (event) {
  53082. run(event.data);
  53083. };
  53084. var post = function (id) {
  53085. // old engines have not location.origin
  53086. global.postMessage(String(id), location.protocol + '//' + location.host);
  53087. };
  53088. // Node.js 0.9+ & IE10+ has setImmediate, otherwise:
  53089. if (!set || !clear) {
  53090. set = function setImmediate(fn) {
  53091. var args = arraySlice(arguments, 1);
  53092. queue[++counter] = function () {
  53093. apply(isCallable(fn) ? fn : Function(fn), undefined, args);
  53094. };
  53095. defer(counter);
  53096. return counter;
  53097. };
  53098. clear = function clearImmediate(id) {
  53099. delete queue[id];
  53100. };
  53101. // Node.js 0.8-
  53102. if (IS_NODE) {
  53103. defer = function (id) {
  53104. process.nextTick(runner(id));
  53105. };
  53106. // Sphere (JS game engine) Dispatch API
  53107. } else if (Dispatch && Dispatch.now) {
  53108. defer = function (id) {
  53109. Dispatch.now(runner(id));
  53110. };
  53111. // Browsers with MessageChannel, includes WebWorkers
  53112. // except iOS - https://github.com/zloirock/core-js/issues/624
  53113. } else if (MessageChannel && !IS_IOS) {
  53114. channel = new MessageChannel();
  53115. port = channel.port2;
  53116. channel.port1.onmessage = listener;
  53117. defer = bind(port.postMessage, port);
  53118. // Browsers with postMessage, skip WebWorkers
  53119. // IE8 has postMessage, but it's sync & typeof its postMessage is 'object'
  53120. } else if (
  53121. global.addEventListener &&
  53122. isCallable(global.postMessage) &&
  53123. !global.importScripts &&
  53124. location && location.protocol !== 'file:' &&
  53125. !fails(post)
  53126. ) {
  53127. defer = post;
  53128. global.addEventListener('message', listener, false);
  53129. // IE8-
  53130. } else if (ONREADYSTATECHANGE in createElement('script')) {
  53131. defer = function (id) {
  53132. html.appendChild(createElement('script'))[ONREADYSTATECHANGE] = function () {
  53133. html.removeChild(this);
  53134. run(id);
  53135. };
  53136. };
  53137. // Rest old browsers
  53138. } else {
  53139. defer = function (id) {
  53140. setTimeout(runner(id), 0);
  53141. };
  53142. }
  53143. }
  53144. module.exports = {
  53145. set: set,
  53146. clear: clear
  53147. };
  53148. },{"../internals/array-slice":436,"../internals/document-create-element":461,"../internals/engine-is-ios":467,"../internals/engine-is-node":468,"../internals/fails":477,"../internals/function-apply":479,"../internals/function-bind-context":480,"../internals/global":491,"../internals/has-own-property":492,"../internals/html":495,"../internals/is-callable":504}],571:[function(_dereq_,module,exports){
  53149. var toIntegerOrInfinity = _dereq_('../internals/to-integer-or-infinity');
  53150. var max = Math.max;
  53151. var min = Math.min;
  53152. // Helper for a popular repeating case of the spec:
  53153. // Let integer be ? ToInteger(index).
  53154. // If integer < 0, let result be max((length + integer), 0); else let result be min(integer, length).
  53155. module.exports = function (index, length) {
  53156. var integer = toIntegerOrInfinity(index);
  53157. return integer < 0 ? max(integer + length, 0) : min(integer, length);
  53158. };
  53159. },{"../internals/to-integer-or-infinity":573}],572:[function(_dereq_,module,exports){
  53160. // toObject with fallback for non-array-like ES3 strings
  53161. var IndexedObject = _dereq_('../internals/indexed-object');
  53162. var requireObjectCoercible = _dereq_('../internals/require-object-coercible');
  53163. module.exports = function (it) {
  53164. return IndexedObject(requireObjectCoercible(it));
  53165. };
  53166. },{"../internals/indexed-object":497,"../internals/require-object-coercible":554}],573:[function(_dereq_,module,exports){
  53167. var ceil = Math.ceil;
  53168. var floor = Math.floor;
  53169. // `ToIntegerOrInfinity` abstract operation
  53170. // https://tc39.es/ecma262/#sec-tointegerorinfinity
  53171. module.exports = function (argument) {
  53172. var number = +argument;
  53173. // eslint-disable-next-line no-self-compare -- safe
  53174. return number !== number || number === 0 ? 0 : (number > 0 ? floor : ceil)(number);
  53175. };
  53176. },{}],574:[function(_dereq_,module,exports){
  53177. var toIntegerOrInfinity = _dereq_('../internals/to-integer-or-infinity');
  53178. var min = Math.min;
  53179. // `ToLength` abstract operation
  53180. // https://tc39.es/ecma262/#sec-tolength
  53181. module.exports = function (argument) {
  53182. return argument > 0 ? min(toIntegerOrInfinity(argument), 0x1FFFFFFFFFFFFF) : 0; // 2 ** 53 - 1 == 9007199254740991
  53183. };
  53184. },{"../internals/to-integer-or-infinity":573}],575:[function(_dereq_,module,exports){
  53185. var global = _dereq_('../internals/global');
  53186. var requireObjectCoercible = _dereq_('../internals/require-object-coercible');
  53187. var Object = global.Object;
  53188. // `ToObject` abstract operation
  53189. // https://tc39.es/ecma262/#sec-toobject
  53190. module.exports = function (argument) {
  53191. return Object(requireObjectCoercible(argument));
  53192. };
  53193. },{"../internals/global":491,"../internals/require-object-coercible":554}],576:[function(_dereq_,module,exports){
  53194. var global = _dereq_('../internals/global');
  53195. var call = _dereq_('../internals/function-call');
  53196. var isObject = _dereq_('../internals/is-object');
  53197. var isSymbol = _dereq_('../internals/is-symbol');
  53198. var getMethod = _dereq_('../internals/get-method');
  53199. var ordinaryToPrimitive = _dereq_('../internals/ordinary-to-primitive');
  53200. var wellKnownSymbol = _dereq_('../internals/well-known-symbol');
  53201. var TypeError = global.TypeError;
  53202. var TO_PRIMITIVE = wellKnownSymbol('toPrimitive');
  53203. // `ToPrimitive` abstract operation
  53204. // https://tc39.es/ecma262/#sec-toprimitive
  53205. module.exports = function (input, pref) {
  53206. if (!isObject(input) || isSymbol(input)) return input;
  53207. var exoticToPrim = getMethod(input, TO_PRIMITIVE);
  53208. var result;
  53209. if (exoticToPrim) {
  53210. if (pref === undefined) pref = 'default';
  53211. result = call(exoticToPrim, input, pref);
  53212. if (!isObject(result) || isSymbol(result)) return result;
  53213. throw TypeError("Can't convert object to primitive value");
  53214. }
  53215. if (pref === undefined) pref = 'number';
  53216. return ordinaryToPrimitive(input, pref);
  53217. };
  53218. },{"../internals/function-call":483,"../internals/get-method":490,"../internals/global":491,"../internals/is-object":509,"../internals/is-symbol":512,"../internals/ordinary-to-primitive":546,"../internals/well-known-symbol":586}],577:[function(_dereq_,module,exports){
  53219. var toPrimitive = _dereq_('../internals/to-primitive');
  53220. var isSymbol = _dereq_('../internals/is-symbol');
  53221. // `ToPropertyKey` abstract operation
  53222. // https://tc39.es/ecma262/#sec-topropertykey
  53223. module.exports = function (argument) {
  53224. var key = toPrimitive(argument, 'string');
  53225. return isSymbol(key) ? key : key + '';
  53226. };
  53227. },{"../internals/is-symbol":512,"../internals/to-primitive":576}],578:[function(_dereq_,module,exports){
  53228. var wellKnownSymbol = _dereq_('../internals/well-known-symbol');
  53229. var TO_STRING_TAG = wellKnownSymbol('toStringTag');
  53230. var test = {};
  53231. test[TO_STRING_TAG] = 'z';
  53232. module.exports = String(test) === '[object z]';
  53233. },{"../internals/well-known-symbol":586}],579:[function(_dereq_,module,exports){
  53234. var global = _dereq_('../internals/global');
  53235. var classof = _dereq_('../internals/classof');
  53236. var String = global.String;
  53237. module.exports = function (argument) {
  53238. if (classof(argument) === 'Symbol') throw TypeError('Cannot convert a Symbol value to a string');
  53239. return String(argument);
  53240. };
  53241. },{"../internals/classof":443,"../internals/global":491}],580:[function(_dereq_,module,exports){
  53242. var global = _dereq_('../internals/global');
  53243. var String = global.String;
  53244. module.exports = function (argument) {
  53245. try {
  53246. return String(argument);
  53247. } catch (error) {
  53248. return 'Object';
  53249. }
  53250. };
  53251. },{"../internals/global":491}],581:[function(_dereq_,module,exports){
  53252. var uncurryThis = _dereq_('../internals/function-uncurry-this');
  53253. var id = 0;
  53254. var postfix = Math.random();
  53255. var toString = uncurryThis(1.0.toString);
  53256. module.exports = function (key) {
  53257. return 'Symbol(' + (key === undefined ? '' : key) + ')_' + toString(++id + postfix, 36);
  53258. };
  53259. },{"../internals/function-uncurry-this":485}],582:[function(_dereq_,module,exports){
  53260. /* eslint-disable es/no-symbol -- required for testing */
  53261. var NATIVE_SYMBOL = _dereq_('../internals/native-symbol');
  53262. module.exports = NATIVE_SYMBOL
  53263. && !Symbol.sham
  53264. && typeof Symbol.iterator == 'symbol';
  53265. },{"../internals/native-symbol":522}],583:[function(_dereq_,module,exports){
  53266. var DESCRIPTORS = _dereq_('../internals/descriptors');
  53267. var fails = _dereq_('../internals/fails');
  53268. // V8 ~ Chrome 36-
  53269. // https://bugs.chromium.org/p/v8/issues/detail?id=3334
  53270. module.exports = DESCRIPTORS && fails(function () {
  53271. // eslint-disable-next-line es/no-object-defineproperty -- required for testing
  53272. return Object.defineProperty(function () { /* empty */ }, 'prototype', {
  53273. value: 42,
  53274. writable: false
  53275. }).prototype != 42;
  53276. });
  53277. },{"../internals/descriptors":460,"../internals/fails":477}],584:[function(_dereq_,module,exports){
  53278. var global = _dereq_('../internals/global');
  53279. var TypeError = global.TypeError;
  53280. module.exports = function (passed, required) {
  53281. if (passed < required) throw TypeError('Not enough arguments');
  53282. return passed;
  53283. };
  53284. },{"../internals/global":491}],585:[function(_dereq_,module,exports){
  53285. var wellKnownSymbol = _dereq_('../internals/well-known-symbol');
  53286. exports.f = wellKnownSymbol;
  53287. },{"../internals/well-known-symbol":586}],586:[function(_dereq_,module,exports){
  53288. var global = _dereq_('../internals/global');
  53289. var shared = _dereq_('../internals/shared');
  53290. var hasOwn = _dereq_('../internals/has-own-property');
  53291. var uid = _dereq_('../internals/uid');
  53292. var NATIVE_SYMBOL = _dereq_('../internals/native-symbol');
  53293. var USE_SYMBOL_AS_UID = _dereq_('../internals/use-symbol-as-uid');
  53294. var WellKnownSymbolsStore = shared('wks');
  53295. var Symbol = global.Symbol;
  53296. var symbolFor = Symbol && Symbol['for'];
  53297. var createWellKnownSymbol = USE_SYMBOL_AS_UID ? Symbol : Symbol && Symbol.withoutSetter || uid;
  53298. module.exports = function (name) {
  53299. if (!hasOwn(WellKnownSymbolsStore, name) || !(NATIVE_SYMBOL || typeof WellKnownSymbolsStore[name] == 'string')) {
  53300. var description = 'Symbol.' + name;
  53301. if (NATIVE_SYMBOL && hasOwn(Symbol, name)) {
  53302. WellKnownSymbolsStore[name] = Symbol[name];
  53303. } else if (USE_SYMBOL_AS_UID && symbolFor) {
  53304. WellKnownSymbolsStore[name] = symbolFor(description);
  53305. } else {
  53306. WellKnownSymbolsStore[name] = createWellKnownSymbol(description);
  53307. }
  53308. } return WellKnownSymbolsStore[name];
  53309. };
  53310. },{"../internals/global":491,"../internals/has-own-property":492,"../internals/native-symbol":522,"../internals/shared":561,"../internals/uid":581,"../internals/use-symbol-as-uid":582}],587:[function(_dereq_,module,exports){
  53311. // a string of all valid unicode whitespaces
  53312. module.exports = '\u0009\u000A\u000B\u000C\u000D\u0020\u00A0\u1680\u2000\u2001\u2002' +
  53313. '\u2003\u2004\u2005\u2006\u2007\u2008\u2009\u200A\u202F\u205F\u3000\u2028\u2029\uFEFF';
  53314. },{}],588:[function(_dereq_,module,exports){
  53315. 'use strict';
  53316. var $ = _dereq_('../internals/export');
  53317. var global = _dereq_('../internals/global');
  53318. var isPrototypeOf = _dereq_('../internals/object-is-prototype-of');
  53319. var getPrototypeOf = _dereq_('../internals/object-get-prototype-of');
  53320. var setPrototypeOf = _dereq_('../internals/object-set-prototype-of');
  53321. var copyConstructorProperties = _dereq_('../internals/copy-constructor-properties');
  53322. var create = _dereq_('../internals/object-create');
  53323. var createNonEnumerableProperty = _dereq_('../internals/create-non-enumerable-property');
  53324. var createPropertyDescriptor = _dereq_('../internals/create-property-descriptor');
  53325. var clearErrorStack = _dereq_('../internals/clear-error-stack');
  53326. var installErrorCause = _dereq_('../internals/install-error-cause');
  53327. var iterate = _dereq_('../internals/iterate');
  53328. var normalizeStringArgument = _dereq_('../internals/normalize-string-argument');
  53329. var wellKnownSymbol = _dereq_('../internals/well-known-symbol');
  53330. var ERROR_STACK_INSTALLABLE = _dereq_('../internals/error-stack-installable');
  53331. var TO_STRING_TAG = wellKnownSymbol('toStringTag');
  53332. var Error = global.Error;
  53333. var push = [].push;
  53334. var $AggregateError = function AggregateError(errors, message /* , options */) {
  53335. var options = arguments.length > 2 ? arguments[2] : undefined;
  53336. var isInstance = isPrototypeOf(AggregateErrorPrototype, this);
  53337. var that;
  53338. if (setPrototypeOf) {
  53339. that = setPrototypeOf(new Error(), isInstance ? getPrototypeOf(this) : AggregateErrorPrototype);
  53340. } else {
  53341. that = isInstance ? this : create(AggregateErrorPrototype);
  53342. createNonEnumerableProperty(that, TO_STRING_TAG, 'Error');
  53343. }
  53344. if (message !== undefined) createNonEnumerableProperty(that, 'message', normalizeStringArgument(message));
  53345. if (ERROR_STACK_INSTALLABLE) createNonEnumerableProperty(that, 'stack', clearErrorStack(that.stack, 1));
  53346. installErrorCause(that, options);
  53347. var errorsArray = [];
  53348. iterate(errors, push, { that: errorsArray });
  53349. createNonEnumerableProperty(that, 'errors', errorsArray);
  53350. return that;
  53351. };
  53352. if (setPrototypeOf) setPrototypeOf($AggregateError, Error);
  53353. else copyConstructorProperties($AggregateError, Error, { name: true });
  53354. var AggregateErrorPrototype = $AggregateError.prototype = create(Error.prototype, {
  53355. constructor: createPropertyDescriptor(1, $AggregateError),
  53356. message: createPropertyDescriptor(1, ''),
  53357. name: createPropertyDescriptor(1, 'AggregateError')
  53358. });
  53359. // `AggregateError` constructor
  53360. // https://tc39.es/ecma262/#sec-aggregate-error-constructor
  53361. $({ global: true }, {
  53362. AggregateError: $AggregateError
  53363. });
  53364. },{"../internals/clear-error-stack":444,"../internals/copy-constructor-properties":451,"../internals/create-non-enumerable-property":455,"../internals/create-property-descriptor":456,"../internals/error-stack-installable":475,"../internals/export":476,"../internals/global":491,"../internals/install-error-cause":499,"../internals/iterate":513,"../internals/normalize-string-argument":526,"../internals/object-create":530,"../internals/object-get-prototype-of":537,"../internals/object-is-prototype-of":539,"../internals/object-set-prototype-of":543,"../internals/well-known-symbol":586}],589:[function(_dereq_,module,exports){
  53365. 'use strict';
  53366. var $ = _dereq_('../internals/export');
  53367. var global = _dereq_('../internals/global');
  53368. var fails = _dereq_('../internals/fails');
  53369. var isArray = _dereq_('../internals/is-array');
  53370. var isObject = _dereq_('../internals/is-object');
  53371. var toObject = _dereq_('../internals/to-object');
  53372. var lengthOfArrayLike = _dereq_('../internals/length-of-array-like');
  53373. var createProperty = _dereq_('../internals/create-property');
  53374. var arraySpeciesCreate = _dereq_('../internals/array-species-create');
  53375. var arrayMethodHasSpeciesSupport = _dereq_('../internals/array-method-has-species-support');
  53376. var wellKnownSymbol = _dereq_('../internals/well-known-symbol');
  53377. var V8_VERSION = _dereq_('../internals/engine-v8-version');
  53378. var IS_CONCAT_SPREADABLE = wellKnownSymbol('isConcatSpreadable');
  53379. var MAX_SAFE_INTEGER = 0x1FFFFFFFFFFFFF;
  53380. var MAXIMUM_ALLOWED_INDEX_EXCEEDED = 'Maximum allowed index exceeded';
  53381. var TypeError = global.TypeError;
  53382. // We can't use this feature detection in V8 since it causes
  53383. // deoptimization and serious performance degradation
  53384. // https://github.com/zloirock/core-js/issues/679
  53385. var IS_CONCAT_SPREADABLE_SUPPORT = V8_VERSION >= 51 || !fails(function () {
  53386. var array = [];
  53387. array[IS_CONCAT_SPREADABLE] = false;
  53388. return array.concat()[0] !== array;
  53389. });
  53390. var SPECIES_SUPPORT = arrayMethodHasSpeciesSupport('concat');
  53391. var isConcatSpreadable = function (O) {
  53392. if (!isObject(O)) return false;
  53393. var spreadable = O[IS_CONCAT_SPREADABLE];
  53394. return spreadable !== undefined ? !!spreadable : isArray(O);
  53395. };
  53396. var FORCED = !IS_CONCAT_SPREADABLE_SUPPORT || !SPECIES_SUPPORT;
  53397. // `Array.prototype.concat` method
  53398. // https://tc39.es/ecma262/#sec-array.prototype.concat
  53399. // with adding support of @@isConcatSpreadable and @@species
  53400. $({ target: 'Array', proto: true, forced: FORCED }, {
  53401. // eslint-disable-next-line no-unused-vars -- required for `.length`
  53402. concat: function concat(arg) {
  53403. var O = toObject(this);
  53404. var A = arraySpeciesCreate(O, 0);
  53405. var n = 0;
  53406. var i, k, length, len, E;
  53407. for (i = -1, length = arguments.length; i < length; i++) {
  53408. E = i === -1 ? O : arguments[i];
  53409. if (isConcatSpreadable(E)) {
  53410. len = lengthOfArrayLike(E);
  53411. if (n + len > MAX_SAFE_INTEGER) throw TypeError(MAXIMUM_ALLOWED_INDEX_EXCEEDED);
  53412. for (k = 0; k < len; k++, n++) if (k in E) createProperty(A, n, E[k]);
  53413. } else {
  53414. if (n >= MAX_SAFE_INTEGER) throw TypeError(MAXIMUM_ALLOWED_INDEX_EXCEEDED);
  53415. createProperty(A, n++, E);
  53416. }
  53417. }
  53418. A.length = n;
  53419. return A;
  53420. }
  53421. });
  53422. },{"../internals/array-method-has-species-support":432,"../internals/array-species-create":439,"../internals/create-property":457,"../internals/engine-v8-version":471,"../internals/export":476,"../internals/fails":477,"../internals/global":491,"../internals/is-array":503,"../internals/is-object":509,"../internals/length-of-array-like":517,"../internals/to-object":575,"../internals/well-known-symbol":586}],590:[function(_dereq_,module,exports){
  53423. 'use strict';
  53424. var $ = _dereq_('../internals/export');
  53425. var $every = _dereq_('../internals/array-iteration').every;
  53426. var arrayMethodIsStrict = _dereq_('../internals/array-method-is-strict');
  53427. var STRICT_METHOD = arrayMethodIsStrict('every');
  53428. // `Array.prototype.every` method
  53429. // https://tc39.es/ecma262/#sec-array.prototype.every
  53430. $({ target: 'Array', proto: true, forced: !STRICT_METHOD }, {
  53431. every: function every(callbackfn /* , thisArg */) {
  53432. return $every(this, callbackfn, arguments.length > 1 ? arguments[1] : undefined);
  53433. }
  53434. });
  53435. },{"../internals/array-iteration":431,"../internals/array-method-is-strict":433,"../internals/export":476}],591:[function(_dereq_,module,exports){
  53436. 'use strict';
  53437. var $ = _dereq_('../internals/export');
  53438. var $filter = _dereq_('../internals/array-iteration').filter;
  53439. var arrayMethodHasSpeciesSupport = _dereq_('../internals/array-method-has-species-support');
  53440. var HAS_SPECIES_SUPPORT = arrayMethodHasSpeciesSupport('filter');
  53441. // `Array.prototype.filter` method
  53442. // https://tc39.es/ecma262/#sec-array.prototype.filter
  53443. // with adding support of @@species
  53444. $({ target: 'Array', proto: true, forced: !HAS_SPECIES_SUPPORT }, {
  53445. filter: function filter(callbackfn /* , thisArg */) {
  53446. return $filter(this, callbackfn, arguments.length > 1 ? arguments[1] : undefined);
  53447. }
  53448. });
  53449. },{"../internals/array-iteration":431,"../internals/array-method-has-species-support":432,"../internals/export":476}],592:[function(_dereq_,module,exports){
  53450. 'use strict';
  53451. var $ = _dereq_('../internals/export');
  53452. var $find = _dereq_('../internals/array-iteration').find;
  53453. var addToUnscopables = _dereq_('../internals/add-to-unscopables');
  53454. var FIND = 'find';
  53455. var SKIPS_HOLES = true;
  53456. // Shouldn't skip holes
  53457. if (FIND in []) Array(1)[FIND](function () { SKIPS_HOLES = false; });
  53458. // `Array.prototype.find` method
  53459. // https://tc39.es/ecma262/#sec-array.prototype.find
  53460. $({ target: 'Array', proto: true, forced: SKIPS_HOLES }, {
  53461. find: function find(callbackfn /* , that = undefined */) {
  53462. return $find(this, callbackfn, arguments.length > 1 ? arguments[1] : undefined);
  53463. }
  53464. });
  53465. // https://tc39.es/ecma262/#sec-array.prototype-@@unscopables
  53466. addToUnscopables(FIND);
  53467. },{"../internals/add-to-unscopables":424,"../internals/array-iteration":431,"../internals/export":476}],593:[function(_dereq_,module,exports){
  53468. 'use strict';
  53469. var $ = _dereq_('../internals/export');
  53470. var forEach = _dereq_('../internals/array-for-each');
  53471. // `Array.prototype.forEach` method
  53472. // https://tc39.es/ecma262/#sec-array.prototype.foreach
  53473. // eslint-disable-next-line es/no-array-prototype-foreach -- safe
  53474. $({ target: 'Array', proto: true, forced: [].forEach != forEach }, {
  53475. forEach: forEach
  53476. });
  53477. },{"../internals/array-for-each":428,"../internals/export":476}],594:[function(_dereq_,module,exports){
  53478. var $ = _dereq_('../internals/export');
  53479. var from = _dereq_('../internals/array-from');
  53480. var checkCorrectnessOfIteration = _dereq_('../internals/check-correctness-of-iteration');
  53481. var INCORRECT_ITERATION = !checkCorrectnessOfIteration(function (iterable) {
  53482. // eslint-disable-next-line es/no-array-from -- required for testing
  53483. Array.from(iterable);
  53484. });
  53485. // `Array.from` method
  53486. // https://tc39.es/ecma262/#sec-array.from
  53487. $({ target: 'Array', stat: true, forced: INCORRECT_ITERATION }, {
  53488. from: from
  53489. });
  53490. },{"../internals/array-from":429,"../internals/check-correctness-of-iteration":441,"../internals/export":476}],595:[function(_dereq_,module,exports){
  53491. 'use strict';
  53492. var $ = _dereq_('../internals/export');
  53493. var $includes = _dereq_('../internals/array-includes').includes;
  53494. var addToUnscopables = _dereq_('../internals/add-to-unscopables');
  53495. // `Array.prototype.includes` method
  53496. // https://tc39.es/ecma262/#sec-array.prototype.includes
  53497. $({ target: 'Array', proto: true }, {
  53498. includes: function includes(el /* , fromIndex = 0 */) {
  53499. return $includes(this, el, arguments.length > 1 ? arguments[1] : undefined);
  53500. }
  53501. });
  53502. // https://tc39.es/ecma262/#sec-array.prototype-@@unscopables
  53503. addToUnscopables('includes');
  53504. },{"../internals/add-to-unscopables":424,"../internals/array-includes":430,"../internals/export":476}],596:[function(_dereq_,module,exports){
  53505. 'use strict';
  53506. /* eslint-disable es/no-array-prototype-indexof -- required for testing */
  53507. var $ = _dereq_('../internals/export');
  53508. var uncurryThis = _dereq_('../internals/function-uncurry-this');
  53509. var $IndexOf = _dereq_('../internals/array-includes').indexOf;
  53510. var arrayMethodIsStrict = _dereq_('../internals/array-method-is-strict');
  53511. var un$IndexOf = uncurryThis([].indexOf);
  53512. var NEGATIVE_ZERO = !!un$IndexOf && 1 / un$IndexOf([1], 1, -0) < 0;
  53513. var STRICT_METHOD = arrayMethodIsStrict('indexOf');
  53514. // `Array.prototype.indexOf` method
  53515. // https://tc39.es/ecma262/#sec-array.prototype.indexof
  53516. $({ target: 'Array', proto: true, forced: NEGATIVE_ZERO || !STRICT_METHOD }, {
  53517. indexOf: function indexOf(searchElement /* , fromIndex = 0 */) {
  53518. var fromIndex = arguments.length > 1 ? arguments[1] : undefined;
  53519. return NEGATIVE_ZERO
  53520. // convert -0 to +0
  53521. ? un$IndexOf(this, searchElement, fromIndex) || 0
  53522. : $IndexOf(this, searchElement, fromIndex);
  53523. }
  53524. });
  53525. },{"../internals/array-includes":430,"../internals/array-method-is-strict":433,"../internals/export":476,"../internals/function-uncurry-this":485}],597:[function(_dereq_,module,exports){
  53526. var $ = _dereq_('../internals/export');
  53527. var isArray = _dereq_('../internals/is-array');
  53528. // `Array.isArray` method
  53529. // https://tc39.es/ecma262/#sec-array.isarray
  53530. $({ target: 'Array', stat: true }, {
  53531. isArray: isArray
  53532. });
  53533. },{"../internals/export":476,"../internals/is-array":503}],598:[function(_dereq_,module,exports){
  53534. 'use strict';
  53535. var toIndexedObject = _dereq_('../internals/to-indexed-object');
  53536. var addToUnscopables = _dereq_('../internals/add-to-unscopables');
  53537. var Iterators = _dereq_('../internals/iterators');
  53538. var InternalStateModule = _dereq_('../internals/internal-state');
  53539. var defineProperty = _dereq_('../internals/object-define-property').f;
  53540. var defineIterator = _dereq_('../internals/define-iterator');
  53541. var IS_PURE = _dereq_('../internals/is-pure');
  53542. var DESCRIPTORS = _dereq_('../internals/descriptors');
  53543. var ARRAY_ITERATOR = 'Array Iterator';
  53544. var setInternalState = InternalStateModule.set;
  53545. var getInternalState = InternalStateModule.getterFor(ARRAY_ITERATOR);
  53546. // `Array.prototype.entries` method
  53547. // https://tc39.es/ecma262/#sec-array.prototype.entries
  53548. // `Array.prototype.keys` method
  53549. // https://tc39.es/ecma262/#sec-array.prototype.keys
  53550. // `Array.prototype.values` method
  53551. // https://tc39.es/ecma262/#sec-array.prototype.values
  53552. // `Array.prototype[@@iterator]` method
  53553. // https://tc39.es/ecma262/#sec-array.prototype-@@iterator
  53554. // `CreateArrayIterator` internal method
  53555. // https://tc39.es/ecma262/#sec-createarrayiterator
  53556. module.exports = defineIterator(Array, 'Array', function (iterated, kind) {
  53557. setInternalState(this, {
  53558. type: ARRAY_ITERATOR,
  53559. target: toIndexedObject(iterated), // target
  53560. index: 0, // next index
  53561. kind: kind // kind
  53562. });
  53563. // `%ArrayIteratorPrototype%.next` method
  53564. // https://tc39.es/ecma262/#sec-%arrayiteratorprototype%.next
  53565. }, function () {
  53566. var state = getInternalState(this);
  53567. var target = state.target;
  53568. var kind = state.kind;
  53569. var index = state.index++;
  53570. if (!target || index >= target.length) {
  53571. state.target = undefined;
  53572. return { value: undefined, done: true };
  53573. }
  53574. if (kind == 'keys') return { value: index, done: false };
  53575. if (kind == 'values') return { value: target[index], done: false };
  53576. return { value: [index, target[index]], done: false };
  53577. }, 'values');
  53578. // argumentsList[@@iterator] is %ArrayProto_values%
  53579. // https://tc39.es/ecma262/#sec-createunmappedargumentsobject
  53580. // https://tc39.es/ecma262/#sec-createmappedargumentsobject
  53581. var values = Iterators.Arguments = Iterators.Array;
  53582. // https://tc39.es/ecma262/#sec-array.prototype-@@unscopables
  53583. addToUnscopables('keys');
  53584. addToUnscopables('values');
  53585. addToUnscopables('entries');
  53586. // V8 ~ Chrome 45- bug
  53587. if (!IS_PURE && DESCRIPTORS && values.name !== 'values') try {
  53588. defineProperty(values, 'name', { value: 'values' });
  53589. } catch (error) { /* empty */ }
  53590. },{"../internals/add-to-unscopables":424,"../internals/define-iterator":458,"../internals/descriptors":460,"../internals/internal-state":501,"../internals/is-pure":510,"../internals/iterators":516,"../internals/object-define-property":532,"../internals/to-indexed-object":572}],599:[function(_dereq_,module,exports){
  53591. 'use strict';
  53592. var $ = _dereq_('../internals/export');
  53593. var $map = _dereq_('../internals/array-iteration').map;
  53594. var arrayMethodHasSpeciesSupport = _dereq_('../internals/array-method-has-species-support');
  53595. var HAS_SPECIES_SUPPORT = arrayMethodHasSpeciesSupport('map');
  53596. // `Array.prototype.map` method
  53597. // https://tc39.es/ecma262/#sec-array.prototype.map
  53598. // with adding support of @@species
  53599. $({ target: 'Array', proto: true, forced: !HAS_SPECIES_SUPPORT }, {
  53600. map: function map(callbackfn /* , thisArg */) {
  53601. return $map(this, callbackfn, arguments.length > 1 ? arguments[1] : undefined);
  53602. }
  53603. });
  53604. },{"../internals/array-iteration":431,"../internals/array-method-has-species-support":432,"../internals/export":476}],600:[function(_dereq_,module,exports){
  53605. 'use strict';
  53606. var $ = _dereq_('../internals/export');
  53607. var $reduce = _dereq_('../internals/array-reduce').left;
  53608. var arrayMethodIsStrict = _dereq_('../internals/array-method-is-strict');
  53609. var CHROME_VERSION = _dereq_('../internals/engine-v8-version');
  53610. var IS_NODE = _dereq_('../internals/engine-is-node');
  53611. var STRICT_METHOD = arrayMethodIsStrict('reduce');
  53612. // Chrome 80-82 has a critical bug
  53613. // https://bugs.chromium.org/p/chromium/issues/detail?id=1049982
  53614. var CHROME_BUG = !IS_NODE && CHROME_VERSION > 79 && CHROME_VERSION < 83;
  53615. // `Array.prototype.reduce` method
  53616. // https://tc39.es/ecma262/#sec-array.prototype.reduce
  53617. $({ target: 'Array', proto: true, forced: !STRICT_METHOD || CHROME_BUG }, {
  53618. reduce: function reduce(callbackfn /* , initialValue */) {
  53619. var length = arguments.length;
  53620. return $reduce(this, callbackfn, length, length > 1 ? arguments[1] : undefined);
  53621. }
  53622. });
  53623. },{"../internals/array-method-is-strict":433,"../internals/array-reduce":434,"../internals/engine-is-node":468,"../internals/engine-v8-version":471,"../internals/export":476}],601:[function(_dereq_,module,exports){
  53624. 'use strict';
  53625. var $ = _dereq_('../internals/export');
  53626. var global = _dereq_('../internals/global');
  53627. var isArray = _dereq_('../internals/is-array');
  53628. var isConstructor = _dereq_('../internals/is-constructor');
  53629. var isObject = _dereq_('../internals/is-object');
  53630. var toAbsoluteIndex = _dereq_('../internals/to-absolute-index');
  53631. var lengthOfArrayLike = _dereq_('../internals/length-of-array-like');
  53632. var toIndexedObject = _dereq_('../internals/to-indexed-object');
  53633. var createProperty = _dereq_('../internals/create-property');
  53634. var wellKnownSymbol = _dereq_('../internals/well-known-symbol');
  53635. var arrayMethodHasSpeciesSupport = _dereq_('../internals/array-method-has-species-support');
  53636. var un$Slice = _dereq_('../internals/array-slice');
  53637. var HAS_SPECIES_SUPPORT = arrayMethodHasSpeciesSupport('slice');
  53638. var SPECIES = wellKnownSymbol('species');
  53639. var Array = global.Array;
  53640. var max = Math.max;
  53641. // `Array.prototype.slice` method
  53642. // https://tc39.es/ecma262/#sec-array.prototype.slice
  53643. // fallback for not array-like ES3 strings and DOM objects
  53644. $({ target: 'Array', proto: true, forced: !HAS_SPECIES_SUPPORT }, {
  53645. slice: function slice(start, end) {
  53646. var O = toIndexedObject(this);
  53647. var length = lengthOfArrayLike(O);
  53648. var k = toAbsoluteIndex(start, length);
  53649. var fin = toAbsoluteIndex(end === undefined ? length : end, length);
  53650. // inline `ArraySpeciesCreate` for usage native `Array#slice` where it's possible
  53651. var Constructor, result, n;
  53652. if (isArray(O)) {
  53653. Constructor = O.constructor;
  53654. // cross-realm fallback
  53655. if (isConstructor(Constructor) && (Constructor === Array || isArray(Constructor.prototype))) {
  53656. Constructor = undefined;
  53657. } else if (isObject(Constructor)) {
  53658. Constructor = Constructor[SPECIES];
  53659. if (Constructor === null) Constructor = undefined;
  53660. }
  53661. if (Constructor === Array || Constructor === undefined) {
  53662. return un$Slice(O, k, fin);
  53663. }
  53664. }
  53665. result = new (Constructor === undefined ? Array : Constructor)(max(fin - k, 0));
  53666. for (n = 0; k < fin; k++, n++) if (k in O) createProperty(result, n, O[k]);
  53667. result.length = n;
  53668. return result;
  53669. }
  53670. });
  53671. },{"../internals/array-method-has-species-support":432,"../internals/array-slice":436,"../internals/create-property":457,"../internals/export":476,"../internals/global":491,"../internals/is-array":503,"../internals/is-constructor":505,"../internals/is-object":509,"../internals/length-of-array-like":517,"../internals/to-absolute-index":571,"../internals/to-indexed-object":572,"../internals/well-known-symbol":586}],602:[function(_dereq_,module,exports){
  53672. 'use strict';
  53673. var $ = _dereq_('../internals/export');
  53674. var uncurryThis = _dereq_('../internals/function-uncurry-this');
  53675. var aCallable = _dereq_('../internals/a-callable');
  53676. var toObject = _dereq_('../internals/to-object');
  53677. var lengthOfArrayLike = _dereq_('../internals/length-of-array-like');
  53678. var toString = _dereq_('../internals/to-string');
  53679. var fails = _dereq_('../internals/fails');
  53680. var internalSort = _dereq_('../internals/array-sort');
  53681. var arrayMethodIsStrict = _dereq_('../internals/array-method-is-strict');
  53682. var FF = _dereq_('../internals/engine-ff-version');
  53683. var IE_OR_EDGE = _dereq_('../internals/engine-is-ie-or-edge');
  53684. var V8 = _dereq_('../internals/engine-v8-version');
  53685. var WEBKIT = _dereq_('../internals/engine-webkit-version');
  53686. var test = [];
  53687. var un$Sort = uncurryThis(test.sort);
  53688. var push = uncurryThis(test.push);
  53689. // IE8-
  53690. var FAILS_ON_UNDEFINED = fails(function () {
  53691. test.sort(undefined);
  53692. });
  53693. // V8 bug
  53694. var FAILS_ON_NULL = fails(function () {
  53695. test.sort(null);
  53696. });
  53697. // Old WebKit
  53698. var STRICT_METHOD = arrayMethodIsStrict('sort');
  53699. var STABLE_SORT = !fails(function () {
  53700. // feature detection can be too slow, so check engines versions
  53701. if (V8) return V8 < 70;
  53702. if (FF && FF > 3) return;
  53703. if (IE_OR_EDGE) return true;
  53704. if (WEBKIT) return WEBKIT < 603;
  53705. var result = '';
  53706. var code, chr, value, index;
  53707. // generate an array with more 512 elements (Chakra and old V8 fails only in this case)
  53708. for (code = 65; code < 76; code++) {
  53709. chr = String.fromCharCode(code);
  53710. switch (code) {
  53711. case 66: case 69: case 70: case 72: value = 3; break;
  53712. case 68: case 71: value = 4; break;
  53713. default: value = 2;
  53714. }
  53715. for (index = 0; index < 47; index++) {
  53716. test.push({ k: chr + index, v: value });
  53717. }
  53718. }
  53719. test.sort(function (a, b) { return b.v - a.v; });
  53720. for (index = 0; index < test.length; index++) {
  53721. chr = test[index].k.charAt(0);
  53722. if (result.charAt(result.length - 1) !== chr) result += chr;
  53723. }
  53724. return result !== 'DGBEFHACIJK';
  53725. });
  53726. var FORCED = FAILS_ON_UNDEFINED || !FAILS_ON_NULL || !STRICT_METHOD || !STABLE_SORT;
  53727. var getSortCompare = function (comparefn) {
  53728. return function (x, y) {
  53729. if (y === undefined) return -1;
  53730. if (x === undefined) return 1;
  53731. if (comparefn !== undefined) return +comparefn(x, y) || 0;
  53732. return toString(x) > toString(y) ? 1 : -1;
  53733. };
  53734. };
  53735. // `Array.prototype.sort` method
  53736. // https://tc39.es/ecma262/#sec-array.prototype.sort
  53737. $({ target: 'Array', proto: true, forced: FORCED }, {
  53738. sort: function sort(comparefn) {
  53739. if (comparefn !== undefined) aCallable(comparefn);
  53740. var array = toObject(this);
  53741. if (STABLE_SORT) return comparefn === undefined ? un$Sort(array) : un$Sort(array, comparefn);
  53742. var items = [];
  53743. var arrayLength = lengthOfArrayLike(array);
  53744. var itemsLength, index;
  53745. for (index = 0; index < arrayLength; index++) {
  53746. if (index in array) push(items, array[index]);
  53747. }
  53748. internalSort(items, getSortCompare(comparefn));
  53749. itemsLength = items.length;
  53750. index = 0;
  53751. while (index < itemsLength) array[index] = items[index++];
  53752. while (index < arrayLength) delete array[index++];
  53753. return array;
  53754. }
  53755. });
  53756. },{"../internals/a-callable":421,"../internals/array-method-is-strict":433,"../internals/array-sort":437,"../internals/engine-ff-version":463,"../internals/engine-is-ie-or-edge":465,"../internals/engine-v8-version":471,"../internals/engine-webkit-version":472,"../internals/export":476,"../internals/fails":477,"../internals/function-uncurry-this":485,"../internals/length-of-array-like":517,"../internals/to-object":575,"../internals/to-string":579}],603:[function(_dereq_,module,exports){
  53757. 'use strict';
  53758. var $ = _dereq_('../internals/export');
  53759. var global = _dereq_('../internals/global');
  53760. var toAbsoluteIndex = _dereq_('../internals/to-absolute-index');
  53761. var toIntegerOrInfinity = _dereq_('../internals/to-integer-or-infinity');
  53762. var lengthOfArrayLike = _dereq_('../internals/length-of-array-like');
  53763. var toObject = _dereq_('../internals/to-object');
  53764. var arraySpeciesCreate = _dereq_('../internals/array-species-create');
  53765. var createProperty = _dereq_('../internals/create-property');
  53766. var arrayMethodHasSpeciesSupport = _dereq_('../internals/array-method-has-species-support');
  53767. var HAS_SPECIES_SUPPORT = arrayMethodHasSpeciesSupport('splice');
  53768. var TypeError = global.TypeError;
  53769. var max = Math.max;
  53770. var min = Math.min;
  53771. var MAX_SAFE_INTEGER = 0x1FFFFFFFFFFFFF;
  53772. var MAXIMUM_ALLOWED_LENGTH_EXCEEDED = 'Maximum allowed length exceeded';
  53773. // `Array.prototype.splice` method
  53774. // https://tc39.es/ecma262/#sec-array.prototype.splice
  53775. // with adding support of @@species
  53776. $({ target: 'Array', proto: true, forced: !HAS_SPECIES_SUPPORT }, {
  53777. splice: function splice(start, deleteCount /* , ...items */) {
  53778. var O = toObject(this);
  53779. var len = lengthOfArrayLike(O);
  53780. var actualStart = toAbsoluteIndex(start, len);
  53781. var argumentsLength = arguments.length;
  53782. var insertCount, actualDeleteCount, A, k, from, to;
  53783. if (argumentsLength === 0) {
  53784. insertCount = actualDeleteCount = 0;
  53785. } else if (argumentsLength === 1) {
  53786. insertCount = 0;
  53787. actualDeleteCount = len - actualStart;
  53788. } else {
  53789. insertCount = argumentsLength - 2;
  53790. actualDeleteCount = min(max(toIntegerOrInfinity(deleteCount), 0), len - actualStart);
  53791. }
  53792. if (len + insertCount - actualDeleteCount > MAX_SAFE_INTEGER) {
  53793. throw TypeError(MAXIMUM_ALLOWED_LENGTH_EXCEEDED);
  53794. }
  53795. A = arraySpeciesCreate(O, actualDeleteCount);
  53796. for (k = 0; k < actualDeleteCount; k++) {
  53797. from = actualStart + k;
  53798. if (from in O) createProperty(A, k, O[from]);
  53799. }
  53800. A.length = actualDeleteCount;
  53801. if (insertCount < actualDeleteCount) {
  53802. for (k = actualStart; k < len - actualDeleteCount; k++) {
  53803. from = k + actualDeleteCount;
  53804. to = k + insertCount;
  53805. if (from in O) O[to] = O[from];
  53806. else delete O[to];
  53807. }
  53808. for (k = len; k > len - actualDeleteCount + insertCount; k--) delete O[k - 1];
  53809. } else if (insertCount > actualDeleteCount) {
  53810. for (k = len - actualDeleteCount; k > actualStart; k--) {
  53811. from = k + actualDeleteCount - 1;
  53812. to = k + insertCount - 1;
  53813. if (from in O) O[to] = O[from];
  53814. else delete O[to];
  53815. }
  53816. }
  53817. for (k = 0; k < insertCount; k++) {
  53818. O[k + actualStart] = arguments[k + 2];
  53819. }
  53820. O.length = len - actualDeleteCount + insertCount;
  53821. return A;
  53822. }
  53823. });
  53824. },{"../internals/array-method-has-species-support":432,"../internals/array-species-create":439,"../internals/create-property":457,"../internals/export":476,"../internals/global":491,"../internals/length-of-array-like":517,"../internals/to-absolute-index":571,"../internals/to-integer-or-infinity":573,"../internals/to-object":575}],604:[function(_dereq_,module,exports){
  53825. var $ = _dereq_('../internals/export');
  53826. var bind = _dereq_('../internals/function-bind');
  53827. // `Function.prototype.bind` method
  53828. // https://tc39.es/ecma262/#sec-function.prototype.bind
  53829. $({ target: 'Function', proto: true, forced: Function.bind !== bind }, {
  53830. bind: bind
  53831. });
  53832. },{"../internals/export":476,"../internals/function-bind":482}],605:[function(_dereq_,module,exports){
  53833. var $ = _dereq_('../internals/export');
  53834. var global = _dereq_('../internals/global');
  53835. var getBuiltIn = _dereq_('../internals/get-built-in');
  53836. var apply = _dereq_('../internals/function-apply');
  53837. var uncurryThis = _dereq_('../internals/function-uncurry-this');
  53838. var fails = _dereq_('../internals/fails');
  53839. var Array = global.Array;
  53840. var $stringify = getBuiltIn('JSON', 'stringify');
  53841. var exec = uncurryThis(/./.exec);
  53842. var charAt = uncurryThis(''.charAt);
  53843. var charCodeAt = uncurryThis(''.charCodeAt);
  53844. var replace = uncurryThis(''.replace);
  53845. var numberToString = uncurryThis(1.0.toString);
  53846. var tester = /[\uD800-\uDFFF]/g;
  53847. var low = /^[\uD800-\uDBFF]$/;
  53848. var hi = /^[\uDC00-\uDFFF]$/;
  53849. var fix = function (match, offset, string) {
  53850. var prev = charAt(string, offset - 1);
  53851. var next = charAt(string, offset + 1);
  53852. if ((exec(low, match) && !exec(hi, next)) || (exec(hi, match) && !exec(low, prev))) {
  53853. return '\\u' + numberToString(charCodeAt(match, 0), 16);
  53854. } return match;
  53855. };
  53856. var FORCED = fails(function () {
  53857. return $stringify('\uDF06\uD834') !== '"\\udf06\\ud834"'
  53858. || $stringify('\uDEAD') !== '"\\udead"';
  53859. });
  53860. if ($stringify) {
  53861. // `JSON.stringify` method
  53862. // https://tc39.es/ecma262/#sec-json.stringify
  53863. // https://github.com/tc39/proposal-well-formed-stringify
  53864. $({ target: 'JSON', stat: true, forced: FORCED }, {
  53865. // eslint-disable-next-line no-unused-vars -- required for `.length`
  53866. stringify: function stringify(it, replacer, space) {
  53867. for (var i = 0, l = arguments.length, args = Array(l); i < l; i++) args[i] = arguments[i];
  53868. var result = apply($stringify, null, args);
  53869. return typeof result == 'string' ? replace(result, tester, fix) : result;
  53870. }
  53871. });
  53872. }
  53873. },{"../internals/export":476,"../internals/fails":477,"../internals/function-apply":479,"../internals/function-uncurry-this":485,"../internals/get-built-in":486,"../internals/global":491}],606:[function(_dereq_,module,exports){
  53874. var global = _dereq_('../internals/global');
  53875. var setToStringTag = _dereq_('../internals/set-to-string-tag');
  53876. // JSON[@@toStringTag] property
  53877. // https://tc39.es/ecma262/#sec-json-@@tostringtag
  53878. setToStringTag(global.JSON, 'JSON', true);
  53879. },{"../internals/global":491,"../internals/set-to-string-tag":558}],607:[function(_dereq_,module,exports){
  53880. 'use strict';
  53881. var collection = _dereq_('../internals/collection');
  53882. var collectionStrong = _dereq_('../internals/collection-strong');
  53883. // `Map` constructor
  53884. // https://tc39.es/ecma262/#sec-map-objects
  53885. collection('Map', function (init) {
  53886. return function Map() { return init(this, arguments.length ? arguments[0] : undefined); };
  53887. }, collectionStrong);
  53888. },{"../internals/collection":450,"../internals/collection-strong":448}],608:[function(_dereq_,module,exports){
  53889. // empty
  53890. },{}],609:[function(_dereq_,module,exports){
  53891. var $ = _dereq_('../internals/export');
  53892. var isIntegralNumber = _dereq_('../internals/is-integral-number');
  53893. // `Number.isInteger` method
  53894. // https://tc39.es/ecma262/#sec-number.isinteger
  53895. $({ target: 'Number', stat: true }, {
  53896. isInteger: isIntegralNumber
  53897. });
  53898. },{"../internals/export":476,"../internals/is-integral-number":508}],610:[function(_dereq_,module,exports){
  53899. var $ = _dereq_('../internals/export');
  53900. // `Number.isNaN` method
  53901. // https://tc39.es/ecma262/#sec-number.isnan
  53902. $({ target: 'Number', stat: true }, {
  53903. isNaN: function isNaN(number) {
  53904. // eslint-disable-next-line no-self-compare -- NaN check
  53905. return number != number;
  53906. }
  53907. });
  53908. },{"../internals/export":476}],611:[function(_dereq_,module,exports){
  53909. var $ = _dereq_('../internals/export');
  53910. var DESCRIPTORS = _dereq_('../internals/descriptors');
  53911. var create = _dereq_('../internals/object-create');
  53912. // `Object.create` method
  53913. // https://tc39.es/ecma262/#sec-object.create
  53914. $({ target: 'Object', stat: true, sham: !DESCRIPTORS }, {
  53915. create: create
  53916. });
  53917. },{"../internals/descriptors":460,"../internals/export":476,"../internals/object-create":530}],612:[function(_dereq_,module,exports){
  53918. var $ = _dereq_('../internals/export');
  53919. var DESCRIPTORS = _dereq_('../internals/descriptors');
  53920. var defineProperties = _dereq_('../internals/object-define-properties').f;
  53921. // `Object.defineProperties` method
  53922. // https://tc39.es/ecma262/#sec-object.defineproperties
  53923. // eslint-disable-next-line es/no-object-defineproperties -- safe
  53924. $({ target: 'Object', stat: true, forced: Object.defineProperties !== defineProperties, sham: !DESCRIPTORS }, {
  53925. defineProperties: defineProperties
  53926. });
  53927. },{"../internals/descriptors":460,"../internals/export":476,"../internals/object-define-properties":531}],613:[function(_dereq_,module,exports){
  53928. var $ = _dereq_('../internals/export');
  53929. var DESCRIPTORS = _dereq_('../internals/descriptors');
  53930. var defineProperty = _dereq_('../internals/object-define-property').f;
  53931. // `Object.defineProperty` method
  53932. // https://tc39.es/ecma262/#sec-object.defineproperty
  53933. // eslint-disable-next-line es/no-object-defineproperty -- safe
  53934. $({ target: 'Object', stat: true, forced: Object.defineProperty !== defineProperty, sham: !DESCRIPTORS }, {
  53935. defineProperty: defineProperty
  53936. });
  53937. },{"../internals/descriptors":460,"../internals/export":476,"../internals/object-define-property":532}],614:[function(_dereq_,module,exports){
  53938. var $ = _dereq_('../internals/export');
  53939. var $entries = _dereq_('../internals/object-to-array').entries;
  53940. // `Object.entries` method
  53941. // https://tc39.es/ecma262/#sec-object.entries
  53942. $({ target: 'Object', stat: true }, {
  53943. entries: function entries(O) {
  53944. return $entries(O);
  53945. }
  53946. });
  53947. },{"../internals/export":476,"../internals/object-to-array":544}],615:[function(_dereq_,module,exports){
  53948. var $ = _dereq_('../internals/export');
  53949. var FREEZING = _dereq_('../internals/freezing');
  53950. var fails = _dereq_('../internals/fails');
  53951. var isObject = _dereq_('../internals/is-object');
  53952. var onFreeze = _dereq_('../internals/internal-metadata').onFreeze;
  53953. // eslint-disable-next-line es/no-object-freeze -- safe
  53954. var $freeze = Object.freeze;
  53955. var FAILS_ON_PRIMITIVES = fails(function () { $freeze(1); });
  53956. // `Object.freeze` method
  53957. // https://tc39.es/ecma262/#sec-object.freeze
  53958. $({ target: 'Object', stat: true, forced: FAILS_ON_PRIMITIVES, sham: !FREEZING }, {
  53959. freeze: function freeze(it) {
  53960. return $freeze && isObject(it) ? $freeze(onFreeze(it)) : it;
  53961. }
  53962. });
  53963. },{"../internals/export":476,"../internals/fails":477,"../internals/freezing":478,"../internals/internal-metadata":500,"../internals/is-object":509}],616:[function(_dereq_,module,exports){
  53964. var $ = _dereq_('../internals/export');
  53965. var fails = _dereq_('../internals/fails');
  53966. var toIndexedObject = _dereq_('../internals/to-indexed-object');
  53967. var nativeGetOwnPropertyDescriptor = _dereq_('../internals/object-get-own-property-descriptor').f;
  53968. var DESCRIPTORS = _dereq_('../internals/descriptors');
  53969. var FAILS_ON_PRIMITIVES = fails(function () { nativeGetOwnPropertyDescriptor(1); });
  53970. var FORCED = !DESCRIPTORS || FAILS_ON_PRIMITIVES;
  53971. // `Object.getOwnPropertyDescriptor` method
  53972. // https://tc39.es/ecma262/#sec-object.getownpropertydescriptor
  53973. $({ target: 'Object', stat: true, forced: FORCED, sham: !DESCRIPTORS }, {
  53974. getOwnPropertyDescriptor: function getOwnPropertyDescriptor(it, key) {
  53975. return nativeGetOwnPropertyDescriptor(toIndexedObject(it), key);
  53976. }
  53977. });
  53978. },{"../internals/descriptors":460,"../internals/export":476,"../internals/fails":477,"../internals/object-get-own-property-descriptor":533,"../internals/to-indexed-object":572}],617:[function(_dereq_,module,exports){
  53979. var $ = _dereq_('../internals/export');
  53980. var DESCRIPTORS = _dereq_('../internals/descriptors');
  53981. var ownKeys = _dereq_('../internals/own-keys');
  53982. var toIndexedObject = _dereq_('../internals/to-indexed-object');
  53983. var getOwnPropertyDescriptorModule = _dereq_('../internals/object-get-own-property-descriptor');
  53984. var createProperty = _dereq_('../internals/create-property');
  53985. // `Object.getOwnPropertyDescriptors` method
  53986. // https://tc39.es/ecma262/#sec-object.getownpropertydescriptors
  53987. $({ target: 'Object', stat: true, sham: !DESCRIPTORS }, {
  53988. getOwnPropertyDescriptors: function getOwnPropertyDescriptors(object) {
  53989. var O = toIndexedObject(object);
  53990. var getOwnPropertyDescriptor = getOwnPropertyDescriptorModule.f;
  53991. var keys = ownKeys(O);
  53992. var result = {};
  53993. var index = 0;
  53994. var key, descriptor;
  53995. while (keys.length > index) {
  53996. descriptor = getOwnPropertyDescriptor(O, key = keys[index++]);
  53997. if (descriptor !== undefined) createProperty(result, key, descriptor);
  53998. }
  53999. return result;
  54000. }
  54001. });
  54002. },{"../internals/create-property":457,"../internals/descriptors":460,"../internals/export":476,"../internals/object-get-own-property-descriptor":533,"../internals/own-keys":547,"../internals/to-indexed-object":572}],618:[function(_dereq_,module,exports){
  54003. var $ = _dereq_('../internals/export');
  54004. var fails = _dereq_('../internals/fails');
  54005. var toObject = _dereq_('../internals/to-object');
  54006. var nativeGetPrototypeOf = _dereq_('../internals/object-get-prototype-of');
  54007. var CORRECT_PROTOTYPE_GETTER = _dereq_('../internals/correct-prototype-getter');
  54008. var FAILS_ON_PRIMITIVES = fails(function () { nativeGetPrototypeOf(1); });
  54009. // `Object.getPrototypeOf` method
  54010. // https://tc39.es/ecma262/#sec-object.getprototypeof
  54011. $({ target: 'Object', stat: true, forced: FAILS_ON_PRIMITIVES, sham: !CORRECT_PROTOTYPE_GETTER }, {
  54012. getPrototypeOf: function getPrototypeOf(it) {
  54013. return nativeGetPrototypeOf(toObject(it));
  54014. }
  54015. });
  54016. },{"../internals/correct-prototype-getter":453,"../internals/export":476,"../internals/fails":477,"../internals/object-get-prototype-of":537,"../internals/to-object":575}],619:[function(_dereq_,module,exports){
  54017. var $ = _dereq_('../internals/export');
  54018. var toObject = _dereq_('../internals/to-object');
  54019. var nativeKeys = _dereq_('../internals/object-keys');
  54020. var fails = _dereq_('../internals/fails');
  54021. var FAILS_ON_PRIMITIVES = fails(function () { nativeKeys(1); });
  54022. // `Object.keys` method
  54023. // https://tc39.es/ecma262/#sec-object.keys
  54024. $({ target: 'Object', stat: true, forced: FAILS_ON_PRIMITIVES }, {
  54025. keys: function keys(it) {
  54026. return nativeKeys(toObject(it));
  54027. }
  54028. });
  54029. },{"../internals/export":476,"../internals/fails":477,"../internals/object-keys":541,"../internals/to-object":575}],620:[function(_dereq_,module,exports){
  54030. var $ = _dereq_('../internals/export');
  54031. var setPrototypeOf = _dereq_('../internals/object-set-prototype-of');
  54032. // `Object.setPrototypeOf` method
  54033. // https://tc39.es/ecma262/#sec-object.setprototypeof
  54034. $({ target: 'Object', stat: true }, {
  54035. setPrototypeOf: setPrototypeOf
  54036. });
  54037. },{"../internals/export":476,"../internals/object-set-prototype-of":543}],621:[function(_dereq_,module,exports){
  54038. arguments[4][608][0].apply(exports,arguments)
  54039. },{"dup":608}],622:[function(_dereq_,module,exports){
  54040. var $ = _dereq_('../internals/export');
  54041. var $values = _dereq_('../internals/object-to-array').values;
  54042. // `Object.values` method
  54043. // https://tc39.es/ecma262/#sec-object.values
  54044. $({ target: 'Object', stat: true }, {
  54045. values: function values(O) {
  54046. return $values(O);
  54047. }
  54048. });
  54049. },{"../internals/export":476,"../internals/object-to-array":544}],623:[function(_dereq_,module,exports){
  54050. var $ = _dereq_('../internals/export');
  54051. var $parseInt = _dereq_('../internals/number-parse-int');
  54052. // `parseInt` method
  54053. // https://tc39.es/ecma262/#sec-parseint-string-radix
  54054. $({ global: true, forced: parseInt != $parseInt }, {
  54055. parseInt: $parseInt
  54056. });
  54057. },{"../internals/export":476,"../internals/number-parse-int":528}],624:[function(_dereq_,module,exports){
  54058. 'use strict';
  54059. var $ = _dereq_('../internals/export');
  54060. var call = _dereq_('../internals/function-call');
  54061. var aCallable = _dereq_('../internals/a-callable');
  54062. var newPromiseCapabilityModule = _dereq_('../internals/new-promise-capability');
  54063. var perform = _dereq_('../internals/perform');
  54064. var iterate = _dereq_('../internals/iterate');
  54065. // `Promise.allSettled` method
  54066. // https://tc39.es/ecma262/#sec-promise.allsettled
  54067. $({ target: 'Promise', stat: true }, {
  54068. allSettled: function allSettled(iterable) {
  54069. var C = this;
  54070. var capability = newPromiseCapabilityModule.f(C);
  54071. var resolve = capability.resolve;
  54072. var reject = capability.reject;
  54073. var result = perform(function () {
  54074. var promiseResolve = aCallable(C.resolve);
  54075. var values = [];
  54076. var counter = 0;
  54077. var remaining = 1;
  54078. iterate(iterable, function (promise) {
  54079. var index = counter++;
  54080. var alreadyCalled = false;
  54081. remaining++;
  54082. call(promiseResolve, C, promise).then(function (value) {
  54083. if (alreadyCalled) return;
  54084. alreadyCalled = true;
  54085. values[index] = { status: 'fulfilled', value: value };
  54086. --remaining || resolve(values);
  54087. }, function (error) {
  54088. if (alreadyCalled) return;
  54089. alreadyCalled = true;
  54090. values[index] = { status: 'rejected', reason: error };
  54091. --remaining || resolve(values);
  54092. });
  54093. });
  54094. --remaining || resolve(values);
  54095. });
  54096. if (result.error) reject(result.value);
  54097. return capability.promise;
  54098. }
  54099. });
  54100. },{"../internals/a-callable":421,"../internals/export":476,"../internals/function-call":483,"../internals/iterate":513,"../internals/new-promise-capability":525,"../internals/perform":549}],625:[function(_dereq_,module,exports){
  54101. 'use strict';
  54102. var $ = _dereq_('../internals/export');
  54103. var aCallable = _dereq_('../internals/a-callable');
  54104. var getBuiltIn = _dereq_('../internals/get-built-in');
  54105. var call = _dereq_('../internals/function-call');
  54106. var newPromiseCapabilityModule = _dereq_('../internals/new-promise-capability');
  54107. var perform = _dereq_('../internals/perform');
  54108. var iterate = _dereq_('../internals/iterate');
  54109. var PROMISE_ANY_ERROR = 'No one promise resolved';
  54110. // `Promise.any` method
  54111. // https://tc39.es/ecma262/#sec-promise.any
  54112. $({ target: 'Promise', stat: true }, {
  54113. any: function any(iterable) {
  54114. var C = this;
  54115. var AggregateError = getBuiltIn('AggregateError');
  54116. var capability = newPromiseCapabilityModule.f(C);
  54117. var resolve = capability.resolve;
  54118. var reject = capability.reject;
  54119. var result = perform(function () {
  54120. var promiseResolve = aCallable(C.resolve);
  54121. var errors = [];
  54122. var counter = 0;
  54123. var remaining = 1;
  54124. var alreadyResolved = false;
  54125. iterate(iterable, function (promise) {
  54126. var index = counter++;
  54127. var alreadyRejected = false;
  54128. remaining++;
  54129. call(promiseResolve, C, promise).then(function (value) {
  54130. if (alreadyRejected || alreadyResolved) return;
  54131. alreadyResolved = true;
  54132. resolve(value);
  54133. }, function (error) {
  54134. if (alreadyRejected || alreadyResolved) return;
  54135. alreadyRejected = true;
  54136. errors[index] = error;
  54137. --remaining || reject(new AggregateError(errors, PROMISE_ANY_ERROR));
  54138. });
  54139. });
  54140. --remaining || reject(new AggregateError(errors, PROMISE_ANY_ERROR));
  54141. });
  54142. if (result.error) reject(result.value);
  54143. return capability.promise;
  54144. }
  54145. });
  54146. },{"../internals/a-callable":421,"../internals/export":476,"../internals/function-call":483,"../internals/get-built-in":486,"../internals/iterate":513,"../internals/new-promise-capability":525,"../internals/perform":549}],626:[function(_dereq_,module,exports){
  54147. 'use strict';
  54148. var $ = _dereq_('../internals/export');
  54149. var IS_PURE = _dereq_('../internals/is-pure');
  54150. var NativePromise = _dereq_('../internals/native-promise-constructor');
  54151. var fails = _dereq_('../internals/fails');
  54152. var getBuiltIn = _dereq_('../internals/get-built-in');
  54153. var isCallable = _dereq_('../internals/is-callable');
  54154. var speciesConstructor = _dereq_('../internals/species-constructor');
  54155. var promiseResolve = _dereq_('../internals/promise-resolve');
  54156. var redefine = _dereq_('../internals/redefine');
  54157. // Safari bug https://bugs.webkit.org/show_bug.cgi?id=200829
  54158. var NON_GENERIC = !!NativePromise && fails(function () {
  54159. // eslint-disable-next-line unicorn/no-thenable -- required for testing
  54160. NativePromise.prototype['finally'].call({ then: function () { /* empty */ } }, function () { /* empty */ });
  54161. });
  54162. // `Promise.prototype.finally` method
  54163. // https://tc39.es/ecma262/#sec-promise.prototype.finally
  54164. $({ target: 'Promise', proto: true, real: true, forced: NON_GENERIC }, {
  54165. 'finally': function (onFinally) {
  54166. var C = speciesConstructor(this, getBuiltIn('Promise'));
  54167. var isFunction = isCallable(onFinally);
  54168. return this.then(
  54169. isFunction ? function (x) {
  54170. return promiseResolve(C, onFinally()).then(function () { return x; });
  54171. } : onFinally,
  54172. isFunction ? function (e) {
  54173. return promiseResolve(C, onFinally()).then(function () { throw e; });
  54174. } : onFinally
  54175. );
  54176. }
  54177. });
  54178. // makes sure that native promise-based APIs `Promise#finally` properly works with patched `Promise#then`
  54179. if (!IS_PURE && isCallable(NativePromise)) {
  54180. var method = getBuiltIn('Promise').prototype['finally'];
  54181. if (NativePromise.prototype['finally'] !== method) {
  54182. redefine(NativePromise.prototype, 'finally', method, { unsafe: true });
  54183. }
  54184. }
  54185. },{"../internals/export":476,"../internals/fails":477,"../internals/get-built-in":486,"../internals/is-callable":504,"../internals/is-pure":510,"../internals/native-promise-constructor":521,"../internals/promise-resolve":550,"../internals/redefine":553,"../internals/species-constructor":562}],627:[function(_dereq_,module,exports){
  54186. 'use strict';
  54187. var $ = _dereq_('../internals/export');
  54188. var IS_PURE = _dereq_('../internals/is-pure');
  54189. var global = _dereq_('../internals/global');
  54190. var getBuiltIn = _dereq_('../internals/get-built-in');
  54191. var call = _dereq_('../internals/function-call');
  54192. var NativePromise = _dereq_('../internals/native-promise-constructor');
  54193. var redefine = _dereq_('../internals/redefine');
  54194. var redefineAll = _dereq_('../internals/redefine-all');
  54195. var setPrototypeOf = _dereq_('../internals/object-set-prototype-of');
  54196. var setToStringTag = _dereq_('../internals/set-to-string-tag');
  54197. var setSpecies = _dereq_('../internals/set-species');
  54198. var aCallable = _dereq_('../internals/a-callable');
  54199. var isCallable = _dereq_('../internals/is-callable');
  54200. var isObject = _dereq_('../internals/is-object');
  54201. var anInstance = _dereq_('../internals/an-instance');
  54202. var inspectSource = _dereq_('../internals/inspect-source');
  54203. var iterate = _dereq_('../internals/iterate');
  54204. var checkCorrectnessOfIteration = _dereq_('../internals/check-correctness-of-iteration');
  54205. var speciesConstructor = _dereq_('../internals/species-constructor');
  54206. var task = _dereq_('../internals/task').set;
  54207. var microtask = _dereq_('../internals/microtask');
  54208. var promiseResolve = _dereq_('../internals/promise-resolve');
  54209. var hostReportErrors = _dereq_('../internals/host-report-errors');
  54210. var newPromiseCapabilityModule = _dereq_('../internals/new-promise-capability');
  54211. var perform = _dereq_('../internals/perform');
  54212. var Queue = _dereq_('../internals/queue');
  54213. var InternalStateModule = _dereq_('../internals/internal-state');
  54214. var isForced = _dereq_('../internals/is-forced');
  54215. var wellKnownSymbol = _dereq_('../internals/well-known-symbol');
  54216. var IS_BROWSER = _dereq_('../internals/engine-is-browser');
  54217. var IS_NODE = _dereq_('../internals/engine-is-node');
  54218. var V8_VERSION = _dereq_('../internals/engine-v8-version');
  54219. var SPECIES = wellKnownSymbol('species');
  54220. var PROMISE = 'Promise';
  54221. var getInternalState = InternalStateModule.getterFor(PROMISE);
  54222. var setInternalState = InternalStateModule.set;
  54223. var getInternalPromiseState = InternalStateModule.getterFor(PROMISE);
  54224. var NativePromisePrototype = NativePromise && NativePromise.prototype;
  54225. var PromiseConstructor = NativePromise;
  54226. var PromisePrototype = NativePromisePrototype;
  54227. var TypeError = global.TypeError;
  54228. var document = global.document;
  54229. var process = global.process;
  54230. var newPromiseCapability = newPromiseCapabilityModule.f;
  54231. var newGenericPromiseCapability = newPromiseCapability;
  54232. var DISPATCH_EVENT = !!(document && document.createEvent && global.dispatchEvent);
  54233. var NATIVE_REJECTION_EVENT = isCallable(global.PromiseRejectionEvent);
  54234. var UNHANDLED_REJECTION = 'unhandledrejection';
  54235. var REJECTION_HANDLED = 'rejectionhandled';
  54236. var PENDING = 0;
  54237. var FULFILLED = 1;
  54238. var REJECTED = 2;
  54239. var HANDLED = 1;
  54240. var UNHANDLED = 2;
  54241. var SUBCLASSING = false;
  54242. var Internal, OwnPromiseCapability, PromiseWrapper, nativeThen;
  54243. var FORCED = isForced(PROMISE, function () {
  54244. var PROMISE_CONSTRUCTOR_SOURCE = inspectSource(PromiseConstructor);
  54245. var GLOBAL_CORE_JS_PROMISE = PROMISE_CONSTRUCTOR_SOURCE !== String(PromiseConstructor);
  54246. // V8 6.6 (Node 10 and Chrome 66) have a bug with resolving custom thenables
  54247. // https://bugs.chromium.org/p/chromium/issues/detail?id=830565
  54248. // We can't detect it synchronously, so just check versions
  54249. if (!GLOBAL_CORE_JS_PROMISE && V8_VERSION === 66) return true;
  54250. // We need Promise#finally in the pure version for preventing prototype pollution
  54251. if (IS_PURE && !PromisePrototype['finally']) return true;
  54252. // We can't use @@species feature detection in V8 since it causes
  54253. // deoptimization and performance degradation
  54254. // https://github.com/zloirock/core-js/issues/679
  54255. if (V8_VERSION >= 51 && /native code/.test(PROMISE_CONSTRUCTOR_SOURCE)) return false;
  54256. // Detect correctness of subclassing with @@species support
  54257. var promise = new PromiseConstructor(function (resolve) { resolve(1); });
  54258. var FakePromise = function (exec) {
  54259. exec(function () { /* empty */ }, function () { /* empty */ });
  54260. };
  54261. var constructor = promise.constructor = {};
  54262. constructor[SPECIES] = FakePromise;
  54263. SUBCLASSING = promise.then(function () { /* empty */ }) instanceof FakePromise;
  54264. if (!SUBCLASSING) return true;
  54265. // Unhandled rejections tracking support, NodeJS Promise without it fails @@species test
  54266. return !GLOBAL_CORE_JS_PROMISE && IS_BROWSER && !NATIVE_REJECTION_EVENT;
  54267. });
  54268. var INCORRECT_ITERATION = FORCED || !checkCorrectnessOfIteration(function (iterable) {
  54269. PromiseConstructor.all(iterable)['catch'](function () { /* empty */ });
  54270. });
  54271. // helpers
  54272. var isThenable = function (it) {
  54273. var then;
  54274. return isObject(it) && isCallable(then = it.then) ? then : false;
  54275. };
  54276. var callReaction = function (reaction, state) {
  54277. var value = state.value;
  54278. var ok = state.state == FULFILLED;
  54279. var handler = ok ? reaction.ok : reaction.fail;
  54280. var resolve = reaction.resolve;
  54281. var reject = reaction.reject;
  54282. var domain = reaction.domain;
  54283. var result, then, exited;
  54284. try {
  54285. if (handler) {
  54286. if (!ok) {
  54287. if (state.rejection === UNHANDLED) onHandleUnhandled(state);
  54288. state.rejection = HANDLED;
  54289. }
  54290. if (handler === true) result = value;
  54291. else {
  54292. if (domain) domain.enter();
  54293. result = handler(value); // can throw
  54294. if (domain) {
  54295. domain.exit();
  54296. exited = true;
  54297. }
  54298. }
  54299. if (result === reaction.promise) {
  54300. reject(TypeError('Promise-chain cycle'));
  54301. } else if (then = isThenable(result)) {
  54302. call(then, result, resolve, reject);
  54303. } else resolve(result);
  54304. } else reject(value);
  54305. } catch (error) {
  54306. if (domain && !exited) domain.exit();
  54307. reject(error);
  54308. }
  54309. };
  54310. var notify = function (state, isReject) {
  54311. if (state.notified) return;
  54312. state.notified = true;
  54313. microtask(function () {
  54314. var reactions = state.reactions;
  54315. var reaction;
  54316. while (reaction = reactions.get()) {
  54317. callReaction(reaction, state);
  54318. }
  54319. state.notified = false;
  54320. if (isReject && !state.rejection) onUnhandled(state);
  54321. });
  54322. };
  54323. var dispatchEvent = function (name, promise, reason) {
  54324. var event, handler;
  54325. if (DISPATCH_EVENT) {
  54326. event = document.createEvent('Event');
  54327. event.promise = promise;
  54328. event.reason = reason;
  54329. event.initEvent(name, false, true);
  54330. global.dispatchEvent(event);
  54331. } else event = { promise: promise, reason: reason };
  54332. if (!NATIVE_REJECTION_EVENT && (handler = global['on' + name])) handler(event);
  54333. else if (name === UNHANDLED_REJECTION) hostReportErrors('Unhandled promise rejection', reason);
  54334. };
  54335. var onUnhandled = function (state) {
  54336. call(task, global, function () {
  54337. var promise = state.facade;
  54338. var value = state.value;
  54339. var IS_UNHANDLED = isUnhandled(state);
  54340. var result;
  54341. if (IS_UNHANDLED) {
  54342. result = perform(function () {
  54343. if (IS_NODE) {
  54344. process.emit('unhandledRejection', value, promise);
  54345. } else dispatchEvent(UNHANDLED_REJECTION, promise, value);
  54346. });
  54347. // Browsers should not trigger `rejectionHandled` event if it was handled here, NodeJS - should
  54348. state.rejection = IS_NODE || isUnhandled(state) ? UNHANDLED : HANDLED;
  54349. if (result.error) throw result.value;
  54350. }
  54351. });
  54352. };
  54353. var isUnhandled = function (state) {
  54354. return state.rejection !== HANDLED && !state.parent;
  54355. };
  54356. var onHandleUnhandled = function (state) {
  54357. call(task, global, function () {
  54358. var promise = state.facade;
  54359. if (IS_NODE) {
  54360. process.emit('rejectionHandled', promise);
  54361. } else dispatchEvent(REJECTION_HANDLED, promise, state.value);
  54362. });
  54363. };
  54364. var bind = function (fn, state, unwrap) {
  54365. return function (value) {
  54366. fn(state, value, unwrap);
  54367. };
  54368. };
  54369. var internalReject = function (state, value, unwrap) {
  54370. if (state.done) return;
  54371. state.done = true;
  54372. if (unwrap) state = unwrap;
  54373. state.value = value;
  54374. state.state = REJECTED;
  54375. notify(state, true);
  54376. };
  54377. var internalResolve = function (state, value, unwrap) {
  54378. if (state.done) return;
  54379. state.done = true;
  54380. if (unwrap) state = unwrap;
  54381. try {
  54382. if (state.facade === value) throw TypeError("Promise can't be resolved itself");
  54383. var then = isThenable(value);
  54384. if (then) {
  54385. microtask(function () {
  54386. var wrapper = { done: false };
  54387. try {
  54388. call(then, value,
  54389. bind(internalResolve, wrapper, state),
  54390. bind(internalReject, wrapper, state)
  54391. );
  54392. } catch (error) {
  54393. internalReject(wrapper, error, state);
  54394. }
  54395. });
  54396. } else {
  54397. state.value = value;
  54398. state.state = FULFILLED;
  54399. notify(state, false);
  54400. }
  54401. } catch (error) {
  54402. internalReject({ done: false }, error, state);
  54403. }
  54404. };
  54405. // constructor polyfill
  54406. if (FORCED) {
  54407. // 25.4.3.1 Promise(executor)
  54408. PromiseConstructor = function Promise(executor) {
  54409. anInstance(this, PromisePrototype);
  54410. aCallable(executor);
  54411. call(Internal, this);
  54412. var state = getInternalState(this);
  54413. try {
  54414. executor(bind(internalResolve, state), bind(internalReject, state));
  54415. } catch (error) {
  54416. internalReject(state, error);
  54417. }
  54418. };
  54419. PromisePrototype = PromiseConstructor.prototype;
  54420. // eslint-disable-next-line no-unused-vars -- required for `.length`
  54421. Internal = function Promise(executor) {
  54422. setInternalState(this, {
  54423. type: PROMISE,
  54424. done: false,
  54425. notified: false,
  54426. parent: false,
  54427. reactions: new Queue(),
  54428. rejection: false,
  54429. state: PENDING,
  54430. value: undefined
  54431. });
  54432. };
  54433. Internal.prototype = redefineAll(PromisePrototype, {
  54434. // `Promise.prototype.then` method
  54435. // https://tc39.es/ecma262/#sec-promise.prototype.then
  54436. // eslint-disable-next-line unicorn/no-thenable -- safe
  54437. then: function then(onFulfilled, onRejected) {
  54438. var state = getInternalPromiseState(this);
  54439. var reaction = newPromiseCapability(speciesConstructor(this, PromiseConstructor));
  54440. state.parent = true;
  54441. reaction.ok = isCallable(onFulfilled) ? onFulfilled : true;
  54442. reaction.fail = isCallable(onRejected) && onRejected;
  54443. reaction.domain = IS_NODE ? process.domain : undefined;
  54444. if (state.state == PENDING) state.reactions.add(reaction);
  54445. else microtask(function () {
  54446. callReaction(reaction, state);
  54447. });
  54448. return reaction.promise;
  54449. },
  54450. // `Promise.prototype.catch` method
  54451. // https://tc39.es/ecma262/#sec-promise.prototype.catch
  54452. 'catch': function (onRejected) {
  54453. return this.then(undefined, onRejected);
  54454. }
  54455. });
  54456. OwnPromiseCapability = function () {
  54457. var promise = new Internal();
  54458. var state = getInternalState(promise);
  54459. this.promise = promise;
  54460. this.resolve = bind(internalResolve, state);
  54461. this.reject = bind(internalReject, state);
  54462. };
  54463. newPromiseCapabilityModule.f = newPromiseCapability = function (C) {
  54464. return C === PromiseConstructor || C === PromiseWrapper
  54465. ? new OwnPromiseCapability(C)
  54466. : newGenericPromiseCapability(C);
  54467. };
  54468. if (!IS_PURE && isCallable(NativePromise) && NativePromisePrototype !== Object.prototype) {
  54469. nativeThen = NativePromisePrototype.then;
  54470. if (!SUBCLASSING) {
  54471. // make `Promise#then` return a polyfilled `Promise` for native promise-based APIs
  54472. redefine(NativePromisePrototype, 'then', function then(onFulfilled, onRejected) {
  54473. var that = this;
  54474. return new PromiseConstructor(function (resolve, reject) {
  54475. call(nativeThen, that, resolve, reject);
  54476. }).then(onFulfilled, onRejected);
  54477. // https://github.com/zloirock/core-js/issues/640
  54478. }, { unsafe: true });
  54479. // makes sure that native promise-based APIs `Promise#catch` properly works with patched `Promise#then`
  54480. redefine(NativePromisePrototype, 'catch', PromisePrototype['catch'], { unsafe: true });
  54481. }
  54482. // make `.constructor === Promise` work for native promise-based APIs
  54483. try {
  54484. delete NativePromisePrototype.constructor;
  54485. } catch (error) { /* empty */ }
  54486. // make `instanceof Promise` work for native promise-based APIs
  54487. if (setPrototypeOf) {
  54488. setPrototypeOf(NativePromisePrototype, PromisePrototype);
  54489. }
  54490. }
  54491. }
  54492. $({ global: true, wrap: true, forced: FORCED }, {
  54493. Promise: PromiseConstructor
  54494. });
  54495. setToStringTag(PromiseConstructor, PROMISE, false, true);
  54496. setSpecies(PROMISE);
  54497. PromiseWrapper = getBuiltIn(PROMISE);
  54498. // statics
  54499. $({ target: PROMISE, stat: true, forced: FORCED }, {
  54500. // `Promise.reject` method
  54501. // https://tc39.es/ecma262/#sec-promise.reject
  54502. reject: function reject(r) {
  54503. var capability = newPromiseCapability(this);
  54504. call(capability.reject, undefined, r);
  54505. return capability.promise;
  54506. }
  54507. });
  54508. $({ target: PROMISE, stat: true, forced: IS_PURE || FORCED }, {
  54509. // `Promise.resolve` method
  54510. // https://tc39.es/ecma262/#sec-promise.resolve
  54511. resolve: function resolve(x) {
  54512. return promiseResolve(IS_PURE && this === PromiseWrapper ? PromiseConstructor : this, x);
  54513. }
  54514. });
  54515. $({ target: PROMISE, stat: true, forced: INCORRECT_ITERATION }, {
  54516. // `Promise.all` method
  54517. // https://tc39.es/ecma262/#sec-promise.all
  54518. all: function all(iterable) {
  54519. var C = this;
  54520. var capability = newPromiseCapability(C);
  54521. var resolve = capability.resolve;
  54522. var reject = capability.reject;
  54523. var result = perform(function () {
  54524. var $promiseResolve = aCallable(C.resolve);
  54525. var values = [];
  54526. var counter = 0;
  54527. var remaining = 1;
  54528. iterate(iterable, function (promise) {
  54529. var index = counter++;
  54530. var alreadyCalled = false;
  54531. remaining++;
  54532. call($promiseResolve, C, promise).then(function (value) {
  54533. if (alreadyCalled) return;
  54534. alreadyCalled = true;
  54535. values[index] = value;
  54536. --remaining || resolve(values);
  54537. }, reject);
  54538. });
  54539. --remaining || resolve(values);
  54540. });
  54541. if (result.error) reject(result.value);
  54542. return capability.promise;
  54543. },
  54544. // `Promise.race` method
  54545. // https://tc39.es/ecma262/#sec-promise.race
  54546. race: function race(iterable) {
  54547. var C = this;
  54548. var capability = newPromiseCapability(C);
  54549. var reject = capability.reject;
  54550. var result = perform(function () {
  54551. var $promiseResolve = aCallable(C.resolve);
  54552. iterate(iterable, function (promise) {
  54553. call($promiseResolve, C, promise).then(capability.resolve, reject);
  54554. });
  54555. });
  54556. if (result.error) reject(result.value);
  54557. return capability.promise;
  54558. }
  54559. });
  54560. },{"../internals/a-callable":421,"../internals/an-instance":425,"../internals/check-correctness-of-iteration":441,"../internals/engine-is-browser":464,"../internals/engine-is-node":468,"../internals/engine-v8-version":471,"../internals/export":476,"../internals/function-call":483,"../internals/get-built-in":486,"../internals/global":491,"../internals/host-report-errors":494,"../internals/inspect-source":498,"../internals/internal-state":501,"../internals/is-callable":504,"../internals/is-forced":507,"../internals/is-object":509,"../internals/is-pure":510,"../internals/iterate":513,"../internals/microtask":520,"../internals/native-promise-constructor":521,"../internals/new-promise-capability":525,"../internals/object-set-prototype-of":543,"../internals/perform":549,"../internals/promise-resolve":550,"../internals/queue":551,"../internals/redefine":553,"../internals/redefine-all":552,"../internals/set-species":557,"../internals/set-to-string-tag":558,"../internals/species-constructor":562,"../internals/task":570,"../internals/well-known-symbol":586}],628:[function(_dereq_,module,exports){
  54561. var $ = _dereq_('../internals/export');
  54562. var getBuiltIn = _dereq_('../internals/get-built-in');
  54563. var apply = _dereq_('../internals/function-apply');
  54564. var bind = _dereq_('../internals/function-bind');
  54565. var aConstructor = _dereq_('../internals/a-constructor');
  54566. var anObject = _dereq_('../internals/an-object');
  54567. var isObject = _dereq_('../internals/is-object');
  54568. var create = _dereq_('../internals/object-create');
  54569. var fails = _dereq_('../internals/fails');
  54570. var nativeConstruct = getBuiltIn('Reflect', 'construct');
  54571. var ObjectPrototype = Object.prototype;
  54572. var push = [].push;
  54573. // `Reflect.construct` method
  54574. // https://tc39.es/ecma262/#sec-reflect.construct
  54575. // MS Edge supports only 2 arguments and argumentsList argument is optional
  54576. // FF Nightly sets third argument as `new.target`, but does not create `this` from it
  54577. var NEW_TARGET_BUG = fails(function () {
  54578. function F() { /* empty */ }
  54579. return !(nativeConstruct(function () { /* empty */ }, [], F) instanceof F);
  54580. });
  54581. var ARGS_BUG = !fails(function () {
  54582. nativeConstruct(function () { /* empty */ });
  54583. });
  54584. var FORCED = NEW_TARGET_BUG || ARGS_BUG;
  54585. $({ target: 'Reflect', stat: true, forced: FORCED, sham: FORCED }, {
  54586. construct: function construct(Target, args /* , newTarget */) {
  54587. aConstructor(Target);
  54588. anObject(args);
  54589. var newTarget = arguments.length < 3 ? Target : aConstructor(arguments[2]);
  54590. if (ARGS_BUG && !NEW_TARGET_BUG) return nativeConstruct(Target, args, newTarget);
  54591. if (Target == newTarget) {
  54592. // w/o altered newTarget, optimization for 0-4 arguments
  54593. switch (args.length) {
  54594. case 0: return new Target();
  54595. case 1: return new Target(args[0]);
  54596. case 2: return new Target(args[0], args[1]);
  54597. case 3: return new Target(args[0], args[1], args[2]);
  54598. case 4: return new Target(args[0], args[1], args[2], args[3]);
  54599. }
  54600. // w/o altered newTarget, lot of arguments case
  54601. var $args = [null];
  54602. apply(push, $args, args);
  54603. return new (apply(bind, Target, $args))();
  54604. }
  54605. // with altered newTarget, not support built-in constructors
  54606. var proto = newTarget.prototype;
  54607. var instance = create(isObject(proto) ? proto : ObjectPrototype);
  54608. var result = apply(Target, instance, args);
  54609. return isObject(result) ? result : instance;
  54610. }
  54611. });
  54612. },{"../internals/a-constructor":422,"../internals/an-object":426,"../internals/export":476,"../internals/fails":477,"../internals/function-apply":479,"../internals/function-bind":482,"../internals/get-built-in":486,"../internals/is-object":509,"../internals/object-create":530}],629:[function(_dereq_,module,exports){
  54613. var $ = _dereq_('../internals/export');
  54614. var call = _dereq_('../internals/function-call');
  54615. var isObject = _dereq_('../internals/is-object');
  54616. var anObject = _dereq_('../internals/an-object');
  54617. var isDataDescriptor = _dereq_('../internals/is-data-descriptor');
  54618. var getOwnPropertyDescriptorModule = _dereq_('../internals/object-get-own-property-descriptor');
  54619. var getPrototypeOf = _dereq_('../internals/object-get-prototype-of');
  54620. // `Reflect.get` method
  54621. // https://tc39.es/ecma262/#sec-reflect.get
  54622. function get(target, propertyKey /* , receiver */) {
  54623. var receiver = arguments.length < 3 ? target : arguments[2];
  54624. var descriptor, prototype;
  54625. if (anObject(target) === receiver) return target[propertyKey];
  54626. descriptor = getOwnPropertyDescriptorModule.f(target, propertyKey);
  54627. if (descriptor) return isDataDescriptor(descriptor)
  54628. ? descriptor.value
  54629. : descriptor.get === undefined ? undefined : call(descriptor.get, receiver);
  54630. if (isObject(prototype = getPrototypeOf(target))) return get(prototype, propertyKey, receiver);
  54631. }
  54632. $({ target: 'Reflect', stat: true }, {
  54633. get: get
  54634. });
  54635. },{"../internals/an-object":426,"../internals/export":476,"../internals/function-call":483,"../internals/is-data-descriptor":506,"../internals/is-object":509,"../internals/object-get-own-property-descriptor":533,"../internals/object-get-prototype-of":537}],630:[function(_dereq_,module,exports){
  54636. arguments[4][608][0].apply(exports,arguments)
  54637. },{"dup":608}],631:[function(_dereq_,module,exports){
  54638. arguments[4][608][0].apply(exports,arguments)
  54639. },{"dup":608}],632:[function(_dereq_,module,exports){
  54640. 'use strict';
  54641. var collection = _dereq_('../internals/collection');
  54642. var collectionStrong = _dereq_('../internals/collection-strong');
  54643. // `Set` constructor
  54644. // https://tc39.es/ecma262/#sec-set-objects
  54645. collection('Set', function (init) {
  54646. return function Set() { return init(this, arguments.length ? arguments[0] : undefined); };
  54647. }, collectionStrong);
  54648. },{"../internals/collection":450,"../internals/collection-strong":448}],633:[function(_dereq_,module,exports){
  54649. 'use strict';
  54650. var $ = _dereq_('../internals/export');
  54651. var uncurryThis = _dereq_('../internals/function-uncurry-this');
  54652. var notARegExp = _dereq_('../internals/not-a-regexp');
  54653. var requireObjectCoercible = _dereq_('../internals/require-object-coercible');
  54654. var toString = _dereq_('../internals/to-string');
  54655. var correctIsRegExpLogic = _dereq_('../internals/correct-is-regexp-logic');
  54656. var stringIndexOf = uncurryThis(''.indexOf);
  54657. // `String.prototype.includes` method
  54658. // https://tc39.es/ecma262/#sec-string.prototype.includes
  54659. $({ target: 'String', proto: true, forced: !correctIsRegExpLogic('includes') }, {
  54660. includes: function includes(searchString /* , position = 0 */) {
  54661. return !!~stringIndexOf(
  54662. toString(requireObjectCoercible(this)),
  54663. toString(notARegExp(searchString)),
  54664. arguments.length > 1 ? arguments[1] : undefined
  54665. );
  54666. }
  54667. });
  54668. },{"../internals/correct-is-regexp-logic":452,"../internals/export":476,"../internals/function-uncurry-this":485,"../internals/not-a-regexp":527,"../internals/require-object-coercible":554,"../internals/to-string":579}],634:[function(_dereq_,module,exports){
  54669. 'use strict';
  54670. var charAt = _dereq_('../internals/string-multibyte').charAt;
  54671. var toString = _dereq_('../internals/to-string');
  54672. var InternalStateModule = _dereq_('../internals/internal-state');
  54673. var defineIterator = _dereq_('../internals/define-iterator');
  54674. var STRING_ITERATOR = 'String Iterator';
  54675. var setInternalState = InternalStateModule.set;
  54676. var getInternalState = InternalStateModule.getterFor(STRING_ITERATOR);
  54677. // `String.prototype[@@iterator]` method
  54678. // https://tc39.es/ecma262/#sec-string.prototype-@@iterator
  54679. defineIterator(String, 'String', function (iterated) {
  54680. setInternalState(this, {
  54681. type: STRING_ITERATOR,
  54682. string: toString(iterated),
  54683. index: 0
  54684. });
  54685. // `%StringIteratorPrototype%.next` method
  54686. // https://tc39.es/ecma262/#sec-%stringiteratorprototype%.next
  54687. }, function next() {
  54688. var state = getInternalState(this);
  54689. var string = state.string;
  54690. var index = state.index;
  54691. var point;
  54692. if (index >= string.length) return { value: undefined, done: true };
  54693. point = charAt(string, index);
  54694. state.index += point.length;
  54695. return { value: point, done: false };
  54696. });
  54697. },{"../internals/define-iterator":458,"../internals/internal-state":501,"../internals/string-multibyte":563,"../internals/to-string":579}],635:[function(_dereq_,module,exports){
  54698. 'use strict';
  54699. var $ = _dereq_('../internals/export');
  54700. var $padStart = _dereq_('../internals/string-pad').start;
  54701. var WEBKIT_BUG = _dereq_('../internals/string-pad-webkit-bug');
  54702. // `String.prototype.padStart` method
  54703. // https://tc39.es/ecma262/#sec-string.prototype.padstart
  54704. $({ target: 'String', proto: true, forced: WEBKIT_BUG }, {
  54705. padStart: function padStart(maxLength /* , fillString = ' ' */) {
  54706. return $padStart(this, maxLength, arguments.length > 1 ? arguments[1] : undefined);
  54707. }
  54708. });
  54709. },{"../internals/export":476,"../internals/string-pad":565,"../internals/string-pad-webkit-bug":564}],636:[function(_dereq_,module,exports){
  54710. arguments[4][608][0].apply(exports,arguments)
  54711. },{"dup":608}],637:[function(_dereq_,module,exports){
  54712. 'use strict';
  54713. var $ = _dereq_('../internals/export');
  54714. var uncurryThis = _dereq_('../internals/function-uncurry-this');
  54715. var getOwnPropertyDescriptor = _dereq_('../internals/object-get-own-property-descriptor').f;
  54716. var toLength = _dereq_('../internals/to-length');
  54717. var toString = _dereq_('../internals/to-string');
  54718. var notARegExp = _dereq_('../internals/not-a-regexp');
  54719. var requireObjectCoercible = _dereq_('../internals/require-object-coercible');
  54720. var correctIsRegExpLogic = _dereq_('../internals/correct-is-regexp-logic');
  54721. var IS_PURE = _dereq_('../internals/is-pure');
  54722. // eslint-disable-next-line es/no-string-prototype-startswith -- safe
  54723. var un$StartsWith = uncurryThis(''.startsWith);
  54724. var stringSlice = uncurryThis(''.slice);
  54725. var min = Math.min;
  54726. var CORRECT_IS_REGEXP_LOGIC = correctIsRegExpLogic('startsWith');
  54727. // https://github.com/zloirock/core-js/pull/702
  54728. var MDN_POLYFILL_BUG = !IS_PURE && !CORRECT_IS_REGEXP_LOGIC && !!function () {
  54729. var descriptor = getOwnPropertyDescriptor(String.prototype, 'startsWith');
  54730. return descriptor && !descriptor.writable;
  54731. }();
  54732. // `String.prototype.startsWith` method
  54733. // https://tc39.es/ecma262/#sec-string.prototype.startswith
  54734. $({ target: 'String', proto: true, forced: !MDN_POLYFILL_BUG && !CORRECT_IS_REGEXP_LOGIC }, {
  54735. startsWith: function startsWith(searchString /* , position = 0 */) {
  54736. var that = toString(requireObjectCoercible(this));
  54737. notARegExp(searchString);
  54738. var index = toLength(min(arguments.length > 1 ? arguments[1] : undefined, that.length));
  54739. var search = toString(searchString);
  54740. return un$StartsWith
  54741. ? un$StartsWith(that, search, index)
  54742. : stringSlice(that, index, index + search.length) === search;
  54743. }
  54744. });
  54745. },{"../internals/correct-is-regexp-logic":452,"../internals/export":476,"../internals/function-uncurry-this":485,"../internals/is-pure":510,"../internals/not-a-regexp":527,"../internals/object-get-own-property-descriptor":533,"../internals/require-object-coercible":554,"../internals/to-length":574,"../internals/to-string":579}],638:[function(_dereq_,module,exports){
  54746. 'use strict';
  54747. var $ = _dereq_('../internals/export');
  54748. var $trim = _dereq_('../internals/string-trim').trim;
  54749. var forcedStringTrimMethod = _dereq_('../internals/string-trim-forced');
  54750. // `String.prototype.trim` method
  54751. // https://tc39.es/ecma262/#sec-string.prototype.trim
  54752. $({ target: 'String', proto: true, forced: forcedStringTrimMethod('trim') }, {
  54753. trim: function trim() {
  54754. return $trim(this);
  54755. }
  54756. });
  54757. },{"../internals/export":476,"../internals/string-trim":569,"../internals/string-trim-forced":568}],639:[function(_dereq_,module,exports){
  54758. var defineWellKnownSymbol = _dereq_('../internals/define-well-known-symbol');
  54759. // `Symbol.asyncIterator` well-known symbol
  54760. // https://tc39.es/ecma262/#sec-symbol.asynciterator
  54761. defineWellKnownSymbol('asyncIterator');
  54762. },{"../internals/define-well-known-symbol":459}],640:[function(_dereq_,module,exports){
  54763. arguments[4][608][0].apply(exports,arguments)
  54764. },{"dup":608}],641:[function(_dereq_,module,exports){
  54765. var defineWellKnownSymbol = _dereq_('../internals/define-well-known-symbol');
  54766. // `Symbol.hasInstance` well-known symbol
  54767. // https://tc39.es/ecma262/#sec-symbol.hasinstance
  54768. defineWellKnownSymbol('hasInstance');
  54769. },{"../internals/define-well-known-symbol":459}],642:[function(_dereq_,module,exports){
  54770. var defineWellKnownSymbol = _dereq_('../internals/define-well-known-symbol');
  54771. // `Symbol.isConcatSpreadable` well-known symbol
  54772. // https://tc39.es/ecma262/#sec-symbol.isconcatspreadable
  54773. defineWellKnownSymbol('isConcatSpreadable');
  54774. },{"../internals/define-well-known-symbol":459}],643:[function(_dereq_,module,exports){
  54775. var defineWellKnownSymbol = _dereq_('../internals/define-well-known-symbol');
  54776. // `Symbol.iterator` well-known symbol
  54777. // https://tc39.es/ecma262/#sec-symbol.iterator
  54778. defineWellKnownSymbol('iterator');
  54779. },{"../internals/define-well-known-symbol":459}],644:[function(_dereq_,module,exports){
  54780. 'use strict';
  54781. var $ = _dereq_('../internals/export');
  54782. var global = _dereq_('../internals/global');
  54783. var getBuiltIn = _dereq_('../internals/get-built-in');
  54784. var apply = _dereq_('../internals/function-apply');
  54785. var call = _dereq_('../internals/function-call');
  54786. var uncurryThis = _dereq_('../internals/function-uncurry-this');
  54787. var IS_PURE = _dereq_('../internals/is-pure');
  54788. var DESCRIPTORS = _dereq_('../internals/descriptors');
  54789. var NATIVE_SYMBOL = _dereq_('../internals/native-symbol');
  54790. var fails = _dereq_('../internals/fails');
  54791. var hasOwn = _dereq_('../internals/has-own-property');
  54792. var isArray = _dereq_('../internals/is-array');
  54793. var isCallable = _dereq_('../internals/is-callable');
  54794. var isObject = _dereq_('../internals/is-object');
  54795. var isPrototypeOf = _dereq_('../internals/object-is-prototype-of');
  54796. var isSymbol = _dereq_('../internals/is-symbol');
  54797. var anObject = _dereq_('../internals/an-object');
  54798. var toObject = _dereq_('../internals/to-object');
  54799. var toIndexedObject = _dereq_('../internals/to-indexed-object');
  54800. var toPropertyKey = _dereq_('../internals/to-property-key');
  54801. var $toString = _dereq_('../internals/to-string');
  54802. var createPropertyDescriptor = _dereq_('../internals/create-property-descriptor');
  54803. var nativeObjectCreate = _dereq_('../internals/object-create');
  54804. var objectKeys = _dereq_('../internals/object-keys');
  54805. var getOwnPropertyNamesModule = _dereq_('../internals/object-get-own-property-names');
  54806. var getOwnPropertyNamesExternal = _dereq_('../internals/object-get-own-property-names-external');
  54807. var getOwnPropertySymbolsModule = _dereq_('../internals/object-get-own-property-symbols');
  54808. var getOwnPropertyDescriptorModule = _dereq_('../internals/object-get-own-property-descriptor');
  54809. var definePropertyModule = _dereq_('../internals/object-define-property');
  54810. var definePropertiesModule = _dereq_('../internals/object-define-properties');
  54811. var propertyIsEnumerableModule = _dereq_('../internals/object-property-is-enumerable');
  54812. var arraySlice = _dereq_('../internals/array-slice');
  54813. var redefine = _dereq_('../internals/redefine');
  54814. var shared = _dereq_('../internals/shared');
  54815. var sharedKey = _dereq_('../internals/shared-key');
  54816. var hiddenKeys = _dereq_('../internals/hidden-keys');
  54817. var uid = _dereq_('../internals/uid');
  54818. var wellKnownSymbol = _dereq_('../internals/well-known-symbol');
  54819. var wrappedWellKnownSymbolModule = _dereq_('../internals/well-known-symbol-wrapped');
  54820. var defineWellKnownSymbol = _dereq_('../internals/define-well-known-symbol');
  54821. var setToStringTag = _dereq_('../internals/set-to-string-tag');
  54822. var InternalStateModule = _dereq_('../internals/internal-state');
  54823. var $forEach = _dereq_('../internals/array-iteration').forEach;
  54824. var HIDDEN = sharedKey('hidden');
  54825. var SYMBOL = 'Symbol';
  54826. var PROTOTYPE = 'prototype';
  54827. var TO_PRIMITIVE = wellKnownSymbol('toPrimitive');
  54828. var setInternalState = InternalStateModule.set;
  54829. var getInternalState = InternalStateModule.getterFor(SYMBOL);
  54830. var ObjectPrototype = Object[PROTOTYPE];
  54831. var $Symbol = global.Symbol;
  54832. var SymbolPrototype = $Symbol && $Symbol[PROTOTYPE];
  54833. var TypeError = global.TypeError;
  54834. var QObject = global.QObject;
  54835. var $stringify = getBuiltIn('JSON', 'stringify');
  54836. var nativeGetOwnPropertyDescriptor = getOwnPropertyDescriptorModule.f;
  54837. var nativeDefineProperty = definePropertyModule.f;
  54838. var nativeGetOwnPropertyNames = getOwnPropertyNamesExternal.f;
  54839. var nativePropertyIsEnumerable = propertyIsEnumerableModule.f;
  54840. var push = uncurryThis([].push);
  54841. var AllSymbols = shared('symbols');
  54842. var ObjectPrototypeSymbols = shared('op-symbols');
  54843. var StringToSymbolRegistry = shared('string-to-symbol-registry');
  54844. var SymbolToStringRegistry = shared('symbol-to-string-registry');
  54845. var WellKnownSymbolsStore = shared('wks');
  54846. // Don't use setters in Qt Script, https://github.com/zloirock/core-js/issues/173
  54847. var USE_SETTER = !QObject || !QObject[PROTOTYPE] || !QObject[PROTOTYPE].findChild;
  54848. // fallback for old Android, https://code.google.com/p/v8/issues/detail?id=687
  54849. var setSymbolDescriptor = DESCRIPTORS && fails(function () {
  54850. return nativeObjectCreate(nativeDefineProperty({}, 'a', {
  54851. get: function () { return nativeDefineProperty(this, 'a', { value: 7 }).a; }
  54852. })).a != 7;
  54853. }) ? function (O, P, Attributes) {
  54854. var ObjectPrototypeDescriptor = nativeGetOwnPropertyDescriptor(ObjectPrototype, P);
  54855. if (ObjectPrototypeDescriptor) delete ObjectPrototype[P];
  54856. nativeDefineProperty(O, P, Attributes);
  54857. if (ObjectPrototypeDescriptor && O !== ObjectPrototype) {
  54858. nativeDefineProperty(ObjectPrototype, P, ObjectPrototypeDescriptor);
  54859. }
  54860. } : nativeDefineProperty;
  54861. var wrap = function (tag, description) {
  54862. var symbol = AllSymbols[tag] = nativeObjectCreate(SymbolPrototype);
  54863. setInternalState(symbol, {
  54864. type: SYMBOL,
  54865. tag: tag,
  54866. description: description
  54867. });
  54868. if (!DESCRIPTORS) symbol.description = description;
  54869. return symbol;
  54870. };
  54871. var $defineProperty = function defineProperty(O, P, Attributes) {
  54872. if (O === ObjectPrototype) $defineProperty(ObjectPrototypeSymbols, P, Attributes);
  54873. anObject(O);
  54874. var key = toPropertyKey(P);
  54875. anObject(Attributes);
  54876. if (hasOwn(AllSymbols, key)) {
  54877. if (!Attributes.enumerable) {
  54878. if (!hasOwn(O, HIDDEN)) nativeDefineProperty(O, HIDDEN, createPropertyDescriptor(1, {}));
  54879. O[HIDDEN][key] = true;
  54880. } else {
  54881. if (hasOwn(O, HIDDEN) && O[HIDDEN][key]) O[HIDDEN][key] = false;
  54882. Attributes = nativeObjectCreate(Attributes, { enumerable: createPropertyDescriptor(0, false) });
  54883. } return setSymbolDescriptor(O, key, Attributes);
  54884. } return nativeDefineProperty(O, key, Attributes);
  54885. };
  54886. var $defineProperties = function defineProperties(O, Properties) {
  54887. anObject(O);
  54888. var properties = toIndexedObject(Properties);
  54889. var keys = objectKeys(properties).concat($getOwnPropertySymbols(properties));
  54890. $forEach(keys, function (key) {
  54891. if (!DESCRIPTORS || call($propertyIsEnumerable, properties, key)) $defineProperty(O, key, properties[key]);
  54892. });
  54893. return O;
  54894. };
  54895. var $create = function create(O, Properties) {
  54896. return Properties === undefined ? nativeObjectCreate(O) : $defineProperties(nativeObjectCreate(O), Properties);
  54897. };
  54898. var $propertyIsEnumerable = function propertyIsEnumerable(V) {
  54899. var P = toPropertyKey(V);
  54900. var enumerable = call(nativePropertyIsEnumerable, this, P);
  54901. if (this === ObjectPrototype && hasOwn(AllSymbols, P) && !hasOwn(ObjectPrototypeSymbols, P)) return false;
  54902. return enumerable || !hasOwn(this, P) || !hasOwn(AllSymbols, P) || hasOwn(this, HIDDEN) && this[HIDDEN][P]
  54903. ? enumerable : true;
  54904. };
  54905. var $getOwnPropertyDescriptor = function getOwnPropertyDescriptor(O, P) {
  54906. var it = toIndexedObject(O);
  54907. var key = toPropertyKey(P);
  54908. if (it === ObjectPrototype && hasOwn(AllSymbols, key) && !hasOwn(ObjectPrototypeSymbols, key)) return;
  54909. var descriptor = nativeGetOwnPropertyDescriptor(it, key);
  54910. if (descriptor && hasOwn(AllSymbols, key) && !(hasOwn(it, HIDDEN) && it[HIDDEN][key])) {
  54911. descriptor.enumerable = true;
  54912. }
  54913. return descriptor;
  54914. };
  54915. var $getOwnPropertyNames = function getOwnPropertyNames(O) {
  54916. var names = nativeGetOwnPropertyNames(toIndexedObject(O));
  54917. var result = [];
  54918. $forEach(names, function (key) {
  54919. if (!hasOwn(AllSymbols, key) && !hasOwn(hiddenKeys, key)) push(result, key);
  54920. });
  54921. return result;
  54922. };
  54923. var $getOwnPropertySymbols = function getOwnPropertySymbols(O) {
  54924. var IS_OBJECT_PROTOTYPE = O === ObjectPrototype;
  54925. var names = nativeGetOwnPropertyNames(IS_OBJECT_PROTOTYPE ? ObjectPrototypeSymbols : toIndexedObject(O));
  54926. var result = [];
  54927. $forEach(names, function (key) {
  54928. if (hasOwn(AllSymbols, key) && (!IS_OBJECT_PROTOTYPE || hasOwn(ObjectPrototype, key))) {
  54929. push(result, AllSymbols[key]);
  54930. }
  54931. });
  54932. return result;
  54933. };
  54934. // `Symbol` constructor
  54935. // https://tc39.es/ecma262/#sec-symbol-constructor
  54936. if (!NATIVE_SYMBOL) {
  54937. $Symbol = function Symbol() {
  54938. if (isPrototypeOf(SymbolPrototype, this)) throw TypeError('Symbol is not a constructor');
  54939. var description = !arguments.length || arguments[0] === undefined ? undefined : $toString(arguments[0]);
  54940. var tag = uid(description);
  54941. var setter = function (value) {
  54942. if (this === ObjectPrototype) call(setter, ObjectPrototypeSymbols, value);
  54943. if (hasOwn(this, HIDDEN) && hasOwn(this[HIDDEN], tag)) this[HIDDEN][tag] = false;
  54944. setSymbolDescriptor(this, tag, createPropertyDescriptor(1, value));
  54945. };
  54946. if (DESCRIPTORS && USE_SETTER) setSymbolDescriptor(ObjectPrototype, tag, { configurable: true, set: setter });
  54947. return wrap(tag, description);
  54948. };
  54949. SymbolPrototype = $Symbol[PROTOTYPE];
  54950. redefine(SymbolPrototype, 'toString', function toString() {
  54951. return getInternalState(this).tag;
  54952. });
  54953. redefine($Symbol, 'withoutSetter', function (description) {
  54954. return wrap(uid(description), description);
  54955. });
  54956. propertyIsEnumerableModule.f = $propertyIsEnumerable;
  54957. definePropertyModule.f = $defineProperty;
  54958. definePropertiesModule.f = $defineProperties;
  54959. getOwnPropertyDescriptorModule.f = $getOwnPropertyDescriptor;
  54960. getOwnPropertyNamesModule.f = getOwnPropertyNamesExternal.f = $getOwnPropertyNames;
  54961. getOwnPropertySymbolsModule.f = $getOwnPropertySymbols;
  54962. wrappedWellKnownSymbolModule.f = function (name) {
  54963. return wrap(wellKnownSymbol(name), name);
  54964. };
  54965. if (DESCRIPTORS) {
  54966. // https://github.com/tc39/proposal-Symbol-description
  54967. nativeDefineProperty(SymbolPrototype, 'description', {
  54968. configurable: true,
  54969. get: function description() {
  54970. return getInternalState(this).description;
  54971. }
  54972. });
  54973. if (!IS_PURE) {
  54974. redefine(ObjectPrototype, 'propertyIsEnumerable', $propertyIsEnumerable, { unsafe: true });
  54975. }
  54976. }
  54977. }
  54978. $({ global: true, wrap: true, forced: !NATIVE_SYMBOL, sham: !NATIVE_SYMBOL }, {
  54979. Symbol: $Symbol
  54980. });
  54981. $forEach(objectKeys(WellKnownSymbolsStore), function (name) {
  54982. defineWellKnownSymbol(name);
  54983. });
  54984. $({ target: SYMBOL, stat: true, forced: !NATIVE_SYMBOL }, {
  54985. // `Symbol.for` method
  54986. // https://tc39.es/ecma262/#sec-symbol.for
  54987. 'for': function (key) {
  54988. var string = $toString(key);
  54989. if (hasOwn(StringToSymbolRegistry, string)) return StringToSymbolRegistry[string];
  54990. var symbol = $Symbol(string);
  54991. StringToSymbolRegistry[string] = symbol;
  54992. SymbolToStringRegistry[symbol] = string;
  54993. return symbol;
  54994. },
  54995. // `Symbol.keyFor` method
  54996. // https://tc39.es/ecma262/#sec-symbol.keyfor
  54997. keyFor: function keyFor(sym) {
  54998. if (!isSymbol(sym)) throw TypeError(sym + ' is not a symbol');
  54999. if (hasOwn(SymbolToStringRegistry, sym)) return SymbolToStringRegistry[sym];
  55000. },
  55001. useSetter: function () { USE_SETTER = true; },
  55002. useSimple: function () { USE_SETTER = false; }
  55003. });
  55004. $({ target: 'Object', stat: true, forced: !NATIVE_SYMBOL, sham: !DESCRIPTORS }, {
  55005. // `Object.create` method
  55006. // https://tc39.es/ecma262/#sec-object.create
  55007. create: $create,
  55008. // `Object.defineProperty` method
  55009. // https://tc39.es/ecma262/#sec-object.defineproperty
  55010. defineProperty: $defineProperty,
  55011. // `Object.defineProperties` method
  55012. // https://tc39.es/ecma262/#sec-object.defineproperties
  55013. defineProperties: $defineProperties,
  55014. // `Object.getOwnPropertyDescriptor` method
  55015. // https://tc39.es/ecma262/#sec-object.getownpropertydescriptors
  55016. getOwnPropertyDescriptor: $getOwnPropertyDescriptor
  55017. });
  55018. $({ target: 'Object', stat: true, forced: !NATIVE_SYMBOL }, {
  55019. // `Object.getOwnPropertyNames` method
  55020. // https://tc39.es/ecma262/#sec-object.getownpropertynames
  55021. getOwnPropertyNames: $getOwnPropertyNames,
  55022. // `Object.getOwnPropertySymbols` method
  55023. // https://tc39.es/ecma262/#sec-object.getownpropertysymbols
  55024. getOwnPropertySymbols: $getOwnPropertySymbols
  55025. });
  55026. // Chrome 38 and 39 `Object.getOwnPropertySymbols` fails on primitives
  55027. // https://bugs.chromium.org/p/v8/issues/detail?id=3443
  55028. $({ target: 'Object', stat: true, forced: fails(function () { getOwnPropertySymbolsModule.f(1); }) }, {
  55029. getOwnPropertySymbols: function getOwnPropertySymbols(it) {
  55030. return getOwnPropertySymbolsModule.f(toObject(it));
  55031. }
  55032. });
  55033. // `JSON.stringify` method behavior with symbols
  55034. // https://tc39.es/ecma262/#sec-json.stringify
  55035. if ($stringify) {
  55036. var FORCED_JSON_STRINGIFY = !NATIVE_SYMBOL || fails(function () {
  55037. var symbol = $Symbol();
  55038. // MS Edge converts symbol values to JSON as {}
  55039. return $stringify([symbol]) != '[null]'
  55040. // WebKit converts symbol values to JSON as null
  55041. || $stringify({ a: symbol }) != '{}'
  55042. // V8 throws on boxed symbols
  55043. || $stringify(Object(symbol)) != '{}';
  55044. });
  55045. $({ target: 'JSON', stat: true, forced: FORCED_JSON_STRINGIFY }, {
  55046. // eslint-disable-next-line no-unused-vars -- required for `.length`
  55047. stringify: function stringify(it, replacer, space) {
  55048. var args = arraySlice(arguments);
  55049. var $replacer = replacer;
  55050. if (!isObject(replacer) && it === undefined || isSymbol(it)) return; // IE8 returns string on undefined
  55051. if (!isArray(replacer)) replacer = function (key, value) {
  55052. if (isCallable($replacer)) value = call($replacer, this, key, value);
  55053. if (!isSymbol(value)) return value;
  55054. };
  55055. args[1] = replacer;
  55056. return apply($stringify, null, args);
  55057. }
  55058. });
  55059. }
  55060. // `Symbol.prototype[@@toPrimitive]` method
  55061. // https://tc39.es/ecma262/#sec-symbol.prototype-@@toprimitive
  55062. if (!SymbolPrototype[TO_PRIMITIVE]) {
  55063. var valueOf = SymbolPrototype.valueOf;
  55064. // eslint-disable-next-line no-unused-vars -- required for .length
  55065. redefine(SymbolPrototype, TO_PRIMITIVE, function (hint) {
  55066. // TODO: improve hint logic
  55067. return call(valueOf, this);
  55068. });
  55069. }
  55070. // `Symbol.prototype[@@toStringTag]` property
  55071. // https://tc39.es/ecma262/#sec-symbol.prototype-@@tostringtag
  55072. setToStringTag($Symbol, SYMBOL);
  55073. hiddenKeys[HIDDEN] = true;
  55074. },{"../internals/an-object":426,"../internals/array-iteration":431,"../internals/array-slice":436,"../internals/create-property-descriptor":456,"../internals/define-well-known-symbol":459,"../internals/descriptors":460,"../internals/export":476,"../internals/fails":477,"../internals/function-apply":479,"../internals/function-call":483,"../internals/function-uncurry-this":485,"../internals/get-built-in":486,"../internals/global":491,"../internals/has-own-property":492,"../internals/hidden-keys":493,"../internals/internal-state":501,"../internals/is-array":503,"../internals/is-callable":504,"../internals/is-object":509,"../internals/is-pure":510,"../internals/is-symbol":512,"../internals/native-symbol":522,"../internals/object-create":530,"../internals/object-define-properties":531,"../internals/object-define-property":532,"../internals/object-get-own-property-descriptor":533,"../internals/object-get-own-property-names":535,"../internals/object-get-own-property-names-external":534,"../internals/object-get-own-property-symbols":536,"../internals/object-is-prototype-of":539,"../internals/object-keys":541,"../internals/object-property-is-enumerable":542,"../internals/redefine":553,"../internals/set-to-string-tag":558,"../internals/shared":561,"../internals/shared-key":559,"../internals/to-indexed-object":572,"../internals/to-object":575,"../internals/to-property-key":577,"../internals/to-string":579,"../internals/uid":581,"../internals/well-known-symbol":586,"../internals/well-known-symbol-wrapped":585}],645:[function(_dereq_,module,exports){
  55075. var defineWellKnownSymbol = _dereq_('../internals/define-well-known-symbol');
  55076. // `Symbol.matchAll` well-known symbol
  55077. // https://tc39.es/ecma262/#sec-symbol.matchall
  55078. defineWellKnownSymbol('matchAll');
  55079. },{"../internals/define-well-known-symbol":459}],646:[function(_dereq_,module,exports){
  55080. var defineWellKnownSymbol = _dereq_('../internals/define-well-known-symbol');
  55081. // `Symbol.match` well-known symbol
  55082. // https://tc39.es/ecma262/#sec-symbol.match
  55083. defineWellKnownSymbol('match');
  55084. },{"../internals/define-well-known-symbol":459}],647:[function(_dereq_,module,exports){
  55085. var defineWellKnownSymbol = _dereq_('../internals/define-well-known-symbol');
  55086. // `Symbol.replace` well-known symbol
  55087. // https://tc39.es/ecma262/#sec-symbol.replace
  55088. defineWellKnownSymbol('replace');
  55089. },{"../internals/define-well-known-symbol":459}],648:[function(_dereq_,module,exports){
  55090. var defineWellKnownSymbol = _dereq_('../internals/define-well-known-symbol');
  55091. // `Symbol.search` well-known symbol
  55092. // https://tc39.es/ecma262/#sec-symbol.search
  55093. defineWellKnownSymbol('search');
  55094. },{"../internals/define-well-known-symbol":459}],649:[function(_dereq_,module,exports){
  55095. var defineWellKnownSymbol = _dereq_('../internals/define-well-known-symbol');
  55096. // `Symbol.species` well-known symbol
  55097. // https://tc39.es/ecma262/#sec-symbol.species
  55098. defineWellKnownSymbol('species');
  55099. },{"../internals/define-well-known-symbol":459}],650:[function(_dereq_,module,exports){
  55100. var defineWellKnownSymbol = _dereq_('../internals/define-well-known-symbol');
  55101. // `Symbol.split` well-known symbol
  55102. // https://tc39.es/ecma262/#sec-symbol.split
  55103. defineWellKnownSymbol('split');
  55104. },{"../internals/define-well-known-symbol":459}],651:[function(_dereq_,module,exports){
  55105. var defineWellKnownSymbol = _dereq_('../internals/define-well-known-symbol');
  55106. // `Symbol.toPrimitive` well-known symbol
  55107. // https://tc39.es/ecma262/#sec-symbol.toprimitive
  55108. defineWellKnownSymbol('toPrimitive');
  55109. },{"../internals/define-well-known-symbol":459}],652:[function(_dereq_,module,exports){
  55110. var defineWellKnownSymbol = _dereq_('../internals/define-well-known-symbol');
  55111. // `Symbol.toStringTag` well-known symbol
  55112. // https://tc39.es/ecma262/#sec-symbol.tostringtag
  55113. defineWellKnownSymbol('toStringTag');
  55114. },{"../internals/define-well-known-symbol":459}],653:[function(_dereq_,module,exports){
  55115. var defineWellKnownSymbol = _dereq_('../internals/define-well-known-symbol');
  55116. // `Symbol.unscopables` well-known symbol
  55117. // https://tc39.es/ecma262/#sec-symbol.unscopables
  55118. defineWellKnownSymbol('unscopables');
  55119. },{"../internals/define-well-known-symbol":459}],654:[function(_dereq_,module,exports){
  55120. 'use strict';
  55121. var global = _dereq_('../internals/global');
  55122. var uncurryThis = _dereq_('../internals/function-uncurry-this');
  55123. var redefineAll = _dereq_('../internals/redefine-all');
  55124. var InternalMetadataModule = _dereq_('../internals/internal-metadata');
  55125. var collection = _dereq_('../internals/collection');
  55126. var collectionWeak = _dereq_('../internals/collection-weak');
  55127. var isObject = _dereq_('../internals/is-object');
  55128. var isExtensible = _dereq_('../internals/object-is-extensible');
  55129. var enforceInternalState = _dereq_('../internals/internal-state').enforce;
  55130. var NATIVE_WEAK_MAP = _dereq_('../internals/native-weak-map');
  55131. var IS_IE11 = !global.ActiveXObject && 'ActiveXObject' in global;
  55132. var InternalWeakMap;
  55133. var wrapper = function (init) {
  55134. return function WeakMap() {
  55135. return init(this, arguments.length ? arguments[0] : undefined);
  55136. };
  55137. };
  55138. // `WeakMap` constructor
  55139. // https://tc39.es/ecma262/#sec-weakmap-constructor
  55140. var $WeakMap = collection('WeakMap', wrapper, collectionWeak);
  55141. // IE11 WeakMap frozen keys fix
  55142. // We can't use feature detection because it crash some old IE builds
  55143. // https://github.com/zloirock/core-js/issues/485
  55144. if (NATIVE_WEAK_MAP && IS_IE11) {
  55145. InternalWeakMap = collectionWeak.getConstructor(wrapper, 'WeakMap', true);
  55146. InternalMetadataModule.enable();
  55147. var WeakMapPrototype = $WeakMap.prototype;
  55148. var nativeDelete = uncurryThis(WeakMapPrototype['delete']);
  55149. var nativeHas = uncurryThis(WeakMapPrototype.has);
  55150. var nativeGet = uncurryThis(WeakMapPrototype.get);
  55151. var nativeSet = uncurryThis(WeakMapPrototype.set);
  55152. redefineAll(WeakMapPrototype, {
  55153. 'delete': function (key) {
  55154. if (isObject(key) && !isExtensible(key)) {
  55155. var state = enforceInternalState(this);
  55156. if (!state.frozen) state.frozen = new InternalWeakMap();
  55157. return nativeDelete(this, key) || state.frozen['delete'](key);
  55158. } return nativeDelete(this, key);
  55159. },
  55160. has: function has(key) {
  55161. if (isObject(key) && !isExtensible(key)) {
  55162. var state = enforceInternalState(this);
  55163. if (!state.frozen) state.frozen = new InternalWeakMap();
  55164. return nativeHas(this, key) || state.frozen.has(key);
  55165. } return nativeHas(this, key);
  55166. },
  55167. get: function get(key) {
  55168. if (isObject(key) && !isExtensible(key)) {
  55169. var state = enforceInternalState(this);
  55170. if (!state.frozen) state.frozen = new InternalWeakMap();
  55171. return nativeHas(this, key) ? nativeGet(this, key) : state.frozen.get(key);
  55172. } return nativeGet(this, key);
  55173. },
  55174. set: function set(key, value) {
  55175. if (isObject(key) && !isExtensible(key)) {
  55176. var state = enforceInternalState(this);
  55177. if (!state.frozen) state.frozen = new InternalWeakMap();
  55178. nativeHas(this, key) ? nativeSet(this, key, value) : state.frozen.set(key, value);
  55179. } else nativeSet(this, key, value);
  55180. return this;
  55181. }
  55182. });
  55183. }
  55184. },{"../internals/collection":450,"../internals/collection-weak":449,"../internals/function-uncurry-this":485,"../internals/global":491,"../internals/internal-metadata":500,"../internals/internal-state":501,"../internals/is-object":509,"../internals/native-weak-map":524,"../internals/object-is-extensible":538,"../internals/redefine-all":552}],655:[function(_dereq_,module,exports){
  55185. // TODO: Remove from `core-js@4`
  55186. _dereq_('../modules/es.aggregate-error');
  55187. },{"../modules/es.aggregate-error":588}],656:[function(_dereq_,module,exports){
  55188. 'use strict';
  55189. var $ = _dereq_('../internals/export');
  55190. var IS_PURE = _dereq_('../internals/is-pure');
  55191. var deleteAll = _dereq_('../internals/collection-delete-all');
  55192. // `Map.prototype.deleteAll` method
  55193. // https://github.com/tc39/proposal-collection-methods
  55194. $({ target: 'Map', proto: true, real: true, forced: IS_PURE }, {
  55195. deleteAll: deleteAll
  55196. });
  55197. },{"../internals/collection-delete-all":445,"../internals/export":476,"../internals/is-pure":510}],657:[function(_dereq_,module,exports){
  55198. 'use strict';
  55199. var $ = _dereq_('../internals/export');
  55200. var IS_PURE = _dereq_('../internals/is-pure');
  55201. var emplace = _dereq_('../internals/map-emplace');
  55202. // `Map.prototype.emplace` method
  55203. // https://github.com/thumbsupep/proposal-upsert
  55204. $({ target: 'Map', proto: true, real: true, forced: IS_PURE }, {
  55205. emplace: emplace
  55206. });
  55207. },{"../internals/export":476,"../internals/is-pure":510,"../internals/map-emplace":518}],658:[function(_dereq_,module,exports){
  55208. 'use strict';
  55209. var $ = _dereq_('../internals/export');
  55210. var IS_PURE = _dereq_('../internals/is-pure');
  55211. var anObject = _dereq_('../internals/an-object');
  55212. var bind = _dereq_('../internals/function-bind-context');
  55213. var getMapIterator = _dereq_('../internals/get-map-iterator');
  55214. var iterate = _dereq_('../internals/iterate');
  55215. // `Map.prototype.every` method
  55216. // https://github.com/tc39/proposal-collection-methods
  55217. $({ target: 'Map', proto: true, real: true, forced: IS_PURE }, {
  55218. every: function every(callbackfn /* , thisArg */) {
  55219. var map = anObject(this);
  55220. var iterator = getMapIterator(map);
  55221. var boundFunction = bind(callbackfn, arguments.length > 1 ? arguments[1] : undefined);
  55222. return !iterate(iterator, function (key, value, stop) {
  55223. if (!boundFunction(value, key, map)) return stop();
  55224. }, { AS_ENTRIES: true, IS_ITERATOR: true, INTERRUPTED: true }).stopped;
  55225. }
  55226. });
  55227. },{"../internals/an-object":426,"../internals/export":476,"../internals/function-bind-context":480,"../internals/get-map-iterator":489,"../internals/is-pure":510,"../internals/iterate":513}],659:[function(_dereq_,module,exports){
  55228. 'use strict';
  55229. var IS_PURE = _dereq_('../internals/is-pure');
  55230. var $ = _dereq_('../internals/export');
  55231. var getBuiltIn = _dereq_('../internals/get-built-in');
  55232. var bind = _dereq_('../internals/function-bind-context');
  55233. var call = _dereq_('../internals/function-call');
  55234. var aCallable = _dereq_('../internals/a-callable');
  55235. var anObject = _dereq_('../internals/an-object');
  55236. var speciesConstructor = _dereq_('../internals/species-constructor');
  55237. var getMapIterator = _dereq_('../internals/get-map-iterator');
  55238. var iterate = _dereq_('../internals/iterate');
  55239. // `Map.prototype.filter` method
  55240. // https://github.com/tc39/proposal-collection-methods
  55241. $({ target: 'Map', proto: true, real: true, forced: IS_PURE }, {
  55242. filter: function filter(callbackfn /* , thisArg */) {
  55243. var map = anObject(this);
  55244. var iterator = getMapIterator(map);
  55245. var boundFunction = bind(callbackfn, arguments.length > 1 ? arguments[1] : undefined);
  55246. var newMap = new (speciesConstructor(map, getBuiltIn('Map')))();
  55247. var setter = aCallable(newMap.set);
  55248. iterate(iterator, function (key, value) {
  55249. if (boundFunction(value, key, map)) call(setter, newMap, key, value);
  55250. }, { AS_ENTRIES: true, IS_ITERATOR: true });
  55251. return newMap;
  55252. }
  55253. });
  55254. },{"../internals/a-callable":421,"../internals/an-object":426,"../internals/export":476,"../internals/function-bind-context":480,"../internals/function-call":483,"../internals/get-built-in":486,"../internals/get-map-iterator":489,"../internals/is-pure":510,"../internals/iterate":513,"../internals/species-constructor":562}],660:[function(_dereq_,module,exports){
  55255. 'use strict';
  55256. var $ = _dereq_('../internals/export');
  55257. var IS_PURE = _dereq_('../internals/is-pure');
  55258. var anObject = _dereq_('../internals/an-object');
  55259. var bind = _dereq_('../internals/function-bind-context');
  55260. var getMapIterator = _dereq_('../internals/get-map-iterator');
  55261. var iterate = _dereq_('../internals/iterate');
  55262. // `Map.prototype.findKey` method
  55263. // https://github.com/tc39/proposal-collection-methods
  55264. $({ target: 'Map', proto: true, real: true, forced: IS_PURE }, {
  55265. findKey: function findKey(callbackfn /* , thisArg */) {
  55266. var map = anObject(this);
  55267. var iterator = getMapIterator(map);
  55268. var boundFunction = bind(callbackfn, arguments.length > 1 ? arguments[1] : undefined);
  55269. return iterate(iterator, function (key, value, stop) {
  55270. if (boundFunction(value, key, map)) return stop(key);
  55271. }, { AS_ENTRIES: true, IS_ITERATOR: true, INTERRUPTED: true }).result;
  55272. }
  55273. });
  55274. },{"../internals/an-object":426,"../internals/export":476,"../internals/function-bind-context":480,"../internals/get-map-iterator":489,"../internals/is-pure":510,"../internals/iterate":513}],661:[function(_dereq_,module,exports){
  55275. 'use strict';
  55276. var $ = _dereq_('../internals/export');
  55277. var IS_PURE = _dereq_('../internals/is-pure');
  55278. var anObject = _dereq_('../internals/an-object');
  55279. var bind = _dereq_('../internals/function-bind-context');
  55280. var getMapIterator = _dereq_('../internals/get-map-iterator');
  55281. var iterate = _dereq_('../internals/iterate');
  55282. // `Map.prototype.find` method
  55283. // https://github.com/tc39/proposal-collection-methods
  55284. $({ target: 'Map', proto: true, real: true, forced: IS_PURE }, {
  55285. find: function find(callbackfn /* , thisArg */) {
  55286. var map = anObject(this);
  55287. var iterator = getMapIterator(map);
  55288. var boundFunction = bind(callbackfn, arguments.length > 1 ? arguments[1] : undefined);
  55289. return iterate(iterator, function (key, value, stop) {
  55290. if (boundFunction(value, key, map)) return stop(value);
  55291. }, { AS_ENTRIES: true, IS_ITERATOR: true, INTERRUPTED: true }).result;
  55292. }
  55293. });
  55294. },{"../internals/an-object":426,"../internals/export":476,"../internals/function-bind-context":480,"../internals/get-map-iterator":489,"../internals/is-pure":510,"../internals/iterate":513}],662:[function(_dereq_,module,exports){
  55295. var $ = _dereq_('../internals/export');
  55296. var from = _dereq_('../internals/collection-from');
  55297. // `Map.from` method
  55298. // https://tc39.github.io/proposal-setmap-offrom/#sec-map.from
  55299. $({ target: 'Map', stat: true }, {
  55300. from: from
  55301. });
  55302. },{"../internals/collection-from":446,"../internals/export":476}],663:[function(_dereq_,module,exports){
  55303. 'use strict';
  55304. var $ = _dereq_('../internals/export');
  55305. var call = _dereq_('../internals/function-call');
  55306. var uncurryThis = _dereq_('../internals/function-uncurry-this');
  55307. var aCallable = _dereq_('../internals/a-callable');
  55308. var getIterator = _dereq_('../internals/get-iterator');
  55309. var iterate = _dereq_('../internals/iterate');
  55310. var push = uncurryThis([].push);
  55311. // `Map.groupBy` method
  55312. // https://github.com/tc39/proposal-collection-methods
  55313. $({ target: 'Map', stat: true }, {
  55314. groupBy: function groupBy(iterable, keyDerivative) {
  55315. aCallable(keyDerivative);
  55316. var iterator = getIterator(iterable);
  55317. var newMap = new this();
  55318. var has = aCallable(newMap.has);
  55319. var get = aCallable(newMap.get);
  55320. var set = aCallable(newMap.set);
  55321. iterate(iterator, function (element) {
  55322. var derivedKey = keyDerivative(element);
  55323. if (!call(has, newMap, derivedKey)) call(set, newMap, derivedKey, [element]);
  55324. else push(call(get, newMap, derivedKey), element);
  55325. }, { IS_ITERATOR: true });
  55326. return newMap;
  55327. }
  55328. });
  55329. },{"../internals/a-callable":421,"../internals/export":476,"../internals/function-call":483,"../internals/function-uncurry-this":485,"../internals/get-iterator":488,"../internals/iterate":513}],664:[function(_dereq_,module,exports){
  55330. 'use strict';
  55331. var IS_PURE = _dereq_('../internals/is-pure');
  55332. var $ = _dereq_('../internals/export');
  55333. var anObject = _dereq_('../internals/an-object');
  55334. var getMapIterator = _dereq_('../internals/get-map-iterator');
  55335. var sameValueZero = _dereq_('../internals/same-value-zero');
  55336. var iterate = _dereq_('../internals/iterate');
  55337. // `Map.prototype.includes` method
  55338. // https://github.com/tc39/proposal-collection-methods
  55339. $({ target: 'Map', proto: true, real: true, forced: IS_PURE }, {
  55340. includes: function includes(searchElement) {
  55341. return iterate(getMapIterator(anObject(this)), function (key, value, stop) {
  55342. if (sameValueZero(value, searchElement)) return stop();
  55343. }, { AS_ENTRIES: true, IS_ITERATOR: true, INTERRUPTED: true }).stopped;
  55344. }
  55345. });
  55346. },{"../internals/an-object":426,"../internals/export":476,"../internals/get-map-iterator":489,"../internals/is-pure":510,"../internals/iterate":513,"../internals/same-value-zero":555}],665:[function(_dereq_,module,exports){
  55347. 'use strict';
  55348. var $ = _dereq_('../internals/export');
  55349. var call = _dereq_('../internals/function-call');
  55350. var iterate = _dereq_('../internals/iterate');
  55351. var aCallable = _dereq_('../internals/a-callable');
  55352. // `Map.keyBy` method
  55353. // https://github.com/tc39/proposal-collection-methods
  55354. $({ target: 'Map', stat: true }, {
  55355. keyBy: function keyBy(iterable, keyDerivative) {
  55356. var newMap = new this();
  55357. aCallable(keyDerivative);
  55358. var setter = aCallable(newMap.set);
  55359. iterate(iterable, function (element) {
  55360. call(setter, newMap, keyDerivative(element), element);
  55361. });
  55362. return newMap;
  55363. }
  55364. });
  55365. },{"../internals/a-callable":421,"../internals/export":476,"../internals/function-call":483,"../internals/iterate":513}],666:[function(_dereq_,module,exports){
  55366. 'use strict';
  55367. var $ = _dereq_('../internals/export');
  55368. var IS_PURE = _dereq_('../internals/is-pure');
  55369. var anObject = _dereq_('../internals/an-object');
  55370. var getMapIterator = _dereq_('../internals/get-map-iterator');
  55371. var iterate = _dereq_('../internals/iterate');
  55372. // `Map.prototype.keyOf` method
  55373. // https://github.com/tc39/proposal-collection-methods
  55374. $({ target: 'Map', proto: true, real: true, forced: IS_PURE }, {
  55375. keyOf: function keyOf(searchElement) {
  55376. return iterate(getMapIterator(anObject(this)), function (key, value, stop) {
  55377. if (value === searchElement) return stop(key);
  55378. }, { AS_ENTRIES: true, IS_ITERATOR: true, INTERRUPTED: true }).result;
  55379. }
  55380. });
  55381. },{"../internals/an-object":426,"../internals/export":476,"../internals/get-map-iterator":489,"../internals/is-pure":510,"../internals/iterate":513}],667:[function(_dereq_,module,exports){
  55382. 'use strict';
  55383. var IS_PURE = _dereq_('../internals/is-pure');
  55384. var $ = _dereq_('../internals/export');
  55385. var getBuiltIn = _dereq_('../internals/get-built-in');
  55386. var bind = _dereq_('../internals/function-bind-context');
  55387. var call = _dereq_('../internals/function-call');
  55388. var aCallable = _dereq_('../internals/a-callable');
  55389. var anObject = _dereq_('../internals/an-object');
  55390. var speciesConstructor = _dereq_('../internals/species-constructor');
  55391. var getMapIterator = _dereq_('../internals/get-map-iterator');
  55392. var iterate = _dereq_('../internals/iterate');
  55393. // `Map.prototype.mapKeys` method
  55394. // https://github.com/tc39/proposal-collection-methods
  55395. $({ target: 'Map', proto: true, real: true, forced: IS_PURE }, {
  55396. mapKeys: function mapKeys(callbackfn /* , thisArg */) {
  55397. var map = anObject(this);
  55398. var iterator = getMapIterator(map);
  55399. var boundFunction = bind(callbackfn, arguments.length > 1 ? arguments[1] : undefined);
  55400. var newMap = new (speciesConstructor(map, getBuiltIn('Map')))();
  55401. var setter = aCallable(newMap.set);
  55402. iterate(iterator, function (key, value) {
  55403. call(setter, newMap, boundFunction(value, key, map), value);
  55404. }, { AS_ENTRIES: true, IS_ITERATOR: true });
  55405. return newMap;
  55406. }
  55407. });
  55408. },{"../internals/a-callable":421,"../internals/an-object":426,"../internals/export":476,"../internals/function-bind-context":480,"../internals/function-call":483,"../internals/get-built-in":486,"../internals/get-map-iterator":489,"../internals/is-pure":510,"../internals/iterate":513,"../internals/species-constructor":562}],668:[function(_dereq_,module,exports){
  55409. 'use strict';
  55410. var IS_PURE = _dereq_('../internals/is-pure');
  55411. var $ = _dereq_('../internals/export');
  55412. var getBuiltIn = _dereq_('../internals/get-built-in');
  55413. var bind = _dereq_('../internals/function-bind-context');
  55414. var call = _dereq_('../internals/function-call');
  55415. var aCallable = _dereq_('../internals/a-callable');
  55416. var anObject = _dereq_('../internals/an-object');
  55417. var speciesConstructor = _dereq_('../internals/species-constructor');
  55418. var getMapIterator = _dereq_('../internals/get-map-iterator');
  55419. var iterate = _dereq_('../internals/iterate');
  55420. // `Map.prototype.mapValues` method
  55421. // https://github.com/tc39/proposal-collection-methods
  55422. $({ target: 'Map', proto: true, real: true, forced: IS_PURE }, {
  55423. mapValues: function mapValues(callbackfn /* , thisArg */) {
  55424. var map = anObject(this);
  55425. var iterator = getMapIterator(map);
  55426. var boundFunction = bind(callbackfn, arguments.length > 1 ? arguments[1] : undefined);
  55427. var newMap = new (speciesConstructor(map, getBuiltIn('Map')))();
  55428. var setter = aCallable(newMap.set);
  55429. iterate(iterator, function (key, value) {
  55430. call(setter, newMap, key, boundFunction(value, key, map));
  55431. }, { AS_ENTRIES: true, IS_ITERATOR: true });
  55432. return newMap;
  55433. }
  55434. });
  55435. },{"../internals/a-callable":421,"../internals/an-object":426,"../internals/export":476,"../internals/function-bind-context":480,"../internals/function-call":483,"../internals/get-built-in":486,"../internals/get-map-iterator":489,"../internals/is-pure":510,"../internals/iterate":513,"../internals/species-constructor":562}],669:[function(_dereq_,module,exports){
  55436. 'use strict';
  55437. var $ = _dereq_('../internals/export');
  55438. var IS_PURE = _dereq_('../internals/is-pure');
  55439. var aCallable = _dereq_('../internals/a-callable');
  55440. var anObject = _dereq_('../internals/an-object');
  55441. var iterate = _dereq_('../internals/iterate');
  55442. // `Map.prototype.merge` method
  55443. // https://github.com/tc39/proposal-collection-methods
  55444. $({ target: 'Map', proto: true, real: true, forced: IS_PURE }, {
  55445. // eslint-disable-next-line no-unused-vars -- required for `.length`
  55446. merge: function merge(iterable /* ...iterables */) {
  55447. var map = anObject(this);
  55448. var setter = aCallable(map.set);
  55449. var argumentsLength = arguments.length;
  55450. var i = 0;
  55451. while (i < argumentsLength) {
  55452. iterate(arguments[i++], setter, { that: map, AS_ENTRIES: true });
  55453. }
  55454. return map;
  55455. }
  55456. });
  55457. },{"../internals/a-callable":421,"../internals/an-object":426,"../internals/export":476,"../internals/is-pure":510,"../internals/iterate":513}],670:[function(_dereq_,module,exports){
  55458. var $ = _dereq_('../internals/export');
  55459. var of = _dereq_('../internals/collection-of');
  55460. // `Map.of` method
  55461. // https://tc39.github.io/proposal-setmap-offrom/#sec-map.of
  55462. $({ target: 'Map', stat: true }, {
  55463. of: of
  55464. });
  55465. },{"../internals/collection-of":447,"../internals/export":476}],671:[function(_dereq_,module,exports){
  55466. 'use strict';
  55467. var $ = _dereq_('../internals/export');
  55468. var global = _dereq_('../internals/global');
  55469. var IS_PURE = _dereq_('../internals/is-pure');
  55470. var anObject = _dereq_('../internals/an-object');
  55471. var aCallable = _dereq_('../internals/a-callable');
  55472. var getMapIterator = _dereq_('../internals/get-map-iterator');
  55473. var iterate = _dereq_('../internals/iterate');
  55474. var TypeError = global.TypeError;
  55475. // `Map.prototype.reduce` method
  55476. // https://github.com/tc39/proposal-collection-methods
  55477. $({ target: 'Map', proto: true, real: true, forced: IS_PURE }, {
  55478. reduce: function reduce(callbackfn /* , initialValue */) {
  55479. var map = anObject(this);
  55480. var iterator = getMapIterator(map);
  55481. var noInitial = arguments.length < 2;
  55482. var accumulator = noInitial ? undefined : arguments[1];
  55483. aCallable(callbackfn);
  55484. iterate(iterator, function (key, value) {
  55485. if (noInitial) {
  55486. noInitial = false;
  55487. accumulator = value;
  55488. } else {
  55489. accumulator = callbackfn(accumulator, value, key, map);
  55490. }
  55491. }, { AS_ENTRIES: true, IS_ITERATOR: true });
  55492. if (noInitial) throw TypeError('Reduce of empty map with no initial value');
  55493. return accumulator;
  55494. }
  55495. });
  55496. },{"../internals/a-callable":421,"../internals/an-object":426,"../internals/export":476,"../internals/get-map-iterator":489,"../internals/global":491,"../internals/is-pure":510,"../internals/iterate":513}],672:[function(_dereq_,module,exports){
  55497. 'use strict';
  55498. var $ = _dereq_('../internals/export');
  55499. var IS_PURE = _dereq_('../internals/is-pure');
  55500. var anObject = _dereq_('../internals/an-object');
  55501. var bind = _dereq_('../internals/function-bind-context');
  55502. var getMapIterator = _dereq_('../internals/get-map-iterator');
  55503. var iterate = _dereq_('../internals/iterate');
  55504. // `Set.prototype.some` method
  55505. // https://github.com/tc39/proposal-collection-methods
  55506. $({ target: 'Map', proto: true, real: true, forced: IS_PURE }, {
  55507. some: function some(callbackfn /* , thisArg */) {
  55508. var map = anObject(this);
  55509. var iterator = getMapIterator(map);
  55510. var boundFunction = bind(callbackfn, arguments.length > 1 ? arguments[1] : undefined);
  55511. return iterate(iterator, function (key, value, stop) {
  55512. if (boundFunction(value, key, map)) return stop();
  55513. }, { AS_ENTRIES: true, IS_ITERATOR: true, INTERRUPTED: true }).stopped;
  55514. }
  55515. });
  55516. },{"../internals/an-object":426,"../internals/export":476,"../internals/function-bind-context":480,"../internals/get-map-iterator":489,"../internals/is-pure":510,"../internals/iterate":513}],673:[function(_dereq_,module,exports){
  55517. 'use strict';
  55518. // TODO: remove from `core-js@4`
  55519. var $ = _dereq_('../internals/export');
  55520. var IS_PURE = _dereq_('../internals/is-pure');
  55521. var upsert = _dereq_('../internals/map-upsert');
  55522. // `Map.prototype.updateOrInsert` method (replaced by `Map.prototype.emplace`)
  55523. // https://github.com/thumbsupep/proposal-upsert
  55524. $({ target: 'Map', proto: true, real: true, name: 'upsert', forced: IS_PURE }, {
  55525. updateOrInsert: upsert
  55526. });
  55527. },{"../internals/export":476,"../internals/is-pure":510,"../internals/map-upsert":519}],674:[function(_dereq_,module,exports){
  55528. 'use strict';
  55529. var IS_PURE = _dereq_('../internals/is-pure');
  55530. var $ = _dereq_('../internals/export');
  55531. var global = _dereq_('../internals/global');
  55532. var call = _dereq_('../internals/function-call');
  55533. var anObject = _dereq_('../internals/an-object');
  55534. var aCallable = _dereq_('../internals/a-callable');
  55535. var TypeError = global.TypeError;
  55536. // `Set.prototype.update` method
  55537. // https://github.com/tc39/proposal-collection-methods
  55538. $({ target: 'Map', proto: true, real: true, forced: IS_PURE }, {
  55539. update: function update(key, callback /* , thunk */) {
  55540. var map = anObject(this);
  55541. var get = aCallable(map.get);
  55542. var has = aCallable(map.has);
  55543. var set = aCallable(map.set);
  55544. var length = arguments.length;
  55545. aCallable(callback);
  55546. var isPresentInMap = call(has, map, key);
  55547. if (!isPresentInMap && length < 3) {
  55548. throw TypeError('Updating absent value');
  55549. }
  55550. var value = isPresentInMap ? call(get, map, key) : aCallable(length > 2 ? arguments[2] : undefined)(key, map);
  55551. call(set, map, key, callback(value, key, map));
  55552. return map;
  55553. }
  55554. });
  55555. },{"../internals/a-callable":421,"../internals/an-object":426,"../internals/export":476,"../internals/function-call":483,"../internals/global":491,"../internals/is-pure":510}],675:[function(_dereq_,module,exports){
  55556. 'use strict';
  55557. // TODO: remove from `core-js@4`
  55558. var $ = _dereq_('../internals/export');
  55559. var IS_PURE = _dereq_('../internals/is-pure');
  55560. var upsert = _dereq_('../internals/map-upsert');
  55561. // `Map.prototype.upsert` method (replaced by `Map.prototype.emplace`)
  55562. // https://github.com/thumbsupep/proposal-upsert
  55563. $({ target: 'Map', proto: true, real: true, forced: IS_PURE }, {
  55564. upsert: upsert
  55565. });
  55566. },{"../internals/export":476,"../internals/is-pure":510,"../internals/map-upsert":519}],676:[function(_dereq_,module,exports){
  55567. // TODO: Remove from `core-js@4`
  55568. _dereq_('../modules/es.promise.all-settled.js');
  55569. },{"../modules/es.promise.all-settled.js":624}],677:[function(_dereq_,module,exports){
  55570. // TODO: Remove from `core-js@4`
  55571. _dereq_('../modules/es.promise.any');
  55572. },{"../modules/es.promise.any":625}],678:[function(_dereq_,module,exports){
  55573. 'use strict';
  55574. var $ = _dereq_('../internals/export');
  55575. var newPromiseCapabilityModule = _dereq_('../internals/new-promise-capability');
  55576. var perform = _dereq_('../internals/perform');
  55577. // `Promise.try` method
  55578. // https://github.com/tc39/proposal-promise-try
  55579. $({ target: 'Promise', stat: true }, {
  55580. 'try': function (callbackfn) {
  55581. var promiseCapability = newPromiseCapabilityModule.f(this);
  55582. var result = perform(callbackfn);
  55583. (result.error ? promiseCapability.reject : promiseCapability.resolve)(result.value);
  55584. return promiseCapability.promise;
  55585. }
  55586. });
  55587. },{"../internals/export":476,"../internals/new-promise-capability":525,"../internals/perform":549}],679:[function(_dereq_,module,exports){
  55588. var defineWellKnownSymbol = _dereq_('../internals/define-well-known-symbol');
  55589. // `Symbol.asyncDispose` well-known symbol
  55590. // https://github.com/tc39/proposal-using-statement
  55591. defineWellKnownSymbol('asyncDispose');
  55592. },{"../internals/define-well-known-symbol":459}],680:[function(_dereq_,module,exports){
  55593. var defineWellKnownSymbol = _dereq_('../internals/define-well-known-symbol');
  55594. // `Symbol.dispose` well-known symbol
  55595. // https://github.com/tc39/proposal-using-statement
  55596. defineWellKnownSymbol('dispose');
  55597. },{"../internals/define-well-known-symbol":459}],681:[function(_dereq_,module,exports){
  55598. var defineWellKnownSymbol = _dereq_('../internals/define-well-known-symbol');
  55599. // `Symbol.matcher` well-known symbol
  55600. // https://github.com/tc39/proposal-pattern-matching
  55601. defineWellKnownSymbol('matcher');
  55602. },{"../internals/define-well-known-symbol":459}],682:[function(_dereq_,module,exports){
  55603. var defineWellKnownSymbol = _dereq_('../internals/define-well-known-symbol');
  55604. // `Symbol.metadata` well-known symbol
  55605. // https://github.com/tc39/proposal-decorators
  55606. defineWellKnownSymbol('metadata');
  55607. },{"../internals/define-well-known-symbol":459}],683:[function(_dereq_,module,exports){
  55608. var defineWellKnownSymbol = _dereq_('../internals/define-well-known-symbol');
  55609. // `Symbol.observable` well-known symbol
  55610. // https://github.com/tc39/proposal-observable
  55611. defineWellKnownSymbol('observable');
  55612. },{"../internals/define-well-known-symbol":459}],684:[function(_dereq_,module,exports){
  55613. // TODO: remove from `core-js@4`
  55614. var defineWellKnownSymbol = _dereq_('../internals/define-well-known-symbol');
  55615. // `Symbol.patternMatch` well-known symbol
  55616. // https://github.com/tc39/proposal-pattern-matching
  55617. defineWellKnownSymbol('patternMatch');
  55618. },{"../internals/define-well-known-symbol":459}],685:[function(_dereq_,module,exports){
  55619. // TODO: remove from `core-js@4`
  55620. var defineWellKnownSymbol = _dereq_('../internals/define-well-known-symbol');
  55621. defineWellKnownSymbol('replaceAll');
  55622. },{"../internals/define-well-known-symbol":459}],686:[function(_dereq_,module,exports){
  55623. _dereq_('../modules/es.array.iterator');
  55624. var DOMIterables = _dereq_('../internals/dom-iterables');
  55625. var global = _dereq_('../internals/global');
  55626. var classof = _dereq_('../internals/classof');
  55627. var createNonEnumerableProperty = _dereq_('../internals/create-non-enumerable-property');
  55628. var Iterators = _dereq_('../internals/iterators');
  55629. var wellKnownSymbol = _dereq_('../internals/well-known-symbol');
  55630. var TO_STRING_TAG = wellKnownSymbol('toStringTag');
  55631. for (var COLLECTION_NAME in DOMIterables) {
  55632. var Collection = global[COLLECTION_NAME];
  55633. var CollectionPrototype = Collection && Collection.prototype;
  55634. if (CollectionPrototype && classof(CollectionPrototype) !== TO_STRING_TAG) {
  55635. createNonEnumerableProperty(CollectionPrototype, TO_STRING_TAG, COLLECTION_NAME);
  55636. }
  55637. Iterators[COLLECTION_NAME] = Iterators.Array;
  55638. }
  55639. },{"../internals/classof":443,"../internals/create-non-enumerable-property":455,"../internals/dom-iterables":462,"../internals/global":491,"../internals/iterators":516,"../internals/well-known-symbol":586,"../modules/es.array.iterator":598}],687:[function(_dereq_,module,exports){
  55640. var $ = _dereq_('../internals/export');
  55641. var global = _dereq_('../internals/global');
  55642. var apply = _dereq_('../internals/function-apply');
  55643. var isCallable = _dereq_('../internals/is-callable');
  55644. var userAgent = _dereq_('../internals/engine-user-agent');
  55645. var arraySlice = _dereq_('../internals/array-slice');
  55646. var MSIE = /MSIE .\./.test(userAgent); // <- dirty ie9- check
  55647. var Function = global.Function;
  55648. var wrap = function (scheduler) {
  55649. return function (handler, timeout /* , ...arguments */) {
  55650. var boundArgs = arguments.length > 2;
  55651. var args = boundArgs ? arraySlice(arguments, 2) : undefined;
  55652. return scheduler(boundArgs ? function () {
  55653. apply(isCallable(handler) ? handler : Function(handler), this, args);
  55654. } : handler, timeout);
  55655. };
  55656. };
  55657. // ie9- setTimeout & setInterval additional parameters fix
  55658. // https://html.spec.whatwg.org/multipage/timers-and-user-prompts.html#timers
  55659. $({ global: true, bind: true, forced: MSIE }, {
  55660. // `setTimeout` method
  55661. // https://html.spec.whatwg.org/multipage/timers-and-user-prompts.html#dom-settimeout
  55662. setTimeout: wrap(global.setTimeout),
  55663. // `setInterval` method
  55664. // https://html.spec.whatwg.org/multipage/timers-and-user-prompts.html#dom-setinterval
  55665. setInterval: wrap(global.setInterval)
  55666. });
  55667. },{"../internals/array-slice":436,"../internals/engine-user-agent":470,"../internals/export":476,"../internals/function-apply":479,"../internals/global":491,"../internals/is-callable":504}],688:[function(_dereq_,module,exports){
  55668. 'use strict';
  55669. // TODO: in core-js@4, move /modules/ dependencies to public entries for better optimization by tools like `preset-env`
  55670. _dereq_('../modules/es.array.iterator');
  55671. var $ = _dereq_('../internals/export');
  55672. var global = _dereq_('../internals/global');
  55673. var getBuiltIn = _dereq_('../internals/get-built-in');
  55674. var call = _dereq_('../internals/function-call');
  55675. var uncurryThis = _dereq_('../internals/function-uncurry-this');
  55676. var USE_NATIVE_URL = _dereq_('../internals/native-url');
  55677. var redefine = _dereq_('../internals/redefine');
  55678. var redefineAll = _dereq_('../internals/redefine-all');
  55679. var setToStringTag = _dereq_('../internals/set-to-string-tag');
  55680. var createIteratorConstructor = _dereq_('../internals/create-iterator-constructor');
  55681. var InternalStateModule = _dereq_('../internals/internal-state');
  55682. var anInstance = _dereq_('../internals/an-instance');
  55683. var isCallable = _dereq_('../internals/is-callable');
  55684. var hasOwn = _dereq_('../internals/has-own-property');
  55685. var bind = _dereq_('../internals/function-bind-context');
  55686. var classof = _dereq_('../internals/classof');
  55687. var anObject = _dereq_('../internals/an-object');
  55688. var isObject = _dereq_('../internals/is-object');
  55689. var $toString = _dereq_('../internals/to-string');
  55690. var create = _dereq_('../internals/object-create');
  55691. var createPropertyDescriptor = _dereq_('../internals/create-property-descriptor');
  55692. var getIterator = _dereq_('../internals/get-iterator');
  55693. var getIteratorMethod = _dereq_('../internals/get-iterator-method');
  55694. var validateArgumentsLength = _dereq_('../internals/validate-arguments-length');
  55695. var wellKnownSymbol = _dereq_('../internals/well-known-symbol');
  55696. var arraySort = _dereq_('../internals/array-sort');
  55697. var ITERATOR = wellKnownSymbol('iterator');
  55698. var URL_SEARCH_PARAMS = 'URLSearchParams';
  55699. var URL_SEARCH_PARAMS_ITERATOR = URL_SEARCH_PARAMS + 'Iterator';
  55700. var setInternalState = InternalStateModule.set;
  55701. var getInternalParamsState = InternalStateModule.getterFor(URL_SEARCH_PARAMS);
  55702. var getInternalIteratorState = InternalStateModule.getterFor(URL_SEARCH_PARAMS_ITERATOR);
  55703. var n$Fetch = getBuiltIn('fetch');
  55704. var N$Request = getBuiltIn('Request');
  55705. var Headers = getBuiltIn('Headers');
  55706. var RequestPrototype = N$Request && N$Request.prototype;
  55707. var HeadersPrototype = Headers && Headers.prototype;
  55708. var RegExp = global.RegExp;
  55709. var TypeError = global.TypeError;
  55710. var decodeURIComponent = global.decodeURIComponent;
  55711. var encodeURIComponent = global.encodeURIComponent;
  55712. var charAt = uncurryThis(''.charAt);
  55713. var join = uncurryThis([].join);
  55714. var push = uncurryThis([].push);
  55715. var replace = uncurryThis(''.replace);
  55716. var shift = uncurryThis([].shift);
  55717. var splice = uncurryThis([].splice);
  55718. var split = uncurryThis(''.split);
  55719. var stringSlice = uncurryThis(''.slice);
  55720. var plus = /\+/g;
  55721. var sequences = Array(4);
  55722. var percentSequence = function (bytes) {
  55723. return sequences[bytes - 1] || (sequences[bytes - 1] = RegExp('((?:%[\\da-f]{2}){' + bytes + '})', 'gi'));
  55724. };
  55725. var percentDecode = function (sequence) {
  55726. try {
  55727. return decodeURIComponent(sequence);
  55728. } catch (error) {
  55729. return sequence;
  55730. }
  55731. };
  55732. var deserialize = function (it) {
  55733. var result = replace(it, plus, ' ');
  55734. var bytes = 4;
  55735. try {
  55736. return decodeURIComponent(result);
  55737. } catch (error) {
  55738. while (bytes) {
  55739. result = replace(result, percentSequence(bytes--), percentDecode);
  55740. }
  55741. return result;
  55742. }
  55743. };
  55744. var find = /[!'()~]|%20/g;
  55745. var replacements = {
  55746. '!': '%21',
  55747. "'": '%27',
  55748. '(': '%28',
  55749. ')': '%29',
  55750. '~': '%7E',
  55751. '%20': '+'
  55752. };
  55753. var replacer = function (match) {
  55754. return replacements[match];
  55755. };
  55756. var serialize = function (it) {
  55757. return replace(encodeURIComponent(it), find, replacer);
  55758. };
  55759. var URLSearchParamsIterator = createIteratorConstructor(function Iterator(params, kind) {
  55760. setInternalState(this, {
  55761. type: URL_SEARCH_PARAMS_ITERATOR,
  55762. iterator: getIterator(getInternalParamsState(params).entries),
  55763. kind: kind
  55764. });
  55765. }, 'Iterator', function next() {
  55766. var state = getInternalIteratorState(this);
  55767. var kind = state.kind;
  55768. var step = state.iterator.next();
  55769. var entry = step.value;
  55770. if (!step.done) {
  55771. step.value = kind === 'keys' ? entry.key : kind === 'values' ? entry.value : [entry.key, entry.value];
  55772. } return step;
  55773. }, true);
  55774. var URLSearchParamsState = function (init) {
  55775. this.entries = [];
  55776. this.url = null;
  55777. if (init !== undefined) {
  55778. if (isObject(init)) this.parseObject(init);
  55779. else this.parseQuery(typeof init == 'string' ? charAt(init, 0) === '?' ? stringSlice(init, 1) : init : $toString(init));
  55780. }
  55781. };
  55782. URLSearchParamsState.prototype = {
  55783. type: URL_SEARCH_PARAMS,
  55784. bindURL: function (url) {
  55785. this.url = url;
  55786. this.update();
  55787. },
  55788. parseObject: function (object) {
  55789. var iteratorMethod = getIteratorMethod(object);
  55790. var iterator, next, step, entryIterator, entryNext, first, second;
  55791. if (iteratorMethod) {
  55792. iterator = getIterator(object, iteratorMethod);
  55793. next = iterator.next;
  55794. while (!(step = call(next, iterator)).done) {
  55795. entryIterator = getIterator(anObject(step.value));
  55796. entryNext = entryIterator.next;
  55797. if (
  55798. (first = call(entryNext, entryIterator)).done ||
  55799. (second = call(entryNext, entryIterator)).done ||
  55800. !call(entryNext, entryIterator).done
  55801. ) throw TypeError('Expected sequence with length 2');
  55802. push(this.entries, { key: $toString(first.value), value: $toString(second.value) });
  55803. }
  55804. } else for (var key in object) if (hasOwn(object, key)) {
  55805. push(this.entries, { key: key, value: $toString(object[key]) });
  55806. }
  55807. },
  55808. parseQuery: function (query) {
  55809. if (query) {
  55810. var attributes = split(query, '&');
  55811. var index = 0;
  55812. var attribute, entry;
  55813. while (index < attributes.length) {
  55814. attribute = attributes[index++];
  55815. if (attribute.length) {
  55816. entry = split(attribute, '=');
  55817. push(this.entries, {
  55818. key: deserialize(shift(entry)),
  55819. value: deserialize(join(entry, '='))
  55820. });
  55821. }
  55822. }
  55823. }
  55824. },
  55825. serialize: function () {
  55826. var entries = this.entries;
  55827. var result = [];
  55828. var index = 0;
  55829. var entry;
  55830. while (index < entries.length) {
  55831. entry = entries[index++];
  55832. push(result, serialize(entry.key) + '=' + serialize(entry.value));
  55833. } return join(result, '&');
  55834. },
  55835. update: function () {
  55836. this.entries.length = 0;
  55837. this.parseQuery(this.url.query);
  55838. },
  55839. updateURL: function () {
  55840. if (this.url) this.url.update();
  55841. }
  55842. };
  55843. // `URLSearchParams` constructor
  55844. // https://url.spec.whatwg.org/#interface-urlsearchparams
  55845. var URLSearchParamsConstructor = function URLSearchParams(/* init */) {
  55846. anInstance(this, URLSearchParamsPrototype);
  55847. var init = arguments.length > 0 ? arguments[0] : undefined;
  55848. setInternalState(this, new URLSearchParamsState(init));
  55849. };
  55850. var URLSearchParamsPrototype = URLSearchParamsConstructor.prototype;
  55851. redefineAll(URLSearchParamsPrototype, {
  55852. // `URLSearchParams.prototype.append` method
  55853. // https://url.spec.whatwg.org/#dom-urlsearchparams-append
  55854. append: function append(name, value) {
  55855. validateArgumentsLength(arguments.length, 2);
  55856. var state = getInternalParamsState(this);
  55857. push(state.entries, { key: $toString(name), value: $toString(value) });
  55858. state.updateURL();
  55859. },
  55860. // `URLSearchParams.prototype.delete` method
  55861. // https://url.spec.whatwg.org/#dom-urlsearchparams-delete
  55862. 'delete': function (name) {
  55863. validateArgumentsLength(arguments.length, 1);
  55864. var state = getInternalParamsState(this);
  55865. var entries = state.entries;
  55866. var key = $toString(name);
  55867. var index = 0;
  55868. while (index < entries.length) {
  55869. if (entries[index].key === key) splice(entries, index, 1);
  55870. else index++;
  55871. }
  55872. state.updateURL();
  55873. },
  55874. // `URLSearchParams.prototype.get` method
  55875. // https://url.spec.whatwg.org/#dom-urlsearchparams-get
  55876. get: function get(name) {
  55877. validateArgumentsLength(arguments.length, 1);
  55878. var entries = getInternalParamsState(this).entries;
  55879. var key = $toString(name);
  55880. var index = 0;
  55881. for (; index < entries.length; index++) {
  55882. if (entries[index].key === key) return entries[index].value;
  55883. }
  55884. return null;
  55885. },
  55886. // `URLSearchParams.prototype.getAll` method
  55887. // https://url.spec.whatwg.org/#dom-urlsearchparams-getall
  55888. getAll: function getAll(name) {
  55889. validateArgumentsLength(arguments.length, 1);
  55890. var entries = getInternalParamsState(this).entries;
  55891. var key = $toString(name);
  55892. var result = [];
  55893. var index = 0;
  55894. for (; index < entries.length; index++) {
  55895. if (entries[index].key === key) push(result, entries[index].value);
  55896. }
  55897. return result;
  55898. },
  55899. // `URLSearchParams.prototype.has` method
  55900. // https://url.spec.whatwg.org/#dom-urlsearchparams-has
  55901. has: function has(name) {
  55902. validateArgumentsLength(arguments.length, 1);
  55903. var entries = getInternalParamsState(this).entries;
  55904. var key = $toString(name);
  55905. var index = 0;
  55906. while (index < entries.length) {
  55907. if (entries[index++].key === key) return true;
  55908. }
  55909. return false;
  55910. },
  55911. // `URLSearchParams.prototype.set` method
  55912. // https://url.spec.whatwg.org/#dom-urlsearchparams-set
  55913. set: function set(name, value) {
  55914. validateArgumentsLength(arguments.length, 1);
  55915. var state = getInternalParamsState(this);
  55916. var entries = state.entries;
  55917. var found = false;
  55918. var key = $toString(name);
  55919. var val = $toString(value);
  55920. var index = 0;
  55921. var entry;
  55922. for (; index < entries.length; index++) {
  55923. entry = entries[index];
  55924. if (entry.key === key) {
  55925. if (found) splice(entries, index--, 1);
  55926. else {
  55927. found = true;
  55928. entry.value = val;
  55929. }
  55930. }
  55931. }
  55932. if (!found) push(entries, { key: key, value: val });
  55933. state.updateURL();
  55934. },
  55935. // `URLSearchParams.prototype.sort` method
  55936. // https://url.spec.whatwg.org/#dom-urlsearchparams-sort
  55937. sort: function sort() {
  55938. var state = getInternalParamsState(this);
  55939. arraySort(state.entries, function (a, b) {
  55940. return a.key > b.key ? 1 : -1;
  55941. });
  55942. state.updateURL();
  55943. },
  55944. // `URLSearchParams.prototype.forEach` method
  55945. forEach: function forEach(callback /* , thisArg */) {
  55946. var entries = getInternalParamsState(this).entries;
  55947. var boundFunction = bind(callback, arguments.length > 1 ? arguments[1] : undefined);
  55948. var index = 0;
  55949. var entry;
  55950. while (index < entries.length) {
  55951. entry = entries[index++];
  55952. boundFunction(entry.value, entry.key, this);
  55953. }
  55954. },
  55955. // `URLSearchParams.prototype.keys` method
  55956. keys: function keys() {
  55957. return new URLSearchParamsIterator(this, 'keys');
  55958. },
  55959. // `URLSearchParams.prototype.values` method
  55960. values: function values() {
  55961. return new URLSearchParamsIterator(this, 'values');
  55962. },
  55963. // `URLSearchParams.prototype.entries` method
  55964. entries: function entries() {
  55965. return new URLSearchParamsIterator(this, 'entries');
  55966. }
  55967. }, { enumerable: true });
  55968. // `URLSearchParams.prototype[@@iterator]` method
  55969. redefine(URLSearchParamsPrototype, ITERATOR, URLSearchParamsPrototype.entries, { name: 'entries' });
  55970. // `URLSearchParams.prototype.toString` method
  55971. // https://url.spec.whatwg.org/#urlsearchparams-stringification-behavior
  55972. redefine(URLSearchParamsPrototype, 'toString', function toString() {
  55973. return getInternalParamsState(this).serialize();
  55974. }, { enumerable: true });
  55975. setToStringTag(URLSearchParamsConstructor, URL_SEARCH_PARAMS);
  55976. $({ global: true, forced: !USE_NATIVE_URL }, {
  55977. URLSearchParams: URLSearchParamsConstructor
  55978. });
  55979. // Wrap `fetch` and `Request` for correct work with polyfilled `URLSearchParams`
  55980. if (!USE_NATIVE_URL && isCallable(Headers)) {
  55981. var headersHas = uncurryThis(HeadersPrototype.has);
  55982. var headersSet = uncurryThis(HeadersPrototype.set);
  55983. var wrapRequestOptions = function (init) {
  55984. if (isObject(init)) {
  55985. var body = init.body;
  55986. var headers;
  55987. if (classof(body) === URL_SEARCH_PARAMS) {
  55988. headers = init.headers ? new Headers(init.headers) : new Headers();
  55989. if (!headersHas(headers, 'content-type')) {
  55990. headersSet(headers, 'content-type', 'application/x-www-form-urlencoded;charset=UTF-8');
  55991. }
  55992. return create(init, {
  55993. body: createPropertyDescriptor(0, $toString(body)),
  55994. headers: createPropertyDescriptor(0, headers)
  55995. });
  55996. }
  55997. } return init;
  55998. };
  55999. if (isCallable(n$Fetch)) {
  56000. $({ global: true, enumerable: true, forced: true }, {
  56001. fetch: function fetch(input /* , init */) {
  56002. return n$Fetch(input, arguments.length > 1 ? wrapRequestOptions(arguments[1]) : {});
  56003. }
  56004. });
  56005. }
  56006. if (isCallable(N$Request)) {
  56007. var RequestConstructor = function Request(input /* , init */) {
  56008. anInstance(this, RequestPrototype);
  56009. return new N$Request(input, arguments.length > 1 ? wrapRequestOptions(arguments[1]) : {});
  56010. };
  56011. RequestPrototype.constructor = RequestConstructor;
  56012. RequestConstructor.prototype = RequestPrototype;
  56013. $({ global: true, forced: true }, {
  56014. Request: RequestConstructor
  56015. });
  56016. }
  56017. }
  56018. module.exports = {
  56019. URLSearchParams: URLSearchParamsConstructor,
  56020. getState: getInternalParamsState
  56021. };
  56022. },{"../internals/an-instance":425,"../internals/an-object":426,"../internals/array-sort":437,"../internals/classof":443,"../internals/create-iterator-constructor":454,"../internals/create-property-descriptor":456,"../internals/export":476,"../internals/function-bind-context":480,"../internals/function-call":483,"../internals/function-uncurry-this":485,"../internals/get-built-in":486,"../internals/get-iterator":488,"../internals/get-iterator-method":487,"../internals/global":491,"../internals/has-own-property":492,"../internals/internal-state":501,"../internals/is-callable":504,"../internals/is-object":509,"../internals/native-url":523,"../internals/object-create":530,"../internals/redefine":553,"../internals/redefine-all":552,"../internals/set-to-string-tag":558,"../internals/to-string":579,"../internals/validate-arguments-length":584,"../internals/well-known-symbol":586,"../modules/es.array.iterator":598}],689:[function(_dereq_,module,exports){
  56023. 'use strict';
  56024. // TODO: in core-js@4, move /modules/ dependencies to public entries for better optimization by tools like `preset-env`
  56025. _dereq_('../modules/es.string.iterator');
  56026. var $ = _dereq_('../internals/export');
  56027. var DESCRIPTORS = _dereq_('../internals/descriptors');
  56028. var USE_NATIVE_URL = _dereq_('../internals/native-url');
  56029. var global = _dereq_('../internals/global');
  56030. var bind = _dereq_('../internals/function-bind-context');
  56031. var uncurryThis = _dereq_('../internals/function-uncurry-this');
  56032. var defineProperties = _dereq_('../internals/object-define-properties').f;
  56033. var redefine = _dereq_('../internals/redefine');
  56034. var anInstance = _dereq_('../internals/an-instance');
  56035. var hasOwn = _dereq_('../internals/has-own-property');
  56036. var assign = _dereq_('../internals/object-assign');
  56037. var arrayFrom = _dereq_('../internals/array-from');
  56038. var arraySlice = _dereq_('../internals/array-slice-simple');
  56039. var codeAt = _dereq_('../internals/string-multibyte').codeAt;
  56040. var toASCII = _dereq_('../internals/string-punycode-to-ascii');
  56041. var $toString = _dereq_('../internals/to-string');
  56042. var setToStringTag = _dereq_('../internals/set-to-string-tag');
  56043. var URLSearchParamsModule = _dereq_('../modules/web.url-search-params');
  56044. var InternalStateModule = _dereq_('../internals/internal-state');
  56045. var setInternalState = InternalStateModule.set;
  56046. var getInternalURLState = InternalStateModule.getterFor('URL');
  56047. var URLSearchParams = URLSearchParamsModule.URLSearchParams;
  56048. var getInternalSearchParamsState = URLSearchParamsModule.getState;
  56049. var NativeURL = global.URL;
  56050. var TypeError = global.TypeError;
  56051. var parseInt = global.parseInt;
  56052. var floor = Math.floor;
  56053. var pow = Math.pow;
  56054. var charAt = uncurryThis(''.charAt);
  56055. var exec = uncurryThis(/./.exec);
  56056. var join = uncurryThis([].join);
  56057. var numberToString = uncurryThis(1.0.toString);
  56058. var pop = uncurryThis([].pop);
  56059. var push = uncurryThis([].push);
  56060. var replace = uncurryThis(''.replace);
  56061. var shift = uncurryThis([].shift);
  56062. var split = uncurryThis(''.split);
  56063. var stringSlice = uncurryThis(''.slice);
  56064. var toLowerCase = uncurryThis(''.toLowerCase);
  56065. var unshift = uncurryThis([].unshift);
  56066. var INVALID_AUTHORITY = 'Invalid authority';
  56067. var INVALID_SCHEME = 'Invalid scheme';
  56068. var INVALID_HOST = 'Invalid host';
  56069. var INVALID_PORT = 'Invalid port';
  56070. var ALPHA = /[a-z]/i;
  56071. // eslint-disable-next-line regexp/no-obscure-range -- safe
  56072. var ALPHANUMERIC = /[\d+-.a-z]/i;
  56073. var DIGIT = /\d/;
  56074. var HEX_START = /^0x/i;
  56075. var OCT = /^[0-7]+$/;
  56076. var DEC = /^\d+$/;
  56077. var HEX = /^[\da-f]+$/i;
  56078. /* eslint-disable regexp/no-control-character -- safe */
  56079. var FORBIDDEN_HOST_CODE_POINT = /[\0\t\n\r #%/:<>?@[\\\]^|]/;
  56080. var FORBIDDEN_HOST_CODE_POINT_EXCLUDING_PERCENT = /[\0\t\n\r #/:<>?@[\\\]^|]/;
  56081. var LEADING_AND_TRAILING_C0_CONTROL_OR_SPACE = /^[\u0000-\u0020]+|[\u0000-\u0020]+$/g;
  56082. var TAB_AND_NEW_LINE = /[\t\n\r]/g;
  56083. /* eslint-enable regexp/no-control-character -- safe */
  56084. var EOF;
  56085. // https://url.spec.whatwg.org/#ipv4-number-parser
  56086. var parseIPv4 = function (input) {
  56087. var parts = split(input, '.');
  56088. var partsLength, numbers, index, part, radix, number, ipv4;
  56089. if (parts.length && parts[parts.length - 1] == '') {
  56090. parts.length--;
  56091. }
  56092. partsLength = parts.length;
  56093. if (partsLength > 4) return input;
  56094. numbers = [];
  56095. for (index = 0; index < partsLength; index++) {
  56096. part = parts[index];
  56097. if (part == '') return input;
  56098. radix = 10;
  56099. if (part.length > 1 && charAt(part, 0) == '0') {
  56100. radix = exec(HEX_START, part) ? 16 : 8;
  56101. part = stringSlice(part, radix == 8 ? 1 : 2);
  56102. }
  56103. if (part === '') {
  56104. number = 0;
  56105. } else {
  56106. if (!exec(radix == 10 ? DEC : radix == 8 ? OCT : HEX, part)) return input;
  56107. number = parseInt(part, radix);
  56108. }
  56109. push(numbers, number);
  56110. }
  56111. for (index = 0; index < partsLength; index++) {
  56112. number = numbers[index];
  56113. if (index == partsLength - 1) {
  56114. if (number >= pow(256, 5 - partsLength)) return null;
  56115. } else if (number > 255) return null;
  56116. }
  56117. ipv4 = pop(numbers);
  56118. for (index = 0; index < numbers.length; index++) {
  56119. ipv4 += numbers[index] * pow(256, 3 - index);
  56120. }
  56121. return ipv4;
  56122. };
  56123. // https://url.spec.whatwg.org/#concept-ipv6-parser
  56124. // eslint-disable-next-line max-statements -- TODO
  56125. var parseIPv6 = function (input) {
  56126. var address = [0, 0, 0, 0, 0, 0, 0, 0];
  56127. var pieceIndex = 0;
  56128. var compress = null;
  56129. var pointer = 0;
  56130. var value, length, numbersSeen, ipv4Piece, number, swaps, swap;
  56131. var chr = function () {
  56132. return charAt(input, pointer);
  56133. };
  56134. if (chr() == ':') {
  56135. if (charAt(input, 1) != ':') return;
  56136. pointer += 2;
  56137. pieceIndex++;
  56138. compress = pieceIndex;
  56139. }
  56140. while (chr()) {
  56141. if (pieceIndex == 8) return;
  56142. if (chr() == ':') {
  56143. if (compress !== null) return;
  56144. pointer++;
  56145. pieceIndex++;
  56146. compress = pieceIndex;
  56147. continue;
  56148. }
  56149. value = length = 0;
  56150. while (length < 4 && exec(HEX, chr())) {
  56151. value = value * 16 + parseInt(chr(), 16);
  56152. pointer++;
  56153. length++;
  56154. }
  56155. if (chr() == '.') {
  56156. if (length == 0) return;
  56157. pointer -= length;
  56158. if (pieceIndex > 6) return;
  56159. numbersSeen = 0;
  56160. while (chr()) {
  56161. ipv4Piece = null;
  56162. if (numbersSeen > 0) {
  56163. if (chr() == '.' && numbersSeen < 4) pointer++;
  56164. else return;
  56165. }
  56166. if (!exec(DIGIT, chr())) return;
  56167. while (exec(DIGIT, chr())) {
  56168. number = parseInt(chr(), 10);
  56169. if (ipv4Piece === null) ipv4Piece = number;
  56170. else if (ipv4Piece == 0) return;
  56171. else ipv4Piece = ipv4Piece * 10 + number;
  56172. if (ipv4Piece > 255) return;
  56173. pointer++;
  56174. }
  56175. address[pieceIndex] = address[pieceIndex] * 256 + ipv4Piece;
  56176. numbersSeen++;
  56177. if (numbersSeen == 2 || numbersSeen == 4) pieceIndex++;
  56178. }
  56179. if (numbersSeen != 4) return;
  56180. break;
  56181. } else if (chr() == ':') {
  56182. pointer++;
  56183. if (!chr()) return;
  56184. } else if (chr()) return;
  56185. address[pieceIndex++] = value;
  56186. }
  56187. if (compress !== null) {
  56188. swaps = pieceIndex - compress;
  56189. pieceIndex = 7;
  56190. while (pieceIndex != 0 && swaps > 0) {
  56191. swap = address[pieceIndex];
  56192. address[pieceIndex--] = address[compress + swaps - 1];
  56193. address[compress + --swaps] = swap;
  56194. }
  56195. } else if (pieceIndex != 8) return;
  56196. return address;
  56197. };
  56198. var findLongestZeroSequence = function (ipv6) {
  56199. var maxIndex = null;
  56200. var maxLength = 1;
  56201. var currStart = null;
  56202. var currLength = 0;
  56203. var index = 0;
  56204. for (; index < 8; index++) {
  56205. if (ipv6[index] !== 0) {
  56206. if (currLength > maxLength) {
  56207. maxIndex = currStart;
  56208. maxLength = currLength;
  56209. }
  56210. currStart = null;
  56211. currLength = 0;
  56212. } else {
  56213. if (currStart === null) currStart = index;
  56214. ++currLength;
  56215. }
  56216. }
  56217. if (currLength > maxLength) {
  56218. maxIndex = currStart;
  56219. maxLength = currLength;
  56220. }
  56221. return maxIndex;
  56222. };
  56223. // https://url.spec.whatwg.org/#host-serializing
  56224. var serializeHost = function (host) {
  56225. var result, index, compress, ignore0;
  56226. // ipv4
  56227. if (typeof host == 'number') {
  56228. result = [];
  56229. for (index = 0; index < 4; index++) {
  56230. unshift(result, host % 256);
  56231. host = floor(host / 256);
  56232. } return join(result, '.');
  56233. // ipv6
  56234. } else if (typeof host == 'object') {
  56235. result = '';
  56236. compress = findLongestZeroSequence(host);
  56237. for (index = 0; index < 8; index++) {
  56238. if (ignore0 && host[index] === 0) continue;
  56239. if (ignore0) ignore0 = false;
  56240. if (compress === index) {
  56241. result += index ? ':' : '::';
  56242. ignore0 = true;
  56243. } else {
  56244. result += numberToString(host[index], 16);
  56245. if (index < 7) result += ':';
  56246. }
  56247. }
  56248. return '[' + result + ']';
  56249. } return host;
  56250. };
  56251. var C0ControlPercentEncodeSet = {};
  56252. var fragmentPercentEncodeSet = assign({}, C0ControlPercentEncodeSet, {
  56253. ' ': 1, '"': 1, '<': 1, '>': 1, '`': 1
  56254. });
  56255. var pathPercentEncodeSet = assign({}, fragmentPercentEncodeSet, {
  56256. '#': 1, '?': 1, '{': 1, '}': 1
  56257. });
  56258. var userinfoPercentEncodeSet = assign({}, pathPercentEncodeSet, {
  56259. '/': 1, ':': 1, ';': 1, '=': 1, '@': 1, '[': 1, '\\': 1, ']': 1, '^': 1, '|': 1
  56260. });
  56261. var percentEncode = function (chr, set) {
  56262. var code = codeAt(chr, 0);
  56263. return code > 0x20 && code < 0x7F && !hasOwn(set, chr) ? chr : encodeURIComponent(chr);
  56264. };
  56265. // https://url.spec.whatwg.org/#special-scheme
  56266. var specialSchemes = {
  56267. ftp: 21,
  56268. file: null,
  56269. http: 80,
  56270. https: 443,
  56271. ws: 80,
  56272. wss: 443
  56273. };
  56274. // https://url.spec.whatwg.org/#windows-drive-letter
  56275. var isWindowsDriveLetter = function (string, normalized) {
  56276. var second;
  56277. return string.length == 2 && exec(ALPHA, charAt(string, 0))
  56278. && ((second = charAt(string, 1)) == ':' || (!normalized && second == '|'));
  56279. };
  56280. // https://url.spec.whatwg.org/#start-with-a-windows-drive-letter
  56281. var startsWithWindowsDriveLetter = function (string) {
  56282. var third;
  56283. return string.length > 1 && isWindowsDriveLetter(stringSlice(string, 0, 2)) && (
  56284. string.length == 2 ||
  56285. ((third = charAt(string, 2)) === '/' || third === '\\' || third === '?' || third === '#')
  56286. );
  56287. };
  56288. // https://url.spec.whatwg.org/#single-dot-path-segment
  56289. var isSingleDot = function (segment) {
  56290. return segment === '.' || toLowerCase(segment) === '%2e';
  56291. };
  56292. // https://url.spec.whatwg.org/#double-dot-path-segment
  56293. var isDoubleDot = function (segment) {
  56294. segment = toLowerCase(segment);
  56295. return segment === '..' || segment === '%2e.' || segment === '.%2e' || segment === '%2e%2e';
  56296. };
  56297. // States:
  56298. var SCHEME_START = {};
  56299. var SCHEME = {};
  56300. var NO_SCHEME = {};
  56301. var SPECIAL_RELATIVE_OR_AUTHORITY = {};
  56302. var PATH_OR_AUTHORITY = {};
  56303. var RELATIVE = {};
  56304. var RELATIVE_SLASH = {};
  56305. var SPECIAL_AUTHORITY_SLASHES = {};
  56306. var SPECIAL_AUTHORITY_IGNORE_SLASHES = {};
  56307. var AUTHORITY = {};
  56308. var HOST = {};
  56309. var HOSTNAME = {};
  56310. var PORT = {};
  56311. var FILE = {};
  56312. var FILE_SLASH = {};
  56313. var FILE_HOST = {};
  56314. var PATH_START = {};
  56315. var PATH = {};
  56316. var CANNOT_BE_A_BASE_URL_PATH = {};
  56317. var QUERY = {};
  56318. var FRAGMENT = {};
  56319. var URLState = function (url, isBase, base) {
  56320. var urlString = $toString(url);
  56321. var baseState, failure, searchParams;
  56322. if (isBase) {
  56323. failure = this.parse(urlString);
  56324. if (failure) throw TypeError(failure);
  56325. this.searchParams = null;
  56326. } else {
  56327. if (base !== undefined) baseState = new URLState(base, true);
  56328. failure = this.parse(urlString, null, baseState);
  56329. if (failure) throw TypeError(failure);
  56330. searchParams = getInternalSearchParamsState(new URLSearchParams());
  56331. searchParams.bindURL(this);
  56332. this.searchParams = searchParams;
  56333. }
  56334. };
  56335. URLState.prototype = {
  56336. type: 'URL',
  56337. // https://url.spec.whatwg.org/#url-parsing
  56338. // eslint-disable-next-line max-statements -- TODO
  56339. parse: function (input, stateOverride, base) {
  56340. var url = this;
  56341. var state = stateOverride || SCHEME_START;
  56342. var pointer = 0;
  56343. var buffer = '';
  56344. var seenAt = false;
  56345. var seenBracket = false;
  56346. var seenPasswordToken = false;
  56347. var codePoints, chr, bufferCodePoints, failure;
  56348. input = $toString(input);
  56349. if (!stateOverride) {
  56350. url.scheme = '';
  56351. url.username = '';
  56352. url.password = '';
  56353. url.host = null;
  56354. url.port = null;
  56355. url.path = [];
  56356. url.query = null;
  56357. url.fragment = null;
  56358. url.cannotBeABaseURL = false;
  56359. input = replace(input, LEADING_AND_TRAILING_C0_CONTROL_OR_SPACE, '');
  56360. }
  56361. input = replace(input, TAB_AND_NEW_LINE, '');
  56362. codePoints = arrayFrom(input);
  56363. while (pointer <= codePoints.length) {
  56364. chr = codePoints[pointer];
  56365. switch (state) {
  56366. case SCHEME_START:
  56367. if (chr && exec(ALPHA, chr)) {
  56368. buffer += toLowerCase(chr);
  56369. state = SCHEME;
  56370. } else if (!stateOverride) {
  56371. state = NO_SCHEME;
  56372. continue;
  56373. } else return INVALID_SCHEME;
  56374. break;
  56375. case SCHEME:
  56376. if (chr && (exec(ALPHANUMERIC, chr) || chr == '+' || chr == '-' || chr == '.')) {
  56377. buffer += toLowerCase(chr);
  56378. } else if (chr == ':') {
  56379. if (stateOverride && (
  56380. (url.isSpecial() != hasOwn(specialSchemes, buffer)) ||
  56381. (buffer == 'file' && (url.includesCredentials() || url.port !== null)) ||
  56382. (url.scheme == 'file' && !url.host)
  56383. )) return;
  56384. url.scheme = buffer;
  56385. if (stateOverride) {
  56386. if (url.isSpecial() && specialSchemes[url.scheme] == url.port) url.port = null;
  56387. return;
  56388. }
  56389. buffer = '';
  56390. if (url.scheme == 'file') {
  56391. state = FILE;
  56392. } else if (url.isSpecial() && base && base.scheme == url.scheme) {
  56393. state = SPECIAL_RELATIVE_OR_AUTHORITY;
  56394. } else if (url.isSpecial()) {
  56395. state = SPECIAL_AUTHORITY_SLASHES;
  56396. } else if (codePoints[pointer + 1] == '/') {
  56397. state = PATH_OR_AUTHORITY;
  56398. pointer++;
  56399. } else {
  56400. url.cannotBeABaseURL = true;
  56401. push(url.path, '');
  56402. state = CANNOT_BE_A_BASE_URL_PATH;
  56403. }
  56404. } else if (!stateOverride) {
  56405. buffer = '';
  56406. state = NO_SCHEME;
  56407. pointer = 0;
  56408. continue;
  56409. } else return INVALID_SCHEME;
  56410. break;
  56411. case NO_SCHEME:
  56412. if (!base || (base.cannotBeABaseURL && chr != '#')) return INVALID_SCHEME;
  56413. if (base.cannotBeABaseURL && chr == '#') {
  56414. url.scheme = base.scheme;
  56415. url.path = arraySlice(base.path);
  56416. url.query = base.query;
  56417. url.fragment = '';
  56418. url.cannotBeABaseURL = true;
  56419. state = FRAGMENT;
  56420. break;
  56421. }
  56422. state = base.scheme == 'file' ? FILE : RELATIVE;
  56423. continue;
  56424. case SPECIAL_RELATIVE_OR_AUTHORITY:
  56425. if (chr == '/' && codePoints[pointer + 1] == '/') {
  56426. state = SPECIAL_AUTHORITY_IGNORE_SLASHES;
  56427. pointer++;
  56428. } else {
  56429. state = RELATIVE;
  56430. continue;
  56431. } break;
  56432. case PATH_OR_AUTHORITY:
  56433. if (chr == '/') {
  56434. state = AUTHORITY;
  56435. break;
  56436. } else {
  56437. state = PATH;
  56438. continue;
  56439. }
  56440. case RELATIVE:
  56441. url.scheme = base.scheme;
  56442. if (chr == EOF) {
  56443. url.username = base.username;
  56444. url.password = base.password;
  56445. url.host = base.host;
  56446. url.port = base.port;
  56447. url.path = arraySlice(base.path);
  56448. url.query = base.query;
  56449. } else if (chr == '/' || (chr == '\\' && url.isSpecial())) {
  56450. state = RELATIVE_SLASH;
  56451. } else if (chr == '?') {
  56452. url.username = base.username;
  56453. url.password = base.password;
  56454. url.host = base.host;
  56455. url.port = base.port;
  56456. url.path = arraySlice(base.path);
  56457. url.query = '';
  56458. state = QUERY;
  56459. } else if (chr == '#') {
  56460. url.username = base.username;
  56461. url.password = base.password;
  56462. url.host = base.host;
  56463. url.port = base.port;
  56464. url.path = arraySlice(base.path);
  56465. url.query = base.query;
  56466. url.fragment = '';
  56467. state = FRAGMENT;
  56468. } else {
  56469. url.username = base.username;
  56470. url.password = base.password;
  56471. url.host = base.host;
  56472. url.port = base.port;
  56473. url.path = arraySlice(base.path);
  56474. url.path.length--;
  56475. state = PATH;
  56476. continue;
  56477. } break;
  56478. case RELATIVE_SLASH:
  56479. if (url.isSpecial() && (chr == '/' || chr == '\\')) {
  56480. state = SPECIAL_AUTHORITY_IGNORE_SLASHES;
  56481. } else if (chr == '/') {
  56482. state = AUTHORITY;
  56483. } else {
  56484. url.username = base.username;
  56485. url.password = base.password;
  56486. url.host = base.host;
  56487. url.port = base.port;
  56488. state = PATH;
  56489. continue;
  56490. } break;
  56491. case SPECIAL_AUTHORITY_SLASHES:
  56492. state = SPECIAL_AUTHORITY_IGNORE_SLASHES;
  56493. if (chr != '/' || charAt(buffer, pointer + 1) != '/') continue;
  56494. pointer++;
  56495. break;
  56496. case SPECIAL_AUTHORITY_IGNORE_SLASHES:
  56497. if (chr != '/' && chr != '\\') {
  56498. state = AUTHORITY;
  56499. continue;
  56500. } break;
  56501. case AUTHORITY:
  56502. if (chr == '@') {
  56503. if (seenAt) buffer = '%40' + buffer;
  56504. seenAt = true;
  56505. bufferCodePoints = arrayFrom(buffer);
  56506. for (var i = 0; i < bufferCodePoints.length; i++) {
  56507. var codePoint = bufferCodePoints[i];
  56508. if (codePoint == ':' && !seenPasswordToken) {
  56509. seenPasswordToken = true;
  56510. continue;
  56511. }
  56512. var encodedCodePoints = percentEncode(codePoint, userinfoPercentEncodeSet);
  56513. if (seenPasswordToken) url.password += encodedCodePoints;
  56514. else url.username += encodedCodePoints;
  56515. }
  56516. buffer = '';
  56517. } else if (
  56518. chr == EOF || chr == '/' || chr == '?' || chr == '#' ||
  56519. (chr == '\\' && url.isSpecial())
  56520. ) {
  56521. if (seenAt && buffer == '') return INVALID_AUTHORITY;
  56522. pointer -= arrayFrom(buffer).length + 1;
  56523. buffer = '';
  56524. state = HOST;
  56525. } else buffer += chr;
  56526. break;
  56527. case HOST:
  56528. case HOSTNAME:
  56529. if (stateOverride && url.scheme == 'file') {
  56530. state = FILE_HOST;
  56531. continue;
  56532. } else if (chr == ':' && !seenBracket) {
  56533. if (buffer == '') return INVALID_HOST;
  56534. failure = url.parseHost(buffer);
  56535. if (failure) return failure;
  56536. buffer = '';
  56537. state = PORT;
  56538. if (stateOverride == HOSTNAME) return;
  56539. } else if (
  56540. chr == EOF || chr == '/' || chr == '?' || chr == '#' ||
  56541. (chr == '\\' && url.isSpecial())
  56542. ) {
  56543. if (url.isSpecial() && buffer == '') return INVALID_HOST;
  56544. if (stateOverride && buffer == '' && (url.includesCredentials() || url.port !== null)) return;
  56545. failure = url.parseHost(buffer);
  56546. if (failure) return failure;
  56547. buffer = '';
  56548. state = PATH_START;
  56549. if (stateOverride) return;
  56550. continue;
  56551. } else {
  56552. if (chr == '[') seenBracket = true;
  56553. else if (chr == ']') seenBracket = false;
  56554. buffer += chr;
  56555. } break;
  56556. case PORT:
  56557. if (exec(DIGIT, chr)) {
  56558. buffer += chr;
  56559. } else if (
  56560. chr == EOF || chr == '/' || chr == '?' || chr == '#' ||
  56561. (chr == '\\' && url.isSpecial()) ||
  56562. stateOverride
  56563. ) {
  56564. if (buffer != '') {
  56565. var port = parseInt(buffer, 10);
  56566. if (port > 0xFFFF) return INVALID_PORT;
  56567. url.port = (url.isSpecial() && port === specialSchemes[url.scheme]) ? null : port;
  56568. buffer = '';
  56569. }
  56570. if (stateOverride) return;
  56571. state = PATH_START;
  56572. continue;
  56573. } else return INVALID_PORT;
  56574. break;
  56575. case FILE:
  56576. url.scheme = 'file';
  56577. if (chr == '/' || chr == '\\') state = FILE_SLASH;
  56578. else if (base && base.scheme == 'file') {
  56579. if (chr == EOF) {
  56580. url.host = base.host;
  56581. url.path = arraySlice(base.path);
  56582. url.query = base.query;
  56583. } else if (chr == '?') {
  56584. url.host = base.host;
  56585. url.path = arraySlice(base.path);
  56586. url.query = '';
  56587. state = QUERY;
  56588. } else if (chr == '#') {
  56589. url.host = base.host;
  56590. url.path = arraySlice(base.path);
  56591. url.query = base.query;
  56592. url.fragment = '';
  56593. state = FRAGMENT;
  56594. } else {
  56595. if (!startsWithWindowsDriveLetter(join(arraySlice(codePoints, pointer), ''))) {
  56596. url.host = base.host;
  56597. url.path = arraySlice(base.path);
  56598. url.shortenPath();
  56599. }
  56600. state = PATH;
  56601. continue;
  56602. }
  56603. } else {
  56604. state = PATH;
  56605. continue;
  56606. } break;
  56607. case FILE_SLASH:
  56608. if (chr == '/' || chr == '\\') {
  56609. state = FILE_HOST;
  56610. break;
  56611. }
  56612. if (base && base.scheme == 'file' && !startsWithWindowsDriveLetter(join(arraySlice(codePoints, pointer), ''))) {
  56613. if (isWindowsDriveLetter(base.path[0], true)) push(url.path, base.path[0]);
  56614. else url.host = base.host;
  56615. }
  56616. state = PATH;
  56617. continue;
  56618. case FILE_HOST:
  56619. if (chr == EOF || chr == '/' || chr == '\\' || chr == '?' || chr == '#') {
  56620. if (!stateOverride && isWindowsDriveLetter(buffer)) {
  56621. state = PATH;
  56622. } else if (buffer == '') {
  56623. url.host = '';
  56624. if (stateOverride) return;
  56625. state = PATH_START;
  56626. } else {
  56627. failure = url.parseHost(buffer);
  56628. if (failure) return failure;
  56629. if (url.host == 'localhost') url.host = '';
  56630. if (stateOverride) return;
  56631. buffer = '';
  56632. state = PATH_START;
  56633. } continue;
  56634. } else buffer += chr;
  56635. break;
  56636. case PATH_START:
  56637. if (url.isSpecial()) {
  56638. state = PATH;
  56639. if (chr != '/' && chr != '\\') continue;
  56640. } else if (!stateOverride && chr == '?') {
  56641. url.query = '';
  56642. state = QUERY;
  56643. } else if (!stateOverride && chr == '#') {
  56644. url.fragment = '';
  56645. state = FRAGMENT;
  56646. } else if (chr != EOF) {
  56647. state = PATH;
  56648. if (chr != '/') continue;
  56649. } break;
  56650. case PATH:
  56651. if (
  56652. chr == EOF || chr == '/' ||
  56653. (chr == '\\' && url.isSpecial()) ||
  56654. (!stateOverride && (chr == '?' || chr == '#'))
  56655. ) {
  56656. if (isDoubleDot(buffer)) {
  56657. url.shortenPath();
  56658. if (chr != '/' && !(chr == '\\' && url.isSpecial())) {
  56659. push(url.path, '');
  56660. }
  56661. } else if (isSingleDot(buffer)) {
  56662. if (chr != '/' && !(chr == '\\' && url.isSpecial())) {
  56663. push(url.path, '');
  56664. }
  56665. } else {
  56666. if (url.scheme == 'file' && !url.path.length && isWindowsDriveLetter(buffer)) {
  56667. if (url.host) url.host = '';
  56668. buffer = charAt(buffer, 0) + ':'; // normalize windows drive letter
  56669. }
  56670. push(url.path, buffer);
  56671. }
  56672. buffer = '';
  56673. if (url.scheme == 'file' && (chr == EOF || chr == '?' || chr == '#')) {
  56674. while (url.path.length > 1 && url.path[0] === '') {
  56675. shift(url.path);
  56676. }
  56677. }
  56678. if (chr == '?') {
  56679. url.query = '';
  56680. state = QUERY;
  56681. } else if (chr == '#') {
  56682. url.fragment = '';
  56683. state = FRAGMENT;
  56684. }
  56685. } else {
  56686. buffer += percentEncode(chr, pathPercentEncodeSet);
  56687. } break;
  56688. case CANNOT_BE_A_BASE_URL_PATH:
  56689. if (chr == '?') {
  56690. url.query = '';
  56691. state = QUERY;
  56692. } else if (chr == '#') {
  56693. url.fragment = '';
  56694. state = FRAGMENT;
  56695. } else if (chr != EOF) {
  56696. url.path[0] += percentEncode(chr, C0ControlPercentEncodeSet);
  56697. } break;
  56698. case QUERY:
  56699. if (!stateOverride && chr == '#') {
  56700. url.fragment = '';
  56701. state = FRAGMENT;
  56702. } else if (chr != EOF) {
  56703. if (chr == "'" && url.isSpecial()) url.query += '%27';
  56704. else if (chr == '#') url.query += '%23';
  56705. else url.query += percentEncode(chr, C0ControlPercentEncodeSet);
  56706. } break;
  56707. case FRAGMENT:
  56708. if (chr != EOF) url.fragment += percentEncode(chr, fragmentPercentEncodeSet);
  56709. break;
  56710. }
  56711. pointer++;
  56712. }
  56713. },
  56714. // https://url.spec.whatwg.org/#host-parsing
  56715. parseHost: function (input) {
  56716. var result, codePoints, index;
  56717. if (charAt(input, 0) == '[') {
  56718. if (charAt(input, input.length - 1) != ']') return INVALID_HOST;
  56719. result = parseIPv6(stringSlice(input, 1, -1));
  56720. if (!result) return INVALID_HOST;
  56721. this.host = result;
  56722. // opaque host
  56723. } else if (!this.isSpecial()) {
  56724. if (exec(FORBIDDEN_HOST_CODE_POINT_EXCLUDING_PERCENT, input)) return INVALID_HOST;
  56725. result = '';
  56726. codePoints = arrayFrom(input);
  56727. for (index = 0; index < codePoints.length; index++) {
  56728. result += percentEncode(codePoints[index], C0ControlPercentEncodeSet);
  56729. }
  56730. this.host = result;
  56731. } else {
  56732. input = toASCII(input);
  56733. if (exec(FORBIDDEN_HOST_CODE_POINT, input)) return INVALID_HOST;
  56734. result = parseIPv4(input);
  56735. if (result === null) return INVALID_HOST;
  56736. this.host = result;
  56737. }
  56738. },
  56739. // https://url.spec.whatwg.org/#cannot-have-a-username-password-port
  56740. cannotHaveUsernamePasswordPort: function () {
  56741. return !this.host || this.cannotBeABaseURL || this.scheme == 'file';
  56742. },
  56743. // https://url.spec.whatwg.org/#include-credentials
  56744. includesCredentials: function () {
  56745. return this.username != '' || this.password != '';
  56746. },
  56747. // https://url.spec.whatwg.org/#is-special
  56748. isSpecial: function () {
  56749. return hasOwn(specialSchemes, this.scheme);
  56750. },
  56751. // https://url.spec.whatwg.org/#shorten-a-urls-path
  56752. shortenPath: function () {
  56753. var path = this.path;
  56754. var pathSize = path.length;
  56755. if (pathSize && (this.scheme != 'file' || pathSize != 1 || !isWindowsDriveLetter(path[0], true))) {
  56756. path.length--;
  56757. }
  56758. },
  56759. // https://url.spec.whatwg.org/#concept-url-serializer
  56760. serialize: function () {
  56761. var url = this;
  56762. var scheme = url.scheme;
  56763. var username = url.username;
  56764. var password = url.password;
  56765. var host = url.host;
  56766. var port = url.port;
  56767. var path = url.path;
  56768. var query = url.query;
  56769. var fragment = url.fragment;
  56770. var output = scheme + ':';
  56771. if (host !== null) {
  56772. output += '//';
  56773. if (url.includesCredentials()) {
  56774. output += username + (password ? ':' + password : '') + '@';
  56775. }
  56776. output += serializeHost(host);
  56777. if (port !== null) output += ':' + port;
  56778. } else if (scheme == 'file') output += '//';
  56779. output += url.cannotBeABaseURL ? path[0] : path.length ? '/' + join(path, '/') : '';
  56780. if (query !== null) output += '?' + query;
  56781. if (fragment !== null) output += '#' + fragment;
  56782. return output;
  56783. },
  56784. // https://url.spec.whatwg.org/#dom-url-href
  56785. setHref: function (href) {
  56786. var failure = this.parse(href);
  56787. if (failure) throw TypeError(failure);
  56788. this.searchParams.update();
  56789. },
  56790. // https://url.spec.whatwg.org/#dom-url-origin
  56791. getOrigin: function () {
  56792. var scheme = this.scheme;
  56793. var port = this.port;
  56794. if (scheme == 'blob') try {
  56795. return new URLConstructor(scheme.path[0]).origin;
  56796. } catch (error) {
  56797. return 'null';
  56798. }
  56799. if (scheme == 'file' || !this.isSpecial()) return 'null';
  56800. return scheme + '://' + serializeHost(this.host) + (port !== null ? ':' + port : '');
  56801. },
  56802. // https://url.spec.whatwg.org/#dom-url-protocol
  56803. getProtocol: function () {
  56804. return this.scheme + ':';
  56805. },
  56806. setProtocol: function (protocol) {
  56807. this.parse($toString(protocol) + ':', SCHEME_START);
  56808. },
  56809. // https://url.spec.whatwg.org/#dom-url-username
  56810. getUsername: function () {
  56811. return this.username;
  56812. },
  56813. setUsername: function (username) {
  56814. var codePoints = arrayFrom($toString(username));
  56815. if (this.cannotHaveUsernamePasswordPort()) return;
  56816. this.username = '';
  56817. for (var i = 0; i < codePoints.length; i++) {
  56818. this.username += percentEncode(codePoints[i], userinfoPercentEncodeSet);
  56819. }
  56820. },
  56821. // https://url.spec.whatwg.org/#dom-url-password
  56822. getPassword: function () {
  56823. return this.password;
  56824. },
  56825. setPassword: function (password) {
  56826. var codePoints = arrayFrom($toString(password));
  56827. if (this.cannotHaveUsernamePasswordPort()) return;
  56828. this.password = '';
  56829. for (var i = 0; i < codePoints.length; i++) {
  56830. this.password += percentEncode(codePoints[i], userinfoPercentEncodeSet);
  56831. }
  56832. },
  56833. // https://url.spec.whatwg.org/#dom-url-host
  56834. getHost: function () {
  56835. var host = this.host;
  56836. var port = this.port;
  56837. return host === null ? ''
  56838. : port === null ? serializeHost(host)
  56839. : serializeHost(host) + ':' + port;
  56840. },
  56841. setHost: function (host) {
  56842. if (this.cannotBeABaseURL) return;
  56843. this.parse(host, HOST);
  56844. },
  56845. // https://url.spec.whatwg.org/#dom-url-hostname
  56846. getHostname: function () {
  56847. var host = this.host;
  56848. return host === null ? '' : serializeHost(host);
  56849. },
  56850. setHostname: function (hostname) {
  56851. if (this.cannotBeABaseURL) return;
  56852. this.parse(hostname, HOSTNAME);
  56853. },
  56854. // https://url.spec.whatwg.org/#dom-url-port
  56855. getPort: function () {
  56856. var port = this.port;
  56857. return port === null ? '' : $toString(port);
  56858. },
  56859. setPort: function (port) {
  56860. if (this.cannotHaveUsernamePasswordPort()) return;
  56861. port = $toString(port);
  56862. if (port == '') this.port = null;
  56863. else this.parse(port, PORT);
  56864. },
  56865. // https://url.spec.whatwg.org/#dom-url-pathname
  56866. getPathname: function () {
  56867. var path = this.path;
  56868. return this.cannotBeABaseURL ? path[0] : path.length ? '/' + join(path, '/') : '';
  56869. },
  56870. setPathname: function (pathname) {
  56871. if (this.cannotBeABaseURL) return;
  56872. this.path = [];
  56873. this.parse(pathname, PATH_START);
  56874. },
  56875. // https://url.spec.whatwg.org/#dom-url-search
  56876. getSearch: function () {
  56877. var query = this.query;
  56878. return query ? '?' + query : '';
  56879. },
  56880. setSearch: function (search) {
  56881. search = $toString(search);
  56882. if (search == '') {
  56883. this.query = null;
  56884. } else {
  56885. if ('?' == charAt(search, 0)) search = stringSlice(search, 1);
  56886. this.query = '';
  56887. this.parse(search, QUERY);
  56888. }
  56889. this.searchParams.update();
  56890. },
  56891. // https://url.spec.whatwg.org/#dom-url-searchparams
  56892. getSearchParams: function () {
  56893. return this.searchParams.facade;
  56894. },
  56895. // https://url.spec.whatwg.org/#dom-url-hash
  56896. getHash: function () {
  56897. var fragment = this.fragment;
  56898. return fragment ? '#' + fragment : '';
  56899. },
  56900. setHash: function (hash) {
  56901. hash = $toString(hash);
  56902. if (hash == '') {
  56903. this.fragment = null;
  56904. return;
  56905. }
  56906. if ('#' == charAt(hash, 0)) hash = stringSlice(hash, 1);
  56907. this.fragment = '';
  56908. this.parse(hash, FRAGMENT);
  56909. },
  56910. update: function () {
  56911. this.query = this.searchParams.serialize() || null;
  56912. }
  56913. };
  56914. // `URL` constructor
  56915. // https://url.spec.whatwg.org/#url-class
  56916. var URLConstructor = function URL(url /* , base */) {
  56917. var that = anInstance(this, URLPrototype);
  56918. var base = arguments.length > 1 ? arguments[1] : undefined;
  56919. var state = setInternalState(that, new URLState(url, false, base));
  56920. if (!DESCRIPTORS) {
  56921. that.href = state.serialize();
  56922. that.origin = state.getOrigin();
  56923. that.protocol = state.getProtocol();
  56924. that.username = state.getUsername();
  56925. that.password = state.getPassword();
  56926. that.host = state.getHost();
  56927. that.hostname = state.getHostname();
  56928. that.port = state.getPort();
  56929. that.pathname = state.getPathname();
  56930. that.search = state.getSearch();
  56931. that.searchParams = state.getSearchParams();
  56932. that.hash = state.getHash();
  56933. }
  56934. };
  56935. var URLPrototype = URLConstructor.prototype;
  56936. var accessorDescriptor = function (getter, setter) {
  56937. return {
  56938. get: function () {
  56939. return getInternalURLState(this)[getter]();
  56940. },
  56941. set: setter && function (value) {
  56942. return getInternalURLState(this)[setter](value);
  56943. },
  56944. configurable: true,
  56945. enumerable: true
  56946. };
  56947. };
  56948. if (DESCRIPTORS) {
  56949. defineProperties(URLPrototype, {
  56950. // `URL.prototype.href` accessors pair
  56951. // https://url.spec.whatwg.org/#dom-url-href
  56952. href: accessorDescriptor('serialize', 'setHref'),
  56953. // `URL.prototype.origin` getter
  56954. // https://url.spec.whatwg.org/#dom-url-origin
  56955. origin: accessorDescriptor('getOrigin'),
  56956. // `URL.prototype.protocol` accessors pair
  56957. // https://url.spec.whatwg.org/#dom-url-protocol
  56958. protocol: accessorDescriptor('getProtocol', 'setProtocol'),
  56959. // `URL.prototype.username` accessors pair
  56960. // https://url.spec.whatwg.org/#dom-url-username
  56961. username: accessorDescriptor('getUsername', 'setUsername'),
  56962. // `URL.prototype.password` accessors pair
  56963. // https://url.spec.whatwg.org/#dom-url-password
  56964. password: accessorDescriptor('getPassword', 'setPassword'),
  56965. // `URL.prototype.host` accessors pair
  56966. // https://url.spec.whatwg.org/#dom-url-host
  56967. host: accessorDescriptor('getHost', 'setHost'),
  56968. // `URL.prototype.hostname` accessors pair
  56969. // https://url.spec.whatwg.org/#dom-url-hostname
  56970. hostname: accessorDescriptor('getHostname', 'setHostname'),
  56971. // `URL.prototype.port` accessors pair
  56972. // https://url.spec.whatwg.org/#dom-url-port
  56973. port: accessorDescriptor('getPort', 'setPort'),
  56974. // `URL.prototype.pathname` accessors pair
  56975. // https://url.spec.whatwg.org/#dom-url-pathname
  56976. pathname: accessorDescriptor('getPathname', 'setPathname'),
  56977. // `URL.prototype.search` accessors pair
  56978. // https://url.spec.whatwg.org/#dom-url-search
  56979. search: accessorDescriptor('getSearch', 'setSearch'),
  56980. // `URL.prototype.searchParams` getter
  56981. // https://url.spec.whatwg.org/#dom-url-searchparams
  56982. searchParams: accessorDescriptor('getSearchParams'),
  56983. // `URL.prototype.hash` accessors pair
  56984. // https://url.spec.whatwg.org/#dom-url-hash
  56985. hash: accessorDescriptor('getHash', 'setHash')
  56986. });
  56987. }
  56988. // `URL.prototype.toJSON` method
  56989. // https://url.spec.whatwg.org/#dom-url-tojson
  56990. redefine(URLPrototype, 'toJSON', function toJSON() {
  56991. return getInternalURLState(this).serialize();
  56992. }, { enumerable: true });
  56993. // `URL.prototype.toString` method
  56994. // https://url.spec.whatwg.org/#URL-stringification-behavior
  56995. redefine(URLPrototype, 'toString', function toString() {
  56996. return getInternalURLState(this).serialize();
  56997. }, { enumerable: true });
  56998. if (NativeURL) {
  56999. var nativeCreateObjectURL = NativeURL.createObjectURL;
  57000. var nativeRevokeObjectURL = NativeURL.revokeObjectURL;
  57001. // `URL.createObjectURL` method
  57002. // https://developer.mozilla.org/en-US/docs/Web/API/URL/createObjectURL
  57003. if (nativeCreateObjectURL) redefine(URLConstructor, 'createObjectURL', bind(nativeCreateObjectURL, NativeURL));
  57004. // `URL.revokeObjectURL` method
  57005. // https://developer.mozilla.org/en-US/docs/Web/API/URL/revokeObjectURL
  57006. if (nativeRevokeObjectURL) redefine(URLConstructor, 'revokeObjectURL', bind(nativeRevokeObjectURL, NativeURL));
  57007. }
  57008. setToStringTag(URLConstructor, 'URL');
  57009. $({ global: true, forced: !USE_NATIVE_URL, sham: !DESCRIPTORS }, {
  57010. URL: URLConstructor
  57011. });
  57012. },{"../internals/an-instance":425,"../internals/array-from":429,"../internals/array-slice-simple":435,"../internals/descriptors":460,"../internals/export":476,"../internals/function-bind-context":480,"../internals/function-uncurry-this":485,"../internals/global":491,"../internals/has-own-property":492,"../internals/internal-state":501,"../internals/native-url":523,"../internals/object-assign":529,"../internals/object-define-properties":531,"../internals/redefine":553,"../internals/set-to-string-tag":558,"../internals/string-multibyte":563,"../internals/string-punycode-to-ascii":566,"../internals/to-string":579,"../modules/es.string.iterator":634,"../modules/web.url-search-params":688}],690:[function(_dereq_,module,exports){
  57013. arguments[4][608][0].apply(exports,arguments)
  57014. },{"dup":608}],691:[function(_dereq_,module,exports){
  57015. var parent = _dereq_('../../es/array/from');
  57016. module.exports = parent;
  57017. },{"../../es/array/from":341}],692:[function(_dereq_,module,exports){
  57018. var parent = _dereq_('../../es/array/is-array');
  57019. module.exports = parent;
  57020. },{"../../es/array/is-array":342}],693:[function(_dereq_,module,exports){
  57021. var parent = _dereq_('../../../es/array/virtual/entries');
  57022. module.exports = parent;
  57023. },{"../../../es/array/virtual/entries":344}],694:[function(_dereq_,module,exports){
  57024. var parent = _dereq_('../../../es/array/virtual/for-each');
  57025. module.exports = parent;
  57026. },{"../../../es/array/virtual/for-each":348}],695:[function(_dereq_,module,exports){
  57027. var parent = _dereq_('../../../es/array/virtual/keys');
  57028. module.exports = parent;
  57029. },{"../../../es/array/virtual/keys":351}],696:[function(_dereq_,module,exports){
  57030. var parent = _dereq_('../../../es/array/virtual/values');
  57031. module.exports = parent;
  57032. },{"../../../es/array/virtual/values":357}],697:[function(_dereq_,module,exports){
  57033. var parent = _dereq_('../es/get-iterator-method');
  57034. _dereq_('../modules/web.dom-collections.iterator');
  57035. module.exports = parent;
  57036. },{"../es/get-iterator-method":359,"../modules/web.dom-collections.iterator":686}],698:[function(_dereq_,module,exports){
  57037. var parent = _dereq_('../../es/instance/bind');
  57038. module.exports = parent;
  57039. },{"../../es/instance/bind":360}],699:[function(_dereq_,module,exports){
  57040. var parent = _dereq_('../../es/instance/concat');
  57041. module.exports = parent;
  57042. },{"../../es/instance/concat":361}],700:[function(_dereq_,module,exports){
  57043. _dereq_('../../modules/web.dom-collections.iterator');
  57044. var classof = _dereq_('../../internals/classof');
  57045. var hasOwn = _dereq_('../../internals/has-own-property');
  57046. var isPrototypeOf = _dereq_('../../internals/object-is-prototype-of');
  57047. var method = _dereq_('../array/virtual/entries');
  57048. var ArrayPrototype = Array.prototype;
  57049. var DOMIterables = {
  57050. DOMTokenList: true,
  57051. NodeList: true
  57052. };
  57053. module.exports = function (it) {
  57054. var own = it.entries;
  57055. return it === ArrayPrototype || (isPrototypeOf(ArrayPrototype, it) && own === ArrayPrototype.entries)
  57056. || hasOwn(DOMIterables, classof(it)) ? method : own;
  57057. };
  57058. },{"../../internals/classof":443,"../../internals/has-own-property":492,"../../internals/object-is-prototype-of":539,"../../modules/web.dom-collections.iterator":686,"../array/virtual/entries":693}],701:[function(_dereq_,module,exports){
  57059. var parent = _dereq_('../../es/instance/every');
  57060. module.exports = parent;
  57061. },{"../../es/instance/every":362}],702:[function(_dereq_,module,exports){
  57062. var parent = _dereq_('../../es/instance/filter');
  57063. module.exports = parent;
  57064. },{"../../es/instance/filter":363}],703:[function(_dereq_,module,exports){
  57065. var parent = _dereq_('../../es/instance/find');
  57066. module.exports = parent;
  57067. },{"../../es/instance/find":364}],704:[function(_dereq_,module,exports){
  57068. _dereq_('../../modules/web.dom-collections.iterator');
  57069. var classof = _dereq_('../../internals/classof');
  57070. var hasOwn = _dereq_('../../internals/has-own-property');
  57071. var isPrototypeOf = _dereq_('../../internals/object-is-prototype-of');
  57072. var method = _dereq_('../array/virtual/for-each');
  57073. var ArrayPrototype = Array.prototype;
  57074. var DOMIterables = {
  57075. DOMTokenList: true,
  57076. NodeList: true
  57077. };
  57078. module.exports = function (it) {
  57079. var own = it.forEach;
  57080. return it === ArrayPrototype || (isPrototypeOf(ArrayPrototype, it) && own === ArrayPrototype.forEach)
  57081. || hasOwn(DOMIterables, classof(it)) ? method : own;
  57082. };
  57083. },{"../../internals/classof":443,"../../internals/has-own-property":492,"../../internals/object-is-prototype-of":539,"../../modules/web.dom-collections.iterator":686,"../array/virtual/for-each":694}],705:[function(_dereq_,module,exports){
  57084. var parent = _dereq_('../../es/instance/includes');
  57085. module.exports = parent;
  57086. },{"../../es/instance/includes":365}],706:[function(_dereq_,module,exports){
  57087. var parent = _dereq_('../../es/instance/index-of');
  57088. module.exports = parent;
  57089. },{"../../es/instance/index-of":366}],707:[function(_dereq_,module,exports){
  57090. _dereq_('../../modules/web.dom-collections.iterator');
  57091. var classof = _dereq_('../../internals/classof');
  57092. var hasOwn = _dereq_('../../internals/has-own-property');
  57093. var isPrototypeOf = _dereq_('../../internals/object-is-prototype-of');
  57094. var method = _dereq_('../array/virtual/keys');
  57095. var ArrayPrototype = Array.prototype;
  57096. var DOMIterables = {
  57097. DOMTokenList: true,
  57098. NodeList: true
  57099. };
  57100. module.exports = function (it) {
  57101. var own = it.keys;
  57102. return it === ArrayPrototype || (isPrototypeOf(ArrayPrototype, it) && own === ArrayPrototype.keys)
  57103. || hasOwn(DOMIterables, classof(it)) ? method : own;
  57104. };
  57105. },{"../../internals/classof":443,"../../internals/has-own-property":492,"../../internals/object-is-prototype-of":539,"../../modules/web.dom-collections.iterator":686,"../array/virtual/keys":695}],708:[function(_dereq_,module,exports){
  57106. var parent = _dereq_('../../es/instance/map');
  57107. module.exports = parent;
  57108. },{"../../es/instance/map":367}],709:[function(_dereq_,module,exports){
  57109. var parent = _dereq_('../../es/instance/pad-start');
  57110. module.exports = parent;
  57111. },{"../../es/instance/pad-start":368}],710:[function(_dereq_,module,exports){
  57112. var parent = _dereq_('../../es/instance/reduce');
  57113. module.exports = parent;
  57114. },{"../../es/instance/reduce":369}],711:[function(_dereq_,module,exports){
  57115. var parent = _dereq_('../../es/instance/slice');
  57116. module.exports = parent;
  57117. },{"../../es/instance/slice":370}],712:[function(_dereq_,module,exports){
  57118. var parent = _dereq_('../../es/instance/sort');
  57119. module.exports = parent;
  57120. },{"../../es/instance/sort":371}],713:[function(_dereq_,module,exports){
  57121. var parent = _dereq_('../../es/instance/splice');
  57122. module.exports = parent;
  57123. },{"../../es/instance/splice":372}],714:[function(_dereq_,module,exports){
  57124. var parent = _dereq_('../../es/instance/starts-with');
  57125. module.exports = parent;
  57126. },{"../../es/instance/starts-with":373}],715:[function(_dereq_,module,exports){
  57127. var parent = _dereq_('../../es/instance/trim');
  57128. module.exports = parent;
  57129. },{"../../es/instance/trim":374}],716:[function(_dereq_,module,exports){
  57130. _dereq_('../../modules/web.dom-collections.iterator');
  57131. var classof = _dereq_('../../internals/classof');
  57132. var hasOwn = _dereq_('../../internals/has-own-property');
  57133. var isPrototypeOf = _dereq_('../../internals/object-is-prototype-of');
  57134. var method = _dereq_('../array/virtual/values');
  57135. var ArrayPrototype = Array.prototype;
  57136. var DOMIterables = {
  57137. DOMTokenList: true,
  57138. NodeList: true
  57139. };
  57140. module.exports = function (it) {
  57141. var own = it.values;
  57142. return it === ArrayPrototype || (isPrototypeOf(ArrayPrototype, it) && own === ArrayPrototype.values)
  57143. || hasOwn(DOMIterables, classof(it)) ? method : own;
  57144. };
  57145. },{"../../internals/classof":443,"../../internals/has-own-property":492,"../../internals/object-is-prototype-of":539,"../../modules/web.dom-collections.iterator":686,"../array/virtual/values":696}],717:[function(_dereq_,module,exports){
  57146. var parent = _dereq_('../../es/json/stringify');
  57147. module.exports = parent;
  57148. },{"../../es/json/stringify":375}],718:[function(_dereq_,module,exports){
  57149. var parent = _dereq_('../../es/map');
  57150. _dereq_('../../modules/web.dom-collections.iterator');
  57151. module.exports = parent;
  57152. },{"../../es/map":376,"../../modules/web.dom-collections.iterator":686}],719:[function(_dereq_,module,exports){
  57153. var parent = _dereq_('../../es/number/is-integer');
  57154. module.exports = parent;
  57155. },{"../../es/number/is-integer":377}],720:[function(_dereq_,module,exports){
  57156. var parent = _dereq_('../../es/number/is-nan');
  57157. module.exports = parent;
  57158. },{"../../es/number/is-nan":378}],721:[function(_dereq_,module,exports){
  57159. var parent = _dereq_('../../es/object/create');
  57160. module.exports = parent;
  57161. },{"../../es/object/create":379}],722:[function(_dereq_,module,exports){
  57162. var parent = _dereq_('../../es/object/define-properties');
  57163. module.exports = parent;
  57164. },{"../../es/object/define-properties":380}],723:[function(_dereq_,module,exports){
  57165. var parent = _dereq_('../../es/object/define-property');
  57166. module.exports = parent;
  57167. },{"../../es/object/define-property":381}],724:[function(_dereq_,module,exports){
  57168. var parent = _dereq_('../../es/object/entries');
  57169. module.exports = parent;
  57170. },{"../../es/object/entries":382}],725:[function(_dereq_,module,exports){
  57171. var parent = _dereq_('../../es/object/freeze');
  57172. module.exports = parent;
  57173. },{"../../es/object/freeze":383}],726:[function(_dereq_,module,exports){
  57174. var parent = _dereq_('../../es/object/get-own-property-descriptor');
  57175. module.exports = parent;
  57176. },{"../../es/object/get-own-property-descriptor":384}],727:[function(_dereq_,module,exports){
  57177. var parent = _dereq_('../../es/object/get-own-property-descriptors');
  57178. module.exports = parent;
  57179. },{"../../es/object/get-own-property-descriptors":385}],728:[function(_dereq_,module,exports){
  57180. var parent = _dereq_('../../es/object/get-own-property-symbols');
  57181. module.exports = parent;
  57182. },{"../../es/object/get-own-property-symbols":386}],729:[function(_dereq_,module,exports){
  57183. var parent = _dereq_('../../es/object/get-prototype-of');
  57184. module.exports = parent;
  57185. },{"../../es/object/get-prototype-of":387}],730:[function(_dereq_,module,exports){
  57186. var parent = _dereq_('../../es/object/keys');
  57187. module.exports = parent;
  57188. },{"../../es/object/keys":388}],731:[function(_dereq_,module,exports){
  57189. var parent = _dereq_('../../es/object/set-prototype-of');
  57190. module.exports = parent;
  57191. },{"../../es/object/set-prototype-of":389}],732:[function(_dereq_,module,exports){
  57192. var parent = _dereq_('../../es/object/values');
  57193. module.exports = parent;
  57194. },{"../../es/object/values":390}],733:[function(_dereq_,module,exports){
  57195. var parent = _dereq_('../es/parse-int');
  57196. module.exports = parent;
  57197. },{"../es/parse-int":391}],734:[function(_dereq_,module,exports){
  57198. var parent = _dereq_('../../es/promise');
  57199. _dereq_('../../modules/web.dom-collections.iterator');
  57200. module.exports = parent;
  57201. },{"../../es/promise":392,"../../modules/web.dom-collections.iterator":686}],735:[function(_dereq_,module,exports){
  57202. var parent = _dereq_('../../es/reflect/construct');
  57203. module.exports = parent;
  57204. },{"../../es/reflect/construct":393}],736:[function(_dereq_,module,exports){
  57205. var parent = _dereq_('../../es/reflect/get');
  57206. module.exports = parent;
  57207. },{"../../es/reflect/get":394}],737:[function(_dereq_,module,exports){
  57208. _dereq_('../modules/web.timers');
  57209. var path = _dereq_('../internals/path');
  57210. module.exports = path.setTimeout;
  57211. },{"../internals/path":548,"../modules/web.timers":687}],738:[function(_dereq_,module,exports){
  57212. var parent = _dereq_('../../es/set');
  57213. _dereq_('../../modules/web.dom-collections.iterator');
  57214. module.exports = parent;
  57215. },{"../../es/set":395,"../../modules/web.dom-collections.iterator":686}],739:[function(_dereq_,module,exports){
  57216. var parent = _dereq_('../../es/symbol');
  57217. _dereq_('../../modules/web.dom-collections.iterator');
  57218. module.exports = parent;
  57219. },{"../../es/symbol":400,"../../modules/web.dom-collections.iterator":686}],740:[function(_dereq_,module,exports){
  57220. var parent = _dereq_('../../es/symbol/iterator');
  57221. _dereq_('../../modules/web.dom-collections.iterator');
  57222. module.exports = parent;
  57223. },{"../../es/symbol/iterator":401,"../../modules/web.dom-collections.iterator":686}],741:[function(_dereq_,module,exports){
  57224. var parent = _dereq_('../../es/symbol/replace');
  57225. module.exports = parent;
  57226. },{"../../es/symbol/replace":402}],742:[function(_dereq_,module,exports){
  57227. var parent = _dereq_('../../web/url');
  57228. module.exports = parent;
  57229. },{"../../web/url":744}],743:[function(_dereq_,module,exports){
  57230. var parent = _dereq_('../../es/weak-map');
  57231. _dereq_('../../modules/web.dom-collections.iterator');
  57232. module.exports = parent;
  57233. },{"../../es/weak-map":403,"../../modules/web.dom-collections.iterator":686}],744:[function(_dereq_,module,exports){
  57234. _dereq_('../modules/web.url');
  57235. _dereq_('../modules/web.url.to-json');
  57236. _dereq_('../modules/web.url-search-params');
  57237. var path = _dereq_('../internals/path');
  57238. module.exports = path.URL;
  57239. },{"../internals/path":548,"../modules/web.url":689,"../modules/web.url-search-params":688,"../modules/web.url.to-json":690}],745:[function(_dereq_,module,exports){
  57240. ;(function (root, factory, undef) {
  57241. if (typeof exports === "object") {
  57242. // CommonJS
  57243. module.exports = exports = factory(_dereq_("./core"), _dereq_("./enc-base64"), _dereq_("./md5"), _dereq_("./evpkdf"), _dereq_("./cipher-core"));
  57244. }
  57245. else if (typeof define === "function" && define.amd) {
  57246. // AMD
  57247. define(["./core", "./enc-base64", "./md5", "./evpkdf", "./cipher-core"], factory);
  57248. }
  57249. else {
  57250. // Global (browser)
  57251. factory(root.CryptoJS);
  57252. }
  57253. }(this, function (CryptoJS) {
  57254. (function () {
  57255. // Shortcuts
  57256. var C = CryptoJS;
  57257. var C_lib = C.lib;
  57258. var BlockCipher = C_lib.BlockCipher;
  57259. var C_algo = C.algo;
  57260. // Lookup tables
  57261. var SBOX = [];
  57262. var INV_SBOX = [];
  57263. var SUB_MIX_0 = [];
  57264. var SUB_MIX_1 = [];
  57265. var SUB_MIX_2 = [];
  57266. var SUB_MIX_3 = [];
  57267. var INV_SUB_MIX_0 = [];
  57268. var INV_SUB_MIX_1 = [];
  57269. var INV_SUB_MIX_2 = [];
  57270. var INV_SUB_MIX_3 = [];
  57271. // Compute lookup tables
  57272. (function () {
  57273. // Compute double table
  57274. var d = [];
  57275. for (var i = 0; i < 256; i++) {
  57276. if (i < 128) {
  57277. d[i] = i << 1;
  57278. } else {
  57279. d[i] = (i << 1) ^ 0x11b;
  57280. }
  57281. }
  57282. // Walk GF(2^8)
  57283. var x = 0;
  57284. var xi = 0;
  57285. for (var i = 0; i < 256; i++) {
  57286. // Compute sbox
  57287. var sx = xi ^ (xi << 1) ^ (xi << 2) ^ (xi << 3) ^ (xi << 4);
  57288. sx = (sx >>> 8) ^ (sx & 0xff) ^ 0x63;
  57289. SBOX[x] = sx;
  57290. INV_SBOX[sx] = x;
  57291. // Compute multiplication
  57292. var x2 = d[x];
  57293. var x4 = d[x2];
  57294. var x8 = d[x4];
  57295. // Compute sub bytes, mix columns tables
  57296. var t = (d[sx] * 0x101) ^ (sx * 0x1010100);
  57297. SUB_MIX_0[x] = (t << 24) | (t >>> 8);
  57298. SUB_MIX_1[x] = (t << 16) | (t >>> 16);
  57299. SUB_MIX_2[x] = (t << 8) | (t >>> 24);
  57300. SUB_MIX_3[x] = t;
  57301. // Compute inv sub bytes, inv mix columns tables
  57302. var t = (x8 * 0x1010101) ^ (x4 * 0x10001) ^ (x2 * 0x101) ^ (x * 0x1010100);
  57303. INV_SUB_MIX_0[sx] = (t << 24) | (t >>> 8);
  57304. INV_SUB_MIX_1[sx] = (t << 16) | (t >>> 16);
  57305. INV_SUB_MIX_2[sx] = (t << 8) | (t >>> 24);
  57306. INV_SUB_MIX_3[sx] = t;
  57307. // Compute next counter
  57308. if (!x) {
  57309. x = xi = 1;
  57310. } else {
  57311. x = x2 ^ d[d[d[x8 ^ x2]]];
  57312. xi ^= d[d[xi]];
  57313. }
  57314. }
  57315. }());
  57316. // Precomputed Rcon lookup
  57317. var RCON = [0x00, 0x01, 0x02, 0x04, 0x08, 0x10, 0x20, 0x40, 0x80, 0x1b, 0x36];
  57318. /**
  57319. * AES block cipher algorithm.
  57320. */
  57321. var AES = C_algo.AES = BlockCipher.extend({
  57322. _doReset: function () {
  57323. var t;
  57324. // Skip reset of nRounds has been set before and key did not change
  57325. if (this._nRounds && this._keyPriorReset === this._key) {
  57326. return;
  57327. }
  57328. // Shortcuts
  57329. var key = this._keyPriorReset = this._key;
  57330. var keyWords = key.words;
  57331. var keySize = key.sigBytes / 4;
  57332. // Compute number of rounds
  57333. var nRounds = this._nRounds = keySize + 6;
  57334. // Compute number of key schedule rows
  57335. var ksRows = (nRounds + 1) * 4;
  57336. // Compute key schedule
  57337. var keySchedule = this._keySchedule = [];
  57338. for (var ksRow = 0; ksRow < ksRows; ksRow++) {
  57339. if (ksRow < keySize) {
  57340. keySchedule[ksRow] = keyWords[ksRow];
  57341. } else {
  57342. t = keySchedule[ksRow - 1];
  57343. if (!(ksRow % keySize)) {
  57344. // Rot word
  57345. t = (t << 8) | (t >>> 24);
  57346. // Sub word
  57347. t = (SBOX[t >>> 24] << 24) | (SBOX[(t >>> 16) & 0xff] << 16) | (SBOX[(t >>> 8) & 0xff] << 8) | SBOX[t & 0xff];
  57348. // Mix Rcon
  57349. t ^= RCON[(ksRow / keySize) | 0] << 24;
  57350. } else if (keySize > 6 && ksRow % keySize == 4) {
  57351. // Sub word
  57352. t = (SBOX[t >>> 24] << 24) | (SBOX[(t >>> 16) & 0xff] << 16) | (SBOX[(t >>> 8) & 0xff] << 8) | SBOX[t & 0xff];
  57353. }
  57354. keySchedule[ksRow] = keySchedule[ksRow - keySize] ^ t;
  57355. }
  57356. }
  57357. // Compute inv key schedule
  57358. var invKeySchedule = this._invKeySchedule = [];
  57359. for (var invKsRow = 0; invKsRow < ksRows; invKsRow++) {
  57360. var ksRow = ksRows - invKsRow;
  57361. if (invKsRow % 4) {
  57362. var t = keySchedule[ksRow];
  57363. } else {
  57364. var t = keySchedule[ksRow - 4];
  57365. }
  57366. if (invKsRow < 4 || ksRow <= 4) {
  57367. invKeySchedule[invKsRow] = t;
  57368. } else {
  57369. invKeySchedule[invKsRow] = INV_SUB_MIX_0[SBOX[t >>> 24]] ^ INV_SUB_MIX_1[SBOX[(t >>> 16) & 0xff]] ^
  57370. INV_SUB_MIX_2[SBOX[(t >>> 8) & 0xff]] ^ INV_SUB_MIX_3[SBOX[t & 0xff]];
  57371. }
  57372. }
  57373. },
  57374. encryptBlock: function (M, offset) {
  57375. this._doCryptBlock(M, offset, this._keySchedule, SUB_MIX_0, SUB_MIX_1, SUB_MIX_2, SUB_MIX_3, SBOX);
  57376. },
  57377. decryptBlock: function (M, offset) {
  57378. // Swap 2nd and 4th rows
  57379. var t = M[offset + 1];
  57380. M[offset + 1] = M[offset + 3];
  57381. M[offset + 3] = t;
  57382. this._doCryptBlock(M, offset, this._invKeySchedule, INV_SUB_MIX_0, INV_SUB_MIX_1, INV_SUB_MIX_2, INV_SUB_MIX_3, INV_SBOX);
  57383. // Inv swap 2nd and 4th rows
  57384. var t = M[offset + 1];
  57385. M[offset + 1] = M[offset + 3];
  57386. M[offset + 3] = t;
  57387. },
  57388. _doCryptBlock: function (M, offset, keySchedule, SUB_MIX_0, SUB_MIX_1, SUB_MIX_2, SUB_MIX_3, SBOX) {
  57389. // Shortcut
  57390. var nRounds = this._nRounds;
  57391. // Get input, add round key
  57392. var s0 = M[offset] ^ keySchedule[0];
  57393. var s1 = M[offset + 1] ^ keySchedule[1];
  57394. var s2 = M[offset + 2] ^ keySchedule[2];
  57395. var s3 = M[offset + 3] ^ keySchedule[3];
  57396. // Key schedule row counter
  57397. var ksRow = 4;
  57398. // Rounds
  57399. for (var round = 1; round < nRounds; round++) {
  57400. // Shift rows, sub bytes, mix columns, add round key
  57401. var t0 = SUB_MIX_0[s0 >>> 24] ^ SUB_MIX_1[(s1 >>> 16) & 0xff] ^ SUB_MIX_2[(s2 >>> 8) & 0xff] ^ SUB_MIX_3[s3 & 0xff] ^ keySchedule[ksRow++];
  57402. var t1 = SUB_MIX_0[s1 >>> 24] ^ SUB_MIX_1[(s2 >>> 16) & 0xff] ^ SUB_MIX_2[(s3 >>> 8) & 0xff] ^ SUB_MIX_3[s0 & 0xff] ^ keySchedule[ksRow++];
  57403. var t2 = SUB_MIX_0[s2 >>> 24] ^ SUB_MIX_1[(s3 >>> 16) & 0xff] ^ SUB_MIX_2[(s0 >>> 8) & 0xff] ^ SUB_MIX_3[s1 & 0xff] ^ keySchedule[ksRow++];
  57404. var t3 = SUB_MIX_0[s3 >>> 24] ^ SUB_MIX_1[(s0 >>> 16) & 0xff] ^ SUB_MIX_2[(s1 >>> 8) & 0xff] ^ SUB_MIX_3[s2 & 0xff] ^ keySchedule[ksRow++];
  57405. // Update state
  57406. s0 = t0;
  57407. s1 = t1;
  57408. s2 = t2;
  57409. s3 = t3;
  57410. }
  57411. // Shift rows, sub bytes, add round key
  57412. var t0 = ((SBOX[s0 >>> 24] << 24) | (SBOX[(s1 >>> 16) & 0xff] << 16) | (SBOX[(s2 >>> 8) & 0xff] << 8) | SBOX[s3 & 0xff]) ^ keySchedule[ksRow++];
  57413. var t1 = ((SBOX[s1 >>> 24] << 24) | (SBOX[(s2 >>> 16) & 0xff] << 16) | (SBOX[(s3 >>> 8) & 0xff] << 8) | SBOX[s0 & 0xff]) ^ keySchedule[ksRow++];
  57414. var t2 = ((SBOX[s2 >>> 24] << 24) | (SBOX[(s3 >>> 16) & 0xff] << 16) | (SBOX[(s0 >>> 8) & 0xff] << 8) | SBOX[s1 & 0xff]) ^ keySchedule[ksRow++];
  57415. var t3 = ((SBOX[s3 >>> 24] << 24) | (SBOX[(s0 >>> 16) & 0xff] << 16) | (SBOX[(s1 >>> 8) & 0xff] << 8) | SBOX[s2 & 0xff]) ^ keySchedule[ksRow++];
  57416. // Set output
  57417. M[offset] = t0;
  57418. M[offset + 1] = t1;
  57419. M[offset + 2] = t2;
  57420. M[offset + 3] = t3;
  57421. },
  57422. keySize: 256/32
  57423. });
  57424. /**
  57425. * Shortcut functions to the cipher's object interface.
  57426. *
  57427. * @example
  57428. *
  57429. * var ciphertext = CryptoJS.AES.encrypt(message, key, cfg);
  57430. * var plaintext = CryptoJS.AES.decrypt(ciphertext, key, cfg);
  57431. */
  57432. C.AES = BlockCipher._createHelper(AES);
  57433. }());
  57434. return CryptoJS.AES;
  57435. }));
  57436. },{"./cipher-core":746,"./core":747,"./enc-base64":748,"./evpkdf":750,"./md5":752}],746:[function(_dereq_,module,exports){
  57437. ;(function (root, factory, undef) {
  57438. if (typeof exports === "object") {
  57439. // CommonJS
  57440. module.exports = exports = factory(_dereq_("./core"), _dereq_("./evpkdf"));
  57441. }
  57442. else if (typeof define === "function" && define.amd) {
  57443. // AMD
  57444. define(["./core", "./evpkdf"], factory);
  57445. }
  57446. else {
  57447. // Global (browser)
  57448. factory(root.CryptoJS);
  57449. }
  57450. }(this, function (CryptoJS) {
  57451. /**
  57452. * Cipher core components.
  57453. */
  57454. CryptoJS.lib.Cipher || (function (undefined) {
  57455. // Shortcuts
  57456. var C = CryptoJS;
  57457. var C_lib = C.lib;
  57458. var Base = C_lib.Base;
  57459. var WordArray = C_lib.WordArray;
  57460. var BufferedBlockAlgorithm = C_lib.BufferedBlockAlgorithm;
  57461. var C_enc = C.enc;
  57462. var Utf8 = C_enc.Utf8;
  57463. var Base64 = C_enc.Base64;
  57464. var C_algo = C.algo;
  57465. var EvpKDF = C_algo.EvpKDF;
  57466. /**
  57467. * Abstract base cipher template.
  57468. *
  57469. * @property {number} keySize This cipher's key size. Default: 4 (128 bits)
  57470. * @property {number} ivSize This cipher's IV size. Default: 4 (128 bits)
  57471. * @property {number} _ENC_XFORM_MODE A constant representing encryption mode.
  57472. * @property {number} _DEC_XFORM_MODE A constant representing decryption mode.
  57473. */
  57474. var Cipher = C_lib.Cipher = BufferedBlockAlgorithm.extend({
  57475. /**
  57476. * Configuration options.
  57477. *
  57478. * @property {WordArray} iv The IV to use for this operation.
  57479. */
  57480. cfg: Base.extend(),
  57481. /**
  57482. * Creates this cipher in encryption mode.
  57483. *
  57484. * @param {WordArray} key The key.
  57485. * @param {Object} cfg (Optional) The configuration options to use for this operation.
  57486. *
  57487. * @return {Cipher} A cipher instance.
  57488. *
  57489. * @static
  57490. *
  57491. * @example
  57492. *
  57493. * var cipher = CryptoJS.algo.AES.createEncryptor(keyWordArray, { iv: ivWordArray });
  57494. */
  57495. createEncryptor: function (key, cfg) {
  57496. return this.create(this._ENC_XFORM_MODE, key, cfg);
  57497. },
  57498. /**
  57499. * Creates this cipher in decryption mode.
  57500. *
  57501. * @param {WordArray} key The key.
  57502. * @param {Object} cfg (Optional) The configuration options to use for this operation.
  57503. *
  57504. * @return {Cipher} A cipher instance.
  57505. *
  57506. * @static
  57507. *
  57508. * @example
  57509. *
  57510. * var cipher = CryptoJS.algo.AES.createDecryptor(keyWordArray, { iv: ivWordArray });
  57511. */
  57512. createDecryptor: function (key, cfg) {
  57513. return this.create(this._DEC_XFORM_MODE, key, cfg);
  57514. },
  57515. /**
  57516. * Initializes a newly created cipher.
  57517. *
  57518. * @param {number} xformMode Either the encryption or decryption transormation mode constant.
  57519. * @param {WordArray} key The key.
  57520. * @param {Object} cfg (Optional) The configuration options to use for this operation.
  57521. *
  57522. * @example
  57523. *
  57524. * var cipher = CryptoJS.algo.AES.create(CryptoJS.algo.AES._ENC_XFORM_MODE, keyWordArray, { iv: ivWordArray });
  57525. */
  57526. init: function (xformMode, key, cfg) {
  57527. // Apply config defaults
  57528. this.cfg = this.cfg.extend(cfg);
  57529. // Store transform mode and key
  57530. this._xformMode = xformMode;
  57531. this._key = key;
  57532. // Set initial values
  57533. this.reset();
  57534. },
  57535. /**
  57536. * Resets this cipher to its initial state.
  57537. *
  57538. * @example
  57539. *
  57540. * cipher.reset();
  57541. */
  57542. reset: function () {
  57543. // Reset data buffer
  57544. BufferedBlockAlgorithm.reset.call(this);
  57545. // Perform concrete-cipher logic
  57546. this._doReset();
  57547. },
  57548. /**
  57549. * Adds data to be encrypted or decrypted.
  57550. *
  57551. * @param {WordArray|string} dataUpdate The data to encrypt or decrypt.
  57552. *
  57553. * @return {WordArray} The data after processing.
  57554. *
  57555. * @example
  57556. *
  57557. * var encrypted = cipher.process('data');
  57558. * var encrypted = cipher.process(wordArray);
  57559. */
  57560. process: function (dataUpdate) {
  57561. // Append
  57562. this._append(dataUpdate);
  57563. // Process available blocks
  57564. return this._process();
  57565. },
  57566. /**
  57567. * Finalizes the encryption or decryption process.
  57568. * Note that the finalize operation is effectively a destructive, read-once operation.
  57569. *
  57570. * @param {WordArray|string} dataUpdate The final data to encrypt or decrypt.
  57571. *
  57572. * @return {WordArray} The data after final processing.
  57573. *
  57574. * @example
  57575. *
  57576. * var encrypted = cipher.finalize();
  57577. * var encrypted = cipher.finalize('data');
  57578. * var encrypted = cipher.finalize(wordArray);
  57579. */
  57580. finalize: function (dataUpdate) {
  57581. // Final data update
  57582. if (dataUpdate) {
  57583. this._append(dataUpdate);
  57584. }
  57585. // Perform concrete-cipher logic
  57586. var finalProcessedData = this._doFinalize();
  57587. return finalProcessedData;
  57588. },
  57589. keySize: 128/32,
  57590. ivSize: 128/32,
  57591. _ENC_XFORM_MODE: 1,
  57592. _DEC_XFORM_MODE: 2,
  57593. /**
  57594. * Creates shortcut functions to a cipher's object interface.
  57595. *
  57596. * @param {Cipher} cipher The cipher to create a helper for.
  57597. *
  57598. * @return {Object} An object with encrypt and decrypt shortcut functions.
  57599. *
  57600. * @static
  57601. *
  57602. * @example
  57603. *
  57604. * var AES = CryptoJS.lib.Cipher._createHelper(CryptoJS.algo.AES);
  57605. */
  57606. _createHelper: (function () {
  57607. function selectCipherStrategy(key) {
  57608. if (typeof key == 'string') {
  57609. return PasswordBasedCipher;
  57610. } else {
  57611. return SerializableCipher;
  57612. }
  57613. }
  57614. return function (cipher) {
  57615. return {
  57616. encrypt: function (message, key, cfg) {
  57617. return selectCipherStrategy(key).encrypt(cipher, message, key, cfg);
  57618. },
  57619. decrypt: function (ciphertext, key, cfg) {
  57620. return selectCipherStrategy(key).decrypt(cipher, ciphertext, key, cfg);
  57621. }
  57622. };
  57623. };
  57624. }())
  57625. });
  57626. /**
  57627. * Abstract base stream cipher template.
  57628. *
  57629. * @property {number} blockSize The number of 32-bit words this cipher operates on. Default: 1 (32 bits)
  57630. */
  57631. var StreamCipher = C_lib.StreamCipher = Cipher.extend({
  57632. _doFinalize: function () {
  57633. // Process partial blocks
  57634. var finalProcessedBlocks = this._process(!!'flush');
  57635. return finalProcessedBlocks;
  57636. },
  57637. blockSize: 1
  57638. });
  57639. /**
  57640. * Mode namespace.
  57641. */
  57642. var C_mode = C.mode = {};
  57643. /**
  57644. * Abstract base block cipher mode template.
  57645. */
  57646. var BlockCipherMode = C_lib.BlockCipherMode = Base.extend({
  57647. /**
  57648. * Creates this mode for encryption.
  57649. *
  57650. * @param {Cipher} cipher A block cipher instance.
  57651. * @param {Array} iv The IV words.
  57652. *
  57653. * @static
  57654. *
  57655. * @example
  57656. *
  57657. * var mode = CryptoJS.mode.CBC.createEncryptor(cipher, iv.words);
  57658. */
  57659. createEncryptor: function (cipher, iv) {
  57660. return this.Encryptor.create(cipher, iv);
  57661. },
  57662. /**
  57663. * Creates this mode for decryption.
  57664. *
  57665. * @param {Cipher} cipher A block cipher instance.
  57666. * @param {Array} iv The IV words.
  57667. *
  57668. * @static
  57669. *
  57670. * @example
  57671. *
  57672. * var mode = CryptoJS.mode.CBC.createDecryptor(cipher, iv.words);
  57673. */
  57674. createDecryptor: function (cipher, iv) {
  57675. return this.Decryptor.create(cipher, iv);
  57676. },
  57677. /**
  57678. * Initializes a newly created mode.
  57679. *
  57680. * @param {Cipher} cipher A block cipher instance.
  57681. * @param {Array} iv The IV words.
  57682. *
  57683. * @example
  57684. *
  57685. * var mode = CryptoJS.mode.CBC.Encryptor.create(cipher, iv.words);
  57686. */
  57687. init: function (cipher, iv) {
  57688. this._cipher = cipher;
  57689. this._iv = iv;
  57690. }
  57691. });
  57692. /**
  57693. * Cipher Block Chaining mode.
  57694. */
  57695. var CBC = C_mode.CBC = (function () {
  57696. /**
  57697. * Abstract base CBC mode.
  57698. */
  57699. var CBC = BlockCipherMode.extend();
  57700. /**
  57701. * CBC encryptor.
  57702. */
  57703. CBC.Encryptor = CBC.extend({
  57704. /**
  57705. * Processes the data block at offset.
  57706. *
  57707. * @param {Array} words The data words to operate on.
  57708. * @param {number} offset The offset where the block starts.
  57709. *
  57710. * @example
  57711. *
  57712. * mode.processBlock(data.words, offset);
  57713. */
  57714. processBlock: function (words, offset) {
  57715. // Shortcuts
  57716. var cipher = this._cipher;
  57717. var blockSize = cipher.blockSize;
  57718. // XOR and encrypt
  57719. xorBlock.call(this, words, offset, blockSize);
  57720. cipher.encryptBlock(words, offset);
  57721. // Remember this block to use with next block
  57722. this._prevBlock = words.slice(offset, offset + blockSize);
  57723. }
  57724. });
  57725. /**
  57726. * CBC decryptor.
  57727. */
  57728. CBC.Decryptor = CBC.extend({
  57729. /**
  57730. * Processes the data block at offset.
  57731. *
  57732. * @param {Array} words The data words to operate on.
  57733. * @param {number} offset The offset where the block starts.
  57734. *
  57735. * @example
  57736. *
  57737. * mode.processBlock(data.words, offset);
  57738. */
  57739. processBlock: function (words, offset) {
  57740. // Shortcuts
  57741. var cipher = this._cipher;
  57742. var blockSize = cipher.blockSize;
  57743. // Remember this block to use with next block
  57744. var thisBlock = words.slice(offset, offset + blockSize);
  57745. // Decrypt and XOR
  57746. cipher.decryptBlock(words, offset);
  57747. xorBlock.call(this, words, offset, blockSize);
  57748. // This block becomes the previous block
  57749. this._prevBlock = thisBlock;
  57750. }
  57751. });
  57752. function xorBlock(words, offset, blockSize) {
  57753. var block;
  57754. // Shortcut
  57755. var iv = this._iv;
  57756. // Choose mixing block
  57757. if (iv) {
  57758. block = iv;
  57759. // Remove IV for subsequent blocks
  57760. this._iv = undefined;
  57761. } else {
  57762. block = this._prevBlock;
  57763. }
  57764. // XOR blocks
  57765. for (var i = 0; i < blockSize; i++) {
  57766. words[offset + i] ^= block[i];
  57767. }
  57768. }
  57769. return CBC;
  57770. }());
  57771. /**
  57772. * Padding namespace.
  57773. */
  57774. var C_pad = C.pad = {};
  57775. /**
  57776. * PKCS #5/7 padding strategy.
  57777. */
  57778. var Pkcs7 = C_pad.Pkcs7 = {
  57779. /**
  57780. * Pads data using the algorithm defined in PKCS #5/7.
  57781. *
  57782. * @param {WordArray} data The data to pad.
  57783. * @param {number} blockSize The multiple that the data should be padded to.
  57784. *
  57785. * @static
  57786. *
  57787. * @example
  57788. *
  57789. * CryptoJS.pad.Pkcs7.pad(wordArray, 4);
  57790. */
  57791. pad: function (data, blockSize) {
  57792. // Shortcut
  57793. var blockSizeBytes = blockSize * 4;
  57794. // Count padding bytes
  57795. var nPaddingBytes = blockSizeBytes - data.sigBytes % blockSizeBytes;
  57796. // Create padding word
  57797. var paddingWord = (nPaddingBytes << 24) | (nPaddingBytes << 16) | (nPaddingBytes << 8) | nPaddingBytes;
  57798. // Create padding
  57799. var paddingWords = [];
  57800. for (var i = 0; i < nPaddingBytes; i += 4) {
  57801. paddingWords.push(paddingWord);
  57802. }
  57803. var padding = WordArray.create(paddingWords, nPaddingBytes);
  57804. // Add padding
  57805. data.concat(padding);
  57806. },
  57807. /**
  57808. * Unpads data that had been padded using the algorithm defined in PKCS #5/7.
  57809. *
  57810. * @param {WordArray} data The data to unpad.
  57811. *
  57812. * @static
  57813. *
  57814. * @example
  57815. *
  57816. * CryptoJS.pad.Pkcs7.unpad(wordArray);
  57817. */
  57818. unpad: function (data) {
  57819. // Get number of padding bytes from last byte
  57820. var nPaddingBytes = data.words[(data.sigBytes - 1) >>> 2] & 0xff;
  57821. // Remove padding
  57822. data.sigBytes -= nPaddingBytes;
  57823. }
  57824. };
  57825. /**
  57826. * Abstract base block cipher template.
  57827. *
  57828. * @property {number} blockSize The number of 32-bit words this cipher operates on. Default: 4 (128 bits)
  57829. */
  57830. var BlockCipher = C_lib.BlockCipher = Cipher.extend({
  57831. /**
  57832. * Configuration options.
  57833. *
  57834. * @property {Mode} mode The block mode to use. Default: CBC
  57835. * @property {Padding} padding The padding strategy to use. Default: Pkcs7
  57836. */
  57837. cfg: Cipher.cfg.extend({
  57838. mode: CBC,
  57839. padding: Pkcs7
  57840. }),
  57841. reset: function () {
  57842. var modeCreator;
  57843. // Reset cipher
  57844. Cipher.reset.call(this);
  57845. // Shortcuts
  57846. var cfg = this.cfg;
  57847. var iv = cfg.iv;
  57848. var mode = cfg.mode;
  57849. // Reset block mode
  57850. if (this._xformMode == this._ENC_XFORM_MODE) {
  57851. modeCreator = mode.createEncryptor;
  57852. } else /* if (this._xformMode == this._DEC_XFORM_MODE) */ {
  57853. modeCreator = mode.createDecryptor;
  57854. // Keep at least one block in the buffer for unpadding
  57855. this._minBufferSize = 1;
  57856. }
  57857. if (this._mode && this._mode.__creator == modeCreator) {
  57858. this._mode.init(this, iv && iv.words);
  57859. } else {
  57860. this._mode = modeCreator.call(mode, this, iv && iv.words);
  57861. this._mode.__creator = modeCreator;
  57862. }
  57863. },
  57864. _doProcessBlock: function (words, offset) {
  57865. this._mode.processBlock(words, offset);
  57866. },
  57867. _doFinalize: function () {
  57868. var finalProcessedBlocks;
  57869. // Shortcut
  57870. var padding = this.cfg.padding;
  57871. // Finalize
  57872. if (this._xformMode == this._ENC_XFORM_MODE) {
  57873. // Pad data
  57874. padding.pad(this._data, this.blockSize);
  57875. // Process final blocks
  57876. finalProcessedBlocks = this._process(!!'flush');
  57877. } else /* if (this._xformMode == this._DEC_XFORM_MODE) */ {
  57878. // Process final blocks
  57879. finalProcessedBlocks = this._process(!!'flush');
  57880. // Unpad data
  57881. padding.unpad(finalProcessedBlocks);
  57882. }
  57883. return finalProcessedBlocks;
  57884. },
  57885. blockSize: 128/32
  57886. });
  57887. /**
  57888. * A collection of cipher parameters.
  57889. *
  57890. * @property {WordArray} ciphertext The raw ciphertext.
  57891. * @property {WordArray} key The key to this ciphertext.
  57892. * @property {WordArray} iv The IV used in the ciphering operation.
  57893. * @property {WordArray} salt The salt used with a key derivation function.
  57894. * @property {Cipher} algorithm The cipher algorithm.
  57895. * @property {Mode} mode The block mode used in the ciphering operation.
  57896. * @property {Padding} padding The padding scheme used in the ciphering operation.
  57897. * @property {number} blockSize The block size of the cipher.
  57898. * @property {Format} formatter The default formatting strategy to convert this cipher params object to a string.
  57899. */
  57900. var CipherParams = C_lib.CipherParams = Base.extend({
  57901. /**
  57902. * Initializes a newly created cipher params object.
  57903. *
  57904. * @param {Object} cipherParams An object with any of the possible cipher parameters.
  57905. *
  57906. * @example
  57907. *
  57908. * var cipherParams = CryptoJS.lib.CipherParams.create({
  57909. * ciphertext: ciphertextWordArray,
  57910. * key: keyWordArray,
  57911. * iv: ivWordArray,
  57912. * salt: saltWordArray,
  57913. * algorithm: CryptoJS.algo.AES,
  57914. * mode: CryptoJS.mode.CBC,
  57915. * padding: CryptoJS.pad.PKCS7,
  57916. * blockSize: 4,
  57917. * formatter: CryptoJS.format.OpenSSL
  57918. * });
  57919. */
  57920. init: function (cipherParams) {
  57921. this.mixIn(cipherParams);
  57922. },
  57923. /**
  57924. * Converts this cipher params object to a string.
  57925. *
  57926. * @param {Format} formatter (Optional) The formatting strategy to use.
  57927. *
  57928. * @return {string} The stringified cipher params.
  57929. *
  57930. * @throws Error If neither the formatter nor the default formatter is set.
  57931. *
  57932. * @example
  57933. *
  57934. * var string = cipherParams + '';
  57935. * var string = cipherParams.toString();
  57936. * var string = cipherParams.toString(CryptoJS.format.OpenSSL);
  57937. */
  57938. toString: function (formatter) {
  57939. return (formatter || this.formatter).stringify(this);
  57940. }
  57941. });
  57942. /**
  57943. * Format namespace.
  57944. */
  57945. var C_format = C.format = {};
  57946. /**
  57947. * OpenSSL formatting strategy.
  57948. */
  57949. var OpenSSLFormatter = C_format.OpenSSL = {
  57950. /**
  57951. * Converts a cipher params object to an OpenSSL-compatible string.
  57952. *
  57953. * @param {CipherParams} cipherParams The cipher params object.
  57954. *
  57955. * @return {string} The OpenSSL-compatible string.
  57956. *
  57957. * @static
  57958. *
  57959. * @example
  57960. *
  57961. * var openSSLString = CryptoJS.format.OpenSSL.stringify(cipherParams);
  57962. */
  57963. stringify: function (cipherParams) {
  57964. var wordArray;
  57965. // Shortcuts
  57966. var ciphertext = cipherParams.ciphertext;
  57967. var salt = cipherParams.salt;
  57968. // Format
  57969. if (salt) {
  57970. wordArray = WordArray.create([0x53616c74, 0x65645f5f]).concat(salt).concat(ciphertext);
  57971. } else {
  57972. wordArray = ciphertext;
  57973. }
  57974. return wordArray.toString(Base64);
  57975. },
  57976. /**
  57977. * Converts an OpenSSL-compatible string to a cipher params object.
  57978. *
  57979. * @param {string} openSSLStr The OpenSSL-compatible string.
  57980. *
  57981. * @return {CipherParams} The cipher params object.
  57982. *
  57983. * @static
  57984. *
  57985. * @example
  57986. *
  57987. * var cipherParams = CryptoJS.format.OpenSSL.parse(openSSLString);
  57988. */
  57989. parse: function (openSSLStr) {
  57990. var salt;
  57991. // Parse base64
  57992. var ciphertext = Base64.parse(openSSLStr);
  57993. // Shortcut
  57994. var ciphertextWords = ciphertext.words;
  57995. // Test for salt
  57996. if (ciphertextWords[0] == 0x53616c74 && ciphertextWords[1] == 0x65645f5f) {
  57997. // Extract salt
  57998. salt = WordArray.create(ciphertextWords.slice(2, 4));
  57999. // Remove salt from ciphertext
  58000. ciphertextWords.splice(0, 4);
  58001. ciphertext.sigBytes -= 16;
  58002. }
  58003. return CipherParams.create({ ciphertext: ciphertext, salt: salt });
  58004. }
  58005. };
  58006. /**
  58007. * A cipher wrapper that returns ciphertext as a serializable cipher params object.
  58008. */
  58009. var SerializableCipher = C_lib.SerializableCipher = Base.extend({
  58010. /**
  58011. * Configuration options.
  58012. *
  58013. * @property {Formatter} format The formatting strategy to convert cipher param objects to and from a string. Default: OpenSSL
  58014. */
  58015. cfg: Base.extend({
  58016. format: OpenSSLFormatter
  58017. }),
  58018. /**
  58019. * Encrypts a message.
  58020. *
  58021. * @param {Cipher} cipher The cipher algorithm to use.
  58022. * @param {WordArray|string} message The message to encrypt.
  58023. * @param {WordArray} key The key.
  58024. * @param {Object} cfg (Optional) The configuration options to use for this operation.
  58025. *
  58026. * @return {CipherParams} A cipher params object.
  58027. *
  58028. * @static
  58029. *
  58030. * @example
  58031. *
  58032. * var ciphertextParams = CryptoJS.lib.SerializableCipher.encrypt(CryptoJS.algo.AES, message, key);
  58033. * var ciphertextParams = CryptoJS.lib.SerializableCipher.encrypt(CryptoJS.algo.AES, message, key, { iv: iv });
  58034. * var ciphertextParams = CryptoJS.lib.SerializableCipher.encrypt(CryptoJS.algo.AES, message, key, { iv: iv, format: CryptoJS.format.OpenSSL });
  58035. */
  58036. encrypt: function (cipher, message, key, cfg) {
  58037. // Apply config defaults
  58038. cfg = this.cfg.extend(cfg);
  58039. // Encrypt
  58040. var encryptor = cipher.createEncryptor(key, cfg);
  58041. var ciphertext = encryptor.finalize(message);
  58042. // Shortcut
  58043. var cipherCfg = encryptor.cfg;
  58044. // Create and return serializable cipher params
  58045. return CipherParams.create({
  58046. ciphertext: ciphertext,
  58047. key: key,
  58048. iv: cipherCfg.iv,
  58049. algorithm: cipher,
  58050. mode: cipherCfg.mode,
  58051. padding: cipherCfg.padding,
  58052. blockSize: cipher.blockSize,
  58053. formatter: cfg.format
  58054. });
  58055. },
  58056. /**
  58057. * Decrypts serialized ciphertext.
  58058. *
  58059. * @param {Cipher} cipher The cipher algorithm to use.
  58060. * @param {CipherParams|string} ciphertext The ciphertext to decrypt.
  58061. * @param {WordArray} key The key.
  58062. * @param {Object} cfg (Optional) The configuration options to use for this operation.
  58063. *
  58064. * @return {WordArray} The plaintext.
  58065. *
  58066. * @static
  58067. *
  58068. * @example
  58069. *
  58070. * var plaintext = CryptoJS.lib.SerializableCipher.decrypt(CryptoJS.algo.AES, formattedCiphertext, key, { iv: iv, format: CryptoJS.format.OpenSSL });
  58071. * var plaintext = CryptoJS.lib.SerializableCipher.decrypt(CryptoJS.algo.AES, ciphertextParams, key, { iv: iv, format: CryptoJS.format.OpenSSL });
  58072. */
  58073. decrypt: function (cipher, ciphertext, key, cfg) {
  58074. // Apply config defaults
  58075. cfg = this.cfg.extend(cfg);
  58076. // Convert string to CipherParams
  58077. ciphertext = this._parse(ciphertext, cfg.format);
  58078. // Decrypt
  58079. var plaintext = cipher.createDecryptor(key, cfg).finalize(ciphertext.ciphertext);
  58080. return plaintext;
  58081. },
  58082. /**
  58083. * Converts serialized ciphertext to CipherParams,
  58084. * else assumed CipherParams already and returns ciphertext unchanged.
  58085. *
  58086. * @param {CipherParams|string} ciphertext The ciphertext.
  58087. * @param {Formatter} format The formatting strategy to use to parse serialized ciphertext.
  58088. *
  58089. * @return {CipherParams} The unserialized ciphertext.
  58090. *
  58091. * @static
  58092. *
  58093. * @example
  58094. *
  58095. * var ciphertextParams = CryptoJS.lib.SerializableCipher._parse(ciphertextStringOrParams, format);
  58096. */
  58097. _parse: function (ciphertext, format) {
  58098. if (typeof ciphertext == 'string') {
  58099. return format.parse(ciphertext, this);
  58100. } else {
  58101. return ciphertext;
  58102. }
  58103. }
  58104. });
  58105. /**
  58106. * Key derivation function namespace.
  58107. */
  58108. var C_kdf = C.kdf = {};
  58109. /**
  58110. * OpenSSL key derivation function.
  58111. */
  58112. var OpenSSLKdf = C_kdf.OpenSSL = {
  58113. /**
  58114. * Derives a key and IV from a password.
  58115. *
  58116. * @param {string} password The password to derive from.
  58117. * @param {number} keySize The size in words of the key to generate.
  58118. * @param {number} ivSize The size in words of the IV to generate.
  58119. * @param {WordArray|string} salt (Optional) A 64-bit salt to use. If omitted, a salt will be generated randomly.
  58120. *
  58121. * @return {CipherParams} A cipher params object with the key, IV, and salt.
  58122. *
  58123. * @static
  58124. *
  58125. * @example
  58126. *
  58127. * var derivedParams = CryptoJS.kdf.OpenSSL.execute('Password', 256/32, 128/32);
  58128. * var derivedParams = CryptoJS.kdf.OpenSSL.execute('Password', 256/32, 128/32, 'saltsalt');
  58129. */
  58130. execute: function (password, keySize, ivSize, salt) {
  58131. // Generate random salt
  58132. if (!salt) {
  58133. salt = WordArray.random(64/8);
  58134. }
  58135. // Derive key and IV
  58136. var key = EvpKDF.create({ keySize: keySize + ivSize }).compute(password, salt);
  58137. // Separate key and IV
  58138. var iv = WordArray.create(key.words.slice(keySize), ivSize * 4);
  58139. key.sigBytes = keySize * 4;
  58140. // Return params
  58141. return CipherParams.create({ key: key, iv: iv, salt: salt });
  58142. }
  58143. };
  58144. /**
  58145. * A serializable cipher wrapper that derives the key from a password,
  58146. * and returns ciphertext as a serializable cipher params object.
  58147. */
  58148. var PasswordBasedCipher = C_lib.PasswordBasedCipher = SerializableCipher.extend({
  58149. /**
  58150. * Configuration options.
  58151. *
  58152. * @property {KDF} kdf The key derivation function to use to generate a key and IV from a password. Default: OpenSSL
  58153. */
  58154. cfg: SerializableCipher.cfg.extend({
  58155. kdf: OpenSSLKdf
  58156. }),
  58157. /**
  58158. * Encrypts a message using a password.
  58159. *
  58160. * @param {Cipher} cipher The cipher algorithm to use.
  58161. * @param {WordArray|string} message The message to encrypt.
  58162. * @param {string} password The password.
  58163. * @param {Object} cfg (Optional) The configuration options to use for this operation.
  58164. *
  58165. * @return {CipherParams} A cipher params object.
  58166. *
  58167. * @static
  58168. *
  58169. * @example
  58170. *
  58171. * var ciphertextParams = CryptoJS.lib.PasswordBasedCipher.encrypt(CryptoJS.algo.AES, message, 'password');
  58172. * var ciphertextParams = CryptoJS.lib.PasswordBasedCipher.encrypt(CryptoJS.algo.AES, message, 'password', { format: CryptoJS.format.OpenSSL });
  58173. */
  58174. encrypt: function (cipher, message, password, cfg) {
  58175. // Apply config defaults
  58176. cfg = this.cfg.extend(cfg);
  58177. // Derive key and other params
  58178. var derivedParams = cfg.kdf.execute(password, cipher.keySize, cipher.ivSize);
  58179. // Add IV to config
  58180. cfg.iv = derivedParams.iv;
  58181. // Encrypt
  58182. var ciphertext = SerializableCipher.encrypt.call(this, cipher, message, derivedParams.key, cfg);
  58183. // Mix in derived params
  58184. ciphertext.mixIn(derivedParams);
  58185. return ciphertext;
  58186. },
  58187. /**
  58188. * Decrypts serialized ciphertext using a password.
  58189. *
  58190. * @param {Cipher} cipher The cipher algorithm to use.
  58191. * @param {CipherParams|string} ciphertext The ciphertext to decrypt.
  58192. * @param {string} password The password.
  58193. * @param {Object} cfg (Optional) The configuration options to use for this operation.
  58194. *
  58195. * @return {WordArray} The plaintext.
  58196. *
  58197. * @static
  58198. *
  58199. * @example
  58200. *
  58201. * var plaintext = CryptoJS.lib.PasswordBasedCipher.decrypt(CryptoJS.algo.AES, formattedCiphertext, 'password', { format: CryptoJS.format.OpenSSL });
  58202. * var plaintext = CryptoJS.lib.PasswordBasedCipher.decrypt(CryptoJS.algo.AES, ciphertextParams, 'password', { format: CryptoJS.format.OpenSSL });
  58203. */
  58204. decrypt: function (cipher, ciphertext, password, cfg) {
  58205. // Apply config defaults
  58206. cfg = this.cfg.extend(cfg);
  58207. // Convert string to CipherParams
  58208. ciphertext = this._parse(ciphertext, cfg.format);
  58209. // Derive key and other params
  58210. var derivedParams = cfg.kdf.execute(password, cipher.keySize, cipher.ivSize, ciphertext.salt);
  58211. // Add IV to config
  58212. cfg.iv = derivedParams.iv;
  58213. // Decrypt
  58214. var plaintext = SerializableCipher.decrypt.call(this, cipher, ciphertext, derivedParams.key, cfg);
  58215. return plaintext;
  58216. }
  58217. });
  58218. }());
  58219. }));
  58220. },{"./core":747,"./evpkdf":750}],747:[function(_dereq_,module,exports){
  58221. (function (global){(function (){
  58222. ;(function (root, factory) {
  58223. if (typeof exports === "object") {
  58224. // CommonJS
  58225. module.exports = exports = factory();
  58226. }
  58227. else if (typeof define === "function" && define.amd) {
  58228. // AMD
  58229. define([], factory);
  58230. }
  58231. else {
  58232. // Global (browser)
  58233. root.CryptoJS = factory();
  58234. }
  58235. }(this, function () {
  58236. /*globals window, global, require*/
  58237. /**
  58238. * CryptoJS core components.
  58239. */
  58240. var CryptoJS = CryptoJS || (function (Math, undefined) {
  58241. var crypto;
  58242. // Native crypto from window (Browser)
  58243. if (typeof window !== 'undefined' && window.crypto) {
  58244. crypto = window.crypto;
  58245. }
  58246. // Native crypto in web worker (Browser)
  58247. if (typeof self !== 'undefined' && self.crypto) {
  58248. crypto = self.crypto;
  58249. }
  58250. // Native crypto from worker
  58251. if (typeof globalThis !== 'undefined' && globalThis.crypto) {
  58252. crypto = globalThis.crypto;
  58253. }
  58254. // Native (experimental IE 11) crypto from window (Browser)
  58255. if (!crypto && typeof window !== 'undefined' && window.msCrypto) {
  58256. crypto = window.msCrypto;
  58257. }
  58258. // Native crypto from global (NodeJS)
  58259. if (!crypto && typeof global !== 'undefined' && global.crypto) {
  58260. crypto = global.crypto;
  58261. }
  58262. // Native crypto import via require (NodeJS)
  58263. if (!crypto && typeof _dereq_ === 'function') {
  58264. try {
  58265. crypto = _dereq_('crypto');
  58266. } catch (err) {}
  58267. }
  58268. /*
  58269. * Cryptographically secure pseudorandom number generator
  58270. *
  58271. * As Math.random() is cryptographically not safe to use
  58272. */
  58273. var cryptoSecureRandomInt = function () {
  58274. if (crypto) {
  58275. // Use getRandomValues method (Browser)
  58276. if (typeof crypto.getRandomValues === 'function') {
  58277. try {
  58278. return crypto.getRandomValues(new Uint32Array(1))[0];
  58279. } catch (err) {}
  58280. }
  58281. // Use randomBytes method (NodeJS)
  58282. if (typeof crypto.randomBytes === 'function') {
  58283. try {
  58284. return crypto.randomBytes(4).readInt32LE();
  58285. } catch (err) {}
  58286. }
  58287. }
  58288. throw new Error('Native crypto module could not be used to get secure random number.');
  58289. };
  58290. /*
  58291. * Local polyfill of Object.create
  58292. */
  58293. var create = Object.create || (function () {
  58294. function F() {}
  58295. return function (obj) {
  58296. var subtype;
  58297. F.prototype = obj;
  58298. subtype = new F();
  58299. F.prototype = null;
  58300. return subtype;
  58301. };
  58302. }());
  58303. /**
  58304. * CryptoJS namespace.
  58305. */
  58306. var C = {};
  58307. /**
  58308. * Library namespace.
  58309. */
  58310. var C_lib = C.lib = {};
  58311. /**
  58312. * Base object for prototypal inheritance.
  58313. */
  58314. var Base = C_lib.Base = (function () {
  58315. return {
  58316. /**
  58317. * Creates a new object that inherits from this object.
  58318. *
  58319. * @param {Object} overrides Properties to copy into the new object.
  58320. *
  58321. * @return {Object} The new object.
  58322. *
  58323. * @static
  58324. *
  58325. * @example
  58326. *
  58327. * var MyType = CryptoJS.lib.Base.extend({
  58328. * field: 'value',
  58329. *
  58330. * method: function () {
  58331. * }
  58332. * });
  58333. */
  58334. extend: function (overrides) {
  58335. // Spawn
  58336. var subtype = create(this);
  58337. // Augment
  58338. if (overrides) {
  58339. subtype.mixIn(overrides);
  58340. }
  58341. // Create default initializer
  58342. if (!subtype.hasOwnProperty('init') || this.init === subtype.init) {
  58343. subtype.init = function () {
  58344. subtype.$super.init.apply(this, arguments);
  58345. };
  58346. }
  58347. // Initializer's prototype is the subtype object
  58348. subtype.init.prototype = subtype;
  58349. // Reference supertype
  58350. subtype.$super = this;
  58351. return subtype;
  58352. },
  58353. /**
  58354. * Extends this object and runs the init method.
  58355. * Arguments to create() will be passed to init().
  58356. *
  58357. * @return {Object} The new object.
  58358. *
  58359. * @static
  58360. *
  58361. * @example
  58362. *
  58363. * var instance = MyType.create();
  58364. */
  58365. create: function () {
  58366. var instance = this.extend();
  58367. instance.init.apply(instance, arguments);
  58368. return instance;
  58369. },
  58370. /**
  58371. * Initializes a newly created object.
  58372. * Override this method to add some logic when your objects are created.
  58373. *
  58374. * @example
  58375. *
  58376. * var MyType = CryptoJS.lib.Base.extend({
  58377. * init: function () {
  58378. * // ...
  58379. * }
  58380. * });
  58381. */
  58382. init: function () {
  58383. },
  58384. /**
  58385. * Copies properties into this object.
  58386. *
  58387. * @param {Object} properties The properties to mix in.
  58388. *
  58389. * @example
  58390. *
  58391. * MyType.mixIn({
  58392. * field: 'value'
  58393. * });
  58394. */
  58395. mixIn: function (properties) {
  58396. for (var propertyName in properties) {
  58397. if (properties.hasOwnProperty(propertyName)) {
  58398. this[propertyName] = properties[propertyName];
  58399. }
  58400. }
  58401. // IE won't copy toString using the loop above
  58402. if (properties.hasOwnProperty('toString')) {
  58403. this.toString = properties.toString;
  58404. }
  58405. },
  58406. /**
  58407. * Creates a copy of this object.
  58408. *
  58409. * @return {Object} The clone.
  58410. *
  58411. * @example
  58412. *
  58413. * var clone = instance.clone();
  58414. */
  58415. clone: function () {
  58416. return this.init.prototype.extend(this);
  58417. }
  58418. };
  58419. }());
  58420. /**
  58421. * An array of 32-bit words.
  58422. *
  58423. * @property {Array} words The array of 32-bit words.
  58424. * @property {number} sigBytes The number of significant bytes in this word array.
  58425. */
  58426. var WordArray = C_lib.WordArray = Base.extend({
  58427. /**
  58428. * Initializes a newly created word array.
  58429. *
  58430. * @param {Array} words (Optional) An array of 32-bit words.
  58431. * @param {number} sigBytes (Optional) The number of significant bytes in the words.
  58432. *
  58433. * @example
  58434. *
  58435. * var wordArray = CryptoJS.lib.WordArray.create();
  58436. * var wordArray = CryptoJS.lib.WordArray.create([0x00010203, 0x04050607]);
  58437. * var wordArray = CryptoJS.lib.WordArray.create([0x00010203, 0x04050607], 6);
  58438. */
  58439. init: function (words, sigBytes) {
  58440. words = this.words = words || [];
  58441. if (sigBytes != undefined) {
  58442. this.sigBytes = sigBytes;
  58443. } else {
  58444. this.sigBytes = words.length * 4;
  58445. }
  58446. },
  58447. /**
  58448. * Converts this word array to a string.
  58449. *
  58450. * @param {Encoder} encoder (Optional) The encoding strategy to use. Default: CryptoJS.enc.Hex
  58451. *
  58452. * @return {string} The stringified word array.
  58453. *
  58454. * @example
  58455. *
  58456. * var string = wordArray + '';
  58457. * var string = wordArray.toString();
  58458. * var string = wordArray.toString(CryptoJS.enc.Utf8);
  58459. */
  58460. toString: function (encoder) {
  58461. return (encoder || Hex).stringify(this);
  58462. },
  58463. /**
  58464. * Concatenates a word array to this word array.
  58465. *
  58466. * @param {WordArray} wordArray The word array to append.
  58467. *
  58468. * @return {WordArray} This word array.
  58469. *
  58470. * @example
  58471. *
  58472. * wordArray1.concat(wordArray2);
  58473. */
  58474. concat: function (wordArray) {
  58475. // Shortcuts
  58476. var thisWords = this.words;
  58477. var thatWords = wordArray.words;
  58478. var thisSigBytes = this.sigBytes;
  58479. var thatSigBytes = wordArray.sigBytes;
  58480. // Clamp excess bits
  58481. this.clamp();
  58482. // Concat
  58483. if (thisSigBytes % 4) {
  58484. // Copy one byte at a time
  58485. for (var i = 0; i < thatSigBytes; i++) {
  58486. var thatByte = (thatWords[i >>> 2] >>> (24 - (i % 4) * 8)) & 0xff;
  58487. thisWords[(thisSigBytes + i) >>> 2] |= thatByte << (24 - ((thisSigBytes + i) % 4) * 8);
  58488. }
  58489. } else {
  58490. // Copy one word at a time
  58491. for (var j = 0; j < thatSigBytes; j += 4) {
  58492. thisWords[(thisSigBytes + j) >>> 2] = thatWords[j >>> 2];
  58493. }
  58494. }
  58495. this.sigBytes += thatSigBytes;
  58496. // Chainable
  58497. return this;
  58498. },
  58499. /**
  58500. * Removes insignificant bits.
  58501. *
  58502. * @example
  58503. *
  58504. * wordArray.clamp();
  58505. */
  58506. clamp: function () {
  58507. // Shortcuts
  58508. var words = this.words;
  58509. var sigBytes = this.sigBytes;
  58510. // Clamp
  58511. words[sigBytes >>> 2] &= 0xffffffff << (32 - (sigBytes % 4) * 8);
  58512. words.length = Math.ceil(sigBytes / 4);
  58513. },
  58514. /**
  58515. * Creates a copy of this word array.
  58516. *
  58517. * @return {WordArray} The clone.
  58518. *
  58519. * @example
  58520. *
  58521. * var clone = wordArray.clone();
  58522. */
  58523. clone: function () {
  58524. var clone = Base.clone.call(this);
  58525. clone.words = this.words.slice(0);
  58526. return clone;
  58527. },
  58528. /**
  58529. * Creates a word array filled with random bytes.
  58530. *
  58531. * @param {number} nBytes The number of random bytes to generate.
  58532. *
  58533. * @return {WordArray} The random word array.
  58534. *
  58535. * @static
  58536. *
  58537. * @example
  58538. *
  58539. * var wordArray = CryptoJS.lib.WordArray.random(16);
  58540. */
  58541. random: function (nBytes) {
  58542. var words = [];
  58543. for (var i = 0; i < nBytes; i += 4) {
  58544. words.push(cryptoSecureRandomInt());
  58545. }
  58546. return new WordArray.init(words, nBytes);
  58547. }
  58548. });
  58549. /**
  58550. * Encoder namespace.
  58551. */
  58552. var C_enc = C.enc = {};
  58553. /**
  58554. * Hex encoding strategy.
  58555. */
  58556. var Hex = C_enc.Hex = {
  58557. /**
  58558. * Converts a word array to a hex string.
  58559. *
  58560. * @param {WordArray} wordArray The word array.
  58561. *
  58562. * @return {string} The hex string.
  58563. *
  58564. * @static
  58565. *
  58566. * @example
  58567. *
  58568. * var hexString = CryptoJS.enc.Hex.stringify(wordArray);
  58569. */
  58570. stringify: function (wordArray) {
  58571. // Shortcuts
  58572. var words = wordArray.words;
  58573. var sigBytes = wordArray.sigBytes;
  58574. // Convert
  58575. var hexChars = [];
  58576. for (var i = 0; i < sigBytes; i++) {
  58577. var bite = (words[i >>> 2] >>> (24 - (i % 4) * 8)) & 0xff;
  58578. hexChars.push((bite >>> 4).toString(16));
  58579. hexChars.push((bite & 0x0f).toString(16));
  58580. }
  58581. return hexChars.join('');
  58582. },
  58583. /**
  58584. * Converts a hex string to a word array.
  58585. *
  58586. * @param {string} hexStr The hex string.
  58587. *
  58588. * @return {WordArray} The word array.
  58589. *
  58590. * @static
  58591. *
  58592. * @example
  58593. *
  58594. * var wordArray = CryptoJS.enc.Hex.parse(hexString);
  58595. */
  58596. parse: function (hexStr) {
  58597. // Shortcut
  58598. var hexStrLength = hexStr.length;
  58599. // Convert
  58600. var words = [];
  58601. for (var i = 0; i < hexStrLength; i += 2) {
  58602. words[i >>> 3] |= parseInt(hexStr.substr(i, 2), 16) << (24 - (i % 8) * 4);
  58603. }
  58604. return new WordArray.init(words, hexStrLength / 2);
  58605. }
  58606. };
  58607. /**
  58608. * Latin1 encoding strategy.
  58609. */
  58610. var Latin1 = C_enc.Latin1 = {
  58611. /**
  58612. * Converts a word array to a Latin1 string.
  58613. *
  58614. * @param {WordArray} wordArray The word array.
  58615. *
  58616. * @return {string} The Latin1 string.
  58617. *
  58618. * @static
  58619. *
  58620. * @example
  58621. *
  58622. * var latin1String = CryptoJS.enc.Latin1.stringify(wordArray);
  58623. */
  58624. stringify: function (wordArray) {
  58625. // Shortcuts
  58626. var words = wordArray.words;
  58627. var sigBytes = wordArray.sigBytes;
  58628. // Convert
  58629. var latin1Chars = [];
  58630. for (var i = 0; i < sigBytes; i++) {
  58631. var bite = (words[i >>> 2] >>> (24 - (i % 4) * 8)) & 0xff;
  58632. latin1Chars.push(String.fromCharCode(bite));
  58633. }
  58634. return latin1Chars.join('');
  58635. },
  58636. /**
  58637. * Converts a Latin1 string to a word array.
  58638. *
  58639. * @param {string} latin1Str The Latin1 string.
  58640. *
  58641. * @return {WordArray} The word array.
  58642. *
  58643. * @static
  58644. *
  58645. * @example
  58646. *
  58647. * var wordArray = CryptoJS.enc.Latin1.parse(latin1String);
  58648. */
  58649. parse: function (latin1Str) {
  58650. // Shortcut
  58651. var latin1StrLength = latin1Str.length;
  58652. // Convert
  58653. var words = [];
  58654. for (var i = 0; i < latin1StrLength; i++) {
  58655. words[i >>> 2] |= (latin1Str.charCodeAt(i) & 0xff) << (24 - (i % 4) * 8);
  58656. }
  58657. return new WordArray.init(words, latin1StrLength);
  58658. }
  58659. };
  58660. /**
  58661. * UTF-8 encoding strategy.
  58662. */
  58663. var Utf8 = C_enc.Utf8 = {
  58664. /**
  58665. * Converts a word array to a UTF-8 string.
  58666. *
  58667. * @param {WordArray} wordArray The word array.
  58668. *
  58669. * @return {string} The UTF-8 string.
  58670. *
  58671. * @static
  58672. *
  58673. * @example
  58674. *
  58675. * var utf8String = CryptoJS.enc.Utf8.stringify(wordArray);
  58676. */
  58677. stringify: function (wordArray) {
  58678. try {
  58679. return decodeURIComponent(escape(Latin1.stringify(wordArray)));
  58680. } catch (e) {
  58681. throw new Error('Malformed UTF-8 data');
  58682. }
  58683. },
  58684. /**
  58685. * Converts a UTF-8 string to a word array.
  58686. *
  58687. * @param {string} utf8Str The UTF-8 string.
  58688. *
  58689. * @return {WordArray} The word array.
  58690. *
  58691. * @static
  58692. *
  58693. * @example
  58694. *
  58695. * var wordArray = CryptoJS.enc.Utf8.parse(utf8String);
  58696. */
  58697. parse: function (utf8Str) {
  58698. return Latin1.parse(unescape(encodeURIComponent(utf8Str)));
  58699. }
  58700. };
  58701. /**
  58702. * Abstract buffered block algorithm template.
  58703. *
  58704. * The property blockSize must be implemented in a concrete subtype.
  58705. *
  58706. * @property {number} _minBufferSize The number of blocks that should be kept unprocessed in the buffer. Default: 0
  58707. */
  58708. var BufferedBlockAlgorithm = C_lib.BufferedBlockAlgorithm = Base.extend({
  58709. /**
  58710. * Resets this block algorithm's data buffer to its initial state.
  58711. *
  58712. * @example
  58713. *
  58714. * bufferedBlockAlgorithm.reset();
  58715. */
  58716. reset: function () {
  58717. // Initial values
  58718. this._data = new WordArray.init();
  58719. this._nDataBytes = 0;
  58720. },
  58721. /**
  58722. * Adds new data to this block algorithm's buffer.
  58723. *
  58724. * @param {WordArray|string} data The data to append. Strings are converted to a WordArray using UTF-8.
  58725. *
  58726. * @example
  58727. *
  58728. * bufferedBlockAlgorithm._append('data');
  58729. * bufferedBlockAlgorithm._append(wordArray);
  58730. */
  58731. _append: function (data) {
  58732. // Convert string to WordArray, else assume WordArray already
  58733. if (typeof data == 'string') {
  58734. data = Utf8.parse(data);
  58735. }
  58736. // Append
  58737. this._data.concat(data);
  58738. this._nDataBytes += data.sigBytes;
  58739. },
  58740. /**
  58741. * Processes available data blocks.
  58742. *
  58743. * This method invokes _doProcessBlock(offset), which must be implemented by a concrete subtype.
  58744. *
  58745. * @param {boolean} doFlush Whether all blocks and partial blocks should be processed.
  58746. *
  58747. * @return {WordArray} The processed data.
  58748. *
  58749. * @example
  58750. *
  58751. * var processedData = bufferedBlockAlgorithm._process();
  58752. * var processedData = bufferedBlockAlgorithm._process(!!'flush');
  58753. */
  58754. _process: function (doFlush) {
  58755. var processedWords;
  58756. // Shortcuts
  58757. var data = this._data;
  58758. var dataWords = data.words;
  58759. var dataSigBytes = data.sigBytes;
  58760. var blockSize = this.blockSize;
  58761. var blockSizeBytes = blockSize * 4;
  58762. // Count blocks ready
  58763. var nBlocksReady = dataSigBytes / blockSizeBytes;
  58764. if (doFlush) {
  58765. // Round up to include partial blocks
  58766. nBlocksReady = Math.ceil(nBlocksReady);
  58767. } else {
  58768. // Round down to include only full blocks,
  58769. // less the number of blocks that must remain in the buffer
  58770. nBlocksReady = Math.max((nBlocksReady | 0) - this._minBufferSize, 0);
  58771. }
  58772. // Count words ready
  58773. var nWordsReady = nBlocksReady * blockSize;
  58774. // Count bytes ready
  58775. var nBytesReady = Math.min(nWordsReady * 4, dataSigBytes);
  58776. // Process blocks
  58777. if (nWordsReady) {
  58778. for (var offset = 0; offset < nWordsReady; offset += blockSize) {
  58779. // Perform concrete-algorithm logic
  58780. this._doProcessBlock(dataWords, offset);
  58781. }
  58782. // Remove processed words
  58783. processedWords = dataWords.splice(0, nWordsReady);
  58784. data.sigBytes -= nBytesReady;
  58785. }
  58786. // Return processed words
  58787. return new WordArray.init(processedWords, nBytesReady);
  58788. },
  58789. /**
  58790. * Creates a copy of this object.
  58791. *
  58792. * @return {Object} The clone.
  58793. *
  58794. * @example
  58795. *
  58796. * var clone = bufferedBlockAlgorithm.clone();
  58797. */
  58798. clone: function () {
  58799. var clone = Base.clone.call(this);
  58800. clone._data = this._data.clone();
  58801. return clone;
  58802. },
  58803. _minBufferSize: 0
  58804. });
  58805. /**
  58806. * Abstract hasher template.
  58807. *
  58808. * @property {number} blockSize The number of 32-bit words this hasher operates on. Default: 16 (512 bits)
  58809. */
  58810. var Hasher = C_lib.Hasher = BufferedBlockAlgorithm.extend({
  58811. /**
  58812. * Configuration options.
  58813. */
  58814. cfg: Base.extend(),
  58815. /**
  58816. * Initializes a newly created hasher.
  58817. *
  58818. * @param {Object} cfg (Optional) The configuration options to use for this hash computation.
  58819. *
  58820. * @example
  58821. *
  58822. * var hasher = CryptoJS.algo.SHA256.create();
  58823. */
  58824. init: function (cfg) {
  58825. // Apply config defaults
  58826. this.cfg = this.cfg.extend(cfg);
  58827. // Set initial values
  58828. this.reset();
  58829. },
  58830. /**
  58831. * Resets this hasher to its initial state.
  58832. *
  58833. * @example
  58834. *
  58835. * hasher.reset();
  58836. */
  58837. reset: function () {
  58838. // Reset data buffer
  58839. BufferedBlockAlgorithm.reset.call(this);
  58840. // Perform concrete-hasher logic
  58841. this._doReset();
  58842. },
  58843. /**
  58844. * Updates this hasher with a message.
  58845. *
  58846. * @param {WordArray|string} messageUpdate The message to append.
  58847. *
  58848. * @return {Hasher} This hasher.
  58849. *
  58850. * @example
  58851. *
  58852. * hasher.update('message');
  58853. * hasher.update(wordArray);
  58854. */
  58855. update: function (messageUpdate) {
  58856. // Append
  58857. this._append(messageUpdate);
  58858. // Update the hash
  58859. this._process();
  58860. // Chainable
  58861. return this;
  58862. },
  58863. /**
  58864. * Finalizes the hash computation.
  58865. * Note that the finalize operation is effectively a destructive, read-once operation.
  58866. *
  58867. * @param {WordArray|string} messageUpdate (Optional) A final message update.
  58868. *
  58869. * @return {WordArray} The hash.
  58870. *
  58871. * @example
  58872. *
  58873. * var hash = hasher.finalize();
  58874. * var hash = hasher.finalize('message');
  58875. * var hash = hasher.finalize(wordArray);
  58876. */
  58877. finalize: function (messageUpdate) {
  58878. // Final message update
  58879. if (messageUpdate) {
  58880. this._append(messageUpdate);
  58881. }
  58882. // Perform concrete-hasher logic
  58883. var hash = this._doFinalize();
  58884. return hash;
  58885. },
  58886. blockSize: 512/32,
  58887. /**
  58888. * Creates a shortcut function to a hasher's object interface.
  58889. *
  58890. * @param {Hasher} hasher The hasher to create a helper for.
  58891. *
  58892. * @return {Function} The shortcut function.
  58893. *
  58894. * @static
  58895. *
  58896. * @example
  58897. *
  58898. * var SHA256 = CryptoJS.lib.Hasher._createHelper(CryptoJS.algo.SHA256);
  58899. */
  58900. _createHelper: function (hasher) {
  58901. return function (message, cfg) {
  58902. return new hasher.init(cfg).finalize(message);
  58903. };
  58904. },
  58905. /**
  58906. * Creates a shortcut function to the HMAC's object interface.
  58907. *
  58908. * @param {Hasher} hasher The hasher to use in this HMAC helper.
  58909. *
  58910. * @return {Function} The shortcut function.
  58911. *
  58912. * @static
  58913. *
  58914. * @example
  58915. *
  58916. * var HmacSHA256 = CryptoJS.lib.Hasher._createHmacHelper(CryptoJS.algo.SHA256);
  58917. */
  58918. _createHmacHelper: function (hasher) {
  58919. return function (message, key) {
  58920. return new C_algo.HMAC.init(hasher, key).finalize(message);
  58921. };
  58922. }
  58923. });
  58924. /**
  58925. * Algorithm namespace.
  58926. */
  58927. var C_algo = C.algo = {};
  58928. return C;
  58929. }(Math));
  58930. return CryptoJS;
  58931. }));
  58932. }).call(this)}).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {})
  58933. },{"crypto":undefined}],748:[function(_dereq_,module,exports){
  58934. ;(function (root, factory) {
  58935. if (typeof exports === "object") {
  58936. // CommonJS
  58937. module.exports = exports = factory(_dereq_("./core"));
  58938. }
  58939. else if (typeof define === "function" && define.amd) {
  58940. // AMD
  58941. define(["./core"], factory);
  58942. }
  58943. else {
  58944. // Global (browser)
  58945. factory(root.CryptoJS);
  58946. }
  58947. }(this, function (CryptoJS) {
  58948. (function () {
  58949. // Shortcuts
  58950. var C = CryptoJS;
  58951. var C_lib = C.lib;
  58952. var WordArray = C_lib.WordArray;
  58953. var C_enc = C.enc;
  58954. /**
  58955. * Base64 encoding strategy.
  58956. */
  58957. var Base64 = C_enc.Base64 = {
  58958. /**
  58959. * Converts a word array to a Base64 string.
  58960. *
  58961. * @param {WordArray} wordArray The word array.
  58962. *
  58963. * @return {string} The Base64 string.
  58964. *
  58965. * @static
  58966. *
  58967. * @example
  58968. *
  58969. * var base64String = CryptoJS.enc.Base64.stringify(wordArray);
  58970. */
  58971. stringify: function (wordArray) {
  58972. // Shortcuts
  58973. var words = wordArray.words;
  58974. var sigBytes = wordArray.sigBytes;
  58975. var map = this._map;
  58976. // Clamp excess bits
  58977. wordArray.clamp();
  58978. // Convert
  58979. var base64Chars = [];
  58980. for (var i = 0; i < sigBytes; i += 3) {
  58981. var byte1 = (words[i >>> 2] >>> (24 - (i % 4) * 8)) & 0xff;
  58982. var byte2 = (words[(i + 1) >>> 2] >>> (24 - ((i + 1) % 4) * 8)) & 0xff;
  58983. var byte3 = (words[(i + 2) >>> 2] >>> (24 - ((i + 2) % 4) * 8)) & 0xff;
  58984. var triplet = (byte1 << 16) | (byte2 << 8) | byte3;
  58985. for (var j = 0; (j < 4) && (i + j * 0.75 < sigBytes); j++) {
  58986. base64Chars.push(map.charAt((triplet >>> (6 * (3 - j))) & 0x3f));
  58987. }
  58988. }
  58989. // Add padding
  58990. var paddingChar = map.charAt(64);
  58991. if (paddingChar) {
  58992. while (base64Chars.length % 4) {
  58993. base64Chars.push(paddingChar);
  58994. }
  58995. }
  58996. return base64Chars.join('');
  58997. },
  58998. /**
  58999. * Converts a Base64 string to a word array.
  59000. *
  59001. * @param {string} base64Str The Base64 string.
  59002. *
  59003. * @return {WordArray} The word array.
  59004. *
  59005. * @static
  59006. *
  59007. * @example
  59008. *
  59009. * var wordArray = CryptoJS.enc.Base64.parse(base64String);
  59010. */
  59011. parse: function (base64Str) {
  59012. // Shortcuts
  59013. var base64StrLength = base64Str.length;
  59014. var map = this._map;
  59015. var reverseMap = this._reverseMap;
  59016. if (!reverseMap) {
  59017. reverseMap = this._reverseMap = [];
  59018. for (var j = 0; j < map.length; j++) {
  59019. reverseMap[map.charCodeAt(j)] = j;
  59020. }
  59021. }
  59022. // Ignore padding
  59023. var paddingChar = map.charAt(64);
  59024. if (paddingChar) {
  59025. var paddingIndex = base64Str.indexOf(paddingChar);
  59026. if (paddingIndex !== -1) {
  59027. base64StrLength = paddingIndex;
  59028. }
  59029. }
  59030. // Convert
  59031. return parseLoop(base64Str, base64StrLength, reverseMap);
  59032. },
  59033. _map: 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/='
  59034. };
  59035. function parseLoop(base64Str, base64StrLength, reverseMap) {
  59036. var words = [];
  59037. var nBytes = 0;
  59038. for (var i = 0; i < base64StrLength; i++) {
  59039. if (i % 4) {
  59040. var bits1 = reverseMap[base64Str.charCodeAt(i - 1)] << ((i % 4) * 2);
  59041. var bits2 = reverseMap[base64Str.charCodeAt(i)] >>> (6 - (i % 4) * 2);
  59042. var bitsCombined = bits1 | bits2;
  59043. words[nBytes >>> 2] |= bitsCombined << (24 - (nBytes % 4) * 8);
  59044. nBytes++;
  59045. }
  59046. }
  59047. return WordArray.create(words, nBytes);
  59048. }
  59049. }());
  59050. return CryptoJS.enc.Base64;
  59051. }));
  59052. },{"./core":747}],749:[function(_dereq_,module,exports){
  59053. ;(function (root, factory) {
  59054. if (typeof exports === "object") {
  59055. // CommonJS
  59056. module.exports = exports = factory(_dereq_("./core"));
  59057. }
  59058. else if (typeof define === "function" && define.amd) {
  59059. // AMD
  59060. define(["./core"], factory);
  59061. }
  59062. else {
  59063. // Global (browser)
  59064. factory(root.CryptoJS);
  59065. }
  59066. }(this, function (CryptoJS) {
  59067. return CryptoJS.enc.Utf8;
  59068. }));
  59069. },{"./core":747}],750:[function(_dereq_,module,exports){
  59070. ;(function (root, factory, undef) {
  59071. if (typeof exports === "object") {
  59072. // CommonJS
  59073. module.exports = exports = factory(_dereq_("./core"), _dereq_("./sha1"), _dereq_("./hmac"));
  59074. }
  59075. else if (typeof define === "function" && define.amd) {
  59076. // AMD
  59077. define(["./core", "./sha1", "./hmac"], factory);
  59078. }
  59079. else {
  59080. // Global (browser)
  59081. factory(root.CryptoJS);
  59082. }
  59083. }(this, function (CryptoJS) {
  59084. (function () {
  59085. // Shortcuts
  59086. var C = CryptoJS;
  59087. var C_lib = C.lib;
  59088. var Base = C_lib.Base;
  59089. var WordArray = C_lib.WordArray;
  59090. var C_algo = C.algo;
  59091. var MD5 = C_algo.MD5;
  59092. /**
  59093. * This key derivation function is meant to conform with EVP_BytesToKey.
  59094. * www.openssl.org/docs/crypto/EVP_BytesToKey.html
  59095. */
  59096. var EvpKDF = C_algo.EvpKDF = Base.extend({
  59097. /**
  59098. * Configuration options.
  59099. *
  59100. * @property {number} keySize The key size in words to generate. Default: 4 (128 bits)
  59101. * @property {Hasher} hasher The hash algorithm to use. Default: MD5
  59102. * @property {number} iterations The number of iterations to perform. Default: 1
  59103. */
  59104. cfg: Base.extend({
  59105. keySize: 128/32,
  59106. hasher: MD5,
  59107. iterations: 1
  59108. }),
  59109. /**
  59110. * Initializes a newly created key derivation function.
  59111. *
  59112. * @param {Object} cfg (Optional) The configuration options to use for the derivation.
  59113. *
  59114. * @example
  59115. *
  59116. * var kdf = CryptoJS.algo.EvpKDF.create();
  59117. * var kdf = CryptoJS.algo.EvpKDF.create({ keySize: 8 });
  59118. * var kdf = CryptoJS.algo.EvpKDF.create({ keySize: 8, iterations: 1000 });
  59119. */
  59120. init: function (cfg) {
  59121. this.cfg = this.cfg.extend(cfg);
  59122. },
  59123. /**
  59124. * Derives a key from a password.
  59125. *
  59126. * @param {WordArray|string} password The password.
  59127. * @param {WordArray|string} salt A salt.
  59128. *
  59129. * @return {WordArray} The derived key.
  59130. *
  59131. * @example
  59132. *
  59133. * var key = kdf.compute(password, salt);
  59134. */
  59135. compute: function (password, salt) {
  59136. var block;
  59137. // Shortcut
  59138. var cfg = this.cfg;
  59139. // Init hasher
  59140. var hasher = cfg.hasher.create();
  59141. // Initial values
  59142. var derivedKey = WordArray.create();
  59143. // Shortcuts
  59144. var derivedKeyWords = derivedKey.words;
  59145. var keySize = cfg.keySize;
  59146. var iterations = cfg.iterations;
  59147. // Generate key
  59148. while (derivedKeyWords.length < keySize) {
  59149. if (block) {
  59150. hasher.update(block);
  59151. }
  59152. block = hasher.update(password).finalize(salt);
  59153. hasher.reset();
  59154. // Iterations
  59155. for (var i = 1; i < iterations; i++) {
  59156. block = hasher.finalize(block);
  59157. hasher.reset();
  59158. }
  59159. derivedKey.concat(block);
  59160. }
  59161. derivedKey.sigBytes = keySize * 4;
  59162. return derivedKey;
  59163. }
  59164. });
  59165. /**
  59166. * Derives a key from a password.
  59167. *
  59168. * @param {WordArray|string} password The password.
  59169. * @param {WordArray|string} salt A salt.
  59170. * @param {Object} cfg (Optional) The configuration options to use for this computation.
  59171. *
  59172. * @return {WordArray} The derived key.
  59173. *
  59174. * @static
  59175. *
  59176. * @example
  59177. *
  59178. * var key = CryptoJS.EvpKDF(password, salt);
  59179. * var key = CryptoJS.EvpKDF(password, salt, { keySize: 8 });
  59180. * var key = CryptoJS.EvpKDF(password, salt, { keySize: 8, iterations: 1000 });
  59181. */
  59182. C.EvpKDF = function (password, salt, cfg) {
  59183. return EvpKDF.create(cfg).compute(password, salt);
  59184. };
  59185. }());
  59186. return CryptoJS.EvpKDF;
  59187. }));
  59188. },{"./core":747,"./hmac":751,"./sha1":753}],751:[function(_dereq_,module,exports){
  59189. ;(function (root, factory) {
  59190. if (typeof exports === "object") {
  59191. // CommonJS
  59192. module.exports = exports = factory(_dereq_("./core"));
  59193. }
  59194. else if (typeof define === "function" && define.amd) {
  59195. // AMD
  59196. define(["./core"], factory);
  59197. }
  59198. else {
  59199. // Global (browser)
  59200. factory(root.CryptoJS);
  59201. }
  59202. }(this, function (CryptoJS) {
  59203. (function () {
  59204. // Shortcuts
  59205. var C = CryptoJS;
  59206. var C_lib = C.lib;
  59207. var Base = C_lib.Base;
  59208. var C_enc = C.enc;
  59209. var Utf8 = C_enc.Utf8;
  59210. var C_algo = C.algo;
  59211. /**
  59212. * HMAC algorithm.
  59213. */
  59214. var HMAC = C_algo.HMAC = Base.extend({
  59215. /**
  59216. * Initializes a newly created HMAC.
  59217. *
  59218. * @param {Hasher} hasher The hash algorithm to use.
  59219. * @param {WordArray|string} key The secret key.
  59220. *
  59221. * @example
  59222. *
  59223. * var hmacHasher = CryptoJS.algo.HMAC.create(CryptoJS.algo.SHA256, key);
  59224. */
  59225. init: function (hasher, key) {
  59226. // Init hasher
  59227. hasher = this._hasher = new hasher.init();
  59228. // Convert string to WordArray, else assume WordArray already
  59229. if (typeof key == 'string') {
  59230. key = Utf8.parse(key);
  59231. }
  59232. // Shortcuts
  59233. var hasherBlockSize = hasher.blockSize;
  59234. var hasherBlockSizeBytes = hasherBlockSize * 4;
  59235. // Allow arbitrary length keys
  59236. if (key.sigBytes > hasherBlockSizeBytes) {
  59237. key = hasher.finalize(key);
  59238. }
  59239. // Clamp excess bits
  59240. key.clamp();
  59241. // Clone key for inner and outer pads
  59242. var oKey = this._oKey = key.clone();
  59243. var iKey = this._iKey = key.clone();
  59244. // Shortcuts
  59245. var oKeyWords = oKey.words;
  59246. var iKeyWords = iKey.words;
  59247. // XOR keys with pad constants
  59248. for (var i = 0; i < hasherBlockSize; i++) {
  59249. oKeyWords[i] ^= 0x5c5c5c5c;
  59250. iKeyWords[i] ^= 0x36363636;
  59251. }
  59252. oKey.sigBytes = iKey.sigBytes = hasherBlockSizeBytes;
  59253. // Set initial values
  59254. this.reset();
  59255. },
  59256. /**
  59257. * Resets this HMAC to its initial state.
  59258. *
  59259. * @example
  59260. *
  59261. * hmacHasher.reset();
  59262. */
  59263. reset: function () {
  59264. // Shortcut
  59265. var hasher = this._hasher;
  59266. // Reset
  59267. hasher.reset();
  59268. hasher.update(this._iKey);
  59269. },
  59270. /**
  59271. * Updates this HMAC with a message.
  59272. *
  59273. * @param {WordArray|string} messageUpdate The message to append.
  59274. *
  59275. * @return {HMAC} This HMAC instance.
  59276. *
  59277. * @example
  59278. *
  59279. * hmacHasher.update('message');
  59280. * hmacHasher.update(wordArray);
  59281. */
  59282. update: function (messageUpdate) {
  59283. this._hasher.update(messageUpdate);
  59284. // Chainable
  59285. return this;
  59286. },
  59287. /**
  59288. * Finalizes the HMAC computation.
  59289. * Note that the finalize operation is effectively a destructive, read-once operation.
  59290. *
  59291. * @param {WordArray|string} messageUpdate (Optional) A final message update.
  59292. *
  59293. * @return {WordArray} The HMAC.
  59294. *
  59295. * @example
  59296. *
  59297. * var hmac = hmacHasher.finalize();
  59298. * var hmac = hmacHasher.finalize('message');
  59299. * var hmac = hmacHasher.finalize(wordArray);
  59300. */
  59301. finalize: function (messageUpdate) {
  59302. // Shortcut
  59303. var hasher = this._hasher;
  59304. // Compute HMAC
  59305. var innerHash = hasher.finalize(messageUpdate);
  59306. hasher.reset();
  59307. var hmac = hasher.finalize(this._oKey.clone().concat(innerHash));
  59308. return hmac;
  59309. }
  59310. });
  59311. }());
  59312. }));
  59313. },{"./core":747}],752:[function(_dereq_,module,exports){
  59314. ;(function (root, factory) {
  59315. if (typeof exports === "object") {
  59316. // CommonJS
  59317. module.exports = exports = factory(_dereq_("./core"));
  59318. }
  59319. else if (typeof define === "function" && define.amd) {
  59320. // AMD
  59321. define(["./core"], factory);
  59322. }
  59323. else {
  59324. // Global (browser)
  59325. factory(root.CryptoJS);
  59326. }
  59327. }(this, function (CryptoJS) {
  59328. (function (Math) {
  59329. // Shortcuts
  59330. var C = CryptoJS;
  59331. var C_lib = C.lib;
  59332. var WordArray = C_lib.WordArray;
  59333. var Hasher = C_lib.Hasher;
  59334. var C_algo = C.algo;
  59335. // Constants table
  59336. var T = [];
  59337. // Compute constants
  59338. (function () {
  59339. for (var i = 0; i < 64; i++) {
  59340. T[i] = (Math.abs(Math.sin(i + 1)) * 0x100000000) | 0;
  59341. }
  59342. }());
  59343. /**
  59344. * MD5 hash algorithm.
  59345. */
  59346. var MD5 = C_algo.MD5 = Hasher.extend({
  59347. _doReset: function () {
  59348. this._hash = new WordArray.init([
  59349. 0x67452301, 0xefcdab89,
  59350. 0x98badcfe, 0x10325476
  59351. ]);
  59352. },
  59353. _doProcessBlock: function (M, offset) {
  59354. // Swap endian
  59355. for (var i = 0; i < 16; i++) {
  59356. // Shortcuts
  59357. var offset_i = offset + i;
  59358. var M_offset_i = M[offset_i];
  59359. M[offset_i] = (
  59360. (((M_offset_i << 8) | (M_offset_i >>> 24)) & 0x00ff00ff) |
  59361. (((M_offset_i << 24) | (M_offset_i >>> 8)) & 0xff00ff00)
  59362. );
  59363. }
  59364. // Shortcuts
  59365. var H = this._hash.words;
  59366. var M_offset_0 = M[offset + 0];
  59367. var M_offset_1 = M[offset + 1];
  59368. var M_offset_2 = M[offset + 2];
  59369. var M_offset_3 = M[offset + 3];
  59370. var M_offset_4 = M[offset + 4];
  59371. var M_offset_5 = M[offset + 5];
  59372. var M_offset_6 = M[offset + 6];
  59373. var M_offset_7 = M[offset + 7];
  59374. var M_offset_8 = M[offset + 8];
  59375. var M_offset_9 = M[offset + 9];
  59376. var M_offset_10 = M[offset + 10];
  59377. var M_offset_11 = M[offset + 11];
  59378. var M_offset_12 = M[offset + 12];
  59379. var M_offset_13 = M[offset + 13];
  59380. var M_offset_14 = M[offset + 14];
  59381. var M_offset_15 = M[offset + 15];
  59382. // Working varialbes
  59383. var a = H[0];
  59384. var b = H[1];
  59385. var c = H[2];
  59386. var d = H[3];
  59387. // Computation
  59388. a = FF(a, b, c, d, M_offset_0, 7, T[0]);
  59389. d = FF(d, a, b, c, M_offset_1, 12, T[1]);
  59390. c = FF(c, d, a, b, M_offset_2, 17, T[2]);
  59391. b = FF(b, c, d, a, M_offset_3, 22, T[3]);
  59392. a = FF(a, b, c, d, M_offset_4, 7, T[4]);
  59393. d = FF(d, a, b, c, M_offset_5, 12, T[5]);
  59394. c = FF(c, d, a, b, M_offset_6, 17, T[6]);
  59395. b = FF(b, c, d, a, M_offset_7, 22, T[7]);
  59396. a = FF(a, b, c, d, M_offset_8, 7, T[8]);
  59397. d = FF(d, a, b, c, M_offset_9, 12, T[9]);
  59398. c = FF(c, d, a, b, M_offset_10, 17, T[10]);
  59399. b = FF(b, c, d, a, M_offset_11, 22, T[11]);
  59400. a = FF(a, b, c, d, M_offset_12, 7, T[12]);
  59401. d = FF(d, a, b, c, M_offset_13, 12, T[13]);
  59402. c = FF(c, d, a, b, M_offset_14, 17, T[14]);
  59403. b = FF(b, c, d, a, M_offset_15, 22, T[15]);
  59404. a = GG(a, b, c, d, M_offset_1, 5, T[16]);
  59405. d = GG(d, a, b, c, M_offset_6, 9, T[17]);
  59406. c = GG(c, d, a, b, M_offset_11, 14, T[18]);
  59407. b = GG(b, c, d, a, M_offset_0, 20, T[19]);
  59408. a = GG(a, b, c, d, M_offset_5, 5, T[20]);
  59409. d = GG(d, a, b, c, M_offset_10, 9, T[21]);
  59410. c = GG(c, d, a, b, M_offset_15, 14, T[22]);
  59411. b = GG(b, c, d, a, M_offset_4, 20, T[23]);
  59412. a = GG(a, b, c, d, M_offset_9, 5, T[24]);
  59413. d = GG(d, a, b, c, M_offset_14, 9, T[25]);
  59414. c = GG(c, d, a, b, M_offset_3, 14, T[26]);
  59415. b = GG(b, c, d, a, M_offset_8, 20, T[27]);
  59416. a = GG(a, b, c, d, M_offset_13, 5, T[28]);
  59417. d = GG(d, a, b, c, M_offset_2, 9, T[29]);
  59418. c = GG(c, d, a, b, M_offset_7, 14, T[30]);
  59419. b = GG(b, c, d, a, M_offset_12, 20, T[31]);
  59420. a = HH(a, b, c, d, M_offset_5, 4, T[32]);
  59421. d = HH(d, a, b, c, M_offset_8, 11, T[33]);
  59422. c = HH(c, d, a, b, M_offset_11, 16, T[34]);
  59423. b = HH(b, c, d, a, M_offset_14, 23, T[35]);
  59424. a = HH(a, b, c, d, M_offset_1, 4, T[36]);
  59425. d = HH(d, a, b, c, M_offset_4, 11, T[37]);
  59426. c = HH(c, d, a, b, M_offset_7, 16, T[38]);
  59427. b = HH(b, c, d, a, M_offset_10, 23, T[39]);
  59428. a = HH(a, b, c, d, M_offset_13, 4, T[40]);
  59429. d = HH(d, a, b, c, M_offset_0, 11, T[41]);
  59430. c = HH(c, d, a, b, M_offset_3, 16, T[42]);
  59431. b = HH(b, c, d, a, M_offset_6, 23, T[43]);
  59432. a = HH(a, b, c, d, M_offset_9, 4, T[44]);
  59433. d = HH(d, a, b, c, M_offset_12, 11, T[45]);
  59434. c = HH(c, d, a, b, M_offset_15, 16, T[46]);
  59435. b = HH(b, c, d, a, M_offset_2, 23, T[47]);
  59436. a = II(a, b, c, d, M_offset_0, 6, T[48]);
  59437. d = II(d, a, b, c, M_offset_7, 10, T[49]);
  59438. c = II(c, d, a, b, M_offset_14, 15, T[50]);
  59439. b = II(b, c, d, a, M_offset_5, 21, T[51]);
  59440. a = II(a, b, c, d, M_offset_12, 6, T[52]);
  59441. d = II(d, a, b, c, M_offset_3, 10, T[53]);
  59442. c = II(c, d, a, b, M_offset_10, 15, T[54]);
  59443. b = II(b, c, d, a, M_offset_1, 21, T[55]);
  59444. a = II(a, b, c, d, M_offset_8, 6, T[56]);
  59445. d = II(d, a, b, c, M_offset_15, 10, T[57]);
  59446. c = II(c, d, a, b, M_offset_6, 15, T[58]);
  59447. b = II(b, c, d, a, M_offset_13, 21, T[59]);
  59448. a = II(a, b, c, d, M_offset_4, 6, T[60]);
  59449. d = II(d, a, b, c, M_offset_11, 10, T[61]);
  59450. c = II(c, d, a, b, M_offset_2, 15, T[62]);
  59451. b = II(b, c, d, a, M_offset_9, 21, T[63]);
  59452. // Intermediate hash value
  59453. H[0] = (H[0] + a) | 0;
  59454. H[1] = (H[1] + b) | 0;
  59455. H[2] = (H[2] + c) | 0;
  59456. H[3] = (H[3] + d) | 0;
  59457. },
  59458. _doFinalize: function () {
  59459. // Shortcuts
  59460. var data = this._data;
  59461. var dataWords = data.words;
  59462. var nBitsTotal = this._nDataBytes * 8;
  59463. var nBitsLeft = data.sigBytes * 8;
  59464. // Add padding
  59465. dataWords[nBitsLeft >>> 5] |= 0x80 << (24 - nBitsLeft % 32);
  59466. var nBitsTotalH = Math.floor(nBitsTotal / 0x100000000);
  59467. var nBitsTotalL = nBitsTotal;
  59468. dataWords[(((nBitsLeft + 64) >>> 9) << 4) + 15] = (
  59469. (((nBitsTotalH << 8) | (nBitsTotalH >>> 24)) & 0x00ff00ff) |
  59470. (((nBitsTotalH << 24) | (nBitsTotalH >>> 8)) & 0xff00ff00)
  59471. );
  59472. dataWords[(((nBitsLeft + 64) >>> 9) << 4) + 14] = (
  59473. (((nBitsTotalL << 8) | (nBitsTotalL >>> 24)) & 0x00ff00ff) |
  59474. (((nBitsTotalL << 24) | (nBitsTotalL >>> 8)) & 0xff00ff00)
  59475. );
  59476. data.sigBytes = (dataWords.length + 1) * 4;
  59477. // Hash final blocks
  59478. this._process();
  59479. // Shortcuts
  59480. var hash = this._hash;
  59481. var H = hash.words;
  59482. // Swap endian
  59483. for (var i = 0; i < 4; i++) {
  59484. // Shortcut
  59485. var H_i = H[i];
  59486. H[i] = (((H_i << 8) | (H_i >>> 24)) & 0x00ff00ff) |
  59487. (((H_i << 24) | (H_i >>> 8)) & 0xff00ff00);
  59488. }
  59489. // Return final computed hash
  59490. return hash;
  59491. },
  59492. clone: function () {
  59493. var clone = Hasher.clone.call(this);
  59494. clone._hash = this._hash.clone();
  59495. return clone;
  59496. }
  59497. });
  59498. function FF(a, b, c, d, x, s, t) {
  59499. var n = a + ((b & c) | (~b & d)) + x + t;
  59500. return ((n << s) | (n >>> (32 - s))) + b;
  59501. }
  59502. function GG(a, b, c, d, x, s, t) {
  59503. var n = a + ((b & d) | (c & ~d)) + x + t;
  59504. return ((n << s) | (n >>> (32 - s))) + b;
  59505. }
  59506. function HH(a, b, c, d, x, s, t) {
  59507. var n = a + (b ^ c ^ d) + x + t;
  59508. return ((n << s) | (n >>> (32 - s))) + b;
  59509. }
  59510. function II(a, b, c, d, x, s, t) {
  59511. var n = a + (c ^ (b | ~d)) + x + t;
  59512. return ((n << s) | (n >>> (32 - s))) + b;
  59513. }
  59514. /**
  59515. * Shortcut function to the hasher's object interface.
  59516. *
  59517. * @param {WordArray|string} message The message to hash.
  59518. *
  59519. * @return {WordArray} The hash.
  59520. *
  59521. * @static
  59522. *
  59523. * @example
  59524. *
  59525. * var hash = CryptoJS.MD5('message');
  59526. * var hash = CryptoJS.MD5(wordArray);
  59527. */
  59528. C.MD5 = Hasher._createHelper(MD5);
  59529. /**
  59530. * Shortcut function to the HMAC's object interface.
  59531. *
  59532. * @param {WordArray|string} message The message to hash.
  59533. * @param {WordArray|string} key The secret key.
  59534. *
  59535. * @return {WordArray} The HMAC.
  59536. *
  59537. * @static
  59538. *
  59539. * @example
  59540. *
  59541. * var hmac = CryptoJS.HmacMD5(message, key);
  59542. */
  59543. C.HmacMD5 = Hasher._createHmacHelper(MD5);
  59544. }(Math));
  59545. return CryptoJS.MD5;
  59546. }));
  59547. },{"./core":747}],753:[function(_dereq_,module,exports){
  59548. ;(function (root, factory) {
  59549. if (typeof exports === "object") {
  59550. // CommonJS
  59551. module.exports = exports = factory(_dereq_("./core"));
  59552. }
  59553. else if (typeof define === "function" && define.amd) {
  59554. // AMD
  59555. define(["./core"], factory);
  59556. }
  59557. else {
  59558. // Global (browser)
  59559. factory(root.CryptoJS);
  59560. }
  59561. }(this, function (CryptoJS) {
  59562. (function () {
  59563. // Shortcuts
  59564. var C = CryptoJS;
  59565. var C_lib = C.lib;
  59566. var WordArray = C_lib.WordArray;
  59567. var Hasher = C_lib.Hasher;
  59568. var C_algo = C.algo;
  59569. // Reusable object
  59570. var W = [];
  59571. /**
  59572. * SHA-1 hash algorithm.
  59573. */
  59574. var SHA1 = C_algo.SHA1 = Hasher.extend({
  59575. _doReset: function () {
  59576. this._hash = new WordArray.init([
  59577. 0x67452301, 0xefcdab89,
  59578. 0x98badcfe, 0x10325476,
  59579. 0xc3d2e1f0
  59580. ]);
  59581. },
  59582. _doProcessBlock: function (M, offset) {
  59583. // Shortcut
  59584. var H = this._hash.words;
  59585. // Working variables
  59586. var a = H[0];
  59587. var b = H[1];
  59588. var c = H[2];
  59589. var d = H[3];
  59590. var e = H[4];
  59591. // Computation
  59592. for (var i = 0; i < 80; i++) {
  59593. if (i < 16) {
  59594. W[i] = M[offset + i] | 0;
  59595. } else {
  59596. var n = W[i - 3] ^ W[i - 8] ^ W[i - 14] ^ W[i - 16];
  59597. W[i] = (n << 1) | (n >>> 31);
  59598. }
  59599. var t = ((a << 5) | (a >>> 27)) + e + W[i];
  59600. if (i < 20) {
  59601. t += ((b & c) | (~b & d)) + 0x5a827999;
  59602. } else if (i < 40) {
  59603. t += (b ^ c ^ d) + 0x6ed9eba1;
  59604. } else if (i < 60) {
  59605. t += ((b & c) | (b & d) | (c & d)) - 0x70e44324;
  59606. } else /* if (i < 80) */ {
  59607. t += (b ^ c ^ d) - 0x359d3e2a;
  59608. }
  59609. e = d;
  59610. d = c;
  59611. c = (b << 30) | (b >>> 2);
  59612. b = a;
  59613. a = t;
  59614. }
  59615. // Intermediate hash value
  59616. H[0] = (H[0] + a) | 0;
  59617. H[1] = (H[1] + b) | 0;
  59618. H[2] = (H[2] + c) | 0;
  59619. H[3] = (H[3] + d) | 0;
  59620. H[4] = (H[4] + e) | 0;
  59621. },
  59622. _doFinalize: function () {
  59623. // Shortcuts
  59624. var data = this._data;
  59625. var dataWords = data.words;
  59626. var nBitsTotal = this._nDataBytes * 8;
  59627. var nBitsLeft = data.sigBytes * 8;
  59628. // Add padding
  59629. dataWords[nBitsLeft >>> 5] |= 0x80 << (24 - nBitsLeft % 32);
  59630. dataWords[(((nBitsLeft + 64) >>> 9) << 4) + 14] = Math.floor(nBitsTotal / 0x100000000);
  59631. dataWords[(((nBitsLeft + 64) >>> 9) << 4) + 15] = nBitsTotal;
  59632. data.sigBytes = dataWords.length * 4;
  59633. // Hash final blocks
  59634. this._process();
  59635. // Return final computed hash
  59636. return this._hash;
  59637. },
  59638. clone: function () {
  59639. var clone = Hasher.clone.call(this);
  59640. clone._hash = this._hash.clone();
  59641. return clone;
  59642. }
  59643. });
  59644. /**
  59645. * Shortcut function to the hasher's object interface.
  59646. *
  59647. * @param {WordArray|string} message The message to hash.
  59648. *
  59649. * @return {WordArray} The hash.
  59650. *
  59651. * @static
  59652. *
  59653. * @example
  59654. *
  59655. * var hash = CryptoJS.SHA1('message');
  59656. * var hash = CryptoJS.SHA1(wordArray);
  59657. */
  59658. C.SHA1 = Hasher._createHelper(SHA1);
  59659. /**
  59660. * Shortcut function to the HMAC's object interface.
  59661. *
  59662. * @param {WordArray|string} message The message to hash.
  59663. * @param {WordArray|string} key The secret key.
  59664. *
  59665. * @return {WordArray} The HMAC.
  59666. *
  59667. * @static
  59668. *
  59669. * @example
  59670. *
  59671. * var hmac = CryptoJS.HmacSHA1(message, key);
  59672. */
  59673. C.HmacSHA1 = Hasher._createHmacHelper(SHA1);
  59674. }());
  59675. return CryptoJS.SHA1;
  59676. }));
  59677. },{"./core":747}],754:[function(_dereq_,module,exports){
  59678. 'use strict';
  59679. var elliptic = exports;
  59680. elliptic.version = _dereq_('../package.json').version;
  59681. elliptic.utils = _dereq_('./elliptic/utils');
  59682. elliptic.rand = _dereq_('brorand');
  59683. elliptic.curve = _dereq_('./elliptic/curve');
  59684. elliptic.curves = _dereq_('./elliptic/curves');
  59685. // Protocols
  59686. elliptic.ec = _dereq_('./elliptic/ec');
  59687. elliptic.eddsa = _dereq_('./elliptic/eddsa');
  59688. },{"../package.json":770,"./elliptic/curve":757,"./elliptic/curves":760,"./elliptic/ec":761,"./elliptic/eddsa":764,"./elliptic/utils":768,"brorand":322}],755:[function(_dereq_,module,exports){
  59689. 'use strict';
  59690. var BN = _dereq_('bn.js');
  59691. var utils = _dereq_('../utils');
  59692. var getNAF = utils.getNAF;
  59693. var getJSF = utils.getJSF;
  59694. var assert = utils.assert;
  59695. function BaseCurve(type, conf) {
  59696. this.type = type;
  59697. this.p = new BN(conf.p, 16);
  59698. // Use Montgomery, when there is no fast reduction for the prime
  59699. this.red = conf.prime ? BN.red(conf.prime) : BN.mont(this.p);
  59700. // Useful for many curves
  59701. this.zero = new BN(0).toRed(this.red);
  59702. this.one = new BN(1).toRed(this.red);
  59703. this.two = new BN(2).toRed(this.red);
  59704. // Curve configuration, optional
  59705. this.n = conf.n && new BN(conf.n, 16);
  59706. this.g = conf.g && this.pointFromJSON(conf.g, conf.gRed);
  59707. // Temporary arrays
  59708. this._wnafT1 = new Array(4);
  59709. this._wnafT2 = new Array(4);
  59710. this._wnafT3 = new Array(4);
  59711. this._wnafT4 = new Array(4);
  59712. this._bitLength = this.n ? this.n.bitLength() : 0;
  59713. // Generalized Greg Maxwell's trick
  59714. var adjustCount = this.n && this.p.div(this.n);
  59715. if (!adjustCount || adjustCount.cmpn(100) > 0) {
  59716. this.redN = null;
  59717. } else {
  59718. this._maxwellTrick = true;
  59719. this.redN = this.n.toRed(this.red);
  59720. }
  59721. }
  59722. module.exports = BaseCurve;
  59723. BaseCurve.prototype.point = function point() {
  59724. throw new Error('Not implemented');
  59725. };
  59726. BaseCurve.prototype.validate = function validate() {
  59727. throw new Error('Not implemented');
  59728. };
  59729. BaseCurve.prototype._fixedNafMul = function _fixedNafMul(p, k) {
  59730. assert(p.precomputed);
  59731. var doubles = p._getDoubles();
  59732. var naf = getNAF(k, 1, this._bitLength);
  59733. var I = (1 << (doubles.step + 1)) - (doubles.step % 2 === 0 ? 2 : 1);
  59734. I /= 3;
  59735. // Translate into more windowed form
  59736. var repr = [];
  59737. var j;
  59738. var nafW;
  59739. for (j = 0; j < naf.length; j += doubles.step) {
  59740. nafW = 0;
  59741. for (var l = j + doubles.step - 1; l >= j; l--)
  59742. nafW = (nafW << 1) + naf[l];
  59743. repr.push(nafW);
  59744. }
  59745. var a = this.jpoint(null, null, null);
  59746. var b = this.jpoint(null, null, null);
  59747. for (var i = I; i > 0; i--) {
  59748. for (j = 0; j < repr.length; j++) {
  59749. nafW = repr[j];
  59750. if (nafW === i)
  59751. b = b.mixedAdd(doubles.points[j]);
  59752. else if (nafW === -i)
  59753. b = b.mixedAdd(doubles.points[j].neg());
  59754. }
  59755. a = a.add(b);
  59756. }
  59757. return a.toP();
  59758. };
  59759. BaseCurve.prototype._wnafMul = function _wnafMul(p, k) {
  59760. var w = 4;
  59761. // Precompute window
  59762. var nafPoints = p._getNAFPoints(w);
  59763. w = nafPoints.wnd;
  59764. var wnd = nafPoints.points;
  59765. // Get NAF form
  59766. var naf = getNAF(k, w, this._bitLength);
  59767. // Add `this`*(N+1) for every w-NAF index
  59768. var acc = this.jpoint(null, null, null);
  59769. for (var i = naf.length - 1; i >= 0; i--) {
  59770. // Count zeroes
  59771. for (var l = 0; i >= 0 && naf[i] === 0; i--)
  59772. l++;
  59773. if (i >= 0)
  59774. l++;
  59775. acc = acc.dblp(l);
  59776. if (i < 0)
  59777. break;
  59778. var z = naf[i];
  59779. assert(z !== 0);
  59780. if (p.type === 'affine') {
  59781. // J +- P
  59782. if (z > 0)
  59783. acc = acc.mixedAdd(wnd[(z - 1) >> 1]);
  59784. else
  59785. acc = acc.mixedAdd(wnd[(-z - 1) >> 1].neg());
  59786. } else {
  59787. // J +- J
  59788. if (z > 0)
  59789. acc = acc.add(wnd[(z - 1) >> 1]);
  59790. else
  59791. acc = acc.add(wnd[(-z - 1) >> 1].neg());
  59792. }
  59793. }
  59794. return p.type === 'affine' ? acc.toP() : acc;
  59795. };
  59796. BaseCurve.prototype._wnafMulAdd = function _wnafMulAdd(defW,
  59797. points,
  59798. coeffs,
  59799. len,
  59800. jacobianResult) {
  59801. var wndWidth = this._wnafT1;
  59802. var wnd = this._wnafT2;
  59803. var naf = this._wnafT3;
  59804. // Fill all arrays
  59805. var max = 0;
  59806. var i;
  59807. var j;
  59808. var p;
  59809. for (i = 0; i < len; i++) {
  59810. p = points[i];
  59811. var nafPoints = p._getNAFPoints(defW);
  59812. wndWidth[i] = nafPoints.wnd;
  59813. wnd[i] = nafPoints.points;
  59814. }
  59815. // Comb small window NAFs
  59816. for (i = len - 1; i >= 1; i -= 2) {
  59817. var a = i - 1;
  59818. var b = i;
  59819. if (wndWidth[a] !== 1 || wndWidth[b] !== 1) {
  59820. naf[a] = getNAF(coeffs[a], wndWidth[a], this._bitLength);
  59821. naf[b] = getNAF(coeffs[b], wndWidth[b], this._bitLength);
  59822. max = Math.max(naf[a].length, max);
  59823. max = Math.max(naf[b].length, max);
  59824. continue;
  59825. }
  59826. var comb = [
  59827. points[a], /* 1 */
  59828. null, /* 3 */
  59829. null, /* 5 */
  59830. points[b], /* 7 */
  59831. ];
  59832. // Try to avoid Projective points, if possible
  59833. if (points[a].y.cmp(points[b].y) === 0) {
  59834. comb[1] = points[a].add(points[b]);
  59835. comb[2] = points[a].toJ().mixedAdd(points[b].neg());
  59836. } else if (points[a].y.cmp(points[b].y.redNeg()) === 0) {
  59837. comb[1] = points[a].toJ().mixedAdd(points[b]);
  59838. comb[2] = points[a].add(points[b].neg());
  59839. } else {
  59840. comb[1] = points[a].toJ().mixedAdd(points[b]);
  59841. comb[2] = points[a].toJ().mixedAdd(points[b].neg());
  59842. }
  59843. var index = [
  59844. -3, /* -1 -1 */
  59845. -1, /* -1 0 */
  59846. -5, /* -1 1 */
  59847. -7, /* 0 -1 */
  59848. 0, /* 0 0 */
  59849. 7, /* 0 1 */
  59850. 5, /* 1 -1 */
  59851. 1, /* 1 0 */
  59852. 3, /* 1 1 */
  59853. ];
  59854. var jsf = getJSF(coeffs[a], coeffs[b]);
  59855. max = Math.max(jsf[0].length, max);
  59856. naf[a] = new Array(max);
  59857. naf[b] = new Array(max);
  59858. for (j = 0; j < max; j++) {
  59859. var ja = jsf[0][j] | 0;
  59860. var jb = jsf[1][j] | 0;
  59861. naf[a][j] = index[(ja + 1) * 3 + (jb + 1)];
  59862. naf[b][j] = 0;
  59863. wnd[a] = comb;
  59864. }
  59865. }
  59866. var acc = this.jpoint(null, null, null);
  59867. var tmp = this._wnafT4;
  59868. for (i = max; i >= 0; i--) {
  59869. var k = 0;
  59870. while (i >= 0) {
  59871. var zero = true;
  59872. for (j = 0; j < len; j++) {
  59873. tmp[j] = naf[j][i] | 0;
  59874. if (tmp[j] !== 0)
  59875. zero = false;
  59876. }
  59877. if (!zero)
  59878. break;
  59879. k++;
  59880. i--;
  59881. }
  59882. if (i >= 0)
  59883. k++;
  59884. acc = acc.dblp(k);
  59885. if (i < 0)
  59886. break;
  59887. for (j = 0; j < len; j++) {
  59888. var z = tmp[j];
  59889. p;
  59890. if (z === 0)
  59891. continue;
  59892. else if (z > 0)
  59893. p = wnd[j][(z - 1) >> 1];
  59894. else if (z < 0)
  59895. p = wnd[j][(-z - 1) >> 1].neg();
  59896. if (p.type === 'affine')
  59897. acc = acc.mixedAdd(p);
  59898. else
  59899. acc = acc.add(p);
  59900. }
  59901. }
  59902. // Zeroify references
  59903. for (i = 0; i < len; i++)
  59904. wnd[i] = null;
  59905. if (jacobianResult)
  59906. return acc;
  59907. else
  59908. return acc.toP();
  59909. };
  59910. function BasePoint(curve, type) {
  59911. this.curve = curve;
  59912. this.type = type;
  59913. this.precomputed = null;
  59914. }
  59915. BaseCurve.BasePoint = BasePoint;
  59916. BasePoint.prototype.eq = function eq(/*other*/) {
  59917. throw new Error('Not implemented');
  59918. };
  59919. BasePoint.prototype.validate = function validate() {
  59920. return this.curve.validate(this);
  59921. };
  59922. BaseCurve.prototype.decodePoint = function decodePoint(bytes, enc) {
  59923. bytes = utils.toArray(bytes, enc);
  59924. var len = this.p.byteLength();
  59925. // uncompressed, hybrid-odd, hybrid-even
  59926. if ((bytes[0] === 0x04 || bytes[0] === 0x06 || bytes[0] === 0x07) &&
  59927. bytes.length - 1 === 2 * len) {
  59928. if (bytes[0] === 0x06)
  59929. assert(bytes[bytes.length - 1] % 2 === 0);
  59930. else if (bytes[0] === 0x07)
  59931. assert(bytes[bytes.length - 1] % 2 === 1);
  59932. var res = this.point(bytes.slice(1, 1 + len),
  59933. bytes.slice(1 + len, 1 + 2 * len));
  59934. return res;
  59935. } else if ((bytes[0] === 0x02 || bytes[0] === 0x03) &&
  59936. bytes.length - 1 === len) {
  59937. return this.pointFromX(bytes.slice(1, 1 + len), bytes[0] === 0x03);
  59938. }
  59939. throw new Error('Unknown point format');
  59940. };
  59941. BasePoint.prototype.encodeCompressed = function encodeCompressed(enc) {
  59942. return this.encode(enc, true);
  59943. };
  59944. BasePoint.prototype._encode = function _encode(compact) {
  59945. var len = this.curve.p.byteLength();
  59946. var x = this.getX().toArray('be', len);
  59947. if (compact)
  59948. return [ this.getY().isEven() ? 0x02 : 0x03 ].concat(x);
  59949. return [ 0x04 ].concat(x, this.getY().toArray('be', len));
  59950. };
  59951. BasePoint.prototype.encode = function encode(enc, compact) {
  59952. return utils.encode(this._encode(compact), enc);
  59953. };
  59954. BasePoint.prototype.precompute = function precompute(power) {
  59955. if (this.precomputed)
  59956. return this;
  59957. var precomputed = {
  59958. doubles: null,
  59959. naf: null,
  59960. beta: null,
  59961. };
  59962. precomputed.naf = this._getNAFPoints(8);
  59963. precomputed.doubles = this._getDoubles(4, power);
  59964. precomputed.beta = this._getBeta();
  59965. this.precomputed = precomputed;
  59966. return this;
  59967. };
  59968. BasePoint.prototype._hasDoubles = function _hasDoubles(k) {
  59969. if (!this.precomputed)
  59970. return false;
  59971. var doubles = this.precomputed.doubles;
  59972. if (!doubles)
  59973. return false;
  59974. return doubles.points.length >= Math.ceil((k.bitLength() + 1) / doubles.step);
  59975. };
  59976. BasePoint.prototype._getDoubles = function _getDoubles(step, power) {
  59977. if (this.precomputed && this.precomputed.doubles)
  59978. return this.precomputed.doubles;
  59979. var doubles = [ this ];
  59980. var acc = this;
  59981. for (var i = 0; i < power; i += step) {
  59982. for (var j = 0; j < step; j++)
  59983. acc = acc.dbl();
  59984. doubles.push(acc);
  59985. }
  59986. return {
  59987. step: step,
  59988. points: doubles,
  59989. };
  59990. };
  59991. BasePoint.prototype._getNAFPoints = function _getNAFPoints(wnd) {
  59992. if (this.precomputed && this.precomputed.naf)
  59993. return this.precomputed.naf;
  59994. var res = [ this ];
  59995. var max = (1 << wnd) - 1;
  59996. var dbl = max === 1 ? null : this.dbl();
  59997. for (var i = 1; i < max; i++)
  59998. res[i] = res[i - 1].add(dbl);
  59999. return {
  60000. wnd: wnd,
  60001. points: res,
  60002. };
  60003. };
  60004. BasePoint.prototype._getBeta = function _getBeta() {
  60005. return null;
  60006. };
  60007. BasePoint.prototype.dblp = function dblp(k) {
  60008. var r = this;
  60009. for (var i = 0; i < k; i++)
  60010. r = r.dbl();
  60011. return r;
  60012. };
  60013. },{"../utils":768,"bn.js":769}],756:[function(_dereq_,module,exports){
  60014. 'use strict';
  60015. var utils = _dereq_('../utils');
  60016. var BN = _dereq_('bn.js');
  60017. var inherits = _dereq_('inherits');
  60018. var Base = _dereq_('./base');
  60019. var assert = utils.assert;
  60020. function EdwardsCurve(conf) {
  60021. // NOTE: Important as we are creating point in Base.call()
  60022. this.twisted = (conf.a | 0) !== 1;
  60023. this.mOneA = this.twisted && (conf.a | 0) === -1;
  60024. this.extended = this.mOneA;
  60025. Base.call(this, 'edwards', conf);
  60026. this.a = new BN(conf.a, 16).umod(this.red.m);
  60027. this.a = this.a.toRed(this.red);
  60028. this.c = new BN(conf.c, 16).toRed(this.red);
  60029. this.c2 = this.c.redSqr();
  60030. this.d = new BN(conf.d, 16).toRed(this.red);
  60031. this.dd = this.d.redAdd(this.d);
  60032. assert(!this.twisted || this.c.fromRed().cmpn(1) === 0);
  60033. this.oneC = (conf.c | 0) === 1;
  60034. }
  60035. inherits(EdwardsCurve, Base);
  60036. module.exports = EdwardsCurve;
  60037. EdwardsCurve.prototype._mulA = function _mulA(num) {
  60038. if (this.mOneA)
  60039. return num.redNeg();
  60040. else
  60041. return this.a.redMul(num);
  60042. };
  60043. EdwardsCurve.prototype._mulC = function _mulC(num) {
  60044. if (this.oneC)
  60045. return num;
  60046. else
  60047. return this.c.redMul(num);
  60048. };
  60049. // Just for compatibility with Short curve
  60050. EdwardsCurve.prototype.jpoint = function jpoint(x, y, z, t) {
  60051. return this.point(x, y, z, t);
  60052. };
  60053. EdwardsCurve.prototype.pointFromX = function pointFromX(x, odd) {
  60054. x = new BN(x, 16);
  60055. if (!x.red)
  60056. x = x.toRed(this.red);
  60057. var x2 = x.redSqr();
  60058. var rhs = this.c2.redSub(this.a.redMul(x2));
  60059. var lhs = this.one.redSub(this.c2.redMul(this.d).redMul(x2));
  60060. var y2 = rhs.redMul(lhs.redInvm());
  60061. var y = y2.redSqrt();
  60062. if (y.redSqr().redSub(y2).cmp(this.zero) !== 0)
  60063. throw new Error('invalid point');
  60064. var isOdd = y.fromRed().isOdd();
  60065. if (odd && !isOdd || !odd && isOdd)
  60066. y = y.redNeg();
  60067. return this.point(x, y);
  60068. };
  60069. EdwardsCurve.prototype.pointFromY = function pointFromY(y, odd) {
  60070. y = new BN(y, 16);
  60071. if (!y.red)
  60072. y = y.toRed(this.red);
  60073. // x^2 = (y^2 - c^2) / (c^2 d y^2 - a)
  60074. var y2 = y.redSqr();
  60075. var lhs = y2.redSub(this.c2);
  60076. var rhs = y2.redMul(this.d).redMul(this.c2).redSub(this.a);
  60077. var x2 = lhs.redMul(rhs.redInvm());
  60078. if (x2.cmp(this.zero) === 0) {
  60079. if (odd)
  60080. throw new Error('invalid point');
  60081. else
  60082. return this.point(this.zero, y);
  60083. }
  60084. var x = x2.redSqrt();
  60085. if (x.redSqr().redSub(x2).cmp(this.zero) !== 0)
  60086. throw new Error('invalid point');
  60087. if (x.fromRed().isOdd() !== odd)
  60088. x = x.redNeg();
  60089. return this.point(x, y);
  60090. };
  60091. EdwardsCurve.prototype.validate = function validate(point) {
  60092. if (point.isInfinity())
  60093. return true;
  60094. // Curve: A * X^2 + Y^2 = C^2 * (1 + D * X^2 * Y^2)
  60095. point.normalize();
  60096. var x2 = point.x.redSqr();
  60097. var y2 = point.y.redSqr();
  60098. var lhs = x2.redMul(this.a).redAdd(y2);
  60099. var rhs = this.c2.redMul(this.one.redAdd(this.d.redMul(x2).redMul(y2)));
  60100. return lhs.cmp(rhs) === 0;
  60101. };
  60102. function Point(curve, x, y, z, t) {
  60103. Base.BasePoint.call(this, curve, 'projective');
  60104. if (x === null && y === null && z === null) {
  60105. this.x = this.curve.zero;
  60106. this.y = this.curve.one;
  60107. this.z = this.curve.one;
  60108. this.t = this.curve.zero;
  60109. this.zOne = true;
  60110. } else {
  60111. this.x = new BN(x, 16);
  60112. this.y = new BN(y, 16);
  60113. this.z = z ? new BN(z, 16) : this.curve.one;
  60114. this.t = t && new BN(t, 16);
  60115. if (!this.x.red)
  60116. this.x = this.x.toRed(this.curve.red);
  60117. if (!this.y.red)
  60118. this.y = this.y.toRed(this.curve.red);
  60119. if (!this.z.red)
  60120. this.z = this.z.toRed(this.curve.red);
  60121. if (this.t && !this.t.red)
  60122. this.t = this.t.toRed(this.curve.red);
  60123. this.zOne = this.z === this.curve.one;
  60124. // Use extended coordinates
  60125. if (this.curve.extended && !this.t) {
  60126. this.t = this.x.redMul(this.y);
  60127. if (!this.zOne)
  60128. this.t = this.t.redMul(this.z.redInvm());
  60129. }
  60130. }
  60131. }
  60132. inherits(Point, Base.BasePoint);
  60133. EdwardsCurve.prototype.pointFromJSON = function pointFromJSON(obj) {
  60134. return Point.fromJSON(this, obj);
  60135. };
  60136. EdwardsCurve.prototype.point = function point(x, y, z, t) {
  60137. return new Point(this, x, y, z, t);
  60138. };
  60139. Point.fromJSON = function fromJSON(curve, obj) {
  60140. return new Point(curve, obj[0], obj[1], obj[2]);
  60141. };
  60142. Point.prototype.inspect = function inspect() {
  60143. if (this.isInfinity())
  60144. return '<EC Point Infinity>';
  60145. return '<EC Point x: ' + this.x.fromRed().toString(16, 2) +
  60146. ' y: ' + this.y.fromRed().toString(16, 2) +
  60147. ' z: ' + this.z.fromRed().toString(16, 2) + '>';
  60148. };
  60149. Point.prototype.isInfinity = function isInfinity() {
  60150. // XXX This code assumes that zero is always zero in red
  60151. return this.x.cmpn(0) === 0 &&
  60152. (this.y.cmp(this.z) === 0 ||
  60153. (this.zOne && this.y.cmp(this.curve.c) === 0));
  60154. };
  60155. Point.prototype._extDbl = function _extDbl() {
  60156. // hyperelliptic.org/EFD/g1p/auto-twisted-extended-1.html
  60157. // #doubling-dbl-2008-hwcd
  60158. // 4M + 4S
  60159. // A = X1^2
  60160. var a = this.x.redSqr();
  60161. // B = Y1^2
  60162. var b = this.y.redSqr();
  60163. // C = 2 * Z1^2
  60164. var c = this.z.redSqr();
  60165. c = c.redIAdd(c);
  60166. // D = a * A
  60167. var d = this.curve._mulA(a);
  60168. // E = (X1 + Y1)^2 - A - B
  60169. var e = this.x.redAdd(this.y).redSqr().redISub(a).redISub(b);
  60170. // G = D + B
  60171. var g = d.redAdd(b);
  60172. // F = G - C
  60173. var f = g.redSub(c);
  60174. // H = D - B
  60175. var h = d.redSub(b);
  60176. // X3 = E * F
  60177. var nx = e.redMul(f);
  60178. // Y3 = G * H
  60179. var ny = g.redMul(h);
  60180. // T3 = E * H
  60181. var nt = e.redMul(h);
  60182. // Z3 = F * G
  60183. var nz = f.redMul(g);
  60184. return this.curve.point(nx, ny, nz, nt);
  60185. };
  60186. Point.prototype._projDbl = function _projDbl() {
  60187. // hyperelliptic.org/EFD/g1p/auto-twisted-projective.html
  60188. // #doubling-dbl-2008-bbjlp
  60189. // #doubling-dbl-2007-bl
  60190. // and others
  60191. // Generally 3M + 4S or 2M + 4S
  60192. // B = (X1 + Y1)^2
  60193. var b = this.x.redAdd(this.y).redSqr();
  60194. // C = X1^2
  60195. var c = this.x.redSqr();
  60196. // D = Y1^2
  60197. var d = this.y.redSqr();
  60198. var nx;
  60199. var ny;
  60200. var nz;
  60201. var e;
  60202. var h;
  60203. var j;
  60204. if (this.curve.twisted) {
  60205. // E = a * C
  60206. e = this.curve._mulA(c);
  60207. // F = E + D
  60208. var f = e.redAdd(d);
  60209. if (this.zOne) {
  60210. // X3 = (B - C - D) * (F - 2)
  60211. nx = b.redSub(c).redSub(d).redMul(f.redSub(this.curve.two));
  60212. // Y3 = F * (E - D)
  60213. ny = f.redMul(e.redSub(d));
  60214. // Z3 = F^2 - 2 * F
  60215. nz = f.redSqr().redSub(f).redSub(f);
  60216. } else {
  60217. // H = Z1^2
  60218. h = this.z.redSqr();
  60219. // J = F - 2 * H
  60220. j = f.redSub(h).redISub(h);
  60221. // X3 = (B-C-D)*J
  60222. nx = b.redSub(c).redISub(d).redMul(j);
  60223. // Y3 = F * (E - D)
  60224. ny = f.redMul(e.redSub(d));
  60225. // Z3 = F * J
  60226. nz = f.redMul(j);
  60227. }
  60228. } else {
  60229. // E = C + D
  60230. e = c.redAdd(d);
  60231. // H = (c * Z1)^2
  60232. h = this.curve._mulC(this.z).redSqr();
  60233. // J = E - 2 * H
  60234. j = e.redSub(h).redSub(h);
  60235. // X3 = c * (B - E) * J
  60236. nx = this.curve._mulC(b.redISub(e)).redMul(j);
  60237. // Y3 = c * E * (C - D)
  60238. ny = this.curve._mulC(e).redMul(c.redISub(d));
  60239. // Z3 = E * J
  60240. nz = e.redMul(j);
  60241. }
  60242. return this.curve.point(nx, ny, nz);
  60243. };
  60244. Point.prototype.dbl = function dbl() {
  60245. if (this.isInfinity())
  60246. return this;
  60247. // Double in extended coordinates
  60248. if (this.curve.extended)
  60249. return this._extDbl();
  60250. else
  60251. return this._projDbl();
  60252. };
  60253. Point.prototype._extAdd = function _extAdd(p) {
  60254. // hyperelliptic.org/EFD/g1p/auto-twisted-extended-1.html
  60255. // #addition-add-2008-hwcd-3
  60256. // 8M
  60257. // A = (Y1 - X1) * (Y2 - X2)
  60258. var a = this.y.redSub(this.x).redMul(p.y.redSub(p.x));
  60259. // B = (Y1 + X1) * (Y2 + X2)
  60260. var b = this.y.redAdd(this.x).redMul(p.y.redAdd(p.x));
  60261. // C = T1 * k * T2
  60262. var c = this.t.redMul(this.curve.dd).redMul(p.t);
  60263. // D = Z1 * 2 * Z2
  60264. var d = this.z.redMul(p.z.redAdd(p.z));
  60265. // E = B - A
  60266. var e = b.redSub(a);
  60267. // F = D - C
  60268. var f = d.redSub(c);
  60269. // G = D + C
  60270. var g = d.redAdd(c);
  60271. // H = B + A
  60272. var h = b.redAdd(a);
  60273. // X3 = E * F
  60274. var nx = e.redMul(f);
  60275. // Y3 = G * H
  60276. var ny = g.redMul(h);
  60277. // T3 = E * H
  60278. var nt = e.redMul(h);
  60279. // Z3 = F * G
  60280. var nz = f.redMul(g);
  60281. return this.curve.point(nx, ny, nz, nt);
  60282. };
  60283. Point.prototype._projAdd = function _projAdd(p) {
  60284. // hyperelliptic.org/EFD/g1p/auto-twisted-projective.html
  60285. // #addition-add-2008-bbjlp
  60286. // #addition-add-2007-bl
  60287. // 10M + 1S
  60288. // A = Z1 * Z2
  60289. var a = this.z.redMul(p.z);
  60290. // B = A^2
  60291. var b = a.redSqr();
  60292. // C = X1 * X2
  60293. var c = this.x.redMul(p.x);
  60294. // D = Y1 * Y2
  60295. var d = this.y.redMul(p.y);
  60296. // E = d * C * D
  60297. var e = this.curve.d.redMul(c).redMul(d);
  60298. // F = B - E
  60299. var f = b.redSub(e);
  60300. // G = B + E
  60301. var g = b.redAdd(e);
  60302. // X3 = A * F * ((X1 + Y1) * (X2 + Y2) - C - D)
  60303. var tmp = this.x.redAdd(this.y).redMul(p.x.redAdd(p.y)).redISub(c).redISub(d);
  60304. var nx = a.redMul(f).redMul(tmp);
  60305. var ny;
  60306. var nz;
  60307. if (this.curve.twisted) {
  60308. // Y3 = A * G * (D - a * C)
  60309. ny = a.redMul(g).redMul(d.redSub(this.curve._mulA(c)));
  60310. // Z3 = F * G
  60311. nz = f.redMul(g);
  60312. } else {
  60313. // Y3 = A * G * (D - C)
  60314. ny = a.redMul(g).redMul(d.redSub(c));
  60315. // Z3 = c * F * G
  60316. nz = this.curve._mulC(f).redMul(g);
  60317. }
  60318. return this.curve.point(nx, ny, nz);
  60319. };
  60320. Point.prototype.add = function add(p) {
  60321. if (this.isInfinity())
  60322. return p;
  60323. if (p.isInfinity())
  60324. return this;
  60325. if (this.curve.extended)
  60326. return this._extAdd(p);
  60327. else
  60328. return this._projAdd(p);
  60329. };
  60330. Point.prototype.mul = function mul(k) {
  60331. if (this._hasDoubles(k))
  60332. return this.curve._fixedNafMul(this, k);
  60333. else
  60334. return this.curve._wnafMul(this, k);
  60335. };
  60336. Point.prototype.mulAdd = function mulAdd(k1, p, k2) {
  60337. return this.curve._wnafMulAdd(1, [ this, p ], [ k1, k2 ], 2, false);
  60338. };
  60339. Point.prototype.jmulAdd = function jmulAdd(k1, p, k2) {
  60340. return this.curve._wnafMulAdd(1, [ this, p ], [ k1, k2 ], 2, true);
  60341. };
  60342. Point.prototype.normalize = function normalize() {
  60343. if (this.zOne)
  60344. return this;
  60345. // Normalize coordinates
  60346. var zi = this.z.redInvm();
  60347. this.x = this.x.redMul(zi);
  60348. this.y = this.y.redMul(zi);
  60349. if (this.t)
  60350. this.t = this.t.redMul(zi);
  60351. this.z = this.curve.one;
  60352. this.zOne = true;
  60353. return this;
  60354. };
  60355. Point.prototype.neg = function neg() {
  60356. return this.curve.point(this.x.redNeg(),
  60357. this.y,
  60358. this.z,
  60359. this.t && this.t.redNeg());
  60360. };
  60361. Point.prototype.getX = function getX() {
  60362. this.normalize();
  60363. return this.x.fromRed();
  60364. };
  60365. Point.prototype.getY = function getY() {
  60366. this.normalize();
  60367. return this.y.fromRed();
  60368. };
  60369. Point.prototype.eq = function eq(other) {
  60370. return this === other ||
  60371. this.getX().cmp(other.getX()) === 0 &&
  60372. this.getY().cmp(other.getY()) === 0;
  60373. };
  60374. Point.prototype.eqXToP = function eqXToP(x) {
  60375. var rx = x.toRed(this.curve.red).redMul(this.z);
  60376. if (this.x.cmp(rx) === 0)
  60377. return true;
  60378. var xc = x.clone();
  60379. var t = this.curve.redN.redMul(this.z);
  60380. for (;;) {
  60381. xc.iadd(this.curve.n);
  60382. if (xc.cmp(this.curve.p) >= 0)
  60383. return false;
  60384. rx.redIAdd(t);
  60385. if (this.x.cmp(rx) === 0)
  60386. return true;
  60387. }
  60388. };
  60389. // Compatibility with BaseCurve
  60390. Point.prototype.toP = Point.prototype.normalize;
  60391. Point.prototype.mixedAdd = Point.prototype.add;
  60392. },{"../utils":768,"./base":755,"bn.js":769,"inherits":789}],757:[function(_dereq_,module,exports){
  60393. 'use strict';
  60394. var curve = exports;
  60395. curve.base = _dereq_('./base');
  60396. curve.short = _dereq_('./short');
  60397. curve.mont = _dereq_('./mont');
  60398. curve.edwards = _dereq_('./edwards');
  60399. },{"./base":755,"./edwards":756,"./mont":758,"./short":759}],758:[function(_dereq_,module,exports){
  60400. 'use strict';
  60401. var BN = _dereq_('bn.js');
  60402. var inherits = _dereq_('inherits');
  60403. var Base = _dereq_('./base');
  60404. var utils = _dereq_('../utils');
  60405. function MontCurve(conf) {
  60406. Base.call(this, 'mont', conf);
  60407. this.a = new BN(conf.a, 16).toRed(this.red);
  60408. this.b = new BN(conf.b, 16).toRed(this.red);
  60409. this.i4 = new BN(4).toRed(this.red).redInvm();
  60410. this.two = new BN(2).toRed(this.red);
  60411. this.a24 = this.i4.redMul(this.a.redAdd(this.two));
  60412. }
  60413. inherits(MontCurve, Base);
  60414. module.exports = MontCurve;
  60415. MontCurve.prototype.validate = function validate(point) {
  60416. var x = point.normalize().x;
  60417. var x2 = x.redSqr();
  60418. var rhs = x2.redMul(x).redAdd(x2.redMul(this.a)).redAdd(x);
  60419. var y = rhs.redSqrt();
  60420. return y.redSqr().cmp(rhs) === 0;
  60421. };
  60422. function Point(curve, x, z) {
  60423. Base.BasePoint.call(this, curve, 'projective');
  60424. if (x === null && z === null) {
  60425. this.x = this.curve.one;
  60426. this.z = this.curve.zero;
  60427. } else {
  60428. this.x = new BN(x, 16);
  60429. this.z = new BN(z, 16);
  60430. if (!this.x.red)
  60431. this.x = this.x.toRed(this.curve.red);
  60432. if (!this.z.red)
  60433. this.z = this.z.toRed(this.curve.red);
  60434. }
  60435. }
  60436. inherits(Point, Base.BasePoint);
  60437. MontCurve.prototype.decodePoint = function decodePoint(bytes, enc) {
  60438. return this.point(utils.toArray(bytes, enc), 1);
  60439. };
  60440. MontCurve.prototype.point = function point(x, z) {
  60441. return new Point(this, x, z);
  60442. };
  60443. MontCurve.prototype.pointFromJSON = function pointFromJSON(obj) {
  60444. return Point.fromJSON(this, obj);
  60445. };
  60446. Point.prototype.precompute = function precompute() {
  60447. // No-op
  60448. };
  60449. Point.prototype._encode = function _encode() {
  60450. return this.getX().toArray('be', this.curve.p.byteLength());
  60451. };
  60452. Point.fromJSON = function fromJSON(curve, obj) {
  60453. return new Point(curve, obj[0], obj[1] || curve.one);
  60454. };
  60455. Point.prototype.inspect = function inspect() {
  60456. if (this.isInfinity())
  60457. return '<EC Point Infinity>';
  60458. return '<EC Point x: ' + this.x.fromRed().toString(16, 2) +
  60459. ' z: ' + this.z.fromRed().toString(16, 2) + '>';
  60460. };
  60461. Point.prototype.isInfinity = function isInfinity() {
  60462. // XXX This code assumes that zero is always zero in red
  60463. return this.z.cmpn(0) === 0;
  60464. };
  60465. Point.prototype.dbl = function dbl() {
  60466. // http://hyperelliptic.org/EFD/g1p/auto-montgom-xz.html#doubling-dbl-1987-m-3
  60467. // 2M + 2S + 4A
  60468. // A = X1 + Z1
  60469. var a = this.x.redAdd(this.z);
  60470. // AA = A^2
  60471. var aa = a.redSqr();
  60472. // B = X1 - Z1
  60473. var b = this.x.redSub(this.z);
  60474. // BB = B^2
  60475. var bb = b.redSqr();
  60476. // C = AA - BB
  60477. var c = aa.redSub(bb);
  60478. // X3 = AA * BB
  60479. var nx = aa.redMul(bb);
  60480. // Z3 = C * (BB + A24 * C)
  60481. var nz = c.redMul(bb.redAdd(this.curve.a24.redMul(c)));
  60482. return this.curve.point(nx, nz);
  60483. };
  60484. Point.prototype.add = function add() {
  60485. throw new Error('Not supported on Montgomery curve');
  60486. };
  60487. Point.prototype.diffAdd = function diffAdd(p, diff) {
  60488. // http://hyperelliptic.org/EFD/g1p/auto-montgom-xz.html#diffadd-dadd-1987-m-3
  60489. // 4M + 2S + 6A
  60490. // A = X2 + Z2
  60491. var a = this.x.redAdd(this.z);
  60492. // B = X2 - Z2
  60493. var b = this.x.redSub(this.z);
  60494. // C = X3 + Z3
  60495. var c = p.x.redAdd(p.z);
  60496. // D = X3 - Z3
  60497. var d = p.x.redSub(p.z);
  60498. // DA = D * A
  60499. var da = d.redMul(a);
  60500. // CB = C * B
  60501. var cb = c.redMul(b);
  60502. // X5 = Z1 * (DA + CB)^2
  60503. var nx = diff.z.redMul(da.redAdd(cb).redSqr());
  60504. // Z5 = X1 * (DA - CB)^2
  60505. var nz = diff.x.redMul(da.redISub(cb).redSqr());
  60506. return this.curve.point(nx, nz);
  60507. };
  60508. Point.prototype.mul = function mul(k) {
  60509. var t = k.clone();
  60510. var a = this; // (N / 2) * Q + Q
  60511. var b = this.curve.point(null, null); // (N / 2) * Q
  60512. var c = this; // Q
  60513. for (var bits = []; t.cmpn(0) !== 0; t.iushrn(1))
  60514. bits.push(t.andln(1));
  60515. for (var i = bits.length - 1; i >= 0; i--) {
  60516. if (bits[i] === 0) {
  60517. // N * Q + Q = ((N / 2) * Q + Q)) + (N / 2) * Q
  60518. a = a.diffAdd(b, c);
  60519. // N * Q = 2 * ((N / 2) * Q + Q))
  60520. b = b.dbl();
  60521. } else {
  60522. // N * Q = ((N / 2) * Q + Q) + ((N / 2) * Q)
  60523. b = a.diffAdd(b, c);
  60524. // N * Q + Q = 2 * ((N / 2) * Q + Q)
  60525. a = a.dbl();
  60526. }
  60527. }
  60528. return b;
  60529. };
  60530. Point.prototype.mulAdd = function mulAdd() {
  60531. throw new Error('Not supported on Montgomery curve');
  60532. };
  60533. Point.prototype.jumlAdd = function jumlAdd() {
  60534. throw new Error('Not supported on Montgomery curve');
  60535. };
  60536. Point.prototype.eq = function eq(other) {
  60537. return this.getX().cmp(other.getX()) === 0;
  60538. };
  60539. Point.prototype.normalize = function normalize() {
  60540. this.x = this.x.redMul(this.z.redInvm());
  60541. this.z = this.curve.one;
  60542. return this;
  60543. };
  60544. Point.prototype.getX = function getX() {
  60545. // Normalize coordinates
  60546. this.normalize();
  60547. return this.x.fromRed();
  60548. };
  60549. },{"../utils":768,"./base":755,"bn.js":769,"inherits":789}],759:[function(_dereq_,module,exports){
  60550. 'use strict';
  60551. var utils = _dereq_('../utils');
  60552. var BN = _dereq_('bn.js');
  60553. var inherits = _dereq_('inherits');
  60554. var Base = _dereq_('./base');
  60555. var assert = utils.assert;
  60556. function ShortCurve(conf) {
  60557. Base.call(this, 'short', conf);
  60558. this.a = new BN(conf.a, 16).toRed(this.red);
  60559. this.b = new BN(conf.b, 16).toRed(this.red);
  60560. this.tinv = this.two.redInvm();
  60561. this.zeroA = this.a.fromRed().cmpn(0) === 0;
  60562. this.threeA = this.a.fromRed().sub(this.p).cmpn(-3) === 0;
  60563. // If the curve is endomorphic, precalculate beta and lambda
  60564. this.endo = this._getEndomorphism(conf);
  60565. this._endoWnafT1 = new Array(4);
  60566. this._endoWnafT2 = new Array(4);
  60567. }
  60568. inherits(ShortCurve, Base);
  60569. module.exports = ShortCurve;
  60570. ShortCurve.prototype._getEndomorphism = function _getEndomorphism(conf) {
  60571. // No efficient endomorphism
  60572. if (!this.zeroA || !this.g || !this.n || this.p.modn(3) !== 1)
  60573. return;
  60574. // Compute beta and lambda, that lambda * P = (beta * Px; Py)
  60575. var beta;
  60576. var lambda;
  60577. if (conf.beta) {
  60578. beta = new BN(conf.beta, 16).toRed(this.red);
  60579. } else {
  60580. var betas = this._getEndoRoots(this.p);
  60581. // Choose the smallest beta
  60582. beta = betas[0].cmp(betas[1]) < 0 ? betas[0] : betas[1];
  60583. beta = beta.toRed(this.red);
  60584. }
  60585. if (conf.lambda) {
  60586. lambda = new BN(conf.lambda, 16);
  60587. } else {
  60588. // Choose the lambda that is matching selected beta
  60589. var lambdas = this._getEndoRoots(this.n);
  60590. if (this.g.mul(lambdas[0]).x.cmp(this.g.x.redMul(beta)) === 0) {
  60591. lambda = lambdas[0];
  60592. } else {
  60593. lambda = lambdas[1];
  60594. assert(this.g.mul(lambda).x.cmp(this.g.x.redMul(beta)) === 0);
  60595. }
  60596. }
  60597. // Get basis vectors, used for balanced length-two representation
  60598. var basis;
  60599. if (conf.basis) {
  60600. basis = conf.basis.map(function(vec) {
  60601. return {
  60602. a: new BN(vec.a, 16),
  60603. b: new BN(vec.b, 16),
  60604. };
  60605. });
  60606. } else {
  60607. basis = this._getEndoBasis(lambda);
  60608. }
  60609. return {
  60610. beta: beta,
  60611. lambda: lambda,
  60612. basis: basis,
  60613. };
  60614. };
  60615. ShortCurve.prototype._getEndoRoots = function _getEndoRoots(num) {
  60616. // Find roots of for x^2 + x + 1 in F
  60617. // Root = (-1 +- Sqrt(-3)) / 2
  60618. //
  60619. var red = num === this.p ? this.red : BN.mont(num);
  60620. var tinv = new BN(2).toRed(red).redInvm();
  60621. var ntinv = tinv.redNeg();
  60622. var s = new BN(3).toRed(red).redNeg().redSqrt().redMul(tinv);
  60623. var l1 = ntinv.redAdd(s).fromRed();
  60624. var l2 = ntinv.redSub(s).fromRed();
  60625. return [ l1, l2 ];
  60626. };
  60627. ShortCurve.prototype._getEndoBasis = function _getEndoBasis(lambda) {
  60628. // aprxSqrt >= sqrt(this.n)
  60629. var aprxSqrt = this.n.ushrn(Math.floor(this.n.bitLength() / 2));
  60630. // 3.74
  60631. // Run EGCD, until r(L + 1) < aprxSqrt
  60632. var u = lambda;
  60633. var v = this.n.clone();
  60634. var x1 = new BN(1);
  60635. var y1 = new BN(0);
  60636. var x2 = new BN(0);
  60637. var y2 = new BN(1);
  60638. // NOTE: all vectors are roots of: a + b * lambda = 0 (mod n)
  60639. var a0;
  60640. var b0;
  60641. // First vector
  60642. var a1;
  60643. var b1;
  60644. // Second vector
  60645. var a2;
  60646. var b2;
  60647. var prevR;
  60648. var i = 0;
  60649. var r;
  60650. var x;
  60651. while (u.cmpn(0) !== 0) {
  60652. var q = v.div(u);
  60653. r = v.sub(q.mul(u));
  60654. x = x2.sub(q.mul(x1));
  60655. var y = y2.sub(q.mul(y1));
  60656. if (!a1 && r.cmp(aprxSqrt) < 0) {
  60657. a0 = prevR.neg();
  60658. b0 = x1;
  60659. a1 = r.neg();
  60660. b1 = x;
  60661. } else if (a1 && ++i === 2) {
  60662. break;
  60663. }
  60664. prevR = r;
  60665. v = u;
  60666. u = r;
  60667. x2 = x1;
  60668. x1 = x;
  60669. y2 = y1;
  60670. y1 = y;
  60671. }
  60672. a2 = r.neg();
  60673. b2 = x;
  60674. var len1 = a1.sqr().add(b1.sqr());
  60675. var len2 = a2.sqr().add(b2.sqr());
  60676. if (len2.cmp(len1) >= 0) {
  60677. a2 = a0;
  60678. b2 = b0;
  60679. }
  60680. // Normalize signs
  60681. if (a1.negative) {
  60682. a1 = a1.neg();
  60683. b1 = b1.neg();
  60684. }
  60685. if (a2.negative) {
  60686. a2 = a2.neg();
  60687. b2 = b2.neg();
  60688. }
  60689. return [
  60690. { a: a1, b: b1 },
  60691. { a: a2, b: b2 },
  60692. ];
  60693. };
  60694. ShortCurve.prototype._endoSplit = function _endoSplit(k) {
  60695. var basis = this.endo.basis;
  60696. var v1 = basis[0];
  60697. var v2 = basis[1];
  60698. var c1 = v2.b.mul(k).divRound(this.n);
  60699. var c2 = v1.b.neg().mul(k).divRound(this.n);
  60700. var p1 = c1.mul(v1.a);
  60701. var p2 = c2.mul(v2.a);
  60702. var q1 = c1.mul(v1.b);
  60703. var q2 = c2.mul(v2.b);
  60704. // Calculate answer
  60705. var k1 = k.sub(p1).sub(p2);
  60706. var k2 = q1.add(q2).neg();
  60707. return { k1: k1, k2: k2 };
  60708. };
  60709. ShortCurve.prototype.pointFromX = function pointFromX(x, odd) {
  60710. x = new BN(x, 16);
  60711. if (!x.red)
  60712. x = x.toRed(this.red);
  60713. var y2 = x.redSqr().redMul(x).redIAdd(x.redMul(this.a)).redIAdd(this.b);
  60714. var y = y2.redSqrt();
  60715. if (y.redSqr().redSub(y2).cmp(this.zero) !== 0)
  60716. throw new Error('invalid point');
  60717. // XXX Is there any way to tell if the number is odd without converting it
  60718. // to non-red form?
  60719. var isOdd = y.fromRed().isOdd();
  60720. if (odd && !isOdd || !odd && isOdd)
  60721. y = y.redNeg();
  60722. return this.point(x, y);
  60723. };
  60724. ShortCurve.prototype.validate = function validate(point) {
  60725. if (point.inf)
  60726. return true;
  60727. var x = point.x;
  60728. var y = point.y;
  60729. var ax = this.a.redMul(x);
  60730. var rhs = x.redSqr().redMul(x).redIAdd(ax).redIAdd(this.b);
  60731. return y.redSqr().redISub(rhs).cmpn(0) === 0;
  60732. };
  60733. ShortCurve.prototype._endoWnafMulAdd =
  60734. function _endoWnafMulAdd(points, coeffs, jacobianResult) {
  60735. var npoints = this._endoWnafT1;
  60736. var ncoeffs = this._endoWnafT2;
  60737. for (var i = 0; i < points.length; i++) {
  60738. var split = this._endoSplit(coeffs[i]);
  60739. var p = points[i];
  60740. var beta = p._getBeta();
  60741. if (split.k1.negative) {
  60742. split.k1.ineg();
  60743. p = p.neg(true);
  60744. }
  60745. if (split.k2.negative) {
  60746. split.k2.ineg();
  60747. beta = beta.neg(true);
  60748. }
  60749. npoints[i * 2] = p;
  60750. npoints[i * 2 + 1] = beta;
  60751. ncoeffs[i * 2] = split.k1;
  60752. ncoeffs[i * 2 + 1] = split.k2;
  60753. }
  60754. var res = this._wnafMulAdd(1, npoints, ncoeffs, i * 2, jacobianResult);
  60755. // Clean-up references to points and coefficients
  60756. for (var j = 0; j < i * 2; j++) {
  60757. npoints[j] = null;
  60758. ncoeffs[j] = null;
  60759. }
  60760. return res;
  60761. };
  60762. function Point(curve, x, y, isRed) {
  60763. Base.BasePoint.call(this, curve, 'affine');
  60764. if (x === null && y === null) {
  60765. this.x = null;
  60766. this.y = null;
  60767. this.inf = true;
  60768. } else {
  60769. this.x = new BN(x, 16);
  60770. this.y = new BN(y, 16);
  60771. // Force redgomery representation when loading from JSON
  60772. if (isRed) {
  60773. this.x.forceRed(this.curve.red);
  60774. this.y.forceRed(this.curve.red);
  60775. }
  60776. if (!this.x.red)
  60777. this.x = this.x.toRed(this.curve.red);
  60778. if (!this.y.red)
  60779. this.y = this.y.toRed(this.curve.red);
  60780. this.inf = false;
  60781. }
  60782. }
  60783. inherits(Point, Base.BasePoint);
  60784. ShortCurve.prototype.point = function point(x, y, isRed) {
  60785. return new Point(this, x, y, isRed);
  60786. };
  60787. ShortCurve.prototype.pointFromJSON = function pointFromJSON(obj, red) {
  60788. return Point.fromJSON(this, obj, red);
  60789. };
  60790. Point.prototype._getBeta = function _getBeta() {
  60791. if (!this.curve.endo)
  60792. return;
  60793. var pre = this.precomputed;
  60794. if (pre && pre.beta)
  60795. return pre.beta;
  60796. var beta = this.curve.point(this.x.redMul(this.curve.endo.beta), this.y);
  60797. if (pre) {
  60798. var curve = this.curve;
  60799. var endoMul = function(p) {
  60800. return curve.point(p.x.redMul(curve.endo.beta), p.y);
  60801. };
  60802. pre.beta = beta;
  60803. beta.precomputed = {
  60804. beta: null,
  60805. naf: pre.naf && {
  60806. wnd: pre.naf.wnd,
  60807. points: pre.naf.points.map(endoMul),
  60808. },
  60809. doubles: pre.doubles && {
  60810. step: pre.doubles.step,
  60811. points: pre.doubles.points.map(endoMul),
  60812. },
  60813. };
  60814. }
  60815. return beta;
  60816. };
  60817. Point.prototype.toJSON = function toJSON() {
  60818. if (!this.precomputed)
  60819. return [ this.x, this.y ];
  60820. return [ this.x, this.y, this.precomputed && {
  60821. doubles: this.precomputed.doubles && {
  60822. step: this.precomputed.doubles.step,
  60823. points: this.precomputed.doubles.points.slice(1),
  60824. },
  60825. naf: this.precomputed.naf && {
  60826. wnd: this.precomputed.naf.wnd,
  60827. points: this.precomputed.naf.points.slice(1),
  60828. },
  60829. } ];
  60830. };
  60831. Point.fromJSON = function fromJSON(curve, obj, red) {
  60832. if (typeof obj === 'string')
  60833. obj = JSON.parse(obj);
  60834. var res = curve.point(obj[0], obj[1], red);
  60835. if (!obj[2])
  60836. return res;
  60837. function obj2point(obj) {
  60838. return curve.point(obj[0], obj[1], red);
  60839. }
  60840. var pre = obj[2];
  60841. res.precomputed = {
  60842. beta: null,
  60843. doubles: pre.doubles && {
  60844. step: pre.doubles.step,
  60845. points: [ res ].concat(pre.doubles.points.map(obj2point)),
  60846. },
  60847. naf: pre.naf && {
  60848. wnd: pre.naf.wnd,
  60849. points: [ res ].concat(pre.naf.points.map(obj2point)),
  60850. },
  60851. };
  60852. return res;
  60853. };
  60854. Point.prototype.inspect = function inspect() {
  60855. if (this.isInfinity())
  60856. return '<EC Point Infinity>';
  60857. return '<EC Point x: ' + this.x.fromRed().toString(16, 2) +
  60858. ' y: ' + this.y.fromRed().toString(16, 2) + '>';
  60859. };
  60860. Point.prototype.isInfinity = function isInfinity() {
  60861. return this.inf;
  60862. };
  60863. Point.prototype.add = function add(p) {
  60864. // O + P = P
  60865. if (this.inf)
  60866. return p;
  60867. // P + O = P
  60868. if (p.inf)
  60869. return this;
  60870. // P + P = 2P
  60871. if (this.eq(p))
  60872. return this.dbl();
  60873. // P + (-P) = O
  60874. if (this.neg().eq(p))
  60875. return this.curve.point(null, null);
  60876. // P + Q = O
  60877. if (this.x.cmp(p.x) === 0)
  60878. return this.curve.point(null, null);
  60879. var c = this.y.redSub(p.y);
  60880. if (c.cmpn(0) !== 0)
  60881. c = c.redMul(this.x.redSub(p.x).redInvm());
  60882. var nx = c.redSqr().redISub(this.x).redISub(p.x);
  60883. var ny = c.redMul(this.x.redSub(nx)).redISub(this.y);
  60884. return this.curve.point(nx, ny);
  60885. };
  60886. Point.prototype.dbl = function dbl() {
  60887. if (this.inf)
  60888. return this;
  60889. // 2P = O
  60890. var ys1 = this.y.redAdd(this.y);
  60891. if (ys1.cmpn(0) === 0)
  60892. return this.curve.point(null, null);
  60893. var a = this.curve.a;
  60894. var x2 = this.x.redSqr();
  60895. var dyinv = ys1.redInvm();
  60896. var c = x2.redAdd(x2).redIAdd(x2).redIAdd(a).redMul(dyinv);
  60897. var nx = c.redSqr().redISub(this.x.redAdd(this.x));
  60898. var ny = c.redMul(this.x.redSub(nx)).redISub(this.y);
  60899. return this.curve.point(nx, ny);
  60900. };
  60901. Point.prototype.getX = function getX() {
  60902. return this.x.fromRed();
  60903. };
  60904. Point.prototype.getY = function getY() {
  60905. return this.y.fromRed();
  60906. };
  60907. Point.prototype.mul = function mul(k) {
  60908. k = new BN(k, 16);
  60909. if (this.isInfinity())
  60910. return this;
  60911. else if (this._hasDoubles(k))
  60912. return this.curve._fixedNafMul(this, k);
  60913. else if (this.curve.endo)
  60914. return this.curve._endoWnafMulAdd([ this ], [ k ]);
  60915. else
  60916. return this.curve._wnafMul(this, k);
  60917. };
  60918. Point.prototype.mulAdd = function mulAdd(k1, p2, k2) {
  60919. var points = [ this, p2 ];
  60920. var coeffs = [ k1, k2 ];
  60921. if (this.curve.endo)
  60922. return this.curve._endoWnafMulAdd(points, coeffs);
  60923. else
  60924. return this.curve._wnafMulAdd(1, points, coeffs, 2);
  60925. };
  60926. Point.prototype.jmulAdd = function jmulAdd(k1, p2, k2) {
  60927. var points = [ this, p2 ];
  60928. var coeffs = [ k1, k2 ];
  60929. if (this.curve.endo)
  60930. return this.curve._endoWnafMulAdd(points, coeffs, true);
  60931. else
  60932. return this.curve._wnafMulAdd(1, points, coeffs, 2, true);
  60933. };
  60934. Point.prototype.eq = function eq(p) {
  60935. return this === p ||
  60936. this.inf === p.inf &&
  60937. (this.inf || this.x.cmp(p.x) === 0 && this.y.cmp(p.y) === 0);
  60938. };
  60939. Point.prototype.neg = function neg(_precompute) {
  60940. if (this.inf)
  60941. return this;
  60942. var res = this.curve.point(this.x, this.y.redNeg());
  60943. if (_precompute && this.precomputed) {
  60944. var pre = this.precomputed;
  60945. var negate = function(p) {
  60946. return p.neg();
  60947. };
  60948. res.precomputed = {
  60949. naf: pre.naf && {
  60950. wnd: pre.naf.wnd,
  60951. points: pre.naf.points.map(negate),
  60952. },
  60953. doubles: pre.doubles && {
  60954. step: pre.doubles.step,
  60955. points: pre.doubles.points.map(negate),
  60956. },
  60957. };
  60958. }
  60959. return res;
  60960. };
  60961. Point.prototype.toJ = function toJ() {
  60962. if (this.inf)
  60963. return this.curve.jpoint(null, null, null);
  60964. var res = this.curve.jpoint(this.x, this.y, this.curve.one);
  60965. return res;
  60966. };
  60967. function JPoint(curve, x, y, z) {
  60968. Base.BasePoint.call(this, curve, 'jacobian');
  60969. if (x === null && y === null && z === null) {
  60970. this.x = this.curve.one;
  60971. this.y = this.curve.one;
  60972. this.z = new BN(0);
  60973. } else {
  60974. this.x = new BN(x, 16);
  60975. this.y = new BN(y, 16);
  60976. this.z = new BN(z, 16);
  60977. }
  60978. if (!this.x.red)
  60979. this.x = this.x.toRed(this.curve.red);
  60980. if (!this.y.red)
  60981. this.y = this.y.toRed(this.curve.red);
  60982. if (!this.z.red)
  60983. this.z = this.z.toRed(this.curve.red);
  60984. this.zOne = this.z === this.curve.one;
  60985. }
  60986. inherits(JPoint, Base.BasePoint);
  60987. ShortCurve.prototype.jpoint = function jpoint(x, y, z) {
  60988. return new JPoint(this, x, y, z);
  60989. };
  60990. JPoint.prototype.toP = function toP() {
  60991. if (this.isInfinity())
  60992. return this.curve.point(null, null);
  60993. var zinv = this.z.redInvm();
  60994. var zinv2 = zinv.redSqr();
  60995. var ax = this.x.redMul(zinv2);
  60996. var ay = this.y.redMul(zinv2).redMul(zinv);
  60997. return this.curve.point(ax, ay);
  60998. };
  60999. JPoint.prototype.neg = function neg() {
  61000. return this.curve.jpoint(this.x, this.y.redNeg(), this.z);
  61001. };
  61002. JPoint.prototype.add = function add(p) {
  61003. // O + P = P
  61004. if (this.isInfinity())
  61005. return p;
  61006. // P + O = P
  61007. if (p.isInfinity())
  61008. return this;
  61009. // 12M + 4S + 7A
  61010. var pz2 = p.z.redSqr();
  61011. var z2 = this.z.redSqr();
  61012. var u1 = this.x.redMul(pz2);
  61013. var u2 = p.x.redMul(z2);
  61014. var s1 = this.y.redMul(pz2.redMul(p.z));
  61015. var s2 = p.y.redMul(z2.redMul(this.z));
  61016. var h = u1.redSub(u2);
  61017. var r = s1.redSub(s2);
  61018. if (h.cmpn(0) === 0) {
  61019. if (r.cmpn(0) !== 0)
  61020. return this.curve.jpoint(null, null, null);
  61021. else
  61022. return this.dbl();
  61023. }
  61024. var h2 = h.redSqr();
  61025. var h3 = h2.redMul(h);
  61026. var v = u1.redMul(h2);
  61027. var nx = r.redSqr().redIAdd(h3).redISub(v).redISub(v);
  61028. var ny = r.redMul(v.redISub(nx)).redISub(s1.redMul(h3));
  61029. var nz = this.z.redMul(p.z).redMul(h);
  61030. return this.curve.jpoint(nx, ny, nz);
  61031. };
  61032. JPoint.prototype.mixedAdd = function mixedAdd(p) {
  61033. // O + P = P
  61034. if (this.isInfinity())
  61035. return p.toJ();
  61036. // P + O = P
  61037. if (p.isInfinity())
  61038. return this;
  61039. // 8M + 3S + 7A
  61040. var z2 = this.z.redSqr();
  61041. var u1 = this.x;
  61042. var u2 = p.x.redMul(z2);
  61043. var s1 = this.y;
  61044. var s2 = p.y.redMul(z2).redMul(this.z);
  61045. var h = u1.redSub(u2);
  61046. var r = s1.redSub(s2);
  61047. if (h.cmpn(0) === 0) {
  61048. if (r.cmpn(0) !== 0)
  61049. return this.curve.jpoint(null, null, null);
  61050. else
  61051. return this.dbl();
  61052. }
  61053. var h2 = h.redSqr();
  61054. var h3 = h2.redMul(h);
  61055. var v = u1.redMul(h2);
  61056. var nx = r.redSqr().redIAdd(h3).redISub(v).redISub(v);
  61057. var ny = r.redMul(v.redISub(nx)).redISub(s1.redMul(h3));
  61058. var nz = this.z.redMul(h);
  61059. return this.curve.jpoint(nx, ny, nz);
  61060. };
  61061. JPoint.prototype.dblp = function dblp(pow) {
  61062. if (pow === 0)
  61063. return this;
  61064. if (this.isInfinity())
  61065. return this;
  61066. if (!pow)
  61067. return this.dbl();
  61068. var i;
  61069. if (this.curve.zeroA || this.curve.threeA) {
  61070. var r = this;
  61071. for (i = 0; i < pow; i++)
  61072. r = r.dbl();
  61073. return r;
  61074. }
  61075. // 1M + 2S + 1A + N * (4S + 5M + 8A)
  61076. // N = 1 => 6M + 6S + 9A
  61077. var a = this.curve.a;
  61078. var tinv = this.curve.tinv;
  61079. var jx = this.x;
  61080. var jy = this.y;
  61081. var jz = this.z;
  61082. var jz4 = jz.redSqr().redSqr();
  61083. // Reuse results
  61084. var jyd = jy.redAdd(jy);
  61085. for (i = 0; i < pow; i++) {
  61086. var jx2 = jx.redSqr();
  61087. var jyd2 = jyd.redSqr();
  61088. var jyd4 = jyd2.redSqr();
  61089. var c = jx2.redAdd(jx2).redIAdd(jx2).redIAdd(a.redMul(jz4));
  61090. var t1 = jx.redMul(jyd2);
  61091. var nx = c.redSqr().redISub(t1.redAdd(t1));
  61092. var t2 = t1.redISub(nx);
  61093. var dny = c.redMul(t2);
  61094. dny = dny.redIAdd(dny).redISub(jyd4);
  61095. var nz = jyd.redMul(jz);
  61096. if (i + 1 < pow)
  61097. jz4 = jz4.redMul(jyd4);
  61098. jx = nx;
  61099. jz = nz;
  61100. jyd = dny;
  61101. }
  61102. return this.curve.jpoint(jx, jyd.redMul(tinv), jz);
  61103. };
  61104. JPoint.prototype.dbl = function dbl() {
  61105. if (this.isInfinity())
  61106. return this;
  61107. if (this.curve.zeroA)
  61108. return this._zeroDbl();
  61109. else if (this.curve.threeA)
  61110. return this._threeDbl();
  61111. else
  61112. return this._dbl();
  61113. };
  61114. JPoint.prototype._zeroDbl = function _zeroDbl() {
  61115. var nx;
  61116. var ny;
  61117. var nz;
  61118. // Z = 1
  61119. if (this.zOne) {
  61120. // hyperelliptic.org/EFD/g1p/auto-shortw-jacobian-0.html
  61121. // #doubling-mdbl-2007-bl
  61122. // 1M + 5S + 14A
  61123. // XX = X1^2
  61124. var xx = this.x.redSqr();
  61125. // YY = Y1^2
  61126. var yy = this.y.redSqr();
  61127. // YYYY = YY^2
  61128. var yyyy = yy.redSqr();
  61129. // S = 2 * ((X1 + YY)^2 - XX - YYYY)
  61130. var s = this.x.redAdd(yy).redSqr().redISub(xx).redISub(yyyy);
  61131. s = s.redIAdd(s);
  61132. // M = 3 * XX + a; a = 0
  61133. var m = xx.redAdd(xx).redIAdd(xx);
  61134. // T = M ^ 2 - 2*S
  61135. var t = m.redSqr().redISub(s).redISub(s);
  61136. // 8 * YYYY
  61137. var yyyy8 = yyyy.redIAdd(yyyy);
  61138. yyyy8 = yyyy8.redIAdd(yyyy8);
  61139. yyyy8 = yyyy8.redIAdd(yyyy8);
  61140. // X3 = T
  61141. nx = t;
  61142. // Y3 = M * (S - T) - 8 * YYYY
  61143. ny = m.redMul(s.redISub(t)).redISub(yyyy8);
  61144. // Z3 = 2*Y1
  61145. nz = this.y.redAdd(this.y);
  61146. } else {
  61147. // hyperelliptic.org/EFD/g1p/auto-shortw-jacobian-0.html
  61148. // #doubling-dbl-2009-l
  61149. // 2M + 5S + 13A
  61150. // A = X1^2
  61151. var a = this.x.redSqr();
  61152. // B = Y1^2
  61153. var b = this.y.redSqr();
  61154. // C = B^2
  61155. var c = b.redSqr();
  61156. // D = 2 * ((X1 + B)^2 - A - C)
  61157. var d = this.x.redAdd(b).redSqr().redISub(a).redISub(c);
  61158. d = d.redIAdd(d);
  61159. // E = 3 * A
  61160. var e = a.redAdd(a).redIAdd(a);
  61161. // F = E^2
  61162. var f = e.redSqr();
  61163. // 8 * C
  61164. var c8 = c.redIAdd(c);
  61165. c8 = c8.redIAdd(c8);
  61166. c8 = c8.redIAdd(c8);
  61167. // X3 = F - 2 * D
  61168. nx = f.redISub(d).redISub(d);
  61169. // Y3 = E * (D - X3) - 8 * C
  61170. ny = e.redMul(d.redISub(nx)).redISub(c8);
  61171. // Z3 = 2 * Y1 * Z1
  61172. nz = this.y.redMul(this.z);
  61173. nz = nz.redIAdd(nz);
  61174. }
  61175. return this.curve.jpoint(nx, ny, nz);
  61176. };
  61177. JPoint.prototype._threeDbl = function _threeDbl() {
  61178. var nx;
  61179. var ny;
  61180. var nz;
  61181. // Z = 1
  61182. if (this.zOne) {
  61183. // hyperelliptic.org/EFD/g1p/auto-shortw-jacobian-3.html
  61184. // #doubling-mdbl-2007-bl
  61185. // 1M + 5S + 15A
  61186. // XX = X1^2
  61187. var xx = this.x.redSqr();
  61188. // YY = Y1^2
  61189. var yy = this.y.redSqr();
  61190. // YYYY = YY^2
  61191. var yyyy = yy.redSqr();
  61192. // S = 2 * ((X1 + YY)^2 - XX - YYYY)
  61193. var s = this.x.redAdd(yy).redSqr().redISub(xx).redISub(yyyy);
  61194. s = s.redIAdd(s);
  61195. // M = 3 * XX + a
  61196. var m = xx.redAdd(xx).redIAdd(xx).redIAdd(this.curve.a);
  61197. // T = M^2 - 2 * S
  61198. var t = m.redSqr().redISub(s).redISub(s);
  61199. // X3 = T
  61200. nx = t;
  61201. // Y3 = M * (S - T) - 8 * YYYY
  61202. var yyyy8 = yyyy.redIAdd(yyyy);
  61203. yyyy8 = yyyy8.redIAdd(yyyy8);
  61204. yyyy8 = yyyy8.redIAdd(yyyy8);
  61205. ny = m.redMul(s.redISub(t)).redISub(yyyy8);
  61206. // Z3 = 2 * Y1
  61207. nz = this.y.redAdd(this.y);
  61208. } else {
  61209. // hyperelliptic.org/EFD/g1p/auto-shortw-jacobian-3.html#doubling-dbl-2001-b
  61210. // 3M + 5S
  61211. // delta = Z1^2
  61212. var delta = this.z.redSqr();
  61213. // gamma = Y1^2
  61214. var gamma = this.y.redSqr();
  61215. // beta = X1 * gamma
  61216. var beta = this.x.redMul(gamma);
  61217. // alpha = 3 * (X1 - delta) * (X1 + delta)
  61218. var alpha = this.x.redSub(delta).redMul(this.x.redAdd(delta));
  61219. alpha = alpha.redAdd(alpha).redIAdd(alpha);
  61220. // X3 = alpha^2 - 8 * beta
  61221. var beta4 = beta.redIAdd(beta);
  61222. beta4 = beta4.redIAdd(beta4);
  61223. var beta8 = beta4.redAdd(beta4);
  61224. nx = alpha.redSqr().redISub(beta8);
  61225. // Z3 = (Y1 + Z1)^2 - gamma - delta
  61226. nz = this.y.redAdd(this.z).redSqr().redISub(gamma).redISub(delta);
  61227. // Y3 = alpha * (4 * beta - X3) - 8 * gamma^2
  61228. var ggamma8 = gamma.redSqr();
  61229. ggamma8 = ggamma8.redIAdd(ggamma8);
  61230. ggamma8 = ggamma8.redIAdd(ggamma8);
  61231. ggamma8 = ggamma8.redIAdd(ggamma8);
  61232. ny = alpha.redMul(beta4.redISub(nx)).redISub(ggamma8);
  61233. }
  61234. return this.curve.jpoint(nx, ny, nz);
  61235. };
  61236. JPoint.prototype._dbl = function _dbl() {
  61237. var a = this.curve.a;
  61238. // 4M + 6S + 10A
  61239. var jx = this.x;
  61240. var jy = this.y;
  61241. var jz = this.z;
  61242. var jz4 = jz.redSqr().redSqr();
  61243. var jx2 = jx.redSqr();
  61244. var jy2 = jy.redSqr();
  61245. var c = jx2.redAdd(jx2).redIAdd(jx2).redIAdd(a.redMul(jz4));
  61246. var jxd4 = jx.redAdd(jx);
  61247. jxd4 = jxd4.redIAdd(jxd4);
  61248. var t1 = jxd4.redMul(jy2);
  61249. var nx = c.redSqr().redISub(t1.redAdd(t1));
  61250. var t2 = t1.redISub(nx);
  61251. var jyd8 = jy2.redSqr();
  61252. jyd8 = jyd8.redIAdd(jyd8);
  61253. jyd8 = jyd8.redIAdd(jyd8);
  61254. jyd8 = jyd8.redIAdd(jyd8);
  61255. var ny = c.redMul(t2).redISub(jyd8);
  61256. var nz = jy.redAdd(jy).redMul(jz);
  61257. return this.curve.jpoint(nx, ny, nz);
  61258. };
  61259. JPoint.prototype.trpl = function trpl() {
  61260. if (!this.curve.zeroA)
  61261. return this.dbl().add(this);
  61262. // hyperelliptic.org/EFD/g1p/auto-shortw-jacobian-0.html#tripling-tpl-2007-bl
  61263. // 5M + 10S + ...
  61264. // XX = X1^2
  61265. var xx = this.x.redSqr();
  61266. // YY = Y1^2
  61267. var yy = this.y.redSqr();
  61268. // ZZ = Z1^2
  61269. var zz = this.z.redSqr();
  61270. // YYYY = YY^2
  61271. var yyyy = yy.redSqr();
  61272. // M = 3 * XX + a * ZZ2; a = 0
  61273. var m = xx.redAdd(xx).redIAdd(xx);
  61274. // MM = M^2
  61275. var mm = m.redSqr();
  61276. // E = 6 * ((X1 + YY)^2 - XX - YYYY) - MM
  61277. var e = this.x.redAdd(yy).redSqr().redISub(xx).redISub(yyyy);
  61278. e = e.redIAdd(e);
  61279. e = e.redAdd(e).redIAdd(e);
  61280. e = e.redISub(mm);
  61281. // EE = E^2
  61282. var ee = e.redSqr();
  61283. // T = 16*YYYY
  61284. var t = yyyy.redIAdd(yyyy);
  61285. t = t.redIAdd(t);
  61286. t = t.redIAdd(t);
  61287. t = t.redIAdd(t);
  61288. // U = (M + E)^2 - MM - EE - T
  61289. var u = m.redIAdd(e).redSqr().redISub(mm).redISub(ee).redISub(t);
  61290. // X3 = 4 * (X1 * EE - 4 * YY * U)
  61291. var yyu4 = yy.redMul(u);
  61292. yyu4 = yyu4.redIAdd(yyu4);
  61293. yyu4 = yyu4.redIAdd(yyu4);
  61294. var nx = this.x.redMul(ee).redISub(yyu4);
  61295. nx = nx.redIAdd(nx);
  61296. nx = nx.redIAdd(nx);
  61297. // Y3 = 8 * Y1 * (U * (T - U) - E * EE)
  61298. var ny = this.y.redMul(u.redMul(t.redISub(u)).redISub(e.redMul(ee)));
  61299. ny = ny.redIAdd(ny);
  61300. ny = ny.redIAdd(ny);
  61301. ny = ny.redIAdd(ny);
  61302. // Z3 = (Z1 + E)^2 - ZZ - EE
  61303. var nz = this.z.redAdd(e).redSqr().redISub(zz).redISub(ee);
  61304. return this.curve.jpoint(nx, ny, nz);
  61305. };
  61306. JPoint.prototype.mul = function mul(k, kbase) {
  61307. k = new BN(k, kbase);
  61308. return this.curve._wnafMul(this, k);
  61309. };
  61310. JPoint.prototype.eq = function eq(p) {
  61311. if (p.type === 'affine')
  61312. return this.eq(p.toJ());
  61313. if (this === p)
  61314. return true;
  61315. // x1 * z2^2 == x2 * z1^2
  61316. var z2 = this.z.redSqr();
  61317. var pz2 = p.z.redSqr();
  61318. if (this.x.redMul(pz2).redISub(p.x.redMul(z2)).cmpn(0) !== 0)
  61319. return false;
  61320. // y1 * z2^3 == y2 * z1^3
  61321. var z3 = z2.redMul(this.z);
  61322. var pz3 = pz2.redMul(p.z);
  61323. return this.y.redMul(pz3).redISub(p.y.redMul(z3)).cmpn(0) === 0;
  61324. };
  61325. JPoint.prototype.eqXToP = function eqXToP(x) {
  61326. var zs = this.z.redSqr();
  61327. var rx = x.toRed(this.curve.red).redMul(zs);
  61328. if (this.x.cmp(rx) === 0)
  61329. return true;
  61330. var xc = x.clone();
  61331. var t = this.curve.redN.redMul(zs);
  61332. for (;;) {
  61333. xc.iadd(this.curve.n);
  61334. if (xc.cmp(this.curve.p) >= 0)
  61335. return false;
  61336. rx.redIAdd(t);
  61337. if (this.x.cmp(rx) === 0)
  61338. return true;
  61339. }
  61340. };
  61341. JPoint.prototype.inspect = function inspect() {
  61342. if (this.isInfinity())
  61343. return '<EC JPoint Infinity>';
  61344. return '<EC JPoint x: ' + this.x.toString(16, 2) +
  61345. ' y: ' + this.y.toString(16, 2) +
  61346. ' z: ' + this.z.toString(16, 2) + '>';
  61347. };
  61348. JPoint.prototype.isInfinity = function isInfinity() {
  61349. // XXX This code assumes that zero is always zero in red
  61350. return this.z.cmpn(0) === 0;
  61351. };
  61352. },{"../utils":768,"./base":755,"bn.js":769,"inherits":789}],760:[function(_dereq_,module,exports){
  61353. 'use strict';
  61354. var curves = exports;
  61355. var hash = _dereq_('hash.js');
  61356. var curve = _dereq_('./curve');
  61357. var utils = _dereq_('./utils');
  61358. var assert = utils.assert;
  61359. function PresetCurve(options) {
  61360. if (options.type === 'short')
  61361. this.curve = new curve.short(options);
  61362. else if (options.type === 'edwards')
  61363. this.curve = new curve.edwards(options);
  61364. else
  61365. this.curve = new curve.mont(options);
  61366. this.g = this.curve.g;
  61367. this.n = this.curve.n;
  61368. this.hash = options.hash;
  61369. assert(this.g.validate(), 'Invalid curve');
  61370. assert(this.g.mul(this.n).isInfinity(), 'Invalid curve, G*N != O');
  61371. }
  61372. curves.PresetCurve = PresetCurve;
  61373. function defineCurve(name, options) {
  61374. Object.defineProperty(curves, name, {
  61375. configurable: true,
  61376. enumerable: true,
  61377. get: function() {
  61378. var curve = new PresetCurve(options);
  61379. Object.defineProperty(curves, name, {
  61380. configurable: true,
  61381. enumerable: true,
  61382. value: curve,
  61383. });
  61384. return curve;
  61385. },
  61386. });
  61387. }
  61388. defineCurve('p192', {
  61389. type: 'short',
  61390. prime: 'p192',
  61391. p: 'ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff',
  61392. a: 'ffffffff ffffffff ffffffff fffffffe ffffffff fffffffc',
  61393. b: '64210519 e59c80e7 0fa7e9ab 72243049 feb8deec c146b9b1',
  61394. n: 'ffffffff ffffffff ffffffff 99def836 146bc9b1 b4d22831',
  61395. hash: hash.sha256,
  61396. gRed: false,
  61397. g: [
  61398. '188da80e b03090f6 7cbf20eb 43a18800 f4ff0afd 82ff1012',
  61399. '07192b95 ffc8da78 631011ed 6b24cdd5 73f977a1 1e794811',
  61400. ],
  61401. });
  61402. defineCurve('p224', {
  61403. type: 'short',
  61404. prime: 'p224',
  61405. p: 'ffffffff ffffffff ffffffff ffffffff 00000000 00000000 00000001',
  61406. a: 'ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff fffffffe',
  61407. b: 'b4050a85 0c04b3ab f5413256 5044b0b7 d7bfd8ba 270b3943 2355ffb4',
  61408. n: 'ffffffff ffffffff ffffffff ffff16a2 e0b8f03e 13dd2945 5c5c2a3d',
  61409. hash: hash.sha256,
  61410. gRed: false,
  61411. g: [
  61412. 'b70e0cbd 6bb4bf7f 321390b9 4a03c1d3 56c21122 343280d6 115c1d21',
  61413. 'bd376388 b5f723fb 4c22dfe6 cd4375a0 5a074764 44d58199 85007e34',
  61414. ],
  61415. });
  61416. defineCurve('p256', {
  61417. type: 'short',
  61418. prime: null,
  61419. p: 'ffffffff 00000001 00000000 00000000 00000000 ffffffff ffffffff ffffffff',
  61420. a: 'ffffffff 00000001 00000000 00000000 00000000 ffffffff ffffffff fffffffc',
  61421. b: '5ac635d8 aa3a93e7 b3ebbd55 769886bc 651d06b0 cc53b0f6 3bce3c3e 27d2604b',
  61422. n: 'ffffffff 00000000 ffffffff ffffffff bce6faad a7179e84 f3b9cac2 fc632551',
  61423. hash: hash.sha256,
  61424. gRed: false,
  61425. g: [
  61426. '6b17d1f2 e12c4247 f8bce6e5 63a440f2 77037d81 2deb33a0 f4a13945 d898c296',
  61427. '4fe342e2 fe1a7f9b 8ee7eb4a 7c0f9e16 2bce3357 6b315ece cbb64068 37bf51f5',
  61428. ],
  61429. });
  61430. defineCurve('p384', {
  61431. type: 'short',
  61432. prime: null,
  61433. p: 'ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ' +
  61434. 'fffffffe ffffffff 00000000 00000000 ffffffff',
  61435. a: 'ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ' +
  61436. 'fffffffe ffffffff 00000000 00000000 fffffffc',
  61437. b: 'b3312fa7 e23ee7e4 988e056b e3f82d19 181d9c6e fe814112 0314088f ' +
  61438. '5013875a c656398d 8a2ed19d 2a85c8ed d3ec2aef',
  61439. n: 'ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff c7634d81 ' +
  61440. 'f4372ddf 581a0db2 48b0a77a ecec196a ccc52973',
  61441. hash: hash.sha384,
  61442. gRed: false,
  61443. g: [
  61444. 'aa87ca22 be8b0537 8eb1c71e f320ad74 6e1d3b62 8ba79b98 59f741e0 82542a38 ' +
  61445. '5502f25d bf55296c 3a545e38 72760ab7',
  61446. '3617de4a 96262c6f 5d9e98bf 9292dc29 f8f41dbd 289a147c e9da3113 b5f0b8c0 ' +
  61447. '0a60b1ce 1d7e819d 7a431d7c 90ea0e5f',
  61448. ],
  61449. });
  61450. defineCurve('p521', {
  61451. type: 'short',
  61452. prime: null,
  61453. p: '000001ff ffffffff ffffffff ffffffff ffffffff ffffffff ' +
  61454. 'ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ' +
  61455. 'ffffffff ffffffff ffffffff ffffffff ffffffff',
  61456. a: '000001ff ffffffff ffffffff ffffffff ffffffff ffffffff ' +
  61457. 'ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ' +
  61458. 'ffffffff ffffffff ffffffff ffffffff fffffffc',
  61459. b: '00000051 953eb961 8e1c9a1f 929a21a0 b68540ee a2da725b ' +
  61460. '99b315f3 b8b48991 8ef109e1 56193951 ec7e937b 1652c0bd ' +
  61461. '3bb1bf07 3573df88 3d2c34f1 ef451fd4 6b503f00',
  61462. n: '000001ff ffffffff ffffffff ffffffff ffffffff ffffffff ' +
  61463. 'ffffffff ffffffff fffffffa 51868783 bf2f966b 7fcc0148 ' +
  61464. 'f709a5d0 3bb5c9b8 899c47ae bb6fb71e 91386409',
  61465. hash: hash.sha512,
  61466. gRed: false,
  61467. g: [
  61468. '000000c6 858e06b7 0404e9cd 9e3ecb66 2395b442 9c648139 ' +
  61469. '053fb521 f828af60 6b4d3dba a14b5e77 efe75928 fe1dc127 ' +
  61470. 'a2ffa8de 3348b3c1 856a429b f97e7e31 c2e5bd66',
  61471. '00000118 39296a78 9a3bc004 5c8a5fb4 2c7d1bd9 98f54449 ' +
  61472. '579b4468 17afbd17 273e662c 97ee7299 5ef42640 c550b901 ' +
  61473. '3fad0761 353c7086 a272c240 88be9476 9fd16650',
  61474. ],
  61475. });
  61476. defineCurve('curve25519', {
  61477. type: 'mont',
  61478. prime: 'p25519',
  61479. p: '7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed',
  61480. a: '76d06',
  61481. b: '1',
  61482. n: '1000000000000000 0000000000000000 14def9dea2f79cd6 5812631a5cf5d3ed',
  61483. hash: hash.sha256,
  61484. gRed: false,
  61485. g: [
  61486. '9',
  61487. ],
  61488. });
  61489. defineCurve('ed25519', {
  61490. type: 'edwards',
  61491. prime: 'p25519',
  61492. p: '7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed',
  61493. a: '-1',
  61494. c: '1',
  61495. // -121665 * (121666^(-1)) (mod P)
  61496. d: '52036cee2b6ffe73 8cc740797779e898 00700a4d4141d8ab 75eb4dca135978a3',
  61497. n: '1000000000000000 0000000000000000 14def9dea2f79cd6 5812631a5cf5d3ed',
  61498. hash: hash.sha256,
  61499. gRed: false,
  61500. g: [
  61501. '216936d3cd6e53fec0a4e231fdd6dc5c692cc7609525a7b2c9562d608f25d51a',
  61502. // 4/5
  61503. '6666666666666666666666666666666666666666666666666666666666666658',
  61504. ],
  61505. });
  61506. var pre;
  61507. try {
  61508. pre = _dereq_('./precomputed/secp256k1');
  61509. } catch (e) {
  61510. pre = undefined;
  61511. }
  61512. defineCurve('secp256k1', {
  61513. type: 'short',
  61514. prime: 'k256',
  61515. p: 'ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe fffffc2f',
  61516. a: '0',
  61517. b: '7',
  61518. n: 'ffffffff ffffffff ffffffff fffffffe baaedce6 af48a03b bfd25e8c d0364141',
  61519. h: '1',
  61520. hash: hash.sha256,
  61521. // Precomputed endomorphism
  61522. beta: '7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee',
  61523. lambda: '5363ad4cc05c30e0a5261c028812645a122e22ea20816678df02967c1b23bd72',
  61524. basis: [
  61525. {
  61526. a: '3086d221a7d46bcde86c90e49284eb15',
  61527. b: '-e4437ed6010e88286f547fa90abfe4c3',
  61528. },
  61529. {
  61530. a: '114ca50f7a8e2f3f657c1108d9d44cfd8',
  61531. b: '3086d221a7d46bcde86c90e49284eb15',
  61532. },
  61533. ],
  61534. gRed: false,
  61535. g: [
  61536. '79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798',
  61537. '483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8',
  61538. pre,
  61539. ],
  61540. });
  61541. },{"./curve":757,"./precomputed/secp256k1":767,"./utils":768,"hash.js":776}],761:[function(_dereq_,module,exports){
  61542. 'use strict';
  61543. var BN = _dereq_('bn.js');
  61544. var HmacDRBG = _dereq_('hmac-drbg');
  61545. var utils = _dereq_('../utils');
  61546. var curves = _dereq_('../curves');
  61547. var rand = _dereq_('brorand');
  61548. var assert = utils.assert;
  61549. var KeyPair = _dereq_('./key');
  61550. var Signature = _dereq_('./signature');
  61551. function EC(options) {
  61552. if (!(this instanceof EC))
  61553. return new EC(options);
  61554. // Shortcut `elliptic.ec(curve-name)`
  61555. if (typeof options === 'string') {
  61556. assert(Object.prototype.hasOwnProperty.call(curves, options),
  61557. 'Unknown curve ' + options);
  61558. options = curves[options];
  61559. }
  61560. // Shortcut for `elliptic.ec(elliptic.curves.curveName)`
  61561. if (options instanceof curves.PresetCurve)
  61562. options = { curve: options };
  61563. this.curve = options.curve.curve;
  61564. this.n = this.curve.n;
  61565. this.nh = this.n.ushrn(1);
  61566. this.g = this.curve.g;
  61567. // Point on curve
  61568. this.g = options.curve.g;
  61569. this.g.precompute(options.curve.n.bitLength() + 1);
  61570. // Hash for function for DRBG
  61571. this.hash = options.hash || options.curve.hash;
  61572. }
  61573. module.exports = EC;
  61574. EC.prototype.keyPair = function keyPair(options) {
  61575. return new KeyPair(this, options);
  61576. };
  61577. EC.prototype.keyFromPrivate = function keyFromPrivate(priv, enc) {
  61578. return KeyPair.fromPrivate(this, priv, enc);
  61579. };
  61580. EC.prototype.keyFromPublic = function keyFromPublic(pub, enc) {
  61581. return KeyPair.fromPublic(this, pub, enc);
  61582. };
  61583. EC.prototype.genKeyPair = function genKeyPair(options) {
  61584. if (!options)
  61585. options = {};
  61586. // Instantiate Hmac_DRBG
  61587. var drbg = new HmacDRBG({
  61588. hash: this.hash,
  61589. pers: options.pers,
  61590. persEnc: options.persEnc || 'utf8',
  61591. entropy: options.entropy || rand(this.hash.hmacStrength),
  61592. entropyEnc: options.entropy && options.entropyEnc || 'utf8',
  61593. nonce: this.n.toArray(),
  61594. });
  61595. var bytes = this.n.byteLength();
  61596. var ns2 = this.n.sub(new BN(2));
  61597. for (;;) {
  61598. var priv = new BN(drbg.generate(bytes));
  61599. if (priv.cmp(ns2) > 0)
  61600. continue;
  61601. priv.iaddn(1);
  61602. return this.keyFromPrivate(priv);
  61603. }
  61604. };
  61605. EC.prototype._truncateToN = function _truncateToN(msg, truncOnly) {
  61606. var delta = msg.byteLength() * 8 - this.n.bitLength();
  61607. if (delta > 0)
  61608. msg = msg.ushrn(delta);
  61609. if (!truncOnly && msg.cmp(this.n) >= 0)
  61610. return msg.sub(this.n);
  61611. else
  61612. return msg;
  61613. };
  61614. EC.prototype.sign = function sign(msg, key, enc, options) {
  61615. if (typeof enc === 'object') {
  61616. options = enc;
  61617. enc = null;
  61618. }
  61619. if (!options)
  61620. options = {};
  61621. key = this.keyFromPrivate(key, enc);
  61622. msg = this._truncateToN(new BN(msg, 16));
  61623. // Zero-extend key to provide enough entropy
  61624. var bytes = this.n.byteLength();
  61625. var bkey = key.getPrivate().toArray('be', bytes);
  61626. // Zero-extend nonce to have the same byte size as N
  61627. var nonce = msg.toArray('be', bytes);
  61628. // Instantiate Hmac_DRBG
  61629. var drbg = new HmacDRBG({
  61630. hash: this.hash,
  61631. entropy: bkey,
  61632. nonce: nonce,
  61633. pers: options.pers,
  61634. persEnc: options.persEnc || 'utf8',
  61635. });
  61636. // Number of bytes to generate
  61637. var ns1 = this.n.sub(new BN(1));
  61638. for (var iter = 0; ; iter++) {
  61639. var k = options.k ?
  61640. options.k(iter) :
  61641. new BN(drbg.generate(this.n.byteLength()));
  61642. k = this._truncateToN(k, true);
  61643. if (k.cmpn(1) <= 0 || k.cmp(ns1) >= 0)
  61644. continue;
  61645. var kp = this.g.mul(k);
  61646. if (kp.isInfinity())
  61647. continue;
  61648. var kpX = kp.getX();
  61649. var r = kpX.umod(this.n);
  61650. if (r.cmpn(0) === 0)
  61651. continue;
  61652. var s = k.invm(this.n).mul(r.mul(key.getPrivate()).iadd(msg));
  61653. s = s.umod(this.n);
  61654. if (s.cmpn(0) === 0)
  61655. continue;
  61656. var recoveryParam = (kp.getY().isOdd() ? 1 : 0) |
  61657. (kpX.cmp(r) !== 0 ? 2 : 0);
  61658. // Use complement of `s`, if it is > `n / 2`
  61659. if (options.canonical && s.cmp(this.nh) > 0) {
  61660. s = this.n.sub(s);
  61661. recoveryParam ^= 1;
  61662. }
  61663. return new Signature({ r: r, s: s, recoveryParam: recoveryParam });
  61664. }
  61665. };
  61666. EC.prototype.verify = function verify(msg, signature, key, enc) {
  61667. msg = this._truncateToN(new BN(msg, 16));
  61668. key = this.keyFromPublic(key, enc);
  61669. signature = new Signature(signature, 'hex');
  61670. // Perform primitive values validation
  61671. var r = signature.r;
  61672. var s = signature.s;
  61673. if (r.cmpn(1) < 0 || r.cmp(this.n) >= 0)
  61674. return false;
  61675. if (s.cmpn(1) < 0 || s.cmp(this.n) >= 0)
  61676. return false;
  61677. // Validate signature
  61678. var sinv = s.invm(this.n);
  61679. var u1 = sinv.mul(msg).umod(this.n);
  61680. var u2 = sinv.mul(r).umod(this.n);
  61681. var p;
  61682. if (!this.curve._maxwellTrick) {
  61683. p = this.g.mulAdd(u1, key.getPublic(), u2);
  61684. if (p.isInfinity())
  61685. return false;
  61686. return p.getX().umod(this.n).cmp(r) === 0;
  61687. }
  61688. // NOTE: Greg Maxwell's trick, inspired by:
  61689. // https://git.io/vad3K
  61690. p = this.g.jmulAdd(u1, key.getPublic(), u2);
  61691. if (p.isInfinity())
  61692. return false;
  61693. // Compare `p.x` of Jacobian point with `r`,
  61694. // this will do `p.x == r * p.z^2` instead of multiplying `p.x` by the
  61695. // inverse of `p.z^2`
  61696. return p.eqXToP(r);
  61697. };
  61698. EC.prototype.recoverPubKey = function(msg, signature, j, enc) {
  61699. assert((3 & j) === j, 'The recovery param is more than two bits');
  61700. signature = new Signature(signature, enc);
  61701. var n = this.n;
  61702. var e = new BN(msg);
  61703. var r = signature.r;
  61704. var s = signature.s;
  61705. // A set LSB signifies that the y-coordinate is odd
  61706. var isYOdd = j & 1;
  61707. var isSecondKey = j >> 1;
  61708. if (r.cmp(this.curve.p.umod(this.curve.n)) >= 0 && isSecondKey)
  61709. throw new Error('Unable to find sencond key candinate');
  61710. // 1.1. Let x = r + jn.
  61711. if (isSecondKey)
  61712. r = this.curve.pointFromX(r.add(this.curve.n), isYOdd);
  61713. else
  61714. r = this.curve.pointFromX(r, isYOdd);
  61715. var rInv = signature.r.invm(n);
  61716. var s1 = n.sub(e).mul(rInv).umod(n);
  61717. var s2 = s.mul(rInv).umod(n);
  61718. // 1.6.1 Compute Q = r^-1 (sR - eG)
  61719. // Q = r^-1 (sR + -eG)
  61720. return this.g.mulAdd(s1, r, s2);
  61721. };
  61722. EC.prototype.getKeyRecoveryParam = function(e, signature, Q, enc) {
  61723. signature = new Signature(signature, enc);
  61724. if (signature.recoveryParam !== null)
  61725. return signature.recoveryParam;
  61726. for (var i = 0; i < 4; i++) {
  61727. var Qprime;
  61728. try {
  61729. Qprime = this.recoverPubKey(e, signature, i);
  61730. } catch (e) {
  61731. continue;
  61732. }
  61733. if (Qprime.eq(Q))
  61734. return i;
  61735. }
  61736. throw new Error('Unable to find valid recovery factor');
  61737. };
  61738. },{"../curves":760,"../utils":768,"./key":762,"./signature":763,"bn.js":769,"brorand":322,"hmac-drbg":788}],762:[function(_dereq_,module,exports){
  61739. 'use strict';
  61740. var BN = _dereq_('bn.js');
  61741. var utils = _dereq_('../utils');
  61742. var assert = utils.assert;
  61743. function KeyPair(ec, options) {
  61744. this.ec = ec;
  61745. this.priv = null;
  61746. this.pub = null;
  61747. // KeyPair(ec, { priv: ..., pub: ... })
  61748. if (options.priv)
  61749. this._importPrivate(options.priv, options.privEnc);
  61750. if (options.pub)
  61751. this._importPublic(options.pub, options.pubEnc);
  61752. }
  61753. module.exports = KeyPair;
  61754. KeyPair.fromPublic = function fromPublic(ec, pub, enc) {
  61755. if (pub instanceof KeyPair)
  61756. return pub;
  61757. return new KeyPair(ec, {
  61758. pub: pub,
  61759. pubEnc: enc,
  61760. });
  61761. };
  61762. KeyPair.fromPrivate = function fromPrivate(ec, priv, enc) {
  61763. if (priv instanceof KeyPair)
  61764. return priv;
  61765. return new KeyPair(ec, {
  61766. priv: priv,
  61767. privEnc: enc,
  61768. });
  61769. };
  61770. KeyPair.prototype.validate = function validate() {
  61771. var pub = this.getPublic();
  61772. if (pub.isInfinity())
  61773. return { result: false, reason: 'Invalid public key' };
  61774. if (!pub.validate())
  61775. return { result: false, reason: 'Public key is not a point' };
  61776. if (!pub.mul(this.ec.curve.n).isInfinity())
  61777. return { result: false, reason: 'Public key * N != O' };
  61778. return { result: true, reason: null };
  61779. };
  61780. KeyPair.prototype.getPublic = function getPublic(compact, enc) {
  61781. // compact is optional argument
  61782. if (typeof compact === 'string') {
  61783. enc = compact;
  61784. compact = null;
  61785. }
  61786. if (!this.pub)
  61787. this.pub = this.ec.g.mul(this.priv);
  61788. if (!enc)
  61789. return this.pub;
  61790. return this.pub.encode(enc, compact);
  61791. };
  61792. KeyPair.prototype.getPrivate = function getPrivate(enc) {
  61793. if (enc === 'hex')
  61794. return this.priv.toString(16, 2);
  61795. else
  61796. return this.priv;
  61797. };
  61798. KeyPair.prototype._importPrivate = function _importPrivate(key, enc) {
  61799. this.priv = new BN(key, enc || 16);
  61800. // Ensure that the priv won't be bigger than n, otherwise we may fail
  61801. // in fixed multiplication method
  61802. this.priv = this.priv.umod(this.ec.curve.n);
  61803. };
  61804. KeyPair.prototype._importPublic = function _importPublic(key, enc) {
  61805. if (key.x || key.y) {
  61806. // Montgomery points only have an `x` coordinate.
  61807. // Weierstrass/Edwards points on the other hand have both `x` and
  61808. // `y` coordinates.
  61809. if (this.ec.curve.type === 'mont') {
  61810. assert(key.x, 'Need x coordinate');
  61811. } else if (this.ec.curve.type === 'short' ||
  61812. this.ec.curve.type === 'edwards') {
  61813. assert(key.x && key.y, 'Need both x and y coordinate');
  61814. }
  61815. this.pub = this.ec.curve.point(key.x, key.y);
  61816. return;
  61817. }
  61818. this.pub = this.ec.curve.decodePoint(key, enc);
  61819. };
  61820. // ECDH
  61821. KeyPair.prototype.derive = function derive(pub) {
  61822. if(!pub.validate()) {
  61823. assert(pub.validate(), 'public point not validated');
  61824. }
  61825. return pub.mul(this.priv).getX();
  61826. };
  61827. // ECDSA
  61828. KeyPair.prototype.sign = function sign(msg, enc, options) {
  61829. return this.ec.sign(msg, this, enc, options);
  61830. };
  61831. KeyPair.prototype.verify = function verify(msg, signature) {
  61832. return this.ec.verify(msg, signature, this);
  61833. };
  61834. KeyPair.prototype.inspect = function inspect() {
  61835. return '<Key priv: ' + (this.priv && this.priv.toString(16, 2)) +
  61836. ' pub: ' + (this.pub && this.pub.inspect()) + ' >';
  61837. };
  61838. },{"../utils":768,"bn.js":769}],763:[function(_dereq_,module,exports){
  61839. 'use strict';
  61840. var BN = _dereq_('bn.js');
  61841. var utils = _dereq_('../utils');
  61842. var assert = utils.assert;
  61843. function Signature(options, enc) {
  61844. if (options instanceof Signature)
  61845. return options;
  61846. if (this._importDER(options, enc))
  61847. return;
  61848. assert(options.r && options.s, 'Signature without r or s');
  61849. this.r = new BN(options.r, 16);
  61850. this.s = new BN(options.s, 16);
  61851. if (options.recoveryParam === undefined)
  61852. this.recoveryParam = null;
  61853. else
  61854. this.recoveryParam = options.recoveryParam;
  61855. }
  61856. module.exports = Signature;
  61857. function Position() {
  61858. this.place = 0;
  61859. }
  61860. function getLength(buf, p) {
  61861. var initial = buf[p.place++];
  61862. if (!(initial & 0x80)) {
  61863. return initial;
  61864. }
  61865. var octetLen = initial & 0xf;
  61866. // Indefinite length or overflow
  61867. if (octetLen === 0 || octetLen > 4) {
  61868. return false;
  61869. }
  61870. var val = 0;
  61871. for (var i = 0, off = p.place; i < octetLen; i++, off++) {
  61872. val <<= 8;
  61873. val |= buf[off];
  61874. val >>>= 0;
  61875. }
  61876. // Leading zeroes
  61877. if (val <= 0x7f) {
  61878. return false;
  61879. }
  61880. p.place = off;
  61881. return val;
  61882. }
  61883. function rmPadding(buf) {
  61884. var i = 0;
  61885. var len = buf.length - 1;
  61886. while (!buf[i] && !(buf[i + 1] & 0x80) && i < len) {
  61887. i++;
  61888. }
  61889. if (i === 0) {
  61890. return buf;
  61891. }
  61892. return buf.slice(i);
  61893. }
  61894. Signature.prototype._importDER = function _importDER(data, enc) {
  61895. data = utils.toArray(data, enc);
  61896. var p = new Position();
  61897. if (data[p.place++] !== 0x30) {
  61898. return false;
  61899. }
  61900. var len = getLength(data, p);
  61901. if (len === false) {
  61902. return false;
  61903. }
  61904. if ((len + p.place) !== data.length) {
  61905. return false;
  61906. }
  61907. if (data[p.place++] !== 0x02) {
  61908. return false;
  61909. }
  61910. var rlen = getLength(data, p);
  61911. if (rlen === false) {
  61912. return false;
  61913. }
  61914. var r = data.slice(p.place, rlen + p.place);
  61915. p.place += rlen;
  61916. if (data[p.place++] !== 0x02) {
  61917. return false;
  61918. }
  61919. var slen = getLength(data, p);
  61920. if (slen === false) {
  61921. return false;
  61922. }
  61923. if (data.length !== slen + p.place) {
  61924. return false;
  61925. }
  61926. var s = data.slice(p.place, slen + p.place);
  61927. if (r[0] === 0) {
  61928. if (r[1] & 0x80) {
  61929. r = r.slice(1);
  61930. } else {
  61931. // Leading zeroes
  61932. return false;
  61933. }
  61934. }
  61935. if (s[0] === 0) {
  61936. if (s[1] & 0x80) {
  61937. s = s.slice(1);
  61938. } else {
  61939. // Leading zeroes
  61940. return false;
  61941. }
  61942. }
  61943. this.r = new BN(r);
  61944. this.s = new BN(s);
  61945. this.recoveryParam = null;
  61946. return true;
  61947. };
  61948. function constructLength(arr, len) {
  61949. if (len < 0x80) {
  61950. arr.push(len);
  61951. return;
  61952. }
  61953. var octets = 1 + (Math.log(len) / Math.LN2 >>> 3);
  61954. arr.push(octets | 0x80);
  61955. while (--octets) {
  61956. arr.push((len >>> (octets << 3)) & 0xff);
  61957. }
  61958. arr.push(len);
  61959. }
  61960. Signature.prototype.toDER = function toDER(enc) {
  61961. var r = this.r.toArray();
  61962. var s = this.s.toArray();
  61963. // Pad values
  61964. if (r[0] & 0x80)
  61965. r = [ 0 ].concat(r);
  61966. // Pad values
  61967. if (s[0] & 0x80)
  61968. s = [ 0 ].concat(s);
  61969. r = rmPadding(r);
  61970. s = rmPadding(s);
  61971. while (!s[0] && !(s[1] & 0x80)) {
  61972. s = s.slice(1);
  61973. }
  61974. var arr = [ 0x02 ];
  61975. constructLength(arr, r.length);
  61976. arr = arr.concat(r);
  61977. arr.push(0x02);
  61978. constructLength(arr, s.length);
  61979. var backHalf = arr.concat(s);
  61980. var res = [ 0x30 ];
  61981. constructLength(res, backHalf.length);
  61982. res = res.concat(backHalf);
  61983. return utils.encode(res, enc);
  61984. };
  61985. },{"../utils":768,"bn.js":769}],764:[function(_dereq_,module,exports){
  61986. 'use strict';
  61987. var hash = _dereq_('hash.js');
  61988. var curves = _dereq_('../curves');
  61989. var utils = _dereq_('../utils');
  61990. var assert = utils.assert;
  61991. var parseBytes = utils.parseBytes;
  61992. var KeyPair = _dereq_('./key');
  61993. var Signature = _dereq_('./signature');
  61994. function EDDSA(curve) {
  61995. assert(curve === 'ed25519', 'only tested with ed25519 so far');
  61996. if (!(this instanceof EDDSA))
  61997. return new EDDSA(curve);
  61998. curve = curves[curve].curve;
  61999. this.curve = curve;
  62000. this.g = curve.g;
  62001. this.g.precompute(curve.n.bitLength() + 1);
  62002. this.pointClass = curve.point().constructor;
  62003. this.encodingLength = Math.ceil(curve.n.bitLength() / 8);
  62004. this.hash = hash.sha512;
  62005. }
  62006. module.exports = EDDSA;
  62007. /**
  62008. * @param {Array|String} message - message bytes
  62009. * @param {Array|String|KeyPair} secret - secret bytes or a keypair
  62010. * @returns {Signature} - signature
  62011. */
  62012. EDDSA.prototype.sign = function sign(message, secret) {
  62013. message = parseBytes(message);
  62014. var key = this.keyFromSecret(secret);
  62015. var r = this.hashInt(key.messagePrefix(), message);
  62016. var R = this.g.mul(r);
  62017. var Rencoded = this.encodePoint(R);
  62018. var s_ = this.hashInt(Rencoded, key.pubBytes(), message)
  62019. .mul(key.priv());
  62020. var S = r.add(s_).umod(this.curve.n);
  62021. return this.makeSignature({ R: R, S: S, Rencoded: Rencoded });
  62022. };
  62023. /**
  62024. * @param {Array} message - message bytes
  62025. * @param {Array|String|Signature} sig - sig bytes
  62026. * @param {Array|String|Point|KeyPair} pub - public key
  62027. * @returns {Boolean} - true if public key matches sig of message
  62028. */
  62029. EDDSA.prototype.verify = function verify(message, sig, pub) {
  62030. message = parseBytes(message);
  62031. sig = this.makeSignature(sig);
  62032. var key = this.keyFromPublic(pub);
  62033. var h = this.hashInt(sig.Rencoded(), key.pubBytes(), message);
  62034. var SG = this.g.mul(sig.S());
  62035. var RplusAh = sig.R().add(key.pub().mul(h));
  62036. return RplusAh.eq(SG);
  62037. };
  62038. EDDSA.prototype.hashInt = function hashInt() {
  62039. var hash = this.hash();
  62040. for (var i = 0; i < arguments.length; i++)
  62041. hash.update(arguments[i]);
  62042. return utils.intFromLE(hash.digest()).umod(this.curve.n);
  62043. };
  62044. EDDSA.prototype.keyFromPublic = function keyFromPublic(pub) {
  62045. return KeyPair.fromPublic(this, pub);
  62046. };
  62047. EDDSA.prototype.keyFromSecret = function keyFromSecret(secret) {
  62048. return KeyPair.fromSecret(this, secret);
  62049. };
  62050. EDDSA.prototype.makeSignature = function makeSignature(sig) {
  62051. if (sig instanceof Signature)
  62052. return sig;
  62053. return new Signature(this, sig);
  62054. };
  62055. /**
  62056. * * https://tools.ietf.org/html/draft-josefsson-eddsa-ed25519-03#section-5.2
  62057. *
  62058. * EDDSA defines methods for encoding and decoding points and integers. These are
  62059. * helper convenience methods, that pass along to utility functions implied
  62060. * parameters.
  62061. *
  62062. */
  62063. EDDSA.prototype.encodePoint = function encodePoint(point) {
  62064. var enc = point.getY().toArray('le', this.encodingLength);
  62065. enc[this.encodingLength - 1] |= point.getX().isOdd() ? 0x80 : 0;
  62066. return enc;
  62067. };
  62068. EDDSA.prototype.decodePoint = function decodePoint(bytes) {
  62069. bytes = utils.parseBytes(bytes);
  62070. var lastIx = bytes.length - 1;
  62071. var normed = bytes.slice(0, lastIx).concat(bytes[lastIx] & ~0x80);
  62072. var xIsOdd = (bytes[lastIx] & 0x80) !== 0;
  62073. var y = utils.intFromLE(normed);
  62074. return this.curve.pointFromY(y, xIsOdd);
  62075. };
  62076. EDDSA.prototype.encodeInt = function encodeInt(num) {
  62077. return num.toArray('le', this.encodingLength);
  62078. };
  62079. EDDSA.prototype.decodeInt = function decodeInt(bytes) {
  62080. return utils.intFromLE(bytes);
  62081. };
  62082. EDDSA.prototype.isPoint = function isPoint(val) {
  62083. return val instanceof this.pointClass;
  62084. };
  62085. },{"../curves":760,"../utils":768,"./key":765,"./signature":766,"hash.js":776}],765:[function(_dereq_,module,exports){
  62086. 'use strict';
  62087. var utils = _dereq_('../utils');
  62088. var assert = utils.assert;
  62089. var parseBytes = utils.parseBytes;
  62090. var cachedProperty = utils.cachedProperty;
  62091. /**
  62092. * @param {EDDSA} eddsa - instance
  62093. * @param {Object} params - public/private key parameters
  62094. *
  62095. * @param {Array<Byte>} [params.secret] - secret seed bytes
  62096. * @param {Point} [params.pub] - public key point (aka `A` in eddsa terms)
  62097. * @param {Array<Byte>} [params.pub] - public key point encoded as bytes
  62098. *
  62099. */
  62100. function KeyPair(eddsa, params) {
  62101. this.eddsa = eddsa;
  62102. this._secret = parseBytes(params.secret);
  62103. if (eddsa.isPoint(params.pub))
  62104. this._pub = params.pub;
  62105. else
  62106. this._pubBytes = parseBytes(params.pub);
  62107. }
  62108. KeyPair.fromPublic = function fromPublic(eddsa, pub) {
  62109. if (pub instanceof KeyPair)
  62110. return pub;
  62111. return new KeyPair(eddsa, { pub: pub });
  62112. };
  62113. KeyPair.fromSecret = function fromSecret(eddsa, secret) {
  62114. if (secret instanceof KeyPair)
  62115. return secret;
  62116. return new KeyPair(eddsa, { secret: secret });
  62117. };
  62118. KeyPair.prototype.secret = function secret() {
  62119. return this._secret;
  62120. };
  62121. cachedProperty(KeyPair, 'pubBytes', function pubBytes() {
  62122. return this.eddsa.encodePoint(this.pub());
  62123. });
  62124. cachedProperty(KeyPair, 'pub', function pub() {
  62125. if (this._pubBytes)
  62126. return this.eddsa.decodePoint(this._pubBytes);
  62127. return this.eddsa.g.mul(this.priv());
  62128. });
  62129. cachedProperty(KeyPair, 'privBytes', function privBytes() {
  62130. var eddsa = this.eddsa;
  62131. var hash = this.hash();
  62132. var lastIx = eddsa.encodingLength - 1;
  62133. var a = hash.slice(0, eddsa.encodingLength);
  62134. a[0] &= 248;
  62135. a[lastIx] &= 127;
  62136. a[lastIx] |= 64;
  62137. return a;
  62138. });
  62139. cachedProperty(KeyPair, 'priv', function priv() {
  62140. return this.eddsa.decodeInt(this.privBytes());
  62141. });
  62142. cachedProperty(KeyPair, 'hash', function hash() {
  62143. return this.eddsa.hash().update(this.secret()).digest();
  62144. });
  62145. cachedProperty(KeyPair, 'messagePrefix', function messagePrefix() {
  62146. return this.hash().slice(this.eddsa.encodingLength);
  62147. });
  62148. KeyPair.prototype.sign = function sign(message) {
  62149. assert(this._secret, 'KeyPair can only verify');
  62150. return this.eddsa.sign(message, this);
  62151. };
  62152. KeyPair.prototype.verify = function verify(message, sig) {
  62153. return this.eddsa.verify(message, sig, this);
  62154. };
  62155. KeyPair.prototype.getSecret = function getSecret(enc) {
  62156. assert(this._secret, 'KeyPair is public only');
  62157. return utils.encode(this.secret(), enc);
  62158. };
  62159. KeyPair.prototype.getPublic = function getPublic(enc) {
  62160. return utils.encode(this.pubBytes(), enc);
  62161. };
  62162. module.exports = KeyPair;
  62163. },{"../utils":768}],766:[function(_dereq_,module,exports){
  62164. 'use strict';
  62165. var BN = _dereq_('bn.js');
  62166. var utils = _dereq_('../utils');
  62167. var assert = utils.assert;
  62168. var cachedProperty = utils.cachedProperty;
  62169. var parseBytes = utils.parseBytes;
  62170. /**
  62171. * @param {EDDSA} eddsa - eddsa instance
  62172. * @param {Array<Bytes>|Object} sig -
  62173. * @param {Array<Bytes>|Point} [sig.R] - R point as Point or bytes
  62174. * @param {Array<Bytes>|bn} [sig.S] - S scalar as bn or bytes
  62175. * @param {Array<Bytes>} [sig.Rencoded] - R point encoded
  62176. * @param {Array<Bytes>} [sig.Sencoded] - S scalar encoded
  62177. */
  62178. function Signature(eddsa, sig) {
  62179. this.eddsa = eddsa;
  62180. if (typeof sig !== 'object')
  62181. sig = parseBytes(sig);
  62182. if (Array.isArray(sig)) {
  62183. sig = {
  62184. R: sig.slice(0, eddsa.encodingLength),
  62185. S: sig.slice(eddsa.encodingLength),
  62186. };
  62187. }
  62188. assert(sig.R && sig.S, 'Signature without R or S');
  62189. if (eddsa.isPoint(sig.R))
  62190. this._R = sig.R;
  62191. if (sig.S instanceof BN)
  62192. this._S = sig.S;
  62193. this._Rencoded = Array.isArray(sig.R) ? sig.R : sig.Rencoded;
  62194. this._Sencoded = Array.isArray(sig.S) ? sig.S : sig.Sencoded;
  62195. }
  62196. cachedProperty(Signature, 'S', function S() {
  62197. return this.eddsa.decodeInt(this.Sencoded());
  62198. });
  62199. cachedProperty(Signature, 'R', function R() {
  62200. return this.eddsa.decodePoint(this.Rencoded());
  62201. });
  62202. cachedProperty(Signature, 'Rencoded', function Rencoded() {
  62203. return this.eddsa.encodePoint(this.R());
  62204. });
  62205. cachedProperty(Signature, 'Sencoded', function Sencoded() {
  62206. return this.eddsa.encodeInt(this.S());
  62207. });
  62208. Signature.prototype.toBytes = function toBytes() {
  62209. return this.Rencoded().concat(this.Sencoded());
  62210. };
  62211. Signature.prototype.toHex = function toHex() {
  62212. return utils.encode(this.toBytes(), 'hex').toUpperCase();
  62213. };
  62214. module.exports = Signature;
  62215. },{"../utils":768,"bn.js":769}],767:[function(_dereq_,module,exports){
  62216. module.exports = {
  62217. doubles: {
  62218. step: 4,
  62219. points: [
  62220. [
  62221. 'e60fce93b59e9ec53011aabc21c23e97b2a31369b87a5ae9c44ee89e2a6dec0a',
  62222. 'f7e3507399e595929db99f34f57937101296891e44d23f0be1f32cce69616821',
  62223. ],
  62224. [
  62225. '8282263212c609d9ea2a6e3e172de238d8c39cabd5ac1ca10646e23fd5f51508',
  62226. '11f8a8098557dfe45e8256e830b60ace62d613ac2f7b17bed31b6eaff6e26caf',
  62227. ],
  62228. [
  62229. '175e159f728b865a72f99cc6c6fc846de0b93833fd2222ed73fce5b551e5b739',
  62230. 'd3506e0d9e3c79eba4ef97a51ff71f5eacb5955add24345c6efa6ffee9fed695',
  62231. ],
  62232. [
  62233. '363d90d447b00c9c99ceac05b6262ee053441c7e55552ffe526bad8f83ff4640',
  62234. '4e273adfc732221953b445397f3363145b9a89008199ecb62003c7f3bee9de9',
  62235. ],
  62236. [
  62237. '8b4b5f165df3c2be8c6244b5b745638843e4a781a15bcd1b69f79a55dffdf80c',
  62238. '4aad0a6f68d308b4b3fbd7813ab0da04f9e336546162ee56b3eff0c65fd4fd36',
  62239. ],
  62240. [
  62241. '723cbaa6e5db996d6bf771c00bd548c7b700dbffa6c0e77bcb6115925232fcda',
  62242. '96e867b5595cc498a921137488824d6e2660a0653779494801dc069d9eb39f5f',
  62243. ],
  62244. [
  62245. 'eebfa4d493bebf98ba5feec812c2d3b50947961237a919839a533eca0e7dd7fa',
  62246. '5d9a8ca3970ef0f269ee7edaf178089d9ae4cdc3a711f712ddfd4fdae1de8999',
  62247. ],
  62248. [
  62249. '100f44da696e71672791d0a09b7bde459f1215a29b3c03bfefd7835b39a48db0',
  62250. 'cdd9e13192a00b772ec8f3300c090666b7ff4a18ff5195ac0fbd5cd62bc65a09',
  62251. ],
  62252. [
  62253. 'e1031be262c7ed1b1dc9227a4a04c017a77f8d4464f3b3852c8acde6e534fd2d',
  62254. '9d7061928940405e6bb6a4176597535af292dd419e1ced79a44f18f29456a00d',
  62255. ],
  62256. [
  62257. 'feea6cae46d55b530ac2839f143bd7ec5cf8b266a41d6af52d5e688d9094696d',
  62258. 'e57c6b6c97dce1bab06e4e12bf3ecd5c981c8957cc41442d3155debf18090088',
  62259. ],
  62260. [
  62261. 'da67a91d91049cdcb367be4be6ffca3cfeed657d808583de33fa978bc1ec6cb1',
  62262. '9bacaa35481642bc41f463f7ec9780e5dec7adc508f740a17e9ea8e27a68be1d',
  62263. ],
  62264. [
  62265. '53904faa0b334cdda6e000935ef22151ec08d0f7bb11069f57545ccc1a37b7c0',
  62266. '5bc087d0bc80106d88c9eccac20d3c1c13999981e14434699dcb096b022771c8',
  62267. ],
  62268. [
  62269. '8e7bcd0bd35983a7719cca7764ca906779b53a043a9b8bcaeff959f43ad86047',
  62270. '10b7770b2a3da4b3940310420ca9514579e88e2e47fd68b3ea10047e8460372a',
  62271. ],
  62272. [
  62273. '385eed34c1cdff21e6d0818689b81bde71a7f4f18397e6690a841e1599c43862',
  62274. '283bebc3e8ea23f56701de19e9ebf4576b304eec2086dc8cc0458fe5542e5453',
  62275. ],
  62276. [
  62277. '6f9d9b803ecf191637c73a4413dfa180fddf84a5947fbc9c606ed86c3fac3a7',
  62278. '7c80c68e603059ba69b8e2a30e45c4d47ea4dd2f5c281002d86890603a842160',
  62279. ],
  62280. [
  62281. '3322d401243c4e2582a2147c104d6ecbf774d163db0f5e5313b7e0e742d0e6bd',
  62282. '56e70797e9664ef5bfb019bc4ddaf9b72805f63ea2873af624f3a2e96c28b2a0',
  62283. ],
  62284. [
  62285. '85672c7d2de0b7da2bd1770d89665868741b3f9af7643397721d74d28134ab83',
  62286. '7c481b9b5b43b2eb6374049bfa62c2e5e77f17fcc5298f44c8e3094f790313a6',
  62287. ],
  62288. [
  62289. '948bf809b1988a46b06c9f1919413b10f9226c60f668832ffd959af60c82a0a',
  62290. '53a562856dcb6646dc6b74c5d1c3418c6d4dff08c97cd2bed4cb7f88d8c8e589',
  62291. ],
  62292. [
  62293. '6260ce7f461801c34f067ce0f02873a8f1b0e44dfc69752accecd819f38fd8e8',
  62294. 'bc2da82b6fa5b571a7f09049776a1ef7ecd292238051c198c1a84e95b2b4ae17',
  62295. ],
  62296. [
  62297. 'e5037de0afc1d8d43d8348414bbf4103043ec8f575bfdc432953cc8d2037fa2d',
  62298. '4571534baa94d3b5f9f98d09fb990bddbd5f5b03ec481f10e0e5dc841d755bda',
  62299. ],
  62300. [
  62301. 'e06372b0f4a207adf5ea905e8f1771b4e7e8dbd1c6a6c5b725866a0ae4fce725',
  62302. '7a908974bce18cfe12a27bb2ad5a488cd7484a7787104870b27034f94eee31dd',
  62303. ],
  62304. [
  62305. '213c7a715cd5d45358d0bbf9dc0ce02204b10bdde2a3f58540ad6908d0559754',
  62306. '4b6dad0b5ae462507013ad06245ba190bb4850f5f36a7eeddff2c27534b458f2',
  62307. ],
  62308. [
  62309. '4e7c272a7af4b34e8dbb9352a5419a87e2838c70adc62cddf0cc3a3b08fbd53c',
  62310. '17749c766c9d0b18e16fd09f6def681b530b9614bff7dd33e0b3941817dcaae6',
  62311. ],
  62312. [
  62313. 'fea74e3dbe778b1b10f238ad61686aa5c76e3db2be43057632427e2840fb27b6',
  62314. '6e0568db9b0b13297cf674deccb6af93126b596b973f7b77701d3db7f23cb96f',
  62315. ],
  62316. [
  62317. '76e64113f677cf0e10a2570d599968d31544e179b760432952c02a4417bdde39',
  62318. 'c90ddf8dee4e95cf577066d70681f0d35e2a33d2b56d2032b4b1752d1901ac01',
  62319. ],
  62320. [
  62321. 'c738c56b03b2abe1e8281baa743f8f9a8f7cc643df26cbee3ab150242bcbb891',
  62322. '893fb578951ad2537f718f2eacbfbbbb82314eef7880cfe917e735d9699a84c3',
  62323. ],
  62324. [
  62325. 'd895626548b65b81e264c7637c972877d1d72e5f3a925014372e9f6588f6c14b',
  62326. 'febfaa38f2bc7eae728ec60818c340eb03428d632bb067e179363ed75d7d991f',
  62327. ],
  62328. [
  62329. 'b8da94032a957518eb0f6433571e8761ceffc73693e84edd49150a564f676e03',
  62330. '2804dfa44805a1e4d7c99cc9762808b092cc584d95ff3b511488e4e74efdf6e7',
  62331. ],
  62332. [
  62333. 'e80fea14441fb33a7d8adab9475d7fab2019effb5156a792f1a11778e3c0df5d',
  62334. 'eed1de7f638e00771e89768ca3ca94472d155e80af322ea9fcb4291b6ac9ec78',
  62335. ],
  62336. [
  62337. 'a301697bdfcd704313ba48e51d567543f2a182031efd6915ddc07bbcc4e16070',
  62338. '7370f91cfb67e4f5081809fa25d40f9b1735dbf7c0a11a130c0d1a041e177ea1',
  62339. ],
  62340. [
  62341. '90ad85b389d6b936463f9d0512678de208cc330b11307fffab7ac63e3fb04ed4',
  62342. 'e507a3620a38261affdcbd9427222b839aefabe1582894d991d4d48cb6ef150',
  62343. ],
  62344. [
  62345. '8f68b9d2f63b5f339239c1ad981f162ee88c5678723ea3351b7b444c9ec4c0da',
  62346. '662a9f2dba063986de1d90c2b6be215dbbea2cfe95510bfdf23cbf79501fff82',
  62347. ],
  62348. [
  62349. 'e4f3fb0176af85d65ff99ff9198c36091f48e86503681e3e6686fd5053231e11',
  62350. '1e63633ad0ef4f1c1661a6d0ea02b7286cc7e74ec951d1c9822c38576feb73bc',
  62351. ],
  62352. [
  62353. '8c00fa9b18ebf331eb961537a45a4266c7034f2f0d4e1d0716fb6eae20eae29e',
  62354. 'efa47267fea521a1a9dc343a3736c974c2fadafa81e36c54e7d2a4c66702414b',
  62355. ],
  62356. [
  62357. 'e7a26ce69dd4829f3e10cec0a9e98ed3143d084f308b92c0997fddfc60cb3e41',
  62358. '2a758e300fa7984b471b006a1aafbb18d0a6b2c0420e83e20e8a9421cf2cfd51',
  62359. ],
  62360. [
  62361. 'b6459e0ee3662ec8d23540c223bcbdc571cbcb967d79424f3cf29eb3de6b80ef',
  62362. '67c876d06f3e06de1dadf16e5661db3c4b3ae6d48e35b2ff30bf0b61a71ba45',
  62363. ],
  62364. [
  62365. 'd68a80c8280bb840793234aa118f06231d6f1fc67e73c5a5deda0f5b496943e8',
  62366. 'db8ba9fff4b586d00c4b1f9177b0e28b5b0e7b8f7845295a294c84266b133120',
  62367. ],
  62368. [
  62369. '324aed7df65c804252dc0270907a30b09612aeb973449cea4095980fc28d3d5d',
  62370. '648a365774b61f2ff130c0c35aec1f4f19213b0c7e332843967224af96ab7c84',
  62371. ],
  62372. [
  62373. '4df9c14919cde61f6d51dfdbe5fee5dceec4143ba8d1ca888e8bd373fd054c96',
  62374. '35ec51092d8728050974c23a1d85d4b5d506cdc288490192ebac06cad10d5d',
  62375. ],
  62376. [
  62377. '9c3919a84a474870faed8a9c1cc66021523489054d7f0308cbfc99c8ac1f98cd',
  62378. 'ddb84f0f4a4ddd57584f044bf260e641905326f76c64c8e6be7e5e03d4fc599d',
  62379. ],
  62380. [
  62381. '6057170b1dd12fdf8de05f281d8e06bb91e1493a8b91d4cc5a21382120a959e5',
  62382. '9a1af0b26a6a4807add9a2daf71df262465152bc3ee24c65e899be932385a2a8',
  62383. ],
  62384. [
  62385. 'a576df8e23a08411421439a4518da31880cef0fba7d4df12b1a6973eecb94266',
  62386. '40a6bf20e76640b2c92b97afe58cd82c432e10a7f514d9f3ee8be11ae1b28ec8',
  62387. ],
  62388. [
  62389. '7778a78c28dec3e30a05fe9629de8c38bb30d1f5cf9a3a208f763889be58ad71',
  62390. '34626d9ab5a5b22ff7098e12f2ff580087b38411ff24ac563b513fc1fd9f43ac',
  62391. ],
  62392. [
  62393. '928955ee637a84463729fd30e7afd2ed5f96274e5ad7e5cb09eda9c06d903ac',
  62394. 'c25621003d3f42a827b78a13093a95eeac3d26efa8a8d83fc5180e935bcd091f',
  62395. ],
  62396. [
  62397. '85d0fef3ec6db109399064f3a0e3b2855645b4a907ad354527aae75163d82751',
  62398. '1f03648413a38c0be29d496e582cf5663e8751e96877331582c237a24eb1f962',
  62399. ],
  62400. [
  62401. 'ff2b0dce97eece97c1c9b6041798b85dfdfb6d8882da20308f5404824526087e',
  62402. '493d13fef524ba188af4c4dc54d07936c7b7ed6fb90e2ceb2c951e01f0c29907',
  62403. ],
  62404. [
  62405. '827fbbe4b1e880ea9ed2b2e6301b212b57f1ee148cd6dd28780e5e2cf856e241',
  62406. 'c60f9c923c727b0b71bef2c67d1d12687ff7a63186903166d605b68baec293ec',
  62407. ],
  62408. [
  62409. 'eaa649f21f51bdbae7be4ae34ce6e5217a58fdce7f47f9aa7f3b58fa2120e2b3',
  62410. 'be3279ed5bbbb03ac69a80f89879aa5a01a6b965f13f7e59d47a5305ba5ad93d',
  62411. ],
  62412. [
  62413. 'e4a42d43c5cf169d9391df6decf42ee541b6d8f0c9a137401e23632dda34d24f',
  62414. '4d9f92e716d1c73526fc99ccfb8ad34ce886eedfa8d8e4f13a7f7131deba9414',
  62415. ],
  62416. [
  62417. '1ec80fef360cbdd954160fadab352b6b92b53576a88fea4947173b9d4300bf19',
  62418. 'aeefe93756b5340d2f3a4958a7abbf5e0146e77f6295a07b671cdc1cc107cefd',
  62419. ],
  62420. [
  62421. '146a778c04670c2f91b00af4680dfa8bce3490717d58ba889ddb5928366642be',
  62422. 'b318e0ec3354028add669827f9d4b2870aaa971d2f7e5ed1d0b297483d83efd0',
  62423. ],
  62424. [
  62425. 'fa50c0f61d22e5f07e3acebb1aa07b128d0012209a28b9776d76a8793180eef9',
  62426. '6b84c6922397eba9b72cd2872281a68a5e683293a57a213b38cd8d7d3f4f2811',
  62427. ],
  62428. [
  62429. 'da1d61d0ca721a11b1a5bf6b7d88e8421a288ab5d5bba5220e53d32b5f067ec2',
  62430. '8157f55a7c99306c79c0766161c91e2966a73899d279b48a655fba0f1ad836f1',
  62431. ],
  62432. [
  62433. 'a8e282ff0c9706907215ff98e8fd416615311de0446f1e062a73b0610d064e13',
  62434. '7f97355b8db81c09abfb7f3c5b2515888b679a3e50dd6bd6cef7c73111f4cc0c',
  62435. ],
  62436. [
  62437. '174a53b9c9a285872d39e56e6913cab15d59b1fa512508c022f382de8319497c',
  62438. 'ccc9dc37abfc9c1657b4155f2c47f9e6646b3a1d8cb9854383da13ac079afa73',
  62439. ],
  62440. [
  62441. '959396981943785c3d3e57edf5018cdbe039e730e4918b3d884fdff09475b7ba',
  62442. '2e7e552888c331dd8ba0386a4b9cd6849c653f64c8709385e9b8abf87524f2fd',
  62443. ],
  62444. [
  62445. 'd2a63a50ae401e56d645a1153b109a8fcca0a43d561fba2dbb51340c9d82b151',
  62446. 'e82d86fb6443fcb7565aee58b2948220a70f750af484ca52d4142174dcf89405',
  62447. ],
  62448. [
  62449. '64587e2335471eb890ee7896d7cfdc866bacbdbd3839317b3436f9b45617e073',
  62450. 'd99fcdd5bf6902e2ae96dd6447c299a185b90a39133aeab358299e5e9faf6589',
  62451. ],
  62452. [
  62453. '8481bde0e4e4d885b3a546d3e549de042f0aa6cea250e7fd358d6c86dd45e458',
  62454. '38ee7b8cba5404dd84a25bf39cecb2ca900a79c42b262e556d64b1b59779057e',
  62455. ],
  62456. [
  62457. '13464a57a78102aa62b6979ae817f4637ffcfed3c4b1ce30bcd6303f6caf666b',
  62458. '69be159004614580ef7e433453ccb0ca48f300a81d0942e13f495a907f6ecc27',
  62459. ],
  62460. [
  62461. 'bc4a9df5b713fe2e9aef430bcc1dc97a0cd9ccede2f28588cada3a0d2d83f366',
  62462. 'd3a81ca6e785c06383937adf4b798caa6e8a9fbfa547b16d758d666581f33c1',
  62463. ],
  62464. [
  62465. '8c28a97bf8298bc0d23d8c749452a32e694b65e30a9472a3954ab30fe5324caa',
  62466. '40a30463a3305193378fedf31f7cc0eb7ae784f0451cb9459e71dc73cbef9482',
  62467. ],
  62468. [
  62469. '8ea9666139527a8c1dd94ce4f071fd23c8b350c5a4bb33748c4ba111faccae0',
  62470. '620efabbc8ee2782e24e7c0cfb95c5d735b783be9cf0f8e955af34a30e62b945',
  62471. ],
  62472. [
  62473. 'dd3625faef5ba06074669716bbd3788d89bdde815959968092f76cc4eb9a9787',
  62474. '7a188fa3520e30d461da2501045731ca941461982883395937f68d00c644a573',
  62475. ],
  62476. [
  62477. 'f710d79d9eb962297e4f6232b40e8f7feb2bc63814614d692c12de752408221e',
  62478. 'ea98e67232d3b3295d3b535532115ccac8612c721851617526ae47a9c77bfc82',
  62479. ],
  62480. ],
  62481. },
  62482. naf: {
  62483. wnd: 7,
  62484. points: [
  62485. [
  62486. 'f9308a019258c31049344f85f89d5229b531c845836f99b08601f113bce036f9',
  62487. '388f7b0f632de8140fe337e62a37f3566500a99934c2231b6cb9fd7584b8e672',
  62488. ],
  62489. [
  62490. '2f8bde4d1a07209355b4a7250a5c5128e88b84bddc619ab7cba8d569b240efe4',
  62491. 'd8ac222636e5e3d6d4dba9dda6c9c426f788271bab0d6840dca87d3aa6ac62d6',
  62492. ],
  62493. [
  62494. '5cbdf0646e5db4eaa398f365f2ea7a0e3d419b7e0330e39ce92bddedcac4f9bc',
  62495. '6aebca40ba255960a3178d6d861a54dba813d0b813fde7b5a5082628087264da',
  62496. ],
  62497. [
  62498. 'acd484e2f0c7f65309ad178a9f559abde09796974c57e714c35f110dfc27ccbe',
  62499. 'cc338921b0a7d9fd64380971763b61e9add888a4375f8e0f05cc262ac64f9c37',
  62500. ],
  62501. [
  62502. '774ae7f858a9411e5ef4246b70c65aac5649980be5c17891bbec17895da008cb',
  62503. 'd984a032eb6b5e190243dd56d7b7b365372db1e2dff9d6a8301d74c9c953c61b',
  62504. ],
  62505. [
  62506. 'f28773c2d975288bc7d1d205c3748651b075fbc6610e58cddeeddf8f19405aa8',
  62507. 'ab0902e8d880a89758212eb65cdaf473a1a06da521fa91f29b5cb52db03ed81',
  62508. ],
  62509. [
  62510. 'd7924d4f7d43ea965a465ae3095ff41131e5946f3c85f79e44adbcf8e27e080e',
  62511. '581e2872a86c72a683842ec228cc6defea40af2bd896d3a5c504dc9ff6a26b58',
  62512. ],
  62513. [
  62514. 'defdea4cdb677750a420fee807eacf21eb9898ae79b9768766e4faa04a2d4a34',
  62515. '4211ab0694635168e997b0ead2a93daeced1f4a04a95c0f6cfb199f69e56eb77',
  62516. ],
  62517. [
  62518. '2b4ea0a797a443d293ef5cff444f4979f06acfebd7e86d277475656138385b6c',
  62519. '85e89bc037945d93b343083b5a1c86131a01f60c50269763b570c854e5c09b7a',
  62520. ],
  62521. [
  62522. '352bbf4a4cdd12564f93fa332ce333301d9ad40271f8107181340aef25be59d5',
  62523. '321eb4075348f534d59c18259dda3e1f4a1b3b2e71b1039c67bd3d8bcf81998c',
  62524. ],
  62525. [
  62526. '2fa2104d6b38d11b0230010559879124e42ab8dfeff5ff29dc9cdadd4ecacc3f',
  62527. '2de1068295dd865b64569335bd5dd80181d70ecfc882648423ba76b532b7d67',
  62528. ],
  62529. [
  62530. '9248279b09b4d68dab21a9b066edda83263c3d84e09572e269ca0cd7f5453714',
  62531. '73016f7bf234aade5d1aa71bdea2b1ff3fc0de2a887912ffe54a32ce97cb3402',
  62532. ],
  62533. [
  62534. 'daed4f2be3a8bf278e70132fb0beb7522f570e144bf615c07e996d443dee8729',
  62535. 'a69dce4a7d6c98e8d4a1aca87ef8d7003f83c230f3afa726ab40e52290be1c55',
  62536. ],
  62537. [
  62538. 'c44d12c7065d812e8acf28d7cbb19f9011ecd9e9fdf281b0e6a3b5e87d22e7db',
  62539. '2119a460ce326cdc76c45926c982fdac0e106e861edf61c5a039063f0e0e6482',
  62540. ],
  62541. [
  62542. '6a245bf6dc698504c89a20cfded60853152b695336c28063b61c65cbd269e6b4',
  62543. 'e022cf42c2bd4a708b3f5126f16a24ad8b33ba48d0423b6efd5e6348100d8a82',
  62544. ],
  62545. [
  62546. '1697ffa6fd9de627c077e3d2fe541084ce13300b0bec1146f95ae57f0d0bd6a5',
  62547. 'b9c398f186806f5d27561506e4557433a2cf15009e498ae7adee9d63d01b2396',
  62548. ],
  62549. [
  62550. '605bdb019981718b986d0f07e834cb0d9deb8360ffb7f61df982345ef27a7479',
  62551. '2972d2de4f8d20681a78d93ec96fe23c26bfae84fb14db43b01e1e9056b8c49',
  62552. ],
  62553. [
  62554. '62d14dab4150bf497402fdc45a215e10dcb01c354959b10cfe31c7e9d87ff33d',
  62555. '80fc06bd8cc5b01098088a1950eed0db01aa132967ab472235f5642483b25eaf',
  62556. ],
  62557. [
  62558. '80c60ad0040f27dade5b4b06c408e56b2c50e9f56b9b8b425e555c2f86308b6f',
  62559. '1c38303f1cc5c30f26e66bad7fe72f70a65eed4cbe7024eb1aa01f56430bd57a',
  62560. ],
  62561. [
  62562. '7a9375ad6167ad54aa74c6348cc54d344cc5dc9487d847049d5eabb0fa03c8fb',
  62563. 'd0e3fa9eca8726909559e0d79269046bdc59ea10c70ce2b02d499ec224dc7f7',
  62564. ],
  62565. [
  62566. 'd528ecd9b696b54c907a9ed045447a79bb408ec39b68df504bb51f459bc3ffc9',
  62567. 'eecf41253136e5f99966f21881fd656ebc4345405c520dbc063465b521409933',
  62568. ],
  62569. [
  62570. '49370a4b5f43412ea25f514e8ecdad05266115e4a7ecb1387231808f8b45963',
  62571. '758f3f41afd6ed428b3081b0512fd62a54c3f3afbb5b6764b653052a12949c9a',
  62572. ],
  62573. [
  62574. '77f230936ee88cbbd73df930d64702ef881d811e0e1498e2f1c13eb1fc345d74',
  62575. '958ef42a7886b6400a08266e9ba1b37896c95330d97077cbbe8eb3c7671c60d6',
  62576. ],
  62577. [
  62578. 'f2dac991cc4ce4b9ea44887e5c7c0bce58c80074ab9d4dbaeb28531b7739f530',
  62579. 'e0dedc9b3b2f8dad4da1f32dec2531df9eb5fbeb0598e4fd1a117dba703a3c37',
  62580. ],
  62581. [
  62582. '463b3d9f662621fb1b4be8fbbe2520125a216cdfc9dae3debcba4850c690d45b',
  62583. '5ed430d78c296c3543114306dd8622d7c622e27c970a1de31cb377b01af7307e',
  62584. ],
  62585. [
  62586. 'f16f804244e46e2a09232d4aff3b59976b98fac14328a2d1a32496b49998f247',
  62587. 'cedabd9b82203f7e13d206fcdf4e33d92a6c53c26e5cce26d6579962c4e31df6',
  62588. ],
  62589. [
  62590. 'caf754272dc84563b0352b7a14311af55d245315ace27c65369e15f7151d41d1',
  62591. 'cb474660ef35f5f2a41b643fa5e460575f4fa9b7962232a5c32f908318a04476',
  62592. ],
  62593. [
  62594. '2600ca4b282cb986f85d0f1709979d8b44a09c07cb86d7c124497bc86f082120',
  62595. '4119b88753c15bd6a693b03fcddbb45d5ac6be74ab5f0ef44b0be9475a7e4b40',
  62596. ],
  62597. [
  62598. '7635ca72d7e8432c338ec53cd12220bc01c48685e24f7dc8c602a7746998e435',
  62599. '91b649609489d613d1d5e590f78e6d74ecfc061d57048bad9e76f302c5b9c61',
  62600. ],
  62601. [
  62602. '754e3239f325570cdbbf4a87deee8a66b7f2b33479d468fbc1a50743bf56cc18',
  62603. '673fb86e5bda30fb3cd0ed304ea49a023ee33d0197a695d0c5d98093c536683',
  62604. ],
  62605. [
  62606. 'e3e6bd1071a1e96aff57859c82d570f0330800661d1c952f9fe2694691d9b9e8',
  62607. '59c9e0bba394e76f40c0aa58379a3cb6a5a2283993e90c4167002af4920e37f5',
  62608. ],
  62609. [
  62610. '186b483d056a033826ae73d88f732985c4ccb1f32ba35f4b4cc47fdcf04aa6eb',
  62611. '3b952d32c67cf77e2e17446e204180ab21fb8090895138b4a4a797f86e80888b',
  62612. ],
  62613. [
  62614. 'df9d70a6b9876ce544c98561f4be4f725442e6d2b737d9c91a8321724ce0963f',
  62615. '55eb2dafd84d6ccd5f862b785dc39d4ab157222720ef9da217b8c45cf2ba2417',
  62616. ],
  62617. [
  62618. '5edd5cc23c51e87a497ca815d5dce0f8ab52554f849ed8995de64c5f34ce7143',
  62619. 'efae9c8dbc14130661e8cec030c89ad0c13c66c0d17a2905cdc706ab7399a868',
  62620. ],
  62621. [
  62622. '290798c2b6476830da12fe02287e9e777aa3fba1c355b17a722d362f84614fba',
  62623. 'e38da76dcd440621988d00bcf79af25d5b29c094db2a23146d003afd41943e7a',
  62624. ],
  62625. [
  62626. 'af3c423a95d9f5b3054754efa150ac39cd29552fe360257362dfdecef4053b45',
  62627. 'f98a3fd831eb2b749a93b0e6f35cfb40c8cd5aa667a15581bc2feded498fd9c6',
  62628. ],
  62629. [
  62630. '766dbb24d134e745cccaa28c99bf274906bb66b26dcf98df8d2fed50d884249a',
  62631. '744b1152eacbe5e38dcc887980da38b897584a65fa06cedd2c924f97cbac5996',
  62632. ],
  62633. [
  62634. '59dbf46f8c94759ba21277c33784f41645f7b44f6c596a58ce92e666191abe3e',
  62635. 'c534ad44175fbc300f4ea6ce648309a042ce739a7919798cd85e216c4a307f6e',
  62636. ],
  62637. [
  62638. 'f13ada95103c4537305e691e74e9a4a8dd647e711a95e73cb62dc6018cfd87b8',
  62639. 'e13817b44ee14de663bf4bc808341f326949e21a6a75c2570778419bdaf5733d',
  62640. ],
  62641. [
  62642. '7754b4fa0e8aced06d4167a2c59cca4cda1869c06ebadfb6488550015a88522c',
  62643. '30e93e864e669d82224b967c3020b8fa8d1e4e350b6cbcc537a48b57841163a2',
  62644. ],
  62645. [
  62646. '948dcadf5990e048aa3874d46abef9d701858f95de8041d2a6828c99e2262519',
  62647. 'e491a42537f6e597d5d28a3224b1bc25df9154efbd2ef1d2cbba2cae5347d57e',
  62648. ],
  62649. [
  62650. '7962414450c76c1689c7b48f8202ec37fb224cf5ac0bfa1570328a8a3d7c77ab',
  62651. '100b610ec4ffb4760d5c1fc133ef6f6b12507a051f04ac5760afa5b29db83437',
  62652. ],
  62653. [
  62654. '3514087834964b54b15b160644d915485a16977225b8847bb0dd085137ec47ca',
  62655. 'ef0afbb2056205448e1652c48e8127fc6039e77c15c2378b7e7d15a0de293311',
  62656. ],
  62657. [
  62658. 'd3cc30ad6b483e4bc79ce2c9dd8bc54993e947eb8df787b442943d3f7b527eaf',
  62659. '8b378a22d827278d89c5e9be8f9508ae3c2ad46290358630afb34db04eede0a4',
  62660. ],
  62661. [
  62662. '1624d84780732860ce1c78fcbfefe08b2b29823db913f6493975ba0ff4847610',
  62663. '68651cf9b6da903e0914448c6cd9d4ca896878f5282be4c8cc06e2a404078575',
  62664. ],
  62665. [
  62666. '733ce80da955a8a26902c95633e62a985192474b5af207da6df7b4fd5fc61cd4',
  62667. 'f5435a2bd2badf7d485a4d8b8db9fcce3e1ef8e0201e4578c54673bc1dc5ea1d',
  62668. ],
  62669. [
  62670. '15d9441254945064cf1a1c33bbd3b49f8966c5092171e699ef258dfab81c045c',
  62671. 'd56eb30b69463e7234f5137b73b84177434800bacebfc685fc37bbe9efe4070d',
  62672. ],
  62673. [
  62674. 'a1d0fcf2ec9de675b612136e5ce70d271c21417c9d2b8aaaac138599d0717940',
  62675. 'edd77f50bcb5a3cab2e90737309667f2641462a54070f3d519212d39c197a629',
  62676. ],
  62677. [
  62678. 'e22fbe15c0af8ccc5780c0735f84dbe9a790badee8245c06c7ca37331cb36980',
  62679. 'a855babad5cd60c88b430a69f53a1a7a38289154964799be43d06d77d31da06',
  62680. ],
  62681. [
  62682. '311091dd9860e8e20ee13473c1155f5f69635e394704eaa74009452246cfa9b3',
  62683. '66db656f87d1f04fffd1f04788c06830871ec5a64feee685bd80f0b1286d8374',
  62684. ],
  62685. [
  62686. '34c1fd04d301be89b31c0442d3e6ac24883928b45a9340781867d4232ec2dbdf',
  62687. '9414685e97b1b5954bd46f730174136d57f1ceeb487443dc5321857ba73abee',
  62688. ],
  62689. [
  62690. 'f219ea5d6b54701c1c14de5b557eb42a8d13f3abbcd08affcc2a5e6b049b8d63',
  62691. '4cb95957e83d40b0f73af4544cccf6b1f4b08d3c07b27fb8d8c2962a400766d1',
  62692. ],
  62693. [
  62694. 'd7b8740f74a8fbaab1f683db8f45de26543a5490bca627087236912469a0b448',
  62695. 'fa77968128d9c92ee1010f337ad4717eff15db5ed3c049b3411e0315eaa4593b',
  62696. ],
  62697. [
  62698. '32d31c222f8f6f0ef86f7c98d3a3335ead5bcd32abdd94289fe4d3091aa824bf',
  62699. '5f3032f5892156e39ccd3d7915b9e1da2e6dac9e6f26e961118d14b8462e1661',
  62700. ],
  62701. [
  62702. '7461f371914ab32671045a155d9831ea8793d77cd59592c4340f86cbc18347b5',
  62703. '8ec0ba238b96bec0cbdddcae0aa442542eee1ff50c986ea6b39847b3cc092ff6',
  62704. ],
  62705. [
  62706. 'ee079adb1df1860074356a25aa38206a6d716b2c3e67453d287698bad7b2b2d6',
  62707. '8dc2412aafe3be5c4c5f37e0ecc5f9f6a446989af04c4e25ebaac479ec1c8c1e',
  62708. ],
  62709. [
  62710. '16ec93e447ec83f0467b18302ee620f7e65de331874c9dc72bfd8616ba9da6b5',
  62711. '5e4631150e62fb40d0e8c2a7ca5804a39d58186a50e497139626778e25b0674d',
  62712. ],
  62713. [
  62714. 'eaa5f980c245f6f038978290afa70b6bd8855897f98b6aa485b96065d537bd99',
  62715. 'f65f5d3e292c2e0819a528391c994624d784869d7e6ea67fb18041024edc07dc',
  62716. ],
  62717. [
  62718. '78c9407544ac132692ee1910a02439958ae04877151342ea96c4b6b35a49f51',
  62719. 'f3e0319169eb9b85d5404795539a5e68fa1fbd583c064d2462b675f194a3ddb4',
  62720. ],
  62721. [
  62722. '494f4be219a1a77016dcd838431aea0001cdc8ae7a6fc688726578d9702857a5',
  62723. '42242a969283a5f339ba7f075e36ba2af925ce30d767ed6e55f4b031880d562c',
  62724. ],
  62725. [
  62726. 'a598a8030da6d86c6bc7f2f5144ea549d28211ea58faa70ebf4c1e665c1fe9b5',
  62727. '204b5d6f84822c307e4b4a7140737aec23fc63b65b35f86a10026dbd2d864e6b',
  62728. ],
  62729. [
  62730. 'c41916365abb2b5d09192f5f2dbeafec208f020f12570a184dbadc3e58595997',
  62731. '4f14351d0087efa49d245b328984989d5caf9450f34bfc0ed16e96b58fa9913',
  62732. ],
  62733. [
  62734. '841d6063a586fa475a724604da03bc5b92a2e0d2e0a36acfe4c73a5514742881',
  62735. '73867f59c0659e81904f9a1c7543698e62562d6744c169ce7a36de01a8d6154',
  62736. ],
  62737. [
  62738. '5e95bb399a6971d376026947f89bde2f282b33810928be4ded112ac4d70e20d5',
  62739. '39f23f366809085beebfc71181313775a99c9aed7d8ba38b161384c746012865',
  62740. ],
  62741. [
  62742. '36e4641a53948fd476c39f8a99fd974e5ec07564b5315d8bf99471bca0ef2f66',
  62743. 'd2424b1b1abe4eb8164227b085c9aa9456ea13493fd563e06fd51cf5694c78fc',
  62744. ],
  62745. [
  62746. '336581ea7bfbbb290c191a2f507a41cf5643842170e914faeab27c2c579f726',
  62747. 'ead12168595fe1be99252129b6e56b3391f7ab1410cd1e0ef3dcdcabd2fda224',
  62748. ],
  62749. [
  62750. '8ab89816dadfd6b6a1f2634fcf00ec8403781025ed6890c4849742706bd43ede',
  62751. '6fdcef09f2f6d0a044e654aef624136f503d459c3e89845858a47a9129cdd24e',
  62752. ],
  62753. [
  62754. '1e33f1a746c9c5778133344d9299fcaa20b0938e8acff2544bb40284b8c5fb94',
  62755. '60660257dd11b3aa9c8ed618d24edff2306d320f1d03010e33a7d2057f3b3b6',
  62756. ],
  62757. [
  62758. '85b7c1dcb3cec1b7ee7f30ded79dd20a0ed1f4cc18cbcfcfa410361fd8f08f31',
  62759. '3d98a9cdd026dd43f39048f25a8847f4fcafad1895d7a633c6fed3c35e999511',
  62760. ],
  62761. [
  62762. '29df9fbd8d9e46509275f4b125d6d45d7fbe9a3b878a7af872a2800661ac5f51',
  62763. 'b4c4fe99c775a606e2d8862179139ffda61dc861c019e55cd2876eb2a27d84b',
  62764. ],
  62765. [
  62766. 'a0b1cae06b0a847a3fea6e671aaf8adfdfe58ca2f768105c8082b2e449fce252',
  62767. 'ae434102edde0958ec4b19d917a6a28e6b72da1834aff0e650f049503a296cf2',
  62768. ],
  62769. [
  62770. '4e8ceafb9b3e9a136dc7ff67e840295b499dfb3b2133e4ba113f2e4c0e121e5',
  62771. 'cf2174118c8b6d7a4b48f6d534ce5c79422c086a63460502b827ce62a326683c',
  62772. ],
  62773. [
  62774. 'd24a44e047e19b6f5afb81c7ca2f69080a5076689a010919f42725c2b789a33b',
  62775. '6fb8d5591b466f8fc63db50f1c0f1c69013f996887b8244d2cdec417afea8fa3',
  62776. ],
  62777. [
  62778. 'ea01606a7a6c9cdd249fdfcfacb99584001edd28abbab77b5104e98e8e3b35d4',
  62779. '322af4908c7312b0cfbfe369f7a7b3cdb7d4494bc2823700cfd652188a3ea98d',
  62780. ],
  62781. [
  62782. 'af8addbf2b661c8a6c6328655eb96651252007d8c5ea31be4ad196de8ce2131f',
  62783. '6749e67c029b85f52a034eafd096836b2520818680e26ac8f3dfbcdb71749700',
  62784. ],
  62785. [
  62786. 'e3ae1974566ca06cc516d47e0fb165a674a3dabcfca15e722f0e3450f45889',
  62787. '2aeabe7e4531510116217f07bf4d07300de97e4874f81f533420a72eeb0bd6a4',
  62788. ],
  62789. [
  62790. '591ee355313d99721cf6993ffed1e3e301993ff3ed258802075ea8ced397e246',
  62791. 'b0ea558a113c30bea60fc4775460c7901ff0b053d25ca2bdeee98f1a4be5d196',
  62792. ],
  62793. [
  62794. '11396d55fda54c49f19aa97318d8da61fa8584e47b084945077cf03255b52984',
  62795. '998c74a8cd45ac01289d5833a7beb4744ff536b01b257be4c5767bea93ea57a4',
  62796. ],
  62797. [
  62798. '3c5d2a1ba39c5a1790000738c9e0c40b8dcdfd5468754b6405540157e017aa7a',
  62799. 'b2284279995a34e2f9d4de7396fc18b80f9b8b9fdd270f6661f79ca4c81bd257',
  62800. ],
  62801. [
  62802. 'cc8704b8a60a0defa3a99a7299f2e9c3fbc395afb04ac078425ef8a1793cc030',
  62803. 'bdd46039feed17881d1e0862db347f8cf395b74fc4bcdc4e940b74e3ac1f1b13',
  62804. ],
  62805. [
  62806. 'c533e4f7ea8555aacd9777ac5cad29b97dd4defccc53ee7ea204119b2889b197',
  62807. '6f0a256bc5efdf429a2fb6242f1a43a2d9b925bb4a4b3a26bb8e0f45eb596096',
  62808. ],
  62809. [
  62810. 'c14f8f2ccb27d6f109f6d08d03cc96a69ba8c34eec07bbcf566d48e33da6593',
  62811. 'c359d6923bb398f7fd4473e16fe1c28475b740dd098075e6c0e8649113dc3a38',
  62812. ],
  62813. [
  62814. 'a6cbc3046bc6a450bac24789fa17115a4c9739ed75f8f21ce441f72e0b90e6ef',
  62815. '21ae7f4680e889bb130619e2c0f95a360ceb573c70603139862afd617fa9b9f',
  62816. ],
  62817. [
  62818. '347d6d9a02c48927ebfb86c1359b1caf130a3c0267d11ce6344b39f99d43cc38',
  62819. '60ea7f61a353524d1c987f6ecec92f086d565ab687870cb12689ff1e31c74448',
  62820. ],
  62821. [
  62822. 'da6545d2181db8d983f7dcb375ef5866d47c67b1bf31c8cf855ef7437b72656a',
  62823. '49b96715ab6878a79e78f07ce5680c5d6673051b4935bd897fea824b77dc208a',
  62824. ],
  62825. [
  62826. 'c40747cc9d012cb1a13b8148309c6de7ec25d6945d657146b9d5994b8feb1111',
  62827. '5ca560753be2a12fc6de6caf2cb489565db936156b9514e1bb5e83037e0fa2d4',
  62828. ],
  62829. [
  62830. '4e42c8ec82c99798ccf3a610be870e78338c7f713348bd34c8203ef4037f3502',
  62831. '7571d74ee5e0fb92a7a8b33a07783341a5492144cc54bcc40a94473693606437',
  62832. ],
  62833. [
  62834. '3775ab7089bc6af823aba2e1af70b236d251cadb0c86743287522a1b3b0dedea',
  62835. 'be52d107bcfa09d8bcb9736a828cfa7fac8db17bf7a76a2c42ad961409018cf7',
  62836. ],
  62837. [
  62838. 'cee31cbf7e34ec379d94fb814d3d775ad954595d1314ba8846959e3e82f74e26',
  62839. '8fd64a14c06b589c26b947ae2bcf6bfa0149ef0be14ed4d80f448a01c43b1c6d',
  62840. ],
  62841. [
  62842. 'b4f9eaea09b6917619f6ea6a4eb5464efddb58fd45b1ebefcdc1a01d08b47986',
  62843. '39e5c9925b5a54b07433a4f18c61726f8bb131c012ca542eb24a8ac07200682a',
  62844. ],
  62845. [
  62846. 'd4263dfc3d2df923a0179a48966d30ce84e2515afc3dccc1b77907792ebcc60e',
  62847. '62dfaf07a0f78feb30e30d6295853ce189e127760ad6cf7fae164e122a208d54',
  62848. ],
  62849. [
  62850. '48457524820fa65a4f8d35eb6930857c0032acc0a4a2de422233eeda897612c4',
  62851. '25a748ab367979d98733c38a1fa1c2e7dc6cc07db2d60a9ae7a76aaa49bd0f77',
  62852. ],
  62853. [
  62854. 'dfeeef1881101f2cb11644f3a2afdfc2045e19919152923f367a1767c11cceda',
  62855. 'ecfb7056cf1de042f9420bab396793c0c390bde74b4bbdff16a83ae09a9a7517',
  62856. ],
  62857. [
  62858. '6d7ef6b17543f8373c573f44e1f389835d89bcbc6062ced36c82df83b8fae859',
  62859. 'cd450ec335438986dfefa10c57fea9bcc521a0959b2d80bbf74b190dca712d10',
  62860. ],
  62861. [
  62862. 'e75605d59102a5a2684500d3b991f2e3f3c88b93225547035af25af66e04541f',
  62863. 'f5c54754a8f71ee540b9b48728473e314f729ac5308b06938360990e2bfad125',
  62864. ],
  62865. [
  62866. 'eb98660f4c4dfaa06a2be453d5020bc99a0c2e60abe388457dd43fefb1ed620c',
  62867. '6cb9a8876d9cb8520609af3add26cd20a0a7cd8a9411131ce85f44100099223e',
  62868. ],
  62869. [
  62870. '13e87b027d8514d35939f2e6892b19922154596941888336dc3563e3b8dba942',
  62871. 'fef5a3c68059a6dec5d624114bf1e91aac2b9da568d6abeb2570d55646b8adf1',
  62872. ],
  62873. [
  62874. 'ee163026e9fd6fe017c38f06a5be6fc125424b371ce2708e7bf4491691e5764a',
  62875. '1acb250f255dd61c43d94ccc670d0f58f49ae3fa15b96623e5430da0ad6c62b2',
  62876. ],
  62877. [
  62878. 'b268f5ef9ad51e4d78de3a750c2dc89b1e626d43505867999932e5db33af3d80',
  62879. '5f310d4b3c99b9ebb19f77d41c1dee018cf0d34fd4191614003e945a1216e423',
  62880. ],
  62881. [
  62882. 'ff07f3118a9df035e9fad85eb6c7bfe42b02f01ca99ceea3bf7ffdba93c4750d',
  62883. '438136d603e858a3a5c440c38eccbaddc1d2942114e2eddd4740d098ced1f0d8',
  62884. ],
  62885. [
  62886. '8d8b9855c7c052a34146fd20ffb658bea4b9f69e0d825ebec16e8c3ce2b526a1',
  62887. 'cdb559eedc2d79f926baf44fb84ea4d44bcf50fee51d7ceb30e2e7f463036758',
  62888. ],
  62889. [
  62890. '52db0b5384dfbf05bfa9d472d7ae26dfe4b851ceca91b1eba54263180da32b63',
  62891. 'c3b997d050ee5d423ebaf66a6db9f57b3180c902875679de924b69d84a7b375',
  62892. ],
  62893. [
  62894. 'e62f9490d3d51da6395efd24e80919cc7d0f29c3f3fa48c6fff543becbd43352',
  62895. '6d89ad7ba4876b0b22c2ca280c682862f342c8591f1daf5170e07bfd9ccafa7d',
  62896. ],
  62897. [
  62898. '7f30ea2476b399b4957509c88f77d0191afa2ff5cb7b14fd6d8e7d65aaab1193',
  62899. 'ca5ef7d4b231c94c3b15389a5f6311e9daff7bb67b103e9880ef4bff637acaec',
  62900. ],
  62901. [
  62902. '5098ff1e1d9f14fb46a210fada6c903fef0fb7b4a1dd1d9ac60a0361800b7a00',
  62903. '9731141d81fc8f8084d37c6e7542006b3ee1b40d60dfe5362a5b132fd17ddc0',
  62904. ],
  62905. [
  62906. '32b78c7de9ee512a72895be6b9cbefa6e2f3c4ccce445c96b9f2c81e2778ad58',
  62907. 'ee1849f513df71e32efc3896ee28260c73bb80547ae2275ba497237794c8753c',
  62908. ],
  62909. [
  62910. 'e2cb74fddc8e9fbcd076eef2a7c72b0ce37d50f08269dfc074b581550547a4f7',
  62911. 'd3aa2ed71c9dd2247a62df062736eb0baddea9e36122d2be8641abcb005cc4a4',
  62912. ],
  62913. [
  62914. '8438447566d4d7bedadc299496ab357426009a35f235cb141be0d99cd10ae3a8',
  62915. 'c4e1020916980a4da5d01ac5e6ad330734ef0d7906631c4f2390426b2edd791f',
  62916. ],
  62917. [
  62918. '4162d488b89402039b584c6fc6c308870587d9c46f660b878ab65c82c711d67e',
  62919. '67163e903236289f776f22c25fb8a3afc1732f2b84b4e95dbda47ae5a0852649',
  62920. ],
  62921. [
  62922. '3fad3fa84caf0f34f0f89bfd2dcf54fc175d767aec3e50684f3ba4a4bf5f683d',
  62923. 'cd1bc7cb6cc407bb2f0ca647c718a730cf71872e7d0d2a53fa20efcdfe61826',
  62924. ],
  62925. [
  62926. '674f2600a3007a00568c1a7ce05d0816c1fb84bf1370798f1c69532faeb1a86b',
  62927. '299d21f9413f33b3edf43b257004580b70db57da0b182259e09eecc69e0d38a5',
  62928. ],
  62929. [
  62930. 'd32f4da54ade74abb81b815ad1fb3b263d82d6c692714bcff87d29bd5ee9f08f',
  62931. 'f9429e738b8e53b968e99016c059707782e14f4535359d582fc416910b3eea87',
  62932. ],
  62933. [
  62934. '30e4e670435385556e593657135845d36fbb6931f72b08cb1ed954f1e3ce3ff6',
  62935. '462f9bce619898638499350113bbc9b10a878d35da70740dc695a559eb88db7b',
  62936. ],
  62937. [
  62938. 'be2062003c51cc3004682904330e4dee7f3dcd10b01e580bf1971b04d4cad297',
  62939. '62188bc49d61e5428573d48a74e1c655b1c61090905682a0d5558ed72dccb9bc',
  62940. ],
  62941. [
  62942. '93144423ace3451ed29e0fb9ac2af211cb6e84a601df5993c419859fff5df04a',
  62943. '7c10dfb164c3425f5c71a3f9d7992038f1065224f72bb9d1d902a6d13037b47c',
  62944. ],
  62945. [
  62946. 'b015f8044f5fcbdcf21ca26d6c34fb8197829205c7b7d2a7cb66418c157b112c',
  62947. 'ab8c1e086d04e813744a655b2df8d5f83b3cdc6faa3088c1d3aea1454e3a1d5f',
  62948. ],
  62949. [
  62950. 'd5e9e1da649d97d89e4868117a465a3a4f8a18de57a140d36b3f2af341a21b52',
  62951. '4cb04437f391ed73111a13cc1d4dd0db1693465c2240480d8955e8592f27447a',
  62952. ],
  62953. [
  62954. 'd3ae41047dd7ca065dbf8ed77b992439983005cd72e16d6f996a5316d36966bb',
  62955. 'bd1aeb21ad22ebb22a10f0303417c6d964f8cdd7df0aca614b10dc14d125ac46',
  62956. ],
  62957. [
  62958. '463e2763d885f958fc66cdd22800f0a487197d0a82e377b49f80af87c897b065',
  62959. 'bfefacdb0e5d0fd7df3a311a94de062b26b80c61fbc97508b79992671ef7ca7f',
  62960. ],
  62961. [
  62962. '7985fdfd127c0567c6f53ec1bb63ec3158e597c40bfe747c83cddfc910641917',
  62963. '603c12daf3d9862ef2b25fe1de289aed24ed291e0ec6708703a5bd567f32ed03',
  62964. ],
  62965. [
  62966. '74a1ad6b5f76e39db2dd249410eac7f99e74c59cb83d2d0ed5ff1543da7703e9',
  62967. 'cc6157ef18c9c63cd6193d83631bbea0093e0968942e8c33d5737fd790e0db08',
  62968. ],
  62969. [
  62970. '30682a50703375f602d416664ba19b7fc9bab42c72747463a71d0896b22f6da3',
  62971. '553e04f6b018b4fa6c8f39e7f311d3176290d0e0f19ca73f17714d9977a22ff8',
  62972. ],
  62973. [
  62974. '9e2158f0d7c0d5f26c3791efefa79597654e7a2b2464f52b1ee6c1347769ef57',
  62975. '712fcdd1b9053f09003a3481fa7762e9ffd7c8ef35a38509e2fbf2629008373',
  62976. ],
  62977. [
  62978. '176e26989a43c9cfeba4029c202538c28172e566e3c4fce7322857f3be327d66',
  62979. 'ed8cc9d04b29eb877d270b4878dc43c19aefd31f4eee09ee7b47834c1fa4b1c3',
  62980. ],
  62981. [
  62982. '75d46efea3771e6e68abb89a13ad747ecf1892393dfc4f1b7004788c50374da8',
  62983. '9852390a99507679fd0b86fd2b39a868d7efc22151346e1a3ca4726586a6bed8',
  62984. ],
  62985. [
  62986. '809a20c67d64900ffb698c4c825f6d5f2310fb0451c869345b7319f645605721',
  62987. '9e994980d9917e22b76b061927fa04143d096ccc54963e6a5ebfa5f3f8e286c1',
  62988. ],
  62989. [
  62990. '1b38903a43f7f114ed4500b4eac7083fdefece1cf29c63528d563446f972c180',
  62991. '4036edc931a60ae889353f77fd53de4a2708b26b6f5da72ad3394119daf408f9',
  62992. ],
  62993. ],
  62994. },
  62995. };
  62996. },{}],768:[function(_dereq_,module,exports){
  62997. 'use strict';
  62998. var utils = exports;
  62999. var BN = _dereq_('bn.js');
  63000. var minAssert = _dereq_('minimalistic-assert');
  63001. var minUtils = _dereq_('minimalistic-crypto-utils');
  63002. utils.assert = minAssert;
  63003. utils.toArray = minUtils.toArray;
  63004. utils.zero2 = minUtils.zero2;
  63005. utils.toHex = minUtils.toHex;
  63006. utils.encode = minUtils.encode;
  63007. // Represent num in a w-NAF form
  63008. function getNAF(num, w, bits) {
  63009. var naf = new Array(Math.max(num.bitLength(), bits) + 1);
  63010. naf.fill(0);
  63011. var ws = 1 << (w + 1);
  63012. var k = num.clone();
  63013. for (var i = 0; i < naf.length; i++) {
  63014. var z;
  63015. var mod = k.andln(ws - 1);
  63016. if (k.isOdd()) {
  63017. if (mod > (ws >> 1) - 1)
  63018. z = (ws >> 1) - mod;
  63019. else
  63020. z = mod;
  63021. k.isubn(z);
  63022. } else {
  63023. z = 0;
  63024. }
  63025. naf[i] = z;
  63026. k.iushrn(1);
  63027. }
  63028. return naf;
  63029. }
  63030. utils.getNAF = getNAF;
  63031. // Represent k1, k2 in a Joint Sparse Form
  63032. function getJSF(k1, k2) {
  63033. var jsf = [
  63034. [],
  63035. [],
  63036. ];
  63037. k1 = k1.clone();
  63038. k2 = k2.clone();
  63039. var d1 = 0;
  63040. var d2 = 0;
  63041. var m8;
  63042. while (k1.cmpn(-d1) > 0 || k2.cmpn(-d2) > 0) {
  63043. // First phase
  63044. var m14 = (k1.andln(3) + d1) & 3;
  63045. var m24 = (k2.andln(3) + d2) & 3;
  63046. if (m14 === 3)
  63047. m14 = -1;
  63048. if (m24 === 3)
  63049. m24 = -1;
  63050. var u1;
  63051. if ((m14 & 1) === 0) {
  63052. u1 = 0;
  63053. } else {
  63054. m8 = (k1.andln(7) + d1) & 7;
  63055. if ((m8 === 3 || m8 === 5) && m24 === 2)
  63056. u1 = -m14;
  63057. else
  63058. u1 = m14;
  63059. }
  63060. jsf[0].push(u1);
  63061. var u2;
  63062. if ((m24 & 1) === 0) {
  63063. u2 = 0;
  63064. } else {
  63065. m8 = (k2.andln(7) + d2) & 7;
  63066. if ((m8 === 3 || m8 === 5) && m14 === 2)
  63067. u2 = -m24;
  63068. else
  63069. u2 = m24;
  63070. }
  63071. jsf[1].push(u2);
  63072. // Second phase
  63073. if (2 * d1 === u1 + 1)
  63074. d1 = 1 - d1;
  63075. if (2 * d2 === u2 + 1)
  63076. d2 = 1 - d2;
  63077. k1.iushrn(1);
  63078. k2.iushrn(1);
  63079. }
  63080. return jsf;
  63081. }
  63082. utils.getJSF = getJSF;
  63083. function cachedProperty(obj, name, computer) {
  63084. var key = '_' + name;
  63085. obj.prototype[name] = function cachedProperty() {
  63086. return this[key] !== undefined ? this[key] :
  63087. this[key] = computer.call(this);
  63088. };
  63089. }
  63090. utils.cachedProperty = cachedProperty;
  63091. function parseBytes(bytes) {
  63092. return typeof bytes === 'string' ? utils.toArray(bytes, 'hex') :
  63093. bytes;
  63094. }
  63095. utils.parseBytes = parseBytes;
  63096. function intFromLE(bytes) {
  63097. return new BN(bytes, 'hex', 'le');
  63098. }
  63099. utils.intFromLE = intFromLE;
  63100. },{"bn.js":769,"minimalistic-assert":791,"minimalistic-crypto-utils":792}],769:[function(_dereq_,module,exports){
  63101. arguments[4][197][0].apply(exports,arguments)
  63102. },{"buffer":undefined,"dup":197}],770:[function(_dereq_,module,exports){
  63103. module.exports={
  63104. "_args": [
  63105. [
  63106. "elliptic@6.5.4",
  63107. "/home/gitlab-runner/Moralis-JS-SDK"
  63108. ]
  63109. ],
  63110. "_from": "elliptic@6.5.4",
  63111. "_id": "elliptic@6.5.4",
  63112. "_inBundle": false,
  63113. "_integrity": "sha512-iLhC6ULemrljPZb+QutR5TQGB+pdW6KGD5RSegS+8sorOZT+rdQFbsQFJgvN3eRqNALqJer4oQ16YvJHlU8hzQ==",
  63114. "_location": "/elliptic",
  63115. "_phantomChildren": {},
  63116. "_requested": {
  63117. "type": "version",
  63118. "registry": true,
  63119. "raw": "elliptic@6.5.4",
  63120. "name": "elliptic",
  63121. "escapedName": "elliptic",
  63122. "rawSpec": "6.5.4",
  63123. "saveSpec": null,
  63124. "fetchSpec": "6.5.4"
  63125. },
  63126. "_requiredBy": [
  63127. "/@ethersproject/signing-key",
  63128. "/browserify-sign",
  63129. "/create-ecdh"
  63130. ],
  63131. "_resolved": "https://registry.npmjs.org/elliptic/-/elliptic-6.5.4.tgz",
  63132. "_spec": "6.5.4",
  63133. "_where": "/home/gitlab-runner/Moralis-JS-SDK",
  63134. "author": {
  63135. "name": "Fedor Indutny",
  63136. "email": "fedor@indutny.com"
  63137. },
  63138. "bugs": {
  63139. "url": "https://github.com/indutny/elliptic/issues"
  63140. },
  63141. "dependencies": {
  63142. "bn.js": "^4.11.9",
  63143. "brorand": "^1.1.0",
  63144. "hash.js": "^1.0.0",
  63145. "hmac-drbg": "^1.0.1",
  63146. "inherits": "^2.0.4",
  63147. "minimalistic-assert": "^1.0.1",
  63148. "minimalistic-crypto-utils": "^1.0.1"
  63149. },
  63150. "description": "EC cryptography",
  63151. "devDependencies": {
  63152. "brfs": "^2.0.2",
  63153. "coveralls": "^3.1.0",
  63154. "eslint": "^7.6.0",
  63155. "grunt": "^1.2.1",
  63156. "grunt-browserify": "^5.3.0",
  63157. "grunt-cli": "^1.3.2",
  63158. "grunt-contrib-connect": "^3.0.0",
  63159. "grunt-contrib-copy": "^1.0.0",
  63160. "grunt-contrib-uglify": "^5.0.0",
  63161. "grunt-mocha-istanbul": "^5.0.2",
  63162. "grunt-saucelabs": "^9.0.1",
  63163. "istanbul": "^0.4.5",
  63164. "mocha": "^8.0.1"
  63165. },
  63166. "files": [
  63167. "lib"
  63168. ],
  63169. "homepage": "https://github.com/indutny/elliptic",
  63170. "keywords": [
  63171. "EC",
  63172. "Elliptic",
  63173. "curve",
  63174. "Cryptography"
  63175. ],
  63176. "license": "MIT",
  63177. "main": "lib/elliptic.js",
  63178. "name": "elliptic",
  63179. "repository": {
  63180. "type": "git",
  63181. "url": "git+ssh://git@github.com/indutny/elliptic.git"
  63182. },
  63183. "scripts": {
  63184. "lint": "eslint lib test",
  63185. "lint:fix": "npm run lint -- --fix",
  63186. "test": "npm run lint && npm run unit",
  63187. "unit": "istanbul test _mocha --reporter=spec test/index.js",
  63188. "version": "grunt dist && git add dist/"
  63189. },
  63190. "version": "6.5.4"
  63191. }
  63192. },{}],771:[function(_dereq_,module,exports){
  63193. "use strict";
  63194. Object.defineProperty(exports, "__esModule", { value: true });
  63195. exports.version = void 0;
  63196. exports.version = "ethers/5.6.0";
  63197. },{}],772:[function(_dereq_,module,exports){
  63198. "use strict";
  63199. var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
  63200. if (k2 === undefined) k2 = k;
  63201. Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
  63202. }) : (function(o, m, k, k2) {
  63203. if (k2 === undefined) k2 = k;
  63204. o[k2] = m[k];
  63205. }));
  63206. var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
  63207. Object.defineProperty(o, "default", { enumerable: true, value: v });
  63208. }) : function(o, v) {
  63209. o["default"] = v;
  63210. });
  63211. var __importStar = (this && this.__importStar) || function (mod) {
  63212. if (mod && mod.__esModule) return mod;
  63213. var result = {};
  63214. if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
  63215. __setModuleDefault(result, mod);
  63216. return result;
  63217. };
  63218. Object.defineProperty(exports, "__esModule", { value: true });
  63219. exports.Wordlist = exports.version = exports.wordlists = exports.utils = exports.logger = exports.errors = exports.constants = exports.FixedNumber = exports.BigNumber = exports.ContractFactory = exports.Contract = exports.BaseContract = exports.providers = exports.getDefaultProvider = exports.VoidSigner = exports.Wallet = exports.Signer = void 0;
  63220. var contracts_1 = _dereq_("@ethersproject/contracts");
  63221. Object.defineProperty(exports, "BaseContract", { enumerable: true, get: function () { return contracts_1.BaseContract; } });
  63222. Object.defineProperty(exports, "Contract", { enumerable: true, get: function () { return contracts_1.Contract; } });
  63223. Object.defineProperty(exports, "ContractFactory", { enumerable: true, get: function () { return contracts_1.ContractFactory; } });
  63224. var bignumber_1 = _dereq_("@ethersproject/bignumber");
  63225. Object.defineProperty(exports, "BigNumber", { enumerable: true, get: function () { return bignumber_1.BigNumber; } });
  63226. Object.defineProperty(exports, "FixedNumber", { enumerable: true, get: function () { return bignumber_1.FixedNumber; } });
  63227. var abstract_signer_1 = _dereq_("@ethersproject/abstract-signer");
  63228. Object.defineProperty(exports, "Signer", { enumerable: true, get: function () { return abstract_signer_1.Signer; } });
  63229. Object.defineProperty(exports, "VoidSigner", { enumerable: true, get: function () { return abstract_signer_1.VoidSigner; } });
  63230. var wallet_1 = _dereq_("@ethersproject/wallet");
  63231. Object.defineProperty(exports, "Wallet", { enumerable: true, get: function () { return wallet_1.Wallet; } });
  63232. var constants = __importStar(_dereq_("@ethersproject/constants"));
  63233. exports.constants = constants;
  63234. var providers = __importStar(_dereq_("@ethersproject/providers"));
  63235. exports.providers = providers;
  63236. var providers_1 = _dereq_("@ethersproject/providers");
  63237. Object.defineProperty(exports, "getDefaultProvider", { enumerable: true, get: function () { return providers_1.getDefaultProvider; } });
  63238. var wordlists_1 = _dereq_("@ethersproject/wordlists");
  63239. Object.defineProperty(exports, "Wordlist", { enumerable: true, get: function () { return wordlists_1.Wordlist; } });
  63240. Object.defineProperty(exports, "wordlists", { enumerable: true, get: function () { return wordlists_1.wordlists; } });
  63241. var utils = __importStar(_dereq_("./utils"));
  63242. exports.utils = utils;
  63243. var logger_1 = _dereq_("@ethersproject/logger");
  63244. Object.defineProperty(exports, "errors", { enumerable: true, get: function () { return logger_1.ErrorCode; } });
  63245. ////////////////////////
  63246. // Compile-Time Constants
  63247. // This is generated by "npm run dist"
  63248. var _version_1 = _dereq_("./_version");
  63249. Object.defineProperty(exports, "version", { enumerable: true, get: function () { return _version_1.version; } });
  63250. var logger = new logger_1.Logger(_version_1.version);
  63251. exports.logger = logger;
  63252. },{"./_version":771,"./utils":774,"@ethersproject/abstract-signer":187,"@ethersproject/bignumber":196,"@ethersproject/constants":203,"@ethersproject/contracts":206,"@ethersproject/logger":223,"@ethersproject/providers":239,"@ethersproject/wallet":273,"@ethersproject/wordlists":278}],773:[function(_dereq_,module,exports){
  63253. "use strict";
  63254. var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
  63255. if (k2 === undefined) k2 = k;
  63256. Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
  63257. }) : (function(o, m, k, k2) {
  63258. if (k2 === undefined) k2 = k;
  63259. o[k2] = m[k];
  63260. }));
  63261. var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
  63262. Object.defineProperty(o, "default", { enumerable: true, value: v });
  63263. }) : function(o, v) {
  63264. o["default"] = v;
  63265. });
  63266. var __importStar = (this && this.__importStar) || function (mod) {
  63267. if (mod && mod.__esModule) return mod;
  63268. var result = {};
  63269. if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
  63270. __setModuleDefault(result, mod);
  63271. return result;
  63272. };
  63273. Object.defineProperty(exports, "__esModule", { value: true });
  63274. exports.Wordlist = exports.version = exports.wordlists = exports.utils = exports.logger = exports.errors = exports.constants = exports.FixedNumber = exports.BigNumber = exports.ContractFactory = exports.Contract = exports.BaseContract = exports.providers = exports.getDefaultProvider = exports.VoidSigner = exports.Wallet = exports.Signer = exports.ethers = void 0;
  63275. // To modify this file, you must update ./misc/admin/lib/cmds/update-exports.js
  63276. var ethers = __importStar(_dereq_("./ethers"));
  63277. exports.ethers = ethers;
  63278. try {
  63279. var anyGlobal = window;
  63280. if (anyGlobal._ethers == null) {
  63281. anyGlobal._ethers = ethers;
  63282. }
  63283. }
  63284. catch (error) { }
  63285. var ethers_1 = _dereq_("./ethers");
  63286. Object.defineProperty(exports, "Signer", { enumerable: true, get: function () { return ethers_1.Signer; } });
  63287. Object.defineProperty(exports, "Wallet", { enumerable: true, get: function () { return ethers_1.Wallet; } });
  63288. Object.defineProperty(exports, "VoidSigner", { enumerable: true, get: function () { return ethers_1.VoidSigner; } });
  63289. Object.defineProperty(exports, "getDefaultProvider", { enumerable: true, get: function () { return ethers_1.getDefaultProvider; } });
  63290. Object.defineProperty(exports, "providers", { enumerable: true, get: function () { return ethers_1.providers; } });
  63291. Object.defineProperty(exports, "BaseContract", { enumerable: true, get: function () { return ethers_1.BaseContract; } });
  63292. Object.defineProperty(exports, "Contract", { enumerable: true, get: function () { return ethers_1.Contract; } });
  63293. Object.defineProperty(exports, "ContractFactory", { enumerable: true, get: function () { return ethers_1.ContractFactory; } });
  63294. Object.defineProperty(exports, "BigNumber", { enumerable: true, get: function () { return ethers_1.BigNumber; } });
  63295. Object.defineProperty(exports, "FixedNumber", { enumerable: true, get: function () { return ethers_1.FixedNumber; } });
  63296. Object.defineProperty(exports, "constants", { enumerable: true, get: function () { return ethers_1.constants; } });
  63297. Object.defineProperty(exports, "errors", { enumerable: true, get: function () { return ethers_1.errors; } });
  63298. Object.defineProperty(exports, "logger", { enumerable: true, get: function () { return ethers_1.logger; } });
  63299. Object.defineProperty(exports, "utils", { enumerable: true, get: function () { return ethers_1.utils; } });
  63300. Object.defineProperty(exports, "wordlists", { enumerable: true, get: function () { return ethers_1.wordlists; } });
  63301. ////////////////////////
  63302. // Compile-Time Constants
  63303. Object.defineProperty(exports, "version", { enumerable: true, get: function () { return ethers_1.version; } });
  63304. Object.defineProperty(exports, "Wordlist", { enumerable: true, get: function () { return ethers_1.Wordlist; } });
  63305. },{"./ethers":772}],774:[function(_dereq_,module,exports){
  63306. "use strict";
  63307. var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
  63308. if (k2 === undefined) k2 = k;
  63309. Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
  63310. }) : (function(o, m, k, k2) {
  63311. if (k2 === undefined) k2 = k;
  63312. o[k2] = m[k];
  63313. }));
  63314. var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
  63315. Object.defineProperty(o, "default", { enumerable: true, value: v });
  63316. }) : function(o, v) {
  63317. o["default"] = v;
  63318. });
  63319. var __importStar = (this && this.__importStar) || function (mod) {
  63320. if (mod && mod.__esModule) return mod;
  63321. var result = {};
  63322. if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
  63323. __setModuleDefault(result, mod);
  63324. return result;
  63325. };
  63326. Object.defineProperty(exports, "__esModule", { value: true });
  63327. exports.formatBytes32String = exports.Utf8ErrorFuncs = exports.toUtf8String = exports.toUtf8CodePoints = exports.toUtf8Bytes = exports._toEscapedUtf8String = exports.nameprep = exports.hexDataSlice = exports.hexDataLength = exports.hexZeroPad = exports.hexValue = exports.hexStripZeros = exports.hexConcat = exports.isHexString = exports.hexlify = exports.base64 = exports.base58 = exports.TransactionDescription = exports.LogDescription = exports.Interface = exports.SigningKey = exports.HDNode = exports.defaultPath = exports.isBytesLike = exports.isBytes = exports.zeroPad = exports.stripZeros = exports.concat = exports.arrayify = exports.shallowCopy = exports.resolveProperties = exports.getStatic = exports.defineReadOnly = exports.deepCopy = exports.checkProperties = exports.poll = exports.fetchJson = exports._fetchData = exports.RLP = exports.Logger = exports.checkResultErrors = exports.FormatTypes = exports.ParamType = exports.FunctionFragment = exports.EventFragment = exports.ErrorFragment = exports.ConstructorFragment = exports.Fragment = exports.defaultAbiCoder = exports.AbiCoder = void 0;
  63328. exports.Indexed = exports.Utf8ErrorReason = exports.UnicodeNormalizationForm = exports.SupportedAlgorithm = exports.mnemonicToSeed = exports.isValidMnemonic = exports.entropyToMnemonic = exports.mnemonicToEntropy = exports.getAccountPath = exports.verifyTypedData = exports.verifyMessage = exports.recoverPublicKey = exports.computePublicKey = exports.recoverAddress = exports.computeAddress = exports.getJsonWalletAddress = exports.TransactionTypes = exports.serializeTransaction = exports.parseTransaction = exports.accessListify = exports.joinSignature = exports.splitSignature = exports.soliditySha256 = exports.solidityKeccak256 = exports.solidityPack = exports.shuffled = exports.randomBytes = exports.sha512 = exports.sha256 = exports.ripemd160 = exports.keccak256 = exports.computeHmac = exports.commify = exports.parseUnits = exports.formatUnits = exports.parseEther = exports.formatEther = exports.isAddress = exports.getCreate2Address = exports.getContractAddress = exports.getIcapAddress = exports.getAddress = exports._TypedDataEncoder = exports.id = exports.isValidName = exports.namehash = exports.hashMessage = exports.dnsEncode = exports.parseBytes32String = void 0;
  63329. var abi_1 = _dereq_("@ethersproject/abi");
  63330. Object.defineProperty(exports, "AbiCoder", { enumerable: true, get: function () { return abi_1.AbiCoder; } });
  63331. Object.defineProperty(exports, "checkResultErrors", { enumerable: true, get: function () { return abi_1.checkResultErrors; } });
  63332. Object.defineProperty(exports, "ConstructorFragment", { enumerable: true, get: function () { return abi_1.ConstructorFragment; } });
  63333. Object.defineProperty(exports, "defaultAbiCoder", { enumerable: true, get: function () { return abi_1.defaultAbiCoder; } });
  63334. Object.defineProperty(exports, "ErrorFragment", { enumerable: true, get: function () { return abi_1.ErrorFragment; } });
  63335. Object.defineProperty(exports, "EventFragment", { enumerable: true, get: function () { return abi_1.EventFragment; } });
  63336. Object.defineProperty(exports, "FormatTypes", { enumerable: true, get: function () { return abi_1.FormatTypes; } });
  63337. Object.defineProperty(exports, "Fragment", { enumerable: true, get: function () { return abi_1.Fragment; } });
  63338. Object.defineProperty(exports, "FunctionFragment", { enumerable: true, get: function () { return abi_1.FunctionFragment; } });
  63339. Object.defineProperty(exports, "Indexed", { enumerable: true, get: function () { return abi_1.Indexed; } });
  63340. Object.defineProperty(exports, "Interface", { enumerable: true, get: function () { return abi_1.Interface; } });
  63341. Object.defineProperty(exports, "LogDescription", { enumerable: true, get: function () { return abi_1.LogDescription; } });
  63342. Object.defineProperty(exports, "ParamType", { enumerable: true, get: function () { return abi_1.ParamType; } });
  63343. Object.defineProperty(exports, "TransactionDescription", { enumerable: true, get: function () { return abi_1.TransactionDescription; } });
  63344. var address_1 = _dereq_("@ethersproject/address");
  63345. Object.defineProperty(exports, "getAddress", { enumerable: true, get: function () { return address_1.getAddress; } });
  63346. Object.defineProperty(exports, "getCreate2Address", { enumerable: true, get: function () { return address_1.getCreate2Address; } });
  63347. Object.defineProperty(exports, "getContractAddress", { enumerable: true, get: function () { return address_1.getContractAddress; } });
  63348. Object.defineProperty(exports, "getIcapAddress", { enumerable: true, get: function () { return address_1.getIcapAddress; } });
  63349. Object.defineProperty(exports, "isAddress", { enumerable: true, get: function () { return address_1.isAddress; } });
  63350. var base64 = __importStar(_dereq_("@ethersproject/base64"));
  63351. exports.base64 = base64;
  63352. var basex_1 = _dereq_("@ethersproject/basex");
  63353. Object.defineProperty(exports, "base58", { enumerable: true, get: function () { return basex_1.Base58; } });
  63354. var bytes_1 = _dereq_("@ethersproject/bytes");
  63355. Object.defineProperty(exports, "arrayify", { enumerable: true, get: function () { return bytes_1.arrayify; } });
  63356. Object.defineProperty(exports, "concat", { enumerable: true, get: function () { return bytes_1.concat; } });
  63357. Object.defineProperty(exports, "hexConcat", { enumerable: true, get: function () { return bytes_1.hexConcat; } });
  63358. Object.defineProperty(exports, "hexDataSlice", { enumerable: true, get: function () { return bytes_1.hexDataSlice; } });
  63359. Object.defineProperty(exports, "hexDataLength", { enumerable: true, get: function () { return bytes_1.hexDataLength; } });
  63360. Object.defineProperty(exports, "hexlify", { enumerable: true, get: function () { return bytes_1.hexlify; } });
  63361. Object.defineProperty(exports, "hexStripZeros", { enumerable: true, get: function () { return bytes_1.hexStripZeros; } });
  63362. Object.defineProperty(exports, "hexValue", { enumerable: true, get: function () { return bytes_1.hexValue; } });
  63363. Object.defineProperty(exports, "hexZeroPad", { enumerable: true, get: function () { return bytes_1.hexZeroPad; } });
  63364. Object.defineProperty(exports, "isBytes", { enumerable: true, get: function () { return bytes_1.isBytes; } });
  63365. Object.defineProperty(exports, "isBytesLike", { enumerable: true, get: function () { return bytes_1.isBytesLike; } });
  63366. Object.defineProperty(exports, "isHexString", { enumerable: true, get: function () { return bytes_1.isHexString; } });
  63367. Object.defineProperty(exports, "joinSignature", { enumerable: true, get: function () { return bytes_1.joinSignature; } });
  63368. Object.defineProperty(exports, "zeroPad", { enumerable: true, get: function () { return bytes_1.zeroPad; } });
  63369. Object.defineProperty(exports, "splitSignature", { enumerable: true, get: function () { return bytes_1.splitSignature; } });
  63370. Object.defineProperty(exports, "stripZeros", { enumerable: true, get: function () { return bytes_1.stripZeros; } });
  63371. var hash_1 = _dereq_("@ethersproject/hash");
  63372. Object.defineProperty(exports, "_TypedDataEncoder", { enumerable: true, get: function () { return hash_1._TypedDataEncoder; } });
  63373. Object.defineProperty(exports, "dnsEncode", { enumerable: true, get: function () { return hash_1.dnsEncode; } });
  63374. Object.defineProperty(exports, "hashMessage", { enumerable: true, get: function () { return hash_1.hashMessage; } });
  63375. Object.defineProperty(exports, "id", { enumerable: true, get: function () { return hash_1.id; } });
  63376. Object.defineProperty(exports, "isValidName", { enumerable: true, get: function () { return hash_1.isValidName; } });
  63377. Object.defineProperty(exports, "namehash", { enumerable: true, get: function () { return hash_1.namehash; } });
  63378. var hdnode_1 = _dereq_("@ethersproject/hdnode");
  63379. Object.defineProperty(exports, "defaultPath", { enumerable: true, get: function () { return hdnode_1.defaultPath; } });
  63380. Object.defineProperty(exports, "entropyToMnemonic", { enumerable: true, get: function () { return hdnode_1.entropyToMnemonic; } });
  63381. Object.defineProperty(exports, "getAccountPath", { enumerable: true, get: function () { return hdnode_1.getAccountPath; } });
  63382. Object.defineProperty(exports, "HDNode", { enumerable: true, get: function () { return hdnode_1.HDNode; } });
  63383. Object.defineProperty(exports, "isValidMnemonic", { enumerable: true, get: function () { return hdnode_1.isValidMnemonic; } });
  63384. Object.defineProperty(exports, "mnemonicToEntropy", { enumerable: true, get: function () { return hdnode_1.mnemonicToEntropy; } });
  63385. Object.defineProperty(exports, "mnemonicToSeed", { enumerable: true, get: function () { return hdnode_1.mnemonicToSeed; } });
  63386. var json_wallets_1 = _dereq_("@ethersproject/json-wallets");
  63387. Object.defineProperty(exports, "getJsonWalletAddress", { enumerable: true, get: function () { return json_wallets_1.getJsonWalletAddress; } });
  63388. var keccak256_1 = _dereq_("@ethersproject/keccak256");
  63389. Object.defineProperty(exports, "keccak256", { enumerable: true, get: function () { return keccak256_1.keccak256; } });
  63390. var logger_1 = _dereq_("@ethersproject/logger");
  63391. Object.defineProperty(exports, "Logger", { enumerable: true, get: function () { return logger_1.Logger; } });
  63392. var sha2_1 = _dereq_("@ethersproject/sha2");
  63393. Object.defineProperty(exports, "computeHmac", { enumerable: true, get: function () { return sha2_1.computeHmac; } });
  63394. Object.defineProperty(exports, "ripemd160", { enumerable: true, get: function () { return sha2_1.ripemd160; } });
  63395. Object.defineProperty(exports, "sha256", { enumerable: true, get: function () { return sha2_1.sha256; } });
  63396. Object.defineProperty(exports, "sha512", { enumerable: true, get: function () { return sha2_1.sha512; } });
  63397. var solidity_1 = _dereq_("@ethersproject/solidity");
  63398. Object.defineProperty(exports, "solidityKeccak256", { enumerable: true, get: function () { return solidity_1.keccak256; } });
  63399. Object.defineProperty(exports, "solidityPack", { enumerable: true, get: function () { return solidity_1.pack; } });
  63400. Object.defineProperty(exports, "soliditySha256", { enumerable: true, get: function () { return solidity_1.sha256; } });
  63401. var random_1 = _dereq_("@ethersproject/random");
  63402. Object.defineProperty(exports, "randomBytes", { enumerable: true, get: function () { return random_1.randomBytes; } });
  63403. Object.defineProperty(exports, "shuffled", { enumerable: true, get: function () { return random_1.shuffled; } });
  63404. var properties_1 = _dereq_("@ethersproject/properties");
  63405. Object.defineProperty(exports, "checkProperties", { enumerable: true, get: function () { return properties_1.checkProperties; } });
  63406. Object.defineProperty(exports, "deepCopy", { enumerable: true, get: function () { return properties_1.deepCopy; } });
  63407. Object.defineProperty(exports, "defineReadOnly", { enumerable: true, get: function () { return properties_1.defineReadOnly; } });
  63408. Object.defineProperty(exports, "getStatic", { enumerable: true, get: function () { return properties_1.getStatic; } });
  63409. Object.defineProperty(exports, "resolveProperties", { enumerable: true, get: function () { return properties_1.resolveProperties; } });
  63410. Object.defineProperty(exports, "shallowCopy", { enumerable: true, get: function () { return properties_1.shallowCopy; } });
  63411. var RLP = __importStar(_dereq_("@ethersproject/rlp"));
  63412. exports.RLP = RLP;
  63413. var signing_key_1 = _dereq_("@ethersproject/signing-key");
  63414. Object.defineProperty(exports, "computePublicKey", { enumerable: true, get: function () { return signing_key_1.computePublicKey; } });
  63415. Object.defineProperty(exports, "recoverPublicKey", { enumerable: true, get: function () { return signing_key_1.recoverPublicKey; } });
  63416. Object.defineProperty(exports, "SigningKey", { enumerable: true, get: function () { return signing_key_1.SigningKey; } });
  63417. var strings_1 = _dereq_("@ethersproject/strings");
  63418. Object.defineProperty(exports, "formatBytes32String", { enumerable: true, get: function () { return strings_1.formatBytes32String; } });
  63419. Object.defineProperty(exports, "nameprep", { enumerable: true, get: function () { return strings_1.nameprep; } });
  63420. Object.defineProperty(exports, "parseBytes32String", { enumerable: true, get: function () { return strings_1.parseBytes32String; } });
  63421. Object.defineProperty(exports, "_toEscapedUtf8String", { enumerable: true, get: function () { return strings_1._toEscapedUtf8String; } });
  63422. Object.defineProperty(exports, "toUtf8Bytes", { enumerable: true, get: function () { return strings_1.toUtf8Bytes; } });
  63423. Object.defineProperty(exports, "toUtf8CodePoints", { enumerable: true, get: function () { return strings_1.toUtf8CodePoints; } });
  63424. Object.defineProperty(exports, "toUtf8String", { enumerable: true, get: function () { return strings_1.toUtf8String; } });
  63425. Object.defineProperty(exports, "Utf8ErrorFuncs", { enumerable: true, get: function () { return strings_1.Utf8ErrorFuncs; } });
  63426. var transactions_1 = _dereq_("@ethersproject/transactions");
  63427. Object.defineProperty(exports, "accessListify", { enumerable: true, get: function () { return transactions_1.accessListify; } });
  63428. Object.defineProperty(exports, "computeAddress", { enumerable: true, get: function () { return transactions_1.computeAddress; } });
  63429. Object.defineProperty(exports, "parseTransaction", { enumerable: true, get: function () { return transactions_1.parse; } });
  63430. Object.defineProperty(exports, "recoverAddress", { enumerable: true, get: function () { return transactions_1.recoverAddress; } });
  63431. Object.defineProperty(exports, "serializeTransaction", { enumerable: true, get: function () { return transactions_1.serialize; } });
  63432. Object.defineProperty(exports, "TransactionTypes", { enumerable: true, get: function () { return transactions_1.TransactionTypes; } });
  63433. var units_1 = _dereq_("@ethersproject/units");
  63434. Object.defineProperty(exports, "commify", { enumerable: true, get: function () { return units_1.commify; } });
  63435. Object.defineProperty(exports, "formatEther", { enumerable: true, get: function () { return units_1.formatEther; } });
  63436. Object.defineProperty(exports, "parseEther", { enumerable: true, get: function () { return units_1.parseEther; } });
  63437. Object.defineProperty(exports, "formatUnits", { enumerable: true, get: function () { return units_1.formatUnits; } });
  63438. Object.defineProperty(exports, "parseUnits", { enumerable: true, get: function () { return units_1.parseUnits; } });
  63439. var wallet_1 = _dereq_("@ethersproject/wallet");
  63440. Object.defineProperty(exports, "verifyMessage", { enumerable: true, get: function () { return wallet_1.verifyMessage; } });
  63441. Object.defineProperty(exports, "verifyTypedData", { enumerable: true, get: function () { return wallet_1.verifyTypedData; } });
  63442. var web_1 = _dereq_("@ethersproject/web");
  63443. Object.defineProperty(exports, "_fetchData", { enumerable: true, get: function () { return web_1._fetchData; } });
  63444. Object.defineProperty(exports, "fetchJson", { enumerable: true, get: function () { return web_1.fetchJson; } });
  63445. Object.defineProperty(exports, "poll", { enumerable: true, get: function () { return web_1.poll; } });
  63446. ////////////////////////
  63447. // Enums
  63448. var sha2_2 = _dereq_("@ethersproject/sha2");
  63449. Object.defineProperty(exports, "SupportedAlgorithm", { enumerable: true, get: function () { return sha2_2.SupportedAlgorithm; } });
  63450. var strings_2 = _dereq_("@ethersproject/strings");
  63451. Object.defineProperty(exports, "UnicodeNormalizationForm", { enumerable: true, get: function () { return strings_2.UnicodeNormalizationForm; } });
  63452. Object.defineProperty(exports, "Utf8ErrorReason", { enumerable: true, get: function () { return strings_2.Utf8ErrorReason; } });
  63453. },{"@ethersproject/abi":182,"@ethersproject/address":189,"@ethersproject/base64":191,"@ethersproject/basex":192,"@ethersproject/bytes":199,"@ethersproject/hash":209,"@ethersproject/hdnode":214,"@ethersproject/json-wallets":217,"@ethersproject/keccak256":221,"@ethersproject/logger":223,"@ethersproject/properties":229,"@ethersproject/random":250,"@ethersproject/rlp":253,"@ethersproject/sha2":256,"@ethersproject/signing-key":260,"@ethersproject/solidity":262,"@ethersproject/strings":266,"@ethersproject/transactions":269,"@ethersproject/units":271,"@ethersproject/wallet":273,"@ethersproject/web":276}],775:[function(_dereq_,module,exports){
  63454. // Copyright Joyent, Inc. and other Node contributors.
  63455. //
  63456. // Permission is hereby granted, free of charge, to any person obtaining a
  63457. // copy of this software and associated documentation files (the
  63458. // "Software"), to deal in the Software without restriction, including
  63459. // without limitation the rights to use, copy, modify, merge, publish,
  63460. // distribute, sublicense, and/or sell copies of the Software, and to permit
  63461. // persons to whom the Software is furnished to do so, subject to the
  63462. // following conditions:
  63463. //
  63464. // The above copyright notice and this permission notice shall be included
  63465. // in all copies or substantial portions of the Software.
  63466. //
  63467. // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
  63468. // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
  63469. // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
  63470. // NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
  63471. // DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
  63472. // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
  63473. // USE OR OTHER DEALINGS IN THE SOFTWARE.
  63474. 'use strict';
  63475. var R = typeof Reflect === 'object' ? Reflect : null
  63476. var ReflectApply = R && typeof R.apply === 'function'
  63477. ? R.apply
  63478. : function ReflectApply(target, receiver, args) {
  63479. return Function.prototype.apply.call(target, receiver, args);
  63480. }
  63481. var ReflectOwnKeys
  63482. if (R && typeof R.ownKeys === 'function') {
  63483. ReflectOwnKeys = R.ownKeys
  63484. } else if (Object.getOwnPropertySymbols) {
  63485. ReflectOwnKeys = function ReflectOwnKeys(target) {
  63486. return Object.getOwnPropertyNames(target)
  63487. .concat(Object.getOwnPropertySymbols(target));
  63488. };
  63489. } else {
  63490. ReflectOwnKeys = function ReflectOwnKeys(target) {
  63491. return Object.getOwnPropertyNames(target);
  63492. };
  63493. }
  63494. function ProcessEmitWarning(warning) {
  63495. if (console && console.warn) console.warn(warning);
  63496. }
  63497. var NumberIsNaN = Number.isNaN || function NumberIsNaN(value) {
  63498. return value !== value;
  63499. }
  63500. function EventEmitter() {
  63501. EventEmitter.init.call(this);
  63502. }
  63503. module.exports = EventEmitter;
  63504. module.exports.once = once;
  63505. // Backwards-compat with node 0.10.x
  63506. EventEmitter.EventEmitter = EventEmitter;
  63507. EventEmitter.prototype._events = undefined;
  63508. EventEmitter.prototype._eventsCount = 0;
  63509. EventEmitter.prototype._maxListeners = undefined;
  63510. // By default EventEmitters will print a warning if more than 10 listeners are
  63511. // added to it. This is a useful default which helps finding memory leaks.
  63512. var defaultMaxListeners = 10;
  63513. function checkListener(listener) {
  63514. if (typeof listener !== 'function') {
  63515. throw new TypeError('The "listener" argument must be of type Function. Received type ' + typeof listener);
  63516. }
  63517. }
  63518. Object.defineProperty(EventEmitter, 'defaultMaxListeners', {
  63519. enumerable: true,
  63520. get: function() {
  63521. return defaultMaxListeners;
  63522. },
  63523. set: function(arg) {
  63524. if (typeof arg !== 'number' || arg < 0 || NumberIsNaN(arg)) {
  63525. throw new RangeError('The value of "defaultMaxListeners" is out of range. It must be a non-negative number. Received ' + arg + '.');
  63526. }
  63527. defaultMaxListeners = arg;
  63528. }
  63529. });
  63530. EventEmitter.init = function() {
  63531. if (this._events === undefined ||
  63532. this._events === Object.getPrototypeOf(this)._events) {
  63533. this._events = Object.create(null);
  63534. this._eventsCount = 0;
  63535. }
  63536. this._maxListeners = this._maxListeners || undefined;
  63537. };
  63538. // Obviously not all Emitters should be limited to 10. This function allows
  63539. // that to be increased. Set to zero for unlimited.
  63540. EventEmitter.prototype.setMaxListeners = function setMaxListeners(n) {
  63541. if (typeof n !== 'number' || n < 0 || NumberIsNaN(n)) {
  63542. throw new RangeError('The value of "n" is out of range. It must be a non-negative number. Received ' + n + '.');
  63543. }
  63544. this._maxListeners = n;
  63545. return this;
  63546. };
  63547. function _getMaxListeners(that) {
  63548. if (that._maxListeners === undefined)
  63549. return EventEmitter.defaultMaxListeners;
  63550. return that._maxListeners;
  63551. }
  63552. EventEmitter.prototype.getMaxListeners = function getMaxListeners() {
  63553. return _getMaxListeners(this);
  63554. };
  63555. EventEmitter.prototype.emit = function emit(type) {
  63556. var args = [];
  63557. for (var i = 1; i < arguments.length; i++) args.push(arguments[i]);
  63558. var doError = (type === 'error');
  63559. var events = this._events;
  63560. if (events !== undefined)
  63561. doError = (doError && events.error === undefined);
  63562. else if (!doError)
  63563. return false;
  63564. // If there is no 'error' event listener then throw.
  63565. if (doError) {
  63566. var er;
  63567. if (args.length > 0)
  63568. er = args[0];
  63569. if (er instanceof Error) {
  63570. // Note: The comments on the `throw` lines are intentional, they show
  63571. // up in Node's output if this results in an unhandled exception.
  63572. throw er; // Unhandled 'error' event
  63573. }
  63574. // At least give some kind of context to the user
  63575. var err = new Error('Unhandled error.' + (er ? ' (' + er.message + ')' : ''));
  63576. err.context = er;
  63577. throw err; // Unhandled 'error' event
  63578. }
  63579. var handler = events[type];
  63580. if (handler === undefined)
  63581. return false;
  63582. if (typeof handler === 'function') {
  63583. ReflectApply(handler, this, args);
  63584. } else {
  63585. var len = handler.length;
  63586. var listeners = arrayClone(handler, len);
  63587. for (var i = 0; i < len; ++i)
  63588. ReflectApply(listeners[i], this, args);
  63589. }
  63590. return true;
  63591. };
  63592. function _addListener(target, type, listener, prepend) {
  63593. var m;
  63594. var events;
  63595. var existing;
  63596. checkListener(listener);
  63597. events = target._events;
  63598. if (events === undefined) {
  63599. events = target._events = Object.create(null);
  63600. target._eventsCount = 0;
  63601. } else {
  63602. // To avoid recursion in the case that type === "newListener"! Before
  63603. // adding it to the listeners, first emit "newListener".
  63604. if (events.newListener !== undefined) {
  63605. target.emit('newListener', type,
  63606. listener.listener ? listener.listener : listener);
  63607. // Re-assign `events` because a newListener handler could have caused the
  63608. // this._events to be assigned to a new object
  63609. events = target._events;
  63610. }
  63611. existing = events[type];
  63612. }
  63613. if (existing === undefined) {
  63614. // Optimize the case of one listener. Don't need the extra array object.
  63615. existing = events[type] = listener;
  63616. ++target._eventsCount;
  63617. } else {
  63618. if (typeof existing === 'function') {
  63619. // Adding the second element, need to change to array.
  63620. existing = events[type] =
  63621. prepend ? [listener, existing] : [existing, listener];
  63622. // If we've already got an array, just append.
  63623. } else if (prepend) {
  63624. existing.unshift(listener);
  63625. } else {
  63626. existing.push(listener);
  63627. }
  63628. // Check for listener leak
  63629. m = _getMaxListeners(target);
  63630. if (m > 0 && existing.length > m && !existing.warned) {
  63631. existing.warned = true;
  63632. // No error code for this since it is a Warning
  63633. // eslint-disable-next-line no-restricted-syntax
  63634. var w = new Error('Possible EventEmitter memory leak detected. ' +
  63635. existing.length + ' ' + String(type) + ' listeners ' +
  63636. 'added. Use emitter.setMaxListeners() to ' +
  63637. 'increase limit');
  63638. w.name = 'MaxListenersExceededWarning';
  63639. w.emitter = target;
  63640. w.type = type;
  63641. w.count = existing.length;
  63642. ProcessEmitWarning(w);
  63643. }
  63644. }
  63645. return target;
  63646. }
  63647. EventEmitter.prototype.addListener = function addListener(type, listener) {
  63648. return _addListener(this, type, listener, false);
  63649. };
  63650. EventEmitter.prototype.on = EventEmitter.prototype.addListener;
  63651. EventEmitter.prototype.prependListener =
  63652. function prependListener(type, listener) {
  63653. return _addListener(this, type, listener, true);
  63654. };
  63655. function onceWrapper() {
  63656. if (!this.fired) {
  63657. this.target.removeListener(this.type, this.wrapFn);
  63658. this.fired = true;
  63659. if (arguments.length === 0)
  63660. return this.listener.call(this.target);
  63661. return this.listener.apply(this.target, arguments);
  63662. }
  63663. }
  63664. function _onceWrap(target, type, listener) {
  63665. var state = { fired: false, wrapFn: undefined, target: target, type: type, listener: listener };
  63666. var wrapped = onceWrapper.bind(state);
  63667. wrapped.listener = listener;
  63668. state.wrapFn = wrapped;
  63669. return wrapped;
  63670. }
  63671. EventEmitter.prototype.once = function once(type, listener) {
  63672. checkListener(listener);
  63673. this.on(type, _onceWrap(this, type, listener));
  63674. return this;
  63675. };
  63676. EventEmitter.prototype.prependOnceListener =
  63677. function prependOnceListener(type, listener) {
  63678. checkListener(listener);
  63679. this.prependListener(type, _onceWrap(this, type, listener));
  63680. return this;
  63681. };
  63682. // Emits a 'removeListener' event if and only if the listener was removed.
  63683. EventEmitter.prototype.removeListener =
  63684. function removeListener(type, listener) {
  63685. var list, events, position, i, originalListener;
  63686. checkListener(listener);
  63687. events = this._events;
  63688. if (events === undefined)
  63689. return this;
  63690. list = events[type];
  63691. if (list === undefined)
  63692. return this;
  63693. if (list === listener || list.listener === listener) {
  63694. if (--this._eventsCount === 0)
  63695. this._events = Object.create(null);
  63696. else {
  63697. delete events[type];
  63698. if (events.removeListener)
  63699. this.emit('removeListener', type, list.listener || listener);
  63700. }
  63701. } else if (typeof list !== 'function') {
  63702. position = -1;
  63703. for (i = list.length - 1; i >= 0; i--) {
  63704. if (list[i] === listener || list[i].listener === listener) {
  63705. originalListener = list[i].listener;
  63706. position = i;
  63707. break;
  63708. }
  63709. }
  63710. if (position < 0)
  63711. return this;
  63712. if (position === 0)
  63713. list.shift();
  63714. else {
  63715. spliceOne(list, position);
  63716. }
  63717. if (list.length === 1)
  63718. events[type] = list[0];
  63719. if (events.removeListener !== undefined)
  63720. this.emit('removeListener', type, originalListener || listener);
  63721. }
  63722. return this;
  63723. };
  63724. EventEmitter.prototype.off = EventEmitter.prototype.removeListener;
  63725. EventEmitter.prototype.removeAllListeners =
  63726. function removeAllListeners(type) {
  63727. var listeners, events, i;
  63728. events = this._events;
  63729. if (events === undefined)
  63730. return this;
  63731. // not listening for removeListener, no need to emit
  63732. if (events.removeListener === undefined) {
  63733. if (arguments.length === 0) {
  63734. this._events = Object.create(null);
  63735. this._eventsCount = 0;
  63736. } else if (events[type] !== undefined) {
  63737. if (--this._eventsCount === 0)
  63738. this._events = Object.create(null);
  63739. else
  63740. delete events[type];
  63741. }
  63742. return this;
  63743. }
  63744. // emit removeListener for all listeners on all events
  63745. if (arguments.length === 0) {
  63746. var keys = Object.keys(events);
  63747. var key;
  63748. for (i = 0; i < keys.length; ++i) {
  63749. key = keys[i];
  63750. if (key === 'removeListener') continue;
  63751. this.removeAllListeners(key);
  63752. }
  63753. this.removeAllListeners('removeListener');
  63754. this._events = Object.create(null);
  63755. this._eventsCount = 0;
  63756. return this;
  63757. }
  63758. listeners = events[type];
  63759. if (typeof listeners === 'function') {
  63760. this.removeListener(type, listeners);
  63761. } else if (listeners !== undefined) {
  63762. // LIFO order
  63763. for (i = listeners.length - 1; i >= 0; i--) {
  63764. this.removeListener(type, listeners[i]);
  63765. }
  63766. }
  63767. return this;
  63768. };
  63769. function _listeners(target, type, unwrap) {
  63770. var events = target._events;
  63771. if (events === undefined)
  63772. return [];
  63773. var evlistener = events[type];
  63774. if (evlistener === undefined)
  63775. return [];
  63776. if (typeof evlistener === 'function')
  63777. return unwrap ? [evlistener.listener || evlistener] : [evlistener];
  63778. return unwrap ?
  63779. unwrapListeners(evlistener) : arrayClone(evlistener, evlistener.length);
  63780. }
  63781. EventEmitter.prototype.listeners = function listeners(type) {
  63782. return _listeners(this, type, true);
  63783. };
  63784. EventEmitter.prototype.rawListeners = function rawListeners(type) {
  63785. return _listeners(this, type, false);
  63786. };
  63787. EventEmitter.listenerCount = function(emitter, type) {
  63788. if (typeof emitter.listenerCount === 'function') {
  63789. return emitter.listenerCount(type);
  63790. } else {
  63791. return listenerCount.call(emitter, type);
  63792. }
  63793. };
  63794. EventEmitter.prototype.listenerCount = listenerCount;
  63795. function listenerCount(type) {
  63796. var events = this._events;
  63797. if (events !== undefined) {
  63798. var evlistener = events[type];
  63799. if (typeof evlistener === 'function') {
  63800. return 1;
  63801. } else if (evlistener !== undefined) {
  63802. return evlistener.length;
  63803. }
  63804. }
  63805. return 0;
  63806. }
  63807. EventEmitter.prototype.eventNames = function eventNames() {
  63808. return this._eventsCount > 0 ? ReflectOwnKeys(this._events) : [];
  63809. };
  63810. function arrayClone(arr, n) {
  63811. var copy = new Array(n);
  63812. for (var i = 0; i < n; ++i)
  63813. copy[i] = arr[i];
  63814. return copy;
  63815. }
  63816. function spliceOne(list, index) {
  63817. for (; index + 1 < list.length; index++)
  63818. list[index] = list[index + 1];
  63819. list.pop();
  63820. }
  63821. function unwrapListeners(arr) {
  63822. var ret = new Array(arr.length);
  63823. for (var i = 0; i < ret.length; ++i) {
  63824. ret[i] = arr[i].listener || arr[i];
  63825. }
  63826. return ret;
  63827. }
  63828. function once(emitter, name) {
  63829. return new Promise(function (resolve, reject) {
  63830. function errorListener(err) {
  63831. emitter.removeListener(name, resolver);
  63832. reject(err);
  63833. }
  63834. function resolver() {
  63835. if (typeof emitter.removeListener === 'function') {
  63836. emitter.removeListener('error', errorListener);
  63837. }
  63838. resolve([].slice.call(arguments));
  63839. };
  63840. eventTargetAgnosticAddListener(emitter, name, resolver, { once: true });
  63841. if (name !== 'error') {
  63842. addErrorHandlerIfEventEmitter(emitter, errorListener, { once: true });
  63843. }
  63844. });
  63845. }
  63846. function addErrorHandlerIfEventEmitter(emitter, handler, flags) {
  63847. if (typeof emitter.on === 'function') {
  63848. eventTargetAgnosticAddListener(emitter, 'error', handler, flags);
  63849. }
  63850. }
  63851. function eventTargetAgnosticAddListener(emitter, name, listener, flags) {
  63852. if (typeof emitter.on === 'function') {
  63853. if (flags.once) {
  63854. emitter.once(name, listener);
  63855. } else {
  63856. emitter.on(name, listener);
  63857. }
  63858. } else if (typeof emitter.addEventListener === 'function') {
  63859. // EventTarget does not have `error` event semantics like Node
  63860. // EventEmitters, we do not listen for `error` events here.
  63861. emitter.addEventListener(name, function wrapListener(arg) {
  63862. // IE does not have builtin `{ once: true }` support so we
  63863. // have to do it manually.
  63864. if (flags.once) {
  63865. emitter.removeEventListener(name, wrapListener);
  63866. }
  63867. listener(arg);
  63868. });
  63869. } else {
  63870. throw new TypeError('The "emitter" argument must be of type EventEmitter. Received type ' + typeof emitter);
  63871. }
  63872. }
  63873. },{}],776:[function(_dereq_,module,exports){
  63874. var hash = exports;
  63875. hash.utils = _dereq_('./hash/utils');
  63876. hash.common = _dereq_('./hash/common');
  63877. hash.sha = _dereq_('./hash/sha');
  63878. hash.ripemd = _dereq_('./hash/ripemd');
  63879. hash.hmac = _dereq_('./hash/hmac');
  63880. // Proxy hash functions to the main object
  63881. hash.sha1 = hash.sha.sha1;
  63882. hash.sha256 = hash.sha.sha256;
  63883. hash.sha224 = hash.sha.sha224;
  63884. hash.sha384 = hash.sha.sha384;
  63885. hash.sha512 = hash.sha.sha512;
  63886. hash.ripemd160 = hash.ripemd.ripemd160;
  63887. },{"./hash/common":777,"./hash/hmac":778,"./hash/ripemd":779,"./hash/sha":780,"./hash/utils":787}],777:[function(_dereq_,module,exports){
  63888. 'use strict';
  63889. var utils = _dereq_('./utils');
  63890. var assert = _dereq_('minimalistic-assert');
  63891. function BlockHash() {
  63892. this.pending = null;
  63893. this.pendingTotal = 0;
  63894. this.blockSize = this.constructor.blockSize;
  63895. this.outSize = this.constructor.outSize;
  63896. this.hmacStrength = this.constructor.hmacStrength;
  63897. this.padLength = this.constructor.padLength / 8;
  63898. this.endian = 'big';
  63899. this._delta8 = this.blockSize / 8;
  63900. this._delta32 = this.blockSize / 32;
  63901. }
  63902. exports.BlockHash = BlockHash;
  63903. BlockHash.prototype.update = function update(msg, enc) {
  63904. // Convert message to array, pad it, and join into 32bit blocks
  63905. msg = utils.toArray(msg, enc);
  63906. if (!this.pending)
  63907. this.pending = msg;
  63908. else
  63909. this.pending = this.pending.concat(msg);
  63910. this.pendingTotal += msg.length;
  63911. // Enough data, try updating
  63912. if (this.pending.length >= this._delta8) {
  63913. msg = this.pending;
  63914. // Process pending data in blocks
  63915. var r = msg.length % this._delta8;
  63916. this.pending = msg.slice(msg.length - r, msg.length);
  63917. if (this.pending.length === 0)
  63918. this.pending = null;
  63919. msg = utils.join32(msg, 0, msg.length - r, this.endian);
  63920. for (var i = 0; i < msg.length; i += this._delta32)
  63921. this._update(msg, i, i + this._delta32);
  63922. }
  63923. return this;
  63924. };
  63925. BlockHash.prototype.digest = function digest(enc) {
  63926. this.update(this._pad());
  63927. assert(this.pending === null);
  63928. return this._digest(enc);
  63929. };
  63930. BlockHash.prototype._pad = function pad() {
  63931. var len = this.pendingTotal;
  63932. var bytes = this._delta8;
  63933. var k = bytes - ((len + this.padLength) % bytes);
  63934. var res = new Array(k + this.padLength);
  63935. res[0] = 0x80;
  63936. for (var i = 1; i < k; i++)
  63937. res[i] = 0;
  63938. // Append length
  63939. len <<= 3;
  63940. if (this.endian === 'big') {
  63941. for (var t = 8; t < this.padLength; t++)
  63942. res[i++] = 0;
  63943. res[i++] = 0;
  63944. res[i++] = 0;
  63945. res[i++] = 0;
  63946. res[i++] = 0;
  63947. res[i++] = (len >>> 24) & 0xff;
  63948. res[i++] = (len >>> 16) & 0xff;
  63949. res[i++] = (len >>> 8) & 0xff;
  63950. res[i++] = len & 0xff;
  63951. } else {
  63952. res[i++] = len & 0xff;
  63953. res[i++] = (len >>> 8) & 0xff;
  63954. res[i++] = (len >>> 16) & 0xff;
  63955. res[i++] = (len >>> 24) & 0xff;
  63956. res[i++] = 0;
  63957. res[i++] = 0;
  63958. res[i++] = 0;
  63959. res[i++] = 0;
  63960. for (t = 8; t < this.padLength; t++)
  63961. res[i++] = 0;
  63962. }
  63963. return res;
  63964. };
  63965. },{"./utils":787,"minimalistic-assert":791}],778:[function(_dereq_,module,exports){
  63966. 'use strict';
  63967. var utils = _dereq_('./utils');
  63968. var assert = _dereq_('minimalistic-assert');
  63969. function Hmac(hash, key, enc) {
  63970. if (!(this instanceof Hmac))
  63971. return new Hmac(hash, key, enc);
  63972. this.Hash = hash;
  63973. this.blockSize = hash.blockSize / 8;
  63974. this.outSize = hash.outSize / 8;
  63975. this.inner = null;
  63976. this.outer = null;
  63977. this._init(utils.toArray(key, enc));
  63978. }
  63979. module.exports = Hmac;
  63980. Hmac.prototype._init = function init(key) {
  63981. // Shorten key, if needed
  63982. if (key.length > this.blockSize)
  63983. key = new this.Hash().update(key).digest();
  63984. assert(key.length <= this.blockSize);
  63985. // Add padding to key
  63986. for (var i = key.length; i < this.blockSize; i++)
  63987. key.push(0);
  63988. for (i = 0; i < key.length; i++)
  63989. key[i] ^= 0x36;
  63990. this.inner = new this.Hash().update(key);
  63991. // 0x36 ^ 0x5c = 0x6a
  63992. for (i = 0; i < key.length; i++)
  63993. key[i] ^= 0x6a;
  63994. this.outer = new this.Hash().update(key);
  63995. };
  63996. Hmac.prototype.update = function update(msg, enc) {
  63997. this.inner.update(msg, enc);
  63998. return this;
  63999. };
  64000. Hmac.prototype.digest = function digest(enc) {
  64001. this.outer.update(this.inner.digest());
  64002. return this.outer.digest(enc);
  64003. };
  64004. },{"./utils":787,"minimalistic-assert":791}],779:[function(_dereq_,module,exports){
  64005. 'use strict';
  64006. var utils = _dereq_('./utils');
  64007. var common = _dereq_('./common');
  64008. var rotl32 = utils.rotl32;
  64009. var sum32 = utils.sum32;
  64010. var sum32_3 = utils.sum32_3;
  64011. var sum32_4 = utils.sum32_4;
  64012. var BlockHash = common.BlockHash;
  64013. function RIPEMD160() {
  64014. if (!(this instanceof RIPEMD160))
  64015. return new RIPEMD160();
  64016. BlockHash.call(this);
  64017. this.h = [ 0x67452301, 0xefcdab89, 0x98badcfe, 0x10325476, 0xc3d2e1f0 ];
  64018. this.endian = 'little';
  64019. }
  64020. utils.inherits(RIPEMD160, BlockHash);
  64021. exports.ripemd160 = RIPEMD160;
  64022. RIPEMD160.blockSize = 512;
  64023. RIPEMD160.outSize = 160;
  64024. RIPEMD160.hmacStrength = 192;
  64025. RIPEMD160.padLength = 64;
  64026. RIPEMD160.prototype._update = function update(msg, start) {
  64027. var A = this.h[0];
  64028. var B = this.h[1];
  64029. var C = this.h[2];
  64030. var D = this.h[3];
  64031. var E = this.h[4];
  64032. var Ah = A;
  64033. var Bh = B;
  64034. var Ch = C;
  64035. var Dh = D;
  64036. var Eh = E;
  64037. for (var j = 0; j < 80; j++) {
  64038. var T = sum32(
  64039. rotl32(
  64040. sum32_4(A, f(j, B, C, D), msg[r[j] + start], K(j)),
  64041. s[j]),
  64042. E);
  64043. A = E;
  64044. E = D;
  64045. D = rotl32(C, 10);
  64046. C = B;
  64047. B = T;
  64048. T = sum32(
  64049. rotl32(
  64050. sum32_4(Ah, f(79 - j, Bh, Ch, Dh), msg[rh[j] + start], Kh(j)),
  64051. sh[j]),
  64052. Eh);
  64053. Ah = Eh;
  64054. Eh = Dh;
  64055. Dh = rotl32(Ch, 10);
  64056. Ch = Bh;
  64057. Bh = T;
  64058. }
  64059. T = sum32_3(this.h[1], C, Dh);
  64060. this.h[1] = sum32_3(this.h[2], D, Eh);
  64061. this.h[2] = sum32_3(this.h[3], E, Ah);
  64062. this.h[3] = sum32_3(this.h[4], A, Bh);
  64063. this.h[4] = sum32_3(this.h[0], B, Ch);
  64064. this.h[0] = T;
  64065. };
  64066. RIPEMD160.prototype._digest = function digest(enc) {
  64067. if (enc === 'hex')
  64068. return utils.toHex32(this.h, 'little');
  64069. else
  64070. return utils.split32(this.h, 'little');
  64071. };
  64072. function f(j, x, y, z) {
  64073. if (j <= 15)
  64074. return x ^ y ^ z;
  64075. else if (j <= 31)
  64076. return (x & y) | ((~x) & z);
  64077. else if (j <= 47)
  64078. return (x | (~y)) ^ z;
  64079. else if (j <= 63)
  64080. return (x & z) | (y & (~z));
  64081. else
  64082. return x ^ (y | (~z));
  64083. }
  64084. function K(j) {
  64085. if (j <= 15)
  64086. return 0x00000000;
  64087. else if (j <= 31)
  64088. return 0x5a827999;
  64089. else if (j <= 47)
  64090. return 0x6ed9eba1;
  64091. else if (j <= 63)
  64092. return 0x8f1bbcdc;
  64093. else
  64094. return 0xa953fd4e;
  64095. }
  64096. function Kh(j) {
  64097. if (j <= 15)
  64098. return 0x50a28be6;
  64099. else if (j <= 31)
  64100. return 0x5c4dd124;
  64101. else if (j <= 47)
  64102. return 0x6d703ef3;
  64103. else if (j <= 63)
  64104. return 0x7a6d76e9;
  64105. else
  64106. return 0x00000000;
  64107. }
  64108. var r = [
  64109. 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15,
  64110. 7, 4, 13, 1, 10, 6, 15, 3, 12, 0, 9, 5, 2, 14, 11, 8,
  64111. 3, 10, 14, 4, 9, 15, 8, 1, 2, 7, 0, 6, 13, 11, 5, 12,
  64112. 1, 9, 11, 10, 0, 8, 12, 4, 13, 3, 7, 15, 14, 5, 6, 2,
  64113. 4, 0, 5, 9, 7, 12, 2, 10, 14, 1, 3, 8, 11, 6, 15, 13
  64114. ];
  64115. var rh = [
  64116. 5, 14, 7, 0, 9, 2, 11, 4, 13, 6, 15, 8, 1, 10, 3, 12,
  64117. 6, 11, 3, 7, 0, 13, 5, 10, 14, 15, 8, 12, 4, 9, 1, 2,
  64118. 15, 5, 1, 3, 7, 14, 6, 9, 11, 8, 12, 2, 10, 0, 4, 13,
  64119. 8, 6, 4, 1, 3, 11, 15, 0, 5, 12, 2, 13, 9, 7, 10, 14,
  64120. 12, 15, 10, 4, 1, 5, 8, 7, 6, 2, 13, 14, 0, 3, 9, 11
  64121. ];
  64122. var s = [
  64123. 11, 14, 15, 12, 5, 8, 7, 9, 11, 13, 14, 15, 6, 7, 9, 8,
  64124. 7, 6, 8, 13, 11, 9, 7, 15, 7, 12, 15, 9, 11, 7, 13, 12,
  64125. 11, 13, 6, 7, 14, 9, 13, 15, 14, 8, 13, 6, 5, 12, 7, 5,
  64126. 11, 12, 14, 15, 14, 15, 9, 8, 9, 14, 5, 6, 8, 6, 5, 12,
  64127. 9, 15, 5, 11, 6, 8, 13, 12, 5, 12, 13, 14, 11, 8, 5, 6
  64128. ];
  64129. var sh = [
  64130. 8, 9, 9, 11, 13, 15, 15, 5, 7, 7, 8, 11, 14, 14, 12, 6,
  64131. 9, 13, 15, 7, 12, 8, 9, 11, 7, 7, 12, 7, 6, 15, 13, 11,
  64132. 9, 7, 15, 11, 8, 6, 6, 14, 12, 13, 5, 14, 13, 13, 7, 5,
  64133. 15, 5, 8, 11, 14, 14, 6, 14, 6, 9, 12, 9, 12, 5, 15, 8,
  64134. 8, 5, 12, 9, 12, 5, 14, 6, 8, 13, 6, 5, 15, 13, 11, 11
  64135. ];
  64136. },{"./common":777,"./utils":787}],780:[function(_dereq_,module,exports){
  64137. 'use strict';
  64138. exports.sha1 = _dereq_('./sha/1');
  64139. exports.sha224 = _dereq_('./sha/224');
  64140. exports.sha256 = _dereq_('./sha/256');
  64141. exports.sha384 = _dereq_('./sha/384');
  64142. exports.sha512 = _dereq_('./sha/512');
  64143. },{"./sha/1":781,"./sha/224":782,"./sha/256":783,"./sha/384":784,"./sha/512":785}],781:[function(_dereq_,module,exports){
  64144. 'use strict';
  64145. var utils = _dereq_('../utils');
  64146. var common = _dereq_('../common');
  64147. var shaCommon = _dereq_('./common');
  64148. var rotl32 = utils.rotl32;
  64149. var sum32 = utils.sum32;
  64150. var sum32_5 = utils.sum32_5;
  64151. var ft_1 = shaCommon.ft_1;
  64152. var BlockHash = common.BlockHash;
  64153. var sha1_K = [
  64154. 0x5A827999, 0x6ED9EBA1,
  64155. 0x8F1BBCDC, 0xCA62C1D6
  64156. ];
  64157. function SHA1() {
  64158. if (!(this instanceof SHA1))
  64159. return new SHA1();
  64160. BlockHash.call(this);
  64161. this.h = [
  64162. 0x67452301, 0xefcdab89, 0x98badcfe,
  64163. 0x10325476, 0xc3d2e1f0 ];
  64164. this.W = new Array(80);
  64165. }
  64166. utils.inherits(SHA1, BlockHash);
  64167. module.exports = SHA1;
  64168. SHA1.blockSize = 512;
  64169. SHA1.outSize = 160;
  64170. SHA1.hmacStrength = 80;
  64171. SHA1.padLength = 64;
  64172. SHA1.prototype._update = function _update(msg, start) {
  64173. var W = this.W;
  64174. for (var i = 0; i < 16; i++)
  64175. W[i] = msg[start + i];
  64176. for(; i < W.length; i++)
  64177. W[i] = rotl32(W[i - 3] ^ W[i - 8] ^ W[i - 14] ^ W[i - 16], 1);
  64178. var a = this.h[0];
  64179. var b = this.h[1];
  64180. var c = this.h[2];
  64181. var d = this.h[3];
  64182. var e = this.h[4];
  64183. for (i = 0; i < W.length; i++) {
  64184. var s = ~~(i / 20);
  64185. var t = sum32_5(rotl32(a, 5), ft_1(s, b, c, d), e, W[i], sha1_K[s]);
  64186. e = d;
  64187. d = c;
  64188. c = rotl32(b, 30);
  64189. b = a;
  64190. a = t;
  64191. }
  64192. this.h[0] = sum32(this.h[0], a);
  64193. this.h[1] = sum32(this.h[1], b);
  64194. this.h[2] = sum32(this.h[2], c);
  64195. this.h[3] = sum32(this.h[3], d);
  64196. this.h[4] = sum32(this.h[4], e);
  64197. };
  64198. SHA1.prototype._digest = function digest(enc) {
  64199. if (enc === 'hex')
  64200. return utils.toHex32(this.h, 'big');
  64201. else
  64202. return utils.split32(this.h, 'big');
  64203. };
  64204. },{"../common":777,"../utils":787,"./common":786}],782:[function(_dereq_,module,exports){
  64205. 'use strict';
  64206. var utils = _dereq_('../utils');
  64207. var SHA256 = _dereq_('./256');
  64208. function SHA224() {
  64209. if (!(this instanceof SHA224))
  64210. return new SHA224();
  64211. SHA256.call(this);
  64212. this.h = [
  64213. 0xc1059ed8, 0x367cd507, 0x3070dd17, 0xf70e5939,
  64214. 0xffc00b31, 0x68581511, 0x64f98fa7, 0xbefa4fa4 ];
  64215. }
  64216. utils.inherits(SHA224, SHA256);
  64217. module.exports = SHA224;
  64218. SHA224.blockSize = 512;
  64219. SHA224.outSize = 224;
  64220. SHA224.hmacStrength = 192;
  64221. SHA224.padLength = 64;
  64222. SHA224.prototype._digest = function digest(enc) {
  64223. // Just truncate output
  64224. if (enc === 'hex')
  64225. return utils.toHex32(this.h.slice(0, 7), 'big');
  64226. else
  64227. return utils.split32(this.h.slice(0, 7), 'big');
  64228. };
  64229. },{"../utils":787,"./256":783}],783:[function(_dereq_,module,exports){
  64230. 'use strict';
  64231. var utils = _dereq_('../utils');
  64232. var common = _dereq_('../common');
  64233. var shaCommon = _dereq_('./common');
  64234. var assert = _dereq_('minimalistic-assert');
  64235. var sum32 = utils.sum32;
  64236. var sum32_4 = utils.sum32_4;
  64237. var sum32_5 = utils.sum32_5;
  64238. var ch32 = shaCommon.ch32;
  64239. var maj32 = shaCommon.maj32;
  64240. var s0_256 = shaCommon.s0_256;
  64241. var s1_256 = shaCommon.s1_256;
  64242. var g0_256 = shaCommon.g0_256;
  64243. var g1_256 = shaCommon.g1_256;
  64244. var BlockHash = common.BlockHash;
  64245. var sha256_K = [
  64246. 0x428a2f98, 0x71374491, 0xb5c0fbcf, 0xe9b5dba5,
  64247. 0x3956c25b, 0x59f111f1, 0x923f82a4, 0xab1c5ed5,
  64248. 0xd807aa98, 0x12835b01, 0x243185be, 0x550c7dc3,
  64249. 0x72be5d74, 0x80deb1fe, 0x9bdc06a7, 0xc19bf174,
  64250. 0xe49b69c1, 0xefbe4786, 0x0fc19dc6, 0x240ca1cc,
  64251. 0x2de92c6f, 0x4a7484aa, 0x5cb0a9dc, 0x76f988da,
  64252. 0x983e5152, 0xa831c66d, 0xb00327c8, 0xbf597fc7,
  64253. 0xc6e00bf3, 0xd5a79147, 0x06ca6351, 0x14292967,
  64254. 0x27b70a85, 0x2e1b2138, 0x4d2c6dfc, 0x53380d13,
  64255. 0x650a7354, 0x766a0abb, 0x81c2c92e, 0x92722c85,
  64256. 0xa2bfe8a1, 0xa81a664b, 0xc24b8b70, 0xc76c51a3,
  64257. 0xd192e819, 0xd6990624, 0xf40e3585, 0x106aa070,
  64258. 0x19a4c116, 0x1e376c08, 0x2748774c, 0x34b0bcb5,
  64259. 0x391c0cb3, 0x4ed8aa4a, 0x5b9cca4f, 0x682e6ff3,
  64260. 0x748f82ee, 0x78a5636f, 0x84c87814, 0x8cc70208,
  64261. 0x90befffa, 0xa4506ceb, 0xbef9a3f7, 0xc67178f2
  64262. ];
  64263. function SHA256() {
  64264. if (!(this instanceof SHA256))
  64265. return new SHA256();
  64266. BlockHash.call(this);
  64267. this.h = [
  64268. 0x6a09e667, 0xbb67ae85, 0x3c6ef372, 0xa54ff53a,
  64269. 0x510e527f, 0x9b05688c, 0x1f83d9ab, 0x5be0cd19
  64270. ];
  64271. this.k = sha256_K;
  64272. this.W = new Array(64);
  64273. }
  64274. utils.inherits(SHA256, BlockHash);
  64275. module.exports = SHA256;
  64276. SHA256.blockSize = 512;
  64277. SHA256.outSize = 256;
  64278. SHA256.hmacStrength = 192;
  64279. SHA256.padLength = 64;
  64280. SHA256.prototype._update = function _update(msg, start) {
  64281. var W = this.W;
  64282. for (var i = 0; i < 16; i++)
  64283. W[i] = msg[start + i];
  64284. for (; i < W.length; i++)
  64285. W[i] = sum32_4(g1_256(W[i - 2]), W[i - 7], g0_256(W[i - 15]), W[i - 16]);
  64286. var a = this.h[0];
  64287. var b = this.h[1];
  64288. var c = this.h[2];
  64289. var d = this.h[3];
  64290. var e = this.h[4];
  64291. var f = this.h[5];
  64292. var g = this.h[6];
  64293. var h = this.h[7];
  64294. assert(this.k.length === W.length);
  64295. for (i = 0; i < W.length; i++) {
  64296. var T1 = sum32_5(h, s1_256(e), ch32(e, f, g), this.k[i], W[i]);
  64297. var T2 = sum32(s0_256(a), maj32(a, b, c));
  64298. h = g;
  64299. g = f;
  64300. f = e;
  64301. e = sum32(d, T1);
  64302. d = c;
  64303. c = b;
  64304. b = a;
  64305. a = sum32(T1, T2);
  64306. }
  64307. this.h[0] = sum32(this.h[0], a);
  64308. this.h[1] = sum32(this.h[1], b);
  64309. this.h[2] = sum32(this.h[2], c);
  64310. this.h[3] = sum32(this.h[3], d);
  64311. this.h[4] = sum32(this.h[4], e);
  64312. this.h[5] = sum32(this.h[5], f);
  64313. this.h[6] = sum32(this.h[6], g);
  64314. this.h[7] = sum32(this.h[7], h);
  64315. };
  64316. SHA256.prototype._digest = function digest(enc) {
  64317. if (enc === 'hex')
  64318. return utils.toHex32(this.h, 'big');
  64319. else
  64320. return utils.split32(this.h, 'big');
  64321. };
  64322. },{"../common":777,"../utils":787,"./common":786,"minimalistic-assert":791}],784:[function(_dereq_,module,exports){
  64323. 'use strict';
  64324. var utils = _dereq_('../utils');
  64325. var SHA512 = _dereq_('./512');
  64326. function SHA384() {
  64327. if (!(this instanceof SHA384))
  64328. return new SHA384();
  64329. SHA512.call(this);
  64330. this.h = [
  64331. 0xcbbb9d5d, 0xc1059ed8,
  64332. 0x629a292a, 0x367cd507,
  64333. 0x9159015a, 0x3070dd17,
  64334. 0x152fecd8, 0xf70e5939,
  64335. 0x67332667, 0xffc00b31,
  64336. 0x8eb44a87, 0x68581511,
  64337. 0xdb0c2e0d, 0x64f98fa7,
  64338. 0x47b5481d, 0xbefa4fa4 ];
  64339. }
  64340. utils.inherits(SHA384, SHA512);
  64341. module.exports = SHA384;
  64342. SHA384.blockSize = 1024;
  64343. SHA384.outSize = 384;
  64344. SHA384.hmacStrength = 192;
  64345. SHA384.padLength = 128;
  64346. SHA384.prototype._digest = function digest(enc) {
  64347. if (enc === 'hex')
  64348. return utils.toHex32(this.h.slice(0, 12), 'big');
  64349. else
  64350. return utils.split32(this.h.slice(0, 12), 'big');
  64351. };
  64352. },{"../utils":787,"./512":785}],785:[function(_dereq_,module,exports){
  64353. 'use strict';
  64354. var utils = _dereq_('../utils');
  64355. var common = _dereq_('../common');
  64356. var assert = _dereq_('minimalistic-assert');
  64357. var rotr64_hi = utils.rotr64_hi;
  64358. var rotr64_lo = utils.rotr64_lo;
  64359. var shr64_hi = utils.shr64_hi;
  64360. var shr64_lo = utils.shr64_lo;
  64361. var sum64 = utils.sum64;
  64362. var sum64_hi = utils.sum64_hi;
  64363. var sum64_lo = utils.sum64_lo;
  64364. var sum64_4_hi = utils.sum64_4_hi;
  64365. var sum64_4_lo = utils.sum64_4_lo;
  64366. var sum64_5_hi = utils.sum64_5_hi;
  64367. var sum64_5_lo = utils.sum64_5_lo;
  64368. var BlockHash = common.BlockHash;
  64369. var sha512_K = [
  64370. 0x428a2f98, 0xd728ae22, 0x71374491, 0x23ef65cd,
  64371. 0xb5c0fbcf, 0xec4d3b2f, 0xe9b5dba5, 0x8189dbbc,
  64372. 0x3956c25b, 0xf348b538, 0x59f111f1, 0xb605d019,
  64373. 0x923f82a4, 0xaf194f9b, 0xab1c5ed5, 0xda6d8118,
  64374. 0xd807aa98, 0xa3030242, 0x12835b01, 0x45706fbe,
  64375. 0x243185be, 0x4ee4b28c, 0x550c7dc3, 0xd5ffb4e2,
  64376. 0x72be5d74, 0xf27b896f, 0x80deb1fe, 0x3b1696b1,
  64377. 0x9bdc06a7, 0x25c71235, 0xc19bf174, 0xcf692694,
  64378. 0xe49b69c1, 0x9ef14ad2, 0xefbe4786, 0x384f25e3,
  64379. 0x0fc19dc6, 0x8b8cd5b5, 0x240ca1cc, 0x77ac9c65,
  64380. 0x2de92c6f, 0x592b0275, 0x4a7484aa, 0x6ea6e483,
  64381. 0x5cb0a9dc, 0xbd41fbd4, 0x76f988da, 0x831153b5,
  64382. 0x983e5152, 0xee66dfab, 0xa831c66d, 0x2db43210,
  64383. 0xb00327c8, 0x98fb213f, 0xbf597fc7, 0xbeef0ee4,
  64384. 0xc6e00bf3, 0x3da88fc2, 0xd5a79147, 0x930aa725,
  64385. 0x06ca6351, 0xe003826f, 0x14292967, 0x0a0e6e70,
  64386. 0x27b70a85, 0x46d22ffc, 0x2e1b2138, 0x5c26c926,
  64387. 0x4d2c6dfc, 0x5ac42aed, 0x53380d13, 0x9d95b3df,
  64388. 0x650a7354, 0x8baf63de, 0x766a0abb, 0x3c77b2a8,
  64389. 0x81c2c92e, 0x47edaee6, 0x92722c85, 0x1482353b,
  64390. 0xa2bfe8a1, 0x4cf10364, 0xa81a664b, 0xbc423001,
  64391. 0xc24b8b70, 0xd0f89791, 0xc76c51a3, 0x0654be30,
  64392. 0xd192e819, 0xd6ef5218, 0xd6990624, 0x5565a910,
  64393. 0xf40e3585, 0x5771202a, 0x106aa070, 0x32bbd1b8,
  64394. 0x19a4c116, 0xb8d2d0c8, 0x1e376c08, 0x5141ab53,
  64395. 0x2748774c, 0xdf8eeb99, 0x34b0bcb5, 0xe19b48a8,
  64396. 0x391c0cb3, 0xc5c95a63, 0x4ed8aa4a, 0xe3418acb,
  64397. 0x5b9cca4f, 0x7763e373, 0x682e6ff3, 0xd6b2b8a3,
  64398. 0x748f82ee, 0x5defb2fc, 0x78a5636f, 0x43172f60,
  64399. 0x84c87814, 0xa1f0ab72, 0x8cc70208, 0x1a6439ec,
  64400. 0x90befffa, 0x23631e28, 0xa4506ceb, 0xde82bde9,
  64401. 0xbef9a3f7, 0xb2c67915, 0xc67178f2, 0xe372532b,
  64402. 0xca273ece, 0xea26619c, 0xd186b8c7, 0x21c0c207,
  64403. 0xeada7dd6, 0xcde0eb1e, 0xf57d4f7f, 0xee6ed178,
  64404. 0x06f067aa, 0x72176fba, 0x0a637dc5, 0xa2c898a6,
  64405. 0x113f9804, 0xbef90dae, 0x1b710b35, 0x131c471b,
  64406. 0x28db77f5, 0x23047d84, 0x32caab7b, 0x40c72493,
  64407. 0x3c9ebe0a, 0x15c9bebc, 0x431d67c4, 0x9c100d4c,
  64408. 0x4cc5d4be, 0xcb3e42b6, 0x597f299c, 0xfc657e2a,
  64409. 0x5fcb6fab, 0x3ad6faec, 0x6c44198c, 0x4a475817
  64410. ];
  64411. function SHA512() {
  64412. if (!(this instanceof SHA512))
  64413. return new SHA512();
  64414. BlockHash.call(this);
  64415. this.h = [
  64416. 0x6a09e667, 0xf3bcc908,
  64417. 0xbb67ae85, 0x84caa73b,
  64418. 0x3c6ef372, 0xfe94f82b,
  64419. 0xa54ff53a, 0x5f1d36f1,
  64420. 0x510e527f, 0xade682d1,
  64421. 0x9b05688c, 0x2b3e6c1f,
  64422. 0x1f83d9ab, 0xfb41bd6b,
  64423. 0x5be0cd19, 0x137e2179 ];
  64424. this.k = sha512_K;
  64425. this.W = new Array(160);
  64426. }
  64427. utils.inherits(SHA512, BlockHash);
  64428. module.exports = SHA512;
  64429. SHA512.blockSize = 1024;
  64430. SHA512.outSize = 512;
  64431. SHA512.hmacStrength = 192;
  64432. SHA512.padLength = 128;
  64433. SHA512.prototype._prepareBlock = function _prepareBlock(msg, start) {
  64434. var W = this.W;
  64435. // 32 x 32bit words
  64436. for (var i = 0; i < 32; i++)
  64437. W[i] = msg[start + i];
  64438. for (; i < W.length; i += 2) {
  64439. var c0_hi = g1_512_hi(W[i - 4], W[i - 3]); // i - 2
  64440. var c0_lo = g1_512_lo(W[i - 4], W[i - 3]);
  64441. var c1_hi = W[i - 14]; // i - 7
  64442. var c1_lo = W[i - 13];
  64443. var c2_hi = g0_512_hi(W[i - 30], W[i - 29]); // i - 15
  64444. var c2_lo = g0_512_lo(W[i - 30], W[i - 29]);
  64445. var c3_hi = W[i - 32]; // i - 16
  64446. var c3_lo = W[i - 31];
  64447. W[i] = sum64_4_hi(
  64448. c0_hi, c0_lo,
  64449. c1_hi, c1_lo,
  64450. c2_hi, c2_lo,
  64451. c3_hi, c3_lo);
  64452. W[i + 1] = sum64_4_lo(
  64453. c0_hi, c0_lo,
  64454. c1_hi, c1_lo,
  64455. c2_hi, c2_lo,
  64456. c3_hi, c3_lo);
  64457. }
  64458. };
  64459. SHA512.prototype._update = function _update(msg, start) {
  64460. this._prepareBlock(msg, start);
  64461. var W = this.W;
  64462. var ah = this.h[0];
  64463. var al = this.h[1];
  64464. var bh = this.h[2];
  64465. var bl = this.h[3];
  64466. var ch = this.h[4];
  64467. var cl = this.h[5];
  64468. var dh = this.h[6];
  64469. var dl = this.h[7];
  64470. var eh = this.h[8];
  64471. var el = this.h[9];
  64472. var fh = this.h[10];
  64473. var fl = this.h[11];
  64474. var gh = this.h[12];
  64475. var gl = this.h[13];
  64476. var hh = this.h[14];
  64477. var hl = this.h[15];
  64478. assert(this.k.length === W.length);
  64479. for (var i = 0; i < W.length; i += 2) {
  64480. var c0_hi = hh;
  64481. var c0_lo = hl;
  64482. var c1_hi = s1_512_hi(eh, el);
  64483. var c1_lo = s1_512_lo(eh, el);
  64484. var c2_hi = ch64_hi(eh, el, fh, fl, gh, gl);
  64485. var c2_lo = ch64_lo(eh, el, fh, fl, gh, gl);
  64486. var c3_hi = this.k[i];
  64487. var c3_lo = this.k[i + 1];
  64488. var c4_hi = W[i];
  64489. var c4_lo = W[i + 1];
  64490. var T1_hi = sum64_5_hi(
  64491. c0_hi, c0_lo,
  64492. c1_hi, c1_lo,
  64493. c2_hi, c2_lo,
  64494. c3_hi, c3_lo,
  64495. c4_hi, c4_lo);
  64496. var T1_lo = sum64_5_lo(
  64497. c0_hi, c0_lo,
  64498. c1_hi, c1_lo,
  64499. c2_hi, c2_lo,
  64500. c3_hi, c3_lo,
  64501. c4_hi, c4_lo);
  64502. c0_hi = s0_512_hi(ah, al);
  64503. c0_lo = s0_512_lo(ah, al);
  64504. c1_hi = maj64_hi(ah, al, bh, bl, ch, cl);
  64505. c1_lo = maj64_lo(ah, al, bh, bl, ch, cl);
  64506. var T2_hi = sum64_hi(c0_hi, c0_lo, c1_hi, c1_lo);
  64507. var T2_lo = sum64_lo(c0_hi, c0_lo, c1_hi, c1_lo);
  64508. hh = gh;
  64509. hl = gl;
  64510. gh = fh;
  64511. gl = fl;
  64512. fh = eh;
  64513. fl = el;
  64514. eh = sum64_hi(dh, dl, T1_hi, T1_lo);
  64515. el = sum64_lo(dl, dl, T1_hi, T1_lo);
  64516. dh = ch;
  64517. dl = cl;
  64518. ch = bh;
  64519. cl = bl;
  64520. bh = ah;
  64521. bl = al;
  64522. ah = sum64_hi(T1_hi, T1_lo, T2_hi, T2_lo);
  64523. al = sum64_lo(T1_hi, T1_lo, T2_hi, T2_lo);
  64524. }
  64525. sum64(this.h, 0, ah, al);
  64526. sum64(this.h, 2, bh, bl);
  64527. sum64(this.h, 4, ch, cl);
  64528. sum64(this.h, 6, dh, dl);
  64529. sum64(this.h, 8, eh, el);
  64530. sum64(this.h, 10, fh, fl);
  64531. sum64(this.h, 12, gh, gl);
  64532. sum64(this.h, 14, hh, hl);
  64533. };
  64534. SHA512.prototype._digest = function digest(enc) {
  64535. if (enc === 'hex')
  64536. return utils.toHex32(this.h, 'big');
  64537. else
  64538. return utils.split32(this.h, 'big');
  64539. };
  64540. function ch64_hi(xh, xl, yh, yl, zh) {
  64541. var r = (xh & yh) ^ ((~xh) & zh);
  64542. if (r < 0)
  64543. r += 0x100000000;
  64544. return r;
  64545. }
  64546. function ch64_lo(xh, xl, yh, yl, zh, zl) {
  64547. var r = (xl & yl) ^ ((~xl) & zl);
  64548. if (r < 0)
  64549. r += 0x100000000;
  64550. return r;
  64551. }
  64552. function maj64_hi(xh, xl, yh, yl, zh) {
  64553. var r = (xh & yh) ^ (xh & zh) ^ (yh & zh);
  64554. if (r < 0)
  64555. r += 0x100000000;
  64556. return r;
  64557. }
  64558. function maj64_lo(xh, xl, yh, yl, zh, zl) {
  64559. var r = (xl & yl) ^ (xl & zl) ^ (yl & zl);
  64560. if (r < 0)
  64561. r += 0x100000000;
  64562. return r;
  64563. }
  64564. function s0_512_hi(xh, xl) {
  64565. var c0_hi = rotr64_hi(xh, xl, 28);
  64566. var c1_hi = rotr64_hi(xl, xh, 2); // 34
  64567. var c2_hi = rotr64_hi(xl, xh, 7); // 39
  64568. var r = c0_hi ^ c1_hi ^ c2_hi;
  64569. if (r < 0)
  64570. r += 0x100000000;
  64571. return r;
  64572. }
  64573. function s0_512_lo(xh, xl) {
  64574. var c0_lo = rotr64_lo(xh, xl, 28);
  64575. var c1_lo = rotr64_lo(xl, xh, 2); // 34
  64576. var c2_lo = rotr64_lo(xl, xh, 7); // 39
  64577. var r = c0_lo ^ c1_lo ^ c2_lo;
  64578. if (r < 0)
  64579. r += 0x100000000;
  64580. return r;
  64581. }
  64582. function s1_512_hi(xh, xl) {
  64583. var c0_hi = rotr64_hi(xh, xl, 14);
  64584. var c1_hi = rotr64_hi(xh, xl, 18);
  64585. var c2_hi = rotr64_hi(xl, xh, 9); // 41
  64586. var r = c0_hi ^ c1_hi ^ c2_hi;
  64587. if (r < 0)
  64588. r += 0x100000000;
  64589. return r;
  64590. }
  64591. function s1_512_lo(xh, xl) {
  64592. var c0_lo = rotr64_lo(xh, xl, 14);
  64593. var c1_lo = rotr64_lo(xh, xl, 18);
  64594. var c2_lo = rotr64_lo(xl, xh, 9); // 41
  64595. var r = c0_lo ^ c1_lo ^ c2_lo;
  64596. if (r < 0)
  64597. r += 0x100000000;
  64598. return r;
  64599. }
  64600. function g0_512_hi(xh, xl) {
  64601. var c0_hi = rotr64_hi(xh, xl, 1);
  64602. var c1_hi = rotr64_hi(xh, xl, 8);
  64603. var c2_hi = shr64_hi(xh, xl, 7);
  64604. var r = c0_hi ^ c1_hi ^ c2_hi;
  64605. if (r < 0)
  64606. r += 0x100000000;
  64607. return r;
  64608. }
  64609. function g0_512_lo(xh, xl) {
  64610. var c0_lo = rotr64_lo(xh, xl, 1);
  64611. var c1_lo = rotr64_lo(xh, xl, 8);
  64612. var c2_lo = shr64_lo(xh, xl, 7);
  64613. var r = c0_lo ^ c1_lo ^ c2_lo;
  64614. if (r < 0)
  64615. r += 0x100000000;
  64616. return r;
  64617. }
  64618. function g1_512_hi(xh, xl) {
  64619. var c0_hi = rotr64_hi(xh, xl, 19);
  64620. var c1_hi = rotr64_hi(xl, xh, 29); // 61
  64621. var c2_hi = shr64_hi(xh, xl, 6);
  64622. var r = c0_hi ^ c1_hi ^ c2_hi;
  64623. if (r < 0)
  64624. r += 0x100000000;
  64625. return r;
  64626. }
  64627. function g1_512_lo(xh, xl) {
  64628. var c0_lo = rotr64_lo(xh, xl, 19);
  64629. var c1_lo = rotr64_lo(xl, xh, 29); // 61
  64630. var c2_lo = shr64_lo(xh, xl, 6);
  64631. var r = c0_lo ^ c1_lo ^ c2_lo;
  64632. if (r < 0)
  64633. r += 0x100000000;
  64634. return r;
  64635. }
  64636. },{"../common":777,"../utils":787,"minimalistic-assert":791}],786:[function(_dereq_,module,exports){
  64637. 'use strict';
  64638. var utils = _dereq_('../utils');
  64639. var rotr32 = utils.rotr32;
  64640. function ft_1(s, x, y, z) {
  64641. if (s === 0)
  64642. return ch32(x, y, z);
  64643. if (s === 1 || s === 3)
  64644. return p32(x, y, z);
  64645. if (s === 2)
  64646. return maj32(x, y, z);
  64647. }
  64648. exports.ft_1 = ft_1;
  64649. function ch32(x, y, z) {
  64650. return (x & y) ^ ((~x) & z);
  64651. }
  64652. exports.ch32 = ch32;
  64653. function maj32(x, y, z) {
  64654. return (x & y) ^ (x & z) ^ (y & z);
  64655. }
  64656. exports.maj32 = maj32;
  64657. function p32(x, y, z) {
  64658. return x ^ y ^ z;
  64659. }
  64660. exports.p32 = p32;
  64661. function s0_256(x) {
  64662. return rotr32(x, 2) ^ rotr32(x, 13) ^ rotr32(x, 22);
  64663. }
  64664. exports.s0_256 = s0_256;
  64665. function s1_256(x) {
  64666. return rotr32(x, 6) ^ rotr32(x, 11) ^ rotr32(x, 25);
  64667. }
  64668. exports.s1_256 = s1_256;
  64669. function g0_256(x) {
  64670. return rotr32(x, 7) ^ rotr32(x, 18) ^ (x >>> 3);
  64671. }
  64672. exports.g0_256 = g0_256;
  64673. function g1_256(x) {
  64674. return rotr32(x, 17) ^ rotr32(x, 19) ^ (x >>> 10);
  64675. }
  64676. exports.g1_256 = g1_256;
  64677. },{"../utils":787}],787:[function(_dereq_,module,exports){
  64678. 'use strict';
  64679. var assert = _dereq_('minimalistic-assert');
  64680. var inherits = _dereq_('inherits');
  64681. exports.inherits = inherits;
  64682. function isSurrogatePair(msg, i) {
  64683. if ((msg.charCodeAt(i) & 0xFC00) !== 0xD800) {
  64684. return false;
  64685. }
  64686. if (i < 0 || i + 1 >= msg.length) {
  64687. return false;
  64688. }
  64689. return (msg.charCodeAt(i + 1) & 0xFC00) === 0xDC00;
  64690. }
  64691. function toArray(msg, enc) {
  64692. if (Array.isArray(msg))
  64693. return msg.slice();
  64694. if (!msg)
  64695. return [];
  64696. var res = [];
  64697. if (typeof msg === 'string') {
  64698. if (!enc) {
  64699. // Inspired by stringToUtf8ByteArray() in closure-library by Google
  64700. // https://github.com/google/closure-library/blob/8598d87242af59aac233270742c8984e2b2bdbe0/closure/goog/crypt/crypt.js#L117-L143
  64701. // Apache License 2.0
  64702. // https://github.com/google/closure-library/blob/master/LICENSE
  64703. var p = 0;
  64704. for (var i = 0; i < msg.length; i++) {
  64705. var c = msg.charCodeAt(i);
  64706. if (c < 128) {
  64707. res[p++] = c;
  64708. } else if (c < 2048) {
  64709. res[p++] = (c >> 6) | 192;
  64710. res[p++] = (c & 63) | 128;
  64711. } else if (isSurrogatePair(msg, i)) {
  64712. c = 0x10000 + ((c & 0x03FF) << 10) + (msg.charCodeAt(++i) & 0x03FF);
  64713. res[p++] = (c >> 18) | 240;
  64714. res[p++] = ((c >> 12) & 63) | 128;
  64715. res[p++] = ((c >> 6) & 63) | 128;
  64716. res[p++] = (c & 63) | 128;
  64717. } else {
  64718. res[p++] = (c >> 12) | 224;
  64719. res[p++] = ((c >> 6) & 63) | 128;
  64720. res[p++] = (c & 63) | 128;
  64721. }
  64722. }
  64723. } else if (enc === 'hex') {
  64724. msg = msg.replace(/[^a-z0-9]+/ig, '');
  64725. if (msg.length % 2 !== 0)
  64726. msg = '0' + msg;
  64727. for (i = 0; i < msg.length; i += 2)
  64728. res.push(parseInt(msg[i] + msg[i + 1], 16));
  64729. }
  64730. } else {
  64731. for (i = 0; i < msg.length; i++)
  64732. res[i] = msg[i] | 0;
  64733. }
  64734. return res;
  64735. }
  64736. exports.toArray = toArray;
  64737. function toHex(msg) {
  64738. var res = '';
  64739. for (var i = 0; i < msg.length; i++)
  64740. res += zero2(msg[i].toString(16));
  64741. return res;
  64742. }
  64743. exports.toHex = toHex;
  64744. function htonl(w) {
  64745. var res = (w >>> 24) |
  64746. ((w >>> 8) & 0xff00) |
  64747. ((w << 8) & 0xff0000) |
  64748. ((w & 0xff) << 24);
  64749. return res >>> 0;
  64750. }
  64751. exports.htonl = htonl;
  64752. function toHex32(msg, endian) {
  64753. var res = '';
  64754. for (var i = 0; i < msg.length; i++) {
  64755. var w = msg[i];
  64756. if (endian === 'little')
  64757. w = htonl(w);
  64758. res += zero8(w.toString(16));
  64759. }
  64760. return res;
  64761. }
  64762. exports.toHex32 = toHex32;
  64763. function zero2(word) {
  64764. if (word.length === 1)
  64765. return '0' + word;
  64766. else
  64767. return word;
  64768. }
  64769. exports.zero2 = zero2;
  64770. function zero8(word) {
  64771. if (word.length === 7)
  64772. return '0' + word;
  64773. else if (word.length === 6)
  64774. return '00' + word;
  64775. else if (word.length === 5)
  64776. return '000' + word;
  64777. else if (word.length === 4)
  64778. return '0000' + word;
  64779. else if (word.length === 3)
  64780. return '00000' + word;
  64781. else if (word.length === 2)
  64782. return '000000' + word;
  64783. else if (word.length === 1)
  64784. return '0000000' + word;
  64785. else
  64786. return word;
  64787. }
  64788. exports.zero8 = zero8;
  64789. function join32(msg, start, end, endian) {
  64790. var len = end - start;
  64791. assert(len % 4 === 0);
  64792. var res = new Array(len / 4);
  64793. for (var i = 0, k = start; i < res.length; i++, k += 4) {
  64794. var w;
  64795. if (endian === 'big')
  64796. w = (msg[k] << 24) | (msg[k + 1] << 16) | (msg[k + 2] << 8) | msg[k + 3];
  64797. else
  64798. w = (msg[k + 3] << 24) | (msg[k + 2] << 16) | (msg[k + 1] << 8) | msg[k];
  64799. res[i] = w >>> 0;
  64800. }
  64801. return res;
  64802. }
  64803. exports.join32 = join32;
  64804. function split32(msg, endian) {
  64805. var res = new Array(msg.length * 4);
  64806. for (var i = 0, k = 0; i < msg.length; i++, k += 4) {
  64807. var m = msg[i];
  64808. if (endian === 'big') {
  64809. res[k] = m >>> 24;
  64810. res[k + 1] = (m >>> 16) & 0xff;
  64811. res[k + 2] = (m >>> 8) & 0xff;
  64812. res[k + 3] = m & 0xff;
  64813. } else {
  64814. res[k + 3] = m >>> 24;
  64815. res[k + 2] = (m >>> 16) & 0xff;
  64816. res[k + 1] = (m >>> 8) & 0xff;
  64817. res[k] = m & 0xff;
  64818. }
  64819. }
  64820. return res;
  64821. }
  64822. exports.split32 = split32;
  64823. function rotr32(w, b) {
  64824. return (w >>> b) | (w << (32 - b));
  64825. }
  64826. exports.rotr32 = rotr32;
  64827. function rotl32(w, b) {
  64828. return (w << b) | (w >>> (32 - b));
  64829. }
  64830. exports.rotl32 = rotl32;
  64831. function sum32(a, b) {
  64832. return (a + b) >>> 0;
  64833. }
  64834. exports.sum32 = sum32;
  64835. function sum32_3(a, b, c) {
  64836. return (a + b + c) >>> 0;
  64837. }
  64838. exports.sum32_3 = sum32_3;
  64839. function sum32_4(a, b, c, d) {
  64840. return (a + b + c + d) >>> 0;
  64841. }
  64842. exports.sum32_4 = sum32_4;
  64843. function sum32_5(a, b, c, d, e) {
  64844. return (a + b + c + d + e) >>> 0;
  64845. }
  64846. exports.sum32_5 = sum32_5;
  64847. function sum64(buf, pos, ah, al) {
  64848. var bh = buf[pos];
  64849. var bl = buf[pos + 1];
  64850. var lo = (al + bl) >>> 0;
  64851. var hi = (lo < al ? 1 : 0) + ah + bh;
  64852. buf[pos] = hi >>> 0;
  64853. buf[pos + 1] = lo;
  64854. }
  64855. exports.sum64 = sum64;
  64856. function sum64_hi(ah, al, bh, bl) {
  64857. var lo = (al + bl) >>> 0;
  64858. var hi = (lo < al ? 1 : 0) + ah + bh;
  64859. return hi >>> 0;
  64860. }
  64861. exports.sum64_hi = sum64_hi;
  64862. function sum64_lo(ah, al, bh, bl) {
  64863. var lo = al + bl;
  64864. return lo >>> 0;
  64865. }
  64866. exports.sum64_lo = sum64_lo;
  64867. function sum64_4_hi(ah, al, bh, bl, ch, cl, dh, dl) {
  64868. var carry = 0;
  64869. var lo = al;
  64870. lo = (lo + bl) >>> 0;
  64871. carry += lo < al ? 1 : 0;
  64872. lo = (lo + cl) >>> 0;
  64873. carry += lo < cl ? 1 : 0;
  64874. lo = (lo + dl) >>> 0;
  64875. carry += lo < dl ? 1 : 0;
  64876. var hi = ah + bh + ch + dh + carry;
  64877. return hi >>> 0;
  64878. }
  64879. exports.sum64_4_hi = sum64_4_hi;
  64880. function sum64_4_lo(ah, al, bh, bl, ch, cl, dh, dl) {
  64881. var lo = al + bl + cl + dl;
  64882. return lo >>> 0;
  64883. }
  64884. exports.sum64_4_lo = sum64_4_lo;
  64885. function sum64_5_hi(ah, al, bh, bl, ch, cl, dh, dl, eh, el) {
  64886. var carry = 0;
  64887. var lo = al;
  64888. lo = (lo + bl) >>> 0;
  64889. carry += lo < al ? 1 : 0;
  64890. lo = (lo + cl) >>> 0;
  64891. carry += lo < cl ? 1 : 0;
  64892. lo = (lo + dl) >>> 0;
  64893. carry += lo < dl ? 1 : 0;
  64894. lo = (lo + el) >>> 0;
  64895. carry += lo < el ? 1 : 0;
  64896. var hi = ah + bh + ch + dh + eh + carry;
  64897. return hi >>> 0;
  64898. }
  64899. exports.sum64_5_hi = sum64_5_hi;
  64900. function sum64_5_lo(ah, al, bh, bl, ch, cl, dh, dl, eh, el) {
  64901. var lo = al + bl + cl + dl + el;
  64902. return lo >>> 0;
  64903. }
  64904. exports.sum64_5_lo = sum64_5_lo;
  64905. function rotr64_hi(ah, al, num) {
  64906. var r = (al << (32 - num)) | (ah >>> num);
  64907. return r >>> 0;
  64908. }
  64909. exports.rotr64_hi = rotr64_hi;
  64910. function rotr64_lo(ah, al, num) {
  64911. var r = (ah << (32 - num)) | (al >>> num);
  64912. return r >>> 0;
  64913. }
  64914. exports.rotr64_lo = rotr64_lo;
  64915. function shr64_hi(ah, al, num) {
  64916. return ah >>> num;
  64917. }
  64918. exports.shr64_hi = shr64_hi;
  64919. function shr64_lo(ah, al, num) {
  64920. var r = (ah << (32 - num)) | (al >>> num);
  64921. return r >>> 0;
  64922. }
  64923. exports.shr64_lo = shr64_lo;
  64924. },{"inherits":789,"minimalistic-assert":791}],788:[function(_dereq_,module,exports){
  64925. 'use strict';
  64926. var hash = _dereq_('hash.js');
  64927. var utils = _dereq_('minimalistic-crypto-utils');
  64928. var assert = _dereq_('minimalistic-assert');
  64929. function HmacDRBG(options) {
  64930. if (!(this instanceof HmacDRBG))
  64931. return new HmacDRBG(options);
  64932. this.hash = options.hash;
  64933. this.predResist = !!options.predResist;
  64934. this.outLen = this.hash.outSize;
  64935. this.minEntropy = options.minEntropy || this.hash.hmacStrength;
  64936. this._reseed = null;
  64937. this.reseedInterval = null;
  64938. this.K = null;
  64939. this.V = null;
  64940. var entropy = utils.toArray(options.entropy, options.entropyEnc || 'hex');
  64941. var nonce = utils.toArray(options.nonce, options.nonceEnc || 'hex');
  64942. var pers = utils.toArray(options.pers, options.persEnc || 'hex');
  64943. assert(entropy.length >= (this.minEntropy / 8),
  64944. 'Not enough entropy. Minimum is: ' + this.minEntropy + ' bits');
  64945. this._init(entropy, nonce, pers);
  64946. }
  64947. module.exports = HmacDRBG;
  64948. HmacDRBG.prototype._init = function init(entropy, nonce, pers) {
  64949. var seed = entropy.concat(nonce).concat(pers);
  64950. this.K = new Array(this.outLen / 8);
  64951. this.V = new Array(this.outLen / 8);
  64952. for (var i = 0; i < this.V.length; i++) {
  64953. this.K[i] = 0x00;
  64954. this.V[i] = 0x01;
  64955. }
  64956. this._update(seed);
  64957. this._reseed = 1;
  64958. this.reseedInterval = 0x1000000000000; // 2^48
  64959. };
  64960. HmacDRBG.prototype._hmac = function hmac() {
  64961. return new hash.hmac(this.hash, this.K);
  64962. };
  64963. HmacDRBG.prototype._update = function update(seed) {
  64964. var kmac = this._hmac()
  64965. .update(this.V)
  64966. .update([ 0x00 ]);
  64967. if (seed)
  64968. kmac = kmac.update(seed);
  64969. this.K = kmac.digest();
  64970. this.V = this._hmac().update(this.V).digest();
  64971. if (!seed)
  64972. return;
  64973. this.K = this._hmac()
  64974. .update(this.V)
  64975. .update([ 0x01 ])
  64976. .update(seed)
  64977. .digest();
  64978. this.V = this._hmac().update(this.V).digest();
  64979. };
  64980. HmacDRBG.prototype.reseed = function reseed(entropy, entropyEnc, add, addEnc) {
  64981. // Optional entropy enc
  64982. if (typeof entropyEnc !== 'string') {
  64983. addEnc = add;
  64984. add = entropyEnc;
  64985. entropyEnc = null;
  64986. }
  64987. entropy = utils.toArray(entropy, entropyEnc);
  64988. add = utils.toArray(add, addEnc);
  64989. assert(entropy.length >= (this.minEntropy / 8),
  64990. 'Not enough entropy. Minimum is: ' + this.minEntropy + ' bits');
  64991. this._update(entropy.concat(add || []));
  64992. this._reseed = 1;
  64993. };
  64994. HmacDRBG.prototype.generate = function generate(len, enc, add, addEnc) {
  64995. if (this._reseed > this.reseedInterval)
  64996. throw new Error('Reseed is required');
  64997. // Optional encoding
  64998. if (typeof enc !== 'string') {
  64999. addEnc = add;
  65000. add = enc;
  65001. enc = null;
  65002. }
  65003. // Optional additional data
  65004. if (add) {
  65005. add = utils.toArray(add, addEnc || 'hex');
  65006. this._update(add);
  65007. }
  65008. var temp = [];
  65009. while (temp.length < len) {
  65010. this.V = this._hmac().update(this.V).digest();
  65011. temp = temp.concat(this.V);
  65012. }
  65013. var res = temp.slice(0, len);
  65014. this._update(add);
  65015. this._reseed++;
  65016. return utils.encode(res, enc);
  65017. };
  65018. },{"hash.js":776,"minimalistic-assert":791,"minimalistic-crypto-utils":792}],789:[function(_dereq_,module,exports){
  65019. if (typeof Object.create === 'function') {
  65020. // implementation from standard node.js 'util' module
  65021. module.exports = function inherits(ctor, superCtor) {
  65022. if (superCtor) {
  65023. ctor.super_ = superCtor
  65024. ctor.prototype = Object.create(superCtor.prototype, {
  65025. constructor: {
  65026. value: ctor,
  65027. enumerable: false,
  65028. writable: true,
  65029. configurable: true
  65030. }
  65031. })
  65032. }
  65033. };
  65034. } else {
  65035. // old school shim for old browsers
  65036. module.exports = function inherits(ctor, superCtor) {
  65037. if (superCtor) {
  65038. ctor.super_ = superCtor
  65039. var TempCtor = function () {}
  65040. TempCtor.prototype = superCtor.prototype
  65041. ctor.prototype = new TempCtor()
  65042. ctor.prototype.constructor = ctor
  65043. }
  65044. }
  65045. }
  65046. },{}],790:[function(_dereq_,module,exports){
  65047. (function (process,global){(function (){
  65048. /**
  65049. * [js-sha3]{@link https://github.com/emn178/js-sha3}
  65050. *
  65051. * @version 0.8.0
  65052. * @author Chen, Yi-Cyuan [emn178@gmail.com]
  65053. * @copyright Chen, Yi-Cyuan 2015-2018
  65054. * @license MIT
  65055. */
  65056. /*jslint bitwise: true */
  65057. (function () {
  65058. 'use strict';
  65059. var INPUT_ERROR = 'input is invalid type';
  65060. var FINALIZE_ERROR = 'finalize already called';
  65061. var WINDOW = typeof window === 'object';
  65062. var root = WINDOW ? window : {};
  65063. if (root.JS_SHA3_NO_WINDOW) {
  65064. WINDOW = false;
  65065. }
  65066. var WEB_WORKER = !WINDOW && typeof self === 'object';
  65067. var NODE_JS = !root.JS_SHA3_NO_NODE_JS && typeof process === 'object' && process.versions && process.versions.node;
  65068. if (NODE_JS) {
  65069. root = global;
  65070. } else if (WEB_WORKER) {
  65071. root = self;
  65072. }
  65073. var COMMON_JS = !root.JS_SHA3_NO_COMMON_JS && typeof module === 'object' && module.exports;
  65074. var AMD = typeof define === 'function' && define.amd;
  65075. var ARRAY_BUFFER = !root.JS_SHA3_NO_ARRAY_BUFFER && typeof ArrayBuffer !== 'undefined';
  65076. var HEX_CHARS = '0123456789abcdef'.split('');
  65077. var SHAKE_PADDING = [31, 7936, 2031616, 520093696];
  65078. var CSHAKE_PADDING = [4, 1024, 262144, 67108864];
  65079. var KECCAK_PADDING = [1, 256, 65536, 16777216];
  65080. var PADDING = [6, 1536, 393216, 100663296];
  65081. var SHIFT = [0, 8, 16, 24];
  65082. var RC = [1, 0, 32898, 0, 32906, 2147483648, 2147516416, 2147483648, 32907, 0, 2147483649,
  65083. 0, 2147516545, 2147483648, 32777, 2147483648, 138, 0, 136, 0, 2147516425, 0,
  65084. 2147483658, 0, 2147516555, 0, 139, 2147483648, 32905, 2147483648, 32771,
  65085. 2147483648, 32770, 2147483648, 128, 2147483648, 32778, 0, 2147483658, 2147483648,
  65086. 2147516545, 2147483648, 32896, 2147483648, 2147483649, 0, 2147516424, 2147483648];
  65087. var BITS = [224, 256, 384, 512];
  65088. var SHAKE_BITS = [128, 256];
  65089. var OUTPUT_TYPES = ['hex', 'buffer', 'arrayBuffer', 'array', 'digest'];
  65090. var CSHAKE_BYTEPAD = {
  65091. '128': 168,
  65092. '256': 136
  65093. };
  65094. if (root.JS_SHA3_NO_NODE_JS || !Array.isArray) {
  65095. Array.isArray = function (obj) {
  65096. return Object.prototype.toString.call(obj) === '[object Array]';
  65097. };
  65098. }
  65099. if (ARRAY_BUFFER && (root.JS_SHA3_NO_ARRAY_BUFFER_IS_VIEW || !ArrayBuffer.isView)) {
  65100. ArrayBuffer.isView = function (obj) {
  65101. return typeof obj === 'object' && obj.buffer && obj.buffer.constructor === ArrayBuffer;
  65102. };
  65103. }
  65104. var createOutputMethod = function (bits, padding, outputType) {
  65105. return function (message) {
  65106. return new Keccak(bits, padding, bits).update(message)[outputType]();
  65107. };
  65108. };
  65109. var createShakeOutputMethod = function (bits, padding, outputType) {
  65110. return function (message, outputBits) {
  65111. return new Keccak(bits, padding, outputBits).update(message)[outputType]();
  65112. };
  65113. };
  65114. var createCshakeOutputMethod = function (bits, padding, outputType) {
  65115. return function (message, outputBits, n, s) {
  65116. return methods['cshake' + bits].update(message, outputBits, n, s)[outputType]();
  65117. };
  65118. };
  65119. var createKmacOutputMethod = function (bits, padding, outputType) {
  65120. return function (key, message, outputBits, s) {
  65121. return methods['kmac' + bits].update(key, message, outputBits, s)[outputType]();
  65122. };
  65123. };
  65124. var createOutputMethods = function (method, createMethod, bits, padding) {
  65125. for (var i = 0; i < OUTPUT_TYPES.length; ++i) {
  65126. var type = OUTPUT_TYPES[i];
  65127. method[type] = createMethod(bits, padding, type);
  65128. }
  65129. return method;
  65130. };
  65131. var createMethod = function (bits, padding) {
  65132. var method = createOutputMethod(bits, padding, 'hex');
  65133. method.create = function () {
  65134. return new Keccak(bits, padding, bits);
  65135. };
  65136. method.update = function (message) {
  65137. return method.create().update(message);
  65138. };
  65139. return createOutputMethods(method, createOutputMethod, bits, padding);
  65140. };
  65141. var createShakeMethod = function (bits, padding) {
  65142. var method = createShakeOutputMethod(bits, padding, 'hex');
  65143. method.create = function (outputBits) {
  65144. return new Keccak(bits, padding, outputBits);
  65145. };
  65146. method.update = function (message, outputBits) {
  65147. return method.create(outputBits).update(message);
  65148. };
  65149. return createOutputMethods(method, createShakeOutputMethod, bits, padding);
  65150. };
  65151. var createCshakeMethod = function (bits, padding) {
  65152. var w = CSHAKE_BYTEPAD[bits];
  65153. var method = createCshakeOutputMethod(bits, padding, 'hex');
  65154. method.create = function (outputBits, n, s) {
  65155. if (!n && !s) {
  65156. return methods['shake' + bits].create(outputBits);
  65157. } else {
  65158. return new Keccak(bits, padding, outputBits).bytepad([n, s], w);
  65159. }
  65160. };
  65161. method.update = function (message, outputBits, n, s) {
  65162. return method.create(outputBits, n, s).update(message);
  65163. };
  65164. return createOutputMethods(method, createCshakeOutputMethod, bits, padding);
  65165. };
  65166. var createKmacMethod = function (bits, padding) {
  65167. var w = CSHAKE_BYTEPAD[bits];
  65168. var method = createKmacOutputMethod(bits, padding, 'hex');
  65169. method.create = function (key, outputBits, s) {
  65170. return new Kmac(bits, padding, outputBits).bytepad(['KMAC', s], w).bytepad([key], w);
  65171. };
  65172. method.update = function (key, message, outputBits, s) {
  65173. return method.create(key, outputBits, s).update(message);
  65174. };
  65175. return createOutputMethods(method, createKmacOutputMethod, bits, padding);
  65176. };
  65177. var algorithms = [
  65178. { name: 'keccak', padding: KECCAK_PADDING, bits: BITS, createMethod: createMethod },
  65179. { name: 'sha3', padding: PADDING, bits: BITS, createMethod: createMethod },
  65180. { name: 'shake', padding: SHAKE_PADDING, bits: SHAKE_BITS, createMethod: createShakeMethod },
  65181. { name: 'cshake', padding: CSHAKE_PADDING, bits: SHAKE_BITS, createMethod: createCshakeMethod },
  65182. { name: 'kmac', padding: CSHAKE_PADDING, bits: SHAKE_BITS, createMethod: createKmacMethod }
  65183. ];
  65184. var methods = {}, methodNames = [];
  65185. for (var i = 0; i < algorithms.length; ++i) {
  65186. var algorithm = algorithms[i];
  65187. var bits = algorithm.bits;
  65188. for (var j = 0; j < bits.length; ++j) {
  65189. var methodName = algorithm.name + '_' + bits[j];
  65190. methodNames.push(methodName);
  65191. methods[methodName] = algorithm.createMethod(bits[j], algorithm.padding);
  65192. if (algorithm.name !== 'sha3') {
  65193. var newMethodName = algorithm.name + bits[j];
  65194. methodNames.push(newMethodName);
  65195. methods[newMethodName] = methods[methodName];
  65196. }
  65197. }
  65198. }
  65199. function Keccak(bits, padding, outputBits) {
  65200. this.blocks = [];
  65201. this.s = [];
  65202. this.padding = padding;
  65203. this.outputBits = outputBits;
  65204. this.reset = true;
  65205. this.finalized = false;
  65206. this.block = 0;
  65207. this.start = 0;
  65208. this.blockCount = (1600 - (bits << 1)) >> 5;
  65209. this.byteCount = this.blockCount << 2;
  65210. this.outputBlocks = outputBits >> 5;
  65211. this.extraBytes = (outputBits & 31) >> 3;
  65212. for (var i = 0; i < 50; ++i) {
  65213. this.s[i] = 0;
  65214. }
  65215. }
  65216. Keccak.prototype.update = function (message) {
  65217. if (this.finalized) {
  65218. throw new Error(FINALIZE_ERROR);
  65219. }
  65220. var notString, type = typeof message;
  65221. if (type !== 'string') {
  65222. if (type === 'object') {
  65223. if (message === null) {
  65224. throw new Error(INPUT_ERROR);
  65225. } else if (ARRAY_BUFFER && message.constructor === ArrayBuffer) {
  65226. message = new Uint8Array(message);
  65227. } else if (!Array.isArray(message)) {
  65228. if (!ARRAY_BUFFER || !ArrayBuffer.isView(message)) {
  65229. throw new Error(INPUT_ERROR);
  65230. }
  65231. }
  65232. } else {
  65233. throw new Error(INPUT_ERROR);
  65234. }
  65235. notString = true;
  65236. }
  65237. var blocks = this.blocks, byteCount = this.byteCount, length = message.length,
  65238. blockCount = this.blockCount, index = 0, s = this.s, i, code;
  65239. while (index < length) {
  65240. if (this.reset) {
  65241. this.reset = false;
  65242. blocks[0] = this.block;
  65243. for (i = 1; i < blockCount + 1; ++i) {
  65244. blocks[i] = 0;
  65245. }
  65246. }
  65247. if (notString) {
  65248. for (i = this.start; index < length && i < byteCount; ++index) {
  65249. blocks[i >> 2] |= message[index] << SHIFT[i++ & 3];
  65250. }
  65251. } else {
  65252. for (i = this.start; index < length && i < byteCount; ++index) {
  65253. code = message.charCodeAt(index);
  65254. if (code < 0x80) {
  65255. blocks[i >> 2] |= code << SHIFT[i++ & 3];
  65256. } else if (code < 0x800) {
  65257. blocks[i >> 2] |= (0xc0 | (code >> 6)) << SHIFT[i++ & 3];
  65258. blocks[i >> 2] |= (0x80 | (code & 0x3f)) << SHIFT[i++ & 3];
  65259. } else if (code < 0xd800 || code >= 0xe000) {
  65260. blocks[i >> 2] |= (0xe0 | (code >> 12)) << SHIFT[i++ & 3];
  65261. blocks[i >> 2] |= (0x80 | ((code >> 6) & 0x3f)) << SHIFT[i++ & 3];
  65262. blocks[i >> 2] |= (0x80 | (code & 0x3f)) << SHIFT[i++ & 3];
  65263. } else {
  65264. code = 0x10000 + (((code & 0x3ff) << 10) | (message.charCodeAt(++index) & 0x3ff));
  65265. blocks[i >> 2] |= (0xf0 | (code >> 18)) << SHIFT[i++ & 3];
  65266. blocks[i >> 2] |= (0x80 | ((code >> 12) & 0x3f)) << SHIFT[i++ & 3];
  65267. blocks[i >> 2] |= (0x80 | ((code >> 6) & 0x3f)) << SHIFT[i++ & 3];
  65268. blocks[i >> 2] |= (0x80 | (code & 0x3f)) << SHIFT[i++ & 3];
  65269. }
  65270. }
  65271. }
  65272. this.lastByteIndex = i;
  65273. if (i >= byteCount) {
  65274. this.start = i - byteCount;
  65275. this.block = blocks[blockCount];
  65276. for (i = 0; i < blockCount; ++i) {
  65277. s[i] ^= blocks[i];
  65278. }
  65279. f(s);
  65280. this.reset = true;
  65281. } else {
  65282. this.start = i;
  65283. }
  65284. }
  65285. return this;
  65286. };
  65287. Keccak.prototype.encode = function (x, right) {
  65288. var o = x & 255, n = 1;
  65289. var bytes = [o];
  65290. x = x >> 8;
  65291. o = x & 255;
  65292. while (o > 0) {
  65293. bytes.unshift(o);
  65294. x = x >> 8;
  65295. o = x & 255;
  65296. ++n;
  65297. }
  65298. if (right) {
  65299. bytes.push(n);
  65300. } else {
  65301. bytes.unshift(n);
  65302. }
  65303. this.update(bytes);
  65304. return bytes.length;
  65305. };
  65306. Keccak.prototype.encodeString = function (str) {
  65307. var notString, type = typeof str;
  65308. if (type !== 'string') {
  65309. if (type === 'object') {
  65310. if (str === null) {
  65311. throw new Error(INPUT_ERROR);
  65312. } else if (ARRAY_BUFFER && str.constructor === ArrayBuffer) {
  65313. str = new Uint8Array(str);
  65314. } else if (!Array.isArray(str)) {
  65315. if (!ARRAY_BUFFER || !ArrayBuffer.isView(str)) {
  65316. throw new Error(INPUT_ERROR);
  65317. }
  65318. }
  65319. } else {
  65320. throw new Error(INPUT_ERROR);
  65321. }
  65322. notString = true;
  65323. }
  65324. var bytes = 0, length = str.length;
  65325. if (notString) {
  65326. bytes = length;
  65327. } else {
  65328. for (var i = 0; i < str.length; ++i) {
  65329. var code = str.charCodeAt(i);
  65330. if (code < 0x80) {
  65331. bytes += 1;
  65332. } else if (code < 0x800) {
  65333. bytes += 2;
  65334. } else if (code < 0xd800 || code >= 0xe000) {
  65335. bytes += 3;
  65336. } else {
  65337. code = 0x10000 + (((code & 0x3ff) << 10) | (str.charCodeAt(++i) & 0x3ff));
  65338. bytes += 4;
  65339. }
  65340. }
  65341. }
  65342. bytes += this.encode(bytes * 8);
  65343. this.update(str);
  65344. return bytes;
  65345. };
  65346. Keccak.prototype.bytepad = function (strs, w) {
  65347. var bytes = this.encode(w);
  65348. for (var i = 0; i < strs.length; ++i) {
  65349. bytes += this.encodeString(strs[i]);
  65350. }
  65351. var paddingBytes = w - bytes % w;
  65352. var zeros = [];
  65353. zeros.length = paddingBytes;
  65354. this.update(zeros);
  65355. return this;
  65356. };
  65357. Keccak.prototype.finalize = function () {
  65358. if (this.finalized) {
  65359. return;
  65360. }
  65361. this.finalized = true;
  65362. var blocks = this.blocks, i = this.lastByteIndex, blockCount = this.blockCount, s = this.s;
  65363. blocks[i >> 2] |= this.padding[i & 3];
  65364. if (this.lastByteIndex === this.byteCount) {
  65365. blocks[0] = blocks[blockCount];
  65366. for (i = 1; i < blockCount + 1; ++i) {
  65367. blocks[i] = 0;
  65368. }
  65369. }
  65370. blocks[blockCount - 1] |= 0x80000000;
  65371. for (i = 0; i < blockCount; ++i) {
  65372. s[i] ^= blocks[i];
  65373. }
  65374. f(s);
  65375. };
  65376. Keccak.prototype.toString = Keccak.prototype.hex = function () {
  65377. this.finalize();
  65378. var blockCount = this.blockCount, s = this.s, outputBlocks = this.outputBlocks,
  65379. extraBytes = this.extraBytes, i = 0, j = 0;
  65380. var hex = '', block;
  65381. while (j < outputBlocks) {
  65382. for (i = 0; i < blockCount && j < outputBlocks; ++i, ++j) {
  65383. block = s[i];
  65384. hex += HEX_CHARS[(block >> 4) & 0x0F] + HEX_CHARS[block & 0x0F] +
  65385. HEX_CHARS[(block >> 12) & 0x0F] + HEX_CHARS[(block >> 8) & 0x0F] +
  65386. HEX_CHARS[(block >> 20) & 0x0F] + HEX_CHARS[(block >> 16) & 0x0F] +
  65387. HEX_CHARS[(block >> 28) & 0x0F] + HEX_CHARS[(block >> 24) & 0x0F];
  65388. }
  65389. if (j % blockCount === 0) {
  65390. f(s);
  65391. i = 0;
  65392. }
  65393. }
  65394. if (extraBytes) {
  65395. block = s[i];
  65396. hex += HEX_CHARS[(block >> 4) & 0x0F] + HEX_CHARS[block & 0x0F];
  65397. if (extraBytes > 1) {
  65398. hex += HEX_CHARS[(block >> 12) & 0x0F] + HEX_CHARS[(block >> 8) & 0x0F];
  65399. }
  65400. if (extraBytes > 2) {
  65401. hex += HEX_CHARS[(block >> 20) & 0x0F] + HEX_CHARS[(block >> 16) & 0x0F];
  65402. }
  65403. }
  65404. return hex;
  65405. };
  65406. Keccak.prototype.arrayBuffer = function () {
  65407. this.finalize();
  65408. var blockCount = this.blockCount, s = this.s, outputBlocks = this.outputBlocks,
  65409. extraBytes = this.extraBytes, i = 0, j = 0;
  65410. var bytes = this.outputBits >> 3;
  65411. var buffer;
  65412. if (extraBytes) {
  65413. buffer = new ArrayBuffer((outputBlocks + 1) << 2);
  65414. } else {
  65415. buffer = new ArrayBuffer(bytes);
  65416. }
  65417. var array = new Uint32Array(buffer);
  65418. while (j < outputBlocks) {
  65419. for (i = 0; i < blockCount && j < outputBlocks; ++i, ++j) {
  65420. array[j] = s[i];
  65421. }
  65422. if (j % blockCount === 0) {
  65423. f(s);
  65424. }
  65425. }
  65426. if (extraBytes) {
  65427. array[i] = s[i];
  65428. buffer = buffer.slice(0, bytes);
  65429. }
  65430. return buffer;
  65431. };
  65432. Keccak.prototype.buffer = Keccak.prototype.arrayBuffer;
  65433. Keccak.prototype.digest = Keccak.prototype.array = function () {
  65434. this.finalize();
  65435. var blockCount = this.blockCount, s = this.s, outputBlocks = this.outputBlocks,
  65436. extraBytes = this.extraBytes, i = 0, j = 0;
  65437. var array = [], offset, block;
  65438. while (j < outputBlocks) {
  65439. for (i = 0; i < blockCount && j < outputBlocks; ++i, ++j) {
  65440. offset = j << 2;
  65441. block = s[i];
  65442. array[offset] = block & 0xFF;
  65443. array[offset + 1] = (block >> 8) & 0xFF;
  65444. array[offset + 2] = (block >> 16) & 0xFF;
  65445. array[offset + 3] = (block >> 24) & 0xFF;
  65446. }
  65447. if (j % blockCount === 0) {
  65448. f(s);
  65449. }
  65450. }
  65451. if (extraBytes) {
  65452. offset = j << 2;
  65453. block = s[i];
  65454. array[offset] = block & 0xFF;
  65455. if (extraBytes > 1) {
  65456. array[offset + 1] = (block >> 8) & 0xFF;
  65457. }
  65458. if (extraBytes > 2) {
  65459. array[offset + 2] = (block >> 16) & 0xFF;
  65460. }
  65461. }
  65462. return array;
  65463. };
  65464. function Kmac(bits, padding, outputBits) {
  65465. Keccak.call(this, bits, padding, outputBits);
  65466. }
  65467. Kmac.prototype = new Keccak();
  65468. Kmac.prototype.finalize = function () {
  65469. this.encode(this.outputBits, true);
  65470. return Keccak.prototype.finalize.call(this);
  65471. };
  65472. var f = function (s) {
  65473. var h, l, n, c0, c1, c2, c3, c4, c5, c6, c7, c8, c9,
  65474. b0, b1, b2, b3, b4, b5, b6, b7, b8, b9, b10, b11, b12, b13, b14, b15, b16, b17,
  65475. b18, b19, b20, b21, b22, b23, b24, b25, b26, b27, b28, b29, b30, b31, b32, b33,
  65476. b34, b35, b36, b37, b38, b39, b40, b41, b42, b43, b44, b45, b46, b47, b48, b49;
  65477. for (n = 0; n < 48; n += 2) {
  65478. c0 = s[0] ^ s[10] ^ s[20] ^ s[30] ^ s[40];
  65479. c1 = s[1] ^ s[11] ^ s[21] ^ s[31] ^ s[41];
  65480. c2 = s[2] ^ s[12] ^ s[22] ^ s[32] ^ s[42];
  65481. c3 = s[3] ^ s[13] ^ s[23] ^ s[33] ^ s[43];
  65482. c4 = s[4] ^ s[14] ^ s[24] ^ s[34] ^ s[44];
  65483. c5 = s[5] ^ s[15] ^ s[25] ^ s[35] ^ s[45];
  65484. c6 = s[6] ^ s[16] ^ s[26] ^ s[36] ^ s[46];
  65485. c7 = s[7] ^ s[17] ^ s[27] ^ s[37] ^ s[47];
  65486. c8 = s[8] ^ s[18] ^ s[28] ^ s[38] ^ s[48];
  65487. c9 = s[9] ^ s[19] ^ s[29] ^ s[39] ^ s[49];
  65488. h = c8 ^ ((c2 << 1) | (c3 >>> 31));
  65489. l = c9 ^ ((c3 << 1) | (c2 >>> 31));
  65490. s[0] ^= h;
  65491. s[1] ^= l;
  65492. s[10] ^= h;
  65493. s[11] ^= l;
  65494. s[20] ^= h;
  65495. s[21] ^= l;
  65496. s[30] ^= h;
  65497. s[31] ^= l;
  65498. s[40] ^= h;
  65499. s[41] ^= l;
  65500. h = c0 ^ ((c4 << 1) | (c5 >>> 31));
  65501. l = c1 ^ ((c5 << 1) | (c4 >>> 31));
  65502. s[2] ^= h;
  65503. s[3] ^= l;
  65504. s[12] ^= h;
  65505. s[13] ^= l;
  65506. s[22] ^= h;
  65507. s[23] ^= l;
  65508. s[32] ^= h;
  65509. s[33] ^= l;
  65510. s[42] ^= h;
  65511. s[43] ^= l;
  65512. h = c2 ^ ((c6 << 1) | (c7 >>> 31));
  65513. l = c3 ^ ((c7 << 1) | (c6 >>> 31));
  65514. s[4] ^= h;
  65515. s[5] ^= l;
  65516. s[14] ^= h;
  65517. s[15] ^= l;
  65518. s[24] ^= h;
  65519. s[25] ^= l;
  65520. s[34] ^= h;
  65521. s[35] ^= l;
  65522. s[44] ^= h;
  65523. s[45] ^= l;
  65524. h = c4 ^ ((c8 << 1) | (c9 >>> 31));
  65525. l = c5 ^ ((c9 << 1) | (c8 >>> 31));
  65526. s[6] ^= h;
  65527. s[7] ^= l;
  65528. s[16] ^= h;
  65529. s[17] ^= l;
  65530. s[26] ^= h;
  65531. s[27] ^= l;
  65532. s[36] ^= h;
  65533. s[37] ^= l;
  65534. s[46] ^= h;
  65535. s[47] ^= l;
  65536. h = c6 ^ ((c0 << 1) | (c1 >>> 31));
  65537. l = c7 ^ ((c1 << 1) | (c0 >>> 31));
  65538. s[8] ^= h;
  65539. s[9] ^= l;
  65540. s[18] ^= h;
  65541. s[19] ^= l;
  65542. s[28] ^= h;
  65543. s[29] ^= l;
  65544. s[38] ^= h;
  65545. s[39] ^= l;
  65546. s[48] ^= h;
  65547. s[49] ^= l;
  65548. b0 = s[0];
  65549. b1 = s[1];
  65550. b32 = (s[11] << 4) | (s[10] >>> 28);
  65551. b33 = (s[10] << 4) | (s[11] >>> 28);
  65552. b14 = (s[20] << 3) | (s[21] >>> 29);
  65553. b15 = (s[21] << 3) | (s[20] >>> 29);
  65554. b46 = (s[31] << 9) | (s[30] >>> 23);
  65555. b47 = (s[30] << 9) | (s[31] >>> 23);
  65556. b28 = (s[40] << 18) | (s[41] >>> 14);
  65557. b29 = (s[41] << 18) | (s[40] >>> 14);
  65558. b20 = (s[2] << 1) | (s[3] >>> 31);
  65559. b21 = (s[3] << 1) | (s[2] >>> 31);
  65560. b2 = (s[13] << 12) | (s[12] >>> 20);
  65561. b3 = (s[12] << 12) | (s[13] >>> 20);
  65562. b34 = (s[22] << 10) | (s[23] >>> 22);
  65563. b35 = (s[23] << 10) | (s[22] >>> 22);
  65564. b16 = (s[33] << 13) | (s[32] >>> 19);
  65565. b17 = (s[32] << 13) | (s[33] >>> 19);
  65566. b48 = (s[42] << 2) | (s[43] >>> 30);
  65567. b49 = (s[43] << 2) | (s[42] >>> 30);
  65568. b40 = (s[5] << 30) | (s[4] >>> 2);
  65569. b41 = (s[4] << 30) | (s[5] >>> 2);
  65570. b22 = (s[14] << 6) | (s[15] >>> 26);
  65571. b23 = (s[15] << 6) | (s[14] >>> 26);
  65572. b4 = (s[25] << 11) | (s[24] >>> 21);
  65573. b5 = (s[24] << 11) | (s[25] >>> 21);
  65574. b36 = (s[34] << 15) | (s[35] >>> 17);
  65575. b37 = (s[35] << 15) | (s[34] >>> 17);
  65576. b18 = (s[45] << 29) | (s[44] >>> 3);
  65577. b19 = (s[44] << 29) | (s[45] >>> 3);
  65578. b10 = (s[6] << 28) | (s[7] >>> 4);
  65579. b11 = (s[7] << 28) | (s[6] >>> 4);
  65580. b42 = (s[17] << 23) | (s[16] >>> 9);
  65581. b43 = (s[16] << 23) | (s[17] >>> 9);
  65582. b24 = (s[26] << 25) | (s[27] >>> 7);
  65583. b25 = (s[27] << 25) | (s[26] >>> 7);
  65584. b6 = (s[36] << 21) | (s[37] >>> 11);
  65585. b7 = (s[37] << 21) | (s[36] >>> 11);
  65586. b38 = (s[47] << 24) | (s[46] >>> 8);
  65587. b39 = (s[46] << 24) | (s[47] >>> 8);
  65588. b30 = (s[8] << 27) | (s[9] >>> 5);
  65589. b31 = (s[9] << 27) | (s[8] >>> 5);
  65590. b12 = (s[18] << 20) | (s[19] >>> 12);
  65591. b13 = (s[19] << 20) | (s[18] >>> 12);
  65592. b44 = (s[29] << 7) | (s[28] >>> 25);
  65593. b45 = (s[28] << 7) | (s[29] >>> 25);
  65594. b26 = (s[38] << 8) | (s[39] >>> 24);
  65595. b27 = (s[39] << 8) | (s[38] >>> 24);
  65596. b8 = (s[48] << 14) | (s[49] >>> 18);
  65597. b9 = (s[49] << 14) | (s[48] >>> 18);
  65598. s[0] = b0 ^ (~b2 & b4);
  65599. s[1] = b1 ^ (~b3 & b5);
  65600. s[10] = b10 ^ (~b12 & b14);
  65601. s[11] = b11 ^ (~b13 & b15);
  65602. s[20] = b20 ^ (~b22 & b24);
  65603. s[21] = b21 ^ (~b23 & b25);
  65604. s[30] = b30 ^ (~b32 & b34);
  65605. s[31] = b31 ^ (~b33 & b35);
  65606. s[40] = b40 ^ (~b42 & b44);
  65607. s[41] = b41 ^ (~b43 & b45);
  65608. s[2] = b2 ^ (~b4 & b6);
  65609. s[3] = b3 ^ (~b5 & b7);
  65610. s[12] = b12 ^ (~b14 & b16);
  65611. s[13] = b13 ^ (~b15 & b17);
  65612. s[22] = b22 ^ (~b24 & b26);
  65613. s[23] = b23 ^ (~b25 & b27);
  65614. s[32] = b32 ^ (~b34 & b36);
  65615. s[33] = b33 ^ (~b35 & b37);
  65616. s[42] = b42 ^ (~b44 & b46);
  65617. s[43] = b43 ^ (~b45 & b47);
  65618. s[4] = b4 ^ (~b6 & b8);
  65619. s[5] = b5 ^ (~b7 & b9);
  65620. s[14] = b14 ^ (~b16 & b18);
  65621. s[15] = b15 ^ (~b17 & b19);
  65622. s[24] = b24 ^ (~b26 & b28);
  65623. s[25] = b25 ^ (~b27 & b29);
  65624. s[34] = b34 ^ (~b36 & b38);
  65625. s[35] = b35 ^ (~b37 & b39);
  65626. s[44] = b44 ^ (~b46 & b48);
  65627. s[45] = b45 ^ (~b47 & b49);
  65628. s[6] = b6 ^ (~b8 & b0);
  65629. s[7] = b7 ^ (~b9 & b1);
  65630. s[16] = b16 ^ (~b18 & b10);
  65631. s[17] = b17 ^ (~b19 & b11);
  65632. s[26] = b26 ^ (~b28 & b20);
  65633. s[27] = b27 ^ (~b29 & b21);
  65634. s[36] = b36 ^ (~b38 & b30);
  65635. s[37] = b37 ^ (~b39 & b31);
  65636. s[46] = b46 ^ (~b48 & b40);
  65637. s[47] = b47 ^ (~b49 & b41);
  65638. s[8] = b8 ^ (~b0 & b2);
  65639. s[9] = b9 ^ (~b1 & b3);
  65640. s[18] = b18 ^ (~b10 & b12);
  65641. s[19] = b19 ^ (~b11 & b13);
  65642. s[28] = b28 ^ (~b20 & b22);
  65643. s[29] = b29 ^ (~b21 & b23);
  65644. s[38] = b38 ^ (~b30 & b32);
  65645. s[39] = b39 ^ (~b31 & b33);
  65646. s[48] = b48 ^ (~b40 & b42);
  65647. s[49] = b49 ^ (~b41 & b43);
  65648. s[0] ^= RC[n];
  65649. s[1] ^= RC[n + 1];
  65650. }
  65651. };
  65652. if (COMMON_JS) {
  65653. module.exports = methods;
  65654. } else {
  65655. for (i = 0; i < methodNames.length; ++i) {
  65656. root[methodNames[i]] = methods[methodNames[i]];
  65657. }
  65658. if (AMD) {
  65659. define(function () {
  65660. return methods;
  65661. });
  65662. }
  65663. }
  65664. })();
  65665. }).call(this)}).call(this,_dereq_('_process'),typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {})
  65666. },{"_process":323}],791:[function(_dereq_,module,exports){
  65667. module.exports = assert;
  65668. function assert(val, msg) {
  65669. if (!val)
  65670. throw new Error(msg || 'Assertion failed');
  65671. }
  65672. assert.equal = function assertEqual(l, r, msg) {
  65673. if (l != r)
  65674. throw new Error(msg || ('Assertion failed: ' + l + ' != ' + r));
  65675. };
  65676. },{}],792:[function(_dereq_,module,exports){
  65677. 'use strict';
  65678. var utils = exports;
  65679. function toArray(msg, enc) {
  65680. if (Array.isArray(msg))
  65681. return msg.slice();
  65682. if (!msg)
  65683. return [];
  65684. var res = [];
  65685. if (typeof msg !== 'string') {
  65686. for (var i = 0; i < msg.length; i++)
  65687. res[i] = msg[i] | 0;
  65688. return res;
  65689. }
  65690. if (enc === 'hex') {
  65691. msg = msg.replace(/[^a-z0-9]+/ig, '');
  65692. if (msg.length % 2 !== 0)
  65693. msg = '0' + msg;
  65694. for (var i = 0; i < msg.length; i += 2)
  65695. res.push(parseInt(msg[i] + msg[i + 1], 16));
  65696. } else {
  65697. for (var i = 0; i < msg.length; i++) {
  65698. var c = msg.charCodeAt(i);
  65699. var hi = c >> 8;
  65700. var lo = c & 0xff;
  65701. if (hi)
  65702. res.push(hi, lo);
  65703. else
  65704. res.push(lo);
  65705. }
  65706. }
  65707. return res;
  65708. }
  65709. utils.toArray = toArray;
  65710. function zero2(word) {
  65711. if (word.length === 1)
  65712. return '0' + word;
  65713. else
  65714. return word;
  65715. }
  65716. utils.zero2 = zero2;
  65717. function toHex(msg) {
  65718. var res = '';
  65719. for (var i = 0; i < msg.length; i++)
  65720. res += zero2(msg[i].toString(16));
  65721. return res;
  65722. }
  65723. utils.toHex = toHex;
  65724. utils.encode = function encode(arr, enc) {
  65725. if (enc === 'hex')
  65726. return toHex(arr);
  65727. else
  65728. return arr;
  65729. };
  65730. },{}],793:[function(_dereq_,module,exports){
  65731. // shim for using process in browser
  65732. var process = module.exports = {};
  65733. // cached from whatever global is present so that test runners that stub it
  65734. // don't break things. But we need to wrap it in a try catch in case it is
  65735. // wrapped in strict mode code which doesn't define any globals. It's inside a
  65736. // function because try/catches deoptimize in certain engines.
  65737. var cachedSetTimeout;
  65738. var cachedClearTimeout;
  65739. function defaultSetTimout() {
  65740. throw new Error('setTimeout has not been defined');
  65741. }
  65742. function defaultClearTimeout () {
  65743. throw new Error('clearTimeout has not been defined');
  65744. }
  65745. (function () {
  65746. try {
  65747. if (typeof setTimeout === 'function') {
  65748. cachedSetTimeout = setTimeout;
  65749. } else {
  65750. cachedSetTimeout = defaultSetTimout;
  65751. }
  65752. } catch (e) {
  65753. cachedSetTimeout = defaultSetTimout;
  65754. }
  65755. try {
  65756. if (typeof clearTimeout === 'function') {
  65757. cachedClearTimeout = clearTimeout;
  65758. } else {
  65759. cachedClearTimeout = defaultClearTimeout;
  65760. }
  65761. } catch (e) {
  65762. cachedClearTimeout = defaultClearTimeout;
  65763. }
  65764. } ())
  65765. function runTimeout(fun) {
  65766. if (cachedSetTimeout === setTimeout) {
  65767. //normal enviroments in sane situations
  65768. return setTimeout(fun, 0);
  65769. }
  65770. // if setTimeout wasn't available but was latter defined
  65771. if ((cachedSetTimeout === defaultSetTimout || !cachedSetTimeout) && setTimeout) {
  65772. cachedSetTimeout = setTimeout;
  65773. return setTimeout(fun, 0);
  65774. }
  65775. try {
  65776. // when when somebody has screwed with setTimeout but no I.E. maddness
  65777. return cachedSetTimeout(fun, 0);
  65778. } catch(e){
  65779. try {
  65780. // When we are in I.E. but the script has been evaled so I.E. doesn't trust the global object when called normally
  65781. return cachedSetTimeout.call(null, fun, 0);
  65782. } catch(e){
  65783. // same as above but when it's a version of I.E. that must have the global object for 'this', hopfully our context correct otherwise it will throw a global error
  65784. return cachedSetTimeout.call(this, fun, 0);
  65785. }
  65786. }
  65787. }
  65788. function runClearTimeout(marker) {
  65789. if (cachedClearTimeout === clearTimeout) {
  65790. //normal enviroments in sane situations
  65791. return clearTimeout(marker);
  65792. }
  65793. // if clearTimeout wasn't available but was latter defined
  65794. if ((cachedClearTimeout === defaultClearTimeout || !cachedClearTimeout) && clearTimeout) {
  65795. cachedClearTimeout = clearTimeout;
  65796. return clearTimeout(marker);
  65797. }
  65798. try {
  65799. // when when somebody has screwed with setTimeout but no I.E. maddness
  65800. return cachedClearTimeout(marker);
  65801. } catch (e){
  65802. try {
  65803. // When we are in I.E. but the script has been evaled so I.E. doesn't trust the global object when called normally
  65804. return cachedClearTimeout.call(null, marker);
  65805. } catch (e){
  65806. // same as above but when it's a version of I.E. that must have the global object for 'this', hopfully our context correct otherwise it will throw a global error.
  65807. // Some versions of I.E. have different rules for clearTimeout vs setTimeout
  65808. return cachedClearTimeout.call(this, marker);
  65809. }
  65810. }
  65811. }
  65812. var queue = [];
  65813. var draining = false;
  65814. var currentQueue;
  65815. var queueIndex = -1;
  65816. function cleanUpNextTick() {
  65817. if (!draining || !currentQueue) {
  65818. return;
  65819. }
  65820. draining = false;
  65821. if (currentQueue.length) {
  65822. queue = currentQueue.concat(queue);
  65823. } else {
  65824. queueIndex = -1;
  65825. }
  65826. if (queue.length) {
  65827. drainQueue();
  65828. }
  65829. }
  65830. function drainQueue() {
  65831. if (draining) {
  65832. return;
  65833. }
  65834. var timeout = runTimeout(cleanUpNextTick);
  65835. draining = true;
  65836. var len = queue.length;
  65837. while(len) {
  65838. currentQueue = queue;
  65839. queue = [];
  65840. while (++queueIndex < len) {
  65841. if (currentQueue) {
  65842. currentQueue[queueIndex].run();
  65843. }
  65844. }
  65845. queueIndex = -1;
  65846. len = queue.length;
  65847. }
  65848. currentQueue = null;
  65849. draining = false;
  65850. runClearTimeout(timeout);
  65851. }
  65852. process.nextTick = function (fun) {
  65853. var args = new Array(arguments.length - 1);
  65854. if (arguments.length > 1) {
  65855. for (var i = 1; i < arguments.length; i++) {
  65856. args[i - 1] = arguments[i];
  65857. }
  65858. }
  65859. queue.push(new Item(fun, args));
  65860. if (queue.length === 1 && !draining) {
  65861. runTimeout(drainQueue);
  65862. }
  65863. };
  65864. // v8 likes predictible objects
  65865. function Item(fun, array) {
  65866. this.fun = fun;
  65867. this.array = array;
  65868. }
  65869. Item.prototype.run = function () {
  65870. this.fun.apply(null, this.array);
  65871. };
  65872. process.title = 'browser';
  65873. process.browser = true;
  65874. process.env = {};
  65875. process.argv = [];
  65876. process.version = ''; // empty string to avoid regexp issues
  65877. process.versions = {};
  65878. function noop() {}
  65879. process.on = noop;
  65880. process.addListener = noop;
  65881. process.once = noop;
  65882. process.off = noop;
  65883. process.removeListener = noop;
  65884. process.removeAllListeners = noop;
  65885. process.emit = noop;
  65886. process.prependListener = noop;
  65887. process.prependOnceListener = noop;
  65888. process.listeners = function (name) { return [] }
  65889. process.binding = function (name) {
  65890. throw new Error('process.binding is not supported');
  65891. };
  65892. process.cwd = function () { return '/' };
  65893. process.chdir = function (dir) {
  65894. throw new Error('process.chdir is not supported');
  65895. };
  65896. process.umask = function() { return 0; };
  65897. },{}],794:[function(_dereq_,module,exports){
  65898. /**
  65899. * Copyright (c) 2014-present, Facebook, Inc.
  65900. *
  65901. * This source code is licensed under the MIT license found in the
  65902. * LICENSE file in the root directory of this source tree.
  65903. */
  65904. var runtime = (function (exports) {
  65905. "use strict";
  65906. var Op = Object.prototype;
  65907. var hasOwn = Op.hasOwnProperty;
  65908. var undefined; // More compressible than void 0.
  65909. var $Symbol = typeof Symbol === "function" ? Symbol : {};
  65910. var iteratorSymbol = $Symbol.iterator || "@@iterator";
  65911. var asyncIteratorSymbol = $Symbol.asyncIterator || "@@asyncIterator";
  65912. var toStringTagSymbol = $Symbol.toStringTag || "@@toStringTag";
  65913. function define(obj, key, value) {
  65914. Object.defineProperty(obj, key, {
  65915. value: value,
  65916. enumerable: true,
  65917. configurable: true,
  65918. writable: true
  65919. });
  65920. return obj[key];
  65921. }
  65922. try {
  65923. // IE 8 has a broken Object.defineProperty that only works on DOM objects.
  65924. define({}, "");
  65925. } catch (err) {
  65926. define = function(obj, key, value) {
  65927. return obj[key] = value;
  65928. };
  65929. }
  65930. function wrap(innerFn, outerFn, self, tryLocsList) {
  65931. // If outerFn provided and outerFn.prototype is a Generator, then outerFn.prototype instanceof Generator.
  65932. var protoGenerator = outerFn && outerFn.prototype instanceof Generator ? outerFn : Generator;
  65933. var generator = Object.create(protoGenerator.prototype);
  65934. var context = new Context(tryLocsList || []);
  65935. // The ._invoke method unifies the implementations of the .next,
  65936. // .throw, and .return methods.
  65937. generator._invoke = makeInvokeMethod(innerFn, self, context);
  65938. return generator;
  65939. }
  65940. exports.wrap = wrap;
  65941. // Try/catch helper to minimize deoptimizations. Returns a completion
  65942. // record like context.tryEntries[i].completion. This interface could
  65943. // have been (and was previously) designed to take a closure to be
  65944. // invoked without arguments, but in all the cases we care about we
  65945. // already have an existing method we want to call, so there's no need
  65946. // to create a new function object. We can even get away with assuming
  65947. // the method takes exactly one argument, since that happens to be true
  65948. // in every case, so we don't have to touch the arguments object. The
  65949. // only additional allocation required is the completion record, which
  65950. // has a stable shape and so hopefully should be cheap to allocate.
  65951. function tryCatch(fn, obj, arg) {
  65952. try {
  65953. return { type: "normal", arg: fn.call(obj, arg) };
  65954. } catch (err) {
  65955. return { type: "throw", arg: err };
  65956. }
  65957. }
  65958. var GenStateSuspendedStart = "suspendedStart";
  65959. var GenStateSuspendedYield = "suspendedYield";
  65960. var GenStateExecuting = "executing";
  65961. var GenStateCompleted = "completed";
  65962. // Returning this object from the innerFn has the same effect as
  65963. // breaking out of the dispatch switch statement.
  65964. var ContinueSentinel = {};
  65965. // Dummy constructor functions that we use as the .constructor and
  65966. // .constructor.prototype properties for functions that return Generator
  65967. // objects. For full spec compliance, you may wish to configure your
  65968. // minifier not to mangle the names of these two functions.
  65969. function Generator() {}
  65970. function GeneratorFunction() {}
  65971. function GeneratorFunctionPrototype() {}
  65972. // This is a polyfill for %IteratorPrototype% for environments that
  65973. // don't natively support it.
  65974. var IteratorPrototype = {};
  65975. define(IteratorPrototype, iteratorSymbol, function () {
  65976. return this;
  65977. });
  65978. var getProto = Object.getPrototypeOf;
  65979. var NativeIteratorPrototype = getProto && getProto(getProto(values([])));
  65980. if (NativeIteratorPrototype &&
  65981. NativeIteratorPrototype !== Op &&
  65982. hasOwn.call(NativeIteratorPrototype, iteratorSymbol)) {
  65983. // This environment has a native %IteratorPrototype%; use it instead
  65984. // of the polyfill.
  65985. IteratorPrototype = NativeIteratorPrototype;
  65986. }
  65987. var Gp = GeneratorFunctionPrototype.prototype =
  65988. Generator.prototype = Object.create(IteratorPrototype);
  65989. GeneratorFunction.prototype = GeneratorFunctionPrototype;
  65990. define(Gp, "constructor", GeneratorFunctionPrototype);
  65991. define(GeneratorFunctionPrototype, "constructor", GeneratorFunction);
  65992. GeneratorFunction.displayName = define(
  65993. GeneratorFunctionPrototype,
  65994. toStringTagSymbol,
  65995. "GeneratorFunction"
  65996. );
  65997. // Helper for defining the .next, .throw, and .return methods of the
  65998. // Iterator interface in terms of a single ._invoke method.
  65999. function defineIteratorMethods(prototype) {
  66000. ["next", "throw", "return"].forEach(function(method) {
  66001. define(prototype, method, function(arg) {
  66002. return this._invoke(method, arg);
  66003. });
  66004. });
  66005. }
  66006. exports.isGeneratorFunction = function(genFun) {
  66007. var ctor = typeof genFun === "function" && genFun.constructor;
  66008. return ctor
  66009. ? ctor === GeneratorFunction ||
  66010. // For the native GeneratorFunction constructor, the best we can
  66011. // do is to check its .name property.
  66012. (ctor.displayName || ctor.name) === "GeneratorFunction"
  66013. : false;
  66014. };
  66015. exports.mark = function(genFun) {
  66016. if (Object.setPrototypeOf) {
  66017. Object.setPrototypeOf(genFun, GeneratorFunctionPrototype);
  66018. } else {
  66019. genFun.__proto__ = GeneratorFunctionPrototype;
  66020. define(genFun, toStringTagSymbol, "GeneratorFunction");
  66021. }
  66022. genFun.prototype = Object.create(Gp);
  66023. return genFun;
  66024. };
  66025. // Within the body of any async function, `await x` is transformed to
  66026. // `yield regeneratorRuntime.awrap(x)`, so that the runtime can test
  66027. // `hasOwn.call(value, "__await")` to determine if the yielded value is
  66028. // meant to be awaited.
  66029. exports.awrap = function(arg) {
  66030. return { __await: arg };
  66031. };
  66032. function AsyncIterator(generator, PromiseImpl) {
  66033. function invoke(method, arg, resolve, reject) {
  66034. var record = tryCatch(generator[method], generator, arg);
  66035. if (record.type === "throw") {
  66036. reject(record.arg);
  66037. } else {
  66038. var result = record.arg;
  66039. var value = result.value;
  66040. if (value &&
  66041. typeof value === "object" &&
  66042. hasOwn.call(value, "__await")) {
  66043. return PromiseImpl.resolve(value.__await).then(function(value) {
  66044. invoke("next", value, resolve, reject);
  66045. }, function(err) {
  66046. invoke("throw", err, resolve, reject);
  66047. });
  66048. }
  66049. return PromiseImpl.resolve(value).then(function(unwrapped) {
  66050. // When a yielded Promise is resolved, its final value becomes
  66051. // the .value of the Promise<{value,done}> result for the
  66052. // current iteration.
  66053. result.value = unwrapped;
  66054. resolve(result);
  66055. }, function(error) {
  66056. // If a rejected Promise was yielded, throw the rejection back
  66057. // into the async generator function so it can be handled there.
  66058. return invoke("throw", error, resolve, reject);
  66059. });
  66060. }
  66061. }
  66062. var previousPromise;
  66063. function enqueue(method, arg) {
  66064. function callInvokeWithMethodAndArg() {
  66065. return new PromiseImpl(function(resolve, reject) {
  66066. invoke(method, arg, resolve, reject);
  66067. });
  66068. }
  66069. return previousPromise =
  66070. // If enqueue has been called before, then we want to wait until
  66071. // all previous Promises have been resolved before calling invoke,
  66072. // so that results are always delivered in the correct order. If
  66073. // enqueue has not been called before, then it is important to
  66074. // call invoke immediately, without waiting on a callback to fire,
  66075. // so that the async generator function has the opportunity to do
  66076. // any necessary setup in a predictable way. This predictability
  66077. // is why the Promise constructor synchronously invokes its
  66078. // executor callback, and why async functions synchronously
  66079. // execute code before the first await. Since we implement simple
  66080. // async functions in terms of async generators, it is especially
  66081. // important to get this right, even though it requires care.
  66082. previousPromise ? previousPromise.then(
  66083. callInvokeWithMethodAndArg,
  66084. // Avoid propagating failures to Promises returned by later
  66085. // invocations of the iterator.
  66086. callInvokeWithMethodAndArg
  66087. ) : callInvokeWithMethodAndArg();
  66088. }
  66089. // Define the unified helper method that is used to implement .next,
  66090. // .throw, and .return (see defineIteratorMethods).
  66091. this._invoke = enqueue;
  66092. }
  66093. defineIteratorMethods(AsyncIterator.prototype);
  66094. define(AsyncIterator.prototype, asyncIteratorSymbol, function () {
  66095. return this;
  66096. });
  66097. exports.AsyncIterator = AsyncIterator;
  66098. // Note that simple async functions are implemented on top of
  66099. // AsyncIterator objects; they just return a Promise for the value of
  66100. // the final result produced by the iterator.
  66101. exports.async = function(innerFn, outerFn, self, tryLocsList, PromiseImpl) {
  66102. if (PromiseImpl === void 0) PromiseImpl = Promise;
  66103. var iter = new AsyncIterator(
  66104. wrap(innerFn, outerFn, self, tryLocsList),
  66105. PromiseImpl
  66106. );
  66107. return exports.isGeneratorFunction(outerFn)
  66108. ? iter // If outerFn is a generator, return the full iterator.
  66109. : iter.next().then(function(result) {
  66110. return result.done ? result.value : iter.next();
  66111. });
  66112. };
  66113. function makeInvokeMethod(innerFn, self, context) {
  66114. var state = GenStateSuspendedStart;
  66115. return function invoke(method, arg) {
  66116. if (state === GenStateExecuting) {
  66117. throw new Error("Generator is already running");
  66118. }
  66119. if (state === GenStateCompleted) {
  66120. if (method === "throw") {
  66121. throw arg;
  66122. }
  66123. // Be forgiving, per 25.3.3.3.3 of the spec:
  66124. // https://people.mozilla.org/~jorendorff/es6-draft.html#sec-generatorresume
  66125. return doneResult();
  66126. }
  66127. context.method = method;
  66128. context.arg = arg;
  66129. while (true) {
  66130. var delegate = context.delegate;
  66131. if (delegate) {
  66132. var delegateResult = maybeInvokeDelegate(delegate, context);
  66133. if (delegateResult) {
  66134. if (delegateResult === ContinueSentinel) continue;
  66135. return delegateResult;
  66136. }
  66137. }
  66138. if (context.method === "next") {
  66139. // Setting context._sent for legacy support of Babel's
  66140. // function.sent implementation.
  66141. context.sent = context._sent = context.arg;
  66142. } else if (context.method === "throw") {
  66143. if (state === GenStateSuspendedStart) {
  66144. state = GenStateCompleted;
  66145. throw context.arg;
  66146. }
  66147. context.dispatchException(context.arg);
  66148. } else if (context.method === "return") {
  66149. context.abrupt("return", context.arg);
  66150. }
  66151. state = GenStateExecuting;
  66152. var record = tryCatch(innerFn, self, context);
  66153. if (record.type === "normal") {
  66154. // If an exception is thrown from innerFn, we leave state ===
  66155. // GenStateExecuting and loop back for another invocation.
  66156. state = context.done
  66157. ? GenStateCompleted
  66158. : GenStateSuspendedYield;
  66159. if (record.arg === ContinueSentinel) {
  66160. continue;
  66161. }
  66162. return {
  66163. value: record.arg,
  66164. done: context.done
  66165. };
  66166. } else if (record.type === "throw") {
  66167. state = GenStateCompleted;
  66168. // Dispatch the exception by looping back around to the
  66169. // context.dispatchException(context.arg) call above.
  66170. context.method = "throw";
  66171. context.arg = record.arg;
  66172. }
  66173. }
  66174. };
  66175. }
  66176. // Call delegate.iterator[context.method](context.arg) and handle the
  66177. // result, either by returning a { value, done } result from the
  66178. // delegate iterator, or by modifying context.method and context.arg,
  66179. // setting context.delegate to null, and returning the ContinueSentinel.
  66180. function maybeInvokeDelegate(delegate, context) {
  66181. var method = delegate.iterator[context.method];
  66182. if (method === undefined) {
  66183. // A .throw or .return when the delegate iterator has no .throw
  66184. // method always terminates the yield* loop.
  66185. context.delegate = null;
  66186. if (context.method === "throw") {
  66187. // Note: ["return"] must be used for ES3 parsing compatibility.
  66188. if (delegate.iterator["return"]) {
  66189. // If the delegate iterator has a return method, give it a
  66190. // chance to clean up.
  66191. context.method = "return";
  66192. context.arg = undefined;
  66193. maybeInvokeDelegate(delegate, context);
  66194. if (context.method === "throw") {
  66195. // If maybeInvokeDelegate(context) changed context.method from
  66196. // "return" to "throw", let that override the TypeError below.
  66197. return ContinueSentinel;
  66198. }
  66199. }
  66200. context.method = "throw";
  66201. context.arg = new TypeError(
  66202. "The iterator does not provide a 'throw' method");
  66203. }
  66204. return ContinueSentinel;
  66205. }
  66206. var record = tryCatch(method, delegate.iterator, context.arg);
  66207. if (record.type === "throw") {
  66208. context.method = "throw";
  66209. context.arg = record.arg;
  66210. context.delegate = null;
  66211. return ContinueSentinel;
  66212. }
  66213. var info = record.arg;
  66214. if (! info) {
  66215. context.method = "throw";
  66216. context.arg = new TypeError("iterator result is not an object");
  66217. context.delegate = null;
  66218. return ContinueSentinel;
  66219. }
  66220. if (info.done) {
  66221. // Assign the result of the finished delegate to the temporary
  66222. // variable specified by delegate.resultName (see delegateYield).
  66223. context[delegate.resultName] = info.value;
  66224. // Resume execution at the desired location (see delegateYield).
  66225. context.next = delegate.nextLoc;
  66226. // If context.method was "throw" but the delegate handled the
  66227. // exception, let the outer generator proceed normally. If
  66228. // context.method was "next", forget context.arg since it has been
  66229. // "consumed" by the delegate iterator. If context.method was
  66230. // "return", allow the original .return call to continue in the
  66231. // outer generator.
  66232. if (context.method !== "return") {
  66233. context.method = "next";
  66234. context.arg = undefined;
  66235. }
  66236. } else {
  66237. // Re-yield the result returned by the delegate method.
  66238. return info;
  66239. }
  66240. // The delegate iterator is finished, so forget it and continue with
  66241. // the outer generator.
  66242. context.delegate = null;
  66243. return ContinueSentinel;
  66244. }
  66245. // Define Generator.prototype.{next,throw,return} in terms of the
  66246. // unified ._invoke helper method.
  66247. defineIteratorMethods(Gp);
  66248. define(Gp, toStringTagSymbol, "Generator");
  66249. // A Generator should always return itself as the iterator object when the
  66250. // @@iterator function is called on it. Some browsers' implementations of the
  66251. // iterator prototype chain incorrectly implement this, causing the Generator
  66252. // object to not be returned from this call. This ensures that doesn't happen.
  66253. // See https://github.com/facebook/regenerator/issues/274 for more details.
  66254. define(Gp, iteratorSymbol, function() {
  66255. return this;
  66256. });
  66257. define(Gp, "toString", function() {
  66258. return "[object Generator]";
  66259. });
  66260. function pushTryEntry(locs) {
  66261. var entry = { tryLoc: locs[0] };
  66262. if (1 in locs) {
  66263. entry.catchLoc = locs[1];
  66264. }
  66265. if (2 in locs) {
  66266. entry.finallyLoc = locs[2];
  66267. entry.afterLoc = locs[3];
  66268. }
  66269. this.tryEntries.push(entry);
  66270. }
  66271. function resetTryEntry(entry) {
  66272. var record = entry.completion || {};
  66273. record.type = "normal";
  66274. delete record.arg;
  66275. entry.completion = record;
  66276. }
  66277. function Context(tryLocsList) {
  66278. // The root entry object (effectively a try statement without a catch
  66279. // or a finally block) gives us a place to store values thrown from
  66280. // locations where there is no enclosing try statement.
  66281. this.tryEntries = [{ tryLoc: "root" }];
  66282. tryLocsList.forEach(pushTryEntry, this);
  66283. this.reset(true);
  66284. }
  66285. exports.keys = function(object) {
  66286. var keys = [];
  66287. for (var key in object) {
  66288. keys.push(key);
  66289. }
  66290. keys.reverse();
  66291. // Rather than returning an object with a next method, we keep
  66292. // things simple and return the next function itself.
  66293. return function next() {
  66294. while (keys.length) {
  66295. var key = keys.pop();
  66296. if (key in object) {
  66297. next.value = key;
  66298. next.done = false;
  66299. return next;
  66300. }
  66301. }
  66302. // To avoid creating an additional object, we just hang the .value
  66303. // and .done properties off the next function object itself. This
  66304. // also ensures that the minifier will not anonymize the function.
  66305. next.done = true;
  66306. return next;
  66307. };
  66308. };
  66309. function values(iterable) {
  66310. if (iterable) {
  66311. var iteratorMethod = iterable[iteratorSymbol];
  66312. if (iteratorMethod) {
  66313. return iteratorMethod.call(iterable);
  66314. }
  66315. if (typeof iterable.next === "function") {
  66316. return iterable;
  66317. }
  66318. if (!isNaN(iterable.length)) {
  66319. var i = -1, next = function next() {
  66320. while (++i < iterable.length) {
  66321. if (hasOwn.call(iterable, i)) {
  66322. next.value = iterable[i];
  66323. next.done = false;
  66324. return next;
  66325. }
  66326. }
  66327. next.value = undefined;
  66328. next.done = true;
  66329. return next;
  66330. };
  66331. return next.next = next;
  66332. }
  66333. }
  66334. // Return an iterator with no values.
  66335. return { next: doneResult };
  66336. }
  66337. exports.values = values;
  66338. function doneResult() {
  66339. return { value: undefined, done: true };
  66340. }
  66341. Context.prototype = {
  66342. constructor: Context,
  66343. reset: function(skipTempReset) {
  66344. this.prev = 0;
  66345. this.next = 0;
  66346. // Resetting context._sent for legacy support of Babel's
  66347. // function.sent implementation.
  66348. this.sent = this._sent = undefined;
  66349. this.done = false;
  66350. this.delegate = null;
  66351. this.method = "next";
  66352. this.arg = undefined;
  66353. this.tryEntries.forEach(resetTryEntry);
  66354. if (!skipTempReset) {
  66355. for (var name in this) {
  66356. // Not sure about the optimal order of these conditions:
  66357. if (name.charAt(0) === "t" &&
  66358. hasOwn.call(this, name) &&
  66359. !isNaN(+name.slice(1))) {
  66360. this[name] = undefined;
  66361. }
  66362. }
  66363. }
  66364. },
  66365. stop: function() {
  66366. this.done = true;
  66367. var rootEntry = this.tryEntries[0];
  66368. var rootRecord = rootEntry.completion;
  66369. if (rootRecord.type === "throw") {
  66370. throw rootRecord.arg;
  66371. }
  66372. return this.rval;
  66373. },
  66374. dispatchException: function(exception) {
  66375. if (this.done) {
  66376. throw exception;
  66377. }
  66378. var context = this;
  66379. function handle(loc, caught) {
  66380. record.type = "throw";
  66381. record.arg = exception;
  66382. context.next = loc;
  66383. if (caught) {
  66384. // If the dispatched exception was caught by a catch block,
  66385. // then let that catch block handle the exception normally.
  66386. context.method = "next";
  66387. context.arg = undefined;
  66388. }
  66389. return !! caught;
  66390. }
  66391. for (var i = this.tryEntries.length - 1; i >= 0; --i) {
  66392. var entry = this.tryEntries[i];
  66393. var record = entry.completion;
  66394. if (entry.tryLoc === "root") {
  66395. // Exception thrown outside of any try block that could handle
  66396. // it, so set the completion value of the entire function to
  66397. // throw the exception.
  66398. return handle("end");
  66399. }
  66400. if (entry.tryLoc <= this.prev) {
  66401. var hasCatch = hasOwn.call(entry, "catchLoc");
  66402. var hasFinally = hasOwn.call(entry, "finallyLoc");
  66403. if (hasCatch && hasFinally) {
  66404. if (this.prev < entry.catchLoc) {
  66405. return handle(entry.catchLoc, true);
  66406. } else if (this.prev < entry.finallyLoc) {
  66407. return handle(entry.finallyLoc);
  66408. }
  66409. } else if (hasCatch) {
  66410. if (this.prev < entry.catchLoc) {
  66411. return handle(entry.catchLoc, true);
  66412. }
  66413. } else if (hasFinally) {
  66414. if (this.prev < entry.finallyLoc) {
  66415. return handle(entry.finallyLoc);
  66416. }
  66417. } else {
  66418. throw new Error("try statement without catch or finally");
  66419. }
  66420. }
  66421. }
  66422. },
  66423. abrupt: function(type, arg) {
  66424. for (var i = this.tryEntries.length - 1; i >= 0; --i) {
  66425. var entry = this.tryEntries[i];
  66426. if (entry.tryLoc <= this.prev &&
  66427. hasOwn.call(entry, "finallyLoc") &&
  66428. this.prev < entry.finallyLoc) {
  66429. var finallyEntry = entry;
  66430. break;
  66431. }
  66432. }
  66433. if (finallyEntry &&
  66434. (type === "break" ||
  66435. type === "continue") &&
  66436. finallyEntry.tryLoc <= arg &&
  66437. arg <= finallyEntry.finallyLoc) {
  66438. // Ignore the finally entry if control is not jumping to a
  66439. // location outside the try/catch block.
  66440. finallyEntry = null;
  66441. }
  66442. var record = finallyEntry ? finallyEntry.completion : {};
  66443. record.type = type;
  66444. record.arg = arg;
  66445. if (finallyEntry) {
  66446. this.method = "next";
  66447. this.next = finallyEntry.finallyLoc;
  66448. return ContinueSentinel;
  66449. }
  66450. return this.complete(record);
  66451. },
  66452. complete: function(record, afterLoc) {
  66453. if (record.type === "throw") {
  66454. throw record.arg;
  66455. }
  66456. if (record.type === "break" ||
  66457. record.type === "continue") {
  66458. this.next = record.arg;
  66459. } else if (record.type === "return") {
  66460. this.rval = this.arg = record.arg;
  66461. this.method = "return";
  66462. this.next = "end";
  66463. } else if (record.type === "normal" && afterLoc) {
  66464. this.next = afterLoc;
  66465. }
  66466. return ContinueSentinel;
  66467. },
  66468. finish: function(finallyLoc) {
  66469. for (var i = this.tryEntries.length - 1; i >= 0; --i) {
  66470. var entry = this.tryEntries[i];
  66471. if (entry.finallyLoc === finallyLoc) {
  66472. this.complete(entry.completion, entry.afterLoc);
  66473. resetTryEntry(entry);
  66474. return ContinueSentinel;
  66475. }
  66476. }
  66477. },
  66478. "catch": function(tryLoc) {
  66479. for (var i = this.tryEntries.length - 1; i >= 0; --i) {
  66480. var entry = this.tryEntries[i];
  66481. if (entry.tryLoc === tryLoc) {
  66482. var record = entry.completion;
  66483. if (record.type === "throw") {
  66484. var thrown = record.arg;
  66485. resetTryEntry(entry);
  66486. }
  66487. return thrown;
  66488. }
  66489. }
  66490. // The context.catch method must only be called with a location
  66491. // argument that corresponds to a known catch block.
  66492. throw new Error("illegal catch attempt");
  66493. },
  66494. delegateYield: function(iterable, resultName, nextLoc) {
  66495. this.delegate = {
  66496. iterator: values(iterable),
  66497. resultName: resultName,
  66498. nextLoc: nextLoc
  66499. };
  66500. if (this.method === "next") {
  66501. // Deliberately forget the last sent value so that we don't
  66502. // accidentally pass it on to the delegate.
  66503. this.arg = undefined;
  66504. }
  66505. return ContinueSentinel;
  66506. }
  66507. };
  66508. // Regardless of whether this script is executing as a CommonJS module
  66509. // or not, return the runtime object so that we can declare the variable
  66510. // regeneratorRuntime in the outer scope, which allows this module to be
  66511. // injected easily by `bin/regenerator --include-runtime script.js`.
  66512. return exports;
  66513. }(
  66514. // If this script is executing as a CommonJS module, use module.exports
  66515. // as the regeneratorRuntime namespace. Otherwise create a new empty
  66516. // object. Either way, the resulting object will be used to initialize
  66517. // the regeneratorRuntime variable at the top of this file.
  66518. typeof module === "object" ? module.exports : {}
  66519. ));
  66520. try {
  66521. regeneratorRuntime = runtime;
  66522. } catch (accidentalStrictMode) {
  66523. // This module should not be running in strict mode, so the above
  66524. // assignment should always work unless something is misconfigured. Just
  66525. // in case runtime.js accidentally runs in strict mode, in modern engines
  66526. // we can explicitly access globalThis. In older engines we can escape
  66527. // strict mode using a global Function call. This could conceivably fail
  66528. // if a Content Security Policy forbids using Function, but in that case
  66529. // the proper solution is to fix the accidental strict mode problem. If
  66530. // you've misconfigured your bundler to force strict mode and applied a
  66531. // CSP to forbid Function, and you're not willing to fix either of those
  66532. // problems, please detail your unique predicament in a GitHub issue.
  66533. if (typeof globalThis === "object") {
  66534. globalThis.regeneratorRuntime = runtime;
  66535. } else {
  66536. Function("r", "regeneratorRuntime = r")(runtime);
  66537. }
  66538. }
  66539. },{}],795:[function(_dereq_,module,exports){
  66540. (function (setImmediate){(function (){
  66541. "use strict";
  66542. (function(root) {
  66543. const MAX_VALUE = 0x7fffffff;
  66544. // The SHA256 and PBKDF2 implementation are from scrypt-async-js:
  66545. // See: https://github.com/dchest/scrypt-async-js
  66546. function SHA256(m) {
  66547. const K = new Uint32Array([
  66548. 0x428a2f98, 0x71374491, 0xb5c0fbcf, 0xe9b5dba5, 0x3956c25b,
  66549. 0x59f111f1, 0x923f82a4, 0xab1c5ed5, 0xd807aa98, 0x12835b01,
  66550. 0x243185be, 0x550c7dc3, 0x72be5d74, 0x80deb1fe, 0x9bdc06a7,
  66551. 0xc19bf174, 0xe49b69c1, 0xefbe4786, 0x0fc19dc6, 0x240ca1cc,
  66552. 0x2de92c6f, 0x4a7484aa, 0x5cb0a9dc, 0x76f988da, 0x983e5152,
  66553. 0xa831c66d, 0xb00327c8, 0xbf597fc7, 0xc6e00bf3, 0xd5a79147,
  66554. 0x06ca6351, 0x14292967, 0x27b70a85, 0x2e1b2138, 0x4d2c6dfc,
  66555. 0x53380d13, 0x650a7354, 0x766a0abb, 0x81c2c92e, 0x92722c85,
  66556. 0xa2bfe8a1, 0xa81a664b, 0xc24b8b70, 0xc76c51a3, 0xd192e819,
  66557. 0xd6990624, 0xf40e3585, 0x106aa070, 0x19a4c116, 0x1e376c08,
  66558. 0x2748774c, 0x34b0bcb5, 0x391c0cb3, 0x4ed8aa4a, 0x5b9cca4f,
  66559. 0x682e6ff3, 0x748f82ee, 0x78a5636f, 0x84c87814, 0x8cc70208,
  66560. 0x90befffa, 0xa4506ceb, 0xbef9a3f7, 0xc67178f2
  66561. ]);
  66562. let h0 = 0x6a09e667, h1 = 0xbb67ae85, h2 = 0x3c6ef372, h3 = 0xa54ff53a;
  66563. let h4 = 0x510e527f, h5 = 0x9b05688c, h6 = 0x1f83d9ab, h7 = 0x5be0cd19;
  66564. const w = new Uint32Array(64);
  66565. function blocks(p) {
  66566. let off = 0, len = p.length;
  66567. while (len >= 64) {
  66568. let a = h0, b = h1, c = h2, d = h3, e = h4, f = h5, g = h6, h = h7, u, i, j, t1, t2;
  66569. for (i = 0; i < 16; i++) {
  66570. j = off + i*4;
  66571. w[i] = ((p[j] & 0xff)<<24) | ((p[j+1] & 0xff)<<16) |
  66572. ((p[j+2] & 0xff)<<8) | (p[j+3] & 0xff);
  66573. }
  66574. for (i = 16; i < 64; i++) {
  66575. u = w[i-2];
  66576. t1 = ((u>>>17) | (u<<(32-17))) ^ ((u>>>19) | (u<<(32-19))) ^ (u>>>10);
  66577. u = w[i-15];
  66578. t2 = ((u>>>7) | (u<<(32-7))) ^ ((u>>>18) | (u<<(32-18))) ^ (u>>>3);
  66579. w[i] = (((t1 + w[i-7]) | 0) + ((t2 + w[i-16]) | 0)) | 0;
  66580. }
  66581. for (i = 0; i < 64; i++) {
  66582. t1 = ((((((e>>>6) | (e<<(32-6))) ^ ((e>>>11) | (e<<(32-11))) ^
  66583. ((e>>>25) | (e<<(32-25)))) + ((e & f) ^ (~e & g))) | 0) +
  66584. ((h + ((K[i] + w[i]) | 0)) | 0)) | 0;
  66585. t2 = ((((a>>>2) | (a<<(32-2))) ^ ((a>>>13) | (a<<(32-13))) ^
  66586. ((a>>>22) | (a<<(32-22)))) + ((a & b) ^ (a & c) ^ (b & c))) | 0;
  66587. h = g;
  66588. g = f;
  66589. f = e;
  66590. e = (d + t1) | 0;
  66591. d = c;
  66592. c = b;
  66593. b = a;
  66594. a = (t1 + t2) | 0;
  66595. }
  66596. h0 = (h0 + a) | 0;
  66597. h1 = (h1 + b) | 0;
  66598. h2 = (h2 + c) | 0;
  66599. h3 = (h3 + d) | 0;
  66600. h4 = (h4 + e) | 0;
  66601. h5 = (h5 + f) | 0;
  66602. h6 = (h6 + g) | 0;
  66603. h7 = (h7 + h) | 0;
  66604. off += 64;
  66605. len -= 64;
  66606. }
  66607. }
  66608. blocks(m);
  66609. let i, bytesLeft = m.length % 64,
  66610. bitLenHi = (m.length / 0x20000000) | 0,
  66611. bitLenLo = m.length << 3,
  66612. numZeros = (bytesLeft < 56) ? 56 : 120,
  66613. p = m.slice(m.length - bytesLeft, m.length);
  66614. p.push(0x80);
  66615. for (i = bytesLeft + 1; i < numZeros; i++) { p.push(0); }
  66616. p.push((bitLenHi >>> 24) & 0xff);
  66617. p.push((bitLenHi >>> 16) & 0xff);
  66618. p.push((bitLenHi >>> 8) & 0xff);
  66619. p.push((bitLenHi >>> 0) & 0xff);
  66620. p.push((bitLenLo >>> 24) & 0xff);
  66621. p.push((bitLenLo >>> 16) & 0xff);
  66622. p.push((bitLenLo >>> 8) & 0xff);
  66623. p.push((bitLenLo >>> 0) & 0xff);
  66624. blocks(p);
  66625. return [
  66626. (h0 >>> 24) & 0xff, (h0 >>> 16) & 0xff, (h0 >>> 8) & 0xff, (h0 >>> 0) & 0xff,
  66627. (h1 >>> 24) & 0xff, (h1 >>> 16) & 0xff, (h1 >>> 8) & 0xff, (h1 >>> 0) & 0xff,
  66628. (h2 >>> 24) & 0xff, (h2 >>> 16) & 0xff, (h2 >>> 8) & 0xff, (h2 >>> 0) & 0xff,
  66629. (h3 >>> 24) & 0xff, (h3 >>> 16) & 0xff, (h3 >>> 8) & 0xff, (h3 >>> 0) & 0xff,
  66630. (h4 >>> 24) & 0xff, (h4 >>> 16) & 0xff, (h4 >>> 8) & 0xff, (h4 >>> 0) & 0xff,
  66631. (h5 >>> 24) & 0xff, (h5 >>> 16) & 0xff, (h5 >>> 8) & 0xff, (h5 >>> 0) & 0xff,
  66632. (h6 >>> 24) & 0xff, (h6 >>> 16) & 0xff, (h6 >>> 8) & 0xff, (h6 >>> 0) & 0xff,
  66633. (h7 >>> 24) & 0xff, (h7 >>> 16) & 0xff, (h7 >>> 8) & 0xff, (h7 >>> 0) & 0xff
  66634. ];
  66635. }
  66636. function PBKDF2_HMAC_SHA256_OneIter(password, salt, dkLen) {
  66637. // compress password if it's longer than hash block length
  66638. password = (password.length <= 64) ? password : SHA256(password);
  66639. const innerLen = 64 + salt.length + 4;
  66640. const inner = new Array(innerLen);
  66641. const outerKey = new Array(64);
  66642. let i;
  66643. let dk = [];
  66644. // inner = (password ^ ipad) || salt || counter
  66645. for (i = 0; i < 64; i++) { inner[i] = 0x36; }
  66646. for (i = 0; i < password.length; i++) { inner[i] ^= password[i]; }
  66647. for (i = 0; i < salt.length; i++) { inner[64 + i] = salt[i]; }
  66648. for (i = innerLen - 4; i < innerLen; i++) { inner[i] = 0; }
  66649. // outerKey = password ^ opad
  66650. for (i = 0; i < 64; i++) outerKey[i] = 0x5c;
  66651. for (i = 0; i < password.length; i++) outerKey[i] ^= password[i];
  66652. // increments counter inside inner
  66653. function incrementCounter() {
  66654. for (let i = innerLen - 1; i >= innerLen - 4; i--) {
  66655. inner[i]++;
  66656. if (inner[i] <= 0xff) return;
  66657. inner[i] = 0;
  66658. }
  66659. }
  66660. // output blocks = SHA256(outerKey || SHA256(inner)) ...
  66661. while (dkLen >= 32) {
  66662. incrementCounter();
  66663. dk = dk.concat(SHA256(outerKey.concat(SHA256(inner))));
  66664. dkLen -= 32;
  66665. }
  66666. if (dkLen > 0) {
  66667. incrementCounter();
  66668. dk = dk.concat(SHA256(outerKey.concat(SHA256(inner))).slice(0, dkLen));
  66669. }
  66670. return dk;
  66671. }
  66672. // The following is an adaptation of scryptsy
  66673. // See: https://www.npmjs.com/package/scryptsy
  66674. function blockmix_salsa8(BY, Yi, r, x, _X) {
  66675. let i;
  66676. arraycopy(BY, (2 * r - 1) * 16, _X, 0, 16);
  66677. for (i = 0; i < 2 * r; i++) {
  66678. blockxor(BY, i * 16, _X, 16);
  66679. salsa20_8(_X, x);
  66680. arraycopy(_X, 0, BY, Yi + (i * 16), 16);
  66681. }
  66682. for (i = 0; i < r; i++) {
  66683. arraycopy(BY, Yi + (i * 2) * 16, BY, (i * 16), 16);
  66684. }
  66685. for (i = 0; i < r; i++) {
  66686. arraycopy(BY, Yi + (i * 2 + 1) * 16, BY, (i + r) * 16, 16);
  66687. }
  66688. }
  66689. function R(a, b) {
  66690. return (a << b) | (a >>> (32 - b));
  66691. }
  66692. function salsa20_8(B, x) {
  66693. arraycopy(B, 0, x, 0, 16);
  66694. for (let i = 8; i > 0; i -= 2) {
  66695. x[ 4] ^= R(x[ 0] + x[12], 7);
  66696. x[ 8] ^= R(x[ 4] + x[ 0], 9);
  66697. x[12] ^= R(x[ 8] + x[ 4], 13);
  66698. x[ 0] ^= R(x[12] + x[ 8], 18);
  66699. x[ 9] ^= R(x[ 5] + x[ 1], 7);
  66700. x[13] ^= R(x[ 9] + x[ 5], 9);
  66701. x[ 1] ^= R(x[13] + x[ 9], 13);
  66702. x[ 5] ^= R(x[ 1] + x[13], 18);
  66703. x[14] ^= R(x[10] + x[ 6], 7);
  66704. x[ 2] ^= R(x[14] + x[10], 9);
  66705. x[ 6] ^= R(x[ 2] + x[14], 13);
  66706. x[10] ^= R(x[ 6] + x[ 2], 18);
  66707. x[ 3] ^= R(x[15] + x[11], 7);
  66708. x[ 7] ^= R(x[ 3] + x[15], 9);
  66709. x[11] ^= R(x[ 7] + x[ 3], 13);
  66710. x[15] ^= R(x[11] + x[ 7], 18);
  66711. x[ 1] ^= R(x[ 0] + x[ 3], 7);
  66712. x[ 2] ^= R(x[ 1] + x[ 0], 9);
  66713. x[ 3] ^= R(x[ 2] + x[ 1], 13);
  66714. x[ 0] ^= R(x[ 3] + x[ 2], 18);
  66715. x[ 6] ^= R(x[ 5] + x[ 4], 7);
  66716. x[ 7] ^= R(x[ 6] + x[ 5], 9);
  66717. x[ 4] ^= R(x[ 7] + x[ 6], 13);
  66718. x[ 5] ^= R(x[ 4] + x[ 7], 18);
  66719. x[11] ^= R(x[10] + x[ 9], 7);
  66720. x[ 8] ^= R(x[11] + x[10], 9);
  66721. x[ 9] ^= R(x[ 8] + x[11], 13);
  66722. x[10] ^= R(x[ 9] + x[ 8], 18);
  66723. x[12] ^= R(x[15] + x[14], 7);
  66724. x[13] ^= R(x[12] + x[15], 9);
  66725. x[14] ^= R(x[13] + x[12], 13);
  66726. x[15] ^= R(x[14] + x[13], 18);
  66727. }
  66728. for (let i = 0; i < 16; ++i) {
  66729. B[i] += x[i];
  66730. }
  66731. }
  66732. // naive approach... going back to loop unrolling may yield additional performance
  66733. function blockxor(S, Si, D, len) {
  66734. for (let i = 0; i < len; i++) {
  66735. D[i] ^= S[Si + i]
  66736. }
  66737. }
  66738. function arraycopy(src, srcPos, dest, destPos, length) {
  66739. while (length--) {
  66740. dest[destPos++] = src[srcPos++];
  66741. }
  66742. }
  66743. function checkBufferish(o) {
  66744. if (!o || typeof(o.length) !== 'number') { return false; }
  66745. for (let i = 0; i < o.length; i++) {
  66746. const v = o[i];
  66747. if (typeof(v) !== 'number' || v % 1 || v < 0 || v >= 256) {
  66748. return false;
  66749. }
  66750. }
  66751. return true;
  66752. }
  66753. function ensureInteger(value, name) {
  66754. if (typeof(value) !== "number" || (value % 1)) { throw new Error('invalid ' + name); }
  66755. return value;
  66756. }
  66757. // N = Cpu cost, r = Memory cost, p = parallelization cost
  66758. // callback(error, progress, key)
  66759. function _scrypt(password, salt, N, r, p, dkLen, callback) {
  66760. N = ensureInteger(N, 'N');
  66761. r = ensureInteger(r, 'r');
  66762. p = ensureInteger(p, 'p');
  66763. dkLen = ensureInteger(dkLen, 'dkLen');
  66764. if (N === 0 || (N & (N - 1)) !== 0) { throw new Error('N must be power of 2'); }
  66765. if (N > MAX_VALUE / 128 / r) { throw new Error('N too large'); }
  66766. if (r > MAX_VALUE / 128 / p) { throw new Error('r too large'); }
  66767. if (!checkBufferish(password)) {
  66768. throw new Error('password must be an array or buffer');
  66769. }
  66770. password = Array.prototype.slice.call(password);
  66771. if (!checkBufferish(salt)) {
  66772. throw new Error('salt must be an array or buffer');
  66773. }
  66774. salt = Array.prototype.slice.call(salt);
  66775. let b = PBKDF2_HMAC_SHA256_OneIter(password, salt, p * 128 * r);
  66776. const B = new Uint32Array(p * 32 * r)
  66777. for (let i = 0; i < B.length; i++) {
  66778. const j = i * 4;
  66779. B[i] = ((b[j + 3] & 0xff) << 24) |
  66780. ((b[j + 2] & 0xff) << 16) |
  66781. ((b[j + 1] & 0xff) << 8) |
  66782. ((b[j + 0] & 0xff) << 0);
  66783. }
  66784. const XY = new Uint32Array(64 * r);
  66785. const V = new Uint32Array(32 * r * N);
  66786. const Yi = 32 * r;
  66787. // scratch space
  66788. const x = new Uint32Array(16); // salsa20_8
  66789. const _X = new Uint32Array(16); // blockmix_salsa8
  66790. const totalOps = p * N * 2;
  66791. let currentOp = 0;
  66792. let lastPercent10 = null;
  66793. // Set this to true to abandon the scrypt on the next step
  66794. let stop = false;
  66795. // State information
  66796. let state = 0;
  66797. let i0 = 0, i1;
  66798. let Bi;
  66799. // How many blockmix_salsa8 can we do per step?
  66800. const limit = callback ? parseInt(1000 / r): 0xffffffff;
  66801. // Trick from scrypt-async; if there is a setImmediate shim in place, use it
  66802. const nextTick = (typeof(setImmediate) !== 'undefined') ? setImmediate : setTimeout;
  66803. // This is really all I changed; making scryptsy a state machine so we occasionally
  66804. // stop and give other evnts on the evnt loop a chance to run. ~RicMoo
  66805. const incrementalSMix = function() {
  66806. if (stop) {
  66807. return callback(new Error('cancelled'), currentOp / totalOps);
  66808. }
  66809. let steps;
  66810. switch (state) {
  66811. case 0:
  66812. // for (var i = 0; i < p; i++)...
  66813. Bi = i0 * 32 * r;
  66814. arraycopy(B, Bi, XY, 0, Yi); // ROMix - 1
  66815. state = 1; // Move to ROMix 2
  66816. i1 = 0;
  66817. // Fall through
  66818. case 1:
  66819. // Run up to 1000 steps of the first inner smix loop
  66820. steps = N - i1;
  66821. if (steps > limit) { steps = limit; }
  66822. for (let i = 0; i < steps; i++) { // ROMix - 2
  66823. arraycopy(XY, 0, V, (i1 + i) * Yi, Yi) // ROMix - 3
  66824. blockmix_salsa8(XY, Yi, r, x, _X); // ROMix - 4
  66825. }
  66826. // for (var i = 0; i < N; i++)
  66827. i1 += steps;
  66828. currentOp += steps;
  66829. if (callback) {
  66830. // Call the callback with the progress (optionally stopping us)
  66831. const percent10 = parseInt(1000 * currentOp / totalOps);
  66832. if (percent10 !== lastPercent10) {
  66833. stop = callback(null, currentOp / totalOps);
  66834. if (stop) { break; }
  66835. lastPercent10 = percent10;
  66836. }
  66837. }
  66838. if (i1 < N) { break; }
  66839. i1 = 0; // Move to ROMix 6
  66840. state = 2;
  66841. // Fall through
  66842. case 2:
  66843. // Run up to 1000 steps of the second inner smix loop
  66844. steps = N - i1;
  66845. if (steps > limit) { steps = limit; }
  66846. for (let i = 0; i < steps; i++) { // ROMix - 6
  66847. const offset = (2 * r - 1) * 16; // ROMix - 7
  66848. const j = XY[offset] & (N - 1);
  66849. blockxor(V, j * Yi, XY, Yi); // ROMix - 8 (inner)
  66850. blockmix_salsa8(XY, Yi, r, x, _X); // ROMix - 9 (outer)
  66851. }
  66852. // for (var i = 0; i < N; i++)...
  66853. i1 += steps;
  66854. currentOp += steps;
  66855. // Call the callback with the progress (optionally stopping us)
  66856. if (callback) {
  66857. const percent10 = parseInt(1000 * currentOp / totalOps);
  66858. if (percent10 !== lastPercent10) {
  66859. stop = callback(null, currentOp / totalOps);
  66860. if (stop) { break; }
  66861. lastPercent10 = percent10;
  66862. }
  66863. }
  66864. if (i1 < N) { break; }
  66865. arraycopy(XY, 0, B, Bi, Yi); // ROMix - 10
  66866. // for (var i = 0; i < p; i++)...
  66867. i0++;
  66868. if (i0 < p) {
  66869. state = 0;
  66870. break;
  66871. }
  66872. b = [];
  66873. for (let i = 0; i < B.length; i++) {
  66874. b.push((B[i] >> 0) & 0xff);
  66875. b.push((B[i] >> 8) & 0xff);
  66876. b.push((B[i] >> 16) & 0xff);
  66877. b.push((B[i] >> 24) & 0xff);
  66878. }
  66879. const derivedKey = PBKDF2_HMAC_SHA256_OneIter(password, b, dkLen);
  66880. // Send the result to the callback
  66881. if (callback) { callback(null, 1.0, derivedKey); }
  66882. // Done; don't break (which would reschedule)
  66883. return derivedKey;
  66884. }
  66885. // Schedule the next steps
  66886. if (callback) { nextTick(incrementalSMix); }
  66887. }
  66888. // Run the smix state machine until completion
  66889. if (!callback) {
  66890. while (true) {
  66891. const derivedKey = incrementalSMix();
  66892. if (derivedKey != undefined) { return derivedKey; }
  66893. }
  66894. }
  66895. // Bootstrap the async incremental smix
  66896. incrementalSMix();
  66897. }
  66898. const lib = {
  66899. scrypt: function(password, salt, N, r, p, dkLen, progressCallback) {
  66900. return new Promise(function(resolve, reject) {
  66901. let lastProgress = 0;
  66902. if (progressCallback) { progressCallback(0); }
  66903. _scrypt(password, salt, N, r, p, dkLen, function(error, progress, key) {
  66904. if (error) {
  66905. reject(error);
  66906. } else if (key) {
  66907. if (progressCallback && lastProgress !== 1) {
  66908. progressCallback(1);
  66909. }
  66910. resolve(new Uint8Array(key));
  66911. } else if (progressCallback && progress !== lastProgress) {
  66912. lastProgress = progress;
  66913. return progressCallback(progress);
  66914. }
  66915. });
  66916. });
  66917. },
  66918. syncScrypt: function(password, salt, N, r, p, dkLen) {
  66919. return new Uint8Array(_scrypt(password, salt, N, r, p, dkLen));
  66920. }
  66921. };
  66922. // node.js
  66923. if (typeof(exports) !== 'undefined') {
  66924. module.exports = lib;
  66925. // RequireJS/AMD
  66926. // http://www.requirejs.org/docs/api.html
  66927. // https://github.com/amdjs/amdjs-api/wiki/AMD
  66928. } else if (typeof(define) === 'function' && define.amd) {
  66929. define(lib);
  66930. // Web Browsers
  66931. } else if (root) {
  66932. // If there was an existing library "scrypt", make sure it is still available
  66933. if (root.scrypt) {
  66934. root._scrypt = root.scrypt;
  66935. }
  66936. root.scrypt = lib;
  66937. }
  66938. })(this);
  66939. }).call(this)}).call(this,_dereq_("timers").setImmediate)
  66940. },{"timers":796}],796:[function(_dereq_,module,exports){
  66941. (function (setImmediate,clearImmediate){(function (){
  66942. var nextTick = _dereq_('process/browser.js').nextTick;
  66943. var apply = Function.prototype.apply;
  66944. var slice = Array.prototype.slice;
  66945. var immediateIds = {};
  66946. var nextImmediateId = 0;
  66947. // DOM APIs, for completeness
  66948. exports.setTimeout = function() {
  66949. return new Timeout(apply.call(setTimeout, window, arguments), clearTimeout);
  66950. };
  66951. exports.setInterval = function() {
  66952. return new Timeout(apply.call(setInterval, window, arguments), clearInterval);
  66953. };
  66954. exports.clearTimeout =
  66955. exports.clearInterval = function(timeout) { timeout.close(); };
  66956. function Timeout(id, clearFn) {
  66957. this._id = id;
  66958. this._clearFn = clearFn;
  66959. }
  66960. Timeout.prototype.unref = Timeout.prototype.ref = function() {};
  66961. Timeout.prototype.close = function() {
  66962. this._clearFn.call(window, this._id);
  66963. };
  66964. // Does not start the time, just sets up the members needed.
  66965. exports.enroll = function(item, msecs) {
  66966. clearTimeout(item._idleTimeoutId);
  66967. item._idleTimeout = msecs;
  66968. };
  66969. exports.unenroll = function(item) {
  66970. clearTimeout(item._idleTimeoutId);
  66971. item._idleTimeout = -1;
  66972. };
  66973. exports._unrefActive = exports.active = function(item) {
  66974. clearTimeout(item._idleTimeoutId);
  66975. var msecs = item._idleTimeout;
  66976. if (msecs >= 0) {
  66977. item._idleTimeoutId = setTimeout(function onTimeout() {
  66978. if (item._onTimeout)
  66979. item._onTimeout();
  66980. }, msecs);
  66981. }
  66982. };
  66983. // That's not how node.js implements it but the exposed api is the same.
  66984. exports.setImmediate = typeof setImmediate === "function" ? setImmediate : function(fn) {
  66985. var id = nextImmediateId++;
  66986. var args = arguments.length < 2 ? false : slice.call(arguments, 1);
  66987. immediateIds[id] = true;
  66988. nextTick(function onNextTick() {
  66989. if (immediateIds[id]) {
  66990. // fn.call() is faster so we optimize for the common use-case
  66991. // @see http://jsperf.com/call-apply-segu
  66992. if (args) {
  66993. fn.apply(null, args);
  66994. } else {
  66995. fn.call(null);
  66996. }
  66997. // Prevent ids from leaking
  66998. exports.clearImmediate(id);
  66999. }
  67000. });
  67001. return id;
  67002. };
  67003. exports.clearImmediate = typeof clearImmediate === "function" ? clearImmediate : function(id) {
  67004. delete immediateIds[id];
  67005. };
  67006. }).call(this)}).call(this,_dereq_("timers").setImmediate,_dereq_("timers").clearImmediate)
  67007. },{"process/browser.js":793,"timers":796}],797:[function(_dereq_,module,exports){
  67008. "use strict";
  67009. Object.defineProperty(exports, "__esModule", {
  67010. value: true
  67011. });
  67012. Object.defineProperty(exports, "v1", {
  67013. enumerable: true,
  67014. get: function () {
  67015. return _v.default;
  67016. }
  67017. });
  67018. Object.defineProperty(exports, "v3", {
  67019. enumerable: true,
  67020. get: function () {
  67021. return _v2.default;
  67022. }
  67023. });
  67024. Object.defineProperty(exports, "v4", {
  67025. enumerable: true,
  67026. get: function () {
  67027. return _v3.default;
  67028. }
  67029. });
  67030. Object.defineProperty(exports, "v5", {
  67031. enumerable: true,
  67032. get: function () {
  67033. return _v4.default;
  67034. }
  67035. });
  67036. Object.defineProperty(exports, "NIL", {
  67037. enumerable: true,
  67038. get: function () {
  67039. return _nil.default;
  67040. }
  67041. });
  67042. Object.defineProperty(exports, "version", {
  67043. enumerable: true,
  67044. get: function () {
  67045. return _version.default;
  67046. }
  67047. });
  67048. Object.defineProperty(exports, "validate", {
  67049. enumerable: true,
  67050. get: function () {
  67051. return _validate.default;
  67052. }
  67053. });
  67054. Object.defineProperty(exports, "stringify", {
  67055. enumerable: true,
  67056. get: function () {
  67057. return _stringify.default;
  67058. }
  67059. });
  67060. Object.defineProperty(exports, "parse", {
  67061. enumerable: true,
  67062. get: function () {
  67063. return _parse.default;
  67064. }
  67065. });
  67066. var _v = _interopRequireDefault(_dereq_("./v1.js"));
  67067. var _v2 = _interopRequireDefault(_dereq_("./v3.js"));
  67068. var _v3 = _interopRequireDefault(_dereq_("./v4.js"));
  67069. var _v4 = _interopRequireDefault(_dereq_("./v5.js"));
  67070. var _nil = _interopRequireDefault(_dereq_("./nil.js"));
  67071. var _version = _interopRequireDefault(_dereq_("./version.js"));
  67072. var _validate = _interopRequireDefault(_dereq_("./validate.js"));
  67073. var _stringify = _interopRequireDefault(_dereq_("./stringify.js"));
  67074. var _parse = _interopRequireDefault(_dereq_("./parse.js"));
  67075. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  67076. },{"./nil.js":799,"./parse.js":800,"./stringify.js":804,"./v1.js":805,"./v3.js":806,"./v4.js":808,"./v5.js":809,"./validate.js":810,"./version.js":811}],798:[function(_dereq_,module,exports){
  67077. "use strict";
  67078. Object.defineProperty(exports, "__esModule", {
  67079. value: true
  67080. });
  67081. exports.default = void 0;
  67082. /*
  67083. * Browser-compatible JavaScript MD5
  67084. *
  67085. * Modification of JavaScript MD5
  67086. * https://github.com/blueimp/JavaScript-MD5
  67087. *
  67088. * Copyright 2011, Sebastian Tschan
  67089. * https://blueimp.net
  67090. *
  67091. * Licensed under the MIT license:
  67092. * https://opensource.org/licenses/MIT
  67093. *
  67094. * Based on
  67095. * A JavaScript implementation of the RSA Data Security, Inc. MD5 Message
  67096. * Digest Algorithm, as defined in RFC 1321.
  67097. * Version 2.2 Copyright (C) Paul Johnston 1999 - 2009
  67098. * Other contributors: Greg Holt, Andrew Kepert, Ydnar, Lostinet
  67099. * Distributed under the BSD License
  67100. * See http://pajhome.org.uk/crypt/md5 for more info.
  67101. */
  67102. function md5(bytes) {
  67103. if (typeof bytes === 'string') {
  67104. const msg = unescape(encodeURIComponent(bytes)); // UTF8 escape
  67105. bytes = new Uint8Array(msg.length);
  67106. for (let i = 0; i < msg.length; ++i) {
  67107. bytes[i] = msg.charCodeAt(i);
  67108. }
  67109. }
  67110. return md5ToHexEncodedArray(wordsToMd5(bytesToWords(bytes), bytes.length * 8));
  67111. }
  67112. /*
  67113. * Convert an array of little-endian words to an array of bytes
  67114. */
  67115. function md5ToHexEncodedArray(input) {
  67116. const output = [];
  67117. const length32 = input.length * 32;
  67118. const hexTab = '0123456789abcdef';
  67119. for (let i = 0; i < length32; i += 8) {
  67120. const x = input[i >> 5] >>> i % 32 & 0xff;
  67121. const hex = parseInt(hexTab.charAt(x >>> 4 & 0x0f) + hexTab.charAt(x & 0x0f), 16);
  67122. output.push(hex);
  67123. }
  67124. return output;
  67125. }
  67126. /**
  67127. * Calculate output length with padding and bit length
  67128. */
  67129. function getOutputLength(inputLength8) {
  67130. return (inputLength8 + 64 >>> 9 << 4) + 14 + 1;
  67131. }
  67132. /*
  67133. * Calculate the MD5 of an array of little-endian words, and a bit length.
  67134. */
  67135. function wordsToMd5(x, len) {
  67136. /* append padding */
  67137. x[len >> 5] |= 0x80 << len % 32;
  67138. x[getOutputLength(len) - 1] = len;
  67139. let a = 1732584193;
  67140. let b = -271733879;
  67141. let c = -1732584194;
  67142. let d = 271733878;
  67143. for (let i = 0; i < x.length; i += 16) {
  67144. const olda = a;
  67145. const oldb = b;
  67146. const oldc = c;
  67147. const oldd = d;
  67148. a = md5ff(a, b, c, d, x[i], 7, -680876936);
  67149. d = md5ff(d, a, b, c, x[i + 1], 12, -389564586);
  67150. c = md5ff(c, d, a, b, x[i + 2], 17, 606105819);
  67151. b = md5ff(b, c, d, a, x[i + 3], 22, -1044525330);
  67152. a = md5ff(a, b, c, d, x[i + 4], 7, -176418897);
  67153. d = md5ff(d, a, b, c, x[i + 5], 12, 1200080426);
  67154. c = md5ff(c, d, a, b, x[i + 6], 17, -1473231341);
  67155. b = md5ff(b, c, d, a, x[i + 7], 22, -45705983);
  67156. a = md5ff(a, b, c, d, x[i + 8], 7, 1770035416);
  67157. d = md5ff(d, a, b, c, x[i + 9], 12, -1958414417);
  67158. c = md5ff(c, d, a, b, x[i + 10], 17, -42063);
  67159. b = md5ff(b, c, d, a, x[i + 11], 22, -1990404162);
  67160. a = md5ff(a, b, c, d, x[i + 12], 7, 1804603682);
  67161. d = md5ff(d, a, b, c, x[i + 13], 12, -40341101);
  67162. c = md5ff(c, d, a, b, x[i + 14], 17, -1502002290);
  67163. b = md5ff(b, c, d, a, x[i + 15], 22, 1236535329);
  67164. a = md5gg(a, b, c, d, x[i + 1], 5, -165796510);
  67165. d = md5gg(d, a, b, c, x[i + 6], 9, -1069501632);
  67166. c = md5gg(c, d, a, b, x[i + 11], 14, 643717713);
  67167. b = md5gg(b, c, d, a, x[i], 20, -373897302);
  67168. a = md5gg(a, b, c, d, x[i + 5], 5, -701558691);
  67169. d = md5gg(d, a, b, c, x[i + 10], 9, 38016083);
  67170. c = md5gg(c, d, a, b, x[i + 15], 14, -660478335);
  67171. b = md5gg(b, c, d, a, x[i + 4], 20, -405537848);
  67172. a = md5gg(a, b, c, d, x[i + 9], 5, 568446438);
  67173. d = md5gg(d, a, b, c, x[i + 14], 9, -1019803690);
  67174. c = md5gg(c, d, a, b, x[i + 3], 14, -187363961);
  67175. b = md5gg(b, c, d, a, x[i + 8], 20, 1163531501);
  67176. a = md5gg(a, b, c, d, x[i + 13], 5, -1444681467);
  67177. d = md5gg(d, a, b, c, x[i + 2], 9, -51403784);
  67178. c = md5gg(c, d, a, b, x[i + 7], 14, 1735328473);
  67179. b = md5gg(b, c, d, a, x[i + 12], 20, -1926607734);
  67180. a = md5hh(a, b, c, d, x[i + 5], 4, -378558);
  67181. d = md5hh(d, a, b, c, x[i + 8], 11, -2022574463);
  67182. c = md5hh(c, d, a, b, x[i + 11], 16, 1839030562);
  67183. b = md5hh(b, c, d, a, x[i + 14], 23, -35309556);
  67184. a = md5hh(a, b, c, d, x[i + 1], 4, -1530992060);
  67185. d = md5hh(d, a, b, c, x[i + 4], 11, 1272893353);
  67186. c = md5hh(c, d, a, b, x[i + 7], 16, -155497632);
  67187. b = md5hh(b, c, d, a, x[i + 10], 23, -1094730640);
  67188. a = md5hh(a, b, c, d, x[i + 13], 4, 681279174);
  67189. d = md5hh(d, a, b, c, x[i], 11, -358537222);
  67190. c = md5hh(c, d, a, b, x[i + 3], 16, -722521979);
  67191. b = md5hh(b, c, d, a, x[i + 6], 23, 76029189);
  67192. a = md5hh(a, b, c, d, x[i + 9], 4, -640364487);
  67193. d = md5hh(d, a, b, c, x[i + 12], 11, -421815835);
  67194. c = md5hh(c, d, a, b, x[i + 15], 16, 530742520);
  67195. b = md5hh(b, c, d, a, x[i + 2], 23, -995338651);
  67196. a = md5ii(a, b, c, d, x[i], 6, -198630844);
  67197. d = md5ii(d, a, b, c, x[i + 7], 10, 1126891415);
  67198. c = md5ii(c, d, a, b, x[i + 14], 15, -1416354905);
  67199. b = md5ii(b, c, d, a, x[i + 5], 21, -57434055);
  67200. a = md5ii(a, b, c, d, x[i + 12], 6, 1700485571);
  67201. d = md5ii(d, a, b, c, x[i + 3], 10, -1894986606);
  67202. c = md5ii(c, d, a, b, x[i + 10], 15, -1051523);
  67203. b = md5ii(b, c, d, a, x[i + 1], 21, -2054922799);
  67204. a = md5ii(a, b, c, d, x[i + 8], 6, 1873313359);
  67205. d = md5ii(d, a, b, c, x[i + 15], 10, -30611744);
  67206. c = md5ii(c, d, a, b, x[i + 6], 15, -1560198380);
  67207. b = md5ii(b, c, d, a, x[i + 13], 21, 1309151649);
  67208. a = md5ii(a, b, c, d, x[i + 4], 6, -145523070);
  67209. d = md5ii(d, a, b, c, x[i + 11], 10, -1120210379);
  67210. c = md5ii(c, d, a, b, x[i + 2], 15, 718787259);
  67211. b = md5ii(b, c, d, a, x[i + 9], 21, -343485551);
  67212. a = safeAdd(a, olda);
  67213. b = safeAdd(b, oldb);
  67214. c = safeAdd(c, oldc);
  67215. d = safeAdd(d, oldd);
  67216. }
  67217. return [a, b, c, d];
  67218. }
  67219. /*
  67220. * Convert an array bytes to an array of little-endian words
  67221. * Characters >255 have their high-byte silently ignored.
  67222. */
  67223. function bytesToWords(input) {
  67224. if (input.length === 0) {
  67225. return [];
  67226. }
  67227. const length8 = input.length * 8;
  67228. const output = new Uint32Array(getOutputLength(length8));
  67229. for (let i = 0; i < length8; i += 8) {
  67230. output[i >> 5] |= (input[i / 8] & 0xff) << i % 32;
  67231. }
  67232. return output;
  67233. }
  67234. /*
  67235. * Add integers, wrapping at 2^32. This uses 16-bit operations internally
  67236. * to work around bugs in some JS interpreters.
  67237. */
  67238. function safeAdd(x, y) {
  67239. const lsw = (x & 0xffff) + (y & 0xffff);
  67240. const msw = (x >> 16) + (y >> 16) + (lsw >> 16);
  67241. return msw << 16 | lsw & 0xffff;
  67242. }
  67243. /*
  67244. * Bitwise rotate a 32-bit number to the left.
  67245. */
  67246. function bitRotateLeft(num, cnt) {
  67247. return num << cnt | num >>> 32 - cnt;
  67248. }
  67249. /*
  67250. * These functions implement the four basic operations the algorithm uses.
  67251. */
  67252. function md5cmn(q, a, b, x, s, t) {
  67253. return safeAdd(bitRotateLeft(safeAdd(safeAdd(a, q), safeAdd(x, t)), s), b);
  67254. }
  67255. function md5ff(a, b, c, d, x, s, t) {
  67256. return md5cmn(b & c | ~b & d, a, b, x, s, t);
  67257. }
  67258. function md5gg(a, b, c, d, x, s, t) {
  67259. return md5cmn(b & d | c & ~d, a, b, x, s, t);
  67260. }
  67261. function md5hh(a, b, c, d, x, s, t) {
  67262. return md5cmn(b ^ c ^ d, a, b, x, s, t);
  67263. }
  67264. function md5ii(a, b, c, d, x, s, t) {
  67265. return md5cmn(c ^ (b | ~d), a, b, x, s, t);
  67266. }
  67267. var _default = md5;
  67268. exports.default = _default;
  67269. },{}],799:[function(_dereq_,module,exports){
  67270. "use strict";
  67271. Object.defineProperty(exports, "__esModule", {
  67272. value: true
  67273. });
  67274. exports.default = void 0;
  67275. var _default = '00000000-0000-0000-0000-000000000000';
  67276. exports.default = _default;
  67277. },{}],800:[function(_dereq_,module,exports){
  67278. "use strict";
  67279. Object.defineProperty(exports, "__esModule", {
  67280. value: true
  67281. });
  67282. exports.default = void 0;
  67283. var _validate = _interopRequireDefault(_dereq_("./validate.js"));
  67284. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  67285. function parse(uuid) {
  67286. if (!(0, _validate.default)(uuid)) {
  67287. throw TypeError('Invalid UUID');
  67288. }
  67289. let v;
  67290. const arr = new Uint8Array(16); // Parse ########-....-....-....-............
  67291. arr[0] = (v = parseInt(uuid.slice(0, 8), 16)) >>> 24;
  67292. arr[1] = v >>> 16 & 0xff;
  67293. arr[2] = v >>> 8 & 0xff;
  67294. arr[3] = v & 0xff; // Parse ........-####-....-....-............
  67295. arr[4] = (v = parseInt(uuid.slice(9, 13), 16)) >>> 8;
  67296. arr[5] = v & 0xff; // Parse ........-....-####-....-............
  67297. arr[6] = (v = parseInt(uuid.slice(14, 18), 16)) >>> 8;
  67298. arr[7] = v & 0xff; // Parse ........-....-....-####-............
  67299. arr[8] = (v = parseInt(uuid.slice(19, 23), 16)) >>> 8;
  67300. arr[9] = v & 0xff; // Parse ........-....-....-....-############
  67301. // (Use "/" to avoid 32-bit truncation when bit-shifting high-order bytes)
  67302. arr[10] = (v = parseInt(uuid.slice(24, 36), 16)) / 0x10000000000 & 0xff;
  67303. arr[11] = v / 0x100000000 & 0xff;
  67304. arr[12] = v >>> 24 & 0xff;
  67305. arr[13] = v >>> 16 & 0xff;
  67306. arr[14] = v >>> 8 & 0xff;
  67307. arr[15] = v & 0xff;
  67308. return arr;
  67309. }
  67310. var _default = parse;
  67311. exports.default = _default;
  67312. },{"./validate.js":810}],801:[function(_dereq_,module,exports){
  67313. "use strict";
  67314. Object.defineProperty(exports, "__esModule", {
  67315. value: true
  67316. });
  67317. exports.default = void 0;
  67318. var _default = /^(?:[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}|00000000-0000-0000-0000-000000000000)$/i;
  67319. exports.default = _default;
  67320. },{}],802:[function(_dereq_,module,exports){
  67321. "use strict";
  67322. Object.defineProperty(exports, "__esModule", {
  67323. value: true
  67324. });
  67325. exports.default = rng;
  67326. // Unique ID creation requires a high quality random # generator. In the browser we therefore
  67327. // require the crypto API and do not support built-in fallback to lower quality random number
  67328. // generators (like Math.random()).
  67329. let getRandomValues;
  67330. const rnds8 = new Uint8Array(16);
  67331. function rng() {
  67332. // lazy load so that environments that need to polyfill have a chance to do so
  67333. if (!getRandomValues) {
  67334. // getRandomValues needs to be invoked in a context where "this" is a Crypto implementation. Also,
  67335. // find the complete implementation of crypto (msCrypto) on IE11.
  67336. getRandomValues = typeof crypto !== 'undefined' && crypto.getRandomValues && crypto.getRandomValues.bind(crypto) || typeof msCrypto !== 'undefined' && typeof msCrypto.getRandomValues === 'function' && msCrypto.getRandomValues.bind(msCrypto);
  67337. if (!getRandomValues) {
  67338. throw new Error('crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported');
  67339. }
  67340. }
  67341. return getRandomValues(rnds8);
  67342. }
  67343. },{}],803:[function(_dereq_,module,exports){
  67344. "use strict";
  67345. Object.defineProperty(exports, "__esModule", {
  67346. value: true
  67347. });
  67348. exports.default = void 0;
  67349. // Adapted from Chris Veness' SHA1 code at
  67350. // http://www.movable-type.co.uk/scripts/sha1.html
  67351. function f(s, x, y, z) {
  67352. switch (s) {
  67353. case 0:
  67354. return x & y ^ ~x & z;
  67355. case 1:
  67356. return x ^ y ^ z;
  67357. case 2:
  67358. return x & y ^ x & z ^ y & z;
  67359. case 3:
  67360. return x ^ y ^ z;
  67361. }
  67362. }
  67363. function ROTL(x, n) {
  67364. return x << n | x >>> 32 - n;
  67365. }
  67366. function sha1(bytes) {
  67367. const K = [0x5a827999, 0x6ed9eba1, 0x8f1bbcdc, 0xca62c1d6];
  67368. const H = [0x67452301, 0xefcdab89, 0x98badcfe, 0x10325476, 0xc3d2e1f0];
  67369. if (typeof bytes === 'string') {
  67370. const msg = unescape(encodeURIComponent(bytes)); // UTF8 escape
  67371. bytes = [];
  67372. for (let i = 0; i < msg.length; ++i) {
  67373. bytes.push(msg.charCodeAt(i));
  67374. }
  67375. } else if (!Array.isArray(bytes)) {
  67376. // Convert Array-like to Array
  67377. bytes = Array.prototype.slice.call(bytes);
  67378. }
  67379. bytes.push(0x80);
  67380. const l = bytes.length / 4 + 2;
  67381. const N = Math.ceil(l / 16);
  67382. const M = new Array(N);
  67383. for (let i = 0; i < N; ++i) {
  67384. const arr = new Uint32Array(16);
  67385. for (let j = 0; j < 16; ++j) {
  67386. arr[j] = bytes[i * 64 + j * 4] << 24 | bytes[i * 64 + j * 4 + 1] << 16 | bytes[i * 64 + j * 4 + 2] << 8 | bytes[i * 64 + j * 4 + 3];
  67387. }
  67388. M[i] = arr;
  67389. }
  67390. M[N - 1][14] = (bytes.length - 1) * 8 / Math.pow(2, 32);
  67391. M[N - 1][14] = Math.floor(M[N - 1][14]);
  67392. M[N - 1][15] = (bytes.length - 1) * 8 & 0xffffffff;
  67393. for (let i = 0; i < N; ++i) {
  67394. const W = new Uint32Array(80);
  67395. for (let t = 0; t < 16; ++t) {
  67396. W[t] = M[i][t];
  67397. }
  67398. for (let t = 16; t < 80; ++t) {
  67399. W[t] = ROTL(W[t - 3] ^ W[t - 8] ^ W[t - 14] ^ W[t - 16], 1);
  67400. }
  67401. let a = H[0];
  67402. let b = H[1];
  67403. let c = H[2];
  67404. let d = H[3];
  67405. let e = H[4];
  67406. for (let t = 0; t < 80; ++t) {
  67407. const s = Math.floor(t / 20);
  67408. const T = ROTL(a, 5) + f(s, b, c, d) + e + K[s] + W[t] >>> 0;
  67409. e = d;
  67410. d = c;
  67411. c = ROTL(b, 30) >>> 0;
  67412. b = a;
  67413. a = T;
  67414. }
  67415. H[0] = H[0] + a >>> 0;
  67416. H[1] = H[1] + b >>> 0;
  67417. H[2] = H[2] + c >>> 0;
  67418. H[3] = H[3] + d >>> 0;
  67419. H[4] = H[4] + e >>> 0;
  67420. }
  67421. return [H[0] >> 24 & 0xff, H[0] >> 16 & 0xff, H[0] >> 8 & 0xff, H[0] & 0xff, H[1] >> 24 & 0xff, H[1] >> 16 & 0xff, H[1] >> 8 & 0xff, H[1] & 0xff, H[2] >> 24 & 0xff, H[2] >> 16 & 0xff, H[2] >> 8 & 0xff, H[2] & 0xff, H[3] >> 24 & 0xff, H[3] >> 16 & 0xff, H[3] >> 8 & 0xff, H[3] & 0xff, H[4] >> 24 & 0xff, H[4] >> 16 & 0xff, H[4] >> 8 & 0xff, H[4] & 0xff];
  67422. }
  67423. var _default = sha1;
  67424. exports.default = _default;
  67425. },{}],804:[function(_dereq_,module,exports){
  67426. "use strict";
  67427. Object.defineProperty(exports, "__esModule", {
  67428. value: true
  67429. });
  67430. exports.default = void 0;
  67431. var _validate = _interopRequireDefault(_dereq_("./validate.js"));
  67432. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  67433. /**
  67434. * Convert array of 16 byte values to UUID string format of the form:
  67435. * XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX
  67436. */
  67437. const byteToHex = [];
  67438. for (let i = 0; i < 256; ++i) {
  67439. byteToHex.push((i + 0x100).toString(16).substr(1));
  67440. }
  67441. function stringify(arr, offset = 0) {
  67442. // Note: Be careful editing this code! It's been tuned for performance
  67443. // and works in ways you may not expect. See https://github.com/uuidjs/uuid/pull/434
  67444. const uuid = (byteToHex[arr[offset + 0]] + byteToHex[arr[offset + 1]] + byteToHex[arr[offset + 2]] + byteToHex[arr[offset + 3]] + '-' + byteToHex[arr[offset + 4]] + byteToHex[arr[offset + 5]] + '-' + byteToHex[arr[offset + 6]] + byteToHex[arr[offset + 7]] + '-' + byteToHex[arr[offset + 8]] + byteToHex[arr[offset + 9]] + '-' + byteToHex[arr[offset + 10]] + byteToHex[arr[offset + 11]] + byteToHex[arr[offset + 12]] + byteToHex[arr[offset + 13]] + byteToHex[arr[offset + 14]] + byteToHex[arr[offset + 15]]).toLowerCase(); // Consistency check for valid UUID. If this throws, it's likely due to one
  67445. // of the following:
  67446. // - One or more input array values don't map to a hex octet (leading to
  67447. // "undefined" in the uuid)
  67448. // - Invalid input values for the RFC `version` or `variant` fields
  67449. if (!(0, _validate.default)(uuid)) {
  67450. throw TypeError('Stringified UUID is invalid');
  67451. }
  67452. return uuid;
  67453. }
  67454. var _default = stringify;
  67455. exports.default = _default;
  67456. },{"./validate.js":810}],805:[function(_dereq_,module,exports){
  67457. "use strict";
  67458. Object.defineProperty(exports, "__esModule", {
  67459. value: true
  67460. });
  67461. exports.default = void 0;
  67462. var _rng = _interopRequireDefault(_dereq_("./rng.js"));
  67463. var _stringify = _interopRequireDefault(_dereq_("./stringify.js"));
  67464. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  67465. // **`v1()` - Generate time-based UUID**
  67466. //
  67467. // Inspired by https://github.com/LiosK/UUID.js
  67468. // and http://docs.python.org/library/uuid.html
  67469. let _nodeId;
  67470. let _clockseq; // Previous uuid creation time
  67471. let _lastMSecs = 0;
  67472. let _lastNSecs = 0; // See https://github.com/uuidjs/uuid for API details
  67473. function v1(options, buf, offset) {
  67474. let i = buf && offset || 0;
  67475. const b = buf || new Array(16);
  67476. options = options || {};
  67477. let node = options.node || _nodeId;
  67478. let clockseq = options.clockseq !== undefined ? options.clockseq : _clockseq; // node and clockseq need to be initialized to random values if they're not
  67479. // specified. We do this lazily to minimize issues related to insufficient
  67480. // system entropy. See #189
  67481. if (node == null || clockseq == null) {
  67482. const seedBytes = options.random || (options.rng || _rng.default)();
  67483. if (node == null) {
  67484. // Per 4.5, create and 48-bit node id, (47 random bits + multicast bit = 1)
  67485. node = _nodeId = [seedBytes[0] | 0x01, seedBytes[1], seedBytes[2], seedBytes[3], seedBytes[4], seedBytes[5]];
  67486. }
  67487. if (clockseq == null) {
  67488. // Per 4.2.2, randomize (14 bit) clockseq
  67489. clockseq = _clockseq = (seedBytes[6] << 8 | seedBytes[7]) & 0x3fff;
  67490. }
  67491. } // UUID timestamps are 100 nano-second units since the Gregorian epoch,
  67492. // (1582-10-15 00:00). JSNumbers aren't precise enough for this, so
  67493. // time is handled internally as 'msecs' (integer milliseconds) and 'nsecs'
  67494. // (100-nanoseconds offset from msecs) since unix epoch, 1970-01-01 00:00.
  67495. let msecs = options.msecs !== undefined ? options.msecs : Date.now(); // Per 4.2.1.2, use count of uuid's generated during the current clock
  67496. // cycle to simulate higher resolution clock
  67497. let nsecs = options.nsecs !== undefined ? options.nsecs : _lastNSecs + 1; // Time since last uuid creation (in msecs)
  67498. const dt = msecs - _lastMSecs + (nsecs - _lastNSecs) / 10000; // Per 4.2.1.2, Bump clockseq on clock regression
  67499. if (dt < 0 && options.clockseq === undefined) {
  67500. clockseq = clockseq + 1 & 0x3fff;
  67501. } // Reset nsecs if clock regresses (new clockseq) or we've moved onto a new
  67502. // time interval
  67503. if ((dt < 0 || msecs > _lastMSecs) && options.nsecs === undefined) {
  67504. nsecs = 0;
  67505. } // Per 4.2.1.2 Throw error if too many uuids are requested
  67506. if (nsecs >= 10000) {
  67507. throw new Error("uuid.v1(): Can't create more than 10M uuids/sec");
  67508. }
  67509. _lastMSecs = msecs;
  67510. _lastNSecs = nsecs;
  67511. _clockseq = clockseq; // Per 4.1.4 - Convert from unix epoch to Gregorian epoch
  67512. msecs += 12219292800000; // `time_low`
  67513. const tl = ((msecs & 0xfffffff) * 10000 + nsecs) % 0x100000000;
  67514. b[i++] = tl >>> 24 & 0xff;
  67515. b[i++] = tl >>> 16 & 0xff;
  67516. b[i++] = tl >>> 8 & 0xff;
  67517. b[i++] = tl & 0xff; // `time_mid`
  67518. const tmh = msecs / 0x100000000 * 10000 & 0xfffffff;
  67519. b[i++] = tmh >>> 8 & 0xff;
  67520. b[i++] = tmh & 0xff; // `time_high_and_version`
  67521. b[i++] = tmh >>> 24 & 0xf | 0x10; // include version
  67522. b[i++] = tmh >>> 16 & 0xff; // `clock_seq_hi_and_reserved` (Per 4.2.2 - include variant)
  67523. b[i++] = clockseq >>> 8 | 0x80; // `clock_seq_low`
  67524. b[i++] = clockseq & 0xff; // `node`
  67525. for (let n = 0; n < 6; ++n) {
  67526. b[i + n] = node[n];
  67527. }
  67528. return buf || (0, _stringify.default)(b);
  67529. }
  67530. var _default = v1;
  67531. exports.default = _default;
  67532. },{"./rng.js":802,"./stringify.js":804}],806:[function(_dereq_,module,exports){
  67533. "use strict";
  67534. Object.defineProperty(exports, "__esModule", {
  67535. value: true
  67536. });
  67537. exports.default = void 0;
  67538. var _v = _interopRequireDefault(_dereq_("./v35.js"));
  67539. var _md = _interopRequireDefault(_dereq_("./md5.js"));
  67540. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  67541. const v3 = (0, _v.default)('v3', 0x30, _md.default);
  67542. var _default = v3;
  67543. exports.default = _default;
  67544. },{"./md5.js":798,"./v35.js":807}],807:[function(_dereq_,module,exports){
  67545. "use strict";
  67546. Object.defineProperty(exports, "__esModule", {
  67547. value: true
  67548. });
  67549. exports.default = _default;
  67550. exports.URL = exports.DNS = void 0;
  67551. var _stringify = _interopRequireDefault(_dereq_("./stringify.js"));
  67552. var _parse = _interopRequireDefault(_dereq_("./parse.js"));
  67553. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  67554. function stringToBytes(str) {
  67555. str = unescape(encodeURIComponent(str)); // UTF8 escape
  67556. const bytes = [];
  67557. for (let i = 0; i < str.length; ++i) {
  67558. bytes.push(str.charCodeAt(i));
  67559. }
  67560. return bytes;
  67561. }
  67562. const DNS = '6ba7b810-9dad-11d1-80b4-00c04fd430c8';
  67563. exports.DNS = DNS;
  67564. const URL = '6ba7b811-9dad-11d1-80b4-00c04fd430c8';
  67565. exports.URL = URL;
  67566. function _default(name, version, hashfunc) {
  67567. function generateUUID(value, namespace, buf, offset) {
  67568. if (typeof value === 'string') {
  67569. value = stringToBytes(value);
  67570. }
  67571. if (typeof namespace === 'string') {
  67572. namespace = (0, _parse.default)(namespace);
  67573. }
  67574. if (namespace.length !== 16) {
  67575. throw TypeError('Namespace must be array-like (16 iterable integer values, 0-255)');
  67576. } // Compute hash of namespace and value, Per 4.3
  67577. // Future: Use spread syntax when supported on all platforms, e.g. `bytes =
  67578. // hashfunc([...namespace, ... value])`
  67579. let bytes = new Uint8Array(16 + value.length);
  67580. bytes.set(namespace);
  67581. bytes.set(value, namespace.length);
  67582. bytes = hashfunc(bytes);
  67583. bytes[6] = bytes[6] & 0x0f | version;
  67584. bytes[8] = bytes[8] & 0x3f | 0x80;
  67585. if (buf) {
  67586. offset = offset || 0;
  67587. for (let i = 0; i < 16; ++i) {
  67588. buf[offset + i] = bytes[i];
  67589. }
  67590. return buf;
  67591. }
  67592. return (0, _stringify.default)(bytes);
  67593. } // Function#name is not settable on some platforms (#270)
  67594. try {
  67595. generateUUID.name = name; // eslint-disable-next-line no-empty
  67596. } catch (err) {} // For CommonJS default export support
  67597. generateUUID.DNS = DNS;
  67598. generateUUID.URL = URL;
  67599. return generateUUID;
  67600. }
  67601. },{"./parse.js":800,"./stringify.js":804}],808:[function(_dereq_,module,exports){
  67602. "use strict";
  67603. Object.defineProperty(exports, "__esModule", {
  67604. value: true
  67605. });
  67606. exports.default = void 0;
  67607. var _rng = _interopRequireDefault(_dereq_("./rng.js"));
  67608. var _stringify = _interopRequireDefault(_dereq_("./stringify.js"));
  67609. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  67610. function v4(options, buf, offset) {
  67611. options = options || {};
  67612. const rnds = options.random || (options.rng || _rng.default)(); // Per 4.4, set bits for version and `clock_seq_hi_and_reserved`
  67613. rnds[6] = rnds[6] & 0x0f | 0x40;
  67614. rnds[8] = rnds[8] & 0x3f | 0x80; // Copy bytes to buffer, if provided
  67615. if (buf) {
  67616. offset = offset || 0;
  67617. for (let i = 0; i < 16; ++i) {
  67618. buf[offset + i] = rnds[i];
  67619. }
  67620. return buf;
  67621. }
  67622. return (0, _stringify.default)(rnds);
  67623. }
  67624. var _default = v4;
  67625. exports.default = _default;
  67626. },{"./rng.js":802,"./stringify.js":804}],809:[function(_dereq_,module,exports){
  67627. "use strict";
  67628. Object.defineProperty(exports, "__esModule", {
  67629. value: true
  67630. });
  67631. exports.default = void 0;
  67632. var _v = _interopRequireDefault(_dereq_("./v35.js"));
  67633. var _sha = _interopRequireDefault(_dereq_("./sha1.js"));
  67634. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  67635. const v5 = (0, _v.default)('v5', 0x50, _sha.default);
  67636. var _default = v5;
  67637. exports.default = _default;
  67638. },{"./sha1.js":803,"./v35.js":807}],810:[function(_dereq_,module,exports){
  67639. "use strict";
  67640. Object.defineProperty(exports, "__esModule", {
  67641. value: true
  67642. });
  67643. exports.default = void 0;
  67644. var _regex = _interopRequireDefault(_dereq_("./regex.js"));
  67645. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  67646. function validate(uuid) {
  67647. return typeof uuid === 'string' && _regex.default.test(uuid);
  67648. }
  67649. var _default = validate;
  67650. exports.default = _default;
  67651. },{"./regex.js":801}],811:[function(_dereq_,module,exports){
  67652. "use strict";
  67653. Object.defineProperty(exports, "__esModule", {
  67654. value: true
  67655. });
  67656. exports.default = void 0;
  67657. var _validate = _interopRequireDefault(_dereq_("./validate.js"));
  67658. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  67659. function version(uuid) {
  67660. if (!(0, _validate.default)(uuid)) {
  67661. throw TypeError('Invalid UUID');
  67662. }
  67663. return parseInt(uuid.substr(14, 1), 16);
  67664. }
  67665. var _default = version;
  67666. exports.default = _default;
  67667. },{"./validate.js":810}]},{},[25])(25)
  67668. });