parse.js 1.3 MB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143101441014510146101471014810149101501015110152101531015410155101561015710158101591016010161101621016310164101651016610167101681016910170101711017210173101741017510176101771017810179101801018110182101831018410185101861018710188101891019010191101921019310194101951019610197101981019910200102011020210203102041020510206102071020810209102101021110212102131021410215102161021710218102191022010221102221022310224102251022610227102281022910230102311023210233102341023510236102371023810239102401024110242102431024410245102461024710248102491025010251102521025310254102551025610257102581025910260102611026210263102641026510266102671026810269102701027110272102731027410275102761027710278102791028010281102821028310284102851028610287102881028910290102911029210293102941029510296102971029810299103001030110302103031030410305103061030710308103091031010311103121031310314103151031610317103181031910320103211032210323103241032510326103271032810329103301033110332103331033410335103361033710338103391034010341103421034310344103451034610347103481034910350103511035210353103541035510356103571035810359103601036110362103631036410365103661036710368103691037010371103721037310374103751037610377103781037910380103811038210383103841038510386103871038810389103901039110392103931039410395103961039710398103991040010401104021040310404104051040610407104081040910410104111041210413104141041510416104171041810419104201042110422104231042410425104261042710428104291043010431104321043310434104351043610437104381043910440104411044210443104441044510446104471044810449104501045110452104531045410455104561045710458104591046010461104621046310464104651046610467104681046910470104711047210473104741047510476104771047810479104801048110482104831048410485104861048710488104891049010491104921049310494104951049610497104981049910500105011050210503105041050510506105071050810509105101051110512105131051410515105161051710518105191052010521105221052310524105251052610527105281052910530105311053210533105341053510536105371053810539105401054110542105431054410545105461054710548105491055010551105521055310554105551055610557105581055910560105611056210563105641056510566105671056810569105701057110572105731057410575105761057710578105791058010581105821058310584105851058610587105881058910590105911059210593105941059510596105971059810599106001060110602106031060410605106061060710608106091061010611106121061310614106151061610617106181061910620106211062210623106241062510626106271062810629106301063110632106331063410635106361063710638106391064010641106421064310644106451064610647106481064910650106511065210653106541065510656106571065810659106601066110662106631066410665106661066710668106691067010671106721067310674106751067610677106781067910680106811068210683106841068510686106871068810689106901069110692106931069410695106961069710698106991070010701107021070310704107051070610707107081070910710107111071210713107141071510716107171071810719107201072110722107231072410725107261072710728107291073010731107321073310734107351073610737107381073910740107411074210743107441074510746107471074810749107501075110752107531075410755107561075710758107591076010761107621076310764107651076610767107681076910770107711077210773107741077510776107771077810779107801078110782107831078410785107861078710788107891079010791107921079310794107951079610797107981079910800108011080210803108041080510806108071080810809108101081110812108131081410815108161081710818108191082010821108221082310824108251082610827108281082910830108311083210833108341083510836108371083810839108401084110842108431084410845108461084710848108491085010851108521085310854108551085610857108581085910860108611086210863108641086510866108671086810869108701087110872108731087410875108761087710878108791088010881108821088310884108851088610887108881088910890108911089210893108941089510896108971089810899109001090110902109031090410905109061090710908109091091010911109121091310914109151091610917109181091910920109211092210923109241092510926109271092810929109301093110932109331093410935109361093710938109391094010941109421094310944109451094610947109481094910950109511095210953109541095510956109571095810959109601096110962109631096410965109661096710968109691097010971109721097310974109751097610977109781097910980109811098210983109841098510986109871098810989109901099110992109931099410995109961099710998109991100011001110021100311004110051100611007110081100911010110111101211013110141101511016110171101811019110201102111022110231102411025110261102711028110291103011031110321103311034110351103611037110381103911040110411104211043110441104511046110471104811049110501105111052110531105411055110561105711058110591106011061110621106311064110651106611067110681106911070110711107211073110741107511076110771107811079110801108111082110831108411085110861108711088110891109011091110921109311094110951109611097110981109911100111011110211103111041110511106111071110811109111101111111112111131111411115111161111711118111191112011121111221112311124111251112611127111281112911130111311113211133111341113511136111371113811139111401114111142111431114411145111461114711148111491115011151111521115311154111551115611157111581115911160111611116211163111641116511166111671116811169111701117111172111731117411175111761117711178111791118011181111821118311184111851118611187111881118911190111911119211193111941119511196111971119811199112001120111202112031120411205112061120711208112091121011211112121121311214112151121611217112181121911220112211122211223112241122511226112271122811229112301123111232112331123411235112361123711238112391124011241112421124311244112451124611247112481124911250112511125211253112541125511256112571125811259112601126111262112631126411265112661126711268112691127011271112721127311274112751127611277112781127911280112811128211283112841128511286112871128811289112901129111292112931129411295112961129711298112991130011301113021130311304113051130611307113081130911310113111131211313113141131511316113171131811319113201132111322113231132411325113261132711328113291133011331113321133311334113351133611337113381133911340113411134211343113441134511346113471134811349113501135111352113531135411355113561135711358113591136011361113621136311364113651136611367113681136911370113711137211373113741137511376113771137811379113801138111382113831138411385113861138711388113891139011391113921139311394113951139611397113981139911400114011140211403114041140511406114071140811409114101141111412114131141411415114161141711418114191142011421114221142311424114251142611427114281142911430114311143211433114341143511436114371143811439114401144111442114431144411445114461144711448114491145011451114521145311454114551145611457114581145911460114611146211463114641146511466114671146811469114701147111472114731147411475114761147711478114791148011481114821148311484114851148611487114881148911490114911149211493114941149511496114971149811499115001150111502115031150411505115061150711508115091151011511115121151311514115151151611517115181151911520115211152211523115241152511526115271152811529115301153111532115331153411535115361153711538115391154011541115421154311544115451154611547115481154911550115511155211553115541155511556115571155811559115601156111562115631156411565115661156711568115691157011571115721157311574115751157611577115781157911580115811158211583115841158511586115871158811589115901159111592115931159411595115961159711598115991160011601116021160311604116051160611607116081160911610116111161211613116141161511616116171161811619116201162111622116231162411625116261162711628116291163011631116321163311634116351163611637116381163911640116411164211643116441164511646116471164811649116501165111652116531165411655116561165711658116591166011661116621166311664116651166611667116681166911670116711167211673116741167511676116771167811679116801168111682116831168411685116861168711688116891169011691116921169311694116951169611697116981169911700117011170211703117041170511706117071170811709117101171111712117131171411715117161171711718117191172011721117221172311724117251172611727117281172911730117311173211733117341173511736117371173811739117401174111742117431174411745117461174711748117491175011751117521175311754117551175611757117581175911760117611176211763117641176511766117671176811769117701177111772117731177411775117761177711778117791178011781117821178311784117851178611787117881178911790117911179211793117941179511796117971179811799118001180111802118031180411805118061180711808118091181011811118121181311814118151181611817118181181911820118211182211823118241182511826118271182811829118301183111832118331183411835118361183711838118391184011841118421184311844118451184611847118481184911850118511185211853118541185511856118571185811859118601186111862118631186411865118661186711868118691187011871118721187311874118751187611877118781187911880118811188211883118841188511886118871188811889118901189111892118931189411895118961189711898118991190011901119021190311904119051190611907119081190911910119111191211913119141191511916119171191811919119201192111922119231192411925119261192711928119291193011931119321193311934119351193611937119381193911940119411194211943119441194511946119471194811949119501195111952119531195411955119561195711958119591196011961119621196311964119651196611967119681196911970119711197211973119741197511976119771197811979119801198111982119831198411985119861198711988119891199011991119921199311994119951199611997119981199912000120011200212003120041200512006120071200812009120101201112012120131201412015120161201712018120191202012021120221202312024120251202612027120281202912030120311203212033120341203512036120371203812039120401204112042120431204412045120461204712048120491205012051120521205312054120551205612057120581205912060120611206212063120641206512066120671206812069120701207112072120731207412075120761207712078120791208012081120821208312084120851208612087120881208912090120911209212093120941209512096120971209812099121001210112102121031210412105121061210712108121091211012111121121211312114121151211612117121181211912120121211212212123121241212512126121271212812129121301213112132121331213412135121361213712138121391214012141121421214312144121451214612147121481214912150121511215212153121541215512156121571215812159121601216112162121631216412165121661216712168121691217012171121721217312174121751217612177121781217912180121811218212183121841218512186121871218812189121901219112192121931219412195121961219712198121991220012201122021220312204122051220612207122081220912210122111221212213122141221512216122171221812219122201222112222122231222412225122261222712228122291223012231122321223312234122351223612237122381223912240122411224212243122441224512246122471224812249122501225112252122531225412255122561225712258122591226012261122621226312264122651226612267122681226912270122711227212273122741227512276122771227812279122801228112282122831228412285122861228712288122891229012291122921229312294122951229612297122981229912300123011230212303123041230512306123071230812309123101231112312123131231412315123161231712318123191232012321123221232312324123251232612327123281232912330123311233212333123341233512336123371233812339123401234112342123431234412345123461234712348123491235012351123521235312354123551235612357123581235912360123611236212363123641236512366123671236812369123701237112372123731237412375123761237712378123791238012381123821238312384123851238612387123881238912390123911239212393123941239512396123971239812399124001240112402124031240412405124061240712408124091241012411124121241312414124151241612417124181241912420124211242212423124241242512426124271242812429124301243112432124331243412435124361243712438124391244012441124421244312444124451244612447124481244912450124511245212453124541245512456124571245812459124601246112462124631246412465124661246712468124691247012471124721247312474124751247612477124781247912480124811248212483124841248512486124871248812489124901249112492124931249412495124961249712498124991250012501125021250312504125051250612507125081250912510125111251212513125141251512516125171251812519125201252112522125231252412525125261252712528125291253012531125321253312534125351253612537125381253912540125411254212543125441254512546125471254812549125501255112552125531255412555125561255712558125591256012561125621256312564125651256612567125681256912570125711257212573125741257512576125771257812579125801258112582125831258412585125861258712588125891259012591125921259312594125951259612597125981259912600126011260212603126041260512606126071260812609126101261112612126131261412615126161261712618126191262012621126221262312624126251262612627126281262912630126311263212633126341263512636126371263812639126401264112642126431264412645126461264712648126491265012651126521265312654126551265612657126581265912660126611266212663126641266512666126671266812669126701267112672126731267412675126761267712678126791268012681126821268312684126851268612687126881268912690126911269212693126941269512696126971269812699127001270112702127031270412705127061270712708127091271012711127121271312714127151271612717127181271912720127211272212723127241272512726127271272812729127301273112732127331273412735127361273712738127391274012741127421274312744127451274612747127481274912750127511275212753127541275512756127571275812759127601276112762127631276412765127661276712768127691277012771127721277312774127751277612777127781277912780127811278212783127841278512786127871278812789127901279112792127931279412795127961279712798127991280012801128021280312804128051280612807128081280912810128111281212813128141281512816128171281812819128201282112822128231282412825128261282712828128291283012831128321283312834128351283612837128381283912840128411284212843128441284512846128471284812849128501285112852128531285412855128561285712858128591286012861128621286312864128651286612867128681286912870128711287212873128741287512876128771287812879128801288112882128831288412885128861288712888128891289012891128921289312894128951289612897128981289912900129011290212903129041290512906129071290812909129101291112912129131291412915129161291712918129191292012921129221292312924129251292612927129281292912930129311293212933129341293512936129371293812939129401294112942129431294412945129461294712948129491295012951129521295312954129551295612957129581295912960129611296212963129641296512966129671296812969129701297112972129731297412975129761297712978129791298012981129821298312984129851298612987129881298912990129911299212993129941299512996129971299812999130001300113002130031300413005130061300713008130091301013011130121301313014130151301613017130181301913020130211302213023130241302513026130271302813029130301303113032130331303413035130361303713038130391304013041130421304313044130451304613047130481304913050130511305213053130541305513056130571305813059130601306113062130631306413065130661306713068130691307013071130721307313074130751307613077130781307913080130811308213083130841308513086130871308813089130901309113092130931309413095130961309713098130991310013101131021310313104131051310613107131081310913110131111311213113131141311513116131171311813119131201312113122131231312413125131261312713128131291313013131131321313313134131351313613137131381313913140131411314213143131441314513146131471314813149131501315113152131531315413155131561315713158131591316013161131621316313164131651316613167131681316913170131711317213173131741317513176131771317813179131801318113182131831318413185131861318713188131891319013191131921319313194131951319613197131981319913200132011320213203132041320513206132071320813209132101321113212132131321413215132161321713218132191322013221132221322313224132251322613227132281322913230132311323213233132341323513236132371323813239132401324113242132431324413245132461324713248132491325013251132521325313254132551325613257132581325913260132611326213263132641326513266132671326813269132701327113272132731327413275132761327713278132791328013281132821328313284132851328613287132881328913290132911329213293132941329513296132971329813299133001330113302133031330413305133061330713308133091331013311133121331313314133151331613317133181331913320133211332213323133241332513326133271332813329133301333113332133331333413335133361333713338133391334013341133421334313344133451334613347133481334913350133511335213353133541335513356133571335813359133601336113362133631336413365133661336713368133691337013371133721337313374133751337613377133781337913380133811338213383133841338513386133871338813389133901339113392133931339413395133961339713398133991340013401134021340313404134051340613407134081340913410134111341213413134141341513416134171341813419134201342113422134231342413425134261342713428134291343013431134321343313434134351343613437134381343913440134411344213443134441344513446134471344813449134501345113452134531345413455134561345713458134591346013461134621346313464134651346613467134681346913470134711347213473134741347513476134771347813479134801348113482134831348413485134861348713488134891349013491134921349313494134951349613497134981349913500135011350213503135041350513506135071350813509135101351113512135131351413515135161351713518135191352013521135221352313524135251352613527135281352913530135311353213533135341353513536135371353813539135401354113542135431354413545135461354713548135491355013551135521355313554135551355613557135581355913560135611356213563135641356513566135671356813569135701357113572135731357413575135761357713578135791358013581135821358313584135851358613587135881358913590135911359213593135941359513596135971359813599136001360113602136031360413605136061360713608136091361013611136121361313614136151361613617136181361913620136211362213623136241362513626136271362813629136301363113632136331363413635136361363713638136391364013641136421364313644136451364613647136481364913650136511365213653136541365513656136571365813659136601366113662136631366413665136661366713668136691367013671136721367313674136751367613677136781367913680136811368213683136841368513686136871368813689136901369113692136931369413695136961369713698136991370013701137021370313704137051370613707137081370913710137111371213713137141371513716137171371813719137201372113722137231372413725137261372713728137291373013731137321373313734137351373613737137381373913740137411374213743137441374513746137471374813749137501375113752137531375413755137561375713758137591376013761137621376313764137651376613767137681376913770137711377213773137741377513776137771377813779137801378113782137831378413785137861378713788137891379013791137921379313794137951379613797137981379913800138011380213803138041380513806138071380813809138101381113812138131381413815138161381713818138191382013821138221382313824138251382613827138281382913830138311383213833138341383513836138371383813839138401384113842138431384413845138461384713848138491385013851138521385313854138551385613857138581385913860138611386213863138641386513866138671386813869138701387113872138731387413875138761387713878138791388013881138821388313884138851388613887138881388913890138911389213893138941389513896138971389813899139001390113902139031390413905139061390713908139091391013911139121391313914139151391613917139181391913920139211392213923139241392513926139271392813929139301393113932139331393413935139361393713938139391394013941139421394313944139451394613947139481394913950139511395213953139541395513956139571395813959139601396113962139631396413965139661396713968139691397013971139721397313974139751397613977139781397913980139811398213983139841398513986139871398813989139901399113992139931399413995139961399713998139991400014001140021400314004140051400614007140081400914010140111401214013140141401514016140171401814019140201402114022140231402414025140261402714028140291403014031140321403314034140351403614037140381403914040140411404214043140441404514046140471404814049140501405114052140531405414055140561405714058140591406014061140621406314064140651406614067140681406914070140711407214073140741407514076140771407814079140801408114082140831408414085140861408714088140891409014091140921409314094140951409614097140981409914100141011410214103141041410514106141071410814109141101411114112141131411414115141161411714118141191412014121141221412314124141251412614127141281412914130141311413214133141341413514136141371413814139141401414114142141431414414145141461414714148141491415014151141521415314154141551415614157141581415914160141611416214163141641416514166141671416814169141701417114172141731417414175141761417714178141791418014181141821418314184141851418614187141881418914190141911419214193141941419514196141971419814199142001420114202142031420414205142061420714208142091421014211142121421314214142151421614217142181421914220142211422214223142241422514226142271422814229142301423114232142331423414235142361423714238142391424014241142421424314244142451424614247142481424914250142511425214253142541425514256142571425814259142601426114262142631426414265142661426714268142691427014271142721427314274142751427614277142781427914280142811428214283142841428514286142871428814289142901429114292142931429414295142961429714298142991430014301143021430314304143051430614307143081430914310143111431214313143141431514316143171431814319143201432114322143231432414325143261432714328143291433014331143321433314334143351433614337143381433914340143411434214343143441434514346143471434814349143501435114352143531435414355143561435714358143591436014361143621436314364143651436614367143681436914370143711437214373143741437514376143771437814379143801438114382143831438414385143861438714388143891439014391143921439314394143951439614397143981439914400144011440214403144041440514406144071440814409144101441114412144131441414415144161441714418144191442014421144221442314424144251442614427144281442914430144311443214433144341443514436144371443814439144401444114442144431444414445144461444714448144491445014451144521445314454144551445614457144581445914460144611446214463144641446514466144671446814469144701447114472144731447414475144761447714478144791448014481144821448314484144851448614487144881448914490144911449214493144941449514496144971449814499145001450114502145031450414505145061450714508145091451014511145121451314514145151451614517145181451914520145211452214523145241452514526145271452814529145301453114532145331453414535145361453714538145391454014541145421454314544145451454614547145481454914550145511455214553145541455514556145571455814559145601456114562145631456414565145661456714568145691457014571145721457314574145751457614577145781457914580145811458214583145841458514586145871458814589145901459114592145931459414595145961459714598145991460014601146021460314604146051460614607146081460914610146111461214613146141461514616146171461814619146201462114622146231462414625146261462714628146291463014631146321463314634146351463614637146381463914640146411464214643146441464514646146471464814649146501465114652146531465414655146561465714658146591466014661146621466314664146651466614667146681466914670146711467214673146741467514676146771467814679146801468114682146831468414685146861468714688146891469014691146921469314694146951469614697146981469914700147011470214703147041470514706147071470814709147101471114712147131471414715147161471714718147191472014721147221472314724147251472614727147281472914730147311473214733147341473514736147371473814739147401474114742147431474414745147461474714748147491475014751147521475314754147551475614757147581475914760147611476214763147641476514766147671476814769147701477114772147731477414775147761477714778147791478014781147821478314784147851478614787147881478914790147911479214793147941479514796147971479814799148001480114802148031480414805148061480714808148091481014811148121481314814148151481614817148181481914820148211482214823148241482514826148271482814829148301483114832148331483414835148361483714838148391484014841148421484314844148451484614847148481484914850148511485214853148541485514856148571485814859148601486114862148631486414865148661486714868148691487014871148721487314874148751487614877148781487914880148811488214883148841488514886148871488814889148901489114892148931489414895148961489714898148991490014901149021490314904149051490614907149081490914910149111491214913149141491514916149171491814919149201492114922149231492414925149261492714928149291493014931149321493314934149351493614937149381493914940149411494214943149441494514946149471494814949149501495114952149531495414955149561495714958149591496014961149621496314964149651496614967149681496914970149711497214973149741497514976149771497814979149801498114982149831498414985149861498714988149891499014991149921499314994149951499614997149981499915000150011500215003150041500515006150071500815009150101501115012150131501415015150161501715018150191502015021150221502315024150251502615027150281502915030150311503215033150341503515036150371503815039150401504115042150431504415045150461504715048150491505015051150521505315054150551505615057150581505915060150611506215063150641506515066150671506815069150701507115072150731507415075150761507715078150791508015081150821508315084150851508615087150881508915090150911509215093150941509515096150971509815099151001510115102151031510415105151061510715108151091511015111151121511315114151151511615117151181511915120151211512215123151241512515126151271512815129151301513115132151331513415135151361513715138151391514015141151421514315144151451514615147151481514915150151511515215153151541515515156151571515815159151601516115162151631516415165151661516715168151691517015171151721517315174151751517615177151781517915180151811518215183151841518515186151871518815189151901519115192151931519415195151961519715198151991520015201152021520315204152051520615207152081520915210152111521215213152141521515216152171521815219152201522115222152231522415225152261522715228152291523015231152321523315234152351523615237152381523915240152411524215243152441524515246152471524815249152501525115252152531525415255152561525715258152591526015261152621526315264152651526615267152681526915270152711527215273152741527515276152771527815279152801528115282152831528415285152861528715288152891529015291152921529315294152951529615297152981529915300153011530215303153041530515306153071530815309153101531115312153131531415315153161531715318153191532015321153221532315324153251532615327153281532915330153311533215333153341533515336153371533815339153401534115342153431534415345153461534715348153491535015351153521535315354153551535615357153581535915360153611536215363153641536515366153671536815369153701537115372153731537415375153761537715378153791538015381153821538315384153851538615387153881538915390153911539215393153941539515396153971539815399154001540115402154031540415405154061540715408154091541015411154121541315414154151541615417154181541915420154211542215423154241542515426154271542815429154301543115432154331543415435154361543715438154391544015441154421544315444154451544615447154481544915450154511545215453154541545515456154571545815459154601546115462154631546415465154661546715468154691547015471154721547315474154751547615477154781547915480154811548215483154841548515486154871548815489154901549115492154931549415495154961549715498154991550015501155021550315504155051550615507155081550915510155111551215513155141551515516155171551815519155201552115522155231552415525155261552715528155291553015531155321553315534155351553615537155381553915540155411554215543155441554515546155471554815549155501555115552155531555415555155561555715558155591556015561155621556315564155651556615567155681556915570155711557215573155741557515576155771557815579155801558115582155831558415585155861558715588155891559015591155921559315594155951559615597155981559915600156011560215603156041560515606156071560815609156101561115612156131561415615156161561715618156191562015621156221562315624156251562615627156281562915630156311563215633156341563515636156371563815639156401564115642156431564415645156461564715648156491565015651156521565315654156551565615657156581565915660156611566215663156641566515666156671566815669156701567115672156731567415675156761567715678156791568015681156821568315684156851568615687156881568915690156911569215693156941569515696156971569815699157001570115702157031570415705157061570715708157091571015711157121571315714157151571615717157181571915720157211572215723157241572515726157271572815729157301573115732157331573415735157361573715738157391574015741157421574315744157451574615747157481574915750157511575215753157541575515756157571575815759157601576115762157631576415765157661576715768157691577015771157721577315774157751577615777157781577915780157811578215783157841578515786157871578815789157901579115792157931579415795157961579715798157991580015801158021580315804158051580615807158081580915810158111581215813158141581515816158171581815819158201582115822158231582415825158261582715828158291583015831158321583315834158351583615837158381583915840158411584215843158441584515846158471584815849158501585115852158531585415855158561585715858158591586015861158621586315864158651586615867158681586915870158711587215873158741587515876158771587815879158801588115882158831588415885158861588715888158891589015891158921589315894158951589615897158981589915900159011590215903159041590515906159071590815909159101591115912159131591415915159161591715918159191592015921159221592315924159251592615927159281592915930159311593215933159341593515936159371593815939159401594115942159431594415945159461594715948159491595015951159521595315954159551595615957159581595915960159611596215963159641596515966159671596815969159701597115972159731597415975159761597715978159791598015981159821598315984159851598615987159881598915990159911599215993159941599515996159971599815999160001600116002160031600416005160061600716008160091601016011160121601316014160151601616017160181601916020160211602216023160241602516026160271602816029160301603116032160331603416035160361603716038160391604016041160421604316044160451604616047160481604916050160511605216053160541605516056160571605816059160601606116062160631606416065160661606716068160691607016071160721607316074160751607616077160781607916080160811608216083160841608516086160871608816089160901609116092160931609416095160961609716098160991610016101161021610316104161051610616107161081610916110161111611216113161141611516116161171611816119161201612116122161231612416125161261612716128161291613016131161321613316134161351613616137161381613916140161411614216143161441614516146161471614816149161501615116152161531615416155161561615716158161591616016161161621616316164161651616616167161681616916170161711617216173161741617516176161771617816179161801618116182161831618416185161861618716188161891619016191161921619316194161951619616197161981619916200162011620216203162041620516206162071620816209162101621116212162131621416215162161621716218162191622016221162221622316224162251622616227162281622916230162311623216233162341623516236162371623816239162401624116242162431624416245162461624716248162491625016251162521625316254162551625616257162581625916260162611626216263162641626516266162671626816269162701627116272162731627416275162761627716278162791628016281162821628316284162851628616287162881628916290162911629216293162941629516296162971629816299163001630116302163031630416305163061630716308163091631016311163121631316314163151631616317163181631916320163211632216323163241632516326163271632816329163301633116332163331633416335163361633716338163391634016341163421634316344163451634616347163481634916350163511635216353163541635516356163571635816359163601636116362163631636416365163661636716368163691637016371163721637316374163751637616377163781637916380163811638216383163841638516386163871638816389163901639116392163931639416395163961639716398163991640016401164021640316404164051640616407164081640916410164111641216413164141641516416164171641816419164201642116422164231642416425164261642716428164291643016431164321643316434164351643616437164381643916440164411644216443164441644516446164471644816449164501645116452164531645416455164561645716458164591646016461164621646316464164651646616467164681646916470164711647216473164741647516476164771647816479164801648116482164831648416485164861648716488164891649016491164921649316494164951649616497164981649916500165011650216503165041650516506165071650816509165101651116512165131651416515165161651716518165191652016521165221652316524165251652616527165281652916530165311653216533165341653516536165371653816539165401654116542165431654416545165461654716548165491655016551165521655316554165551655616557165581655916560165611656216563165641656516566165671656816569165701657116572165731657416575165761657716578165791658016581165821658316584165851658616587165881658916590165911659216593165941659516596165971659816599166001660116602166031660416605166061660716608166091661016611166121661316614166151661616617166181661916620166211662216623166241662516626166271662816629166301663116632166331663416635166361663716638166391664016641166421664316644166451664616647166481664916650166511665216653166541665516656166571665816659166601666116662166631666416665166661666716668166691667016671166721667316674166751667616677166781667916680166811668216683166841668516686166871668816689166901669116692166931669416695166961669716698166991670016701167021670316704167051670616707167081670916710167111671216713167141671516716167171671816719167201672116722167231672416725167261672716728167291673016731167321673316734167351673616737167381673916740167411674216743167441674516746167471674816749167501675116752167531675416755167561675716758167591676016761167621676316764167651676616767167681676916770167711677216773167741677516776167771677816779167801678116782167831678416785167861678716788167891679016791167921679316794167951679616797167981679916800168011680216803168041680516806168071680816809168101681116812168131681416815168161681716818168191682016821168221682316824168251682616827168281682916830168311683216833168341683516836168371683816839168401684116842168431684416845168461684716848168491685016851168521685316854168551685616857168581685916860168611686216863168641686516866168671686816869168701687116872168731687416875168761687716878168791688016881168821688316884168851688616887168881688916890168911689216893168941689516896168971689816899169001690116902169031690416905169061690716908169091691016911169121691316914169151691616917169181691916920169211692216923169241692516926169271692816929169301693116932169331693416935169361693716938169391694016941169421694316944169451694616947169481694916950169511695216953169541695516956169571695816959169601696116962169631696416965169661696716968169691697016971169721697316974169751697616977169781697916980169811698216983169841698516986169871698816989169901699116992169931699416995169961699716998169991700017001170021700317004170051700617007170081700917010170111701217013170141701517016170171701817019170201702117022170231702417025170261702717028170291703017031170321703317034170351703617037170381703917040170411704217043170441704517046170471704817049170501705117052170531705417055170561705717058170591706017061170621706317064170651706617067170681706917070170711707217073170741707517076170771707817079170801708117082170831708417085170861708717088170891709017091170921709317094170951709617097170981709917100171011710217103171041710517106171071710817109171101711117112171131711417115171161711717118171191712017121171221712317124171251712617127171281712917130171311713217133171341713517136171371713817139171401714117142171431714417145171461714717148171491715017151171521715317154171551715617157171581715917160171611716217163171641716517166171671716817169171701717117172171731717417175171761717717178171791718017181171821718317184171851718617187171881718917190171911719217193171941719517196171971719817199172001720117202172031720417205172061720717208172091721017211172121721317214172151721617217172181721917220172211722217223172241722517226172271722817229172301723117232172331723417235172361723717238172391724017241172421724317244172451724617247172481724917250172511725217253172541725517256172571725817259172601726117262172631726417265172661726717268172691727017271172721727317274172751727617277172781727917280172811728217283172841728517286172871728817289172901729117292172931729417295172961729717298172991730017301173021730317304173051730617307173081730917310173111731217313173141731517316173171731817319173201732117322173231732417325173261732717328173291733017331173321733317334173351733617337173381733917340173411734217343173441734517346173471734817349173501735117352173531735417355173561735717358173591736017361173621736317364173651736617367173681736917370173711737217373173741737517376173771737817379173801738117382173831738417385173861738717388173891739017391173921739317394173951739617397173981739917400174011740217403174041740517406174071740817409174101741117412174131741417415174161741717418174191742017421174221742317424174251742617427174281742917430174311743217433174341743517436174371743817439174401744117442174431744417445174461744717448174491745017451174521745317454174551745617457174581745917460174611746217463174641746517466174671746817469174701747117472174731747417475174761747717478174791748017481174821748317484174851748617487174881748917490174911749217493174941749517496174971749817499175001750117502175031750417505175061750717508175091751017511175121751317514175151751617517175181751917520175211752217523175241752517526175271752817529175301753117532175331753417535175361753717538175391754017541175421754317544175451754617547175481754917550175511755217553175541755517556175571755817559175601756117562175631756417565175661756717568175691757017571175721757317574175751757617577175781757917580175811758217583175841758517586175871758817589175901759117592175931759417595175961759717598175991760017601176021760317604176051760617607176081760917610176111761217613176141761517616176171761817619176201762117622176231762417625176261762717628176291763017631176321763317634176351763617637176381763917640176411764217643176441764517646176471764817649176501765117652176531765417655176561765717658176591766017661176621766317664176651766617667176681766917670176711767217673176741767517676176771767817679176801768117682176831768417685176861768717688176891769017691176921769317694176951769617697176981769917700177011770217703177041770517706177071770817709177101771117712177131771417715177161771717718177191772017721177221772317724177251772617727177281772917730177311773217733177341773517736177371773817739177401774117742177431774417745177461774717748177491775017751177521775317754177551775617757177581775917760177611776217763177641776517766177671776817769177701777117772177731777417775177761777717778177791778017781177821778317784177851778617787177881778917790177911779217793177941779517796177971779817799178001780117802178031780417805178061780717808178091781017811178121781317814178151781617817178181781917820178211782217823178241782517826178271782817829178301783117832178331783417835178361783717838178391784017841178421784317844178451784617847178481784917850178511785217853178541785517856178571785817859178601786117862178631786417865178661786717868178691787017871178721787317874178751787617877178781787917880178811788217883178841788517886178871788817889178901789117892178931789417895178961789717898178991790017901179021790317904179051790617907179081790917910179111791217913179141791517916179171791817919179201792117922179231792417925179261792717928179291793017931179321793317934179351793617937179381793917940179411794217943179441794517946179471794817949179501795117952179531795417955179561795717958179591796017961179621796317964179651796617967179681796917970179711797217973179741797517976179771797817979179801798117982179831798417985179861798717988179891799017991179921799317994179951799617997179981799918000180011800218003180041800518006180071800818009180101801118012180131801418015180161801718018180191802018021180221802318024180251802618027180281802918030180311803218033180341803518036180371803818039180401804118042180431804418045180461804718048180491805018051180521805318054180551805618057180581805918060180611806218063180641806518066180671806818069180701807118072180731807418075180761807718078180791808018081180821808318084180851808618087180881808918090180911809218093180941809518096180971809818099181001810118102181031810418105181061810718108181091811018111181121811318114181151811618117181181811918120181211812218123181241812518126181271812818129181301813118132181331813418135181361813718138181391814018141181421814318144181451814618147181481814918150181511815218153181541815518156181571815818159181601816118162181631816418165181661816718168181691817018171181721817318174181751817618177181781817918180181811818218183181841818518186181871818818189181901819118192181931819418195181961819718198181991820018201182021820318204182051820618207182081820918210182111821218213182141821518216182171821818219182201822118222182231822418225182261822718228182291823018231182321823318234182351823618237182381823918240182411824218243182441824518246182471824818249182501825118252182531825418255182561825718258182591826018261182621826318264182651826618267182681826918270182711827218273182741827518276182771827818279182801828118282182831828418285182861828718288182891829018291182921829318294182951829618297182981829918300183011830218303183041830518306183071830818309183101831118312183131831418315183161831718318183191832018321183221832318324183251832618327183281832918330183311833218333183341833518336183371833818339183401834118342183431834418345183461834718348183491835018351183521835318354183551835618357183581835918360183611836218363183641836518366183671836818369183701837118372183731837418375183761837718378183791838018381183821838318384183851838618387183881838918390183911839218393183941839518396183971839818399184001840118402184031840418405184061840718408184091841018411184121841318414184151841618417184181841918420184211842218423184241842518426184271842818429184301843118432184331843418435184361843718438184391844018441184421844318444184451844618447184481844918450184511845218453184541845518456184571845818459184601846118462184631846418465184661846718468184691847018471184721847318474184751847618477184781847918480184811848218483184841848518486184871848818489184901849118492184931849418495184961849718498184991850018501185021850318504185051850618507185081850918510185111851218513185141851518516185171851818519185201852118522185231852418525185261852718528185291853018531185321853318534185351853618537185381853918540185411854218543185441854518546185471854818549185501855118552185531855418555185561855718558185591856018561185621856318564185651856618567185681856918570185711857218573185741857518576185771857818579185801858118582185831858418585185861858718588185891859018591185921859318594185951859618597185981859918600186011860218603186041860518606186071860818609186101861118612186131861418615186161861718618186191862018621186221862318624186251862618627186281862918630186311863218633186341863518636186371863818639186401864118642186431864418645186461864718648186491865018651186521865318654186551865618657186581865918660186611866218663186641866518666186671866818669186701867118672186731867418675186761867718678186791868018681186821868318684186851868618687186881868918690186911869218693186941869518696186971869818699187001870118702187031870418705187061870718708187091871018711187121871318714187151871618717187181871918720187211872218723187241872518726187271872818729187301873118732187331873418735187361873718738187391874018741187421874318744187451874618747187481874918750187511875218753187541875518756187571875818759187601876118762187631876418765187661876718768187691877018771187721877318774187751877618777187781877918780187811878218783187841878518786187871878818789187901879118792187931879418795187961879718798187991880018801188021880318804188051880618807188081880918810188111881218813188141881518816188171881818819188201882118822188231882418825188261882718828188291883018831188321883318834188351883618837188381883918840188411884218843188441884518846188471884818849188501885118852188531885418855188561885718858188591886018861188621886318864188651886618867188681886918870188711887218873188741887518876188771887818879188801888118882188831888418885188861888718888188891889018891188921889318894188951889618897188981889918900189011890218903189041890518906189071890818909189101891118912189131891418915189161891718918189191892018921189221892318924189251892618927189281892918930189311893218933189341893518936189371893818939189401894118942189431894418945189461894718948189491895018951189521895318954189551895618957189581895918960189611896218963189641896518966189671896818969189701897118972189731897418975189761897718978189791898018981189821898318984189851898618987189881898918990189911899218993189941899518996189971899818999190001900119002190031900419005190061900719008190091901019011190121901319014190151901619017190181901919020190211902219023190241902519026190271902819029190301903119032190331903419035190361903719038190391904019041190421904319044190451904619047190481904919050190511905219053190541905519056190571905819059190601906119062190631906419065190661906719068190691907019071190721907319074190751907619077190781907919080190811908219083190841908519086190871908819089190901909119092190931909419095190961909719098190991910019101191021910319104191051910619107191081910919110191111911219113191141911519116191171911819119191201912119122191231912419125191261912719128191291913019131191321913319134191351913619137191381913919140191411914219143191441914519146191471914819149191501915119152191531915419155191561915719158191591916019161191621916319164191651916619167191681916919170191711917219173191741917519176191771917819179191801918119182191831918419185191861918719188191891919019191191921919319194191951919619197191981919919200192011920219203192041920519206192071920819209192101921119212192131921419215192161921719218192191922019221192221922319224192251922619227192281922919230192311923219233192341923519236192371923819239192401924119242192431924419245192461924719248192491925019251192521925319254192551925619257192581925919260192611926219263192641926519266192671926819269192701927119272192731927419275192761927719278192791928019281192821928319284192851928619287192881928919290192911929219293192941929519296192971929819299193001930119302193031930419305193061930719308193091931019311193121931319314193151931619317193181931919320193211932219323193241932519326193271932819329193301933119332193331933419335193361933719338193391934019341193421934319344193451934619347193481934919350193511935219353193541935519356193571935819359193601936119362193631936419365193661936719368193691937019371193721937319374193751937619377193781937919380193811938219383193841938519386193871938819389193901939119392193931939419395193961939719398193991940019401194021940319404194051940619407194081940919410194111941219413194141941519416194171941819419194201942119422194231942419425194261942719428194291943019431194321943319434194351943619437194381943919440194411944219443194441944519446194471944819449194501945119452194531945419455194561945719458194591946019461194621946319464194651946619467194681946919470194711947219473194741947519476194771947819479194801948119482194831948419485194861948719488194891949019491194921949319494194951949619497194981949919500195011950219503195041950519506195071950819509195101951119512195131951419515195161951719518195191952019521195221952319524195251952619527195281952919530195311953219533195341953519536195371953819539195401954119542195431954419545195461954719548195491955019551195521955319554195551955619557195581955919560195611956219563195641956519566195671956819569195701957119572195731957419575195761957719578195791958019581195821958319584195851958619587195881958919590195911959219593195941959519596195971959819599196001960119602196031960419605196061960719608196091961019611196121961319614196151961619617196181961919620196211962219623196241962519626196271962819629196301963119632196331963419635196361963719638196391964019641196421964319644196451964619647196481964919650196511965219653196541965519656196571965819659196601966119662196631966419665196661966719668196691967019671196721967319674196751967619677196781967919680196811968219683196841968519686196871968819689196901969119692196931969419695196961969719698196991970019701197021970319704197051970619707197081970919710197111971219713197141971519716197171971819719197201972119722197231972419725197261972719728197291973019731197321973319734197351973619737197381973919740197411974219743197441974519746197471974819749197501975119752197531975419755197561975719758197591976019761197621976319764197651976619767197681976919770197711977219773197741977519776197771977819779197801978119782197831978419785197861978719788197891979019791197921979319794197951979619797197981979919800198011980219803198041980519806198071980819809198101981119812198131981419815198161981719818198191982019821198221982319824198251982619827198281982919830198311983219833198341983519836198371983819839198401984119842198431984419845198461984719848198491985019851198521985319854198551985619857198581985919860198611986219863198641986519866198671986819869198701987119872198731987419875198761987719878198791988019881198821988319884198851988619887198881988919890198911989219893198941989519896198971989819899199001990119902199031990419905199061990719908199091991019911199121991319914199151991619917199181991919920199211992219923199241992519926199271992819929199301993119932199331993419935199361993719938199391994019941199421994319944199451994619947199481994919950199511995219953199541995519956199571995819959199601996119962199631996419965199661996719968199691997019971199721997319974199751997619977199781997919980199811998219983199841998519986199871998819989199901999119992199931999419995199961999719998199992000020001200022000320004200052000620007200082000920010200112001220013200142001520016200172001820019200202002120022200232002420025200262002720028200292003020031200322003320034200352003620037200382003920040200412004220043200442004520046200472004820049200502005120052200532005420055200562005720058200592006020061200622006320064200652006620067200682006920070200712007220073200742007520076200772007820079200802008120082200832008420085200862008720088200892009020091200922009320094200952009620097200982009920100201012010220103201042010520106201072010820109201102011120112201132011420115201162011720118201192012020121201222012320124201252012620127201282012920130201312013220133201342013520136201372013820139201402014120142201432014420145201462014720148201492015020151201522015320154201552015620157201582015920160201612016220163201642016520166201672016820169201702017120172201732017420175201762017720178201792018020181201822018320184201852018620187201882018920190201912019220193201942019520196201972019820199202002020120202202032020420205202062020720208202092021020211202122021320214202152021620217202182021920220202212022220223202242022520226202272022820229202302023120232202332023420235202362023720238202392024020241202422024320244202452024620247202482024920250202512025220253202542025520256202572025820259202602026120262202632026420265202662026720268202692027020271202722027320274202752027620277202782027920280202812028220283202842028520286202872028820289202902029120292202932029420295202962029720298202992030020301203022030320304203052030620307203082030920310203112031220313203142031520316203172031820319203202032120322203232032420325203262032720328203292033020331203322033320334203352033620337203382033920340203412034220343203442034520346203472034820349203502035120352203532035420355203562035720358203592036020361203622036320364203652036620367203682036920370203712037220373203742037520376203772037820379203802038120382203832038420385203862038720388203892039020391203922039320394203952039620397203982039920400204012040220403204042040520406204072040820409204102041120412204132041420415204162041720418204192042020421204222042320424204252042620427204282042920430204312043220433204342043520436204372043820439204402044120442204432044420445204462044720448204492045020451204522045320454204552045620457204582045920460204612046220463204642046520466204672046820469204702047120472204732047420475204762047720478204792048020481204822048320484204852048620487204882048920490204912049220493204942049520496204972049820499205002050120502205032050420505205062050720508205092051020511205122051320514205152051620517205182051920520205212052220523205242052520526205272052820529205302053120532205332053420535205362053720538205392054020541205422054320544205452054620547205482054920550205512055220553205542055520556205572055820559205602056120562205632056420565205662056720568205692057020571205722057320574205752057620577205782057920580205812058220583205842058520586205872058820589205902059120592205932059420595205962059720598205992060020601206022060320604206052060620607206082060920610206112061220613206142061520616206172061820619206202062120622206232062420625206262062720628206292063020631206322063320634206352063620637206382063920640206412064220643206442064520646206472064820649206502065120652206532065420655206562065720658206592066020661206622066320664206652066620667206682066920670206712067220673206742067520676206772067820679206802068120682206832068420685206862068720688206892069020691206922069320694206952069620697206982069920700207012070220703207042070520706207072070820709207102071120712207132071420715207162071720718207192072020721207222072320724207252072620727207282072920730207312073220733207342073520736207372073820739207402074120742207432074420745207462074720748207492075020751207522075320754207552075620757207582075920760207612076220763207642076520766207672076820769207702077120772207732077420775207762077720778207792078020781207822078320784207852078620787207882078920790207912079220793207942079520796207972079820799208002080120802208032080420805208062080720808208092081020811208122081320814208152081620817208182081920820208212082220823208242082520826208272082820829208302083120832208332083420835208362083720838208392084020841208422084320844208452084620847208482084920850208512085220853208542085520856208572085820859208602086120862208632086420865208662086720868208692087020871208722087320874208752087620877208782087920880208812088220883208842088520886208872088820889208902089120892208932089420895208962089720898208992090020901209022090320904209052090620907209082090920910209112091220913209142091520916209172091820919209202092120922209232092420925209262092720928209292093020931209322093320934209352093620937209382093920940209412094220943209442094520946209472094820949209502095120952209532095420955209562095720958209592096020961209622096320964209652096620967209682096920970209712097220973209742097520976209772097820979209802098120982209832098420985209862098720988209892099020991209922099320994209952099620997209982099921000210012100221003210042100521006210072100821009210102101121012210132101421015210162101721018210192102021021210222102321024210252102621027210282102921030210312103221033210342103521036210372103821039210402104121042210432104421045210462104721048210492105021051210522105321054210552105621057210582105921060210612106221063210642106521066210672106821069210702107121072210732107421075210762107721078210792108021081210822108321084210852108621087210882108921090210912109221093210942109521096210972109821099211002110121102211032110421105211062110721108211092111021111211122111321114211152111621117211182111921120211212112221123211242112521126211272112821129211302113121132211332113421135211362113721138211392114021141211422114321144211452114621147211482114921150211512115221153211542115521156211572115821159211602116121162211632116421165211662116721168211692117021171211722117321174211752117621177211782117921180211812118221183211842118521186211872118821189211902119121192211932119421195211962119721198211992120021201212022120321204212052120621207212082120921210212112121221213212142121521216212172121821219212202122121222212232122421225212262122721228212292123021231212322123321234212352123621237212382123921240212412124221243212442124521246212472124821249212502125121252212532125421255212562125721258212592126021261212622126321264212652126621267212682126921270212712127221273212742127521276212772127821279212802128121282212832128421285212862128721288212892129021291212922129321294212952129621297212982129921300213012130221303213042130521306213072130821309213102131121312213132131421315213162131721318213192132021321213222132321324213252132621327213282132921330213312133221333213342133521336213372133821339213402134121342213432134421345213462134721348213492135021351213522135321354213552135621357213582135921360213612136221363213642136521366213672136821369213702137121372213732137421375213762137721378213792138021381213822138321384213852138621387213882138921390213912139221393213942139521396213972139821399214002140121402214032140421405214062140721408214092141021411214122141321414214152141621417214182141921420214212142221423214242142521426214272142821429214302143121432214332143421435214362143721438214392144021441214422144321444214452144621447214482144921450214512145221453214542145521456214572145821459214602146121462214632146421465214662146721468214692147021471214722147321474214752147621477214782147921480214812148221483214842148521486214872148821489214902149121492214932149421495214962149721498214992150021501215022150321504215052150621507215082150921510215112151221513215142151521516215172151821519215202152121522215232152421525215262152721528215292153021531215322153321534215352153621537215382153921540215412154221543215442154521546215472154821549215502155121552215532155421555215562155721558215592156021561215622156321564215652156621567215682156921570215712157221573215742157521576215772157821579215802158121582215832158421585215862158721588215892159021591215922159321594215952159621597215982159921600216012160221603216042160521606216072160821609216102161121612216132161421615216162161721618216192162021621216222162321624216252162621627216282162921630216312163221633216342163521636216372163821639216402164121642216432164421645216462164721648216492165021651216522165321654216552165621657216582165921660216612166221663216642166521666216672166821669216702167121672216732167421675216762167721678216792168021681216822168321684216852168621687216882168921690216912169221693216942169521696216972169821699217002170121702217032170421705217062170721708217092171021711217122171321714217152171621717217182171921720217212172221723217242172521726217272172821729217302173121732217332173421735217362173721738217392174021741217422174321744217452174621747217482174921750217512175221753217542175521756217572175821759217602176121762217632176421765217662176721768217692177021771217722177321774217752177621777217782177921780217812178221783217842178521786217872178821789217902179121792217932179421795217962179721798217992180021801218022180321804218052180621807218082180921810218112181221813218142181521816218172181821819218202182121822218232182421825218262182721828218292183021831218322183321834218352183621837218382183921840218412184221843218442184521846218472184821849218502185121852218532185421855218562185721858218592186021861218622186321864218652186621867218682186921870218712187221873218742187521876218772187821879218802188121882218832188421885218862188721888218892189021891218922189321894218952189621897218982189921900219012190221903219042190521906219072190821909219102191121912219132191421915219162191721918219192192021921219222192321924219252192621927219282192921930219312193221933219342193521936219372193821939219402194121942219432194421945219462194721948219492195021951219522195321954219552195621957219582195921960219612196221963219642196521966219672196821969219702197121972219732197421975219762197721978219792198021981219822198321984219852198621987219882198921990219912199221993219942199521996219972199821999220002200122002220032200422005220062200722008220092201022011220122201322014220152201622017220182201922020220212202222023220242202522026220272202822029220302203122032220332203422035220362203722038220392204022041220422204322044220452204622047220482204922050220512205222053220542205522056220572205822059220602206122062220632206422065220662206722068220692207022071220722207322074220752207622077220782207922080220812208222083220842208522086220872208822089220902209122092220932209422095220962209722098220992210022101221022210322104221052210622107221082210922110221112211222113221142211522116221172211822119221202212122122221232212422125221262212722128221292213022131221322213322134221352213622137221382213922140221412214222143221442214522146221472214822149221502215122152221532215422155221562215722158221592216022161221622216322164221652216622167221682216922170221712217222173221742217522176221772217822179221802218122182221832218422185221862218722188221892219022191221922219322194221952219622197221982219922200222012220222203222042220522206222072220822209222102221122212222132221422215222162221722218222192222022221222222222322224222252222622227222282222922230222312223222233222342223522236222372223822239222402224122242222432224422245222462224722248222492225022251222522225322254222552225622257222582225922260222612226222263222642226522266222672226822269222702227122272222732227422275222762227722278222792228022281222822228322284222852228622287222882228922290222912229222293222942229522296222972229822299223002230122302223032230422305223062230722308223092231022311223122231322314223152231622317223182231922320223212232222323223242232522326223272232822329223302233122332223332233422335223362233722338223392234022341223422234322344223452234622347223482234922350223512235222353223542235522356223572235822359223602236122362223632236422365223662236722368223692237022371223722237322374223752237622377223782237922380223812238222383223842238522386223872238822389223902239122392223932239422395223962239722398223992240022401224022240322404224052240622407224082240922410224112241222413224142241522416224172241822419224202242122422224232242422425224262242722428224292243022431224322243322434224352243622437224382243922440224412244222443224442244522446224472244822449224502245122452224532245422455224562245722458224592246022461224622246322464224652246622467224682246922470224712247222473224742247522476224772247822479224802248122482224832248422485224862248722488224892249022491224922249322494224952249622497224982249922500225012250222503225042250522506225072250822509225102251122512225132251422515225162251722518225192252022521225222252322524225252252622527225282252922530225312253222533225342253522536225372253822539225402254122542225432254422545225462254722548225492255022551225522255322554225552255622557225582255922560225612256222563225642256522566225672256822569225702257122572225732257422575225762257722578225792258022581225822258322584225852258622587225882258922590225912259222593225942259522596225972259822599226002260122602226032260422605226062260722608226092261022611226122261322614226152261622617226182261922620226212262222623226242262522626226272262822629226302263122632226332263422635226362263722638226392264022641226422264322644226452264622647226482264922650226512265222653226542265522656226572265822659226602266122662226632266422665226662266722668226692267022671226722267322674226752267622677226782267922680226812268222683226842268522686226872268822689226902269122692226932269422695226962269722698226992270022701227022270322704227052270622707227082270922710227112271222713227142271522716227172271822719227202272122722227232272422725227262272722728227292273022731227322273322734227352273622737227382273922740227412274222743227442274522746227472274822749227502275122752227532275422755227562275722758227592276022761227622276322764227652276622767227682276922770227712277222773227742277522776227772277822779227802278122782227832278422785227862278722788227892279022791227922279322794227952279622797227982279922800228012280222803228042280522806228072280822809228102281122812228132281422815228162281722818228192282022821228222282322824228252282622827228282282922830228312283222833228342283522836228372283822839228402284122842228432284422845228462284722848228492285022851228522285322854228552285622857228582285922860228612286222863228642286522866228672286822869228702287122872228732287422875228762287722878228792288022881228822288322884228852288622887228882288922890228912289222893228942289522896228972289822899229002290122902229032290422905229062290722908229092291022911229122291322914229152291622917229182291922920229212292222923229242292522926229272292822929229302293122932229332293422935229362293722938229392294022941229422294322944229452294622947229482294922950229512295222953229542295522956229572295822959229602296122962229632296422965229662296722968229692297022971229722297322974229752297622977229782297922980229812298222983229842298522986229872298822989229902299122992229932299422995229962299722998229992300023001230022300323004230052300623007230082300923010230112301223013230142301523016230172301823019230202302123022230232302423025230262302723028230292303023031230322303323034230352303623037230382303923040230412304223043230442304523046230472304823049230502305123052230532305423055230562305723058230592306023061230622306323064230652306623067230682306923070230712307223073230742307523076230772307823079230802308123082230832308423085230862308723088230892309023091230922309323094230952309623097230982309923100231012310223103231042310523106231072310823109231102311123112231132311423115231162311723118231192312023121231222312323124231252312623127231282312923130231312313223133231342313523136231372313823139231402314123142231432314423145231462314723148231492315023151231522315323154231552315623157231582315923160231612316223163231642316523166231672316823169231702317123172231732317423175231762317723178231792318023181231822318323184231852318623187231882318923190231912319223193231942319523196231972319823199232002320123202232032320423205232062320723208232092321023211232122321323214232152321623217232182321923220232212322223223232242322523226232272322823229232302323123232232332323423235232362323723238232392324023241232422324323244232452324623247232482324923250232512325223253232542325523256232572325823259232602326123262232632326423265232662326723268232692327023271232722327323274232752327623277232782327923280232812328223283232842328523286232872328823289232902329123292232932329423295232962329723298232992330023301233022330323304233052330623307233082330923310233112331223313233142331523316233172331823319233202332123322233232332423325233262332723328233292333023331233322333323334233352333623337233382333923340233412334223343233442334523346233472334823349233502335123352233532335423355233562335723358233592336023361233622336323364233652336623367233682336923370233712337223373233742337523376233772337823379233802338123382233832338423385233862338723388233892339023391233922339323394233952339623397233982339923400234012340223403234042340523406234072340823409234102341123412234132341423415234162341723418234192342023421234222342323424234252342623427234282342923430234312343223433234342343523436234372343823439234402344123442234432344423445234462344723448234492345023451234522345323454234552345623457234582345923460234612346223463234642346523466234672346823469234702347123472234732347423475234762347723478234792348023481234822348323484234852348623487234882348923490234912349223493234942349523496234972349823499235002350123502235032350423505235062350723508235092351023511235122351323514235152351623517235182351923520235212352223523235242352523526235272352823529235302353123532235332353423535235362353723538235392354023541235422354323544235452354623547235482354923550235512355223553235542355523556235572355823559235602356123562235632356423565235662356723568235692357023571235722357323574235752357623577235782357923580235812358223583235842358523586235872358823589235902359123592235932359423595235962359723598235992360023601236022360323604236052360623607236082360923610236112361223613236142361523616236172361823619236202362123622236232362423625236262362723628236292363023631236322363323634236352363623637236382363923640236412364223643236442364523646236472364823649236502365123652236532365423655236562365723658236592366023661236622366323664236652366623667236682366923670236712367223673236742367523676236772367823679236802368123682236832368423685236862368723688236892369023691236922369323694236952369623697236982369923700237012370223703237042370523706237072370823709237102371123712237132371423715237162371723718237192372023721237222372323724237252372623727237282372923730237312373223733237342373523736237372373823739237402374123742237432374423745237462374723748237492375023751237522375323754237552375623757237582375923760237612376223763237642376523766237672376823769237702377123772237732377423775237762377723778237792378023781237822378323784237852378623787237882378923790237912379223793237942379523796237972379823799238002380123802238032380423805238062380723808238092381023811238122381323814238152381623817238182381923820238212382223823238242382523826238272382823829238302383123832238332383423835238362383723838238392384023841238422384323844238452384623847238482384923850238512385223853238542385523856238572385823859238602386123862238632386423865238662386723868238692387023871238722387323874238752387623877238782387923880238812388223883238842388523886238872388823889238902389123892238932389423895238962389723898238992390023901239022390323904239052390623907239082390923910239112391223913239142391523916239172391823919239202392123922239232392423925239262392723928239292393023931239322393323934239352393623937239382393923940239412394223943239442394523946239472394823949239502395123952239532395423955239562395723958239592396023961239622396323964239652396623967239682396923970239712397223973239742397523976239772397823979239802398123982239832398423985239862398723988239892399023991239922399323994239952399623997239982399924000240012400224003240042400524006240072400824009240102401124012240132401424015240162401724018240192402024021240222402324024240252402624027240282402924030240312403224033240342403524036240372403824039240402404124042240432404424045240462404724048240492405024051240522405324054240552405624057240582405924060240612406224063240642406524066240672406824069240702407124072240732407424075240762407724078240792408024081240822408324084240852408624087240882408924090240912409224093240942409524096240972409824099241002410124102241032410424105241062410724108241092411024111241122411324114241152411624117241182411924120241212412224123241242412524126241272412824129241302413124132241332413424135241362413724138241392414024141241422414324144241452414624147241482414924150241512415224153241542415524156241572415824159241602416124162241632416424165241662416724168241692417024171241722417324174241752417624177241782417924180241812418224183241842418524186241872418824189241902419124192241932419424195241962419724198241992420024201242022420324204242052420624207242082420924210242112421224213242142421524216242172421824219242202422124222242232422424225242262422724228242292423024231242322423324234242352423624237242382423924240242412424224243242442424524246242472424824249242502425124252242532425424255242562425724258242592426024261242622426324264242652426624267242682426924270242712427224273242742427524276242772427824279242802428124282242832428424285242862428724288242892429024291242922429324294242952429624297242982429924300243012430224303243042430524306243072430824309243102431124312243132431424315243162431724318243192432024321243222432324324243252432624327243282432924330243312433224333243342433524336243372433824339243402434124342243432434424345243462434724348243492435024351243522435324354243552435624357243582435924360243612436224363243642436524366243672436824369243702437124372243732437424375243762437724378243792438024381243822438324384243852438624387243882438924390243912439224393243942439524396243972439824399244002440124402244032440424405244062440724408244092441024411244122441324414244152441624417244182441924420244212442224423244242442524426244272442824429244302443124432244332443424435244362443724438244392444024441244422444324444244452444624447244482444924450244512445224453244542445524456244572445824459244602446124462244632446424465244662446724468244692447024471244722447324474244752447624477244782447924480244812448224483244842448524486244872448824489244902449124492244932449424495244962449724498244992450024501245022450324504245052450624507245082450924510245112451224513245142451524516245172451824519245202452124522245232452424525245262452724528245292453024531245322453324534245352453624537245382453924540245412454224543245442454524546245472454824549245502455124552245532455424555245562455724558245592456024561245622456324564245652456624567245682456924570245712457224573245742457524576245772457824579245802458124582245832458424585245862458724588245892459024591245922459324594245952459624597245982459924600246012460224603246042460524606246072460824609246102461124612246132461424615246162461724618246192462024621246222462324624246252462624627246282462924630246312463224633246342463524636246372463824639246402464124642246432464424645246462464724648246492465024651246522465324654246552465624657246582465924660246612466224663246642466524666246672466824669246702467124672246732467424675246762467724678246792468024681246822468324684246852468624687246882468924690246912469224693246942469524696246972469824699247002470124702247032470424705247062470724708247092471024711247122471324714247152471624717247182471924720247212472224723247242472524726247272472824729247302473124732247332473424735247362473724738247392474024741247422474324744247452474624747247482474924750247512475224753247542475524756247572475824759247602476124762247632476424765247662476724768247692477024771247722477324774247752477624777247782477924780247812478224783247842478524786247872478824789247902479124792247932479424795247962479724798247992480024801248022480324804248052480624807248082480924810248112481224813248142481524816248172481824819248202482124822248232482424825248262482724828248292483024831248322483324834248352483624837248382483924840248412484224843248442484524846248472484824849248502485124852248532485424855248562485724858248592486024861248622486324864248652486624867248682486924870248712487224873248742487524876248772487824879248802488124882248832488424885248862488724888248892489024891248922489324894248952489624897248982489924900249012490224903249042490524906249072490824909249102491124912249132491424915249162491724918249192492024921249222492324924249252492624927249282492924930249312493224933249342493524936249372493824939249402494124942249432494424945249462494724948249492495024951249522495324954249552495624957249582495924960249612496224963249642496524966249672496824969249702497124972249732497424975249762497724978249792498024981249822498324984249852498624987249882498924990249912499224993249942499524996249972499824999250002500125002250032500425005250062500725008250092501025011250122501325014250152501625017250182501925020250212502225023250242502525026250272502825029250302503125032250332503425035250362503725038250392504025041250422504325044250452504625047250482504925050250512505225053250542505525056250572505825059250602506125062250632506425065250662506725068250692507025071250722507325074250752507625077250782507925080250812508225083250842508525086250872508825089250902509125092250932509425095250962509725098250992510025101251022510325104251052510625107251082510925110251112511225113251142511525116251172511825119251202512125122251232512425125251262512725128251292513025131251322513325134251352513625137251382513925140251412514225143251442514525146251472514825149251502515125152251532515425155251562515725158251592516025161251622516325164251652516625167251682516925170251712517225173251742517525176251772517825179251802518125182251832518425185251862518725188251892519025191251922519325194251952519625197251982519925200252012520225203252042520525206252072520825209252102521125212252132521425215252162521725218252192522025221252222522325224252252522625227252282522925230252312523225233252342523525236252372523825239252402524125242252432524425245252462524725248252492525025251252522525325254252552525625257252582525925260252612526225263252642526525266252672526825269252702527125272252732527425275252762527725278252792528025281252822528325284252852528625287252882528925290252912529225293252942529525296252972529825299253002530125302253032530425305253062530725308253092531025311253122531325314253152531625317253182531925320253212532225323253242532525326253272532825329253302533125332253332533425335253362533725338253392534025341253422534325344253452534625347253482534925350253512535225353253542535525356253572535825359253602536125362253632536425365253662536725368253692537025371253722537325374253752537625377253782537925380253812538225383253842538525386253872538825389253902539125392253932539425395253962539725398253992540025401254022540325404254052540625407254082540925410254112541225413254142541525416254172541825419254202542125422254232542425425254262542725428254292543025431254322543325434254352543625437254382543925440254412544225443254442544525446254472544825449254502545125452254532545425455254562545725458254592546025461254622546325464254652546625467254682546925470254712547225473254742547525476254772547825479254802548125482254832548425485254862548725488254892549025491254922549325494254952549625497254982549925500255012550225503255042550525506255072550825509255102551125512255132551425515255162551725518255192552025521255222552325524255252552625527255282552925530255312553225533255342553525536255372553825539255402554125542255432554425545255462554725548255492555025551255522555325554255552555625557255582555925560255612556225563255642556525566255672556825569255702557125572255732557425575255762557725578255792558025581255822558325584255852558625587255882558925590255912559225593255942559525596255972559825599256002560125602256032560425605256062560725608256092561025611256122561325614256152561625617256182561925620256212562225623256242562525626256272562825629256302563125632256332563425635256362563725638256392564025641256422564325644256452564625647256482564925650256512565225653256542565525656256572565825659256602566125662256632566425665256662566725668256692567025671256722567325674256752567625677256782567925680256812568225683256842568525686256872568825689256902569125692256932569425695256962569725698256992570025701257022570325704257052570625707257082570925710257112571225713257142571525716257172571825719257202572125722257232572425725257262572725728257292573025731257322573325734257352573625737257382573925740257412574225743257442574525746257472574825749257502575125752257532575425755257562575725758257592576025761257622576325764257652576625767257682576925770257712577225773257742577525776257772577825779257802578125782257832578425785257862578725788257892579025791257922579325794257952579625797257982579925800258012580225803258042580525806258072580825809258102581125812258132581425815258162581725818258192582025821258222582325824258252582625827258282582925830258312583225833258342583525836258372583825839258402584125842258432584425845258462584725848258492585025851258522585325854258552585625857258582585925860258612586225863258642586525866258672586825869258702587125872258732587425875258762587725878258792588025881258822588325884258852588625887258882588925890258912589225893258942589525896258972589825899259002590125902259032590425905259062590725908259092591025911259122591325914259152591625917259182591925920259212592225923259242592525926259272592825929259302593125932259332593425935259362593725938259392594025941259422594325944259452594625947259482594925950259512595225953259542595525956259572595825959259602596125962259632596425965259662596725968259692597025971259722597325974259752597625977259782597925980259812598225983259842598525986259872598825989259902599125992259932599425995259962599725998259992600026001260022600326004260052600626007260082600926010260112601226013260142601526016260172601826019260202602126022260232602426025260262602726028260292603026031260322603326034260352603626037260382603926040260412604226043260442604526046260472604826049260502605126052260532605426055260562605726058260592606026061260622606326064260652606626067260682606926070260712607226073260742607526076260772607826079260802608126082260832608426085260862608726088260892609026091260922609326094260952609626097260982609926100261012610226103261042610526106261072610826109261102611126112261132611426115261162611726118261192612026121261222612326124261252612626127261282612926130261312613226133261342613526136261372613826139261402614126142261432614426145261462614726148261492615026151261522615326154261552615626157261582615926160261612616226163261642616526166261672616826169261702617126172261732617426175261762617726178261792618026181261822618326184261852618626187261882618926190261912619226193261942619526196261972619826199262002620126202262032620426205262062620726208262092621026211262122621326214262152621626217262182621926220262212622226223262242622526226262272622826229262302623126232262332623426235262362623726238262392624026241262422624326244262452624626247262482624926250262512625226253262542625526256262572625826259262602626126262262632626426265262662626726268262692627026271262722627326274262752627626277262782627926280262812628226283262842628526286262872628826289262902629126292262932629426295262962629726298262992630026301263022630326304263052630626307263082630926310263112631226313263142631526316263172631826319263202632126322263232632426325263262632726328263292633026331263322633326334263352633626337263382633926340263412634226343263442634526346263472634826349263502635126352263532635426355263562635726358263592636026361263622636326364263652636626367263682636926370263712637226373263742637526376263772637826379263802638126382263832638426385263862638726388263892639026391263922639326394263952639626397263982639926400264012640226403264042640526406264072640826409264102641126412264132641426415264162641726418264192642026421264222642326424264252642626427264282642926430264312643226433264342643526436264372643826439264402644126442264432644426445264462644726448264492645026451264522645326454264552645626457264582645926460264612646226463264642646526466264672646826469264702647126472264732647426475264762647726478264792648026481264822648326484264852648626487264882648926490264912649226493264942649526496264972649826499265002650126502265032650426505265062650726508265092651026511265122651326514265152651626517265182651926520265212652226523265242652526526265272652826529265302653126532265332653426535265362653726538265392654026541265422654326544265452654626547265482654926550265512655226553265542655526556265572655826559265602656126562265632656426565265662656726568265692657026571265722657326574265752657626577265782657926580265812658226583265842658526586265872658826589265902659126592265932659426595265962659726598265992660026601266022660326604266052660626607266082660926610266112661226613266142661526616266172661826619266202662126622266232662426625266262662726628266292663026631266322663326634266352663626637266382663926640266412664226643266442664526646266472664826649266502665126652266532665426655266562665726658266592666026661266622666326664266652666626667266682666926670266712667226673266742667526676266772667826679266802668126682266832668426685266862668726688266892669026691266922669326694266952669626697266982669926700267012670226703267042670526706267072670826709267102671126712267132671426715267162671726718267192672026721267222672326724267252672626727267282672926730267312673226733267342673526736267372673826739267402674126742267432674426745267462674726748267492675026751267522675326754267552675626757267582675926760267612676226763267642676526766267672676826769267702677126772267732677426775267762677726778267792678026781267822678326784267852678626787267882678926790267912679226793267942679526796267972679826799268002680126802268032680426805268062680726808268092681026811268122681326814268152681626817268182681926820268212682226823268242682526826268272682826829268302683126832268332683426835268362683726838268392684026841268422684326844268452684626847268482684926850268512685226853268542685526856268572685826859268602686126862268632686426865268662686726868268692687026871268722687326874268752687626877268782687926880268812688226883268842688526886268872688826889268902689126892268932689426895268962689726898268992690026901269022690326904269052690626907269082690926910269112691226913269142691526916269172691826919269202692126922269232692426925269262692726928269292693026931269322693326934269352693626937269382693926940269412694226943269442694526946269472694826949269502695126952269532695426955269562695726958269592696026961269622696326964269652696626967269682696926970269712697226973269742697526976269772697826979269802698126982269832698426985269862698726988269892699026991269922699326994269952699626997269982699927000270012700227003270042700527006270072700827009270102701127012270132701427015270162701727018270192702027021270222702327024270252702627027270282702927030270312703227033270342703527036270372703827039270402704127042270432704427045270462704727048270492705027051270522705327054270552705627057270582705927060270612706227063270642706527066270672706827069270702707127072270732707427075270762707727078270792708027081270822708327084270852708627087270882708927090270912709227093270942709527096270972709827099271002710127102271032710427105271062710727108271092711027111271122711327114271152711627117271182711927120271212712227123271242712527126271272712827129271302713127132271332713427135271362713727138271392714027141271422714327144271452714627147271482714927150271512715227153271542715527156271572715827159271602716127162271632716427165271662716727168271692717027171271722717327174271752717627177271782717927180271812718227183271842718527186271872718827189271902719127192271932719427195271962719727198271992720027201272022720327204272052720627207272082720927210272112721227213272142721527216272172721827219272202722127222272232722427225272262722727228272292723027231272322723327234272352723627237272382723927240272412724227243272442724527246272472724827249272502725127252272532725427255272562725727258272592726027261272622726327264272652726627267272682726927270272712727227273272742727527276272772727827279272802728127282272832728427285272862728727288272892729027291272922729327294272952729627297272982729927300273012730227303273042730527306273072730827309273102731127312273132731427315273162731727318273192732027321273222732327324273252732627327273282732927330273312733227333273342733527336273372733827339273402734127342273432734427345273462734727348273492735027351273522735327354273552735627357273582735927360273612736227363273642736527366273672736827369273702737127372273732737427375273762737727378273792738027381273822738327384273852738627387273882738927390273912739227393273942739527396273972739827399274002740127402274032740427405274062740727408274092741027411274122741327414274152741627417274182741927420274212742227423274242742527426274272742827429274302743127432274332743427435274362743727438274392744027441274422744327444274452744627447274482744927450274512745227453274542745527456274572745827459274602746127462274632746427465274662746727468274692747027471274722747327474274752747627477274782747927480274812748227483274842748527486274872748827489274902749127492274932749427495274962749727498274992750027501275022750327504275052750627507275082750927510275112751227513275142751527516275172751827519275202752127522275232752427525275262752727528275292753027531275322753327534275352753627537275382753927540275412754227543275442754527546275472754827549275502755127552275532755427555275562755727558275592756027561275622756327564275652756627567275682756927570275712757227573275742757527576275772757827579275802758127582275832758427585275862758727588275892759027591275922759327594275952759627597275982759927600276012760227603276042760527606276072760827609276102761127612276132761427615276162761727618276192762027621276222762327624276252762627627276282762927630276312763227633276342763527636276372763827639276402764127642276432764427645276462764727648276492765027651276522765327654276552765627657276582765927660276612766227663276642766527666276672766827669276702767127672276732767427675276762767727678276792768027681276822768327684276852768627687276882768927690276912769227693276942769527696276972769827699277002770127702277032770427705277062770727708277092771027711277122771327714277152771627717277182771927720277212772227723277242772527726277272772827729277302773127732277332773427735277362773727738277392774027741277422774327744277452774627747277482774927750277512775227753277542775527756277572775827759277602776127762277632776427765277662776727768277692777027771277722777327774277752777627777277782777927780277812778227783277842778527786277872778827789277902779127792277932779427795277962779727798277992780027801278022780327804278052780627807278082780927810278112781227813278142781527816278172781827819278202782127822278232782427825278262782727828278292783027831278322783327834278352783627837278382783927840278412784227843278442784527846278472784827849278502785127852278532785427855278562785727858278592786027861278622786327864278652786627867278682786927870278712787227873278742787527876278772787827879278802788127882278832788427885278862788727888278892789027891278922789327894278952789627897278982789927900279012790227903279042790527906279072790827909279102791127912279132791427915279162791727918279192792027921279222792327924279252792627927279282792927930279312793227933279342793527936279372793827939279402794127942279432794427945279462794727948279492795027951279522795327954279552795627957279582795927960279612796227963279642796527966279672796827969279702797127972279732797427975279762797727978279792798027981279822798327984279852798627987279882798927990279912799227993279942799527996279972799827999280002800128002280032800428005280062800728008280092801028011280122801328014280152801628017280182801928020280212802228023280242802528026280272802828029280302803128032280332803428035280362803728038280392804028041280422804328044280452804628047280482804928050280512805228053280542805528056280572805828059280602806128062280632806428065280662806728068280692807028071280722807328074280752807628077280782807928080280812808228083280842808528086280872808828089280902809128092280932809428095280962809728098280992810028101281022810328104281052810628107281082810928110281112811228113281142811528116281172811828119281202812128122281232812428125281262812728128281292813028131281322813328134281352813628137281382813928140281412814228143281442814528146281472814828149281502815128152281532815428155281562815728158281592816028161281622816328164281652816628167281682816928170281712817228173281742817528176281772817828179281802818128182281832818428185281862818728188281892819028191281922819328194281952819628197281982819928200282012820228203282042820528206282072820828209282102821128212282132821428215282162821728218282192822028221282222822328224282252822628227282282822928230282312823228233282342823528236282372823828239282402824128242282432824428245282462824728248282492825028251282522825328254282552825628257282582825928260282612826228263282642826528266282672826828269282702827128272282732827428275282762827728278282792828028281282822828328284282852828628287282882828928290282912829228293282942829528296282972829828299283002830128302283032830428305283062830728308283092831028311283122831328314283152831628317283182831928320283212832228323283242832528326283272832828329283302833128332283332833428335283362833728338283392834028341283422834328344283452834628347283482834928350283512835228353283542835528356283572835828359283602836128362283632836428365283662836728368283692837028371283722837328374283752837628377283782837928380283812838228383283842838528386283872838828389283902839128392283932839428395283962839728398283992840028401284022840328404284052840628407284082840928410284112841228413284142841528416284172841828419284202842128422284232842428425284262842728428284292843028431284322843328434284352843628437284382843928440284412844228443284442844528446284472844828449284502845128452284532845428455284562845728458284592846028461284622846328464284652846628467284682846928470284712847228473284742847528476284772847828479284802848128482284832848428485284862848728488284892849028491284922849328494284952849628497284982849928500285012850228503285042850528506285072850828509285102851128512285132851428515285162851728518285192852028521285222852328524285252852628527285282852928530285312853228533285342853528536285372853828539285402854128542285432854428545285462854728548285492855028551285522855328554285552855628557285582855928560285612856228563285642856528566285672856828569285702857128572285732857428575285762857728578285792858028581285822858328584285852858628587285882858928590285912859228593285942859528596285972859828599286002860128602286032860428605286062860728608286092861028611286122861328614286152861628617286182861928620286212862228623286242862528626286272862828629286302863128632286332863428635286362863728638286392864028641286422864328644286452864628647286482864928650286512865228653286542865528656286572865828659286602866128662286632866428665286662866728668286692867028671286722867328674286752867628677286782867928680286812868228683286842868528686286872868828689286902869128692286932869428695286962869728698286992870028701287022870328704287052870628707287082870928710287112871228713287142871528716287172871828719287202872128722287232872428725287262872728728287292873028731287322873328734287352873628737287382873928740287412874228743287442874528746287472874828749287502875128752287532875428755287562875728758287592876028761287622876328764287652876628767287682876928770287712877228773287742877528776287772877828779287802878128782287832878428785287862878728788287892879028791287922879328794287952879628797287982879928800288012880228803288042880528806288072880828809288102881128812288132881428815288162881728818288192882028821288222882328824288252882628827288282882928830288312883228833288342883528836288372883828839288402884128842288432884428845288462884728848288492885028851288522885328854288552885628857288582885928860288612886228863288642886528866288672886828869288702887128872288732887428875288762887728878288792888028881288822888328884288852888628887288882888928890288912889228893288942889528896288972889828899289002890128902289032890428905289062890728908289092891028911289122891328914289152891628917289182891928920289212892228923289242892528926289272892828929289302893128932289332893428935289362893728938289392894028941289422894328944289452894628947289482894928950289512895228953289542895528956289572895828959289602896128962289632896428965289662896728968289692897028971289722897328974289752897628977289782897928980289812898228983289842898528986289872898828989289902899128992289932899428995289962899728998289992900029001290022900329004290052900629007290082900929010290112901229013290142901529016290172901829019290202902129022290232902429025290262902729028290292903029031290322903329034290352903629037290382903929040290412904229043290442904529046290472904829049290502905129052290532905429055290562905729058290592906029061290622906329064290652906629067290682906929070290712907229073290742907529076290772907829079290802908129082290832908429085290862908729088290892909029091290922909329094290952909629097290982909929100291012910229103291042910529106291072910829109291102911129112291132911429115291162911729118291192912029121291222912329124291252912629127291282912929130291312913229133291342913529136291372913829139291402914129142291432914429145291462914729148291492915029151291522915329154291552915629157291582915929160291612916229163291642916529166291672916829169291702917129172291732917429175291762917729178291792918029181291822918329184291852918629187291882918929190291912919229193291942919529196291972919829199292002920129202292032920429205292062920729208292092921029211292122921329214292152921629217292182921929220292212922229223292242922529226292272922829229292302923129232292332923429235292362923729238292392924029241292422924329244292452924629247292482924929250292512925229253292542925529256292572925829259292602926129262292632926429265292662926729268292692927029271292722927329274292752927629277292782927929280292812928229283292842928529286292872928829289292902929129292292932929429295292962929729298292992930029301293022930329304293052930629307293082930929310293112931229313293142931529316293172931829319293202932129322293232932429325293262932729328293292933029331293322933329334293352933629337293382933929340293412934229343293442934529346293472934829349293502935129352293532935429355293562935729358293592936029361293622936329364293652936629367293682936929370293712937229373293742937529376293772937829379293802938129382293832938429385293862938729388293892939029391293922939329394293952939629397293982939929400294012940229403294042940529406294072940829409294102941129412294132941429415294162941729418294192942029421294222942329424294252942629427294282942929430294312943229433294342943529436294372943829439294402944129442294432944429445294462944729448294492945029451294522945329454294552945629457294582945929460294612946229463294642946529466294672946829469294702947129472294732947429475294762947729478294792948029481294822948329484294852948629487294882948929490294912949229493294942949529496294972949829499295002950129502295032950429505295062950729508295092951029511295122951329514295152951629517295182951929520295212952229523295242952529526295272952829529295302953129532295332953429535295362953729538295392954029541295422954329544295452954629547295482954929550295512955229553295542955529556295572955829559295602956129562295632956429565295662956729568295692957029571295722957329574295752957629577295782957929580295812958229583295842958529586295872958829589295902959129592295932959429595295962959729598295992960029601296022960329604296052960629607296082960929610296112961229613296142961529616296172961829619296202962129622296232962429625296262962729628296292963029631296322963329634296352963629637296382963929640296412964229643296442964529646296472964829649296502965129652296532965429655296562965729658296592966029661296622966329664296652966629667296682966929670296712967229673296742967529676296772967829679296802968129682296832968429685296862968729688296892969029691296922969329694296952969629697296982969929700297012970229703297042970529706297072970829709297102971129712297132971429715297162971729718297192972029721297222972329724297252972629727297282972929730297312973229733297342973529736297372973829739297402974129742297432974429745297462974729748297492975029751297522975329754297552975629757297582975929760297612976229763297642976529766297672976829769297702977129772297732977429775297762977729778297792978029781297822978329784297852978629787297882978929790297912979229793297942979529796297972979829799298002980129802298032980429805298062980729808298092981029811298122981329814298152981629817298182981929820298212982229823298242982529826298272982829829298302983129832298332983429835298362983729838298392984029841298422984329844298452984629847298482984929850298512985229853298542985529856298572985829859298602986129862298632986429865298662986729868298692987029871298722987329874298752987629877298782987929880298812988229883298842988529886298872988829889298902989129892298932989429895298962989729898298992990029901299022990329904299052990629907299082990929910299112991229913299142991529916299172991829919299202992129922299232992429925299262992729928299292993029931299322993329934299352993629937299382993929940299412994229943299442994529946299472994829949299502995129952299532995429955299562995729958299592996029961299622996329964299652996629967299682996929970299712997229973299742997529976299772997829979299802998129982299832998429985299862998729988299892999029991299922999329994299952999629997299982999930000300013000230003300043000530006300073000830009300103001130012300133001430015300163001730018300193002030021300223002330024300253002630027300283002930030300313003230033300343003530036300373003830039300403004130042300433004430045300463004730048300493005030051300523005330054300553005630057300583005930060300613006230063300643006530066300673006830069300703007130072300733007430075300763007730078300793008030081300823008330084300853008630087300883008930090300913009230093300943009530096300973009830099301003010130102301033010430105301063010730108301093011030111301123011330114301153011630117301183011930120301213012230123301243012530126301273012830129301303013130132301333013430135301363013730138301393014030141301423014330144301453014630147301483014930150301513015230153301543015530156301573015830159301603016130162301633016430165301663016730168301693017030171301723017330174301753017630177301783017930180301813018230183301843018530186301873018830189301903019130192301933019430195301963019730198301993020030201302023020330204302053020630207302083020930210302113021230213302143021530216302173021830219302203022130222302233022430225302263022730228302293023030231302323023330234302353023630237302383023930240302413024230243302443024530246302473024830249302503025130252302533025430255302563025730258302593026030261302623026330264302653026630267302683026930270302713027230273302743027530276302773027830279302803028130282302833028430285302863028730288302893029030291302923029330294302953029630297302983029930300303013030230303303043030530306303073030830309303103031130312303133031430315303163031730318303193032030321303223032330324303253032630327303283032930330303313033230333303343033530336303373033830339303403034130342303433034430345303463034730348303493035030351303523035330354303553035630357303583035930360303613036230363303643036530366303673036830369303703037130372303733037430375303763037730378303793038030381303823038330384303853038630387303883038930390303913039230393303943039530396303973039830399304003040130402304033040430405304063040730408304093041030411304123041330414304153041630417304183041930420304213042230423304243042530426304273042830429304303043130432304333043430435304363043730438304393044030441304423044330444304453044630447304483044930450304513045230453304543045530456304573045830459304603046130462304633046430465304663046730468304693047030471304723047330474304753047630477304783047930480304813048230483304843048530486304873048830489304903049130492304933049430495304963049730498304993050030501305023050330504305053050630507305083050930510305113051230513305143051530516305173051830519305203052130522305233052430525305263052730528305293053030531305323053330534305353053630537305383053930540305413054230543305443054530546305473054830549305503055130552305533055430555305563055730558305593056030561305623056330564305653056630567305683056930570305713057230573305743057530576305773057830579305803058130582305833058430585305863058730588305893059030591305923059330594305953059630597305983059930600306013060230603306043060530606306073060830609306103061130612306133061430615306163061730618306193062030621306223062330624306253062630627306283062930630306313063230633306343063530636306373063830639306403064130642306433064430645306463064730648306493065030651306523065330654306553065630657306583065930660306613066230663306643066530666306673066830669306703067130672306733067430675306763067730678306793068030681306823068330684306853068630687306883068930690306913069230693306943069530696306973069830699307003070130702307033070430705307063070730708307093071030711307123071330714307153071630717307183071930720307213072230723307243072530726307273072830729307303073130732307333073430735307363073730738307393074030741307423074330744307453074630747307483074930750307513075230753307543075530756307573075830759307603076130762307633076430765307663076730768307693077030771307723077330774307753077630777307783077930780307813078230783307843078530786307873078830789307903079130792307933079430795307963079730798307993080030801308023080330804308053080630807308083080930810308113081230813308143081530816308173081830819308203082130822308233082430825308263082730828308293083030831308323083330834308353083630837308383083930840308413084230843308443084530846308473084830849308503085130852308533085430855308563085730858308593086030861308623086330864308653086630867308683086930870308713087230873308743087530876308773087830879308803088130882308833088430885308863088730888308893089030891308923089330894308953089630897308983089930900309013090230903309043090530906309073090830909309103091130912309133091430915309163091730918309193092030921309223092330924309253092630927309283092930930309313093230933309343093530936309373093830939309403094130942309433094430945309463094730948309493095030951309523095330954309553095630957309583095930960309613096230963309643096530966309673096830969309703097130972309733097430975309763097730978309793098030981309823098330984309853098630987309883098930990309913099230993309943099530996309973099830999310003100131002310033100431005310063100731008310093101031011310123101331014310153101631017310183101931020310213102231023310243102531026310273102831029310303103131032310333103431035310363103731038310393104031041310423104331044310453104631047310483104931050310513105231053310543105531056310573105831059310603106131062310633106431065310663106731068310693107031071310723107331074310753107631077310783107931080310813108231083310843108531086310873108831089310903109131092310933109431095310963109731098310993110031101311023110331104311053110631107311083110931110311113111231113311143111531116311173111831119311203112131122311233112431125311263112731128311293113031131311323113331134311353113631137311383113931140311413114231143311443114531146311473114831149311503115131152311533115431155311563115731158311593116031161311623116331164311653116631167311683116931170311713117231173311743117531176311773117831179311803118131182311833118431185311863118731188311893119031191311923119331194311953119631197311983119931200312013120231203312043120531206312073120831209312103121131212312133121431215312163121731218312193122031221312223122331224312253122631227312283122931230312313123231233312343123531236312373123831239312403124131242312433124431245312463124731248312493125031251312523125331254312553125631257312583125931260312613126231263312643126531266312673126831269312703127131272312733127431275312763127731278312793128031281312823128331284312853128631287312883128931290312913129231293312943129531296312973129831299313003130131302313033130431305313063130731308313093131031311313123131331314313153131631317313183131931320313213132231323313243132531326313273132831329313303133131332313333133431335313363133731338313393134031341313423134331344313453134631347313483134931350313513135231353313543135531356313573135831359313603136131362313633136431365313663136731368313693137031371313723137331374313753137631377313783137931380313813138231383313843138531386313873138831389313903139131392313933139431395313963139731398313993140031401314023140331404314053140631407314083140931410314113141231413314143141531416314173141831419314203142131422314233142431425314263142731428314293143031431314323143331434314353143631437314383143931440314413144231443314443144531446314473144831449314503145131452314533145431455314563145731458314593146031461314623146331464314653146631467314683146931470314713147231473314743147531476314773147831479314803148131482314833148431485314863148731488314893149031491314923149331494314953149631497314983149931500315013150231503315043150531506315073150831509315103151131512315133151431515315163151731518315193152031521315223152331524315253152631527315283152931530315313153231533315343153531536315373153831539315403154131542315433154431545315463154731548315493155031551315523155331554315553155631557315583155931560315613156231563315643156531566315673156831569315703157131572315733157431575315763157731578315793158031581315823158331584315853158631587315883158931590315913159231593315943159531596315973159831599316003160131602316033160431605316063160731608316093161031611316123161331614316153161631617316183161931620316213162231623316243162531626316273162831629316303163131632316333163431635316363163731638316393164031641316423164331644316453164631647316483164931650316513165231653316543165531656316573165831659316603166131662316633166431665316663166731668316693167031671316723167331674316753167631677316783167931680316813168231683316843168531686316873168831689316903169131692316933169431695316963169731698316993170031701317023170331704317053170631707317083170931710317113171231713317143171531716317173171831719317203172131722317233172431725317263172731728317293173031731317323173331734317353173631737317383173931740317413174231743317443174531746317473174831749317503175131752317533175431755317563175731758317593176031761317623176331764317653176631767317683176931770317713177231773317743177531776317773177831779317803178131782317833178431785317863178731788317893179031791317923179331794317953179631797317983179931800318013180231803318043180531806318073180831809318103181131812318133181431815318163181731818318193182031821318223182331824318253182631827318283182931830318313183231833318343183531836318373183831839318403184131842318433184431845318463184731848318493185031851318523185331854318553185631857318583185931860318613186231863318643186531866318673186831869318703187131872318733187431875318763187731878318793188031881318823188331884318853188631887318883188931890318913189231893318943189531896318973189831899319003190131902319033190431905319063190731908319093191031911319123191331914319153191631917319183191931920319213192231923319243192531926319273192831929319303193131932319333193431935319363193731938319393194031941319423194331944319453194631947319483194931950319513195231953319543195531956319573195831959319603196131962319633196431965319663196731968319693197031971319723197331974319753197631977319783197931980319813198231983319843198531986319873198831989319903199131992319933199431995319963199731998319993200032001320023200332004320053200632007320083200932010320113201232013320143201532016320173201832019320203202132022320233202432025320263202732028320293203032031320323203332034320353203632037320383203932040320413204232043320443204532046320473204832049320503205132052320533205432055320563205732058320593206032061320623206332064320653206632067320683206932070320713207232073320743207532076320773207832079320803208132082320833208432085320863208732088320893209032091320923209332094320953209632097320983209932100321013210232103321043210532106321073210832109321103211132112321133211432115321163211732118321193212032121321223212332124321253212632127321283212932130321313213232133321343213532136321373213832139321403214132142321433214432145321463214732148321493215032151321523215332154321553215632157321583215932160321613216232163321643216532166321673216832169321703217132172321733217432175321763217732178321793218032181321823218332184321853218632187321883218932190321913219232193321943219532196321973219832199322003220132202322033220432205322063220732208322093221032211322123221332214322153221632217322183221932220322213222232223322243222532226322273222832229322303223132232322333223432235322363223732238322393224032241322423224332244322453224632247322483224932250322513225232253322543225532256322573225832259322603226132262322633226432265322663226732268322693227032271322723227332274322753227632277322783227932280322813228232283322843228532286322873228832289322903229132292322933229432295322963229732298322993230032301323023230332304323053230632307323083230932310323113231232313323143231532316323173231832319323203232132322323233232432325323263232732328323293233032331323323233332334323353233632337323383233932340323413234232343323443234532346323473234832349323503235132352323533235432355323563235732358323593236032361323623236332364323653236632367323683236932370323713237232373323743237532376323773237832379323803238132382323833238432385323863238732388323893239032391323923239332394323953239632397323983239932400324013240232403324043240532406324073240832409324103241132412324133241432415324163241732418324193242032421324223242332424324253242632427324283242932430324313243232433324343243532436324373243832439324403244132442324433244432445324463244732448324493245032451324523245332454324553245632457324583245932460324613246232463324643246532466324673246832469324703247132472324733247432475324763247732478324793248032481324823248332484324853248632487324883248932490324913249232493324943249532496324973249832499325003250132502325033250432505325063250732508325093251032511325123251332514325153251632517325183251932520325213252232523325243252532526325273252832529325303253132532325333253432535325363253732538325393254032541325423254332544325453254632547325483254932550325513255232553325543255532556325573255832559325603256132562325633256432565325663256732568325693257032571325723257332574325753257632577325783257932580325813258232583325843258532586325873258832589325903259132592325933259432595325963259732598325993260032601326023260332604326053260632607326083260932610326113261232613326143261532616326173261832619326203262132622326233262432625326263262732628326293263032631326323263332634326353263632637326383263932640326413264232643326443264532646326473264832649326503265132652326533265432655326563265732658326593266032661326623266332664326653266632667326683266932670326713267232673326743267532676326773267832679326803268132682326833268432685326863268732688326893269032691326923269332694326953269632697326983269932700327013270232703327043270532706327073270832709327103271132712327133271432715327163271732718327193272032721327223272332724327253272632727327283272932730327313273232733327343273532736327373273832739327403274132742327433274432745327463274732748327493275032751327523275332754327553275632757327583275932760327613276232763327643276532766327673276832769327703277132772327733277432775327763277732778327793278032781327823278332784327853278632787327883278932790327913279232793327943279532796327973279832799328003280132802328033280432805328063280732808328093281032811328123281332814328153281632817328183281932820328213282232823328243282532826328273282832829328303283132832328333283432835328363283732838328393284032841328423284332844328453284632847328483284932850328513285232853328543285532856328573285832859328603286132862328633286432865328663286732868328693287032871328723287332874328753287632877328783287932880328813288232883328843288532886328873288832889328903289132892328933289432895328963289732898328993290032901329023290332904329053290632907329083290932910329113291232913329143291532916329173291832919329203292132922329233292432925329263292732928329293293032931329323293332934329353293632937329383293932940329413294232943329443294532946329473294832949329503295132952329533295432955329563295732958329593296032961329623296332964329653296632967329683296932970329713297232973329743297532976329773297832979329803298132982329833298432985329863298732988329893299032991329923299332994329953299632997329983299933000330013300233003330043300533006330073300833009330103301133012330133301433015330163301733018330193302033021330223302333024330253302633027330283302933030330313303233033330343303533036330373303833039330403304133042330433304433045330463304733048330493305033051330523305333054330553305633057330583305933060330613306233063330643306533066330673306833069330703307133072330733307433075330763307733078330793308033081330823308333084330853308633087330883308933090330913309233093330943309533096330973309833099331003310133102331033310433105331063310733108331093311033111331123311333114331153311633117331183311933120331213312233123331243312533126331273312833129331303313133132331333313433135331363313733138331393314033141331423314333144331453314633147331483314933150331513315233153331543315533156331573315833159331603316133162331633316433165331663316733168331693317033171331723317333174331753317633177331783317933180331813318233183331843318533186331873318833189331903319133192331933319433195331963319733198331993320033201332023320333204332053320633207332083320933210332113321233213332143321533216332173321833219332203322133222332233322433225332263322733228332293323033231332323323333234332353323633237332383323933240332413324233243332443324533246332473324833249332503325133252332533325433255332563325733258332593326033261332623326333264332653326633267332683326933270332713327233273332743327533276332773327833279332803328133282332833328433285332863328733288332893329033291332923329333294332953329633297332983329933300333013330233303333043330533306333073330833309333103331133312333133331433315333163331733318333193332033321333223332333324333253332633327333283332933330333313333233333333343333533336333373333833339333403334133342333433334433345333463334733348333493335033351333523335333354333553335633357333583335933360333613336233363333643336533366333673336833369333703337133372333733337433375333763337733378333793338033381333823338333384333853338633387333883338933390333913339233393333943339533396333973339833399334003340133402334033340433405334063340733408334093341033411334123341333414334153341633417334183341933420334213342233423334243342533426334273342833429334303343133432334333343433435334363343733438334393344033441334423344333444334453344633447334483344933450334513345233453334543345533456334573345833459334603346133462334633346433465334663346733468334693347033471334723347333474334753347633477334783347933480334813348233483334843348533486334873348833489334903349133492334933349433495334963349733498334993350033501335023350333504335053350633507335083350933510335113351233513335143351533516335173351833519335203352133522335233352433525335263352733528335293353033531335323353333534335353353633537335383353933540335413354233543335443354533546335473354833549335503355133552335533355433555335563355733558335593356033561335623356333564335653356633567335683356933570335713357233573335743357533576335773357833579335803358133582335833358433585335863358733588335893359033591335923359333594335953359633597335983359933600336013360233603336043360533606336073360833609336103361133612336133361433615336163361733618336193362033621336223362333624336253362633627336283362933630336313363233633336343363533636336373363833639336403364133642336433364433645336463364733648336493365033651336523365333654336553365633657336583365933660336613366233663336643366533666336673366833669336703367133672336733367433675336763367733678336793368033681336823368333684336853368633687336883368933690336913369233693336943369533696336973369833699337003370133702337033370433705337063370733708337093371033711337123371333714337153371633717337183371933720337213372233723337243372533726337273372833729337303373133732337333373433735337363373733738337393374033741337423374333744337453374633747337483374933750337513375233753337543375533756337573375833759337603376133762337633376433765337663376733768337693377033771337723377333774337753377633777337783377933780337813378233783337843378533786337873378833789337903379133792337933379433795337963379733798337993380033801338023380333804338053380633807338083380933810338113381233813338143381533816338173381833819338203382133822338233382433825338263382733828338293383033831338323383333834338353383633837338383383933840338413384233843338443384533846338473384833849338503385133852338533385433855338563385733858338593386033861338623386333864338653386633867338683386933870338713387233873338743387533876338773387833879338803388133882338833388433885338863388733888338893389033891338923389333894338953389633897338983389933900339013390233903339043390533906339073390833909339103391133912339133391433915339163391733918339193392033921339223392333924339253392633927339283392933930339313393233933339343393533936339373393833939339403394133942339433394433945339463394733948339493395033951339523395333954339553395633957339583395933960339613396233963339643396533966339673396833969339703397133972339733397433975339763397733978339793398033981339823398333984339853398633987339883398933990339913399233993339943399533996339973399833999340003400134002340033400434005340063400734008340093401034011340123401334014340153401634017340183401934020340213402234023340243402534026340273402834029340303403134032340333403434035340363403734038340393404034041340423404334044340453404634047340483404934050340513405234053340543405534056340573405834059340603406134062340633406434065340663406734068340693407034071340723407334074340753407634077340783407934080340813408234083340843408534086340873408834089340903409134092340933409434095340963409734098340993410034101341023410334104341053410634107341083410934110341113411234113341143411534116341173411834119341203412134122341233412434125341263412734128341293413034131341323413334134341353413634137341383413934140341413414234143341443414534146341473414834149341503415134152341533415434155341563415734158341593416034161341623416334164341653416634167341683416934170341713417234173341743417534176341773417834179341803418134182341833418434185341863418734188341893419034191341923419334194341953419634197341983419934200342013420234203342043420534206342073420834209342103421134212342133421434215342163421734218342193422034221342223422334224342253422634227342283422934230342313423234233342343423534236342373423834239342403424134242342433424434245342463424734248342493425034251342523425334254342553425634257342583425934260342613426234263342643426534266342673426834269342703427134272342733427434275342763427734278342793428034281342823428334284342853428634287342883428934290342913429234293342943429534296342973429834299343003430134302343033430434305343063430734308343093431034311343123431334314343153431634317343183431934320343213432234323343243432534326343273432834329343303433134332343333433434335343363433734338343393434034341343423434334344343453434634347343483434934350343513435234353343543435534356343573435834359343603436134362343633436434365343663436734368343693437034371343723437334374343753437634377343783437934380343813438234383343843438534386343873438834389343903439134392343933439434395343963439734398343993440034401344023440334404344053440634407344083440934410344113441234413344143441534416344173441834419344203442134422344233442434425344263442734428344293443034431344323443334434344353443634437344383443934440344413444234443344443444534446344473444834449344503445134452344533445434455344563445734458344593446034461344623446334464344653446634467344683446934470344713447234473344743447534476344773447834479344803448134482344833448434485344863448734488344893449034491344923449334494344953449634497344983449934500345013450234503345043450534506345073450834509345103451134512345133451434515345163451734518345193452034521345223452334524345253452634527345283452934530345313453234533345343453534536345373453834539345403454134542345433454434545345463454734548345493455034551345523455334554345553455634557345583455934560345613456234563345643456534566345673456834569345703457134572345733457434575345763457734578345793458034581345823458334584345853458634587345883458934590345913459234593345943459534596345973459834599346003460134602346033460434605346063460734608346093461034611346123461334614346153461634617346183461934620346213462234623346243462534626346273462834629346303463134632346333463434635346363463734638346393464034641346423464334644346453464634647346483464934650346513465234653346543465534656346573465834659346603466134662346633466434665346663466734668346693467034671346723467334674346753467634677346783467934680346813468234683346843468534686346873468834689346903469134692346933469434695346963469734698346993470034701347023470334704347053470634707347083470934710347113471234713347143471534716347173471834719347203472134722347233472434725347263472734728347293473034731347323473334734347353473634737347383473934740347413474234743347443474534746347473474834749347503475134752347533475434755347563475734758347593476034761347623476334764347653476634767347683476934770347713477234773347743477534776347773477834779347803478134782347833478434785347863478734788347893479034791347923479334794347953479634797347983479934800348013480234803348043480534806348073480834809348103481134812348133481434815348163481734818348193482034821348223482334824348253482634827348283482934830348313483234833348343483534836348373483834839348403484134842348433484434845348463484734848348493485034851348523485334854348553485634857348583485934860348613486234863348643486534866348673486834869348703487134872348733487434875348763487734878348793488034881348823488334884348853488634887348883488934890348913489234893348943489534896348973489834899349003490134902349033490434905349063490734908349093491034911349123491334914349153491634917349183491934920349213492234923349243492534926349273492834929349303493134932349333493434935349363493734938349393494034941349423494334944349453494634947349483494934950349513495234953349543495534956349573495834959349603496134962349633496434965349663496734968349693497034971349723497334974349753497634977349783497934980349813498234983349843498534986349873498834989349903499134992349933499434995349963499734998349993500035001350023500335004350053500635007350083500935010350113501235013350143501535016350173501835019350203502135022350233502435025350263502735028350293503035031350323503335034350353503635037350383503935040350413504235043350443504535046350473504835049350503505135052350533505435055350563505735058350593506035061350623506335064350653506635067350683506935070350713507235073350743507535076350773507835079350803508135082350833508435085350863508735088350893509035091350923509335094350953509635097350983509935100351013510235103351043510535106351073510835109351103511135112351133511435115351163511735118351193512035121351223512335124351253512635127351283512935130351313513235133351343513535136351373513835139351403514135142351433514435145351463514735148351493515035151351523515335154351553515635157351583515935160351613516235163351643516535166351673516835169351703517135172351733517435175351763517735178351793518035181351823518335184351853518635187351883518935190351913519235193351943519535196351973519835199352003520135202352033520435205352063520735208352093521035211352123521335214352153521635217352183521935220352213522235223352243522535226352273522835229352303523135232352333523435235352363523735238352393524035241352423524335244352453524635247352483524935250352513525235253352543525535256352573525835259352603526135262352633526435265352663526735268352693527035271352723527335274352753527635277352783527935280352813528235283352843528535286352873528835289352903529135292352933529435295352963529735298352993530035301353023530335304353053530635307353083530935310353113531235313353143531535316353173531835319353203532135322353233532435325353263532735328353293533035331353323533335334353353533635337353383533935340353413534235343353443534535346353473534835349353503535135352353533535435355353563535735358353593536035361353623536335364353653536635367353683536935370353713537235373353743537535376353773537835379353803538135382353833538435385353863538735388353893539035391353923539335394353953539635397353983539935400354013540235403354043540535406354073540835409354103541135412354133541435415354163541735418354193542035421354223542335424354253542635427354283542935430354313543235433354343543535436354373543835439354403544135442354433544435445354463544735448354493545035451354523545335454354553545635457354583545935460354613546235463354643546535466354673546835469354703547135472354733547435475354763547735478354793548035481354823548335484354853548635487354883548935490354913549235493354943549535496354973549835499355003550135502355033550435505355063550735508355093551035511355123551335514355153551635517355183551935520355213552235523355243552535526355273552835529355303553135532355333553435535355363553735538355393554035541355423554335544355453554635547355483554935550355513555235553355543555535556355573555835559355603556135562355633556435565355663556735568355693557035571355723557335574355753557635577355783557935580355813558235583355843558535586355873558835589355903559135592355933559435595355963559735598355993560035601356023560335604356053560635607356083560935610356113561235613356143561535616356173561835619356203562135622356233562435625356263562735628356293563035631356323563335634356353563635637356383563935640356413564235643356443564535646356473564835649356503565135652356533565435655356563565735658356593566035661356623566335664356653566635667356683566935670356713567235673356743567535676356773567835679356803568135682356833568435685356863568735688356893569035691356923569335694356953569635697356983569935700357013570235703357043570535706357073570835709357103571135712357133571435715357163571735718357193572035721357223572335724357253572635727357283572935730357313573235733357343573535736357373573835739357403574135742357433574435745357463574735748357493575035751357523575335754357553575635757357583575935760357613576235763357643576535766357673576835769357703577135772357733577435775357763577735778357793578035781357823578335784357853578635787357883578935790357913579235793357943579535796357973579835799358003580135802358033580435805358063580735808358093581035811358123581335814358153581635817358183581935820358213582235823358243582535826358273582835829358303583135832358333583435835358363583735838358393584035841358423584335844358453584635847358483584935850358513585235853358543585535856358573585835859358603586135862358633586435865358663586735868358693587035871358723587335874358753587635877358783587935880358813588235883358843588535886358873588835889358903589135892358933589435895358963589735898358993590035901359023590335904359053590635907359083590935910359113591235913359143591535916359173591835919359203592135922359233592435925359263592735928359293593035931359323593335934359353593635937359383593935940359413594235943359443594535946359473594835949359503595135952359533595435955359563595735958359593596035961359623596335964359653596635967359683596935970359713597235973359743597535976359773597835979359803598135982359833598435985359863598735988359893599035991359923599335994359953599635997359983599936000360013600236003360043600536006360073600836009360103601136012360133601436015360163601736018360193602036021360223602336024360253602636027360283602936030360313603236033360343603536036360373603836039360403604136042360433604436045360463604736048360493605036051360523605336054360553605636057360583605936060360613606236063360643606536066360673606836069360703607136072360733607436075360763607736078360793608036081360823608336084360853608636087360883608936090360913609236093360943609536096360973609836099361003610136102361033610436105361063610736108361093611036111361123611336114361153611636117361183611936120361213612236123361243612536126361273612836129361303613136132361333613436135361363613736138361393614036141361423614336144361453614636147361483614936150361513615236153361543615536156361573615836159361603616136162361633616436165361663616736168361693617036171361723617336174361753617636177361783617936180361813618236183361843618536186361873618836189361903619136192361933619436195361963619736198361993620036201362023620336204362053620636207362083620936210362113621236213362143621536216362173621836219362203622136222362233622436225362263622736228362293623036231362323623336234362353623636237362383623936240362413624236243362443624536246362473624836249362503625136252362533625436255362563625736258362593626036261362623626336264362653626636267362683626936270362713627236273362743627536276362773627836279362803628136282362833628436285362863628736288362893629036291362923629336294362953629636297362983629936300363013630236303363043630536306363073630836309363103631136312363133631436315363163631736318363193632036321363223632336324363253632636327363283632936330363313633236333363343633536336363373633836339363403634136342363433634436345363463634736348363493635036351363523635336354363553635636357363583635936360363613636236363363643636536366363673636836369363703637136372363733637436375363763637736378363793638036381363823638336384363853638636387363883638936390363913639236393363943639536396363973639836399364003640136402364033640436405364063640736408364093641036411364123641336414364153641636417364183641936420364213642236423364243642536426364273642836429364303643136432364333643436435364363643736438364393644036441364423644336444364453644636447364483644936450364513645236453364543645536456364573645836459364603646136462364633646436465364663646736468364693647036471364723647336474364753647636477364783647936480364813648236483364843648536486364873648836489364903649136492364933649436495364963649736498364993650036501365023650336504365053650636507365083650936510365113651236513365143651536516365173651836519365203652136522365233652436525365263652736528365293653036531365323653336534365353653636537365383653936540365413654236543365443654536546365473654836549365503655136552365533655436555365563655736558365593656036561365623656336564365653656636567365683656936570365713657236573365743657536576365773657836579365803658136582365833658436585365863658736588365893659036591365923659336594365953659636597365983659936600366013660236603366043660536606366073660836609366103661136612366133661436615366163661736618366193662036621366223662336624366253662636627366283662936630366313663236633366343663536636366373663836639366403664136642366433664436645366463664736648366493665036651366523665336654366553665636657366583665936660366613666236663366643666536666366673666836669366703667136672366733667436675366763667736678366793668036681366823668336684366853668636687366883668936690366913669236693366943669536696366973669836699367003670136702367033670436705367063670736708367093671036711367123671336714367153671636717367183671936720367213672236723367243672536726367273672836729367303673136732367333673436735367363673736738367393674036741367423674336744367453674636747367483674936750367513675236753367543675536756367573675836759367603676136762367633676436765367663676736768367693677036771367723677336774367753677636777367783677936780367813678236783367843678536786367873678836789367903679136792367933679436795367963679736798367993680036801368023680336804368053680636807368083680936810368113681236813368143681536816368173681836819368203682136822368233682436825368263682736828368293683036831368323683336834368353683636837368383683936840368413684236843368443684536846368473684836849368503685136852368533685436855368563685736858368593686036861368623686336864368653686636867368683686936870368713687236873368743687536876368773687836879368803688136882368833688436885368863688736888368893689036891368923689336894368953689636897368983689936900369013690236903369043690536906369073690836909369103691136912369133691436915369163691736918369193692036921369223692336924369253692636927369283692936930369313693236933369343693536936369373693836939369403694136942369433694436945369463694736948369493695036951369523695336954369553695636957369583695936960369613696236963369643696536966369673696836969369703697136972369733697436975369763697736978369793698036981369823698336984369853698636987369883698936990369913699236993369943699536996369973699836999370003700137002370033700437005370063700737008370093701037011370123701337014370153701637017370183701937020370213702237023370243702537026370273702837029370303703137032370333703437035370363703737038370393704037041370423704337044370453704637047370483704937050370513705237053370543705537056370573705837059370603706137062370633706437065370663706737068370693707037071370723707337074370753707637077370783707937080370813708237083370843708537086370873708837089370903709137092370933709437095370963709737098370993710037101371023710337104371053710637107371083710937110371113711237113371143711537116371173711837119371203712137122371233712437125371263712737128371293713037131371323713337134371353713637137371383713937140371413714237143371443714537146371473714837149371503715137152371533715437155371563715737158371593716037161371623716337164371653716637167371683716937170371713717237173371743717537176371773717837179371803718137182371833718437185371863718737188371893719037191371923719337194371953719637197371983719937200372013720237203372043720537206372073720837209372103721137212372133721437215372163721737218372193722037221372223722337224372253722637227372283722937230372313723237233372343723537236372373723837239372403724137242372433724437245372463724737248372493725037251372523725337254372553725637257372583725937260372613726237263372643726537266372673726837269372703727137272372733727437275372763727737278372793728037281372823728337284372853728637287372883728937290372913729237293372943729537296372973729837299373003730137302373033730437305373063730737308373093731037311373123731337314373153731637317373183731937320373213732237323373243732537326373273732837329373303733137332373333733437335373363733737338373393734037341373423734337344373453734637347373483734937350373513735237353373543735537356373573735837359373603736137362373633736437365373663736737368373693737037371373723737337374373753737637377373783737937380373813738237383373843738537386373873738837389373903739137392373933739437395373963739737398373993740037401374023740337404374053740637407374083740937410374113741237413374143741537416374173741837419374203742137422374233742437425374263742737428374293743037431374323743337434374353743637437374383743937440374413744237443374443744537446374473744837449374503745137452374533745437455374563745737458374593746037461374623746337464374653746637467374683746937470374713747237473374743747537476374773747837479374803748137482374833748437485374863748737488374893749037491374923749337494374953749637497374983749937500375013750237503375043750537506375073750837509375103751137512375133751437515375163751737518375193752037521375223752337524375253752637527375283752937530375313753237533375343753537536375373753837539375403754137542375433754437545375463754737548375493755037551375523755337554375553755637557375583755937560375613756237563375643756537566375673756837569375703757137572375733757437575375763757737578375793758037581375823758337584375853758637587375883758937590375913759237593375943759537596375973759837599376003760137602376033760437605376063760737608376093761037611376123761337614376153761637617376183761937620376213762237623376243762537626376273762837629376303763137632376333763437635376363763737638376393764037641376423764337644376453764637647376483764937650376513765237653376543765537656376573765837659376603766137662376633766437665376663766737668376693767037671376723767337674376753767637677376783767937680376813768237683376843768537686376873768837689376903769137692376933769437695376963769737698376993770037701377023770337704377053770637707377083770937710377113771237713377143771537716377173771837719377203772137722377233772437725377263772737728377293773037731377323773337734377353773637737377383773937740377413774237743377443774537746377473774837749377503775137752377533775437755377563775737758377593776037761377623776337764377653776637767377683776937770377713777237773377743777537776377773777837779377803778137782377833778437785377863778737788377893779037791377923779337794377953779637797377983779937800378013780237803378043780537806378073780837809378103781137812378133781437815378163781737818378193782037821378223782337824378253782637827378283782937830378313783237833378343783537836378373783837839378403784137842378433784437845378463784737848378493785037851378523785337854378553785637857378583785937860378613786237863378643786537866378673786837869378703787137872378733787437875378763787737878378793788037881378823788337884378853788637887378883788937890378913789237893378943789537896378973789837899379003790137902379033790437905379063790737908379093791037911379123791337914379153791637917379183791937920379213792237923379243792537926379273792837929379303793137932379333793437935379363793737938379393794037941379423794337944379453794637947379483794937950379513795237953379543795537956379573795837959379603796137962379633796437965379663796737968379693797037971379723797337974379753797637977379783797937980379813798237983379843798537986379873798837989379903799137992379933799437995379963799737998379993800038001380023800338004380053800638007380083800938010380113801238013380143801538016380173801838019380203802138022380233802438025380263802738028380293803038031380323803338034380353803638037380383803938040380413804238043380443804538046380473804838049380503805138052380533805438055380563805738058380593806038061380623806338064380653806638067380683806938070380713807238073380743807538076380773807838079380803808138082380833808438085380863808738088380893809038091380923809338094380953809638097380983809938100381013810238103381043810538106381073810838109381103811138112381133811438115381163811738118381193812038121381223812338124381253812638127381283812938130381313813238133381343813538136381373813838139381403814138142381433814438145381463814738148381493815038151381523815338154381553815638157381583815938160381613816238163381643816538166381673816838169381703817138172381733817438175381763817738178381793818038181381823818338184381853818638187381883818938190381913819238193381943819538196381973819838199382003820138202382033820438205382063820738208382093821038211382123821338214382153821638217382183821938220382213822238223382243822538226382273822838229382303823138232382333823438235382363823738238382393824038241382423824338244382453824638247382483824938250382513825238253382543825538256382573825838259382603826138262382633826438265382663826738268382693827038271382723827338274382753827638277382783827938280382813828238283382843828538286382873828838289382903829138292382933829438295382963829738298382993830038301383023830338304383053830638307383083830938310383113831238313383143831538316383173831838319383203832138322383233832438325383263832738328383293833038331383323833338334383353833638337383383833938340383413834238343383443834538346383473834838349383503835138352383533835438355383563835738358383593836038361383623836338364383653836638367383683836938370383713837238373383743837538376383773837838379383803838138382383833838438385383863838738388383893839038391383923839338394383953839638397383983839938400384013840238403384043840538406384073840838409384103841138412384133841438415384163841738418384193842038421384223842338424384253842638427384283842938430384313843238433384343843538436384373843838439384403844138442384433844438445384463844738448384493845038451384523845338454384553845638457384583845938460384613846238463384643846538466384673846838469384703847138472384733847438475384763847738478384793848038481384823848338484384853848638487384883848938490384913849238493384943849538496384973849838499385003850138502385033850438505385063850738508385093851038511385123851338514385153851638517385183851938520385213852238523385243852538526385273852838529385303853138532385333853438535385363853738538385393854038541385423854338544385453854638547385483854938550385513855238553385543855538556385573855838559385603856138562385633856438565385663856738568385693857038571385723857338574385753857638577385783857938580385813858238583385843858538586385873858838589385903859138592385933859438595385963859738598385993860038601386023860338604386053860638607386083860938610386113861238613386143861538616386173861838619386203862138622386233862438625386263862738628386293863038631386323863338634386353863638637386383863938640386413864238643386443864538646386473864838649386503865138652386533865438655386563865738658386593866038661386623866338664386653866638667386683866938670386713867238673386743867538676386773867838679386803868138682386833868438685386863868738688386893869038691386923869338694386953869638697386983869938700387013870238703387043870538706387073870838709387103871138712387133871438715387163871738718387193872038721387223872338724387253872638727387283872938730387313873238733387343873538736387373873838739387403874138742387433874438745387463874738748387493875038751387523875338754387553875638757387583875938760387613876238763387643876538766387673876838769387703877138772387733877438775387763877738778387793878038781387823878338784387853878638787387883878938790387913879238793387943879538796387973879838799388003880138802388033880438805388063880738808388093881038811388123881338814388153881638817388183881938820388213882238823388243882538826388273882838829388303883138832388333883438835388363883738838388393884038841388423884338844388453884638847388483884938850388513885238853388543885538856388573885838859388603886138862388633886438865388663886738868388693887038871388723887338874388753887638877388783887938880388813888238883388843888538886388873888838889388903889138892388933889438895388963889738898388993890038901389023890338904389053890638907389083890938910389113891238913389143891538916389173891838919389203892138922389233892438925389263892738928389293893038931389323893338934389353893638937389383893938940389413894238943389443894538946389473894838949389503895138952389533895438955389563895738958389593896038961389623896338964389653896638967389683896938970389713897238973389743897538976389773897838979389803898138982389833898438985389863898738988389893899038991389923899338994389953899638997389983899939000390013900239003390043900539006390073900839009390103901139012390133901439015390163901739018390193902039021390223902339024390253902639027390283902939030390313903239033390343903539036390373903839039390403904139042390433904439045390463904739048390493905039051390523905339054390553905639057390583905939060390613906239063390643906539066390673906839069390703907139072390733907439075390763907739078390793908039081390823908339084390853908639087390883908939090390913909239093390943909539096390973909839099391003910139102391033910439105391063910739108391093911039111391123911339114391153911639117391183911939120391213912239123391243912539126391273912839129391303913139132391333913439135391363913739138391393914039141391423914339144391453914639147391483914939150391513915239153391543915539156391573915839159391603916139162391633916439165391663916739168391693917039171391723917339174391753917639177391783917939180391813918239183391843918539186391873918839189391903919139192391933919439195391963919739198391993920039201
  1. /**
  2. * Parse JavaScript SDK v3.5.1
  3. *
  4. * The source tree of this library can be found at
  5. * https://github.com/ParsePlatform/Parse-SDK-JS
  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.Parse = 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 _interopRequireDefault = _dereq_("@babel/runtime-corejs3/helpers/interopRequireDefault");
  10. var _Object$defineProperty = _dereq_("@babel/runtime-corejs3/core-js-stable/object/define-property");
  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 RESTController = _CoreManager.default.getRESTController();
  88. return RESTController.request('POST', 'events/' + name, {
  89. dimensions: dimensions
  90. });
  91. }
  92. };
  93. _CoreManager.default.setAnalyticsController(DefaultController);
  94. },{"./CoreManager":4,"@babel/runtime-corejs3/core-js-stable/object/define-property":82,"@babel/runtime-corejs3/helpers/interopRequireDefault":128}],2:[function(_dereq_,module,exports){
  95. "use strict";
  96. var _interopRequireDefault = _dereq_("@babel/runtime-corejs3/helpers/interopRequireDefault");
  97. var _Object$defineProperty = _dereq_("@babel/runtime-corejs3/core-js-stable/object/define-property");
  98. _Object$defineProperty(exports, "__esModule", {
  99. value: true
  100. });
  101. exports.default = void 0;
  102. var _ParseUser = _interopRequireDefault(_dereq_("./ParseUser"));
  103. /**
  104. * Copyright (c) 2015-present, Parse, LLC.
  105. * All rights reserved.
  106. *
  107. * This source code is licensed under the BSD-style license found in the
  108. * LICENSE file in the root directory of this source tree. An additional grant
  109. * of patent rights can be found in the PATENTS file in the same directory.
  110. *
  111. * @flow-weak
  112. */
  113. var uuidv4 = _dereq_('./uuid');
  114. var registered = false;
  115. /**
  116. * Provides utility functions for working with Anonymously logged-in users. <br />
  117. * Anonymous users have some unique characteristics:
  118. * <ul>
  119. * <li>Anonymous users don't need a user name or password.</li>
  120. * <ul>
  121. * <li>Once logged out, an anonymous user cannot be recovered.</li>
  122. * </ul>
  123. * <li>signUp converts an anonymous user to a standard user with the given username and password.</li>
  124. * <ul>
  125. * <li>Data associated with the anonymous user is retained.</li>
  126. * </ul>
  127. * <li>logIn switches users without converting the anonymous user.</li>
  128. * <ul>
  129. * <li>Data associated with the anonymous user will be lost.</li>
  130. * </ul>
  131. * <li>Service logIn (e.g. Facebook, Twitter) will attempt to convert
  132. * the anonymous user into a standard user by linking it to the service.</li>
  133. * <ul>
  134. * <li>If a user already exists that is linked to the service, it will instead switch to the existing user.</li>
  135. * </ul>
  136. * <li>Service linking (e.g. Facebook, Twitter) will convert the anonymous user
  137. * into a standard user by linking it to the service.</li>
  138. * </ul>
  139. *
  140. * @class Parse.AnonymousUtils
  141. * @static
  142. */
  143. var AnonymousUtils = {
  144. /**
  145. * Gets whether the user has their account linked to anonymous user.
  146. *
  147. * @function isLinked
  148. * @name Parse.AnonymousUtils.isLinked
  149. * @param {Parse.User} user User to check for.
  150. * The user must be logged in on this device.
  151. * @returns {boolean} <code>true</code> if the user has their account
  152. * linked to an anonymous user.
  153. * @static
  154. */
  155. isLinked: function (user
  156. /*: ParseUser*/
  157. ) {
  158. var provider = this._getAuthProvider();
  159. return user._isLinked(provider.getAuthType());
  160. },
  161. /**
  162. * Logs in a user Anonymously.
  163. *
  164. * @function logIn
  165. * @name Parse.AnonymousUtils.logIn
  166. * @param {object} options MasterKey / SessionToken.
  167. * @returns {Promise} Logged in user
  168. * @static
  169. */
  170. logIn: function (options
  171. /*:: ?: RequestOptions*/
  172. )
  173. /*: Promise<ParseUser>*/
  174. {
  175. var provider = this._getAuthProvider();
  176. return _ParseUser.default.logInWith(provider.getAuthType(), provider.getAuthData(), options);
  177. },
  178. /**
  179. * Links Anonymous User to an existing PFUser.
  180. *
  181. * @function link
  182. * @name Parse.AnonymousUtils.link
  183. * @param {Parse.User} user User to link. This must be the current user.
  184. * @param {object} options MasterKey / SessionToken.
  185. * @returns {Promise} Linked with User
  186. * @static
  187. */
  188. link: function (user
  189. /*: ParseUser*/
  190. , options
  191. /*:: ?: RequestOptions*/
  192. )
  193. /*: Promise<ParseUser>*/
  194. {
  195. var provider = this._getAuthProvider();
  196. return user.linkWith(provider.getAuthType(), provider.getAuthData(), options);
  197. },
  198. /**
  199. * Returns true if Authentication Provider has been registered for use.
  200. *
  201. * @function isRegistered
  202. * @name Parse.AnonymousUtils.isRegistered
  203. * @returns {boolean}
  204. * @static
  205. */
  206. isRegistered: function ()
  207. /*: boolean*/
  208. {
  209. return registered;
  210. },
  211. _getAuthProvider: function () {
  212. var provider = {
  213. restoreAuthentication: function () {
  214. return true;
  215. },
  216. getAuthType: function () {
  217. return 'anonymous';
  218. },
  219. getAuthData: function () {
  220. return {
  221. authData: {
  222. id: uuidv4()
  223. }
  224. };
  225. }
  226. };
  227. if (!registered) {
  228. _ParseUser.default._registerAuthenticationProvider(provider);
  229. registered = true;
  230. }
  231. return provider;
  232. }
  233. };
  234. var _default = AnonymousUtils;
  235. exports.default = _default;
  236. },{"./ParseUser":35,"./uuid":54,"@babel/runtime-corejs3/core-js-stable/object/define-property":82,"@babel/runtime-corejs3/helpers/interopRequireDefault":128}],3:[function(_dereq_,module,exports){
  237. "use strict";
  238. var _interopRequireDefault = _dereq_("@babel/runtime-corejs3/helpers/interopRequireDefault");
  239. var _Object$defineProperty = _dereq_("@babel/runtime-corejs3/core-js-stable/object/define-property");
  240. _Object$defineProperty(exports, "__esModule", {
  241. value: true
  242. });
  243. exports.getJobStatus = getJobStatus;
  244. exports.getJobsData = getJobsData;
  245. exports.run = run;
  246. exports.startJob = startJob;
  247. var _promise = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/promise"));
  248. var _keys = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/object/keys"));
  249. var _typeof2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/helpers/typeof"));
  250. var _CoreManager = _interopRequireDefault(_dereq_("./CoreManager"));
  251. var _decode = _interopRequireDefault(_dereq_("./decode"));
  252. var _encode = _interopRequireDefault(_dereq_("./encode"));
  253. var _ParseError = _interopRequireDefault(_dereq_("./ParseError"));
  254. var _ParseQuery = _interopRequireDefault(_dereq_("./ParseQuery"));
  255. var _ParseObject = _interopRequireDefault(_dereq_("./ParseObject"));
  256. /**
  257. * Copyright (c) 2015-present, Parse, LLC.
  258. * All rights reserved.
  259. *
  260. * This source code is licensed under the BSD-style license found in the
  261. * LICENSE file in the root directory of this source tree. An additional grant
  262. * of patent rights can be found in the PATENTS file in the same directory.
  263. *
  264. * @flow
  265. */
  266. /**
  267. * Contains functions for calling and declaring
  268. * <a href="/docs/cloud_code_guide#functions">cloud functions</a>.
  269. * <p><strong><em>
  270. * Some functions are only available from Cloud Code.
  271. * </em></strong></p>
  272. *
  273. * @class Parse.Cloud
  274. * @static
  275. * @hideconstructor
  276. */
  277. /**
  278. * Makes a call to a cloud function.
  279. *
  280. * @function run
  281. * @name Parse.Cloud.run
  282. * @param {string} name The function name.
  283. * @param {object} data The parameters to send to the cloud function.
  284. * @param {object} options
  285. * @returns {Promise} A promise that will be resolved with the result
  286. * of the function.
  287. */
  288. function run(name
  289. /*: string*/
  290. , data
  291. /*: mixed*/
  292. , options
  293. /*: RequestOptions*/
  294. )
  295. /*: Promise<mixed>*/
  296. {
  297. options = options || {};
  298. if (typeof name !== 'string' || name.length === 0) {
  299. throw new TypeError('Cloud function name must be a string.');
  300. }
  301. var requestOptions = {};
  302. if (options.useMasterKey) {
  303. requestOptions.useMasterKey = options.useMasterKey;
  304. }
  305. if (options.sessionToken) {
  306. requestOptions.sessionToken = options.sessionToken;
  307. }
  308. if (options.context && (0, _typeof2.default)(options.context) === 'object') {
  309. requestOptions.context = options.context;
  310. }
  311. return _CoreManager.default.getCloudController().run(name, data, requestOptions);
  312. }
  313. /**
  314. * Gets data for the current set of cloud jobs.
  315. *
  316. * @function getJobsData
  317. * @name Parse.Cloud.getJobsData
  318. * @returns {Promise} A promise that will be resolved with the result
  319. * of the function.
  320. */
  321. function getJobsData()
  322. /*: Promise<Object>*/
  323. {
  324. return _CoreManager.default.getCloudController().getJobsData({
  325. useMasterKey: true
  326. });
  327. }
  328. /**
  329. * Starts a given cloud job, which will process asynchronously.
  330. *
  331. * @function startJob
  332. * @name Parse.Cloud.startJob
  333. * @param {string} name The function name.
  334. * @param {object} data The parameters to send to the cloud function.
  335. * @returns {Promise} A promise that will be resolved with the jobStatusId
  336. * of the job.
  337. */
  338. function startJob(name
  339. /*: string*/
  340. , data
  341. /*: mixed*/
  342. )
  343. /*: Promise<string>*/
  344. {
  345. if (typeof name !== 'string' || name.length === 0) {
  346. throw new TypeError('Cloud job name must be a string.');
  347. }
  348. return _CoreManager.default.getCloudController().startJob(name, data, {
  349. useMasterKey: true
  350. });
  351. }
  352. /**
  353. * Gets job status by Id
  354. *
  355. * @function getJobStatus
  356. * @name Parse.Cloud.getJobStatus
  357. * @param {string} jobStatusId The Id of Job Status.
  358. * @returns {Parse.Object} Status of Job.
  359. */
  360. function getJobStatus(jobStatusId
  361. /*: string*/
  362. )
  363. /*: Promise<ParseObject>*/
  364. {
  365. var query = new _ParseQuery.default('_JobStatus');
  366. return query.get(jobStatusId, {
  367. useMasterKey: true
  368. });
  369. }
  370. var DefaultController = {
  371. run: function (name, data, options
  372. /*: RequestOptions*/
  373. ) {
  374. var RESTController = _CoreManager.default.getRESTController();
  375. var payload = (0, _encode.default)(data, true);
  376. var request = RESTController.request('POST', 'functions/' + name, payload, options);
  377. return request.then(function (res) {
  378. if ((0, _typeof2.default)(res) === 'object' && (0, _keys.default)(res).length > 0 && !res.hasOwnProperty('result')) {
  379. throw new _ParseError.default(_ParseError.default.INVALID_JSON, 'The server returned an invalid response.');
  380. }
  381. var decoded = (0, _decode.default)(res);
  382. if (decoded && decoded.hasOwnProperty('result')) {
  383. return _promise.default.resolve(decoded.result);
  384. }
  385. return _promise.default.resolve(undefined);
  386. });
  387. },
  388. getJobsData: function (options
  389. /*: RequestOptions*/
  390. ) {
  391. var RESTController = _CoreManager.default.getRESTController();
  392. return RESTController.request('GET', 'cloud_code/jobs/data', null, options);
  393. },
  394. startJob: function (name, data, options
  395. /*: RequestOptions*/
  396. ) {
  397. var RESTController = _CoreManager.default.getRESTController();
  398. var payload = (0, _encode.default)(data, true);
  399. return RESTController.request('POST', 'jobs/' + name, payload, options);
  400. }
  401. };
  402. _CoreManager.default.setCloudController(DefaultController);
  403. },{"./CoreManager":4,"./ParseError":22,"./ParseObject":27,"./ParseQuery":30,"./decode":45,"./encode":46,"@babel/runtime-corejs3/core-js-stable/object/define-property":82,"@babel/runtime-corejs3/core-js-stable/object/keys":89,"@babel/runtime-corejs3/core-js-stable/promise":92,"@babel/runtime-corejs3/helpers/interopRequireDefault":128,"@babel/runtime-corejs3/helpers/typeof":140}],4:[function(_dereq_,module,exports){
  404. (function (process){(function (){
  405. "use strict";
  406. var _interopRequireDefault = _dereq_("@babel/runtime-corejs3/helpers/interopRequireDefault");
  407. var _concat = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/instance/concat"));
  408. var _forEach = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/instance/for-each"));
  409. /*
  410. * Copyright (c) 2015-present, Parse, LLC.
  411. * All rights reserved.
  412. *
  413. * This source code is licensed under the BSD-style license found in the
  414. * LICENSE file in the root directory of this source tree. An additional grant
  415. * of patent rights can be found in the PATENTS file in the same directory.
  416. *
  417. * @flow
  418. */
  419. /*:: import type { AttributeMap, ObjectCache, OpsMap, State } from './ObjectStateMutations';*/
  420. /*:: import type ParseFile from './ParseFile';*/
  421. /*:: import type { FileSource } from './ParseFile';*/
  422. /*:: import type { Op } from './ParseOp';*/
  423. /*:: import type ParseObject from './ParseObject';*/
  424. /*:: import type { QueryJSON } from './ParseQuery';*/
  425. /*:: import type ParseUser from './ParseUser';*/
  426. /*:: import type { AuthData } from './ParseUser';*/
  427. /*:: import type { PushData } from './Push';*/
  428. /*:: import type { RequestOptions, FullOptions } from './RESTController';*/
  429. /*:: type AnalyticsController = {
  430. track: (name: string, dimensions: { [key: string]: string }) => Promise,
  431. };*/
  432. /*:: type CloudController = {
  433. run: (name: string, data: mixed, options: RequestOptions) => Promise,
  434. getJobsData: (options: RequestOptions) => Promise,
  435. startJob: (name: string, data: mixed, options: RequestOptions) => Promise,
  436. };*/
  437. /*:: type ConfigController = {
  438. current: () => Promise,
  439. get: () => Promise,
  440. save: (attrs: { [key: string]: any }) => Promise,
  441. };*/
  442. /*:: type CryptoController = {
  443. encrypt: (obj: any, secretKey: string) => string,
  444. decrypt: (encryptedText: string, secretKey: any) => string,
  445. };*/
  446. /*:: type FileController = {
  447. saveFile: (name: string, source: FileSource, options: FullOptions) => Promise,
  448. saveBase64: (name: string, source: FileSource, options: FullOptions) => Promise,
  449. download: (uri: string) => Promise,
  450. };*/
  451. /*:: type InstallationController = {
  452. currentInstallationId: () => Promise,
  453. };*/
  454. /*:: type ObjectController = {
  455. fetch: (
  456. object: ParseObject | Array<ParseObject>,
  457. forceFetch: boolean,
  458. options: RequestOptions
  459. ) => Promise,
  460. save: (object: ParseObject | Array<ParseObject | ParseFile>, options: RequestOptions) => Promise,
  461. destroy: (object: ParseObject | Array<ParseObject>, options: RequestOptions) => Promise,
  462. };*/
  463. /*:: type ObjectStateController = {
  464. getState: (obj: any) => ?State,
  465. initializeState: (obj: any, initial?: State) => State,
  466. removeState: (obj: any) => ?State,
  467. getServerData: (obj: any) => AttributeMap,
  468. setServerData: (obj: any, attributes: AttributeMap) => void,
  469. getPendingOps: (obj: any) => Array<OpsMap>,
  470. setPendingOp: (obj: any, attr: string, op: ?Op) => void,
  471. pushPendingState: (obj: any) => void,
  472. popPendingState: (obj: any) => OpsMap,
  473. mergeFirstPendingState: (obj: any) => void,
  474. getObjectCache: (obj: any) => ObjectCache,
  475. estimateAttribute: (obj: any, attr: string) => mixed,
  476. estimateAttributes: (obj: any) => AttributeMap,
  477. commitServerChanges: (obj: any, changes: AttributeMap) => void,
  478. enqueueTask: (obj: any, task: () => Promise) => Promise,
  479. clearAllState: () => void,
  480. duplicateState: (source: any, dest: any) => void,
  481. };*/
  482. /*:: type PushController = {
  483. send: (data: PushData) => Promise,
  484. };*/
  485. /*:: type QueryController = {
  486. find: (className: string, params: QueryJSON, options: RequestOptions) => Promise,
  487. aggregate: (className: string, params: any, options: RequestOptions) => Promise,
  488. };*/
  489. /*:: type RESTController = {
  490. request: (method: string, path: string, data: mixed, options: RequestOptions) => Promise,
  491. ajax: (method: string, url: string, data: any, headers?: any, options: FullOptions) => Promise,
  492. };*/
  493. /*:: type SchemaController = {
  494. purge: (className: string) => Promise,
  495. get: (className: string, options: RequestOptions) => Promise,
  496. delete: (className: string, options: RequestOptions) => Promise,
  497. create: (className: string, params: any, options: RequestOptions) => Promise,
  498. update: (className: string, params: any, options: RequestOptions) => Promise,
  499. send(className: string, method: string, params: any, options: RequestOptions): Promise,
  500. };*/
  501. /*:: type SessionController = {
  502. getSession: (token: RequestOptions) => Promise,
  503. };*/
  504. /*:: type StorageController =
  505. | {
  506. async: 0,
  507. getItem: (path: string) => ?string,
  508. setItem: (path: string, value: string) => void,
  509. removeItem: (path: string) => void,
  510. getItemAsync?: (path: string) => Promise,
  511. setItemAsync?: (path: string, value: string) => Promise,
  512. removeItemAsync?: (path: string) => Promise,
  513. clear: () => void,
  514. }
  515. | {
  516. async: 1,
  517. getItem?: (path: string) => ?string,
  518. setItem?: (path: string, value: string) => void,
  519. removeItem?: (path: string) => void,
  520. getItemAsync: (path: string) => Promise,
  521. setItemAsync: (path: string, value: string) => Promise,
  522. removeItemAsync: (path: string) => Promise,
  523. clear: () => void,
  524. };*/
  525. /*:: type LocalDatastoreController = {
  526. fromPinWithName: (name: string) => ?any,
  527. pinWithName: (name: string, objects: any) => void,
  528. unPinWithName: (name: string) => void,
  529. getAllContents: () => ?any,
  530. clear: () => void,
  531. };*/
  532. /*:: type UserController = {
  533. setCurrentUser: (user: ParseUser) => Promise,
  534. currentUser: () => ?ParseUser,
  535. currentUserAsync: () => Promise,
  536. signUp: (user: ParseUser, attrs: AttributeMap, options: RequestOptions) => Promise,
  537. logIn: (user: ParseUser, options: RequestOptions) => Promise,
  538. become: (options: RequestOptions) => Promise,
  539. hydrate: (userJSON: AttributeMap) => Promise,
  540. logOut: (options: RequestOptions) => Promise,
  541. me: (options: RequestOptions) => Promise,
  542. requestPasswordReset: (email: string, options: RequestOptions) => Promise,
  543. updateUserOnDisk: (user: ParseUser) => Promise,
  544. upgradeToRevocableSession: (user: ParseUser, options: RequestOptions) => Promise,
  545. linkWith: (user: ParseUser, authData: AuthData) => Promise,
  546. removeUserFromDisk: () => Promise,
  547. verifyPassword: (username: string, password: string, options: RequestOptions) => Promise,
  548. requestEmailVerification: (email: string, options: RequestOptions) => Promise,
  549. };*/
  550. /*:: type HooksController = {
  551. get: (type: string, functionName?: string, triggerName?: string) => Promise,
  552. create: (hook: mixed) => Promise,
  553. delete: (hook: mixed) => Promise,
  554. update: (hook: mixed) => Promise,
  555. send: (method: string, path: string, body?: mixed) => Promise,
  556. };*/
  557. /*:: type WebSocketController = {
  558. onopen: () => void,
  559. onmessage: (message: any) => void,
  560. onclose: () => void,
  561. onerror: (error: any) => void,
  562. send: (data: any) => void,
  563. close: () => void,
  564. };*/
  565. /*:: type Config = {
  566. AnalyticsController?: AnalyticsController,
  567. CloudController?: CloudController,
  568. ConfigController?: ConfigController,
  569. FileController?: FileController,
  570. InstallationController?: InstallationController,
  571. ObjectController?: ObjectController,
  572. ObjectStateController?: ObjectStateController,
  573. PushController?: PushController,
  574. QueryController?: QueryController,
  575. RESTController?: RESTController,
  576. SchemaController?: SchemaController,
  577. SessionController?: SessionController,
  578. StorageController?: StorageController,
  579. LocalDatastoreController?: LocalDatastoreController,
  580. UserController?: UserController,
  581. HooksController?: HooksController,
  582. WebSocketController?: WebSocketController,
  583. };*/
  584. var config
  585. /*: Config & { [key: string]: mixed }*/
  586. = {
  587. // Defaults
  588. IS_NODE: typeof process !== 'undefined' && !!process.versions && !!process.versions.node && !process.versions.electron,
  589. REQUEST_ATTEMPT_LIMIT: 5,
  590. REQUEST_BATCH_SIZE: 20,
  591. REQUEST_HEADERS: {},
  592. SERVER_URL: 'https://api.parse.com/1',
  593. SERVER_AUTH_TYPE: null,
  594. SERVER_AUTH_TOKEN: null,
  595. LIVEQUERY_SERVER_URL: null,
  596. ENCRYPTED_KEY: null,
  597. VERSION: 'js' + "3.5.1",
  598. APPLICATION_ID: null,
  599. JAVASCRIPT_KEY: null,
  600. MASTER_KEY: null,
  601. USE_MASTER_KEY: false,
  602. PERFORM_USER_REWRITE: true,
  603. FORCE_REVOCABLE_SESSION: false,
  604. ENCRYPTED_USER: false,
  605. IDEMPOTENCY: false,
  606. ALLOW_CUSTOM_OBJECT_ID: false
  607. };
  608. function requireMethods(name
  609. /*: string*/
  610. , methods
  611. /*: Array<string>*/
  612. , controller
  613. /*: any*/
  614. ) {
  615. (0, _forEach.default)(methods).call(methods, function (func) {
  616. if (typeof controller[func] !== 'function') {
  617. var _context;
  618. throw new Error((0, _concat.default)(_context = "".concat(name, " must implement ")).call(_context, func, "()"));
  619. }
  620. });
  621. }
  622. module.exports = {
  623. get: function (key
  624. /*: string*/
  625. )
  626. /*: any*/
  627. {
  628. if (config.hasOwnProperty(key)) {
  629. return config[key];
  630. }
  631. throw new Error('Configuration key not found: ' + key);
  632. },
  633. set: function (key
  634. /*: string*/
  635. , value
  636. /*: any*/
  637. )
  638. /*: void*/
  639. {
  640. config[key] = value;
  641. },
  642. /* Specialized Controller Setters/Getters */
  643. setAnalyticsController: function (controller
  644. /*: AnalyticsController*/
  645. ) {
  646. requireMethods('AnalyticsController', ['track'], controller);
  647. config['AnalyticsController'] = controller;
  648. },
  649. getAnalyticsController: function ()
  650. /*: AnalyticsController*/
  651. {
  652. return config['AnalyticsController'];
  653. },
  654. setCloudController: function (controller
  655. /*: CloudController*/
  656. ) {
  657. requireMethods('CloudController', ['run', 'getJobsData', 'startJob'], controller);
  658. config['CloudController'] = controller;
  659. },
  660. getCloudController: function ()
  661. /*: CloudController*/
  662. {
  663. return config['CloudController'];
  664. },
  665. setConfigController: function (controller
  666. /*: ConfigController*/
  667. ) {
  668. requireMethods('ConfigController', ['current', 'get', 'save'], controller);
  669. config['ConfigController'] = controller;
  670. },
  671. getConfigController: function ()
  672. /*: ConfigController*/
  673. {
  674. return config['ConfigController'];
  675. },
  676. setCryptoController: function (controller
  677. /*: CryptoController*/
  678. ) {
  679. requireMethods('CryptoController', ['encrypt', 'decrypt'], controller);
  680. config['CryptoController'] = controller;
  681. },
  682. getCryptoController: function ()
  683. /*: CryptoController*/
  684. {
  685. return config['CryptoController'];
  686. },
  687. setFileController: function (controller
  688. /*: FileController*/
  689. ) {
  690. requireMethods('FileController', ['saveFile', 'saveBase64'], controller);
  691. config['FileController'] = controller;
  692. },
  693. getFileController: function ()
  694. /*: FileController*/
  695. {
  696. return config['FileController'];
  697. },
  698. setInstallationController: function (controller
  699. /*: InstallationController*/
  700. ) {
  701. requireMethods('InstallationController', ['currentInstallationId'], controller);
  702. config['InstallationController'] = controller;
  703. },
  704. getInstallationController: function ()
  705. /*: InstallationController*/
  706. {
  707. return config['InstallationController'];
  708. },
  709. setObjectController: function (controller
  710. /*: ObjectController*/
  711. ) {
  712. requireMethods('ObjectController', ['save', 'fetch', 'destroy'], controller);
  713. config['ObjectController'] = controller;
  714. },
  715. getObjectController: function ()
  716. /*: ObjectController*/
  717. {
  718. return config['ObjectController'];
  719. },
  720. setObjectStateController: function (controller
  721. /*: ObjectStateController*/
  722. ) {
  723. requireMethods('ObjectStateController', ['getState', 'initializeState', 'removeState', 'getServerData', 'setServerData', 'getPendingOps', 'setPendingOp', 'pushPendingState', 'popPendingState', 'mergeFirstPendingState', 'getObjectCache', 'estimateAttribute', 'estimateAttributes', 'commitServerChanges', 'enqueueTask', 'clearAllState'], controller);
  724. config['ObjectStateController'] = controller;
  725. },
  726. getObjectStateController: function ()
  727. /*: ObjectStateController*/
  728. {
  729. return config['ObjectStateController'];
  730. },
  731. setPushController: function (controller
  732. /*: PushController*/
  733. ) {
  734. requireMethods('PushController', ['send'], controller);
  735. config['PushController'] = controller;
  736. },
  737. getPushController: function ()
  738. /*: PushController*/
  739. {
  740. return config['PushController'];
  741. },
  742. setQueryController: function (controller
  743. /*: QueryController*/
  744. ) {
  745. requireMethods('QueryController', ['find', 'aggregate'], controller);
  746. config['QueryController'] = controller;
  747. },
  748. getQueryController: function ()
  749. /*: QueryController*/
  750. {
  751. return config['QueryController'];
  752. },
  753. setRESTController: function (controller
  754. /*: RESTController*/
  755. ) {
  756. requireMethods('RESTController', ['request', 'ajax'], controller);
  757. config['RESTController'] = controller;
  758. },
  759. getRESTController: function ()
  760. /*: RESTController*/
  761. {
  762. return config['RESTController'];
  763. },
  764. setSchemaController: function (controller
  765. /*: SchemaController*/
  766. ) {
  767. requireMethods('SchemaController', ['get', 'create', 'update', 'delete', 'send', 'purge'], controller);
  768. config['SchemaController'] = controller;
  769. },
  770. getSchemaController: function ()
  771. /*: SchemaController*/
  772. {
  773. return config['SchemaController'];
  774. },
  775. setSessionController: function (controller
  776. /*: SessionController*/
  777. ) {
  778. requireMethods('SessionController', ['getSession'], controller);
  779. config['SessionController'] = controller;
  780. },
  781. getSessionController: function ()
  782. /*: SessionController*/
  783. {
  784. return config['SessionController'];
  785. },
  786. setStorageController: function (controller
  787. /*: StorageController*/
  788. ) {
  789. if (controller.async) {
  790. requireMethods('An async StorageController', ['getItemAsync', 'setItemAsync', 'removeItemAsync', 'getAllKeysAsync'], controller);
  791. } else {
  792. requireMethods('A synchronous StorageController', ['getItem', 'setItem', 'removeItem', 'getAllKeys'], controller);
  793. }
  794. config['StorageController'] = controller;
  795. },
  796. setLocalDatastoreController: function (controller
  797. /*: LocalDatastoreController*/
  798. ) {
  799. requireMethods('LocalDatastoreController', ['pinWithName', 'fromPinWithName', 'unPinWithName', 'getAllContents', 'clear'], controller);
  800. config['LocalDatastoreController'] = controller;
  801. },
  802. getLocalDatastoreController: function ()
  803. /*: LocalDatastoreController*/
  804. {
  805. return config['LocalDatastoreController'];
  806. },
  807. setLocalDatastore: function (store
  808. /*: any*/
  809. ) {
  810. config['LocalDatastore'] = store;
  811. },
  812. getLocalDatastore: function () {
  813. return config['LocalDatastore'];
  814. },
  815. getStorageController: function ()
  816. /*: StorageController*/
  817. {
  818. return config['StorageController'];
  819. },
  820. setAsyncStorage: function (storage
  821. /*: any*/
  822. ) {
  823. config['AsyncStorage'] = storage;
  824. },
  825. getAsyncStorage: function () {
  826. return config['AsyncStorage'];
  827. },
  828. setWebSocketController: function (controller
  829. /*: WebSocketController*/
  830. ) {
  831. config['WebSocketController'] = controller;
  832. },
  833. getWebSocketController: function ()
  834. /*: WebSocketController*/
  835. {
  836. return config['WebSocketController'];
  837. },
  838. setUserController: function (controller
  839. /*: UserController*/
  840. ) {
  841. requireMethods('UserController', ['setCurrentUser', 'currentUser', 'currentUserAsync', 'signUp', 'logIn', 'become', 'logOut', 'me', 'requestPasswordReset', 'upgradeToRevocableSession', 'requestEmailVerification', 'verifyPassword', 'linkWith'], controller);
  842. config['UserController'] = controller;
  843. },
  844. getUserController: function ()
  845. /*: UserController*/
  846. {
  847. return config['UserController'];
  848. },
  849. setLiveQueryController: function (controller
  850. /*: any*/
  851. ) {
  852. requireMethods('LiveQueryController', ['setDefaultLiveQueryClient', 'getDefaultLiveQueryClient', '_clearCachedDefaultClient'], controller);
  853. config['LiveQueryController'] = controller;
  854. },
  855. getLiveQueryController: function ()
  856. /*: any*/
  857. {
  858. return config['LiveQueryController'];
  859. },
  860. setHooksController: function (controller
  861. /*: HooksController*/
  862. ) {
  863. requireMethods('HooksController', ['create', 'get', 'update', 'remove'], controller);
  864. config['HooksController'] = controller;
  865. },
  866. getHooksController: function ()
  867. /*: HooksController*/
  868. {
  869. return config['HooksController'];
  870. }
  871. };
  872. }).call(this)}).call(this,_dereq_('_process'))
  873. },{"@babel/runtime-corejs3/core-js-stable/instance/concat":58,"@babel/runtime-corejs3/core-js-stable/instance/for-each":64,"@babel/runtime-corejs3/helpers/interopRequireDefault":128,"_process":145}],5:[function(_dereq_,module,exports){
  874. "use strict";
  875. var _interopRequireDefault = _dereq_("@babel/runtime-corejs3/helpers/interopRequireDefault");
  876. var _stringify = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/json/stringify"));
  877. var AES;
  878. var ENC;
  879. AES = _dereq_('crypto-js/aes');
  880. ENC = _dereq_('crypto-js/enc-utf8');
  881. var CryptoJS;
  882. var CryptoController = {
  883. encrypt: function (obj
  884. /*: any*/
  885. , secretKey
  886. /*: string*/
  887. )
  888. /*: ?string*/
  889. {
  890. var encrypted = AES.encrypt((0, _stringify.default)(obj), secretKey);
  891. return encrypted.toString();
  892. },
  893. decrypt: function (encryptedText
  894. /*: string*/
  895. , secretKey
  896. /*: string*/
  897. )
  898. /*: ?string*/
  899. {
  900. var decryptedStr = AES.decrypt(encryptedText, secretKey).toString(ENC);
  901. return decryptedStr;
  902. }
  903. };
  904. module.exports = CryptoController;
  905. },{"@babel/runtime-corejs3/core-js-stable/json/stringify":76,"@babel/runtime-corejs3/helpers/interopRequireDefault":128,"crypto-js/aes":596,"crypto-js/enc-utf8":600}],6:[function(_dereq_,module,exports){
  906. "use strict";
  907. /**
  908. * Copyright (c) 2015-present, Parse, LLC.
  909. * All rights reserved.
  910. *
  911. * This source code is licensed under the BSD-style license found in the
  912. * LICENSE file in the root directory of this source tree. An additional grant
  913. * of patent rights can be found in the PATENTS file in the same directory.
  914. *
  915. * This is a simple wrapper to unify EventEmitter implementations across platforms.
  916. */
  917. module.exports = _dereq_('events').EventEmitter;
  918. var EventEmitter;
  919. },{"events":605}],7:[function(_dereq_,module,exports){
  920. "use strict";
  921. var _interopRequireDefault = _dereq_("@babel/runtime-corejs3/helpers/interopRequireDefault");
  922. var _sliceInstanceProperty = _dereq_("@babel/runtime-corejs3/core-js-stable/instance/slice");
  923. var _reverseInstanceProperty = _dereq_("@babel/runtime-corejs3/core-js-stable/instance/reverse");
  924. var _Promise = _dereq_("@babel/runtime-corejs3/core-js-stable/promise");
  925. var _Object$setPrototypeOf = _dereq_("@babel/runtime-corejs3/core-js-stable/object/set-prototype-of");
  926. var _typeof = _dereq_("@babel/runtime-corejs3/helpers/typeof");
  927. var _forEachInstanceProperty = _dereq_("@babel/runtime-corejs3/core-js-stable/instance/for-each");
  928. var _Object$getPrototypeOf = _dereq_("@babel/runtime-corejs3/core-js-stable/object/get-prototype-of");
  929. var _Object$create = _dereq_("@babel/runtime-corejs3/core-js-stable/object/create");
  930. var _Object$defineProperty = _dereq_("@babel/runtime-corejs3/core-js-stable/object/define-property");
  931. var _Symbol = _dereq_("@babel/runtime-corejs3/core-js-stable/symbol");
  932. var _find = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/instance/find"));
  933. var _setInterval2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/set-interval"));
  934. var _toConsumableArray2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/helpers/toConsumableArray"));
  935. var _findIndex = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/instance/find-index"));
  936. var _splice = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/instance/splice"));
  937. var _stringify = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/json/stringify"));
  938. var _asyncToGenerator2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/helpers/asyncToGenerator"));
  939. var _CoreManager = _interopRequireDefault(_dereq_("./CoreManager"));
  940. var _ParseObject = _interopRequireDefault(_dereq_("./ParseObject"));
  941. var _ParseQuery = _interopRequireDefault(_dereq_("./ParseQuery"));
  942. var _Storage = _interopRequireDefault(_dereq_("./Storage"));
  943. function _regeneratorRuntime() {
  944. "use strict";
  945. /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */
  946. _regeneratorRuntime = function () {
  947. return exports;
  948. };
  949. var exports = {},
  950. Op = Object.prototype,
  951. hasOwn = Op.hasOwnProperty,
  952. $Symbol = "function" == typeof _Symbol ? _Symbol : {},
  953. iteratorSymbol = $Symbol.iterator || "@@iterator",
  954. asyncIteratorSymbol = $Symbol.asyncIterator || "@@asyncIterator",
  955. toStringTagSymbol = $Symbol.toStringTag || "@@toStringTag";
  956. function define(obj, key, value) {
  957. return _Object$defineProperty(obj, key, {
  958. value: value,
  959. enumerable: !0,
  960. configurable: !0,
  961. writable: !0
  962. }), obj[key];
  963. }
  964. try {
  965. define({}, "");
  966. } catch (err) {
  967. define = function (obj, key, value) {
  968. return obj[key] = value;
  969. };
  970. }
  971. function wrap(innerFn, outerFn, self, tryLocsList) {
  972. var protoGenerator = outerFn && outerFn.prototype instanceof Generator ? outerFn : Generator,
  973. generator = _Object$create(protoGenerator.prototype),
  974. context = new Context(tryLocsList || []);
  975. return generator._invoke = function (innerFn, self, context) {
  976. var state = "suspendedStart";
  977. return function (method, arg) {
  978. if ("executing" === state) throw new Error("Generator is already running");
  979. if ("completed" === state) {
  980. if ("throw" === method) throw arg;
  981. return doneResult();
  982. }
  983. for (context.method = method, context.arg = arg;;) {
  984. var delegate = context.delegate;
  985. if (delegate) {
  986. var delegateResult = maybeInvokeDelegate(delegate, context);
  987. if (delegateResult) {
  988. if (delegateResult === ContinueSentinel) continue;
  989. return delegateResult;
  990. }
  991. }
  992. if ("next" === context.method) context.sent = context._sent = context.arg;else if ("throw" === context.method) {
  993. if ("suspendedStart" === state) throw state = "completed", context.arg;
  994. context.dispatchException(context.arg);
  995. } else "return" === context.method && context.abrupt("return", context.arg);
  996. state = "executing";
  997. var record = tryCatch(innerFn, self, context);
  998. if ("normal" === record.type) {
  999. if (state = context.done ? "completed" : "suspendedYield", record.arg === ContinueSentinel) continue;
  1000. return {
  1001. value: record.arg,
  1002. done: context.done
  1003. };
  1004. }
  1005. "throw" === record.type && (state = "completed", context.method = "throw", context.arg = record.arg);
  1006. }
  1007. };
  1008. }(innerFn, self, context), generator;
  1009. }
  1010. function tryCatch(fn, obj, arg) {
  1011. try {
  1012. return {
  1013. type: "normal",
  1014. arg: fn.call(obj, arg)
  1015. };
  1016. } catch (err) {
  1017. return {
  1018. type: "throw",
  1019. arg: err
  1020. };
  1021. }
  1022. }
  1023. exports.wrap = wrap;
  1024. var ContinueSentinel = {};
  1025. function Generator() {}
  1026. function GeneratorFunction() {}
  1027. function GeneratorFunctionPrototype() {}
  1028. var IteratorPrototype = {};
  1029. define(IteratorPrototype, iteratorSymbol, function () {
  1030. return this;
  1031. });
  1032. var getProto = _Object$getPrototypeOf,
  1033. NativeIteratorPrototype = getProto && getProto(getProto(values([])));
  1034. NativeIteratorPrototype && NativeIteratorPrototype !== Op && hasOwn.call(NativeIteratorPrototype, iteratorSymbol) && (IteratorPrototype = NativeIteratorPrototype);
  1035. var Gp = GeneratorFunctionPrototype.prototype = Generator.prototype = _Object$create(IteratorPrototype);
  1036. function defineIteratorMethods(prototype) {
  1037. var _context9;
  1038. _forEachInstanceProperty(_context9 = ["next", "throw", "return"]).call(_context9, function (method) {
  1039. define(prototype, method, function (arg) {
  1040. return this._invoke(method, arg);
  1041. });
  1042. });
  1043. }
  1044. function AsyncIterator(generator, PromiseImpl) {
  1045. function invoke(method, arg, resolve, reject) {
  1046. var record = tryCatch(generator[method], generator, arg);
  1047. if ("throw" !== record.type) {
  1048. var result = record.arg,
  1049. value = result.value;
  1050. return value && "object" == _typeof(value) && hasOwn.call(value, "__await") ? PromiseImpl.resolve(value.__await).then(function (value) {
  1051. invoke("next", value, resolve, reject);
  1052. }, function (err) {
  1053. invoke("throw", err, resolve, reject);
  1054. }) : PromiseImpl.resolve(value).then(function (unwrapped) {
  1055. result.value = unwrapped, resolve(result);
  1056. }, function (error) {
  1057. return invoke("throw", error, resolve, reject);
  1058. });
  1059. }
  1060. reject(record.arg);
  1061. }
  1062. var previousPromise;
  1063. this._invoke = function (method, arg) {
  1064. function callInvokeWithMethodAndArg() {
  1065. return new PromiseImpl(function (resolve, reject) {
  1066. invoke(method, arg, resolve, reject);
  1067. });
  1068. }
  1069. return previousPromise = previousPromise ? previousPromise.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg();
  1070. };
  1071. }
  1072. function maybeInvokeDelegate(delegate, context) {
  1073. var method = delegate.iterator[context.method];
  1074. if (undefined === method) {
  1075. if (context.delegate = null, "throw" === context.method) {
  1076. if (delegate.iterator.return && (context.method = "return", context.arg = undefined, maybeInvokeDelegate(delegate, context), "throw" === context.method)) return ContinueSentinel;
  1077. context.method = "throw", context.arg = new TypeError("The iterator does not provide a 'throw' method");
  1078. }
  1079. return ContinueSentinel;
  1080. }
  1081. var record = tryCatch(method, delegate.iterator, context.arg);
  1082. if ("throw" === record.type) return context.method = "throw", context.arg = record.arg, context.delegate = null, ContinueSentinel;
  1083. var info = record.arg;
  1084. return info ? info.done ? (context[delegate.resultName] = info.value, context.next = delegate.nextLoc, "return" !== context.method && (context.method = "next", context.arg = undefined), context.delegate = null, ContinueSentinel) : info : (context.method = "throw", context.arg = new TypeError("iterator result is not an object"), context.delegate = null, ContinueSentinel);
  1085. }
  1086. function pushTryEntry(locs) {
  1087. var entry = {
  1088. tryLoc: locs[0]
  1089. };
  1090. 1 in locs && (entry.catchLoc = locs[1]), 2 in locs && (entry.finallyLoc = locs[2], entry.afterLoc = locs[3]), this.tryEntries.push(entry);
  1091. }
  1092. function resetTryEntry(entry) {
  1093. var record = entry.completion || {};
  1094. record.type = "normal", delete record.arg, entry.completion = record;
  1095. }
  1096. function Context(tryLocsList) {
  1097. this.tryEntries = [{
  1098. tryLoc: "root"
  1099. }], _forEachInstanceProperty(tryLocsList).call(tryLocsList, pushTryEntry, this), this.reset(!0);
  1100. }
  1101. function values(iterable) {
  1102. if (iterable) {
  1103. var iteratorMethod = iterable[iteratorSymbol];
  1104. if (iteratorMethod) return iteratorMethod.call(iterable);
  1105. if ("function" == typeof iterable.next) return iterable;
  1106. if (!isNaN(iterable.length)) {
  1107. var i = -1,
  1108. next = function next() {
  1109. for (; ++i < iterable.length;) {
  1110. if (hasOwn.call(iterable, i)) return next.value = iterable[i], next.done = !1, next;
  1111. }
  1112. return next.value = undefined, next.done = !0, next;
  1113. };
  1114. return next.next = next;
  1115. }
  1116. }
  1117. return {
  1118. next: doneResult
  1119. };
  1120. }
  1121. function doneResult() {
  1122. return {
  1123. value: undefined,
  1124. done: !0
  1125. };
  1126. }
  1127. return GeneratorFunction.prototype = GeneratorFunctionPrototype, define(Gp, "constructor", GeneratorFunctionPrototype), define(GeneratorFunctionPrototype, "constructor", GeneratorFunction), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, toStringTagSymbol, "GeneratorFunction"), exports.isGeneratorFunction = function (genFun) {
  1128. var ctor = "function" == typeof genFun && genFun.constructor;
  1129. return !!ctor && (ctor === GeneratorFunction || "GeneratorFunction" === (ctor.displayName || ctor.name));
  1130. }, exports.mark = function (genFun) {
  1131. return _Object$setPrototypeOf ? _Object$setPrototypeOf(genFun, GeneratorFunctionPrototype) : (genFun.__proto__ = GeneratorFunctionPrototype, define(genFun, toStringTagSymbol, "GeneratorFunction")), genFun.prototype = _Object$create(Gp), genFun;
  1132. }, exports.awrap = function (arg) {
  1133. return {
  1134. __await: arg
  1135. };
  1136. }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, asyncIteratorSymbol, function () {
  1137. return this;
  1138. }), exports.AsyncIterator = AsyncIterator, exports.async = function (innerFn, outerFn, self, tryLocsList, PromiseImpl) {
  1139. void 0 === PromiseImpl && (PromiseImpl = _Promise);
  1140. var iter = new AsyncIterator(wrap(innerFn, outerFn, self, tryLocsList), PromiseImpl);
  1141. return exports.isGeneratorFunction(outerFn) ? iter : iter.next().then(function (result) {
  1142. return result.done ? result.value : iter.next();
  1143. });
  1144. }, defineIteratorMethods(Gp), define(Gp, toStringTagSymbol, "Generator"), define(Gp, iteratorSymbol, function () {
  1145. return this;
  1146. }), define(Gp, "toString", function () {
  1147. return "[object Generator]";
  1148. }), exports.keys = function (object) {
  1149. var keys = [];
  1150. for (var key in object) {
  1151. keys.push(key);
  1152. }
  1153. return _reverseInstanceProperty(keys).call(keys), function next() {
  1154. for (; keys.length;) {
  1155. var key = keys.pop();
  1156. if (key in object) return next.value = key, next.done = !1, next;
  1157. }
  1158. return next.done = !0, next;
  1159. };
  1160. }, exports.values = values, Context.prototype = {
  1161. constructor: Context,
  1162. reset: function (skipTempReset) {
  1163. var _context10;
  1164. if (this.prev = 0, this.next = 0, this.sent = this._sent = undefined, this.done = !1, this.delegate = null, this.method = "next", this.arg = undefined, _forEachInstanceProperty(_context10 = this.tryEntries).call(_context10, resetTryEntry), !skipTempReset) for (var name in this) {
  1165. "t" === name.charAt(0) && hasOwn.call(this, name) && !isNaN(+_sliceInstanceProperty(name).call(name, 1)) && (this[name] = undefined);
  1166. }
  1167. },
  1168. stop: function () {
  1169. this.done = !0;
  1170. var rootRecord = this.tryEntries[0].completion;
  1171. if ("throw" === rootRecord.type) throw rootRecord.arg;
  1172. return this.rval;
  1173. },
  1174. dispatchException: function (exception) {
  1175. if (this.done) throw exception;
  1176. var context = this;
  1177. function handle(loc, caught) {
  1178. return record.type = "throw", record.arg = exception, context.next = loc, caught && (context.method = "next", context.arg = undefined), !!caught;
  1179. }
  1180. for (var i = this.tryEntries.length - 1; i >= 0; --i) {
  1181. var entry = this.tryEntries[i],
  1182. record = entry.completion;
  1183. if ("root" === entry.tryLoc) return handle("end");
  1184. if (entry.tryLoc <= this.prev) {
  1185. var hasCatch = hasOwn.call(entry, "catchLoc"),
  1186. hasFinally = hasOwn.call(entry, "finallyLoc");
  1187. if (hasCatch && hasFinally) {
  1188. if (this.prev < entry.catchLoc) return handle(entry.catchLoc, !0);
  1189. if (this.prev < entry.finallyLoc) return handle(entry.finallyLoc);
  1190. } else if (hasCatch) {
  1191. if (this.prev < entry.catchLoc) return handle(entry.catchLoc, !0);
  1192. } else {
  1193. if (!hasFinally) throw new Error("try statement without catch or finally");
  1194. if (this.prev < entry.finallyLoc) return handle(entry.finallyLoc);
  1195. }
  1196. }
  1197. }
  1198. },
  1199. abrupt: function (type, arg) {
  1200. for (var i = this.tryEntries.length - 1; i >= 0; --i) {
  1201. var entry = this.tryEntries[i];
  1202. if (entry.tryLoc <= this.prev && hasOwn.call(entry, "finallyLoc") && this.prev < entry.finallyLoc) {
  1203. var finallyEntry = entry;
  1204. break;
  1205. }
  1206. }
  1207. finallyEntry && ("break" === type || "continue" === type) && finallyEntry.tryLoc <= arg && arg <= finallyEntry.finallyLoc && (finallyEntry = null);
  1208. var record = finallyEntry ? finallyEntry.completion : {};
  1209. return record.type = type, record.arg = arg, finallyEntry ? (this.method = "next", this.next = finallyEntry.finallyLoc, ContinueSentinel) : this.complete(record);
  1210. },
  1211. complete: function (record, afterLoc) {
  1212. if ("throw" === record.type) throw record.arg;
  1213. return "break" === record.type || "continue" === record.type ? this.next = record.arg : "return" === record.type ? (this.rval = this.arg = record.arg, this.method = "return", this.next = "end") : "normal" === record.type && afterLoc && (this.next = afterLoc), ContinueSentinel;
  1214. },
  1215. finish: function (finallyLoc) {
  1216. for (var i = this.tryEntries.length - 1; i >= 0; --i) {
  1217. var entry = this.tryEntries[i];
  1218. if (entry.finallyLoc === finallyLoc) return this.complete(entry.completion, entry.afterLoc), resetTryEntry(entry), ContinueSentinel;
  1219. }
  1220. },
  1221. catch: function (tryLoc) {
  1222. for (var i = this.tryEntries.length - 1; i >= 0; --i) {
  1223. var entry = this.tryEntries[i];
  1224. if (entry.tryLoc === tryLoc) {
  1225. var record = entry.completion;
  1226. if ("throw" === record.type) {
  1227. var thrown = record.arg;
  1228. resetTryEntry(entry);
  1229. }
  1230. return thrown;
  1231. }
  1232. }
  1233. throw new Error("illegal catch attempt");
  1234. },
  1235. delegateYield: function (iterable, resultName, nextLoc) {
  1236. return this.delegate = {
  1237. iterator: values(iterable),
  1238. resultName: resultName,
  1239. nextLoc: nextLoc
  1240. }, "next" === this.method && (this.arg = undefined), ContinueSentinel;
  1241. }
  1242. }, exports;
  1243. }
  1244. var QUEUE_KEY = 'Parse/Eventually/Queue';
  1245. var queueCache = [];
  1246. var dirtyCache = true;
  1247. var polling = undefined;
  1248. /**
  1249. * Provides utility functions to queue objects that will be
  1250. * saved to the server at a later date.
  1251. *
  1252. * @class Parse.EventuallyQueue
  1253. * @static
  1254. */
  1255. var EventuallyQueue = {
  1256. /**
  1257. * Add object to queue with save operation.
  1258. *
  1259. * @function save
  1260. * @name Parse.EventuallyQueue.save
  1261. * @param {ParseObject} object Parse.Object to be saved eventually
  1262. * @param {object} [serverOptions] See {@link https://parseplatform.org/Parse-SDK-JS/api/master/Parse.Object.html#save Parse.Object.save} options.
  1263. * @returns {Promise} A promise that is fulfilled if object is added to queue.
  1264. * @static
  1265. * @see Parse.Object#saveEventually
  1266. */
  1267. save: function (object
  1268. /*: ParseObject*/
  1269. )
  1270. /*: Promise*/
  1271. {
  1272. var serverOptions
  1273. /*: SaveOptions*/
  1274. = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
  1275. return this.enqueue('save', object, serverOptions);
  1276. },
  1277. /**
  1278. * Add object to queue with save operation.
  1279. *
  1280. * @function destroy
  1281. * @name Parse.EventuallyQueue.destroy
  1282. * @param {ParseObject} object Parse.Object to be destroyed eventually
  1283. * @param {object} [serverOptions] See {@link https://parseplatform.org/Parse-SDK-JS/api/master/Parse.Object.html#destroy Parse.Object.destroy} options
  1284. * @returns {Promise} A promise that is fulfilled if object is added to queue.
  1285. * @static
  1286. * @see Parse.Object#destroyEventually
  1287. */
  1288. destroy: function (object
  1289. /*: ParseObject*/
  1290. )
  1291. /*: Promise*/
  1292. {
  1293. var serverOptions
  1294. /*: RequestOptions*/
  1295. = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
  1296. return this.enqueue('destroy', object, serverOptions);
  1297. },
  1298. /**
  1299. * Generate unique identifier to avoid duplicates and maintain previous state.
  1300. *
  1301. * @param {string} action save / destroy
  1302. * @param {object} object Parse.Object to be queued
  1303. * @returns {string}
  1304. * @static
  1305. * @ignore
  1306. */
  1307. generateQueueId: function (action
  1308. /*: string*/
  1309. , object
  1310. /*: ParseObject*/
  1311. )
  1312. /*: string*/
  1313. {
  1314. object._getId();
  1315. var className = object.className,
  1316. id = object.id,
  1317. _localId = object._localId;
  1318. var uniqueId = object.get('hash') || _localId;
  1319. return [action, className, id, uniqueId].join('_');
  1320. },
  1321. /**
  1322. * Build queue object and add to queue.
  1323. *
  1324. * @param {string} action save / destroy
  1325. * @param {object} object Parse.Object to be queued
  1326. * @param {object} [serverOptions]
  1327. * @returns {Promise} A promise that is fulfilled if object is added to queue.
  1328. * @static
  1329. * @ignore
  1330. */
  1331. enqueue: function (action
  1332. /*: string*/
  1333. , object
  1334. /*: ParseObject*/
  1335. , serverOptions
  1336. /*: SaveOptions | RequestOptions*/
  1337. )
  1338. /*: Promise*/
  1339. {
  1340. var _this = this;
  1341. return (0, _asyncToGenerator2.default)( /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
  1342. var queueData, queueId, index, prop;
  1343. return _regeneratorRuntime().wrap(function _callee$(_context) {
  1344. while (1) {
  1345. switch (_context.prev = _context.next) {
  1346. case 0:
  1347. _context.next = 2;
  1348. return _this.getQueue();
  1349. case 2:
  1350. queueData = _context.sent;
  1351. queueId = _this.generateQueueId(action, object);
  1352. index = _this.queueItemExists(queueData, queueId);
  1353. if (index > -1) {
  1354. // Add cached values to new object if they don't exist
  1355. for (prop in queueData[index].object) {
  1356. if (typeof object.get(prop) === 'undefined') {
  1357. object.set(prop, queueData[index].object[prop]);
  1358. }
  1359. }
  1360. } else {
  1361. index = queueData.length;
  1362. }
  1363. queueData[index] = {
  1364. queueId: queueId,
  1365. action: action,
  1366. object: object.toJSON(),
  1367. serverOptions: serverOptions,
  1368. id: object.id,
  1369. className: object.className,
  1370. hash: object.get('hash'),
  1371. createdAt: new Date()
  1372. };
  1373. return _context.abrupt("return", _this.setQueue(queueData));
  1374. case 8:
  1375. case "end":
  1376. return _context.stop();
  1377. }
  1378. }
  1379. }, _callee);
  1380. }))();
  1381. },
  1382. store: function store(data) {
  1383. return _Storage.default.setItemAsync(QUEUE_KEY, (0, _stringify.default)(data));
  1384. },
  1385. load: function load() {
  1386. return _Storage.default.getItemAsync(QUEUE_KEY);
  1387. },
  1388. /**
  1389. * Sets the in-memory queue from local storage and returns.
  1390. *
  1391. * @function getQueue
  1392. * @name Parse.EventuallyQueue.getQueue
  1393. * @returns {Promise<Array>}
  1394. * @static
  1395. */
  1396. getQueue: function getQueue()
  1397. /*: Promise<Array>*/
  1398. {
  1399. var _this2 = this;
  1400. return (0, _asyncToGenerator2.default)( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2() {
  1401. return _regeneratorRuntime().wrap(function _callee2$(_context2) {
  1402. while (1) {
  1403. switch (_context2.prev = _context2.next) {
  1404. case 0:
  1405. if (!dirtyCache) {
  1406. _context2.next = 10;
  1407. break;
  1408. }
  1409. _context2.t0 = JSON;
  1410. _context2.next = 4;
  1411. return _this2.load();
  1412. case 4:
  1413. _context2.t1 = _context2.sent;
  1414. if (_context2.t1) {
  1415. _context2.next = 7;
  1416. break;
  1417. }
  1418. _context2.t1 = '[]';
  1419. case 7:
  1420. _context2.t2 = _context2.t1;
  1421. queueCache = _context2.t0.parse.call(_context2.t0, _context2.t2);
  1422. dirtyCache = false;
  1423. case 10:
  1424. return _context2.abrupt("return", queueCache);
  1425. case 11:
  1426. case "end":
  1427. return _context2.stop();
  1428. }
  1429. }
  1430. }, _callee2);
  1431. }))();
  1432. },
  1433. /**
  1434. * Saves the queue to local storage
  1435. *
  1436. * @param {Queue} queue Queue containing Parse.Object data.
  1437. * @returns {Promise} A promise that is fulfilled when queue is stored.
  1438. * @static
  1439. * @ignore
  1440. */
  1441. setQueue: function setQueue(queue
  1442. /*: Queue*/
  1443. )
  1444. /*: Promise<void>*/
  1445. {
  1446. queueCache = queue;
  1447. return this.store(queueCache);
  1448. },
  1449. /**
  1450. * Removes Parse.Object data from queue.
  1451. *
  1452. * @param {string} queueId Unique identifier for Parse.Object data.
  1453. * @returns {Promise} A promise that is fulfilled when queue is stored.
  1454. * @static
  1455. * @ignore
  1456. */
  1457. remove: function remove(queueId
  1458. /*: string*/
  1459. )
  1460. /*: Promise<void>*/
  1461. {
  1462. var _this3 = this;
  1463. return (0, _asyncToGenerator2.default)( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3() {
  1464. var queueData, index;
  1465. return _regeneratorRuntime().wrap(function _callee3$(_context3) {
  1466. while (1) {
  1467. switch (_context3.prev = _context3.next) {
  1468. case 0:
  1469. _context3.next = 2;
  1470. return _this3.getQueue();
  1471. case 2:
  1472. queueData = _context3.sent;
  1473. index = _this3.queueItemExists(queueData, queueId);
  1474. if (!(index > -1)) {
  1475. _context3.next = 8;
  1476. break;
  1477. }
  1478. (0, _splice.default)(queueData).call(queueData, index, 1);
  1479. _context3.next = 8;
  1480. return _this3.setQueue(queueData);
  1481. case 8:
  1482. case "end":
  1483. return _context3.stop();
  1484. }
  1485. }
  1486. }, _callee3);
  1487. }))();
  1488. },
  1489. /**
  1490. * Removes all objects from queue.
  1491. *
  1492. * @function clear
  1493. * @name Parse.EventuallyQueue.clear
  1494. * @returns {Promise} A promise that is fulfilled when queue is cleared.
  1495. * @static
  1496. */
  1497. clear: function clear()
  1498. /*: Promise*/
  1499. {
  1500. queueCache = [];
  1501. return this.store([]);
  1502. },
  1503. /**
  1504. * Return the index of a queueId in the queue. Returns -1 if not found.
  1505. *
  1506. * @param {Queue} queue Queue containing Parse.Object data.
  1507. * @param {string} queueId Unique identifier for Parse.Object data.
  1508. * @returns {number}
  1509. * @static
  1510. * @ignore
  1511. */
  1512. queueItemExists: function queueItemExists(queue
  1513. /*: Queue*/
  1514. , queueId
  1515. /*: string*/
  1516. )
  1517. /*: number*/
  1518. {
  1519. return (0, _findIndex.default)(queue).call(queue, function (data) {
  1520. return data.queueId === queueId;
  1521. });
  1522. },
  1523. /**
  1524. * Return the number of objects in the queue.
  1525. *
  1526. * @function length
  1527. * @name Parse.EventuallyQueue.length
  1528. * @returns {number}
  1529. * @static
  1530. */
  1531. length: function length()
  1532. /*: number*/
  1533. {
  1534. var _this4 = this;
  1535. return (0, _asyncToGenerator2.default)( /*#__PURE__*/_regeneratorRuntime().mark(function _callee4() {
  1536. var queueData;
  1537. return _regeneratorRuntime().wrap(function _callee4$(_context4) {
  1538. while (1) {
  1539. switch (_context4.prev = _context4.next) {
  1540. case 0:
  1541. _context4.next = 2;
  1542. return _this4.getQueue();
  1543. case 2:
  1544. queueData = _context4.sent;
  1545. return _context4.abrupt("return", queueData.length);
  1546. case 4:
  1547. case "end":
  1548. return _context4.stop();
  1549. }
  1550. }
  1551. }, _callee4);
  1552. }))();
  1553. },
  1554. /**
  1555. * Sends the queue to the server.
  1556. *
  1557. * @function sendQueue
  1558. * @name Parse.EventuallyQueue.sendQueue
  1559. * @returns {Promise<boolean>} Returns true if queue was sent successfully.
  1560. * @static
  1561. */
  1562. sendQueue: function sendQueue()
  1563. /*: Promise<boolean>*/
  1564. {
  1565. var _this5 = this;
  1566. return (0, _asyncToGenerator2.default)( /*#__PURE__*/_regeneratorRuntime().mark(function _callee5() {
  1567. var queue, queueData, i, queueObject, id, hash, className, ObjectType;
  1568. return _regeneratorRuntime().wrap(function _callee5$(_context5) {
  1569. while (1) {
  1570. switch (_context5.prev = _context5.next) {
  1571. case 0:
  1572. _context5.next = 2;
  1573. return _this5.getQueue();
  1574. case 2:
  1575. queue = _context5.sent;
  1576. queueData = (0, _toConsumableArray2.default)(queue);
  1577. if (!(queueData.length === 0)) {
  1578. _context5.next = 6;
  1579. break;
  1580. }
  1581. return _context5.abrupt("return", false);
  1582. case 6:
  1583. i = 0;
  1584. case 7:
  1585. if (!(i < queueData.length)) {
  1586. _context5.next = 26;
  1587. break;
  1588. }
  1589. queueObject = queueData[i];
  1590. id = queueObject.id, hash = queueObject.hash, className = queueObject.className;
  1591. ObjectType = _ParseObject.default.extend(className);
  1592. if (!id) {
  1593. _context5.next = 16;
  1594. break;
  1595. }
  1596. _context5.next = 14;
  1597. return _this5.process.byId(ObjectType, queueObject);
  1598. case 14:
  1599. _context5.next = 23;
  1600. break;
  1601. case 16:
  1602. if (!hash) {
  1603. _context5.next = 21;
  1604. break;
  1605. }
  1606. _context5.next = 19;
  1607. return _this5.process.byHash(ObjectType, queueObject);
  1608. case 19:
  1609. _context5.next = 23;
  1610. break;
  1611. case 21:
  1612. _context5.next = 23;
  1613. return _this5.process.create(ObjectType, queueObject);
  1614. case 23:
  1615. i += 1;
  1616. _context5.next = 7;
  1617. break;
  1618. case 26:
  1619. return _context5.abrupt("return", true);
  1620. case 27:
  1621. case "end":
  1622. return _context5.stop();
  1623. }
  1624. }
  1625. }, _callee5);
  1626. }))();
  1627. },
  1628. /**
  1629. * Build queue object and add to queue.
  1630. *
  1631. * @param {ParseObject} object Parse.Object to be processed
  1632. * @param {QueueObject} queueObject Parse.Object data from the queue
  1633. * @returns {Promise} A promise that is fulfilled when operation is performed.
  1634. * @static
  1635. * @ignore
  1636. */
  1637. sendQueueCallback: function sendQueueCallback(object
  1638. /*: ParseObject*/
  1639. , queueObject
  1640. /*: QueueObject*/
  1641. )
  1642. /*: Promise<void>*/
  1643. {
  1644. var _this6 = this;
  1645. return (0, _asyncToGenerator2.default)( /*#__PURE__*/_regeneratorRuntime().mark(function _callee6() {
  1646. return _regeneratorRuntime().wrap(function _callee6$(_context6) {
  1647. while (1) {
  1648. switch (_context6.prev = _context6.next) {
  1649. case 0:
  1650. if (object) {
  1651. _context6.next = 2;
  1652. break;
  1653. }
  1654. return _context6.abrupt("return", _this6.remove(queueObject.queueId));
  1655. case 2:
  1656. _context6.t0 = queueObject.action;
  1657. _context6.next = _context6.t0 === 'save' ? 5 : _context6.t0 === 'destroy' ? 20 : 33;
  1658. break;
  1659. case 5:
  1660. if (!(typeof object.updatedAt !== 'undefined' && object.updatedAt > new Date(queueObject.object.createdAt))) {
  1661. _context6.next = 7;
  1662. break;
  1663. }
  1664. return _context6.abrupt("return", _this6.remove(queueObject.queueId));
  1665. case 7:
  1666. _context6.prev = 7;
  1667. _context6.next = 10;
  1668. return object.save(queueObject.object, queueObject.serverOptions);
  1669. case 10:
  1670. _context6.next = 12;
  1671. return _this6.remove(queueObject.queueId);
  1672. case 12:
  1673. _context6.next = 19;
  1674. break;
  1675. case 14:
  1676. _context6.prev = 14;
  1677. _context6.t1 = _context6["catch"](7);
  1678. if (!(_context6.t1.message !== 'XMLHttpRequest failed: "Unable to connect to the Parse API"')) {
  1679. _context6.next = 19;
  1680. break;
  1681. }
  1682. _context6.next = 19;
  1683. return _this6.remove(queueObject.queueId);
  1684. case 19:
  1685. return _context6.abrupt("break", 33);
  1686. case 20:
  1687. _context6.prev = 20;
  1688. _context6.next = 23;
  1689. return object.destroy(queueObject.serverOptions);
  1690. case 23:
  1691. _context6.next = 25;
  1692. return _this6.remove(queueObject.queueId);
  1693. case 25:
  1694. _context6.next = 32;
  1695. break;
  1696. case 27:
  1697. _context6.prev = 27;
  1698. _context6.t2 = _context6["catch"](20);
  1699. if (!(_context6.t2.message !== 'XMLHttpRequest failed: "Unable to connect to the Parse API"')) {
  1700. _context6.next = 32;
  1701. break;
  1702. }
  1703. _context6.next = 32;
  1704. return _this6.remove(queueObject.queueId);
  1705. case 32:
  1706. return _context6.abrupt("break", 33);
  1707. case 33:
  1708. case "end":
  1709. return _context6.stop();
  1710. }
  1711. }
  1712. }, _callee6, null, [[7, 14], [20, 27]]);
  1713. }))();
  1714. },
  1715. /**
  1716. * Start polling server for network connection.
  1717. * Will send queue if connection is established.
  1718. *
  1719. * @function poll
  1720. * @name Parse.EventuallyQueue.poll
  1721. * @param [ms] Milliseconds to ping the server. Default 2000ms
  1722. * @static
  1723. */
  1724. poll: function poll() {
  1725. var _this7 = this;
  1726. var ms
  1727. /*: number*/
  1728. = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 2000;
  1729. if (polling) {
  1730. return;
  1731. }
  1732. polling = (0, _setInterval2.default)(function () {
  1733. var RESTController = _CoreManager.default.getRESTController();
  1734. RESTController.request('GET', 'health').then(function (_ref) {
  1735. var status = _ref.status;
  1736. if (status === 'ok') {
  1737. _this7.stopPoll();
  1738. return _this7.sendQueue();
  1739. }
  1740. }).catch(function (e) {
  1741. return e;
  1742. });
  1743. }, ms);
  1744. },
  1745. /**
  1746. * Turns off polling.
  1747. *
  1748. * @function stopPoll
  1749. * @name Parse.EventuallyQueue.stopPoll
  1750. * @static
  1751. */
  1752. stopPoll: function stopPoll() {
  1753. clearInterval(polling);
  1754. polling = undefined;
  1755. },
  1756. /**
  1757. * Return true if pinging the server.
  1758. *
  1759. * @function isPolling
  1760. * @name Parse.EventuallyQueue.isPolling
  1761. * @returns {boolean}
  1762. * @static
  1763. */
  1764. isPolling: function isPolling()
  1765. /*: boolean*/
  1766. {
  1767. return !!polling;
  1768. },
  1769. _setPolling: function _setPolling(flag
  1770. /*: boolean*/
  1771. ) {
  1772. polling = flag;
  1773. },
  1774. process: {
  1775. create: function create(ObjectType, queueObject) {
  1776. var object = new ObjectType();
  1777. return EventuallyQueue.sendQueueCallback(object, queueObject);
  1778. },
  1779. byId: function byId(ObjectType, queueObject) {
  1780. return (0, _asyncToGenerator2.default)( /*#__PURE__*/_regeneratorRuntime().mark(function _callee7() {
  1781. var sessionToken, query, results;
  1782. return _regeneratorRuntime().wrap(function _callee7$(_context7) {
  1783. while (1) {
  1784. switch (_context7.prev = _context7.next) {
  1785. case 0:
  1786. sessionToken = queueObject.serverOptions.sessionToken;
  1787. query = new _ParseQuery.default(ObjectType);
  1788. query.equalTo('objectId', queueObject.id);
  1789. _context7.next = 5;
  1790. return (0, _find.default)(query).call(query, {
  1791. sessionToken: sessionToken
  1792. });
  1793. case 5:
  1794. results = _context7.sent;
  1795. return _context7.abrupt("return", EventuallyQueue.sendQueueCallback(results[0], queueObject));
  1796. case 7:
  1797. case "end":
  1798. return _context7.stop();
  1799. }
  1800. }
  1801. }, _callee7);
  1802. }))();
  1803. },
  1804. byHash: function byHash(ObjectType, queueObject) {
  1805. return (0, _asyncToGenerator2.default)( /*#__PURE__*/_regeneratorRuntime().mark(function _callee8() {
  1806. var sessionToken, query, results;
  1807. return _regeneratorRuntime().wrap(function _callee8$(_context8) {
  1808. while (1) {
  1809. switch (_context8.prev = _context8.next) {
  1810. case 0:
  1811. sessionToken = queueObject.serverOptions.sessionToken;
  1812. query = new _ParseQuery.default(ObjectType);
  1813. query.equalTo('hash', queueObject.hash);
  1814. _context8.next = 5;
  1815. return (0, _find.default)(query).call(query, {
  1816. sessionToken: sessionToken
  1817. });
  1818. case 5:
  1819. results = _context8.sent;
  1820. if (!(results.length > 0)) {
  1821. _context8.next = 8;
  1822. break;
  1823. }
  1824. return _context8.abrupt("return", EventuallyQueue.sendQueueCallback(results[0], queueObject));
  1825. case 8:
  1826. return _context8.abrupt("return", EventuallyQueue.process.create(ObjectType, queueObject));
  1827. case 9:
  1828. case "end":
  1829. return _context8.stop();
  1830. }
  1831. }
  1832. }, _callee8);
  1833. }))();
  1834. }
  1835. }
  1836. };
  1837. module.exports = EventuallyQueue;
  1838. },{"./CoreManager":4,"./ParseObject":27,"./ParseQuery":30,"./Storage":39,"@babel/runtime-corejs3/core-js-stable/instance/find":63,"@babel/runtime-corejs3/core-js-stable/instance/find-index":62,"@babel/runtime-corejs3/core-js-stable/instance/for-each":64,"@babel/runtime-corejs3/core-js-stable/instance/reverse":70,"@babel/runtime-corejs3/core-js-stable/instance/slice":71,"@babel/runtime-corejs3/core-js-stable/instance/splice":73,"@babel/runtime-corejs3/core-js-stable/json/stringify":76,"@babel/runtime-corejs3/core-js-stable/object/create":80,"@babel/runtime-corejs3/core-js-stable/object/define-property":82,"@babel/runtime-corejs3/core-js-stable/object/get-prototype-of":88,"@babel/runtime-corejs3/core-js-stable/object/set-prototype-of":90,"@babel/runtime-corejs3/core-js-stable/promise":92,"@babel/runtime-corejs3/core-js-stable/set-interval":94,"@babel/runtime-corejs3/core-js-stable/symbol":97,"@babel/runtime-corejs3/helpers/asyncToGenerator":120,"@babel/runtime-corejs3/helpers/interopRequireDefault":128,"@babel/runtime-corejs3/helpers/toConsumableArray":139,"@babel/runtime-corejs3/helpers/typeof":140}],8:[function(_dereq_,module,exports){
  1839. "use strict";
  1840. var _interopRequireDefault = _dereq_("@babel/runtime-corejs3/helpers/interopRequireDefault");
  1841. var _Object$defineProperty = _dereq_("@babel/runtime-corejs3/core-js-stable/object/define-property");
  1842. _Object$defineProperty(exports, "__esModule", {
  1843. value: true
  1844. });
  1845. exports.default = void 0;
  1846. var _ParseUser = _interopRequireDefault(_dereq_("./ParseUser"));
  1847. /**
  1848. * Copyright (c) 2015-present, Parse, LLC.
  1849. * All rights reserved.
  1850. *
  1851. * This source code is licensed under the BSD-style license found in the
  1852. * LICENSE file in the root directory of this source tree. An additional grant
  1853. * of patent rights can be found in the PATENTS file in the same directory.
  1854. *
  1855. * @flow-weak
  1856. */
  1857. /* global FB */
  1858. var initialized = false;
  1859. var requestedPermissions;
  1860. var initOptions;
  1861. var provider = {
  1862. authenticate: function (options) {
  1863. var _this = this;
  1864. if (typeof FB === 'undefined') {
  1865. options.error(this, 'Facebook SDK not found.');
  1866. }
  1867. FB.login(function (response) {
  1868. if (response.authResponse) {
  1869. if (options.success) {
  1870. options.success(_this, {
  1871. id: response.authResponse.userID,
  1872. access_token: response.authResponse.accessToken,
  1873. expiration_date: new Date(response.authResponse.expiresIn * 1000 + new Date().getTime()).toJSON()
  1874. });
  1875. }
  1876. } else {
  1877. if (options.error) {
  1878. options.error(_this, response);
  1879. }
  1880. }
  1881. }, {
  1882. scope: requestedPermissions
  1883. });
  1884. },
  1885. restoreAuthentication: function (authData) {
  1886. if (authData) {
  1887. var newOptions = {};
  1888. if (initOptions) {
  1889. for (var key in initOptions) {
  1890. newOptions[key] = initOptions[key];
  1891. }
  1892. } // Suppress checks for login status from the browser.
  1893. newOptions.status = false; // If the user doesn't match the one known by the FB SDK, log out.
  1894. // Most of the time, the users will match -- it's only in cases where
  1895. // the FB SDK knows of a different user than the one being restored
  1896. // from a Parse User that logged in with username/password.
  1897. var existingResponse = FB.getAuthResponse();
  1898. if (existingResponse && existingResponse.userID !== authData.id) {
  1899. FB.logout();
  1900. }
  1901. FB.init(newOptions);
  1902. }
  1903. return true;
  1904. },
  1905. getAuthType: function () {
  1906. return 'facebook';
  1907. },
  1908. deauthenticate: function () {
  1909. this.restoreAuthentication(null);
  1910. }
  1911. };
  1912. /**
  1913. * Provides a set of utilities for using Parse with Facebook.
  1914. *
  1915. * @class Parse.FacebookUtils
  1916. * @static
  1917. * @hideconstructor
  1918. */
  1919. var FacebookUtils = {
  1920. /**
  1921. * Initializes Parse Facebook integration. Call this function after you
  1922. * have loaded the Facebook Javascript SDK with the same parameters
  1923. * as you would pass to<code>
  1924. * <a href=
  1925. * "https://developers.facebook.com/docs/reference/javascript/FB.init/">
  1926. * FB.init()</a></code>. Parse.FacebookUtils will invoke FB.init() for you
  1927. * with these arguments.
  1928. *
  1929. * @function init
  1930. * @name Parse.FacebookUtils.init
  1931. * @param {object} options Facebook options argument as described here:
  1932. * <a href=
  1933. * "https://developers.facebook.com/docs/reference/javascript/FB.init/">
  1934. * FB.init()</a>. The status flag will be coerced to 'false' because it
  1935. * interferes with Parse Facebook integration. Call FB.getLoginStatus()
  1936. * explicitly if this behavior is required by your application.
  1937. */
  1938. init: function (options) {
  1939. if (typeof FB === 'undefined') {
  1940. throw new Error('The Facebook JavaScript SDK must be loaded before calling init.');
  1941. }
  1942. initOptions = {};
  1943. if (options) {
  1944. for (var key in options) {
  1945. initOptions[key] = options[key];
  1946. }
  1947. }
  1948. if (initOptions.status && typeof console !== 'undefined') {
  1949. var warn = console.warn || console.log || function () {}; // eslint-disable-line no-console
  1950. 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.');
  1951. }
  1952. initOptions.status = false;
  1953. FB.init(initOptions);
  1954. _ParseUser.default._registerAuthenticationProvider(provider);
  1955. initialized = true;
  1956. },
  1957. /**
  1958. * Gets whether the user has their account linked to Facebook.
  1959. *
  1960. * @function isLinked
  1961. * @name Parse.FacebookUtils.isLinked
  1962. * @param {Parse.User} user User to check for a facebook link.
  1963. * The user must be logged in on this device.
  1964. * @returns {boolean} <code>true</code> if the user has their account
  1965. * linked to Facebook.
  1966. */
  1967. isLinked: function (user) {
  1968. return user._isLinked('facebook');
  1969. },
  1970. /**
  1971. * Logs in a user using Facebook. This method delegates to the Facebook
  1972. * SDK to authenticate the user, and then automatically logs in (or
  1973. * creates, in the case where it is a new user) a Parse.User.
  1974. *
  1975. * Standard API:
  1976. *
  1977. * <code>logIn(permission: string, authData: Object);</code>
  1978. *
  1979. * Advanced API: Used for handling your own oAuth tokens
  1980. * {@link https://docs.parseplatform.org/rest/guide/#linking-users}
  1981. *
  1982. * <code>logIn(authData: Object, options?: Object);</code>
  1983. *
  1984. * @function logIn
  1985. * @name Parse.FacebookUtils.logIn
  1986. * @param {(string | object)} permissions The permissions required for Facebook
  1987. * log in. This is a comma-separated string of permissions.
  1988. * Alternatively, supply a Facebook authData object as described in our
  1989. * REST API docs if you want to handle getting facebook auth tokens
  1990. * yourself.
  1991. * @param {object} options MasterKey / SessionToken. Alternatively can be used for authData if permissions is a string
  1992. * @returns {Promise}
  1993. */
  1994. logIn: function (permissions, options) {
  1995. if (!permissions || typeof permissions === 'string') {
  1996. if (!initialized) {
  1997. throw new Error('You must initialize FacebookUtils before calling logIn.');
  1998. }
  1999. requestedPermissions = permissions;
  2000. return _ParseUser.default.logInWith('facebook', options);
  2001. }
  2002. return _ParseUser.default.logInWith('facebook', {
  2003. authData: permissions
  2004. }, options);
  2005. },
  2006. /**
  2007. * Links Facebook to an existing PFUser. This method delegates to the
  2008. * Facebook SDK to authenticate the user, and then automatically links
  2009. * the account to the Parse.User.
  2010. *
  2011. * Standard API:
  2012. *
  2013. * <code>link(user: Parse.User, permission: string, authData?: Object);</code>
  2014. *
  2015. * Advanced API: Used for handling your own oAuth tokens
  2016. * {@link https://docs.parseplatform.org/rest/guide/#linking-users}
  2017. *
  2018. * <code>link(user: Parse.User, authData: Object, options?: FullOptions);</code>
  2019. *
  2020. * @function link
  2021. * @name Parse.FacebookUtils.link
  2022. * @param {Parse.User} user User to link to Facebook. This must be the
  2023. * current user.
  2024. * @param {(string | object)} permissions The permissions required for Facebook
  2025. * log in. This is a comma-separated string of permissions.
  2026. * Alternatively, supply a Facebook authData object as described in our
  2027. * REST API docs if you want to handle getting facebook auth tokens
  2028. * yourself.
  2029. * @param {object} options MasterKey / SessionToken. Alternatively can be used for authData if permissions is a string
  2030. * @returns {Promise}
  2031. */
  2032. link: function (user, permissions, options) {
  2033. if (!permissions || typeof permissions === 'string') {
  2034. if (!initialized) {
  2035. throw new Error('You must initialize FacebookUtils before calling link.');
  2036. }
  2037. requestedPermissions = permissions;
  2038. return user.linkWith('facebook', options);
  2039. }
  2040. return user.linkWith('facebook', {
  2041. authData: permissions
  2042. }, options);
  2043. },
  2044. /**
  2045. * Unlinks the Parse.User from a Facebook account.
  2046. *
  2047. * @function unlink
  2048. * @name Parse.FacebookUtils.unlink
  2049. * @param {Parse.User} user User to unlink from Facebook. This must be the
  2050. * current user.
  2051. * @param {object} options Standard options object with success and error
  2052. * callbacks.
  2053. * @returns {Promise}
  2054. */
  2055. unlink: function (user, options) {
  2056. if (!initialized) {
  2057. throw new Error('You must initialize FacebookUtils before calling unlink.');
  2058. }
  2059. return user._unlinkFrom('facebook', options);
  2060. },
  2061. // Used for testing purposes
  2062. _getAuthProvider: function () {
  2063. return provider;
  2064. }
  2065. };
  2066. var _default = FacebookUtils;
  2067. exports.default = _default;
  2068. },{"./ParseUser":35,"@babel/runtime-corejs3/core-js-stable/object/define-property":82,"@babel/runtime-corejs3/helpers/interopRequireDefault":128}],9:[function(_dereq_,module,exports){
  2069. "use strict";
  2070. var _keysInstanceProperty = _dereq_("@babel/runtime-corejs3/core-js-stable/instance/keys");
  2071. var _idbKeyval = _dereq_("idb-keyval");
  2072. /**
  2073. * @flow
  2074. */
  2075. /* global window */
  2076. if (typeof window !== 'undefined' && window.indexedDB) {
  2077. var ParseStore = (0, _idbKeyval.createStore)('parseDB', 'parseStore');
  2078. var IndexedDBStorageController = {
  2079. async: 1,
  2080. getItemAsync: function (path
  2081. /*: string*/
  2082. ) {
  2083. return (0, _idbKeyval.get)(path, ParseStore);
  2084. },
  2085. setItemAsync: function (path
  2086. /*: string*/
  2087. , value
  2088. /*: string*/
  2089. ) {
  2090. return (0, _idbKeyval.set)(path, value, ParseStore);
  2091. },
  2092. removeItemAsync: function (path
  2093. /*: string*/
  2094. ) {
  2095. return (0, _idbKeyval.del)(path, ParseStore);
  2096. },
  2097. getAllKeysAsync: function () {
  2098. return (0, _keysInstanceProperty(_idbKeyval))(ParseStore);
  2099. },
  2100. clear: function () {
  2101. return (0, _idbKeyval.clear)(ParseStore);
  2102. }
  2103. };
  2104. module.exports = IndexedDBStorageController;
  2105. } else {
  2106. // IndexedDB not supported
  2107. module.exports = undefined;
  2108. }
  2109. },{"@babel/runtime-corejs3/core-js-stable/instance/keys":67,"idb-keyval":606}],10:[function(_dereq_,module,exports){
  2110. "use strict";
  2111. var _interopRequireDefault = _dereq_("@babel/runtime-corejs3/helpers/interopRequireDefault");
  2112. var _promise = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/promise"));
  2113. var _Storage = _interopRequireDefault(_dereq_("./Storage"));
  2114. /**
  2115. * Copyright (c) 2015-present, Parse, LLC.
  2116. * All rights reserved.
  2117. *
  2118. * This source code is licensed under the BSD-style license found in the
  2119. * LICENSE file in the root directory of this source tree. An additional grant
  2120. * of patent rights can be found in the PATENTS file in the same directory.
  2121. *
  2122. * @flow
  2123. */
  2124. var uuidv4 = _dereq_('./uuid');
  2125. var iidCache = null;
  2126. var InstallationController = {
  2127. currentInstallationId: function ()
  2128. /*: Promise<string>*/
  2129. {
  2130. if (typeof iidCache === 'string') {
  2131. return _promise.default.resolve(iidCache);
  2132. }
  2133. var path = _Storage.default.generatePath('installationId');
  2134. return _Storage.default.getItemAsync(path).then(function (iid) {
  2135. if (!iid) {
  2136. iid = uuidv4();
  2137. return _Storage.default.setItemAsync(path, iid).then(function () {
  2138. iidCache = iid;
  2139. return iid;
  2140. });
  2141. }
  2142. iidCache = iid;
  2143. return iid;
  2144. });
  2145. },
  2146. _clearCache: function () {
  2147. iidCache = null;
  2148. },
  2149. _setInstallationIdCache: function (iid
  2150. /*: string*/
  2151. ) {
  2152. iidCache = iid;
  2153. }
  2154. };
  2155. module.exports = InstallationController;
  2156. },{"./Storage":39,"./uuid":54,"@babel/runtime-corejs3/core-js-stable/promise":92,"@babel/runtime-corejs3/helpers/interopRequireDefault":128}],11:[function(_dereq_,module,exports){
  2157. "use strict";
  2158. var _interopRequireDefault = _dereq_("@babel/runtime-corejs3/helpers/interopRequireDefault");
  2159. var _Object$defineProperty = _dereq_("@babel/runtime-corejs3/core-js-stable/object/define-property");
  2160. var _Array$isArray = _dereq_("@babel/runtime-corejs3/core-js-stable/array/is-array");
  2161. var _getIteratorMethod = _dereq_("@babel/runtime-corejs3/core-js/get-iterator-method");
  2162. var _Symbol = _dereq_("@babel/runtime-corejs3/core-js-stable/symbol");
  2163. var _Array$from = _dereq_("@babel/runtime-corejs3/core-js-stable/array/from");
  2164. var _sliceInstanceProperty = _dereq_("@babel/runtime-corejs3/core-js-stable/instance/slice");
  2165. var _Reflect$construct = _dereq_("@babel/runtime-corejs3/core-js-stable/reflect/construct");
  2166. _Object$defineProperty(exports, "__esModule", {
  2167. value: true
  2168. });
  2169. exports.default = void 0;
  2170. var _typeof2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/helpers/typeof"));
  2171. var _bind = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/instance/bind"));
  2172. var _setTimeout2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/set-timeout"));
  2173. var _values = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/instance/values"));
  2174. var _forEach = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/instance/for-each"));
  2175. var _stringify = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/json/stringify"));
  2176. var _keys = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/instance/keys"));
  2177. var _map = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/map"));
  2178. var _indexOf = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/instance/index-of"));
  2179. var _classCallCheck2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/helpers/classCallCheck"));
  2180. var _createClass2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/helpers/createClass"));
  2181. var _assertThisInitialized2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/helpers/assertThisInitialized"));
  2182. var _inherits2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/helpers/inherits"));
  2183. var _possibleConstructorReturn2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/helpers/possibleConstructorReturn"));
  2184. var _getPrototypeOf2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/helpers/getPrototypeOf"));
  2185. var _defineProperty2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/helpers/defineProperty"));
  2186. var _CoreManager = _interopRequireDefault(_dereq_("./CoreManager"));
  2187. var _EventEmitter2 = _interopRequireDefault(_dereq_("./EventEmitter"));
  2188. var _ParseObject = _interopRequireDefault(_dereq_("./ParseObject"));
  2189. var _LiveQuerySubscription = _interopRequireDefault(_dereq_("./LiveQuerySubscription"));
  2190. var _promiseUtils = _dereq_("./promiseUtils");
  2191. function _createForOfIteratorHelper(o, allowArrayLike) {
  2192. var it = typeof _Symbol !== "undefined" && _getIteratorMethod(o) || o["@@iterator"];
  2193. if (!it) {
  2194. if (_Array$isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") {
  2195. if (it) o = it;
  2196. var i = 0;
  2197. var F = function () {};
  2198. return {
  2199. s: F,
  2200. n: function () {
  2201. if (i >= o.length) return {
  2202. done: true
  2203. };
  2204. return {
  2205. done: false,
  2206. value: o[i++]
  2207. };
  2208. },
  2209. e: function (_e) {
  2210. throw _e;
  2211. },
  2212. f: F
  2213. };
  2214. }
  2215. throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
  2216. }
  2217. var normalCompletion = true,
  2218. didErr = false,
  2219. err;
  2220. return {
  2221. s: function () {
  2222. it = it.call(o);
  2223. },
  2224. n: function () {
  2225. var step = it.next();
  2226. normalCompletion = step.done;
  2227. return step;
  2228. },
  2229. e: function (_e2) {
  2230. didErr = true;
  2231. err = _e2;
  2232. },
  2233. f: function () {
  2234. try {
  2235. if (!normalCompletion && it.return != null) it.return();
  2236. } finally {
  2237. if (didErr) throw err;
  2238. }
  2239. }
  2240. };
  2241. }
  2242. function _unsupportedIterableToArray(o, minLen) {
  2243. var _context6;
  2244. if (!o) return;
  2245. if (typeof o === "string") return _arrayLikeToArray(o, minLen);
  2246. var n = _sliceInstanceProperty(_context6 = Object.prototype.toString.call(o)).call(_context6, 8, -1);
  2247. if (n === "Object" && o.constructor) n = o.constructor.name;
  2248. if (n === "Map" || n === "Set") return _Array$from(o);
  2249. if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen);
  2250. }
  2251. function _arrayLikeToArray(arr, len) {
  2252. if (len == null || len > arr.length) len = arr.length;
  2253. for (var i = 0, arr2 = new Array(len); i < len; i++) {
  2254. arr2[i] = arr[i];
  2255. }
  2256. return arr2;
  2257. }
  2258. function _createSuper(Derived) {
  2259. var hasNativeReflectConstruct = _isNativeReflectConstruct();
  2260. return function () {
  2261. var Super = (0, _getPrototypeOf2.default)(Derived),
  2262. result;
  2263. if (hasNativeReflectConstruct) {
  2264. var NewTarget = (0, _getPrototypeOf2.default)(this).constructor;
  2265. result = _Reflect$construct(Super, arguments, NewTarget);
  2266. } else {
  2267. result = Super.apply(this, arguments);
  2268. }
  2269. return (0, _possibleConstructorReturn2.default)(this, result);
  2270. };
  2271. }
  2272. function _isNativeReflectConstruct() {
  2273. if (typeof Reflect === "undefined" || !_Reflect$construct) return false;
  2274. if (_Reflect$construct.sham) return false;
  2275. if (typeof Proxy === "function") return true;
  2276. try {
  2277. Boolean.prototype.valueOf.call(_Reflect$construct(Boolean, [], function () {}));
  2278. return true;
  2279. } catch (e) {
  2280. return false;
  2281. }
  2282. } // The LiveQuery client inner state
  2283. var CLIENT_STATE = {
  2284. INITIALIZED: 'initialized',
  2285. CONNECTING: 'connecting',
  2286. CONNECTED: 'connected',
  2287. CLOSED: 'closed',
  2288. RECONNECTING: 'reconnecting',
  2289. DISCONNECTED: 'disconnected'
  2290. }; // The event type the LiveQuery client should sent to server
  2291. var OP_TYPES = {
  2292. CONNECT: 'connect',
  2293. SUBSCRIBE: 'subscribe',
  2294. UNSUBSCRIBE: 'unsubscribe',
  2295. ERROR: 'error'
  2296. }; // The event we get back from LiveQuery server
  2297. var OP_EVENTS = {
  2298. CONNECTED: 'connected',
  2299. SUBSCRIBED: 'subscribed',
  2300. UNSUBSCRIBED: 'unsubscribed',
  2301. ERROR: 'error',
  2302. CREATE: 'create',
  2303. UPDATE: 'update',
  2304. ENTER: 'enter',
  2305. LEAVE: 'leave',
  2306. DELETE: 'delete'
  2307. }; // The event the LiveQuery client should emit
  2308. var CLIENT_EMMITER_TYPES = {
  2309. CLOSE: 'close',
  2310. ERROR: 'error',
  2311. OPEN: 'open'
  2312. }; // The event the LiveQuery subscription should emit
  2313. var SUBSCRIPTION_EMMITER_TYPES = {
  2314. OPEN: 'open',
  2315. CLOSE: 'close',
  2316. ERROR: 'error',
  2317. CREATE: 'create',
  2318. UPDATE: 'update',
  2319. ENTER: 'enter',
  2320. LEAVE: 'leave',
  2321. DELETE: 'delete'
  2322. };
  2323. var generateInterval = function (k) {
  2324. return Math.random() * Math.min(30, Math.pow(2, k) - 1) * 1000;
  2325. };
  2326. /**
  2327. * Creates a new LiveQueryClient.
  2328. * Extends events.EventEmitter
  2329. * <a href="https://nodejs.org/api/events.html#events_class_eventemitter">cloud functions</a>.
  2330. *
  2331. * A wrapper of a standard WebSocket client. We add several useful methods to
  2332. * help you connect/disconnect to LiveQueryServer, subscribe/unsubscribe a ParseQuery easily.
  2333. *
  2334. * javascriptKey and masterKey are used for verifying the LiveQueryClient when it tries
  2335. * to connect to the LiveQuery server
  2336. *
  2337. * We expose three events to help you monitor the status of the LiveQueryClient.
  2338. *
  2339. * <pre>
  2340. * let Parse = require('parse/node');
  2341. * let LiveQueryClient = Parse.LiveQueryClient;
  2342. * let client = new LiveQueryClient({
  2343. * applicationId: '',
  2344. * serverURL: '',
  2345. * javascriptKey: '',
  2346. * masterKey: ''
  2347. * });
  2348. * </pre>
  2349. *
  2350. * Open - When we establish the WebSocket connection to the LiveQuery server, you'll get this event.
  2351. * <pre>
  2352. * client.on('open', () => {
  2353. *
  2354. * });</pre>
  2355. *
  2356. * Close - When we lose the WebSocket connection to the LiveQuery server, you'll get this event.
  2357. * <pre>
  2358. * client.on('close', () => {
  2359. *
  2360. * });</pre>
  2361. *
  2362. * Error - When some network error or LiveQuery server error happens, you'll get this event.
  2363. * <pre>
  2364. * client.on('error', (error) => {
  2365. *
  2366. * });</pre>
  2367. *
  2368. * @alias Parse.LiveQueryClient
  2369. */
  2370. var LiveQueryClient = /*#__PURE__*/function (_EventEmitter) {
  2371. (0, _inherits2.default)(LiveQueryClient, _EventEmitter);
  2372. var _super = _createSuper(LiveQueryClient);
  2373. /**
  2374. * @param {object} options
  2375. * @param {string} options.applicationId - applicationId of your Parse app
  2376. * @param {string} options.serverURL - <b>the URL of your LiveQuery server</b>
  2377. * @param {string} options.javascriptKey (optional)
  2378. * @param {string} options.masterKey (optional) Your Parse Master Key. (Node.js only!)
  2379. * @param {string} options.sessionToken (optional)
  2380. * @param {string} options.installationId (optional)
  2381. */
  2382. function LiveQueryClient(_ref) {
  2383. var _this;
  2384. var applicationId = _ref.applicationId,
  2385. serverURL = _ref.serverURL,
  2386. javascriptKey = _ref.javascriptKey,
  2387. masterKey = _ref.masterKey,
  2388. sessionToken = _ref.sessionToken,
  2389. installationId = _ref.installationId;
  2390. (0, _classCallCheck2.default)(this, LiveQueryClient);
  2391. _this = _super.call(this);
  2392. (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "attempts", void 0);
  2393. (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "id", void 0);
  2394. (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "requestId", void 0);
  2395. (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "applicationId", void 0);
  2396. (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "serverURL", void 0);
  2397. (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "javascriptKey", void 0);
  2398. (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "masterKey", void 0);
  2399. (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "sessionToken", void 0);
  2400. (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "installationId", void 0);
  2401. (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "additionalProperties", void 0);
  2402. (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "connectPromise", void 0);
  2403. (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "subscriptions", void 0);
  2404. (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "socket", void 0);
  2405. (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "state", void 0);
  2406. if (!serverURL || (0, _indexOf.default)(serverURL).call(serverURL, 'ws') !== 0) {
  2407. throw new Error('You need to set a proper Parse LiveQuery server url before using LiveQueryClient');
  2408. }
  2409. _this.reconnectHandle = null;
  2410. _this.attempts = 1;
  2411. _this.id = 0;
  2412. _this.requestId = 1;
  2413. _this.serverURL = serverURL;
  2414. _this.applicationId = applicationId;
  2415. _this.javascriptKey = javascriptKey || undefined;
  2416. _this.masterKey = masterKey || undefined;
  2417. _this.sessionToken = sessionToken || undefined;
  2418. _this.installationId = installationId || undefined;
  2419. _this.additionalProperties = true;
  2420. _this.connectPromise = (0, _promiseUtils.resolvingPromise)();
  2421. _this.subscriptions = new _map.default();
  2422. _this.state = CLIENT_STATE.INITIALIZED; // adding listener so process does not crash
  2423. // best practice is for developer to register their own listener
  2424. _this.on('error', function () {});
  2425. return _this;
  2426. }
  2427. (0, _createClass2.default)(LiveQueryClient, [{
  2428. key: "shouldOpen",
  2429. value: function ()
  2430. /*: any*/
  2431. {
  2432. return this.state === CLIENT_STATE.INITIALIZED || this.state === CLIENT_STATE.DISCONNECTED;
  2433. }
  2434. /**
  2435. * Subscribes to a ParseQuery
  2436. *
  2437. * If you provide the sessionToken, when the LiveQuery server gets ParseObject's
  2438. * updates from parse server, it'll try to check whether the sessionToken fulfills
  2439. * the ParseObject's ACL. The LiveQuery server will only send updates to clients whose
  2440. * sessionToken is fit for the ParseObject's ACL. You can check the LiveQuery protocol
  2441. * <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
  2442. * from our Standard API.
  2443. *
  2444. * @param {object} query - the ParseQuery you want to subscribe to
  2445. * @param {string} sessionToken (optional)
  2446. * @returns {LiveQuerySubscription} subscription
  2447. */
  2448. }, {
  2449. key: "subscribe",
  2450. value: function (query
  2451. /*: Object*/
  2452. , sessionToken
  2453. /*: ?string*/
  2454. )
  2455. /*: LiveQuerySubscription*/
  2456. {
  2457. var _this2 = this;
  2458. if (!query) {
  2459. return;
  2460. }
  2461. var className = query.className;
  2462. var queryJSON = query.toJSON();
  2463. var where = queryJSON.where;
  2464. var fields = (0, _keys.default)(queryJSON) ? (0, _keys.default)(queryJSON).split(',') : undefined;
  2465. var subscribeRequest = {
  2466. op: OP_TYPES.SUBSCRIBE,
  2467. requestId: this.requestId,
  2468. query: {
  2469. className: className,
  2470. where: where,
  2471. fields: fields
  2472. }
  2473. };
  2474. if (sessionToken) {
  2475. subscribeRequest.sessionToken = sessionToken;
  2476. }
  2477. var subscription = new _LiveQuerySubscription.default(this.requestId, query, sessionToken);
  2478. this.subscriptions.set(this.requestId, subscription);
  2479. this.requestId += 1;
  2480. this.connectPromise.then(function () {
  2481. _this2.socket.send((0, _stringify.default)(subscribeRequest));
  2482. });
  2483. return subscription;
  2484. }
  2485. /**
  2486. * After calling unsubscribe you'll stop receiving events from the subscription object.
  2487. *
  2488. * @param {object} subscription - subscription you would like to unsubscribe from.
  2489. */
  2490. }, {
  2491. key: "unsubscribe",
  2492. value: function (subscription
  2493. /*: Object*/
  2494. ) {
  2495. var _this3 = this;
  2496. if (!subscription) {
  2497. return;
  2498. }
  2499. this.subscriptions.delete(subscription.id);
  2500. var unsubscribeRequest = {
  2501. op: OP_TYPES.UNSUBSCRIBE,
  2502. requestId: subscription.id
  2503. };
  2504. this.connectPromise.then(function () {
  2505. _this3.socket.send((0, _stringify.default)(unsubscribeRequest));
  2506. });
  2507. }
  2508. /**
  2509. * After open is called, the LiveQueryClient will try to send a connect request
  2510. * to the LiveQuery server.
  2511. *
  2512. */
  2513. }, {
  2514. key: "open",
  2515. value: function () {
  2516. var _this4 = this;
  2517. var WebSocketImplementation = _CoreManager.default.getWebSocketController();
  2518. if (!WebSocketImplementation) {
  2519. this.emit(CLIENT_EMMITER_TYPES.ERROR, 'Can not find WebSocket implementation');
  2520. return;
  2521. }
  2522. if (this.state !== CLIENT_STATE.RECONNECTING) {
  2523. this.state = CLIENT_STATE.CONNECTING;
  2524. }
  2525. this.socket = new WebSocketImplementation(this.serverURL); // Bind WebSocket callbacks
  2526. this.socket.onopen = function () {
  2527. _this4._handleWebSocketOpen();
  2528. };
  2529. this.socket.onmessage = function (event) {
  2530. _this4._handleWebSocketMessage(event);
  2531. };
  2532. this.socket.onclose = function () {
  2533. _this4._handleWebSocketClose();
  2534. };
  2535. this.socket.onerror = function (error) {
  2536. _this4._handleWebSocketError(error);
  2537. };
  2538. }
  2539. }, {
  2540. key: "resubscribe",
  2541. value: function () {
  2542. var _context,
  2543. _this5 = this;
  2544. (0, _forEach.default)(_context = this.subscriptions).call(_context, function (subscription, requestId) {
  2545. var query = subscription.query;
  2546. var queryJSON = query.toJSON();
  2547. var where = queryJSON.where;
  2548. var fields = (0, _keys.default)(queryJSON) ? (0, _keys.default)(queryJSON).split(',') : undefined;
  2549. var className = query.className;
  2550. var sessionToken = subscription.sessionToken;
  2551. var subscribeRequest = {
  2552. op: OP_TYPES.SUBSCRIBE,
  2553. requestId: requestId,
  2554. query: {
  2555. className: className,
  2556. where: where,
  2557. fields: fields
  2558. }
  2559. };
  2560. if (sessionToken) {
  2561. subscribeRequest.sessionToken = sessionToken;
  2562. }
  2563. _this5.connectPromise.then(function () {
  2564. _this5.socket.send((0, _stringify.default)(subscribeRequest));
  2565. });
  2566. });
  2567. }
  2568. /**
  2569. * This method will close the WebSocket connection to this LiveQueryClient,
  2570. * cancel the auto reconnect and unsubscribe all subscriptions based on it.
  2571. *
  2572. */
  2573. }, {
  2574. key: "close",
  2575. value: function () {
  2576. var _context2;
  2577. if (this.state === CLIENT_STATE.INITIALIZED || this.state === CLIENT_STATE.DISCONNECTED) {
  2578. return;
  2579. }
  2580. this.state = CLIENT_STATE.DISCONNECTED;
  2581. this.socket.close(); // Notify each subscription about the close
  2582. var _iterator = _createForOfIteratorHelper((0, _values.default)(_context2 = this.subscriptions).call(_context2)),
  2583. _step;
  2584. try {
  2585. for (_iterator.s(); !(_step = _iterator.n()).done;) {
  2586. var subscription = _step.value;
  2587. subscription.subscribed = false;
  2588. subscription.emit(SUBSCRIPTION_EMMITER_TYPES.CLOSE);
  2589. }
  2590. } catch (err) {
  2591. _iterator.e(err);
  2592. } finally {
  2593. _iterator.f();
  2594. }
  2595. this._handleReset();
  2596. this.emit(CLIENT_EMMITER_TYPES.CLOSE);
  2597. } // ensure we start with valid state if connect is called again after close
  2598. }, {
  2599. key: "_handleReset",
  2600. value: function () {
  2601. this.attempts = 1;
  2602. this.id = 0;
  2603. this.requestId = 1;
  2604. this.connectPromise = (0, _promiseUtils.resolvingPromise)();
  2605. this.subscriptions = new _map.default();
  2606. }
  2607. }, {
  2608. key: "_handleWebSocketOpen",
  2609. value: function () {
  2610. this.attempts = 1;
  2611. var connectRequest = {
  2612. op: OP_TYPES.CONNECT,
  2613. applicationId: this.applicationId,
  2614. javascriptKey: this.javascriptKey,
  2615. masterKey: this.masterKey,
  2616. sessionToken: this.sessionToken
  2617. };
  2618. if (this.additionalProperties) {
  2619. connectRequest.installationId = this.installationId;
  2620. }
  2621. this.socket.send((0, _stringify.default)(connectRequest));
  2622. }
  2623. }, {
  2624. key: "_handleWebSocketMessage",
  2625. value: function (event
  2626. /*: any*/
  2627. ) {
  2628. var data = event.data;
  2629. if (typeof data === 'string') {
  2630. data = JSON.parse(data);
  2631. }
  2632. var subscription = null;
  2633. if (data.requestId) {
  2634. subscription = this.subscriptions.get(data.requestId);
  2635. }
  2636. var response = {
  2637. clientId: data.clientId,
  2638. installationId: data.installationId
  2639. };
  2640. switch (data.op) {
  2641. case OP_EVENTS.CONNECTED:
  2642. if (this.state === CLIENT_STATE.RECONNECTING) {
  2643. this.resubscribe();
  2644. }
  2645. this.emit(CLIENT_EMMITER_TYPES.OPEN);
  2646. this.id = data.clientId;
  2647. this.connectPromise.resolve();
  2648. this.state = CLIENT_STATE.CONNECTED;
  2649. break;
  2650. case OP_EVENTS.SUBSCRIBED:
  2651. if (subscription) {
  2652. subscription.subscribed = true;
  2653. subscription.subscribePromise.resolve();
  2654. (0, _setTimeout2.default)(function () {
  2655. return subscription.emit(SUBSCRIPTION_EMMITER_TYPES.OPEN, response);
  2656. }, 200);
  2657. }
  2658. break;
  2659. case OP_EVENTS.ERROR:
  2660. if (data.requestId) {
  2661. if (subscription) {
  2662. subscription.subscribePromise.resolve();
  2663. (0, _setTimeout2.default)(function () {
  2664. return subscription.emit(SUBSCRIPTION_EMMITER_TYPES.ERROR, data.error);
  2665. }, 200);
  2666. }
  2667. } else {
  2668. this.emit(CLIENT_EMMITER_TYPES.ERROR, data.error);
  2669. }
  2670. if (data.error === 'Additional properties not allowed') {
  2671. this.additionalProperties = false;
  2672. }
  2673. if (data.reconnect) {
  2674. this._handleReconnect();
  2675. }
  2676. break;
  2677. case OP_EVENTS.UNSUBSCRIBED:
  2678. // We have already deleted subscription in unsubscribe(), do nothing here
  2679. break;
  2680. default:
  2681. {
  2682. // create, update, enter, leave, delete cases
  2683. if (!subscription) {
  2684. break;
  2685. }
  2686. var override = false;
  2687. if (data.original) {
  2688. override = true;
  2689. delete data.original.__type; // Check for removed fields
  2690. for (var field in data.original) {
  2691. if (!(field in data.object)) {
  2692. data.object[field] = undefined;
  2693. }
  2694. }
  2695. data.original = _ParseObject.default.fromJSON(data.original, false);
  2696. }
  2697. delete data.object.__type;
  2698. var parseObject = _ParseObject.default.fromJSON(data.object, !(subscription.query && subscription.query._select) ? override : false);
  2699. if (data.original) {
  2700. subscription.emit(data.op, parseObject, data.original, response);
  2701. } else {
  2702. subscription.emit(data.op, parseObject, response);
  2703. }
  2704. var localDatastore = _CoreManager.default.getLocalDatastore();
  2705. if (override && localDatastore.isEnabled) {
  2706. localDatastore._updateObjectIfPinned(parseObject).then(function () {});
  2707. }
  2708. }
  2709. }
  2710. }
  2711. }, {
  2712. key: "_handleWebSocketClose",
  2713. value: function () {
  2714. var _context3;
  2715. if (this.state === CLIENT_STATE.DISCONNECTED) {
  2716. return;
  2717. }
  2718. this.state = CLIENT_STATE.CLOSED;
  2719. this.emit(CLIENT_EMMITER_TYPES.CLOSE); // Notify each subscription about the close
  2720. var _iterator2 = _createForOfIteratorHelper((0, _values.default)(_context3 = this.subscriptions).call(_context3)),
  2721. _step2;
  2722. try {
  2723. for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
  2724. var subscription = _step2.value;
  2725. subscription.emit(SUBSCRIPTION_EMMITER_TYPES.CLOSE);
  2726. }
  2727. } catch (err) {
  2728. _iterator2.e(err);
  2729. } finally {
  2730. _iterator2.f();
  2731. }
  2732. this._handleReconnect();
  2733. }
  2734. }, {
  2735. key: "_handleWebSocketError",
  2736. value: function (error
  2737. /*: any*/
  2738. ) {
  2739. var _context4;
  2740. this.emit(CLIENT_EMMITER_TYPES.ERROR, error);
  2741. var _iterator3 = _createForOfIteratorHelper((0, _values.default)(_context4 = this.subscriptions).call(_context4)),
  2742. _step3;
  2743. try {
  2744. for (_iterator3.s(); !(_step3 = _iterator3.n()).done;) {
  2745. var subscription = _step3.value;
  2746. subscription.emit(SUBSCRIPTION_EMMITER_TYPES.ERROR, error);
  2747. }
  2748. } catch (err) {
  2749. _iterator3.e(err);
  2750. } finally {
  2751. _iterator3.f();
  2752. }
  2753. this._handleReconnect();
  2754. }
  2755. }, {
  2756. key: "_handleReconnect",
  2757. value: function () {
  2758. var _context5,
  2759. _this6 = this; // if closed or currently reconnecting we stop attempting to reconnect
  2760. if (this.state === CLIENT_STATE.DISCONNECTED) {
  2761. return;
  2762. }
  2763. this.state = CLIENT_STATE.RECONNECTING;
  2764. var time = generateInterval(this.attempts); // handle case when both close/error occur at frequent rates we ensure we do not reconnect unnecessarily.
  2765. // we're unable to distinguish different between close/error when we're unable to reconnect therefore
  2766. // we try to reconnect in both cases
  2767. // server side ws and browser WebSocket behave differently in when close/error get triggered
  2768. if (this.reconnectHandle) {
  2769. clearTimeout(this.reconnectHandle);
  2770. }
  2771. this.reconnectHandle = (0, _setTimeout2.default)((0, _bind.default)(_context5 = function () {
  2772. _this6.attempts++;
  2773. _this6.connectPromise = (0, _promiseUtils.resolvingPromise)();
  2774. _this6.open();
  2775. }).call(_context5, this), time);
  2776. }
  2777. }]);
  2778. return LiveQueryClient;
  2779. }(_EventEmitter2.default);
  2780. _CoreManager.default.setWebSocketController(typeof WebSocket === 'function' || (typeof WebSocket === "undefined" ? "undefined" : (0, _typeof2.default)(WebSocket)) === 'object' ? WebSocket : null);
  2781. var _default = LiveQueryClient;
  2782. exports.default = _default;
  2783. },{"./CoreManager":4,"./EventEmitter":6,"./LiveQuerySubscription":12,"./ParseObject":27,"./promiseUtils":51,"@babel/runtime-corejs3/core-js-stable/array/from":55,"@babel/runtime-corejs3/core-js-stable/array/is-array":56,"@babel/runtime-corejs3/core-js-stable/instance/bind":57,"@babel/runtime-corejs3/core-js-stable/instance/for-each":64,"@babel/runtime-corejs3/core-js-stable/instance/index-of":66,"@babel/runtime-corejs3/core-js-stable/instance/keys":67,"@babel/runtime-corejs3/core-js-stable/instance/slice":71,"@babel/runtime-corejs3/core-js-stable/instance/values":75,"@babel/runtime-corejs3/core-js-stable/json/stringify":76,"@babel/runtime-corejs3/core-js-stable/map":77,"@babel/runtime-corejs3/core-js-stable/object/define-property":82,"@babel/runtime-corejs3/core-js-stable/reflect/construct":93,"@babel/runtime-corejs3/core-js-stable/set-timeout":95,"@babel/runtime-corejs3/core-js-stable/symbol":97,"@babel/runtime-corejs3/core-js/get-iterator-method":101,"@babel/runtime-corejs3/helpers/assertThisInitialized":119,"@babel/runtime-corejs3/helpers/classCallCheck":121,"@babel/runtime-corejs3/helpers/createClass":123,"@babel/runtime-corejs3/helpers/defineProperty":124,"@babel/runtime-corejs3/helpers/getPrototypeOf":126,"@babel/runtime-corejs3/helpers/inherits":127,"@babel/runtime-corejs3/helpers/interopRequireDefault":128,"@babel/runtime-corejs3/helpers/possibleConstructorReturn":135,"@babel/runtime-corejs3/helpers/typeof":140}],12:[function(_dereq_,module,exports){
  2784. "use strict";
  2785. var _interopRequireDefault = _dereq_("@babel/runtime-corejs3/helpers/interopRequireDefault");
  2786. var _Object$defineProperty = _dereq_("@babel/runtime-corejs3/core-js-stable/object/define-property");
  2787. var _Reflect$construct = _dereq_("@babel/runtime-corejs3/core-js-stable/reflect/construct");
  2788. _Object$defineProperty(exports, "__esModule", {
  2789. value: true
  2790. });
  2791. exports.default = void 0;
  2792. var _classCallCheck2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/helpers/classCallCheck"));
  2793. var _createClass2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/helpers/createClass"));
  2794. var _inherits2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/helpers/inherits"));
  2795. var _possibleConstructorReturn2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/helpers/possibleConstructorReturn"));
  2796. var _getPrototypeOf2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/helpers/getPrototypeOf"));
  2797. var _EventEmitter2 = _interopRequireDefault(_dereq_("./EventEmitter"));
  2798. var _CoreManager = _interopRequireDefault(_dereq_("./CoreManager"));
  2799. var _promiseUtils = _dereq_("./promiseUtils");
  2800. function _createSuper(Derived) {
  2801. var hasNativeReflectConstruct = _isNativeReflectConstruct();
  2802. return function () {
  2803. var Super = (0, _getPrototypeOf2.default)(Derived),
  2804. result;
  2805. if (hasNativeReflectConstruct) {
  2806. var NewTarget = (0, _getPrototypeOf2.default)(this).constructor;
  2807. result = _Reflect$construct(Super, arguments, NewTarget);
  2808. } else {
  2809. result = Super.apply(this, arguments);
  2810. }
  2811. return (0, _possibleConstructorReturn2.default)(this, result);
  2812. };
  2813. }
  2814. function _isNativeReflectConstruct() {
  2815. if (typeof Reflect === "undefined" || !_Reflect$construct) return false;
  2816. if (_Reflect$construct.sham) return false;
  2817. if (typeof Proxy === "function") return true;
  2818. try {
  2819. Boolean.prototype.valueOf.call(_Reflect$construct(Boolean, [], function () {}));
  2820. return true;
  2821. } catch (e) {
  2822. return false;
  2823. }
  2824. }
  2825. /**
  2826. * Creates a new LiveQuery Subscription.
  2827. * Extends events.EventEmitter
  2828. * <a href="https://nodejs.org/api/events.html#events_class_eventemitter">cloud functions</a>.
  2829. *
  2830. * <p>Response Object - Contains data from the client that made the request
  2831. * <ul>
  2832. * <li>clientId</li>
  2833. * <li>installationId - requires Parse Server 4.0.0+</li>
  2834. * </ul>
  2835. * </p>
  2836. *
  2837. * <p>Open Event - When you call query.subscribe(), we send a subscribe request to
  2838. * the LiveQuery server, when we get the confirmation from the LiveQuery server,
  2839. * this event will be emitted. When the client loses WebSocket connection to the
  2840. * LiveQuery server, we will try to auto reconnect the LiveQuery server. If we
  2841. * reconnect the LiveQuery server and successfully resubscribe the ParseQuery,
  2842. * you'll also get this event.
  2843. *
  2844. * <pre>
  2845. * subscription.on('open', (response) => {
  2846. *
  2847. * });</pre></p>
  2848. *
  2849. * <p>Create Event - When a new ParseObject is created and it fulfills the ParseQuery you subscribe,
  2850. * you'll get this event. The object is the ParseObject which is created.
  2851. *
  2852. * <pre>
  2853. * subscription.on('create', (object, response) => {
  2854. *
  2855. * });</pre></p>
  2856. *
  2857. * <p>Update Event - When an existing ParseObject (original) which fulfills the ParseQuery you subscribe
  2858. * is updated (The ParseObject fulfills the ParseQuery before and after changes),
  2859. * you'll get this event. The object is the ParseObject which is updated.
  2860. * Its content is the latest value of the ParseObject.
  2861. *
  2862. * Parse-Server 3.1.3+ Required for original object parameter
  2863. *
  2864. * <pre>
  2865. * subscription.on('update', (object, original, response) => {
  2866. *
  2867. * });</pre></p>
  2868. *
  2869. * <p>Enter Event - When an existing ParseObject's (original) old value doesn't fulfill the ParseQuery
  2870. * but its new value fulfills the ParseQuery, you'll get this event. The object is the
  2871. * ParseObject which enters the ParseQuery. Its content is the latest value of the ParseObject.
  2872. *
  2873. * Parse-Server 3.1.3+ Required for original object parameter
  2874. *
  2875. * <pre>
  2876. * subscription.on('enter', (object, original, response) => {
  2877. *
  2878. * });</pre></p>
  2879. *
  2880. *
  2881. * <p>Update Event - When an existing ParseObject's old value fulfills the ParseQuery but its new value
  2882. * doesn't fulfill the ParseQuery, you'll get this event. The object is the ParseObject
  2883. * which leaves the ParseQuery. Its content is the latest value of the ParseObject.
  2884. *
  2885. * <pre>
  2886. * subscription.on('leave', (object, response) => {
  2887. *
  2888. * });</pre></p>
  2889. *
  2890. *
  2891. * <p>Delete Event - When an existing ParseObject which fulfills the ParseQuery is deleted, you'll
  2892. * get this event. The object is the ParseObject which is deleted.
  2893. *
  2894. * <pre>
  2895. * subscription.on('delete', (object, response) => {
  2896. *
  2897. * });</pre></p>
  2898. *
  2899. *
  2900. * <p>Close Event - When the client loses the WebSocket connection to the LiveQuery
  2901. * server and we stop receiving events, you'll get this event.
  2902. *
  2903. * <pre>
  2904. * subscription.on('close', () => {
  2905. *
  2906. * });</pre></p>
  2907. *
  2908. * @alias Parse.LiveQuerySubscription
  2909. */
  2910. var Subscription = /*#__PURE__*/function (_EventEmitter) {
  2911. (0, _inherits2.default)(Subscription, _EventEmitter);
  2912. var _super = _createSuper(Subscription);
  2913. /*
  2914. * @param {string} id - subscription id
  2915. * @param {string} query - query to subscribe to
  2916. * @param {string} sessionToken - optional session token
  2917. */
  2918. function Subscription(id, query, sessionToken) {
  2919. var _this;
  2920. (0, _classCallCheck2.default)(this, Subscription);
  2921. _this = _super.call(this);
  2922. _this.id = id;
  2923. _this.query = query;
  2924. _this.sessionToken = sessionToken;
  2925. _this.subscribePromise = (0, _promiseUtils.resolvingPromise)();
  2926. _this.subscribed = false; // adding listener so process does not crash
  2927. // best practice is for developer to register their own listener
  2928. _this.on('error', function () {});
  2929. return _this;
  2930. }
  2931. /**
  2932. * Close the subscription
  2933. *
  2934. * @returns {Promise}
  2935. */
  2936. (0, _createClass2.default)(Subscription, [{
  2937. key: "unsubscribe",
  2938. value: function ()
  2939. /*: Promise*/
  2940. {
  2941. var _this2 = this;
  2942. return _CoreManager.default.getLiveQueryController().getDefaultLiveQueryClient().then(function (liveQueryClient) {
  2943. liveQueryClient.unsubscribe(_this2);
  2944. _this2.emit('close');
  2945. });
  2946. }
  2947. }]);
  2948. return Subscription;
  2949. }(_EventEmitter2.default);
  2950. var _default = Subscription;
  2951. exports.default = _default;
  2952. },{"./CoreManager":4,"./EventEmitter":6,"./promiseUtils":51,"@babel/runtime-corejs3/core-js-stable/object/define-property":82,"@babel/runtime-corejs3/core-js-stable/reflect/construct":93,"@babel/runtime-corejs3/helpers/classCallCheck":121,"@babel/runtime-corejs3/helpers/createClass":123,"@babel/runtime-corejs3/helpers/getPrototypeOf":126,"@babel/runtime-corejs3/helpers/inherits":127,"@babel/runtime-corejs3/helpers/interopRequireDefault":128,"@babel/runtime-corejs3/helpers/possibleConstructorReturn":135}],13:[function(_dereq_,module,exports){
  2953. "use strict";
  2954. var _interopRequireDefault = _dereq_("@babel/runtime-corejs3/helpers/interopRequireDefault");
  2955. var _reverseInstanceProperty = _dereq_("@babel/runtime-corejs3/core-js-stable/instance/reverse");
  2956. var _Promise2 = _dereq_("@babel/runtime-corejs3/core-js-stable/promise");
  2957. var _Object$setPrototypeOf = _dereq_("@babel/runtime-corejs3/core-js-stable/object/set-prototype-of");
  2958. var _typeof = _dereq_("@babel/runtime-corejs3/helpers/typeof");
  2959. var _forEachInstanceProperty = _dereq_("@babel/runtime-corejs3/core-js-stable/instance/for-each");
  2960. var _Object$getPrototypeOf = _dereq_("@babel/runtime-corejs3/core-js-stable/object/get-prototype-of");
  2961. var _Object$create = _dereq_("@babel/runtime-corejs3/core-js-stable/object/create");
  2962. var _Object$defineProperty = _dereq_("@babel/runtime-corejs3/core-js-stable/object/define-property");
  2963. var _Array$isArray2 = _dereq_("@babel/runtime-corejs3/core-js-stable/array/is-array");
  2964. var _getIteratorMethod = _dereq_("@babel/runtime-corejs3/core-js/get-iterator-method");
  2965. var _Symbol = _dereq_("@babel/runtime-corejs3/core-js-stable/symbol");
  2966. var _Array$from2 = _dereq_("@babel/runtime-corejs3/core-js-stable/array/from");
  2967. var _sliceInstanceProperty = _dereq_("@babel/runtime-corejs3/core-js-stable/instance/slice");
  2968. var _find = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/instance/find"));
  2969. var _from = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/array/from"));
  2970. var _map = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/instance/map"));
  2971. var _isArray = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/array/is-array"));
  2972. var _regenerator = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/regenerator"));
  2973. var _keys2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/instance/keys"));
  2974. var _startsWith = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/instance/starts-with"));
  2975. var _keys3 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/object/keys"));
  2976. var _includes = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/instance/includes"));
  2977. var _filter = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/instance/filter"));
  2978. var _concat = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/instance/concat"));
  2979. var _set = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/set"));
  2980. var _toConsumableArray2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/helpers/toConsumableArray"));
  2981. var _promise = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/promise"));
  2982. var _slicedToArray2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/helpers/slicedToArray"));
  2983. var _asyncToGenerator2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/helpers/asyncToGenerator"));
  2984. var _CoreManager = _interopRequireDefault(_dereq_("./CoreManager"));
  2985. var _ParseQuery = _interopRequireDefault(_dereq_("./ParseQuery"));
  2986. var _LocalDatastoreUtils = _dereq_("./LocalDatastoreUtils");
  2987. function _regeneratorRuntime() {
  2988. "use strict";
  2989. /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */
  2990. _regeneratorRuntime = function () {
  2991. return exports;
  2992. };
  2993. var exports = {},
  2994. Op = Object.prototype,
  2995. hasOwn = Op.hasOwnProperty,
  2996. $Symbol = "function" == typeof _Symbol ? _Symbol : {},
  2997. iteratorSymbol = $Symbol.iterator || "@@iterator",
  2998. asyncIteratorSymbol = $Symbol.asyncIterator || "@@asyncIterator",
  2999. toStringTagSymbol = $Symbol.toStringTag || "@@toStringTag";
  3000. function define(obj, key, value) {
  3001. return _Object$defineProperty(obj, key, {
  3002. value: value,
  3003. enumerable: !0,
  3004. configurable: !0,
  3005. writable: !0
  3006. }), obj[key];
  3007. }
  3008. try {
  3009. define({}, "");
  3010. } catch (err) {
  3011. define = function (obj, key, value) {
  3012. return obj[key] = value;
  3013. };
  3014. }
  3015. function wrap(innerFn, outerFn, self, tryLocsList) {
  3016. var protoGenerator = outerFn && outerFn.prototype instanceof Generator ? outerFn : Generator,
  3017. generator = _Object$create(protoGenerator.prototype),
  3018. context = new Context(tryLocsList || []);
  3019. return generator._invoke = function (innerFn, self, context) {
  3020. var state = "suspendedStart";
  3021. return function (method, arg) {
  3022. if ("executing" === state) throw new Error("Generator is already running");
  3023. if ("completed" === state) {
  3024. if ("throw" === method) throw arg;
  3025. return doneResult();
  3026. }
  3027. for (context.method = method, context.arg = arg;;) {
  3028. var delegate = context.delegate;
  3029. if (delegate) {
  3030. var delegateResult = maybeInvokeDelegate(delegate, context);
  3031. if (delegateResult) {
  3032. if (delegateResult === ContinueSentinel) continue;
  3033. return delegateResult;
  3034. }
  3035. }
  3036. if ("next" === context.method) context.sent = context._sent = context.arg;else if ("throw" === context.method) {
  3037. if ("suspendedStart" === state) throw state = "completed", context.arg;
  3038. context.dispatchException(context.arg);
  3039. } else "return" === context.method && context.abrupt("return", context.arg);
  3040. state = "executing";
  3041. var record = tryCatch(innerFn, self, context);
  3042. if ("normal" === record.type) {
  3043. if (state = context.done ? "completed" : "suspendedYield", record.arg === ContinueSentinel) continue;
  3044. return {
  3045. value: record.arg,
  3046. done: context.done
  3047. };
  3048. }
  3049. "throw" === record.type && (state = "completed", context.method = "throw", context.arg = record.arg);
  3050. }
  3051. };
  3052. }(innerFn, self, context), generator;
  3053. }
  3054. function tryCatch(fn, obj, arg) {
  3055. try {
  3056. return {
  3057. type: "normal",
  3058. arg: fn.call(obj, arg)
  3059. };
  3060. } catch (err) {
  3061. return {
  3062. type: "throw",
  3063. arg: err
  3064. };
  3065. }
  3066. }
  3067. exports.wrap = wrap;
  3068. var ContinueSentinel = {};
  3069. function Generator() {}
  3070. function GeneratorFunction() {}
  3071. function GeneratorFunctionPrototype() {}
  3072. var IteratorPrototype = {};
  3073. define(IteratorPrototype, iteratorSymbol, function () {
  3074. return this;
  3075. });
  3076. var getProto = _Object$getPrototypeOf,
  3077. NativeIteratorPrototype = getProto && getProto(getProto(values([])));
  3078. NativeIteratorPrototype && NativeIteratorPrototype !== Op && hasOwn.call(NativeIteratorPrototype, iteratorSymbol) && (IteratorPrototype = NativeIteratorPrototype);
  3079. var Gp = GeneratorFunctionPrototype.prototype = Generator.prototype = _Object$create(IteratorPrototype);
  3080. function defineIteratorMethods(prototype) {
  3081. var _context19;
  3082. _forEachInstanceProperty(_context19 = ["next", "throw", "return"]).call(_context19, function (method) {
  3083. define(prototype, method, function (arg) {
  3084. return this._invoke(method, arg);
  3085. });
  3086. });
  3087. }
  3088. function AsyncIterator(generator, PromiseImpl) {
  3089. function invoke(method, arg, resolve, reject) {
  3090. var record = tryCatch(generator[method], generator, arg);
  3091. if ("throw" !== record.type) {
  3092. var result = record.arg,
  3093. value = result.value;
  3094. return value && "object" == _typeof(value) && hasOwn.call(value, "__await") ? PromiseImpl.resolve(value.__await).then(function (value) {
  3095. invoke("next", value, resolve, reject);
  3096. }, function (err) {
  3097. invoke("throw", err, resolve, reject);
  3098. }) : PromiseImpl.resolve(value).then(function (unwrapped) {
  3099. result.value = unwrapped, resolve(result);
  3100. }, function (error) {
  3101. return invoke("throw", error, resolve, reject);
  3102. });
  3103. }
  3104. reject(record.arg);
  3105. }
  3106. var previousPromise;
  3107. this._invoke = function (method, arg) {
  3108. function callInvokeWithMethodAndArg() {
  3109. return new PromiseImpl(function (resolve, reject) {
  3110. invoke(method, arg, resolve, reject);
  3111. });
  3112. }
  3113. return previousPromise = previousPromise ? previousPromise.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg();
  3114. };
  3115. }
  3116. function maybeInvokeDelegate(delegate, context) {
  3117. var method = delegate.iterator[context.method];
  3118. if (undefined === method) {
  3119. if (context.delegate = null, "throw" === context.method) {
  3120. if (delegate.iterator.return && (context.method = "return", context.arg = undefined, maybeInvokeDelegate(delegate, context), "throw" === context.method)) return ContinueSentinel;
  3121. context.method = "throw", context.arg = new TypeError("The iterator does not provide a 'throw' method");
  3122. }
  3123. return ContinueSentinel;
  3124. }
  3125. var record = tryCatch(method, delegate.iterator, context.arg);
  3126. if ("throw" === record.type) return context.method = "throw", context.arg = record.arg, context.delegate = null, ContinueSentinel;
  3127. var info = record.arg;
  3128. return info ? info.done ? (context[delegate.resultName] = info.value, context.next = delegate.nextLoc, "return" !== context.method && (context.method = "next", context.arg = undefined), context.delegate = null, ContinueSentinel) : info : (context.method = "throw", context.arg = new TypeError("iterator result is not an object"), context.delegate = null, ContinueSentinel);
  3129. }
  3130. function pushTryEntry(locs) {
  3131. var entry = {
  3132. tryLoc: locs[0]
  3133. };
  3134. 1 in locs && (entry.catchLoc = locs[1]), 2 in locs && (entry.finallyLoc = locs[2], entry.afterLoc = locs[3]), this.tryEntries.push(entry);
  3135. }
  3136. function resetTryEntry(entry) {
  3137. var record = entry.completion || {};
  3138. record.type = "normal", delete record.arg, entry.completion = record;
  3139. }
  3140. function Context(tryLocsList) {
  3141. this.tryEntries = [{
  3142. tryLoc: "root"
  3143. }], _forEachInstanceProperty(tryLocsList).call(tryLocsList, pushTryEntry, this), this.reset(!0);
  3144. }
  3145. function values(iterable) {
  3146. if (iterable) {
  3147. var iteratorMethod = iterable[iteratorSymbol];
  3148. if (iteratorMethod) return iteratorMethod.call(iterable);
  3149. if ("function" == typeof iterable.next) return iterable;
  3150. if (!isNaN(iterable.length)) {
  3151. var i = -1,
  3152. next = function next() {
  3153. for (; ++i < iterable.length;) {
  3154. if (hasOwn.call(iterable, i)) return next.value = iterable[i], next.done = !1, next;
  3155. }
  3156. return next.value = undefined, next.done = !0, next;
  3157. };
  3158. return next.next = next;
  3159. }
  3160. }
  3161. return {
  3162. next: doneResult
  3163. };
  3164. }
  3165. function doneResult() {
  3166. return {
  3167. value: undefined,
  3168. done: !0
  3169. };
  3170. }
  3171. return GeneratorFunction.prototype = GeneratorFunctionPrototype, define(Gp, "constructor", GeneratorFunctionPrototype), define(GeneratorFunctionPrototype, "constructor", GeneratorFunction), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, toStringTagSymbol, "GeneratorFunction"), exports.isGeneratorFunction = function (genFun) {
  3172. var ctor = "function" == typeof genFun && genFun.constructor;
  3173. return !!ctor && (ctor === GeneratorFunction || "GeneratorFunction" === (ctor.displayName || ctor.name));
  3174. }, exports.mark = function (genFun) {
  3175. return _Object$setPrototypeOf ? _Object$setPrototypeOf(genFun, GeneratorFunctionPrototype) : (genFun.__proto__ = GeneratorFunctionPrototype, define(genFun, toStringTagSymbol, "GeneratorFunction")), genFun.prototype = _Object$create(Gp), genFun;
  3176. }, exports.awrap = function (arg) {
  3177. return {
  3178. __await: arg
  3179. };
  3180. }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, asyncIteratorSymbol, function () {
  3181. return this;
  3182. }), exports.AsyncIterator = AsyncIterator, exports.async = function (innerFn, outerFn, self, tryLocsList, PromiseImpl) {
  3183. void 0 === PromiseImpl && (PromiseImpl = _Promise2);
  3184. var iter = new AsyncIterator(wrap(innerFn, outerFn, self, tryLocsList), PromiseImpl);
  3185. return exports.isGeneratorFunction(outerFn) ? iter : iter.next().then(function (result) {
  3186. return result.done ? result.value : iter.next();
  3187. });
  3188. }, defineIteratorMethods(Gp), define(Gp, toStringTagSymbol, "Generator"), define(Gp, iteratorSymbol, function () {
  3189. return this;
  3190. }), define(Gp, "toString", function () {
  3191. return "[object Generator]";
  3192. }), exports.keys = function (object) {
  3193. var keys = [];
  3194. for (var key in object) {
  3195. keys.push(key);
  3196. }
  3197. return _reverseInstanceProperty(keys).call(keys), function next() {
  3198. for (; keys.length;) {
  3199. var key = keys.pop();
  3200. if (key in object) return next.value = key, next.done = !1, next;
  3201. }
  3202. return next.done = !0, next;
  3203. };
  3204. }, exports.values = values, Context.prototype = {
  3205. constructor: Context,
  3206. reset: function (skipTempReset) {
  3207. var _context20;
  3208. if (this.prev = 0, this.next = 0, this.sent = this._sent = undefined, this.done = !1, this.delegate = null, this.method = "next", this.arg = undefined, _forEachInstanceProperty(_context20 = this.tryEntries).call(_context20, resetTryEntry), !skipTempReset) for (var name in this) {
  3209. "t" === name.charAt(0) && hasOwn.call(this, name) && !isNaN(+_sliceInstanceProperty(name).call(name, 1)) && (this[name] = undefined);
  3210. }
  3211. },
  3212. stop: function () {
  3213. this.done = !0;
  3214. var rootRecord = this.tryEntries[0].completion;
  3215. if ("throw" === rootRecord.type) throw rootRecord.arg;
  3216. return this.rval;
  3217. },
  3218. dispatchException: function (exception) {
  3219. if (this.done) throw exception;
  3220. var context = this;
  3221. function handle(loc, caught) {
  3222. return record.type = "throw", record.arg = exception, context.next = loc, caught && (context.method = "next", context.arg = undefined), !!caught;
  3223. }
  3224. for (var i = this.tryEntries.length - 1; i >= 0; --i) {
  3225. var entry = this.tryEntries[i],
  3226. record = entry.completion;
  3227. if ("root" === entry.tryLoc) return handle("end");
  3228. if (entry.tryLoc <= this.prev) {
  3229. var hasCatch = hasOwn.call(entry, "catchLoc"),
  3230. hasFinally = hasOwn.call(entry, "finallyLoc");
  3231. if (hasCatch && hasFinally) {
  3232. if (this.prev < entry.catchLoc) return handle(entry.catchLoc, !0);
  3233. if (this.prev < entry.finallyLoc) return handle(entry.finallyLoc);
  3234. } else if (hasCatch) {
  3235. if (this.prev < entry.catchLoc) return handle(entry.catchLoc, !0);
  3236. } else {
  3237. if (!hasFinally) throw new Error("try statement without catch or finally");
  3238. if (this.prev < entry.finallyLoc) return handle(entry.finallyLoc);
  3239. }
  3240. }
  3241. }
  3242. },
  3243. abrupt: function (type, arg) {
  3244. for (var i = this.tryEntries.length - 1; i >= 0; --i) {
  3245. var entry = this.tryEntries[i];
  3246. if (entry.tryLoc <= this.prev && hasOwn.call(entry, "finallyLoc") && this.prev < entry.finallyLoc) {
  3247. var finallyEntry = entry;
  3248. break;
  3249. }
  3250. }
  3251. finallyEntry && ("break" === type || "continue" === type) && finallyEntry.tryLoc <= arg && arg <= finallyEntry.finallyLoc && (finallyEntry = null);
  3252. var record = finallyEntry ? finallyEntry.completion : {};
  3253. return record.type = type, record.arg = arg, finallyEntry ? (this.method = "next", this.next = finallyEntry.finallyLoc, ContinueSentinel) : this.complete(record);
  3254. },
  3255. complete: function (record, afterLoc) {
  3256. if ("throw" === record.type) throw record.arg;
  3257. return "break" === record.type || "continue" === record.type ? this.next = record.arg : "return" === record.type ? (this.rval = this.arg = record.arg, this.method = "return", this.next = "end") : "normal" === record.type && afterLoc && (this.next = afterLoc), ContinueSentinel;
  3258. },
  3259. finish: function (finallyLoc) {
  3260. for (var i = this.tryEntries.length - 1; i >= 0; --i) {
  3261. var entry = this.tryEntries[i];
  3262. if (entry.finallyLoc === finallyLoc) return this.complete(entry.completion, entry.afterLoc), resetTryEntry(entry), ContinueSentinel;
  3263. }
  3264. },
  3265. catch: function (tryLoc) {
  3266. for (var i = this.tryEntries.length - 1; i >= 0; --i) {
  3267. var entry = this.tryEntries[i];
  3268. if (entry.tryLoc === tryLoc) {
  3269. var record = entry.completion;
  3270. if ("throw" === record.type) {
  3271. var thrown = record.arg;
  3272. resetTryEntry(entry);
  3273. }
  3274. return thrown;
  3275. }
  3276. }
  3277. throw new Error("illegal catch attempt");
  3278. },
  3279. delegateYield: function (iterable, resultName, nextLoc) {
  3280. return this.delegate = {
  3281. iterator: values(iterable),
  3282. resultName: resultName,
  3283. nextLoc: nextLoc
  3284. }, "next" === this.method && (this.arg = undefined), ContinueSentinel;
  3285. }
  3286. }, exports;
  3287. }
  3288. function _createForOfIteratorHelper(o, allowArrayLike) {
  3289. var it = typeof _Symbol !== "undefined" && _getIteratorMethod(o) || o["@@iterator"];
  3290. if (!it) {
  3291. if (_Array$isArray2(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") {
  3292. if (it) o = it;
  3293. var i = 0;
  3294. var F = function () {};
  3295. return {
  3296. s: F,
  3297. n: function () {
  3298. if (i >= o.length) return {
  3299. done: true
  3300. };
  3301. return {
  3302. done: false,
  3303. value: o[i++]
  3304. };
  3305. },
  3306. e: function (_e) {
  3307. throw _e;
  3308. },
  3309. f: F
  3310. };
  3311. }
  3312. throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
  3313. }
  3314. var normalCompletion = true,
  3315. didErr = false,
  3316. err;
  3317. return {
  3318. s: function () {
  3319. it = it.call(o);
  3320. },
  3321. n: function () {
  3322. var step = it.next();
  3323. normalCompletion = step.done;
  3324. return step;
  3325. },
  3326. e: function (_e2) {
  3327. didErr = true;
  3328. err = _e2;
  3329. },
  3330. f: function () {
  3331. try {
  3332. if (!normalCompletion && it.return != null) it.return();
  3333. } finally {
  3334. if (didErr) throw err;
  3335. }
  3336. }
  3337. };
  3338. }
  3339. function _unsupportedIterableToArray(o, minLen) {
  3340. var _context18;
  3341. if (!o) return;
  3342. if (typeof o === "string") return _arrayLikeToArray(o, minLen);
  3343. var n = _sliceInstanceProperty(_context18 = Object.prototype.toString.call(o)).call(_context18, 8, -1);
  3344. if (n === "Object" && o.constructor) n = o.constructor.name;
  3345. if (n === "Map" || n === "Set") return _Array$from2(o);
  3346. if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen);
  3347. }
  3348. function _arrayLikeToArray(arr, len) {
  3349. if (len == null || len > arr.length) len = arr.length;
  3350. for (var i = 0, arr2 = new Array(len); i < len; i++) {
  3351. arr2[i] = arr[i];
  3352. }
  3353. return arr2;
  3354. }
  3355. /**
  3356. * Provides a local datastore which can be used to store and retrieve <code>Parse.Object</code>. <br />
  3357. * To enable this functionality, call <code>Parse.enableLocalDatastore()</code>.
  3358. *
  3359. * Pin object to add to local datastore
  3360. *
  3361. * <pre>await object.pin();</pre>
  3362. * <pre>await object.pinWithName('pinName');</pre>
  3363. *
  3364. * Query pinned objects
  3365. *
  3366. * <pre>query.fromLocalDatastore();</pre>
  3367. * <pre>query.fromPin();</pre>
  3368. * <pre>query.fromPinWithName();</pre>
  3369. *
  3370. * <pre>const localObjects = await query.find();</pre>
  3371. *
  3372. * @class Parse.LocalDatastore
  3373. * @static
  3374. */
  3375. var LocalDatastore = {
  3376. isEnabled: false,
  3377. isSyncing: false,
  3378. fromPinWithName: function (name
  3379. /*: string*/
  3380. )
  3381. /*: Promise<Array<Object>>*/
  3382. {
  3383. var controller = _CoreManager.default.getLocalDatastoreController();
  3384. return controller.fromPinWithName(name);
  3385. },
  3386. pinWithName: function (name
  3387. /*: string*/
  3388. , value
  3389. /*: any*/
  3390. )
  3391. /*: Promise<void>*/
  3392. {
  3393. var controller = _CoreManager.default.getLocalDatastoreController();
  3394. return controller.pinWithName(name, value);
  3395. },
  3396. unPinWithName: function (name
  3397. /*: string*/
  3398. )
  3399. /*: Promise<void>*/
  3400. {
  3401. var controller = _CoreManager.default.getLocalDatastoreController();
  3402. return controller.unPinWithName(name);
  3403. },
  3404. _getAllContents: function ()
  3405. /*: Promise<Object>*/
  3406. {
  3407. var controller = _CoreManager.default.getLocalDatastoreController();
  3408. return controller.getAllContents();
  3409. },
  3410. // Use for testing
  3411. _getRawStorage: function ()
  3412. /*: Promise<Object>*/
  3413. {
  3414. var controller = _CoreManager.default.getLocalDatastoreController();
  3415. return controller.getRawStorage();
  3416. },
  3417. _clear: function ()
  3418. /*: Promise<void>*/
  3419. {
  3420. var controller = _CoreManager.default.getLocalDatastoreController();
  3421. return controller.clear();
  3422. },
  3423. // Pin the object and children recursively
  3424. // Saves the object and children key to Pin Name
  3425. _handlePinAllWithName: function (name
  3426. /*: string*/
  3427. , objects
  3428. /*: Array<ParseObject>*/
  3429. )
  3430. /*: Promise<void>*/
  3431. {
  3432. var _this = this;
  3433. return (0, _asyncToGenerator2.default)( /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
  3434. var _context;
  3435. var pinName, toPinPromises, objectKeys, _iterator, _step, parent, children, parentKey, json, objectKey, fromPinPromise, _yield$Promise$all, _yield$Promise$all2, pinned, toPin;
  3436. return _regeneratorRuntime().wrap(function _callee$(_context2) {
  3437. while (1) {
  3438. switch (_context2.prev = _context2.next) {
  3439. case 0:
  3440. pinName = _this.getPinName(name);
  3441. toPinPromises = [];
  3442. objectKeys = [];
  3443. _iterator = _createForOfIteratorHelper(objects);
  3444. try {
  3445. for (_iterator.s(); !(_step = _iterator.n()).done;) {
  3446. parent = _step.value;
  3447. children = _this._getChildren(parent);
  3448. parentKey = _this.getKeyForObject(parent);
  3449. json = parent._toFullJSON(undefined, true);
  3450. if (parent._localId) {
  3451. json._localId = parent._localId;
  3452. }
  3453. children[parentKey] = json;
  3454. for (objectKey in children) {
  3455. objectKeys.push(objectKey);
  3456. toPinPromises.push(_this.pinWithName(objectKey, [children[objectKey]]));
  3457. }
  3458. }
  3459. } catch (err) {
  3460. _iterator.e(err);
  3461. } finally {
  3462. _iterator.f();
  3463. }
  3464. fromPinPromise = _this.fromPinWithName(pinName);
  3465. _context2.next = 8;
  3466. return _promise.default.all([fromPinPromise, toPinPromises]);
  3467. case 8:
  3468. _yield$Promise$all = _context2.sent;
  3469. _yield$Promise$all2 = (0, _slicedToArray2.default)(_yield$Promise$all, 1);
  3470. pinned = _yield$Promise$all2[0];
  3471. toPin = (0, _toConsumableArray2.default)(new _set.default((0, _concat.default)(_context = []).call(_context, (0, _toConsumableArray2.default)(pinned || []), objectKeys)));
  3472. return _context2.abrupt("return", _this.pinWithName(pinName, toPin));
  3473. case 13:
  3474. case "end":
  3475. return _context2.stop();
  3476. }
  3477. }
  3478. }, _callee);
  3479. }))();
  3480. },
  3481. // Removes object and children keys from pin name
  3482. // Keeps the object and children pinned
  3483. _handleUnPinAllWithName: function _handleUnPinAllWithName(name
  3484. /*: string*/
  3485. , objects
  3486. /*: Array<ParseObject>*/
  3487. ) {
  3488. var _this2 = this;
  3489. return (0, _asyncToGenerator2.default)( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2() {
  3490. var localDatastore, pinName, promises, objectKeys, _iterator2, _step2, _objectKeys, _context3, parent, children, parentKey, pinned, _iterator3, _step3, objectKey, hasReference, key, pinnedObjects;
  3491. return _regeneratorRuntime().wrap(function _callee2$(_context4) {
  3492. while (1) {
  3493. switch (_context4.prev = _context4.next) {
  3494. case 0:
  3495. _context4.next = 2;
  3496. return _this2._getAllContents();
  3497. case 2:
  3498. localDatastore = _context4.sent;
  3499. pinName = _this2.getPinName(name);
  3500. promises = [];
  3501. objectKeys = [];
  3502. _iterator2 = _createForOfIteratorHelper(objects);
  3503. try {
  3504. for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
  3505. parent = _step2.value;
  3506. children = _this2._getChildren(parent);
  3507. parentKey = _this2.getKeyForObject(parent);
  3508. (_objectKeys = objectKeys).push.apply(_objectKeys, (0, _concat.default)(_context3 = [parentKey]).call(_context3, (0, _toConsumableArray2.default)((0, _keys3.default)(children))));
  3509. }
  3510. } catch (err) {
  3511. _iterator2.e(err);
  3512. } finally {
  3513. _iterator2.f();
  3514. }
  3515. objectKeys = (0, _toConsumableArray2.default)(new _set.default(objectKeys));
  3516. pinned = localDatastore[pinName] || [];
  3517. pinned = (0, _filter.default)(pinned).call(pinned, function (item) {
  3518. return !(0, _includes.default)(objectKeys).call(objectKeys, item);
  3519. });
  3520. if (pinned.length == 0) {
  3521. promises.push(_this2.unPinWithName(pinName));
  3522. delete localDatastore[pinName];
  3523. } else {
  3524. promises.push(_this2.pinWithName(pinName, pinned));
  3525. localDatastore[pinName] = pinned;
  3526. }
  3527. _iterator3 = _createForOfIteratorHelper(objectKeys);
  3528. _context4.prev = 13;
  3529. _iterator3.s();
  3530. case 15:
  3531. if ((_step3 = _iterator3.n()).done) {
  3532. _context4.next = 31;
  3533. break;
  3534. }
  3535. objectKey = _step3.value;
  3536. hasReference = false;
  3537. _context4.t0 = (0, _keys2.default)(_regenerator.default).call(_regenerator.default, localDatastore);
  3538. case 19:
  3539. if ((_context4.t1 = _context4.t0()).done) {
  3540. _context4.next = 28;
  3541. break;
  3542. }
  3543. key = _context4.t1.value;
  3544. if (!(key === _LocalDatastoreUtils.DEFAULT_PIN || (0, _startsWith.default)(key).call(key, _LocalDatastoreUtils.PIN_PREFIX))) {
  3545. _context4.next = 26;
  3546. break;
  3547. }
  3548. pinnedObjects = localDatastore[key] || [];
  3549. if (!(0, _includes.default)(pinnedObjects).call(pinnedObjects, objectKey)) {
  3550. _context4.next = 26;
  3551. break;
  3552. }
  3553. hasReference = true;
  3554. return _context4.abrupt("break", 28);
  3555. case 26:
  3556. _context4.next = 19;
  3557. break;
  3558. case 28:
  3559. if (!hasReference) {
  3560. promises.push(_this2.unPinWithName(objectKey));
  3561. }
  3562. case 29:
  3563. _context4.next = 15;
  3564. break;
  3565. case 31:
  3566. _context4.next = 36;
  3567. break;
  3568. case 33:
  3569. _context4.prev = 33;
  3570. _context4.t2 = _context4["catch"](13);
  3571. _iterator3.e(_context4.t2);
  3572. case 36:
  3573. _context4.prev = 36;
  3574. _iterator3.f();
  3575. return _context4.finish(36);
  3576. case 39:
  3577. return _context4.abrupt("return", _promise.default.all(promises));
  3578. case 40:
  3579. case "end":
  3580. return _context4.stop();
  3581. }
  3582. }
  3583. }, _callee2, null, [[13, 33, 36, 39]]);
  3584. }))();
  3585. },
  3586. // Retrieve all pointer fields from object recursively
  3587. _getChildren: function _getChildren(object
  3588. /*: ParseObject*/
  3589. ) {
  3590. var encountered = {};
  3591. var json = object._toFullJSON(undefined, true);
  3592. for (var key in json) {
  3593. if (json[key] && json[key].__type && json[key].__type === 'Object') {
  3594. this._traverse(json[key], encountered);
  3595. }
  3596. }
  3597. return encountered;
  3598. },
  3599. _traverse: function _traverse(object
  3600. /*: any*/
  3601. , encountered
  3602. /*: any*/
  3603. ) {
  3604. if (!object.objectId) {
  3605. return;
  3606. } else {
  3607. var objectKey = this.getKeyForObject(object);
  3608. if (encountered[objectKey]) {
  3609. return;
  3610. }
  3611. encountered[objectKey] = object;
  3612. }
  3613. for (var key in object) {
  3614. var json = object[key];
  3615. if (!object[key]) {
  3616. json = object;
  3617. }
  3618. if (json.__type && json.__type === 'Object') {
  3619. this._traverse(json, encountered);
  3620. }
  3621. }
  3622. },
  3623. // Transform keys in pin name to objects
  3624. _serializeObjectsFromPinName: function _serializeObjectsFromPinName(name
  3625. /*: string*/
  3626. ) {
  3627. var _this3 = this;
  3628. return (0, _asyncToGenerator2.default)( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3() {
  3629. var _context5, _concatInstanceProper, _context6;
  3630. var localDatastore, allObjects, key, pinName, pinned, promises, objects;
  3631. return _regeneratorRuntime().wrap(function _callee3$(_context7) {
  3632. while (1) {
  3633. switch (_context7.prev = _context7.next) {
  3634. case 0:
  3635. _context7.next = 2;
  3636. return _this3._getAllContents();
  3637. case 2:
  3638. localDatastore = _context7.sent;
  3639. allObjects = [];
  3640. for (key in localDatastore) {
  3641. if ((0, _startsWith.default)(key).call(key, _LocalDatastoreUtils.OBJECT_PREFIX)) {
  3642. allObjects.push(localDatastore[key][0]);
  3643. }
  3644. }
  3645. if (name) {
  3646. _context7.next = 7;
  3647. break;
  3648. }
  3649. return _context7.abrupt("return", allObjects);
  3650. case 7:
  3651. pinName = _this3.getPinName(name);
  3652. pinned = localDatastore[pinName];
  3653. if ((0, _isArray.default)(pinned)) {
  3654. _context7.next = 11;
  3655. break;
  3656. }
  3657. return _context7.abrupt("return", []);
  3658. case 11:
  3659. promises = (0, _map.default)(pinned).call(pinned, function (objectKey) {
  3660. return _this3.fromPinWithName(objectKey);
  3661. });
  3662. _context7.next = 14;
  3663. return _promise.default.all(promises);
  3664. case 14:
  3665. objects = _context7.sent;
  3666. objects = (_concatInstanceProper = (0, _concat.default)(_context5 = [])).call.apply(_concatInstanceProper, (0, _concat.default)(_context6 = [_context5]).call(_context6, (0, _toConsumableArray2.default)(objects)));
  3667. return _context7.abrupt("return", (0, _filter.default)(objects).call(objects, function (object) {
  3668. return object != null;
  3669. }));
  3670. case 17:
  3671. case "end":
  3672. return _context7.stop();
  3673. }
  3674. }
  3675. }, _callee3);
  3676. }))();
  3677. },
  3678. // Replaces object pointers with pinned pointers
  3679. // The object pointers may contain old data
  3680. // Uses Breadth First Search Algorithm
  3681. _serializeObject: function _serializeObject(objectKey
  3682. /*: string*/
  3683. , localDatastore
  3684. /*: any*/
  3685. ) {
  3686. var _this4 = this;
  3687. return (0, _asyncToGenerator2.default)( /*#__PURE__*/_regeneratorRuntime().mark(function _callee4() {
  3688. var LDS, root, queue, meta, uniqueId, nodeId, subTreeRoot, field, value, key, pointer;
  3689. return _regeneratorRuntime().wrap(function _callee4$(_context8) {
  3690. while (1) {
  3691. switch (_context8.prev = _context8.next) {
  3692. case 0:
  3693. LDS = localDatastore;
  3694. if (LDS) {
  3695. _context8.next = 5;
  3696. break;
  3697. }
  3698. _context8.next = 4;
  3699. return _this4._getAllContents();
  3700. case 4:
  3701. LDS = _context8.sent;
  3702. case 5:
  3703. if (!(!LDS[objectKey] || LDS[objectKey].length === 0)) {
  3704. _context8.next = 7;
  3705. break;
  3706. }
  3707. return _context8.abrupt("return", null);
  3708. case 7:
  3709. root = LDS[objectKey][0];
  3710. queue = [];
  3711. meta = {};
  3712. uniqueId = 0;
  3713. meta[uniqueId] = root;
  3714. queue.push(uniqueId);
  3715. while (queue.length !== 0) {
  3716. nodeId = queue.shift();
  3717. subTreeRoot = meta[nodeId];
  3718. for (field in subTreeRoot) {
  3719. value = subTreeRoot[field];
  3720. if (value.__type && value.__type === 'Object') {
  3721. key = _this4.getKeyForObject(value);
  3722. if (LDS[key] && LDS[key].length > 0) {
  3723. pointer = LDS[key][0];
  3724. uniqueId++;
  3725. meta[uniqueId] = pointer;
  3726. subTreeRoot[field] = pointer;
  3727. queue.push(uniqueId);
  3728. }
  3729. }
  3730. }
  3731. }
  3732. return _context8.abrupt("return", root);
  3733. case 15:
  3734. case "end":
  3735. return _context8.stop();
  3736. }
  3737. }
  3738. }, _callee4);
  3739. }))();
  3740. },
  3741. // Called when an object is save / fetched
  3742. // Update object pin value
  3743. _updateObjectIfPinned: function _updateObjectIfPinned(object
  3744. /*: ParseObject*/
  3745. )
  3746. /*: Promise<void>*/
  3747. {
  3748. var _this5 = this;
  3749. return (0, _asyncToGenerator2.default)( /*#__PURE__*/_regeneratorRuntime().mark(function _callee5() {
  3750. var objectKey, pinned;
  3751. return _regeneratorRuntime().wrap(function _callee5$(_context9) {
  3752. while (1) {
  3753. switch (_context9.prev = _context9.next) {
  3754. case 0:
  3755. if (_this5.isEnabled) {
  3756. _context9.next = 2;
  3757. break;
  3758. }
  3759. return _context9.abrupt("return");
  3760. case 2:
  3761. objectKey = _this5.getKeyForObject(object);
  3762. _context9.next = 5;
  3763. return _this5.fromPinWithName(objectKey);
  3764. case 5:
  3765. pinned = _context9.sent;
  3766. if (!(!pinned || pinned.length === 0)) {
  3767. _context9.next = 8;
  3768. break;
  3769. }
  3770. return _context9.abrupt("return");
  3771. case 8:
  3772. return _context9.abrupt("return", _this5.pinWithName(objectKey, [object._toFullJSON()]));
  3773. case 9:
  3774. case "end":
  3775. return _context9.stop();
  3776. }
  3777. }
  3778. }, _callee5);
  3779. }))();
  3780. },
  3781. // Called when object is destroyed
  3782. // Unpin object and remove all references from pin names
  3783. // TODO: Destroy children?
  3784. _destroyObjectIfPinned: function _destroyObjectIfPinned(object
  3785. /*: ParseObject*/
  3786. ) {
  3787. var _this6 = this;
  3788. return (0, _asyncToGenerator2.default)( /*#__PURE__*/_regeneratorRuntime().mark(function _callee6() {
  3789. var localDatastore, objectKey, pin, promises, key, pinned;
  3790. return _regeneratorRuntime().wrap(function _callee6$(_context10) {
  3791. while (1) {
  3792. switch (_context10.prev = _context10.next) {
  3793. case 0:
  3794. if (_this6.isEnabled) {
  3795. _context10.next = 2;
  3796. break;
  3797. }
  3798. return _context10.abrupt("return");
  3799. case 2:
  3800. _context10.next = 4;
  3801. return _this6._getAllContents();
  3802. case 4:
  3803. localDatastore = _context10.sent;
  3804. objectKey = _this6.getKeyForObject(object);
  3805. pin = localDatastore[objectKey];
  3806. if (pin) {
  3807. _context10.next = 9;
  3808. break;
  3809. }
  3810. return _context10.abrupt("return");
  3811. case 9:
  3812. promises = [_this6.unPinWithName(objectKey)];
  3813. delete localDatastore[objectKey];
  3814. for (key in localDatastore) {
  3815. if (key === _LocalDatastoreUtils.DEFAULT_PIN || (0, _startsWith.default)(key).call(key, _LocalDatastoreUtils.PIN_PREFIX)) {
  3816. pinned = localDatastore[key] || [];
  3817. if ((0, _includes.default)(pinned).call(pinned, objectKey)) {
  3818. pinned = (0, _filter.default)(pinned).call(pinned, function (item) {
  3819. return item !== objectKey;
  3820. });
  3821. if (pinned.length == 0) {
  3822. promises.push(_this6.unPinWithName(key));
  3823. delete localDatastore[key];
  3824. } else {
  3825. promises.push(_this6.pinWithName(key, pinned));
  3826. localDatastore[key] = pinned;
  3827. }
  3828. }
  3829. }
  3830. }
  3831. return _context10.abrupt("return", _promise.default.all(promises));
  3832. case 13:
  3833. case "end":
  3834. return _context10.stop();
  3835. }
  3836. }
  3837. }, _callee6);
  3838. }))();
  3839. },
  3840. // Update pin and references of the unsaved object
  3841. _updateLocalIdForObject: function _updateLocalIdForObject(localId
  3842. /*: string*/
  3843. , object
  3844. /*: ParseObject*/
  3845. ) {
  3846. var _this7 = this;
  3847. return (0, _asyncToGenerator2.default)( /*#__PURE__*/_regeneratorRuntime().mark(function _callee7() {
  3848. var _context11, _context12;
  3849. var localKey, objectKey, unsaved, promises, localDatastore, key, pinned;
  3850. return _regeneratorRuntime().wrap(function _callee7$(_context13) {
  3851. while (1) {
  3852. switch (_context13.prev = _context13.next) {
  3853. case 0:
  3854. if (_this7.isEnabled) {
  3855. _context13.next = 2;
  3856. break;
  3857. }
  3858. return _context13.abrupt("return");
  3859. case 2:
  3860. localKey = (0, _concat.default)(_context11 = (0, _concat.default)(_context12 = "".concat(_LocalDatastoreUtils.OBJECT_PREFIX)).call(_context12, object.className, "_")).call(_context11, localId);
  3861. objectKey = _this7.getKeyForObject(object);
  3862. _context13.next = 6;
  3863. return _this7.fromPinWithName(localKey);
  3864. case 6:
  3865. unsaved = _context13.sent;
  3866. if (!(!unsaved || unsaved.length === 0)) {
  3867. _context13.next = 9;
  3868. break;
  3869. }
  3870. return _context13.abrupt("return");
  3871. case 9:
  3872. promises = [_this7.unPinWithName(localKey), _this7.pinWithName(objectKey, unsaved)];
  3873. _context13.next = 12;
  3874. return _this7._getAllContents();
  3875. case 12:
  3876. localDatastore = _context13.sent;
  3877. for (key in localDatastore) {
  3878. if (key === _LocalDatastoreUtils.DEFAULT_PIN || (0, _startsWith.default)(key).call(key, _LocalDatastoreUtils.PIN_PREFIX)) {
  3879. pinned = localDatastore[key] || [];
  3880. if ((0, _includes.default)(pinned).call(pinned, localKey)) {
  3881. pinned = (0, _filter.default)(pinned).call(pinned, function (item) {
  3882. return item !== localKey;
  3883. });
  3884. pinned.push(objectKey);
  3885. promises.push(_this7.pinWithName(key, pinned));
  3886. localDatastore[key] = pinned;
  3887. }
  3888. }
  3889. }
  3890. return _context13.abrupt("return", _promise.default.all(promises));
  3891. case 15:
  3892. case "end":
  3893. return _context13.stop();
  3894. }
  3895. }
  3896. }, _callee7);
  3897. }))();
  3898. },
  3899. /**
  3900. * Updates Local Datastore from Server
  3901. *
  3902. * <pre>
  3903. * await Parse.LocalDatastore.updateFromServer();
  3904. * </pre>
  3905. *
  3906. * @function updateFromServer
  3907. * @name Parse.LocalDatastore.updateFromServer
  3908. * @static
  3909. */
  3910. updateFromServer: function updateFromServer() {
  3911. var _this8 = this;
  3912. return (0, _asyncToGenerator2.default)( /*#__PURE__*/_regeneratorRuntime().mark(function _callee8() {
  3913. var _context14;
  3914. var localDatastore, keys, key, pointersHash, _i, _keys, _key, _key$split, _key$split2, className, objectId, queryPromises, responses, objects, pinPromises;
  3915. return _regeneratorRuntime().wrap(function _callee8$(_context15) {
  3916. while (1) {
  3917. switch (_context15.prev = _context15.next) {
  3918. case 0:
  3919. if (!(!_this8.checkIfEnabled() || _this8.isSyncing)) {
  3920. _context15.next = 2;
  3921. break;
  3922. }
  3923. return _context15.abrupt("return");
  3924. case 2:
  3925. _context15.next = 4;
  3926. return _this8._getAllContents();
  3927. case 4:
  3928. localDatastore = _context15.sent;
  3929. keys = [];
  3930. for (key in localDatastore) {
  3931. if ((0, _startsWith.default)(key).call(key, _LocalDatastoreUtils.OBJECT_PREFIX)) {
  3932. keys.push(key);
  3933. }
  3934. }
  3935. if (!(keys.length === 0)) {
  3936. _context15.next = 9;
  3937. break;
  3938. }
  3939. return _context15.abrupt("return");
  3940. case 9:
  3941. _this8.isSyncing = true;
  3942. pointersHash = {};
  3943. _i = 0, _keys = keys;
  3944. case 12:
  3945. if (!(_i < _keys.length)) {
  3946. _context15.next = 23;
  3947. break;
  3948. }
  3949. _key = _keys[_i]; // Ignore the OBJECT_PREFIX
  3950. _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' ]
  3951. if (_key.split('_').length === 5 && _key.split('_')[3] === 'User') {
  3952. className = '_User';
  3953. objectId = _key.split('_')[4];
  3954. }
  3955. if (!(0, _startsWith.default)(objectId).call(objectId, 'local')) {
  3956. _context15.next = 18;
  3957. break;
  3958. }
  3959. return _context15.abrupt("continue", 20);
  3960. case 18:
  3961. if (!(className in pointersHash)) {
  3962. pointersHash[className] = new _set.default();
  3963. }
  3964. pointersHash[className].add(objectId);
  3965. case 20:
  3966. _i++;
  3967. _context15.next = 12;
  3968. break;
  3969. case 23:
  3970. queryPromises = (0, _map.default)(_context14 = (0, _keys3.default)(pointersHash)).call(_context14, function (className) {
  3971. var objectIds = (0, _from.default)(pointersHash[className]);
  3972. var query = new _ParseQuery.default(className);
  3973. query.limit(objectIds.length);
  3974. if (objectIds.length === 1) {
  3975. query.equalTo('objectId', objectIds[0]);
  3976. } else {
  3977. query.containedIn('objectId', objectIds);
  3978. }
  3979. return (0, _find.default)(query).call(query);
  3980. });
  3981. _context15.prev = 24;
  3982. _context15.next = 27;
  3983. return _promise.default.all(queryPromises);
  3984. case 27:
  3985. responses = _context15.sent;
  3986. objects = (0, _concat.default)([]).apply([], responses);
  3987. pinPromises = (0, _map.default)(objects).call(objects, function (object) {
  3988. var objectKey = _this8.getKeyForObject(object);
  3989. return _this8.pinWithName(objectKey, object._toFullJSON());
  3990. });
  3991. _context15.next = 32;
  3992. return _promise.default.all(pinPromises);
  3993. case 32:
  3994. _this8.isSyncing = false;
  3995. _context15.next = 39;
  3996. break;
  3997. case 35:
  3998. _context15.prev = 35;
  3999. _context15.t0 = _context15["catch"](24);
  4000. console.error('Error syncing LocalDatastore: ', _context15.t0);
  4001. _this8.isSyncing = false;
  4002. case 39:
  4003. case "end":
  4004. return _context15.stop();
  4005. }
  4006. }
  4007. }, _callee8, null, [[24, 35]]);
  4008. }))();
  4009. },
  4010. getKeyForObject: function getKeyForObject(object
  4011. /*: any*/
  4012. ) {
  4013. var _context16, _context17;
  4014. var objectId = object.objectId || object._getId();
  4015. return (0, _concat.default)(_context16 = (0, _concat.default)(_context17 = "".concat(_LocalDatastoreUtils.OBJECT_PREFIX)).call(_context17, object.className, "_")).call(_context16, objectId);
  4016. },
  4017. getPinName: function getPinName(pinName
  4018. /*: ?string*/
  4019. ) {
  4020. if (!pinName || pinName === _LocalDatastoreUtils.DEFAULT_PIN) {
  4021. return _LocalDatastoreUtils.DEFAULT_PIN;
  4022. }
  4023. return _LocalDatastoreUtils.PIN_PREFIX + pinName;
  4024. },
  4025. checkIfEnabled: function checkIfEnabled() {
  4026. if (!this.isEnabled) {
  4027. console.error('Parse.enableLocalDatastore() must be called first');
  4028. }
  4029. return this.isEnabled;
  4030. }
  4031. };
  4032. module.exports = LocalDatastore;
  4033. _CoreManager.default.setLocalDatastoreController(_dereq_('./LocalDatastoreController'));
  4034. _CoreManager.default.setLocalDatastore(LocalDatastore);
  4035. },{"./CoreManager":4,"./LocalDatastoreController":14,"./LocalDatastoreUtils":15,"./ParseQuery":30,"@babel/runtime-corejs3/core-js-stable/array/from":55,"@babel/runtime-corejs3/core-js-stable/array/is-array":56,"@babel/runtime-corejs3/core-js-stable/instance/concat":58,"@babel/runtime-corejs3/core-js-stable/instance/filter":61,"@babel/runtime-corejs3/core-js-stable/instance/find":63,"@babel/runtime-corejs3/core-js-stable/instance/for-each":64,"@babel/runtime-corejs3/core-js-stable/instance/includes":65,"@babel/runtime-corejs3/core-js-stable/instance/keys":67,"@babel/runtime-corejs3/core-js-stable/instance/map":68,"@babel/runtime-corejs3/core-js-stable/instance/reverse":70,"@babel/runtime-corejs3/core-js-stable/instance/slice":71,"@babel/runtime-corejs3/core-js-stable/instance/starts-with":74,"@babel/runtime-corejs3/core-js-stable/object/create":80,"@babel/runtime-corejs3/core-js-stable/object/define-property":82,"@babel/runtime-corejs3/core-js-stable/object/get-prototype-of":88,"@babel/runtime-corejs3/core-js-stable/object/keys":89,"@babel/runtime-corejs3/core-js-stable/object/set-prototype-of":90,"@babel/runtime-corejs3/core-js-stable/promise":92,"@babel/runtime-corejs3/core-js-stable/set":96,"@babel/runtime-corejs3/core-js-stable/symbol":97,"@babel/runtime-corejs3/core-js/get-iterator-method":101,"@babel/runtime-corejs3/helpers/asyncToGenerator":120,"@babel/runtime-corejs3/helpers/interopRequireDefault":128,"@babel/runtime-corejs3/helpers/slicedToArray":137,"@babel/runtime-corejs3/helpers/toConsumableArray":139,"@babel/runtime-corejs3/helpers/typeof":140,"@babel/runtime-corejs3/regenerator":144}],14:[function(_dereq_,module,exports){
  4036. "use strict";
  4037. var _interopRequireDefault = _dereq_("@babel/runtime-corejs3/helpers/interopRequireDefault");
  4038. var _Array$isArray = _dereq_("@babel/runtime-corejs3/core-js-stable/array/is-array");
  4039. var _getIteratorMethod = _dereq_("@babel/runtime-corejs3/core-js/get-iterator-method");
  4040. var _Array$from = _dereq_("@babel/runtime-corejs3/core-js-stable/array/from");
  4041. var _sliceInstanceProperty = _dereq_("@babel/runtime-corejs3/core-js-stable/instance/slice");
  4042. var _reverseInstanceProperty = _dereq_("@babel/runtime-corejs3/core-js-stable/instance/reverse");
  4043. var _Promise2 = _dereq_("@babel/runtime-corejs3/core-js-stable/promise");
  4044. var _Object$setPrototypeOf = _dereq_("@babel/runtime-corejs3/core-js-stable/object/set-prototype-of");
  4045. var _typeof = _dereq_("@babel/runtime-corejs3/helpers/typeof");
  4046. var _forEachInstanceProperty = _dereq_("@babel/runtime-corejs3/core-js-stable/instance/for-each");
  4047. var _Object$getPrototypeOf = _dereq_("@babel/runtime-corejs3/core-js-stable/object/get-prototype-of");
  4048. var _Object$create = _dereq_("@babel/runtime-corejs3/core-js-stable/object/create");
  4049. var _Object$defineProperty = _dereq_("@babel/runtime-corejs3/core-js-stable/object/define-property");
  4050. var _Symbol = _dereq_("@babel/runtime-corejs3/core-js-stable/symbol");
  4051. var _map = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/instance/map"));
  4052. var _promise = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/promise"));
  4053. var _reduce = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/instance/reduce"));
  4054. var _stringify = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/json/stringify"));
  4055. var _asyncToGenerator2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/helpers/asyncToGenerator"));
  4056. var _LocalDatastoreUtils = _dereq_("./LocalDatastoreUtils");
  4057. var _Storage = _interopRequireDefault(_dereq_("./Storage"));
  4058. function _createForOfIteratorHelper(o, allowArrayLike) {
  4059. var it = typeof _Symbol !== "undefined" && _getIteratorMethod(o) || o["@@iterator"];
  4060. if (!it) {
  4061. if (_Array$isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") {
  4062. if (it) o = it;
  4063. var i = 0;
  4064. var F = function () {};
  4065. return {
  4066. s: F,
  4067. n: function () {
  4068. if (i >= o.length) return {
  4069. done: true
  4070. };
  4071. return {
  4072. done: false,
  4073. value: o[i++]
  4074. };
  4075. },
  4076. e: function (_e) {
  4077. throw _e;
  4078. },
  4079. f: F
  4080. };
  4081. }
  4082. throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
  4083. }
  4084. var normalCompletion = true,
  4085. didErr = false,
  4086. err;
  4087. return {
  4088. s: function () {
  4089. it = it.call(o);
  4090. },
  4091. n: function () {
  4092. var step = it.next();
  4093. normalCompletion = step.done;
  4094. return step;
  4095. },
  4096. e: function (_e2) {
  4097. didErr = true;
  4098. err = _e2;
  4099. },
  4100. f: function () {
  4101. try {
  4102. if (!normalCompletion && it.return != null) it.return();
  4103. } finally {
  4104. if (didErr) throw err;
  4105. }
  4106. }
  4107. };
  4108. }
  4109. function _unsupportedIterableToArray(o, minLen) {
  4110. var _context9;
  4111. if (!o) return;
  4112. if (typeof o === "string") return _arrayLikeToArray(o, minLen);
  4113. var n = _sliceInstanceProperty(_context9 = Object.prototype.toString.call(o)).call(_context9, 8, -1);
  4114. if (n === "Object" && o.constructor) n = o.constructor.name;
  4115. if (n === "Map" || n === "Set") return _Array$from(o);
  4116. if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen);
  4117. }
  4118. function _arrayLikeToArray(arr, len) {
  4119. if (len == null || len > arr.length) len = arr.length;
  4120. for (var i = 0, arr2 = new Array(len); i < len; i++) {
  4121. arr2[i] = arr[i];
  4122. }
  4123. return arr2;
  4124. }
  4125. function _regeneratorRuntime() {
  4126. "use strict";
  4127. /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */
  4128. _regeneratorRuntime = function () {
  4129. return exports;
  4130. };
  4131. var exports = {},
  4132. Op = Object.prototype,
  4133. hasOwn = Op.hasOwnProperty,
  4134. $Symbol = "function" == typeof _Symbol ? _Symbol : {},
  4135. iteratorSymbol = $Symbol.iterator || "@@iterator",
  4136. asyncIteratorSymbol = $Symbol.asyncIterator || "@@asyncIterator",
  4137. toStringTagSymbol = $Symbol.toStringTag || "@@toStringTag";
  4138. function define(obj, key, value) {
  4139. return _Object$defineProperty(obj, key, {
  4140. value: value,
  4141. enumerable: !0,
  4142. configurable: !0,
  4143. writable: !0
  4144. }), obj[key];
  4145. }
  4146. try {
  4147. define({}, "");
  4148. } catch (err) {
  4149. define = function (obj, key, value) {
  4150. return obj[key] = value;
  4151. };
  4152. }
  4153. function wrap(innerFn, outerFn, self, tryLocsList) {
  4154. var protoGenerator = outerFn && outerFn.prototype instanceof Generator ? outerFn : Generator,
  4155. generator = _Object$create(protoGenerator.prototype),
  4156. context = new Context(tryLocsList || []);
  4157. return generator._invoke = function (innerFn, self, context) {
  4158. var state = "suspendedStart";
  4159. return function (method, arg) {
  4160. if ("executing" === state) throw new Error("Generator is already running");
  4161. if ("completed" === state) {
  4162. if ("throw" === method) throw arg;
  4163. return doneResult();
  4164. }
  4165. for (context.method = method, context.arg = arg;;) {
  4166. var delegate = context.delegate;
  4167. if (delegate) {
  4168. var delegateResult = maybeInvokeDelegate(delegate, context);
  4169. if (delegateResult) {
  4170. if (delegateResult === ContinueSentinel) continue;
  4171. return delegateResult;
  4172. }
  4173. }
  4174. if ("next" === context.method) context.sent = context._sent = context.arg;else if ("throw" === context.method) {
  4175. if ("suspendedStart" === state) throw state = "completed", context.arg;
  4176. context.dispatchException(context.arg);
  4177. } else "return" === context.method && context.abrupt("return", context.arg);
  4178. state = "executing";
  4179. var record = tryCatch(innerFn, self, context);
  4180. if ("normal" === record.type) {
  4181. if (state = context.done ? "completed" : "suspendedYield", record.arg === ContinueSentinel) continue;
  4182. return {
  4183. value: record.arg,
  4184. done: context.done
  4185. };
  4186. }
  4187. "throw" === record.type && (state = "completed", context.method = "throw", context.arg = record.arg);
  4188. }
  4189. };
  4190. }(innerFn, self, context), generator;
  4191. }
  4192. function tryCatch(fn, obj, arg) {
  4193. try {
  4194. return {
  4195. type: "normal",
  4196. arg: fn.call(obj, arg)
  4197. };
  4198. } catch (err) {
  4199. return {
  4200. type: "throw",
  4201. arg: err
  4202. };
  4203. }
  4204. }
  4205. exports.wrap = wrap;
  4206. var ContinueSentinel = {};
  4207. function Generator() {}
  4208. function GeneratorFunction() {}
  4209. function GeneratorFunctionPrototype() {}
  4210. var IteratorPrototype = {};
  4211. define(IteratorPrototype, iteratorSymbol, function () {
  4212. return this;
  4213. });
  4214. var getProto = _Object$getPrototypeOf,
  4215. NativeIteratorPrototype = getProto && getProto(getProto(values([])));
  4216. NativeIteratorPrototype && NativeIteratorPrototype !== Op && hasOwn.call(NativeIteratorPrototype, iteratorSymbol) && (IteratorPrototype = NativeIteratorPrototype);
  4217. var Gp = GeneratorFunctionPrototype.prototype = Generator.prototype = _Object$create(IteratorPrototype);
  4218. function defineIteratorMethods(prototype) {
  4219. var _context7;
  4220. _forEachInstanceProperty(_context7 = ["next", "throw", "return"]).call(_context7, function (method) {
  4221. define(prototype, method, function (arg) {
  4222. return this._invoke(method, arg);
  4223. });
  4224. });
  4225. }
  4226. function AsyncIterator(generator, PromiseImpl) {
  4227. function invoke(method, arg, resolve, reject) {
  4228. var record = tryCatch(generator[method], generator, arg);
  4229. if ("throw" !== record.type) {
  4230. var result = record.arg,
  4231. value = result.value;
  4232. return value && "object" == _typeof(value) && hasOwn.call(value, "__await") ? PromiseImpl.resolve(value.__await).then(function (value) {
  4233. invoke("next", value, resolve, reject);
  4234. }, function (err) {
  4235. invoke("throw", err, resolve, reject);
  4236. }) : PromiseImpl.resolve(value).then(function (unwrapped) {
  4237. result.value = unwrapped, resolve(result);
  4238. }, function (error) {
  4239. return invoke("throw", error, resolve, reject);
  4240. });
  4241. }
  4242. reject(record.arg);
  4243. }
  4244. var previousPromise;
  4245. this._invoke = function (method, arg) {
  4246. function callInvokeWithMethodAndArg() {
  4247. return new PromiseImpl(function (resolve, reject) {
  4248. invoke(method, arg, resolve, reject);
  4249. });
  4250. }
  4251. return previousPromise = previousPromise ? previousPromise.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg();
  4252. };
  4253. }
  4254. function maybeInvokeDelegate(delegate, context) {
  4255. var method = delegate.iterator[context.method];
  4256. if (undefined === method) {
  4257. if (context.delegate = null, "throw" === context.method) {
  4258. if (delegate.iterator.return && (context.method = "return", context.arg = undefined, maybeInvokeDelegate(delegate, context), "throw" === context.method)) return ContinueSentinel;
  4259. context.method = "throw", context.arg = new TypeError("The iterator does not provide a 'throw' method");
  4260. }
  4261. return ContinueSentinel;
  4262. }
  4263. var record = tryCatch(method, delegate.iterator, context.arg);
  4264. if ("throw" === record.type) return context.method = "throw", context.arg = record.arg, context.delegate = null, ContinueSentinel;
  4265. var info = record.arg;
  4266. return info ? info.done ? (context[delegate.resultName] = info.value, context.next = delegate.nextLoc, "return" !== context.method && (context.method = "next", context.arg = undefined), context.delegate = null, ContinueSentinel) : info : (context.method = "throw", context.arg = new TypeError("iterator result is not an object"), context.delegate = null, ContinueSentinel);
  4267. }
  4268. function pushTryEntry(locs) {
  4269. var entry = {
  4270. tryLoc: locs[0]
  4271. };
  4272. 1 in locs && (entry.catchLoc = locs[1]), 2 in locs && (entry.finallyLoc = locs[2], entry.afterLoc = locs[3]), this.tryEntries.push(entry);
  4273. }
  4274. function resetTryEntry(entry) {
  4275. var record = entry.completion || {};
  4276. record.type = "normal", delete record.arg, entry.completion = record;
  4277. }
  4278. function Context(tryLocsList) {
  4279. this.tryEntries = [{
  4280. tryLoc: "root"
  4281. }], _forEachInstanceProperty(tryLocsList).call(tryLocsList, pushTryEntry, this), this.reset(!0);
  4282. }
  4283. function values(iterable) {
  4284. if (iterable) {
  4285. var iteratorMethod = iterable[iteratorSymbol];
  4286. if (iteratorMethod) return iteratorMethod.call(iterable);
  4287. if ("function" == typeof iterable.next) return iterable;
  4288. if (!isNaN(iterable.length)) {
  4289. var i = -1,
  4290. next = function next() {
  4291. for (; ++i < iterable.length;) {
  4292. if (hasOwn.call(iterable, i)) return next.value = iterable[i], next.done = !1, next;
  4293. }
  4294. return next.value = undefined, next.done = !0, next;
  4295. };
  4296. return next.next = next;
  4297. }
  4298. }
  4299. return {
  4300. next: doneResult
  4301. };
  4302. }
  4303. function doneResult() {
  4304. return {
  4305. value: undefined,
  4306. done: !0
  4307. };
  4308. }
  4309. return GeneratorFunction.prototype = GeneratorFunctionPrototype, define(Gp, "constructor", GeneratorFunctionPrototype), define(GeneratorFunctionPrototype, "constructor", GeneratorFunction), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, toStringTagSymbol, "GeneratorFunction"), exports.isGeneratorFunction = function (genFun) {
  4310. var ctor = "function" == typeof genFun && genFun.constructor;
  4311. return !!ctor && (ctor === GeneratorFunction || "GeneratorFunction" === (ctor.displayName || ctor.name));
  4312. }, exports.mark = function (genFun) {
  4313. return _Object$setPrototypeOf ? _Object$setPrototypeOf(genFun, GeneratorFunctionPrototype) : (genFun.__proto__ = GeneratorFunctionPrototype, define(genFun, toStringTagSymbol, "GeneratorFunction")), genFun.prototype = _Object$create(Gp), genFun;
  4314. }, exports.awrap = function (arg) {
  4315. return {
  4316. __await: arg
  4317. };
  4318. }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, asyncIteratorSymbol, function () {
  4319. return this;
  4320. }), exports.AsyncIterator = AsyncIterator, exports.async = function (innerFn, outerFn, self, tryLocsList, PromiseImpl) {
  4321. void 0 === PromiseImpl && (PromiseImpl = _Promise2);
  4322. var iter = new AsyncIterator(wrap(innerFn, outerFn, self, tryLocsList), PromiseImpl);
  4323. return exports.isGeneratorFunction(outerFn) ? iter : iter.next().then(function (result) {
  4324. return result.done ? result.value : iter.next();
  4325. });
  4326. }, defineIteratorMethods(Gp), define(Gp, toStringTagSymbol, "Generator"), define(Gp, iteratorSymbol, function () {
  4327. return this;
  4328. }), define(Gp, "toString", function () {
  4329. return "[object Generator]";
  4330. }), exports.keys = function (object) {
  4331. var keys = [];
  4332. for (var key in object) {
  4333. keys.push(key);
  4334. }
  4335. return _reverseInstanceProperty(keys).call(keys), function next() {
  4336. for (; keys.length;) {
  4337. var key = keys.pop();
  4338. if (key in object) return next.value = key, next.done = !1, next;
  4339. }
  4340. return next.done = !0, next;
  4341. };
  4342. }, exports.values = values, Context.prototype = {
  4343. constructor: Context,
  4344. reset: function (skipTempReset) {
  4345. var _context8;
  4346. if (this.prev = 0, this.next = 0, this.sent = this._sent = undefined, this.done = !1, this.delegate = null, this.method = "next", this.arg = undefined, _forEachInstanceProperty(_context8 = this.tryEntries).call(_context8, resetTryEntry), !skipTempReset) for (var name in this) {
  4347. "t" === name.charAt(0) && hasOwn.call(this, name) && !isNaN(+_sliceInstanceProperty(name).call(name, 1)) && (this[name] = undefined);
  4348. }
  4349. },
  4350. stop: function () {
  4351. this.done = !0;
  4352. var rootRecord = this.tryEntries[0].completion;
  4353. if ("throw" === rootRecord.type) throw rootRecord.arg;
  4354. return this.rval;
  4355. },
  4356. dispatchException: function (exception) {
  4357. if (this.done) throw exception;
  4358. var context = this;
  4359. function handle(loc, caught) {
  4360. return record.type = "throw", record.arg = exception, context.next = loc, caught && (context.method = "next", context.arg = undefined), !!caught;
  4361. }
  4362. for (var i = this.tryEntries.length - 1; i >= 0; --i) {
  4363. var entry = this.tryEntries[i],
  4364. record = entry.completion;
  4365. if ("root" === entry.tryLoc) return handle("end");
  4366. if (entry.tryLoc <= this.prev) {
  4367. var hasCatch = hasOwn.call(entry, "catchLoc"),
  4368. hasFinally = hasOwn.call(entry, "finallyLoc");
  4369. if (hasCatch && hasFinally) {
  4370. if (this.prev < entry.catchLoc) return handle(entry.catchLoc, !0);
  4371. if (this.prev < entry.finallyLoc) return handle(entry.finallyLoc);
  4372. } else if (hasCatch) {
  4373. if (this.prev < entry.catchLoc) return handle(entry.catchLoc, !0);
  4374. } else {
  4375. if (!hasFinally) throw new Error("try statement without catch or finally");
  4376. if (this.prev < entry.finallyLoc) return handle(entry.finallyLoc);
  4377. }
  4378. }
  4379. }
  4380. },
  4381. abrupt: function (type, arg) {
  4382. for (var i = this.tryEntries.length - 1; i >= 0; --i) {
  4383. var entry = this.tryEntries[i];
  4384. if (entry.tryLoc <= this.prev && hasOwn.call(entry, "finallyLoc") && this.prev < entry.finallyLoc) {
  4385. var finallyEntry = entry;
  4386. break;
  4387. }
  4388. }
  4389. finallyEntry && ("break" === type || "continue" === type) && finallyEntry.tryLoc <= arg && arg <= finallyEntry.finallyLoc && (finallyEntry = null);
  4390. var record = finallyEntry ? finallyEntry.completion : {};
  4391. return record.type = type, record.arg = arg, finallyEntry ? (this.method = "next", this.next = finallyEntry.finallyLoc, ContinueSentinel) : this.complete(record);
  4392. },
  4393. complete: function (record, afterLoc) {
  4394. if ("throw" === record.type) throw record.arg;
  4395. return "break" === record.type || "continue" === record.type ? this.next = record.arg : "return" === record.type ? (this.rval = this.arg = record.arg, this.method = "return", this.next = "end") : "normal" === record.type && afterLoc && (this.next = afterLoc), ContinueSentinel;
  4396. },
  4397. finish: function (finallyLoc) {
  4398. for (var i = this.tryEntries.length - 1; i >= 0; --i) {
  4399. var entry = this.tryEntries[i];
  4400. if (entry.finallyLoc === finallyLoc) return this.complete(entry.completion, entry.afterLoc), resetTryEntry(entry), ContinueSentinel;
  4401. }
  4402. },
  4403. catch: function (tryLoc) {
  4404. for (var i = this.tryEntries.length - 1; i >= 0; --i) {
  4405. var entry = this.tryEntries[i];
  4406. if (entry.tryLoc === tryLoc) {
  4407. var record = entry.completion;
  4408. if ("throw" === record.type) {
  4409. var thrown = record.arg;
  4410. resetTryEntry(entry);
  4411. }
  4412. return thrown;
  4413. }
  4414. }
  4415. throw new Error("illegal catch attempt");
  4416. },
  4417. delegateYield: function (iterable, resultName, nextLoc) {
  4418. return this.delegate = {
  4419. iterator: values(iterable),
  4420. resultName: resultName,
  4421. nextLoc: nextLoc
  4422. }, "next" === this.method && (this.arg = undefined), ContinueSentinel;
  4423. }
  4424. }, exports;
  4425. }
  4426. var LocalDatastoreController = {
  4427. fromPinWithName: function (name
  4428. /*: string*/
  4429. )
  4430. /*: Array<Object>*/
  4431. {
  4432. return (0, _asyncToGenerator2.default)( /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
  4433. var values, objects;
  4434. return _regeneratorRuntime().wrap(function _callee$(_context) {
  4435. while (1) {
  4436. switch (_context.prev = _context.next) {
  4437. case 0:
  4438. _context.next = 2;
  4439. return _Storage.default.getItemAsync(name);
  4440. case 2:
  4441. values = _context.sent;
  4442. if (values) {
  4443. _context.next = 5;
  4444. break;
  4445. }
  4446. return _context.abrupt("return", []);
  4447. case 5:
  4448. objects = JSON.parse(values);
  4449. return _context.abrupt("return", objects);
  4450. case 7:
  4451. case "end":
  4452. return _context.stop();
  4453. }
  4454. }
  4455. }, _callee);
  4456. }))();
  4457. },
  4458. pinWithName: function pinWithName(name
  4459. /*: string*/
  4460. , value
  4461. /*: any*/
  4462. ) {
  4463. var values = (0, _stringify.default)(value);
  4464. return _Storage.default.setItemAsync(name, values);
  4465. },
  4466. unPinWithName: function unPinWithName(name
  4467. /*: string*/
  4468. ) {
  4469. return _Storage.default.removeItemAsync(name);
  4470. },
  4471. getAllContents: function getAllContents()
  4472. /*: Object*/
  4473. {
  4474. return (0, _asyncToGenerator2.default)( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3() {
  4475. var keys;
  4476. return _regeneratorRuntime().wrap(function _callee3$(_context3) {
  4477. while (1) {
  4478. switch (_context3.prev = _context3.next) {
  4479. case 0:
  4480. _context3.next = 2;
  4481. return _Storage.default.getAllKeysAsync();
  4482. case 2:
  4483. keys = _context3.sent;
  4484. return _context3.abrupt("return", (0, _reduce.default)(keys).call(keys, /*#__PURE__*/function () {
  4485. var _ref = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(previousPromise, key) {
  4486. var LDS, value;
  4487. return _regeneratorRuntime().wrap(function _callee2$(_context2) {
  4488. while (1) {
  4489. switch (_context2.prev = _context2.next) {
  4490. case 0:
  4491. _context2.next = 2;
  4492. return previousPromise;
  4493. case 2:
  4494. LDS = _context2.sent;
  4495. if (!(0, _LocalDatastoreUtils.isLocalDatastoreKey)(key)) {
  4496. _context2.next = 8;
  4497. break;
  4498. }
  4499. _context2.next = 6;
  4500. return _Storage.default.getItemAsync(key);
  4501. case 6:
  4502. value = _context2.sent;
  4503. try {
  4504. LDS[key] = JSON.parse(value);
  4505. } catch (error) {
  4506. console.error('Error getAllContents: ', error);
  4507. }
  4508. case 8:
  4509. return _context2.abrupt("return", LDS);
  4510. case 9:
  4511. case "end":
  4512. return _context2.stop();
  4513. }
  4514. }
  4515. }, _callee2);
  4516. }));
  4517. return function (_x, _x2) {
  4518. return _ref.apply(this, arguments);
  4519. };
  4520. }(), _promise.default.resolve({})));
  4521. case 4:
  4522. case "end":
  4523. return _context3.stop();
  4524. }
  4525. }
  4526. }, _callee3);
  4527. }))();
  4528. },
  4529. // Used for testing
  4530. getRawStorage: function getRawStorage()
  4531. /*: Object*/
  4532. {
  4533. return (0, _asyncToGenerator2.default)( /*#__PURE__*/_regeneratorRuntime().mark(function _callee5() {
  4534. var keys;
  4535. return _regeneratorRuntime().wrap(function _callee5$(_context5) {
  4536. while (1) {
  4537. switch (_context5.prev = _context5.next) {
  4538. case 0:
  4539. _context5.next = 2;
  4540. return _Storage.default.getAllKeysAsync();
  4541. case 2:
  4542. keys = _context5.sent;
  4543. return _context5.abrupt("return", (0, _reduce.default)(keys).call(keys, /*#__PURE__*/function () {
  4544. var _ref2 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regeneratorRuntime().mark(function _callee4(previousPromise, key) {
  4545. var LDS, value;
  4546. return _regeneratorRuntime().wrap(function _callee4$(_context4) {
  4547. while (1) {
  4548. switch (_context4.prev = _context4.next) {
  4549. case 0:
  4550. _context4.next = 2;
  4551. return previousPromise;
  4552. case 2:
  4553. LDS = _context4.sent;
  4554. _context4.next = 5;
  4555. return _Storage.default.getItemAsync(key);
  4556. case 5:
  4557. value = _context4.sent;
  4558. LDS[key] = value;
  4559. return _context4.abrupt("return", LDS);
  4560. case 8:
  4561. case "end":
  4562. return _context4.stop();
  4563. }
  4564. }
  4565. }, _callee4);
  4566. }));
  4567. return function (_x3, _x4) {
  4568. return _ref2.apply(this, arguments);
  4569. };
  4570. }(), _promise.default.resolve({})));
  4571. case 4:
  4572. case "end":
  4573. return _context5.stop();
  4574. }
  4575. }
  4576. }, _callee5);
  4577. }))();
  4578. },
  4579. clear: function clear()
  4580. /*: Promise*/
  4581. {
  4582. var _this = this;
  4583. return (0, _asyncToGenerator2.default)( /*#__PURE__*/_regeneratorRuntime().mark(function _callee6() {
  4584. var keys, toRemove, _iterator, _step, key, promises;
  4585. return _regeneratorRuntime().wrap(function _callee6$(_context6) {
  4586. while (1) {
  4587. switch (_context6.prev = _context6.next) {
  4588. case 0:
  4589. _context6.next = 2;
  4590. return _Storage.default.getAllKeysAsync();
  4591. case 2:
  4592. keys = _context6.sent;
  4593. toRemove = [];
  4594. _iterator = _createForOfIteratorHelper(keys);
  4595. try {
  4596. for (_iterator.s(); !(_step = _iterator.n()).done;) {
  4597. key = _step.value;
  4598. if ((0, _LocalDatastoreUtils.isLocalDatastoreKey)(key)) {
  4599. toRemove.push(key);
  4600. }
  4601. }
  4602. } catch (err) {
  4603. _iterator.e(err);
  4604. } finally {
  4605. _iterator.f();
  4606. }
  4607. promises = (0, _map.default)(toRemove).call(toRemove, _this.unPinWithName);
  4608. return _context6.abrupt("return", _promise.default.all(promises));
  4609. case 8:
  4610. case "end":
  4611. return _context6.stop();
  4612. }
  4613. }
  4614. }, _callee6);
  4615. }))();
  4616. }
  4617. };
  4618. module.exports = LocalDatastoreController;
  4619. },{"./LocalDatastoreUtils":15,"./Storage":39,"@babel/runtime-corejs3/core-js-stable/array/from":55,"@babel/runtime-corejs3/core-js-stable/array/is-array":56,"@babel/runtime-corejs3/core-js-stable/instance/for-each":64,"@babel/runtime-corejs3/core-js-stable/instance/map":68,"@babel/runtime-corejs3/core-js-stable/instance/reduce":69,"@babel/runtime-corejs3/core-js-stable/instance/reverse":70,"@babel/runtime-corejs3/core-js-stable/instance/slice":71,"@babel/runtime-corejs3/core-js-stable/json/stringify":76,"@babel/runtime-corejs3/core-js-stable/object/create":80,"@babel/runtime-corejs3/core-js-stable/object/define-property":82,"@babel/runtime-corejs3/core-js-stable/object/get-prototype-of":88,"@babel/runtime-corejs3/core-js-stable/object/set-prototype-of":90,"@babel/runtime-corejs3/core-js-stable/promise":92,"@babel/runtime-corejs3/core-js-stable/symbol":97,"@babel/runtime-corejs3/core-js/get-iterator-method":101,"@babel/runtime-corejs3/helpers/asyncToGenerator":120,"@babel/runtime-corejs3/helpers/interopRequireDefault":128,"@babel/runtime-corejs3/helpers/typeof":140}],15:[function(_dereq_,module,exports){
  4620. "use strict";
  4621. var _interopRequireDefault = _dereq_("@babel/runtime-corejs3/helpers/interopRequireDefault");
  4622. var _Object$defineProperty = _dereq_("@babel/runtime-corejs3/core-js-stable/object/define-property");
  4623. _Object$defineProperty(exports, "__esModule", {
  4624. value: true
  4625. });
  4626. exports.PIN_PREFIX = exports.OBJECT_PREFIX = exports.DEFAULT_PIN = void 0;
  4627. exports.isLocalDatastoreKey = isLocalDatastoreKey;
  4628. var _startsWith = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/instance/starts-with"));
  4629. /**
  4630. * Copyright (c) 2015-present, Parse, LLC.
  4631. * All rights reserved.
  4632. *
  4633. * This source code is licensed under the BSD-style license found in the
  4634. * LICENSE file in the root directory of this source tree. An additional grant
  4635. * of patent rights can be found in the PATENTS file in the same directory.
  4636. *
  4637. * @flow
  4638. * @private
  4639. */
  4640. var DEFAULT_PIN = '_default';
  4641. exports.DEFAULT_PIN = DEFAULT_PIN;
  4642. var PIN_PREFIX = 'parsePin_';
  4643. exports.PIN_PREFIX = PIN_PREFIX;
  4644. var OBJECT_PREFIX = 'Parse_LDS_';
  4645. exports.OBJECT_PREFIX = OBJECT_PREFIX;
  4646. function isLocalDatastoreKey(key
  4647. /*: string*/
  4648. )
  4649. /*: boolean*/
  4650. {
  4651. return !!(key && (key === DEFAULT_PIN || (0, _startsWith.default)(key).call(key, PIN_PREFIX) || (0, _startsWith.default)(key).call(key, OBJECT_PREFIX)));
  4652. }
  4653. },{"@babel/runtime-corejs3/core-js-stable/instance/starts-with":74,"@babel/runtime-corejs3/core-js-stable/object/define-property":82,"@babel/runtime-corejs3/helpers/interopRequireDefault":128}],16:[function(_dereq_,module,exports){
  4654. "use strict";
  4655. var _interopRequireDefault = _dereq_("@babel/runtime-corejs3/helpers/interopRequireDefault");
  4656. var _Object$defineProperty = _dereq_("@babel/runtime-corejs3/core-js-stable/object/define-property");
  4657. var _Object$defineProperties = _dereq_("@babel/runtime-corejs3/core-js-stable/object/define-properties");
  4658. var _Object$getOwnPropertyDescriptors = _dereq_("@babel/runtime-corejs3/core-js-stable/object/get-own-property-descriptors");
  4659. var _forEachInstanceProperty = _dereq_("@babel/runtime-corejs3/core-js-stable/instance/for-each");
  4660. var _Object$getOwnPropertyDescriptor = _dereq_("@babel/runtime-corejs3/core-js-stable/object/get-own-property-descriptor");
  4661. var _filterInstanceProperty = _dereq_("@babel/runtime-corejs3/core-js-stable/instance/filter");
  4662. var _Object$getOwnPropertySymbols = _dereq_("@babel/runtime-corejs3/core-js-stable/object/get-own-property-symbols");
  4663. var _Object$keys = _dereq_("@babel/runtime-corejs3/core-js-stable/object/keys");
  4664. _Object$defineProperty(exports, "__esModule", {
  4665. value: true
  4666. });
  4667. exports.commitServerChanges = commitServerChanges;
  4668. exports.defaultState = defaultState;
  4669. exports.estimateAttribute = estimateAttribute;
  4670. exports.estimateAttributes = estimateAttributes;
  4671. exports.mergeFirstPendingState = mergeFirstPendingState;
  4672. exports.popPendingState = popPendingState;
  4673. exports.pushPendingState = pushPendingState;
  4674. exports.setPendingOp = setPendingOp;
  4675. exports.setServerData = setServerData;
  4676. var _stringify = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/json/stringify"));
  4677. var _typeof2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/helpers/typeof"));
  4678. var _defineProperty2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/helpers/defineProperty"));
  4679. var _includes = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/instance/includes"));
  4680. var _encode = _interopRequireDefault(_dereq_("./encode"));
  4681. var _ParseFile = _interopRequireDefault(_dereq_("./ParseFile"));
  4682. var _ParseObject = _interopRequireDefault(_dereq_("./ParseObject"));
  4683. var _ParseRelation = _interopRequireDefault(_dereq_("./ParseRelation"));
  4684. var _TaskQueue = _interopRequireDefault(_dereq_("./TaskQueue"));
  4685. var _ParseOp = _dereq_("./ParseOp");
  4686. function ownKeys(object, enumerableOnly) {
  4687. var keys = _Object$keys(object);
  4688. if (_Object$getOwnPropertySymbols) {
  4689. var symbols = _Object$getOwnPropertySymbols(object);
  4690. enumerableOnly && (symbols = _filterInstanceProperty(symbols).call(symbols, function (sym) {
  4691. return _Object$getOwnPropertyDescriptor(object, sym).enumerable;
  4692. })), keys.push.apply(keys, symbols);
  4693. }
  4694. return keys;
  4695. }
  4696. function _objectSpread(target) {
  4697. for (var i = 1; i < arguments.length; i++) {
  4698. var _context, _context2;
  4699. var source = null != arguments[i] ? arguments[i] : {};
  4700. i % 2 ? _forEachInstanceProperty(_context = ownKeys(Object(source), !0)).call(_context, function (key) {
  4701. (0, _defineProperty2.default)(target, key, source[key]);
  4702. }) : _Object$getOwnPropertyDescriptors ? _Object$defineProperties(target, _Object$getOwnPropertyDescriptors(source)) : _forEachInstanceProperty(_context2 = ownKeys(Object(source))).call(_context2, function (key) {
  4703. _Object$defineProperty(target, key, _Object$getOwnPropertyDescriptor(source, key));
  4704. });
  4705. }
  4706. return target;
  4707. }
  4708. function defaultState()
  4709. /*: State*/
  4710. {
  4711. return {
  4712. serverData: {},
  4713. pendingOps: [{}],
  4714. objectCache: {},
  4715. tasks: new _TaskQueue.default(),
  4716. existed: false
  4717. };
  4718. }
  4719. function setServerData(serverData
  4720. /*: AttributeMap*/
  4721. , attributes
  4722. /*: AttributeMap*/
  4723. ) {
  4724. for (var _attr in attributes) {
  4725. if (typeof attributes[_attr] !== 'undefined') {
  4726. serverData[_attr] = attributes[_attr];
  4727. } else {
  4728. delete serverData[_attr];
  4729. }
  4730. }
  4731. }
  4732. function setPendingOp(pendingOps
  4733. /*: Array<OpsMap>*/
  4734. , attr
  4735. /*: string*/
  4736. , op
  4737. /*: ?Op*/
  4738. ) {
  4739. var last = pendingOps.length - 1;
  4740. if (op) {
  4741. pendingOps[last][attr] = op;
  4742. } else {
  4743. delete pendingOps[last][attr];
  4744. }
  4745. }
  4746. function pushPendingState(pendingOps
  4747. /*: Array<OpsMap>*/
  4748. ) {
  4749. pendingOps.push({});
  4750. }
  4751. function popPendingState(pendingOps
  4752. /*: Array<OpsMap>*/
  4753. )
  4754. /*: OpsMap*/
  4755. {
  4756. var first = pendingOps.shift();
  4757. if (!pendingOps.length) {
  4758. pendingOps[0] = {};
  4759. }
  4760. return first;
  4761. }
  4762. function mergeFirstPendingState(pendingOps
  4763. /*: Array<OpsMap>*/
  4764. ) {
  4765. var first = popPendingState(pendingOps);
  4766. var next = pendingOps[0];
  4767. for (var _attr2 in first) {
  4768. if (next[_attr2] && first[_attr2]) {
  4769. var merged = next[_attr2].mergeWith(first[_attr2]);
  4770. if (merged) {
  4771. next[_attr2] = merged;
  4772. }
  4773. } else {
  4774. next[_attr2] = first[_attr2];
  4775. }
  4776. }
  4777. }
  4778. function estimateAttribute(serverData
  4779. /*: AttributeMap*/
  4780. , pendingOps
  4781. /*: Array<OpsMap>*/
  4782. , className
  4783. /*: string*/
  4784. , id
  4785. /*: ?string*/
  4786. , attr
  4787. /*: string*/
  4788. )
  4789. /*: mixed*/
  4790. {
  4791. var value = serverData[attr];
  4792. for (var i = 0; i < pendingOps.length; i++) {
  4793. if (pendingOps[i][attr]) {
  4794. if (pendingOps[i][attr] instanceof _ParseOp.RelationOp) {
  4795. if (id) {
  4796. value = pendingOps[i][attr].applyTo(value, {
  4797. className: className,
  4798. id: id
  4799. }, attr);
  4800. }
  4801. } else {
  4802. value = pendingOps[i][attr].applyTo(value);
  4803. }
  4804. }
  4805. }
  4806. return value;
  4807. }
  4808. function estimateAttributes(serverData
  4809. /*: AttributeMap*/
  4810. , pendingOps
  4811. /*: Array<OpsMap>*/
  4812. , className
  4813. /*: string*/
  4814. , id
  4815. /*: ?string*/
  4816. )
  4817. /*: AttributeMap*/
  4818. {
  4819. var data = {};
  4820. for (var attr in serverData) {
  4821. data[attr] = serverData[attr];
  4822. }
  4823. for (var i = 0; i < pendingOps.length; i++) {
  4824. for (attr in pendingOps[i]) {
  4825. if (pendingOps[i][attr] instanceof _ParseOp.RelationOp) {
  4826. if (id) {
  4827. data[attr] = pendingOps[i][attr].applyTo(data[attr], {
  4828. className: className,
  4829. id: id
  4830. }, attr);
  4831. }
  4832. } else {
  4833. if ((0, _includes.default)(attr).call(attr, '.')) {
  4834. // convert a.b.c into { a: { b: { c: value } } }
  4835. var fields = attr.split('.');
  4836. var first = fields[0];
  4837. var last = fields[fields.length - 1];
  4838. data[first] = _objectSpread({}, serverData[first]);
  4839. var object = _objectSpread({}, data);
  4840. for (var _i = 0; _i < fields.length - 1; _i++) {
  4841. var key = fields[_i];
  4842. if (!(key in object)) {
  4843. object[key] = {};
  4844. }
  4845. object = object[key];
  4846. }
  4847. object[last] = pendingOps[i][attr].applyTo(object[last]);
  4848. } else {
  4849. data[attr] = pendingOps[i][attr].applyTo(data[attr]);
  4850. }
  4851. }
  4852. }
  4853. }
  4854. return data;
  4855. }
  4856. function nestedSet(obj, key, value) {
  4857. var path = key.split('.');
  4858. for (var i = 0; i < path.length - 1; i++) {
  4859. if (!(path[i] in obj)) obj[path[i]] = {};
  4860. obj = obj[path[i]];
  4861. }
  4862. if (typeof value === 'undefined') {
  4863. delete obj[path[path.length - 1]];
  4864. } else {
  4865. obj[path[path.length - 1]] = value;
  4866. }
  4867. }
  4868. function commitServerChanges(serverData
  4869. /*: AttributeMap*/
  4870. , objectCache
  4871. /*: ObjectCache*/
  4872. , changes
  4873. /*: AttributeMap*/
  4874. ) {
  4875. for (var _attr3 in changes) {
  4876. var val = changes[_attr3];
  4877. nestedSet(serverData, _attr3, val);
  4878. if (val && (0, _typeof2.default)(val) === 'object' && !(val instanceof _ParseObject.default) && !(val instanceof _ParseFile.default) && !(val instanceof _ParseRelation.default)) {
  4879. var json = (0, _encode.default)(val, false, true);
  4880. objectCache[_attr3] = (0, _stringify.default)(json);
  4881. }
  4882. }
  4883. }
  4884. },{"./ParseFile":23,"./ParseObject":27,"./ParseOp":28,"./ParseRelation":31,"./TaskQueue":41,"./encode":46,"@babel/runtime-corejs3/core-js-stable/instance/filter":61,"@babel/runtime-corejs3/core-js-stable/instance/for-each":64,"@babel/runtime-corejs3/core-js-stable/instance/includes":65,"@babel/runtime-corejs3/core-js-stable/json/stringify":76,"@babel/runtime-corejs3/core-js-stable/object/define-properties":81,"@babel/runtime-corejs3/core-js-stable/object/define-property":82,"@babel/runtime-corejs3/core-js-stable/object/get-own-property-descriptor":85,"@babel/runtime-corejs3/core-js-stable/object/get-own-property-descriptors":86,"@babel/runtime-corejs3/core-js-stable/object/get-own-property-symbols":87,"@babel/runtime-corejs3/core-js-stable/object/keys":89,"@babel/runtime-corejs3/helpers/defineProperty":124,"@babel/runtime-corejs3/helpers/interopRequireDefault":128,"@babel/runtime-corejs3/helpers/typeof":140}],17:[function(_dereq_,module,exports){
  4885. "use strict";
  4886. var _interopRequireDefault = _dereq_("@babel/runtime-corejs3/helpers/interopRequireDefault");
  4887. var _Array$isArray2 = _dereq_("@babel/runtime-corejs3/core-js-stable/array/is-array");
  4888. var _getIteratorMethod = _dereq_("@babel/runtime-corejs3/core-js/get-iterator-method");
  4889. var _Symbol = _dereq_("@babel/runtime-corejs3/core-js-stable/symbol");
  4890. var _Array$from = _dereq_("@babel/runtime-corejs3/core-js-stable/array/from");
  4891. var _sliceInstanceProperty2 = _dereq_("@babel/runtime-corejs3/core-js-stable/instance/slice");
  4892. var _keys = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/object/keys"));
  4893. var _forEach = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/instance/for-each"));
  4894. var _map = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/instance/map"));
  4895. var _concat = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/instance/concat"));
  4896. var _typeof2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/helpers/typeof"));
  4897. var _isInteger = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/number/is-integer"));
  4898. var _slicedToArray2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/helpers/slicedToArray"));
  4899. var _slice = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/instance/slice"));
  4900. var _filter = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/instance/filter"));
  4901. var _isArray = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/array/is-array"));
  4902. var _indexOf = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/instance/index-of"));
  4903. function _createForOfIteratorHelper(o, allowArrayLike) {
  4904. var it = typeof _Symbol !== "undefined" && _getIteratorMethod(o) || o["@@iterator"];
  4905. if (!it) {
  4906. if (_Array$isArray2(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") {
  4907. if (it) o = it;
  4908. var i = 0;
  4909. var F = function () {};
  4910. return {
  4911. s: F,
  4912. n: function () {
  4913. if (i >= o.length) return {
  4914. done: true
  4915. };
  4916. return {
  4917. done: false,
  4918. value: o[i++]
  4919. };
  4920. },
  4921. e: function (_e) {
  4922. throw _e;
  4923. },
  4924. f: F
  4925. };
  4926. }
  4927. throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
  4928. }
  4929. var normalCompletion = true,
  4930. didErr = false,
  4931. err;
  4932. return {
  4933. s: function () {
  4934. it = it.call(o);
  4935. },
  4936. n: function () {
  4937. var step = it.next();
  4938. normalCompletion = step.done;
  4939. return step;
  4940. },
  4941. e: function (_e2) {
  4942. didErr = true;
  4943. err = _e2;
  4944. },
  4945. f: function () {
  4946. try {
  4947. if (!normalCompletion && it.return != null) it.return();
  4948. } finally {
  4949. if (didErr) throw err;
  4950. }
  4951. }
  4952. };
  4953. }
  4954. function _unsupportedIterableToArray(o, minLen) {
  4955. var _context6;
  4956. if (!o) return;
  4957. if (typeof o === "string") return _arrayLikeToArray(o, minLen);
  4958. var n = _sliceInstanceProperty2(_context6 = Object.prototype.toString.call(o)).call(_context6, 8, -1);
  4959. if (n === "Object" && o.constructor) n = o.constructor.name;
  4960. if (n === "Map" || n === "Set") return _Array$from(o);
  4961. if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen);
  4962. }
  4963. function _arrayLikeToArray(arr, len) {
  4964. if (len == null || len > arr.length) len = arr.length;
  4965. for (var i = 0, arr2 = new Array(len); i < len; i++) {
  4966. arr2[i] = arr[i];
  4967. }
  4968. return arr2;
  4969. }
  4970. var equalObjects = _dereq_('./equals').default;
  4971. var decode = _dereq_('./decode').default;
  4972. var ParseError = _dereq_('./ParseError').default;
  4973. var ParsePolygon = _dereq_('./ParsePolygon').default;
  4974. var ParseGeoPoint = _dereq_('./ParseGeoPoint').default;
  4975. /**
  4976. * contains -- Determines if an object is contained in a list with special handling for Parse pointers.
  4977. *
  4978. * @param haystack
  4979. * @param needle
  4980. * @private
  4981. * @returns {boolean}
  4982. */
  4983. function contains(haystack, needle) {
  4984. if (needle && needle.__type && (needle.__type === 'Pointer' || needle.__type === 'Object')) {
  4985. for (var i in haystack) {
  4986. var ptr = haystack[i];
  4987. if (typeof ptr === 'string' && ptr === needle.objectId) {
  4988. return true;
  4989. }
  4990. if (ptr.className === needle.className && ptr.objectId === needle.objectId) {
  4991. return true;
  4992. }
  4993. }
  4994. return false;
  4995. }
  4996. return (0, _indexOf.default)(haystack).call(haystack, needle) > -1;
  4997. }
  4998. function transformObject(object) {
  4999. if (object._toFullJSON) {
  5000. return object._toFullJSON();
  5001. }
  5002. return object;
  5003. }
  5004. /**
  5005. * matchesQuery -- Determines if an object would be returned by a Parse Query
  5006. * It's a lightweight, where-clause only implementation of a full query engine.
  5007. * Since we find queries that match objects, rather than objects that match
  5008. * queries, we can avoid building a full-blown query tool.
  5009. *
  5010. * @param className
  5011. * @param object
  5012. * @param objects
  5013. * @param query
  5014. * @private
  5015. * @returns {boolean}
  5016. */
  5017. function matchesQuery(className, object, objects, query) {
  5018. if (object.className !== className) {
  5019. return false;
  5020. }
  5021. var obj = object;
  5022. var q = query;
  5023. if (object.toJSON) {
  5024. obj = object.toJSON();
  5025. }
  5026. if (query.toJSON) {
  5027. q = query.toJSON().where;
  5028. }
  5029. obj.className = className;
  5030. for (var field in q) {
  5031. if (!matchesKeyConstraints(className, obj, objects, field, q[field])) {
  5032. return false;
  5033. }
  5034. }
  5035. return true;
  5036. }
  5037. function equalObjectsGeneric(obj, compareTo, eqlFn) {
  5038. if ((0, _isArray.default)(obj)) {
  5039. for (var i = 0; i < obj.length; i++) {
  5040. if (eqlFn(obj[i], compareTo)) {
  5041. return true;
  5042. }
  5043. }
  5044. return false;
  5045. }
  5046. return eqlFn(obj, compareTo);
  5047. }
  5048. /**
  5049. * @typedef RelativeTimeToDateResult
  5050. * @property {string} status The conversion status, `error` if conversion failed or
  5051. * `success` if conversion succeeded.
  5052. * @property {string} info The error message if conversion failed, or the relative
  5053. * time indication (`past`, `present`, `future`) if conversion succeeded.
  5054. * @property {Date|undefined} result The converted date, or `undefined` if conversion
  5055. * failed.
  5056. */
  5057. /**
  5058. * Converts human readable relative date string, for example, 'in 10 days' to a date
  5059. * relative to now.
  5060. *
  5061. * @param {string} text The text to convert.
  5062. * @param {Date} [now=new Date()] The date from which add or subtract. Default is now.
  5063. * @returns {RelativeTimeToDateResult}
  5064. */
  5065. function relativeTimeToDate(text) {
  5066. var now = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : new Date();
  5067. text = text.toLowerCase();
  5068. var parts = text.split(' '); // Filter out whitespace
  5069. parts = (0, _filter.default)(parts).call(parts, function (part) {
  5070. return part !== '';
  5071. });
  5072. var future = parts[0] === 'in';
  5073. var past = parts[parts.length - 1] === 'ago';
  5074. if (!future && !past && text !== 'now') {
  5075. return {
  5076. status: 'error',
  5077. info: "Time should either start with 'in' or end with 'ago'"
  5078. };
  5079. }
  5080. if (future && past) {
  5081. return {
  5082. status: 'error',
  5083. info: "Time cannot have both 'in' and 'ago'"
  5084. };
  5085. } // strip the 'ago' or 'in'
  5086. if (future) {
  5087. parts = (0, _slice.default)(parts).call(parts, 1);
  5088. } else {
  5089. // past
  5090. parts = (0, _slice.default)(parts).call(parts, 0, parts.length - 1);
  5091. }
  5092. if (parts.length % 2 !== 0 && text !== 'now') {
  5093. return {
  5094. status: 'error',
  5095. info: 'Invalid time string. Dangling unit or number.'
  5096. };
  5097. }
  5098. var pairs = [];
  5099. while (parts.length) {
  5100. pairs.push([parts.shift(), parts.shift()]);
  5101. }
  5102. var seconds = 0;
  5103. for (var _i = 0, _pairs = pairs; _i < _pairs.length; _i++) {
  5104. var _pairs$_i = (0, _slicedToArray2.default)(_pairs[_i], 2),
  5105. num = _pairs$_i[0],
  5106. interval = _pairs$_i[1];
  5107. var val = Number(num);
  5108. if (!(0, _isInteger.default)(val)) {
  5109. return {
  5110. status: 'error',
  5111. info: "'".concat(num, "' is not an integer.")
  5112. };
  5113. }
  5114. switch (interval) {
  5115. case 'yr':
  5116. case 'yrs':
  5117. case 'year':
  5118. case 'years':
  5119. seconds += val * 31536000; // 365 * 24 * 60 * 60
  5120. break;
  5121. case 'wk':
  5122. case 'wks':
  5123. case 'week':
  5124. case 'weeks':
  5125. seconds += val * 604800; // 7 * 24 * 60 * 60
  5126. break;
  5127. case 'd':
  5128. case 'day':
  5129. case 'days':
  5130. seconds += val * 86400; // 24 * 60 * 60
  5131. break;
  5132. case 'hr':
  5133. case 'hrs':
  5134. case 'hour':
  5135. case 'hours':
  5136. seconds += val * 3600; // 60 * 60
  5137. break;
  5138. case 'min':
  5139. case 'mins':
  5140. case 'minute':
  5141. case 'minutes':
  5142. seconds += val * 60;
  5143. break;
  5144. case 'sec':
  5145. case 'secs':
  5146. case 'second':
  5147. case 'seconds':
  5148. seconds += val;
  5149. break;
  5150. default:
  5151. return {
  5152. status: 'error',
  5153. info: "Invalid interval: '".concat(interval, "'")
  5154. };
  5155. }
  5156. }
  5157. var milliseconds = seconds * 1000;
  5158. if (future) {
  5159. return {
  5160. status: 'success',
  5161. info: 'future',
  5162. result: new Date(now.valueOf() + milliseconds)
  5163. };
  5164. } else if (past) {
  5165. return {
  5166. status: 'success',
  5167. info: 'past',
  5168. result: new Date(now.valueOf() - milliseconds)
  5169. };
  5170. } else {
  5171. return {
  5172. status: 'success',
  5173. info: 'present',
  5174. result: new Date(now.valueOf())
  5175. };
  5176. }
  5177. }
  5178. /**
  5179. * Determines whether an object matches a single key's constraints
  5180. *
  5181. * @param className
  5182. * @param object
  5183. * @param objects
  5184. * @param key
  5185. * @param constraints
  5186. * @private
  5187. * @returns {boolean}
  5188. */
  5189. function matchesKeyConstraints(className, object, objects, key, constraints) {
  5190. if (constraints === null) {
  5191. return false;
  5192. }
  5193. if ((0, _indexOf.default)(key).call(key, '.') >= 0) {
  5194. // Key references a subobject
  5195. var keyComponents = key.split('.');
  5196. var subObjectKey = keyComponents[0];
  5197. var keyRemainder = (0, _slice.default)(keyComponents).call(keyComponents, 1).join('.');
  5198. return matchesKeyConstraints(className, object[subObjectKey] || {}, objects, keyRemainder, constraints);
  5199. }
  5200. var i;
  5201. if (key === '$or') {
  5202. for (i = 0; i < constraints.length; i++) {
  5203. if (matchesQuery(className, object, objects, constraints[i])) {
  5204. return true;
  5205. }
  5206. }
  5207. return false;
  5208. }
  5209. if (key === '$and') {
  5210. for (i = 0; i < constraints.length; i++) {
  5211. if (!matchesQuery(className, object, objects, constraints[i])) {
  5212. return false;
  5213. }
  5214. }
  5215. return true;
  5216. }
  5217. if (key === '$nor') {
  5218. for (i = 0; i < constraints.length; i++) {
  5219. if (matchesQuery(className, object, objects, constraints[i])) {
  5220. return false;
  5221. }
  5222. }
  5223. return true;
  5224. }
  5225. if (key === '$relatedTo') {
  5226. // Bail! We can't handle relational queries locally
  5227. return false;
  5228. }
  5229. if (!/^[A-Za-z][0-9A-Za-z_]*$/.test(key)) {
  5230. throw new ParseError(ParseError.INVALID_KEY_NAME, "Invalid Key: ".concat(key));
  5231. } // Equality (or Array contains) cases
  5232. if ((0, _typeof2.default)(constraints) !== 'object') {
  5233. if ((0, _isArray.default)(object[key])) {
  5234. var _context;
  5235. return (0, _indexOf.default)(_context = object[key]).call(_context, constraints) > -1;
  5236. }
  5237. return object[key] === constraints;
  5238. }
  5239. var compareTo;
  5240. if (constraints.__type) {
  5241. if (constraints.__type === 'Pointer') {
  5242. return equalObjectsGeneric(object[key], constraints, function (obj, ptr) {
  5243. return typeof obj !== 'undefined' && ptr.className === obj.className && ptr.objectId === obj.objectId;
  5244. });
  5245. }
  5246. return equalObjectsGeneric(decode(object[key]), decode(constraints), equalObjects);
  5247. } // More complex cases
  5248. for (var condition in constraints) {
  5249. compareTo = constraints[condition];
  5250. if (compareTo.__type) {
  5251. compareTo = decode(compareTo);
  5252. } // is it a $relativeTime? convert to date
  5253. if (compareTo['$relativeTime']) {
  5254. var parserResult = relativeTimeToDate(compareTo['$relativeTime']);
  5255. if (parserResult.status !== 'success') {
  5256. var _context2;
  5257. throw new ParseError(ParseError.INVALID_JSON, (0, _concat.default)(_context2 = "bad $relativeTime (".concat(key, ") value. ")).call(_context2, parserResult.info));
  5258. }
  5259. compareTo = parserResult.result;
  5260. } // Compare Date Object or Date String
  5261. if (toString.call(compareTo) === '[object Date]' || typeof compareTo === 'string' && new Date(compareTo) !== 'Invalid Date' && !isNaN(new Date(compareTo))) {
  5262. object[key] = new Date(object[key].iso ? object[key].iso : object[key]);
  5263. }
  5264. switch (condition) {
  5265. case '$lt':
  5266. if (object[key] >= compareTo) {
  5267. return false;
  5268. }
  5269. break;
  5270. case '$lte':
  5271. if (object[key] > compareTo) {
  5272. return false;
  5273. }
  5274. break;
  5275. case '$gt':
  5276. if (object[key] <= compareTo) {
  5277. return false;
  5278. }
  5279. break;
  5280. case '$gte':
  5281. if (object[key] < compareTo) {
  5282. return false;
  5283. }
  5284. break;
  5285. case '$ne':
  5286. if (equalObjects(object[key], compareTo)) {
  5287. return false;
  5288. }
  5289. break;
  5290. case '$in':
  5291. if (!contains(compareTo, object[key])) {
  5292. return false;
  5293. }
  5294. break;
  5295. case '$nin':
  5296. if (contains(compareTo, object[key])) {
  5297. return false;
  5298. }
  5299. break;
  5300. case '$all':
  5301. for (i = 0; i < compareTo.length; i++) {
  5302. var _context3;
  5303. if ((0, _indexOf.default)(_context3 = object[key]).call(_context3, compareTo[i]) < 0) {
  5304. return false;
  5305. }
  5306. }
  5307. break;
  5308. case '$exists':
  5309. {
  5310. var propertyExists = typeof object[key] !== 'undefined';
  5311. var existenceIsRequired = constraints['$exists'];
  5312. if (typeof constraints['$exists'] !== 'boolean') {
  5313. // The SDK will never submit a non-boolean for $exists, but if someone
  5314. // tries to submit a non-boolean for $exits outside the SDKs, just ignore it.
  5315. break;
  5316. }
  5317. if (!propertyExists && existenceIsRequired || propertyExists && !existenceIsRequired) {
  5318. return false;
  5319. }
  5320. break;
  5321. }
  5322. case '$regex':
  5323. {
  5324. if ((0, _typeof2.default)(compareTo) === 'object') {
  5325. return compareTo.test(object[key]);
  5326. } // JS doesn't support perl-style escaping
  5327. var expString = '';
  5328. var escapeEnd = -2;
  5329. var escapeStart = (0, _indexOf.default)(compareTo).call(compareTo, '\\Q');
  5330. while (escapeStart > -1) {
  5331. // Add the unescaped portion
  5332. expString += compareTo.substring(escapeEnd + 2, escapeStart);
  5333. escapeEnd = (0, _indexOf.default)(compareTo).call(compareTo, '\\E', escapeStart);
  5334. if (escapeEnd > -1) {
  5335. expString += compareTo.substring(escapeStart + 2, escapeEnd).replace(/\\\\\\\\E/g, '\\E').replace(/\W/g, '\\$&');
  5336. }
  5337. escapeStart = (0, _indexOf.default)(compareTo).call(compareTo, '\\Q', escapeEnd);
  5338. }
  5339. expString += compareTo.substring(Math.max(escapeStart, escapeEnd + 2));
  5340. var modifiers = constraints.$options || '';
  5341. modifiers = modifiers.replace('x', '').replace('s', ''); // Parse Server / Mongo support x and s modifiers but JS RegExp doesn't
  5342. var exp = new RegExp(expString, modifiers);
  5343. if (!exp.test(object[key])) {
  5344. return false;
  5345. }
  5346. break;
  5347. }
  5348. case '$nearSphere':
  5349. {
  5350. if (!compareTo || !object[key]) {
  5351. return false;
  5352. }
  5353. var distance = compareTo.radiansTo(object[key]);
  5354. var max = constraints.$maxDistance || Infinity;
  5355. return distance <= max;
  5356. }
  5357. case '$within':
  5358. {
  5359. if (!compareTo || !object[key]) {
  5360. return false;
  5361. }
  5362. var southWest = compareTo.$box[0];
  5363. var northEast = compareTo.$box[1];
  5364. if (southWest.latitude > northEast.latitude || southWest.longitude > northEast.longitude) {
  5365. // Invalid box, crosses the date line
  5366. return false;
  5367. }
  5368. return object[key].latitude > southWest.latitude && object[key].latitude < northEast.latitude && object[key].longitude > southWest.longitude && object[key].longitude < northEast.longitude;
  5369. }
  5370. case '$options':
  5371. // Not a query type, but a way to add options to $regex. Ignore and
  5372. // avoid the default
  5373. break;
  5374. case '$maxDistance':
  5375. // Not a query type, but a way to add a cap to $nearSphere. Ignore and
  5376. // avoid the default
  5377. break;
  5378. case '$select':
  5379. {
  5380. var subQueryObjects = (0, _filter.default)(objects).call(objects, function (obj, index, arr) {
  5381. return matchesQuery(compareTo.query.className, obj, arr, compareTo.query.where);
  5382. });
  5383. for (var _i2 = 0; _i2 < subQueryObjects.length; _i2 += 1) {
  5384. var subObject = transformObject(subQueryObjects[_i2]);
  5385. return equalObjects(object[key], subObject[compareTo.key]);
  5386. }
  5387. return false;
  5388. }
  5389. case '$dontSelect':
  5390. {
  5391. var _subQueryObjects = (0, _filter.default)(objects).call(objects, function (obj, index, arr) {
  5392. return matchesQuery(compareTo.query.className, obj, arr, compareTo.query.where);
  5393. });
  5394. for (var _i3 = 0; _i3 < _subQueryObjects.length; _i3 += 1) {
  5395. var _subObject = transformObject(_subQueryObjects[_i3]);
  5396. return !equalObjects(object[key], _subObject[compareTo.key]);
  5397. }
  5398. return false;
  5399. }
  5400. case '$inQuery':
  5401. {
  5402. var _subQueryObjects2 = (0, _filter.default)(objects).call(objects, function (obj, index, arr) {
  5403. return matchesQuery(compareTo.className, obj, arr, compareTo.where);
  5404. });
  5405. for (var _i4 = 0; _i4 < _subQueryObjects2.length; _i4 += 1) {
  5406. var _subObject2 = transformObject(_subQueryObjects2[_i4]);
  5407. if (object[key].className === _subObject2.className && object[key].objectId === _subObject2.objectId) {
  5408. return true;
  5409. }
  5410. }
  5411. return false;
  5412. }
  5413. case '$notInQuery':
  5414. {
  5415. var _subQueryObjects3 = (0, _filter.default)(objects).call(objects, function (obj, index, arr) {
  5416. return matchesQuery(compareTo.className, obj, arr, compareTo.where);
  5417. });
  5418. for (var _i5 = 0; _i5 < _subQueryObjects3.length; _i5 += 1) {
  5419. var _subObject3 = transformObject(_subQueryObjects3[_i5]);
  5420. if (object[key].className === _subObject3.className && object[key].objectId === _subObject3.objectId) {
  5421. return false;
  5422. }
  5423. }
  5424. return true;
  5425. }
  5426. case '$containedBy':
  5427. {
  5428. var _iterator = _createForOfIteratorHelper(object[key]),
  5429. _step;
  5430. try {
  5431. for (_iterator.s(); !(_step = _iterator.n()).done;) {
  5432. var value = _step.value;
  5433. if (!contains(compareTo, value)) {
  5434. return false;
  5435. }
  5436. }
  5437. } catch (err) {
  5438. _iterator.e(err);
  5439. } finally {
  5440. _iterator.f();
  5441. }
  5442. return true;
  5443. }
  5444. case '$geoWithin':
  5445. {
  5446. if (compareTo.$polygon) {
  5447. var _context4;
  5448. var points = (0, _map.default)(_context4 = compareTo.$polygon).call(_context4, function (geoPoint) {
  5449. return [geoPoint.latitude, geoPoint.longitude];
  5450. });
  5451. var polygon = new ParsePolygon(points);
  5452. return polygon.containsPoint(object[key]);
  5453. }
  5454. if (compareTo.$centerSphere) {
  5455. var _compareTo$$centerSph = (0, _slicedToArray2.default)(compareTo.$centerSphere, 2),
  5456. WGS84Point = _compareTo$$centerSph[0],
  5457. maxDistance = _compareTo$$centerSph[1];
  5458. var centerPoint = new ParseGeoPoint({
  5459. latitude: WGS84Point[1],
  5460. longitude: WGS84Point[0]
  5461. });
  5462. var point = new ParseGeoPoint(object[key]);
  5463. var _distance = point.radiansTo(centerPoint);
  5464. return _distance <= maxDistance;
  5465. }
  5466. break;
  5467. }
  5468. case '$geoIntersects':
  5469. {
  5470. var _polygon = new ParsePolygon(object[key].coordinates);
  5471. var _point = new ParseGeoPoint(compareTo.$point);
  5472. return _polygon.containsPoint(_point);
  5473. }
  5474. default:
  5475. return false;
  5476. }
  5477. }
  5478. return true;
  5479. }
  5480. function validateQuery(query
  5481. /*: any*/
  5482. ) {
  5483. var _context5;
  5484. var q = query;
  5485. if (query.toJSON) {
  5486. q = query.toJSON().where;
  5487. }
  5488. var specialQuerykeys = ['$and', '$or', '$nor', '_rperm', '_wperm', '_perishable_token', '_email_verify_token', '_email_verify_token_expires_at', '_account_lockout_expires_at', '_failed_login_count'];
  5489. (0, _forEach.default)(_context5 = (0, _keys.default)(q)).call(_context5, function (key) {
  5490. if (q && q[key] && q[key].$regex) {
  5491. if (typeof q[key].$options === 'string') {
  5492. if (!q[key].$options.match(/^[imxs]+$/)) {
  5493. throw new ParseError(ParseError.INVALID_QUERY, "Bad $options value for query: ".concat(q[key].$options));
  5494. }
  5495. }
  5496. }
  5497. if ((0, _indexOf.default)(specialQuerykeys).call(specialQuerykeys, key) < 0 && !key.match(/^[a-zA-Z][a-zA-Z0-9_\.]*$/)) {
  5498. throw new ParseError(ParseError.INVALID_KEY_NAME, "Invalid key name: ".concat(key));
  5499. }
  5500. });
  5501. }
  5502. var OfflineQuery = {
  5503. matchesQuery: matchesQuery,
  5504. validateQuery: validateQuery
  5505. };
  5506. module.exports = OfflineQuery;
  5507. },{"./ParseError":22,"./ParseGeoPoint":24,"./ParsePolygon":29,"./decode":45,"./equals":47,"@babel/runtime-corejs3/core-js-stable/array/from":55,"@babel/runtime-corejs3/core-js-stable/array/is-array":56,"@babel/runtime-corejs3/core-js-stable/instance/concat":58,"@babel/runtime-corejs3/core-js-stable/instance/filter":61,"@babel/runtime-corejs3/core-js-stable/instance/for-each":64,"@babel/runtime-corejs3/core-js-stable/instance/index-of":66,"@babel/runtime-corejs3/core-js-stable/instance/map":68,"@babel/runtime-corejs3/core-js-stable/instance/slice":71,"@babel/runtime-corejs3/core-js-stable/number/is-integer":78,"@babel/runtime-corejs3/core-js-stable/object/keys":89,"@babel/runtime-corejs3/core-js-stable/symbol":97,"@babel/runtime-corejs3/core-js/get-iterator-method":101,"@babel/runtime-corejs3/helpers/interopRequireDefault":128,"@babel/runtime-corejs3/helpers/slicedToArray":137,"@babel/runtime-corejs3/helpers/typeof":140}],18:[function(_dereq_,module,exports){
  5508. (function (process){(function (){
  5509. "use strict";
  5510. var _interopRequireDefault = _dereq_("@babel/runtime-corejs3/helpers/interopRequireDefault");
  5511. var _Object$getOwnPropertyDescriptor = _dereq_("@babel/runtime-corejs3/core-js-stable/object/get-own-property-descriptor");
  5512. var _Object$defineProperty = _dereq_("@babel/runtime-corejs3/core-js-stable/object/define-property");
  5513. var _typeof = _dereq_("@babel/runtime-corejs3/helpers/typeof");
  5514. var _WeakMap = _dereq_("@babel/runtime-corejs3/core-js-stable/weak-map");
  5515. var _promise = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/promise"));
  5516. var _decode = _interopRequireDefault(_dereq_("./decode"));
  5517. var _encode = _interopRequireDefault(_dereq_("./encode"));
  5518. var _CoreManager = _interopRequireDefault(_dereq_("./CoreManager"));
  5519. var _CryptoController = _interopRequireDefault(_dereq_("./CryptoController"));
  5520. var _EventuallyQueue = _interopRequireDefault(_dereq_("./EventuallyQueue"));
  5521. var _InstallationController = _interopRequireDefault(_dereq_("./InstallationController"));
  5522. var ParseOp = _interopRequireWildcard(_dereq_("./ParseOp"));
  5523. var _RESTController = _interopRequireDefault(_dereq_("./RESTController"));
  5524. function _getRequireWildcardCache(nodeInterop) {
  5525. if (typeof _WeakMap !== "function") return null;
  5526. var cacheBabelInterop = new _WeakMap();
  5527. var cacheNodeInterop = new _WeakMap();
  5528. return (_getRequireWildcardCache = function (nodeInterop) {
  5529. return nodeInterop ? cacheNodeInterop : cacheBabelInterop;
  5530. })(nodeInterop);
  5531. }
  5532. function _interopRequireWildcard(obj, nodeInterop) {
  5533. if (!nodeInterop && obj && obj.__esModule) {
  5534. return obj;
  5535. }
  5536. if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") {
  5537. return {
  5538. default: obj
  5539. };
  5540. }
  5541. var cache = _getRequireWildcardCache(nodeInterop);
  5542. if (cache && cache.has(obj)) {
  5543. return cache.get(obj);
  5544. }
  5545. var newObj = {};
  5546. for (var key in obj) {
  5547. if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) {
  5548. var desc = _Object$defineProperty && _Object$getOwnPropertyDescriptor ? _Object$getOwnPropertyDescriptor(obj, key) : null;
  5549. if (desc && (desc.get || desc.set)) {
  5550. _Object$defineProperty(newObj, key, desc);
  5551. } else {
  5552. newObj[key] = obj[key];
  5553. }
  5554. }
  5555. }
  5556. newObj.default = obj;
  5557. if (cache) {
  5558. cache.set(obj, newObj);
  5559. }
  5560. return newObj;
  5561. }
  5562. /**
  5563. * Copyright (c) 2015-present, Parse, LLC.
  5564. * All rights reserved.
  5565. *
  5566. * This source code is licensed under the BSD-style license found in the
  5567. * LICENSE file in the root directory of this source tree. An additional grant
  5568. * of patent rights can be found in the PATENTS file in the same directory.
  5569. */
  5570. /**
  5571. * Contains all Parse API classes and functions.
  5572. *
  5573. * @static
  5574. * @global
  5575. * @class
  5576. * @hideconstructor
  5577. */
  5578. var Parse = {
  5579. /**
  5580. * Call this method first to set up your authentication tokens for Parse.
  5581. *
  5582. * @param {string} applicationId Your Parse Application ID.
  5583. * @param {string} [javaScriptKey] Your Parse JavaScript Key (Not needed for parse-server)
  5584. * @param {string} [masterKey] Your Parse Master Key. (Node.js only!)
  5585. * @static
  5586. */
  5587. initialize: function (applicationId
  5588. /*: string*/
  5589. , javaScriptKey
  5590. /*: string*/
  5591. ) {
  5592. if ("browser" === 'browser' && _CoreManager.default.get('IS_NODE') && !process.env.SERVER_RENDERING) {
  5593. /* eslint-disable no-console */
  5594. 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.");
  5595. /* eslint-enable no-console */
  5596. }
  5597. Parse._initialize(applicationId, javaScriptKey);
  5598. },
  5599. _initialize: function (applicationId
  5600. /*: string*/
  5601. , javaScriptKey
  5602. /*: string*/
  5603. , masterKey
  5604. /*: string*/
  5605. ) {
  5606. _CoreManager.default.set('APPLICATION_ID', applicationId);
  5607. _CoreManager.default.set('JAVASCRIPT_KEY', javaScriptKey);
  5608. _CoreManager.default.set('MASTER_KEY', masterKey);
  5609. _CoreManager.default.set('USE_MASTER_KEY', false);
  5610. },
  5611. /**
  5612. * Call this method to set your AsyncStorage engine
  5613. * Starting Parse@1.11, the ParseSDK do not provide a React AsyncStorage as the ReactNative module
  5614. * is not provided at a stable path and changes over versions.
  5615. *
  5616. * @param {AsyncStorage} storage a react native async storage.
  5617. * @static
  5618. */
  5619. setAsyncStorage: function (storage
  5620. /*: any*/
  5621. ) {
  5622. _CoreManager.default.setAsyncStorage(storage);
  5623. },
  5624. /**
  5625. * Call this method to set your LocalDatastoreStorage engine
  5626. * If using React-Native use {@link Parse.setAsyncStorage Parse.setAsyncStorage()}
  5627. *
  5628. * @param {LocalDatastoreController} controller a data storage.
  5629. * @static
  5630. */
  5631. setLocalDatastoreController: function (controller
  5632. /*: any*/
  5633. ) {
  5634. _CoreManager.default.setLocalDatastoreController(controller);
  5635. },
  5636. /**
  5637. * Returns information regarding the current server's health
  5638. *
  5639. * @returns {Promise}
  5640. * @static
  5641. */
  5642. getServerHealth: function () {
  5643. return _CoreManager.default.getRESTController().request('GET', 'health');
  5644. },
  5645. /**
  5646. * @member {string} Parse.applicationId
  5647. * @static
  5648. */
  5649. set applicationId(value) {
  5650. _CoreManager.default.set('APPLICATION_ID', value);
  5651. },
  5652. get applicationId() {
  5653. return _CoreManager.default.get('APPLICATION_ID');
  5654. },
  5655. /**
  5656. * @member {string} Parse.javaScriptKey
  5657. * @static
  5658. */
  5659. set javaScriptKey(value) {
  5660. _CoreManager.default.set('JAVASCRIPT_KEY', value);
  5661. },
  5662. get javaScriptKey() {
  5663. return _CoreManager.default.get('JAVASCRIPT_KEY');
  5664. },
  5665. /**
  5666. * @member {string} Parse.masterKey
  5667. * @static
  5668. */
  5669. set masterKey(value) {
  5670. _CoreManager.default.set('MASTER_KEY', value);
  5671. },
  5672. get masterKey() {
  5673. return _CoreManager.default.get('MASTER_KEY');
  5674. },
  5675. /**
  5676. * @member {string} Parse.serverURL
  5677. * @static
  5678. */
  5679. set serverURL(value) {
  5680. _CoreManager.default.set('SERVER_URL', value);
  5681. },
  5682. get serverURL() {
  5683. return _CoreManager.default.get('SERVER_URL');
  5684. },
  5685. /**
  5686. * @member {string} Parse.serverAuthToken
  5687. * @static
  5688. */
  5689. set serverAuthToken(value) {
  5690. _CoreManager.default.set('SERVER_AUTH_TOKEN', value);
  5691. },
  5692. get serverAuthToken() {
  5693. return _CoreManager.default.get('SERVER_AUTH_TOKEN');
  5694. },
  5695. /**
  5696. * @member {string} Parse.serverAuthType
  5697. * @static
  5698. */
  5699. set serverAuthType(value) {
  5700. _CoreManager.default.set('SERVER_AUTH_TYPE', value);
  5701. },
  5702. get serverAuthType() {
  5703. return _CoreManager.default.get('SERVER_AUTH_TYPE');
  5704. },
  5705. /**
  5706. * @member {string} Parse.liveQueryServerURL
  5707. * @static
  5708. */
  5709. set liveQueryServerURL(value) {
  5710. _CoreManager.default.set('LIVEQUERY_SERVER_URL', value);
  5711. },
  5712. get liveQueryServerURL() {
  5713. return _CoreManager.default.get('LIVEQUERY_SERVER_URL');
  5714. },
  5715. /**
  5716. * @member {string} Parse.encryptedUser
  5717. * @static
  5718. */
  5719. set encryptedUser(value) {
  5720. _CoreManager.default.set('ENCRYPTED_USER', value);
  5721. },
  5722. get encryptedUser() {
  5723. return _CoreManager.default.get('ENCRYPTED_USER');
  5724. },
  5725. /**
  5726. * @member {string} Parse.secret
  5727. * @static
  5728. */
  5729. set secret(value) {
  5730. _CoreManager.default.set('ENCRYPTED_KEY', value);
  5731. },
  5732. get secret() {
  5733. return _CoreManager.default.get('ENCRYPTED_KEY');
  5734. },
  5735. /**
  5736. * @member {boolean} Parse.idempotency
  5737. * @static
  5738. */
  5739. set idempotency(value) {
  5740. _CoreManager.default.set('IDEMPOTENCY', value);
  5741. },
  5742. get idempotency() {
  5743. return _CoreManager.default.get('IDEMPOTENCY');
  5744. },
  5745. /**
  5746. * @member {boolean} Parse.allowCustomObjectId
  5747. * @static
  5748. */
  5749. set allowCustomObjectId(value) {
  5750. _CoreManager.default.set('ALLOW_CUSTOM_OBJECT_ID', value);
  5751. },
  5752. get allowCustomObjectId() {
  5753. return _CoreManager.default.get('ALLOW_CUSTOM_OBJECT_ID');
  5754. }
  5755. };
  5756. Parse.ACL = _dereq_('./ParseACL').default;
  5757. Parse.Analytics = _dereq_('./Analytics');
  5758. Parse.AnonymousUtils = _dereq_('./AnonymousUtils').default;
  5759. Parse.Cloud = _dereq_('./Cloud');
  5760. Parse.CLP = _dereq_('./ParseCLP').default;
  5761. Parse.CoreManager = _dereq_('./CoreManager');
  5762. Parse.Config = _dereq_('./ParseConfig').default;
  5763. Parse.Error = _dereq_('./ParseError').default;
  5764. Parse.EventuallyQueue = _EventuallyQueue.default;
  5765. Parse.FacebookUtils = _dereq_('./FacebookUtils').default;
  5766. Parse.File = _dereq_('./ParseFile').default;
  5767. Parse.GeoPoint = _dereq_('./ParseGeoPoint').default;
  5768. Parse.Polygon = _dereq_('./ParsePolygon').default;
  5769. Parse.Installation = _dereq_('./ParseInstallation').default;
  5770. Parse.LocalDatastore = _dereq_('./LocalDatastore');
  5771. Parse.Object = _dereq_('./ParseObject').default;
  5772. Parse.Op = {
  5773. Set: ParseOp.SetOp,
  5774. Unset: ParseOp.UnsetOp,
  5775. Increment: ParseOp.IncrementOp,
  5776. Add: ParseOp.AddOp,
  5777. Remove: ParseOp.RemoveOp,
  5778. AddUnique: ParseOp.AddUniqueOp,
  5779. Relation: ParseOp.RelationOp
  5780. };
  5781. Parse.Push = _dereq_('./Push');
  5782. Parse.Query = _dereq_('./ParseQuery').default;
  5783. Parse.Relation = _dereq_('./ParseRelation').default;
  5784. Parse.Role = _dereq_('./ParseRole').default;
  5785. Parse.Schema = _dereq_('./ParseSchema').default;
  5786. Parse.Session = _dereq_('./ParseSession').default;
  5787. Parse.Storage = _dereq_('./Storage');
  5788. Parse.User = _dereq_('./ParseUser').default;
  5789. Parse.LiveQuery = _dereq_('./ParseLiveQuery').default;
  5790. Parse.LiveQueryClient = _dereq_('./LiveQueryClient').default;
  5791. Parse.IndexedDB = _dereq_('./IndexedDBStorageController');
  5792. Parse._request = function () {
  5793. for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
  5794. args[_key] = arguments[_key];
  5795. }
  5796. return _CoreManager.default.getRESTController().request.apply(null, args);
  5797. };
  5798. Parse._ajax = function () {
  5799. for (var _len2 = arguments.length, args = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
  5800. args[_key2] = arguments[_key2];
  5801. }
  5802. return _CoreManager.default.getRESTController().ajax.apply(null, args);
  5803. }; // We attempt to match the signatures of the legacy versions of these methods
  5804. Parse._decode = function (_, value) {
  5805. return (0, _decode.default)(value);
  5806. };
  5807. Parse._encode = function (value, _, disallowObjects) {
  5808. return (0, _encode.default)(value, disallowObjects);
  5809. };
  5810. Parse._getInstallationId = function () {
  5811. return _CoreManager.default.getInstallationController().currentInstallationId();
  5812. };
  5813. /**
  5814. * Enable pinning in your application.
  5815. * This must be called after `Parse.initialize` in your application.
  5816. *
  5817. * @param [polling] Allow pinging the server /health endpoint. Default true
  5818. * @param [ms] Milliseconds to ping the server. Default 2000ms
  5819. * @static
  5820. */
  5821. Parse.enableLocalDatastore = function () {
  5822. var polling = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : true;
  5823. var ms
  5824. /*: number*/
  5825. = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 2000;
  5826. if (!Parse.applicationId) {
  5827. console.log("'enableLocalDataStore' must be called after 'initialize'");
  5828. return;
  5829. }
  5830. if (!Parse.LocalDatastore.isEnabled) {
  5831. Parse.LocalDatastore.isEnabled = true;
  5832. if (polling) {
  5833. _EventuallyQueue.default.poll(ms);
  5834. }
  5835. }
  5836. };
  5837. /**
  5838. * Flag that indicates whether Local Datastore is enabled.
  5839. *
  5840. * @static
  5841. * @returns {boolean}
  5842. */
  5843. Parse.isLocalDatastoreEnabled = function () {
  5844. return Parse.LocalDatastore.isEnabled;
  5845. };
  5846. /**
  5847. * Gets all contents from Local Datastore
  5848. *
  5849. * <pre>
  5850. * await Parse.dumpLocalDatastore();
  5851. * </pre>
  5852. *
  5853. * @static
  5854. * @returns {object}
  5855. */
  5856. Parse.dumpLocalDatastore = function () {
  5857. if (!Parse.LocalDatastore.isEnabled) {
  5858. console.log('Parse.enableLocalDatastore() must be called first'); // eslint-disable-line no-console
  5859. return _promise.default.resolve({});
  5860. } else {
  5861. return Parse.LocalDatastore._getAllContents();
  5862. }
  5863. };
  5864. /**
  5865. * Enable the current user encryption.
  5866. * This must be called before login any user.
  5867. *
  5868. * @static
  5869. */
  5870. Parse.enableEncryptedUser = function () {
  5871. Parse.encryptedUser = true;
  5872. };
  5873. /**
  5874. * Flag that indicates whether Encrypted User is enabled.
  5875. *
  5876. * @static
  5877. * @returns {boolean}
  5878. */
  5879. Parse.isEncryptedUserEnabled = function () {
  5880. return Parse.encryptedUser;
  5881. };
  5882. _CoreManager.default.setCryptoController(_CryptoController.default);
  5883. _CoreManager.default.setInstallationController(_InstallationController.default);
  5884. _CoreManager.default.setRESTController(_RESTController.default);
  5885. // For legacy requires, of the form `var Parse = require('parse').Parse`
  5886. Parse.Parse = Parse;
  5887. module.exports = Parse;
  5888. }).call(this)}).call(this,_dereq_('_process'))
  5889. },{"./Analytics":1,"./AnonymousUtils":2,"./Cloud":3,"./CoreManager":4,"./CryptoController":5,"./EventuallyQueue":7,"./FacebookUtils":8,"./IndexedDBStorageController":9,"./InstallationController":10,"./LiveQueryClient":11,"./LocalDatastore":13,"./ParseACL":19,"./ParseCLP":20,"./ParseConfig":21,"./ParseError":22,"./ParseFile":23,"./ParseGeoPoint":24,"./ParseInstallation":25,"./ParseLiveQuery":26,"./ParseObject":27,"./ParseOp":28,"./ParsePolygon":29,"./ParseQuery":30,"./ParseRelation":31,"./ParseRole":32,"./ParseSchema":33,"./ParseSession":34,"./ParseUser":35,"./Push":36,"./RESTController":37,"./Storage":39,"./decode":45,"./encode":46,"@babel/runtime-corejs3/core-js-stable/object/define-property":82,"@babel/runtime-corejs3/core-js-stable/object/get-own-property-descriptor":85,"@babel/runtime-corejs3/core-js-stable/promise":92,"@babel/runtime-corejs3/core-js-stable/weak-map":98,"@babel/runtime-corejs3/helpers/interopRequireDefault":128,"@babel/runtime-corejs3/helpers/typeof":140,"_process":145}],19:[function(_dereq_,module,exports){
  5890. "use strict";
  5891. var _interopRequireDefault = _dereq_("@babel/runtime-corejs3/helpers/interopRequireDefault");
  5892. var _Object$defineProperty = _dereq_("@babel/runtime-corejs3/core-js-stable/object/define-property");
  5893. _Object$defineProperty(exports, "__esModule", {
  5894. value: true
  5895. });
  5896. exports.default = void 0;
  5897. var _keys = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/object/keys"));
  5898. var _typeof2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/helpers/typeof"));
  5899. var _classCallCheck2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/helpers/classCallCheck"));
  5900. var _createClass2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/helpers/createClass"));
  5901. var _defineProperty2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/helpers/defineProperty"));
  5902. var _ParseRole = _interopRequireDefault(_dereq_("./ParseRole"));
  5903. var _ParseUser = _interopRequireDefault(_dereq_("./ParseUser"));
  5904. /**
  5905. * Copyright (c) 2015-present, Parse, LLC.
  5906. * All rights reserved.
  5907. *
  5908. * This source code is licensed under the BSD-style license found in the
  5909. * LICENSE file in the root directory of this source tree. An additional grant
  5910. * of patent rights can be found in the PATENTS file in the same directory.
  5911. *
  5912. * @flow
  5913. */
  5914. var PUBLIC_KEY = '*';
  5915. /**
  5916. * Creates a new ACL.
  5917. * If no argument is given, the ACL has no permissions for anyone.
  5918. * If the argument is a Parse.User, the ACL will have read and write
  5919. * permission for only that user.
  5920. * If the argument is any other JSON object, that object will be interpretted
  5921. * as a serialized ACL created with toJSON().
  5922. *
  5923. * <p>An ACL, or Access Control List can be added to any
  5924. * <code>Parse.Object</code> to restrict access to only a subset of users
  5925. * of your application.</p>
  5926. *
  5927. * @alias Parse.ACL
  5928. */
  5929. var ParseACL = /*#__PURE__*/function () {
  5930. /**
  5931. * @param {(Parse.User | object)} arg1 The user to initialize the ACL for
  5932. */
  5933. function ParseACL(arg1
  5934. /*: ParseUser | ByIdMap*/
  5935. ) {
  5936. (0, _classCallCheck2.default)(this, ParseACL);
  5937. (0, _defineProperty2.default)(this, "permissionsById", void 0);
  5938. this.permissionsById = {};
  5939. if (arg1 && (0, _typeof2.default)(arg1) === 'object') {
  5940. if (arg1 instanceof _ParseUser.default) {
  5941. this.setReadAccess(arg1, true);
  5942. this.setWriteAccess(arg1, true);
  5943. } else {
  5944. for (var _userId in arg1) {
  5945. var accessList = arg1[_userId];
  5946. this.permissionsById[_userId] = {};
  5947. for (var _permission in accessList) {
  5948. var allowed = accessList[_permission];
  5949. if (_permission !== 'read' && _permission !== 'write') {
  5950. throw new TypeError('Tried to create an ACL with an invalid permission type.');
  5951. }
  5952. if (typeof allowed !== 'boolean') {
  5953. throw new TypeError('Tried to create an ACL with an invalid permission value.');
  5954. }
  5955. this.permissionsById[_userId][_permission] = allowed;
  5956. }
  5957. }
  5958. }
  5959. } else if (typeof arg1 === 'function') {
  5960. throw new TypeError('ParseACL constructed with a function. Did you forget ()?');
  5961. }
  5962. }
  5963. /**
  5964. * Returns a JSON-encoded version of the ACL.
  5965. *
  5966. * @returns {object}
  5967. */
  5968. (0, _createClass2.default)(ParseACL, [{
  5969. key: "toJSON",
  5970. value: function ()
  5971. /*: ByIdMap*/
  5972. {
  5973. var permissions = {};
  5974. for (var p in this.permissionsById) {
  5975. permissions[p] = this.permissionsById[p];
  5976. }
  5977. return permissions;
  5978. }
  5979. /**
  5980. * Returns whether this ACL is equal to another object
  5981. *
  5982. * @param {ParseACL} other The other object's ACL to compare to
  5983. * @returns {boolean}
  5984. */
  5985. }, {
  5986. key: "equals",
  5987. value: function (other
  5988. /*: ParseACL*/
  5989. )
  5990. /*: boolean*/
  5991. {
  5992. if (!(other instanceof ParseACL)) {
  5993. return false;
  5994. }
  5995. var users = (0, _keys.default)(this.permissionsById);
  5996. var otherUsers = (0, _keys.default)(other.permissionsById);
  5997. if (users.length !== otherUsers.length) {
  5998. return false;
  5999. }
  6000. for (var u in this.permissionsById) {
  6001. if (!other.permissionsById[u]) {
  6002. return false;
  6003. }
  6004. if (this.permissionsById[u].read !== other.permissionsById[u].read) {
  6005. return false;
  6006. }
  6007. if (this.permissionsById[u].write !== other.permissionsById[u].write) {
  6008. return false;
  6009. }
  6010. }
  6011. return true;
  6012. }
  6013. }, {
  6014. key: "_setAccess",
  6015. value: function (accessType
  6016. /*: string*/
  6017. , userId
  6018. /*: ParseUser | ParseRole | string*/
  6019. , allowed
  6020. /*: boolean*/
  6021. ) {
  6022. if (userId instanceof _ParseUser.default) {
  6023. userId = userId.id;
  6024. } else if (userId instanceof _ParseRole.default) {
  6025. var name = userId.getName();
  6026. if (!name) {
  6027. throw new TypeError('Role must have a name');
  6028. }
  6029. userId = 'role:' + name;
  6030. }
  6031. if (typeof userId !== 'string') {
  6032. throw new TypeError('userId must be a string.');
  6033. }
  6034. if (typeof allowed !== 'boolean') {
  6035. throw new TypeError('allowed must be either true or false.');
  6036. }
  6037. var permissions = this.permissionsById[userId];
  6038. if (!permissions) {
  6039. if (!allowed) {
  6040. // The user already doesn't have this permission, so no action is needed
  6041. return;
  6042. } else {
  6043. permissions = {};
  6044. this.permissionsById[userId] = permissions;
  6045. }
  6046. }
  6047. if (allowed) {
  6048. this.permissionsById[userId][accessType] = true;
  6049. } else {
  6050. delete permissions[accessType];
  6051. if ((0, _keys.default)(permissions).length === 0) {
  6052. delete this.permissionsById[userId];
  6053. }
  6054. }
  6055. }
  6056. }, {
  6057. key: "_getAccess",
  6058. value: function (accessType
  6059. /*: string*/
  6060. , userId
  6061. /*: ParseUser | ParseRole | string*/
  6062. )
  6063. /*: boolean*/
  6064. {
  6065. if (userId instanceof _ParseUser.default) {
  6066. userId = userId.id;
  6067. if (!userId) {
  6068. throw new Error('Cannot get access for a ParseUser without an ID');
  6069. }
  6070. } else if (userId instanceof _ParseRole.default) {
  6071. var name = userId.getName();
  6072. if (!name) {
  6073. throw new TypeError('Role must have a name');
  6074. }
  6075. userId = 'role:' + name;
  6076. }
  6077. var permissions = this.permissionsById[userId];
  6078. if (!permissions) {
  6079. return false;
  6080. }
  6081. return !!permissions[accessType];
  6082. }
  6083. /**
  6084. * Sets whether the given user is allowed to read this object.
  6085. *
  6086. * @param userId An instance of Parse.User or its objectId.
  6087. * @param {boolean} allowed Whether that user should have read access.
  6088. */
  6089. }, {
  6090. key: "setReadAccess",
  6091. value: function (userId
  6092. /*: ParseUser | ParseRole | string*/
  6093. , allowed
  6094. /*: boolean*/
  6095. ) {
  6096. this._setAccess('read', userId, allowed);
  6097. }
  6098. /**
  6099. * Get whether the given user id is *explicitly* allowed to read this object.
  6100. * Even if this returns false, the user may still be able to access it if
  6101. * getPublicReadAccess returns true or a role that the user belongs to has
  6102. * write access.
  6103. *
  6104. * @param userId An instance of Parse.User or its objectId, or a Parse.Role.
  6105. * @returns {boolean}
  6106. */
  6107. }, {
  6108. key: "getReadAccess",
  6109. value: function (userId
  6110. /*: ParseUser | ParseRole | string*/
  6111. )
  6112. /*: boolean*/
  6113. {
  6114. return this._getAccess('read', userId);
  6115. }
  6116. /**
  6117. * Sets whether the given user id is allowed to write this object.
  6118. *
  6119. * @param userId An instance of Parse.User or its objectId, or a Parse.Role..
  6120. * @param {boolean} allowed Whether that user should have write access.
  6121. */
  6122. }, {
  6123. key: "setWriteAccess",
  6124. value: function (userId
  6125. /*: ParseUser | ParseRole | string*/
  6126. , allowed
  6127. /*: boolean*/
  6128. ) {
  6129. this._setAccess('write', userId, allowed);
  6130. }
  6131. /**
  6132. * Gets whether the given user id is *explicitly* allowed to write this object.
  6133. * Even if this returns false, the user may still be able to write it if
  6134. * getPublicWriteAccess returns true or a role that the user belongs to has
  6135. * write access.
  6136. *
  6137. * @param userId An instance of Parse.User or its objectId, or a Parse.Role.
  6138. * @returns {boolean}
  6139. */
  6140. }, {
  6141. key: "getWriteAccess",
  6142. value: function (userId
  6143. /*: ParseUser | ParseRole | string*/
  6144. )
  6145. /*: boolean*/
  6146. {
  6147. return this._getAccess('write', userId);
  6148. }
  6149. /**
  6150. * Sets whether the public is allowed to read this object.
  6151. *
  6152. * @param {boolean} allowed
  6153. */
  6154. }, {
  6155. key: "setPublicReadAccess",
  6156. value: function (allowed
  6157. /*: boolean*/
  6158. ) {
  6159. this.setReadAccess(PUBLIC_KEY, allowed);
  6160. }
  6161. /**
  6162. * Gets whether the public is allowed to read this object.
  6163. *
  6164. * @returns {boolean}
  6165. */
  6166. }, {
  6167. key: "getPublicReadAccess",
  6168. value: function ()
  6169. /*: boolean*/
  6170. {
  6171. return this.getReadAccess(PUBLIC_KEY);
  6172. }
  6173. /**
  6174. * Sets whether the public is allowed to write this object.
  6175. *
  6176. * @param {boolean} allowed
  6177. */
  6178. }, {
  6179. key: "setPublicWriteAccess",
  6180. value: function (allowed
  6181. /*: boolean*/
  6182. ) {
  6183. this.setWriteAccess(PUBLIC_KEY, allowed);
  6184. }
  6185. /**
  6186. * Gets whether the public is allowed to write this object.
  6187. *
  6188. * @returns {boolean}
  6189. */
  6190. }, {
  6191. key: "getPublicWriteAccess",
  6192. value: function ()
  6193. /*: boolean*/
  6194. {
  6195. return this.getWriteAccess(PUBLIC_KEY);
  6196. }
  6197. /**
  6198. * Gets whether users belonging to the given role are allowed
  6199. * to read this object. Even if this returns false, the role may
  6200. * still be able to write it if a parent role has read access.
  6201. *
  6202. * @param role The name of the role, or a Parse.Role object.
  6203. * @returns {boolean} true if the role has read access. false otherwise.
  6204. * @throws {TypeError} If role is neither a Parse.Role nor a String.
  6205. */
  6206. }, {
  6207. key: "getRoleReadAccess",
  6208. value: function (role
  6209. /*: ParseRole | string*/
  6210. )
  6211. /*: boolean*/
  6212. {
  6213. if (role instanceof _ParseRole.default) {
  6214. // Normalize to the String name
  6215. role = role.getName();
  6216. }
  6217. if (typeof role !== 'string') {
  6218. throw new TypeError('role must be a ParseRole or a String');
  6219. }
  6220. return this.getReadAccess('role:' + role);
  6221. }
  6222. /**
  6223. * Gets whether users belonging to the given role are allowed
  6224. * to write this object. Even if this returns false, the role may
  6225. * still be able to write it if a parent role has write access.
  6226. *
  6227. * @param role The name of the role, or a Parse.Role object.
  6228. * @returns {boolean} true if the role has write access. false otherwise.
  6229. * @throws {TypeError} If role is neither a Parse.Role nor a String.
  6230. */
  6231. }, {
  6232. key: "getRoleWriteAccess",
  6233. value: function (role
  6234. /*: ParseRole | string*/
  6235. )
  6236. /*: boolean*/
  6237. {
  6238. if (role instanceof _ParseRole.default) {
  6239. // Normalize to the String name
  6240. role = role.getName();
  6241. }
  6242. if (typeof role !== 'string') {
  6243. throw new TypeError('role must be a ParseRole or a String');
  6244. }
  6245. return this.getWriteAccess('role:' + role);
  6246. }
  6247. /**
  6248. * Sets whether users belonging to the given role are allowed
  6249. * to read this object.
  6250. *
  6251. * @param role The name of the role, or a Parse.Role object.
  6252. * @param {boolean} allowed Whether the given role can read this object.
  6253. * @throws {TypeError} If role is neither a Parse.Role nor a String.
  6254. */
  6255. }, {
  6256. key: "setRoleReadAccess",
  6257. value: function (role
  6258. /*: ParseRole | string*/
  6259. , allowed
  6260. /*: boolean*/
  6261. ) {
  6262. if (role instanceof _ParseRole.default) {
  6263. // Normalize to the String name
  6264. role = role.getName();
  6265. }
  6266. if (typeof role !== 'string') {
  6267. throw new TypeError('role must be a ParseRole or a String');
  6268. }
  6269. this.setReadAccess('role:' + role, allowed);
  6270. }
  6271. /**
  6272. * Sets whether users belonging to the given role are allowed
  6273. * to write this object.
  6274. *
  6275. * @param role The name of the role, or a Parse.Role object.
  6276. * @param {boolean} allowed Whether the given role can write this object.
  6277. * @throws {TypeError} If role is neither a Parse.Role nor a String.
  6278. */
  6279. }, {
  6280. key: "setRoleWriteAccess",
  6281. value: function (role
  6282. /*: ParseRole | string*/
  6283. , allowed
  6284. /*: boolean*/
  6285. ) {
  6286. if (role instanceof _ParseRole.default) {
  6287. // Normalize to the String name
  6288. role = role.getName();
  6289. }
  6290. if (typeof role !== 'string') {
  6291. throw new TypeError('role must be a ParseRole or a String');
  6292. }
  6293. this.setWriteAccess('role:' + role, allowed);
  6294. }
  6295. }]);
  6296. return ParseACL;
  6297. }();
  6298. var _default = ParseACL;
  6299. exports.default = _default;
  6300. },{"./ParseRole":32,"./ParseUser":35,"@babel/runtime-corejs3/core-js-stable/object/define-property":82,"@babel/runtime-corejs3/core-js-stable/object/keys":89,"@babel/runtime-corejs3/helpers/classCallCheck":121,"@babel/runtime-corejs3/helpers/createClass":123,"@babel/runtime-corejs3/helpers/defineProperty":124,"@babel/runtime-corejs3/helpers/interopRequireDefault":128,"@babel/runtime-corejs3/helpers/typeof":140}],20:[function(_dereq_,module,exports){
  6301. "use strict";
  6302. var _interopRequireDefault = _dereq_("@babel/runtime-corejs3/helpers/interopRequireDefault");
  6303. var _Object$defineProperty = _dereq_("@babel/runtime-corejs3/core-js-stable/object/define-property");
  6304. var _Object$defineProperties = _dereq_("@babel/runtime-corejs3/core-js-stable/object/define-properties");
  6305. var _Object$getOwnPropertyDescriptors = _dereq_("@babel/runtime-corejs3/core-js-stable/object/get-own-property-descriptors");
  6306. var _forEachInstanceProperty = _dereq_("@babel/runtime-corejs3/core-js-stable/instance/for-each");
  6307. var _Object$getOwnPropertyDescriptor = _dereq_("@babel/runtime-corejs3/core-js-stable/object/get-own-property-descriptor");
  6308. var _filterInstanceProperty = _dereq_("@babel/runtime-corejs3/core-js-stable/instance/filter");
  6309. var _Object$getOwnPropertySymbols = _dereq_("@babel/runtime-corejs3/core-js-stable/object/get-own-property-symbols");
  6310. var _Object$keys2 = _dereq_("@babel/runtime-corejs3/core-js-stable/object/keys");
  6311. var _Array$isArray2 = _dereq_("@babel/runtime-corejs3/core-js-stable/array/is-array");
  6312. var _getIteratorMethod = _dereq_("@babel/runtime-corejs3/core-js/get-iterator-method");
  6313. var _Symbol = _dereq_("@babel/runtime-corejs3/core-js-stable/symbol");
  6314. var _Array$from = _dereq_("@babel/runtime-corejs3/core-js-stable/array/from");
  6315. var _sliceInstanceProperty2 = _dereq_("@babel/runtime-corejs3/core-js-stable/instance/slice");
  6316. _Object$defineProperty(exports, "__esModule", {
  6317. value: true
  6318. });
  6319. exports.default = void 0;
  6320. var _isArray = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/array/is-array"));
  6321. var _keys = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/object/keys"));
  6322. var _slice = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/instance/slice"));
  6323. var _assign = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/object/assign"));
  6324. var _slicedToArray2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/helpers/slicedToArray"));
  6325. var _entries = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/instance/entries"));
  6326. var _every = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/instance/every"));
  6327. var _includes = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/instance/includes"));
  6328. var _typeof2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/helpers/typeof"));
  6329. var _classCallCheck2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/helpers/classCallCheck"));
  6330. var _createClass2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/helpers/createClass"));
  6331. var _defineProperty2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/helpers/defineProperty"));
  6332. var _map = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/map"));
  6333. var _ParseRole = _interopRequireDefault(_dereq_("./ParseRole"));
  6334. var _ParseUser = _interopRequireDefault(_dereq_("./ParseUser"));
  6335. function ownKeys(object, enumerableOnly) {
  6336. var keys = _Object$keys2(object);
  6337. if (_Object$getOwnPropertySymbols) {
  6338. var symbols = _Object$getOwnPropertySymbols(object);
  6339. enumerableOnly && (symbols = _filterInstanceProperty(symbols).call(symbols, function (sym) {
  6340. return _Object$getOwnPropertyDescriptor(object, sym).enumerable;
  6341. })), keys.push.apply(keys, symbols);
  6342. }
  6343. return keys;
  6344. }
  6345. function _objectSpread(target) {
  6346. for (var i = 1; i < arguments.length; i++) {
  6347. var _context3, _context4;
  6348. var source = null != arguments[i] ? arguments[i] : {};
  6349. i % 2 ? _forEachInstanceProperty(_context3 = ownKeys(Object(source), !0)).call(_context3, function (key) {
  6350. (0, _defineProperty2.default)(target, key, source[key]);
  6351. }) : _Object$getOwnPropertyDescriptors ? _Object$defineProperties(target, _Object$getOwnPropertyDescriptors(source)) : _forEachInstanceProperty(_context4 = ownKeys(Object(source))).call(_context4, function (key) {
  6352. _Object$defineProperty(target, key, _Object$getOwnPropertyDescriptor(source, key));
  6353. });
  6354. }
  6355. return target;
  6356. }
  6357. function _createForOfIteratorHelper(o, allowArrayLike) {
  6358. var it = typeof _Symbol !== "undefined" && _getIteratorMethod(o) || o["@@iterator"];
  6359. if (!it) {
  6360. if (_Array$isArray2(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") {
  6361. if (it) o = it;
  6362. var i = 0;
  6363. var F = function () {};
  6364. return {
  6365. s: F,
  6366. n: function () {
  6367. if (i >= o.length) return {
  6368. done: true
  6369. };
  6370. return {
  6371. done: false,
  6372. value: o[i++]
  6373. };
  6374. },
  6375. e: function (_e) {
  6376. throw _e;
  6377. },
  6378. f: F
  6379. };
  6380. }
  6381. throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
  6382. }
  6383. var normalCompletion = true,
  6384. didErr = false,
  6385. err;
  6386. return {
  6387. s: function () {
  6388. it = it.call(o);
  6389. },
  6390. n: function () {
  6391. var step = it.next();
  6392. normalCompletion = step.done;
  6393. return step;
  6394. },
  6395. e: function (_e2) {
  6396. didErr = true;
  6397. err = _e2;
  6398. },
  6399. f: function () {
  6400. try {
  6401. if (!normalCompletion && it.return != null) it.return();
  6402. } finally {
  6403. if (didErr) throw err;
  6404. }
  6405. }
  6406. };
  6407. }
  6408. function _unsupportedIterableToArray(o, minLen) {
  6409. var _context2;
  6410. if (!o) return;
  6411. if (typeof o === "string") return _arrayLikeToArray(o, minLen);
  6412. var n = _sliceInstanceProperty2(_context2 = Object.prototype.toString.call(o)).call(_context2, 8, -1);
  6413. if (n === "Object" && o.constructor) n = o.constructor.name;
  6414. if (n === "Map" || n === "Set") return _Array$from(o);
  6415. if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen);
  6416. }
  6417. function _arrayLikeToArray(arr, len) {
  6418. if (len == null || len > arr.length) len = arr.length;
  6419. for (var i = 0, arr2 = new Array(len); i < len; i++) {
  6420. arr2[i] = arr[i];
  6421. }
  6422. return arr2;
  6423. }
  6424. var PUBLIC_KEY = '*';
  6425. var VALID_PERMISSIONS
  6426. /*: Map<string, UsersMap>*/
  6427. = new _map.default();
  6428. VALID_PERMISSIONS.set('get', {});
  6429. VALID_PERMISSIONS.set('find', {});
  6430. VALID_PERMISSIONS.set('count', {});
  6431. VALID_PERMISSIONS.set('create', {});
  6432. VALID_PERMISSIONS.set('update', {});
  6433. VALID_PERMISSIONS.set('delete', {});
  6434. VALID_PERMISSIONS.set('addField', {});
  6435. var VALID_PERMISSIONS_EXTENDED
  6436. /*: Map<string, UsersMap>*/
  6437. = new _map.default();
  6438. VALID_PERMISSIONS_EXTENDED.set('protectedFields', {});
  6439. /**
  6440. * Creates a new CLP.
  6441. * If no argument is given, the CLP has no permissions for anyone.
  6442. * If the argument is a Parse.User or Parse.Role, the CLP will have read and write
  6443. * permission for only that user or role.
  6444. * If the argument is any other JSON object, that object will be interpretted
  6445. * as a serialized CLP created with toJSON().
  6446. *
  6447. * <p>A CLP, or Class Level Permissions can be added to any
  6448. * <code>Parse.Schema</code> to restrict access to only a subset of users
  6449. * of your application.</p>
  6450. *
  6451. * <p>
  6452. * For get/count/find/create/update/delete/addField using the following functions:
  6453. *
  6454. * Entity is type Parse.User or Parse.Role or string
  6455. * Role is type Parse.Role or Name of Parse.Role
  6456. *
  6457. * getGetRequiresAuthentication()
  6458. * setGetRequiresAuthentication(allowed: boolean)
  6459. * getGetPointerFields()
  6460. * setGetPointerFields(pointerFields: string[])
  6461. * getGetAccess(entity: Entity)
  6462. * setGetAccess(entity: Entity, allowed: boolean)
  6463. * getPublicGetAccess()
  6464. * setPublicGetAccess(allowed: boolean)
  6465. * getRoleGetAccess(role: Role)
  6466. * setRoleGetAccess(role: Role, allowed: boolean)
  6467. * getFindRequiresAuthentication()
  6468. * setFindRequiresAuthentication(allowed: boolean)
  6469. * getFindPointerFields()
  6470. * setFindPointerFields(pointerFields: string[])
  6471. * getFindAccess(entity: Entity)
  6472. * setFindAccess(entity: Entity, allowed: boolean)
  6473. * getPublicFindAccess()
  6474. * setPublicFindAccess(allowed: boolean)
  6475. * getRoleFindAccess(role: Role)
  6476. * setRoleFindAccess(role: Role, allowed: boolean)
  6477. * getCountRequiresAuthentication()
  6478. * setCountRequiresAuthentication(allowed: boolean)
  6479. * getCountPointerFields()
  6480. * setCountPointerFields(pointerFields: string[])
  6481. * getCountAccess(entity: Entity)
  6482. * setCountAccess(entity: Entity, allowed: boolean)
  6483. * getPublicCountAccess()
  6484. * setPublicCountAccess(allowed: boolean)
  6485. * getRoleCountAccess(role: Role)
  6486. * setRoleCountAccess(role: Role, allowed: boolean)
  6487. * getCreateRequiresAuthentication()
  6488. * setCreateRequiresAuthentication(allowed: boolean)
  6489. * getCreatePointerFields()
  6490. * setCreatePointerFields(pointerFields: string[])
  6491. * getCreateAccess(entity: Entity)
  6492. * setCreateAccess(entity: Entity, allowed: boolean)
  6493. * getPublicCreateAccess()
  6494. * setPublicCreateAccess(allowed: Boolean)
  6495. * getRoleCreateAccess(role: Role)
  6496. * setRoleCreateAccess(role: Role, allowed: boolean)
  6497. * getUpdateRequiresAuthentication()
  6498. * setUpdateRequiresAuthentication(allowed: boolean)
  6499. * getUpdatePointerFields()
  6500. * setUpdatePointerFields(pointerFields: string[])
  6501. * getUpdateAccess(entity: Entity)
  6502. * setUpdateAccess(entity: Entity, allowed: boolean)
  6503. * getPublicUpdateAccess()
  6504. * setPublicUpdateAccess(allowed: boolean)
  6505. * getRoleUpdateAccess(role: Role)
  6506. * setRoleUpdateAccess(role: Role, allowed: boolean)
  6507. * getDeleteRequiresAuthentication()
  6508. * setDeleteRequiresAuthentication(allowed: boolean)
  6509. * getDeletePointerFields()
  6510. * setDeletePointerFields(pointerFields: string[])
  6511. * getDeleteAccess(entity: Entity)
  6512. * setDeleteAccess(entity: Entity, allowed: boolean)
  6513. * getPublicDeleteAccess()
  6514. * setPublicDeleteAccess(allowed: boolean)
  6515. * getRoleDeleteAccess(role: Role)
  6516. * setRoleDeleteAccess(role: Role, allowed: boolean)
  6517. * getAddFieldRequiresAuthentication()
  6518. * setAddFieldRequiresAuthentication(allowed: boolean)
  6519. * getAddFieldPointerFields()
  6520. * setAddFieldPointerFields(pointerFields: string[])
  6521. * getAddFieldAccess(entity: Entity)
  6522. * setAddFieldAccess(entity: Entity, allowed: boolean)
  6523. * getPublicAddFieldAccess()
  6524. * setPublicAddFieldAccess(allowed: boolean)
  6525. * getRoleAddFieldAccess(role: Role)
  6526. * setRoleAddFieldAccess(role: Role, allowed: boolean)
  6527. * </p>
  6528. *
  6529. * @alias Parse.CLP
  6530. */
  6531. var ParseCLP = /*#__PURE__*/function () {
  6532. /**
  6533. * @param {(Parse.User | Parse.Role | object)} userId The user to initialize the CLP for
  6534. */
  6535. function ParseCLP(userId
  6536. /*: ParseUser | ParseRole | PermissionsMap*/
  6537. ) {
  6538. var _this = this;
  6539. (0, _classCallCheck2.default)(this, ParseCLP);
  6540. (0, _defineProperty2.default)(this, "permissionsMap", void 0);
  6541. this.permissionsMap = {}; // Initialize permissions Map with default permissions
  6542. var _iterator = _createForOfIteratorHelper((0, _entries.default)(VALID_PERMISSIONS).call(VALID_PERMISSIONS)),
  6543. _step;
  6544. try {
  6545. var _loop = function _loop() {
  6546. var _step$value = (0, _slicedToArray2.default)(_step.value, 2),
  6547. operation = _step$value[0],
  6548. group = _step$value[1];
  6549. _this.permissionsMap[operation] = (0, _assign.default)({}, group);
  6550. var action = operation.charAt(0).toUpperCase() + (0, _slice.default)(operation).call(operation, 1);
  6551. _this["get".concat(action, "RequiresAuthentication")] = function () {
  6552. return this._getAccess(operation, 'requiresAuthentication');
  6553. };
  6554. _this["set".concat(action, "RequiresAuthentication")] = function (allowed) {
  6555. this._setAccess(operation, 'requiresAuthentication', allowed);
  6556. };
  6557. _this["get".concat(action, "PointerFields")] = function () {
  6558. return this._getAccess(operation, 'pointerFields', false);
  6559. };
  6560. _this["set".concat(action, "PointerFields")] = function (pointerFields) {
  6561. this._setArrayAccess(operation, 'pointerFields', pointerFields);
  6562. };
  6563. _this["get".concat(action, "Access")] = function (entity) {
  6564. return this._getAccess(operation, entity);
  6565. };
  6566. _this["set".concat(action, "Access")] = function (entity, allowed) {
  6567. this._setAccess(operation, entity, allowed);
  6568. };
  6569. _this["getPublic".concat(action, "Access")] = function () {
  6570. return this["get".concat(action, "Access")](PUBLIC_KEY);
  6571. };
  6572. _this["setPublic".concat(action, "Access")] = function (allowed) {
  6573. this["set".concat(action, "Access")](PUBLIC_KEY, allowed);
  6574. };
  6575. _this["getRole".concat(action, "Access")] = function (role) {
  6576. return this["get".concat(action, "Access")](this._getRoleName(role));
  6577. };
  6578. _this["setRole".concat(action, "Access")] = function (role, allowed) {
  6579. this["set".concat(action, "Access")](this._getRoleName(role), allowed);
  6580. };
  6581. };
  6582. for (_iterator.s(); !(_step = _iterator.n()).done;) {
  6583. _loop();
  6584. } // Initialize permissions Map with default extended permissions
  6585. } catch (err) {
  6586. _iterator.e(err);
  6587. } finally {
  6588. _iterator.f();
  6589. }
  6590. var _iterator2 = _createForOfIteratorHelper((0, _entries.default)(VALID_PERMISSIONS_EXTENDED).call(VALID_PERMISSIONS_EXTENDED)),
  6591. _step2;
  6592. try {
  6593. for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
  6594. var _step2$value = (0, _slicedToArray2.default)(_step2.value, 2),
  6595. operation = _step2$value[0],
  6596. group = _step2$value[1];
  6597. this.permissionsMap[operation] = (0, _assign.default)({}, group);
  6598. }
  6599. } catch (err) {
  6600. _iterator2.e(err);
  6601. } finally {
  6602. _iterator2.f();
  6603. }
  6604. if (userId && (0, _typeof2.default)(userId) === 'object') {
  6605. if (userId instanceof _ParseUser.default) {
  6606. this.setReadAccess(userId, true);
  6607. this.setWriteAccess(userId, true);
  6608. } else if (userId instanceof _ParseRole.default) {
  6609. this.setRoleReadAccess(userId, true);
  6610. this.setRoleWriteAccess(userId, true);
  6611. } else {
  6612. for (var _permission in userId) {
  6613. var _context;
  6614. var users = userId[_permission];
  6615. var isValidPermission = !!VALID_PERMISSIONS.get(_permission);
  6616. var isValidPermissionExtended = !!VALID_PERMISSIONS_EXTENDED.get(_permission);
  6617. var isValidGroupPermission = (0, _includes.default)(_context = ['readUserFields', 'writeUserFields']).call(_context, _permission);
  6618. if (typeof _permission !== 'string' || !(isValidPermission || isValidPermissionExtended || isValidGroupPermission)) {
  6619. throw new TypeError('Tried to create an CLP with an invalid permission type.');
  6620. }
  6621. if (isValidGroupPermission) {
  6622. if ((0, _every.default)(users).call(users, function (pointer) {
  6623. return typeof pointer === 'string';
  6624. })) {
  6625. this.permissionsMap[_permission] = users;
  6626. continue;
  6627. } else {
  6628. throw new TypeError('Tried to create an CLP with an invalid permission value.');
  6629. }
  6630. }
  6631. for (var user in users) {
  6632. var allowed = users[user];
  6633. if (typeof allowed !== 'boolean' && !isValidPermissionExtended && user !== 'pointerFields') {
  6634. throw new TypeError('Tried to create an CLP with an invalid permission value.');
  6635. }
  6636. this.permissionsMap[_permission][user] = allowed;
  6637. }
  6638. }
  6639. }
  6640. } else if (typeof userId === 'function') {
  6641. throw new TypeError('ParseCLP constructed with a function. Did you forget ()?');
  6642. }
  6643. }
  6644. /**
  6645. * Returns a JSON-encoded version of the CLP.
  6646. *
  6647. * @returns {object}
  6648. */
  6649. (0, _createClass2.default)(ParseCLP, [{
  6650. key: "toJSON",
  6651. value: function toJSON()
  6652. /*: PermissionsMap*/
  6653. {
  6654. return _objectSpread({}, this.permissionsMap);
  6655. }
  6656. /**
  6657. * Returns whether this CLP is equal to another object
  6658. *
  6659. * @param other The other object to compare to
  6660. * @returns {boolean}
  6661. */
  6662. }, {
  6663. key: "equals",
  6664. value: function equals(other
  6665. /*: ParseCLP*/
  6666. )
  6667. /*: boolean*/
  6668. {
  6669. if (!(other instanceof ParseCLP)) {
  6670. return false;
  6671. }
  6672. var permissions = (0, _keys.default)(this.permissionsMap);
  6673. var otherPermissions = (0, _keys.default)(other.permissionsMap);
  6674. if (permissions.length !== otherPermissions.length) {
  6675. return false;
  6676. }
  6677. for (var _permission2 in this.permissionsMap) {
  6678. if (!other.permissionsMap[_permission2]) {
  6679. return false;
  6680. }
  6681. var users = (0, _keys.default)(this.permissionsMap[_permission2]);
  6682. var otherUsers = (0, _keys.default)(other.permissionsMap[_permission2]);
  6683. if (users.length !== otherUsers.length) {
  6684. return false;
  6685. }
  6686. for (var user in this.permissionsMap[_permission2]) {
  6687. if (!other.permissionsMap[_permission2][user]) {
  6688. return false;
  6689. }
  6690. if (this.permissionsMap[_permission2][user] !== other.permissionsMap[_permission2][user]) {
  6691. return false;
  6692. }
  6693. }
  6694. }
  6695. return true;
  6696. }
  6697. }, {
  6698. key: "_getRoleName",
  6699. value: function _getRoleName(role
  6700. /*: ParseRole | string*/
  6701. )
  6702. /*: string*/
  6703. {
  6704. var name = role;
  6705. if (role instanceof _ParseRole.default) {
  6706. // Normalize to the String name
  6707. name = role.getName();
  6708. }
  6709. if (typeof name !== 'string') {
  6710. throw new TypeError('role must be a Parse.Role or a String');
  6711. }
  6712. return "role:".concat(name);
  6713. }
  6714. }, {
  6715. key: "_parseEntity",
  6716. value: function _parseEntity(entity
  6717. /*: Entity*/
  6718. ) {
  6719. var userId = entity;
  6720. if (userId instanceof _ParseUser.default) {
  6721. userId = userId.id;
  6722. if (!userId) {
  6723. throw new Error('Cannot get access for a Parse.User without an id.');
  6724. }
  6725. } else if (userId instanceof _ParseRole.default) {
  6726. userId = this._getRoleName(userId);
  6727. }
  6728. if (typeof userId !== 'string') {
  6729. throw new TypeError('userId must be a string.');
  6730. }
  6731. return userId;
  6732. }
  6733. }, {
  6734. key: "_setAccess",
  6735. value: function _setAccess(permission
  6736. /*: string*/
  6737. , userId
  6738. /*: Entity*/
  6739. , allowed
  6740. /*: boolean*/
  6741. ) {
  6742. userId = this._parseEntity(userId);
  6743. if (typeof allowed !== 'boolean') {
  6744. throw new TypeError('allowed must be either true or false.');
  6745. }
  6746. var permissions = this.permissionsMap[permission][userId];
  6747. if (!permissions) {
  6748. if (!allowed) {
  6749. // The user already doesn't have this permission, so no action is needed
  6750. return;
  6751. } else {
  6752. this.permissionsMap[permission][userId] = {};
  6753. }
  6754. }
  6755. if (allowed) {
  6756. this.permissionsMap[permission][userId] = true;
  6757. } else {
  6758. delete this.permissionsMap[permission][userId];
  6759. }
  6760. }
  6761. }, {
  6762. key: "_getAccess",
  6763. value: function _getAccess(permission
  6764. /*: string*/
  6765. , userId
  6766. /*: Entity*/
  6767. )
  6768. /*: boolean | string[]*/
  6769. {
  6770. var returnBoolean = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : true;
  6771. userId = this._parseEntity(userId);
  6772. var permissions = this.permissionsMap[permission][userId];
  6773. if (returnBoolean) {
  6774. if (!permissions) {
  6775. return false;
  6776. }
  6777. return !!this.permissionsMap[permission][userId];
  6778. }
  6779. return permissions;
  6780. }
  6781. }, {
  6782. key: "_setArrayAccess",
  6783. value: function _setArrayAccess(permission
  6784. /*: string*/
  6785. , userId
  6786. /*: Entity*/
  6787. , fields
  6788. /*: string*/
  6789. ) {
  6790. userId = this._parseEntity(userId);
  6791. var permissions = this.permissionsMap[permission][userId];
  6792. if (!permissions) {
  6793. this.permissionsMap[permission][userId] = [];
  6794. }
  6795. if (!fields || (0, _isArray.default)(fields) && fields.length === 0) {
  6796. delete this.permissionsMap[permission][userId];
  6797. } else if ((0, _isArray.default)(fields) && (0, _every.default)(fields).call(fields, function (field) {
  6798. return typeof field === 'string';
  6799. })) {
  6800. this.permissionsMap[permission][userId] = fields;
  6801. } else {
  6802. throw new TypeError('fields must be an array of strings or undefined.');
  6803. }
  6804. }
  6805. }, {
  6806. key: "_setGroupPointerPermission",
  6807. value: function _setGroupPointerPermission(operation
  6808. /*: string*/
  6809. , pointerFields
  6810. /*: string[]*/
  6811. ) {
  6812. var fields = this.permissionsMap[operation];
  6813. if (!fields) {
  6814. this.permissionsMap[operation] = [];
  6815. }
  6816. if (!pointerFields || (0, _isArray.default)(pointerFields) && pointerFields.length === 0) {
  6817. delete this.permissionsMap[operation];
  6818. } else if ((0, _isArray.default)(pointerFields) && (0, _every.default)(pointerFields).call(pointerFields, function (field) {
  6819. return typeof field === 'string';
  6820. })) {
  6821. this.permissionsMap[operation] = pointerFields;
  6822. } else {
  6823. throw new TypeError("".concat(operation, ".pointerFields must be an array of strings or undefined."));
  6824. }
  6825. }
  6826. }, {
  6827. key: "_getGroupPointerPermissions",
  6828. value: function _getGroupPointerPermissions(operation
  6829. /*: string*/
  6830. )
  6831. /*: string[]*/
  6832. {
  6833. return this.permissionsMap[operation];
  6834. }
  6835. /**
  6836. * Sets user pointer fields to allow permission for get/count/find operations.
  6837. *
  6838. * @param {string[]} pointerFields User pointer fields
  6839. */
  6840. }, {
  6841. key: "setReadUserFields",
  6842. value: function setReadUserFields(pointerFields
  6843. /*: string[]*/
  6844. ) {
  6845. this._setGroupPointerPermission('readUserFields', pointerFields);
  6846. }
  6847. /**
  6848. * @returns {string[]} User pointer fields
  6849. */
  6850. }, {
  6851. key: "getReadUserFields",
  6852. value: function getReadUserFields()
  6853. /*: string[]*/
  6854. {
  6855. return this._getGroupPointerPermissions('readUserFields');
  6856. }
  6857. /**
  6858. * Sets user pointer fields to allow permission for create/delete/update/addField operations
  6859. *
  6860. * @param {string[]} pointerFields User pointer fields
  6861. */
  6862. }, {
  6863. key: "setWriteUserFields",
  6864. value: function setWriteUserFields(pointerFields
  6865. /*: string[]*/
  6866. ) {
  6867. this._setGroupPointerPermission('writeUserFields', pointerFields);
  6868. }
  6869. /**
  6870. * @returns {string[]} User pointer fields
  6871. */
  6872. }, {
  6873. key: "getWriteUserFields",
  6874. value: function getWriteUserFields()
  6875. /*: string[]*/
  6876. {
  6877. return this._getGroupPointerPermissions('writeUserFields');
  6878. }
  6879. /**
  6880. * Sets whether the given user is allowed to retrieve fields from this class.
  6881. *
  6882. * @param userId An instance of Parse.User or its objectId.
  6883. * @param {string[]} fields fields to be protected
  6884. */
  6885. }, {
  6886. key: "setProtectedFields",
  6887. value: function setProtectedFields(userId
  6888. /*: Entity*/
  6889. , fields
  6890. /*: string[]*/
  6891. ) {
  6892. this._setArrayAccess('protectedFields', userId, fields);
  6893. }
  6894. /**
  6895. * Returns array of fields are accessable to this user.
  6896. *
  6897. * @param userId An instance of Parse.User or its objectId, or a Parse.Role.
  6898. * @returns {string[]}
  6899. */
  6900. }, {
  6901. key: "getProtectedFields",
  6902. value: function getProtectedFields(userId
  6903. /*: Entity*/
  6904. )
  6905. /*: string[]*/
  6906. {
  6907. return this._getAccess('protectedFields', userId, false);
  6908. }
  6909. /**
  6910. * Sets whether the given user is allowed to read from this class.
  6911. *
  6912. * @param userId An instance of Parse.User or its objectId.
  6913. * @param {boolean} allowed whether that user should have read access.
  6914. */
  6915. }, {
  6916. key: "setReadAccess",
  6917. value: function setReadAccess(userId
  6918. /*: Entity*/
  6919. , allowed
  6920. /*: boolean*/
  6921. ) {
  6922. this._setAccess('find', userId, allowed);
  6923. this._setAccess('get', userId, allowed);
  6924. this._setAccess('count', userId, allowed);
  6925. }
  6926. /**
  6927. * Get whether the given user id is *explicitly* allowed to read from this class.
  6928. * Even if this returns false, the user may still be able to access it if
  6929. * getPublicReadAccess returns true or a role that the user belongs to has
  6930. * write access.
  6931. *
  6932. * @param userId An instance of Parse.User or its objectId, or a Parse.Role.
  6933. * @returns {boolean}
  6934. */
  6935. }, {
  6936. key: "getReadAccess",
  6937. value: function getReadAccess(userId
  6938. /*: Entity*/
  6939. )
  6940. /*: boolean*/
  6941. {
  6942. return this._getAccess('find', userId) && this._getAccess('get', userId) && this._getAccess('count', userId);
  6943. }
  6944. /**
  6945. * Sets whether the given user id is allowed to write to this class.
  6946. *
  6947. * @param userId An instance of Parse.User or its objectId, or a Parse.Role..
  6948. * @param {boolean} allowed Whether that user should have write access.
  6949. */
  6950. }, {
  6951. key: "setWriteAccess",
  6952. value: function setWriteAccess(userId
  6953. /*: Entity*/
  6954. , allowed
  6955. /*: boolean*/
  6956. ) {
  6957. this._setAccess('create', userId, allowed);
  6958. this._setAccess('update', userId, allowed);
  6959. this._setAccess('delete', userId, allowed);
  6960. this._setAccess('addField', userId, allowed);
  6961. }
  6962. /**
  6963. * Gets whether the given user id is *explicitly* allowed to write to this class.
  6964. * Even if this returns false, the user may still be able to write it if
  6965. * getPublicWriteAccess returns true or a role that the user belongs to has
  6966. * write access.
  6967. *
  6968. * @param userId An instance of Parse.User or its objectId, or a Parse.Role.
  6969. * @returns {boolean}
  6970. */
  6971. }, {
  6972. key: "getWriteAccess",
  6973. value: function getWriteAccess(userId
  6974. /*: Entity*/
  6975. )
  6976. /*: boolean*/
  6977. {
  6978. return this._getAccess('create', userId) && this._getAccess('update', userId) && this._getAccess('delete', userId) && this._getAccess('addField', userId);
  6979. }
  6980. /**
  6981. * Sets whether the public is allowed to read from this class.
  6982. *
  6983. * @param {boolean} allowed
  6984. */
  6985. }, {
  6986. key: "setPublicReadAccess",
  6987. value: function setPublicReadAccess(allowed
  6988. /*: boolean*/
  6989. ) {
  6990. this.setReadAccess(PUBLIC_KEY, allowed);
  6991. }
  6992. /**
  6993. * Gets whether the public is allowed to read from this class.
  6994. *
  6995. * @returns {boolean}
  6996. */
  6997. }, {
  6998. key: "getPublicReadAccess",
  6999. value: function getPublicReadAccess()
  7000. /*: boolean*/
  7001. {
  7002. return this.getReadAccess(PUBLIC_KEY);
  7003. }
  7004. /**
  7005. * Sets whether the public is allowed to write to this class.
  7006. *
  7007. * @param {boolean} allowed
  7008. */
  7009. }, {
  7010. key: "setPublicWriteAccess",
  7011. value: function setPublicWriteAccess(allowed
  7012. /*: boolean*/
  7013. ) {
  7014. this.setWriteAccess(PUBLIC_KEY, allowed);
  7015. }
  7016. /**
  7017. * Gets whether the public is allowed to write to this class.
  7018. *
  7019. * @returns {boolean}
  7020. */
  7021. }, {
  7022. key: "getPublicWriteAccess",
  7023. value: function getPublicWriteAccess()
  7024. /*: boolean*/
  7025. {
  7026. return this.getWriteAccess(PUBLIC_KEY);
  7027. }
  7028. /**
  7029. * Sets whether the public is allowed to protect fields in this class.
  7030. *
  7031. * @param {string[]} fields
  7032. */
  7033. }, {
  7034. key: "setPublicProtectedFields",
  7035. value: function setPublicProtectedFields(fields
  7036. /*: string[]*/
  7037. ) {
  7038. this.setProtectedFields(PUBLIC_KEY, fields);
  7039. }
  7040. /**
  7041. * Gets whether the public is allowed to read fields from this class.
  7042. *
  7043. * @returns {string[]}
  7044. */
  7045. }, {
  7046. key: "getPublicProtectedFields",
  7047. value: function getPublicProtectedFields()
  7048. /*: string[]*/
  7049. {
  7050. return this.getProtectedFields(PUBLIC_KEY);
  7051. }
  7052. /**
  7053. * Gets whether users belonging to the given role are allowed
  7054. * to read from this class. Even if this returns false, the role may
  7055. * still be able to write it if a parent role has read access.
  7056. *
  7057. * @param role The name of the role, or a Parse.Role object.
  7058. * @returns {boolean} true if the role has read access. false otherwise.
  7059. * @throws {TypeError} If role is neither a Parse.Role nor a String.
  7060. */
  7061. }, {
  7062. key: "getRoleReadAccess",
  7063. value: function getRoleReadAccess(role
  7064. /*: ParseRole | string*/
  7065. )
  7066. /*: boolean*/
  7067. {
  7068. return this.getReadAccess(this._getRoleName(role));
  7069. }
  7070. /**
  7071. * Gets whether users belonging to the given role are allowed
  7072. * to write to this user. Even if this returns false, the role may
  7073. * still be able to write it if a parent role has write access.
  7074. *
  7075. * @param role The name of the role, or a Parse.Role object.
  7076. * @returns {boolean} true if the role has write access. false otherwise.
  7077. * @throws {TypeError} If role is neither a Parse.Role nor a String.
  7078. */
  7079. }, {
  7080. key: "getRoleWriteAccess",
  7081. value: function getRoleWriteAccess(role
  7082. /*: ParseRole | string*/
  7083. )
  7084. /*: boolean*/
  7085. {
  7086. return this.getWriteAccess(this._getRoleName(role));
  7087. }
  7088. /**
  7089. * Sets whether users belonging to the given role are allowed
  7090. * to read from this class.
  7091. *
  7092. * @param role The name of the role, or a Parse.Role object.
  7093. * @param {boolean} allowed Whether the given role can read this object.
  7094. * @throws {TypeError} If role is neither a Parse.Role nor a String.
  7095. */
  7096. }, {
  7097. key: "setRoleReadAccess",
  7098. value: function setRoleReadAccess(role
  7099. /*: ParseRole | string*/
  7100. , allowed
  7101. /*: boolean*/
  7102. ) {
  7103. this.setReadAccess(this._getRoleName(role), allowed);
  7104. }
  7105. /**
  7106. * Sets whether users belonging to the given role are allowed
  7107. * to write to this class.
  7108. *
  7109. * @param role The name of the role, or a Parse.Role object.
  7110. * @param {boolean} allowed Whether the given role can write this object.
  7111. * @throws {TypeError} If role is neither a Parse.Role nor a String.
  7112. */
  7113. }, {
  7114. key: "setRoleWriteAccess",
  7115. value: function setRoleWriteAccess(role
  7116. /*: ParseRole | string*/
  7117. , allowed
  7118. /*: boolean*/
  7119. ) {
  7120. this.setWriteAccess(this._getRoleName(role), allowed);
  7121. }
  7122. /**
  7123. * Gets whether users belonging to the given role are allowed
  7124. * to count to this user. Even if this returns false, the role may
  7125. * still be able to count it if a parent role has count access.
  7126. *
  7127. * @param role The name of the role, or a Parse.Role object.
  7128. * @returns {string[]}
  7129. * @throws {TypeError} If role is neither a Parse.Role nor a String.
  7130. */
  7131. }, {
  7132. key: "getRoleProtectedFields",
  7133. value: function getRoleProtectedFields(role
  7134. /*: ParseRole | string*/
  7135. )
  7136. /*: string[]*/
  7137. {
  7138. return this.getProtectedFields(this._getRoleName(role));
  7139. }
  7140. /**
  7141. * Sets whether users belonging to the given role are allowed
  7142. * to set access field in this class.
  7143. *
  7144. * @param role The name of the role, or a Parse.Role object.
  7145. * @param {string[]} fields Fields to be protected by Role.
  7146. * @throws {TypeError} If role is neither a Parse.Role nor a String.
  7147. */
  7148. }, {
  7149. key: "setRoleProtectedFields",
  7150. value: function setRoleProtectedFields(role
  7151. /*: ParseRole | string*/
  7152. , fields
  7153. /*: string[]*/
  7154. ) {
  7155. this.setProtectedFields(this._getRoleName(role), fields);
  7156. }
  7157. }]);
  7158. return ParseCLP;
  7159. }();
  7160. var _default = ParseCLP;
  7161. exports.default = _default;
  7162. },{"./ParseRole":32,"./ParseUser":35,"@babel/runtime-corejs3/core-js-stable/array/from":55,"@babel/runtime-corejs3/core-js-stable/array/is-array":56,"@babel/runtime-corejs3/core-js-stable/instance/entries":59,"@babel/runtime-corejs3/core-js-stable/instance/every":60,"@babel/runtime-corejs3/core-js-stable/instance/filter":61,"@babel/runtime-corejs3/core-js-stable/instance/for-each":64,"@babel/runtime-corejs3/core-js-stable/instance/includes":65,"@babel/runtime-corejs3/core-js-stable/instance/slice":71,"@babel/runtime-corejs3/core-js-stable/map":77,"@babel/runtime-corejs3/core-js-stable/object/assign":79,"@babel/runtime-corejs3/core-js-stable/object/define-properties":81,"@babel/runtime-corejs3/core-js-stable/object/define-property":82,"@babel/runtime-corejs3/core-js-stable/object/get-own-property-descriptor":85,"@babel/runtime-corejs3/core-js-stable/object/get-own-property-descriptors":86,"@babel/runtime-corejs3/core-js-stable/object/get-own-property-symbols":87,"@babel/runtime-corejs3/core-js-stable/object/keys":89,"@babel/runtime-corejs3/core-js-stable/symbol":97,"@babel/runtime-corejs3/core-js/get-iterator-method":101,"@babel/runtime-corejs3/helpers/classCallCheck":121,"@babel/runtime-corejs3/helpers/createClass":123,"@babel/runtime-corejs3/helpers/defineProperty":124,"@babel/runtime-corejs3/helpers/interopRequireDefault":128,"@babel/runtime-corejs3/helpers/slicedToArray":137,"@babel/runtime-corejs3/helpers/typeof":140}],21:[function(_dereq_,module,exports){
  7163. "use strict";
  7164. var _interopRequireDefault = _dereq_("@babel/runtime-corejs3/helpers/interopRequireDefault");
  7165. var _Object$defineProperty = _dereq_("@babel/runtime-corejs3/core-js-stable/object/define-property");
  7166. _Object$defineProperty(exports, "__esModule", {
  7167. value: true
  7168. });
  7169. exports.default = void 0;
  7170. var _stringify = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/json/stringify"));
  7171. var _typeof2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/helpers/typeof"));
  7172. var _promise = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/promise"));
  7173. var _classCallCheck2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/helpers/classCallCheck"));
  7174. var _createClass2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/helpers/createClass"));
  7175. var _defineProperty2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/helpers/defineProperty"));
  7176. var _CoreManager = _interopRequireDefault(_dereq_("./CoreManager"));
  7177. var _decode = _interopRequireDefault(_dereq_("./decode"));
  7178. var _encode = _interopRequireDefault(_dereq_("./encode"));
  7179. var _escape2 = _interopRequireDefault(_dereq_("./escape"));
  7180. var _ParseError = _interopRequireDefault(_dereq_("./ParseError"));
  7181. var _Storage = _interopRequireDefault(_dereq_("./Storage"));
  7182. /**
  7183. * Copyright (c) 2015-present, Parse, LLC.
  7184. * All rights reserved.
  7185. *
  7186. * This source code is licensed under the BSD-style license found in the
  7187. * LICENSE file in the root directory of this source tree. An additional grant
  7188. * of patent rights can be found in the PATENTS file in the same directory.
  7189. *
  7190. * @flow
  7191. */
  7192. /**
  7193. * Parse.Config is a local representation of configuration data that
  7194. * can be set from the Parse dashboard.
  7195. *
  7196. * @alias Parse.Config
  7197. */
  7198. var ParseConfig = /*#__PURE__*/function () {
  7199. function ParseConfig() {
  7200. (0, _classCallCheck2.default)(this, ParseConfig);
  7201. (0, _defineProperty2.default)(this, "attributes", void 0);
  7202. (0, _defineProperty2.default)(this, "_escapedAttributes", void 0);
  7203. this.attributes = {};
  7204. this._escapedAttributes = {};
  7205. }
  7206. /**
  7207. * Gets the value of an attribute.
  7208. *
  7209. * @param {string} attr The name of an attribute.
  7210. * @returns {*}
  7211. */
  7212. (0, _createClass2.default)(ParseConfig, [{
  7213. key: "get",
  7214. value: function (attr
  7215. /*: string*/
  7216. )
  7217. /*: any*/
  7218. {
  7219. return this.attributes[attr];
  7220. }
  7221. /**
  7222. * Gets the HTML-escaped value of an attribute.
  7223. *
  7224. * @param {string} attr The name of an attribute.
  7225. * @returns {string}
  7226. */
  7227. }, {
  7228. key: "escape",
  7229. value: function (attr
  7230. /*: string*/
  7231. )
  7232. /*: string*/
  7233. {
  7234. var html = this._escapedAttributes[attr];
  7235. if (html) {
  7236. return html;
  7237. }
  7238. var val = this.attributes[attr];
  7239. var escaped = '';
  7240. if (val != null) {
  7241. escaped = (0, _escape2.default)(val.toString());
  7242. }
  7243. this._escapedAttributes[attr] = escaped;
  7244. return escaped;
  7245. }
  7246. /**
  7247. * Retrieves the most recently-fetched configuration object, either from
  7248. * memory or from local storage if necessary.
  7249. *
  7250. * @static
  7251. * @returns {Parse.Config} The most recently-fetched Parse.Config if it
  7252. * exists, else an empty Parse.Config.
  7253. */
  7254. }], [{
  7255. key: "current",
  7256. value: function () {
  7257. var controller = _CoreManager.default.getConfigController();
  7258. return controller.current();
  7259. }
  7260. /**
  7261. * Gets a new configuration object from the server.
  7262. *
  7263. * @static
  7264. * @param {object} options
  7265. * Valid options are:<ul>
  7266. * <li>useMasterKey: In Cloud Code and Node only, causes the Master Key to
  7267. * be used for this request.
  7268. * </ul>
  7269. * @returns {Promise} A promise that is resolved with a newly-created
  7270. * configuration object when the get completes.
  7271. */
  7272. }, {
  7273. key: "get",
  7274. value: function () {
  7275. var options
  7276. /*: RequestOptions*/
  7277. = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
  7278. var controller = _CoreManager.default.getConfigController();
  7279. return controller.get(options);
  7280. }
  7281. /**
  7282. * Save value keys to the server.
  7283. *
  7284. * @static
  7285. * @param {object} attrs The config parameters and values.
  7286. * @param {object} masterKeyOnlyFlags The flags that define whether config parameters listed
  7287. * in `attrs` should be retrievable only by using the master key.
  7288. * For example: `param1: true` makes `param1` only retrievable by using the master key.
  7289. * If a parameter is not provided or set to `false`, it can be retrieved without
  7290. * using the master key.
  7291. * @returns {Promise} A promise that is resolved with a newly-created
  7292. * configuration object or with the current with the update.
  7293. */
  7294. }, {
  7295. key: "save",
  7296. value: function (attrs
  7297. /*: { [key: string]: any }*/
  7298. , masterKeyOnlyFlags
  7299. /*: { [key: string]: any }*/
  7300. ) {
  7301. var controller = _CoreManager.default.getConfigController(); //To avoid a mismatch with the local and the cloud config we get a new version
  7302. return controller.save(attrs, masterKeyOnlyFlags).then(function () {
  7303. return controller.get({
  7304. useMasterKey: true
  7305. });
  7306. }, function (error) {
  7307. return _promise.default.reject(error);
  7308. });
  7309. }
  7310. /**
  7311. * Used for testing
  7312. *
  7313. * @private
  7314. */
  7315. }, {
  7316. key: "_clearCache",
  7317. value: function () {
  7318. currentConfig = null;
  7319. }
  7320. }]);
  7321. return ParseConfig;
  7322. }();
  7323. var currentConfig = null;
  7324. var CURRENT_CONFIG_KEY = 'currentConfig';
  7325. function decodePayload(data) {
  7326. try {
  7327. var json = JSON.parse(data);
  7328. if (json && (0, _typeof2.default)(json) === 'object') {
  7329. return (0, _decode.default)(json);
  7330. }
  7331. } catch (e) {
  7332. return null;
  7333. }
  7334. }
  7335. var DefaultController = {
  7336. current: function () {
  7337. if (currentConfig) {
  7338. return currentConfig;
  7339. }
  7340. var config = new ParseConfig();
  7341. var storagePath = _Storage.default.generatePath(CURRENT_CONFIG_KEY);
  7342. if (!_Storage.default.async()) {
  7343. var configData = _Storage.default.getItem(storagePath);
  7344. if (configData) {
  7345. var attributes = decodePayload(configData);
  7346. if (attributes) {
  7347. config.attributes = attributes;
  7348. currentConfig = config;
  7349. }
  7350. }
  7351. return config;
  7352. } // Return a promise for async storage controllers
  7353. return _Storage.default.getItemAsync(storagePath).then(function (configData) {
  7354. if (configData) {
  7355. var _attributes = decodePayload(configData);
  7356. if (_attributes) {
  7357. config.attributes = _attributes;
  7358. currentConfig = config;
  7359. }
  7360. }
  7361. return config;
  7362. });
  7363. },
  7364. get: function () {
  7365. var options
  7366. /*: RequestOptions*/
  7367. = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
  7368. var RESTController = _CoreManager.default.getRESTController();
  7369. return RESTController.request('GET', 'config', {}, options).then(function (response) {
  7370. if (!response || !response.params) {
  7371. var error = new _ParseError.default(_ParseError.default.INVALID_JSON, 'Config JSON response invalid.');
  7372. return _promise.default.reject(error);
  7373. }
  7374. var config = new ParseConfig();
  7375. config.attributes = {};
  7376. for (var attr in response.params) {
  7377. config.attributes[attr] = (0, _decode.default)(response.params[attr]);
  7378. }
  7379. currentConfig = config;
  7380. return _Storage.default.setItemAsync(_Storage.default.generatePath(CURRENT_CONFIG_KEY), (0, _stringify.default)(response.params)).then(function () {
  7381. return config;
  7382. });
  7383. });
  7384. },
  7385. save: function (attrs
  7386. /*: { [key: string]: any }*/
  7387. , masterKeyOnlyFlags
  7388. /*: { [key: string]: any }*/
  7389. ) {
  7390. var RESTController = _CoreManager.default.getRESTController();
  7391. var encodedAttrs = {};
  7392. for (var _key in attrs) {
  7393. encodedAttrs[_key] = (0, _encode.default)(attrs[_key]);
  7394. }
  7395. return RESTController.request('PUT', 'config', {
  7396. params: encodedAttrs,
  7397. masterKeyOnly: masterKeyOnlyFlags
  7398. }, {
  7399. useMasterKey: true
  7400. }).then(function (response) {
  7401. if (response && response.result) {
  7402. return _promise.default.resolve();
  7403. } else {
  7404. var error = new _ParseError.default(_ParseError.default.INTERNAL_SERVER_ERROR, 'Error occured updating Config.');
  7405. return _promise.default.reject(error);
  7406. }
  7407. });
  7408. }
  7409. };
  7410. _CoreManager.default.setConfigController(DefaultController);
  7411. var _default = ParseConfig;
  7412. exports.default = _default;
  7413. },{"./CoreManager":4,"./ParseError":22,"./Storage":39,"./decode":45,"./encode":46,"./escape":48,"@babel/runtime-corejs3/core-js-stable/json/stringify":76,"@babel/runtime-corejs3/core-js-stable/object/define-property":82,"@babel/runtime-corejs3/core-js-stable/promise":92,"@babel/runtime-corejs3/helpers/classCallCheck":121,"@babel/runtime-corejs3/helpers/createClass":123,"@babel/runtime-corejs3/helpers/defineProperty":124,"@babel/runtime-corejs3/helpers/interopRequireDefault":128,"@babel/runtime-corejs3/helpers/typeof":140}],22:[function(_dereq_,module,exports){
  7414. "use strict";
  7415. var _interopRequireDefault = _dereq_("@babel/runtime-corejs3/helpers/interopRequireDefault");
  7416. var _Object$defineProperty2 = _dereq_("@babel/runtime-corejs3/core-js-stable/object/define-property");
  7417. var _Reflect$construct = _dereq_("@babel/runtime-corejs3/core-js-stable/reflect/construct");
  7418. _Object$defineProperty2(exports, "__esModule", {
  7419. value: true
  7420. });
  7421. exports.default = void 0;
  7422. var _defineProperty = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/object/define-property"));
  7423. var _classCallCheck2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/helpers/classCallCheck"));
  7424. var _createClass2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/helpers/createClass"));
  7425. var _assertThisInitialized2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/helpers/assertThisInitialized"));
  7426. var _inherits2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/helpers/inherits"));
  7427. var _possibleConstructorReturn2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/helpers/possibleConstructorReturn"));
  7428. var _getPrototypeOf2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/helpers/getPrototypeOf"));
  7429. var _wrapNativeSuper2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/helpers/wrapNativeSuper"));
  7430. function _createSuper(Derived) {
  7431. var hasNativeReflectConstruct = _isNativeReflectConstruct();
  7432. return function () {
  7433. var Super = (0, _getPrototypeOf2.default)(Derived),
  7434. result;
  7435. if (hasNativeReflectConstruct) {
  7436. var NewTarget = (0, _getPrototypeOf2.default)(this).constructor;
  7437. result = _Reflect$construct(Super, arguments, NewTarget);
  7438. } else {
  7439. result = Super.apply(this, arguments);
  7440. }
  7441. return (0, _possibleConstructorReturn2.default)(this, result);
  7442. };
  7443. }
  7444. function _isNativeReflectConstruct() {
  7445. if (typeof Reflect === "undefined" || !_Reflect$construct) return false;
  7446. if (_Reflect$construct.sham) return false;
  7447. if (typeof Proxy === "function") return true;
  7448. try {
  7449. Boolean.prototype.valueOf.call(_Reflect$construct(Boolean, [], function () {}));
  7450. return true;
  7451. } catch (e) {
  7452. return false;
  7453. }
  7454. }
  7455. /**
  7456. * Copyright (c) 2015-present, Parse, LLC.
  7457. * All rights reserved.
  7458. *
  7459. * This source code is licensed under the BSD-style license found in the
  7460. * LICENSE file in the root directory of this source tree. An additional grant
  7461. * of patent rights can be found in the PATENTS file in the same directory.
  7462. */
  7463. /**
  7464. * Constructs a new Parse.Error object with the given code and message.
  7465. *
  7466. * @alias Parse.Error
  7467. */
  7468. var ParseError = /*#__PURE__*/function (_Error) {
  7469. (0, _inherits2.default)(ParseError, _Error);
  7470. var _super = _createSuper(ParseError);
  7471. /**
  7472. * @param {number} code An error code constant from <code>Parse.Error</code>.
  7473. * @param {string} message A detailed description of the error.
  7474. */
  7475. function ParseError(code, message) {
  7476. var _this;
  7477. (0, _classCallCheck2.default)(this, ParseError);
  7478. _this = _super.call(this, message);
  7479. _this.code = code;
  7480. (0, _defineProperty.default)((0, _assertThisInitialized2.default)(_this), 'message', {
  7481. enumerable: true,
  7482. value: message
  7483. });
  7484. return _this;
  7485. }
  7486. (0, _createClass2.default)(ParseError, [{
  7487. key: "toString",
  7488. value: function () {
  7489. return 'ParseError: ' + this.code + ' ' + this.message;
  7490. }
  7491. }]);
  7492. return ParseError;
  7493. }( /*#__PURE__*/(0, _wrapNativeSuper2.default)(Error));
  7494. /**
  7495. * Error code indicating some error other than those enumerated here.
  7496. *
  7497. * @property {number} OTHER_CAUSE
  7498. * @static
  7499. */
  7500. ParseError.OTHER_CAUSE = -1;
  7501. /**
  7502. * Error code indicating that something has gone wrong with the server.
  7503. *
  7504. * @property {number} INTERNAL_SERVER_ERROR
  7505. * @static
  7506. */
  7507. ParseError.INTERNAL_SERVER_ERROR = 1;
  7508. /**
  7509. * Error code indicating the connection to the Parse servers failed.
  7510. *
  7511. * @property {number} CONNECTION_FAILED
  7512. * @static
  7513. */
  7514. ParseError.CONNECTION_FAILED = 100;
  7515. /**
  7516. * Error code indicating the specified object doesn't exist.
  7517. *
  7518. * @property {number} OBJECT_NOT_FOUND
  7519. * @static
  7520. */
  7521. ParseError.OBJECT_NOT_FOUND = 101;
  7522. /**
  7523. * Error code indicating you tried to query with a datatype that doesn't
  7524. * support it, like exact matching an array or object.
  7525. *
  7526. * @property {number} INVALID_QUERY
  7527. * @static
  7528. */
  7529. ParseError.INVALID_QUERY = 102;
  7530. /**
  7531. * Error code indicating a missing or invalid classname. Classnames are
  7532. * case-sensitive. They must start with a letter, and a-zA-Z0-9_ are the
  7533. * only valid characters.
  7534. *
  7535. * @property {number} INVALID_CLASS_NAME
  7536. * @static
  7537. */
  7538. ParseError.INVALID_CLASS_NAME = 103;
  7539. /**
  7540. * Error code indicating an unspecified object id.
  7541. *
  7542. * @property {number} MISSING_OBJECT_ID
  7543. * @static
  7544. */
  7545. ParseError.MISSING_OBJECT_ID = 104;
  7546. /**
  7547. * Error code indicating an invalid key name. Keys are case-sensitive. They
  7548. * must start with a letter, and a-zA-Z0-9_ are the only valid characters.
  7549. *
  7550. * @property {number} INVALID_KEY_NAME
  7551. * @static
  7552. */
  7553. ParseError.INVALID_KEY_NAME = 105;
  7554. /**
  7555. * Error code indicating a malformed pointer. You should not see this unless
  7556. * you have been mucking about changing internal Parse code.
  7557. *
  7558. * @property {number} INVALID_POINTER
  7559. * @static
  7560. */
  7561. ParseError.INVALID_POINTER = 106;
  7562. /**
  7563. * Error code indicating that badly formed JSON was received upstream. This
  7564. * either indicates you have done something unusual with modifying how
  7565. * things encode to JSON, or the network is failing badly.
  7566. *
  7567. * @property {number} INVALID_JSON
  7568. * @static
  7569. */
  7570. ParseError.INVALID_JSON = 107;
  7571. /**
  7572. * Error code indicating that the feature you tried to access is only
  7573. * available internally for testing purposes.
  7574. *
  7575. * @property {number} COMMAND_UNAVAILABLE
  7576. * @static
  7577. */
  7578. ParseError.COMMAND_UNAVAILABLE = 108;
  7579. /**
  7580. * You must call Parse.initialize before using the Parse library.
  7581. *
  7582. * @property {number} NOT_INITIALIZED
  7583. * @static
  7584. */
  7585. ParseError.NOT_INITIALIZED = 109;
  7586. /**
  7587. * Error code indicating that a field was set to an inconsistent type.
  7588. *
  7589. * @property {number} INCORRECT_TYPE
  7590. * @static
  7591. */
  7592. ParseError.INCORRECT_TYPE = 111;
  7593. /**
  7594. * Error code indicating an invalid channel name. A channel name is either
  7595. * an empty string (the broadcast channel) or contains only a-zA-Z0-9_
  7596. * characters and starts with a letter.
  7597. *
  7598. * @property {number} INVALID_CHANNEL_NAME
  7599. * @static
  7600. */
  7601. ParseError.INVALID_CHANNEL_NAME = 112;
  7602. /**
  7603. * Error code indicating that push is misconfigured.
  7604. *
  7605. * @property {number} PUSH_MISCONFIGURED
  7606. * @static
  7607. */
  7608. ParseError.PUSH_MISCONFIGURED = 115;
  7609. /**
  7610. * Error code indicating that the object is too large.
  7611. *
  7612. * @property {number} OBJECT_TOO_LARGE
  7613. * @static
  7614. */
  7615. ParseError.OBJECT_TOO_LARGE = 116;
  7616. /**
  7617. * Error code indicating that the operation isn't allowed for clients.
  7618. *
  7619. * @property {number} OPERATION_FORBIDDEN
  7620. * @static
  7621. */
  7622. ParseError.OPERATION_FORBIDDEN = 119;
  7623. /**
  7624. * Error code indicating the result was not found in the cache.
  7625. *
  7626. * @property {number} CACHE_MISS
  7627. * @static
  7628. */
  7629. ParseError.CACHE_MISS = 120;
  7630. /**
  7631. * Error code indicating that an invalid key was used in a nested
  7632. * JSONObject.
  7633. *
  7634. * @property {number} INVALID_NESTED_KEY
  7635. * @static
  7636. */
  7637. ParseError.INVALID_NESTED_KEY = 121;
  7638. /**
  7639. * Error code indicating that an invalid filename was used for ParseFile.
  7640. * A valid file name contains only a-zA-Z0-9_. characters and is between 1
  7641. * and 128 characters.
  7642. *
  7643. * @property {number} INVALID_FILE_NAME
  7644. * @static
  7645. */
  7646. ParseError.INVALID_FILE_NAME = 122;
  7647. /**
  7648. * Error code indicating an invalid ACL was provided.
  7649. *
  7650. * @property {number} INVALID_ACL
  7651. * @static
  7652. */
  7653. ParseError.INVALID_ACL = 123;
  7654. /**
  7655. * Error code indicating that the request timed out on the server. Typically
  7656. * this indicates that the request is too expensive to run.
  7657. *
  7658. * @property {number} TIMEOUT
  7659. * @static
  7660. */
  7661. ParseError.TIMEOUT = 124;
  7662. /**
  7663. * Error code indicating that the email address was invalid.
  7664. *
  7665. * @property {number} INVALID_EMAIL_ADDRESS
  7666. * @static
  7667. */
  7668. ParseError.INVALID_EMAIL_ADDRESS = 125;
  7669. /**
  7670. * Error code indicating a missing content type.
  7671. *
  7672. * @property {number} MISSING_CONTENT_TYPE
  7673. * @static
  7674. */
  7675. ParseError.MISSING_CONTENT_TYPE = 126;
  7676. /**
  7677. * Error code indicating a missing content length.
  7678. *
  7679. * @property {number} MISSING_CONTENT_LENGTH
  7680. * @static
  7681. */
  7682. ParseError.MISSING_CONTENT_LENGTH = 127;
  7683. /**
  7684. * Error code indicating an invalid content length.
  7685. *
  7686. * @property {number} INVALID_CONTENT_LENGTH
  7687. * @static
  7688. */
  7689. ParseError.INVALID_CONTENT_LENGTH = 128;
  7690. /**
  7691. * Error code indicating a file that was too large.
  7692. *
  7693. * @property {number} FILE_TOO_LARGE
  7694. * @static
  7695. */
  7696. ParseError.FILE_TOO_LARGE = 129;
  7697. /**
  7698. * Error code indicating an error saving a file.
  7699. *
  7700. * @property {number} FILE_SAVE_ERROR
  7701. * @static
  7702. */
  7703. ParseError.FILE_SAVE_ERROR = 130;
  7704. /**
  7705. * Error code indicating that a unique field was given a value that is
  7706. * already taken.
  7707. *
  7708. * @property {number} DUPLICATE_VALUE
  7709. * @static
  7710. */
  7711. ParseError.DUPLICATE_VALUE = 137;
  7712. /**
  7713. * Error code indicating that a role's name is invalid.
  7714. *
  7715. * @property {number} INVALID_ROLE_NAME
  7716. * @static
  7717. */
  7718. ParseError.INVALID_ROLE_NAME = 139;
  7719. /**
  7720. * Error code indicating that an application quota was exceeded. Upgrade to
  7721. * resolve.
  7722. *
  7723. * @property {number} EXCEEDED_QUOTA
  7724. * @static
  7725. */
  7726. ParseError.EXCEEDED_QUOTA = 140;
  7727. /**
  7728. * Error code indicating that a Cloud Code script failed.
  7729. *
  7730. * @property {number} SCRIPT_FAILED
  7731. * @static
  7732. */
  7733. ParseError.SCRIPT_FAILED = 141;
  7734. /**
  7735. * Error code indicating that a Cloud Code validation failed.
  7736. *
  7737. * @property {number} VALIDATION_ERROR
  7738. * @static
  7739. */
  7740. ParseError.VALIDATION_ERROR = 142;
  7741. /**
  7742. * Error code indicating that invalid image data was provided.
  7743. *
  7744. * @property {number} INVALID_IMAGE_DATA
  7745. * @static
  7746. */
  7747. ParseError.INVALID_IMAGE_DATA = 143;
  7748. /**
  7749. * Error code indicating an unsaved file.
  7750. *
  7751. * @property {number} UNSAVED_FILE_ERROR
  7752. * @static
  7753. */
  7754. ParseError.UNSAVED_FILE_ERROR = 151;
  7755. /**
  7756. * Error code indicating an invalid push time.
  7757. *
  7758. * @property {number} INVALID_PUSH_TIME_ERROR
  7759. * @static
  7760. */
  7761. ParseError.INVALID_PUSH_TIME_ERROR = 152;
  7762. /**
  7763. * Error code indicating an error deleting a file.
  7764. *
  7765. * @property {number} FILE_DELETE_ERROR
  7766. * @static
  7767. */
  7768. ParseError.FILE_DELETE_ERROR = 153;
  7769. /**
  7770. * Error code indicating an error deleting an unnamed file.
  7771. *
  7772. * @property {number} FILE_DELETE_UNNAMED_ERROR
  7773. * @static
  7774. */
  7775. ParseError.FILE_DELETE_UNNAMED_ERROR = 161;
  7776. /**
  7777. * Error code indicating that the application has exceeded its request
  7778. * limit.
  7779. *
  7780. * @property {number} REQUEST_LIMIT_EXCEEDED
  7781. * @static
  7782. */
  7783. ParseError.REQUEST_LIMIT_EXCEEDED = 155;
  7784. /**
  7785. * Error code indicating that the request was a duplicate and has been discarded due to
  7786. * idempotency rules.
  7787. *
  7788. * @property {number} DUPLICATE_REQUEST
  7789. * @static
  7790. */
  7791. ParseError.DUPLICATE_REQUEST = 159;
  7792. /**
  7793. * Error code indicating an invalid event name.
  7794. *
  7795. * @property {number} INVALID_EVENT_NAME
  7796. * @static
  7797. */
  7798. ParseError.INVALID_EVENT_NAME = 160;
  7799. /**
  7800. * Error code indicating that a field had an invalid value.
  7801. *
  7802. * @property {number} INVALID_VALUE
  7803. * @static
  7804. */
  7805. ParseError.INVALID_VALUE = 162;
  7806. /**
  7807. * Error code indicating that the username is missing or empty.
  7808. *
  7809. * @property {number} USERNAME_MISSING
  7810. * @static
  7811. */
  7812. ParseError.USERNAME_MISSING = 200;
  7813. /**
  7814. * Error code indicating that the password is missing or empty.
  7815. *
  7816. * @property {number} PASSWORD_MISSING
  7817. * @static
  7818. */
  7819. ParseError.PASSWORD_MISSING = 201;
  7820. /**
  7821. * Error code indicating that the username has already been taken.
  7822. *
  7823. * @property {number} USERNAME_TAKEN
  7824. * @static
  7825. */
  7826. ParseError.USERNAME_TAKEN = 202;
  7827. /**
  7828. * Error code indicating that the email has already been taken.
  7829. *
  7830. * @property {number} EMAIL_TAKEN
  7831. * @static
  7832. */
  7833. ParseError.EMAIL_TAKEN = 203;
  7834. /**
  7835. * Error code indicating that the email is missing, but must be specified.
  7836. *
  7837. * @property {number} EMAIL_MISSING
  7838. * @static
  7839. */
  7840. ParseError.EMAIL_MISSING = 204;
  7841. /**
  7842. * Error code indicating that a user with the specified email was not found.
  7843. *
  7844. * @property {number} EMAIL_NOT_FOUND
  7845. * @static
  7846. */
  7847. ParseError.EMAIL_NOT_FOUND = 205;
  7848. /**
  7849. * Error code indicating that a user object without a valid session could
  7850. * not be altered.
  7851. *
  7852. * @property {number} SESSION_MISSING
  7853. * @static
  7854. */
  7855. ParseError.SESSION_MISSING = 206;
  7856. /**
  7857. * Error code indicating that a user can only be created through signup.
  7858. *
  7859. * @property {number} MUST_CREATE_USER_THROUGH_SIGNUP
  7860. * @static
  7861. */
  7862. ParseError.MUST_CREATE_USER_THROUGH_SIGNUP = 207;
  7863. /**
  7864. * Error code indicating that an an account being linked is already linked
  7865. * to another user.
  7866. *
  7867. * @property {number} ACCOUNT_ALREADY_LINKED
  7868. * @static
  7869. */
  7870. ParseError.ACCOUNT_ALREADY_LINKED = 208;
  7871. /**
  7872. * Error code indicating that the current session token is invalid.
  7873. *
  7874. * @property {number} INVALID_SESSION_TOKEN
  7875. * @static
  7876. */
  7877. ParseError.INVALID_SESSION_TOKEN = 209;
  7878. /**
  7879. * Error code indicating an error enabling or verifying MFA
  7880. *
  7881. * @property {number} MFA_ERROR
  7882. * @static
  7883. */
  7884. ParseError.MFA_ERROR = 210;
  7885. /**
  7886. * Error code indicating that a valid MFA token must be provided
  7887. *
  7888. * @property {number} MFA_TOKEN_REQUIRED
  7889. * @static
  7890. */
  7891. ParseError.MFA_TOKEN_REQUIRED = 211;
  7892. /**
  7893. * Error code indicating that a user cannot be linked to an account because
  7894. * that account's id could not be found.
  7895. *
  7896. * @property {number} LINKED_ID_MISSING
  7897. * @static
  7898. */
  7899. ParseError.LINKED_ID_MISSING = 250;
  7900. /**
  7901. * Error code indicating that a user with a linked (e.g. Facebook) account
  7902. * has an invalid session.
  7903. *
  7904. * @property {number} INVALID_LINKED_SESSION
  7905. * @static
  7906. */
  7907. ParseError.INVALID_LINKED_SESSION = 251;
  7908. /**
  7909. * Error code indicating that a service being linked (e.g. Facebook or
  7910. * Twitter) is unsupported.
  7911. *
  7912. * @property {number} UNSUPPORTED_SERVICE
  7913. * @static
  7914. */
  7915. ParseError.UNSUPPORTED_SERVICE = 252;
  7916. /**
  7917. * Error code indicating an invalid operation occured on schema
  7918. *
  7919. * @property {number} INVALID_SCHEMA_OPERATION
  7920. * @static
  7921. */
  7922. ParseError.INVALID_SCHEMA_OPERATION = 255;
  7923. /**
  7924. * Error code indicating that there were multiple errors. Aggregate errors
  7925. * have an "errors" property, which is an array of error objects with more
  7926. * detail about each error that occurred.
  7927. *
  7928. * @property {number} AGGREGATE_ERROR
  7929. * @static
  7930. */
  7931. ParseError.AGGREGATE_ERROR = 600;
  7932. /**
  7933. * Error code indicating the client was unable to read an input file.
  7934. *
  7935. * @property {number} FILE_READ_ERROR
  7936. * @static
  7937. */
  7938. ParseError.FILE_READ_ERROR = 601;
  7939. /**
  7940. * Error code indicating a real error code is unavailable because
  7941. * we had to use an XDomainRequest object to allow CORS requests in
  7942. * Internet Explorer, which strips the body from HTTP responses that have
  7943. * a non-2XX status code.
  7944. *
  7945. * @property {number} X_DOMAIN_REQUEST
  7946. * @static
  7947. */
  7948. ParseError.X_DOMAIN_REQUEST = 602;
  7949. var _default = ParseError;
  7950. exports.default = _default;
  7951. },{"@babel/runtime-corejs3/core-js-stable/object/define-property":82,"@babel/runtime-corejs3/core-js-stable/reflect/construct":93,"@babel/runtime-corejs3/helpers/assertThisInitialized":119,"@babel/runtime-corejs3/helpers/classCallCheck":121,"@babel/runtime-corejs3/helpers/createClass":123,"@babel/runtime-corejs3/helpers/getPrototypeOf":126,"@babel/runtime-corejs3/helpers/inherits":127,"@babel/runtime-corejs3/helpers/interopRequireDefault":128,"@babel/runtime-corejs3/helpers/possibleConstructorReturn":135,"@babel/runtime-corejs3/helpers/wrapNativeSuper":142}],23:[function(_dereq_,module,exports){
  7952. "use strict";
  7953. var _interopRequireDefault = _dereq_("@babel/runtime-corejs3/helpers/interopRequireDefault");
  7954. var _Object$defineProperties = _dereq_("@babel/runtime-corejs3/core-js-stable/object/define-properties");
  7955. var _Object$getOwnPropertyDescriptors = _dereq_("@babel/runtime-corejs3/core-js-stable/object/get-own-property-descriptors");
  7956. var _Object$getOwnPropertyDescriptor = _dereq_("@babel/runtime-corejs3/core-js-stable/object/get-own-property-descriptor");
  7957. var _filterInstanceProperty = _dereq_("@babel/runtime-corejs3/core-js-stable/instance/filter");
  7958. var _Object$getOwnPropertySymbols = _dereq_("@babel/runtime-corejs3/core-js-stable/object/get-own-property-symbols");
  7959. var _Object$keys2 = _dereq_("@babel/runtime-corejs3/core-js-stable/object/keys");
  7960. var _sliceInstanceProperty2 = _dereq_("@babel/runtime-corejs3/core-js-stable/instance/slice");
  7961. var _reverseInstanceProperty = _dereq_("@babel/runtime-corejs3/core-js-stable/instance/reverse");
  7962. var _Promise2 = _dereq_("@babel/runtime-corejs3/core-js-stable/promise");
  7963. var _Object$setPrototypeOf = _dereq_("@babel/runtime-corejs3/core-js-stable/object/set-prototype-of");
  7964. var _typeof3 = _dereq_("@babel/runtime-corejs3/helpers/typeof");
  7965. var _forEachInstanceProperty2 = _dereq_("@babel/runtime-corejs3/core-js-stable/instance/for-each");
  7966. var _Object$getPrototypeOf = _dereq_("@babel/runtime-corejs3/core-js-stable/object/get-prototype-of");
  7967. var _Object$create = _dereq_("@babel/runtime-corejs3/core-js-stable/object/create");
  7968. var _Object$defineProperty = _dereq_("@babel/runtime-corejs3/core-js-stable/object/define-property");
  7969. var _Symbol = _dereq_("@babel/runtime-corejs3/core-js-stable/symbol");
  7970. _Object$defineProperty(exports, "__esModule", {
  7971. value: true
  7972. });
  7973. exports.default = void 0;
  7974. var _indexOf = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/instance/index-of"));
  7975. var _slicedToArray2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/helpers/slicedToArray"));
  7976. var _promise = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/promise"));
  7977. var _keys = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/object/keys"));
  7978. var _forEach = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/instance/for-each"));
  7979. var _typeof2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/helpers/typeof"));
  7980. var _asyncToGenerator2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/helpers/asyncToGenerator"));
  7981. var _slice = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/instance/slice"));
  7982. var _isArray = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/array/is-array"));
  7983. var _classCallCheck2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/helpers/classCallCheck"));
  7984. var _createClass2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/helpers/createClass"));
  7985. var _defineProperty2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/helpers/defineProperty"));
  7986. var _CoreManager = _interopRequireDefault(_dereq_("./CoreManager"));
  7987. function ownKeys(object, enumerableOnly) {
  7988. var keys = _Object$keys2(object);
  7989. if (_Object$getOwnPropertySymbols) {
  7990. var symbols = _Object$getOwnPropertySymbols(object);
  7991. enumerableOnly && (symbols = _filterInstanceProperty(symbols).call(symbols, function (sym) {
  7992. return _Object$getOwnPropertyDescriptor(object, sym).enumerable;
  7993. })), keys.push.apply(keys, symbols);
  7994. }
  7995. return keys;
  7996. }
  7997. function _objectSpread(target) {
  7998. for (var i = 1; i < arguments.length; i++) {
  7999. var _context10, _context11;
  8000. var source = null != arguments[i] ? arguments[i] : {};
  8001. i % 2 ? _forEachInstanceProperty2(_context10 = ownKeys(Object(source), !0)).call(_context10, function (key) {
  8002. (0, _defineProperty2.default)(target, key, source[key]);
  8003. }) : _Object$getOwnPropertyDescriptors ? _Object$defineProperties(target, _Object$getOwnPropertyDescriptors(source)) : _forEachInstanceProperty2(_context11 = ownKeys(Object(source))).call(_context11, function (key) {
  8004. _Object$defineProperty(target, key, _Object$getOwnPropertyDescriptor(source, key));
  8005. });
  8006. }
  8007. return target;
  8008. }
  8009. function _regeneratorRuntime() {
  8010. "use strict";
  8011. /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */
  8012. _regeneratorRuntime = function () {
  8013. return exports;
  8014. };
  8015. var exports = {},
  8016. Op = Object.prototype,
  8017. hasOwn = Op.hasOwnProperty,
  8018. $Symbol = "function" == typeof _Symbol ? _Symbol : {},
  8019. iteratorSymbol = $Symbol.iterator || "@@iterator",
  8020. asyncIteratorSymbol = $Symbol.asyncIterator || "@@asyncIterator",
  8021. toStringTagSymbol = $Symbol.toStringTag || "@@toStringTag";
  8022. function define(obj, key, value) {
  8023. return _Object$defineProperty(obj, key, {
  8024. value: value,
  8025. enumerable: !0,
  8026. configurable: !0,
  8027. writable: !0
  8028. }), obj[key];
  8029. }
  8030. try {
  8031. define({}, "");
  8032. } catch (err) {
  8033. define = function (obj, key, value) {
  8034. return obj[key] = value;
  8035. };
  8036. }
  8037. function wrap(innerFn, outerFn, self, tryLocsList) {
  8038. var protoGenerator = outerFn && outerFn.prototype instanceof Generator ? outerFn : Generator,
  8039. generator = _Object$create(protoGenerator.prototype),
  8040. context = new Context(tryLocsList || []);
  8041. return generator._invoke = function (innerFn, self, context) {
  8042. var state = "suspendedStart";
  8043. return function (method, arg) {
  8044. if ("executing" === state) throw new Error("Generator is already running");
  8045. if ("completed" === state) {
  8046. if ("throw" === method) throw arg;
  8047. return doneResult();
  8048. }
  8049. for (context.method = method, context.arg = arg;;) {
  8050. var delegate = context.delegate;
  8051. if (delegate) {
  8052. var delegateResult = maybeInvokeDelegate(delegate, context);
  8053. if (delegateResult) {
  8054. if (delegateResult === ContinueSentinel) continue;
  8055. return delegateResult;
  8056. }
  8057. }
  8058. if ("next" === context.method) context.sent = context._sent = context.arg;else if ("throw" === context.method) {
  8059. if ("suspendedStart" === state) throw state = "completed", context.arg;
  8060. context.dispatchException(context.arg);
  8061. } else "return" === context.method && context.abrupt("return", context.arg);
  8062. state = "executing";
  8063. var record = tryCatch(innerFn, self, context);
  8064. if ("normal" === record.type) {
  8065. if (state = context.done ? "completed" : "suspendedYield", record.arg === ContinueSentinel) continue;
  8066. return {
  8067. value: record.arg,
  8068. done: context.done
  8069. };
  8070. }
  8071. "throw" === record.type && (state = "completed", context.method = "throw", context.arg = record.arg);
  8072. }
  8073. };
  8074. }(innerFn, self, context), generator;
  8075. }
  8076. function tryCatch(fn, obj, arg) {
  8077. try {
  8078. return {
  8079. type: "normal",
  8080. arg: fn.call(obj, arg)
  8081. };
  8082. } catch (err) {
  8083. return {
  8084. type: "throw",
  8085. arg: err
  8086. };
  8087. }
  8088. }
  8089. exports.wrap = wrap;
  8090. var ContinueSentinel = {};
  8091. function Generator() {}
  8092. function GeneratorFunction() {}
  8093. function GeneratorFunctionPrototype() {}
  8094. var IteratorPrototype = {};
  8095. define(IteratorPrototype, iteratorSymbol, function () {
  8096. return this;
  8097. });
  8098. var getProto = _Object$getPrototypeOf,
  8099. NativeIteratorPrototype = getProto && getProto(getProto(values([])));
  8100. NativeIteratorPrototype && NativeIteratorPrototype !== Op && hasOwn.call(NativeIteratorPrototype, iteratorSymbol) && (IteratorPrototype = NativeIteratorPrototype);
  8101. var Gp = GeneratorFunctionPrototype.prototype = Generator.prototype = _Object$create(IteratorPrototype);
  8102. function defineIteratorMethods(prototype) {
  8103. var _context8;
  8104. _forEachInstanceProperty2(_context8 = ["next", "throw", "return"]).call(_context8, function (method) {
  8105. define(prototype, method, function (arg) {
  8106. return this._invoke(method, arg);
  8107. });
  8108. });
  8109. }
  8110. function AsyncIterator(generator, PromiseImpl) {
  8111. function invoke(method, arg, resolve, reject) {
  8112. var record = tryCatch(generator[method], generator, arg);
  8113. if ("throw" !== record.type) {
  8114. var result = record.arg,
  8115. value = result.value;
  8116. return value && "object" == _typeof3(value) && hasOwn.call(value, "__await") ? PromiseImpl.resolve(value.__await).then(function (value) {
  8117. invoke("next", value, resolve, reject);
  8118. }, function (err) {
  8119. invoke("throw", err, resolve, reject);
  8120. }) : PromiseImpl.resolve(value).then(function (unwrapped) {
  8121. result.value = unwrapped, resolve(result);
  8122. }, function (error) {
  8123. return invoke("throw", error, resolve, reject);
  8124. });
  8125. }
  8126. reject(record.arg);
  8127. }
  8128. var previousPromise;
  8129. this._invoke = function (method, arg) {
  8130. function callInvokeWithMethodAndArg() {
  8131. return new PromiseImpl(function (resolve, reject) {
  8132. invoke(method, arg, resolve, reject);
  8133. });
  8134. }
  8135. return previousPromise = previousPromise ? previousPromise.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg();
  8136. };
  8137. }
  8138. function maybeInvokeDelegate(delegate, context) {
  8139. var method = delegate.iterator[context.method];
  8140. if (undefined === method) {
  8141. if (context.delegate = null, "throw" === context.method) {
  8142. if (delegate.iterator.return && (context.method = "return", context.arg = undefined, maybeInvokeDelegate(delegate, context), "throw" === context.method)) return ContinueSentinel;
  8143. context.method = "throw", context.arg = new TypeError("The iterator does not provide a 'throw' method");
  8144. }
  8145. return ContinueSentinel;
  8146. }
  8147. var record = tryCatch(method, delegate.iterator, context.arg);
  8148. if ("throw" === record.type) return context.method = "throw", context.arg = record.arg, context.delegate = null, ContinueSentinel;
  8149. var info = record.arg;
  8150. return info ? info.done ? (context[delegate.resultName] = info.value, context.next = delegate.nextLoc, "return" !== context.method && (context.method = "next", context.arg = undefined), context.delegate = null, ContinueSentinel) : info : (context.method = "throw", context.arg = new TypeError("iterator result is not an object"), context.delegate = null, ContinueSentinel);
  8151. }
  8152. function pushTryEntry(locs) {
  8153. var entry = {
  8154. tryLoc: locs[0]
  8155. };
  8156. 1 in locs && (entry.catchLoc = locs[1]), 2 in locs && (entry.finallyLoc = locs[2], entry.afterLoc = locs[3]), this.tryEntries.push(entry);
  8157. }
  8158. function resetTryEntry(entry) {
  8159. var record = entry.completion || {};
  8160. record.type = "normal", delete record.arg, entry.completion = record;
  8161. }
  8162. function Context(tryLocsList) {
  8163. this.tryEntries = [{
  8164. tryLoc: "root"
  8165. }], _forEachInstanceProperty2(tryLocsList).call(tryLocsList, pushTryEntry, this), this.reset(!0);
  8166. }
  8167. function values(iterable) {
  8168. if (iterable) {
  8169. var iteratorMethod = iterable[iteratorSymbol];
  8170. if (iteratorMethod) return iteratorMethod.call(iterable);
  8171. if ("function" == typeof iterable.next) return iterable;
  8172. if (!isNaN(iterable.length)) {
  8173. var i = -1,
  8174. next = function next() {
  8175. for (; ++i < iterable.length;) {
  8176. if (hasOwn.call(iterable, i)) return next.value = iterable[i], next.done = !1, next;
  8177. }
  8178. return next.value = undefined, next.done = !0, next;
  8179. };
  8180. return next.next = next;
  8181. }
  8182. }
  8183. return {
  8184. next: doneResult
  8185. };
  8186. }
  8187. function doneResult() {
  8188. return {
  8189. value: undefined,
  8190. done: !0
  8191. };
  8192. }
  8193. return GeneratorFunction.prototype = GeneratorFunctionPrototype, define(Gp, "constructor", GeneratorFunctionPrototype), define(GeneratorFunctionPrototype, "constructor", GeneratorFunction), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, toStringTagSymbol, "GeneratorFunction"), exports.isGeneratorFunction = function (genFun) {
  8194. var ctor = "function" == typeof genFun && genFun.constructor;
  8195. return !!ctor && (ctor === GeneratorFunction || "GeneratorFunction" === (ctor.displayName || ctor.name));
  8196. }, exports.mark = function (genFun) {
  8197. return _Object$setPrototypeOf ? _Object$setPrototypeOf(genFun, GeneratorFunctionPrototype) : (genFun.__proto__ = GeneratorFunctionPrototype, define(genFun, toStringTagSymbol, "GeneratorFunction")), genFun.prototype = _Object$create(Gp), genFun;
  8198. }, exports.awrap = function (arg) {
  8199. return {
  8200. __await: arg
  8201. };
  8202. }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, asyncIteratorSymbol, function () {
  8203. return this;
  8204. }), exports.AsyncIterator = AsyncIterator, exports.async = function (innerFn, outerFn, self, tryLocsList, PromiseImpl) {
  8205. void 0 === PromiseImpl && (PromiseImpl = _Promise2);
  8206. var iter = new AsyncIterator(wrap(innerFn, outerFn, self, tryLocsList), PromiseImpl);
  8207. return exports.isGeneratorFunction(outerFn) ? iter : iter.next().then(function (result) {
  8208. return result.done ? result.value : iter.next();
  8209. });
  8210. }, defineIteratorMethods(Gp), define(Gp, toStringTagSymbol, "Generator"), define(Gp, iteratorSymbol, function () {
  8211. return this;
  8212. }), define(Gp, "toString", function () {
  8213. return "[object Generator]";
  8214. }), exports.keys = function (object) {
  8215. var keys = [];
  8216. for (var key in object) {
  8217. keys.push(key);
  8218. }
  8219. return _reverseInstanceProperty(keys).call(keys), function next() {
  8220. for (; keys.length;) {
  8221. var key = keys.pop();
  8222. if (key in object) return next.value = key, next.done = !1, next;
  8223. }
  8224. return next.done = !0, next;
  8225. };
  8226. }, exports.values = values, Context.prototype = {
  8227. constructor: Context,
  8228. reset: function (skipTempReset) {
  8229. var _context9;
  8230. if (this.prev = 0, this.next = 0, this.sent = this._sent = undefined, this.done = !1, this.delegate = null, this.method = "next", this.arg = undefined, _forEachInstanceProperty2(_context9 = this.tryEntries).call(_context9, resetTryEntry), !skipTempReset) for (var name in this) {
  8231. "t" === name.charAt(0) && hasOwn.call(this, name) && !isNaN(+_sliceInstanceProperty2(name).call(name, 1)) && (this[name] = undefined);
  8232. }
  8233. },
  8234. stop: function () {
  8235. this.done = !0;
  8236. var rootRecord = this.tryEntries[0].completion;
  8237. if ("throw" === rootRecord.type) throw rootRecord.arg;
  8238. return this.rval;
  8239. },
  8240. dispatchException: function (exception) {
  8241. if (this.done) throw exception;
  8242. var context = this;
  8243. function handle(loc, caught) {
  8244. return record.type = "throw", record.arg = exception, context.next = loc, caught && (context.method = "next", context.arg = undefined), !!caught;
  8245. }
  8246. for (var i = this.tryEntries.length - 1; i >= 0; --i) {
  8247. var entry = this.tryEntries[i],
  8248. record = entry.completion;
  8249. if ("root" === entry.tryLoc) return handle("end");
  8250. if (entry.tryLoc <= this.prev) {
  8251. var hasCatch = hasOwn.call(entry, "catchLoc"),
  8252. hasFinally = hasOwn.call(entry, "finallyLoc");
  8253. if (hasCatch && hasFinally) {
  8254. if (this.prev < entry.catchLoc) return handle(entry.catchLoc, !0);
  8255. if (this.prev < entry.finallyLoc) return handle(entry.finallyLoc);
  8256. } else if (hasCatch) {
  8257. if (this.prev < entry.catchLoc) return handle(entry.catchLoc, !0);
  8258. } else {
  8259. if (!hasFinally) throw new Error("try statement without catch or finally");
  8260. if (this.prev < entry.finallyLoc) return handle(entry.finallyLoc);
  8261. }
  8262. }
  8263. }
  8264. },
  8265. abrupt: function (type, arg) {
  8266. for (var i = this.tryEntries.length - 1; i >= 0; --i) {
  8267. var entry = this.tryEntries[i];
  8268. if (entry.tryLoc <= this.prev && hasOwn.call(entry, "finallyLoc") && this.prev < entry.finallyLoc) {
  8269. var finallyEntry = entry;
  8270. break;
  8271. }
  8272. }
  8273. finallyEntry && ("break" === type || "continue" === type) && finallyEntry.tryLoc <= arg && arg <= finallyEntry.finallyLoc && (finallyEntry = null);
  8274. var record = finallyEntry ? finallyEntry.completion : {};
  8275. return record.type = type, record.arg = arg, finallyEntry ? (this.method = "next", this.next = finallyEntry.finallyLoc, ContinueSentinel) : this.complete(record);
  8276. },
  8277. complete: function (record, afterLoc) {
  8278. if ("throw" === record.type) throw record.arg;
  8279. return "break" === record.type || "continue" === record.type ? this.next = record.arg : "return" === record.type ? (this.rval = this.arg = record.arg, this.method = "return", this.next = "end") : "normal" === record.type && afterLoc && (this.next = afterLoc), ContinueSentinel;
  8280. },
  8281. finish: function (finallyLoc) {
  8282. for (var i = this.tryEntries.length - 1; i >= 0; --i) {
  8283. var entry = this.tryEntries[i];
  8284. if (entry.finallyLoc === finallyLoc) return this.complete(entry.completion, entry.afterLoc), resetTryEntry(entry), ContinueSentinel;
  8285. }
  8286. },
  8287. catch: function (tryLoc) {
  8288. for (var i = this.tryEntries.length - 1; i >= 0; --i) {
  8289. var entry = this.tryEntries[i];
  8290. if (entry.tryLoc === tryLoc) {
  8291. var record = entry.completion;
  8292. if ("throw" === record.type) {
  8293. var thrown = record.arg;
  8294. resetTryEntry(entry);
  8295. }
  8296. return thrown;
  8297. }
  8298. }
  8299. throw new Error("illegal catch attempt");
  8300. },
  8301. delegateYield: function (iterable, resultName, nextLoc) {
  8302. return this.delegate = {
  8303. iterator: values(iterable),
  8304. resultName: resultName,
  8305. nextLoc: nextLoc
  8306. }, "next" === this.method && (this.arg = undefined), ContinueSentinel;
  8307. }
  8308. }, exports;
  8309. }
  8310. var ParseError = _dereq_('./ParseError').default;
  8311. var XHR = null;
  8312. if (typeof XMLHttpRequest !== 'undefined') {
  8313. XHR = XMLHttpRequest;
  8314. }
  8315. /*:: type Base64 = { base64: string };*/
  8316. /*:: type Uri = { uri: string };*/
  8317. /*:: type FileData = Array<number> | Base64 | Blob | Uri;*/
  8318. /*:: export type FileSource =
  8319. | {
  8320. format: 'file',
  8321. file: Blob,
  8322. type: string,
  8323. }
  8324. | {
  8325. format: 'base64',
  8326. base64: string,
  8327. type: string,
  8328. }
  8329. | {
  8330. format: 'uri',
  8331. uri: string,
  8332. type: string,
  8333. };*/
  8334. function b64Digit(number
  8335. /*: number*/
  8336. )
  8337. /*: string*/
  8338. {
  8339. if (number < 26) {
  8340. return String.fromCharCode(65 + number);
  8341. }
  8342. if (number < 52) {
  8343. return String.fromCharCode(97 + (number - 26));
  8344. }
  8345. if (number < 62) {
  8346. return String.fromCharCode(48 + (number - 52));
  8347. }
  8348. if (number === 62) {
  8349. return '+';
  8350. }
  8351. if (number === 63) {
  8352. return '/';
  8353. }
  8354. throw new TypeError('Tried to encode large digit ' + number + ' in base64.');
  8355. }
  8356. /**
  8357. * A Parse.File is a local representation of a file that is saved to the Parse
  8358. * cloud.
  8359. *
  8360. * @alias Parse.File
  8361. */
  8362. var ParseFile = /*#__PURE__*/function () {
  8363. /**
  8364. * @param name {String} The file's name. This will be prefixed by a unique
  8365. * value once the file has finished saving. The file name must begin with
  8366. * an alphanumeric character, and consist of alphanumeric characters,
  8367. * periods, spaces, underscores, or dashes.
  8368. * @param data {Array} The data for the file, as either:
  8369. * 1. an Array of byte value Numbers, or
  8370. * 2. an Object like { base64: "..." } with a base64-encoded String.
  8371. * 3. an Object like { uri: "..." } with a uri String.
  8372. * 4. a File object selected with a file upload control. (3) only works
  8373. * in Firefox 3.6+, Safari 6.0.2+, Chrome 7+, and IE 10+.
  8374. * For example:
  8375. * <pre>
  8376. * var fileUploadControl = $("#profilePhotoFileUpload")[0];
  8377. * if (fileUploadControl.files.length > 0) {
  8378. * var file = fileUploadControl.files[0];
  8379. * var name = "photo.jpg";
  8380. * var parseFile = new Parse.File(name, file);
  8381. * parseFile.save().then(function() {
  8382. * // The file has been saved to Parse.
  8383. * }, function(error) {
  8384. * // The file either could not be read, or could not be saved to Parse.
  8385. * });
  8386. * }</pre>
  8387. * @param type {String} Optional Content-Type header to use for the file. If
  8388. * this is omitted, the content type will be inferred from the name's
  8389. * extension.
  8390. * @param metadata {Object} Optional key value pairs to be stored with file object
  8391. * @param tags {Object} Optional key value pairs to be stored with file object
  8392. */
  8393. function ParseFile(name
  8394. /*: string*/
  8395. , data
  8396. /*:: ?: FileData*/
  8397. , type
  8398. /*:: ?: string*/
  8399. , metadata
  8400. /*:: ?: Object*/
  8401. , tags
  8402. /*:: ?: Object*/
  8403. ) {
  8404. (0, _classCallCheck2.default)(this, ParseFile);
  8405. (0, _defineProperty2.default)(this, "_name", void 0);
  8406. (0, _defineProperty2.default)(this, "_url", void 0);
  8407. (0, _defineProperty2.default)(this, "_source", void 0);
  8408. (0, _defineProperty2.default)(this, "_previousSave", void 0);
  8409. (0, _defineProperty2.default)(this, "_data", void 0);
  8410. (0, _defineProperty2.default)(this, "_requestTask", void 0);
  8411. (0, _defineProperty2.default)(this, "_metadata", void 0);
  8412. (0, _defineProperty2.default)(this, "_tags", void 0);
  8413. var specifiedType = type || '';
  8414. this._name = name;
  8415. this._metadata = metadata || {};
  8416. this._tags = tags || {};
  8417. if (data !== undefined) {
  8418. if ((0, _isArray.default)(data)) {
  8419. this._data = ParseFile.encodeBase64(data);
  8420. this._source = {
  8421. format: 'base64',
  8422. base64: this._data,
  8423. type: specifiedType
  8424. };
  8425. } else if (typeof Blob !== 'undefined' && data instanceof Blob) {
  8426. this._source = {
  8427. format: 'file',
  8428. file: data,
  8429. type: specifiedType
  8430. };
  8431. } else if (data && typeof data.uri === 'string' && data.uri !== undefined) {
  8432. this._source = {
  8433. format: 'uri',
  8434. uri: data.uri,
  8435. type: specifiedType
  8436. };
  8437. } else if (data && typeof data.base64 === 'string') {
  8438. var _context, _context2, _context3;
  8439. var base64 = (0, _slice.default)(_context = data.base64.split(',')).call(_context, -1)[0];
  8440. var dataType = specifiedType || (0, _slice.default)(_context2 = (0, _slice.default)(_context3 = data.base64.split(';')).call(_context3, 0, 1)[0].split(':')).call(_context2, 1, 2)[0] || 'text/plain';
  8441. this._data = base64;
  8442. this._source = {
  8443. format: 'base64',
  8444. base64: base64,
  8445. type: dataType
  8446. };
  8447. } else {
  8448. throw new TypeError('Cannot create a Parse.File with that data.');
  8449. }
  8450. }
  8451. }
  8452. /**
  8453. * Return the data for the file, downloading it if not already present.
  8454. * Data is present if initialized with Byte Array, Base64 or Saved with Uri.
  8455. * Data is cleared if saved with File object selected with a file upload control
  8456. *
  8457. * @returns {Promise} Promise that is resolve with base64 data
  8458. */
  8459. (0, _createClass2.default)(ParseFile, [{
  8460. key: "getData",
  8461. value: function () {
  8462. var _getData = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
  8463. var _this = this;
  8464. var options, controller, result;
  8465. return _regeneratorRuntime().wrap(function (_context4) {
  8466. while (1) {
  8467. switch (_context4.prev = _context4.next) {
  8468. case 0:
  8469. if (!this._data) {
  8470. _context4.next = 2;
  8471. break;
  8472. }
  8473. return _context4.abrupt("return", this._data);
  8474. case 2:
  8475. if (this._url) {
  8476. _context4.next = 4;
  8477. break;
  8478. }
  8479. throw new Error('Cannot retrieve data for unsaved ParseFile.');
  8480. case 4:
  8481. options = {
  8482. requestTask: function (task) {
  8483. return _this._requestTask = task;
  8484. }
  8485. };
  8486. controller = _CoreManager.default.getFileController();
  8487. _context4.next = 8;
  8488. return controller.download(this._url, options);
  8489. case 8:
  8490. result = _context4.sent;
  8491. this._data = result.base64;
  8492. return _context4.abrupt("return", this._data);
  8493. case 11:
  8494. case "end":
  8495. return _context4.stop();
  8496. }
  8497. }
  8498. }, _callee, this);
  8499. }));
  8500. function getData() {
  8501. return _getData.apply(this, arguments);
  8502. }
  8503. return getData;
  8504. }()
  8505. /**
  8506. * Gets the name of the file. Before save is called, this is the filename
  8507. * given by the user. After save is called, that name gets prefixed with a
  8508. * unique identifier.
  8509. *
  8510. * @returns {string}
  8511. */
  8512. }, {
  8513. key: "name",
  8514. value: function ()
  8515. /*: string*/
  8516. {
  8517. return this._name;
  8518. }
  8519. /**
  8520. * Gets the url of the file. It is only available after you save the file or
  8521. * after you get the file from a Parse.Object.
  8522. *
  8523. * @param {object} options An object to specify url options
  8524. * @returns {string}
  8525. */
  8526. }, {
  8527. key: "url",
  8528. value: function (options
  8529. /*:: ?: { forceSecure?: boolean }*/
  8530. )
  8531. /*: ?string*/
  8532. {
  8533. options = options || {};
  8534. if (!this._url) {
  8535. return;
  8536. }
  8537. if (options.forceSecure) {
  8538. return this._url.replace(/^http:\/\//i, 'https://');
  8539. } else {
  8540. return this._url;
  8541. }
  8542. }
  8543. /**
  8544. * Gets the metadata of the file.
  8545. *
  8546. * @returns {object}
  8547. */
  8548. }, {
  8549. key: "metadata",
  8550. value: function ()
  8551. /*: Object*/
  8552. {
  8553. return this._metadata;
  8554. }
  8555. /**
  8556. * Gets the tags of the file.
  8557. *
  8558. * @returns {object}
  8559. */
  8560. }, {
  8561. key: "tags",
  8562. value: function ()
  8563. /*: Object*/
  8564. {
  8565. return this._tags;
  8566. }
  8567. /**
  8568. * Saves the file to the Parse cloud.
  8569. *
  8570. * @param {object} options
  8571. * * Valid options are:<ul>
  8572. * <li>useMasterKey: In Cloud Code and Node only, causes the Master Key to
  8573. * be used for this request.
  8574. * <li>sessionToken: A valid session token, used for making a request on
  8575. * behalf of a specific user.
  8576. * <li>progress: In Browser only, callback for upload progress. For example:
  8577. * <pre>
  8578. * let parseFile = new Parse.File(name, file);
  8579. * parseFile.save({
  8580. * progress: (progressValue, loaded, total, { type }) => {
  8581. * if (type === "upload" && progressValue !== null) {
  8582. * // Update the UI using progressValue
  8583. * }
  8584. * }
  8585. * });
  8586. * </pre>
  8587. * </ul>
  8588. * @returns {Promise} Promise that is resolved when the save finishes.
  8589. */
  8590. }, {
  8591. key: "save",
  8592. value: function (options
  8593. /*:: ?: FullOptions*/
  8594. ) {
  8595. var _this2 = this;
  8596. options = options || {};
  8597. options.requestTask = function (task) {
  8598. return _this2._requestTask = task;
  8599. };
  8600. options.metadata = this._metadata;
  8601. options.tags = this._tags;
  8602. var controller = _CoreManager.default.getFileController();
  8603. if (!this._previousSave) {
  8604. if (this._source.format === 'file') {
  8605. this._previousSave = controller.saveFile(this._name, this._source, options).then(function (res) {
  8606. _this2._name = res.name;
  8607. _this2._url = res.url;
  8608. _this2._data = null;
  8609. _this2._requestTask = null;
  8610. return _this2;
  8611. });
  8612. } else if (this._source.format === 'uri') {
  8613. this._previousSave = controller.download(this._source.uri, options).then(function (result) {
  8614. if (!(result && result.base64)) {
  8615. return {};
  8616. }
  8617. var newSource = {
  8618. format: 'base64',
  8619. base64: result.base64,
  8620. type: result.contentType
  8621. };
  8622. _this2._data = result.base64;
  8623. _this2._requestTask = null;
  8624. return controller.saveBase64(_this2._name, newSource, options);
  8625. }).then(function (res) {
  8626. _this2._name = res.name;
  8627. _this2._url = res.url;
  8628. _this2._requestTask = null;
  8629. return _this2;
  8630. });
  8631. } else {
  8632. this._previousSave = controller.saveBase64(this._name, this._source, options).then(function (res) {
  8633. _this2._name = res.name;
  8634. _this2._url = res.url;
  8635. _this2._requestTask = null;
  8636. return _this2;
  8637. });
  8638. }
  8639. }
  8640. if (this._previousSave) {
  8641. return this._previousSave;
  8642. }
  8643. }
  8644. /**
  8645. * Aborts the request if it has already been sent.
  8646. */
  8647. }, {
  8648. key: "cancel",
  8649. value: function () {
  8650. if (this._requestTask && typeof this._requestTask.abort === 'function') {
  8651. this._requestTask.abort();
  8652. }
  8653. this._requestTask = null;
  8654. }
  8655. /**
  8656. * Deletes the file from the Parse cloud.
  8657. * In Cloud Code and Node only with Master Key.
  8658. *
  8659. * @param {object} options
  8660. * * Valid options are:<ul>
  8661. * <li>useMasterKey: In Cloud Code and Node only, causes the Master Key to
  8662. * be used for this request.
  8663. * <pre>
  8664. * @returns {Promise} Promise that is resolved when the delete finishes.
  8665. */
  8666. }, {
  8667. key: "destroy",
  8668. value: function () {
  8669. var _this3 = this;
  8670. var options
  8671. /*:: ?: FullOptions*/
  8672. = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
  8673. if (!this._name) {
  8674. throw new ParseError(ParseError.FILE_DELETE_UNNAMED_ERROR, 'Cannot delete an unnamed file.');
  8675. }
  8676. var destroyOptions = {
  8677. useMasterKey: true
  8678. };
  8679. if (options.hasOwnProperty('useMasterKey')) {
  8680. destroyOptions.useMasterKey = options.useMasterKey;
  8681. }
  8682. var controller = _CoreManager.default.getFileController();
  8683. return controller.deleteFile(this._name, destroyOptions).then(function () {
  8684. _this3._data = null;
  8685. _this3._requestTask = null;
  8686. return _this3;
  8687. });
  8688. }
  8689. }, {
  8690. key: "toJSON",
  8691. value: function ()
  8692. /*: { name: ?string, url: ?string }*/
  8693. {
  8694. return {
  8695. __type: 'File',
  8696. name: this._name,
  8697. url: this._url
  8698. };
  8699. }
  8700. }, {
  8701. key: "equals",
  8702. value: function (other
  8703. /*: mixed*/
  8704. )
  8705. /*: boolean*/
  8706. {
  8707. if (this === other) {
  8708. return true;
  8709. } // Unsaved Files are never equal, since they will be saved to different URLs
  8710. return other instanceof ParseFile && this.name() === other.name() && this.url() === other.url() && typeof this.url() !== 'undefined';
  8711. }
  8712. /**
  8713. * Sets metadata to be saved with file object. Overwrites existing metadata
  8714. *
  8715. * @param {object} metadata Key value pairs to be stored with file object
  8716. */
  8717. }, {
  8718. key: "setMetadata",
  8719. value: function (metadata
  8720. /*: any*/
  8721. ) {
  8722. var _this4 = this;
  8723. if (metadata && (0, _typeof2.default)(metadata) === 'object') {
  8724. var _context5;
  8725. (0, _forEach.default)(_context5 = (0, _keys.default)(metadata)).call(_context5, function (key) {
  8726. _this4.addMetadata(key, metadata[key]);
  8727. });
  8728. }
  8729. }
  8730. /**
  8731. * Sets metadata to be saved with file object. Adds to existing metadata.
  8732. *
  8733. * @param {string} key key to store the metadata
  8734. * @param {*} value metadata
  8735. */
  8736. }, {
  8737. key: "addMetadata",
  8738. value: function (key
  8739. /*: string*/
  8740. , value
  8741. /*: any*/
  8742. ) {
  8743. if (typeof key === 'string') {
  8744. this._metadata[key] = value;
  8745. }
  8746. }
  8747. /**
  8748. * Sets tags to be saved with file object. Overwrites existing tags
  8749. *
  8750. * @param {object} tags Key value pairs to be stored with file object
  8751. */
  8752. }, {
  8753. key: "setTags",
  8754. value: function (tags
  8755. /*: any*/
  8756. ) {
  8757. var _this5 = this;
  8758. if (tags && (0, _typeof2.default)(tags) === 'object') {
  8759. var _context6;
  8760. (0, _forEach.default)(_context6 = (0, _keys.default)(tags)).call(_context6, function (key) {
  8761. _this5.addTag(key, tags[key]);
  8762. });
  8763. }
  8764. }
  8765. /**
  8766. * Sets tags to be saved with file object. Adds to existing tags.
  8767. *
  8768. * @param {string} key key to store tags
  8769. * @param {*} value tag
  8770. */
  8771. }, {
  8772. key: "addTag",
  8773. value: function (key
  8774. /*: string*/
  8775. , value
  8776. /*: string*/
  8777. ) {
  8778. if (typeof key === 'string') {
  8779. this._tags[key] = value;
  8780. }
  8781. }
  8782. }], [{
  8783. key: "fromJSON",
  8784. value: function (obj)
  8785. /*: ParseFile*/
  8786. {
  8787. if (obj.__type !== 'File') {
  8788. throw new TypeError('JSON object does not represent a ParseFile');
  8789. }
  8790. var file = new ParseFile(obj.name);
  8791. file._url = obj.url;
  8792. return file;
  8793. }
  8794. }, {
  8795. key: "encodeBase64",
  8796. value: function (bytes
  8797. /*: Array<number>*/
  8798. )
  8799. /*: string*/
  8800. {
  8801. var chunks = [];
  8802. chunks.length = Math.ceil(bytes.length / 3);
  8803. for (var i = 0; i < chunks.length; i++) {
  8804. var b1 = bytes[i * 3];
  8805. var b2 = bytes[i * 3 + 1] || 0;
  8806. var b3 = bytes[i * 3 + 2] || 0;
  8807. var has2 = i * 3 + 1 < bytes.length;
  8808. var has3 = i * 3 + 2 < bytes.length;
  8809. 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('');
  8810. }
  8811. return chunks.join('');
  8812. }
  8813. }]);
  8814. return ParseFile;
  8815. }();
  8816. var DefaultController = {
  8817. saveFile: function () {
  8818. var _saveFile = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(name
  8819. /*: string*/
  8820. , source
  8821. /*: FileSource*/
  8822. , options
  8823. /*:: ?: FullOptions*/
  8824. ) {
  8825. var base64Data, _base64Data$split, _base64Data$split2, first, second, data, newSource;
  8826. return _regeneratorRuntime().wrap(function _callee2$(_context7) {
  8827. while (1) {
  8828. switch (_context7.prev = _context7.next) {
  8829. case 0:
  8830. if (!(source.format !== 'file')) {
  8831. _context7.next = 2;
  8832. break;
  8833. }
  8834. throw new Error('saveFile can only be used with File-type sources.');
  8835. case 2:
  8836. _context7.next = 4;
  8837. return new _promise.default(function (res, rej) {
  8838. // eslint-disable-next-line no-undef
  8839. var reader = new FileReader();
  8840. reader.onload = function () {
  8841. return res(reader.result);
  8842. };
  8843. reader.onerror = function (error) {
  8844. return rej(error);
  8845. };
  8846. reader.readAsDataURL(source.file);
  8847. });
  8848. case 4:
  8849. base64Data = _context7.sent; // we only want the data after the comma
  8850. // For example: "data:application/pdf;base64,JVBERi0xLjQKJ..." we would only want "JVBERi0xLjQKJ..."
  8851. _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
  8852. // use the entire string instead
  8853. data = second ? second : first;
  8854. newSource = {
  8855. format: 'base64',
  8856. base64: data,
  8857. type: source.type || (source.file ? source.file.type : null)
  8858. };
  8859. _context7.next = 10;
  8860. return DefaultController.saveBase64(name, newSource, options);
  8861. case 10:
  8862. return _context7.abrupt("return", _context7.sent);
  8863. case 11:
  8864. case "end":
  8865. return _context7.stop();
  8866. }
  8867. }
  8868. }, _callee2);
  8869. }));
  8870. function saveFile(_x, _x2, _x3) {
  8871. return _saveFile.apply(this, arguments);
  8872. }
  8873. return saveFile;
  8874. }(),
  8875. saveBase64: function saveBase64(name
  8876. /*: string*/
  8877. , source
  8878. /*: FileSource*/
  8879. , options
  8880. /*:: ?: FullOptions*/
  8881. ) {
  8882. if (source.format !== 'base64') {
  8883. throw new Error('saveBase64 can only be used with Base64-type sources.');
  8884. }
  8885. var data
  8886. /*: { base64: any, _ContentType?: any, fileData: Object }*/
  8887. = {
  8888. base64: source.base64,
  8889. fileData: {
  8890. metadata: _objectSpread({}, options.metadata),
  8891. tags: _objectSpread({}, options.tags)
  8892. }
  8893. };
  8894. delete options.metadata;
  8895. delete options.tags;
  8896. if (source.type) {
  8897. data._ContentType = source.type;
  8898. }
  8899. var path = 'files/' + name;
  8900. return _CoreManager.default.getRESTController().request('POST', path, data, options);
  8901. },
  8902. download: function download(uri, options) {
  8903. if (XHR) {
  8904. return this.downloadAjax(uri, options);
  8905. } else {
  8906. return _promise.default.reject('Cannot make a request: No definition of XMLHttpRequest was found.');
  8907. }
  8908. },
  8909. downloadAjax: function downloadAjax(uri, options) {
  8910. return new _promise.default(function (resolve, reject) {
  8911. var xhr = new XHR();
  8912. xhr.open('GET', uri, true);
  8913. xhr.responseType = 'arraybuffer';
  8914. xhr.onerror = function (e) {
  8915. reject(e);
  8916. };
  8917. xhr.onreadystatechange = function () {
  8918. if (xhr.readyState !== xhr.DONE) {
  8919. return;
  8920. }
  8921. if (!this.response) {
  8922. return resolve({});
  8923. }
  8924. var bytes = new Uint8Array(this.response);
  8925. resolve({
  8926. base64: ParseFile.encodeBase64(bytes),
  8927. contentType: xhr.getResponseHeader('content-type')
  8928. });
  8929. };
  8930. options.requestTask(xhr);
  8931. xhr.send();
  8932. });
  8933. },
  8934. deleteFile: function deleteFile(name
  8935. /*: string*/
  8936. , options
  8937. /*:: ?: FullOptions*/
  8938. ) {
  8939. var headers = {
  8940. 'X-Parse-Application-ID': _CoreManager.default.get('APPLICATION_ID')
  8941. };
  8942. if (options.useMasterKey) {
  8943. headers['X-Parse-Master-Key'] = _CoreManager.default.get('MASTER_KEY');
  8944. }
  8945. var url = _CoreManager.default.get('SERVER_URL');
  8946. if (url[url.length - 1] !== '/') {
  8947. url += '/';
  8948. }
  8949. url += 'files/' + name;
  8950. return _CoreManager.default.getRESTController().ajax('DELETE', url, '', headers).catch(function (response) {
  8951. // TODO: return JSON object in server
  8952. if (!response || response === 'SyntaxError: Unexpected end of JSON input') {
  8953. return _promise.default.resolve();
  8954. } else {
  8955. return _CoreManager.default.getRESTController().handleError(response);
  8956. }
  8957. });
  8958. },
  8959. _setXHR: function _setXHR(xhr
  8960. /*: any*/
  8961. ) {
  8962. XHR = xhr;
  8963. },
  8964. _getXHR: function _getXHR() {
  8965. return XHR;
  8966. }
  8967. };
  8968. _CoreManager.default.setFileController(DefaultController);
  8969. var _default = ParseFile;
  8970. exports.default = _default;
  8971. exports.b64Digit = b64Digit;
  8972. },{"./CoreManager":4,"./ParseError":22,"@babel/runtime-corejs3/core-js-stable/array/is-array":56,"@babel/runtime-corejs3/core-js-stable/instance/filter":61,"@babel/runtime-corejs3/core-js-stable/instance/for-each":64,"@babel/runtime-corejs3/core-js-stable/instance/index-of":66,"@babel/runtime-corejs3/core-js-stable/instance/reverse":70,"@babel/runtime-corejs3/core-js-stable/instance/slice":71,"@babel/runtime-corejs3/core-js-stable/object/create":80,"@babel/runtime-corejs3/core-js-stable/object/define-properties":81,"@babel/runtime-corejs3/core-js-stable/object/define-property":82,"@babel/runtime-corejs3/core-js-stable/object/get-own-property-descriptor":85,"@babel/runtime-corejs3/core-js-stable/object/get-own-property-descriptors":86,"@babel/runtime-corejs3/core-js-stable/object/get-own-property-symbols":87,"@babel/runtime-corejs3/core-js-stable/object/get-prototype-of":88,"@babel/runtime-corejs3/core-js-stable/object/keys":89,"@babel/runtime-corejs3/core-js-stable/object/set-prototype-of":90,"@babel/runtime-corejs3/core-js-stable/promise":92,"@babel/runtime-corejs3/core-js-stable/symbol":97,"@babel/runtime-corejs3/helpers/asyncToGenerator":120,"@babel/runtime-corejs3/helpers/classCallCheck":121,"@babel/runtime-corejs3/helpers/createClass":123,"@babel/runtime-corejs3/helpers/defineProperty":124,"@babel/runtime-corejs3/helpers/interopRequireDefault":128,"@babel/runtime-corejs3/helpers/slicedToArray":137,"@babel/runtime-corejs3/helpers/typeof":140}],24:[function(_dereq_,module,exports){
  8973. "use strict";
  8974. var _interopRequireDefault = _dereq_("@babel/runtime-corejs3/helpers/interopRequireDefault");
  8975. var _Object$defineProperty = _dereq_("@babel/runtime-corejs3/core-js-stable/object/define-property");
  8976. _Object$defineProperty(exports, "__esModule", {
  8977. value: true
  8978. });
  8979. exports.default = void 0;
  8980. var _typeof2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/helpers/typeof"));
  8981. var _isArray = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/array/is-array"));
  8982. var _classCallCheck2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/helpers/classCallCheck"));
  8983. var _createClass2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/helpers/createClass"));
  8984. var _defineProperty2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/helpers/defineProperty"));
  8985. /**
  8986. * Copyright (c) 2015-present, Parse, LLC.
  8987. * All rights reserved.
  8988. *
  8989. * This source code is licensed under the BSD-style license found in the
  8990. * LICENSE file in the root directory of this source tree. An additional grant
  8991. * of patent rights can be found in the PATENTS file in the same directory.
  8992. *
  8993. * @flow
  8994. */
  8995. /**
  8996. * Creates a new GeoPoint with any of the following forms:<br>
  8997. * <pre>
  8998. * new GeoPoint(otherGeoPoint)
  8999. * new GeoPoint(30, 30)
  9000. * new GeoPoint([30, 30])
  9001. * new GeoPoint({latitude: 30, longitude: 30})
  9002. * new GeoPoint() // defaults to (0, 0)
  9003. * </pre>
  9004. * <p>Represents a latitude / longitude point that may be associated
  9005. * with a key in a ParseObject or used as a reference point for geo queries.
  9006. * This allows proximity-based queries on the key.</p>
  9007. *
  9008. * <p>Only one key in a class may contain a GeoPoint.</p>
  9009. *
  9010. * <p>Example:<pre>
  9011. * var point = new Parse.GeoPoint(30.0, -20.0);
  9012. * var object = new Parse.Object("PlaceObject");
  9013. * object.set("location", point);
  9014. * object.save();</pre></p>
  9015. *
  9016. * @alias Parse.GeoPoint
  9017. */
  9018. /* global navigator */
  9019. var ParseGeoPoint = /*#__PURE__*/function () {
  9020. /**
  9021. * @param {(number[] | object | number)} arg1 Either a list of coordinate pairs, an object with `latitude`, `longitude`, or the latitude or the point.
  9022. * @param {number} arg2 The longitude of the GeoPoint
  9023. */
  9024. function ParseGeoPoint(arg1
  9025. /*: Array<number> | { latitude: number, longitude: number } | number*/
  9026. , arg2
  9027. /*:: ?: number*/
  9028. ) {
  9029. (0, _classCallCheck2.default)(this, ParseGeoPoint);
  9030. (0, _defineProperty2.default)(this, "_latitude", void 0);
  9031. (0, _defineProperty2.default)(this, "_longitude", void 0);
  9032. if ((0, _isArray.default)(arg1)) {
  9033. ParseGeoPoint._validate(arg1[0], arg1[1]);
  9034. this._latitude = arg1[0];
  9035. this._longitude = arg1[1];
  9036. } else if ((0, _typeof2.default)(arg1) === 'object') {
  9037. ParseGeoPoint._validate(arg1.latitude, arg1.longitude);
  9038. this._latitude = arg1.latitude;
  9039. this._longitude = arg1.longitude;
  9040. } else if (arg1 !== undefined && arg2 !== undefined) {
  9041. ParseGeoPoint._validate(arg1, arg2);
  9042. this._latitude = arg1;
  9043. this._longitude = arg2;
  9044. } else {
  9045. this._latitude = 0;
  9046. this._longitude = 0;
  9047. }
  9048. }
  9049. /**
  9050. * North-south portion of the coordinate, in range [-90, 90].
  9051. * Throws an exception if set out of range in a modern browser.
  9052. *
  9053. * @property {number} latitude
  9054. * @returns {number}
  9055. */
  9056. (0, _createClass2.default)(ParseGeoPoint, [{
  9057. key: "latitude",
  9058. get: function ()
  9059. /*: number*/
  9060. {
  9061. return this._latitude;
  9062. },
  9063. set: function (val
  9064. /*: number*/
  9065. ) {
  9066. ParseGeoPoint._validate(val, this.longitude);
  9067. this._latitude = val;
  9068. }
  9069. /**
  9070. * East-west portion of the coordinate, in range [-180, 180].
  9071. * Throws if set out of range in a modern browser.
  9072. *
  9073. * @property {number} longitude
  9074. * @returns {number}
  9075. */
  9076. }, {
  9077. key: "longitude",
  9078. get: function ()
  9079. /*: number*/
  9080. {
  9081. return this._longitude;
  9082. },
  9083. set: function (val
  9084. /*: number*/
  9085. ) {
  9086. ParseGeoPoint._validate(this.latitude, val);
  9087. this._longitude = val;
  9088. }
  9089. /**
  9090. * Returns a JSON representation of the GeoPoint, suitable for Parse.
  9091. *
  9092. * @returns {object}
  9093. */
  9094. }, {
  9095. key: "toJSON",
  9096. value: function ()
  9097. /*: { __type: string, latitude: number, longitude: number }*/
  9098. {
  9099. ParseGeoPoint._validate(this._latitude, this._longitude);
  9100. return {
  9101. __type: 'GeoPoint',
  9102. latitude: this._latitude,
  9103. longitude: this._longitude
  9104. };
  9105. }
  9106. }, {
  9107. key: "equals",
  9108. value: function (other
  9109. /*: mixed*/
  9110. )
  9111. /*: boolean*/
  9112. {
  9113. return other instanceof ParseGeoPoint && this.latitude === other.latitude && this.longitude === other.longitude;
  9114. }
  9115. /**
  9116. * Returns the distance from this GeoPoint to another in radians.
  9117. *
  9118. * @param {Parse.GeoPoint} point the other Parse.GeoPoint.
  9119. * @returns {number}
  9120. */
  9121. }, {
  9122. key: "radiansTo",
  9123. value: function (point
  9124. /*: ParseGeoPoint*/
  9125. )
  9126. /*: number*/
  9127. {
  9128. var d2r = Math.PI / 180.0;
  9129. var lat1rad = this.latitude * d2r;
  9130. var long1rad = this.longitude * d2r;
  9131. var lat2rad = point.latitude * d2r;
  9132. var long2rad = point.longitude * d2r;
  9133. var sinDeltaLatDiv2 = Math.sin((lat1rad - lat2rad) / 2);
  9134. var sinDeltaLongDiv2 = Math.sin((long1rad - long2rad) / 2); // Square of half the straight line chord distance between both points.
  9135. var a = sinDeltaLatDiv2 * sinDeltaLatDiv2 + Math.cos(lat1rad) * Math.cos(lat2rad) * sinDeltaLongDiv2 * sinDeltaLongDiv2;
  9136. a = Math.min(1.0, a);
  9137. return 2 * Math.asin(Math.sqrt(a));
  9138. }
  9139. /**
  9140. * Returns the distance from this GeoPoint to another in kilometers.
  9141. *
  9142. * @param {Parse.GeoPoint} point the other Parse.GeoPoint.
  9143. * @returns {number}
  9144. */
  9145. }, {
  9146. key: "kilometersTo",
  9147. value: function (point
  9148. /*: ParseGeoPoint*/
  9149. )
  9150. /*: number*/
  9151. {
  9152. return this.radiansTo(point) * 6371.0;
  9153. }
  9154. /**
  9155. * Returns the distance from this GeoPoint to another in miles.
  9156. *
  9157. * @param {Parse.GeoPoint} point the other Parse.GeoPoint.
  9158. * @returns {number}
  9159. */
  9160. }, {
  9161. key: "milesTo",
  9162. value: function (point
  9163. /*: ParseGeoPoint*/
  9164. )
  9165. /*: number*/
  9166. {
  9167. return this.radiansTo(point) * 3958.8;
  9168. }
  9169. /*
  9170. * Throws an exception if the given lat-long is out of bounds.
  9171. */
  9172. }], [{
  9173. key: "_validate",
  9174. value: function (latitude
  9175. /*: number*/
  9176. , longitude
  9177. /*: number*/
  9178. ) {
  9179. if (isNaN(latitude) || isNaN(longitude) || typeof latitude !== 'number' || typeof longitude !== 'number') {
  9180. throw new TypeError('GeoPoint latitude and longitude must be valid numbers');
  9181. }
  9182. if (latitude < -90.0) {
  9183. throw new TypeError('GeoPoint latitude out of bounds: ' + latitude + ' < -90.0.');
  9184. }
  9185. if (latitude > 90.0) {
  9186. throw new TypeError('GeoPoint latitude out of bounds: ' + latitude + ' > 90.0.');
  9187. }
  9188. if (longitude < -180.0) {
  9189. throw new TypeError('GeoPoint longitude out of bounds: ' + longitude + ' < -180.0.');
  9190. }
  9191. if (longitude > 180.0) {
  9192. throw new TypeError('GeoPoint longitude out of bounds: ' + longitude + ' > 180.0.');
  9193. }
  9194. }
  9195. /**
  9196. * Creates a GeoPoint with the user's current location, if available.
  9197. *
  9198. * @static
  9199. * @returns {Parse.GeoPoint} User's current location
  9200. */
  9201. }, {
  9202. key: "current",
  9203. value: function () {
  9204. return navigator.geolocation.getCurrentPosition(function (location) {
  9205. return new ParseGeoPoint(location.coords.latitude, location.coords.longitude);
  9206. });
  9207. }
  9208. }]);
  9209. return ParseGeoPoint;
  9210. }();
  9211. var _default = ParseGeoPoint;
  9212. exports.default = _default;
  9213. },{"@babel/runtime-corejs3/core-js-stable/array/is-array":56,"@babel/runtime-corejs3/core-js-stable/object/define-property":82,"@babel/runtime-corejs3/helpers/classCallCheck":121,"@babel/runtime-corejs3/helpers/createClass":123,"@babel/runtime-corejs3/helpers/defineProperty":124,"@babel/runtime-corejs3/helpers/interopRequireDefault":128,"@babel/runtime-corejs3/helpers/typeof":140}],25:[function(_dereq_,module,exports){
  9214. "use strict";
  9215. var _interopRequireDefault = _dereq_("@babel/runtime-corejs3/helpers/interopRequireDefault");
  9216. var _Object$defineProperty = _dereq_("@babel/runtime-corejs3/core-js-stable/object/define-property");
  9217. var _Reflect$construct = _dereq_("@babel/runtime-corejs3/core-js-stable/reflect/construct");
  9218. _Object$defineProperty(exports, "__esModule", {
  9219. value: true
  9220. });
  9221. exports.default = void 0;
  9222. var _typeof2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/helpers/typeof"));
  9223. var _createClass2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/helpers/createClass"));
  9224. var _classCallCheck2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/helpers/classCallCheck"));
  9225. var _inherits2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/helpers/inherits"));
  9226. var _possibleConstructorReturn2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/helpers/possibleConstructorReturn"));
  9227. var _getPrototypeOf2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/helpers/getPrototypeOf"));
  9228. var _ParseObject2 = _interopRequireDefault(_dereq_("./ParseObject"));
  9229. function _createSuper(Derived) {
  9230. var hasNativeReflectConstruct = _isNativeReflectConstruct();
  9231. return function () {
  9232. var Super = (0, _getPrototypeOf2.default)(Derived),
  9233. result;
  9234. if (hasNativeReflectConstruct) {
  9235. var NewTarget = (0, _getPrototypeOf2.default)(this).constructor;
  9236. result = _Reflect$construct(Super, arguments, NewTarget);
  9237. } else {
  9238. result = Super.apply(this, arguments);
  9239. }
  9240. return (0, _possibleConstructorReturn2.default)(this, result);
  9241. };
  9242. }
  9243. function _isNativeReflectConstruct() {
  9244. if (typeof Reflect === "undefined" || !_Reflect$construct) return false;
  9245. if (_Reflect$construct.sham) return false;
  9246. if (typeof Proxy === "function") return true;
  9247. try {
  9248. Boolean.prototype.valueOf.call(_Reflect$construct(Boolean, [], function () {}));
  9249. return true;
  9250. } catch (e) {
  9251. return false;
  9252. }
  9253. }
  9254. var Installation = /*#__PURE__*/function (_ParseObject) {
  9255. (0, _inherits2.default)(Installation, _ParseObject);
  9256. var _super = _createSuper(Installation);
  9257. function Installation(attributes
  9258. /*: ?AttributeMap*/
  9259. ) {
  9260. var _this;
  9261. (0, _classCallCheck2.default)(this, Installation);
  9262. _this = _super.call(this, '_Installation');
  9263. if (attributes && (0, _typeof2.default)(attributes) === 'object') {
  9264. if (!_this.set(attributes || {})) {
  9265. throw new Error("Can't create an invalid Installation");
  9266. }
  9267. }
  9268. return _this;
  9269. }
  9270. return (0, _createClass2.default)(Installation);
  9271. }(_ParseObject2.default);
  9272. exports.default = Installation;
  9273. _ParseObject2.default.registerSubclass('_Installation', Installation);
  9274. },{"./ParseObject":27,"@babel/runtime-corejs3/core-js-stable/object/define-property":82,"@babel/runtime-corejs3/core-js-stable/reflect/construct":93,"@babel/runtime-corejs3/helpers/classCallCheck":121,"@babel/runtime-corejs3/helpers/createClass":123,"@babel/runtime-corejs3/helpers/getPrototypeOf":126,"@babel/runtime-corejs3/helpers/inherits":127,"@babel/runtime-corejs3/helpers/interopRequireDefault":128,"@babel/runtime-corejs3/helpers/possibleConstructorReturn":135,"@babel/runtime-corejs3/helpers/typeof":140}],26:[function(_dereq_,module,exports){
  9275. "use strict";
  9276. var _interopRequireDefault = _dereq_("@babel/runtime-corejs3/helpers/interopRequireDefault");
  9277. var _sliceInstanceProperty = _dereq_("@babel/runtime-corejs3/core-js-stable/instance/slice");
  9278. var _reverseInstanceProperty = _dereq_("@babel/runtime-corejs3/core-js-stable/instance/reverse");
  9279. var _Promise2 = _dereq_("@babel/runtime-corejs3/core-js-stable/promise");
  9280. var _Object$setPrototypeOf = _dereq_("@babel/runtime-corejs3/core-js-stable/object/set-prototype-of");
  9281. var _typeof = _dereq_("@babel/runtime-corejs3/helpers/typeof");
  9282. var _forEachInstanceProperty = _dereq_("@babel/runtime-corejs3/core-js-stable/instance/for-each");
  9283. var _Object$getPrototypeOf = _dereq_("@babel/runtime-corejs3/core-js-stable/object/get-prototype-of");
  9284. var _Object$create = _dereq_("@babel/runtime-corejs3/core-js-stable/object/create");
  9285. var _Object$defineProperty = _dereq_("@babel/runtime-corejs3/core-js-stable/object/define-property");
  9286. var _Symbol = _dereq_("@babel/runtime-corejs3/core-js-stable/symbol");
  9287. _Object$defineProperty(exports, "__esModule", {
  9288. value: true
  9289. });
  9290. exports.default = void 0;
  9291. var _indexOf = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/instance/index-of"));
  9292. var _promise = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/promise"));
  9293. var _slicedToArray2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/helpers/slicedToArray"));
  9294. var _asyncToGenerator2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/helpers/asyncToGenerator"));
  9295. var _EventEmitter = _interopRequireDefault(_dereq_("./EventEmitter"));
  9296. var _LiveQueryClient = _interopRequireDefault(_dereq_("./LiveQueryClient"));
  9297. var _CoreManager = _interopRequireDefault(_dereq_("./CoreManager"));
  9298. function _regeneratorRuntime() {
  9299. "use strict";
  9300. /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */
  9301. _regeneratorRuntime = function () {
  9302. return exports;
  9303. };
  9304. var exports = {},
  9305. Op = Object.prototype,
  9306. hasOwn = Op.hasOwnProperty,
  9307. $Symbol = "function" == typeof _Symbol ? _Symbol : {},
  9308. iteratorSymbol = $Symbol.iterator || "@@iterator",
  9309. asyncIteratorSymbol = $Symbol.asyncIterator || "@@asyncIterator",
  9310. toStringTagSymbol = $Symbol.toStringTag || "@@toStringTag";
  9311. function define(obj, key, value) {
  9312. return _Object$defineProperty(obj, key, {
  9313. value: value,
  9314. enumerable: !0,
  9315. configurable: !0,
  9316. writable: !0
  9317. }), obj[key];
  9318. }
  9319. try {
  9320. define({}, "");
  9321. } catch (err) {
  9322. define = function (obj, key, value) {
  9323. return obj[key] = value;
  9324. };
  9325. }
  9326. function wrap(innerFn, outerFn, self, tryLocsList) {
  9327. var protoGenerator = outerFn && outerFn.prototype instanceof Generator ? outerFn : Generator,
  9328. generator = _Object$create(protoGenerator.prototype),
  9329. context = new Context(tryLocsList || []);
  9330. return generator._invoke = function (innerFn, self, context) {
  9331. var state = "suspendedStart";
  9332. return function (method, arg) {
  9333. if ("executing" === state) throw new Error("Generator is already running");
  9334. if ("completed" === state) {
  9335. if ("throw" === method) throw arg;
  9336. return doneResult();
  9337. }
  9338. for (context.method = method, context.arg = arg;;) {
  9339. var delegate = context.delegate;
  9340. if (delegate) {
  9341. var delegateResult = maybeInvokeDelegate(delegate, context);
  9342. if (delegateResult) {
  9343. if (delegateResult === ContinueSentinel) continue;
  9344. return delegateResult;
  9345. }
  9346. }
  9347. if ("next" === context.method) context.sent = context._sent = context.arg;else if ("throw" === context.method) {
  9348. if ("suspendedStart" === state) throw state = "completed", context.arg;
  9349. context.dispatchException(context.arg);
  9350. } else "return" === context.method && context.abrupt("return", context.arg);
  9351. state = "executing";
  9352. var record = tryCatch(innerFn, self, context);
  9353. if ("normal" === record.type) {
  9354. if (state = context.done ? "completed" : "suspendedYield", record.arg === ContinueSentinel) continue;
  9355. return {
  9356. value: record.arg,
  9357. done: context.done
  9358. };
  9359. }
  9360. "throw" === record.type && (state = "completed", context.method = "throw", context.arg = record.arg);
  9361. }
  9362. };
  9363. }(innerFn, self, context), generator;
  9364. }
  9365. function tryCatch(fn, obj, arg) {
  9366. try {
  9367. return {
  9368. type: "normal",
  9369. arg: fn.call(obj, arg)
  9370. };
  9371. } catch (err) {
  9372. return {
  9373. type: "throw",
  9374. arg: err
  9375. };
  9376. }
  9377. }
  9378. exports.wrap = wrap;
  9379. var ContinueSentinel = {};
  9380. function Generator() {}
  9381. function GeneratorFunction() {}
  9382. function GeneratorFunctionPrototype() {}
  9383. var IteratorPrototype = {};
  9384. define(IteratorPrototype, iteratorSymbol, function () {
  9385. return this;
  9386. });
  9387. var getProto = _Object$getPrototypeOf,
  9388. NativeIteratorPrototype = getProto && getProto(getProto(values([])));
  9389. NativeIteratorPrototype && NativeIteratorPrototype !== Op && hasOwn.call(NativeIteratorPrototype, iteratorSymbol) && (IteratorPrototype = NativeIteratorPrototype);
  9390. var Gp = GeneratorFunctionPrototype.prototype = Generator.prototype = _Object$create(IteratorPrototype);
  9391. function defineIteratorMethods(prototype) {
  9392. var _context4;
  9393. _forEachInstanceProperty(_context4 = ["next", "throw", "return"]).call(_context4, function (method) {
  9394. define(prototype, method, function (arg) {
  9395. return this._invoke(method, arg);
  9396. });
  9397. });
  9398. }
  9399. function AsyncIterator(generator, PromiseImpl) {
  9400. function invoke(method, arg, resolve, reject) {
  9401. var record = tryCatch(generator[method], generator, arg);
  9402. if ("throw" !== record.type) {
  9403. var result = record.arg,
  9404. value = result.value;
  9405. return value && "object" == _typeof(value) && hasOwn.call(value, "__await") ? PromiseImpl.resolve(value.__await).then(function (value) {
  9406. invoke("next", value, resolve, reject);
  9407. }, function (err) {
  9408. invoke("throw", err, resolve, reject);
  9409. }) : PromiseImpl.resolve(value).then(function (unwrapped) {
  9410. result.value = unwrapped, resolve(result);
  9411. }, function (error) {
  9412. return invoke("throw", error, resolve, reject);
  9413. });
  9414. }
  9415. reject(record.arg);
  9416. }
  9417. var previousPromise;
  9418. this._invoke = function (method, arg) {
  9419. function callInvokeWithMethodAndArg() {
  9420. return new PromiseImpl(function (resolve, reject) {
  9421. invoke(method, arg, resolve, reject);
  9422. });
  9423. }
  9424. return previousPromise = previousPromise ? previousPromise.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg();
  9425. };
  9426. }
  9427. function maybeInvokeDelegate(delegate, context) {
  9428. var method = delegate.iterator[context.method];
  9429. if (undefined === method) {
  9430. if (context.delegate = null, "throw" === context.method) {
  9431. if (delegate.iterator.return && (context.method = "return", context.arg = undefined, maybeInvokeDelegate(delegate, context), "throw" === context.method)) return ContinueSentinel;
  9432. context.method = "throw", context.arg = new TypeError("The iterator does not provide a 'throw' method");
  9433. }
  9434. return ContinueSentinel;
  9435. }
  9436. var record = tryCatch(method, delegate.iterator, context.arg);
  9437. if ("throw" === record.type) return context.method = "throw", context.arg = record.arg, context.delegate = null, ContinueSentinel;
  9438. var info = record.arg;
  9439. return info ? info.done ? (context[delegate.resultName] = info.value, context.next = delegate.nextLoc, "return" !== context.method && (context.method = "next", context.arg = undefined), context.delegate = null, ContinueSentinel) : info : (context.method = "throw", context.arg = new TypeError("iterator result is not an object"), context.delegate = null, ContinueSentinel);
  9440. }
  9441. function pushTryEntry(locs) {
  9442. var entry = {
  9443. tryLoc: locs[0]
  9444. };
  9445. 1 in locs && (entry.catchLoc = locs[1]), 2 in locs && (entry.finallyLoc = locs[2], entry.afterLoc = locs[3]), this.tryEntries.push(entry);
  9446. }
  9447. function resetTryEntry(entry) {
  9448. var record = entry.completion || {};
  9449. record.type = "normal", delete record.arg, entry.completion = record;
  9450. }
  9451. function Context(tryLocsList) {
  9452. this.tryEntries = [{
  9453. tryLoc: "root"
  9454. }], _forEachInstanceProperty(tryLocsList).call(tryLocsList, pushTryEntry, this), this.reset(!0);
  9455. }
  9456. function values(iterable) {
  9457. if (iterable) {
  9458. var iteratorMethod = iterable[iteratorSymbol];
  9459. if (iteratorMethod) return iteratorMethod.call(iterable);
  9460. if ("function" == typeof iterable.next) return iterable;
  9461. if (!isNaN(iterable.length)) {
  9462. var i = -1,
  9463. next = function next() {
  9464. for (; ++i < iterable.length;) {
  9465. if (hasOwn.call(iterable, i)) return next.value = iterable[i], next.done = !1, next;
  9466. }
  9467. return next.value = undefined, next.done = !0, next;
  9468. };
  9469. return next.next = next;
  9470. }
  9471. }
  9472. return {
  9473. next: doneResult
  9474. };
  9475. }
  9476. function doneResult() {
  9477. return {
  9478. value: undefined,
  9479. done: !0
  9480. };
  9481. }
  9482. return GeneratorFunction.prototype = GeneratorFunctionPrototype, define(Gp, "constructor", GeneratorFunctionPrototype), define(GeneratorFunctionPrototype, "constructor", GeneratorFunction), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, toStringTagSymbol, "GeneratorFunction"), exports.isGeneratorFunction = function (genFun) {
  9483. var ctor = "function" == typeof genFun && genFun.constructor;
  9484. return !!ctor && (ctor === GeneratorFunction || "GeneratorFunction" === (ctor.displayName || ctor.name));
  9485. }, exports.mark = function (genFun) {
  9486. return _Object$setPrototypeOf ? _Object$setPrototypeOf(genFun, GeneratorFunctionPrototype) : (genFun.__proto__ = GeneratorFunctionPrototype, define(genFun, toStringTagSymbol, "GeneratorFunction")), genFun.prototype = _Object$create(Gp), genFun;
  9487. }, exports.awrap = function (arg) {
  9488. return {
  9489. __await: arg
  9490. };
  9491. }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, asyncIteratorSymbol, function () {
  9492. return this;
  9493. }), exports.AsyncIterator = AsyncIterator, exports.async = function (innerFn, outerFn, self, tryLocsList, PromiseImpl) {
  9494. void 0 === PromiseImpl && (PromiseImpl = _Promise2);
  9495. var iter = new AsyncIterator(wrap(innerFn, outerFn, self, tryLocsList), PromiseImpl);
  9496. return exports.isGeneratorFunction(outerFn) ? iter : iter.next().then(function (result) {
  9497. return result.done ? result.value : iter.next();
  9498. });
  9499. }, defineIteratorMethods(Gp), define(Gp, toStringTagSymbol, "Generator"), define(Gp, iteratorSymbol, function () {
  9500. return this;
  9501. }), define(Gp, "toString", function () {
  9502. return "[object Generator]";
  9503. }), exports.keys = function (object) {
  9504. var keys = [];
  9505. for (var key in object) {
  9506. keys.push(key);
  9507. }
  9508. return _reverseInstanceProperty(keys).call(keys), function next() {
  9509. for (; keys.length;) {
  9510. var key = keys.pop();
  9511. if (key in object) return next.value = key, next.done = !1, next;
  9512. }
  9513. return next.done = !0, next;
  9514. };
  9515. }, exports.values = values, Context.prototype = {
  9516. constructor: Context,
  9517. reset: function (skipTempReset) {
  9518. var _context5;
  9519. if (this.prev = 0, this.next = 0, this.sent = this._sent = undefined, this.done = !1, this.delegate = null, this.method = "next", this.arg = undefined, _forEachInstanceProperty(_context5 = this.tryEntries).call(_context5, resetTryEntry), !skipTempReset) for (var name in this) {
  9520. "t" === name.charAt(0) && hasOwn.call(this, name) && !isNaN(+_sliceInstanceProperty(name).call(name, 1)) && (this[name] = undefined);
  9521. }
  9522. },
  9523. stop: function () {
  9524. this.done = !0;
  9525. var rootRecord = this.tryEntries[0].completion;
  9526. if ("throw" === rootRecord.type) throw rootRecord.arg;
  9527. return this.rval;
  9528. },
  9529. dispatchException: function (exception) {
  9530. if (this.done) throw exception;
  9531. var context = this;
  9532. function handle(loc, caught) {
  9533. return record.type = "throw", record.arg = exception, context.next = loc, caught && (context.method = "next", context.arg = undefined), !!caught;
  9534. }
  9535. for (var i = this.tryEntries.length - 1; i >= 0; --i) {
  9536. var entry = this.tryEntries[i],
  9537. record = entry.completion;
  9538. if ("root" === entry.tryLoc) return handle("end");
  9539. if (entry.tryLoc <= this.prev) {
  9540. var hasCatch = hasOwn.call(entry, "catchLoc"),
  9541. hasFinally = hasOwn.call(entry, "finallyLoc");
  9542. if (hasCatch && hasFinally) {
  9543. if (this.prev < entry.catchLoc) return handle(entry.catchLoc, !0);
  9544. if (this.prev < entry.finallyLoc) return handle(entry.finallyLoc);
  9545. } else if (hasCatch) {
  9546. if (this.prev < entry.catchLoc) return handle(entry.catchLoc, !0);
  9547. } else {
  9548. if (!hasFinally) throw new Error("try statement without catch or finally");
  9549. if (this.prev < entry.finallyLoc) return handle(entry.finallyLoc);
  9550. }
  9551. }
  9552. }
  9553. },
  9554. abrupt: function (type, arg) {
  9555. for (var i = this.tryEntries.length - 1; i >= 0; --i) {
  9556. var entry = this.tryEntries[i];
  9557. if (entry.tryLoc <= this.prev && hasOwn.call(entry, "finallyLoc") && this.prev < entry.finallyLoc) {
  9558. var finallyEntry = entry;
  9559. break;
  9560. }
  9561. }
  9562. finallyEntry && ("break" === type || "continue" === type) && finallyEntry.tryLoc <= arg && arg <= finallyEntry.finallyLoc && (finallyEntry = null);
  9563. var record = finallyEntry ? finallyEntry.completion : {};
  9564. return record.type = type, record.arg = arg, finallyEntry ? (this.method = "next", this.next = finallyEntry.finallyLoc, ContinueSentinel) : this.complete(record);
  9565. },
  9566. complete: function (record, afterLoc) {
  9567. if ("throw" === record.type) throw record.arg;
  9568. return "break" === record.type || "continue" === record.type ? this.next = record.arg : "return" === record.type ? (this.rval = this.arg = record.arg, this.method = "return", this.next = "end") : "normal" === record.type && afterLoc && (this.next = afterLoc), ContinueSentinel;
  9569. },
  9570. finish: function (finallyLoc) {
  9571. for (var i = this.tryEntries.length - 1; i >= 0; --i) {
  9572. var entry = this.tryEntries[i];
  9573. if (entry.finallyLoc === finallyLoc) return this.complete(entry.completion, entry.afterLoc), resetTryEntry(entry), ContinueSentinel;
  9574. }
  9575. },
  9576. catch: function (tryLoc) {
  9577. for (var i = this.tryEntries.length - 1; i >= 0; --i) {
  9578. var entry = this.tryEntries[i];
  9579. if (entry.tryLoc === tryLoc) {
  9580. var record = entry.completion;
  9581. if ("throw" === record.type) {
  9582. var thrown = record.arg;
  9583. resetTryEntry(entry);
  9584. }
  9585. return thrown;
  9586. }
  9587. }
  9588. throw new Error("illegal catch attempt");
  9589. },
  9590. delegateYield: function (iterable, resultName, nextLoc) {
  9591. return this.delegate = {
  9592. iterator: values(iterable),
  9593. resultName: resultName,
  9594. nextLoc: nextLoc
  9595. }, "next" === this.method && (this.arg = undefined), ContinueSentinel;
  9596. }
  9597. }, exports;
  9598. }
  9599. function getLiveQueryClient()
  9600. /*: LiveQueryClient*/
  9601. {
  9602. return _CoreManager.default.getLiveQueryController().getDefaultLiveQueryClient();
  9603. }
  9604. /**
  9605. * We expose three events to help you monitor the status of the WebSocket connection:
  9606. *
  9607. * <p>Open - When we establish the WebSocket connection to the LiveQuery server, you'll get this event.
  9608. *
  9609. * <pre>
  9610. * Parse.LiveQuery.on('open', () => {
  9611. *
  9612. * });</pre></p>
  9613. *
  9614. * <p>Close - When we lose the WebSocket connection to the LiveQuery server, you'll get this event.
  9615. *
  9616. * <pre>
  9617. * Parse.LiveQuery.on('close', () => {
  9618. *
  9619. * });</pre></p>
  9620. *
  9621. * <p>Error - When some network error or LiveQuery server error happens, you'll get this event.
  9622. *
  9623. * <pre>
  9624. * Parse.LiveQuery.on('error', (error) => {
  9625. *
  9626. * });</pre></p>
  9627. *
  9628. * @class Parse.LiveQuery
  9629. * @static
  9630. */
  9631. var LiveQuery = new _EventEmitter.default();
  9632. /**
  9633. * After open is called, the LiveQuery will try to send a connect request
  9634. * to the LiveQuery server.
  9635. */
  9636. LiveQuery.open = /*#__PURE__*/(0, _asyncToGenerator2.default)( /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
  9637. var liveQueryClient;
  9638. return _regeneratorRuntime().wrap(function _callee$(_context) {
  9639. while (1) {
  9640. switch (_context.prev = _context.next) {
  9641. case 0:
  9642. _context.next = 2;
  9643. return getLiveQueryClient();
  9644. case 2:
  9645. liveQueryClient = _context.sent;
  9646. liveQueryClient.open();
  9647. case 4:
  9648. case "end":
  9649. return _context.stop();
  9650. }
  9651. }
  9652. }, _callee);
  9653. }));
  9654. /**
  9655. * When you're done using LiveQuery, you can call Parse.LiveQuery.close().
  9656. * This function will close the WebSocket connection to the LiveQuery server,
  9657. * cancel the auto reconnect, and unsubscribe all subscriptions based on it.
  9658. * If you call query.subscribe() after this, we'll create a new WebSocket
  9659. * connection to the LiveQuery server.
  9660. */
  9661. LiveQuery.close = /*#__PURE__*/(0, _asyncToGenerator2.default)( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2() {
  9662. var liveQueryClient;
  9663. return _regeneratorRuntime().wrap(function _callee2$(_context2) {
  9664. while (1) {
  9665. switch (_context2.prev = _context2.next) {
  9666. case 0:
  9667. _context2.next = 2;
  9668. return getLiveQueryClient();
  9669. case 2:
  9670. liveQueryClient = _context2.sent;
  9671. liveQueryClient.close();
  9672. case 4:
  9673. case "end":
  9674. return _context2.stop();
  9675. }
  9676. }
  9677. }, _callee2);
  9678. })); // Register a default onError callback to make sure we do not crash on error
  9679. LiveQuery.on('error', function () {});
  9680. var _default = LiveQuery;
  9681. exports.default = _default;
  9682. var defaultLiveQueryClient;
  9683. var DefaultLiveQueryController = {
  9684. setDefaultLiveQueryClient: function setDefaultLiveQueryClient(liveQueryClient
  9685. /*: LiveQueryClient*/
  9686. ) {
  9687. defaultLiveQueryClient = liveQueryClient;
  9688. },
  9689. getDefaultLiveQueryClient: function getDefaultLiveQueryClient()
  9690. /*: Promise<LiveQueryClient>*/
  9691. {
  9692. return (0, _asyncToGenerator2.default)( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3() {
  9693. var _yield$Promise$all, _yield$Promise$all2, currentUser, installationId, sessionToken, liveQueryServerURL, serverURL, protocol, host, applicationId, javascriptKey, masterKey;
  9694. return _regeneratorRuntime().wrap(function _callee3$(_context3) {
  9695. while (1) {
  9696. switch (_context3.prev = _context3.next) {
  9697. case 0:
  9698. if (!defaultLiveQueryClient) {
  9699. _context3.next = 2;
  9700. break;
  9701. }
  9702. return _context3.abrupt("return", defaultLiveQueryClient);
  9703. case 2:
  9704. _context3.next = 4;
  9705. return _promise.default.all([_CoreManager.default.getUserController().currentUserAsync(), _CoreManager.default.getInstallationController().currentInstallationId()]);
  9706. case 4:
  9707. _yield$Promise$all = _context3.sent;
  9708. _yield$Promise$all2 = (0, _slicedToArray2.default)(_yield$Promise$all, 2);
  9709. currentUser = _yield$Promise$all2[0];
  9710. installationId = _yield$Promise$all2[1];
  9711. sessionToken = currentUser ? currentUser.getSessionToken() : undefined;
  9712. liveQueryServerURL = _CoreManager.default.get('LIVEQUERY_SERVER_URL');
  9713. if (!(liveQueryServerURL && (0, _indexOf.default)(liveQueryServerURL).call(liveQueryServerURL, 'ws') !== 0)) {
  9714. _context3.next = 12;
  9715. break;
  9716. }
  9717. throw new Error('You need to set a proper Parse LiveQuery server url before using LiveQueryClient');
  9718. case 12:
  9719. // If we can not find Parse.liveQueryServerURL, we try to extract it from Parse.serverURL
  9720. if (!liveQueryServerURL) {
  9721. serverURL = _CoreManager.default.get('SERVER_URL');
  9722. protocol = (0, _indexOf.default)(serverURL).call(serverURL, 'https') === 0 ? 'wss://' : 'ws://';
  9723. host = serverURL.replace(/^https?:\/\//, '');
  9724. liveQueryServerURL = protocol + host;
  9725. _CoreManager.default.set('LIVEQUERY_SERVER_URL', liveQueryServerURL);
  9726. }
  9727. applicationId = _CoreManager.default.get('APPLICATION_ID');
  9728. javascriptKey = _CoreManager.default.get('JAVASCRIPT_KEY');
  9729. masterKey = _CoreManager.default.get('MASTER_KEY');
  9730. defaultLiveQueryClient = new _LiveQueryClient.default({
  9731. applicationId: applicationId,
  9732. serverURL: liveQueryServerURL,
  9733. javascriptKey: javascriptKey,
  9734. masterKey: masterKey,
  9735. sessionToken: sessionToken,
  9736. installationId: installationId
  9737. });
  9738. defaultLiveQueryClient.on('error', function (error) {
  9739. LiveQuery.emit('error', error);
  9740. });
  9741. defaultLiveQueryClient.on('open', function () {
  9742. LiveQuery.emit('open');
  9743. });
  9744. defaultLiveQueryClient.on('close', function () {
  9745. LiveQuery.emit('close');
  9746. });
  9747. return _context3.abrupt("return", defaultLiveQueryClient);
  9748. case 21:
  9749. case "end":
  9750. return _context3.stop();
  9751. }
  9752. }
  9753. }, _callee3);
  9754. }))();
  9755. },
  9756. _clearCachedDefaultClient: function _clearCachedDefaultClient() {
  9757. defaultLiveQueryClient = null;
  9758. }
  9759. };
  9760. _CoreManager.default.setLiveQueryController(DefaultLiveQueryController);
  9761. },{"./CoreManager":4,"./EventEmitter":6,"./LiveQueryClient":11,"@babel/runtime-corejs3/core-js-stable/instance/for-each":64,"@babel/runtime-corejs3/core-js-stable/instance/index-of":66,"@babel/runtime-corejs3/core-js-stable/instance/reverse":70,"@babel/runtime-corejs3/core-js-stable/instance/slice":71,"@babel/runtime-corejs3/core-js-stable/object/create":80,"@babel/runtime-corejs3/core-js-stable/object/define-property":82,"@babel/runtime-corejs3/core-js-stable/object/get-prototype-of":88,"@babel/runtime-corejs3/core-js-stable/object/set-prototype-of":90,"@babel/runtime-corejs3/core-js-stable/promise":92,"@babel/runtime-corejs3/core-js-stable/symbol":97,"@babel/runtime-corejs3/helpers/asyncToGenerator":120,"@babel/runtime-corejs3/helpers/interopRequireDefault":128,"@babel/runtime-corejs3/helpers/slicedToArray":137,"@babel/runtime-corejs3/helpers/typeof":140}],27:[function(_dereq_,module,exports){
  9762. "use strict";
  9763. var _interopRequireDefault = _dereq_("@babel/runtime-corejs3/helpers/interopRequireDefault");
  9764. var _WeakMap = _dereq_("@babel/runtime-corejs3/core-js-stable/weak-map");
  9765. var _Array$isArray2 = _dereq_("@babel/runtime-corejs3/core-js-stable/array/is-array");
  9766. var _getIteratorMethod = _dereq_("@babel/runtime-corejs3/core-js/get-iterator-method");
  9767. var _Array$from = _dereq_("@babel/runtime-corejs3/core-js-stable/array/from");
  9768. var _sliceInstanceProperty = _dereq_("@babel/runtime-corejs3/core-js-stable/instance/slice");
  9769. var _reverseInstanceProperty = _dereq_("@babel/runtime-corejs3/core-js-stable/instance/reverse");
  9770. var _Promise2 = _dereq_("@babel/runtime-corejs3/core-js-stable/promise");
  9771. var _Object$setPrototypeOf = _dereq_("@babel/runtime-corejs3/core-js-stable/object/set-prototype-of");
  9772. var _typeof3 = _dereq_("@babel/runtime-corejs3/helpers/typeof");
  9773. var _Object$getPrototypeOf2 = _dereq_("@babel/runtime-corejs3/core-js-stable/object/get-prototype-of");
  9774. var _Object$create2 = _dereq_("@babel/runtime-corejs3/core-js-stable/object/create");
  9775. var _Symbol = _dereq_("@babel/runtime-corejs3/core-js-stable/symbol");
  9776. var _Object$defineProperty2 = _dereq_("@babel/runtime-corejs3/core-js-stable/object/define-property");
  9777. var _Object$defineProperties = _dereq_("@babel/runtime-corejs3/core-js-stable/object/define-properties");
  9778. var _Object$getOwnPropertyDescriptors = _dereq_("@babel/runtime-corejs3/core-js-stable/object/get-own-property-descriptors");
  9779. var _forEachInstanceProperty2 = _dereq_("@babel/runtime-corejs3/core-js-stable/instance/for-each");
  9780. var _Object$getOwnPropertyDescriptor = _dereq_("@babel/runtime-corejs3/core-js-stable/object/get-own-property-descriptor");
  9781. var _filterInstanceProperty = _dereq_("@babel/runtime-corejs3/core-js-stable/instance/filter");
  9782. var _Object$getOwnPropertySymbols = _dereq_("@babel/runtime-corejs3/core-js-stable/object/get-own-property-symbols");
  9783. var _Object$keys2 = _dereq_("@babel/runtime-corejs3/core-js-stable/object/keys");
  9784. _Object$defineProperty2(exports, "__esModule", {
  9785. value: true
  9786. });
  9787. exports.default = void 0;
  9788. var _map = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/instance/map"));
  9789. var _find = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/instance/find"));
  9790. var _defineProperty2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/object/define-property"));
  9791. var _create = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/object/create"));
  9792. var _promise = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/promise"));
  9793. var _isArray = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/array/is-array"));
  9794. var _asyncToGenerator2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/helpers/asyncToGenerator"));
  9795. var _concat = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/instance/concat"));
  9796. var _getPrototypeOf = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/object/get-prototype-of"));
  9797. var _includes = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/instance/includes"));
  9798. var _stringify = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/json/stringify"));
  9799. var _forEach = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/instance/for-each"));
  9800. var _keys = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/object/keys"));
  9801. var _freeze = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/object/freeze"));
  9802. var _typeof2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/helpers/typeof"));
  9803. var _classCallCheck2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/helpers/classCallCheck"));
  9804. var _createClass2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/helpers/createClass"));
  9805. var _defineProperty3 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/helpers/defineProperty"));
  9806. var _indexOf = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/instance/index-of"));
  9807. var _CoreManager = _interopRequireDefault(_dereq_("./CoreManager"));
  9808. var _canBeSerialized = _interopRequireDefault(_dereq_("./canBeSerialized"));
  9809. var _decode = _interopRequireDefault(_dereq_("./decode"));
  9810. var _encode = _interopRequireDefault(_dereq_("./encode"));
  9811. var _escape2 = _interopRequireDefault(_dereq_("./escape"));
  9812. var _EventuallyQueue = _interopRequireDefault(_dereq_("./EventuallyQueue"));
  9813. var _ParseACL = _interopRequireDefault(_dereq_("./ParseACL"));
  9814. var _parseDate = _interopRequireDefault(_dereq_("./parseDate"));
  9815. var _ParseError = _interopRequireDefault(_dereq_("./ParseError"));
  9816. var _ParseFile = _interopRequireDefault(_dereq_("./ParseFile"));
  9817. var _promiseUtils = _dereq_("./promiseUtils");
  9818. var _LocalDatastoreUtils = _dereq_("./LocalDatastoreUtils");
  9819. var _ParseOp = _dereq_("./ParseOp");
  9820. var _ParseQuery = _interopRequireDefault(_dereq_("./ParseQuery"));
  9821. var _ParseRelation = _interopRequireDefault(_dereq_("./ParseRelation"));
  9822. var SingleInstanceStateController = _interopRequireWildcard(_dereq_("./SingleInstanceStateController"));
  9823. var _unique = _interopRequireDefault(_dereq_("./unique"));
  9824. var UniqueInstanceStateController = _interopRequireWildcard(_dereq_("./UniqueInstanceStateController"));
  9825. var _unsavedChildren = _interopRequireDefault(_dereq_("./unsavedChildren"));
  9826. function _getRequireWildcardCache(nodeInterop) {
  9827. if (typeof _WeakMap !== "function") return null;
  9828. var cacheBabelInterop = new _WeakMap();
  9829. var cacheNodeInterop = new _WeakMap();
  9830. return (_getRequireWildcardCache = function (nodeInterop) {
  9831. return nodeInterop ? cacheNodeInterop : cacheBabelInterop;
  9832. })(nodeInterop);
  9833. }
  9834. function _interopRequireWildcard(obj, nodeInterop) {
  9835. if (!nodeInterop && obj && obj.__esModule) {
  9836. return obj;
  9837. }
  9838. if (obj === null || _typeof3(obj) !== "object" && typeof obj !== "function") {
  9839. return {
  9840. default: obj
  9841. };
  9842. }
  9843. var cache = _getRequireWildcardCache(nodeInterop);
  9844. if (cache && cache.has(obj)) {
  9845. return cache.get(obj);
  9846. }
  9847. var newObj = {};
  9848. for (var key in obj) {
  9849. if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) {
  9850. var desc = _Object$defineProperty2 && _Object$getOwnPropertyDescriptor ? _Object$getOwnPropertyDescriptor(obj, key) : null;
  9851. if (desc && (desc.get || desc.set)) {
  9852. _Object$defineProperty2(newObj, key, desc);
  9853. } else {
  9854. newObj[key] = obj[key];
  9855. }
  9856. }
  9857. }
  9858. newObj.default = obj;
  9859. if (cache) {
  9860. cache.set(obj, newObj);
  9861. }
  9862. return newObj;
  9863. }
  9864. function _createForOfIteratorHelper(o, allowArrayLike) {
  9865. var it = typeof _Symbol !== "undefined" && _getIteratorMethod(o) || o["@@iterator"];
  9866. if (!it) {
  9867. if (_Array$isArray2(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") {
  9868. if (it) o = it;
  9869. var i = 0;
  9870. var F = function () {};
  9871. return {
  9872. s: F,
  9873. n: function () {
  9874. if (i >= o.length) return {
  9875. done: true
  9876. };
  9877. return {
  9878. done: false,
  9879. value: o[i++]
  9880. };
  9881. },
  9882. e: function (_e) {
  9883. throw _e;
  9884. },
  9885. f: F
  9886. };
  9887. }
  9888. throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
  9889. }
  9890. var normalCompletion = true,
  9891. didErr = false,
  9892. err;
  9893. return {
  9894. s: function () {
  9895. it = it.call(o);
  9896. },
  9897. n: function () {
  9898. var step = it.next();
  9899. normalCompletion = step.done;
  9900. return step;
  9901. },
  9902. e: function (_e2) {
  9903. didErr = true;
  9904. err = _e2;
  9905. },
  9906. f: function () {
  9907. try {
  9908. if (!normalCompletion && it.return != null) it.return();
  9909. } finally {
  9910. if (didErr) throw err;
  9911. }
  9912. }
  9913. };
  9914. }
  9915. function _unsupportedIterableToArray(o, minLen) {
  9916. var _context20;
  9917. if (!o) return;
  9918. if (typeof o === "string") return _arrayLikeToArray(o, minLen);
  9919. var n = _sliceInstanceProperty(_context20 = Object.prototype.toString.call(o)).call(_context20, 8, -1);
  9920. if (n === "Object" && o.constructor) n = o.constructor.name;
  9921. if (n === "Map" || n === "Set") return _Array$from(o);
  9922. if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen);
  9923. }
  9924. function _arrayLikeToArray(arr, len) {
  9925. if (len == null || len > arr.length) len = arr.length;
  9926. for (var i = 0, arr2 = new Array(len); i < len; i++) {
  9927. arr2[i] = arr[i];
  9928. }
  9929. return arr2;
  9930. }
  9931. function _regeneratorRuntime() {
  9932. "use strict";
  9933. /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */
  9934. _regeneratorRuntime = function () {
  9935. return exports;
  9936. };
  9937. var exports = {},
  9938. Op = Object.prototype,
  9939. hasOwn = Op.hasOwnProperty,
  9940. $Symbol = "function" == typeof _Symbol ? _Symbol : {},
  9941. iteratorSymbol = $Symbol.iterator || "@@iterator",
  9942. asyncIteratorSymbol = $Symbol.asyncIterator || "@@asyncIterator",
  9943. toStringTagSymbol = $Symbol.toStringTag || "@@toStringTag";
  9944. function define(obj, key, value) {
  9945. return _Object$defineProperty2(obj, key, {
  9946. value: value,
  9947. enumerable: !0,
  9948. configurable: !0,
  9949. writable: !0
  9950. }), obj[key];
  9951. }
  9952. try {
  9953. define({}, "");
  9954. } catch (err) {
  9955. define = function (obj, key, value) {
  9956. return obj[key] = value;
  9957. };
  9958. }
  9959. function wrap(innerFn, outerFn, self, tryLocsList) {
  9960. var protoGenerator = outerFn && outerFn.prototype instanceof Generator ? outerFn : Generator,
  9961. generator = _Object$create2(protoGenerator.prototype),
  9962. context = new Context(tryLocsList || []);
  9963. return generator._invoke = function (innerFn, self, context) {
  9964. var state = "suspendedStart";
  9965. return function (method, arg) {
  9966. if ("executing" === state) throw new Error("Generator is already running");
  9967. if ("completed" === state) {
  9968. if ("throw" === method) throw arg;
  9969. return doneResult();
  9970. }
  9971. for (context.method = method, context.arg = arg;;) {
  9972. var delegate = context.delegate;
  9973. if (delegate) {
  9974. var delegateResult = maybeInvokeDelegate(delegate, context);
  9975. if (delegateResult) {
  9976. if (delegateResult === ContinueSentinel) continue;
  9977. return delegateResult;
  9978. }
  9979. }
  9980. if ("next" === context.method) context.sent = context._sent = context.arg;else if ("throw" === context.method) {
  9981. if ("suspendedStart" === state) throw state = "completed", context.arg;
  9982. context.dispatchException(context.arg);
  9983. } else "return" === context.method && context.abrupt("return", context.arg);
  9984. state = "executing";
  9985. var record = tryCatch(innerFn, self, context);
  9986. if ("normal" === record.type) {
  9987. if (state = context.done ? "completed" : "suspendedYield", record.arg === ContinueSentinel) continue;
  9988. return {
  9989. value: record.arg,
  9990. done: context.done
  9991. };
  9992. }
  9993. "throw" === record.type && (state = "completed", context.method = "throw", context.arg = record.arg);
  9994. }
  9995. };
  9996. }(innerFn, self, context), generator;
  9997. }
  9998. function tryCatch(fn, obj, arg) {
  9999. try {
  10000. return {
  10001. type: "normal",
  10002. arg: fn.call(obj, arg)
  10003. };
  10004. } catch (err) {
  10005. return {
  10006. type: "throw",
  10007. arg: err
  10008. };
  10009. }
  10010. }
  10011. exports.wrap = wrap;
  10012. var ContinueSentinel = {};
  10013. function Generator() {}
  10014. function GeneratorFunction() {}
  10015. function GeneratorFunctionPrototype() {}
  10016. var IteratorPrototype = {};
  10017. define(IteratorPrototype, iteratorSymbol, function () {
  10018. return this;
  10019. });
  10020. var getProto = _Object$getPrototypeOf2,
  10021. NativeIteratorPrototype = getProto && getProto(getProto(values([])));
  10022. NativeIteratorPrototype && NativeIteratorPrototype !== Op && hasOwn.call(NativeIteratorPrototype, iteratorSymbol) && (IteratorPrototype = NativeIteratorPrototype);
  10023. var Gp = GeneratorFunctionPrototype.prototype = Generator.prototype = _Object$create2(IteratorPrototype);
  10024. function defineIteratorMethods(prototype) {
  10025. var _context18;
  10026. _forEachInstanceProperty2(_context18 = ["next", "throw", "return"]).call(_context18, function (method) {
  10027. define(prototype, method, function (arg) {
  10028. return this._invoke(method, arg);
  10029. });
  10030. });
  10031. }
  10032. function AsyncIterator(generator, PromiseImpl) {
  10033. function invoke(method, arg, resolve, reject) {
  10034. var record = tryCatch(generator[method], generator, arg);
  10035. if ("throw" !== record.type) {
  10036. var result = record.arg,
  10037. value = result.value;
  10038. return value && "object" == _typeof3(value) && hasOwn.call(value, "__await") ? PromiseImpl.resolve(value.__await).then(function (value) {
  10039. invoke("next", value, resolve, reject);
  10040. }, function (err) {
  10041. invoke("throw", err, resolve, reject);
  10042. }) : PromiseImpl.resolve(value).then(function (unwrapped) {
  10043. result.value = unwrapped, resolve(result);
  10044. }, function (error) {
  10045. return invoke("throw", error, resolve, reject);
  10046. });
  10047. }
  10048. reject(record.arg);
  10049. }
  10050. var previousPromise;
  10051. this._invoke = function (method, arg) {
  10052. function callInvokeWithMethodAndArg() {
  10053. return new PromiseImpl(function (resolve, reject) {
  10054. invoke(method, arg, resolve, reject);
  10055. });
  10056. }
  10057. return previousPromise = previousPromise ? previousPromise.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg();
  10058. };
  10059. }
  10060. function maybeInvokeDelegate(delegate, context) {
  10061. var method = delegate.iterator[context.method];
  10062. if (undefined === method) {
  10063. if (context.delegate = null, "throw" === context.method) {
  10064. if (delegate.iterator.return && (context.method = "return", context.arg = undefined, maybeInvokeDelegate(delegate, context), "throw" === context.method)) return ContinueSentinel;
  10065. context.method = "throw", context.arg = new TypeError("The iterator does not provide a 'throw' method");
  10066. }
  10067. return ContinueSentinel;
  10068. }
  10069. var record = tryCatch(method, delegate.iterator, context.arg);
  10070. if ("throw" === record.type) return context.method = "throw", context.arg = record.arg, context.delegate = null, ContinueSentinel;
  10071. var info = record.arg;
  10072. return info ? info.done ? (context[delegate.resultName] = info.value, context.next = delegate.nextLoc, "return" !== context.method && (context.method = "next", context.arg = undefined), context.delegate = null, ContinueSentinel) : info : (context.method = "throw", context.arg = new TypeError("iterator result is not an object"), context.delegate = null, ContinueSentinel);
  10073. }
  10074. function pushTryEntry(locs) {
  10075. var entry = {
  10076. tryLoc: locs[0]
  10077. };
  10078. 1 in locs && (entry.catchLoc = locs[1]), 2 in locs && (entry.finallyLoc = locs[2], entry.afterLoc = locs[3]), this.tryEntries.push(entry);
  10079. }
  10080. function resetTryEntry(entry) {
  10081. var record = entry.completion || {};
  10082. record.type = "normal", delete record.arg, entry.completion = record;
  10083. }
  10084. function Context(tryLocsList) {
  10085. this.tryEntries = [{
  10086. tryLoc: "root"
  10087. }], _forEachInstanceProperty2(tryLocsList).call(tryLocsList, pushTryEntry, this), this.reset(!0);
  10088. }
  10089. function values(iterable) {
  10090. if (iterable) {
  10091. var iteratorMethod = iterable[iteratorSymbol];
  10092. if (iteratorMethod) return iteratorMethod.call(iterable);
  10093. if ("function" == typeof iterable.next) return iterable;
  10094. if (!isNaN(iterable.length)) {
  10095. var i = -1,
  10096. next = function next() {
  10097. for (; ++i < iterable.length;) {
  10098. if (hasOwn.call(iterable, i)) return next.value = iterable[i], next.done = !1, next;
  10099. }
  10100. return next.value = undefined, next.done = !0, next;
  10101. };
  10102. return next.next = next;
  10103. }
  10104. }
  10105. return {
  10106. next: doneResult
  10107. };
  10108. }
  10109. function doneResult() {
  10110. return {
  10111. value: undefined,
  10112. done: !0
  10113. };
  10114. }
  10115. return GeneratorFunction.prototype = GeneratorFunctionPrototype, define(Gp, "constructor", GeneratorFunctionPrototype), define(GeneratorFunctionPrototype, "constructor", GeneratorFunction), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, toStringTagSymbol, "GeneratorFunction"), exports.isGeneratorFunction = function (genFun) {
  10116. var ctor = "function" == typeof genFun && genFun.constructor;
  10117. return !!ctor && (ctor === GeneratorFunction || "GeneratorFunction" === (ctor.displayName || ctor.name));
  10118. }, exports.mark = function (genFun) {
  10119. return _Object$setPrototypeOf ? _Object$setPrototypeOf(genFun, GeneratorFunctionPrototype) : (genFun.__proto__ = GeneratorFunctionPrototype, define(genFun, toStringTagSymbol, "GeneratorFunction")), genFun.prototype = _Object$create2(Gp), genFun;
  10120. }, exports.awrap = function (arg) {
  10121. return {
  10122. __await: arg
  10123. };
  10124. }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, asyncIteratorSymbol, function () {
  10125. return this;
  10126. }), exports.AsyncIterator = AsyncIterator, exports.async = function (innerFn, outerFn, self, tryLocsList, PromiseImpl) {
  10127. void 0 === PromiseImpl && (PromiseImpl = _Promise2);
  10128. var iter = new AsyncIterator(wrap(innerFn, outerFn, self, tryLocsList), PromiseImpl);
  10129. return exports.isGeneratorFunction(outerFn) ? iter : iter.next().then(function (result) {
  10130. return result.done ? result.value : iter.next();
  10131. });
  10132. }, defineIteratorMethods(Gp), define(Gp, toStringTagSymbol, "Generator"), define(Gp, iteratorSymbol, function () {
  10133. return this;
  10134. }), define(Gp, "toString", function () {
  10135. return "[object Generator]";
  10136. }), exports.keys = function (object) {
  10137. var keys = [];
  10138. for (var key in object) {
  10139. keys.push(key);
  10140. }
  10141. return _reverseInstanceProperty(keys).call(keys), function next() {
  10142. for (; keys.length;) {
  10143. var key = keys.pop();
  10144. if (key in object) return next.value = key, next.done = !1, next;
  10145. }
  10146. return next.done = !0, next;
  10147. };
  10148. }, exports.values = values, Context.prototype = {
  10149. constructor: Context,
  10150. reset: function (skipTempReset) {
  10151. var _context19;
  10152. if (this.prev = 0, this.next = 0, this.sent = this._sent = undefined, this.done = !1, this.delegate = null, this.method = "next", this.arg = undefined, _forEachInstanceProperty2(_context19 = this.tryEntries).call(_context19, resetTryEntry), !skipTempReset) for (var name in this) {
  10153. "t" === name.charAt(0) && hasOwn.call(this, name) && !isNaN(+_sliceInstanceProperty(name).call(name, 1)) && (this[name] = undefined);
  10154. }
  10155. },
  10156. stop: function () {
  10157. this.done = !0;
  10158. var rootRecord = this.tryEntries[0].completion;
  10159. if ("throw" === rootRecord.type) throw rootRecord.arg;
  10160. return this.rval;
  10161. },
  10162. dispatchException: function (exception) {
  10163. if (this.done) throw exception;
  10164. var context = this;
  10165. function handle(loc, caught) {
  10166. return record.type = "throw", record.arg = exception, context.next = loc, caught && (context.method = "next", context.arg = undefined), !!caught;
  10167. }
  10168. for (var i = this.tryEntries.length - 1; i >= 0; --i) {
  10169. var entry = this.tryEntries[i],
  10170. record = entry.completion;
  10171. if ("root" === entry.tryLoc) return handle("end");
  10172. if (entry.tryLoc <= this.prev) {
  10173. var hasCatch = hasOwn.call(entry, "catchLoc"),
  10174. hasFinally = hasOwn.call(entry, "finallyLoc");
  10175. if (hasCatch && hasFinally) {
  10176. if (this.prev < entry.catchLoc) return handle(entry.catchLoc, !0);
  10177. if (this.prev < entry.finallyLoc) return handle(entry.finallyLoc);
  10178. } else if (hasCatch) {
  10179. if (this.prev < entry.catchLoc) return handle(entry.catchLoc, !0);
  10180. } else {
  10181. if (!hasFinally) throw new Error("try statement without catch or finally");
  10182. if (this.prev < entry.finallyLoc) return handle(entry.finallyLoc);
  10183. }
  10184. }
  10185. }
  10186. },
  10187. abrupt: function (type, arg) {
  10188. for (var i = this.tryEntries.length - 1; i >= 0; --i) {
  10189. var entry = this.tryEntries[i];
  10190. if (entry.tryLoc <= this.prev && hasOwn.call(entry, "finallyLoc") && this.prev < entry.finallyLoc) {
  10191. var finallyEntry = entry;
  10192. break;
  10193. }
  10194. }
  10195. finallyEntry && ("break" === type || "continue" === type) && finallyEntry.tryLoc <= arg && arg <= finallyEntry.finallyLoc && (finallyEntry = null);
  10196. var record = finallyEntry ? finallyEntry.completion : {};
  10197. return record.type = type, record.arg = arg, finallyEntry ? (this.method = "next", this.next = finallyEntry.finallyLoc, ContinueSentinel) : this.complete(record);
  10198. },
  10199. complete: function (record, afterLoc) {
  10200. if ("throw" === record.type) throw record.arg;
  10201. return "break" === record.type || "continue" === record.type ? this.next = record.arg : "return" === record.type ? (this.rval = this.arg = record.arg, this.method = "return", this.next = "end") : "normal" === record.type && afterLoc && (this.next = afterLoc), ContinueSentinel;
  10202. },
  10203. finish: function (finallyLoc) {
  10204. for (var i = this.tryEntries.length - 1; i >= 0; --i) {
  10205. var entry = this.tryEntries[i];
  10206. if (entry.finallyLoc === finallyLoc) return this.complete(entry.completion, entry.afterLoc), resetTryEntry(entry), ContinueSentinel;
  10207. }
  10208. },
  10209. catch: function (tryLoc) {
  10210. for (var i = this.tryEntries.length - 1; i >= 0; --i) {
  10211. var entry = this.tryEntries[i];
  10212. if (entry.tryLoc === tryLoc) {
  10213. var record = entry.completion;
  10214. if ("throw" === record.type) {
  10215. var thrown = record.arg;
  10216. resetTryEntry(entry);
  10217. }
  10218. return thrown;
  10219. }
  10220. }
  10221. throw new Error("illegal catch attempt");
  10222. },
  10223. delegateYield: function (iterable, resultName, nextLoc) {
  10224. return this.delegate = {
  10225. iterator: values(iterable),
  10226. resultName: resultName,
  10227. nextLoc: nextLoc
  10228. }, "next" === this.method && (this.arg = undefined), ContinueSentinel;
  10229. }
  10230. }, exports;
  10231. }
  10232. function ownKeys(object, enumerableOnly) {
  10233. var keys = _Object$keys2(object);
  10234. if (_Object$getOwnPropertySymbols) {
  10235. var symbols = _Object$getOwnPropertySymbols(object);
  10236. enumerableOnly && (symbols = _filterInstanceProperty(symbols).call(symbols, function (sym) {
  10237. return _Object$getOwnPropertyDescriptor(object, sym).enumerable;
  10238. })), keys.push.apply(keys, symbols);
  10239. }
  10240. return keys;
  10241. }
  10242. function _objectSpread(target) {
  10243. for (var i = 1; i < arguments.length; i++) {
  10244. var _context16, _context17;
  10245. var source = null != arguments[i] ? arguments[i] : {};
  10246. i % 2 ? _forEachInstanceProperty2(_context16 = ownKeys(Object(source), !0)).call(_context16, function (key) {
  10247. (0, _defineProperty3.default)(target, key, source[key]);
  10248. }) : _Object$getOwnPropertyDescriptors ? _Object$defineProperties(target, _Object$getOwnPropertyDescriptors(source)) : _forEachInstanceProperty2(_context17 = ownKeys(Object(source))).call(_context17, function (key) {
  10249. _Object$defineProperty2(target, key, _Object$getOwnPropertyDescriptor(source, key));
  10250. });
  10251. }
  10252. return target;
  10253. }
  10254. var uuidv4 = _dereq_('./uuid');
  10255. /*:: export type Pointer = {
  10256. __type: string,
  10257. className: string,
  10258. objectId: string,
  10259. };*/
  10260. /*:: type SaveParams = {
  10261. method: string,
  10262. path: string,
  10263. body: AttributeMap,
  10264. };*/
  10265. /*:: export type SaveOptions = FullOptions & {
  10266. cascadeSave?: boolean,
  10267. context?: AttributeMap,
  10268. };*/
  10269. // Mapping of class names to constructors, so we can populate objects from the
  10270. // server with appropriate subclasses of ParseObject
  10271. var classMap = {}; // Global counter for generating unique Ids for non-single-instance objects
  10272. var objectCount = 0; // On web clients, objects are single-instance: any two objects with the same Id
  10273. // will have the same attributes. However, this may be dangerous default
  10274. // behavior in a server scenario
  10275. var singleInstance = !_CoreManager.default.get('IS_NODE');
  10276. if (singleInstance) {
  10277. _CoreManager.default.setObjectStateController(SingleInstanceStateController);
  10278. } else {
  10279. _CoreManager.default.setObjectStateController(UniqueInstanceStateController);
  10280. }
  10281. function getServerUrlPath() {
  10282. var serverUrl = _CoreManager.default.get('SERVER_URL');
  10283. if (serverUrl[serverUrl.length - 1] !== '/') {
  10284. serverUrl += '/';
  10285. }
  10286. var url = serverUrl.replace(/https?:\/\//, '');
  10287. return url.substr((0, _indexOf.default)(url).call(url, '/'));
  10288. }
  10289. /**
  10290. * Creates a new model with defined attributes.
  10291. *
  10292. * <p>You won't normally call this method directly. It is recommended that
  10293. * you use a subclass of <code>Parse.Object</code> instead, created by calling
  10294. * <code>extend</code>.</p>
  10295. *
  10296. * <p>However, if you don't want to use a subclass, or aren't sure which
  10297. * subclass is appropriate, you can use this form:<pre>
  10298. * var object = new Parse.Object("ClassName");
  10299. * </pre>
  10300. * That is basically equivalent to:<pre>
  10301. * var MyClass = Parse.Object.extend("ClassName");
  10302. * var object = new MyClass();
  10303. * </pre></p>
  10304. *
  10305. * @alias Parse.Object
  10306. */
  10307. var ParseObject = /*#__PURE__*/function () {
  10308. /**
  10309. * @param {string} className The class name for the object
  10310. * @param {object} attributes The initial set of data to store in the object.
  10311. * @param {object} options The options for this object instance.
  10312. */
  10313. function ParseObject(className
  10314. /*: ?string | { className: string, [attr: string]: mixed }*/
  10315. , attributes
  10316. /*:: ?: { [attr: string]: mixed }*/
  10317. , options
  10318. /*:: ?: { ignoreValidation: boolean }*/
  10319. ) {
  10320. (0, _classCallCheck2.default)(this, ParseObject);
  10321. (0, _defineProperty3.default)(this, "id", void 0);
  10322. (0, _defineProperty3.default)(this, "_localId", void 0);
  10323. (0, _defineProperty3.default)(this, "_objCount", void 0);
  10324. (0, _defineProperty3.default)(this, "className", void 0); // Enable legacy initializers
  10325. if (typeof this.initialize === 'function') {
  10326. this.initialize.apply(this, arguments);
  10327. }
  10328. var toSet = null;
  10329. this._objCount = objectCount++;
  10330. if (typeof className === 'string') {
  10331. this.className = className;
  10332. if (attributes && (0, _typeof2.default)(attributes) === 'object') {
  10333. toSet = attributes;
  10334. }
  10335. } else if (className && (0, _typeof2.default)(className) === 'object') {
  10336. this.className = className.className;
  10337. toSet = {};
  10338. for (var _attr in className) {
  10339. if (_attr !== 'className') {
  10340. toSet[_attr] = className[_attr];
  10341. }
  10342. }
  10343. if (attributes && (0, _typeof2.default)(attributes) === 'object') {
  10344. options = attributes;
  10345. }
  10346. }
  10347. if (toSet && !this.set(toSet, options)) {
  10348. throw new Error("Can't create an invalid Parse Object");
  10349. }
  10350. }
  10351. /**
  10352. * The ID of this object, unique within its class.
  10353. *
  10354. * @property {string} id
  10355. */
  10356. (0, _createClass2.default)(ParseObject, [{
  10357. key: "attributes",
  10358. get:
  10359. /** Prototype getters / setters **/
  10360. function ()
  10361. /*: AttributeMap*/
  10362. {
  10363. var stateController = _CoreManager.default.getObjectStateController();
  10364. return (0, _freeze.default)(stateController.estimateAttributes(this._getStateIdentifier()));
  10365. }
  10366. /**
  10367. * The first time this object was saved on the server.
  10368. *
  10369. * @property {Date} createdAt
  10370. * @returns {Date}
  10371. */
  10372. }, {
  10373. key: "createdAt",
  10374. get: function ()
  10375. /*: ?Date*/
  10376. {
  10377. return this._getServerData().createdAt;
  10378. }
  10379. /**
  10380. * The last time this object was updated on the server.
  10381. *
  10382. * @property {Date} updatedAt
  10383. * @returns {Date}
  10384. */
  10385. }, {
  10386. key: "updatedAt",
  10387. get: function ()
  10388. /*: ?Date*/
  10389. {
  10390. return this._getServerData().updatedAt;
  10391. }
  10392. /** Private methods **/
  10393. /**
  10394. * Returns a local or server Id used uniquely identify this object
  10395. *
  10396. * @returns {string}
  10397. */
  10398. }, {
  10399. key: "_getId",
  10400. value: function ()
  10401. /*: string*/
  10402. {
  10403. if (typeof this.id === 'string') {
  10404. return this.id;
  10405. }
  10406. if (typeof this._localId === 'string') {
  10407. return this._localId;
  10408. }
  10409. var localId = 'local' + uuidv4();
  10410. this._localId = localId;
  10411. return localId;
  10412. }
  10413. /**
  10414. * Returns a unique identifier used to pull data from the State Controller.
  10415. *
  10416. * @returns {Parse.Object|object}
  10417. */
  10418. }, {
  10419. key: "_getStateIdentifier",
  10420. value: function ()
  10421. /*: ParseObject | { id: string, className: string }*/
  10422. {
  10423. if (singleInstance) {
  10424. var id = this.id;
  10425. if (!id) {
  10426. id = this._getId();
  10427. }
  10428. return {
  10429. id: id,
  10430. className: this.className
  10431. };
  10432. } else {
  10433. return this;
  10434. }
  10435. }
  10436. }, {
  10437. key: "_getServerData",
  10438. value: function ()
  10439. /*: AttributeMap*/
  10440. {
  10441. var stateController = _CoreManager.default.getObjectStateController();
  10442. return stateController.getServerData(this._getStateIdentifier());
  10443. }
  10444. }, {
  10445. key: "_clearServerData",
  10446. value: function () {
  10447. var serverData = this._getServerData();
  10448. var unset = {};
  10449. for (var _attr2 in serverData) {
  10450. unset[_attr2] = undefined;
  10451. }
  10452. var stateController = _CoreManager.default.getObjectStateController();
  10453. stateController.setServerData(this._getStateIdentifier(), unset);
  10454. }
  10455. }, {
  10456. key: "_getPendingOps",
  10457. value: function ()
  10458. /*: Array<OpsMap>*/
  10459. {
  10460. var stateController = _CoreManager.default.getObjectStateController();
  10461. return stateController.getPendingOps(this._getStateIdentifier());
  10462. }
  10463. /**
  10464. * @param {Array<string>} [keysToClear] - if specified, only ops matching
  10465. * these fields will be cleared
  10466. */
  10467. }, {
  10468. key: "_clearPendingOps",
  10469. value: function (keysToClear
  10470. /*:: ?: Array<string>*/
  10471. ) {
  10472. var pending = this._getPendingOps();
  10473. var latest = pending[pending.length - 1];
  10474. var keys = keysToClear || (0, _keys.default)(latest);
  10475. (0, _forEach.default)(keys).call(keys, function (key) {
  10476. delete latest[key];
  10477. });
  10478. }
  10479. }, {
  10480. key: "_getDirtyObjectAttributes",
  10481. value: function ()
  10482. /*: AttributeMap*/
  10483. {
  10484. var attributes = this.attributes;
  10485. var stateController = _CoreManager.default.getObjectStateController();
  10486. var objectCache = stateController.getObjectCache(this._getStateIdentifier());
  10487. var dirty = {};
  10488. for (var _attr3 in attributes) {
  10489. var val = attributes[_attr3];
  10490. if (val && (0, _typeof2.default)(val) === 'object' && !(val instanceof ParseObject) && !(val instanceof _ParseFile.default) && !(val instanceof _ParseRelation.default)) {
  10491. // Due to the way browsers construct maps, the key order will not change
  10492. // unless the object is changed
  10493. try {
  10494. var json = (0, _encode.default)(val, false, true);
  10495. var stringified = (0, _stringify.default)(json);
  10496. if (objectCache[_attr3] !== stringified) {
  10497. dirty[_attr3] = val;
  10498. }
  10499. } catch (e) {
  10500. // Error occurred, possibly by a nested unsaved pointer in a mutable container
  10501. // No matter how it happened, it indicates a change in the attribute
  10502. dirty[_attr3] = val;
  10503. }
  10504. }
  10505. }
  10506. return dirty;
  10507. }
  10508. }, {
  10509. key: "_toFullJSON",
  10510. value: function (seen
  10511. /*:: ?: Array<any>*/
  10512. , offline
  10513. /*:: ?: boolean*/
  10514. )
  10515. /*: AttributeMap*/
  10516. {
  10517. var json
  10518. /*: { [key: string]: mixed }*/
  10519. = this.toJSON(seen, offline);
  10520. json.__type = 'Object';
  10521. json.className = this.className;
  10522. return json;
  10523. }
  10524. }, {
  10525. key: "_getSaveJSON",
  10526. value: function ()
  10527. /*: AttributeMap*/
  10528. {
  10529. var pending = this._getPendingOps();
  10530. var dirtyObjects = this._getDirtyObjectAttributes();
  10531. var json = {};
  10532. for (var attr in dirtyObjects) {
  10533. var isDotNotation = false;
  10534. for (var i = 0; i < pending.length; i += 1) {
  10535. for (var field in pending[i]) {
  10536. // Dot notation operations are handled later
  10537. if ((0, _includes.default)(field).call(field, '.')) {
  10538. var fieldName = field.split('.')[0];
  10539. if (fieldName === attr) {
  10540. isDotNotation = true;
  10541. break;
  10542. }
  10543. }
  10544. }
  10545. }
  10546. if (!isDotNotation) {
  10547. json[attr] = new _ParseOp.SetOp(dirtyObjects[attr]).toJSON();
  10548. }
  10549. }
  10550. for (attr in pending[0]) {
  10551. json[attr] = pending[0][attr].toJSON();
  10552. }
  10553. return json;
  10554. }
  10555. }, {
  10556. key: "_getSaveParams",
  10557. value: function ()
  10558. /*: SaveParams*/
  10559. {
  10560. var method = this.id ? 'PUT' : 'POST';
  10561. var body = this._getSaveJSON();
  10562. var path = 'classes/' + this.className;
  10563. if (_CoreManager.default.get('ALLOW_CUSTOM_OBJECT_ID')) {
  10564. if (!this.createdAt) {
  10565. method = 'POST';
  10566. body.objectId = this.id;
  10567. } else {
  10568. method = 'PUT';
  10569. path += '/' + this.id;
  10570. }
  10571. } else if (this.id) {
  10572. path += '/' + this.id;
  10573. } else if (this.className === '_User') {
  10574. path = 'users';
  10575. }
  10576. return {
  10577. method: method,
  10578. body: body,
  10579. path: path
  10580. };
  10581. }
  10582. }, {
  10583. key: "_finishFetch",
  10584. value: function (serverData
  10585. /*: AttributeMap*/
  10586. ) {
  10587. if (!this.id && serverData.objectId) {
  10588. this.id = serverData.objectId;
  10589. }
  10590. var stateController = _CoreManager.default.getObjectStateController();
  10591. stateController.initializeState(this._getStateIdentifier());
  10592. var decoded = {};
  10593. for (var _attr4 in serverData) {
  10594. if (_attr4 === 'ACL') {
  10595. decoded[_attr4] = new _ParseACL.default(serverData[_attr4]);
  10596. } else if (_attr4 !== 'objectId') {
  10597. decoded[_attr4] = (0, _decode.default)(serverData[_attr4]);
  10598. if (decoded[_attr4] instanceof _ParseRelation.default) {
  10599. decoded[_attr4]._ensureParentAndKey(this, _attr4);
  10600. }
  10601. }
  10602. }
  10603. if (decoded.createdAt && typeof decoded.createdAt === 'string') {
  10604. decoded.createdAt = (0, _parseDate.default)(decoded.createdAt);
  10605. }
  10606. if (decoded.updatedAt && typeof decoded.updatedAt === 'string') {
  10607. decoded.updatedAt = (0, _parseDate.default)(decoded.updatedAt);
  10608. }
  10609. if (!decoded.updatedAt && decoded.createdAt) {
  10610. decoded.updatedAt = decoded.createdAt;
  10611. }
  10612. stateController.commitServerChanges(this._getStateIdentifier(), decoded);
  10613. }
  10614. }, {
  10615. key: "_setExisted",
  10616. value: function (existed
  10617. /*: boolean*/
  10618. ) {
  10619. var stateController = _CoreManager.default.getObjectStateController();
  10620. var state = stateController.getState(this._getStateIdentifier());
  10621. if (state) {
  10622. state.existed = existed;
  10623. }
  10624. }
  10625. }, {
  10626. key: "_migrateId",
  10627. value: function (serverId
  10628. /*: string*/
  10629. ) {
  10630. if (this._localId && serverId) {
  10631. if (singleInstance) {
  10632. var stateController = _CoreManager.default.getObjectStateController();
  10633. var oldState = stateController.removeState(this._getStateIdentifier());
  10634. this.id = serverId;
  10635. delete this._localId;
  10636. if (oldState) {
  10637. stateController.initializeState(this._getStateIdentifier(), oldState);
  10638. }
  10639. } else {
  10640. this.id = serverId;
  10641. delete this._localId;
  10642. }
  10643. }
  10644. }
  10645. }, {
  10646. key: "_handleSaveResponse",
  10647. value: function (response
  10648. /*: AttributeMap*/
  10649. , status
  10650. /*: number*/
  10651. ) {
  10652. var changes = {};
  10653. var stateController = _CoreManager.default.getObjectStateController();
  10654. var pending = stateController.popPendingState(this._getStateIdentifier());
  10655. for (var attr in pending) {
  10656. if (pending[attr] instanceof _ParseOp.RelationOp) {
  10657. changes[attr] = pending[attr].applyTo(undefined, this, attr);
  10658. } else if (!(attr in response)) {
  10659. // Only SetOps and UnsetOps should not come back with results
  10660. changes[attr] = pending[attr].applyTo(undefined);
  10661. }
  10662. }
  10663. for (attr in response) {
  10664. if ((attr === 'createdAt' || attr === 'updatedAt') && typeof response[attr] === 'string') {
  10665. changes[attr] = (0, _parseDate.default)(response[attr]);
  10666. } else if (attr === 'ACL') {
  10667. changes[attr] = new _ParseACL.default(response[attr]);
  10668. } else if (attr !== 'objectId') {
  10669. var val = (0, _decode.default)(response[attr]);
  10670. if (val && (0, _getPrototypeOf.default)(val) === Object.prototype) {
  10671. changes[attr] = _objectSpread(_objectSpread({}, this.attributes[attr]), val);
  10672. } else {
  10673. changes[attr] = val;
  10674. }
  10675. if (changes[attr] instanceof _ParseOp.UnsetOp) {
  10676. changes[attr] = undefined;
  10677. }
  10678. }
  10679. }
  10680. if (changes.createdAt && !changes.updatedAt) {
  10681. changes.updatedAt = changes.createdAt;
  10682. }
  10683. this._migrateId(response.objectId);
  10684. if (status !== 201) {
  10685. this._setExisted(true);
  10686. }
  10687. stateController.commitServerChanges(this._getStateIdentifier(), changes);
  10688. }
  10689. }, {
  10690. key: "_handleSaveError",
  10691. value: function () {
  10692. var stateController = _CoreManager.default.getObjectStateController();
  10693. stateController.mergeFirstPendingState(this._getStateIdentifier());
  10694. }
  10695. }, {
  10696. key: "initialize",
  10697. value:
  10698. /** Public methods **/
  10699. function () {// NOOP
  10700. }
  10701. /**
  10702. * Returns a JSON version of the object suitable for saving to Parse.
  10703. *
  10704. * @param seen
  10705. * @param offline
  10706. * @returns {object}
  10707. */
  10708. }, {
  10709. key: "toJSON",
  10710. value: function (seen
  10711. /*: Array<any> | void*/
  10712. , offline
  10713. /*:: ?: boolean*/
  10714. )
  10715. /*: AttributeMap*/
  10716. {
  10717. var seenEntry = this.id ? this.className + ':' + this.id : this;
  10718. seen = seen || [seenEntry];
  10719. var json = {};
  10720. var attrs = this.attributes;
  10721. for (var _attr5 in attrs) {
  10722. if ((_attr5 === 'createdAt' || _attr5 === 'updatedAt') && attrs[_attr5].toJSON) {
  10723. json[_attr5] = attrs[_attr5].toJSON();
  10724. } else {
  10725. json[_attr5] = (0, _encode.default)(attrs[_attr5], false, false, seen, offline);
  10726. }
  10727. }
  10728. var pending = this._getPendingOps();
  10729. for (var _attr6 in pending[0]) {
  10730. json[_attr6] = pending[0][_attr6].toJSON(offline);
  10731. }
  10732. if (this.id) {
  10733. json.objectId = this.id;
  10734. }
  10735. return json;
  10736. }
  10737. /**
  10738. * Determines whether this ParseObject is equal to another ParseObject
  10739. *
  10740. * @param {object} other - An other object ot compare
  10741. * @returns {boolean}
  10742. */
  10743. }, {
  10744. key: "equals",
  10745. value: function (other
  10746. /*: mixed*/
  10747. )
  10748. /*: boolean*/
  10749. {
  10750. if (this === other) {
  10751. return true;
  10752. }
  10753. return other instanceof ParseObject && this.className === other.className && this.id === other.id && typeof this.id !== 'undefined';
  10754. }
  10755. /**
  10756. * Returns true if this object has been modified since its last
  10757. * save/refresh. If an attribute is specified, it returns true only if that
  10758. * particular attribute has been modified since the last save/refresh.
  10759. *
  10760. * @param {string} attr An attribute name (optional).
  10761. * @returns {boolean}
  10762. */
  10763. }, {
  10764. key: "dirty",
  10765. value: function (attr
  10766. /*:: ?: string*/
  10767. )
  10768. /*: boolean*/
  10769. {
  10770. if (!this.id) {
  10771. return true;
  10772. }
  10773. var pendingOps = this._getPendingOps();
  10774. var dirtyObjects = this._getDirtyObjectAttributes();
  10775. if (attr) {
  10776. if (dirtyObjects.hasOwnProperty(attr)) {
  10777. return true;
  10778. }
  10779. for (var i = 0; i < pendingOps.length; i++) {
  10780. if (pendingOps[i].hasOwnProperty(attr)) {
  10781. return true;
  10782. }
  10783. }
  10784. return false;
  10785. }
  10786. if ((0, _keys.default)(pendingOps[0]).length !== 0) {
  10787. return true;
  10788. }
  10789. if ((0, _keys.default)(dirtyObjects).length !== 0) {
  10790. return true;
  10791. }
  10792. return false;
  10793. }
  10794. /**
  10795. * Returns an array of keys that have been modified since last save/refresh
  10796. *
  10797. * @returns {string[]}
  10798. */
  10799. }, {
  10800. key: "dirtyKeys",
  10801. value: function ()
  10802. /*: Array<string>*/
  10803. {
  10804. var pendingOps = this._getPendingOps();
  10805. var keys = {};
  10806. for (var i = 0; i < pendingOps.length; i++) {
  10807. for (var _attr7 in pendingOps[i]) {
  10808. keys[_attr7] = true;
  10809. }
  10810. }
  10811. var dirtyObjects = this._getDirtyObjectAttributes();
  10812. for (var _attr8 in dirtyObjects) {
  10813. keys[_attr8] = true;
  10814. }
  10815. return (0, _keys.default)(keys);
  10816. }
  10817. /**
  10818. * Returns true if the object has been fetched.
  10819. *
  10820. * @returns {boolean}
  10821. */
  10822. }, {
  10823. key: "isDataAvailable",
  10824. value: function ()
  10825. /*: boolean*/
  10826. {
  10827. var serverData = this._getServerData();
  10828. return !!(0, _keys.default)(serverData).length;
  10829. }
  10830. /**
  10831. * Gets a Pointer referencing this Object.
  10832. *
  10833. * @returns {Pointer}
  10834. */
  10835. }, {
  10836. key: "toPointer",
  10837. value: function ()
  10838. /*: Pointer*/
  10839. {
  10840. if (!this.id) {
  10841. throw new Error('Cannot create a pointer to an unsaved ParseObject');
  10842. }
  10843. return {
  10844. __type: 'Pointer',
  10845. className: this.className,
  10846. objectId: this.id
  10847. };
  10848. }
  10849. /**
  10850. * Gets a Pointer referencing this Object.
  10851. *
  10852. * @returns {Pointer}
  10853. */
  10854. }, {
  10855. key: "toOfflinePointer",
  10856. value: function ()
  10857. /*: Pointer*/
  10858. {
  10859. if (!this._localId) {
  10860. throw new Error('Cannot create a offline pointer to a saved ParseObject');
  10861. }
  10862. return {
  10863. __type: 'Object',
  10864. className: this.className,
  10865. _localId: this._localId
  10866. };
  10867. }
  10868. /**
  10869. * Gets the value of an attribute.
  10870. *
  10871. * @param {string} attr The string name of an attribute.
  10872. * @returns {*}
  10873. */
  10874. }, {
  10875. key: "get",
  10876. value: function (attr
  10877. /*: string*/
  10878. )
  10879. /*: mixed*/
  10880. {
  10881. return this.attributes[attr];
  10882. }
  10883. /**
  10884. * Gets a relation on the given class for the attribute.
  10885. *
  10886. * @param {string} attr The attribute to get the relation for.
  10887. * @returns {Parse.Relation}
  10888. */
  10889. }, {
  10890. key: "relation",
  10891. value: function (attr
  10892. /*: string*/
  10893. )
  10894. /*: ParseRelation*/
  10895. {
  10896. var value = this.get(attr);
  10897. if (value) {
  10898. if (!(value instanceof _ParseRelation.default)) {
  10899. throw new Error('Called relation() on non-relation field ' + attr);
  10900. }
  10901. value._ensureParentAndKey(this, attr);
  10902. return value;
  10903. }
  10904. return new _ParseRelation.default(this, attr);
  10905. }
  10906. /**
  10907. * Gets the HTML-escaped value of an attribute.
  10908. *
  10909. * @param {string} attr The string name of an attribute.
  10910. * @returns {string}
  10911. */
  10912. }, {
  10913. key: "escape",
  10914. value: function (attr
  10915. /*: string*/
  10916. )
  10917. /*: string*/
  10918. {
  10919. var val = this.attributes[attr];
  10920. if (val == null) {
  10921. return '';
  10922. }
  10923. if (typeof val !== 'string') {
  10924. if (typeof val.toString !== 'function') {
  10925. return '';
  10926. }
  10927. val = val.toString();
  10928. }
  10929. return (0, _escape2.default)(val);
  10930. }
  10931. /**
  10932. * Returns <code>true</code> if the attribute contains a value that is not
  10933. * null or undefined.
  10934. *
  10935. * @param {string} attr The string name of the attribute.
  10936. * @returns {boolean}
  10937. */
  10938. }, {
  10939. key: "has",
  10940. value: function (attr
  10941. /*: string*/
  10942. )
  10943. /*: boolean*/
  10944. {
  10945. var attributes = this.attributes;
  10946. if (attributes.hasOwnProperty(attr)) {
  10947. return attributes[attr] != null;
  10948. }
  10949. return false;
  10950. }
  10951. /**
  10952. * Sets a hash of model attributes on the object.
  10953. *
  10954. * <p>You can call it with an object containing keys and values, with one
  10955. * key and value, or dot notation. For example:<pre>
  10956. * gameTurn.set({
  10957. * player: player1,
  10958. * diceRoll: 2
  10959. * }, {
  10960. * error: function(gameTurnAgain, error) {
  10961. * // The set failed validation.
  10962. * }
  10963. * });
  10964. *
  10965. * game.set("currentPlayer", player2, {
  10966. * error: function(gameTurnAgain, error) {
  10967. * // The set failed validation.
  10968. * }
  10969. * });
  10970. *
  10971. * game.set("finished", true);</pre></p>
  10972. *
  10973. * game.set("player.score", 10);</pre></p>
  10974. *
  10975. * @param {(string|object)} key The key to set.
  10976. * @param {(string|object)} value The value to give it.
  10977. * @param {object} options A set of options for the set.
  10978. * The only supported option is <code>error</code>.
  10979. * @returns {(ParseObject|boolean)} true if the set succeeded.
  10980. */
  10981. }, {
  10982. key: "set",
  10983. value: function (key
  10984. /*: mixed*/
  10985. , value
  10986. /*: mixed*/
  10987. , options
  10988. /*:: ?: mixed*/
  10989. )
  10990. /*: ParseObject | boolean*/
  10991. {
  10992. var changes = {};
  10993. var newOps = {};
  10994. if (key && (0, _typeof2.default)(key) === 'object') {
  10995. changes = key;
  10996. options = value;
  10997. } else if (typeof key === 'string') {
  10998. changes[key] = value;
  10999. } else {
  11000. return this;
  11001. }
  11002. options = options || {};
  11003. var readonly = [];
  11004. if (typeof this.constructor.readOnlyAttributes === 'function') {
  11005. readonly = (0, _concat.default)(readonly).call(readonly, this.constructor.readOnlyAttributes());
  11006. }
  11007. for (var k in changes) {
  11008. if (k === 'createdAt' || k === 'updatedAt') {
  11009. // This property is read-only, but for legacy reasons we silently
  11010. // ignore it
  11011. continue;
  11012. }
  11013. if ((0, _indexOf.default)(readonly).call(readonly, k) > -1) {
  11014. throw new Error('Cannot modify readonly attribute: ' + k);
  11015. }
  11016. if (options.unset) {
  11017. newOps[k] = new _ParseOp.UnsetOp();
  11018. } else if (changes[k] instanceof _ParseOp.Op) {
  11019. newOps[k] = changes[k];
  11020. } else if (changes[k] && (0, _typeof2.default)(changes[k]) === 'object' && typeof changes[k].__op === 'string') {
  11021. newOps[k] = (0, _ParseOp.opFromJSON)(changes[k]);
  11022. } else if (k === 'objectId' || k === 'id') {
  11023. if (typeof changes[k] === 'string') {
  11024. this.id = changes[k];
  11025. }
  11026. } else if (k === 'ACL' && (0, _typeof2.default)(changes[k]) === 'object' && !(changes[k] instanceof _ParseACL.default)) {
  11027. newOps[k] = new _ParseOp.SetOp(new _ParseACL.default(changes[k]));
  11028. } else if (changes[k] instanceof _ParseRelation.default) {
  11029. var relation = new _ParseRelation.default(this, k);
  11030. relation.targetClassName = changes[k].targetClassName;
  11031. newOps[k] = new _ParseOp.SetOp(relation);
  11032. } else {
  11033. newOps[k] = new _ParseOp.SetOp(changes[k]);
  11034. }
  11035. }
  11036. var currentAttributes = this.attributes; // Calculate new values
  11037. var newValues = {};
  11038. for (var _attr9 in newOps) {
  11039. if (newOps[_attr9] instanceof _ParseOp.RelationOp) {
  11040. newValues[_attr9] = newOps[_attr9].applyTo(currentAttributes[_attr9], this, _attr9);
  11041. } else if (!(newOps[_attr9] instanceof _ParseOp.UnsetOp)) {
  11042. newValues[_attr9] = newOps[_attr9].applyTo(currentAttributes[_attr9]);
  11043. }
  11044. } // Validate changes
  11045. if (!options.ignoreValidation) {
  11046. var validation = this.validate(newValues);
  11047. if (validation) {
  11048. if (typeof options.error === 'function') {
  11049. options.error(this, validation);
  11050. }
  11051. return false;
  11052. }
  11053. } // Consolidate Ops
  11054. var pendingOps = this._getPendingOps();
  11055. var last = pendingOps.length - 1;
  11056. var stateController = _CoreManager.default.getObjectStateController();
  11057. for (var _attr10 in newOps) {
  11058. var nextOp = newOps[_attr10].mergeWith(pendingOps[last][_attr10]);
  11059. stateController.setPendingOp(this._getStateIdentifier(), _attr10, nextOp);
  11060. }
  11061. return this;
  11062. }
  11063. /**
  11064. * Remove an attribute from the model. This is a noop if the attribute doesn't
  11065. * exist.
  11066. *
  11067. * @param {string} attr The string name of an attribute.
  11068. * @param options
  11069. * @returns {(ParseObject | boolean)}
  11070. */
  11071. }, {
  11072. key: "unset",
  11073. value: function (attr
  11074. /*: string*/
  11075. , options
  11076. /*:: ?: { [opt: string]: mixed }*/
  11077. )
  11078. /*: ParseObject | boolean*/
  11079. {
  11080. options = options || {};
  11081. options.unset = true;
  11082. return this.set(attr, null, options);
  11083. }
  11084. /**
  11085. * Atomically increments the value of the given attribute the next time the
  11086. * object is saved. If no amount is specified, 1 is used by default.
  11087. *
  11088. * @param attr {String} The key.
  11089. * @param amount {Number} The amount to increment by (optional).
  11090. * @returns {(ParseObject|boolean)}
  11091. */
  11092. }, {
  11093. key: "increment",
  11094. value: function (attr
  11095. /*: string*/
  11096. , amount
  11097. /*:: ?: number*/
  11098. )
  11099. /*: ParseObject | boolean*/
  11100. {
  11101. if (typeof amount === 'undefined') {
  11102. amount = 1;
  11103. }
  11104. if (typeof amount !== 'number') {
  11105. throw new Error('Cannot increment by a non-numeric amount.');
  11106. }
  11107. return this.set(attr, new _ParseOp.IncrementOp(amount));
  11108. }
  11109. /**
  11110. * Atomically decrements the value of the given attribute the next time the
  11111. * object is saved. If no amount is specified, 1 is used by default.
  11112. *
  11113. * @param attr {String} The key.
  11114. * @param amount {Number} The amount to decrement by (optional).
  11115. * @returns {(ParseObject | boolean)}
  11116. */
  11117. }, {
  11118. key: "decrement",
  11119. value: function (attr
  11120. /*: string*/
  11121. , amount
  11122. /*:: ?: number*/
  11123. )
  11124. /*: ParseObject | boolean*/
  11125. {
  11126. if (typeof amount === 'undefined') {
  11127. amount = 1;
  11128. }
  11129. if (typeof amount !== 'number') {
  11130. throw new Error('Cannot decrement by a non-numeric amount.');
  11131. }
  11132. return this.set(attr, new _ParseOp.IncrementOp(amount * -1));
  11133. }
  11134. /**
  11135. * Atomically add an object to the end of the array associated with a given
  11136. * key.
  11137. *
  11138. * @param attr {String} The key.
  11139. * @param item {} The item to add.
  11140. * @returns {(ParseObject | boolean)}
  11141. */
  11142. }, {
  11143. key: "add",
  11144. value: function (attr
  11145. /*: string*/
  11146. , item
  11147. /*: mixed*/
  11148. )
  11149. /*: ParseObject | boolean*/
  11150. {
  11151. return this.set(attr, new _ParseOp.AddOp([item]));
  11152. }
  11153. /**
  11154. * Atomically add the objects to the end of the array associated with a given
  11155. * key.
  11156. *
  11157. * @param attr {String} The key.
  11158. * @param items {Object[]} The items to add.
  11159. * @returns {(ParseObject | boolean)}
  11160. */
  11161. }, {
  11162. key: "addAll",
  11163. value: function (attr
  11164. /*: string*/
  11165. , items
  11166. /*: Array<mixed>*/
  11167. )
  11168. /*: ParseObject | boolean*/
  11169. {
  11170. return this.set(attr, new _ParseOp.AddOp(items));
  11171. }
  11172. /**
  11173. * Atomically add an object to the array associated with a given key, only
  11174. * if it is not already present in the array. The position of the insert is
  11175. * not guaranteed.
  11176. *
  11177. * @param attr {String} The key.
  11178. * @param item {} The object to add.
  11179. * @returns {(ParseObject | boolean)}
  11180. */
  11181. }, {
  11182. key: "addUnique",
  11183. value: function (attr
  11184. /*: string*/
  11185. , item
  11186. /*: mixed*/
  11187. )
  11188. /*: ParseObject | boolean*/
  11189. {
  11190. return this.set(attr, new _ParseOp.AddUniqueOp([item]));
  11191. }
  11192. /**
  11193. * Atomically add the objects to the array associated with a given key, only
  11194. * if it is not already present in the array. The position of the insert is
  11195. * not guaranteed.
  11196. *
  11197. * @param attr {String} The key.
  11198. * @param items {Object[]} The objects to add.
  11199. * @returns {(ParseObject | boolean)}
  11200. */
  11201. }, {
  11202. key: "addAllUnique",
  11203. value: function (attr
  11204. /*: string*/
  11205. , items
  11206. /*: Array<mixed>*/
  11207. )
  11208. /*: ParseObject | boolean*/
  11209. {
  11210. return this.set(attr, new _ParseOp.AddUniqueOp(items));
  11211. }
  11212. /**
  11213. * Atomically remove all instances of an object from the array associated
  11214. * with a given key.
  11215. *
  11216. * @param attr {String} The key.
  11217. * @param item {} The object to remove.
  11218. * @returns {(ParseObject | boolean)}
  11219. */
  11220. }, {
  11221. key: "remove",
  11222. value: function (attr
  11223. /*: string*/
  11224. , item
  11225. /*: mixed*/
  11226. )
  11227. /*: ParseObject | boolean*/
  11228. {
  11229. return this.set(attr, new _ParseOp.RemoveOp([item]));
  11230. }
  11231. /**
  11232. * Atomically remove all instances of the objects from the array associated
  11233. * with a given key.
  11234. *
  11235. * @param attr {String} The key.
  11236. * @param items {Object[]} The object to remove.
  11237. * @returns {(ParseObject | boolean)}
  11238. */
  11239. }, {
  11240. key: "removeAll",
  11241. value: function (attr
  11242. /*: string*/
  11243. , items
  11244. /*: Array<mixed>*/
  11245. )
  11246. /*: ParseObject | boolean*/
  11247. {
  11248. return this.set(attr, new _ParseOp.RemoveOp(items));
  11249. }
  11250. /**
  11251. * Returns an instance of a subclass of Parse.Op describing what kind of
  11252. * modification has been performed on this field since the last time it was
  11253. * saved. For example, after calling object.increment("x"), calling
  11254. * object.op("x") would return an instance of Parse.Op.Increment.
  11255. *
  11256. * @param attr {String} The key.
  11257. * @returns {Parse.Op} The operation, or undefined if none.
  11258. */
  11259. }, {
  11260. key: "op",
  11261. value: function (attr
  11262. /*: string*/
  11263. )
  11264. /*: ?Op*/
  11265. {
  11266. var pending = this._getPendingOps();
  11267. for (var i = pending.length; i--;) {
  11268. if (pending[i][attr]) {
  11269. return pending[i][attr];
  11270. }
  11271. }
  11272. }
  11273. /**
  11274. * Creates a new model with identical attributes to this one.
  11275. *
  11276. * @returns {Parse.Object}
  11277. */
  11278. }, {
  11279. key: "clone",
  11280. value: function clone()
  11281. /*: any*/
  11282. {
  11283. var clone = new this.constructor(this.className);
  11284. var attributes = this.attributes;
  11285. if (typeof this.constructor.readOnlyAttributes === 'function') {
  11286. var readonly = this.constructor.readOnlyAttributes() || []; // Attributes are frozen, so we have to rebuild an object,
  11287. // rather than delete readonly keys
  11288. var copy = {};
  11289. for (var a in attributes) {
  11290. if ((0, _indexOf.default)(readonly).call(readonly, a) < 0) {
  11291. copy[a] = attributes[a];
  11292. }
  11293. }
  11294. attributes = copy;
  11295. }
  11296. if (clone.set) {
  11297. clone.set(attributes);
  11298. }
  11299. return clone;
  11300. }
  11301. /**
  11302. * Creates a new instance of this object. Not to be confused with clone()
  11303. *
  11304. * @returns {Parse.Object}
  11305. */
  11306. }, {
  11307. key: "newInstance",
  11308. value: function ()
  11309. /*: any*/
  11310. {
  11311. var clone = new this.constructor(this.className);
  11312. clone.id = this.id;
  11313. if (singleInstance) {
  11314. // Just return an object with the right id
  11315. return clone;
  11316. }
  11317. var stateController = _CoreManager.default.getObjectStateController();
  11318. if (stateController) {
  11319. stateController.duplicateState(this._getStateIdentifier(), clone._getStateIdentifier());
  11320. }
  11321. return clone;
  11322. }
  11323. /**
  11324. * Returns true if this object has never been saved to Parse.
  11325. *
  11326. * @returns {boolean}
  11327. */
  11328. }, {
  11329. key: "isNew",
  11330. value: function ()
  11331. /*: boolean*/
  11332. {
  11333. return !this.id;
  11334. }
  11335. /**
  11336. * Returns true if this object was created by the Parse server when the
  11337. * object might have already been there (e.g. in the case of a Facebook
  11338. * login)
  11339. *
  11340. * @returns {boolean}
  11341. */
  11342. }, {
  11343. key: "existed",
  11344. value: function ()
  11345. /*: boolean*/
  11346. {
  11347. if (!this.id) {
  11348. return false;
  11349. }
  11350. var stateController = _CoreManager.default.getObjectStateController();
  11351. var state = stateController.getState(this._getStateIdentifier());
  11352. if (state) {
  11353. return state.existed;
  11354. }
  11355. return false;
  11356. }
  11357. /**
  11358. * Returns true if this object exists on the Server
  11359. *
  11360. * @param {object} options
  11361. * Valid options are:<ul>
  11362. * <li>useMasterKey: In Cloud Code and Node only, causes the Master Key to
  11363. * be used for this request.
  11364. * <li>sessionToken: A valid session token, used for making a request on
  11365. * behalf of a specific user.
  11366. * </ul>
  11367. * @returns {Promise<boolean>} A boolean promise that is fulfilled if object exists.
  11368. */
  11369. }, {
  11370. key: "exists",
  11371. value: function () {
  11372. var _exists = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(options
  11373. /*:: ?: RequestOptions*/
  11374. ) {
  11375. var query;
  11376. return _regeneratorRuntime().wrap(function _callee$(_context) {
  11377. while (1) {
  11378. switch (_context.prev = _context.next) {
  11379. case 0:
  11380. if (this.id) {
  11381. _context.next = 2;
  11382. break;
  11383. }
  11384. return _context.abrupt("return", false);
  11385. case 2:
  11386. _context.prev = 2;
  11387. query = new _ParseQuery.default(this.className);
  11388. _context.next = 6;
  11389. return query.get(this.id, options);
  11390. case 6:
  11391. return _context.abrupt("return", true);
  11392. case 9:
  11393. _context.prev = 9;
  11394. _context.t0 = _context["catch"](2);
  11395. if (!(_context.t0.code === _ParseError.default.OBJECT_NOT_FOUND)) {
  11396. _context.next = 13;
  11397. break;
  11398. }
  11399. return _context.abrupt("return", false);
  11400. case 13:
  11401. throw _context.t0;
  11402. case 14:
  11403. case "end":
  11404. return _context.stop();
  11405. }
  11406. }
  11407. }, _callee, this, [[2, 9]]);
  11408. }));
  11409. function exists(_x) {
  11410. return _exists.apply(this, arguments);
  11411. }
  11412. return exists;
  11413. }()
  11414. /**
  11415. * Checks if the model is currently in a valid state.
  11416. *
  11417. * @returns {boolean}
  11418. */
  11419. }, {
  11420. key: "isValid",
  11421. value: function isValid()
  11422. /*: boolean*/
  11423. {
  11424. return !this.validate(this.attributes);
  11425. }
  11426. /**
  11427. * You should not call this function directly unless you subclass
  11428. * <code>Parse.Object</code>, in which case you can override this method
  11429. * to provide additional validation on <code>set</code> and
  11430. * <code>save</code>. Your implementation should return
  11431. *
  11432. * @param {object} attrs The current data to validate.
  11433. * @returns {Parse.Error|boolean} False if the data is valid. An error object otherwise.
  11434. * @see Parse.Object#set
  11435. */
  11436. }, {
  11437. key: "validate",
  11438. value: function validate(attrs
  11439. /*: AttributeMap*/
  11440. )
  11441. /*: ParseError | boolean*/
  11442. {
  11443. if (attrs.hasOwnProperty('ACL') && !(attrs.ACL instanceof _ParseACL.default)) {
  11444. return new _ParseError.default(_ParseError.default.OTHER_CAUSE, 'ACL must be a Parse ACL.');
  11445. }
  11446. for (var _key in attrs) {
  11447. if (!/^[A-Za-z][0-9A-Za-z_.]*$/.test(_key)) {
  11448. return new _ParseError.default(_ParseError.default.INVALID_KEY_NAME);
  11449. }
  11450. }
  11451. return false;
  11452. }
  11453. /**
  11454. * Returns the ACL for this object.
  11455. *
  11456. * @returns {Parse.ACL} An instance of Parse.ACL.
  11457. * @see Parse.Object#get
  11458. */
  11459. }, {
  11460. key: "getACL",
  11461. value: function getACL()
  11462. /*: ?ParseACL*/
  11463. {
  11464. var acl = this.get('ACL');
  11465. if (acl instanceof _ParseACL.default) {
  11466. return acl;
  11467. }
  11468. return null;
  11469. }
  11470. /**
  11471. * Sets the ACL to be used for this object.
  11472. *
  11473. * @param {Parse.ACL} acl An instance of Parse.ACL.
  11474. * @param {object} options
  11475. * @returns {(ParseObject | boolean)} Whether the set passed validation.
  11476. * @see Parse.Object#set
  11477. */
  11478. }, {
  11479. key: "setACL",
  11480. value: function setACL(acl
  11481. /*: ParseACL*/
  11482. , options
  11483. /*:: ?: mixed*/
  11484. )
  11485. /*: ParseObject | boolean*/
  11486. {
  11487. return this.set('ACL', acl, options);
  11488. }
  11489. /**
  11490. * Clears any (or specific) changes to this object made since the last call to save()
  11491. *
  11492. * @param {string} [keys] - specify which fields to revert
  11493. */
  11494. }, {
  11495. key: "revert",
  11496. value: function revert()
  11497. /*: void*/
  11498. {
  11499. var keysToRevert;
  11500. for (var _len = arguments.length, keys = new Array(_len), _key2 = 0; _key2 < _len; _key2++) {
  11501. keys[_key2] = arguments[_key2];
  11502. }
  11503. if (keys.length) {
  11504. keysToRevert = [];
  11505. var _iterator = _createForOfIteratorHelper(keys),
  11506. _step;
  11507. try {
  11508. for (_iterator.s(); !(_step = _iterator.n()).done;) {
  11509. var _key3 = _step.value;
  11510. if (typeof _key3 === 'string') {
  11511. keysToRevert.push(_key3);
  11512. } else {
  11513. throw new Error('Parse.Object#revert expects either no, or a list of string, arguments.');
  11514. }
  11515. }
  11516. } catch (err) {
  11517. _iterator.e(err);
  11518. } finally {
  11519. _iterator.f();
  11520. }
  11521. }
  11522. this._clearPendingOps(keysToRevert);
  11523. }
  11524. /**
  11525. * Clears all attributes on a model
  11526. *
  11527. * @returns {(ParseObject | boolean)}
  11528. */
  11529. }, {
  11530. key: "clear",
  11531. value: function clear()
  11532. /*: ParseObject | boolean*/
  11533. {
  11534. var attributes = this.attributes;
  11535. var erasable = {};
  11536. var readonly = ['createdAt', 'updatedAt'];
  11537. if (typeof this.constructor.readOnlyAttributes === 'function') {
  11538. readonly = (0, _concat.default)(readonly).call(readonly, this.constructor.readOnlyAttributes());
  11539. }
  11540. for (var _attr11 in attributes) {
  11541. if ((0, _indexOf.default)(readonly).call(readonly, _attr11) < 0) {
  11542. erasable[_attr11] = true;
  11543. }
  11544. }
  11545. return this.set(erasable, {
  11546. unset: true
  11547. });
  11548. }
  11549. /**
  11550. * Fetch the model from the server. If the server's representation of the
  11551. * model differs from its current attributes, they will be overriden.
  11552. *
  11553. * @param {object} options
  11554. * Valid options are:<ul>
  11555. * <li>useMasterKey: In Cloud Code and Node only, causes the Master Key to
  11556. * be used for this request.
  11557. * <li>sessionToken: A valid session token, used for making a request on
  11558. * behalf of a specific user.
  11559. * <li>include: The name(s) of the key(s) to include. Can be a string, an array of strings,
  11560. * or an array of array of strings.
  11561. * <li>context: A dictionary that is accessible in Cloud Code `beforeFind` trigger.
  11562. * </ul>
  11563. * @returns {Promise} A promise that is fulfilled when the fetch
  11564. * completes.
  11565. */
  11566. }, {
  11567. key: "fetch",
  11568. value: function fetch(options
  11569. /*: RequestOptions*/
  11570. )
  11571. /*: Promise*/
  11572. {
  11573. options = options || {};
  11574. var fetchOptions = {};
  11575. if (options.hasOwnProperty('useMasterKey')) {
  11576. fetchOptions.useMasterKey = options.useMasterKey;
  11577. }
  11578. if (options.hasOwnProperty('sessionToken')) {
  11579. fetchOptions.sessionToken = options.sessionToken;
  11580. }
  11581. if (options.hasOwnProperty('context') && (0, _typeof2.default)(options.context) === 'object') {
  11582. fetchOptions.context = options.context;
  11583. }
  11584. if (options.hasOwnProperty('include')) {
  11585. fetchOptions.include = [];
  11586. if ((0, _isArray.default)(options.include)) {
  11587. var _context2;
  11588. (0, _forEach.default)(_context2 = options.include).call(_context2, function (key) {
  11589. if ((0, _isArray.default)(key)) {
  11590. var _context3;
  11591. fetchOptions.include = (0, _concat.default)(_context3 = fetchOptions.include).call(_context3, key);
  11592. } else {
  11593. fetchOptions.include.push(key);
  11594. }
  11595. });
  11596. } else {
  11597. fetchOptions.include.push(options.include);
  11598. }
  11599. }
  11600. var controller = _CoreManager.default.getObjectController();
  11601. return controller.fetch(this, true, fetchOptions);
  11602. }
  11603. /**
  11604. * Fetch the model from the server. If the server's representation of the
  11605. * model differs from its current attributes, they will be overriden.
  11606. *
  11607. * Includes nested Parse.Objects for the provided key. You can use dot
  11608. * notation to specify which fields in the included object are also fetched.
  11609. *
  11610. * @param {string | Array<string | Array<string>>} keys The name(s) of the key(s) to include.
  11611. * @param {object} options
  11612. * Valid options are:<ul>
  11613. * <li>useMasterKey: In Cloud Code and Node only, causes the Master Key to
  11614. * be used for this request.
  11615. * <li>sessionToken: A valid session token, used for making a request on
  11616. * behalf of a specific user.
  11617. * </ul>
  11618. * @returns {Promise} A promise that is fulfilled when the fetch
  11619. * completes.
  11620. */
  11621. }, {
  11622. key: "fetchWithInclude",
  11623. value: function fetchWithInclude(keys
  11624. /*: String | Array<string | Array<string>>*/
  11625. , options
  11626. /*: RequestOptions*/
  11627. )
  11628. /*: Promise*/
  11629. {
  11630. options = options || {};
  11631. options.include = keys;
  11632. return this.fetch(options);
  11633. }
  11634. /**
  11635. * Saves this object to the server at some unspecified time in the future,
  11636. * even if Parse is currently inaccessible.
  11637. *
  11638. * Use this when you may not have a solid network connection, and don't need to know when the save completes.
  11639. * If there is some problem with the object such that it can't be saved, it will be silently discarded.
  11640. *
  11641. * Objects saved with this method will be stored locally in an on-disk cache until they can be delivered to Parse.
  11642. * They will be sent immediately if possible. Otherwise, they will be sent the next time a network connection is
  11643. * available. Objects saved this way will persist even after the app is closed, in which case they will be sent the
  11644. * next time the app is opened.
  11645. *
  11646. * @param {object} [options]
  11647. * Used to pass option parameters to method if arg1 and arg2 were both passed as strings.
  11648. * Valid options are:
  11649. * <ul>
  11650. * <li>sessionToken: A valid session token, used for making a request on
  11651. * behalf of a specific user.
  11652. * <li>cascadeSave: If `false`, nested objects will not be saved (default is `true`).
  11653. * <li>context: A dictionary that is accessible in Cloud Code `beforeSave` and `afterSave` triggers.
  11654. * </ul>
  11655. * @returns {Promise} A promise that is fulfilled when the save
  11656. * completes.
  11657. */
  11658. }, {
  11659. key: "saveEventually",
  11660. value: function () {
  11661. var _saveEventually = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(options
  11662. /*: SaveOptions*/
  11663. ) {
  11664. return _regeneratorRuntime().wrap(function _callee2$(_context4) {
  11665. while (1) {
  11666. switch (_context4.prev = _context4.next) {
  11667. case 0:
  11668. _context4.prev = 0;
  11669. _context4.next = 3;
  11670. return this.save(null, options);
  11671. case 3:
  11672. _context4.next = 11;
  11673. break;
  11674. case 5:
  11675. _context4.prev = 5;
  11676. _context4.t0 = _context4["catch"](0);
  11677. if (!(_context4.t0.message === 'XMLHttpRequest failed: "Unable to connect to the Parse API"')) {
  11678. _context4.next = 11;
  11679. break;
  11680. }
  11681. _context4.next = 10;
  11682. return _EventuallyQueue.default.save(this, options);
  11683. case 10:
  11684. _EventuallyQueue.default.poll();
  11685. case 11:
  11686. return _context4.abrupt("return", this);
  11687. case 12:
  11688. case "end":
  11689. return _context4.stop();
  11690. }
  11691. }
  11692. }, _callee2, this, [[0, 5]]);
  11693. }));
  11694. function saveEventually(_x2) {
  11695. return _saveEventually.apply(this, arguments);
  11696. }
  11697. return saveEventually;
  11698. }()
  11699. /**
  11700. * Set a hash of model attributes, and save the model to the server.
  11701. * updatedAt will be updated when the request returns.
  11702. * You can either call it as:<pre>
  11703. * object.save();</pre>
  11704. * or<pre>
  11705. * object.save(attrs);</pre>
  11706. * or<pre>
  11707. * object.save(null, options);</pre>
  11708. * or<pre>
  11709. * object.save(attrs, options);</pre>
  11710. * or<pre>
  11711. * object.save(key, value);</pre>
  11712. * or<pre>
  11713. * object.save(key, value, options);</pre>
  11714. *
  11715. * Example 1: <pre>
  11716. * gameTurn.save({
  11717. * player: "Jake Cutter",
  11718. * diceRoll: 2
  11719. * }).then(function(gameTurnAgain) {
  11720. * // The save was successful.
  11721. * }, function(error) {
  11722. * // The save failed. Error is an instance of Parse.Error.
  11723. * });</pre>
  11724. *
  11725. * Example 2: <pre>
  11726. * gameTurn.save("player", "Jake Cutter");</pre>
  11727. *
  11728. * @param {string | object | null} [arg1]
  11729. * Valid options are:<ul>
  11730. * <li>`Object` - Key/value pairs to update on the object.</li>
  11731. * <li>`String` Key - Key of attribute to update (requires arg2 to also be string)</li>
  11732. * <li>`null` - Passing null for arg1 allows you to save the object with options passed in arg2.</li>
  11733. * </ul>
  11734. * @param {string | object} [arg2]
  11735. * <ul>
  11736. * <li>`String` Value - If arg1 was passed as a key, arg2 is the value that should be set on that key.</li>
  11737. * <li>`Object` Options - Valid options are:
  11738. * <ul>
  11739. * <li>useMasterKey: In Cloud Code and Node only, causes the Master Key to
  11740. * be used for this request.
  11741. * <li>sessionToken: A valid session token, used for making a request on
  11742. * behalf of a specific user.
  11743. * <li>cascadeSave: If `false`, nested objects will not be saved (default is `true`).
  11744. * <li>context: A dictionary that is accessible in Cloud Code `beforeSave` and `afterSave` triggers.
  11745. * </ul>
  11746. * </li>
  11747. * </ul>
  11748. * @param {object} [arg3]
  11749. * Used to pass option parameters to method if arg1 and arg2 were both passed as strings.
  11750. * Valid options are:
  11751. * <ul>
  11752. * <li>useMasterKey: In Cloud Code and Node only, causes the Master Key to
  11753. * be used for this request.
  11754. * <li>sessionToken: A valid session token, used for making a request on
  11755. * behalf of a specific user.
  11756. * <li>cascadeSave: If `false`, nested objects will not be saved (default is `true`).
  11757. * <li>context: A dictionary that is accessible in Cloud Code `beforeSave` and `afterSave` triggers.
  11758. * </ul>
  11759. * @returns {Promise} A promise that is fulfilled when the save
  11760. * completes.
  11761. */
  11762. }, {
  11763. key: "save",
  11764. value: function save(arg1
  11765. /*: ?string | { [attr: string]: mixed }*/
  11766. , arg2
  11767. /*: SaveOptions | mixed*/
  11768. , arg3
  11769. /*:: ?: SaveOptions*/
  11770. )
  11771. /*: Promise*/
  11772. {
  11773. var _this = this;
  11774. var attrs;
  11775. var options;
  11776. if ((0, _typeof2.default)(arg1) === 'object' || typeof arg1 === 'undefined') {
  11777. attrs = arg1;
  11778. if ((0, _typeof2.default)(arg2) === 'object') {
  11779. options = arg2;
  11780. }
  11781. } else {
  11782. attrs = {};
  11783. attrs[arg1] = arg2;
  11784. options = arg3;
  11785. }
  11786. if (attrs) {
  11787. var validation = this.validate(attrs);
  11788. if (validation) {
  11789. return _promise.default.reject(validation);
  11790. }
  11791. this.set(attrs, options);
  11792. }
  11793. options = options || {};
  11794. var saveOptions = {};
  11795. if (options.hasOwnProperty('useMasterKey')) {
  11796. saveOptions.useMasterKey = !!options.useMasterKey;
  11797. }
  11798. if (options.hasOwnProperty('sessionToken') && typeof options.sessionToken === 'string') {
  11799. saveOptions.sessionToken = options.sessionToken;
  11800. }
  11801. if (options.hasOwnProperty('installationId') && typeof options.installationId === 'string') {
  11802. saveOptions.installationId = options.installationId;
  11803. }
  11804. if (options.hasOwnProperty('context') && (0, _typeof2.default)(options.context) === 'object') {
  11805. saveOptions.context = options.context;
  11806. }
  11807. var controller = _CoreManager.default.getObjectController();
  11808. var unsaved = options.cascadeSave !== false ? (0, _unsavedChildren.default)(this) : null;
  11809. return controller.save(unsaved, saveOptions).then(function () {
  11810. return controller.save(_this, saveOptions);
  11811. });
  11812. }
  11813. /**
  11814. * Deletes this object from the server at some unspecified time in the future,
  11815. * even if Parse is currently inaccessible.
  11816. *
  11817. * Use this when you may not have a solid network connection,
  11818. * and don't need to know when the delete completes. If there is some problem with the object
  11819. * such that it can't be deleted, the request will be silently discarded.
  11820. *
  11821. * Delete instructions made with this method will be stored locally in an on-disk cache until they can be transmitted
  11822. * to Parse. They will be sent immediately if possible. Otherwise, they will be sent the next time a network connection
  11823. * is available. Delete requests will persist even after the app is closed, in which case they will be sent the
  11824. * next time the app is opened.
  11825. *
  11826. * @param {object} [options]
  11827. * Valid options are:<ul>
  11828. * <li>sessionToken: A valid session token, used for making a request on
  11829. * behalf of a specific user.
  11830. * <li>context: A dictionary that is accessible in Cloud Code `beforeDelete` and `afterDelete` triggers.
  11831. * </ul>
  11832. * @returns {Promise} A promise that is fulfilled when the destroy
  11833. * completes.
  11834. */
  11835. }, {
  11836. key: "destroyEventually",
  11837. value: function () {
  11838. var _destroyEventually = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3(options
  11839. /*: RequestOptions*/
  11840. ) {
  11841. return _regeneratorRuntime().wrap(function _callee3$(_context5) {
  11842. while (1) {
  11843. switch (_context5.prev = _context5.next) {
  11844. case 0:
  11845. _context5.prev = 0;
  11846. _context5.next = 3;
  11847. return this.destroy(options);
  11848. case 3:
  11849. _context5.next = 11;
  11850. break;
  11851. case 5:
  11852. _context5.prev = 5;
  11853. _context5.t0 = _context5["catch"](0);
  11854. if (!(_context5.t0.message === 'XMLHttpRequest failed: "Unable to connect to the Parse API"')) {
  11855. _context5.next = 11;
  11856. break;
  11857. }
  11858. _context5.next = 10;
  11859. return _EventuallyQueue.default.destroy(this, options);
  11860. case 10:
  11861. _EventuallyQueue.default.poll();
  11862. case 11:
  11863. return _context5.abrupt("return", this);
  11864. case 12:
  11865. case "end":
  11866. return _context5.stop();
  11867. }
  11868. }
  11869. }, _callee3, this, [[0, 5]]);
  11870. }));
  11871. function destroyEventually(_x3) {
  11872. return _destroyEventually.apply(this, arguments);
  11873. }
  11874. return destroyEventually;
  11875. }()
  11876. /**
  11877. * Destroy this model on the server if it was already persisted.
  11878. *
  11879. * @param {object} options
  11880. * Valid options are:<ul>
  11881. * <li>useMasterKey: In Cloud Code and Node only, causes the Master Key to
  11882. * be used for this request.
  11883. * <li>sessionToken: A valid session token, used for making a request on
  11884. * behalf of a specific user.
  11885. * <li>context: A dictionary that is accessible in Cloud Code `beforeDelete` and `afterDelete` triggers.
  11886. * </ul>
  11887. * @returns {Promise} A promise that is fulfilled when the destroy
  11888. * completes.
  11889. */
  11890. }, {
  11891. key: "destroy",
  11892. value: function destroy(options
  11893. /*: RequestOptions*/
  11894. )
  11895. /*: Promise*/
  11896. {
  11897. options = options || {};
  11898. var destroyOptions = {};
  11899. if (options.hasOwnProperty('useMasterKey')) {
  11900. destroyOptions.useMasterKey = options.useMasterKey;
  11901. }
  11902. if (options.hasOwnProperty('sessionToken')) {
  11903. destroyOptions.sessionToken = options.sessionToken;
  11904. }
  11905. if (options.hasOwnProperty('context') && (0, _typeof2.default)(options.context) === 'object') {
  11906. destroyOptions.context = options.context;
  11907. }
  11908. if (!this.id) {
  11909. return _promise.default.resolve();
  11910. }
  11911. return _CoreManager.default.getObjectController().destroy(this, destroyOptions);
  11912. }
  11913. /**
  11914. * Asynchronously stores the object and every object it points to in the local datastore,
  11915. * recursively, using a default pin name: _default.
  11916. *
  11917. * If those other objects have not been fetched from Parse, they will not be stored.
  11918. * However, if they have changed data, all the changes will be retained.
  11919. *
  11920. * <pre>
  11921. * await object.pin();
  11922. * </pre>
  11923. *
  11924. * To retrieve object:
  11925. * <code>query.fromLocalDatastore()</code> or <code>query.fromPin()</code>
  11926. *
  11927. * @returns {Promise} A promise that is fulfilled when the pin completes.
  11928. */
  11929. }, {
  11930. key: "pin",
  11931. value: function pin()
  11932. /*: Promise<void>*/
  11933. {
  11934. return ParseObject.pinAllWithName(_LocalDatastoreUtils.DEFAULT_PIN, [this]);
  11935. }
  11936. /**
  11937. * Asynchronously removes the object and every object it points to in the local datastore,
  11938. * recursively, using a default pin name: _default.
  11939. *
  11940. * <pre>
  11941. * await object.unPin();
  11942. * </pre>
  11943. *
  11944. * @returns {Promise} A promise that is fulfilled when the unPin completes.
  11945. */
  11946. }, {
  11947. key: "unPin",
  11948. value: function unPin()
  11949. /*: Promise<void>*/
  11950. {
  11951. return ParseObject.unPinAllWithName(_LocalDatastoreUtils.DEFAULT_PIN, [this]);
  11952. }
  11953. /**
  11954. * Asynchronously returns if the object is pinned
  11955. *
  11956. * <pre>
  11957. * const isPinned = await object.isPinned();
  11958. * </pre>
  11959. *
  11960. * @returns {Promise<boolean>} A boolean promise that is fulfilled if object is pinned.
  11961. */
  11962. }, {
  11963. key: "isPinned",
  11964. value: function () {
  11965. var _isPinned = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regeneratorRuntime().mark(function _callee4() {
  11966. var localDatastore, objectKey, pin;
  11967. return _regeneratorRuntime().wrap(function _callee4$(_context6) {
  11968. while (1) {
  11969. switch (_context6.prev = _context6.next) {
  11970. case 0:
  11971. localDatastore = _CoreManager.default.getLocalDatastore();
  11972. if (localDatastore.isEnabled) {
  11973. _context6.next = 3;
  11974. break;
  11975. }
  11976. return _context6.abrupt("return", _promise.default.reject('Parse.enableLocalDatastore() must be called first'));
  11977. case 3:
  11978. objectKey = localDatastore.getKeyForObject(this);
  11979. _context6.next = 6;
  11980. return localDatastore.fromPinWithName(objectKey);
  11981. case 6:
  11982. pin = _context6.sent;
  11983. return _context6.abrupt("return", pin.length > 0);
  11984. case 8:
  11985. case "end":
  11986. return _context6.stop();
  11987. }
  11988. }
  11989. }, _callee4, this);
  11990. }));
  11991. function isPinned() {
  11992. return _isPinned.apply(this, arguments);
  11993. }
  11994. return isPinned;
  11995. }()
  11996. /**
  11997. * Asynchronously stores the objects and every object they point to in the local datastore, recursively.
  11998. *
  11999. * If those other objects have not been fetched from Parse, they will not be stored.
  12000. * However, if they have changed data, all the changes will be retained.
  12001. *
  12002. * <pre>
  12003. * await object.pinWithName(name);
  12004. * </pre>
  12005. *
  12006. * To retrieve object:
  12007. * <code>query.fromLocalDatastore()</code> or <code>query.fromPinWithName(name)</code>
  12008. *
  12009. * @param {string} name Name of Pin.
  12010. * @returns {Promise} A promise that is fulfilled when the pin completes.
  12011. */
  12012. }, {
  12013. key: "pinWithName",
  12014. value: function pinWithName(name
  12015. /*: string*/
  12016. )
  12017. /*: Promise<void>*/
  12018. {
  12019. return ParseObject.pinAllWithName(name, [this]);
  12020. }
  12021. /**
  12022. * Asynchronously removes the object and every object it points to in the local datastore, recursively.
  12023. *
  12024. * <pre>
  12025. * await object.unPinWithName(name);
  12026. * </pre>
  12027. *
  12028. * @param {string} name Name of Pin.
  12029. * @returns {Promise} A promise that is fulfilled when the unPin completes.
  12030. */
  12031. }, {
  12032. key: "unPinWithName",
  12033. value: function unPinWithName(name
  12034. /*: string*/
  12035. )
  12036. /*: Promise<void>*/
  12037. {
  12038. return ParseObject.unPinAllWithName(name, [this]);
  12039. }
  12040. /**
  12041. * Asynchronously loads data from the local datastore into this object.
  12042. *
  12043. * <pre>
  12044. * await object.fetchFromLocalDatastore();
  12045. * </pre>
  12046. *
  12047. * You can create an unfetched pointer with <code>Parse.Object.createWithoutData()</code>
  12048. * and then call <code>fetchFromLocalDatastore()</code> on it.
  12049. *
  12050. * @returns {Promise} A promise that is fulfilled when the fetch completes.
  12051. */
  12052. }, {
  12053. key: "fetchFromLocalDatastore",
  12054. value: function () {
  12055. var _fetchFromLocalDatastore = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regeneratorRuntime().mark(function _callee5() {
  12056. var localDatastore, objectKey, pinned, result;
  12057. return _regeneratorRuntime().wrap(function _callee5$(_context7) {
  12058. while (1) {
  12059. switch (_context7.prev = _context7.next) {
  12060. case 0:
  12061. localDatastore = _CoreManager.default.getLocalDatastore();
  12062. if (localDatastore.isEnabled) {
  12063. _context7.next = 3;
  12064. break;
  12065. }
  12066. throw new Error('Parse.enableLocalDatastore() must be called first');
  12067. case 3:
  12068. objectKey = localDatastore.getKeyForObject(this);
  12069. _context7.next = 6;
  12070. return localDatastore._serializeObject(objectKey);
  12071. case 6:
  12072. pinned = _context7.sent;
  12073. if (pinned) {
  12074. _context7.next = 9;
  12075. break;
  12076. }
  12077. throw new Error('Cannot fetch an unsaved ParseObject');
  12078. case 9:
  12079. result = ParseObject.fromJSON(pinned);
  12080. this._finishFetch(result.toJSON());
  12081. return _context7.abrupt("return", this);
  12082. case 12:
  12083. case "end":
  12084. return _context7.stop();
  12085. }
  12086. }
  12087. }, _callee5, this);
  12088. }));
  12089. function fetchFromLocalDatastore() {
  12090. return _fetchFromLocalDatastore.apply(this, arguments);
  12091. }
  12092. return fetchFromLocalDatastore;
  12093. }()
  12094. /** Static methods **/
  12095. }], [{
  12096. key: "_getClassMap",
  12097. value: function _getClassMap() {
  12098. return classMap;
  12099. }
  12100. }, {
  12101. key: "_clearAllState",
  12102. value: function _clearAllState() {
  12103. var stateController = _CoreManager.default.getObjectStateController();
  12104. stateController.clearAllState();
  12105. }
  12106. /**
  12107. * Fetches the given list of Parse.Object.
  12108. * If any error is encountered, stops and calls the error handler.
  12109. *
  12110. * <pre>
  12111. * Parse.Object.fetchAll([object1, object2, ...])
  12112. * .then((list) => {
  12113. * // All the objects were fetched.
  12114. * }, (error) => {
  12115. * // An error occurred while fetching one of the objects.
  12116. * });
  12117. * </pre>
  12118. *
  12119. * @param {Array} list A list of <code>Parse.Object</code>.
  12120. * @param {object} options
  12121. * Valid options are:<ul>
  12122. * <li>useMasterKey: In Cloud Code and Node only, causes the Master Key to
  12123. * be used for this request.
  12124. * <li>sessionToken: A valid session token, used for making a request on
  12125. * behalf of a specific user.
  12126. * <li>include: The name(s) of the key(s) to include. Can be a string, an array of strings,
  12127. * or an array of array of strings.
  12128. * </ul>
  12129. * @static
  12130. * @returns {Parse.Object[]}
  12131. */
  12132. }, {
  12133. key: "fetchAll",
  12134. value: function fetchAll(list
  12135. /*: Array<ParseObject>*/
  12136. ) {
  12137. var options
  12138. /*: RequestOptions*/
  12139. = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
  12140. var queryOptions = {};
  12141. if (options.hasOwnProperty('useMasterKey')) {
  12142. queryOptions.useMasterKey = options.useMasterKey;
  12143. }
  12144. if (options.hasOwnProperty('sessionToken')) {
  12145. queryOptions.sessionToken = options.sessionToken;
  12146. }
  12147. if (options.hasOwnProperty('include')) {
  12148. queryOptions.include = ParseObject.handleIncludeOptions(options);
  12149. }
  12150. return _CoreManager.default.getObjectController().fetch(list, true, queryOptions);
  12151. }
  12152. /**
  12153. * Fetches the given list of Parse.Object.
  12154. *
  12155. * Includes nested Parse.Objects for the provided key. You can use dot
  12156. * notation to specify which fields in the included object are also fetched.
  12157. *
  12158. * If any error is encountered, stops and calls the error handler.
  12159. *
  12160. * <pre>
  12161. * Parse.Object.fetchAllWithInclude([object1, object2, ...], [pointer1, pointer2, ...])
  12162. * .then((list) => {
  12163. * // All the objects were fetched.
  12164. * }, (error) => {
  12165. * // An error occurred while fetching one of the objects.
  12166. * });
  12167. * </pre>
  12168. *
  12169. * @param {Array} list A list of <code>Parse.Object</code>.
  12170. * @param {string | Array<string | Array<string>>} keys The name(s) of the key(s) to include.
  12171. * @param {object} options
  12172. * Valid options are:<ul>
  12173. * <li>useMasterKey: In Cloud Code and Node only, causes the Master Key to
  12174. * be used for this request.
  12175. * <li>sessionToken: A valid session token, used for making a request on
  12176. * behalf of a specific user.
  12177. * </ul>
  12178. * @static
  12179. * @returns {Parse.Object[]}
  12180. */
  12181. }, {
  12182. key: "fetchAllWithInclude",
  12183. value: function fetchAllWithInclude(list
  12184. /*: Array<ParseObject>*/
  12185. , keys
  12186. /*: String | Array<string | Array<string>>*/
  12187. , options
  12188. /*: RequestOptions*/
  12189. ) {
  12190. options = options || {};
  12191. options.include = keys;
  12192. return ParseObject.fetchAll(list, options);
  12193. }
  12194. /**
  12195. * Fetches the given list of Parse.Object if needed.
  12196. * If any error is encountered, stops and calls the error handler.
  12197. *
  12198. * Includes nested Parse.Objects for the provided key. You can use dot
  12199. * notation to specify which fields in the included object are also fetched.
  12200. *
  12201. * If any error is encountered, stops and calls the error handler.
  12202. *
  12203. * <pre>
  12204. * Parse.Object.fetchAllIfNeededWithInclude([object1, object2, ...], [pointer1, pointer2, ...])
  12205. * .then((list) => {
  12206. * // All the objects were fetched.
  12207. * }, (error) => {
  12208. * // An error occurred while fetching one of the objects.
  12209. * });
  12210. * </pre>
  12211. *
  12212. * @param {Array} list A list of <code>Parse.Object</code>.
  12213. * @param {string | Array<string | Array<string>>} keys The name(s) of the key(s) to include.
  12214. * @param {object} options
  12215. * Valid options are:<ul>
  12216. * <li>useMasterKey: In Cloud Code and Node only, causes the Master Key to
  12217. * be used for this request.
  12218. * <li>sessionToken: A valid session token, used for making a request on
  12219. * behalf of a specific user.
  12220. * </ul>
  12221. * @static
  12222. * @returns {Parse.Object[]}
  12223. */
  12224. }, {
  12225. key: "fetchAllIfNeededWithInclude",
  12226. value: function fetchAllIfNeededWithInclude(list
  12227. /*: Array<ParseObject>*/
  12228. , keys
  12229. /*: String | Array<string | Array<string>>*/
  12230. , options
  12231. /*: RequestOptions*/
  12232. ) {
  12233. options = options || {};
  12234. options.include = keys;
  12235. return ParseObject.fetchAllIfNeeded(list, options);
  12236. }
  12237. /**
  12238. * Fetches the given list of Parse.Object if needed.
  12239. * If any error is encountered, stops and calls the error handler.
  12240. *
  12241. * <pre>
  12242. * Parse.Object.fetchAllIfNeeded([object1, ...])
  12243. * .then((list) => {
  12244. * // Objects were fetched and updated.
  12245. * }, (error) => {
  12246. * // An error occurred while fetching one of the objects.
  12247. * });
  12248. * </pre>
  12249. *
  12250. * @param {Array} list A list of <code>Parse.Object</code>.
  12251. * @param {object} options
  12252. * @static
  12253. * @returns {Parse.Object[]}
  12254. */
  12255. }, {
  12256. key: "fetchAllIfNeeded",
  12257. value: function fetchAllIfNeeded(list
  12258. /*: Array<ParseObject>*/
  12259. , options) {
  12260. options = options || {};
  12261. var queryOptions = {};
  12262. if (options.hasOwnProperty('useMasterKey')) {
  12263. queryOptions.useMasterKey = options.useMasterKey;
  12264. }
  12265. if (options.hasOwnProperty('sessionToken')) {
  12266. queryOptions.sessionToken = options.sessionToken;
  12267. }
  12268. if (options.hasOwnProperty('include')) {
  12269. queryOptions.include = ParseObject.handleIncludeOptions(options);
  12270. }
  12271. return _CoreManager.default.getObjectController().fetch(list, false, queryOptions);
  12272. }
  12273. }, {
  12274. key: "handleIncludeOptions",
  12275. value: function handleIncludeOptions(options) {
  12276. var include = [];
  12277. if ((0, _isArray.default)(options.include)) {
  12278. var _context8;
  12279. (0, _forEach.default)(_context8 = options.include).call(_context8, function (key) {
  12280. if ((0, _isArray.default)(key)) {
  12281. include = (0, _concat.default)(include).call(include, key);
  12282. } else {
  12283. include.push(key);
  12284. }
  12285. });
  12286. } else {
  12287. include.push(options.include);
  12288. }
  12289. return include;
  12290. }
  12291. /**
  12292. * Destroy the given list of models on the server if it was already persisted.
  12293. *
  12294. * <p>Unlike saveAll, if an error occurs while deleting an individual model,
  12295. * this method will continue trying to delete the rest of the models if
  12296. * possible, except in the case of a fatal error like a connection error.
  12297. *
  12298. * <p>In particular, the Parse.Error object returned in the case of error may
  12299. * be one of two types:
  12300. *
  12301. * <ul>
  12302. * <li>A Parse.Error.AGGREGATE_ERROR. This object's "errors" property is an
  12303. * array of other Parse.Error objects. Each error object in this array
  12304. * has an "object" property that references the object that could not be
  12305. * deleted (for instance, because that object could not be found).</li>
  12306. * <li>A non-aggregate Parse.Error. This indicates a serious error that
  12307. * caused the delete operation to be aborted partway through (for
  12308. * instance, a connection failure in the middle of the delete).</li>
  12309. * </ul>
  12310. *
  12311. * <pre>
  12312. * Parse.Object.destroyAll([object1, object2, ...])
  12313. * .then((list) => {
  12314. * // All the objects were deleted.
  12315. * }, (error) => {
  12316. * // An error occurred while deleting one or more of the objects.
  12317. * // If this is an aggregate error, then we can inspect each error
  12318. * // object individually to determine the reason why a particular
  12319. * // object was not deleted.
  12320. * if (error.code === Parse.Error.AGGREGATE_ERROR) {
  12321. * for (var i = 0; i < error.errors.length; i++) {
  12322. * console.log("Couldn't delete " + error.errors[i].object.id +
  12323. * "due to " + error.errors[i].message);
  12324. * }
  12325. * } else {
  12326. * console.log("Delete aborted because of " + error.message);
  12327. * }
  12328. * });
  12329. * </pre>
  12330. *
  12331. * @param {Array} list A list of <code>Parse.Object</code>.
  12332. * @param {object} options
  12333. * @static
  12334. * @returns {Promise} A promise that is fulfilled when the destroyAll
  12335. * completes.
  12336. */
  12337. }, {
  12338. key: "destroyAll",
  12339. value: function destroyAll(list
  12340. /*: Array<ParseObject>*/
  12341. ) {
  12342. var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
  12343. var destroyOptions = {};
  12344. if (options.hasOwnProperty('useMasterKey')) {
  12345. destroyOptions.useMasterKey = options.useMasterKey;
  12346. }
  12347. if (options.hasOwnProperty('sessionToken')) {
  12348. destroyOptions.sessionToken = options.sessionToken;
  12349. }
  12350. if (options.hasOwnProperty('batchSize') && typeof options.batchSize === 'number') {
  12351. destroyOptions.batchSize = options.batchSize;
  12352. }
  12353. if (options.hasOwnProperty('context') && (0, _typeof2.default)(options.context) === 'object') {
  12354. destroyOptions.context = options.context;
  12355. }
  12356. return _CoreManager.default.getObjectController().destroy(list, destroyOptions);
  12357. }
  12358. /**
  12359. * Saves the given list of Parse.Object.
  12360. * If any error is encountered, stops and calls the error handler.
  12361. *
  12362. * <pre>
  12363. * Parse.Object.saveAll([object1, object2, ...])
  12364. * .then((list) => {
  12365. * // All the objects were saved.
  12366. * }, (error) => {
  12367. * // An error occurred while saving one of the objects.
  12368. * });
  12369. * </pre>
  12370. *
  12371. * @param {Array} list A list of <code>Parse.Object</code>.
  12372. * @param {object} options
  12373. * @static
  12374. * @returns {Parse.Object[]}
  12375. */
  12376. }, {
  12377. key: "saveAll",
  12378. value: function saveAll(list
  12379. /*: Array<ParseObject>*/
  12380. ) {
  12381. var options
  12382. /*: RequestOptions*/
  12383. = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
  12384. var saveOptions = {};
  12385. if (options.hasOwnProperty('useMasterKey')) {
  12386. saveOptions.useMasterKey = options.useMasterKey;
  12387. }
  12388. if (options.hasOwnProperty('sessionToken')) {
  12389. saveOptions.sessionToken = options.sessionToken;
  12390. }
  12391. if (options.hasOwnProperty('batchSize') && typeof options.batchSize === 'number') {
  12392. saveOptions.batchSize = options.batchSize;
  12393. }
  12394. if (options.hasOwnProperty('context') && (0, _typeof2.default)(options.context) === 'object') {
  12395. saveOptions.context = options.context;
  12396. }
  12397. return _CoreManager.default.getObjectController().save(list, saveOptions);
  12398. }
  12399. /**
  12400. * Creates a reference to a subclass of Parse.Object with the given id. This
  12401. * does not exist on Parse.Object, only on subclasses.
  12402. *
  12403. * <p>A shortcut for: <pre>
  12404. * var Foo = Parse.Object.extend("Foo");
  12405. * var pointerToFoo = new Foo();
  12406. * pointerToFoo.id = "myObjectId";
  12407. * </pre>
  12408. *
  12409. * @param {string} id The ID of the object to create a reference to.
  12410. * @static
  12411. * @returns {Parse.Object} A Parse.Object reference.
  12412. */
  12413. }, {
  12414. key: "createWithoutData",
  12415. value: function createWithoutData(id
  12416. /*: string*/
  12417. ) {
  12418. var obj = new this();
  12419. obj.id = id;
  12420. return obj;
  12421. }
  12422. /**
  12423. * Creates a new instance of a Parse Object from a JSON representation.
  12424. *
  12425. * @param {object} json The JSON map of the Object's data
  12426. * @param {boolean} override In single instance mode, all old server data
  12427. * is overwritten if this is set to true
  12428. * @param {boolean} dirty Whether the Parse.Object should set JSON keys to dirty
  12429. * @static
  12430. * @returns {Parse.Object} A Parse.Object reference
  12431. */
  12432. }, {
  12433. key: "fromJSON",
  12434. value: function fromJSON(json
  12435. /*: any*/
  12436. , override
  12437. /*:: ?: boolean*/
  12438. , dirty
  12439. /*:: ?: boolean*/
  12440. ) {
  12441. if (!json.className) {
  12442. throw new Error('Cannot create an object without a className');
  12443. }
  12444. var constructor = classMap[json.className];
  12445. var o = constructor ? new constructor(json.className) : new ParseObject(json.className);
  12446. var otherAttributes = {};
  12447. for (var _attr12 in json) {
  12448. if (_attr12 !== 'className' && _attr12 !== '__type') {
  12449. otherAttributes[_attr12] = json[_attr12];
  12450. if (dirty) {
  12451. o.set(_attr12, json[_attr12]);
  12452. }
  12453. }
  12454. }
  12455. if (override) {
  12456. // id needs to be set before clearServerData can work
  12457. if (otherAttributes.objectId) {
  12458. o.id = otherAttributes.objectId;
  12459. }
  12460. var preserved = null;
  12461. if (typeof o._preserveFieldsOnFetch === 'function') {
  12462. preserved = o._preserveFieldsOnFetch();
  12463. }
  12464. o._clearServerData();
  12465. if (preserved) {
  12466. o._finishFetch(preserved);
  12467. }
  12468. }
  12469. o._finishFetch(otherAttributes);
  12470. if (json.objectId) {
  12471. o._setExisted(true);
  12472. }
  12473. return o;
  12474. }
  12475. /**
  12476. * Registers a subclass of Parse.Object with a specific class name.
  12477. * When objects of that class are retrieved from a query, they will be
  12478. * instantiated with this subclass.
  12479. * This is only necessary when using ES6 subclassing.
  12480. *
  12481. * @param {string} className The class name of the subclass
  12482. * @param {Function} constructor The subclass
  12483. */
  12484. }, {
  12485. key: "registerSubclass",
  12486. value: function registerSubclass(className
  12487. /*: string*/
  12488. , constructor
  12489. /*: any*/
  12490. ) {
  12491. if (typeof className !== 'string') {
  12492. throw new TypeError('The first argument must be a valid class name.');
  12493. }
  12494. if (typeof constructor === 'undefined') {
  12495. throw new TypeError('You must supply a subclass constructor.');
  12496. }
  12497. if (typeof constructor !== 'function') {
  12498. throw new TypeError('You must register the subclass constructor. ' + 'Did you attempt to register an instance of the subclass?');
  12499. }
  12500. classMap[className] = constructor;
  12501. if (!constructor.className) {
  12502. constructor.className = className;
  12503. }
  12504. }
  12505. /**
  12506. * Unegisters a subclass of Parse.Object with a specific class name.
  12507. *
  12508. * @param {string} className The class name of the subclass
  12509. */
  12510. }, {
  12511. key: "unregisterSubclass",
  12512. value: function unregisterSubclass(className
  12513. /*: string*/
  12514. ) {
  12515. if (typeof className !== 'string') {
  12516. throw new TypeError('The first argument must be a valid class name.');
  12517. }
  12518. delete classMap[className];
  12519. }
  12520. /**
  12521. * Creates a new subclass of Parse.Object for the given Parse class name.
  12522. *
  12523. * <p>Every extension of a Parse class will inherit from the most recent
  12524. * previous extension of that class. When a Parse.Object is automatically
  12525. * created by parsing JSON, it will use the most recent extension of that
  12526. * class.</p>
  12527. *
  12528. * <p>You should call either:<pre>
  12529. * var MyClass = Parse.Object.extend("MyClass", {
  12530. * <i>Instance methods</i>,
  12531. * initialize: function(attrs, options) {
  12532. * this.someInstanceProperty = [],
  12533. * <i>Other instance properties</i>
  12534. * }
  12535. * }, {
  12536. * <i>Class properties</i>
  12537. * });</pre>
  12538. * or, for Backbone compatibility:<pre>
  12539. * var MyClass = Parse.Object.extend({
  12540. * className: "MyClass",
  12541. * <i>Instance methods</i>,
  12542. * initialize: function(attrs, options) {
  12543. * this.someInstanceProperty = [],
  12544. * <i>Other instance properties</i>
  12545. * }
  12546. * }, {
  12547. * <i>Class properties</i>
  12548. * });</pre></p>
  12549. *
  12550. * @param {string} className The name of the Parse class backing this model.
  12551. * @param {object} protoProps Instance properties to add to instances of the
  12552. * class returned from this method.
  12553. * @param {object} classProps Class properties to add the class returned from
  12554. * this method.
  12555. * @returns {Parse.Object} A new subclass of Parse.Object.
  12556. */
  12557. }, {
  12558. key: "extend",
  12559. value: function extend(className
  12560. /*: any*/
  12561. , protoProps
  12562. /*: any*/
  12563. , classProps
  12564. /*: any*/
  12565. ) {
  12566. if (typeof className !== 'string') {
  12567. if (className && typeof className.className === 'string') {
  12568. return ParseObject.extend(className.className, className, protoProps);
  12569. } else {
  12570. throw new Error("Parse.Object.extend's first argument should be the className.");
  12571. }
  12572. }
  12573. var adjustedClassName = className;
  12574. if (adjustedClassName === 'User' && _CoreManager.default.get('PERFORM_USER_REWRITE')) {
  12575. adjustedClassName = '_User';
  12576. }
  12577. var parentProto = ParseObject.prototype;
  12578. if (this.hasOwnProperty('__super__') && this.__super__) {
  12579. parentProto = this.prototype;
  12580. } else if (classMap[adjustedClassName]) {
  12581. parentProto = classMap[adjustedClassName].prototype;
  12582. }
  12583. var ParseObjectSubclass = function ParseObjectSubclass(attributes, options) {
  12584. this.className = adjustedClassName;
  12585. this._objCount = objectCount++; // Enable legacy initializers
  12586. if (typeof this.initialize === 'function') {
  12587. this.initialize.apply(this, arguments);
  12588. }
  12589. if (attributes && (0, _typeof2.default)(attributes) === 'object') {
  12590. if (!this.set(attributes || {}, options)) {
  12591. throw new Error("Can't create an invalid Parse Object");
  12592. }
  12593. }
  12594. };
  12595. ParseObjectSubclass.className = adjustedClassName;
  12596. ParseObjectSubclass.__super__ = parentProto;
  12597. ParseObjectSubclass.prototype = (0, _create.default)(parentProto, {
  12598. constructor: {
  12599. value: ParseObjectSubclass,
  12600. enumerable: false,
  12601. writable: true,
  12602. configurable: true
  12603. }
  12604. });
  12605. if (protoProps) {
  12606. for (var prop in protoProps) {
  12607. if (prop !== 'className') {
  12608. (0, _defineProperty2.default)(ParseObjectSubclass.prototype, prop, {
  12609. value: protoProps[prop],
  12610. enumerable: false,
  12611. writable: true,
  12612. configurable: true
  12613. });
  12614. }
  12615. }
  12616. }
  12617. if (classProps) {
  12618. for (var _prop in classProps) {
  12619. if (_prop !== 'className') {
  12620. (0, _defineProperty2.default)(ParseObjectSubclass, _prop, {
  12621. value: classProps[_prop],
  12622. enumerable: false,
  12623. writable: true,
  12624. configurable: true
  12625. });
  12626. }
  12627. }
  12628. }
  12629. ParseObjectSubclass.extend = function (name, protoProps, classProps) {
  12630. if (typeof name === 'string') {
  12631. return ParseObject.extend.call(ParseObjectSubclass, name, protoProps, classProps);
  12632. }
  12633. return ParseObject.extend.call(ParseObjectSubclass, adjustedClassName, name, protoProps);
  12634. };
  12635. ParseObjectSubclass.createWithoutData = ParseObject.createWithoutData;
  12636. classMap[adjustedClassName] = ParseObjectSubclass;
  12637. return ParseObjectSubclass;
  12638. }
  12639. /**
  12640. * Enable single instance objects, where any local objects with the same Id
  12641. * share the same attributes, and stay synchronized with each other.
  12642. * This is disabled by default in server environments, since it can lead to
  12643. * security issues.
  12644. *
  12645. * @static
  12646. */
  12647. }, {
  12648. key: "enableSingleInstance",
  12649. value: function enableSingleInstance() {
  12650. singleInstance = true;
  12651. _CoreManager.default.setObjectStateController(SingleInstanceStateController);
  12652. }
  12653. /**
  12654. * Disable single instance objects, where any local objects with the same Id
  12655. * share the same attributes, and stay synchronized with each other.
  12656. * When disabled, you can have two instances of the same object in memory
  12657. * without them sharing attributes.
  12658. *
  12659. * @static
  12660. */
  12661. }, {
  12662. key: "disableSingleInstance",
  12663. value: function disableSingleInstance() {
  12664. singleInstance = false;
  12665. _CoreManager.default.setObjectStateController(UniqueInstanceStateController);
  12666. }
  12667. /**
  12668. * Asynchronously stores the objects and every object they point to in the local datastore,
  12669. * recursively, using a default pin name: _default.
  12670. *
  12671. * If those other objects have not been fetched from Parse, they will not be stored.
  12672. * However, if they have changed data, all the changes will be retained.
  12673. *
  12674. * <pre>
  12675. * await Parse.Object.pinAll([...]);
  12676. * </pre>
  12677. *
  12678. * To retrieve object:
  12679. * <code>query.fromLocalDatastore()</code> or <code>query.fromPin()</code>
  12680. *
  12681. * @param {Array} objects A list of <code>Parse.Object</code>.
  12682. * @returns {Promise} A promise that is fulfilled when the pin completes.
  12683. * @static
  12684. */
  12685. }, {
  12686. key: "pinAll",
  12687. value: function pinAll(objects
  12688. /*: Array<ParseObject>*/
  12689. )
  12690. /*: Promise<void>*/
  12691. {
  12692. var localDatastore = _CoreManager.default.getLocalDatastore();
  12693. if (!localDatastore.isEnabled) {
  12694. return _promise.default.reject('Parse.enableLocalDatastore() must be called first');
  12695. }
  12696. return ParseObject.pinAllWithName(_LocalDatastoreUtils.DEFAULT_PIN, objects);
  12697. }
  12698. /**
  12699. * Asynchronously stores the objects and every object they point to in the local datastore, recursively.
  12700. *
  12701. * If those other objects have not been fetched from Parse, they will not be stored.
  12702. * However, if they have changed data, all the changes will be retained.
  12703. *
  12704. * <pre>
  12705. * await Parse.Object.pinAllWithName(name, [obj1, obj2, ...]);
  12706. * </pre>
  12707. *
  12708. * To retrieve object:
  12709. * <code>query.fromLocalDatastore()</code> or <code>query.fromPinWithName(name)</code>
  12710. *
  12711. * @param {string} name Name of Pin.
  12712. * @param {Array} objects A list of <code>Parse.Object</code>.
  12713. * @returns {Promise} A promise that is fulfilled when the pin completes.
  12714. * @static
  12715. */
  12716. }, {
  12717. key: "pinAllWithName",
  12718. value: function pinAllWithName(name
  12719. /*: string*/
  12720. , objects
  12721. /*: Array<ParseObject>*/
  12722. )
  12723. /*: Promise<void>*/
  12724. {
  12725. var localDatastore = _CoreManager.default.getLocalDatastore();
  12726. if (!localDatastore.isEnabled) {
  12727. return _promise.default.reject('Parse.enableLocalDatastore() must be called first');
  12728. }
  12729. return localDatastore._handlePinAllWithName(name, objects);
  12730. }
  12731. /**
  12732. * Asynchronously removes the objects and every object they point to in the local datastore,
  12733. * recursively, using a default pin name: _default.
  12734. *
  12735. * <pre>
  12736. * await Parse.Object.unPinAll([...]);
  12737. * </pre>
  12738. *
  12739. * @param {Array} objects A list of <code>Parse.Object</code>.
  12740. * @returns {Promise} A promise that is fulfilled when the unPin completes.
  12741. * @static
  12742. */
  12743. }, {
  12744. key: "unPinAll",
  12745. value: function unPinAll(objects
  12746. /*: Array<ParseObject>*/
  12747. )
  12748. /*: Promise<void>*/
  12749. {
  12750. var localDatastore = _CoreManager.default.getLocalDatastore();
  12751. if (!localDatastore.isEnabled) {
  12752. return _promise.default.reject('Parse.enableLocalDatastore() must be called first');
  12753. }
  12754. return ParseObject.unPinAllWithName(_LocalDatastoreUtils.DEFAULT_PIN, objects);
  12755. }
  12756. /**
  12757. * Asynchronously removes the objects and every object they point to in the local datastore, recursively.
  12758. *
  12759. * <pre>
  12760. * await Parse.Object.unPinAllWithName(name, [obj1, obj2, ...]);
  12761. * </pre>
  12762. *
  12763. * @param {string} name Name of Pin.
  12764. * @param {Array} objects A list of <code>Parse.Object</code>.
  12765. * @returns {Promise} A promise that is fulfilled when the unPin completes.
  12766. * @static
  12767. */
  12768. }, {
  12769. key: "unPinAllWithName",
  12770. value: function unPinAllWithName(name
  12771. /*: string*/
  12772. , objects
  12773. /*: Array<ParseObject>*/
  12774. )
  12775. /*: Promise<void>*/
  12776. {
  12777. var localDatastore = _CoreManager.default.getLocalDatastore();
  12778. if (!localDatastore.isEnabled) {
  12779. return _promise.default.reject('Parse.enableLocalDatastore() must be called first');
  12780. }
  12781. return localDatastore._handleUnPinAllWithName(name, objects);
  12782. }
  12783. /**
  12784. * Asynchronously removes all objects in the local datastore using a default pin name: _default.
  12785. *
  12786. * <pre>
  12787. * await Parse.Object.unPinAllObjects();
  12788. * </pre>
  12789. *
  12790. * @returns {Promise} A promise that is fulfilled when the unPin completes.
  12791. * @static
  12792. */
  12793. }, {
  12794. key: "unPinAllObjects",
  12795. value: function unPinAllObjects()
  12796. /*: Promise<void>*/
  12797. {
  12798. var localDatastore = _CoreManager.default.getLocalDatastore();
  12799. if (!localDatastore.isEnabled) {
  12800. return _promise.default.reject('Parse.enableLocalDatastore() must be called first');
  12801. }
  12802. return localDatastore.unPinWithName(_LocalDatastoreUtils.DEFAULT_PIN);
  12803. }
  12804. /**
  12805. * Asynchronously removes all objects with the specified pin name.
  12806. * Deletes the pin name also.
  12807. *
  12808. * <pre>
  12809. * await Parse.Object.unPinAllObjectsWithName(name);
  12810. * </pre>
  12811. *
  12812. * @param {string} name Name of Pin.
  12813. * @returns {Promise} A promise that is fulfilled when the unPin completes.
  12814. * @static
  12815. */
  12816. }, {
  12817. key: "unPinAllObjectsWithName",
  12818. value: function unPinAllObjectsWithName(name
  12819. /*: string*/
  12820. )
  12821. /*: Promise<void>*/
  12822. {
  12823. var localDatastore = _CoreManager.default.getLocalDatastore();
  12824. if (!localDatastore.isEnabled) {
  12825. return _promise.default.reject('Parse.enableLocalDatastore() must be called first');
  12826. }
  12827. return localDatastore.unPinWithName(_LocalDatastoreUtils.PIN_PREFIX + name);
  12828. }
  12829. }]);
  12830. return ParseObject;
  12831. }();
  12832. var DefaultController = {
  12833. fetch: function fetch(target
  12834. /*: ParseObject | Array<ParseObject>*/
  12835. , forceFetch
  12836. /*: boolean*/
  12837. , options
  12838. /*: RequestOptions*/
  12839. )
  12840. /*: Promise<Array<void> | ParseObject>*/
  12841. {
  12842. var localDatastore = _CoreManager.default.getLocalDatastore();
  12843. if ((0, _isArray.default)(target)) {
  12844. if (target.length < 1) {
  12845. return _promise.default.resolve([]);
  12846. }
  12847. var objs = [];
  12848. var ids = [];
  12849. var className = null;
  12850. var results = [];
  12851. var error = null;
  12852. (0, _forEach.default)(target).call(target, function (el) {
  12853. if (error) {
  12854. return;
  12855. }
  12856. if (!className) {
  12857. className = el.className;
  12858. }
  12859. if (className !== el.className) {
  12860. error = new _ParseError.default(_ParseError.default.INVALID_CLASS_NAME, 'All objects should be of the same class');
  12861. }
  12862. if (!el.id) {
  12863. error = new _ParseError.default(_ParseError.default.MISSING_OBJECT_ID, 'All objects must have an ID');
  12864. }
  12865. if (forceFetch || !el.isDataAvailable()) {
  12866. ids.push(el.id);
  12867. objs.push(el);
  12868. }
  12869. results.push(el);
  12870. });
  12871. if (error) {
  12872. return _promise.default.reject(error);
  12873. }
  12874. var query = new _ParseQuery.default(className);
  12875. query.containedIn('objectId', ids);
  12876. if (options && options.include) {
  12877. query.include(options.include);
  12878. }
  12879. query._limit = ids.length;
  12880. return (0, _find.default)(query).call(query, options).then( /*#__PURE__*/function () {
  12881. var _ref = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regeneratorRuntime().mark(function _callee6(objects) {
  12882. var idMap, i, obj, _i, _obj, id, _iterator2, _step2, object;
  12883. return _regeneratorRuntime().wrap(function _callee6$(_context9) {
  12884. while (1) {
  12885. switch (_context9.prev = _context9.next) {
  12886. case 0:
  12887. idMap = {};
  12888. (0, _forEach.default)(objects).call(objects, function (o) {
  12889. idMap[o.id] = o;
  12890. });
  12891. i = 0;
  12892. case 3:
  12893. if (!(i < objs.length)) {
  12894. _context9.next = 11;
  12895. break;
  12896. }
  12897. obj = objs[i];
  12898. if (!(!obj || !obj.id || !idMap[obj.id])) {
  12899. _context9.next = 8;
  12900. break;
  12901. }
  12902. if (!forceFetch) {
  12903. _context9.next = 8;
  12904. break;
  12905. }
  12906. return _context9.abrupt("return", _promise.default.reject(new _ParseError.default(_ParseError.default.OBJECT_NOT_FOUND, 'All objects must exist on the server.')));
  12907. case 8:
  12908. i++;
  12909. _context9.next = 3;
  12910. break;
  12911. case 11:
  12912. if (!singleInstance) {
  12913. // If single instance objects are disabled, we need to replace the
  12914. for (_i = 0; _i < results.length; _i++) {
  12915. _obj = results[_i];
  12916. if (_obj && _obj.id && idMap[_obj.id]) {
  12917. id = _obj.id;
  12918. _obj._finishFetch(idMap[id].toJSON());
  12919. results[_i] = idMap[id];
  12920. }
  12921. }
  12922. }
  12923. _iterator2 = _createForOfIteratorHelper(results);
  12924. _context9.prev = 13;
  12925. _iterator2.s();
  12926. case 15:
  12927. if ((_step2 = _iterator2.n()).done) {
  12928. _context9.next = 21;
  12929. break;
  12930. }
  12931. object = _step2.value;
  12932. _context9.next = 19;
  12933. return localDatastore._updateObjectIfPinned(object);
  12934. case 19:
  12935. _context9.next = 15;
  12936. break;
  12937. case 21:
  12938. _context9.next = 26;
  12939. break;
  12940. case 23:
  12941. _context9.prev = 23;
  12942. _context9.t0 = _context9["catch"](13);
  12943. _iterator2.e(_context9.t0);
  12944. case 26:
  12945. _context9.prev = 26;
  12946. _iterator2.f();
  12947. return _context9.finish(26);
  12948. case 29:
  12949. return _context9.abrupt("return", _promise.default.resolve(results));
  12950. case 30:
  12951. case "end":
  12952. return _context9.stop();
  12953. }
  12954. }
  12955. }, _callee6, null, [[13, 23, 26, 29]]);
  12956. }));
  12957. return function (_x4) {
  12958. return _ref.apply(this, arguments);
  12959. };
  12960. }());
  12961. } else if (target instanceof ParseObject) {
  12962. if (!target.id) {
  12963. return _promise.default.reject(new _ParseError.default(_ParseError.default.MISSING_OBJECT_ID, 'Object does not have an ID'));
  12964. }
  12965. var RESTController = _CoreManager.default.getRESTController();
  12966. var params = {};
  12967. if (options && options.include) {
  12968. params.include = options.include.join();
  12969. }
  12970. return RESTController.request('GET', 'classes/' + target.className + '/' + target._getId(), params, options).then( /*#__PURE__*/function () {
  12971. var _ref2 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regeneratorRuntime().mark(function _callee7(response) {
  12972. return _regeneratorRuntime().wrap(function _callee7$(_context10) {
  12973. while (1) {
  12974. switch (_context10.prev = _context10.next) {
  12975. case 0:
  12976. target._clearPendingOps();
  12977. target._clearServerData();
  12978. target._finishFetch(response);
  12979. _context10.next = 5;
  12980. return localDatastore._updateObjectIfPinned(target);
  12981. case 5:
  12982. return _context10.abrupt("return", target);
  12983. case 6:
  12984. case "end":
  12985. return _context10.stop();
  12986. }
  12987. }
  12988. }, _callee7);
  12989. }));
  12990. return function (_x5) {
  12991. return _ref2.apply(this, arguments);
  12992. };
  12993. }());
  12994. }
  12995. return _promise.default.resolve();
  12996. },
  12997. destroy: function destroy(target
  12998. /*: ParseObject | Array<ParseObject>*/
  12999. , options
  13000. /*: RequestOptions*/
  13001. )
  13002. /*: Promise<Array<void> | ParseObject>*/
  13003. {
  13004. return (0, _asyncToGenerator2.default)( /*#__PURE__*/_regeneratorRuntime().mark(function _callee10() {
  13005. var batchSize, localDatastore, RESTController, batches, deleteCompleted, errors;
  13006. return _regeneratorRuntime().wrap(function _callee10$(_context13) {
  13007. while (1) {
  13008. switch (_context13.prev = _context13.next) {
  13009. case 0:
  13010. batchSize = options && options.batchSize ? options.batchSize : _CoreManager.default.get('REQUEST_BATCH_SIZE');
  13011. localDatastore = _CoreManager.default.getLocalDatastore();
  13012. RESTController = _CoreManager.default.getRESTController();
  13013. if (!(0, _isArray.default)(target)) {
  13014. _context13.next = 15;
  13015. break;
  13016. }
  13017. if (!(target.length < 1)) {
  13018. _context13.next = 6;
  13019. break;
  13020. }
  13021. return _context13.abrupt("return", _promise.default.resolve([]));
  13022. case 6:
  13023. batches = [[]];
  13024. (0, _forEach.default)(target).call(target, function (obj) {
  13025. if (!obj.id) {
  13026. return;
  13027. }
  13028. batches[batches.length - 1].push(obj);
  13029. if (batches[batches.length - 1].length >= batchSize) {
  13030. batches.push([]);
  13031. }
  13032. });
  13033. if (batches[batches.length - 1].length === 0) {
  13034. // If the last batch is empty, remove it
  13035. batches.pop();
  13036. }
  13037. deleteCompleted = _promise.default.resolve();
  13038. errors = [];
  13039. (0, _forEach.default)(batches).call(batches, function (batch) {
  13040. deleteCompleted = deleteCompleted.then(function () {
  13041. return RESTController.request('POST', 'batch', {
  13042. requests: (0, _map.default)(batch).call(batch, function (obj) {
  13043. return {
  13044. method: 'DELETE',
  13045. path: getServerUrlPath() + 'classes/' + obj.className + '/' + obj._getId(),
  13046. body: {}
  13047. };
  13048. })
  13049. }, options).then(function (results) {
  13050. for (var i = 0; i < results.length; i++) {
  13051. if (results[i] && results[i].hasOwnProperty('error')) {
  13052. var err = new _ParseError.default(results[i].error.code, results[i].error.error);
  13053. err.object = batch[i];
  13054. errors.push(err);
  13055. }
  13056. }
  13057. });
  13058. });
  13059. });
  13060. return _context13.abrupt("return", deleteCompleted.then( /*#__PURE__*/(0, _asyncToGenerator2.default)( /*#__PURE__*/_regeneratorRuntime().mark(function _callee8() {
  13061. var aggregate, _iterator3, _step3, object;
  13062. return _regeneratorRuntime().wrap(function _callee8$(_context11) {
  13063. while (1) {
  13064. switch (_context11.prev = _context11.next) {
  13065. case 0:
  13066. if (!errors.length) {
  13067. _context11.next = 4;
  13068. break;
  13069. }
  13070. aggregate = new _ParseError.default(_ParseError.default.AGGREGATE_ERROR);
  13071. aggregate.errors = errors;
  13072. return _context11.abrupt("return", _promise.default.reject(aggregate));
  13073. case 4:
  13074. _iterator3 = _createForOfIteratorHelper(target);
  13075. _context11.prev = 5;
  13076. _iterator3.s();
  13077. case 7:
  13078. if ((_step3 = _iterator3.n()).done) {
  13079. _context11.next = 13;
  13080. break;
  13081. }
  13082. object = _step3.value;
  13083. _context11.next = 11;
  13084. return localDatastore._destroyObjectIfPinned(object);
  13085. case 11:
  13086. _context11.next = 7;
  13087. break;
  13088. case 13:
  13089. _context11.next = 18;
  13090. break;
  13091. case 15:
  13092. _context11.prev = 15;
  13093. _context11.t0 = _context11["catch"](5);
  13094. _iterator3.e(_context11.t0);
  13095. case 18:
  13096. _context11.prev = 18;
  13097. _iterator3.f();
  13098. return _context11.finish(18);
  13099. case 21:
  13100. return _context11.abrupt("return", _promise.default.resolve(target));
  13101. case 22:
  13102. case "end":
  13103. return _context11.stop();
  13104. }
  13105. }
  13106. }, _callee8, null, [[5, 15, 18, 21]]);
  13107. }))));
  13108. case 15:
  13109. if (!(target instanceof ParseObject)) {
  13110. _context13.next = 17;
  13111. break;
  13112. }
  13113. return _context13.abrupt("return", RESTController.request('DELETE', 'classes/' + target.className + '/' + target._getId(), {}, options).then( /*#__PURE__*/(0, _asyncToGenerator2.default)( /*#__PURE__*/_regeneratorRuntime().mark(function _callee9() {
  13114. return _regeneratorRuntime().wrap(function _callee9$(_context12) {
  13115. while (1) {
  13116. switch (_context12.prev = _context12.next) {
  13117. case 0:
  13118. _context12.next = 2;
  13119. return localDatastore._destroyObjectIfPinned(target);
  13120. case 2:
  13121. return _context12.abrupt("return", _promise.default.resolve(target));
  13122. case 3:
  13123. case "end":
  13124. return _context12.stop();
  13125. }
  13126. }
  13127. }, _callee9);
  13128. }))));
  13129. case 17:
  13130. return _context13.abrupt("return", _promise.default.resolve(target));
  13131. case 18:
  13132. case "end":
  13133. return _context13.stop();
  13134. }
  13135. }
  13136. }, _callee10);
  13137. }))();
  13138. },
  13139. save: function save(target
  13140. /*: ParseObject | Array<ParseObject | ParseFile>*/
  13141. , options
  13142. /*: RequestOptions*/
  13143. ) {
  13144. var batchSize = options && options.batchSize ? options.batchSize : _CoreManager.default.get('REQUEST_BATCH_SIZE');
  13145. var localDatastore = _CoreManager.default.getLocalDatastore();
  13146. var mapIdForPin = {};
  13147. var RESTController = _CoreManager.default.getRESTController();
  13148. var stateController = _CoreManager.default.getObjectStateController();
  13149. var allowCustomObjectId = _CoreManager.default.get('ALLOW_CUSTOM_OBJECT_ID');
  13150. options = options || {};
  13151. options.returnStatus = options.returnStatus || true;
  13152. if ((0, _isArray.default)(target)) {
  13153. if (target.length < 1) {
  13154. return _promise.default.resolve([]);
  13155. }
  13156. var unsaved = (0, _concat.default)(target).call(target);
  13157. for (var i = 0; i < target.length; i++) {
  13158. if (target[i] instanceof ParseObject) {
  13159. unsaved = (0, _concat.default)(unsaved).call(unsaved, (0, _unsavedChildren.default)(target[i], true));
  13160. }
  13161. }
  13162. unsaved = (0, _unique.default)(unsaved);
  13163. var filesSaved
  13164. /*: Array<ParseFile>*/
  13165. = [];
  13166. var pending
  13167. /*: Array<ParseObject>*/
  13168. = [];
  13169. (0, _forEach.default)(unsaved).call(unsaved, function (el) {
  13170. if (el instanceof _ParseFile.default) {
  13171. filesSaved.push(el.save(options));
  13172. } else if (el instanceof ParseObject) {
  13173. pending.push(el);
  13174. }
  13175. });
  13176. return _promise.default.all(filesSaved).then(function () {
  13177. var objectError = null;
  13178. return (0, _promiseUtils.continueWhile)(function () {
  13179. return pending.length > 0;
  13180. }, function () {
  13181. var batch = [];
  13182. var nextPending = [];
  13183. (0, _forEach.default)(pending).call(pending, function (el) {
  13184. if (allowCustomObjectId && Object.prototype.hasOwnProperty.call(el, 'id') && !el.id) {
  13185. throw new _ParseError.default(_ParseError.default.MISSING_OBJECT_ID, 'objectId must not be empty or null');
  13186. }
  13187. if (batch.length < batchSize && (0, _canBeSerialized.default)(el)) {
  13188. batch.push(el);
  13189. } else {
  13190. nextPending.push(el);
  13191. }
  13192. });
  13193. pending = nextPending;
  13194. if (batch.length < 1) {
  13195. return _promise.default.reject(new _ParseError.default(_ParseError.default.OTHER_CAUSE, 'Tried to save a batch with a cycle.'));
  13196. } // Queue up tasks for each object in the batch.
  13197. // When every task is ready, the API request will execute
  13198. var batchReturned = new _promiseUtils.resolvingPromise();
  13199. var batchReady = [];
  13200. var batchTasks = [];
  13201. (0, _forEach.default)(batch).call(batch, function (obj, index) {
  13202. var ready = new _promiseUtils.resolvingPromise();
  13203. batchReady.push(ready);
  13204. var task = function task() {
  13205. ready.resolve();
  13206. return batchReturned.then(function (responses) {
  13207. if (responses[index].hasOwnProperty('success')) {
  13208. var objectId = responses[index].success.objectId;
  13209. var status = responses[index]._status;
  13210. delete responses[index]._status;
  13211. mapIdForPin[objectId] = obj._localId;
  13212. obj._handleSaveResponse(responses[index].success, status);
  13213. } else {
  13214. if (!objectError && responses[index].hasOwnProperty('error')) {
  13215. var serverError = responses[index].error;
  13216. objectError = new _ParseError.default(serverError.code, serverError.error); // Cancel the rest of the save
  13217. pending = [];
  13218. }
  13219. obj._handleSaveError();
  13220. }
  13221. });
  13222. };
  13223. stateController.pushPendingState(obj._getStateIdentifier());
  13224. batchTasks.push(stateController.enqueueTask(obj._getStateIdentifier(), task));
  13225. });
  13226. (0, _promiseUtils.when)(batchReady).then(function () {
  13227. // Kick off the batch request
  13228. return RESTController.request('POST', 'batch', {
  13229. requests: (0, _map.default)(batch).call(batch, function (obj) {
  13230. var params = obj._getSaveParams();
  13231. params.path = getServerUrlPath() + params.path;
  13232. return params;
  13233. })
  13234. }, options);
  13235. }).then(batchReturned.resolve, function (error) {
  13236. batchReturned.reject(new _ParseError.default(_ParseError.default.INCORRECT_TYPE, error.message));
  13237. });
  13238. return (0, _promiseUtils.when)(batchTasks);
  13239. }).then( /*#__PURE__*/(0, _asyncToGenerator2.default)( /*#__PURE__*/_regeneratorRuntime().mark(function _callee11() {
  13240. var _iterator4, _step4, object;
  13241. return _regeneratorRuntime().wrap(function _callee11$(_context14) {
  13242. while (1) {
  13243. switch (_context14.prev = _context14.next) {
  13244. case 0:
  13245. if (!objectError) {
  13246. _context14.next = 2;
  13247. break;
  13248. }
  13249. return _context14.abrupt("return", _promise.default.reject(objectError));
  13250. case 2:
  13251. _iterator4 = _createForOfIteratorHelper(target);
  13252. _context14.prev = 3;
  13253. _iterator4.s();
  13254. case 5:
  13255. if ((_step4 = _iterator4.n()).done) {
  13256. _context14.next = 13;
  13257. break;
  13258. }
  13259. object = _step4.value;
  13260. _context14.next = 9;
  13261. return localDatastore._updateLocalIdForObject(mapIdForPin[object.id], object);
  13262. case 9:
  13263. _context14.next = 11;
  13264. return localDatastore._updateObjectIfPinned(object);
  13265. case 11:
  13266. _context14.next = 5;
  13267. break;
  13268. case 13:
  13269. _context14.next = 18;
  13270. break;
  13271. case 15:
  13272. _context14.prev = 15;
  13273. _context14.t0 = _context14["catch"](3);
  13274. _iterator4.e(_context14.t0);
  13275. case 18:
  13276. _context14.prev = 18;
  13277. _iterator4.f();
  13278. return _context14.finish(18);
  13279. case 21:
  13280. return _context14.abrupt("return", _promise.default.resolve(target));
  13281. case 22:
  13282. case "end":
  13283. return _context14.stop();
  13284. }
  13285. }
  13286. }, _callee11, null, [[3, 15, 18, 21]]);
  13287. })));
  13288. });
  13289. } else if (target instanceof ParseObject) {
  13290. if (allowCustomObjectId && Object.prototype.hasOwnProperty.call(target, 'id') && !target.id) {
  13291. throw new _ParseError.default(_ParseError.default.MISSING_OBJECT_ID, 'objectId must not be empty or null');
  13292. } // generate _localId in case if cascadeSave=false
  13293. target._getId();
  13294. var localId = target._localId; // copying target lets Flow guarantee the pointer isn't modified elsewhere
  13295. var targetCopy = target;
  13296. var task = function task() {
  13297. var params = targetCopy._getSaveParams();
  13298. return RESTController.request(params.method, params.path, params.body, options).then(function (response) {
  13299. var status = response._status;
  13300. delete response._status;
  13301. targetCopy._handleSaveResponse(response, status);
  13302. }, function (error) {
  13303. targetCopy._handleSaveError();
  13304. return _promise.default.reject(error);
  13305. });
  13306. };
  13307. stateController.pushPendingState(target._getStateIdentifier());
  13308. return stateController.enqueueTask(target._getStateIdentifier(), task).then( /*#__PURE__*/(0, _asyncToGenerator2.default)( /*#__PURE__*/_regeneratorRuntime().mark(function _callee12() {
  13309. return _regeneratorRuntime().wrap(function _callee12$(_context15) {
  13310. while (1) {
  13311. switch (_context15.prev = _context15.next) {
  13312. case 0:
  13313. _context15.next = 2;
  13314. return localDatastore._updateLocalIdForObject(localId, target);
  13315. case 2:
  13316. _context15.next = 4;
  13317. return localDatastore._updateObjectIfPinned(target);
  13318. case 4:
  13319. return _context15.abrupt("return", target);
  13320. case 5:
  13321. case "end":
  13322. return _context15.stop();
  13323. }
  13324. }
  13325. }, _callee12);
  13326. })), function (error) {
  13327. return _promise.default.reject(error);
  13328. });
  13329. }
  13330. return _promise.default.resolve();
  13331. }
  13332. };
  13333. _CoreManager.default.setObjectController(DefaultController);
  13334. var _default = ParseObject;
  13335. exports.default = _default;
  13336. },{"./CoreManager":4,"./EventuallyQueue":7,"./LocalDatastoreUtils":15,"./ParseACL":19,"./ParseError":22,"./ParseFile":23,"./ParseOp":28,"./ParseQuery":30,"./ParseRelation":31,"./SingleInstanceStateController":38,"./UniqueInstanceStateController":42,"./canBeSerialized":44,"./decode":45,"./encode":46,"./escape":48,"./parseDate":50,"./promiseUtils":51,"./unique":52,"./unsavedChildren":53,"./uuid":54,"@babel/runtime-corejs3/core-js-stable/array/from":55,"@babel/runtime-corejs3/core-js-stable/array/is-array":56,"@babel/runtime-corejs3/core-js-stable/instance/concat":58,"@babel/runtime-corejs3/core-js-stable/instance/filter":61,"@babel/runtime-corejs3/core-js-stable/instance/find":63,"@babel/runtime-corejs3/core-js-stable/instance/for-each":64,"@babel/runtime-corejs3/core-js-stable/instance/includes":65,"@babel/runtime-corejs3/core-js-stable/instance/index-of":66,"@babel/runtime-corejs3/core-js-stable/instance/map":68,"@babel/runtime-corejs3/core-js-stable/instance/reverse":70,"@babel/runtime-corejs3/core-js-stable/instance/slice":71,"@babel/runtime-corejs3/core-js-stable/json/stringify":76,"@babel/runtime-corejs3/core-js-stable/object/create":80,"@babel/runtime-corejs3/core-js-stable/object/define-properties":81,"@babel/runtime-corejs3/core-js-stable/object/define-property":82,"@babel/runtime-corejs3/core-js-stable/object/freeze":84,"@babel/runtime-corejs3/core-js-stable/object/get-own-property-descriptor":85,"@babel/runtime-corejs3/core-js-stable/object/get-own-property-descriptors":86,"@babel/runtime-corejs3/core-js-stable/object/get-own-property-symbols":87,"@babel/runtime-corejs3/core-js-stable/object/get-prototype-of":88,"@babel/runtime-corejs3/core-js-stable/object/keys":89,"@babel/runtime-corejs3/core-js-stable/object/set-prototype-of":90,"@babel/runtime-corejs3/core-js-stable/promise":92,"@babel/runtime-corejs3/core-js-stable/symbol":97,"@babel/runtime-corejs3/core-js-stable/weak-map":98,"@babel/runtime-corejs3/core-js/get-iterator-method":101,"@babel/runtime-corejs3/helpers/asyncToGenerator":120,"@babel/runtime-corejs3/helpers/classCallCheck":121,"@babel/runtime-corejs3/helpers/createClass":123,"@babel/runtime-corejs3/helpers/defineProperty":124,"@babel/runtime-corejs3/helpers/interopRequireDefault":128,"@babel/runtime-corejs3/helpers/typeof":140}],28:[function(_dereq_,module,exports){
  13337. "use strict";
  13338. var _interopRequireDefault = _dereq_("@babel/runtime-corejs3/helpers/interopRequireDefault");
  13339. var _Object$defineProperty = _dereq_("@babel/runtime-corejs3/core-js-stable/object/define-property");
  13340. var _Reflect$construct = _dereq_("@babel/runtime-corejs3/core-js-stable/reflect/construct");
  13341. _Object$defineProperty(exports, "__esModule", {
  13342. value: true
  13343. });
  13344. exports.UnsetOp = exports.SetOp = exports.RemoveOp = exports.RelationOp = exports.Op = exports.IncrementOp = exports.AddUniqueOp = exports.AddOp = void 0;
  13345. exports.opFromJSON = opFromJSON;
  13346. var _map = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/instance/map"));
  13347. var _splice = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/instance/splice"));
  13348. var _indexOf = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/instance/index-of"));
  13349. var _forEach = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/instance/for-each"));
  13350. var _assertThisInitialized2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/helpers/assertThisInitialized"));
  13351. var _inherits2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/helpers/inherits"));
  13352. var _possibleConstructorReturn2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/helpers/possibleConstructorReturn"));
  13353. var _getPrototypeOf2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/helpers/getPrototypeOf"));
  13354. var _defineProperty2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/helpers/defineProperty"));
  13355. var _classCallCheck2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/helpers/classCallCheck"));
  13356. var _createClass2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/helpers/createClass"));
  13357. var _concat = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/instance/concat"));
  13358. var _isArray = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/array/is-array"));
  13359. var _arrayContainsObject = _interopRequireDefault(_dereq_("./arrayContainsObject"));
  13360. var _decode = _interopRequireDefault(_dereq_("./decode"));
  13361. var _encode = _interopRequireDefault(_dereq_("./encode"));
  13362. var _ParseObject = _interopRequireDefault(_dereq_("./ParseObject"));
  13363. var _ParseRelation = _interopRequireDefault(_dereq_("./ParseRelation"));
  13364. var _unique = _interopRequireDefault(_dereq_("./unique"));
  13365. function _createSuper(Derived) {
  13366. var hasNativeReflectConstruct = _isNativeReflectConstruct();
  13367. return function () {
  13368. var Super = (0, _getPrototypeOf2.default)(Derived),
  13369. result;
  13370. if (hasNativeReflectConstruct) {
  13371. var NewTarget = (0, _getPrototypeOf2.default)(this).constructor;
  13372. result = _Reflect$construct(Super, arguments, NewTarget);
  13373. } else {
  13374. result = Super.apply(this, arguments);
  13375. }
  13376. return (0, _possibleConstructorReturn2.default)(this, result);
  13377. };
  13378. }
  13379. function _isNativeReflectConstruct() {
  13380. if (typeof Reflect === "undefined" || !_Reflect$construct) return false;
  13381. if (_Reflect$construct.sham) return false;
  13382. if (typeof Proxy === "function") return true;
  13383. try {
  13384. Boolean.prototype.valueOf.call(_Reflect$construct(Boolean, [], function () {}));
  13385. return true;
  13386. } catch (e) {
  13387. return false;
  13388. }
  13389. }
  13390. function opFromJSON(json
  13391. /*: { [key: string]: any }*/
  13392. )
  13393. /*: ?Op*/
  13394. {
  13395. if (!json || !json.__op) {
  13396. return null;
  13397. }
  13398. switch (json.__op) {
  13399. case 'Delete':
  13400. return new UnsetOp();
  13401. case 'Increment':
  13402. return new IncrementOp(json.amount);
  13403. case 'Add':
  13404. return new AddOp((0, _decode.default)(json.objects));
  13405. case 'AddUnique':
  13406. return new AddUniqueOp((0, _decode.default)(json.objects));
  13407. case 'Remove':
  13408. return new RemoveOp((0, _decode.default)(json.objects));
  13409. case 'AddRelation':
  13410. {
  13411. var toAdd = (0, _decode.default)(json.objects);
  13412. if (!(0, _isArray.default)(toAdd)) {
  13413. return new RelationOp([], []);
  13414. }
  13415. return new RelationOp(toAdd, []);
  13416. }
  13417. case 'RemoveRelation':
  13418. {
  13419. var toRemove = (0, _decode.default)(json.objects);
  13420. if (!(0, _isArray.default)(toRemove)) {
  13421. return new RelationOp([], []);
  13422. }
  13423. return new RelationOp([], toRemove);
  13424. }
  13425. case 'Batch':
  13426. {
  13427. var _toAdd = [];
  13428. var _toRemove = [];
  13429. for (var i = 0; i < json.ops.length; i++) {
  13430. if (json.ops[i].__op === 'AddRelation') {
  13431. _toAdd = (0, _concat.default)(_toAdd).call(_toAdd, (0, _decode.default)(json.ops[i].objects));
  13432. } else if (json.ops[i].__op === 'RemoveRelation') {
  13433. _toRemove = (0, _concat.default)(_toRemove).call(_toRemove, (0, _decode.default)(json.ops[i].objects));
  13434. }
  13435. }
  13436. return new RelationOp(_toAdd, _toRemove);
  13437. }
  13438. }
  13439. return null;
  13440. }
  13441. var Op = /*#__PURE__*/function () {
  13442. function Op() {
  13443. (0, _classCallCheck2.default)(this, Op);
  13444. }
  13445. (0, _createClass2.default)(Op, [{
  13446. key: "applyTo",
  13447. value: // Empty parent class
  13448. function ()
  13449. /*: mixed*/
  13450. {}
  13451. /* eslint-disable-line no-unused-vars */
  13452. }, {
  13453. key: "mergeWith",
  13454. value: function ()
  13455. /*: ?Op*/
  13456. {}
  13457. /* eslint-disable-line no-unused-vars */
  13458. }, {
  13459. key: "toJSON",
  13460. value: function ()
  13461. /*: mixed*/
  13462. {}
  13463. }]);
  13464. return Op;
  13465. }();
  13466. exports.Op = Op;
  13467. var SetOp = /*#__PURE__*/function (_Op) {
  13468. (0, _inherits2.default)(SetOp, _Op);
  13469. var _super = _createSuper(SetOp);
  13470. function SetOp(value
  13471. /*: mixed*/
  13472. ) {
  13473. var _this;
  13474. (0, _classCallCheck2.default)(this, SetOp);
  13475. _this = _super.call(this);
  13476. (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "_value", void 0);
  13477. _this._value = value;
  13478. return _this;
  13479. }
  13480. (0, _createClass2.default)(SetOp, [{
  13481. key: "applyTo",
  13482. value: function ()
  13483. /*: mixed*/
  13484. {
  13485. return this._value;
  13486. }
  13487. }, {
  13488. key: "mergeWith",
  13489. value: function ()
  13490. /*: SetOp*/
  13491. {
  13492. return new SetOp(this._value);
  13493. }
  13494. }, {
  13495. key: "toJSON",
  13496. value: function (offline
  13497. /*:: ?: boolean*/
  13498. ) {
  13499. return (0, _encode.default)(this._value, false, true, undefined, offline);
  13500. }
  13501. }]);
  13502. return SetOp;
  13503. }(Op);
  13504. exports.SetOp = SetOp;
  13505. var UnsetOp = /*#__PURE__*/function (_Op2) {
  13506. (0, _inherits2.default)(UnsetOp, _Op2);
  13507. var _super2 = _createSuper(UnsetOp);
  13508. function UnsetOp() {
  13509. (0, _classCallCheck2.default)(this, UnsetOp);
  13510. return _super2.apply(this, arguments);
  13511. }
  13512. (0, _createClass2.default)(UnsetOp, [{
  13513. key: "applyTo",
  13514. value: function () {
  13515. return undefined;
  13516. }
  13517. }, {
  13518. key: "mergeWith",
  13519. value: function ()
  13520. /*: UnsetOp*/
  13521. {
  13522. return new UnsetOp();
  13523. }
  13524. }, {
  13525. key: "toJSON",
  13526. value: function ()
  13527. /*: { __op: string }*/
  13528. {
  13529. return {
  13530. __op: 'Delete'
  13531. };
  13532. }
  13533. }]);
  13534. return UnsetOp;
  13535. }(Op);
  13536. exports.UnsetOp = UnsetOp;
  13537. var IncrementOp = /*#__PURE__*/function (_Op3) {
  13538. (0, _inherits2.default)(IncrementOp, _Op3);
  13539. var _super3 = _createSuper(IncrementOp);
  13540. function IncrementOp(amount
  13541. /*: number*/
  13542. ) {
  13543. var _this2;
  13544. (0, _classCallCheck2.default)(this, IncrementOp);
  13545. _this2 = _super3.call(this);
  13546. (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this2), "_amount", void 0);
  13547. if (typeof amount !== 'number') {
  13548. throw new TypeError('Increment Op must be initialized with a numeric amount.');
  13549. }
  13550. _this2._amount = amount;
  13551. return _this2;
  13552. }
  13553. (0, _createClass2.default)(IncrementOp, [{
  13554. key: "applyTo",
  13555. value: function (value
  13556. /*: ?mixed*/
  13557. )
  13558. /*: number*/
  13559. {
  13560. if (typeof value === 'undefined') {
  13561. return this._amount;
  13562. }
  13563. if (typeof value !== 'number') {
  13564. throw new TypeError('Cannot increment a non-numeric value.');
  13565. }
  13566. return this._amount + value;
  13567. }
  13568. }, {
  13569. key: "mergeWith",
  13570. value: function (previous
  13571. /*: Op*/
  13572. )
  13573. /*: Op*/
  13574. {
  13575. if (!previous) {
  13576. return this;
  13577. }
  13578. if (previous instanceof SetOp) {
  13579. return new SetOp(this.applyTo(previous._value));
  13580. }
  13581. if (previous instanceof UnsetOp) {
  13582. return new SetOp(this._amount);
  13583. }
  13584. if (previous instanceof IncrementOp) {
  13585. return new IncrementOp(this.applyTo(previous._amount));
  13586. }
  13587. throw new Error('Cannot merge Increment Op with the previous Op');
  13588. }
  13589. }, {
  13590. key: "toJSON",
  13591. value: function ()
  13592. /*: { __op: string, amount: number }*/
  13593. {
  13594. return {
  13595. __op: 'Increment',
  13596. amount: this._amount
  13597. };
  13598. }
  13599. }]);
  13600. return IncrementOp;
  13601. }(Op);
  13602. exports.IncrementOp = IncrementOp;
  13603. var AddOp = /*#__PURE__*/function (_Op4) {
  13604. (0, _inherits2.default)(AddOp, _Op4);
  13605. var _super4 = _createSuper(AddOp);
  13606. function AddOp(value
  13607. /*: mixed | Array<mixed>*/
  13608. ) {
  13609. var _this3;
  13610. (0, _classCallCheck2.default)(this, AddOp);
  13611. _this3 = _super4.call(this);
  13612. (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this3), "_value", void 0);
  13613. _this3._value = (0, _isArray.default)(value) ? value : [value];
  13614. return _this3;
  13615. }
  13616. (0, _createClass2.default)(AddOp, [{
  13617. key: "applyTo",
  13618. value: function (value
  13619. /*: mixed*/
  13620. )
  13621. /*: Array<mixed>*/
  13622. {
  13623. if (value == null) {
  13624. return this._value;
  13625. }
  13626. if ((0, _isArray.default)(value)) {
  13627. return (0, _concat.default)(value).call(value, this._value);
  13628. }
  13629. throw new Error('Cannot add elements to a non-array value');
  13630. }
  13631. }, {
  13632. key: "mergeWith",
  13633. value: function (previous
  13634. /*: Op*/
  13635. )
  13636. /*: Op*/
  13637. {
  13638. if (!previous) {
  13639. return this;
  13640. }
  13641. if (previous instanceof SetOp) {
  13642. return new SetOp(this.applyTo(previous._value));
  13643. }
  13644. if (previous instanceof UnsetOp) {
  13645. return new SetOp(this._value);
  13646. }
  13647. if (previous instanceof AddOp) {
  13648. return new AddOp(this.applyTo(previous._value));
  13649. }
  13650. throw new Error('Cannot merge Add Op with the previous Op');
  13651. }
  13652. }, {
  13653. key: "toJSON",
  13654. value: function ()
  13655. /*: { __op: string, objects: mixed }*/
  13656. {
  13657. return {
  13658. __op: 'Add',
  13659. objects: (0, _encode.default)(this._value, false, true)
  13660. };
  13661. }
  13662. }]);
  13663. return AddOp;
  13664. }(Op);
  13665. exports.AddOp = AddOp;
  13666. var AddUniqueOp = /*#__PURE__*/function (_Op5) {
  13667. (0, _inherits2.default)(AddUniqueOp, _Op5);
  13668. var _super5 = _createSuper(AddUniqueOp);
  13669. function AddUniqueOp(value
  13670. /*: mixed | Array<mixed>*/
  13671. ) {
  13672. var _this4;
  13673. (0, _classCallCheck2.default)(this, AddUniqueOp);
  13674. _this4 = _super5.call(this);
  13675. (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this4), "_value", void 0);
  13676. _this4._value = (0, _unique.default)((0, _isArray.default)(value) ? value : [value]);
  13677. return _this4;
  13678. }
  13679. (0, _createClass2.default)(AddUniqueOp, [{
  13680. key: "applyTo",
  13681. value: function (value
  13682. /*: mixed | Array<mixed>*/
  13683. )
  13684. /*: Array<mixed>*/
  13685. {
  13686. if (value == null) {
  13687. return this._value || [];
  13688. }
  13689. if ((0, _isArray.default)(value)) {
  13690. var _context;
  13691. var toAdd = [];
  13692. (0, _forEach.default)(_context = this._value).call(_context, function (v) {
  13693. if (v instanceof _ParseObject.default) {
  13694. if (!(0, _arrayContainsObject.default)(value, v)) {
  13695. toAdd.push(v);
  13696. }
  13697. } else {
  13698. if ((0, _indexOf.default)(value).call(value, v) < 0) {
  13699. toAdd.push(v);
  13700. }
  13701. }
  13702. });
  13703. return (0, _concat.default)(value).call(value, toAdd);
  13704. }
  13705. throw new Error('Cannot add elements to a non-array value');
  13706. }
  13707. }, {
  13708. key: "mergeWith",
  13709. value: function (previous
  13710. /*: Op*/
  13711. )
  13712. /*: Op*/
  13713. {
  13714. if (!previous) {
  13715. return this;
  13716. }
  13717. if (previous instanceof SetOp) {
  13718. return new SetOp(this.applyTo(previous._value));
  13719. }
  13720. if (previous instanceof UnsetOp) {
  13721. return new SetOp(this._value);
  13722. }
  13723. if (previous instanceof AddUniqueOp) {
  13724. return new AddUniqueOp(this.applyTo(previous._value));
  13725. }
  13726. throw new Error('Cannot merge AddUnique Op with the previous Op');
  13727. }
  13728. }, {
  13729. key: "toJSON",
  13730. value: function ()
  13731. /*: { __op: string, objects: mixed }*/
  13732. {
  13733. return {
  13734. __op: 'AddUnique',
  13735. objects: (0, _encode.default)(this._value, false, true)
  13736. };
  13737. }
  13738. }]);
  13739. return AddUniqueOp;
  13740. }(Op);
  13741. exports.AddUniqueOp = AddUniqueOp;
  13742. var RemoveOp = /*#__PURE__*/function (_Op6) {
  13743. (0, _inherits2.default)(RemoveOp, _Op6);
  13744. var _super6 = _createSuper(RemoveOp);
  13745. function RemoveOp(value
  13746. /*: mixed | Array<mixed>*/
  13747. ) {
  13748. var _this5;
  13749. (0, _classCallCheck2.default)(this, RemoveOp);
  13750. _this5 = _super6.call(this);
  13751. (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this5), "_value", void 0);
  13752. _this5._value = (0, _unique.default)((0, _isArray.default)(value) ? value : [value]);
  13753. return _this5;
  13754. }
  13755. (0, _createClass2.default)(RemoveOp, [{
  13756. key: "applyTo",
  13757. value: function (value
  13758. /*: mixed | Array<mixed>*/
  13759. )
  13760. /*: Array<mixed>*/
  13761. {
  13762. if (value == null) {
  13763. return [];
  13764. }
  13765. if ((0, _isArray.default)(value)) {
  13766. // var i = value.indexOf(this._value);
  13767. var removed = (0, _concat.default)(value).call(value, []);
  13768. for (var i = 0; i < this._value.length; i++) {
  13769. var index = (0, _indexOf.default)(removed).call(removed, this._value[i]);
  13770. while (index > -1) {
  13771. (0, _splice.default)(removed).call(removed, index, 1);
  13772. index = (0, _indexOf.default)(removed).call(removed, this._value[i]);
  13773. }
  13774. if (this._value[i] instanceof _ParseObject.default && this._value[i].id) {
  13775. for (var j = 0; j < removed.length; j++) {
  13776. if (removed[j] instanceof _ParseObject.default && this._value[i].id === removed[j].id) {
  13777. (0, _splice.default)(removed).call(removed, j, 1);
  13778. j--;
  13779. }
  13780. }
  13781. }
  13782. }
  13783. return removed;
  13784. }
  13785. throw new Error('Cannot remove elements from a non-array value');
  13786. }
  13787. }, {
  13788. key: "mergeWith",
  13789. value: function (previous
  13790. /*: Op*/
  13791. )
  13792. /*: Op*/
  13793. {
  13794. if (!previous) {
  13795. return this;
  13796. }
  13797. if (previous instanceof SetOp) {
  13798. return new SetOp(this.applyTo(previous._value));
  13799. }
  13800. if (previous instanceof UnsetOp) {
  13801. return new UnsetOp();
  13802. }
  13803. if (previous instanceof RemoveOp) {
  13804. var _context2;
  13805. var uniques = (0, _concat.default)(_context2 = previous._value).call(_context2, []);
  13806. for (var i = 0; i < this._value.length; i++) {
  13807. if (this._value[i] instanceof _ParseObject.default) {
  13808. if (!(0, _arrayContainsObject.default)(uniques, this._value[i])) {
  13809. uniques.push(this._value[i]);
  13810. }
  13811. } else {
  13812. if ((0, _indexOf.default)(uniques).call(uniques, this._value[i]) < 0) {
  13813. uniques.push(this._value[i]);
  13814. }
  13815. }
  13816. }
  13817. return new RemoveOp(uniques);
  13818. }
  13819. throw new Error('Cannot merge Remove Op with the previous Op');
  13820. }
  13821. }, {
  13822. key: "toJSON",
  13823. value: function ()
  13824. /*: { __op: string, objects: mixed }*/
  13825. {
  13826. return {
  13827. __op: 'Remove',
  13828. objects: (0, _encode.default)(this._value, false, true)
  13829. };
  13830. }
  13831. }]);
  13832. return RemoveOp;
  13833. }(Op);
  13834. exports.RemoveOp = RemoveOp;
  13835. var RelationOp = /*#__PURE__*/function (_Op7) {
  13836. (0, _inherits2.default)(RelationOp, _Op7);
  13837. var _super7 = _createSuper(RelationOp);
  13838. function RelationOp(adds
  13839. /*: Array<ParseObject | string>*/
  13840. , removes
  13841. /*: Array<ParseObject | string>*/
  13842. ) {
  13843. var _this6;
  13844. (0, _classCallCheck2.default)(this, RelationOp);
  13845. _this6 = _super7.call(this);
  13846. (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this6), "_targetClassName", void 0);
  13847. (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this6), "relationsToAdd", void 0);
  13848. (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this6), "relationsToRemove", void 0);
  13849. _this6._targetClassName = null;
  13850. if ((0, _isArray.default)(adds)) {
  13851. _this6.relationsToAdd = (0, _unique.default)((0, _map.default)(adds).call(adds, _this6._extractId, (0, _assertThisInitialized2.default)(_this6)));
  13852. }
  13853. if ((0, _isArray.default)(removes)) {
  13854. _this6.relationsToRemove = (0, _unique.default)((0, _map.default)(removes).call(removes, _this6._extractId, (0, _assertThisInitialized2.default)(_this6)));
  13855. }
  13856. return _this6;
  13857. }
  13858. (0, _createClass2.default)(RelationOp, [{
  13859. key: "_extractId",
  13860. value: function (obj
  13861. /*: string | ParseObject*/
  13862. )
  13863. /*: string*/
  13864. {
  13865. if (typeof obj === 'string') {
  13866. return obj;
  13867. }
  13868. if (!obj.id) {
  13869. throw new Error('You cannot add or remove an unsaved Parse Object from a relation');
  13870. }
  13871. if (!this._targetClassName) {
  13872. this._targetClassName = obj.className;
  13873. }
  13874. if (this._targetClassName !== obj.className) {
  13875. throw new Error('Tried to create a Relation with 2 different object types: ' + this._targetClassName + ' and ' + obj.className + '.');
  13876. }
  13877. return obj.id;
  13878. }
  13879. }, {
  13880. key: "applyTo",
  13881. value: function (value
  13882. /*: mixed*/
  13883. , object
  13884. /*:: ?: { className: string, id: ?string }*/
  13885. , key
  13886. /*:: ?: string*/
  13887. )
  13888. /*: ?ParseRelation*/
  13889. {
  13890. if (!value) {
  13891. var _context3;
  13892. if (!object || !key) {
  13893. throw new Error('Cannot apply a RelationOp without either a previous value, or an object and a key');
  13894. }
  13895. var parent = new _ParseObject.default(object.className);
  13896. if (object.id && (0, _indexOf.default)(_context3 = object.id).call(_context3, 'local') === 0) {
  13897. parent._localId = object.id;
  13898. } else if (object.id) {
  13899. parent.id = object.id;
  13900. }
  13901. var relation = new _ParseRelation.default(parent, key);
  13902. relation.targetClassName = this._targetClassName;
  13903. return relation;
  13904. }
  13905. if (value instanceof _ParseRelation.default) {
  13906. if (this._targetClassName) {
  13907. if (value.targetClassName) {
  13908. if (this._targetClassName !== value.targetClassName) {
  13909. throw new Error('Related object must be a ' + value.targetClassName + ', but a ' + this._targetClassName + ' was passed in.');
  13910. }
  13911. } else {
  13912. value.targetClassName = this._targetClassName;
  13913. }
  13914. }
  13915. return value;
  13916. } else {
  13917. throw new Error('Relation cannot be applied to a non-relation field');
  13918. }
  13919. }
  13920. }, {
  13921. key: "mergeWith",
  13922. value: function (previous
  13923. /*: Op*/
  13924. )
  13925. /*: Op*/
  13926. {
  13927. if (!previous) {
  13928. return this;
  13929. } else if (previous instanceof UnsetOp) {
  13930. throw new Error('You cannot modify a relation after deleting it.');
  13931. } else if (previous instanceof SetOp && previous._value instanceof _ParseRelation.default) {
  13932. return this;
  13933. } else if (previous instanceof RelationOp) {
  13934. var _context4, _context5, _context6, _context7, _context8, _context9;
  13935. if (previous._targetClassName && previous._targetClassName !== this._targetClassName) {
  13936. throw new Error('Related object must be of class ' + previous._targetClassName + ', but ' + (this._targetClassName || 'null') + ' was passed in.');
  13937. }
  13938. var newAdd = (0, _concat.default)(_context4 = previous.relationsToAdd).call(_context4, []);
  13939. (0, _forEach.default)(_context5 = this.relationsToRemove).call(_context5, function (r) {
  13940. var index = (0, _indexOf.default)(newAdd).call(newAdd, r);
  13941. if (index > -1) {
  13942. (0, _splice.default)(newAdd).call(newAdd, index, 1);
  13943. }
  13944. });
  13945. (0, _forEach.default)(_context6 = this.relationsToAdd).call(_context6, function (r) {
  13946. var index = (0, _indexOf.default)(newAdd).call(newAdd, r);
  13947. if (index < 0) {
  13948. newAdd.push(r);
  13949. }
  13950. });
  13951. var newRemove = (0, _concat.default)(_context7 = previous.relationsToRemove).call(_context7, []);
  13952. (0, _forEach.default)(_context8 = this.relationsToAdd).call(_context8, function (r) {
  13953. var index = (0, _indexOf.default)(newRemove).call(newRemove, r);
  13954. if (index > -1) {
  13955. (0, _splice.default)(newRemove).call(newRemove, index, 1);
  13956. }
  13957. });
  13958. (0, _forEach.default)(_context9 = this.relationsToRemove).call(_context9, function (r) {
  13959. var index = (0, _indexOf.default)(newRemove).call(newRemove, r);
  13960. if (index < 0) {
  13961. newRemove.push(r);
  13962. }
  13963. });
  13964. var newRelation = new RelationOp(newAdd, newRemove);
  13965. newRelation._targetClassName = this._targetClassName;
  13966. return newRelation;
  13967. }
  13968. throw new Error('Cannot merge Relation Op with the previous Op');
  13969. }
  13970. }, {
  13971. key: "toJSON",
  13972. value: function ()
  13973. /*: { __op?: string, objects?: mixed, ops?: mixed }*/
  13974. {
  13975. var _this7 = this;
  13976. var idToPointer = function (id) {
  13977. return {
  13978. __type: 'Pointer',
  13979. className: _this7._targetClassName,
  13980. objectId: id
  13981. };
  13982. };
  13983. var adds = null;
  13984. var removes = null;
  13985. var pointers = null;
  13986. if (this.relationsToAdd.length > 0) {
  13987. var _context10;
  13988. pointers = (0, _map.default)(_context10 = this.relationsToAdd).call(_context10, idToPointer);
  13989. adds = {
  13990. __op: 'AddRelation',
  13991. objects: pointers
  13992. };
  13993. }
  13994. if (this.relationsToRemove.length > 0) {
  13995. var _context11;
  13996. pointers = (0, _map.default)(_context11 = this.relationsToRemove).call(_context11, idToPointer);
  13997. removes = {
  13998. __op: 'RemoveRelation',
  13999. objects: pointers
  14000. };
  14001. }
  14002. if (adds && removes) {
  14003. return {
  14004. __op: 'Batch',
  14005. ops: [adds, removes]
  14006. };
  14007. }
  14008. return adds || removes || {};
  14009. }
  14010. }]);
  14011. return RelationOp;
  14012. }(Op);
  14013. exports.RelationOp = RelationOp;
  14014. },{"./ParseObject":27,"./ParseRelation":31,"./arrayContainsObject":43,"./decode":45,"./encode":46,"./unique":52,"@babel/runtime-corejs3/core-js-stable/array/is-array":56,"@babel/runtime-corejs3/core-js-stable/instance/concat":58,"@babel/runtime-corejs3/core-js-stable/instance/for-each":64,"@babel/runtime-corejs3/core-js-stable/instance/index-of":66,"@babel/runtime-corejs3/core-js-stable/instance/map":68,"@babel/runtime-corejs3/core-js-stable/instance/splice":73,"@babel/runtime-corejs3/core-js-stable/object/define-property":82,"@babel/runtime-corejs3/core-js-stable/reflect/construct":93,"@babel/runtime-corejs3/helpers/assertThisInitialized":119,"@babel/runtime-corejs3/helpers/classCallCheck":121,"@babel/runtime-corejs3/helpers/createClass":123,"@babel/runtime-corejs3/helpers/defineProperty":124,"@babel/runtime-corejs3/helpers/getPrototypeOf":126,"@babel/runtime-corejs3/helpers/inherits":127,"@babel/runtime-corejs3/helpers/interopRequireDefault":128,"@babel/runtime-corejs3/helpers/possibleConstructorReturn":135}],29:[function(_dereq_,module,exports){
  14015. "use strict";
  14016. var _interopRequireDefault = _dereq_("@babel/runtime-corejs3/helpers/interopRequireDefault");
  14017. var _Object$defineProperty = _dereq_("@babel/runtime-corejs3/core-js-stable/object/define-property");
  14018. _Object$defineProperty(exports, "__esModule", {
  14019. value: true
  14020. });
  14021. exports.default = void 0;
  14022. var _isArray = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/array/is-array"));
  14023. var _classCallCheck2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/helpers/classCallCheck"));
  14024. var _createClass2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/helpers/createClass"));
  14025. var _defineProperty2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/helpers/defineProperty"));
  14026. var _ParseGeoPoint = _interopRequireDefault(_dereq_("./ParseGeoPoint"));
  14027. /**
  14028. * Copyright (c) 2015-present, Parse, LLC.
  14029. * All rights reserved.
  14030. *
  14031. * This source code is licensed under the BSD-style license found in the
  14032. * LICENSE file in the root directory of this source tree. An additional grant
  14033. * of patent rights can be found in the PATENTS file in the same directory.
  14034. *
  14035. * @flow
  14036. */
  14037. /**
  14038. * Creates a new Polygon with any of the following forms:<br>
  14039. * <pre>
  14040. * new Polygon([[0,0],[0,1],[1,1],[1,0]])
  14041. * new Polygon([GeoPoint, GeoPoint, GeoPoint])
  14042. * </pre>
  14043. *
  14044. * <p>Represents a coordinates that may be associated
  14045. * with a key in a ParseObject or used as a reference point for geo queries.
  14046. * This allows proximity-based queries on the key.</p>
  14047. *
  14048. * <p>Example:<pre>
  14049. * var polygon = new Parse.Polygon([[0,0],[0,1],[1,1],[1,0]]);
  14050. * var object = new Parse.Object("PlaceObject");
  14051. * object.set("area", polygon);
  14052. * object.save();</pre></p>
  14053. *
  14054. * @alias Parse.Polygon
  14055. */
  14056. var ParsePolygon = /*#__PURE__*/function () {
  14057. /**
  14058. * @param {(number[][] | Parse.GeoPoint[])} coordinates An Array of coordinate pairs
  14059. */
  14060. function ParsePolygon(coordinates
  14061. /*: Array<Array<number>> | Array<ParseGeoPoint>*/
  14062. ) {
  14063. (0, _classCallCheck2.default)(this, ParsePolygon);
  14064. (0, _defineProperty2.default)(this, "_coordinates", void 0);
  14065. this._coordinates = ParsePolygon._validate(coordinates);
  14066. }
  14067. /**
  14068. * Coordinates value for this Polygon.
  14069. * Throws an exception if not valid type.
  14070. *
  14071. * @property {(number[][] | Parse.GeoPoint[])} coordinates list of coordinates
  14072. * @returns {number[][]}
  14073. */
  14074. (0, _createClass2.default)(ParsePolygon, [{
  14075. key: "coordinates",
  14076. get: function ()
  14077. /*: Array<Array<number>>*/
  14078. {
  14079. return this._coordinates;
  14080. },
  14081. set: function (coords
  14082. /*: Array<Array<number>> | Array<ParseGeoPoint>*/
  14083. ) {
  14084. this._coordinates = ParsePolygon._validate(coords);
  14085. }
  14086. /**
  14087. * Returns a JSON representation of the Polygon, suitable for Parse.
  14088. *
  14089. * @returns {object}
  14090. */
  14091. }, {
  14092. key: "toJSON",
  14093. value: function ()
  14094. /*: { __type: string, coordinates: Array<Array<number>> }*/
  14095. {
  14096. ParsePolygon._validate(this._coordinates);
  14097. return {
  14098. __type: 'Polygon',
  14099. coordinates: this._coordinates
  14100. };
  14101. }
  14102. /**
  14103. * Checks if two polygons are equal
  14104. *
  14105. * @param {(Parse.Polygon | object)} other
  14106. * @returns {boolean}
  14107. */
  14108. }, {
  14109. key: "equals",
  14110. value: function (other
  14111. /*: mixed*/
  14112. )
  14113. /*: boolean*/
  14114. {
  14115. if (!(other instanceof ParsePolygon) || this.coordinates.length !== other.coordinates.length) {
  14116. return false;
  14117. }
  14118. var isEqual = true;
  14119. for (var i = 1; i < this._coordinates.length; i += 1) {
  14120. if (this._coordinates[i][0] != other.coordinates[i][0] || this._coordinates[i][1] != other.coordinates[i][1]) {
  14121. isEqual = false;
  14122. break;
  14123. }
  14124. }
  14125. return isEqual;
  14126. }
  14127. /**
  14128. *
  14129. * @param {Parse.GeoPoint} point
  14130. * @returns {boolean} Returns if the point is contained in the polygon
  14131. */
  14132. }, {
  14133. key: "containsPoint",
  14134. value: function (point
  14135. /*: ParseGeoPoint*/
  14136. )
  14137. /*: boolean*/
  14138. {
  14139. var minX = this._coordinates[0][0];
  14140. var maxX = this._coordinates[0][0];
  14141. var minY = this._coordinates[0][1];
  14142. var maxY = this._coordinates[0][1];
  14143. for (var i = 1; i < this._coordinates.length; i += 1) {
  14144. var p = this._coordinates[i];
  14145. minX = Math.min(p[0], minX);
  14146. maxX = Math.max(p[0], maxX);
  14147. minY = Math.min(p[1], minY);
  14148. maxY = Math.max(p[1], maxY);
  14149. }
  14150. var outside = point.latitude < minX || point.latitude > maxX || point.longitude < minY || point.longitude > maxY;
  14151. if (outside) {
  14152. return false;
  14153. }
  14154. var inside = false;
  14155. for (var _i = 0, j = this._coordinates.length - 1; _i < this._coordinates.length; j = _i++) {
  14156. var startX = this._coordinates[_i][0];
  14157. var startY = this._coordinates[_i][1];
  14158. var endX = this._coordinates[j][0];
  14159. var endY = this._coordinates[j][1];
  14160. var intersect = startY > point.longitude != endY > point.longitude && point.latitude < (endX - startX) * (point.longitude - startY) / (endY - startY) + startX;
  14161. if (intersect) {
  14162. inside = !inside;
  14163. }
  14164. }
  14165. return inside;
  14166. }
  14167. /**
  14168. * Validates that the list of coordinates can form a valid polygon
  14169. *
  14170. * @param {Array} coords the list of coordinates to validate as a polygon
  14171. * @throws {TypeError}
  14172. * @returns {number[][]} Array of coordinates if validated.
  14173. */
  14174. }], [{
  14175. key: "_validate",
  14176. value: function (coords
  14177. /*: Array<Array<number>> | Array<ParseGeoPoint>*/
  14178. )
  14179. /*: Array<Array<number>>*/
  14180. {
  14181. if (!(0, _isArray.default)(coords)) {
  14182. throw new TypeError('Coordinates must be an Array');
  14183. }
  14184. if (coords.length < 3) {
  14185. throw new TypeError('Polygon must have at least 3 GeoPoints or Points');
  14186. }
  14187. var points = [];
  14188. for (var i = 0; i < coords.length; i += 1) {
  14189. var coord = coords[i];
  14190. var geoPoint = void 0;
  14191. if (coord instanceof _ParseGeoPoint.default) {
  14192. geoPoint = coord;
  14193. } else if ((0, _isArray.default)(coord) && coord.length === 2) {
  14194. geoPoint = new _ParseGeoPoint.default(coord[0], coord[1]);
  14195. } else {
  14196. throw new TypeError('Coordinates must be an Array of GeoPoints or Points');
  14197. }
  14198. points.push([geoPoint.latitude, geoPoint.longitude]);
  14199. }
  14200. return points;
  14201. }
  14202. }]);
  14203. return ParsePolygon;
  14204. }();
  14205. var _default = ParsePolygon;
  14206. exports.default = _default;
  14207. },{"./ParseGeoPoint":24,"@babel/runtime-corejs3/core-js-stable/array/is-array":56,"@babel/runtime-corejs3/core-js-stable/object/define-property":82,"@babel/runtime-corejs3/helpers/classCallCheck":121,"@babel/runtime-corejs3/helpers/createClass":123,"@babel/runtime-corejs3/helpers/defineProperty":124,"@babel/runtime-corejs3/helpers/interopRequireDefault":128}],30:[function(_dereq_,module,exports){
  14208. "use strict";
  14209. var _interopRequireDefault = _dereq_("@babel/runtime-corejs3/helpers/interopRequireDefault");
  14210. var _sliceInstanceProperty2 = _dereq_("@babel/runtime-corejs3/core-js-stable/instance/slice");
  14211. var _reverseInstanceProperty = _dereq_("@babel/runtime-corejs3/core-js-stable/instance/reverse");
  14212. var _Promise2 = _dereq_("@babel/runtime-corejs3/core-js-stable/promise");
  14213. var _Object$setPrototypeOf = _dereq_("@babel/runtime-corejs3/core-js-stable/object/set-prototype-of");
  14214. var _typeof3 = _dereq_("@babel/runtime-corejs3/helpers/typeof");
  14215. var _forEachInstanceProperty2 = _dereq_("@babel/runtime-corejs3/core-js-stable/instance/for-each");
  14216. var _Object$getPrototypeOf = _dereq_("@babel/runtime-corejs3/core-js-stable/object/get-prototype-of");
  14217. var _Object$create = _dereq_("@babel/runtime-corejs3/core-js-stable/object/create");
  14218. var _Object$defineProperty = _dereq_("@babel/runtime-corejs3/core-js-stable/object/define-property");
  14219. var _Symbol = _dereq_("@babel/runtime-corejs3/core-js-stable/symbol");
  14220. _Object$defineProperty(exports, "__esModule", {
  14221. value: true
  14222. });
  14223. exports.default = void 0;
  14224. var _entries = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/object/entries"));
  14225. var _slicedToArray2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/helpers/slicedToArray"));
  14226. var _isArray = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/array/is-array"));
  14227. var _toConsumableArray2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/helpers/toConsumableArray"));
  14228. var _find = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/instance/find"));
  14229. var _promise = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/promise"));
  14230. var _splice = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/instance/splice"));
  14231. var _sort = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/instance/sort"));
  14232. var _includes = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/instance/includes"));
  14233. var _concat = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/instance/concat"));
  14234. var _keys = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/instance/keys"));
  14235. var _filter2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/instance/filter"));
  14236. var _asyncToGenerator2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/helpers/asyncToGenerator"));
  14237. var _map2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/instance/map"));
  14238. var _classCallCheck2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/helpers/classCallCheck"));
  14239. var _createClass2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/helpers/createClass"));
  14240. var _defineProperty2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/helpers/defineProperty"));
  14241. var _slice = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/instance/slice"));
  14242. var _keys2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/object/keys"));
  14243. var _typeof2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/helpers/typeof"));
  14244. var _indexOf = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/instance/index-of"));
  14245. var _forEach = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/instance/for-each"));
  14246. var _CoreManager = _interopRequireDefault(_dereq_("./CoreManager"));
  14247. var _encode = _interopRequireDefault(_dereq_("./encode"));
  14248. var _promiseUtils = _dereq_("./promiseUtils");
  14249. var _ParseError = _interopRequireDefault(_dereq_("./ParseError"));
  14250. var _ParseGeoPoint = _interopRequireDefault(_dereq_("./ParseGeoPoint"));
  14251. var _ParseObject = _interopRequireDefault(_dereq_("./ParseObject"));
  14252. var _OfflineQuery = _interopRequireDefault(_dereq_("./OfflineQuery"));
  14253. var _LocalDatastoreUtils = _dereq_("./LocalDatastoreUtils");
  14254. function _regeneratorRuntime() {
  14255. "use strict";
  14256. /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */
  14257. _regeneratorRuntime = function () {
  14258. return exports;
  14259. };
  14260. var exports = {},
  14261. Op = Object.prototype,
  14262. hasOwn = Op.hasOwnProperty,
  14263. $Symbol = "function" == typeof _Symbol ? _Symbol : {},
  14264. iteratorSymbol = $Symbol.iterator || "@@iterator",
  14265. asyncIteratorSymbol = $Symbol.asyncIterator || "@@asyncIterator",
  14266. toStringTagSymbol = $Symbol.toStringTag || "@@toStringTag";
  14267. function define(obj, key, value) {
  14268. return _Object$defineProperty(obj, key, {
  14269. value: value,
  14270. enumerable: !0,
  14271. configurable: !0,
  14272. writable: !0
  14273. }), obj[key];
  14274. }
  14275. try {
  14276. define({}, "");
  14277. } catch (err) {
  14278. define = function (obj, key, value) {
  14279. return obj[key] = value;
  14280. };
  14281. }
  14282. function wrap(innerFn, outerFn, self, tryLocsList) {
  14283. var protoGenerator = outerFn && outerFn.prototype instanceof Generator ? outerFn : Generator,
  14284. generator = _Object$create(protoGenerator.prototype),
  14285. context = new Context(tryLocsList || []);
  14286. return generator._invoke = function (innerFn, self, context) {
  14287. var state = "suspendedStart";
  14288. return function (method, arg) {
  14289. if ("executing" === state) throw new Error("Generator is already running");
  14290. if ("completed" === state) {
  14291. if ("throw" === method) throw arg;
  14292. return doneResult();
  14293. }
  14294. for (context.method = method, context.arg = arg;;) {
  14295. var delegate = context.delegate;
  14296. if (delegate) {
  14297. var delegateResult = maybeInvokeDelegate(delegate, context);
  14298. if (delegateResult) {
  14299. if (delegateResult === ContinueSentinel) continue;
  14300. return delegateResult;
  14301. }
  14302. }
  14303. if ("next" === context.method) context.sent = context._sent = context.arg;else if ("throw" === context.method) {
  14304. if ("suspendedStart" === state) throw state = "completed", context.arg;
  14305. context.dispatchException(context.arg);
  14306. } else "return" === context.method && context.abrupt("return", context.arg);
  14307. state = "executing";
  14308. var record = tryCatch(innerFn, self, context);
  14309. if ("normal" === record.type) {
  14310. if (state = context.done ? "completed" : "suspendedYield", record.arg === ContinueSentinel) continue;
  14311. return {
  14312. value: record.arg,
  14313. done: context.done
  14314. };
  14315. }
  14316. "throw" === record.type && (state = "completed", context.method = "throw", context.arg = record.arg);
  14317. }
  14318. };
  14319. }(innerFn, self, context), generator;
  14320. }
  14321. function tryCatch(fn, obj, arg) {
  14322. try {
  14323. return {
  14324. type: "normal",
  14325. arg: fn.call(obj, arg)
  14326. };
  14327. } catch (err) {
  14328. return {
  14329. type: "throw",
  14330. arg: err
  14331. };
  14332. }
  14333. }
  14334. exports.wrap = wrap;
  14335. var ContinueSentinel = {};
  14336. function Generator() {}
  14337. function GeneratorFunction() {}
  14338. function GeneratorFunctionPrototype() {}
  14339. var IteratorPrototype = {};
  14340. define(IteratorPrototype, iteratorSymbol, function () {
  14341. return this;
  14342. });
  14343. var getProto = _Object$getPrototypeOf,
  14344. NativeIteratorPrototype = getProto && getProto(getProto(values([])));
  14345. NativeIteratorPrototype && NativeIteratorPrototype !== Op && hasOwn.call(NativeIteratorPrototype, iteratorSymbol) && (IteratorPrototype = NativeIteratorPrototype);
  14346. var Gp = GeneratorFunctionPrototype.prototype = Generator.prototype = _Object$create(IteratorPrototype);
  14347. function defineIteratorMethods(prototype) {
  14348. var _context23;
  14349. _forEachInstanceProperty2(_context23 = ["next", "throw", "return"]).call(_context23, function (method) {
  14350. define(prototype, method, function (arg) {
  14351. return this._invoke(method, arg);
  14352. });
  14353. });
  14354. }
  14355. function AsyncIterator(generator, PromiseImpl) {
  14356. function invoke(method, arg, resolve, reject) {
  14357. var record = tryCatch(generator[method], generator, arg);
  14358. if ("throw" !== record.type) {
  14359. var result = record.arg,
  14360. value = result.value;
  14361. return value && "object" == _typeof3(value) && hasOwn.call(value, "__await") ? PromiseImpl.resolve(value.__await).then(function (value) {
  14362. invoke("next", value, resolve, reject);
  14363. }, function (err) {
  14364. invoke("throw", err, resolve, reject);
  14365. }) : PromiseImpl.resolve(value).then(function (unwrapped) {
  14366. result.value = unwrapped, resolve(result);
  14367. }, function (error) {
  14368. return invoke("throw", error, resolve, reject);
  14369. });
  14370. }
  14371. reject(record.arg);
  14372. }
  14373. var previousPromise;
  14374. this._invoke = function (method, arg) {
  14375. function callInvokeWithMethodAndArg() {
  14376. return new PromiseImpl(function (resolve, reject) {
  14377. invoke(method, arg, resolve, reject);
  14378. });
  14379. }
  14380. return previousPromise = previousPromise ? previousPromise.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg();
  14381. };
  14382. }
  14383. function maybeInvokeDelegate(delegate, context) {
  14384. var method = delegate.iterator[context.method];
  14385. if (undefined === method) {
  14386. if (context.delegate = null, "throw" === context.method) {
  14387. if (delegate.iterator.return && (context.method = "return", context.arg = undefined, maybeInvokeDelegate(delegate, context), "throw" === context.method)) return ContinueSentinel;
  14388. context.method = "throw", context.arg = new TypeError("The iterator does not provide a 'throw' method");
  14389. }
  14390. return ContinueSentinel;
  14391. }
  14392. var record = tryCatch(method, delegate.iterator, context.arg);
  14393. if ("throw" === record.type) return context.method = "throw", context.arg = record.arg, context.delegate = null, ContinueSentinel;
  14394. var info = record.arg;
  14395. return info ? info.done ? (context[delegate.resultName] = info.value, context.next = delegate.nextLoc, "return" !== context.method && (context.method = "next", context.arg = undefined), context.delegate = null, ContinueSentinel) : info : (context.method = "throw", context.arg = new TypeError("iterator result is not an object"), context.delegate = null, ContinueSentinel);
  14396. }
  14397. function pushTryEntry(locs) {
  14398. var entry = {
  14399. tryLoc: locs[0]
  14400. };
  14401. 1 in locs && (entry.catchLoc = locs[1]), 2 in locs && (entry.finallyLoc = locs[2], entry.afterLoc = locs[3]), this.tryEntries.push(entry);
  14402. }
  14403. function resetTryEntry(entry) {
  14404. var record = entry.completion || {};
  14405. record.type = "normal", delete record.arg, entry.completion = record;
  14406. }
  14407. function Context(tryLocsList) {
  14408. this.tryEntries = [{
  14409. tryLoc: "root"
  14410. }], _forEachInstanceProperty2(tryLocsList).call(tryLocsList, pushTryEntry, this), this.reset(!0);
  14411. }
  14412. function values(iterable) {
  14413. if (iterable) {
  14414. var iteratorMethod = iterable[iteratorSymbol];
  14415. if (iteratorMethod) return iteratorMethod.call(iterable);
  14416. if ("function" == typeof iterable.next) return iterable;
  14417. if (!isNaN(iterable.length)) {
  14418. var i = -1,
  14419. next = function next() {
  14420. for (; ++i < iterable.length;) {
  14421. if (hasOwn.call(iterable, i)) return next.value = iterable[i], next.done = !1, next;
  14422. }
  14423. return next.value = undefined, next.done = !0, next;
  14424. };
  14425. return next.next = next;
  14426. }
  14427. }
  14428. return {
  14429. next: doneResult
  14430. };
  14431. }
  14432. function doneResult() {
  14433. return {
  14434. value: undefined,
  14435. done: !0
  14436. };
  14437. }
  14438. return GeneratorFunction.prototype = GeneratorFunctionPrototype, define(Gp, "constructor", GeneratorFunctionPrototype), define(GeneratorFunctionPrototype, "constructor", GeneratorFunction), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, toStringTagSymbol, "GeneratorFunction"), exports.isGeneratorFunction = function (genFun) {
  14439. var ctor = "function" == typeof genFun && genFun.constructor;
  14440. return !!ctor && (ctor === GeneratorFunction || "GeneratorFunction" === (ctor.displayName || ctor.name));
  14441. }, exports.mark = function (genFun) {
  14442. return _Object$setPrototypeOf ? _Object$setPrototypeOf(genFun, GeneratorFunctionPrototype) : (genFun.__proto__ = GeneratorFunctionPrototype, define(genFun, toStringTagSymbol, "GeneratorFunction")), genFun.prototype = _Object$create(Gp), genFun;
  14443. }, exports.awrap = function (arg) {
  14444. return {
  14445. __await: arg
  14446. };
  14447. }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, asyncIteratorSymbol, function () {
  14448. return this;
  14449. }), exports.AsyncIterator = AsyncIterator, exports.async = function (innerFn, outerFn, self, tryLocsList, PromiseImpl) {
  14450. void 0 === PromiseImpl && (PromiseImpl = _Promise2);
  14451. var iter = new AsyncIterator(wrap(innerFn, outerFn, self, tryLocsList), PromiseImpl);
  14452. return exports.isGeneratorFunction(outerFn) ? iter : iter.next().then(function (result) {
  14453. return result.done ? result.value : iter.next();
  14454. });
  14455. }, defineIteratorMethods(Gp), define(Gp, toStringTagSymbol, "Generator"), define(Gp, iteratorSymbol, function () {
  14456. return this;
  14457. }), define(Gp, "toString", function () {
  14458. return "[object Generator]";
  14459. }), exports.keys = function (object) {
  14460. var keys = [];
  14461. for (var key in object) {
  14462. keys.push(key);
  14463. }
  14464. return _reverseInstanceProperty(keys).call(keys), function next() {
  14465. for (; keys.length;) {
  14466. var key = keys.pop();
  14467. if (key in object) return next.value = key, next.done = !1, next;
  14468. }
  14469. return next.done = !0, next;
  14470. };
  14471. }, exports.values = values, Context.prototype = {
  14472. constructor: Context,
  14473. reset: function (skipTempReset) {
  14474. var _context24;
  14475. if (this.prev = 0, this.next = 0, this.sent = this._sent = undefined, this.done = !1, this.delegate = null, this.method = "next", this.arg = undefined, _forEachInstanceProperty2(_context24 = this.tryEntries).call(_context24, resetTryEntry), !skipTempReset) for (var name in this) {
  14476. "t" === name.charAt(0) && hasOwn.call(this, name) && !isNaN(+_sliceInstanceProperty2(name).call(name, 1)) && (this[name] = undefined);
  14477. }
  14478. },
  14479. stop: function () {
  14480. this.done = !0;
  14481. var rootRecord = this.tryEntries[0].completion;
  14482. if ("throw" === rootRecord.type) throw rootRecord.arg;
  14483. return this.rval;
  14484. },
  14485. dispatchException: function (exception) {
  14486. if (this.done) throw exception;
  14487. var context = this;
  14488. function handle(loc, caught) {
  14489. return record.type = "throw", record.arg = exception, context.next = loc, caught && (context.method = "next", context.arg = undefined), !!caught;
  14490. }
  14491. for (var i = this.tryEntries.length - 1; i >= 0; --i) {
  14492. var entry = this.tryEntries[i],
  14493. record = entry.completion;
  14494. if ("root" === entry.tryLoc) return handle("end");
  14495. if (entry.tryLoc <= this.prev) {
  14496. var hasCatch = hasOwn.call(entry, "catchLoc"),
  14497. hasFinally = hasOwn.call(entry, "finallyLoc");
  14498. if (hasCatch && hasFinally) {
  14499. if (this.prev < entry.catchLoc) return handle(entry.catchLoc, !0);
  14500. if (this.prev < entry.finallyLoc) return handle(entry.finallyLoc);
  14501. } else if (hasCatch) {
  14502. if (this.prev < entry.catchLoc) return handle(entry.catchLoc, !0);
  14503. } else {
  14504. if (!hasFinally) throw new Error("try statement without catch or finally");
  14505. if (this.prev < entry.finallyLoc) return handle(entry.finallyLoc);
  14506. }
  14507. }
  14508. }
  14509. },
  14510. abrupt: function (type, arg) {
  14511. for (var i = this.tryEntries.length - 1; i >= 0; --i) {
  14512. var entry = this.tryEntries[i];
  14513. if (entry.tryLoc <= this.prev && hasOwn.call(entry, "finallyLoc") && this.prev < entry.finallyLoc) {
  14514. var finallyEntry = entry;
  14515. break;
  14516. }
  14517. }
  14518. finallyEntry && ("break" === type || "continue" === type) && finallyEntry.tryLoc <= arg && arg <= finallyEntry.finallyLoc && (finallyEntry = null);
  14519. var record = finallyEntry ? finallyEntry.completion : {};
  14520. return record.type = type, record.arg = arg, finallyEntry ? (this.method = "next", this.next = finallyEntry.finallyLoc, ContinueSentinel) : this.complete(record);
  14521. },
  14522. complete: function (record, afterLoc) {
  14523. if ("throw" === record.type) throw record.arg;
  14524. return "break" === record.type || "continue" === record.type ? this.next = record.arg : "return" === record.type ? (this.rval = this.arg = record.arg, this.method = "return", this.next = "end") : "normal" === record.type && afterLoc && (this.next = afterLoc), ContinueSentinel;
  14525. },
  14526. finish: function (finallyLoc) {
  14527. for (var i = this.tryEntries.length - 1; i >= 0; --i) {
  14528. var entry = this.tryEntries[i];
  14529. if (entry.finallyLoc === finallyLoc) return this.complete(entry.completion, entry.afterLoc), resetTryEntry(entry), ContinueSentinel;
  14530. }
  14531. },
  14532. catch: function (tryLoc) {
  14533. for (var i = this.tryEntries.length - 1; i >= 0; --i) {
  14534. var entry = this.tryEntries[i];
  14535. if (entry.tryLoc === tryLoc) {
  14536. var record = entry.completion;
  14537. if ("throw" === record.type) {
  14538. var thrown = record.arg;
  14539. resetTryEntry(entry);
  14540. }
  14541. return thrown;
  14542. }
  14543. }
  14544. throw new Error("illegal catch attempt");
  14545. },
  14546. delegateYield: function (iterable, resultName, nextLoc) {
  14547. return this.delegate = {
  14548. iterator: values(iterable),
  14549. resultName: resultName,
  14550. nextLoc: nextLoc
  14551. }, "next" === this.method && (this.arg = undefined), ContinueSentinel;
  14552. }
  14553. }, exports;
  14554. }
  14555. /**
  14556. * Converts a string into a regex that matches it.
  14557. * Surrounding with \Q .. \E does this, we just need to escape any \E's in
  14558. * the text separately.
  14559. *
  14560. * @param s
  14561. * @private
  14562. * @returns {string}
  14563. */
  14564. function quote(s
  14565. /*: string*/
  14566. )
  14567. /*: string*/
  14568. {
  14569. return '\\Q' + s.replace('\\E', '\\E\\\\E\\Q') + '\\E';
  14570. }
  14571. /**
  14572. * Extracts the class name from queries. If not all queries have the same
  14573. * class name an error will be thrown.
  14574. *
  14575. * @param queries
  14576. * @private
  14577. * @returns {string}
  14578. */
  14579. function _getClassNameFromQueries(queries
  14580. /*: Array<ParseQuery>*/
  14581. )
  14582. /*: ?string*/
  14583. {
  14584. var className = null;
  14585. (0, _forEach.default)(queries).call(queries, function (q) {
  14586. if (!className) {
  14587. className = q.className;
  14588. }
  14589. if (className !== q.className) {
  14590. throw new Error('All queries must be for the same class.');
  14591. }
  14592. });
  14593. return className;
  14594. }
  14595. /*
  14596. * Handles pre-populating the result data of a query with select fields,
  14597. * making sure that the data object contains keys for all objects that have
  14598. * been requested with a select, so that our cached state updates correctly.
  14599. */
  14600. function handleSelectResult(data
  14601. /*: any*/
  14602. , select
  14603. /*: Array<string>*/
  14604. ) {
  14605. var serverDataMask = {};
  14606. (0, _forEach.default)(select).call(select, function (field) {
  14607. var hasSubObjectSelect = (0, _indexOf.default)(field).call(field, '.') !== -1;
  14608. if (!hasSubObjectSelect && !data.hasOwnProperty(field)) {
  14609. // this field was selected, but is missing from the retrieved data
  14610. data[field] = undefined;
  14611. } else if (hasSubObjectSelect) {
  14612. // this field references a sub-object,
  14613. // so we need to walk down the path components
  14614. var pathComponents = field.split('.');
  14615. var _obj = data;
  14616. var serverMask = serverDataMask;
  14617. (0, _forEach.default)(pathComponents).call(pathComponents, function (component, index, arr) {
  14618. // add keys if the expected data is missing
  14619. if (_obj && !_obj.hasOwnProperty(component)) {
  14620. _obj[component] = undefined;
  14621. }
  14622. if (_obj && (0, _typeof2.default)(_obj) === 'object') {
  14623. _obj = _obj[component];
  14624. } //add this path component to the server mask so we can fill it in later if needed
  14625. if (index < arr.length - 1) {
  14626. if (!serverMask[component]) {
  14627. serverMask[component] = {};
  14628. }
  14629. serverMask = serverMask[component];
  14630. }
  14631. });
  14632. }
  14633. });
  14634. if ((0, _keys2.default)(serverDataMask).length > 0) {
  14635. // When selecting from sub-objects, we don't want to blow away the missing
  14636. // information that we may have retrieved before. We've already added any
  14637. // missing selected keys to sub-objects, but we still need to add in the
  14638. // data for any previously retrieved sub-objects that were not selected.
  14639. var serverData = _CoreManager.default.getObjectStateController().getServerData({
  14640. id: data.objectId,
  14641. className: data.className
  14642. });
  14643. copyMissingDataWithMask(serverData, data, serverDataMask, false);
  14644. }
  14645. }
  14646. function copyMissingDataWithMask(src, dest, mask, copyThisLevel) {
  14647. //copy missing elements at this level
  14648. if (copyThisLevel) {
  14649. for (var _key in src) {
  14650. if (src.hasOwnProperty(_key) && !dest.hasOwnProperty(_key)) {
  14651. dest[_key] = src[_key];
  14652. }
  14653. }
  14654. }
  14655. for (var _key2 in mask) {
  14656. if (dest[_key2] !== undefined && dest[_key2] !== null && src !== undefined && src !== null) {
  14657. //traverse into objects as needed
  14658. copyMissingDataWithMask(src[_key2], dest[_key2], mask[_key2], true);
  14659. }
  14660. }
  14661. }
  14662. function handleOfflineSort(a, b, sorts) {
  14663. var order = sorts[0];
  14664. var operator = (0, _slice.default)(order).call(order, 0, 1);
  14665. var isDescending = operator === '-';
  14666. if (isDescending) {
  14667. order = order.substring(1);
  14668. }
  14669. if (order === '_created_at') {
  14670. order = 'createdAt';
  14671. }
  14672. if (order === '_updated_at') {
  14673. order = 'updatedAt';
  14674. }
  14675. if (!/^[A-Za-z][0-9A-Za-z_]*$/.test(order) || order === 'password') {
  14676. throw new _ParseError.default(_ParseError.default.INVALID_KEY_NAME, "Invalid Key: ".concat(order));
  14677. }
  14678. var field1 = a.get(order);
  14679. var field2 = b.get(order);
  14680. if (field1 < field2) {
  14681. return isDescending ? 1 : -1;
  14682. }
  14683. if (field1 > field2) {
  14684. return isDescending ? -1 : 1;
  14685. }
  14686. if (sorts.length > 1) {
  14687. var remainingSorts = (0, _slice.default)(sorts).call(sorts, 1);
  14688. return handleOfflineSort(a, b, remainingSorts);
  14689. }
  14690. return 0;
  14691. }
  14692. /**
  14693. * Creates a new parse Parse.Query for the given Parse.Object subclass.
  14694. *
  14695. * <p>Parse.Query defines a query that is used to fetch Parse.Objects. The
  14696. * most common use case is finding all objects that match a query through the
  14697. * <code>find</code> method. for example, this sample code fetches all objects
  14698. * of class <code>myclass</code>. it calls a different function depending on
  14699. * whether the fetch succeeded or not.
  14700. *
  14701. * <pre>
  14702. * var query = new Parse.Query(myclass);
  14703. * query.find().then((results) => {
  14704. * // results is an array of parse.object.
  14705. * }).catch((error) => {
  14706. * // error is an instance of parse.error.
  14707. * });</pre></p>
  14708. *
  14709. * <p>a Parse.Query can also be used to retrieve a single object whose id is
  14710. * known, through the get method. for example, this sample code fetches an
  14711. * object of class <code>myclass</code> and id <code>myid</code>. it calls a
  14712. * different function depending on whether the fetch succeeded or not.
  14713. *
  14714. * <pre>
  14715. * var query = new Parse.Query(myclass);
  14716. * query.get(myid).then((object) => {
  14717. * // object is an instance of parse.object.
  14718. * }).catch((error) => {
  14719. * // error is an instance of parse.error.
  14720. * });</pre></p>
  14721. *
  14722. * <p>a Parse.Query can also be used to count the number of objects that match
  14723. * the query without retrieving all of those objects. for example, this
  14724. * sample code counts the number of objects of the class <code>myclass</code>
  14725. * <pre>
  14726. * var query = new Parse.Query(myclass);
  14727. * query.count().then((number) => {
  14728. * // there are number instances of myclass.
  14729. * }).catch((error) => {
  14730. * // error is an instance of Parse.Error.
  14731. * });</pre></p>
  14732. *
  14733. * @alias Parse.Query
  14734. */
  14735. var ParseQuery = /*#__PURE__*/function () {
  14736. /**
  14737. * @property {string} className
  14738. */
  14739. /**
  14740. * @param {(string | Parse.Object)} objectClass An instance of a subclass of Parse.Object, or a Parse className string.
  14741. */
  14742. function ParseQuery(objectClass
  14743. /*: string | ParseObject*/
  14744. ) {
  14745. (0, _classCallCheck2.default)(this, ParseQuery);
  14746. (0, _defineProperty2.default)(this, "className", void 0);
  14747. (0, _defineProperty2.default)(this, "_where", void 0);
  14748. (0, _defineProperty2.default)(this, "_include", void 0);
  14749. (0, _defineProperty2.default)(this, "_exclude", void 0);
  14750. (0, _defineProperty2.default)(this, "_select", void 0);
  14751. (0, _defineProperty2.default)(this, "_limit", void 0);
  14752. (0, _defineProperty2.default)(this, "_skip", void 0);
  14753. (0, _defineProperty2.default)(this, "_count", void 0);
  14754. (0, _defineProperty2.default)(this, "_order", void 0);
  14755. (0, _defineProperty2.default)(this, "_readPreference", void 0);
  14756. (0, _defineProperty2.default)(this, "_includeReadPreference", void 0);
  14757. (0, _defineProperty2.default)(this, "_subqueryReadPreference", void 0);
  14758. (0, _defineProperty2.default)(this, "_queriesLocalDatastore", void 0);
  14759. (0, _defineProperty2.default)(this, "_localDatastorePinName", void 0);
  14760. (0, _defineProperty2.default)(this, "_extraOptions", void 0);
  14761. (0, _defineProperty2.default)(this, "_hint", void 0);
  14762. (0, _defineProperty2.default)(this, "_explain", void 0);
  14763. (0, _defineProperty2.default)(this, "_xhrRequest", void 0);
  14764. if (typeof objectClass === 'string') {
  14765. if (objectClass === 'User' && _CoreManager.default.get('PERFORM_USER_REWRITE')) {
  14766. this.className = '_User';
  14767. } else {
  14768. this.className = objectClass;
  14769. }
  14770. } else if (objectClass instanceof _ParseObject.default) {
  14771. this.className = objectClass.className;
  14772. } else if (typeof objectClass === 'function') {
  14773. if (typeof objectClass.className === 'string') {
  14774. this.className = objectClass.className;
  14775. } else {
  14776. var _obj2 = new objectClass();
  14777. this.className = _obj2.className;
  14778. }
  14779. } else {
  14780. throw new TypeError('A ParseQuery must be constructed with a ParseObject or class name.');
  14781. }
  14782. this._where = {};
  14783. this._include = [];
  14784. this._exclude = [];
  14785. this._count = false;
  14786. this._limit = -1; // negative limit is not sent in the server request
  14787. this._skip = 0;
  14788. this._readPreference = null;
  14789. this._includeReadPreference = null;
  14790. this._subqueryReadPreference = null;
  14791. this._queriesLocalDatastore = false;
  14792. this._localDatastorePinName = null;
  14793. this._extraOptions = {};
  14794. this._xhrRequest = {
  14795. task: null,
  14796. onchange: function () {}
  14797. };
  14798. }
  14799. /**
  14800. * Adds constraint that at least one of the passed in queries matches.
  14801. *
  14802. * @param {Array} queries
  14803. * @returns {Parse.Query} Returns the query, so you can chain this call.
  14804. */
  14805. (0, _createClass2.default)(ParseQuery, [{
  14806. key: "_orQuery",
  14807. value: function (queries
  14808. /*: Array<ParseQuery>*/
  14809. )
  14810. /*: ParseQuery*/
  14811. {
  14812. var queryJSON = (0, _map2.default)(queries).call(queries, function (q) {
  14813. return q.toJSON().where;
  14814. });
  14815. this._where.$or = queryJSON;
  14816. return this;
  14817. }
  14818. /**
  14819. * Adds constraint that all of the passed in queries match.
  14820. *
  14821. * @param {Array} queries
  14822. * @returns {Parse.Query} Returns the query, so you can chain this call.
  14823. */
  14824. }, {
  14825. key: "_andQuery",
  14826. value: function (queries
  14827. /*: Array<ParseQuery>*/
  14828. )
  14829. /*: ParseQuery*/
  14830. {
  14831. var queryJSON = (0, _map2.default)(queries).call(queries, function (q) {
  14832. return q.toJSON().where;
  14833. });
  14834. this._where.$and = queryJSON;
  14835. return this;
  14836. }
  14837. /**
  14838. * Adds constraint that none of the passed in queries match.
  14839. *
  14840. * @param {Array} queries
  14841. * @returns {Parse.Query} Returns the query, so you can chain this call.
  14842. */
  14843. }, {
  14844. key: "_norQuery",
  14845. value: function (queries
  14846. /*: Array<ParseQuery>*/
  14847. )
  14848. /*: ParseQuery*/
  14849. {
  14850. var queryJSON = (0, _map2.default)(queries).call(queries, function (q) {
  14851. return q.toJSON().where;
  14852. });
  14853. this._where.$nor = queryJSON;
  14854. return this;
  14855. }
  14856. /**
  14857. * Helper for condition queries
  14858. *
  14859. * @param key
  14860. * @param condition
  14861. * @param value
  14862. * @returns {Parse.Query}
  14863. */
  14864. }, {
  14865. key: "_addCondition",
  14866. value: function (key
  14867. /*: string*/
  14868. , condition
  14869. /*: string*/
  14870. , value
  14871. /*: mixed*/
  14872. )
  14873. /*: ParseQuery*/
  14874. {
  14875. if (!this._where[key] || typeof this._where[key] === 'string') {
  14876. this._where[key] = {};
  14877. }
  14878. this._where[key][condition] = (0, _encode.default)(value, false, true);
  14879. return this;
  14880. }
  14881. /**
  14882. * Converts string for regular expression at the beginning
  14883. *
  14884. * @param string
  14885. * @returns {string}
  14886. */
  14887. }, {
  14888. key: "_regexStartWith",
  14889. value: function (string
  14890. /*: string*/
  14891. )
  14892. /*: string*/
  14893. {
  14894. return '^' + quote(string);
  14895. }
  14896. }, {
  14897. key: "_handleOfflineQuery",
  14898. value: function () {
  14899. var _handleOfflineQuery2 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(params
  14900. /*: any*/
  14901. ) {
  14902. var _context,
  14903. _this2 = this;
  14904. var localDatastore, objects, results, keys, alwaysSelectedKeys, sorts, count, limit;
  14905. return _regeneratorRuntime().wrap(function (_context3) {
  14906. while (1) {
  14907. switch (_context3.prev = _context3.next) {
  14908. case 0:
  14909. _OfflineQuery.default.validateQuery(this);
  14910. localDatastore = _CoreManager.default.getLocalDatastore();
  14911. _context3.next = 4;
  14912. return localDatastore._serializeObjectsFromPinName(this._localDatastorePinName);
  14913. case 4:
  14914. objects = _context3.sent;
  14915. results = (0, _filter2.default)(_context = (0, _map2.default)(objects).call(objects, function (json, index, arr) {
  14916. var object = _ParseObject.default.fromJSON(json, false);
  14917. if (json._localId && !json.objectId) {
  14918. object._localId = json._localId;
  14919. }
  14920. if (!_OfflineQuery.default.matchesQuery(_this2.className, object, arr, _this2)) {
  14921. return null;
  14922. }
  14923. return object;
  14924. })).call(_context, function (object) {
  14925. return object !== null;
  14926. });
  14927. if ((0, _keys.default)(params)) {
  14928. keys = (0, _keys.default)(params).split(',');
  14929. alwaysSelectedKeys = ['className', 'objectId', 'createdAt', 'updatedAt', 'ACL'];
  14930. keys = (0, _concat.default)(keys).call(keys, alwaysSelectedKeys);
  14931. results = (0, _map2.default)(results).call(results, function (object) {
  14932. var _context2;
  14933. var json = object._toFullJSON();
  14934. (0, _forEach.default)(_context2 = (0, _keys2.default)(json)).call(_context2, function (key) {
  14935. if (!(0, _includes.default)(keys).call(keys, key)) {
  14936. delete json[key];
  14937. }
  14938. });
  14939. return _ParseObject.default.fromJSON(json, false);
  14940. });
  14941. }
  14942. if (params.order) {
  14943. sorts = params.order.split(',');
  14944. (0, _sort.default)(results).call(results, function (a, b) {
  14945. return handleOfflineSort(a, b, sorts);
  14946. });
  14947. } // count total before applying limit/skip
  14948. if (params.count) {
  14949. count = results.length; // total count from response
  14950. }
  14951. if (params.skip) {
  14952. if (params.skip >= results.length) {
  14953. results = [];
  14954. } else {
  14955. results = (0, _splice.default)(results).call(results, params.skip, results.length);
  14956. }
  14957. }
  14958. limit = results.length;
  14959. if (params.limit !== 0 && params.limit < results.length) {
  14960. limit = params.limit;
  14961. }
  14962. results = (0, _splice.default)(results).call(results, 0, limit);
  14963. if (!(typeof count === 'number')) {
  14964. _context3.next = 15;
  14965. break;
  14966. }
  14967. return _context3.abrupt("return", {
  14968. results: results,
  14969. count: count
  14970. });
  14971. case 15:
  14972. return _context3.abrupt("return", results);
  14973. case 16:
  14974. case "end":
  14975. return _context3.stop();
  14976. }
  14977. }
  14978. }, _callee, this);
  14979. }));
  14980. function _handleOfflineQuery() {
  14981. return _handleOfflineQuery2.apply(this, arguments);
  14982. }
  14983. return _handleOfflineQuery;
  14984. }()
  14985. /**
  14986. * Returns a JSON representation of this query.
  14987. *
  14988. * @returns {object} The JSON representation of the query.
  14989. */
  14990. }, {
  14991. key: "toJSON",
  14992. value: function ()
  14993. /*: QueryJSON*/
  14994. {
  14995. var params
  14996. /*: QueryJSON*/
  14997. = {
  14998. where: this._where
  14999. };
  15000. if (this._include.length) {
  15001. params.include = this._include.join(',');
  15002. }
  15003. if (this._exclude.length) {
  15004. params.excludeKeys = this._exclude.join(',');
  15005. }
  15006. if (this._select) {
  15007. params.keys = this._select.join(',');
  15008. }
  15009. if (this._count) {
  15010. params.count = 1;
  15011. }
  15012. if (this._limit >= 0) {
  15013. params.limit = this._limit;
  15014. }
  15015. if (this._skip > 0) {
  15016. params.skip = this._skip;
  15017. }
  15018. if (this._order) {
  15019. params.order = this._order.join(',');
  15020. }
  15021. if (this._readPreference) {
  15022. params.readPreference = this._readPreference;
  15023. }
  15024. if (this._includeReadPreference) {
  15025. params.includeReadPreference = this._includeReadPreference;
  15026. }
  15027. if (this._subqueryReadPreference) {
  15028. params.subqueryReadPreference = this._subqueryReadPreference;
  15029. }
  15030. if (this._hint) {
  15031. params.hint = this._hint;
  15032. }
  15033. if (this._explain) {
  15034. params.explain = true;
  15035. }
  15036. for (var _key3 in this._extraOptions) {
  15037. params[_key3] = this._extraOptions[_key3];
  15038. }
  15039. return params;
  15040. }
  15041. /**
  15042. * Return a query with conditions from json, can be useful to send query from server side to client
  15043. * Not static, all query conditions was set before calling this method will be deleted.
  15044. * For example on the server side we have
  15045. * var query = new Parse.Query("className");
  15046. * query.equalTo(key: value);
  15047. * query.limit(100);
  15048. * ... (others queries)
  15049. * Create JSON representation of Query Object
  15050. * var jsonFromServer = query.fromJSON();
  15051. *
  15052. * On client side getting query:
  15053. * var query = new Parse.Query("className");
  15054. * query.fromJSON(jsonFromServer);
  15055. *
  15056. * and continue to query...
  15057. * query.skip(100).find().then(...);
  15058. *
  15059. * @param {QueryJSON} json from Parse.Query.toJSON() method
  15060. * @returns {Parse.Query} Returns the query, so you can chain this call.
  15061. */
  15062. }, {
  15063. key: "withJSON",
  15064. value: function (json
  15065. /*: QueryJSON*/
  15066. )
  15067. /*: ParseQuery*/
  15068. {
  15069. if (json.where) {
  15070. this._where = json.where;
  15071. }
  15072. if (json.include) {
  15073. this._include = json.include.split(',');
  15074. }
  15075. if ((0, _keys.default)(json)) {
  15076. this._select = (0, _keys.default)(json).split(',');
  15077. }
  15078. if (json.excludeKeys) {
  15079. this._exclude = json.excludeKeys.split(',');
  15080. }
  15081. if (json.count) {
  15082. this._count = json.count === 1;
  15083. }
  15084. if (json.limit) {
  15085. this._limit = json.limit;
  15086. }
  15087. if (json.skip) {
  15088. this._skip = json.skip;
  15089. }
  15090. if (json.order) {
  15091. this._order = json.order.split(',');
  15092. }
  15093. if (json.readPreference) {
  15094. this._readPreference = json.readPreference;
  15095. }
  15096. if (json.includeReadPreference) {
  15097. this._includeReadPreference = json.includeReadPreference;
  15098. }
  15099. if (json.subqueryReadPreference) {
  15100. this._subqueryReadPreference = json.subqueryReadPreference;
  15101. }
  15102. if (json.hint) {
  15103. this._hint = json.hint;
  15104. }
  15105. if (json.explain) {
  15106. this._explain = !!json.explain;
  15107. }
  15108. for (var _key4 in json) {
  15109. if (json.hasOwnProperty(_key4)) {
  15110. var _context4;
  15111. if ((0, _indexOf.default)(_context4 = ['where', 'include', 'keys', 'count', 'limit', 'skip', 'order', 'readPreference', 'includeReadPreference', 'subqueryReadPreference', 'hint', 'explain']).call(_context4, _key4) === -1) {
  15112. this._extraOptions[_key4] = json[_key4];
  15113. }
  15114. }
  15115. }
  15116. return this;
  15117. }
  15118. /**
  15119. * Static method to restore Parse.Query by json representation
  15120. * Internally calling Parse.Query.withJSON
  15121. *
  15122. * @param {string} className
  15123. * @param {QueryJSON} json from Parse.Query.toJSON() method
  15124. * @returns {Parse.Query} new created query
  15125. */
  15126. }, {
  15127. key: "get",
  15128. value:
  15129. /**
  15130. * Constructs a Parse.Object whose id is already known by fetching data from
  15131. * the server. Unlike the <code>first</code> method, it never returns undefined.
  15132. *
  15133. * @param {string} objectId The id of the object to be fetched.
  15134. * @param {object} options
  15135. * Valid options are:<ul>
  15136. * <li>useMasterKey: In Cloud Code and Node only, causes the Master Key to
  15137. * be used for this request.
  15138. * <li>sessionToken: A valid session token, used for making a request on
  15139. * behalf of a specific user.
  15140. * <li>context: A dictionary that is accessible in Cloud Code `beforeFind` trigger.
  15141. * <li>json: Return raw json without converting to Parse.Object
  15142. * </ul>
  15143. *
  15144. * @returns {Promise} A promise that is resolved with the result when
  15145. * the query completes.
  15146. */
  15147. function (objectId
  15148. /*: string*/
  15149. , options
  15150. /*:: ?: FullOptions*/
  15151. )
  15152. /*: Promise<ParseObject>*/
  15153. {
  15154. this.equalTo('objectId', objectId);
  15155. var firstOptions = {};
  15156. if (options && options.hasOwnProperty('useMasterKey')) {
  15157. firstOptions.useMasterKey = options.useMasterKey;
  15158. }
  15159. if (options && options.hasOwnProperty('sessionToken')) {
  15160. firstOptions.sessionToken = options.sessionToken;
  15161. }
  15162. if (options && options.hasOwnProperty('context') && (0, _typeof2.default)(options.context) === 'object') {
  15163. firstOptions.context = options.context;
  15164. }
  15165. if (options && options.hasOwnProperty('json')) {
  15166. firstOptions.json = options.json;
  15167. }
  15168. return this.first(firstOptions).then(function (response) {
  15169. if (response) {
  15170. return response;
  15171. }
  15172. var errorObject = new _ParseError.default(_ParseError.default.OBJECT_NOT_FOUND, 'Object not found.');
  15173. return _promise.default.reject(errorObject);
  15174. });
  15175. }
  15176. /**
  15177. * Retrieves a list of ParseObjects that satisfy this query.
  15178. *
  15179. * @param {object} options Valid options
  15180. * are:<ul>
  15181. * <li>useMasterKey: In Cloud Code and Node only, causes the Master Key to
  15182. * be used for this request.
  15183. * <li>sessionToken: A valid session token, used for making a request on
  15184. * behalf of a specific user.
  15185. * <li>context: A dictionary that is accessible in Cloud Code `beforeFind` trigger.
  15186. * <li>json: Return raw json without converting to Parse.Object
  15187. * </ul>
  15188. *
  15189. * @returns {Promise} A promise that is resolved with the results when
  15190. * the query completes.
  15191. */
  15192. }, {
  15193. key: "find",
  15194. value: function (options
  15195. /*:: ?: FullOptions*/
  15196. )
  15197. /*: Promise<Array<ParseObject>>*/
  15198. {
  15199. var _this3 = this;
  15200. options = options || {};
  15201. var findOptions = {};
  15202. if (options.hasOwnProperty('useMasterKey')) {
  15203. findOptions.useMasterKey = options.useMasterKey;
  15204. }
  15205. if (options.hasOwnProperty('sessionToken')) {
  15206. findOptions.sessionToken = options.sessionToken;
  15207. }
  15208. if (options.hasOwnProperty('context') && (0, _typeof2.default)(options.context) === 'object') {
  15209. findOptions.context = options.context;
  15210. }
  15211. this._setRequestTask(findOptions);
  15212. var controller = _CoreManager.default.getQueryController();
  15213. var select = this._select;
  15214. if (this._queriesLocalDatastore) {
  15215. return this._handleOfflineQuery(this.toJSON());
  15216. }
  15217. return (0, _find.default)(controller).call(controller, this.className, this.toJSON(), findOptions).then(function (response) {
  15218. var _context5; // Return generic object when explain is used
  15219. if (_this3._explain) {
  15220. return response.results;
  15221. }
  15222. var results = (0, _map2.default)(_context5 = response.results).call(_context5, function (data) {
  15223. // In cases of relations, the server may send back a className
  15224. // on the top level of the payload
  15225. var override = response.className || _this3.className;
  15226. if (!data.className) {
  15227. data.className = override;
  15228. } // Make sure the data object contains keys for all objects that
  15229. // have been requested with a select, so that our cached state
  15230. // updates correctly.
  15231. if (select) {
  15232. handleSelectResult(data, select);
  15233. }
  15234. if (options.json) {
  15235. return data;
  15236. } else {
  15237. return _ParseObject.default.fromJSON(data, !select);
  15238. }
  15239. });
  15240. var count = response.count;
  15241. if (typeof count === 'number') {
  15242. return {
  15243. results: results,
  15244. count: count
  15245. };
  15246. } else {
  15247. return results;
  15248. }
  15249. });
  15250. }
  15251. /**
  15252. * Retrieves a complete list of ParseObjects that satisfy this query.
  15253. * Using `eachBatch` under the hood to fetch all the valid objects.
  15254. *
  15255. * @param {object} options Valid options are:<ul>
  15256. * <li>batchSize: How many objects to yield in each batch (default: 100)
  15257. * <li>useMasterKey: In Cloud Code and Node only, causes the Master Key to
  15258. * be used for this request.
  15259. * <li>sessionToken: A valid session token, used for making a request on
  15260. * behalf of a specific user.
  15261. * </ul>
  15262. * @returns {Promise} A promise that is resolved with the results when
  15263. * the query completes.
  15264. */
  15265. }, {
  15266. key: "findAll",
  15267. value: function () {
  15268. var _findAll = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(options
  15269. /*:: ?: BatchOptions*/
  15270. ) {
  15271. var result;
  15272. return _regeneratorRuntime().wrap(function _callee2$(_context7) {
  15273. while (1) {
  15274. switch (_context7.prev = _context7.next) {
  15275. case 0:
  15276. result
  15277. /*: ParseObject[]*/
  15278. = [];
  15279. _context7.next = 3;
  15280. return this.eachBatch(function (objects
  15281. /*: ParseObject[]*/
  15282. ) {
  15283. var _context6;
  15284. result = (0, _concat.default)(_context6 = []).call(_context6, (0, _toConsumableArray2.default)(result), (0, _toConsumableArray2.default)(objects));
  15285. }, options);
  15286. case 3:
  15287. return _context7.abrupt("return", result);
  15288. case 4:
  15289. case "end":
  15290. return _context7.stop();
  15291. }
  15292. }
  15293. }, _callee2, this);
  15294. }));
  15295. function findAll(_x2) {
  15296. return _findAll.apply(this, arguments);
  15297. }
  15298. return findAll;
  15299. }()
  15300. /**
  15301. * Counts the number of objects that match this query.
  15302. *
  15303. * @param {object} options
  15304. * Valid options are:<ul>
  15305. * <li>useMasterKey: In Cloud Code and Node only, causes the Master Key to
  15306. * be used for this request.
  15307. * <li>sessionToken: A valid session token, used for making a request on
  15308. * behalf of a specific user.
  15309. * </ul>
  15310. *
  15311. * @returns {Promise} A promise that is resolved with the count when
  15312. * the query completes.
  15313. */
  15314. }, {
  15315. key: "count",
  15316. value: function count(options
  15317. /*:: ?: FullOptions*/
  15318. )
  15319. /*: Promise<number>*/
  15320. {
  15321. options = options || {};
  15322. var findOptions = {};
  15323. if (options.hasOwnProperty('useMasterKey')) {
  15324. findOptions.useMasterKey = options.useMasterKey;
  15325. }
  15326. if (options.hasOwnProperty('sessionToken')) {
  15327. findOptions.sessionToken = options.sessionToken;
  15328. }
  15329. this._setRequestTask(findOptions);
  15330. var controller = _CoreManager.default.getQueryController();
  15331. var params = this.toJSON();
  15332. params.limit = 0;
  15333. params.count = 1;
  15334. return (0, _find.default)(controller).call(controller, this.className, params, findOptions).then(function (result) {
  15335. return result.count;
  15336. });
  15337. }
  15338. /**
  15339. * Executes a distinct query and returns unique values
  15340. *
  15341. * @param {string} key A field to find distinct values
  15342. * @param {object} options
  15343. * Valid options are:<ul>
  15344. * <li>sessionToken: A valid session token, used for making a request on
  15345. * behalf of a specific user.
  15346. * </ul>
  15347. *
  15348. * @returns {Promise} A promise that is resolved with the query completes.
  15349. */
  15350. }, {
  15351. key: "distinct",
  15352. value: function distinct(key
  15353. /*: string*/
  15354. , options
  15355. /*:: ?: FullOptions*/
  15356. )
  15357. /*: Promise<Array<mixed>>*/
  15358. {
  15359. options = options || {};
  15360. var distinctOptions = {};
  15361. distinctOptions.useMasterKey = true;
  15362. if (options.hasOwnProperty('sessionToken')) {
  15363. distinctOptions.sessionToken = options.sessionToken;
  15364. }
  15365. this._setRequestTask(distinctOptions);
  15366. var controller = _CoreManager.default.getQueryController();
  15367. var params = {
  15368. distinct: key,
  15369. where: this._where,
  15370. hint: this._hint
  15371. };
  15372. return controller.aggregate(this.className, params, distinctOptions).then(function (results) {
  15373. return results.results;
  15374. });
  15375. }
  15376. /**
  15377. * Executes an aggregate query and returns aggregate results
  15378. *
  15379. * @param {(Array|object)} pipeline Array or Object of stages to process query
  15380. * @param {object} options Valid options are:<ul>
  15381. * <li>sessionToken: A valid session token, used for making a request on
  15382. * behalf of a specific user.
  15383. * </ul>
  15384. *
  15385. * @returns {Promise} A promise that is resolved with the query completes.
  15386. */
  15387. }, {
  15388. key: "aggregate",
  15389. value: function aggregate(pipeline
  15390. /*: mixed*/
  15391. , options
  15392. /*:: ?: FullOptions*/
  15393. )
  15394. /*: Promise<Array<mixed>>*/
  15395. {
  15396. options = options || {};
  15397. var aggregateOptions = {};
  15398. aggregateOptions.useMasterKey = true;
  15399. if (options.hasOwnProperty('sessionToken')) {
  15400. aggregateOptions.sessionToken = options.sessionToken;
  15401. }
  15402. this._setRequestTask(aggregateOptions);
  15403. var controller = _CoreManager.default.getQueryController();
  15404. if (!(0, _isArray.default)(pipeline) && (0, _typeof2.default)(pipeline) !== 'object') {
  15405. throw new Error('Invalid pipeline must be Array or Object');
  15406. }
  15407. if ((0, _keys2.default)(this._where || {}).length) {
  15408. if (!(0, _isArray.default)(pipeline)) {
  15409. pipeline = [pipeline];
  15410. }
  15411. pipeline.unshift({
  15412. match: this._where
  15413. });
  15414. }
  15415. var params = {
  15416. pipeline: pipeline,
  15417. hint: this._hint,
  15418. explain: this._explain,
  15419. readPreference: this._readPreference
  15420. };
  15421. return controller.aggregate(this.className, params, aggregateOptions).then(function (results) {
  15422. return results.results;
  15423. });
  15424. }
  15425. /**
  15426. * Retrieves at most one Parse.Object that satisfies this query.
  15427. *
  15428. * Returns the object if there is one, otherwise undefined.
  15429. *
  15430. * @param {object} options Valid options are:<ul>
  15431. * <li>useMasterKey: In Cloud Code and Node only, causes the Master Key to
  15432. * be used for this request.
  15433. * <li>sessionToken: A valid session token, used for making a request on
  15434. * behalf of a specific user.
  15435. * <li>context: A dictionary that is accessible in Cloud Code `beforeFind` trigger.
  15436. * <li>json: Return raw json without converting to Parse.Object
  15437. * </ul>
  15438. *
  15439. * @returns {Promise} A promise that is resolved with the object when
  15440. * the query completes.
  15441. */
  15442. }, {
  15443. key: "first",
  15444. value: function first(options
  15445. /*:: ?: FullOptions*/
  15446. )
  15447. /*: Promise<ParseObject | void>*/
  15448. {
  15449. var _this4 = this;
  15450. options = options || {};
  15451. var findOptions = {};
  15452. if (options.hasOwnProperty('useMasterKey')) {
  15453. findOptions.useMasterKey = options.useMasterKey;
  15454. }
  15455. if (options.hasOwnProperty('sessionToken')) {
  15456. findOptions.sessionToken = options.sessionToken;
  15457. }
  15458. if (options.hasOwnProperty('context') && (0, _typeof2.default)(options.context) === 'object') {
  15459. findOptions.context = options.context;
  15460. }
  15461. this._setRequestTask(findOptions);
  15462. var controller = _CoreManager.default.getQueryController();
  15463. var params = this.toJSON();
  15464. params.limit = 1;
  15465. var select = this._select;
  15466. if (this._queriesLocalDatastore) {
  15467. return this._handleOfflineQuery(params).then(function (objects) {
  15468. if (!objects[0]) {
  15469. return undefined;
  15470. }
  15471. return objects[0];
  15472. });
  15473. }
  15474. return (0, _find.default)(controller).call(controller, this.className, params, findOptions).then(function (response) {
  15475. var objects = response.results;
  15476. if (!objects[0]) {
  15477. return undefined;
  15478. }
  15479. if (!objects[0].className) {
  15480. objects[0].className = _this4.className;
  15481. } // Make sure the data object contains keys for all objects that
  15482. // have been requested with a select, so that our cached state
  15483. // updates correctly.
  15484. if (select) {
  15485. handleSelectResult(objects[0], select);
  15486. }
  15487. if (options.json) {
  15488. return objects[0];
  15489. } else {
  15490. return _ParseObject.default.fromJSON(objects[0], !select);
  15491. }
  15492. });
  15493. }
  15494. /**
  15495. * Iterates over objects matching a query, calling a callback for each batch.
  15496. * If the callback returns a promise, the iteration will not continue until
  15497. * that promise has been fulfilled. If the callback returns a rejected
  15498. * promise, then iteration will stop with that error. The items are processed
  15499. * in an unspecified order. The query may not have any sort order, and may
  15500. * not use limit or skip.
  15501. *
  15502. * @param {Function} callback Callback that will be called with each result
  15503. * of the query.
  15504. * @param {object} options Valid options are:<ul>
  15505. * <li>batchSize: How many objects to yield in each batch (default: 100)
  15506. * <li>useMasterKey: In Cloud Code and Node only, causes the Master Key to
  15507. * be used for this request.
  15508. * <li>sessionToken: A valid session token, used for making a request on
  15509. * behalf of a specific user.
  15510. * <li>context: A dictionary that is accessible in Cloud Code `beforeFind` trigger.
  15511. * </ul>
  15512. * @returns {Promise} A promise that will be fulfilled once the
  15513. * iteration has completed.
  15514. */
  15515. }, {
  15516. key: "eachBatch",
  15517. value: function eachBatch(callback
  15518. /*: (objs: Array<ParseObject>) => Promise<*>*/
  15519. , options
  15520. /*:: ?: BatchOptions*/
  15521. )
  15522. /*: Promise<void>*/
  15523. {
  15524. var _context8;
  15525. options = options || {};
  15526. if (this._order || this._skip || this._limit >= 0) {
  15527. var error = 'Cannot iterate on a query with sort, skip, or limit.';
  15528. return _promise.default.reject(error);
  15529. }
  15530. var query = new ParseQuery(this.className);
  15531. query._limit = options.batchSize || 100;
  15532. query._include = (0, _map2.default)(_context8 = this._include).call(_context8, function (i) {
  15533. return i;
  15534. });
  15535. if (this._select) {
  15536. var _context9;
  15537. query._select = (0, _map2.default)(_context9 = this._select).call(_context9, function (s) {
  15538. return s;
  15539. });
  15540. }
  15541. query._hint = this._hint;
  15542. query._where = {};
  15543. for (var _attr in this._where) {
  15544. var val = this._where[_attr];
  15545. if ((0, _isArray.default)(val)) {
  15546. query._where[_attr] = (0, _map2.default)(val).call(val, function (v) {
  15547. return v;
  15548. });
  15549. } else if (val && (0, _typeof2.default)(val) === 'object') {
  15550. var conditionMap = {};
  15551. query._where[_attr] = conditionMap;
  15552. for (var cond in val) {
  15553. conditionMap[cond] = val[cond];
  15554. }
  15555. } else {
  15556. query._where[_attr] = val;
  15557. }
  15558. }
  15559. query.ascending('objectId');
  15560. var findOptions = {};
  15561. if (options.hasOwnProperty('useMasterKey')) {
  15562. findOptions.useMasterKey = options.useMasterKey;
  15563. }
  15564. if (options.hasOwnProperty('sessionToken')) {
  15565. findOptions.sessionToken = options.sessionToken;
  15566. }
  15567. if (options.hasOwnProperty('context') && (0, _typeof2.default)(options.context) === 'object') {
  15568. findOptions.context = options.context;
  15569. }
  15570. if (options.hasOwnProperty('json')) {
  15571. findOptions.json = options.json;
  15572. }
  15573. var finished = false;
  15574. var previousResults = [];
  15575. return (0, _promiseUtils.continueWhile)(function () {
  15576. return !finished;
  15577. }, /*#__PURE__*/(0, _asyncToGenerator2.default)( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3() {
  15578. var _yield$Promise$all, _yield$Promise$all2, results;
  15579. return _regeneratorRuntime().wrap(function _callee3$(_context10) {
  15580. while (1) {
  15581. switch (_context10.prev = _context10.next) {
  15582. case 0:
  15583. _context10.next = 2;
  15584. return _promise.default.all([(0, _find.default)(query).call(query, findOptions), _promise.default.resolve(previousResults.length > 0 && callback(previousResults))]);
  15585. case 2:
  15586. _yield$Promise$all = _context10.sent;
  15587. _yield$Promise$all2 = (0, _slicedToArray2.default)(_yield$Promise$all, 1);
  15588. results = _yield$Promise$all2[0];
  15589. if (!(results.length >= query._limit)) {
  15590. _context10.next = 10;
  15591. break;
  15592. }
  15593. query.greaterThan('objectId', results[results.length - 1].id);
  15594. previousResults = results;
  15595. _context10.next = 17;
  15596. break;
  15597. case 10:
  15598. if (!(results.length > 0)) {
  15599. _context10.next = 16;
  15600. break;
  15601. }
  15602. _context10.next = 13;
  15603. return _promise.default.resolve(callback(results));
  15604. case 13:
  15605. finished = true;
  15606. _context10.next = 17;
  15607. break;
  15608. case 16:
  15609. finished = true;
  15610. case 17:
  15611. case "end":
  15612. return _context10.stop();
  15613. }
  15614. }
  15615. }, _callee3);
  15616. })));
  15617. }
  15618. /**
  15619. * Iterates over each result of a query, calling a callback for each one. If
  15620. * the callback returns a promise, the iteration will not continue until
  15621. * that promise has been fulfilled. If the callback returns a rejected
  15622. * promise, then iteration will stop with that error. The items are
  15623. * processed in an unspecified order. The query may not have any sort order,
  15624. * and may not use limit or skip.
  15625. *
  15626. * @param {Function} callback Callback that will be called with each result
  15627. * of the query.
  15628. * @param {object} options Valid options are:<ul>
  15629. * <li>useMasterKey: In Cloud Code and Node only, causes the Master Key to
  15630. * be used for this request.
  15631. * <li>sessionToken: A valid session token, used for making a request on
  15632. * behalf of a specific user.
  15633. * <li>json: Return raw json without converting to Parse.Object
  15634. * </ul>
  15635. * @returns {Promise} A promise that will be fulfilled once the
  15636. * iteration has completed.
  15637. */
  15638. }, {
  15639. key: "each",
  15640. value: function each(callback
  15641. /*: (obj: ParseObject) => any*/
  15642. , options
  15643. /*:: ?: BatchOptions*/
  15644. )
  15645. /*: Promise<void>*/
  15646. {
  15647. return this.eachBatch(function (results) {
  15648. var callbacksDone = _promise.default.resolve();
  15649. (0, _forEach.default)(results).call(results, function (result) {
  15650. callbacksDone = callbacksDone.then(function () {
  15651. return callback(result);
  15652. });
  15653. });
  15654. return callbacksDone;
  15655. }, options);
  15656. }
  15657. /**
  15658. * Adds a hint to force index selection. (https://docs.mongodb.com/manual/reference/operator/meta/hint/)
  15659. *
  15660. * @param {(string|object)} value String or Object of index that should be used when executing query
  15661. * @returns {Parse.Query} Returns the query, so you can chain this call.
  15662. */
  15663. }, {
  15664. key: "hint",
  15665. value: function hint(value
  15666. /*: mixed*/
  15667. )
  15668. /*: ParseQuery*/
  15669. {
  15670. if (typeof value === 'undefined') {
  15671. delete this._hint;
  15672. }
  15673. this._hint = value;
  15674. return this;
  15675. }
  15676. /**
  15677. * Investigates the query execution plan. Useful for optimizing queries. (https://docs.mongodb.com/manual/reference/operator/meta/explain/)
  15678. *
  15679. * @param {boolean} explain Used to toggle the information on the query plan.
  15680. * @returns {Parse.Query} Returns the query, so you can chain this call.
  15681. */
  15682. }, {
  15683. key: "explain",
  15684. value: function explain()
  15685. /*: ParseQuery*/
  15686. {
  15687. var _explain
  15688. /*: boolean*/
  15689. = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : true;
  15690. if (typeof _explain !== 'boolean') {
  15691. throw new Error('You can only set explain to a boolean value');
  15692. }
  15693. this._explain = _explain;
  15694. return this;
  15695. }
  15696. /**
  15697. * Iterates over each result of a query, calling a callback for each one. If
  15698. * the callback returns a promise, the iteration will not continue until
  15699. * that promise has been fulfilled. If the callback returns a rejected
  15700. * promise, then iteration will stop with that error. The items are
  15701. * processed in an unspecified order. The query may not have any sort order,
  15702. * and may not use limit or skip.
  15703. *
  15704. * @param {Function} callback Callback <ul>
  15705. * <li>currentObject: The current Parse.Object being processed in the array.</li>
  15706. * <li>index: The index of the current Parse.Object being processed in the array.</li>
  15707. * <li>query: The query map was called upon.</li>
  15708. * </ul>
  15709. *
  15710. * @param {object} options Valid options are:<ul>
  15711. * <li>useMasterKey: In Cloud Code and Node only, causes the Master Key to
  15712. * be used for this request.
  15713. * <li>sessionToken: A valid session token, used for making a request on
  15714. * behalf of a specific user.
  15715. * </ul>
  15716. * @returns {Promise} A promise that will be fulfilled once the
  15717. * iteration has completed.
  15718. */
  15719. }, {
  15720. key: "map",
  15721. value: function () {
  15722. var _map = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regeneratorRuntime().mark(function _callee4(callback
  15723. /*: (currentObject: ParseObject, index: number, query: ParseQuery) => any*/
  15724. , options
  15725. /*:: ?: BatchOptions*/
  15726. ) {
  15727. var _this5 = this;
  15728. var array, index;
  15729. return _regeneratorRuntime().wrap(function _callee4$(_context11) {
  15730. while (1) {
  15731. switch (_context11.prev = _context11.next) {
  15732. case 0:
  15733. array = [];
  15734. index = 0;
  15735. _context11.next = 4;
  15736. return this.each(function (object) {
  15737. return _promise.default.resolve(callback(object, index, _this5)).then(function (result) {
  15738. array.push(result);
  15739. index += 1;
  15740. });
  15741. }, options);
  15742. case 4:
  15743. return _context11.abrupt("return", array);
  15744. case 5:
  15745. case "end":
  15746. return _context11.stop();
  15747. }
  15748. }
  15749. }, _callee4, this);
  15750. }));
  15751. function map(_x3, _x4) {
  15752. return _map.apply(this, arguments);
  15753. }
  15754. return map;
  15755. }()
  15756. /**
  15757. * Iterates over each result of a query, calling a callback for each one. If
  15758. * the callback returns a promise, the iteration will not continue until
  15759. * that promise has been fulfilled. If the callback returns a rejected
  15760. * promise, then iteration will stop with that error. The items are
  15761. * processed in an unspecified order. The query may not have any sort order,
  15762. * and may not use limit or skip.
  15763. *
  15764. * @param {Function} callback Callback <ul>
  15765. * <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>
  15766. * <li>currentObject: The current Parse.Object being processed in the array.</li>
  15767. * <li>index: The index of the current Parse.Object being processed in the array.</li>
  15768. * </ul>
  15769. * @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.
  15770. * @param {object} options Valid options are:<ul>
  15771. * <li>useMasterKey: In Cloud Code and Node only, causes the Master Key to
  15772. * be used for this request.
  15773. * <li>sessionToken: A valid session token, used for making a request on
  15774. * behalf of a specific user.
  15775. * </ul>
  15776. * @returns {Promise} A promise that will be fulfilled once the
  15777. * iteration has completed.
  15778. */
  15779. }, {
  15780. key: "reduce",
  15781. value: function () {
  15782. var _reduce = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regeneratorRuntime().mark(function _callee5(callback
  15783. /*: (accumulator: any, currentObject: ParseObject, index: number) => any*/
  15784. , initialValue
  15785. /*: any*/
  15786. , options
  15787. /*:: ?: BatchOptions*/
  15788. ) {
  15789. var accumulator, index;
  15790. return _regeneratorRuntime().wrap(function _callee5$(_context12) {
  15791. while (1) {
  15792. switch (_context12.prev = _context12.next) {
  15793. case 0:
  15794. accumulator = initialValue;
  15795. index = 0;
  15796. _context12.next = 4;
  15797. return this.each(function (object) {
  15798. // If no initial value was given, we take the first object from the query
  15799. // as the initial value and don't call the callback with it.
  15800. if (index === 0 && initialValue === undefined) {
  15801. accumulator = object;
  15802. index += 1;
  15803. return;
  15804. }
  15805. return _promise.default.resolve(callback(accumulator, object, index)).then(function (result) {
  15806. accumulator = result;
  15807. index += 1;
  15808. });
  15809. }, options);
  15810. case 4:
  15811. if (!(index === 0 && initialValue === undefined)) {
  15812. _context12.next = 6;
  15813. break;
  15814. }
  15815. throw new TypeError('Reducing empty query result set with no initial value');
  15816. case 6:
  15817. return _context12.abrupt("return", accumulator);
  15818. case 7:
  15819. case "end":
  15820. return _context12.stop();
  15821. }
  15822. }
  15823. }, _callee5, this);
  15824. }));
  15825. function reduce(_x5, _x6, _x7) {
  15826. return _reduce.apply(this, arguments);
  15827. }
  15828. return reduce;
  15829. }()
  15830. /**
  15831. * Iterates over each result of a query, calling a callback for each one. If
  15832. * the callback returns a promise, the iteration will not continue until
  15833. * that promise has been fulfilled. If the callback returns a rejected
  15834. * promise, then iteration will stop with that error. The items are
  15835. * processed in an unspecified order. The query may not have any sort order,
  15836. * and may not use limit or skip.
  15837. *
  15838. * @param {Function} callback Callback <ul>
  15839. * <li>currentObject: The current Parse.Object being processed in the array.</li>
  15840. * <li>index: The index of the current Parse.Object being processed in the array.</li>
  15841. * <li>query: The query filter was called upon.</li>
  15842. * </ul>
  15843. *
  15844. * @param {object} options Valid options are:<ul>
  15845. * <li>useMasterKey: In Cloud Code and Node only, causes the Master Key to
  15846. * be used for this request.
  15847. * <li>sessionToken: A valid session token, used for making a request on
  15848. * behalf of a specific user.
  15849. * </ul>
  15850. * @returns {Promise} A promise that will be fulfilled once the
  15851. * iteration has completed.
  15852. */
  15853. }, {
  15854. key: "filter",
  15855. value: function () {
  15856. var _filter = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regeneratorRuntime().mark(function _callee6(callback
  15857. /*: (currentObject: ParseObject, index: number, query: ParseQuery) => boolean*/
  15858. , options
  15859. /*:: ?: BatchOptions*/
  15860. ) {
  15861. var _this6 = this;
  15862. var array, index;
  15863. return _regeneratorRuntime().wrap(function _callee6$(_context13) {
  15864. while (1) {
  15865. switch (_context13.prev = _context13.next) {
  15866. case 0:
  15867. array = [];
  15868. index = 0;
  15869. _context13.next = 4;
  15870. return this.each(function (object) {
  15871. return _promise.default.resolve(callback(object, index, _this6)).then(function (flag) {
  15872. if (flag) {
  15873. array.push(object);
  15874. }
  15875. index += 1;
  15876. });
  15877. }, options);
  15878. case 4:
  15879. return _context13.abrupt("return", array);
  15880. case 5:
  15881. case "end":
  15882. return _context13.stop();
  15883. }
  15884. }
  15885. }, _callee6, this);
  15886. }));
  15887. function filter(_x8, _x9) {
  15888. return _filter.apply(this, arguments);
  15889. }
  15890. return filter;
  15891. }()
  15892. /** Query Conditions **/
  15893. /**
  15894. * Adds a constraint to the query that requires a particular key's value to
  15895. * be equal to the provided value.
  15896. *
  15897. * @param {string} key The key to check.
  15898. * @param value The value that the Parse.Object must contain.
  15899. * @returns {Parse.Query} Returns the query, so you can chain this call.
  15900. */
  15901. }, {
  15902. key: "equalTo",
  15903. value: function equalTo(key
  15904. /*: string | { [key: string]: any }*/
  15905. , value
  15906. /*: ?mixed*/
  15907. )
  15908. /*: ParseQuery*/
  15909. {
  15910. var _this7 = this;
  15911. if (key && (0, _typeof2.default)(key) === 'object') {
  15912. var _context14;
  15913. (0, _forEach.default)(_context14 = (0, _entries.default)(key)).call(_context14, function (_ref2) {
  15914. var _ref3 = (0, _slicedToArray2.default)(_ref2, 2),
  15915. k = _ref3[0],
  15916. val = _ref3[1];
  15917. return _this7.equalTo(k, val);
  15918. });
  15919. return this;
  15920. }
  15921. if (typeof value === 'undefined') {
  15922. return this.doesNotExist(key);
  15923. }
  15924. this._where[key] = (0, _encode.default)(value, false, true);
  15925. return this;
  15926. }
  15927. /**
  15928. * Adds a constraint to the query that requires a particular key's value to
  15929. * be not equal to the provided value.
  15930. *
  15931. * @param {string} key The key to check.
  15932. * @param value The value that must not be equalled.
  15933. * @returns {Parse.Query} Returns the query, so you can chain this call.
  15934. */
  15935. }, {
  15936. key: "notEqualTo",
  15937. value: function notEqualTo(key
  15938. /*: string | { [key: string]: any }*/
  15939. , value
  15940. /*: ?mixed*/
  15941. )
  15942. /*: ParseQuery*/
  15943. {
  15944. var _this8 = this;
  15945. if (key && (0, _typeof2.default)(key) === 'object') {
  15946. var _context15;
  15947. (0, _forEach.default)(_context15 = (0, _entries.default)(key)).call(_context15, function (_ref4) {
  15948. var _ref5 = (0, _slicedToArray2.default)(_ref4, 2),
  15949. k = _ref5[0],
  15950. val = _ref5[1];
  15951. return _this8.notEqualTo(k, val);
  15952. });
  15953. return this;
  15954. }
  15955. return this._addCondition(key, '$ne', value);
  15956. }
  15957. /**
  15958. * Adds a constraint to the query that requires a particular key's value to
  15959. * be less than the provided value.
  15960. *
  15961. * @param {string} key The key to check.
  15962. * @param value The value that provides an upper bound.
  15963. * @returns {Parse.Query} Returns the query, so you can chain this call.
  15964. */
  15965. }, {
  15966. key: "lessThan",
  15967. value: function lessThan(key
  15968. /*: string*/
  15969. , value
  15970. /*: mixed*/
  15971. )
  15972. /*: ParseQuery*/
  15973. {
  15974. return this._addCondition(key, '$lt', value);
  15975. }
  15976. /**
  15977. * Adds a constraint to the query that requires a particular key's value to
  15978. * be greater than the provided value.
  15979. *
  15980. * @param {string} key The key to check.
  15981. * @param value The value that provides an lower bound.
  15982. * @returns {Parse.Query} Returns the query, so you can chain this call.
  15983. */
  15984. }, {
  15985. key: "greaterThan",
  15986. value: function greaterThan(key
  15987. /*: string*/
  15988. , value
  15989. /*: mixed*/
  15990. )
  15991. /*: ParseQuery*/
  15992. {
  15993. return this._addCondition(key, '$gt', value);
  15994. }
  15995. /**
  15996. * Adds a constraint to the query that requires a particular key's value to
  15997. * be less than or equal to the provided value.
  15998. *
  15999. * @param {string} key The key to check.
  16000. * @param value The value that provides an upper bound.
  16001. * @returns {Parse.Query} Returns the query, so you can chain this call.
  16002. */
  16003. }, {
  16004. key: "lessThanOrEqualTo",
  16005. value: function lessThanOrEqualTo(key
  16006. /*: string*/
  16007. , value
  16008. /*: mixed*/
  16009. )
  16010. /*: ParseQuery*/
  16011. {
  16012. return this._addCondition(key, '$lte', value);
  16013. }
  16014. /**
  16015. * Adds a constraint to the query that requires a particular key's value to
  16016. * be greater than or equal to the provided value.
  16017. *
  16018. * @param {string} key The key to check.
  16019. * @param {*} value The value that provides an lower bound.
  16020. * @returns {Parse.Query} Returns the query, so you can chain this call.
  16021. */
  16022. }, {
  16023. key: "greaterThanOrEqualTo",
  16024. value: function greaterThanOrEqualTo(key
  16025. /*: string*/
  16026. , value
  16027. /*: mixed*/
  16028. )
  16029. /*: ParseQuery*/
  16030. {
  16031. return this._addCondition(key, '$gte', value);
  16032. }
  16033. /**
  16034. * Adds a constraint to the query that requires a particular key's value to
  16035. * be contained in the provided list of values.
  16036. *
  16037. * @param {string} key The key to check.
  16038. * @param {*} value The values that will match.
  16039. * @returns {Parse.Query} Returns the query, so you can chain this call.
  16040. */
  16041. }, {
  16042. key: "containedIn",
  16043. value: function containedIn(key
  16044. /*: string*/
  16045. , value
  16046. /*: mixed*/
  16047. )
  16048. /*: ParseQuery*/
  16049. {
  16050. return this._addCondition(key, '$in', value);
  16051. }
  16052. /**
  16053. * Adds a constraint to the query that requires a particular key's value to
  16054. * not be contained in the provided list of values.
  16055. *
  16056. * @param {string} key The key to check.
  16057. * @param {*} value The values that will not match.
  16058. * @returns {Parse.Query} Returns the query, so you can chain this call.
  16059. */
  16060. }, {
  16061. key: "notContainedIn",
  16062. value: function notContainedIn(key
  16063. /*: string*/
  16064. , value
  16065. /*: mixed*/
  16066. )
  16067. /*: ParseQuery*/
  16068. {
  16069. return this._addCondition(key, '$nin', value);
  16070. }
  16071. /**
  16072. * Adds a constraint to the query that requires a particular key's value to
  16073. * be contained by the provided list of values. Get objects where all array elements match.
  16074. *
  16075. * @param {string} key The key to check.
  16076. * @param {Array} values The values that will match.
  16077. * @returns {Parse.Query} Returns the query, so you can chain this call.
  16078. */
  16079. }, {
  16080. key: "containedBy",
  16081. value: function containedBy(key
  16082. /*: string*/
  16083. , values
  16084. /*: Array<mixed>*/
  16085. )
  16086. /*: ParseQuery*/
  16087. {
  16088. return this._addCondition(key, '$containedBy', values);
  16089. }
  16090. /**
  16091. * Adds a constraint to the query that requires a particular key's value to
  16092. * contain each one of the provided list of values.
  16093. *
  16094. * @param {string} key The key to check. This key's value must be an array.
  16095. * @param {Array} values The values that will match.
  16096. * @returns {Parse.Query} Returns the query, so you can chain this call.
  16097. */
  16098. }, {
  16099. key: "containsAll",
  16100. value: function containsAll(key
  16101. /*: string*/
  16102. , values
  16103. /*: Array<mixed>*/
  16104. )
  16105. /*: ParseQuery*/
  16106. {
  16107. return this._addCondition(key, '$all', values);
  16108. }
  16109. /**
  16110. * Adds a constraint to the query that requires a particular key's value to
  16111. * contain each one of the provided list of values starting with given strings.
  16112. *
  16113. * @param {string} key The key to check. This key's value must be an array.
  16114. * @param {Array<string>} values The string values that will match as starting string.
  16115. * @returns {Parse.Query} Returns the query, so you can chain this call.
  16116. */
  16117. }, {
  16118. key: "containsAllStartingWith",
  16119. value: function containsAllStartingWith(key
  16120. /*: string*/
  16121. , values
  16122. /*: Array<string>*/
  16123. )
  16124. /*: ParseQuery*/
  16125. {
  16126. var _this = this;
  16127. if (!(0, _isArray.default)(values)) {
  16128. values = [values];
  16129. }
  16130. var regexObject = (0, _map2.default)(values).call(values, function (value) {
  16131. return {
  16132. $regex: _this._regexStartWith(value)
  16133. };
  16134. });
  16135. return this.containsAll(key, regexObject);
  16136. }
  16137. /**
  16138. * Adds a constraint for finding objects that contain the given key.
  16139. *
  16140. * @param {string} key The key that should exist.
  16141. * @returns {Parse.Query} Returns the query, so you can chain this call.
  16142. */
  16143. }, {
  16144. key: "exists",
  16145. value: function exists(key
  16146. /*: string*/
  16147. )
  16148. /*: ParseQuery*/
  16149. {
  16150. return this._addCondition(key, '$exists', true);
  16151. }
  16152. /**
  16153. * Adds a constraint for finding objects that do not contain a given key.
  16154. *
  16155. * @param {string} key The key that should not exist
  16156. * @returns {Parse.Query} Returns the query, so you can chain this call.
  16157. */
  16158. }, {
  16159. key: "doesNotExist",
  16160. value: function doesNotExist(key
  16161. /*: string*/
  16162. )
  16163. /*: ParseQuery*/
  16164. {
  16165. return this._addCondition(key, '$exists', false);
  16166. }
  16167. /**
  16168. * Adds a regular expression constraint for finding string values that match
  16169. * the provided regular expression.
  16170. * This may be slow for large datasets.
  16171. *
  16172. * @param {string} key The key that the string to match is stored in.
  16173. * @param {RegExp} regex The regular expression pattern to match.
  16174. * @param {string} modifiers The regular expression mode.
  16175. * @returns {Parse.Query} Returns the query, so you can chain this call.
  16176. */
  16177. }, {
  16178. key: "matches",
  16179. value: function matches(key
  16180. /*: string*/
  16181. , regex
  16182. /*: RegExp*/
  16183. , modifiers
  16184. /*: string*/
  16185. )
  16186. /*: ParseQuery*/
  16187. {
  16188. this._addCondition(key, '$regex', regex);
  16189. if (!modifiers) {
  16190. modifiers = '';
  16191. }
  16192. if (regex.ignoreCase) {
  16193. modifiers += 'i';
  16194. }
  16195. if (regex.multiline) {
  16196. modifiers += 'm';
  16197. }
  16198. if (modifiers.length) {
  16199. this._addCondition(key, '$options', modifiers);
  16200. }
  16201. return this;
  16202. }
  16203. /**
  16204. * Adds a constraint that requires that a key's value matches a Parse.Query
  16205. * constraint.
  16206. *
  16207. * @param {string} key The key that the contains the object to match the
  16208. * query.
  16209. * @param {Parse.Query} query The query that should match.
  16210. * @returns {Parse.Query} Returns the query, so you can chain this call.
  16211. */
  16212. }, {
  16213. key: "matchesQuery",
  16214. value: function matchesQuery(key
  16215. /*: string*/
  16216. , query
  16217. /*: ParseQuery*/
  16218. )
  16219. /*: ParseQuery*/
  16220. {
  16221. var queryJSON = query.toJSON();
  16222. queryJSON.className = query.className;
  16223. return this._addCondition(key, '$inQuery', queryJSON);
  16224. }
  16225. /**
  16226. * Adds a constraint that requires that a key's value not matches a
  16227. * Parse.Query constraint.
  16228. *
  16229. * @param {string} key The key that the contains the object to match the
  16230. * query.
  16231. * @param {Parse.Query} query The query that should not match.
  16232. * @returns {Parse.Query} Returns the query, so you can chain this call.
  16233. */
  16234. }, {
  16235. key: "doesNotMatchQuery",
  16236. value: function doesNotMatchQuery(key
  16237. /*: string*/
  16238. , query
  16239. /*: ParseQuery*/
  16240. )
  16241. /*: ParseQuery*/
  16242. {
  16243. var queryJSON = query.toJSON();
  16244. queryJSON.className = query.className;
  16245. return this._addCondition(key, '$notInQuery', queryJSON);
  16246. }
  16247. /**
  16248. * Adds a constraint that requires that a key's value matches a value in
  16249. * an object returned by a different Parse.Query.
  16250. *
  16251. * @param {string} key The key that contains the value that is being
  16252. * matched.
  16253. * @param {string} queryKey The key in the objects returned by the query to
  16254. * match against.
  16255. * @param {Parse.Query} query The query to run.
  16256. * @returns {Parse.Query} Returns the query, so you can chain this call.
  16257. */
  16258. }, {
  16259. key: "matchesKeyInQuery",
  16260. value: function matchesKeyInQuery(key
  16261. /*: string*/
  16262. , queryKey
  16263. /*: string*/
  16264. , query
  16265. /*: ParseQuery*/
  16266. )
  16267. /*: ParseQuery*/
  16268. {
  16269. var queryJSON = query.toJSON();
  16270. queryJSON.className = query.className;
  16271. return this._addCondition(key, '$select', {
  16272. key: queryKey,
  16273. query: queryJSON
  16274. });
  16275. }
  16276. /**
  16277. * Adds a constraint that requires that a key's value not match a value in
  16278. * an object returned by a different Parse.Query.
  16279. *
  16280. * @param {string} key The key that contains the value that is being
  16281. * excluded.
  16282. * @param {string} queryKey The key in the objects returned by the query to
  16283. * match against.
  16284. * @param {Parse.Query} query The query to run.
  16285. * @returns {Parse.Query} Returns the query, so you can chain this call.
  16286. */
  16287. }, {
  16288. key: "doesNotMatchKeyInQuery",
  16289. value: function doesNotMatchKeyInQuery(key
  16290. /*: string*/
  16291. , queryKey
  16292. /*: string*/
  16293. , query
  16294. /*: ParseQuery*/
  16295. )
  16296. /*: ParseQuery*/
  16297. {
  16298. var queryJSON = query.toJSON();
  16299. queryJSON.className = query.className;
  16300. return this._addCondition(key, '$dontSelect', {
  16301. key: queryKey,
  16302. query: queryJSON
  16303. });
  16304. }
  16305. /**
  16306. * Adds a constraint for finding string values that contain a provided
  16307. * string. This may be slow for large datasets.
  16308. *
  16309. * @param {string} key The key that the string to match is stored in.
  16310. * @param {string} substring The substring that the value must contain.
  16311. * @returns {Parse.Query} Returns the query, so you can chain this call.
  16312. */
  16313. }, {
  16314. key: "contains",
  16315. value: function contains(key
  16316. /*: string*/
  16317. , substring
  16318. /*: string*/
  16319. )
  16320. /*: ParseQuery*/
  16321. {
  16322. if (typeof substring !== 'string') {
  16323. throw new Error('The value being searched for must be a string.');
  16324. }
  16325. return this._addCondition(key, '$regex', quote(substring));
  16326. }
  16327. /**
  16328. * Adds a constraint for finding string values that contain a provided
  16329. * string. This may be slow for large datasets. Requires Parse-Server > 2.5.0
  16330. *
  16331. * In order to sort you must use select and ascending ($score is required)
  16332. * <pre>
  16333. * query.fullText('field', 'term');
  16334. * query.ascending('$score');
  16335. * query.select('$score');
  16336. * </pre>
  16337. *
  16338. * To retrieve the weight / rank
  16339. * <pre>
  16340. * object->get('score');
  16341. * </pre>
  16342. *
  16343. * You can define optionals by providing an object as a third parameter
  16344. * <pre>
  16345. * query.fullText('field', 'term', { language: 'es', diacriticSensitive: true });
  16346. * </pre>
  16347. *
  16348. * @param {string} key The key that the string to match is stored in.
  16349. * @param {string} value The string to search
  16350. * @param {object} options (Optional)
  16351. * @param {string} options.language The language that determines the list of stop words for the search and the rules for the stemmer and tokenizer.
  16352. * @param {boolean} options.caseSensitive A boolean flag to enable or disable case sensitive search.
  16353. * @param {boolean} options.diacriticSensitive A boolean flag to enable or disable diacritic sensitive search.
  16354. * @returns {Parse.Query} Returns the query, so you can chain this call.
  16355. */
  16356. }, {
  16357. key: "fullText",
  16358. value: function fullText(key
  16359. /*: string*/
  16360. , value
  16361. /*: string*/
  16362. , options
  16363. /*: ?Object*/
  16364. )
  16365. /*: ParseQuery*/
  16366. {
  16367. options = options || {};
  16368. if (!key) {
  16369. throw new Error('A key is required.');
  16370. }
  16371. if (!value) {
  16372. throw new Error('A search term is required');
  16373. }
  16374. if (typeof value !== 'string') {
  16375. throw new Error('The value being searched for must be a string.');
  16376. }
  16377. var fullOptions = {};
  16378. fullOptions.$term = value;
  16379. for (var option in options) {
  16380. switch (option) {
  16381. case 'language':
  16382. fullOptions.$language = options[option];
  16383. break;
  16384. case 'caseSensitive':
  16385. fullOptions.$caseSensitive = options[option];
  16386. break;
  16387. case 'diacriticSensitive':
  16388. fullOptions.$diacriticSensitive = options[option];
  16389. break;
  16390. default:
  16391. throw new Error("Unknown option: ".concat(option));
  16392. }
  16393. }
  16394. return this._addCondition(key, '$text', {
  16395. $search: fullOptions
  16396. });
  16397. }
  16398. /**
  16399. * Method to sort the full text search by text score
  16400. *
  16401. * @returns {Parse.Query} Returns the query, so you can chain this call.
  16402. */
  16403. }, {
  16404. key: "sortByTextScore",
  16405. value: function sortByTextScore() {
  16406. this.ascending('$score');
  16407. this.select(['$score']);
  16408. return this;
  16409. }
  16410. /**
  16411. * Adds a constraint for finding string values that start with a provided
  16412. * string. This query will use the backend index, so it will be fast even
  16413. * for large datasets.
  16414. *
  16415. * @param {string} key The key that the string to match is stored in.
  16416. * @param {string} prefix The substring that the value must start with.
  16417. * @param {string} modifiers The regular expression mode.
  16418. * @returns {Parse.Query} Returns the query, so you can chain this call.
  16419. */
  16420. }, {
  16421. key: "startsWith",
  16422. value: function startsWith(key
  16423. /*: string*/
  16424. , prefix
  16425. /*: string*/
  16426. , modifiers
  16427. /*: string*/
  16428. )
  16429. /*: ParseQuery*/
  16430. {
  16431. if (typeof prefix !== 'string') {
  16432. throw new Error('The value being searched for must be a string.');
  16433. }
  16434. return this.matches(key, this._regexStartWith(prefix), modifiers);
  16435. }
  16436. /**
  16437. * Adds a constraint for finding string values that end with a provided
  16438. * string. This will be slow for large datasets.
  16439. *
  16440. * @param {string} key The key that the string to match is stored in.
  16441. * @param {string} suffix The substring that the value must end with.
  16442. * @param {string} modifiers The regular expression mode.
  16443. * @returns {Parse.Query} Returns the query, so you can chain this call.
  16444. */
  16445. }, {
  16446. key: "endsWith",
  16447. value: function endsWith(key
  16448. /*: string*/
  16449. , suffix
  16450. /*: string*/
  16451. , modifiers
  16452. /*: string*/
  16453. )
  16454. /*: ParseQuery*/
  16455. {
  16456. if (typeof suffix !== 'string') {
  16457. throw new Error('The value being searched for must be a string.');
  16458. }
  16459. return this.matches(key, quote(suffix) + '$', modifiers);
  16460. }
  16461. /**
  16462. * Adds a proximity based constraint for finding objects with key point
  16463. * values near the point given.
  16464. *
  16465. * @param {string} key The key that the Parse.GeoPoint is stored in.
  16466. * @param {Parse.GeoPoint} point The reference Parse.GeoPoint that is used.
  16467. * @returns {Parse.Query} Returns the query, so you can chain this call.
  16468. */
  16469. }, {
  16470. key: "near",
  16471. value: function near(key
  16472. /*: string*/
  16473. , point
  16474. /*: ParseGeoPoint*/
  16475. )
  16476. /*: ParseQuery*/
  16477. {
  16478. if (!(point instanceof _ParseGeoPoint.default)) {
  16479. // Try to cast it as a GeoPoint
  16480. point = new _ParseGeoPoint.default(point);
  16481. }
  16482. return this._addCondition(key, '$nearSphere', point);
  16483. }
  16484. /**
  16485. * Adds a proximity based constraint for finding objects with key point
  16486. * values near the point given and within the maximum distance given.
  16487. *
  16488. * @param {string} key The key that the Parse.GeoPoint is stored in.
  16489. * @param {Parse.GeoPoint} point The reference Parse.GeoPoint that is used.
  16490. * @param {number} maxDistance Maximum distance (in radians) of results to return.
  16491. * @param {boolean} sorted A Bool value that is true if results should be
  16492. * sorted by distance ascending, false is no sorting is required,
  16493. * defaults to true.
  16494. * @returns {Parse.Query} Returns the query, so you can chain this call.
  16495. */
  16496. }, {
  16497. key: "withinRadians",
  16498. value: function withinRadians(key
  16499. /*: string*/
  16500. , point
  16501. /*: ParseGeoPoint*/
  16502. , maxDistance
  16503. /*: number*/
  16504. , sorted
  16505. /*: boolean*/
  16506. )
  16507. /*: ParseQuery*/
  16508. {
  16509. if (sorted || sorted === undefined) {
  16510. this.near(key, point);
  16511. return this._addCondition(key, '$maxDistance', maxDistance);
  16512. } else {
  16513. return this._addCondition(key, '$geoWithin', {
  16514. $centerSphere: [[point.longitude, point.latitude], maxDistance]
  16515. });
  16516. }
  16517. }
  16518. /**
  16519. * Adds a proximity based constraint for finding objects with key point
  16520. * values near the point given and within the maximum distance given.
  16521. * Radius of earth used is 3958.8 miles.
  16522. *
  16523. * @param {string} key The key that the Parse.GeoPoint is stored in.
  16524. * @param {Parse.GeoPoint} point The reference Parse.GeoPoint that is used.
  16525. * @param {number} maxDistance Maximum distance (in miles) of results to return.
  16526. * @param {boolean} sorted A Bool value that is true if results should be
  16527. * sorted by distance ascending, false is no sorting is required,
  16528. * defaults to true.
  16529. * @returns {Parse.Query} Returns the query, so you can chain this call.
  16530. */
  16531. }, {
  16532. key: "withinMiles",
  16533. value: function withinMiles(key
  16534. /*: string*/
  16535. , point
  16536. /*: ParseGeoPoint*/
  16537. , maxDistance
  16538. /*: number*/
  16539. , sorted
  16540. /*: boolean*/
  16541. )
  16542. /*: ParseQuery*/
  16543. {
  16544. return this.withinRadians(key, point, maxDistance / 3958.8, sorted);
  16545. }
  16546. /**
  16547. * Adds a proximity based constraint for finding objects with key point
  16548. * values near the point given and within the maximum distance given.
  16549. * Radius of earth used is 6371.0 kilometers.
  16550. *
  16551. * @param {string} key The key that the Parse.GeoPoint is stored in.
  16552. * @param {Parse.GeoPoint} point The reference Parse.GeoPoint that is used.
  16553. * @param {number} maxDistance Maximum distance (in kilometers) of results to return.
  16554. * @param {boolean} sorted A Bool value that is true if results should be
  16555. * sorted by distance ascending, false is no sorting is required,
  16556. * defaults to true.
  16557. * @returns {Parse.Query} Returns the query, so you can chain this call.
  16558. */
  16559. }, {
  16560. key: "withinKilometers",
  16561. value: function withinKilometers(key
  16562. /*: string*/
  16563. , point
  16564. /*: ParseGeoPoint*/
  16565. , maxDistance
  16566. /*: number*/
  16567. , sorted
  16568. /*: boolean*/
  16569. )
  16570. /*: ParseQuery*/
  16571. {
  16572. return this.withinRadians(key, point, maxDistance / 6371.0, sorted);
  16573. }
  16574. /**
  16575. * Adds a constraint to the query that requires a particular key's
  16576. * coordinates be contained within a given rectangular geographic bounding
  16577. * box.
  16578. *
  16579. * @param {string} key The key to be constrained.
  16580. * @param {Parse.GeoPoint} southwest
  16581. * The lower-left inclusive corner of the box.
  16582. * @param {Parse.GeoPoint} northeast
  16583. * The upper-right inclusive corner of the box.
  16584. * @returns {Parse.Query} Returns the query, so you can chain this call.
  16585. */
  16586. }, {
  16587. key: "withinGeoBox",
  16588. value: function withinGeoBox(key
  16589. /*: string*/
  16590. , southwest
  16591. /*: ParseGeoPoint*/
  16592. , northeast
  16593. /*: ParseGeoPoint*/
  16594. )
  16595. /*: ParseQuery*/
  16596. {
  16597. if (!(southwest instanceof _ParseGeoPoint.default)) {
  16598. southwest = new _ParseGeoPoint.default(southwest);
  16599. }
  16600. if (!(northeast instanceof _ParseGeoPoint.default)) {
  16601. northeast = new _ParseGeoPoint.default(northeast);
  16602. }
  16603. this._addCondition(key, '$within', {
  16604. $box: [southwest, northeast]
  16605. });
  16606. return this;
  16607. }
  16608. /**
  16609. * Adds a constraint to the query that requires a particular key's
  16610. * coordinates be contained within and on the bounds of a given polygon.
  16611. * Supports closed and open (last point is connected to first) paths
  16612. *
  16613. * Polygon must have at least 3 points
  16614. *
  16615. * @param {string} key The key to be constrained.
  16616. * @param {Array} points Array of Coordinates / GeoPoints
  16617. * @returns {Parse.Query} Returns the query, so you can chain this call.
  16618. */
  16619. }, {
  16620. key: "withinPolygon",
  16621. value: function withinPolygon(key
  16622. /*: string*/
  16623. , points
  16624. /*: Array<Array<number>>*/
  16625. )
  16626. /*: ParseQuery*/
  16627. {
  16628. return this._addCondition(key, '$geoWithin', {
  16629. $polygon: points
  16630. });
  16631. }
  16632. /**
  16633. * Add a constraint to the query that requires a particular key's
  16634. * coordinates that contains a ParseGeoPoint
  16635. *
  16636. * @param {string} key The key to be constrained.
  16637. * @param {Parse.GeoPoint} point
  16638. * @returns {Parse.Query} Returns the query, so you can chain this call.
  16639. */
  16640. }, {
  16641. key: "polygonContains",
  16642. value: function polygonContains(key
  16643. /*: string*/
  16644. , point
  16645. /*: ParseGeoPoint*/
  16646. )
  16647. /*: ParseQuery*/
  16648. {
  16649. return this._addCondition(key, '$geoIntersects', {
  16650. $point: point
  16651. });
  16652. }
  16653. /** Query Orderings **/
  16654. /**
  16655. * Sorts the results in ascending order by the given key.
  16656. *
  16657. * @param {(string|string[])} keys The key to order by, which is a
  16658. * string of comma separated values, or an Array of keys, or multiple keys.
  16659. * @returns {Parse.Query} Returns the query, so you can chain this call.
  16660. */
  16661. }, {
  16662. key: "ascending",
  16663. value: function ascending()
  16664. /*: ParseQuery*/
  16665. {
  16666. this._order = [];
  16667. for (var _len = arguments.length, keys = new Array(_len), _key5 = 0; _key5 < _len; _key5++) {
  16668. keys[_key5] = arguments[_key5];
  16669. }
  16670. return this.addAscending.apply(this, keys);
  16671. }
  16672. /**
  16673. * Sorts the results in ascending order by the given key,
  16674. * but can also add secondary sort descriptors without overwriting _order.
  16675. *
  16676. * @param {(string|string[])} keys The key to order by, which is a
  16677. * string of comma separated values, or an Array of keys, or multiple keys.
  16678. * @returns {Parse.Query} Returns the query, so you can chain this call.
  16679. */
  16680. }, {
  16681. key: "addAscending",
  16682. value: function addAscending()
  16683. /*: ParseQuery*/
  16684. {
  16685. var _this9 = this;
  16686. if (!this._order) {
  16687. this._order = [];
  16688. }
  16689. for (var _len2 = arguments.length, keys = new Array(_len2), _key6 = 0; _key6 < _len2; _key6++) {
  16690. keys[_key6] = arguments[_key6];
  16691. }
  16692. (0, _forEach.default)(keys).call(keys, function (key) {
  16693. var _context16;
  16694. if ((0, _isArray.default)(key)) {
  16695. key = key.join();
  16696. }
  16697. _this9._order = (0, _concat.default)(_context16 = _this9._order).call(_context16, key.replace(/\s/g, '').split(','));
  16698. });
  16699. return this;
  16700. }
  16701. /**
  16702. * Sorts the results in descending order by the given key.
  16703. *
  16704. * @param {(string|string[])} keys The key to order by, which is a
  16705. * string of comma separated values, or an Array of keys, or multiple keys.
  16706. * @returns {Parse.Query} Returns the query, so you can chain this call.
  16707. */
  16708. }, {
  16709. key: "descending",
  16710. value: function descending()
  16711. /*: ParseQuery*/
  16712. {
  16713. this._order = [];
  16714. for (var _len3 = arguments.length, keys = new Array(_len3), _key7 = 0; _key7 < _len3; _key7++) {
  16715. keys[_key7] = arguments[_key7];
  16716. }
  16717. return this.addDescending.apply(this, keys);
  16718. }
  16719. /**
  16720. * Sorts the results in descending order by the given key,
  16721. * but can also add secondary sort descriptors without overwriting _order.
  16722. *
  16723. * @param {(string|string[])} keys The key to order by, which is a
  16724. * string of comma separated values, or an Array of keys, or multiple keys.
  16725. * @returns {Parse.Query} Returns the query, so you can chain this call.
  16726. */
  16727. }, {
  16728. key: "addDescending",
  16729. value: function addDescending()
  16730. /*: ParseQuery*/
  16731. {
  16732. var _this10 = this;
  16733. if (!this._order) {
  16734. this._order = [];
  16735. }
  16736. for (var _len4 = arguments.length, keys = new Array(_len4), _key8 = 0; _key8 < _len4; _key8++) {
  16737. keys[_key8] = arguments[_key8];
  16738. }
  16739. (0, _forEach.default)(keys).call(keys, function (key) {
  16740. var _context17, _context18;
  16741. if ((0, _isArray.default)(key)) {
  16742. key = key.join();
  16743. }
  16744. _this10._order = (0, _concat.default)(_context17 = _this10._order).call(_context17, (0, _map2.default)(_context18 = key.replace(/\s/g, '').split(',')).call(_context18, function (k) {
  16745. return '-' + k;
  16746. }));
  16747. });
  16748. return this;
  16749. }
  16750. /** Query Options **/
  16751. /**
  16752. * Sets the number of results to skip before returning any results.
  16753. * This is useful for pagination.
  16754. * Default is to skip zero results.
  16755. *
  16756. * @param {number} n the number of results to skip.
  16757. * @returns {Parse.Query} Returns the query, so you can chain this call.
  16758. */
  16759. }, {
  16760. key: "skip",
  16761. value: function skip(n
  16762. /*: number*/
  16763. )
  16764. /*: ParseQuery*/
  16765. {
  16766. if (typeof n !== 'number' || n < 0) {
  16767. throw new Error('You can only skip by a positive number');
  16768. }
  16769. this._skip = n;
  16770. return this;
  16771. }
  16772. /**
  16773. * Sets the limit of the number of results to return. The default limit is 100.
  16774. *
  16775. * @param {number} n the number of results to limit to.
  16776. * @returns {Parse.Query} Returns the query, so you can chain this call.
  16777. */
  16778. }, {
  16779. key: "limit",
  16780. value: function limit(n
  16781. /*: number*/
  16782. )
  16783. /*: ParseQuery*/
  16784. {
  16785. if (typeof n !== 'number') {
  16786. throw new Error('You can only set the limit to a numeric value');
  16787. }
  16788. this._limit = n;
  16789. return this;
  16790. }
  16791. /**
  16792. * Sets the flag to include with response the total number of objects satisfying this query,
  16793. * despite limits/skip. Might be useful for pagination.
  16794. * Note that result of this query will be wrapped as an object with
  16795. * `results`: holding {ParseObject} array and `count`: integer holding total number
  16796. *
  16797. * @param {boolean} includeCount false - disable, true - enable.
  16798. * @returns {Parse.Query} Returns the query, so you can chain this call.
  16799. */
  16800. }, {
  16801. key: "withCount",
  16802. value: function withCount()
  16803. /*: ParseQuery*/
  16804. {
  16805. var includeCount
  16806. /*: boolean*/
  16807. = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : true;
  16808. if (typeof includeCount !== 'boolean') {
  16809. throw new Error('You can only set withCount to a boolean value');
  16810. }
  16811. this._count = includeCount;
  16812. return this;
  16813. }
  16814. /**
  16815. * Includes nested Parse.Objects for the provided key. You can use dot
  16816. * notation to specify which fields in the included object are also fetched.
  16817. *
  16818. * You can include all nested Parse.Objects by passing in '*'.
  16819. * Requires Parse Server 3.0.0+
  16820. * <pre>query.include('*');</pre>
  16821. *
  16822. * @param {...string|Array<string>} keys The name(s) of the key(s) to include.
  16823. * @returns {Parse.Query} Returns the query, so you can chain this call.
  16824. */
  16825. }, {
  16826. key: "include",
  16827. value: function include()
  16828. /*: ParseQuery*/
  16829. {
  16830. var _this11 = this;
  16831. for (var _len5 = arguments.length, keys = new Array(_len5), _key9 = 0; _key9 < _len5; _key9++) {
  16832. keys[_key9] = arguments[_key9];
  16833. }
  16834. (0, _forEach.default)(keys).call(keys, function (key) {
  16835. if ((0, _isArray.default)(key)) {
  16836. var _context19;
  16837. _this11._include = (0, _concat.default)(_context19 = _this11._include).call(_context19, key);
  16838. } else {
  16839. _this11._include.push(key);
  16840. }
  16841. });
  16842. return this;
  16843. }
  16844. /**
  16845. * Includes all nested Parse.Objects one level deep.
  16846. *
  16847. * Requires Parse Server 3.0.0+
  16848. *
  16849. * @returns {Parse.Query} Returns the query, so you can chain this call.
  16850. */
  16851. }, {
  16852. key: "includeAll",
  16853. value: function includeAll()
  16854. /*: ParseQuery*/
  16855. {
  16856. return this.include('*');
  16857. }
  16858. /**
  16859. * Restricts the fields of the returned Parse.Objects to include only the
  16860. * provided keys. If this is called multiple times, then all of the keys
  16861. * specified in each of the calls will be included.
  16862. *
  16863. * @param {...string|Array<string>} keys The name(s) of the key(s) to include.
  16864. * @returns {Parse.Query} Returns the query, so you can chain this call.
  16865. */
  16866. }, {
  16867. key: "select",
  16868. value: function select()
  16869. /*: ParseQuery*/
  16870. {
  16871. var _this12 = this;
  16872. if (!this._select) {
  16873. this._select = [];
  16874. }
  16875. for (var _len6 = arguments.length, keys = new Array(_len6), _key10 = 0; _key10 < _len6; _key10++) {
  16876. keys[_key10] = arguments[_key10];
  16877. }
  16878. (0, _forEach.default)(keys).call(keys, function (key) {
  16879. if ((0, _isArray.default)(key)) {
  16880. var _context20;
  16881. _this12._select = (0, _concat.default)(_context20 = _this12._select).call(_context20, key);
  16882. } else {
  16883. _this12._select.push(key);
  16884. }
  16885. });
  16886. return this;
  16887. }
  16888. /**
  16889. * Restricts the fields of the returned Parse.Objects to all keys except the
  16890. * provided keys. Exclude takes precedence over select and include.
  16891. *
  16892. * Requires Parse Server 3.6.0+
  16893. *
  16894. * @param {...string|Array<string>} keys The name(s) of the key(s) to exclude.
  16895. * @returns {Parse.Query} Returns the query, so you can chain this call.
  16896. */
  16897. }, {
  16898. key: "exclude",
  16899. value: function exclude()
  16900. /*: ParseQuery*/
  16901. {
  16902. var _this13 = this;
  16903. for (var _len7 = arguments.length, keys = new Array(_len7), _key11 = 0; _key11 < _len7; _key11++) {
  16904. keys[_key11] = arguments[_key11];
  16905. }
  16906. (0, _forEach.default)(keys).call(keys, function (key) {
  16907. if ((0, _isArray.default)(key)) {
  16908. var _context21;
  16909. _this13._exclude = (0, _concat.default)(_context21 = _this13._exclude).call(_context21, key);
  16910. } else {
  16911. _this13._exclude.push(key);
  16912. }
  16913. });
  16914. return this;
  16915. }
  16916. /**
  16917. * Changes the read preference that the backend will use when performing the query to the database.
  16918. *
  16919. * @param {string} readPreference The read preference for the main query.
  16920. * @param {string} includeReadPreference The read preference for the queries to include pointers.
  16921. * @param {string} subqueryReadPreference The read preference for the sub queries.
  16922. * @returns {Parse.Query} Returns the query, so you can chain this call.
  16923. */
  16924. }, {
  16925. key: "readPreference",
  16926. value: function readPreference(_readPreference
  16927. /*: string*/
  16928. , includeReadPreference
  16929. /*:: ?: string*/
  16930. , subqueryReadPreference
  16931. /*:: ?: string*/
  16932. )
  16933. /*: ParseQuery*/
  16934. {
  16935. this._readPreference = _readPreference;
  16936. this._includeReadPreference = includeReadPreference;
  16937. this._subqueryReadPreference = subqueryReadPreference;
  16938. return this;
  16939. }
  16940. /**
  16941. * Subscribe this query to get liveQuery updates
  16942. *
  16943. * @param {string} sessionToken (optional) Defaults to the currentUser
  16944. * @returns {Promise<LiveQuerySubscription>} Returns the liveQuerySubscription, it's an event emitter
  16945. * which can be used to get liveQuery updates.
  16946. */
  16947. }, {
  16948. key: "subscribe",
  16949. value: function () {
  16950. var _subscribe = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regeneratorRuntime().mark(function _callee7(sessionToken
  16951. /*:: ?: string*/
  16952. ) {
  16953. var currentUser, liveQueryClient, subscription;
  16954. return _regeneratorRuntime().wrap(function _callee7$(_context22) {
  16955. while (1) {
  16956. switch (_context22.prev = _context22.next) {
  16957. case 0:
  16958. _context22.next = 2;
  16959. return _CoreManager.default.getUserController().currentUserAsync();
  16960. case 2:
  16961. currentUser = _context22.sent;
  16962. if (!sessionToken) {
  16963. sessionToken = currentUser ? currentUser.getSessionToken() : undefined;
  16964. }
  16965. _context22.next = 6;
  16966. return _CoreManager.default.getLiveQueryController().getDefaultLiveQueryClient();
  16967. case 6:
  16968. liveQueryClient = _context22.sent;
  16969. if (liveQueryClient.shouldOpen()) {
  16970. liveQueryClient.open();
  16971. }
  16972. subscription = liveQueryClient.subscribe(this, sessionToken);
  16973. return _context22.abrupt("return", subscription.subscribePromise.then(function () {
  16974. return subscription;
  16975. }));
  16976. case 10:
  16977. case "end":
  16978. return _context22.stop();
  16979. }
  16980. }
  16981. }, _callee7, this);
  16982. }));
  16983. function subscribe(_x10) {
  16984. return _subscribe.apply(this, arguments);
  16985. }
  16986. return subscribe;
  16987. }()
  16988. /**
  16989. * Constructs a Parse.Query that is the OR of the passed in queries. For
  16990. * example:
  16991. * <pre>var compoundQuery = Parse.Query.or(query1, query2, query3);</pre>
  16992. *
  16993. * will create a compoundQuery that is an or of the query1, query2, and
  16994. * query3.
  16995. *
  16996. * @param {...Parse.Query} queries The list of queries to OR.
  16997. * @static
  16998. * @returns {Parse.Query} The query that is the OR of the passed in queries.
  16999. */
  17000. }, {
  17001. key: "fromNetwork",
  17002. value:
  17003. /**
  17004. * Change the source of this query to the server.
  17005. *
  17006. * @returns {Parse.Query} Returns the query, so you can chain this call.
  17007. */
  17008. function fromNetwork()
  17009. /*: ParseQuery*/
  17010. {
  17011. this._queriesLocalDatastore = false;
  17012. this._localDatastorePinName = null;
  17013. return this;
  17014. }
  17015. /**
  17016. * Changes the source of this query to all pinned objects.
  17017. *
  17018. * @returns {Parse.Query} Returns the query, so you can chain this call.
  17019. */
  17020. }, {
  17021. key: "fromLocalDatastore",
  17022. value: function fromLocalDatastore()
  17023. /*: ParseQuery*/
  17024. {
  17025. return this.fromPinWithName(null);
  17026. }
  17027. /**
  17028. * Changes the source of this query to the default group of pinned objects.
  17029. *
  17030. * @returns {Parse.Query} Returns the query, so you can chain this call.
  17031. */
  17032. }, {
  17033. key: "fromPin",
  17034. value: function fromPin()
  17035. /*: ParseQuery*/
  17036. {
  17037. return this.fromPinWithName(_LocalDatastoreUtils.DEFAULT_PIN);
  17038. }
  17039. /**
  17040. * Changes the source of this query to a specific group of pinned objects.
  17041. *
  17042. * @param {string} name The name of query source.
  17043. * @returns {Parse.Query} Returns the query, so you can chain this call.
  17044. */
  17045. }, {
  17046. key: "fromPinWithName",
  17047. value: function fromPinWithName(name
  17048. /*:: ?: string*/
  17049. )
  17050. /*: ParseQuery*/
  17051. {
  17052. var localDatastore = _CoreManager.default.getLocalDatastore();
  17053. if (localDatastore.checkIfEnabled()) {
  17054. this._queriesLocalDatastore = true;
  17055. this._localDatastorePinName = name;
  17056. }
  17057. return this;
  17058. }
  17059. /**
  17060. * Cancels the current network request (if any is running).
  17061. *
  17062. * @returns {Parse.Query} Returns the query, so you can chain this call.
  17063. */
  17064. }, {
  17065. key: "cancel",
  17066. value: function cancel()
  17067. /*: ParseQuery*/
  17068. {
  17069. var _this14 = this;
  17070. if (this._xhrRequest.task && typeof this._xhrRequest.task.abort === 'function') {
  17071. this._xhrRequest.task._aborted = true;
  17072. this._xhrRequest.task.abort();
  17073. this._xhrRequest.task = null;
  17074. this._xhrRequest.onchange = function () {};
  17075. return this;
  17076. }
  17077. return this._xhrRequest.onchange = function () {
  17078. return _this14.cancel();
  17079. };
  17080. }
  17081. }, {
  17082. key: "_setRequestTask",
  17083. value: function _setRequestTask(options) {
  17084. var _this15 = this;
  17085. options.requestTask = function (task) {
  17086. _this15._xhrRequest.task = task;
  17087. _this15._xhrRequest.onchange();
  17088. };
  17089. }
  17090. }], [{
  17091. key: "fromJSON",
  17092. value: function fromJSON(className
  17093. /*: string*/
  17094. , json
  17095. /*: QueryJSON*/
  17096. )
  17097. /*: ParseQuery*/
  17098. {
  17099. var query = new ParseQuery(className);
  17100. return query.withJSON(json);
  17101. }
  17102. }, {
  17103. key: "or",
  17104. value: function or()
  17105. /*: ParseQuery*/
  17106. {
  17107. for (var _len8 = arguments.length, queries = new Array(_len8), _key12 = 0; _key12 < _len8; _key12++) {
  17108. queries[_key12] = arguments[_key12];
  17109. }
  17110. var className = _getClassNameFromQueries(queries);
  17111. var query = new ParseQuery(className);
  17112. query._orQuery(queries);
  17113. return query;
  17114. }
  17115. /**
  17116. * Constructs a Parse.Query that is the AND of the passed in queries. For
  17117. * example:
  17118. * <pre>var compoundQuery = Parse.Query.and(query1, query2, query3);</pre>
  17119. *
  17120. * will create a compoundQuery that is an and of the query1, query2, and
  17121. * query3.
  17122. *
  17123. * @param {...Parse.Query} queries The list of queries to AND.
  17124. * @static
  17125. * @returns {Parse.Query} The query that is the AND of the passed in queries.
  17126. */
  17127. }, {
  17128. key: "and",
  17129. value: function and()
  17130. /*: ParseQuery*/
  17131. {
  17132. for (var _len9 = arguments.length, queries = new Array(_len9), _key13 = 0; _key13 < _len9; _key13++) {
  17133. queries[_key13] = arguments[_key13];
  17134. }
  17135. var className = _getClassNameFromQueries(queries);
  17136. var query = new ParseQuery(className);
  17137. query._andQuery(queries);
  17138. return query;
  17139. }
  17140. /**
  17141. * Constructs a Parse.Query that is the NOR of the passed in queries. For
  17142. * example:
  17143. * <pre>const compoundQuery = Parse.Query.nor(query1, query2, query3);</pre>
  17144. *
  17145. * will create a compoundQuery that is a nor of the query1, query2, and
  17146. * query3.
  17147. *
  17148. * @param {...Parse.Query} queries The list of queries to NOR.
  17149. * @static
  17150. * @returns {Parse.Query} The query that is the NOR of the passed in queries.
  17151. */
  17152. }, {
  17153. key: "nor",
  17154. value: function nor()
  17155. /*: ParseQuery*/
  17156. {
  17157. for (var _len10 = arguments.length, queries = new Array(_len10), _key14 = 0; _key14 < _len10; _key14++) {
  17158. queries[_key14] = arguments[_key14];
  17159. }
  17160. var className = _getClassNameFromQueries(queries);
  17161. var query = new ParseQuery(className);
  17162. query._norQuery(queries);
  17163. return query;
  17164. }
  17165. }]);
  17166. return ParseQuery;
  17167. }();
  17168. var DefaultController = {
  17169. find: function find(className
  17170. /*: string*/
  17171. , params
  17172. /*: QueryJSON*/
  17173. , options
  17174. /*: RequestOptions*/
  17175. )
  17176. /*: Promise<Array<ParseObject>>*/
  17177. {
  17178. var RESTController = _CoreManager.default.getRESTController();
  17179. return RESTController.request('GET', 'classes/' + className, params, options);
  17180. },
  17181. aggregate: function aggregate(className
  17182. /*: string*/
  17183. , params
  17184. /*: any*/
  17185. , options
  17186. /*: RequestOptions*/
  17187. )
  17188. /*: Promise<Array<mixed>>*/
  17189. {
  17190. var RESTController = _CoreManager.default.getRESTController();
  17191. return RESTController.request('GET', 'aggregate/' + className, params, options);
  17192. }
  17193. };
  17194. _CoreManager.default.setQueryController(DefaultController);
  17195. var _default = ParseQuery;
  17196. exports.default = _default;
  17197. },{"./CoreManager":4,"./LocalDatastoreUtils":15,"./OfflineQuery":17,"./ParseError":22,"./ParseGeoPoint":24,"./ParseObject":27,"./encode":46,"./promiseUtils":51,"@babel/runtime-corejs3/core-js-stable/array/is-array":56,"@babel/runtime-corejs3/core-js-stable/instance/concat":58,"@babel/runtime-corejs3/core-js-stable/instance/filter":61,"@babel/runtime-corejs3/core-js-stable/instance/find":63,"@babel/runtime-corejs3/core-js-stable/instance/for-each":64,"@babel/runtime-corejs3/core-js-stable/instance/includes":65,"@babel/runtime-corejs3/core-js-stable/instance/index-of":66,"@babel/runtime-corejs3/core-js-stable/instance/keys":67,"@babel/runtime-corejs3/core-js-stable/instance/map":68,"@babel/runtime-corejs3/core-js-stable/instance/reverse":70,"@babel/runtime-corejs3/core-js-stable/instance/slice":71,"@babel/runtime-corejs3/core-js-stable/instance/sort":72,"@babel/runtime-corejs3/core-js-stable/instance/splice":73,"@babel/runtime-corejs3/core-js-stable/object/create":80,"@babel/runtime-corejs3/core-js-stable/object/define-property":82,"@babel/runtime-corejs3/core-js-stable/object/entries":83,"@babel/runtime-corejs3/core-js-stable/object/get-prototype-of":88,"@babel/runtime-corejs3/core-js-stable/object/keys":89,"@babel/runtime-corejs3/core-js-stable/object/set-prototype-of":90,"@babel/runtime-corejs3/core-js-stable/promise":92,"@babel/runtime-corejs3/core-js-stable/symbol":97,"@babel/runtime-corejs3/helpers/asyncToGenerator":120,"@babel/runtime-corejs3/helpers/classCallCheck":121,"@babel/runtime-corejs3/helpers/createClass":123,"@babel/runtime-corejs3/helpers/defineProperty":124,"@babel/runtime-corejs3/helpers/interopRequireDefault":128,"@babel/runtime-corejs3/helpers/slicedToArray":137,"@babel/runtime-corejs3/helpers/toConsumableArray":139,"@babel/runtime-corejs3/helpers/typeof":140}],31:[function(_dereq_,module,exports){
  17198. "use strict";
  17199. var _interopRequireDefault = _dereq_("@babel/runtime-corejs3/helpers/interopRequireDefault");
  17200. var _Object$defineProperty = _dereq_("@babel/runtime-corejs3/core-js-stable/object/define-property");
  17201. _Object$defineProperty(exports, "__esModule", {
  17202. value: true
  17203. });
  17204. exports.default = void 0;
  17205. var _isArray = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/array/is-array"));
  17206. var _classCallCheck2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/helpers/classCallCheck"));
  17207. var _createClass2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/helpers/createClass"));
  17208. var _defineProperty2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/helpers/defineProperty"));
  17209. var _ParseOp = _dereq_("./ParseOp");
  17210. var _ParseObject = _interopRequireDefault(_dereq_("./ParseObject"));
  17211. var _ParseQuery = _interopRequireDefault(_dereq_("./ParseQuery"));
  17212. /**
  17213. * Copyright (c) 2015-present, Parse, LLC.
  17214. * All rights reserved.
  17215. *
  17216. * This source code is licensed under the BSD-style license found in the
  17217. * LICENSE file in the root directory of this source tree. An additional grant
  17218. * of patent rights can be found in the PATENTS file in the same directory.
  17219. *
  17220. * @flow
  17221. */
  17222. /**
  17223. * Creates a new Relation for the given parent object and key. This
  17224. * constructor should rarely be used directly, but rather created by
  17225. * Parse.Object.relation.
  17226. *
  17227. * <p>
  17228. * A class that is used to access all of the children of a many-to-many
  17229. * relationship. Each instance of Parse.Relation is associated with a
  17230. * particular parent object and key.
  17231. * </p>
  17232. *
  17233. * @alias Parse.Relation
  17234. */
  17235. var ParseRelation = /*#__PURE__*/function () {
  17236. /**
  17237. * @param {Parse.Object} parent The parent of this relation.
  17238. * @param {string} key The key for this relation on the parent.
  17239. */
  17240. function ParseRelation(parent
  17241. /*: ?ParseObject*/
  17242. , key
  17243. /*: ?string*/
  17244. ) {
  17245. (0, _classCallCheck2.default)(this, ParseRelation);
  17246. (0, _defineProperty2.default)(this, "parent", void 0);
  17247. (0, _defineProperty2.default)(this, "key", void 0);
  17248. (0, _defineProperty2.default)(this, "targetClassName", void 0);
  17249. this.parent = parent;
  17250. this.key = key;
  17251. this.targetClassName = null;
  17252. }
  17253. /*
  17254. * Makes sure that this relation has the right parent and key.
  17255. */
  17256. (0, _createClass2.default)(ParseRelation, [{
  17257. key: "_ensureParentAndKey",
  17258. value: function (parent
  17259. /*: ParseObject*/
  17260. , key
  17261. /*: string*/
  17262. ) {
  17263. this.key = this.key || key;
  17264. if (this.key !== key) {
  17265. throw new Error('Internal Error. Relation retrieved from two different keys.');
  17266. }
  17267. if (this.parent) {
  17268. if (this.parent.className !== parent.className) {
  17269. throw new Error('Internal Error. Relation retrieved from two different Objects.');
  17270. }
  17271. if (this.parent.id) {
  17272. if (this.parent.id !== parent.id) {
  17273. throw new Error('Internal Error. Relation retrieved from two different Objects.');
  17274. }
  17275. } else if (parent.id) {
  17276. this.parent = parent;
  17277. }
  17278. } else {
  17279. this.parent = parent;
  17280. }
  17281. }
  17282. /**
  17283. * Adds a Parse.Object or an array of Parse.Objects to the relation.
  17284. *
  17285. * @param {(Parse.Object|Array)} objects The item or items to add.
  17286. * @returns {Parse.Object} The parent of the relation.
  17287. */
  17288. }, {
  17289. key: "add",
  17290. value: function (objects
  17291. /*: ParseObject | Array<ParseObject | string>*/
  17292. )
  17293. /*: ParseObject*/
  17294. {
  17295. if (!(0, _isArray.default)(objects)) {
  17296. objects = [objects];
  17297. }
  17298. var change = new _ParseOp.RelationOp(objects, []);
  17299. var parent = this.parent;
  17300. if (!parent) {
  17301. throw new Error('Cannot add to a Relation without a parent');
  17302. }
  17303. if (objects.length === 0) {
  17304. return parent;
  17305. }
  17306. parent.set(this.key, change);
  17307. this.targetClassName = change._targetClassName;
  17308. return parent;
  17309. }
  17310. /**
  17311. * Removes a Parse.Object or an array of Parse.Objects from this relation.
  17312. *
  17313. * @param {(Parse.Object|Array)} objects The item or items to remove.
  17314. */
  17315. }, {
  17316. key: "remove",
  17317. value: function (objects
  17318. /*: ParseObject | Array<ParseObject | string>*/
  17319. ) {
  17320. if (!(0, _isArray.default)(objects)) {
  17321. objects = [objects];
  17322. }
  17323. var change = new _ParseOp.RelationOp([], objects);
  17324. if (!this.parent) {
  17325. throw new Error('Cannot remove from a Relation without a parent');
  17326. }
  17327. if (objects.length === 0) {
  17328. return;
  17329. }
  17330. this.parent.set(this.key, change);
  17331. this.targetClassName = change._targetClassName;
  17332. }
  17333. /**
  17334. * Returns a JSON version of the object suitable for saving to disk.
  17335. *
  17336. * @returns {object} JSON representation of Relation
  17337. */
  17338. }, {
  17339. key: "toJSON",
  17340. value: function ()
  17341. /*: { __type: 'Relation', className: ?string }*/
  17342. {
  17343. return {
  17344. __type: 'Relation',
  17345. className: this.targetClassName
  17346. };
  17347. }
  17348. /**
  17349. * Returns a Parse.Query that is limited to objects in this
  17350. * relation.
  17351. *
  17352. * @returns {Parse.Query} Relation Query
  17353. */
  17354. }, {
  17355. key: "query",
  17356. value: function query()
  17357. /*: ParseQuery*/
  17358. {
  17359. var query;
  17360. var parent = this.parent;
  17361. if (!parent) {
  17362. throw new Error('Cannot construct a query for a Relation without a parent');
  17363. }
  17364. if (!this.targetClassName) {
  17365. query = new _ParseQuery.default(parent.className);
  17366. query._extraOptions.redirectClassNameForKey = this.key;
  17367. } else {
  17368. query = new _ParseQuery.default(this.targetClassName);
  17369. }
  17370. query._addCondition('$relatedTo', 'object', {
  17371. __type: 'Pointer',
  17372. className: parent.className,
  17373. objectId: parent.id
  17374. });
  17375. query._addCondition('$relatedTo', 'key', this.key);
  17376. return query;
  17377. }
  17378. }]);
  17379. return ParseRelation;
  17380. }();
  17381. var _default = ParseRelation;
  17382. exports.default = _default;
  17383. },{"./ParseObject":27,"./ParseOp":28,"./ParseQuery":30,"@babel/runtime-corejs3/core-js-stable/array/is-array":56,"@babel/runtime-corejs3/core-js-stable/object/define-property":82,"@babel/runtime-corejs3/helpers/classCallCheck":121,"@babel/runtime-corejs3/helpers/createClass":123,"@babel/runtime-corejs3/helpers/defineProperty":124,"@babel/runtime-corejs3/helpers/interopRequireDefault":128}],32:[function(_dereq_,module,exports){
  17384. "use strict";
  17385. var _interopRequireDefault = _dereq_("@babel/runtime-corejs3/helpers/interopRequireDefault");
  17386. var _Object$defineProperty = _dereq_("@babel/runtime-corejs3/core-js-stable/object/define-property");
  17387. var _Reflect$construct = _dereq_("@babel/runtime-corejs3/core-js-stable/reflect/construct");
  17388. _Object$defineProperty(exports, "__esModule", {
  17389. value: true
  17390. });
  17391. exports.default = void 0;
  17392. var _classCallCheck2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/helpers/classCallCheck"));
  17393. var _createClass2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/helpers/createClass"));
  17394. var _get2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/helpers/get"));
  17395. var _inherits2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/helpers/inherits"));
  17396. var _possibleConstructorReturn2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/helpers/possibleConstructorReturn"));
  17397. var _getPrototypeOf2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/helpers/getPrototypeOf"));
  17398. var _ParseACL = _interopRequireDefault(_dereq_("./ParseACL"));
  17399. var _ParseError = _interopRequireDefault(_dereq_("./ParseError"));
  17400. var _ParseObject2 = _interopRequireDefault(_dereq_("./ParseObject"));
  17401. function _createSuper(Derived) {
  17402. var hasNativeReflectConstruct = _isNativeReflectConstruct();
  17403. return function () {
  17404. var Super = (0, _getPrototypeOf2.default)(Derived),
  17405. result;
  17406. if (hasNativeReflectConstruct) {
  17407. var NewTarget = (0, _getPrototypeOf2.default)(this).constructor;
  17408. result = _Reflect$construct(Super, arguments, NewTarget);
  17409. } else {
  17410. result = Super.apply(this, arguments);
  17411. }
  17412. return (0, _possibleConstructorReturn2.default)(this, result);
  17413. };
  17414. }
  17415. function _isNativeReflectConstruct() {
  17416. if (typeof Reflect === "undefined" || !_Reflect$construct) return false;
  17417. if (_Reflect$construct.sham) return false;
  17418. if (typeof Proxy === "function") return true;
  17419. try {
  17420. Boolean.prototype.valueOf.call(_Reflect$construct(Boolean, [], function () {}));
  17421. return true;
  17422. } catch (e) {
  17423. return false;
  17424. }
  17425. }
  17426. /**
  17427. * Represents a Role on the Parse server. Roles represent groupings of
  17428. * Users for the purposes of granting permissions (e.g. specifying an ACL
  17429. * for an Object). Roles are specified by their sets of child users and
  17430. * child roles, all of which are granted any permissions that the parent
  17431. * role has.
  17432. *
  17433. * <p>Roles must have a name (which cannot be changed after creation of the
  17434. * role), and must specify an ACL.</p>
  17435. *
  17436. * @alias Parse.Role
  17437. * @augments Parse.Object
  17438. */
  17439. var ParseRole = /*#__PURE__*/function (_ParseObject) {
  17440. (0, _inherits2.default)(ParseRole, _ParseObject);
  17441. var _super = _createSuper(ParseRole);
  17442. /**
  17443. * @param {string} name The name of the Role to create.
  17444. * @param {Parse.ACL} acl The ACL for this role. Roles must have an ACL.
  17445. * A Parse.Role is a local representation of a role persisted to the Parse
  17446. * cloud.
  17447. */
  17448. function ParseRole(name
  17449. /*: string*/
  17450. , acl
  17451. /*: ParseACL*/
  17452. ) {
  17453. var _this;
  17454. (0, _classCallCheck2.default)(this, ParseRole);
  17455. _this = _super.call(this, '_Role');
  17456. if (typeof name === 'string' && acl instanceof _ParseACL.default) {
  17457. _this.setName(name);
  17458. _this.setACL(acl);
  17459. }
  17460. return _this;
  17461. }
  17462. /**
  17463. * Gets the name of the role. You can alternatively call role.get("name")
  17464. *
  17465. * @returns {string} the name of the role.
  17466. */
  17467. (0, _createClass2.default)(ParseRole, [{
  17468. key: "getName",
  17469. value: function ()
  17470. /*: ?string*/
  17471. {
  17472. var name = this.get('name');
  17473. if (name == null || typeof name === 'string') {
  17474. return name;
  17475. }
  17476. return '';
  17477. }
  17478. /**
  17479. * Sets the name for a role. This value must be set before the role has
  17480. * been saved to the server, and cannot be set once the role has been
  17481. * saved.
  17482. *
  17483. * <p>
  17484. * A role's name can only contain alphanumeric characters, _, -, and
  17485. * spaces.
  17486. * </p>
  17487. *
  17488. * <p>This is equivalent to calling role.set("name", name)</p>
  17489. *
  17490. * @param {string} name The name of the role.
  17491. * @param {object} options Standard options object with success and error
  17492. * callbacks.
  17493. * @returns {(ParseObject|boolean)} true if the set succeeded.
  17494. */
  17495. }, {
  17496. key: "setName",
  17497. value: function (name
  17498. /*: string*/
  17499. , options
  17500. /*:: ?: mixed*/
  17501. )
  17502. /*: ParseObject | boolean*/
  17503. {
  17504. this._validateName(name);
  17505. return this.set('name', name, options);
  17506. }
  17507. /**
  17508. * Gets the Parse.Relation for the Parse.Users that are direct
  17509. * children of this role. These users are granted any privileges that this
  17510. * role has been granted (e.g. read or write access through ACLs). You can
  17511. * add or remove users from the role through this relation.
  17512. *
  17513. * <p>This is equivalent to calling role.relation("users")</p>
  17514. *
  17515. * @returns {Parse.Relation} the relation for the users belonging to this
  17516. * role.
  17517. */
  17518. }, {
  17519. key: "getUsers",
  17520. value: function ()
  17521. /*: ParseRelation*/
  17522. {
  17523. return this.relation('users');
  17524. }
  17525. /**
  17526. * Gets the Parse.Relation for the Parse.Roles that are direct
  17527. * children of this role. These roles' users are granted any privileges that
  17528. * this role has been granted (e.g. read or write access through ACLs). You
  17529. * can add or remove child roles from this role through this relation.
  17530. *
  17531. * <p>This is equivalent to calling role.relation("roles")</p>
  17532. *
  17533. * @returns {Parse.Relation} the relation for the roles belonging to this
  17534. * role.
  17535. */
  17536. }, {
  17537. key: "getRoles",
  17538. value: function ()
  17539. /*: ParseRelation*/
  17540. {
  17541. return this.relation('roles');
  17542. }
  17543. }, {
  17544. key: "_validateName",
  17545. value: function (newName) {
  17546. if (typeof newName !== 'string') {
  17547. throw new _ParseError.default(_ParseError.default.OTHER_CAUSE, "A role's name must be a String.");
  17548. }
  17549. if (!/^[0-9a-zA-Z\-_ ]+$/.test(newName)) {
  17550. throw new _ParseError.default(_ParseError.default.OTHER_CAUSE, "A role's name can be only contain alphanumeric characters, _, " + '-, and spaces.');
  17551. }
  17552. }
  17553. }, {
  17554. key: "validate",
  17555. value: function (attrs
  17556. /*: AttributeMap*/
  17557. , options
  17558. /*:: ?: mixed*/
  17559. )
  17560. /*: ParseError | boolean*/
  17561. {
  17562. var isInvalid = (0, _get2.default)((0, _getPrototypeOf2.default)(ParseRole.prototype), "validate", this).call(this, attrs, options);
  17563. if (isInvalid) {
  17564. return isInvalid;
  17565. }
  17566. if ('name' in attrs && attrs.name !== this.getName()) {
  17567. var newName = attrs.name;
  17568. if (this.id && this.id !== attrs.objectId) {
  17569. // Check to see if the objectId being set matches this.id
  17570. // This happens during a fetch -- the id is set before calling fetch
  17571. // Let the name be set in this case
  17572. return new _ParseError.default(_ParseError.default.OTHER_CAUSE, "A role's name can only be set before it has been saved.");
  17573. }
  17574. try {
  17575. this._validateName(newName);
  17576. } catch (e) {
  17577. return e;
  17578. }
  17579. }
  17580. return false;
  17581. }
  17582. }]);
  17583. return ParseRole;
  17584. }(_ParseObject2.default);
  17585. _ParseObject2.default.registerSubclass('_Role', ParseRole);
  17586. var _default = ParseRole;
  17587. exports.default = _default;
  17588. },{"./ParseACL":19,"./ParseError":22,"./ParseObject":27,"@babel/runtime-corejs3/core-js-stable/object/define-property":82,"@babel/runtime-corejs3/core-js-stable/reflect/construct":93,"@babel/runtime-corejs3/helpers/classCallCheck":121,"@babel/runtime-corejs3/helpers/createClass":123,"@babel/runtime-corejs3/helpers/get":125,"@babel/runtime-corejs3/helpers/getPrototypeOf":126,"@babel/runtime-corejs3/helpers/inherits":127,"@babel/runtime-corejs3/helpers/interopRequireDefault":128,"@babel/runtime-corejs3/helpers/possibleConstructorReturn":135}],33:[function(_dereq_,module,exports){
  17589. "use strict";
  17590. var _interopRequireDefault = _dereq_("@babel/runtime-corejs3/helpers/interopRequireDefault");
  17591. var _Object$defineProperty = _dereq_("@babel/runtime-corejs3/core-js-stable/object/define-property");
  17592. _Object$defineProperty(exports, "__esModule", {
  17593. value: true
  17594. });
  17595. exports.default = void 0;
  17596. var _indexOf = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/instance/index-of"));
  17597. var _classCallCheck2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/helpers/classCallCheck"));
  17598. var _createClass2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/helpers/createClass"));
  17599. var _defineProperty2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/helpers/defineProperty"));
  17600. var _CoreManager = _interopRequireDefault(_dereq_("./CoreManager"));
  17601. var _ParseObject = _interopRequireDefault(_dereq_("./ParseObject"));
  17602. var _ParseCLP = _interopRequireDefault(_dereq_("./ParseCLP"));
  17603. /**
  17604. * Copyright (c) 2015-present, Parse, LLC.
  17605. * All rights reserved.
  17606. *
  17607. * This source code is licensed under the BSD-style license found in the
  17608. * LICENSE file in the root directory of this source tree. An additional grant
  17609. * of patent rights can be found in the PATENTS file in the same directory.
  17610. *
  17611. * @flow
  17612. */
  17613. var FIELD_TYPES = ['String', 'Number', 'Boolean', 'Date', 'File', 'GeoPoint', 'Polygon', 'Array', 'Object', 'Pointer', 'Relation'];
  17614. /*:: type FieldOptions = {
  17615. required: boolean,
  17616. defaultValue: mixed,
  17617. };*/
  17618. /**
  17619. * A Parse.Schema object is for handling schema data from Parse.
  17620. * <p>All the schemas methods require MasterKey.
  17621. *
  17622. * When adding fields, you may set required and default values. (Requires Parse Server 3.7.0+)
  17623. *
  17624. * <pre>
  17625. * const options = { required: true, defaultValue: 'hello world' };
  17626. * const schema = new Parse.Schema('MyClass');
  17627. * schema.addString('field', options);
  17628. * schema.addIndex('index_name', { 'field': 1 });
  17629. * schema.save();
  17630. * </pre>
  17631. * </p>
  17632. *
  17633. * @alias Parse.Schema
  17634. */
  17635. var ParseSchema = /*#__PURE__*/function () {
  17636. /**
  17637. * @param {string} className Parse Class string.
  17638. */
  17639. function ParseSchema(className
  17640. /*: string*/
  17641. ) {
  17642. (0, _classCallCheck2.default)(this, ParseSchema);
  17643. (0, _defineProperty2.default)(this, "className", void 0);
  17644. (0, _defineProperty2.default)(this, "_fields", void 0);
  17645. (0, _defineProperty2.default)(this, "_indexes", void 0);
  17646. (0, _defineProperty2.default)(this, "_clp", void 0);
  17647. if (typeof className === 'string') {
  17648. if (className === 'User' && _CoreManager.default.get('PERFORM_USER_REWRITE')) {
  17649. this.className = '_User';
  17650. } else {
  17651. this.className = className;
  17652. }
  17653. }
  17654. this._fields = {};
  17655. this._indexes = {};
  17656. }
  17657. /**
  17658. * Static method to get all schemas
  17659. *
  17660. * @returns {Promise} A promise that is resolved with the result when
  17661. * the query completes.
  17662. */
  17663. (0, _createClass2.default)(ParseSchema, [{
  17664. key: "get",
  17665. value:
  17666. /**
  17667. * Get the Schema from Parse
  17668. *
  17669. * @returns {Promise} A promise that is resolved with the result when
  17670. * the query completes.
  17671. */
  17672. function () {
  17673. this.assertClassName();
  17674. var controller = _CoreManager.default.getSchemaController();
  17675. return controller.get(this.className).then(function (response) {
  17676. if (!response) {
  17677. throw new Error('Schema not found.');
  17678. }
  17679. return response;
  17680. });
  17681. }
  17682. /**
  17683. * Create a new Schema on Parse
  17684. *
  17685. * @returns {Promise} A promise that is resolved with the result when
  17686. * the query completes.
  17687. */
  17688. }, {
  17689. key: "save",
  17690. value: function () {
  17691. this.assertClassName();
  17692. var controller = _CoreManager.default.getSchemaController();
  17693. var params = {
  17694. className: this.className,
  17695. fields: this._fields,
  17696. indexes: this._indexes,
  17697. classLevelPermissions: this._clp
  17698. };
  17699. return controller.create(this.className, params);
  17700. }
  17701. /**
  17702. * Update a Schema on Parse
  17703. *
  17704. * @returns {Promise} A promise that is resolved with the result when
  17705. * the query completes.
  17706. */
  17707. }, {
  17708. key: "update",
  17709. value: function () {
  17710. this.assertClassName();
  17711. var controller = _CoreManager.default.getSchemaController();
  17712. var params = {
  17713. className: this.className,
  17714. fields: this._fields,
  17715. indexes: this._indexes,
  17716. classLevelPermissions: this._clp
  17717. };
  17718. this._fields = {};
  17719. this._indexes = {};
  17720. return controller.update(this.className, params);
  17721. }
  17722. /**
  17723. * Removing a Schema from Parse
  17724. * Can only be used on Schema without objects
  17725. *
  17726. * @returns {Promise} A promise that is resolved with the result when
  17727. * the query completes.
  17728. */
  17729. }, {
  17730. key: "delete",
  17731. value: function () {
  17732. this.assertClassName();
  17733. var controller = _CoreManager.default.getSchemaController();
  17734. return controller.delete(this.className);
  17735. }
  17736. /**
  17737. * Removes all objects from a Schema (class) in Parse.
  17738. * EXERCISE CAUTION, running this will delete all objects for this schema and cannot be reversed
  17739. *
  17740. * @returns {Promise} A promise that is resolved with the result when
  17741. * the query completes.
  17742. */
  17743. }, {
  17744. key: "purge",
  17745. value: function () {
  17746. this.assertClassName();
  17747. var controller = _CoreManager.default.getSchemaController();
  17748. return controller.purge(this.className);
  17749. }
  17750. /**
  17751. * Assert if ClassName has been filled
  17752. *
  17753. * @private
  17754. */
  17755. }, {
  17756. key: "assertClassName",
  17757. value: function () {
  17758. if (!this.className) {
  17759. throw new Error('You must set a Class Name before making any request.');
  17760. }
  17761. }
  17762. /**
  17763. * Sets Class Level Permissions when creating / updating a Schema.
  17764. * EXERCISE CAUTION, running this may override CLP for this schema and cannot be reversed
  17765. *
  17766. * @param {object | Parse.CLP} clp Class Level Permissions
  17767. * @returns {Parse.Schema} Returns the schema, so you can chain this call.
  17768. */
  17769. }, {
  17770. key: "setCLP",
  17771. value: function (clp
  17772. /*: PermissionsMap | ParseCLP*/
  17773. ) {
  17774. if (clp instanceof _ParseCLP.default) {
  17775. this._clp = clp.toJSON();
  17776. } else {
  17777. this._clp = clp;
  17778. }
  17779. return this;
  17780. }
  17781. /**
  17782. * Adding a Field to Create / Update a Schema
  17783. *
  17784. * @param {string} name Name of the field that will be created on Parse
  17785. * @param {string} type Can be a (String|Number|Boolean|Date|Parse.File|Parse.GeoPoint|Array|Object|Pointer|Parse.Relation)
  17786. * @param {object} options
  17787. * Valid options are:<ul>
  17788. * <li>required: If field is not set, save operation fails (Requires Parse Server 3.7.0+)
  17789. * <li>defaultValue: If field is not set, a default value is selected (Requires Parse Server 3.7.0+)
  17790. * <li>targetClass: Required if type is Pointer or Parse.Relation
  17791. * </ul>
  17792. * @returns {Parse.Schema} Returns the schema, so you can chain this call.
  17793. */
  17794. }, {
  17795. key: "addField",
  17796. value: function (name
  17797. /*: string*/
  17798. , type
  17799. /*: string*/
  17800. ) {
  17801. var options
  17802. /*: FieldOptions*/
  17803. = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
  17804. type = type || 'String';
  17805. if (!name) {
  17806. throw new Error('field name may not be null.');
  17807. }
  17808. if ((0, _indexOf.default)(FIELD_TYPES).call(FIELD_TYPES, type) === -1) {
  17809. throw new Error("".concat(type, " is not a valid type."));
  17810. }
  17811. if (type === 'Pointer') {
  17812. return this.addPointer(name, options.targetClass, options);
  17813. }
  17814. if (type === 'Relation') {
  17815. return this.addRelation(name, options.targetClass, options);
  17816. }
  17817. var fieldOptions = {
  17818. type: type
  17819. };
  17820. if (typeof options.required === 'boolean') {
  17821. fieldOptions.required = options.required;
  17822. }
  17823. if (options.defaultValue !== undefined) {
  17824. fieldOptions.defaultValue = options.defaultValue;
  17825. }
  17826. if (type === 'Date') {
  17827. if (options && options.defaultValue) {
  17828. fieldOptions.defaultValue = {
  17829. __type: 'Date',
  17830. iso: new Date(options.defaultValue)
  17831. };
  17832. }
  17833. }
  17834. this._fields[name] = fieldOptions;
  17835. return this;
  17836. }
  17837. /**
  17838. * Adding an Index to Create / Update a Schema
  17839. *
  17840. * @param {string} name Name of the index
  17841. * @param {object} index { field: value }
  17842. * @returns {Parse.Schema} Returns the schema, so you can chain this call.
  17843. *
  17844. * <pre>
  17845. * schema.addIndex('index_name', { 'field': 1 });
  17846. * </pre>
  17847. */
  17848. }, {
  17849. key: "addIndex",
  17850. value: function (name
  17851. /*: string*/
  17852. , index
  17853. /*: any*/
  17854. ) {
  17855. if (!name) {
  17856. throw new Error('index name may not be null.');
  17857. }
  17858. if (!index) {
  17859. throw new Error('index may not be null.');
  17860. }
  17861. this._indexes[name] = index;
  17862. return this;
  17863. }
  17864. /**
  17865. * Adding String Field
  17866. *
  17867. * @param {string} name Name of the field that will be created on Parse
  17868. * @param {object} options See {@link https://parseplatform.org/Parse-SDK-JS/api/master/Parse.Schema.html#addField addField}
  17869. * @returns {Parse.Schema} Returns the schema, so you can chain this call.
  17870. */
  17871. }, {
  17872. key: "addString",
  17873. value: function (name
  17874. /*: string*/
  17875. , options
  17876. /*: FieldOptions*/
  17877. ) {
  17878. return this.addField(name, 'String', options);
  17879. }
  17880. /**
  17881. * Adding Number Field
  17882. *
  17883. * @param {string} name Name of the field that will be created on Parse
  17884. * @param {object} options See {@link https://parseplatform.org/Parse-SDK-JS/api/master/Parse.Schema.html#addField addField}
  17885. * @returns {Parse.Schema} Returns the schema, so you can chain this call.
  17886. */
  17887. }, {
  17888. key: "addNumber",
  17889. value: function (name
  17890. /*: string*/
  17891. , options
  17892. /*: FieldOptions*/
  17893. ) {
  17894. return this.addField(name, 'Number', options);
  17895. }
  17896. /**
  17897. * Adding Boolean Field
  17898. *
  17899. * @param {string} name Name of the field that will be created on Parse
  17900. * @param {object} options See {@link https://parseplatform.org/Parse-SDK-JS/api/master/Parse.Schema.html#addField addField}
  17901. * @returns {Parse.Schema} Returns the schema, so you can chain this call.
  17902. */
  17903. }, {
  17904. key: "addBoolean",
  17905. value: function (name
  17906. /*: string*/
  17907. , options
  17908. /*: FieldOptions*/
  17909. ) {
  17910. return this.addField(name, 'Boolean', options);
  17911. }
  17912. /**
  17913. * Adding Date Field
  17914. *
  17915. * @param {string} name Name of the field that will be created on Parse
  17916. * @param {object} options See {@link https://parseplatform.org/Parse-SDK-JS/api/master/Parse.Schema.html#addField addField}
  17917. * @returns {Parse.Schema} Returns the schema, so you can chain this call.
  17918. */
  17919. }, {
  17920. key: "addDate",
  17921. value: function (name
  17922. /*: string*/
  17923. , options
  17924. /*: FieldOptions*/
  17925. ) {
  17926. return this.addField(name, 'Date', options);
  17927. }
  17928. /**
  17929. * Adding File Field
  17930. *
  17931. * @param {string} name Name of the field that will be created on Parse
  17932. * @param {object} options See {@link https://parseplatform.org/Parse-SDK-JS/api/master/Parse.Schema.html#addField addField}
  17933. * @returns {Parse.Schema} Returns the schema, so you can chain this call.
  17934. */
  17935. }, {
  17936. key: "addFile",
  17937. value: function (name
  17938. /*: string*/
  17939. , options
  17940. /*: FieldOptions*/
  17941. ) {
  17942. return this.addField(name, 'File', options);
  17943. }
  17944. /**
  17945. * Adding GeoPoint Field
  17946. *
  17947. * @param {string} name Name of the field that will be created on Parse
  17948. * @param {object} options See {@link https://parseplatform.org/Parse-SDK-JS/api/master/Parse.Schema.html#addField addField}
  17949. * @returns {Parse.Schema} Returns the schema, so you can chain this call.
  17950. */
  17951. }, {
  17952. key: "addGeoPoint",
  17953. value: function (name
  17954. /*: string*/
  17955. , options
  17956. /*: FieldOptions*/
  17957. ) {
  17958. return this.addField(name, 'GeoPoint', options);
  17959. }
  17960. /**
  17961. * Adding Polygon Field
  17962. *
  17963. * @param {string} name Name of the field that will be created on Parse
  17964. * @param {object} options See {@link https://parseplatform.org/Parse-SDK-JS/api/master/Parse.Schema.html#addField addField}
  17965. * @returns {Parse.Schema} Returns the schema, so you can chain this call.
  17966. */
  17967. }, {
  17968. key: "addPolygon",
  17969. value: function (name
  17970. /*: string*/
  17971. , options
  17972. /*: FieldOptions*/
  17973. ) {
  17974. return this.addField(name, 'Polygon', options);
  17975. }
  17976. /**
  17977. * Adding Array Field
  17978. *
  17979. * @param {string} name Name of the field that will be created on Parse
  17980. * @param {object} options See {@link https://parseplatform.org/Parse-SDK-JS/api/master/Parse.Schema.html#addField addField}
  17981. * @returns {Parse.Schema} Returns the schema, so you can chain this call.
  17982. */
  17983. }, {
  17984. key: "addArray",
  17985. value: function (name
  17986. /*: string*/
  17987. , options
  17988. /*: FieldOptions*/
  17989. ) {
  17990. return this.addField(name, 'Array', options);
  17991. }
  17992. /**
  17993. * Adding Object Field
  17994. *
  17995. * @param {string} name Name of the field that will be created on Parse
  17996. * @param {object} options See {@link https://parseplatform.org/Parse-SDK-JS/api/master/Parse.Schema.html#addField addField}
  17997. * @returns {Parse.Schema} Returns the schema, so you can chain this call.
  17998. */
  17999. }, {
  18000. key: "addObject",
  18001. value: function (name
  18002. /*: string*/
  18003. , options
  18004. /*: FieldOptions*/
  18005. ) {
  18006. return this.addField(name, 'Object', options);
  18007. }
  18008. /**
  18009. * Adding Pointer Field
  18010. *
  18011. * @param {string} name Name of the field that will be created on Parse
  18012. * @param {string} targetClass Name of the target Pointer Class
  18013. * @param {object} options See {@link https://parseplatform.org/Parse-SDK-JS/api/master/Parse.Schema.html#addField addField}
  18014. * @returns {Parse.Schema} Returns the schema, so you can chain this call.
  18015. */
  18016. }, {
  18017. key: "addPointer",
  18018. value: function (name
  18019. /*: string*/
  18020. , targetClass
  18021. /*: string*/
  18022. ) {
  18023. var options
  18024. /*: FieldOptions*/
  18025. = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
  18026. if (!name) {
  18027. throw new Error('field name may not be null.');
  18028. }
  18029. if (!targetClass) {
  18030. throw new Error('You need to set the targetClass of the Pointer.');
  18031. }
  18032. var fieldOptions = {
  18033. type: 'Pointer',
  18034. targetClass: targetClass
  18035. };
  18036. if (typeof options.required === 'boolean') {
  18037. fieldOptions.required = options.required;
  18038. }
  18039. if (options.defaultValue !== undefined) {
  18040. fieldOptions.defaultValue = options.defaultValue;
  18041. if (options.defaultValue instanceof _ParseObject.default) {
  18042. fieldOptions.defaultValue = options.defaultValue.toPointer();
  18043. }
  18044. }
  18045. this._fields[name] = fieldOptions;
  18046. return this;
  18047. }
  18048. /**
  18049. * Adding Relation Field
  18050. *
  18051. * @param {string} name Name of the field that will be created on Parse
  18052. * @param {string} targetClass Name of the target Pointer Class
  18053. * @returns {Parse.Schema} Returns the schema, so you can chain this call.
  18054. */
  18055. }, {
  18056. key: "addRelation",
  18057. value: function (name
  18058. /*: string*/
  18059. , targetClass
  18060. /*: string*/
  18061. ) {
  18062. if (!name) {
  18063. throw new Error('field name may not be null.');
  18064. }
  18065. if (!targetClass) {
  18066. throw new Error('You need to set the targetClass of the Relation.');
  18067. }
  18068. this._fields[name] = {
  18069. type: 'Relation',
  18070. targetClass: targetClass
  18071. };
  18072. return this;
  18073. }
  18074. /**
  18075. * Deleting a Field to Update on a Schema
  18076. *
  18077. * @param {string} name Name of the field
  18078. * @returns {Parse.Schema} Returns the schema, so you can chain this call.
  18079. */
  18080. }, {
  18081. key: "deleteField",
  18082. value: function (name
  18083. /*: string*/
  18084. ) {
  18085. this._fields[name] = {
  18086. __op: 'Delete'
  18087. };
  18088. return this;
  18089. }
  18090. /**
  18091. * Deleting an Index to Update on a Schema
  18092. *
  18093. * @param {string} name Name of the field
  18094. * @returns {Parse.Schema} Returns the schema, so you can chain this call.
  18095. */
  18096. }, {
  18097. key: "deleteIndex",
  18098. value: function (name
  18099. /*: string*/
  18100. ) {
  18101. this._indexes[name] = {
  18102. __op: 'Delete'
  18103. };
  18104. return this;
  18105. }
  18106. }], [{
  18107. key: "all",
  18108. value: function () {
  18109. var controller = _CoreManager.default.getSchemaController();
  18110. return controller.get('').then(function (response) {
  18111. if (response.results.length === 0) {
  18112. throw new Error('Schema not found.');
  18113. }
  18114. return response.results;
  18115. });
  18116. }
  18117. }]);
  18118. return ParseSchema;
  18119. }();
  18120. var DefaultController = {
  18121. send: function (className
  18122. /*: string*/
  18123. , method
  18124. /*: string*/
  18125. )
  18126. /*: Promise*/
  18127. {
  18128. var params
  18129. /*: any*/
  18130. = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
  18131. var RESTController = _CoreManager.default.getRESTController();
  18132. return RESTController.request(method, "schemas/".concat(className), params, {
  18133. useMasterKey: true
  18134. });
  18135. },
  18136. get: function (className
  18137. /*: string*/
  18138. )
  18139. /*: Promise*/
  18140. {
  18141. return this.send(className, 'GET');
  18142. },
  18143. create: function (className
  18144. /*: string*/
  18145. , params
  18146. /*: any*/
  18147. )
  18148. /*: Promise*/
  18149. {
  18150. return this.send(className, 'POST', params);
  18151. },
  18152. update: function (className
  18153. /*: string*/
  18154. , params
  18155. /*: any*/
  18156. )
  18157. /*: Promise*/
  18158. {
  18159. return this.send(className, 'PUT', params);
  18160. },
  18161. delete: function (className
  18162. /*: string*/
  18163. )
  18164. /*: Promise*/
  18165. {
  18166. return this.send(className, 'DELETE');
  18167. },
  18168. purge: function (className
  18169. /*: string*/
  18170. )
  18171. /*: Promise*/
  18172. {
  18173. var RESTController = _CoreManager.default.getRESTController();
  18174. return RESTController.request('DELETE', "purge/".concat(className), {}, {
  18175. useMasterKey: true
  18176. });
  18177. }
  18178. };
  18179. _CoreManager.default.setSchemaController(DefaultController);
  18180. var _default = ParseSchema;
  18181. exports.default = _default;
  18182. },{"./CoreManager":4,"./ParseCLP":20,"./ParseObject":27,"@babel/runtime-corejs3/core-js-stable/instance/index-of":66,"@babel/runtime-corejs3/core-js-stable/object/define-property":82,"@babel/runtime-corejs3/helpers/classCallCheck":121,"@babel/runtime-corejs3/helpers/createClass":123,"@babel/runtime-corejs3/helpers/defineProperty":124,"@babel/runtime-corejs3/helpers/interopRequireDefault":128}],34:[function(_dereq_,module,exports){
  18183. "use strict";
  18184. var _interopRequireDefault = _dereq_("@babel/runtime-corejs3/helpers/interopRequireDefault");
  18185. var _Object$defineProperty = _dereq_("@babel/runtime-corejs3/core-js-stable/object/define-property");
  18186. var _Reflect$construct = _dereq_("@babel/runtime-corejs3/core-js-stable/reflect/construct");
  18187. _Object$defineProperty(exports, "__esModule", {
  18188. value: true
  18189. });
  18190. exports.default = void 0;
  18191. var _promise = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/promise"));
  18192. var _typeof2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/helpers/typeof"));
  18193. var _classCallCheck2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/helpers/classCallCheck"));
  18194. var _createClass2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/helpers/createClass"));
  18195. var _inherits2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/helpers/inherits"));
  18196. var _possibleConstructorReturn2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/helpers/possibleConstructorReturn"));
  18197. var _getPrototypeOf2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/helpers/getPrototypeOf"));
  18198. var _CoreManager = _interopRequireDefault(_dereq_("./CoreManager"));
  18199. var _isRevocableSession = _interopRequireDefault(_dereq_("./isRevocableSession"));
  18200. var _ParseObject2 = _interopRequireDefault(_dereq_("./ParseObject"));
  18201. var _ParseUser = _interopRequireDefault(_dereq_("./ParseUser"));
  18202. function _createSuper(Derived) {
  18203. var hasNativeReflectConstruct = _isNativeReflectConstruct();
  18204. return function () {
  18205. var Super = (0, _getPrototypeOf2.default)(Derived),
  18206. result;
  18207. if (hasNativeReflectConstruct) {
  18208. var NewTarget = (0, _getPrototypeOf2.default)(this).constructor;
  18209. result = _Reflect$construct(Super, arguments, NewTarget);
  18210. } else {
  18211. result = Super.apply(this, arguments);
  18212. }
  18213. return (0, _possibleConstructorReturn2.default)(this, result);
  18214. };
  18215. }
  18216. function _isNativeReflectConstruct() {
  18217. if (typeof Reflect === "undefined" || !_Reflect$construct) return false;
  18218. if (_Reflect$construct.sham) return false;
  18219. if (typeof Proxy === "function") return true;
  18220. try {
  18221. Boolean.prototype.valueOf.call(_Reflect$construct(Boolean, [], function () {}));
  18222. return true;
  18223. } catch (e) {
  18224. return false;
  18225. }
  18226. }
  18227. /**
  18228. * <p>A Parse.Session object is a local representation of a revocable session.
  18229. * This class is a subclass of a Parse.Object, and retains the same
  18230. * functionality of a Parse.Object.</p>
  18231. *
  18232. * @alias Parse.Session
  18233. * @augments Parse.Object
  18234. */
  18235. var ParseSession = /*#__PURE__*/function (_ParseObject) {
  18236. (0, _inherits2.default)(ParseSession, _ParseObject);
  18237. var _super = _createSuper(ParseSession);
  18238. /**
  18239. * @param {object} attributes The initial set of data to store in the user.
  18240. */
  18241. function ParseSession(attributes
  18242. /*: ?AttributeMap*/
  18243. ) {
  18244. var _this;
  18245. (0, _classCallCheck2.default)(this, ParseSession);
  18246. _this = _super.call(this, '_Session');
  18247. if (attributes && (0, _typeof2.default)(attributes) === 'object') {
  18248. if (!_this.set(attributes || {})) {
  18249. throw new Error("Can't create an invalid Session");
  18250. }
  18251. }
  18252. return _this;
  18253. }
  18254. /**
  18255. * Returns the session token string.
  18256. *
  18257. * @returns {string}
  18258. */
  18259. (0, _createClass2.default)(ParseSession, [{
  18260. key: "getSessionToken",
  18261. value: function ()
  18262. /*: string*/
  18263. {
  18264. var token = this.get('sessionToken');
  18265. if (typeof token === 'string') {
  18266. return token;
  18267. }
  18268. return '';
  18269. }
  18270. }], [{
  18271. key: "readOnlyAttributes",
  18272. value: function () {
  18273. return ['createdWith', 'expiresAt', 'installationId', 'restricted', 'sessionToken', 'user'];
  18274. }
  18275. /**
  18276. * Retrieves the Session object for the currently logged in session.
  18277. *
  18278. * @param {object} options useMasterKey
  18279. * @static
  18280. * @returns {Promise} A promise that is resolved with the Parse.Session
  18281. * object after it has been fetched. If there is no current user, the
  18282. * promise will be rejected.
  18283. */
  18284. }, {
  18285. key: "current",
  18286. value: function (options
  18287. /*: FullOptions*/
  18288. ) {
  18289. options = options || {};
  18290. var controller = _CoreManager.default.getSessionController();
  18291. var sessionOptions = {};
  18292. if (options.hasOwnProperty('useMasterKey')) {
  18293. sessionOptions.useMasterKey = options.useMasterKey;
  18294. }
  18295. return _ParseUser.default.currentAsync().then(function (user) {
  18296. if (!user) {
  18297. return _promise.default.reject('There is no current user.');
  18298. }
  18299. sessionOptions.sessionToken = user.getSessionToken();
  18300. return controller.getSession(sessionOptions);
  18301. });
  18302. }
  18303. /**
  18304. * Determines whether the current session token is revocable.
  18305. * This method is useful for migrating Express.js or Node.js web apps to
  18306. * use revocable sessions. If you are migrating an app that uses the Parse
  18307. * SDK in the browser only, please use Parse.User.enableRevocableSession()
  18308. * instead, so that sessions can be automatically upgraded.
  18309. *
  18310. * @static
  18311. * @returns {boolean}
  18312. */
  18313. }, {
  18314. key: "isCurrentSessionRevocable",
  18315. value: function ()
  18316. /*: boolean*/
  18317. {
  18318. var currentUser = _ParseUser.default.current();
  18319. if (currentUser) {
  18320. return (0, _isRevocableSession.default)(currentUser.getSessionToken() || '');
  18321. }
  18322. return false;
  18323. }
  18324. }]);
  18325. return ParseSession;
  18326. }(_ParseObject2.default);
  18327. _ParseObject2.default.registerSubclass('_Session', ParseSession);
  18328. var DefaultController = {
  18329. getSession: function (options
  18330. /*: RequestOptions*/
  18331. )
  18332. /*: Promise<ParseSession>*/
  18333. {
  18334. var RESTController = _CoreManager.default.getRESTController();
  18335. var session = new ParseSession();
  18336. return RESTController.request('GET', 'sessions/me', {}, options).then(function (sessionData) {
  18337. session._finishFetch(sessionData);
  18338. session._setExisted(true);
  18339. return session;
  18340. });
  18341. }
  18342. };
  18343. _CoreManager.default.setSessionController(DefaultController);
  18344. var _default = ParseSession;
  18345. exports.default = _default;
  18346. },{"./CoreManager":4,"./ParseObject":27,"./ParseUser":35,"./isRevocableSession":49,"@babel/runtime-corejs3/core-js-stable/object/define-property":82,"@babel/runtime-corejs3/core-js-stable/promise":92,"@babel/runtime-corejs3/core-js-stable/reflect/construct":93,"@babel/runtime-corejs3/helpers/classCallCheck":121,"@babel/runtime-corejs3/helpers/createClass":123,"@babel/runtime-corejs3/helpers/getPrototypeOf":126,"@babel/runtime-corejs3/helpers/inherits":127,"@babel/runtime-corejs3/helpers/interopRequireDefault":128,"@babel/runtime-corejs3/helpers/possibleConstructorReturn":135,"@babel/runtime-corejs3/helpers/typeof":140}],35:[function(_dereq_,module,exports){
  18347. "use strict";
  18348. var _interopRequireDefault = _dereq_("@babel/runtime-corejs3/helpers/interopRequireDefault");
  18349. var _sliceInstanceProperty = _dereq_("@babel/runtime-corejs3/core-js-stable/instance/slice");
  18350. var _reverseInstanceProperty = _dereq_("@babel/runtime-corejs3/core-js-stable/instance/reverse");
  18351. var _Promise2 = _dereq_("@babel/runtime-corejs3/core-js-stable/promise");
  18352. var _Object$setPrototypeOf = _dereq_("@babel/runtime-corejs3/core-js-stable/object/set-prototype-of");
  18353. var _typeof3 = _dereq_("@babel/runtime-corejs3/helpers/typeof");
  18354. var _forEachInstanceProperty = _dereq_("@babel/runtime-corejs3/core-js-stable/instance/for-each");
  18355. var _Object$getPrototypeOf = _dereq_("@babel/runtime-corejs3/core-js-stable/object/get-prototype-of");
  18356. var _Object$create = _dereq_("@babel/runtime-corejs3/core-js-stable/object/create");
  18357. var _Object$defineProperty2 = _dereq_("@babel/runtime-corejs3/core-js-stable/object/define-property");
  18358. var _Symbol = _dereq_("@babel/runtime-corejs3/core-js-stable/symbol");
  18359. var _Reflect$construct = _dereq_("@babel/runtime-corejs3/core-js-stable/reflect/construct");
  18360. _Object$defineProperty2(exports, "__esModule", {
  18361. value: true
  18362. });
  18363. exports.default = void 0;
  18364. var _stringify = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/json/stringify"));
  18365. var _defineProperty = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/object/define-property"));
  18366. var _asyncToGenerator2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/helpers/asyncToGenerator"));
  18367. var _promise = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/promise"));
  18368. var _typeof2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/helpers/typeof"));
  18369. var _classCallCheck2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/helpers/classCallCheck"));
  18370. var _createClass2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/helpers/createClass"));
  18371. var _get2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/helpers/get"));
  18372. var _inherits2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/helpers/inherits"));
  18373. var _possibleConstructorReturn2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/helpers/possibleConstructorReturn"));
  18374. var _getPrototypeOf2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/helpers/getPrototypeOf"));
  18375. var _CoreManager = _interopRequireDefault(_dereq_("./CoreManager"));
  18376. var _isRevocableSession = _interopRequireDefault(_dereq_("./isRevocableSession"));
  18377. var _ParseError = _interopRequireDefault(_dereq_("./ParseError"));
  18378. var _ParseObject2 = _interopRequireDefault(_dereq_("./ParseObject"));
  18379. var _ParseSession = _interopRequireDefault(_dereq_("./ParseSession"));
  18380. var _Storage = _interopRequireDefault(_dereq_("./Storage"));
  18381. function _regeneratorRuntime() {
  18382. "use strict";
  18383. /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */
  18384. _regeneratorRuntime = function () {
  18385. return exports;
  18386. };
  18387. var exports = {},
  18388. Op = Object.prototype,
  18389. hasOwn = Op.hasOwnProperty,
  18390. $Symbol = "function" == typeof _Symbol ? _Symbol : {},
  18391. iteratorSymbol = $Symbol.iterator || "@@iterator",
  18392. asyncIteratorSymbol = $Symbol.asyncIterator || "@@asyncIterator",
  18393. toStringTagSymbol = $Symbol.toStringTag || "@@toStringTag";
  18394. function define(obj, key, value) {
  18395. return _Object$defineProperty2(obj, key, {
  18396. value: value,
  18397. enumerable: !0,
  18398. configurable: !0,
  18399. writable: !0
  18400. }), obj[key];
  18401. }
  18402. try {
  18403. define({}, "");
  18404. } catch (err) {
  18405. define = function (obj, key, value) {
  18406. return obj[key] = value;
  18407. };
  18408. }
  18409. function wrap(innerFn, outerFn, self, tryLocsList) {
  18410. var protoGenerator = outerFn && outerFn.prototype instanceof Generator ? outerFn : Generator,
  18411. generator = _Object$create(protoGenerator.prototype),
  18412. context = new Context(tryLocsList || []);
  18413. return generator._invoke = function (innerFn, self, context) {
  18414. var state = "suspendedStart";
  18415. return function (method, arg) {
  18416. if ("executing" === state) throw new Error("Generator is already running");
  18417. if ("completed" === state) {
  18418. if ("throw" === method) throw arg;
  18419. return doneResult();
  18420. }
  18421. for (context.method = method, context.arg = arg;;) {
  18422. var delegate = context.delegate;
  18423. if (delegate) {
  18424. var delegateResult = maybeInvokeDelegate(delegate, context);
  18425. if (delegateResult) {
  18426. if (delegateResult === ContinueSentinel) continue;
  18427. return delegateResult;
  18428. }
  18429. }
  18430. if ("next" === context.method) context.sent = context._sent = context.arg;else if ("throw" === context.method) {
  18431. if ("suspendedStart" === state) throw state = "completed", context.arg;
  18432. context.dispatchException(context.arg);
  18433. } else "return" === context.method && context.abrupt("return", context.arg);
  18434. state = "executing";
  18435. var record = tryCatch(innerFn, self, context);
  18436. if ("normal" === record.type) {
  18437. if (state = context.done ? "completed" : "suspendedYield", record.arg === ContinueSentinel) continue;
  18438. return {
  18439. value: record.arg,
  18440. done: context.done
  18441. };
  18442. }
  18443. "throw" === record.type && (state = "completed", context.method = "throw", context.arg = record.arg);
  18444. }
  18445. };
  18446. }(innerFn, self, context), generator;
  18447. }
  18448. function tryCatch(fn, obj, arg) {
  18449. try {
  18450. return {
  18451. type: "normal",
  18452. arg: fn.call(obj, arg)
  18453. };
  18454. } catch (err) {
  18455. return {
  18456. type: "throw",
  18457. arg: err
  18458. };
  18459. }
  18460. }
  18461. exports.wrap = wrap;
  18462. var ContinueSentinel = {};
  18463. function Generator() {}
  18464. function GeneratorFunction() {}
  18465. function GeneratorFunctionPrototype() {}
  18466. var IteratorPrototype = {};
  18467. define(IteratorPrototype, iteratorSymbol, function () {
  18468. return this;
  18469. });
  18470. var getProto = _Object$getPrototypeOf,
  18471. NativeIteratorPrototype = getProto && getProto(getProto(values([])));
  18472. NativeIteratorPrototype && NativeIteratorPrototype !== Op && hasOwn.call(NativeIteratorPrototype, iteratorSymbol) && (IteratorPrototype = NativeIteratorPrototype);
  18473. var Gp = GeneratorFunctionPrototype.prototype = Generator.prototype = _Object$create(IteratorPrototype);
  18474. function defineIteratorMethods(prototype) {
  18475. var _context7;
  18476. _forEachInstanceProperty(_context7 = ["next", "throw", "return"]).call(_context7, function (method) {
  18477. define(prototype, method, function (arg) {
  18478. return this._invoke(method, arg);
  18479. });
  18480. });
  18481. }
  18482. function AsyncIterator(generator, PromiseImpl) {
  18483. function invoke(method, arg, resolve, reject) {
  18484. var record = tryCatch(generator[method], generator, arg);
  18485. if ("throw" !== record.type) {
  18486. var result = record.arg,
  18487. value = result.value;
  18488. return value && "object" == _typeof3(value) && hasOwn.call(value, "__await") ? PromiseImpl.resolve(value.__await).then(function (value) {
  18489. invoke("next", value, resolve, reject);
  18490. }, function (err) {
  18491. invoke("throw", err, resolve, reject);
  18492. }) : PromiseImpl.resolve(value).then(function (unwrapped) {
  18493. result.value = unwrapped, resolve(result);
  18494. }, function (error) {
  18495. return invoke("throw", error, resolve, reject);
  18496. });
  18497. }
  18498. reject(record.arg);
  18499. }
  18500. var previousPromise;
  18501. this._invoke = function (method, arg) {
  18502. function callInvokeWithMethodAndArg() {
  18503. return new PromiseImpl(function (resolve, reject) {
  18504. invoke(method, arg, resolve, reject);
  18505. });
  18506. }
  18507. return previousPromise = previousPromise ? previousPromise.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg();
  18508. };
  18509. }
  18510. function maybeInvokeDelegate(delegate, context) {
  18511. var method = delegate.iterator[context.method];
  18512. if (undefined === method) {
  18513. if (context.delegate = null, "throw" === context.method) {
  18514. if (delegate.iterator.return && (context.method = "return", context.arg = undefined, maybeInvokeDelegate(delegate, context), "throw" === context.method)) return ContinueSentinel;
  18515. context.method = "throw", context.arg = new TypeError("The iterator does not provide a 'throw' method");
  18516. }
  18517. return ContinueSentinel;
  18518. }
  18519. var record = tryCatch(method, delegate.iterator, context.arg);
  18520. if ("throw" === record.type) return context.method = "throw", context.arg = record.arg, context.delegate = null, ContinueSentinel;
  18521. var info = record.arg;
  18522. return info ? info.done ? (context[delegate.resultName] = info.value, context.next = delegate.nextLoc, "return" !== context.method && (context.method = "next", context.arg = undefined), context.delegate = null, ContinueSentinel) : info : (context.method = "throw", context.arg = new TypeError("iterator result is not an object"), context.delegate = null, ContinueSentinel);
  18523. }
  18524. function pushTryEntry(locs) {
  18525. var entry = {
  18526. tryLoc: locs[0]
  18527. };
  18528. 1 in locs && (entry.catchLoc = locs[1]), 2 in locs && (entry.finallyLoc = locs[2], entry.afterLoc = locs[3]), this.tryEntries.push(entry);
  18529. }
  18530. function resetTryEntry(entry) {
  18531. var record = entry.completion || {};
  18532. record.type = "normal", delete record.arg, entry.completion = record;
  18533. }
  18534. function Context(tryLocsList) {
  18535. this.tryEntries = [{
  18536. tryLoc: "root"
  18537. }], _forEachInstanceProperty(tryLocsList).call(tryLocsList, pushTryEntry, this), this.reset(!0);
  18538. }
  18539. function values(iterable) {
  18540. if (iterable) {
  18541. var iteratorMethod = iterable[iteratorSymbol];
  18542. if (iteratorMethod) return iteratorMethod.call(iterable);
  18543. if ("function" == typeof iterable.next) return iterable;
  18544. if (!isNaN(iterable.length)) {
  18545. var i = -1,
  18546. next = function next() {
  18547. for (; ++i < iterable.length;) {
  18548. if (hasOwn.call(iterable, i)) return next.value = iterable[i], next.done = !1, next;
  18549. }
  18550. return next.value = undefined, next.done = !0, next;
  18551. };
  18552. return next.next = next;
  18553. }
  18554. }
  18555. return {
  18556. next: doneResult
  18557. };
  18558. }
  18559. function doneResult() {
  18560. return {
  18561. value: undefined,
  18562. done: !0
  18563. };
  18564. }
  18565. return GeneratorFunction.prototype = GeneratorFunctionPrototype, define(Gp, "constructor", GeneratorFunctionPrototype), define(GeneratorFunctionPrototype, "constructor", GeneratorFunction), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, toStringTagSymbol, "GeneratorFunction"), exports.isGeneratorFunction = function (genFun) {
  18566. var ctor = "function" == typeof genFun && genFun.constructor;
  18567. return !!ctor && (ctor === GeneratorFunction || "GeneratorFunction" === (ctor.displayName || ctor.name));
  18568. }, exports.mark = function (genFun) {
  18569. return _Object$setPrototypeOf ? _Object$setPrototypeOf(genFun, GeneratorFunctionPrototype) : (genFun.__proto__ = GeneratorFunctionPrototype, define(genFun, toStringTagSymbol, "GeneratorFunction")), genFun.prototype = _Object$create(Gp), genFun;
  18570. }, exports.awrap = function (arg) {
  18571. return {
  18572. __await: arg
  18573. };
  18574. }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, asyncIteratorSymbol, function () {
  18575. return this;
  18576. }), exports.AsyncIterator = AsyncIterator, exports.async = function (innerFn, outerFn, self, tryLocsList, PromiseImpl) {
  18577. void 0 === PromiseImpl && (PromiseImpl = _Promise2);
  18578. var iter = new AsyncIterator(wrap(innerFn, outerFn, self, tryLocsList), PromiseImpl);
  18579. return exports.isGeneratorFunction(outerFn) ? iter : iter.next().then(function (result) {
  18580. return result.done ? result.value : iter.next();
  18581. });
  18582. }, defineIteratorMethods(Gp), define(Gp, toStringTagSymbol, "Generator"), define(Gp, iteratorSymbol, function () {
  18583. return this;
  18584. }), define(Gp, "toString", function () {
  18585. return "[object Generator]";
  18586. }), exports.keys = function (object) {
  18587. var keys = [];
  18588. for (var key in object) {
  18589. keys.push(key);
  18590. }
  18591. return _reverseInstanceProperty(keys).call(keys), function next() {
  18592. for (; keys.length;) {
  18593. var key = keys.pop();
  18594. if (key in object) return next.value = key, next.done = !1, next;
  18595. }
  18596. return next.done = !0, next;
  18597. };
  18598. }, exports.values = values, Context.prototype = {
  18599. constructor: Context,
  18600. reset: function (skipTempReset) {
  18601. var _context8;
  18602. if (this.prev = 0, this.next = 0, this.sent = this._sent = undefined, this.done = !1, this.delegate = null, this.method = "next", this.arg = undefined, _forEachInstanceProperty(_context8 = this.tryEntries).call(_context8, resetTryEntry), !skipTempReset) for (var name in this) {
  18603. "t" === name.charAt(0) && hasOwn.call(this, name) && !isNaN(+_sliceInstanceProperty(name).call(name, 1)) && (this[name] = undefined);
  18604. }
  18605. },
  18606. stop: function () {
  18607. this.done = !0;
  18608. var rootRecord = this.tryEntries[0].completion;
  18609. if ("throw" === rootRecord.type) throw rootRecord.arg;
  18610. return this.rval;
  18611. },
  18612. dispatchException: function (exception) {
  18613. if (this.done) throw exception;
  18614. var context = this;
  18615. function handle(loc, caught) {
  18616. return record.type = "throw", record.arg = exception, context.next = loc, caught && (context.method = "next", context.arg = undefined), !!caught;
  18617. }
  18618. for (var i = this.tryEntries.length - 1; i >= 0; --i) {
  18619. var entry = this.tryEntries[i],
  18620. record = entry.completion;
  18621. if ("root" === entry.tryLoc) return handle("end");
  18622. if (entry.tryLoc <= this.prev) {
  18623. var hasCatch = hasOwn.call(entry, "catchLoc"),
  18624. hasFinally = hasOwn.call(entry, "finallyLoc");
  18625. if (hasCatch && hasFinally) {
  18626. if (this.prev < entry.catchLoc) return handle(entry.catchLoc, !0);
  18627. if (this.prev < entry.finallyLoc) return handle(entry.finallyLoc);
  18628. } else if (hasCatch) {
  18629. if (this.prev < entry.catchLoc) return handle(entry.catchLoc, !0);
  18630. } else {
  18631. if (!hasFinally) throw new Error("try statement without catch or finally");
  18632. if (this.prev < entry.finallyLoc) return handle(entry.finallyLoc);
  18633. }
  18634. }
  18635. }
  18636. },
  18637. abrupt: function (type, arg) {
  18638. for (var i = this.tryEntries.length - 1; i >= 0; --i) {
  18639. var entry = this.tryEntries[i];
  18640. if (entry.tryLoc <= this.prev && hasOwn.call(entry, "finallyLoc") && this.prev < entry.finallyLoc) {
  18641. var finallyEntry = entry;
  18642. break;
  18643. }
  18644. }
  18645. finallyEntry && ("break" === type || "continue" === type) && finallyEntry.tryLoc <= arg && arg <= finallyEntry.finallyLoc && (finallyEntry = null);
  18646. var record = finallyEntry ? finallyEntry.completion : {};
  18647. return record.type = type, record.arg = arg, finallyEntry ? (this.method = "next", this.next = finallyEntry.finallyLoc, ContinueSentinel) : this.complete(record);
  18648. },
  18649. complete: function (record, afterLoc) {
  18650. if ("throw" === record.type) throw record.arg;
  18651. return "break" === record.type || "continue" === record.type ? this.next = record.arg : "return" === record.type ? (this.rval = this.arg = record.arg, this.method = "return", this.next = "end") : "normal" === record.type && afterLoc && (this.next = afterLoc), ContinueSentinel;
  18652. },
  18653. finish: function (finallyLoc) {
  18654. for (var i = this.tryEntries.length - 1; i >= 0; --i) {
  18655. var entry = this.tryEntries[i];
  18656. if (entry.finallyLoc === finallyLoc) return this.complete(entry.completion, entry.afterLoc), resetTryEntry(entry), ContinueSentinel;
  18657. }
  18658. },
  18659. catch: function (tryLoc) {
  18660. for (var i = this.tryEntries.length - 1; i >= 0; --i) {
  18661. var entry = this.tryEntries[i];
  18662. if (entry.tryLoc === tryLoc) {
  18663. var record = entry.completion;
  18664. if ("throw" === record.type) {
  18665. var thrown = record.arg;
  18666. resetTryEntry(entry);
  18667. }
  18668. return thrown;
  18669. }
  18670. }
  18671. throw new Error("illegal catch attempt");
  18672. },
  18673. delegateYield: function (iterable, resultName, nextLoc) {
  18674. return this.delegate = {
  18675. iterator: values(iterable),
  18676. resultName: resultName,
  18677. nextLoc: nextLoc
  18678. }, "next" === this.method && (this.arg = undefined), ContinueSentinel;
  18679. }
  18680. }, exports;
  18681. }
  18682. function _createSuper(Derived) {
  18683. var hasNativeReflectConstruct = _isNativeReflectConstruct();
  18684. return function () {
  18685. var Super = (0, _getPrototypeOf2.default)(Derived),
  18686. result;
  18687. if (hasNativeReflectConstruct) {
  18688. var NewTarget = (0, _getPrototypeOf2.default)(this).constructor;
  18689. result = _Reflect$construct(Super, arguments, NewTarget);
  18690. } else {
  18691. result = Super.apply(this, arguments);
  18692. }
  18693. return (0, _possibleConstructorReturn2.default)(this, result);
  18694. };
  18695. }
  18696. function _isNativeReflectConstruct() {
  18697. if (typeof Reflect === "undefined" || !_Reflect$construct) return false;
  18698. if (_Reflect$construct.sham) return false;
  18699. if (typeof Proxy === "function") return true;
  18700. try {
  18701. Boolean.prototype.valueOf.call(_Reflect$construct(Boolean, [], function () {}));
  18702. return true;
  18703. } catch (e) {
  18704. return false;
  18705. }
  18706. }
  18707. var CURRENT_USER_KEY = 'currentUser';
  18708. var canUseCurrentUser = !_CoreManager.default.get('IS_NODE');
  18709. var currentUserCacheMatchesDisk = false;
  18710. var currentUserCache = null;
  18711. var authProviders = {};
  18712. /**
  18713. * <p>A Parse.User object is a local representation of a user persisted to the
  18714. * Parse cloud. This class is a subclass of a Parse.Object, and retains the
  18715. * same functionality of a Parse.Object, but also extends it with various
  18716. * user specific methods, like authentication, signing up, and validation of
  18717. * uniqueness.</p>
  18718. *
  18719. * @alias Parse.User
  18720. * @augments Parse.Object
  18721. */
  18722. var ParseUser = /*#__PURE__*/function (_ParseObject) {
  18723. (0, _inherits2.default)(ParseUser, _ParseObject);
  18724. var _super = _createSuper(ParseUser);
  18725. /**
  18726. * @param {object} attributes The initial set of data to store in the user.
  18727. */
  18728. function ParseUser(attributes
  18729. /*: ?AttributeMap*/
  18730. ) {
  18731. var _this;
  18732. (0, _classCallCheck2.default)(this, ParseUser);
  18733. _this = _super.call(this, '_User');
  18734. if (attributes && (0, _typeof2.default)(attributes) === 'object') {
  18735. if (!_this.set(attributes || {})) {
  18736. throw new Error("Can't create an invalid Parse User");
  18737. }
  18738. }
  18739. return _this;
  18740. }
  18741. /**
  18742. * Request a revocable session token to replace the older style of token.
  18743. *
  18744. * @param {object} options
  18745. * @returns {Promise} A promise that is resolved when the replacement
  18746. * token has been fetched.
  18747. */
  18748. (0, _createClass2.default)(ParseUser, [{
  18749. key: "_upgradeToRevocableSession",
  18750. value: function (options
  18751. /*: RequestOptions*/
  18752. )
  18753. /*: Promise<void>*/
  18754. {
  18755. options = options || {};
  18756. var upgradeOptions = {};
  18757. if (options.hasOwnProperty('useMasterKey')) {
  18758. upgradeOptions.useMasterKey = options.useMasterKey;
  18759. }
  18760. var controller = _CoreManager.default.getUserController();
  18761. return controller.upgradeToRevocableSession(this, upgradeOptions);
  18762. }
  18763. /**
  18764. * 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
  18765. * your users to sign up or log into your application using their existing identities.
  18766. * Since 2.9.0
  18767. *
  18768. * @see {@link https://docs.parseplatform.org/js/guide/#linking-users Linking Users}
  18769. * @param {string | AuthProvider} provider Name of auth provider or {@link https://parseplatform.org/Parse-SDK-JS/api/master/AuthProvider.html AuthProvider}
  18770. * @param {object} options
  18771. * <ul>
  18772. * <li>If provider is string, options is {@link http://docs.parseplatform.org/parse-server/guide/#supported-3rd-party-authentications authData}
  18773. * <li>If provider is AuthProvider, options is saveOpts
  18774. * </ul>
  18775. * @param {object} saveOpts useMasterKey / sessionToken
  18776. * @returns {Promise} A promise that is fulfilled with the user is linked
  18777. */
  18778. }, {
  18779. key: "linkWith",
  18780. value: function (provider
  18781. /*: any*/
  18782. , options
  18783. /*: { authData?: AuthData }*/
  18784. )
  18785. /*: Promise<ParseUser>*/
  18786. {
  18787. var _this2 = this;
  18788. var saveOpts
  18789. /*:: ?: FullOptions*/
  18790. = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
  18791. saveOpts.sessionToken = saveOpts.sessionToken || this.getSessionToken() || '';
  18792. var authType;
  18793. if (typeof provider === 'string') {
  18794. authType = provider;
  18795. if (authProviders[provider]) {
  18796. provider = authProviders[provider];
  18797. } else {
  18798. var authProvider = {
  18799. restoreAuthentication: function () {
  18800. return true;
  18801. },
  18802. getAuthType: function () {
  18803. return authType;
  18804. }
  18805. };
  18806. authProviders[authProvider.getAuthType()] = authProvider;
  18807. provider = authProvider;
  18808. }
  18809. } else {
  18810. authType = provider.getAuthType();
  18811. }
  18812. if (options && options.hasOwnProperty('authData')) {
  18813. var authData = this.get('authData') || {};
  18814. if ((0, _typeof2.default)(authData) !== 'object') {
  18815. throw new Error('Invalid type: authData field should be an object');
  18816. }
  18817. authData[authType] = options.authData;
  18818. var controller = _CoreManager.default.getUserController();
  18819. return controller.linkWith(this, authData, saveOpts);
  18820. } else {
  18821. return new _promise.default(function (resolve, reject) {
  18822. provider.authenticate({
  18823. success: function (provider, result) {
  18824. var opts = {};
  18825. opts.authData = result;
  18826. _this2.linkWith(provider, opts, saveOpts).then(function () {
  18827. resolve(_this2);
  18828. }, function (error) {
  18829. reject(error);
  18830. });
  18831. },
  18832. error: function (provider, _error) {
  18833. reject(_error);
  18834. }
  18835. });
  18836. });
  18837. }
  18838. }
  18839. /**
  18840. * @param provider
  18841. * @param options
  18842. * @param saveOpts
  18843. * @deprecated since 2.9.0 see {@link https://parseplatform.org/Parse-SDK-JS/api/master/Parse.User.html#linkWith linkWith}
  18844. * @returns {Promise}
  18845. */
  18846. }, {
  18847. key: "_linkWith",
  18848. value: function (provider
  18849. /*: any*/
  18850. , options
  18851. /*: { authData?: AuthData }*/
  18852. )
  18853. /*: Promise<ParseUser>*/
  18854. {
  18855. var saveOpts
  18856. /*:: ?: FullOptions*/
  18857. = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
  18858. return this.linkWith(provider, options, saveOpts);
  18859. }
  18860. /**
  18861. * Synchronizes auth data for a provider (e.g. puts the access token in the
  18862. * right place to be used by the Facebook SDK).
  18863. *
  18864. * @param provider
  18865. */
  18866. }, {
  18867. key: "_synchronizeAuthData",
  18868. value: function (provider
  18869. /*: string*/
  18870. ) {
  18871. if (!this.isCurrent() || !provider) {
  18872. return;
  18873. }
  18874. var authType;
  18875. if (typeof provider === 'string') {
  18876. authType = provider;
  18877. provider = authProviders[authType];
  18878. } else {
  18879. authType = provider.getAuthType();
  18880. }
  18881. var authData = this.get('authData');
  18882. if (!provider || !authData || (0, _typeof2.default)(authData) !== 'object') {
  18883. return;
  18884. }
  18885. var success = provider.restoreAuthentication(authData[authType]);
  18886. if (!success) {
  18887. this._unlinkFrom(provider);
  18888. }
  18889. }
  18890. /**
  18891. * Synchronizes authData for all providers.
  18892. */
  18893. }, {
  18894. key: "_synchronizeAllAuthData",
  18895. value: function () {
  18896. var authData = this.get('authData');
  18897. if ((0, _typeof2.default)(authData) !== 'object') {
  18898. return;
  18899. }
  18900. for (var _key in authData) {
  18901. this._synchronizeAuthData(_key);
  18902. }
  18903. }
  18904. /**
  18905. * Removes null values from authData (which exist temporarily for unlinking)
  18906. */
  18907. }, {
  18908. key: "_cleanupAuthData",
  18909. value: function () {
  18910. if (!this.isCurrent()) {
  18911. return;
  18912. }
  18913. var authData = this.get('authData');
  18914. if ((0, _typeof2.default)(authData) !== 'object') {
  18915. return;
  18916. }
  18917. for (var _key2 in authData) {
  18918. if (!authData[_key2]) {
  18919. delete authData[_key2];
  18920. }
  18921. }
  18922. }
  18923. /**
  18924. * Unlinks a user from a service.
  18925. *
  18926. * @param {string | AuthProvider} provider Name of auth provider or {@link https://parseplatform.org/Parse-SDK-JS/api/master/AuthProvider.html AuthProvider}
  18927. * @param {object} options MasterKey / SessionToken
  18928. * @returns {Promise} A promise that is fulfilled when the unlinking
  18929. * finishes.
  18930. */
  18931. }, {
  18932. key: "_unlinkFrom",
  18933. value: function (provider
  18934. /*: any*/
  18935. , options
  18936. /*:: ?: FullOptions*/
  18937. )
  18938. /*: Promise<ParseUser>*/
  18939. {
  18940. var _this3 = this;
  18941. return this.linkWith(provider, {
  18942. authData: null
  18943. }, options).then(function () {
  18944. _this3._synchronizeAuthData(provider);
  18945. return _promise.default.resolve(_this3);
  18946. });
  18947. }
  18948. /**
  18949. * Checks whether a user is linked to a service.
  18950. *
  18951. * @param {object} provider service to link to
  18952. * @returns {boolean} true if link was successful
  18953. */
  18954. }, {
  18955. key: "_isLinked",
  18956. value: function (provider
  18957. /*: any*/
  18958. )
  18959. /*: boolean*/
  18960. {
  18961. var authType;
  18962. if (typeof provider === 'string') {
  18963. authType = provider;
  18964. } else {
  18965. authType = provider.getAuthType();
  18966. }
  18967. var authData = this.get('authData') || {};
  18968. if ((0, _typeof2.default)(authData) !== 'object') {
  18969. return false;
  18970. }
  18971. return !!authData[authType];
  18972. }
  18973. /**
  18974. * Deauthenticates all providers.
  18975. */
  18976. }, {
  18977. key: "_logOutWithAll",
  18978. value: function () {
  18979. var authData = this.get('authData');
  18980. if ((0, _typeof2.default)(authData) !== 'object') {
  18981. return;
  18982. }
  18983. for (var _key3 in authData) {
  18984. this._logOutWith(_key3);
  18985. }
  18986. }
  18987. /**
  18988. * Deauthenticates a single provider (e.g. removing access tokens from the
  18989. * Facebook SDK).
  18990. *
  18991. * @param {object} provider service to logout of
  18992. */
  18993. }, {
  18994. key: "_logOutWith",
  18995. value: function (provider
  18996. /*: any*/
  18997. ) {
  18998. if (!this.isCurrent()) {
  18999. return;
  19000. }
  19001. if (typeof provider === 'string') {
  19002. provider = authProviders[provider];
  19003. }
  19004. if (provider && provider.deauthenticate) {
  19005. provider.deauthenticate();
  19006. }
  19007. }
  19008. /**
  19009. * Class instance method used to maintain specific keys when a fetch occurs.
  19010. * Used to ensure that the session token is not lost.
  19011. *
  19012. * @returns {object} sessionToken
  19013. */
  19014. }, {
  19015. key: "_preserveFieldsOnFetch",
  19016. value: function ()
  19017. /*: AttributeMap*/
  19018. {
  19019. return {
  19020. sessionToken: this.get('sessionToken')
  19021. };
  19022. }
  19023. /**
  19024. * Returns true if <code>current</code> would return this user.
  19025. *
  19026. * @returns {boolean} true if user is cached on disk
  19027. */
  19028. }, {
  19029. key: "isCurrent",
  19030. value: function ()
  19031. /*: boolean*/
  19032. {
  19033. var current = ParseUser.current();
  19034. return !!current && current.id === this.id;
  19035. }
  19036. /**
  19037. * Returns true if <code>current</code> would return this user.
  19038. *
  19039. * @returns {Promise<boolean>} true if user is cached on disk
  19040. */
  19041. }, {
  19042. key: "isCurrentAsync",
  19043. value: function () {
  19044. var _isCurrentAsync = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
  19045. var current;
  19046. return _regeneratorRuntime().wrap(function _callee$(_context) {
  19047. while (1) {
  19048. switch (_context.prev = _context.next) {
  19049. case 0:
  19050. _context.next = 2;
  19051. return ParseUser.currentAsync();
  19052. case 2:
  19053. current = _context.sent;
  19054. return _context.abrupt("return", !!current && current.id === this.id);
  19055. case 4:
  19056. case "end":
  19057. return _context.stop();
  19058. }
  19059. }
  19060. }, _callee, this);
  19061. }));
  19062. function isCurrentAsync() {
  19063. return _isCurrentAsync.apply(this, arguments);
  19064. }
  19065. return isCurrentAsync;
  19066. }()
  19067. /**
  19068. * Returns get("username").
  19069. *
  19070. * @returns {string}
  19071. */
  19072. }, {
  19073. key: "getUsername",
  19074. value: function getUsername()
  19075. /*: ?string*/
  19076. {
  19077. var username = this.get('username');
  19078. if (username == null || typeof username === 'string') {
  19079. return username;
  19080. }
  19081. return '';
  19082. }
  19083. /**
  19084. * Calls set("username", username, options) and returns the result.
  19085. *
  19086. * @param {string} username
  19087. */
  19088. }, {
  19089. key: "setUsername",
  19090. value: function setUsername(username
  19091. /*: string*/
  19092. ) {
  19093. // Strip anonymity
  19094. var authData = this.get('authData');
  19095. if (authData && (0, _typeof2.default)(authData) === 'object' && authData.hasOwnProperty('anonymous')) {
  19096. // We need to set anonymous to null instead of deleting it in order to remove it from Parse.
  19097. authData.anonymous = null;
  19098. }
  19099. this.set('username', username);
  19100. }
  19101. /**
  19102. * Calls set("password", password, options) and returns the result.
  19103. *
  19104. * @param {string} password User's Password
  19105. */
  19106. }, {
  19107. key: "setPassword",
  19108. value: function setPassword(password
  19109. /*: string*/
  19110. ) {
  19111. this.set('password', password);
  19112. }
  19113. /**
  19114. * Returns get("email").
  19115. *
  19116. * @returns {string} User's Email
  19117. */
  19118. }, {
  19119. key: "getEmail",
  19120. value: function getEmail()
  19121. /*: ?string*/
  19122. {
  19123. var email = this.get('email');
  19124. if (email == null || typeof email === 'string') {
  19125. return email;
  19126. }
  19127. return '';
  19128. }
  19129. /**
  19130. * Calls set("email", email) and returns the result.
  19131. *
  19132. * @param {string} email
  19133. * @returns {boolean}
  19134. */
  19135. }, {
  19136. key: "setEmail",
  19137. value: function setEmail(email
  19138. /*: string*/
  19139. ) {
  19140. return this.set('email', email);
  19141. }
  19142. /**
  19143. * Returns the session token for this user, if the user has been logged in,
  19144. * or if it is the result of a query with the master key. Otherwise, returns
  19145. * undefined.
  19146. *
  19147. * @returns {string} the session token, or undefined
  19148. */
  19149. }, {
  19150. key: "getSessionToken",
  19151. value: function getSessionToken()
  19152. /*: ?string*/
  19153. {
  19154. var token = this.get('sessionToken');
  19155. if (token == null || typeof token === 'string') {
  19156. return token;
  19157. }
  19158. return '';
  19159. }
  19160. /**
  19161. * Checks whether this user is the current user and has been authenticated.
  19162. *
  19163. * @returns {boolean} whether this user is the current user and is logged in.
  19164. */
  19165. }, {
  19166. key: "authenticated",
  19167. value: function authenticated()
  19168. /*: boolean*/
  19169. {
  19170. var current = ParseUser.current();
  19171. return !!this.get('sessionToken') && !!current && current.id === this.id;
  19172. }
  19173. /**
  19174. * Signs up a new user. You should call this instead of save for
  19175. * new Parse.Users. This will create a new Parse.User on the server, and
  19176. * also persist the session on disk so that you can access the user using
  19177. * <code>current</code>.
  19178. *
  19179. * <p>A username and password must be set before calling signUp.</p>
  19180. *
  19181. * @param {object} attrs Extra fields to set on the new user, or null.
  19182. * @param {object} options
  19183. * @returns {Promise} A promise that is fulfilled when the signup
  19184. * finishes.
  19185. */
  19186. }, {
  19187. key: "signUp",
  19188. value: function signUp(attrs
  19189. /*: AttributeMap*/
  19190. , options
  19191. /*:: ?: FullOptions*/
  19192. )
  19193. /*: Promise<ParseUser>*/
  19194. {
  19195. options = options || {};
  19196. var signupOptions = {};
  19197. if (options.hasOwnProperty('useMasterKey')) {
  19198. signupOptions.useMasterKey = options.useMasterKey;
  19199. }
  19200. if (options.hasOwnProperty('installationId')) {
  19201. signupOptions.installationId = options.installationId;
  19202. }
  19203. if (options.hasOwnProperty('context') && Object.prototype.toString.call(options.context) === '[object Object]') {
  19204. signupOptions.context = options.context;
  19205. }
  19206. var controller = _CoreManager.default.getUserController();
  19207. return controller.signUp(this, attrs, signupOptions);
  19208. }
  19209. /**
  19210. * Logs in a Parse.User. On success, this saves the session to disk,
  19211. * so you can retrieve the currently logged in user using
  19212. * <code>current</code>.
  19213. *
  19214. * <p>A username and password must be set before calling logIn.</p>
  19215. *
  19216. * @param {object} options
  19217. * @returns {Promise} A promise that is fulfilled with the user when
  19218. * the login is complete.
  19219. */
  19220. }, {
  19221. key: "logIn",
  19222. value: function logIn(options
  19223. /*:: ?: FullOptions*/
  19224. )
  19225. /*: Promise<ParseUser>*/
  19226. {
  19227. options = options || {};
  19228. var loginOptions = {
  19229. usePost: true
  19230. };
  19231. if (options.hasOwnProperty('useMasterKey')) {
  19232. loginOptions.useMasterKey = options.useMasterKey;
  19233. }
  19234. if (options.hasOwnProperty('installationId')) {
  19235. loginOptions.installationId = options.installationId;
  19236. }
  19237. if (options.hasOwnProperty('usePost')) {
  19238. loginOptions.usePost = options.usePost;
  19239. }
  19240. var controller = _CoreManager.default.getUserController();
  19241. return controller.logIn(this, loginOptions);
  19242. }
  19243. /**
  19244. * Wrap the default save behavior with functionality to save to local
  19245. * storage if this is current user.
  19246. *
  19247. * @param {...any} args
  19248. * @returns {Promise}
  19249. */
  19250. }, {
  19251. key: "save",
  19252. value: function () {
  19253. var _save = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2() {
  19254. var _len,
  19255. args,
  19256. _key4,
  19257. current,
  19258. _args2 = arguments;
  19259. return _regeneratorRuntime().wrap(function _callee2$(_context2) {
  19260. while (1) {
  19261. switch (_context2.prev = _context2.next) {
  19262. case 0:
  19263. for (_len = _args2.length, args = new Array(_len), _key4 = 0; _key4 < _len; _key4++) {
  19264. args[_key4] = _args2[_key4];
  19265. }
  19266. _context2.next = 3;
  19267. return (0, _get2.default)((0, _getPrototypeOf2.default)(ParseUser.prototype), "save", this).apply(this, args);
  19268. case 3:
  19269. _context2.next = 5;
  19270. return this.isCurrentAsync();
  19271. case 5:
  19272. current = _context2.sent;
  19273. if (!current) {
  19274. _context2.next = 8;
  19275. break;
  19276. }
  19277. return _context2.abrupt("return", _CoreManager.default.getUserController().updateUserOnDisk(this));
  19278. case 8:
  19279. return _context2.abrupt("return", this);
  19280. case 9:
  19281. case "end":
  19282. return _context2.stop();
  19283. }
  19284. }
  19285. }, _callee2, this);
  19286. }));
  19287. function save() {
  19288. return _save.apply(this, arguments);
  19289. }
  19290. return save;
  19291. }()
  19292. /**
  19293. * Wrap the default destroy behavior with functionality that logs out
  19294. * the current user when it is destroyed
  19295. *
  19296. * @param {...any} args
  19297. * @returns {Parse.User}
  19298. */
  19299. }, {
  19300. key: "destroy",
  19301. value: function () {
  19302. var _destroy = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3() {
  19303. var _len2,
  19304. args,
  19305. _key5,
  19306. current,
  19307. _args3 = arguments;
  19308. return _regeneratorRuntime().wrap(function _callee3$(_context3) {
  19309. while (1) {
  19310. switch (_context3.prev = _context3.next) {
  19311. case 0:
  19312. for (_len2 = _args3.length, args = new Array(_len2), _key5 = 0; _key5 < _len2; _key5++) {
  19313. args[_key5] = _args3[_key5];
  19314. }
  19315. _context3.next = 3;
  19316. return (0, _get2.default)((0, _getPrototypeOf2.default)(ParseUser.prototype), "destroy", this).apply(this, args);
  19317. case 3:
  19318. _context3.next = 5;
  19319. return this.isCurrentAsync();
  19320. case 5:
  19321. current = _context3.sent;
  19322. if (!current) {
  19323. _context3.next = 8;
  19324. break;
  19325. }
  19326. return _context3.abrupt("return", _CoreManager.default.getUserController().removeUserFromDisk());
  19327. case 8:
  19328. return _context3.abrupt("return", this);
  19329. case 9:
  19330. case "end":
  19331. return _context3.stop();
  19332. }
  19333. }
  19334. }, _callee3, this);
  19335. }));
  19336. function destroy() {
  19337. return _destroy.apply(this, arguments);
  19338. }
  19339. return destroy;
  19340. }()
  19341. /**
  19342. * Wrap the default fetch behavior with functionality to save to local
  19343. * storage if this is current user.
  19344. *
  19345. * @param {...any} args
  19346. * @returns {Parse.User}
  19347. */
  19348. }, {
  19349. key: "fetch",
  19350. value: function () {
  19351. var _fetch = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regeneratorRuntime().mark(function _callee4() {
  19352. var _len3,
  19353. args,
  19354. _key6,
  19355. current,
  19356. _args4 = arguments;
  19357. return _regeneratorRuntime().wrap(function _callee4$(_context4) {
  19358. while (1) {
  19359. switch (_context4.prev = _context4.next) {
  19360. case 0:
  19361. for (_len3 = _args4.length, args = new Array(_len3), _key6 = 0; _key6 < _len3; _key6++) {
  19362. args[_key6] = _args4[_key6];
  19363. }
  19364. _context4.next = 3;
  19365. return (0, _get2.default)((0, _getPrototypeOf2.default)(ParseUser.prototype), "fetch", this).apply(this, args);
  19366. case 3:
  19367. _context4.next = 5;
  19368. return this.isCurrentAsync();
  19369. case 5:
  19370. current = _context4.sent;
  19371. if (!current) {
  19372. _context4.next = 8;
  19373. break;
  19374. }
  19375. return _context4.abrupt("return", _CoreManager.default.getUserController().updateUserOnDisk(this));
  19376. case 8:
  19377. return _context4.abrupt("return", this);
  19378. case 9:
  19379. case "end":
  19380. return _context4.stop();
  19381. }
  19382. }
  19383. }, _callee4, this);
  19384. }));
  19385. function fetch() {
  19386. return _fetch.apply(this, arguments);
  19387. }
  19388. return fetch;
  19389. }()
  19390. /**
  19391. * Wrap the default fetchWithInclude behavior with functionality to save to local
  19392. * storage if this is current user.
  19393. *
  19394. * @param {...any} args
  19395. * @returns {Parse.User}
  19396. */
  19397. }, {
  19398. key: "fetchWithInclude",
  19399. value: function () {
  19400. var _fetchWithInclude = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regeneratorRuntime().mark(function _callee5() {
  19401. var _len4,
  19402. args,
  19403. _key7,
  19404. current,
  19405. _args5 = arguments;
  19406. return _regeneratorRuntime().wrap(function _callee5$(_context5) {
  19407. while (1) {
  19408. switch (_context5.prev = _context5.next) {
  19409. case 0:
  19410. for (_len4 = _args5.length, args = new Array(_len4), _key7 = 0; _key7 < _len4; _key7++) {
  19411. args[_key7] = _args5[_key7];
  19412. }
  19413. _context5.next = 3;
  19414. return (0, _get2.default)((0, _getPrototypeOf2.default)(ParseUser.prototype), "fetchWithInclude", this).apply(this, args);
  19415. case 3:
  19416. _context5.next = 5;
  19417. return this.isCurrentAsync();
  19418. case 5:
  19419. current = _context5.sent;
  19420. if (!current) {
  19421. _context5.next = 8;
  19422. break;
  19423. }
  19424. return _context5.abrupt("return", _CoreManager.default.getUserController().updateUserOnDisk(this));
  19425. case 8:
  19426. return _context5.abrupt("return", this);
  19427. case 9:
  19428. case "end":
  19429. return _context5.stop();
  19430. }
  19431. }
  19432. }, _callee5, this);
  19433. }));
  19434. function fetchWithInclude() {
  19435. return _fetchWithInclude.apply(this, arguments);
  19436. }
  19437. return fetchWithInclude;
  19438. }()
  19439. /**
  19440. * Verify whether a given password is the password of the current user.
  19441. *
  19442. * @param {string} password A password to be verified
  19443. * @param {object} options
  19444. * @returns {Promise} A promise that is fulfilled with a user
  19445. * when the password is correct.
  19446. */
  19447. }, {
  19448. key: "verifyPassword",
  19449. value: function verifyPassword(password
  19450. /*: string*/
  19451. , options
  19452. /*:: ?: RequestOptions*/
  19453. )
  19454. /*: Promise<ParseUser>*/
  19455. {
  19456. var username = this.getUsername() || '';
  19457. return ParseUser.verifyPassword(username, password, options);
  19458. }
  19459. }], [{
  19460. key: "readOnlyAttributes",
  19461. value: function readOnlyAttributes() {
  19462. return ['sessionToken'];
  19463. }
  19464. /**
  19465. * Adds functionality to the existing Parse.User class.
  19466. *
  19467. * @param {object} protoProps A set of properties to add to the prototype
  19468. * @param {object} classProps A set of static properties to add to the class
  19469. * @static
  19470. * @returns {Parse.User} The newly extended Parse.User class
  19471. */
  19472. }, {
  19473. key: "extend",
  19474. value: function extend(protoProps
  19475. /*: { [prop: string]: any }*/
  19476. , classProps
  19477. /*: { [prop: string]: any }*/
  19478. ) {
  19479. if (protoProps) {
  19480. for (var _prop in protoProps) {
  19481. if (_prop !== 'className') {
  19482. (0, _defineProperty.default)(ParseUser.prototype, _prop, {
  19483. value: protoProps[_prop],
  19484. enumerable: false,
  19485. writable: true,
  19486. configurable: true
  19487. });
  19488. }
  19489. }
  19490. }
  19491. if (classProps) {
  19492. for (var _prop2 in classProps) {
  19493. if (_prop2 !== 'className') {
  19494. (0, _defineProperty.default)(ParseUser, _prop2, {
  19495. value: classProps[_prop2],
  19496. enumerable: false,
  19497. writable: true,
  19498. configurable: true
  19499. });
  19500. }
  19501. }
  19502. }
  19503. return ParseUser;
  19504. }
  19505. /**
  19506. * Retrieves the currently logged in ParseUser with a valid session,
  19507. * either from memory or localStorage, if necessary.
  19508. *
  19509. * @static
  19510. * @returns {Parse.Object} The currently logged in Parse.User.
  19511. */
  19512. }, {
  19513. key: "current",
  19514. value: function current()
  19515. /*: ?ParseUser*/
  19516. {
  19517. if (!canUseCurrentUser) {
  19518. return null;
  19519. }
  19520. var controller = _CoreManager.default.getUserController();
  19521. return controller.currentUser();
  19522. }
  19523. /**
  19524. * Retrieves the currently logged in ParseUser from asynchronous Storage.
  19525. *
  19526. * @static
  19527. * @returns {Promise} A Promise that is resolved with the currently
  19528. * logged in Parse User
  19529. */
  19530. }, {
  19531. key: "currentAsync",
  19532. value: function currentAsync()
  19533. /*: Promise<?ParseUser>*/
  19534. {
  19535. if (!canUseCurrentUser) {
  19536. return _promise.default.resolve(null);
  19537. }
  19538. var controller = _CoreManager.default.getUserController();
  19539. return controller.currentUserAsync();
  19540. }
  19541. /**
  19542. * Signs up a new user with a username (or email) and password.
  19543. * This will create a new Parse.User on the server, and also persist the
  19544. * session in localStorage so that you can access the user using
  19545. * {@link #current}.
  19546. *
  19547. * @param {string} username The username (or email) to sign up with.
  19548. * @param {string} password The password to sign up with.
  19549. * @param {object} attrs Extra fields to set on the new user.
  19550. * @param {object} options
  19551. * @static
  19552. * @returns {Promise} A promise that is fulfilled with the user when
  19553. * the signup completes.
  19554. */
  19555. }, {
  19556. key: "signUp",
  19557. value: function signUp(username
  19558. /*: string*/
  19559. , password
  19560. /*: string*/
  19561. , attrs
  19562. /*: AttributeMap*/
  19563. , options
  19564. /*:: ?: FullOptions*/
  19565. ) {
  19566. attrs = attrs || {};
  19567. attrs.username = username;
  19568. attrs.password = password;
  19569. var user = new this(attrs);
  19570. return user.signUp({}, options);
  19571. }
  19572. /**
  19573. * Logs in a user with a username (or email) and password. On success, this
  19574. * saves the session to disk, so you can retrieve the currently logged in
  19575. * user using <code>current</code>.
  19576. *
  19577. * @param {string} username The username (or email) to log in with.
  19578. * @param {string} password The password to log in with.
  19579. * @param {object} options
  19580. * @static
  19581. * @returns {Promise} A promise that is fulfilled with the user when
  19582. * the login completes.
  19583. */
  19584. }, {
  19585. key: "logIn",
  19586. value: function logIn(username
  19587. /*: string*/
  19588. , password
  19589. /*: string*/
  19590. , options
  19591. /*:: ?: FullOptions*/
  19592. ) {
  19593. if (typeof username !== 'string') {
  19594. return _promise.default.reject(new _ParseError.default(_ParseError.default.OTHER_CAUSE, 'Username must be a string.'));
  19595. } else if (typeof password !== 'string') {
  19596. return _promise.default.reject(new _ParseError.default(_ParseError.default.OTHER_CAUSE, 'Password must be a string.'));
  19597. }
  19598. var user = new this();
  19599. user._finishFetch({
  19600. username: username,
  19601. password: password
  19602. });
  19603. return user.logIn(options);
  19604. }
  19605. /**
  19606. * Logs in a user with a session token. On success, this saves the session
  19607. * to disk, so you can retrieve the currently logged in user using
  19608. * <code>current</code>.
  19609. *
  19610. * @param {string} sessionToken The sessionToken to log in with.
  19611. * @param {object} options
  19612. * @static
  19613. * @returns {Promise} A promise that is fulfilled with the user when
  19614. * the login completes.
  19615. */
  19616. }, {
  19617. key: "become",
  19618. value: function become(sessionToken
  19619. /*: string*/
  19620. , options
  19621. /*:: ?: RequestOptions*/
  19622. ) {
  19623. if (!canUseCurrentUser) {
  19624. throw new Error('It is not memory-safe to become a user in a server environment');
  19625. }
  19626. options = options || {};
  19627. var becomeOptions
  19628. /*: RequestOptions*/
  19629. = {
  19630. sessionToken: sessionToken
  19631. };
  19632. if (options.hasOwnProperty('useMasterKey')) {
  19633. becomeOptions.useMasterKey = options.useMasterKey;
  19634. }
  19635. var controller = _CoreManager.default.getUserController();
  19636. var user = new this();
  19637. return controller.become(user, becomeOptions);
  19638. }
  19639. /**
  19640. * Retrieves a user with a session token.
  19641. *
  19642. * @param {string} sessionToken The sessionToken to get user with.
  19643. * @param {object} options
  19644. * @static
  19645. * @returns {Promise} A promise that is fulfilled with the user is fetched.
  19646. */
  19647. }, {
  19648. key: "me",
  19649. value: function me(sessionToken
  19650. /*: string*/
  19651. ) {
  19652. var options
  19653. /*:: ?: RequestOptions*/
  19654. = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
  19655. var controller = _CoreManager.default.getUserController();
  19656. var meOptions
  19657. /*: RequestOptions*/
  19658. = {
  19659. sessionToken: sessionToken
  19660. };
  19661. if (options.useMasterKey) {
  19662. meOptions.useMasterKey = options.useMasterKey;
  19663. }
  19664. var user = new this();
  19665. return controller.me(user, meOptions);
  19666. }
  19667. /**
  19668. * Logs in a user with a session token. On success, this saves the session
  19669. * to disk, so you can retrieve the currently logged in user using
  19670. * <code>current</code>. If there is no session token the user will not logged in.
  19671. *
  19672. * @param {object} userJSON The JSON map of the User's data
  19673. * @static
  19674. * @returns {Promise} A promise that is fulfilled with the user when
  19675. * the login completes.
  19676. */
  19677. }, {
  19678. key: "hydrate",
  19679. value: function hydrate(userJSON
  19680. /*: AttributeMap*/
  19681. ) {
  19682. var controller = _CoreManager.default.getUserController();
  19683. var user = new this();
  19684. return controller.hydrate(user, userJSON);
  19685. }
  19686. /**
  19687. * Static version of {@link https://parseplatform.org/Parse-SDK-JS/api/master/Parse.User.html#linkWith linkWith}
  19688. *
  19689. * @param provider
  19690. * @param options
  19691. * @param saveOpts
  19692. * @static
  19693. * @returns {Promise}
  19694. */
  19695. }, {
  19696. key: "logInWith",
  19697. value: function logInWith(provider
  19698. /*: any*/
  19699. , options
  19700. /*: { authData?: AuthData }*/
  19701. , saveOpts
  19702. /*:: ?: FullOptions*/
  19703. )
  19704. /*: Promise<ParseUser>*/
  19705. {
  19706. var user = new this();
  19707. return user.linkWith(provider, options, saveOpts);
  19708. }
  19709. /**
  19710. * Logs out the currently logged in user session. This will remove the
  19711. * session from disk, log out of linked services, and future calls to
  19712. * <code>current</code> will return <code>null</code>.
  19713. *
  19714. * @param {object} options
  19715. * @static
  19716. * @returns {Promise} A promise that is resolved when the session is
  19717. * destroyed on the server.
  19718. */
  19719. }, {
  19720. key: "logOut",
  19721. value: function logOut() {
  19722. var options
  19723. /*: RequestOptions*/
  19724. = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
  19725. var controller = _CoreManager.default.getUserController();
  19726. return controller.logOut(options);
  19727. }
  19728. /**
  19729. * Requests a password reset email to be sent to the specified email address
  19730. * associated with the user account. This email allows the user to securely
  19731. * reset their password on the Parse site.
  19732. *
  19733. * @param {string} email The email address associated with the user that
  19734. * forgot their password.
  19735. * @param {object} options
  19736. * @static
  19737. * @returns {Promise}
  19738. */
  19739. }, {
  19740. key: "requestPasswordReset",
  19741. value: function requestPasswordReset(email
  19742. /*: string*/
  19743. , options
  19744. /*:: ?: RequestOptions*/
  19745. ) {
  19746. options = options || {};
  19747. var requestOptions = {};
  19748. if (options.hasOwnProperty('useMasterKey')) {
  19749. requestOptions.useMasterKey = options.useMasterKey;
  19750. }
  19751. var controller = _CoreManager.default.getUserController();
  19752. return controller.requestPasswordReset(email, requestOptions);
  19753. }
  19754. /**
  19755. * Request an email verification.
  19756. *
  19757. * @param {string} email The email address associated with the user that
  19758. * needs to verify their email.
  19759. * @param {object} options
  19760. * @static
  19761. * @returns {Promise}
  19762. */
  19763. }, {
  19764. key: "requestEmailVerification",
  19765. value: function requestEmailVerification(email
  19766. /*: string*/
  19767. , options
  19768. /*:: ?: RequestOptions*/
  19769. ) {
  19770. options = options || {};
  19771. var requestOptions = {};
  19772. if (options.hasOwnProperty('useMasterKey')) {
  19773. requestOptions.useMasterKey = options.useMasterKey;
  19774. }
  19775. var controller = _CoreManager.default.getUserController();
  19776. return controller.requestEmailVerification(email, requestOptions);
  19777. }
  19778. /**
  19779. * Verify whether a given password is the password of the current user.
  19780. *
  19781. * @param {string} username A username to be used for identificaiton
  19782. * @param {string} password A password to be verified
  19783. * @param {object} options
  19784. * @static
  19785. * @returns {Promise} A promise that is fulfilled with a user
  19786. * when the password is correct.
  19787. */
  19788. }, {
  19789. key: "verifyPassword",
  19790. value: function verifyPassword(username
  19791. /*: string*/
  19792. , password
  19793. /*: string*/
  19794. , options
  19795. /*:: ?: RequestOptions*/
  19796. ) {
  19797. if (typeof username !== 'string') {
  19798. return _promise.default.reject(new _ParseError.default(_ParseError.default.OTHER_CAUSE, 'Username must be a string.'));
  19799. }
  19800. if (typeof password !== 'string') {
  19801. return _promise.default.reject(new _ParseError.default(_ParseError.default.OTHER_CAUSE, 'Password must be a string.'));
  19802. }
  19803. options = options || {};
  19804. var verificationOption = {};
  19805. if (options.hasOwnProperty('useMasterKey')) {
  19806. verificationOption.useMasterKey = options.useMasterKey;
  19807. }
  19808. var controller = _CoreManager.default.getUserController();
  19809. return controller.verifyPassword(username, password, verificationOption);
  19810. }
  19811. /**
  19812. * Allow someone to define a custom User class without className
  19813. * being rewritten to _User. The default behavior is to rewrite
  19814. * User to _User for legacy reasons. This allows developers to
  19815. * override that behavior.
  19816. *
  19817. * @param {boolean} isAllowed Whether or not to allow custom User class
  19818. * @static
  19819. */
  19820. }, {
  19821. key: "allowCustomUserClass",
  19822. value: function allowCustomUserClass(isAllowed
  19823. /*: boolean*/
  19824. ) {
  19825. _CoreManager.default.set('PERFORM_USER_REWRITE', !isAllowed);
  19826. }
  19827. /**
  19828. * Allows a legacy application to start using revocable sessions. If the
  19829. * current session token is not revocable, a request will be made for a new,
  19830. * revocable session.
  19831. * It is not necessary to call this method from cloud code unless you are
  19832. * handling user signup or login from the server side. In a cloud code call,
  19833. * this function will not attempt to upgrade the current token.
  19834. *
  19835. * @param {object} options
  19836. * @static
  19837. * @returns {Promise} A promise that is resolved when the process has
  19838. * completed. If a replacement session token is requested, the promise
  19839. * will be resolved after a new token has been fetched.
  19840. */
  19841. }, {
  19842. key: "enableRevocableSession",
  19843. value: function enableRevocableSession(options
  19844. /*:: ?: RequestOptions*/
  19845. ) {
  19846. options = options || {};
  19847. _CoreManager.default.set('FORCE_REVOCABLE_SESSION', true);
  19848. if (canUseCurrentUser) {
  19849. var current = ParseUser.current();
  19850. if (current) {
  19851. return current._upgradeToRevocableSession(options);
  19852. }
  19853. }
  19854. return _promise.default.resolve();
  19855. }
  19856. /**
  19857. * Enables the use of become or the current user in a server
  19858. * environment. These features are disabled by default, since they depend on
  19859. * global objects that are not memory-safe for most servers.
  19860. *
  19861. * @static
  19862. */
  19863. }, {
  19864. key: "enableUnsafeCurrentUser",
  19865. value: function enableUnsafeCurrentUser() {
  19866. canUseCurrentUser = true;
  19867. }
  19868. /**
  19869. * Disables the use of become or the current user in any environment.
  19870. * These features are disabled on servers by default, since they depend on
  19871. * global objects that are not memory-safe for most servers.
  19872. *
  19873. * @static
  19874. */
  19875. }, {
  19876. key: "disableUnsafeCurrentUser",
  19877. value: function disableUnsafeCurrentUser() {
  19878. canUseCurrentUser = false;
  19879. }
  19880. /**
  19881. * When registering users with {@link https://parseplatform.org/Parse-SDK-JS/api/master/Parse.User.html#linkWith linkWith} a basic auth provider
  19882. * is automatically created for you.
  19883. *
  19884. * For advanced authentication, you can register an Auth provider to
  19885. * implement custom authentication, deauthentication.
  19886. *
  19887. * @param provider
  19888. * @see {@link https://parseplatform.org/Parse-SDK-JS/api/master/AuthProvider.html AuthProvider}
  19889. * @see {@link https://docs.parseplatform.org/js/guide/#custom-authentication-module Custom Authentication Module}
  19890. * @static
  19891. */
  19892. }, {
  19893. key: "_registerAuthenticationProvider",
  19894. value: function _registerAuthenticationProvider(provider
  19895. /*: any*/
  19896. ) {
  19897. authProviders[provider.getAuthType()] = provider; // Synchronize the current user with the auth provider.
  19898. ParseUser.currentAsync().then(function (current) {
  19899. if (current) {
  19900. current._synchronizeAuthData(provider.getAuthType());
  19901. }
  19902. });
  19903. }
  19904. /**
  19905. * @param provider
  19906. * @param options
  19907. * @param saveOpts
  19908. * @deprecated since 2.9.0 see {@link https://parseplatform.org/Parse-SDK-JS/api/master/Parse.User.html#logInWith logInWith}
  19909. * @static
  19910. * @returns {Promise}
  19911. */
  19912. }, {
  19913. key: "_logInWith",
  19914. value: function _logInWith(provider
  19915. /*: any*/
  19916. , options
  19917. /*: { authData?: AuthData }*/
  19918. , saveOpts
  19919. /*:: ?: FullOptions*/
  19920. ) {
  19921. var user = new this();
  19922. return user.linkWith(provider, options, saveOpts);
  19923. }
  19924. }, {
  19925. key: "_clearCache",
  19926. value: function _clearCache() {
  19927. currentUserCache = null;
  19928. currentUserCacheMatchesDisk = false;
  19929. }
  19930. }, {
  19931. key: "_setCurrentUserCache",
  19932. value: function _setCurrentUserCache(user
  19933. /*: ParseUser*/
  19934. ) {
  19935. currentUserCache = user;
  19936. }
  19937. }]);
  19938. return ParseUser;
  19939. }(_ParseObject2.default);
  19940. _ParseObject2.default.registerSubclass('_User', ParseUser);
  19941. var DefaultController = {
  19942. updateUserOnDisk: function updateUserOnDisk(user) {
  19943. var path = _Storage.default.generatePath(CURRENT_USER_KEY);
  19944. var json = user.toJSON();
  19945. delete json.password;
  19946. json.className = '_User';
  19947. var userData = (0, _stringify.default)(json);
  19948. if (_CoreManager.default.get('ENCRYPTED_USER')) {
  19949. var crypto = _CoreManager.default.getCryptoController();
  19950. userData = crypto.encrypt(json, _CoreManager.default.get('ENCRYPTED_KEY'));
  19951. }
  19952. return _Storage.default.setItemAsync(path, userData).then(function () {
  19953. return user;
  19954. });
  19955. },
  19956. removeUserFromDisk: function removeUserFromDisk() {
  19957. var path = _Storage.default.generatePath(CURRENT_USER_KEY);
  19958. currentUserCacheMatchesDisk = true;
  19959. currentUserCache = null;
  19960. return _Storage.default.removeItemAsync(path);
  19961. },
  19962. setCurrentUser: function setCurrentUser(user) {
  19963. currentUserCache = user;
  19964. user._cleanupAuthData();
  19965. user._synchronizeAllAuthData();
  19966. return DefaultController.updateUserOnDisk(user);
  19967. },
  19968. currentUser: function currentUser()
  19969. /*: ?ParseUser*/
  19970. {
  19971. if (currentUserCache) {
  19972. return currentUserCache;
  19973. }
  19974. if (currentUserCacheMatchesDisk) {
  19975. return null;
  19976. }
  19977. if (_Storage.default.async()) {
  19978. throw new Error('Cannot call currentUser() when using a platform with an async ' + 'storage system. Call currentUserAsync() instead.');
  19979. }
  19980. var path = _Storage.default.generatePath(CURRENT_USER_KEY);
  19981. var userData = _Storage.default.getItem(path);
  19982. currentUserCacheMatchesDisk = true;
  19983. if (!userData) {
  19984. currentUserCache = null;
  19985. return null;
  19986. }
  19987. if (_CoreManager.default.get('ENCRYPTED_USER')) {
  19988. var crypto = _CoreManager.default.getCryptoController();
  19989. userData = crypto.decrypt(userData, _CoreManager.default.get('ENCRYPTED_KEY'));
  19990. }
  19991. userData = JSON.parse(userData);
  19992. if (!userData.className) {
  19993. userData.className = '_User';
  19994. }
  19995. if (userData._id) {
  19996. if (userData.objectId !== userData._id) {
  19997. userData.objectId = userData._id;
  19998. }
  19999. delete userData._id;
  20000. }
  20001. if (userData._sessionToken) {
  20002. userData.sessionToken = userData._sessionToken;
  20003. delete userData._sessionToken;
  20004. }
  20005. var current = _ParseObject2.default.fromJSON(userData);
  20006. currentUserCache = current;
  20007. current._synchronizeAllAuthData();
  20008. return current;
  20009. },
  20010. currentUserAsync: function currentUserAsync()
  20011. /*: Promise<?ParseUser>*/
  20012. {
  20013. if (currentUserCache) {
  20014. return _promise.default.resolve(currentUserCache);
  20015. }
  20016. if (currentUserCacheMatchesDisk) {
  20017. return _promise.default.resolve(null);
  20018. }
  20019. var path = _Storage.default.generatePath(CURRENT_USER_KEY);
  20020. return _Storage.default.getItemAsync(path).then(function (userData) {
  20021. currentUserCacheMatchesDisk = true;
  20022. if (!userData) {
  20023. currentUserCache = null;
  20024. return _promise.default.resolve(null);
  20025. }
  20026. if (_CoreManager.default.get('ENCRYPTED_USER')) {
  20027. var crypto = _CoreManager.default.getCryptoController();
  20028. userData = crypto.decrypt(userData.toString(), _CoreManager.default.get('ENCRYPTED_KEY'));
  20029. }
  20030. userData = JSON.parse(userData);
  20031. if (!userData.className) {
  20032. userData.className = '_User';
  20033. }
  20034. if (userData._id) {
  20035. if (userData.objectId !== userData._id) {
  20036. userData.objectId = userData._id;
  20037. }
  20038. delete userData._id;
  20039. }
  20040. if (userData._sessionToken) {
  20041. userData.sessionToken = userData._sessionToken;
  20042. delete userData._sessionToken;
  20043. }
  20044. var current = _ParseObject2.default.fromJSON(userData);
  20045. currentUserCache = current;
  20046. current._synchronizeAllAuthData();
  20047. return _promise.default.resolve(current);
  20048. });
  20049. },
  20050. signUp: function signUp(user
  20051. /*: ParseUser*/
  20052. , attrs
  20053. /*: AttributeMap*/
  20054. , options
  20055. /*: RequestOptions*/
  20056. )
  20057. /*: Promise<ParseUser>*/
  20058. {
  20059. var username = attrs && attrs.username || user.get('username');
  20060. var password = attrs && attrs.password || user.get('password');
  20061. if (!username || !username.length) {
  20062. return _promise.default.reject(new _ParseError.default(_ParseError.default.OTHER_CAUSE, 'Cannot sign up user with an empty username.'));
  20063. }
  20064. if (!password || !password.length) {
  20065. return _promise.default.reject(new _ParseError.default(_ParseError.default.OTHER_CAUSE, 'Cannot sign up user with an empty password.'));
  20066. }
  20067. return user.save(attrs, options).then(function () {
  20068. // Clear the password field
  20069. user._finishFetch({
  20070. password: undefined
  20071. });
  20072. if (canUseCurrentUser) {
  20073. return DefaultController.setCurrentUser(user);
  20074. }
  20075. return user;
  20076. });
  20077. },
  20078. logIn: function logIn(user
  20079. /*: ParseUser*/
  20080. , options
  20081. /*: RequestOptions*/
  20082. )
  20083. /*: Promise<ParseUser>*/
  20084. {
  20085. var RESTController = _CoreManager.default.getRESTController();
  20086. var stateController = _CoreManager.default.getObjectStateController();
  20087. var auth = {
  20088. username: user.get('username'),
  20089. password: user.get('password')
  20090. };
  20091. return RESTController.request(options.usePost ? 'POST' : 'GET', 'login', auth, options).then(function (response) {
  20092. user._migrateId(response.objectId);
  20093. user._setExisted(true);
  20094. stateController.setPendingOp(user._getStateIdentifier(), 'username', undefined);
  20095. stateController.setPendingOp(user._getStateIdentifier(), 'password', undefined);
  20096. response.password = undefined;
  20097. user._finishFetch(response);
  20098. if (!canUseCurrentUser) {
  20099. // We can't set the current user, so just return the one we logged in
  20100. return _promise.default.resolve(user);
  20101. }
  20102. return DefaultController.setCurrentUser(user);
  20103. });
  20104. },
  20105. become: function become(user
  20106. /*: ParseUser*/
  20107. , options
  20108. /*: RequestOptions*/
  20109. )
  20110. /*: Promise<ParseUser>*/
  20111. {
  20112. var RESTController = _CoreManager.default.getRESTController();
  20113. return RESTController.request('GET', 'users/me', {}, options).then(function (response) {
  20114. user._finishFetch(response);
  20115. user._setExisted(true);
  20116. return DefaultController.setCurrentUser(user);
  20117. });
  20118. },
  20119. hydrate: function hydrate(user
  20120. /*: ParseUser*/
  20121. , userJSON
  20122. /*: AttributeMap*/
  20123. )
  20124. /*: Promise<ParseUser>*/
  20125. {
  20126. user._finishFetch(userJSON);
  20127. user._setExisted(true);
  20128. if (userJSON.sessionToken && canUseCurrentUser) {
  20129. return DefaultController.setCurrentUser(user);
  20130. } else {
  20131. return _promise.default.resolve(user);
  20132. }
  20133. },
  20134. me: function me(user
  20135. /*: ParseUser*/
  20136. , options
  20137. /*: RequestOptions*/
  20138. )
  20139. /*: Promise<ParseUser>*/
  20140. {
  20141. var RESTController = _CoreManager.default.getRESTController();
  20142. return RESTController.request('GET', 'users/me', {}, options).then(function (response) {
  20143. user._finishFetch(response);
  20144. user._setExisted(true);
  20145. return user;
  20146. });
  20147. },
  20148. logOut: function logOut(options
  20149. /*: RequestOptions*/
  20150. )
  20151. /*: Promise<ParseUser>*/
  20152. {
  20153. var RESTController = _CoreManager.default.getRESTController();
  20154. if (options.sessionToken) {
  20155. return RESTController.request('POST', 'logout', {}, options);
  20156. }
  20157. return DefaultController.currentUserAsync().then(function (currentUser) {
  20158. var path = _Storage.default.generatePath(CURRENT_USER_KEY);
  20159. var promise = _Storage.default.removeItemAsync(path);
  20160. if (currentUser !== null) {
  20161. var currentSession = currentUser.getSessionToken();
  20162. if (currentSession && (0, _isRevocableSession.default)(currentSession)) {
  20163. promise = promise.then(function () {
  20164. return RESTController.request('POST', 'logout', {}, {
  20165. sessionToken: currentSession
  20166. });
  20167. });
  20168. }
  20169. currentUser._logOutWithAll();
  20170. currentUser._finishFetch({
  20171. sessionToken: undefined
  20172. });
  20173. }
  20174. currentUserCacheMatchesDisk = true;
  20175. currentUserCache = null;
  20176. return promise;
  20177. });
  20178. },
  20179. requestPasswordReset: function requestPasswordReset(email
  20180. /*: string*/
  20181. , options
  20182. /*: RequestOptions*/
  20183. ) {
  20184. var RESTController = _CoreManager.default.getRESTController();
  20185. return RESTController.request('POST', 'requestPasswordReset', {
  20186. email: email
  20187. }, options);
  20188. },
  20189. upgradeToRevocableSession: function upgradeToRevocableSession(user
  20190. /*: ParseUser*/
  20191. , options
  20192. /*: RequestOptions*/
  20193. ) {
  20194. return (0, _asyncToGenerator2.default)( /*#__PURE__*/_regeneratorRuntime().mark(function _callee6() {
  20195. var token, RESTController, result, session, current;
  20196. return _regeneratorRuntime().wrap(function _callee6$(_context6) {
  20197. while (1) {
  20198. switch (_context6.prev = _context6.next) {
  20199. case 0:
  20200. token = user.getSessionToken();
  20201. if (token) {
  20202. _context6.next = 3;
  20203. break;
  20204. }
  20205. return _context6.abrupt("return", _promise.default.reject(new _ParseError.default(_ParseError.default.SESSION_MISSING, 'Cannot upgrade a user with no session token')));
  20206. case 3:
  20207. options.sessionToken = token;
  20208. RESTController = _CoreManager.default.getRESTController();
  20209. _context6.next = 7;
  20210. return RESTController.request('POST', 'upgradeToRevocableSession', {}, options);
  20211. case 7:
  20212. result = _context6.sent;
  20213. session = new _ParseSession.default();
  20214. session._finishFetch(result);
  20215. user._finishFetch({
  20216. sessionToken: session.getSessionToken()
  20217. });
  20218. _context6.next = 13;
  20219. return user.isCurrentAsync();
  20220. case 13:
  20221. current = _context6.sent;
  20222. if (!current) {
  20223. _context6.next = 16;
  20224. break;
  20225. }
  20226. return _context6.abrupt("return", DefaultController.setCurrentUser(user));
  20227. case 16:
  20228. return _context6.abrupt("return", _promise.default.resolve(user));
  20229. case 17:
  20230. case "end":
  20231. return _context6.stop();
  20232. }
  20233. }
  20234. }, _callee6);
  20235. }))();
  20236. },
  20237. linkWith: function linkWith(user
  20238. /*: ParseUser*/
  20239. , authData
  20240. /*: AuthData*/
  20241. , options
  20242. /*: FullOptions*/
  20243. ) {
  20244. return user.save({
  20245. authData: authData
  20246. }, options).then(function () {
  20247. if (canUseCurrentUser) {
  20248. return DefaultController.setCurrentUser(user);
  20249. }
  20250. return user;
  20251. });
  20252. },
  20253. verifyPassword: function verifyPassword(username
  20254. /*: string*/
  20255. , password
  20256. /*: string*/
  20257. , options
  20258. /*: RequestOptions*/
  20259. ) {
  20260. var RESTController = _CoreManager.default.getRESTController();
  20261. return RESTController.request('GET', 'verifyPassword', {
  20262. username: username,
  20263. password: password
  20264. }, options);
  20265. },
  20266. requestEmailVerification: function requestEmailVerification(email
  20267. /*: string*/
  20268. , options
  20269. /*: RequestOptions*/
  20270. ) {
  20271. var RESTController = _CoreManager.default.getRESTController();
  20272. return RESTController.request('POST', 'verificationEmailRequest', {
  20273. email: email
  20274. }, options);
  20275. }
  20276. };
  20277. _CoreManager.default.setUserController(DefaultController);
  20278. var _default = ParseUser;
  20279. exports.default = _default;
  20280. },{"./CoreManager":4,"./ParseError":22,"./ParseObject":27,"./ParseSession":34,"./Storage":39,"./isRevocableSession":49,"@babel/runtime-corejs3/core-js-stable/instance/for-each":64,"@babel/runtime-corejs3/core-js-stable/instance/reverse":70,"@babel/runtime-corejs3/core-js-stable/instance/slice":71,"@babel/runtime-corejs3/core-js-stable/json/stringify":76,"@babel/runtime-corejs3/core-js-stable/object/create":80,"@babel/runtime-corejs3/core-js-stable/object/define-property":82,"@babel/runtime-corejs3/core-js-stable/object/get-prototype-of":88,"@babel/runtime-corejs3/core-js-stable/object/set-prototype-of":90,"@babel/runtime-corejs3/core-js-stable/promise":92,"@babel/runtime-corejs3/core-js-stable/reflect/construct":93,"@babel/runtime-corejs3/core-js-stable/symbol":97,"@babel/runtime-corejs3/helpers/asyncToGenerator":120,"@babel/runtime-corejs3/helpers/classCallCheck":121,"@babel/runtime-corejs3/helpers/createClass":123,"@babel/runtime-corejs3/helpers/get":125,"@babel/runtime-corejs3/helpers/getPrototypeOf":126,"@babel/runtime-corejs3/helpers/inherits":127,"@babel/runtime-corejs3/helpers/interopRequireDefault":128,"@babel/runtime-corejs3/helpers/possibleConstructorReturn":135,"@babel/runtime-corejs3/helpers/typeof":140}],36:[function(_dereq_,module,exports){
  20281. "use strict";
  20282. var _interopRequireDefault = _dereq_("@babel/runtime-corejs3/helpers/interopRequireDefault");
  20283. var _Object$defineProperty = _dereq_("@babel/runtime-corejs3/core-js-stable/object/define-property");
  20284. _Object$defineProperty(exports, "__esModule", {
  20285. value: true
  20286. });
  20287. exports.getPushStatus = getPushStatus;
  20288. exports.send = send;
  20289. var _typeof2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/helpers/typeof"));
  20290. var _CoreManager = _interopRequireDefault(_dereq_("./CoreManager"));
  20291. var _ParseQuery = _interopRequireDefault(_dereq_("./ParseQuery"));
  20292. /**
  20293. * Copyright (c) 2015-present, Parse, LLC.
  20294. * All rights reserved.
  20295. *
  20296. * This source code is licensed under the BSD-style license found in the
  20297. * LICENSE file in the root directory of this source tree. An additional grant
  20298. * of patent rights can be found in the PATENTS file in the same directory.
  20299. *
  20300. * @flow
  20301. */
  20302. /**
  20303. * Contains functions to deal with Push in Parse.
  20304. *
  20305. * @class Parse.Push
  20306. * @static
  20307. * @hideconstructor
  20308. */
  20309. /**
  20310. * Sends a push notification.
  20311. * **Available in Cloud Code only.**
  20312. *
  20313. * See {@link https://docs.parseplatform.org/js/guide/#push-notifications Push Notification Guide}
  20314. *
  20315. * @function send
  20316. * @name Parse.Push.send
  20317. * @param {object} data - The data of the push notification. Valid fields
  20318. * are:
  20319. * <ol>
  20320. * <li>channels - An Array of channels to push to.</li>
  20321. * <li>push_time - A Date object for when to send the push.</li>
  20322. * <li>expiration_time - A Date object for when to expire
  20323. * the push.</li>
  20324. * <li>expiration_interval - The seconds from now to expire the push.</li>
  20325. * <li>where - A Parse.Query over Parse.Installation that is used to match
  20326. * a set of installations to push to.</li>
  20327. * <li>data - The data to send as part of the push.</li>
  20328. * <ol>
  20329. * @param {object} options Valid options
  20330. * are:<ul>
  20331. * <li>useMasterKey: In Cloud Code and Node only, causes the Master Key to
  20332. * be used for this request.
  20333. * </ul>
  20334. * @returns {Promise} A promise that is fulfilled when the push request
  20335. * completes.
  20336. */
  20337. function send(data
  20338. /*: PushData*/
  20339. )
  20340. /*: Promise*/
  20341. {
  20342. var options
  20343. /*:: ?: FullOptions*/
  20344. = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
  20345. if (data.where && data.where instanceof _ParseQuery.default) {
  20346. data.where = data.where.toJSON().where;
  20347. }
  20348. if (data.push_time && (0, _typeof2.default)(data.push_time) === 'object') {
  20349. data.push_time = data.push_time.toJSON();
  20350. }
  20351. if (data.expiration_time && (0, _typeof2.default)(data.expiration_time) === 'object') {
  20352. data.expiration_time = data.expiration_time.toJSON();
  20353. }
  20354. if (data.expiration_time && data.expiration_interval) {
  20355. throw new Error('expiration_time and expiration_interval cannot both be set.');
  20356. }
  20357. var pushOptions = {
  20358. useMasterKey: true
  20359. };
  20360. if (options.hasOwnProperty('useMasterKey')) {
  20361. pushOptions.useMasterKey = options.useMasterKey;
  20362. }
  20363. return _CoreManager.default.getPushController().send(data, pushOptions);
  20364. }
  20365. /**
  20366. * Gets push status by Id
  20367. *
  20368. * @function getPushStatus
  20369. * @name Parse.Push.getPushStatus
  20370. * @param {string} pushStatusId The Id of Push Status.
  20371. * @param {object} options Valid options
  20372. * are:<ul>
  20373. * <li>useMasterKey: In Cloud Code and Node only, causes the Master Key to
  20374. * be used for this request.
  20375. * </ul>
  20376. * @returns {Parse.Object} Status of Push.
  20377. */
  20378. function getPushStatus(pushStatusId
  20379. /*: string*/
  20380. )
  20381. /*: Promise<string>*/
  20382. {
  20383. var options
  20384. /*:: ?: FullOptions*/
  20385. = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
  20386. var pushOptions = {
  20387. useMasterKey: true
  20388. };
  20389. if (options.hasOwnProperty('useMasterKey')) {
  20390. pushOptions.useMasterKey = options.useMasterKey;
  20391. }
  20392. var query = new _ParseQuery.default('_PushStatus');
  20393. return query.get(pushStatusId, pushOptions);
  20394. }
  20395. var DefaultController = {
  20396. send: function (data
  20397. /*: PushData*/
  20398. , options
  20399. /*:: ?: FullOptions*/
  20400. ) {
  20401. return _CoreManager.default.getRESTController().request('POST', 'push', data, options);
  20402. }
  20403. };
  20404. _CoreManager.default.setPushController(DefaultController);
  20405. },{"./CoreManager":4,"./ParseQuery":30,"@babel/runtime-corejs3/core-js-stable/object/define-property":82,"@babel/runtime-corejs3/helpers/interopRequireDefault":128,"@babel/runtime-corejs3/helpers/typeof":140}],37:[function(_dereq_,module,exports){
  20406. (function (process){(function (){
  20407. "use strict";
  20408. var _interopRequireDefault = _dereq_("@babel/runtime-corejs3/helpers/interopRequireDefault");
  20409. var _Object$defineProperty = _dereq_("@babel/runtime-corejs3/core-js-stable/object/define-property");
  20410. var _Object$defineProperties = _dereq_("@babel/runtime-corejs3/core-js-stable/object/define-properties");
  20411. var _Object$getOwnPropertyDescriptors = _dereq_("@babel/runtime-corejs3/core-js-stable/object/get-own-property-descriptors");
  20412. var _forEachInstanceProperty = _dereq_("@babel/runtime-corejs3/core-js-stable/instance/for-each");
  20413. var _Object$getOwnPropertyDescriptor = _dereq_("@babel/runtime-corejs3/core-js-stable/object/get-own-property-descriptor");
  20414. var _filterInstanceProperty = _dereq_("@babel/runtime-corejs3/core-js-stable/instance/filter");
  20415. var _Object$getOwnPropertySymbols = _dereq_("@babel/runtime-corejs3/core-js-stable/object/get-own-property-symbols");
  20416. var _Object$keys = _dereq_("@babel/runtime-corejs3/core-js-stable/object/keys");
  20417. var _defineProperty2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/helpers/defineProperty"));
  20418. var _typeof2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/helpers/typeof"));
  20419. var _setTimeout2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/set-timeout"));
  20420. var _includes = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/instance/includes"));
  20421. var _stringify = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/json/stringify"));
  20422. var _promise = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/promise"));
  20423. var _CoreManager = _interopRequireDefault(_dereq_("./CoreManager"));
  20424. var _ParseError = _interopRequireDefault(_dereq_("./ParseError"));
  20425. var _promiseUtils = _dereq_("./promiseUtils");
  20426. function ownKeys(object, enumerableOnly) {
  20427. var keys = _Object$keys(object);
  20428. if (_Object$getOwnPropertySymbols) {
  20429. var symbols = _Object$getOwnPropertySymbols(object);
  20430. enumerableOnly && (symbols = _filterInstanceProperty(symbols).call(symbols, function (sym) {
  20431. return _Object$getOwnPropertyDescriptor(object, sym).enumerable;
  20432. })), keys.push.apply(keys, symbols);
  20433. }
  20434. return keys;
  20435. }
  20436. function _objectSpread(target) {
  20437. for (var i = 1; i < arguments.length; i++) {
  20438. var _context4, _context5;
  20439. var source = null != arguments[i] ? arguments[i] : {};
  20440. i % 2 ? _forEachInstanceProperty(_context4 = ownKeys(Object(source), !0)).call(_context4, function (key) {
  20441. (0, _defineProperty2.default)(target, key, source[key]);
  20442. }) : _Object$getOwnPropertyDescriptors ? _Object$defineProperties(target, _Object$getOwnPropertyDescriptors(source)) : _forEachInstanceProperty(_context5 = ownKeys(Object(source))).call(_context5, function (key) {
  20443. _Object$defineProperty(target, key, _Object$getOwnPropertyDescriptor(source, key));
  20444. });
  20445. }
  20446. return target;
  20447. }
  20448. /**
  20449. * Copyright (c) 2015-present, Parse, LLC.
  20450. * All rights reserved.
  20451. *
  20452. * This source code is licensed under the BSD-style license found in the
  20453. * LICENSE file in the root directory of this source tree. An additional grant
  20454. * of patent rights can be found in the PATENTS file in the same directory.
  20455. *
  20456. * @flow
  20457. */
  20458. /* global XMLHttpRequest, XDomainRequest */
  20459. var uuidv4 = _dereq_('./uuid');
  20460. var XHR = null;
  20461. if (typeof XMLHttpRequest !== 'undefined') {
  20462. XHR = XMLHttpRequest;
  20463. }
  20464. var useXDomainRequest = false;
  20465. if (typeof XDomainRequest !== 'undefined' && !('withCredentials' in new XMLHttpRequest())) {
  20466. useXDomainRequest = true;
  20467. }
  20468. function ajaxIE9(method
  20469. /*: string*/
  20470. , url
  20471. /*: string*/
  20472. , data
  20473. /*: any*/
  20474. , headers
  20475. /*:: ?: any*/
  20476. , options
  20477. /*:: ?: FullOptions*/
  20478. ) {
  20479. return new _promise.default(function (resolve, reject) {
  20480. var xdr = new XDomainRequest();
  20481. xdr.onload = function () {
  20482. var response;
  20483. try {
  20484. response = JSON.parse(xdr.responseText);
  20485. } catch (e) {
  20486. reject(e);
  20487. }
  20488. if (response) {
  20489. resolve({
  20490. response: response
  20491. });
  20492. }
  20493. };
  20494. xdr.onerror = xdr.ontimeout = function () {
  20495. // Let's fake a real error message.
  20496. var fakeResponse = {
  20497. responseText: (0, _stringify.default)({
  20498. code: _ParseError.default.X_DOMAIN_REQUEST,
  20499. error: "IE's XDomainRequest does not supply error info."
  20500. })
  20501. };
  20502. reject(fakeResponse);
  20503. };
  20504. xdr.onprogress = function () {
  20505. if (options && typeof options.progress === 'function') {
  20506. options.progress(xdr.responseText);
  20507. }
  20508. };
  20509. xdr.open(method, url);
  20510. xdr.send(data);
  20511. if (options && typeof options.requestTask === 'function') {
  20512. options.requestTask(xdr);
  20513. }
  20514. });
  20515. }
  20516. var RESTController = {
  20517. ajax: function (method
  20518. /*: string*/
  20519. , url
  20520. /*: string*/
  20521. , data
  20522. /*: any*/
  20523. , headers
  20524. /*:: ?: any*/
  20525. , options
  20526. /*:: ?: FullOptions*/
  20527. ) {
  20528. var _context;
  20529. if (useXDomainRequest) {
  20530. return ajaxIE9(method, url, data, headers, options);
  20531. }
  20532. var promise = (0, _promiseUtils.resolvingPromise)();
  20533. var isIdempotent = _CoreManager.default.get('IDEMPOTENCY') && (0, _includes.default)(_context = ['POST', 'PUT']).call(_context, method);
  20534. var requestId = isIdempotent ? uuidv4() : '';
  20535. var attempts = 0;
  20536. (function dispatch() {
  20537. if (XHR == null) {
  20538. throw new Error('Cannot make a request: No definition of XMLHttpRequest was found.');
  20539. }
  20540. var handled = false;
  20541. var xhr = new XHR();
  20542. xhr.onreadystatechange = function () {
  20543. if (xhr.readyState !== 4 || handled || xhr._aborted) {
  20544. return;
  20545. }
  20546. handled = true;
  20547. if (xhr.status >= 200 && xhr.status < 300) {
  20548. var response;
  20549. try {
  20550. response = JSON.parse(xhr.responseText);
  20551. if (typeof xhr.getResponseHeader === 'function') {
  20552. var _context2, _context3;
  20553. if ((0, _includes.default)(_context2 = xhr.getAllResponseHeaders() || '').call(_context2, 'x-parse-job-status-id: ')) {
  20554. response = xhr.getResponseHeader('x-parse-job-status-id');
  20555. }
  20556. if ((0, _includes.default)(_context3 = xhr.getAllResponseHeaders() || '').call(_context3, 'x-parse-push-status-id: ')) {
  20557. response = xhr.getResponseHeader('x-parse-push-status-id');
  20558. }
  20559. }
  20560. } catch (e) {
  20561. promise.reject(e.toString());
  20562. }
  20563. if (response) {
  20564. promise.resolve({
  20565. response: response,
  20566. status: xhr.status,
  20567. xhr: xhr
  20568. });
  20569. }
  20570. } else if (xhr.status >= 500 || xhr.status === 0) {
  20571. // retry on 5XX or node-xmlhttprequest error
  20572. if (++attempts < _CoreManager.default.get('REQUEST_ATTEMPT_LIMIT')) {
  20573. // Exponentially-growing random delay
  20574. var delay = Math.round(Math.random() * 125 * Math.pow(2, attempts));
  20575. (0, _setTimeout2.default)(dispatch, delay);
  20576. } else if (xhr.status === 0) {
  20577. promise.reject('Unable to connect to the Parse API');
  20578. } else {
  20579. // After the retry limit is reached, fail
  20580. promise.reject(xhr);
  20581. }
  20582. } else {
  20583. promise.reject(xhr);
  20584. }
  20585. };
  20586. headers = headers || {};
  20587. if (typeof headers['Content-Type'] !== 'string') {
  20588. headers['Content-Type'] = 'text/plain'; // Avoid pre-flight
  20589. }
  20590. if (_CoreManager.default.get('IS_NODE')) {
  20591. headers['User-Agent'] = 'Parse/' + _CoreManager.default.get('VERSION') + ' (NodeJS ' + process.versions.node + ')';
  20592. }
  20593. if (isIdempotent) {
  20594. headers['X-Parse-Request-Id'] = requestId;
  20595. }
  20596. if (_CoreManager.default.get('SERVER_AUTH_TYPE') && _CoreManager.default.get('SERVER_AUTH_TOKEN')) {
  20597. headers['Authorization'] = _CoreManager.default.get('SERVER_AUTH_TYPE') + ' ' + _CoreManager.default.get('SERVER_AUTH_TOKEN');
  20598. }
  20599. var customHeaders = _CoreManager.default.get('REQUEST_HEADERS');
  20600. for (var key in customHeaders) {
  20601. headers[key] = customHeaders[key];
  20602. }
  20603. function handleProgress(type, event) {
  20604. if (options && typeof options.progress === 'function') {
  20605. if (event.lengthComputable) {
  20606. options.progress(event.loaded / event.total, event.loaded, event.total, {
  20607. type: type
  20608. });
  20609. } else {
  20610. options.progress(null, null, null, {
  20611. type: type
  20612. });
  20613. }
  20614. }
  20615. }
  20616. xhr.onprogress = function (event) {
  20617. handleProgress('download', event);
  20618. };
  20619. if (xhr.upload) {
  20620. xhr.upload.onprogress = function (event) {
  20621. handleProgress('upload', event);
  20622. };
  20623. }
  20624. xhr.open(method, url, true);
  20625. for (var h in headers) {
  20626. xhr.setRequestHeader(h, headers[h]);
  20627. }
  20628. xhr.onabort = function () {
  20629. promise.resolve({
  20630. response: {
  20631. results: []
  20632. },
  20633. status: 0,
  20634. xhr: xhr
  20635. });
  20636. };
  20637. xhr.send(data);
  20638. if (options && typeof options.requestTask === 'function') {
  20639. options.requestTask(xhr);
  20640. }
  20641. })();
  20642. return promise;
  20643. },
  20644. request: function request(method
  20645. /*: string*/
  20646. , path
  20647. /*: string*/
  20648. , data
  20649. /*: mixed*/
  20650. , options
  20651. /*:: ?: RequestOptions*/
  20652. ) {
  20653. options = options || {};
  20654. var url = _CoreManager.default.get('SERVER_URL');
  20655. if (url[url.length - 1] !== '/') {
  20656. url += '/';
  20657. }
  20658. url += path;
  20659. var payload = {};
  20660. if (data && (0, _typeof2.default)(data) === 'object') {
  20661. for (var k in data) {
  20662. payload[k] = data[k];
  20663. }
  20664. } // Add context
  20665. var context = options.context;
  20666. if (context !== undefined) {
  20667. payload._context = context;
  20668. }
  20669. if (method !== 'POST') {
  20670. payload._method = method;
  20671. method = 'POST';
  20672. }
  20673. payload._ApplicationId = _CoreManager.default.get('APPLICATION_ID');
  20674. var jsKey = _CoreManager.default.get('JAVASCRIPT_KEY');
  20675. if (jsKey) {
  20676. payload._JavaScriptKey = jsKey;
  20677. }
  20678. payload._ClientVersion = _CoreManager.default.get('VERSION');
  20679. var useMasterKey = options.useMasterKey;
  20680. if (typeof useMasterKey === 'undefined') {
  20681. useMasterKey = _CoreManager.default.get('USE_MASTER_KEY');
  20682. }
  20683. if (useMasterKey) {
  20684. if (_CoreManager.default.get('MASTER_KEY')) {
  20685. delete payload._JavaScriptKey;
  20686. payload._MasterKey = _CoreManager.default.get('MASTER_KEY');
  20687. } else {
  20688. throw new Error('Cannot use the Master Key, it has not been provided.');
  20689. }
  20690. }
  20691. if (_CoreManager.default.get('FORCE_REVOCABLE_SESSION')) {
  20692. payload._RevocableSession = '1';
  20693. }
  20694. var installationId = options.installationId;
  20695. var installationIdPromise;
  20696. if (installationId && typeof installationId === 'string') {
  20697. installationIdPromise = _promise.default.resolve(installationId);
  20698. } else {
  20699. var installationController = _CoreManager.default.getInstallationController();
  20700. installationIdPromise = installationController.currentInstallationId();
  20701. }
  20702. return installationIdPromise.then(function (iid) {
  20703. payload._InstallationId = iid;
  20704. var userController = _CoreManager.default.getUserController();
  20705. if (options && typeof options.sessionToken === 'string') {
  20706. return _promise.default.resolve(options.sessionToken);
  20707. } else if (userController) {
  20708. return userController.currentUserAsync().then(function (user) {
  20709. if (user) {
  20710. return _promise.default.resolve(user.getSessionToken());
  20711. }
  20712. return _promise.default.resolve(null);
  20713. });
  20714. }
  20715. return _promise.default.resolve(null);
  20716. }).then(function (token) {
  20717. if (token) {
  20718. payload._SessionToken = token;
  20719. }
  20720. var payloadString = (0, _stringify.default)(payload);
  20721. return RESTController.ajax(method, url, payloadString, {}, options).then(function (_ref) {
  20722. var response = _ref.response,
  20723. status = _ref.status;
  20724. if (options.returnStatus) {
  20725. return _objectSpread(_objectSpread({}, response), {}, {
  20726. _status: status
  20727. });
  20728. } else {
  20729. return response;
  20730. }
  20731. });
  20732. }).catch(RESTController.handleError);
  20733. },
  20734. handleError: function handleError(response) {
  20735. // Transform the error into an instance of ParseError by trying to parse
  20736. // the error string as JSON
  20737. var error;
  20738. if (response && response.responseText) {
  20739. try {
  20740. var errorJSON = JSON.parse(response.responseText);
  20741. error = new _ParseError.default(errorJSON.code, errorJSON.error);
  20742. } catch (e) {
  20743. // If we fail to parse the error text, that's okay.
  20744. error = new _ParseError.default(_ParseError.default.INVALID_JSON, 'Received an error with invalid JSON from Parse: ' + response.responseText);
  20745. }
  20746. } else {
  20747. var message = response.message ? response.message : response;
  20748. error = new _ParseError.default(_ParseError.default.CONNECTION_FAILED, 'XMLHttpRequest failed: ' + (0, _stringify.default)(message));
  20749. }
  20750. return _promise.default.reject(error);
  20751. },
  20752. _setXHR: function _setXHR(xhr
  20753. /*: any*/
  20754. ) {
  20755. XHR = xhr;
  20756. },
  20757. _getXHR: function _getXHR() {
  20758. return XHR;
  20759. }
  20760. };
  20761. module.exports = RESTController;
  20762. }).call(this)}).call(this,_dereq_('_process'))
  20763. },{"./CoreManager":4,"./ParseError":22,"./promiseUtils":51,"./uuid":54,"@babel/runtime-corejs3/core-js-stable/instance/filter":61,"@babel/runtime-corejs3/core-js-stable/instance/for-each":64,"@babel/runtime-corejs3/core-js-stable/instance/includes":65,"@babel/runtime-corejs3/core-js-stable/json/stringify":76,"@babel/runtime-corejs3/core-js-stable/object/define-properties":81,"@babel/runtime-corejs3/core-js-stable/object/define-property":82,"@babel/runtime-corejs3/core-js-stable/object/get-own-property-descriptor":85,"@babel/runtime-corejs3/core-js-stable/object/get-own-property-descriptors":86,"@babel/runtime-corejs3/core-js-stable/object/get-own-property-symbols":87,"@babel/runtime-corejs3/core-js-stable/object/keys":89,"@babel/runtime-corejs3/core-js-stable/promise":92,"@babel/runtime-corejs3/core-js-stable/set-timeout":95,"@babel/runtime-corejs3/helpers/defineProperty":124,"@babel/runtime-corejs3/helpers/interopRequireDefault":128,"@babel/runtime-corejs3/helpers/typeof":140,"_process":145}],38:[function(_dereq_,module,exports){
  20764. "use strict";
  20765. var _Object$getOwnPropertyDescriptor = _dereq_("@babel/runtime-corejs3/core-js-stable/object/get-own-property-descriptor");
  20766. var _Object$defineProperty = _dereq_("@babel/runtime-corejs3/core-js-stable/object/define-property");
  20767. var _typeof = _dereq_("@babel/runtime-corejs3/helpers/typeof");
  20768. var _WeakMap = _dereq_("@babel/runtime-corejs3/core-js-stable/weak-map");
  20769. _Object$defineProperty(exports, "__esModule", {
  20770. value: true
  20771. });
  20772. exports.clearAllState = clearAllState;
  20773. exports.commitServerChanges = commitServerChanges;
  20774. exports.duplicateState = duplicateState;
  20775. exports.enqueueTask = enqueueTask;
  20776. exports.estimateAttribute = estimateAttribute;
  20777. exports.estimateAttributes = estimateAttributes;
  20778. exports.getObjectCache = getObjectCache;
  20779. exports.getPendingOps = getPendingOps;
  20780. exports.getServerData = getServerData;
  20781. exports.getState = getState;
  20782. exports.initializeState = initializeState;
  20783. exports.mergeFirstPendingState = mergeFirstPendingState;
  20784. exports.popPendingState = popPendingState;
  20785. exports.pushPendingState = pushPendingState;
  20786. exports.removeState = removeState;
  20787. exports.setPendingOp = setPendingOp;
  20788. exports.setServerData = setServerData;
  20789. var ObjectStateMutations = _interopRequireWildcard(_dereq_("./ObjectStateMutations"));
  20790. function _getRequireWildcardCache(nodeInterop) {
  20791. if (typeof _WeakMap !== "function") return null;
  20792. var cacheBabelInterop = new _WeakMap();
  20793. var cacheNodeInterop = new _WeakMap();
  20794. return (_getRequireWildcardCache = function (nodeInterop) {
  20795. return nodeInterop ? cacheNodeInterop : cacheBabelInterop;
  20796. })(nodeInterop);
  20797. }
  20798. function _interopRequireWildcard(obj, nodeInterop) {
  20799. if (!nodeInterop && obj && obj.__esModule) {
  20800. return obj;
  20801. }
  20802. if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") {
  20803. return {
  20804. default: obj
  20805. };
  20806. }
  20807. var cache = _getRequireWildcardCache(nodeInterop);
  20808. if (cache && cache.has(obj)) {
  20809. return cache.get(obj);
  20810. }
  20811. var newObj = {};
  20812. for (var key in obj) {
  20813. if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) {
  20814. var desc = _Object$defineProperty && _Object$getOwnPropertyDescriptor ? _Object$getOwnPropertyDescriptor(obj, key) : null;
  20815. if (desc && (desc.get || desc.set)) {
  20816. _Object$defineProperty(newObj, key, desc);
  20817. } else {
  20818. newObj[key] = obj[key];
  20819. }
  20820. }
  20821. }
  20822. newObj.default = obj;
  20823. if (cache) {
  20824. cache.set(obj, newObj);
  20825. }
  20826. return newObj;
  20827. }
  20828. /**
  20829. * Copyright (c) 2015-present, Parse, LLC.
  20830. * All rights reserved.
  20831. *
  20832. * This source code is licensed under the BSD-style license found in the
  20833. * LICENSE file in the root directory of this source tree. An additional grant
  20834. * of patent rights can be found in the PATENTS file in the same directory.
  20835. *
  20836. * @flow
  20837. */
  20838. var objectState
  20839. /*: {
  20840. [className: string]: {
  20841. [id: string]: State,
  20842. },
  20843. }*/
  20844. = {};
  20845. function getState(obj
  20846. /*: ObjectIdentifier*/
  20847. )
  20848. /*: ?State*/
  20849. {
  20850. var classData = objectState[obj.className];
  20851. if (classData) {
  20852. return classData[obj.id] || null;
  20853. }
  20854. return null;
  20855. }
  20856. function initializeState(obj
  20857. /*: ObjectIdentifier*/
  20858. , initial
  20859. /*:: ?: State*/
  20860. )
  20861. /*: State*/
  20862. {
  20863. var state = getState(obj);
  20864. if (state) {
  20865. return state;
  20866. }
  20867. if (!objectState[obj.className]) {
  20868. objectState[obj.className] = {};
  20869. }
  20870. if (!initial) {
  20871. initial = ObjectStateMutations.defaultState();
  20872. }
  20873. state = objectState[obj.className][obj.id] = initial;
  20874. return state;
  20875. }
  20876. function removeState(obj
  20877. /*: ObjectIdentifier*/
  20878. )
  20879. /*: ?State*/
  20880. {
  20881. var state = getState(obj);
  20882. if (state === null) {
  20883. return null;
  20884. }
  20885. delete objectState[obj.className][obj.id];
  20886. return state;
  20887. }
  20888. function getServerData(obj
  20889. /*: ObjectIdentifier*/
  20890. )
  20891. /*: AttributeMap*/
  20892. {
  20893. var state = getState(obj);
  20894. if (state) {
  20895. return state.serverData;
  20896. }
  20897. return {};
  20898. }
  20899. function setServerData(obj
  20900. /*: ObjectIdentifier*/
  20901. , attributes
  20902. /*: AttributeMap*/
  20903. ) {
  20904. var serverData = initializeState(obj).serverData;
  20905. ObjectStateMutations.setServerData(serverData, attributes);
  20906. }
  20907. function getPendingOps(obj
  20908. /*: ObjectIdentifier*/
  20909. )
  20910. /*: Array<OpsMap>*/
  20911. {
  20912. var state = getState(obj);
  20913. if (state) {
  20914. return state.pendingOps;
  20915. }
  20916. return [{}];
  20917. }
  20918. function setPendingOp(obj
  20919. /*: ObjectIdentifier*/
  20920. , attr
  20921. /*: string*/
  20922. , op
  20923. /*: ?Op*/
  20924. ) {
  20925. var pendingOps = initializeState(obj).pendingOps;
  20926. ObjectStateMutations.setPendingOp(pendingOps, attr, op);
  20927. }
  20928. function pushPendingState(obj
  20929. /*: ObjectIdentifier*/
  20930. ) {
  20931. var pendingOps = initializeState(obj).pendingOps;
  20932. ObjectStateMutations.pushPendingState(pendingOps);
  20933. }
  20934. function popPendingState(obj
  20935. /*: ObjectIdentifier*/
  20936. )
  20937. /*: OpsMap*/
  20938. {
  20939. var pendingOps = initializeState(obj).pendingOps;
  20940. return ObjectStateMutations.popPendingState(pendingOps);
  20941. }
  20942. function mergeFirstPendingState(obj
  20943. /*: ObjectIdentifier*/
  20944. ) {
  20945. var pendingOps = getPendingOps(obj);
  20946. ObjectStateMutations.mergeFirstPendingState(pendingOps);
  20947. }
  20948. function getObjectCache(obj
  20949. /*: ObjectIdentifier*/
  20950. )
  20951. /*: ObjectCache*/
  20952. {
  20953. var state = getState(obj);
  20954. if (state) {
  20955. return state.objectCache;
  20956. }
  20957. return {};
  20958. }
  20959. function estimateAttribute(obj
  20960. /*: ObjectIdentifier*/
  20961. , attr
  20962. /*: string*/
  20963. )
  20964. /*: mixed*/
  20965. {
  20966. var serverData = getServerData(obj);
  20967. var pendingOps = getPendingOps(obj);
  20968. return ObjectStateMutations.estimateAttribute(serverData, pendingOps, obj.className, obj.id, attr);
  20969. }
  20970. function estimateAttributes(obj
  20971. /*: ObjectIdentifier*/
  20972. )
  20973. /*: AttributeMap*/
  20974. {
  20975. var serverData = getServerData(obj);
  20976. var pendingOps = getPendingOps(obj);
  20977. return ObjectStateMutations.estimateAttributes(serverData, pendingOps, obj.className, obj.id);
  20978. }
  20979. function commitServerChanges(obj
  20980. /*: ObjectIdentifier*/
  20981. , changes
  20982. /*: AttributeMap*/
  20983. ) {
  20984. var state = initializeState(obj);
  20985. ObjectStateMutations.commitServerChanges(state.serverData, state.objectCache, changes);
  20986. }
  20987. function enqueueTask(obj
  20988. /*: ObjectIdentifier*/
  20989. , task
  20990. /*: () => Promise*/
  20991. )
  20992. /*: Promise*/
  20993. {
  20994. var state = initializeState(obj);
  20995. return state.tasks.enqueue(task);
  20996. }
  20997. function clearAllState() {
  20998. objectState = {};
  20999. }
  21000. function duplicateState(source
  21001. /*: { id: string }*/
  21002. , dest
  21003. /*: { id: string }*/
  21004. ) {
  21005. dest.id = source.id;
  21006. }
  21007. },{"./ObjectStateMutations":16,"@babel/runtime-corejs3/core-js-stable/object/define-property":82,"@babel/runtime-corejs3/core-js-stable/object/get-own-property-descriptor":85,"@babel/runtime-corejs3/core-js-stable/weak-map":98,"@babel/runtime-corejs3/helpers/typeof":140}],39:[function(_dereq_,module,exports){
  21008. "use strict";
  21009. var _interopRequireDefault = _dereq_("@babel/runtime-corejs3/helpers/interopRequireDefault");
  21010. var _promise = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/promise"));
  21011. var _CoreManager = _interopRequireDefault(_dereq_("./CoreManager"));
  21012. /**
  21013. * Copyright (c) 2015-present, Parse, LLC.
  21014. * All rights reserved.
  21015. *
  21016. * This source code is licensed under the BSD-style license found in the
  21017. * LICENSE file in the root directory of this source tree. An additional grant
  21018. * of patent rights can be found in the PATENTS file in the same directory.
  21019. *
  21020. * @flow
  21021. */
  21022. var Storage = {
  21023. async: function ()
  21024. /*: boolean*/
  21025. {
  21026. var controller = _CoreManager.default.getStorageController();
  21027. return !!controller.async;
  21028. },
  21029. getItem: function (path
  21030. /*: string*/
  21031. )
  21032. /*: ?string*/
  21033. {
  21034. var controller = _CoreManager.default.getStorageController();
  21035. if (controller.async === 1) {
  21036. throw new Error('Synchronous storage is not supported by the current storage controller');
  21037. }
  21038. return controller.getItem(path);
  21039. },
  21040. getItemAsync: function (path
  21041. /*: string*/
  21042. )
  21043. /*: Promise<string>*/
  21044. {
  21045. var controller = _CoreManager.default.getStorageController();
  21046. if (controller.async === 1) {
  21047. return controller.getItemAsync(path);
  21048. }
  21049. return _promise.default.resolve(controller.getItem(path));
  21050. },
  21051. setItem: function (path
  21052. /*: string*/
  21053. , value
  21054. /*: string*/
  21055. )
  21056. /*: void*/
  21057. {
  21058. var controller = _CoreManager.default.getStorageController();
  21059. if (controller.async === 1) {
  21060. throw new Error('Synchronous storage is not supported by the current storage controller');
  21061. }
  21062. return controller.setItem(path, value);
  21063. },
  21064. setItemAsync: function (path
  21065. /*: string*/
  21066. , value
  21067. /*: string*/
  21068. )
  21069. /*: Promise<void>*/
  21070. {
  21071. var controller = _CoreManager.default.getStorageController();
  21072. if (controller.async === 1) {
  21073. return controller.setItemAsync(path, value);
  21074. }
  21075. return _promise.default.resolve(controller.setItem(path, value));
  21076. },
  21077. removeItem: function (path
  21078. /*: string*/
  21079. )
  21080. /*: void*/
  21081. {
  21082. var controller = _CoreManager.default.getStorageController();
  21083. if (controller.async === 1) {
  21084. throw new Error('Synchronous storage is not supported by the current storage controller');
  21085. }
  21086. return controller.removeItem(path);
  21087. },
  21088. removeItemAsync: function (path
  21089. /*: string*/
  21090. )
  21091. /*: Promise<void>*/
  21092. {
  21093. var controller = _CoreManager.default.getStorageController();
  21094. if (controller.async === 1) {
  21095. return controller.removeItemAsync(path);
  21096. }
  21097. return _promise.default.resolve(controller.removeItem(path));
  21098. },
  21099. getAllKeys: function ()
  21100. /*: Array<string>*/
  21101. {
  21102. var controller = _CoreManager.default.getStorageController();
  21103. if (controller.async === 1) {
  21104. throw new Error('Synchronous storage is not supported by the current storage controller');
  21105. }
  21106. return controller.getAllKeys();
  21107. },
  21108. getAllKeysAsync: function ()
  21109. /*: Promise<Array<string>>*/
  21110. {
  21111. var controller = _CoreManager.default.getStorageController();
  21112. if (controller.async === 1) {
  21113. return controller.getAllKeysAsync();
  21114. }
  21115. return _promise.default.resolve(controller.getAllKeys());
  21116. },
  21117. generatePath: function (path
  21118. /*: string*/
  21119. )
  21120. /*: string*/
  21121. {
  21122. if (!_CoreManager.default.get('APPLICATION_ID')) {
  21123. throw new Error('You need to call Parse.initialize before using Parse.');
  21124. }
  21125. if (typeof path !== 'string') {
  21126. throw new Error('Tried to get a Storage path that was not a String.');
  21127. }
  21128. if (path[0] === '/') {
  21129. path = path.substr(1);
  21130. }
  21131. return 'Parse/' + _CoreManager.default.get('APPLICATION_ID') + '/' + path;
  21132. },
  21133. _clear: function () {
  21134. var controller = _CoreManager.default.getStorageController();
  21135. if (controller.hasOwnProperty('clear')) {
  21136. controller.clear();
  21137. }
  21138. }
  21139. };
  21140. module.exports = Storage;
  21141. _CoreManager.default.setStorageController(_dereq_('./StorageController.browser'));
  21142. },{"./CoreManager":4,"./StorageController.browser":40,"@babel/runtime-corejs3/core-js-stable/promise":92,"@babel/runtime-corejs3/helpers/interopRequireDefault":128}],40:[function(_dereq_,module,exports){
  21143. "use strict";
  21144. /**
  21145. * Copyright (c) 2015-present, Parse, LLC.
  21146. * All rights reserved.
  21147. *
  21148. * This source code is licensed under the BSD-style license found in the
  21149. * LICENSE file in the root directory of this source tree. An additional grant
  21150. * of patent rights can be found in the PATENTS file in the same directory.
  21151. *
  21152. * @flow
  21153. * @private
  21154. */
  21155. /* global localStorage */
  21156. var StorageController = {
  21157. async: 0,
  21158. getItem: function (path
  21159. /*: string*/
  21160. )
  21161. /*: ?string*/
  21162. {
  21163. return localStorage.getItem(path);
  21164. },
  21165. setItem: function (path
  21166. /*: string*/
  21167. , value
  21168. /*: string*/
  21169. ) {
  21170. try {
  21171. localStorage.setItem(path, value);
  21172. } catch (e) {
  21173. // Quota exceeded, possibly due to Safari Private Browsing mode
  21174. console.log(e.message);
  21175. }
  21176. },
  21177. removeItem: function (path
  21178. /*: string*/
  21179. ) {
  21180. localStorage.removeItem(path);
  21181. },
  21182. getAllKeys: function () {
  21183. var keys = [];
  21184. for (var i = 0; i < localStorage.length; i += 1) {
  21185. keys.push(localStorage.key(i));
  21186. }
  21187. return keys;
  21188. },
  21189. clear: function () {
  21190. localStorage.clear();
  21191. }
  21192. };
  21193. module.exports = StorageController;
  21194. },{}],41:[function(_dereq_,module,exports){
  21195. "use strict";
  21196. var _interopRequireDefault = _dereq_("@babel/runtime-corejs3/helpers/interopRequireDefault");
  21197. var _classCallCheck2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/helpers/classCallCheck"));
  21198. var _createClass2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/helpers/createClass"));
  21199. var _defineProperty2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/helpers/defineProperty"));
  21200. var _promiseUtils = _dereq_("./promiseUtils");
  21201. /**
  21202. * Copyright (c) 2015-present, Parse, LLC.
  21203. * All rights reserved.
  21204. *
  21205. * This source code is licensed under the BSD-style license found in the
  21206. * LICENSE file in the root directory of this source tree. An additional grant
  21207. * of patent rights can be found in the PATENTS file in the same directory.
  21208. *
  21209. * @flow
  21210. */
  21211. var TaskQueue = /*#__PURE__*/function () {
  21212. function TaskQueue() {
  21213. (0, _classCallCheck2.default)(this, TaskQueue);
  21214. (0, _defineProperty2.default)(this, "queue", void 0);
  21215. this.queue = [];
  21216. }
  21217. (0, _createClass2.default)(TaskQueue, [{
  21218. key: "enqueue",
  21219. value: function (task
  21220. /*: () => Promise*/
  21221. )
  21222. /*: Promise*/
  21223. {
  21224. var _this = this;
  21225. var taskComplete = new _promiseUtils.resolvingPromise();
  21226. this.queue.push({
  21227. task: task,
  21228. _completion: taskComplete
  21229. });
  21230. if (this.queue.length === 1) {
  21231. task().then(function () {
  21232. _this._dequeue();
  21233. taskComplete.resolve();
  21234. }, function (error) {
  21235. _this._dequeue();
  21236. taskComplete.reject(error);
  21237. });
  21238. }
  21239. return taskComplete;
  21240. }
  21241. }, {
  21242. key: "_dequeue",
  21243. value: function () {
  21244. var _this2 = this;
  21245. this.queue.shift();
  21246. if (this.queue.length) {
  21247. var next = this.queue[0];
  21248. next.task().then(function () {
  21249. _this2._dequeue();
  21250. next._completion.resolve();
  21251. }, function (error) {
  21252. _this2._dequeue();
  21253. next._completion.reject(error);
  21254. });
  21255. }
  21256. }
  21257. }]);
  21258. return TaskQueue;
  21259. }();
  21260. module.exports = TaskQueue;
  21261. },{"./promiseUtils":51,"@babel/runtime-corejs3/helpers/classCallCheck":121,"@babel/runtime-corejs3/helpers/createClass":123,"@babel/runtime-corejs3/helpers/defineProperty":124,"@babel/runtime-corejs3/helpers/interopRequireDefault":128}],42:[function(_dereq_,module,exports){
  21262. "use strict";
  21263. var _interopRequireDefault = _dereq_("@babel/runtime-corejs3/helpers/interopRequireDefault");
  21264. var _Object$getOwnPropertyDescriptor = _dereq_("@babel/runtime-corejs3/core-js-stable/object/get-own-property-descriptor");
  21265. var _Object$defineProperty = _dereq_("@babel/runtime-corejs3/core-js-stable/object/define-property");
  21266. var _typeof = _dereq_("@babel/runtime-corejs3/helpers/typeof");
  21267. var _WeakMap2 = _dereq_("@babel/runtime-corejs3/core-js-stable/weak-map");
  21268. _Object$defineProperty(exports, "__esModule", {
  21269. value: true
  21270. });
  21271. exports.clearAllState = clearAllState;
  21272. exports.commitServerChanges = commitServerChanges;
  21273. exports.duplicateState = duplicateState;
  21274. exports.enqueueTask = enqueueTask;
  21275. exports.estimateAttribute = estimateAttribute;
  21276. exports.estimateAttributes = estimateAttributes;
  21277. exports.getObjectCache = getObjectCache;
  21278. exports.getPendingOps = getPendingOps;
  21279. exports.getServerData = getServerData;
  21280. exports.getState = getState;
  21281. exports.initializeState = initializeState;
  21282. exports.mergeFirstPendingState = mergeFirstPendingState;
  21283. exports.popPendingState = popPendingState;
  21284. exports.pushPendingState = pushPendingState;
  21285. exports.removeState = removeState;
  21286. exports.setPendingOp = setPendingOp;
  21287. exports.setServerData = setServerData;
  21288. var _weakMap = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/weak-map"));
  21289. var ObjectStateMutations = _interopRequireWildcard(_dereq_("./ObjectStateMutations"));
  21290. var _TaskQueue = _interopRequireDefault(_dereq_("./TaskQueue"));
  21291. function _getRequireWildcardCache(nodeInterop) {
  21292. if (typeof _WeakMap2 !== "function") return null;
  21293. var cacheBabelInterop = new _WeakMap2();
  21294. var cacheNodeInterop = new _WeakMap2();
  21295. return (_getRequireWildcardCache = function (nodeInterop) {
  21296. return nodeInterop ? cacheNodeInterop : cacheBabelInterop;
  21297. })(nodeInterop);
  21298. }
  21299. function _interopRequireWildcard(obj, nodeInterop) {
  21300. if (!nodeInterop && obj && obj.__esModule) {
  21301. return obj;
  21302. }
  21303. if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") {
  21304. return {
  21305. default: obj
  21306. };
  21307. }
  21308. var cache = _getRequireWildcardCache(nodeInterop);
  21309. if (cache && cache.has(obj)) {
  21310. return cache.get(obj);
  21311. }
  21312. var newObj = {};
  21313. for (var key in obj) {
  21314. if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) {
  21315. var desc = _Object$defineProperty && _Object$getOwnPropertyDescriptor ? _Object$getOwnPropertyDescriptor(obj, key) : null;
  21316. if (desc && (desc.get || desc.set)) {
  21317. _Object$defineProperty(newObj, key, desc);
  21318. } else {
  21319. newObj[key] = obj[key];
  21320. }
  21321. }
  21322. }
  21323. newObj.default = obj;
  21324. if (cache) {
  21325. cache.set(obj, newObj);
  21326. }
  21327. return newObj;
  21328. }
  21329. /**
  21330. * Copyright (c) 2015-present, Parse, LLC.
  21331. * All rights reserved.
  21332. *
  21333. * This source code is licensed under the BSD-style license found in the
  21334. * LICENSE file in the root directory of this source tree. An additional grant
  21335. * of patent rights can be found in the PATENTS file in the same directory.
  21336. *
  21337. * @flow
  21338. */
  21339. var objectState = new _weakMap.default();
  21340. function getState(obj
  21341. /*: ParseObject*/
  21342. )
  21343. /*: ?State*/
  21344. {
  21345. var classData = objectState.get(obj);
  21346. return classData || null;
  21347. }
  21348. function initializeState(obj
  21349. /*: ParseObject*/
  21350. , initial
  21351. /*:: ?: State*/
  21352. )
  21353. /*: State*/
  21354. {
  21355. var state = getState(obj);
  21356. if (state) {
  21357. return state;
  21358. }
  21359. if (!initial) {
  21360. initial = {
  21361. serverData: {},
  21362. pendingOps: [{}],
  21363. objectCache: {},
  21364. tasks: new _TaskQueue.default(),
  21365. existed: false
  21366. };
  21367. }
  21368. state = initial;
  21369. objectState.set(obj, state);
  21370. return state;
  21371. }
  21372. function removeState(obj
  21373. /*: ParseObject*/
  21374. )
  21375. /*: ?State*/
  21376. {
  21377. var state = getState(obj);
  21378. if (state === null) {
  21379. return null;
  21380. }
  21381. objectState.delete(obj);
  21382. return state;
  21383. }
  21384. function getServerData(obj
  21385. /*: ParseObject*/
  21386. )
  21387. /*: AttributeMap*/
  21388. {
  21389. var state = getState(obj);
  21390. if (state) {
  21391. return state.serverData;
  21392. }
  21393. return {};
  21394. }
  21395. function setServerData(obj
  21396. /*: ParseObject*/
  21397. , attributes
  21398. /*: AttributeMap*/
  21399. ) {
  21400. var serverData = initializeState(obj).serverData;
  21401. ObjectStateMutations.setServerData(serverData, attributes);
  21402. }
  21403. function getPendingOps(obj
  21404. /*: ParseObject*/
  21405. )
  21406. /*: Array<OpsMap>*/
  21407. {
  21408. var state = getState(obj);
  21409. if (state) {
  21410. return state.pendingOps;
  21411. }
  21412. return [{}];
  21413. }
  21414. function setPendingOp(obj
  21415. /*: ParseObject*/
  21416. , attr
  21417. /*: string*/
  21418. , op
  21419. /*: ?Op*/
  21420. ) {
  21421. var pendingOps = initializeState(obj).pendingOps;
  21422. ObjectStateMutations.setPendingOp(pendingOps, attr, op);
  21423. }
  21424. function pushPendingState(obj
  21425. /*: ParseObject*/
  21426. ) {
  21427. var pendingOps = initializeState(obj).pendingOps;
  21428. ObjectStateMutations.pushPendingState(pendingOps);
  21429. }
  21430. function popPendingState(obj
  21431. /*: ParseObject*/
  21432. )
  21433. /*: OpsMap*/
  21434. {
  21435. var pendingOps = initializeState(obj).pendingOps;
  21436. return ObjectStateMutations.popPendingState(pendingOps);
  21437. }
  21438. function mergeFirstPendingState(obj
  21439. /*: ParseObject*/
  21440. ) {
  21441. var pendingOps = getPendingOps(obj);
  21442. ObjectStateMutations.mergeFirstPendingState(pendingOps);
  21443. }
  21444. function getObjectCache(obj
  21445. /*: ParseObject*/
  21446. )
  21447. /*: ObjectCache*/
  21448. {
  21449. var state = getState(obj);
  21450. if (state) {
  21451. return state.objectCache;
  21452. }
  21453. return {};
  21454. }
  21455. function estimateAttribute(obj
  21456. /*: ParseObject*/
  21457. , attr
  21458. /*: string*/
  21459. )
  21460. /*: mixed*/
  21461. {
  21462. var serverData = getServerData(obj);
  21463. var pendingOps = getPendingOps(obj);
  21464. return ObjectStateMutations.estimateAttribute(serverData, pendingOps, obj.className, obj.id, attr);
  21465. }
  21466. function estimateAttributes(obj
  21467. /*: ParseObject*/
  21468. )
  21469. /*: AttributeMap*/
  21470. {
  21471. var serverData = getServerData(obj);
  21472. var pendingOps = getPendingOps(obj);
  21473. return ObjectStateMutations.estimateAttributes(serverData, pendingOps, obj.className, obj.id);
  21474. }
  21475. function commitServerChanges(obj
  21476. /*: ParseObject*/
  21477. , changes
  21478. /*: AttributeMap*/
  21479. ) {
  21480. var state = initializeState(obj);
  21481. ObjectStateMutations.commitServerChanges(state.serverData, state.objectCache, changes);
  21482. }
  21483. function enqueueTask(obj
  21484. /*: ParseObject*/
  21485. , task
  21486. /*: () => Promise*/
  21487. )
  21488. /*: Promise*/
  21489. {
  21490. var state = initializeState(obj);
  21491. return state.tasks.enqueue(task);
  21492. }
  21493. function duplicateState(source
  21494. /*: ParseObject*/
  21495. , dest
  21496. /*: ParseObject*/
  21497. )
  21498. /*: void*/
  21499. {
  21500. var oldState = initializeState(source);
  21501. var newState = initializeState(dest);
  21502. for (var key in oldState.serverData) {
  21503. newState.serverData[key] = oldState.serverData[key];
  21504. }
  21505. for (var index = 0; index < oldState.pendingOps.length; index++) {
  21506. for (var _key in oldState.pendingOps[index]) {
  21507. newState.pendingOps[index][_key] = oldState.pendingOps[index][_key];
  21508. }
  21509. }
  21510. for (var _key2 in oldState.objectCache) {
  21511. newState.objectCache[_key2] = oldState.objectCache[_key2];
  21512. }
  21513. newState.existed = oldState.existed;
  21514. }
  21515. function clearAllState() {
  21516. objectState = new _weakMap.default();
  21517. }
  21518. },{"./ObjectStateMutations":16,"./TaskQueue":41,"@babel/runtime-corejs3/core-js-stable/object/define-property":82,"@babel/runtime-corejs3/core-js-stable/object/get-own-property-descriptor":85,"@babel/runtime-corejs3/core-js-stable/weak-map":98,"@babel/runtime-corejs3/helpers/interopRequireDefault":128,"@babel/runtime-corejs3/helpers/typeof":140}],43:[function(_dereq_,module,exports){
  21519. "use strict";
  21520. var _interopRequireDefault = _dereq_("@babel/runtime-corejs3/helpers/interopRequireDefault");
  21521. var _Object$defineProperty = _dereq_("@babel/runtime-corejs3/core-js-stable/object/define-property");
  21522. _Object$defineProperty(exports, "__esModule", {
  21523. value: true
  21524. });
  21525. exports.default = arrayContainsObject;
  21526. var _indexOf = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/instance/index-of"));
  21527. var _ParseObject = _interopRequireDefault(_dereq_("./ParseObject"));
  21528. /**
  21529. * Copyright (c) 2015-present, Parse, LLC.
  21530. * All rights reserved.
  21531. *
  21532. * This source code is licensed under the BSD-style license found in the
  21533. * LICENSE file in the root directory of this source tree. An additional grant
  21534. * of patent rights can be found in the PATENTS file in the same directory.
  21535. *
  21536. * @flow
  21537. */
  21538. function arrayContainsObject(array
  21539. /*: Array<any>*/
  21540. , object
  21541. /*: ParseObject*/
  21542. )
  21543. /*: boolean*/
  21544. {
  21545. if ((0, _indexOf.default)(array).call(array, object) > -1) {
  21546. return true;
  21547. }
  21548. for (var i = 0; i < array.length; i++) {
  21549. if (array[i] instanceof _ParseObject.default && array[i].className === object.className && array[i]._getId() === object._getId()) {
  21550. return true;
  21551. }
  21552. }
  21553. return false;
  21554. }
  21555. },{"./ParseObject":27,"@babel/runtime-corejs3/core-js-stable/instance/index-of":66,"@babel/runtime-corejs3/core-js-stable/object/define-property":82,"@babel/runtime-corejs3/helpers/interopRequireDefault":128}],44:[function(_dereq_,module,exports){
  21556. "use strict";
  21557. var _interopRequireDefault = _dereq_("@babel/runtime-corejs3/helpers/interopRequireDefault");
  21558. var _Object$defineProperty = _dereq_("@babel/runtime-corejs3/core-js-stable/object/define-property");
  21559. _Object$defineProperty(exports, "__esModule", {
  21560. value: true
  21561. });
  21562. exports.default = canBeSerialized;
  21563. var _isArray = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/array/is-array"));
  21564. var _typeof2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/helpers/typeof"));
  21565. var _ParseFile = _interopRequireDefault(_dereq_("./ParseFile"));
  21566. var _ParseObject = _interopRequireDefault(_dereq_("./ParseObject"));
  21567. var _ParseRelation = _interopRequireDefault(_dereq_("./ParseRelation"));
  21568. /**
  21569. * Copyright (c) 2015-present, Parse, LLC.
  21570. * All rights reserved.
  21571. *
  21572. * This source code is licensed under the BSD-style license found in the
  21573. * LICENSE file in the root directory of this source tree. An additional grant
  21574. * of patent rights can be found in the PATENTS file in the same directory.
  21575. *
  21576. * @flow
  21577. */
  21578. function canBeSerialized(obj
  21579. /*: ParseObject*/
  21580. )
  21581. /*: boolean*/
  21582. {
  21583. if (!(obj instanceof _ParseObject.default)) {
  21584. return true;
  21585. }
  21586. var attributes = obj.attributes;
  21587. for (var attr in attributes) {
  21588. var val = attributes[attr];
  21589. if (!canBeSerializedHelper(val)) {
  21590. return false;
  21591. }
  21592. }
  21593. return true;
  21594. }
  21595. function canBeSerializedHelper(value
  21596. /*: any*/
  21597. )
  21598. /*: boolean*/
  21599. {
  21600. if ((0, _typeof2.default)(value) !== 'object') {
  21601. return true;
  21602. }
  21603. if (value instanceof _ParseRelation.default) {
  21604. return true;
  21605. }
  21606. if (value instanceof _ParseObject.default) {
  21607. return !!value.id;
  21608. }
  21609. if (value instanceof _ParseFile.default) {
  21610. if (value.url()) {
  21611. return true;
  21612. }
  21613. return false;
  21614. }
  21615. if ((0, _isArray.default)(value)) {
  21616. for (var i = 0; i < value.length; i++) {
  21617. if (!canBeSerializedHelper(value[i])) {
  21618. return false;
  21619. }
  21620. }
  21621. return true;
  21622. }
  21623. for (var k in value) {
  21624. if (!canBeSerializedHelper(value[k])) {
  21625. return false;
  21626. }
  21627. }
  21628. return true;
  21629. }
  21630. },{"./ParseFile":23,"./ParseObject":27,"./ParseRelation":31,"@babel/runtime-corejs3/core-js-stable/array/is-array":56,"@babel/runtime-corejs3/core-js-stable/object/define-property":82,"@babel/runtime-corejs3/helpers/interopRequireDefault":128,"@babel/runtime-corejs3/helpers/typeof":140}],45:[function(_dereq_,module,exports){
  21631. "use strict";
  21632. var _interopRequireDefault = _dereq_("@babel/runtime-corejs3/helpers/interopRequireDefault");
  21633. var _Object$defineProperty = _dereq_("@babel/runtime-corejs3/core-js-stable/object/define-property");
  21634. _Object$defineProperty(exports, "__esModule", {
  21635. value: true
  21636. });
  21637. exports.default = decode;
  21638. var _forEach = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/instance/for-each"));
  21639. var _isArray = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/array/is-array"));
  21640. var _typeof2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/helpers/typeof"));
  21641. var _ParseACL = _interopRequireDefault(_dereq_("./ParseACL"));
  21642. var _ParseFile = _interopRequireDefault(_dereq_("./ParseFile"));
  21643. var _ParseGeoPoint = _interopRequireDefault(_dereq_("./ParseGeoPoint"));
  21644. var _ParsePolygon = _interopRequireDefault(_dereq_("./ParsePolygon"));
  21645. var _ParseObject = _interopRequireDefault(_dereq_("./ParseObject"));
  21646. var _ParseOp = _dereq_("./ParseOp");
  21647. var _ParseRelation = _interopRequireDefault(_dereq_("./ParseRelation"));
  21648. /**
  21649. * Copyright (c) 2015-present, Parse, LLC.
  21650. * All rights reserved.
  21651. *
  21652. * This source code is licensed under the BSD-style license found in the
  21653. * LICENSE file in the root directory of this source tree. An additional grant
  21654. * of patent rights can be found in the PATENTS file in the same directory.
  21655. *
  21656. * @flow
  21657. */
  21658. // eslint-disable-line no-unused-vars
  21659. function decode(value
  21660. /*: any*/
  21661. )
  21662. /*: any*/
  21663. {
  21664. if (value === null || (0, _typeof2.default)(value) !== 'object' || value instanceof Date) {
  21665. return value;
  21666. }
  21667. if ((0, _isArray.default)(value)) {
  21668. var dup = [];
  21669. (0, _forEach.default)(value).call(value, function (v, i) {
  21670. dup[i] = decode(v);
  21671. });
  21672. return dup;
  21673. }
  21674. if (typeof value.__op === 'string') {
  21675. return (0, _ParseOp.opFromJSON)(value);
  21676. }
  21677. if (value.__type === 'Pointer' && value.className) {
  21678. return _ParseObject.default.fromJSON(value);
  21679. }
  21680. if (value.__type === 'Object' && value.className) {
  21681. return _ParseObject.default.fromJSON(value);
  21682. }
  21683. if (value.__type === 'Relation') {
  21684. // The parent and key fields will be populated by the parent
  21685. var relation = new _ParseRelation.default(null, null);
  21686. relation.targetClassName = value.className;
  21687. return relation;
  21688. }
  21689. if (value.__type === 'Date') {
  21690. return new Date(value.iso);
  21691. }
  21692. if (value.__type === 'File') {
  21693. return _ParseFile.default.fromJSON(value);
  21694. }
  21695. if (value.__type === 'GeoPoint') {
  21696. return new _ParseGeoPoint.default({
  21697. latitude: value.latitude,
  21698. longitude: value.longitude
  21699. });
  21700. }
  21701. if (value.__type === 'Polygon') {
  21702. return new _ParsePolygon.default(value.coordinates);
  21703. }
  21704. var copy = {};
  21705. for (var k in value) {
  21706. copy[k] = decode(value[k]);
  21707. }
  21708. return copy;
  21709. }
  21710. },{"./ParseACL":19,"./ParseFile":23,"./ParseGeoPoint":24,"./ParseObject":27,"./ParseOp":28,"./ParsePolygon":29,"./ParseRelation":31,"@babel/runtime-corejs3/core-js-stable/array/is-array":56,"@babel/runtime-corejs3/core-js-stable/instance/for-each":64,"@babel/runtime-corejs3/core-js-stable/object/define-property":82,"@babel/runtime-corejs3/helpers/interopRequireDefault":128,"@babel/runtime-corejs3/helpers/typeof":140}],46:[function(_dereq_,module,exports){
  21711. "use strict";
  21712. var _interopRequireDefault = _dereq_("@babel/runtime-corejs3/helpers/interopRequireDefault");
  21713. var _Object$defineProperty = _dereq_("@babel/runtime-corejs3/core-js-stable/object/define-property");
  21714. _Object$defineProperty(exports, "__esModule", {
  21715. value: true
  21716. });
  21717. exports.default = _default;
  21718. var _typeof2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/helpers/typeof"));
  21719. var _map = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/instance/map"));
  21720. var _isArray = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/array/is-array"));
  21721. var _concat = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/instance/concat"));
  21722. var _startsWith = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/instance/starts-with"));
  21723. var _keys = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/object/keys"));
  21724. var _indexOf = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/instance/index-of"));
  21725. var _ParseACL = _interopRequireDefault(_dereq_("./ParseACL"));
  21726. var _ParseFile = _interopRequireDefault(_dereq_("./ParseFile"));
  21727. var _ParseGeoPoint = _interopRequireDefault(_dereq_("./ParseGeoPoint"));
  21728. var _ParsePolygon = _interopRequireDefault(_dereq_("./ParsePolygon"));
  21729. var _ParseObject = _interopRequireDefault(_dereq_("./ParseObject"));
  21730. var _ParseOp = _dereq_("./ParseOp");
  21731. var _ParseRelation = _interopRequireDefault(_dereq_("./ParseRelation"));
  21732. /**
  21733. * Copyright (c) 2015-present, Parse, LLC.
  21734. * All rights reserved.
  21735. *
  21736. * This source code is licensed under the BSD-style license found in the
  21737. * LICENSE file in the root directory of this source tree. An additional grant
  21738. * of patent rights can be found in the PATENTS file in the same directory.
  21739. *
  21740. * @flow
  21741. */
  21742. function encode(value
  21743. /*: mixed*/
  21744. , disallowObjects
  21745. /*: boolean*/
  21746. , forcePointers
  21747. /*: boolean*/
  21748. , seen
  21749. /*: Array<mixed>*/
  21750. , offline
  21751. /*: boolean*/
  21752. )
  21753. /*: any*/
  21754. {
  21755. if (value instanceof _ParseObject.default) {
  21756. if (disallowObjects) {
  21757. throw new Error('Parse Objects not allowed here');
  21758. }
  21759. var seenEntry = value.id ? value.className + ':' + value.id : value;
  21760. if (forcePointers || !seen || (0, _indexOf.default)(seen).call(seen, seenEntry) > -1 || value.dirty() || (0, _keys.default)(value._getServerData()).length < 1) {
  21761. var _context;
  21762. if (offline && (0, _startsWith.default)(_context = value._getId()).call(_context, 'local')) {
  21763. return value.toOfflinePointer();
  21764. }
  21765. return value.toPointer();
  21766. }
  21767. seen = (0, _concat.default)(seen).call(seen, seenEntry);
  21768. return value._toFullJSON(seen, offline);
  21769. }
  21770. if (value instanceof _ParseOp.Op || value instanceof _ParseACL.default || value instanceof _ParseGeoPoint.default || value instanceof _ParsePolygon.default || value instanceof _ParseRelation.default) {
  21771. return value.toJSON();
  21772. }
  21773. if (value instanceof _ParseFile.default) {
  21774. if (!value.url()) {
  21775. throw new Error('Tried to encode an unsaved file.');
  21776. }
  21777. return value.toJSON();
  21778. }
  21779. if (Object.prototype.toString.call(value) === '[object Date]') {
  21780. if (isNaN(value)) {
  21781. throw new Error('Tried to encode an invalid date.');
  21782. }
  21783. return {
  21784. __type: 'Date',
  21785. iso: value
  21786. /*: any*/
  21787. .toJSON()
  21788. };
  21789. }
  21790. if (Object.prototype.toString.call(value) === '[object RegExp]' && typeof value.source === 'string') {
  21791. return value.source;
  21792. }
  21793. if ((0, _isArray.default)(value)) {
  21794. return (0, _map.default)(value).call(value, function (v) {
  21795. return encode(v, disallowObjects, forcePointers, seen, offline);
  21796. });
  21797. }
  21798. if (value && (0, _typeof2.default)(value) === 'object') {
  21799. var output = {};
  21800. for (var k in value) {
  21801. output[k] = encode(value[k], disallowObjects, forcePointers, seen, offline);
  21802. }
  21803. return output;
  21804. }
  21805. return value;
  21806. }
  21807. function _default(value
  21808. /*: mixed*/
  21809. , disallowObjects
  21810. /*:: ?: boolean*/
  21811. , forcePointers
  21812. /*:: ?: boolean*/
  21813. , seen
  21814. /*:: ?: Array<mixed>*/
  21815. , offline
  21816. /*:: ?: boolean*/
  21817. )
  21818. /*: any*/
  21819. {
  21820. return encode(value, !!disallowObjects, !!forcePointers, seen || [], offline);
  21821. }
  21822. },{"./ParseACL":19,"./ParseFile":23,"./ParseGeoPoint":24,"./ParseObject":27,"./ParseOp":28,"./ParsePolygon":29,"./ParseRelation":31,"@babel/runtime-corejs3/core-js-stable/array/is-array":56,"@babel/runtime-corejs3/core-js-stable/instance/concat":58,"@babel/runtime-corejs3/core-js-stable/instance/index-of":66,"@babel/runtime-corejs3/core-js-stable/instance/map":68,"@babel/runtime-corejs3/core-js-stable/instance/starts-with":74,"@babel/runtime-corejs3/core-js-stable/object/define-property":82,"@babel/runtime-corejs3/core-js-stable/object/keys":89,"@babel/runtime-corejs3/helpers/interopRequireDefault":128,"@babel/runtime-corejs3/helpers/typeof":140}],47:[function(_dereq_,module,exports){
  21823. "use strict";
  21824. var _interopRequireDefault = _dereq_("@babel/runtime-corejs3/helpers/interopRequireDefault");
  21825. var _Object$defineProperty = _dereq_("@babel/runtime-corejs3/core-js-stable/object/define-property");
  21826. _Object$defineProperty(exports, "__esModule", {
  21827. value: true
  21828. });
  21829. exports.default = equals;
  21830. var _keys = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/object/keys"));
  21831. var _isArray = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/array/is-array"));
  21832. var _typeof2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/helpers/typeof"));
  21833. var _ParseACL = _interopRequireDefault(_dereq_("./ParseACL"));
  21834. var _ParseFile = _interopRequireDefault(_dereq_("./ParseFile"));
  21835. var _ParseGeoPoint = _interopRequireDefault(_dereq_("./ParseGeoPoint"));
  21836. var _ParseObject = _interopRequireDefault(_dereq_("./ParseObject"));
  21837. /**
  21838. * Copyright (c) 2015-present, Parse, LLC.
  21839. * All rights reserved.
  21840. *
  21841. * This source code is licensed under the BSD-style license found in the
  21842. * LICENSE file in the root directory of this source tree. An additional grant
  21843. * of patent rights can be found in the PATENTS file in the same directory.
  21844. */
  21845. function equals(a, b) {
  21846. var toString = Object.prototype.toString;
  21847. if (toString.call(a) === '[object Date]' || toString.call(b) === '[object Date]') {
  21848. var dateA = new Date(a);
  21849. var dateB = new Date(b);
  21850. return +dateA === +dateB;
  21851. }
  21852. if ((0, _typeof2.default)(a) !== (0, _typeof2.default)(b)) {
  21853. return false;
  21854. }
  21855. if (!a || (0, _typeof2.default)(a) !== 'object') {
  21856. // a is a primitive
  21857. return a === b;
  21858. }
  21859. if ((0, _isArray.default)(a) || (0, _isArray.default)(b)) {
  21860. if (!(0, _isArray.default)(a) || !(0, _isArray.default)(b)) {
  21861. return false;
  21862. }
  21863. if (a.length !== b.length) {
  21864. return false;
  21865. }
  21866. for (var i = a.length; i--;) {
  21867. if (!equals(a[i], b[i])) {
  21868. return false;
  21869. }
  21870. }
  21871. return true;
  21872. }
  21873. if (a instanceof _ParseACL.default || a instanceof _ParseFile.default || a instanceof _ParseGeoPoint.default || a instanceof _ParseObject.default) {
  21874. return a.equals(b);
  21875. }
  21876. if (b instanceof _ParseObject.default) {
  21877. if (a.__type === 'Object' || a.__type === 'Pointer') {
  21878. return a.objectId === b.id && a.className === b.className;
  21879. }
  21880. }
  21881. if ((0, _keys.default)(a).length !== (0, _keys.default)(b).length) {
  21882. return false;
  21883. }
  21884. for (var k in a) {
  21885. if (!equals(a[k], b[k])) {
  21886. return false;
  21887. }
  21888. }
  21889. return true;
  21890. }
  21891. },{"./ParseACL":19,"./ParseFile":23,"./ParseGeoPoint":24,"./ParseObject":27,"@babel/runtime-corejs3/core-js-stable/array/is-array":56,"@babel/runtime-corejs3/core-js-stable/object/define-property":82,"@babel/runtime-corejs3/core-js-stable/object/keys":89,"@babel/runtime-corejs3/helpers/interopRequireDefault":128,"@babel/runtime-corejs3/helpers/typeof":140}],48:[function(_dereq_,module,exports){
  21892. "use strict";
  21893. var _Object$defineProperty = _dereq_("@babel/runtime-corejs3/core-js-stable/object/define-property");
  21894. _Object$defineProperty(exports, "__esModule", {
  21895. value: true
  21896. });
  21897. exports.default = escape;
  21898. /*
  21899. * Copyright (c) 2015-present, Parse, LLC.
  21900. * All rights reserved.
  21901. *
  21902. * This source code is licensed under the BSD-style license found in the
  21903. * LICENSE file in the root directory of this source tree. An additional grant
  21904. * of patent rights can be found in the PATENTS file in the same directory.
  21905. *
  21906. * @flow
  21907. */
  21908. var encoded = {
  21909. '&': '&amp;',
  21910. '<': '&lt;',
  21911. '>': '&gt;',
  21912. '/': '&#x2F;',
  21913. "'": '&#x27;',
  21914. '"': '&quot;'
  21915. };
  21916. function escape(str
  21917. /*: string*/
  21918. )
  21919. /*: string*/
  21920. {
  21921. return str.replace(/[&<>\/'"]/g, function (char) {
  21922. return encoded[char];
  21923. });
  21924. }
  21925. },{"@babel/runtime-corejs3/core-js-stable/object/define-property":82}],49:[function(_dereq_,module,exports){
  21926. "use strict";
  21927. var _interopRequireDefault = _dereq_("@babel/runtime-corejs3/helpers/interopRequireDefault");
  21928. var _Object$defineProperty = _dereq_("@babel/runtime-corejs3/core-js-stable/object/define-property");
  21929. _Object$defineProperty(exports, "__esModule", {
  21930. value: true
  21931. });
  21932. exports.default = isRevocableSession;
  21933. var _indexOf = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/instance/index-of"));
  21934. /**
  21935. * Copyright (c) 2015-present, Parse, LLC.
  21936. * All rights reserved.
  21937. *
  21938. * This source code is licensed under the BSD-style license found in the
  21939. * LICENSE file in the root directory of this source tree. An additional grant
  21940. * of patent rights can be found in the PATENTS file in the same directory.
  21941. *
  21942. * @flow
  21943. */
  21944. function isRevocableSession(token
  21945. /*: string*/
  21946. )
  21947. /*: boolean*/
  21948. {
  21949. return (0, _indexOf.default)(token).call(token, 'r:') > -1;
  21950. }
  21951. },{"@babel/runtime-corejs3/core-js-stable/instance/index-of":66,"@babel/runtime-corejs3/core-js-stable/object/define-property":82,"@babel/runtime-corejs3/helpers/interopRequireDefault":128}],50:[function(_dereq_,module,exports){
  21952. "use strict";
  21953. var _interopRequireDefault = _dereq_("@babel/runtime-corejs3/helpers/interopRequireDefault");
  21954. var _Object$defineProperty = _dereq_("@babel/runtime-corejs3/core-js-stable/object/define-property");
  21955. _Object$defineProperty(exports, "__esModule", {
  21956. value: true
  21957. });
  21958. exports.default = parseDate;
  21959. var _parseInt2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/parse-int"));
  21960. /**
  21961. * Copyright (c) 2015-present, Parse, LLC.
  21962. * All rights reserved.
  21963. *
  21964. * This source code is licensed under the BSD-style license found in the
  21965. * LICENSE file in the root directory of this source tree. An additional grant
  21966. * of patent rights can be found in the PATENTS file in the same directory.
  21967. *
  21968. * @flow
  21969. */
  21970. function parseDate(iso8601
  21971. /*: string*/
  21972. )
  21973. /*: ?Date*/
  21974. {
  21975. 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$');
  21976. var match = regexp.exec(iso8601);
  21977. if (!match) {
  21978. return null;
  21979. }
  21980. var year = (0, _parseInt2.default)(match[1]) || 0;
  21981. var month = ((0, _parseInt2.default)(match[2]) || 1) - 1;
  21982. var day = (0, _parseInt2.default)(match[3]) || 0;
  21983. var hour = (0, _parseInt2.default)(match[4]) || 0;
  21984. var minute = (0, _parseInt2.default)(match[5]) || 0;
  21985. var second = (0, _parseInt2.default)(match[6]) || 0;
  21986. var milli = (0, _parseInt2.default)(match[8]) || 0;
  21987. return new Date(Date.UTC(year, month, day, hour, minute, second, milli));
  21988. }
  21989. },{"@babel/runtime-corejs3/core-js-stable/object/define-property":82,"@babel/runtime-corejs3/core-js-stable/parse-int":91,"@babel/runtime-corejs3/helpers/interopRequireDefault":128}],51:[function(_dereq_,module,exports){
  21990. "use strict";
  21991. var _interopRequireDefault = _dereq_("@babel/runtime-corejs3/helpers/interopRequireDefault");
  21992. var _Object$defineProperty = _dereq_("@babel/runtime-corejs3/core-js-stable/object/define-property");
  21993. _Object$defineProperty(exports, "__esModule", {
  21994. value: true
  21995. });
  21996. exports.continueWhile = continueWhile;
  21997. exports.resolvingPromise = resolvingPromise;
  21998. exports.when = when;
  21999. var _isArray = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/array/is-array"));
  22000. var _promise = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/promise")); // Create Deferred Promise
  22001. function resolvingPromise() {
  22002. var res;
  22003. var rej;
  22004. var promise = new _promise.default(function (resolve, reject) {
  22005. res = resolve;
  22006. rej = reject;
  22007. });
  22008. promise.resolve = res;
  22009. promise.reject = rej;
  22010. return promise;
  22011. }
  22012. function when(promises) {
  22013. var objects;
  22014. var arrayArgument = (0, _isArray.default)(promises);
  22015. if (arrayArgument) {
  22016. objects = promises;
  22017. } else {
  22018. objects = arguments;
  22019. }
  22020. var total = objects.length;
  22021. var hadError = false;
  22022. var results = [];
  22023. var returnValue = arrayArgument ? [results] : results;
  22024. var errors = [];
  22025. results.length = objects.length;
  22026. errors.length = objects.length;
  22027. if (total === 0) {
  22028. return _promise.default.resolve(returnValue);
  22029. }
  22030. var promise = new resolvingPromise();
  22031. var resolveOne = function () {
  22032. total--;
  22033. if (total <= 0) {
  22034. if (hadError) {
  22035. promise.reject(errors);
  22036. } else {
  22037. promise.resolve(returnValue);
  22038. }
  22039. }
  22040. };
  22041. var chain = function (object, index) {
  22042. if (object && typeof object.then === 'function') {
  22043. object.then(function (result) {
  22044. results[index] = result;
  22045. resolveOne();
  22046. }, function (error) {
  22047. errors[index] = error;
  22048. hadError = true;
  22049. resolveOne();
  22050. });
  22051. } else {
  22052. results[index] = object;
  22053. resolveOne();
  22054. }
  22055. };
  22056. for (var i = 0; i < objects.length; i++) {
  22057. chain(objects[i], i);
  22058. }
  22059. return promise;
  22060. }
  22061. function continueWhile(test, emitter) {
  22062. if (test()) {
  22063. return emitter().then(function () {
  22064. return continueWhile(test, emitter);
  22065. });
  22066. }
  22067. return _promise.default.resolve();
  22068. }
  22069. },{"@babel/runtime-corejs3/core-js-stable/array/is-array":56,"@babel/runtime-corejs3/core-js-stable/object/define-property":82,"@babel/runtime-corejs3/core-js-stable/promise":92,"@babel/runtime-corejs3/helpers/interopRequireDefault":128}],52:[function(_dereq_,module,exports){
  22070. "use strict";
  22071. var _interopRequireDefault = _dereq_("@babel/runtime-corejs3/helpers/interopRequireDefault");
  22072. var _Object$defineProperty = _dereq_("@babel/runtime-corejs3/core-js-stable/object/define-property");
  22073. _Object$defineProperty(exports, "__esModule", {
  22074. value: true
  22075. });
  22076. exports.default = unique;
  22077. var _indexOf = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/instance/index-of"));
  22078. var _forEach = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/instance/for-each"));
  22079. var _arrayContainsObject = _interopRequireDefault(_dereq_("./arrayContainsObject"));
  22080. var _ParseObject = _interopRequireDefault(_dereq_("./ParseObject"));
  22081. /**
  22082. * Copyright (c) 2015-present, Parse, LLC.
  22083. * All rights reserved.
  22084. *
  22085. * This source code is licensed under the BSD-style license found in the
  22086. * LICENSE file in the root directory of this source tree. An additional grant
  22087. * of patent rights can be found in the PATENTS file in the same directory.
  22088. *
  22089. * @flow
  22090. */
  22091. function unique
  22092. /*:: <T>*/
  22093. (arr
  22094. /*: Array<T>*/
  22095. )
  22096. /*: Array<T>*/
  22097. {
  22098. var uniques = [];
  22099. (0, _forEach.default)(arr).call(arr, function (value) {
  22100. if (value instanceof _ParseObject.default) {
  22101. if (!(0, _arrayContainsObject.default)(uniques, value)) {
  22102. uniques.push(value);
  22103. }
  22104. } else {
  22105. if ((0, _indexOf.default)(uniques).call(uniques, value) < 0) {
  22106. uniques.push(value);
  22107. }
  22108. }
  22109. });
  22110. return uniques;
  22111. }
  22112. },{"./ParseObject":27,"./arrayContainsObject":43,"@babel/runtime-corejs3/core-js-stable/instance/for-each":64,"@babel/runtime-corejs3/core-js-stable/instance/index-of":66,"@babel/runtime-corejs3/core-js-stable/object/define-property":82,"@babel/runtime-corejs3/helpers/interopRequireDefault":128}],53:[function(_dereq_,module,exports){
  22113. "use strict";
  22114. var _interopRequireDefault = _dereq_("@babel/runtime-corejs3/helpers/interopRequireDefault");
  22115. var _Object$defineProperty = _dereq_("@babel/runtime-corejs3/core-js-stable/object/define-property");
  22116. _Object$defineProperty(exports, "__esModule", {
  22117. value: true
  22118. });
  22119. exports.default = unsavedChildren;
  22120. var _forEach = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/instance/for-each"));
  22121. var _isArray = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/array/is-array"));
  22122. var _indexOf = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/instance/index-of"));
  22123. var _concat = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/instance/concat"));
  22124. var _typeof2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/helpers/typeof"));
  22125. var _ParseFile = _interopRequireDefault(_dereq_("./ParseFile"));
  22126. var _ParseObject = _interopRequireDefault(_dereq_("./ParseObject"));
  22127. var _ParseRelation = _interopRequireDefault(_dereq_("./ParseRelation"));
  22128. /**
  22129. * Copyright (c) 2015-present, Parse, LLC.
  22130. * All rights reserved.
  22131. *
  22132. * This source code is licensed under the BSD-style license found in the
  22133. * LICENSE file in the root directory of this source tree. An additional grant
  22134. * of patent rights can be found in the PATENTS file in the same directory.
  22135. *
  22136. * @flow
  22137. */
  22138. /**
  22139. * Return an array of unsaved children, which are either Parse Objects or Files.
  22140. * If it encounters any dirty Objects without Ids, it will throw an exception.
  22141. *
  22142. * @param {Parse.Object} obj
  22143. * @param {boolean} allowDeepUnsaved
  22144. * @returns {Array}
  22145. */
  22146. function unsavedChildren(obj
  22147. /*: ParseObject*/
  22148. , allowDeepUnsaved
  22149. /*:: ?: boolean*/
  22150. )
  22151. /*: Array<ParseFile | ParseObject>*/
  22152. {
  22153. var encountered = {
  22154. objects: {},
  22155. files: []
  22156. };
  22157. var identifier = obj.className + ':' + obj._getId();
  22158. encountered.objects[identifier] = obj.dirty() ? obj : true;
  22159. var attributes = obj.attributes;
  22160. for (var attr in attributes) {
  22161. if ((0, _typeof2.default)(attributes[attr]) === 'object') {
  22162. traverse(attributes[attr], encountered, false, !!allowDeepUnsaved);
  22163. }
  22164. }
  22165. var unsaved = [];
  22166. for (var id in encountered.objects) {
  22167. if (id !== identifier && encountered.objects[id] !== true) {
  22168. unsaved.push(encountered.objects[id]);
  22169. }
  22170. }
  22171. return (0, _concat.default)(unsaved).call(unsaved, encountered.files);
  22172. }
  22173. function traverse(obj
  22174. /*: ParseObject*/
  22175. , encountered
  22176. /*: EncounterMap*/
  22177. , shouldThrow
  22178. /*: boolean*/
  22179. , allowDeepUnsaved
  22180. /*: boolean*/
  22181. ) {
  22182. if (obj instanceof _ParseObject.default) {
  22183. if (!obj.id && shouldThrow) {
  22184. throw new Error('Cannot create a pointer to an unsaved Object.');
  22185. }
  22186. var _identifier = obj.className + ':' + obj._getId();
  22187. if (!encountered.objects[_identifier]) {
  22188. encountered.objects[_identifier] = obj.dirty() ? obj : true;
  22189. var attributes = obj.attributes;
  22190. for (var attr in attributes) {
  22191. if ((0, _typeof2.default)(attributes[attr]) === 'object') {
  22192. traverse(attributes[attr], encountered, !allowDeepUnsaved, allowDeepUnsaved);
  22193. }
  22194. }
  22195. }
  22196. return;
  22197. }
  22198. if (obj instanceof _ParseFile.default) {
  22199. var _context;
  22200. if (!obj.url() && (0, _indexOf.default)(_context = encountered.files).call(_context, obj) < 0) {
  22201. encountered.files.push(obj);
  22202. }
  22203. return;
  22204. }
  22205. if (obj instanceof _ParseRelation.default) {
  22206. return;
  22207. }
  22208. if ((0, _isArray.default)(obj)) {
  22209. (0, _forEach.default)(obj).call(obj, function (el) {
  22210. if ((0, _typeof2.default)(el) === 'object') {
  22211. traverse(el, encountered, shouldThrow, allowDeepUnsaved);
  22212. }
  22213. });
  22214. }
  22215. for (var k in obj) {
  22216. if ((0, _typeof2.default)(obj[k]) === 'object') {
  22217. traverse(obj[k], encountered, shouldThrow, allowDeepUnsaved);
  22218. }
  22219. }
  22220. }
  22221. },{"./ParseFile":23,"./ParseObject":27,"./ParseRelation":31,"@babel/runtime-corejs3/core-js-stable/array/is-array":56,"@babel/runtime-corejs3/core-js-stable/instance/concat":58,"@babel/runtime-corejs3/core-js-stable/instance/for-each":64,"@babel/runtime-corejs3/core-js-stable/instance/index-of":66,"@babel/runtime-corejs3/core-js-stable/object/define-property":82,"@babel/runtime-corejs3/helpers/interopRequireDefault":128,"@babel/runtime-corejs3/helpers/typeof":140}],54:[function(_dereq_,module,exports){
  22222. "use strict";
  22223. var uuid = null;
  22224. uuid = _dereq_('uuid/v4');
  22225. module.exports = uuid;
  22226. },{"uuid/v4":610}],55:[function(_dereq_,module,exports){
  22227. module.exports = _dereq_("core-js-pure/stable/array/from");
  22228. },{"core-js-pure/stable/array/from":545}],56:[function(_dereq_,module,exports){
  22229. module.exports = _dereq_("core-js-pure/stable/array/is-array");
  22230. },{"core-js-pure/stable/array/is-array":546}],57:[function(_dereq_,module,exports){
  22231. module.exports = _dereq_("core-js-pure/stable/instance/bind");
  22232. },{"core-js-pure/stable/instance/bind":552}],58:[function(_dereq_,module,exports){
  22233. module.exports = _dereq_("core-js-pure/stable/instance/concat");
  22234. },{"core-js-pure/stable/instance/concat":553}],59:[function(_dereq_,module,exports){
  22235. module.exports = _dereq_("core-js-pure/stable/instance/entries");
  22236. },{"core-js-pure/stable/instance/entries":554}],60:[function(_dereq_,module,exports){
  22237. module.exports = _dereq_("core-js-pure/stable/instance/every");
  22238. },{"core-js-pure/stable/instance/every":555}],61:[function(_dereq_,module,exports){
  22239. module.exports = _dereq_("core-js-pure/stable/instance/filter");
  22240. },{"core-js-pure/stable/instance/filter":556}],62:[function(_dereq_,module,exports){
  22241. module.exports = _dereq_("core-js-pure/stable/instance/find-index");
  22242. },{"core-js-pure/stable/instance/find-index":557}],63:[function(_dereq_,module,exports){
  22243. module.exports = _dereq_("core-js-pure/stable/instance/find");
  22244. },{"core-js-pure/stable/instance/find":558}],64:[function(_dereq_,module,exports){
  22245. module.exports = _dereq_("core-js-pure/stable/instance/for-each");
  22246. },{"core-js-pure/stable/instance/for-each":559}],65:[function(_dereq_,module,exports){
  22247. module.exports = _dereq_("core-js-pure/stable/instance/includes");
  22248. },{"core-js-pure/stable/instance/includes":560}],66:[function(_dereq_,module,exports){
  22249. module.exports = _dereq_("core-js-pure/stable/instance/index-of");
  22250. },{"core-js-pure/stable/instance/index-of":561}],67:[function(_dereq_,module,exports){
  22251. module.exports = _dereq_("core-js-pure/stable/instance/keys");
  22252. },{"core-js-pure/stable/instance/keys":562}],68:[function(_dereq_,module,exports){
  22253. module.exports = _dereq_("core-js-pure/stable/instance/map");
  22254. },{"core-js-pure/stable/instance/map":563}],69:[function(_dereq_,module,exports){
  22255. module.exports = _dereq_("core-js-pure/stable/instance/reduce");
  22256. },{"core-js-pure/stable/instance/reduce":564}],70:[function(_dereq_,module,exports){
  22257. module.exports = _dereq_("core-js-pure/stable/instance/reverse");
  22258. },{"core-js-pure/stable/instance/reverse":565}],71:[function(_dereq_,module,exports){
  22259. module.exports = _dereq_("core-js-pure/stable/instance/slice");
  22260. },{"core-js-pure/stable/instance/slice":566}],72:[function(_dereq_,module,exports){
  22261. module.exports = _dereq_("core-js-pure/stable/instance/sort");
  22262. },{"core-js-pure/stable/instance/sort":567}],73:[function(_dereq_,module,exports){
  22263. module.exports = _dereq_("core-js-pure/stable/instance/splice");
  22264. },{"core-js-pure/stable/instance/splice":568}],74:[function(_dereq_,module,exports){
  22265. module.exports = _dereq_("core-js-pure/stable/instance/starts-with");
  22266. },{"core-js-pure/stable/instance/starts-with":569}],75:[function(_dereq_,module,exports){
  22267. module.exports = _dereq_("core-js-pure/stable/instance/values");
  22268. },{"core-js-pure/stable/instance/values":570}],76:[function(_dereq_,module,exports){
  22269. module.exports = _dereq_("core-js-pure/stable/json/stringify");
  22270. },{"core-js-pure/stable/json/stringify":571}],77:[function(_dereq_,module,exports){
  22271. module.exports = _dereq_("core-js-pure/stable/map");
  22272. },{"core-js-pure/stable/map":572}],78:[function(_dereq_,module,exports){
  22273. module.exports = _dereq_("core-js-pure/stable/number/is-integer");
  22274. },{"core-js-pure/stable/number/is-integer":573}],79:[function(_dereq_,module,exports){
  22275. module.exports = _dereq_("core-js-pure/stable/object/assign");
  22276. },{"core-js-pure/stable/object/assign":574}],80:[function(_dereq_,module,exports){
  22277. module.exports = _dereq_("core-js-pure/stable/object/create");
  22278. },{"core-js-pure/stable/object/create":575}],81:[function(_dereq_,module,exports){
  22279. module.exports = _dereq_("core-js-pure/stable/object/define-properties");
  22280. },{"core-js-pure/stable/object/define-properties":576}],82:[function(_dereq_,module,exports){
  22281. module.exports = _dereq_("core-js-pure/stable/object/define-property");
  22282. },{"core-js-pure/stable/object/define-property":577}],83:[function(_dereq_,module,exports){
  22283. module.exports = _dereq_("core-js-pure/stable/object/entries");
  22284. },{"core-js-pure/stable/object/entries":578}],84:[function(_dereq_,module,exports){
  22285. module.exports = _dereq_("core-js-pure/stable/object/freeze");
  22286. },{"core-js-pure/stable/object/freeze":579}],85:[function(_dereq_,module,exports){
  22287. module.exports = _dereq_("core-js-pure/stable/object/get-own-property-descriptor");
  22288. },{"core-js-pure/stable/object/get-own-property-descriptor":580}],86:[function(_dereq_,module,exports){
  22289. module.exports = _dereq_("core-js-pure/stable/object/get-own-property-descriptors");
  22290. },{"core-js-pure/stable/object/get-own-property-descriptors":581}],87:[function(_dereq_,module,exports){
  22291. module.exports = _dereq_("core-js-pure/stable/object/get-own-property-symbols");
  22292. },{"core-js-pure/stable/object/get-own-property-symbols":582}],88:[function(_dereq_,module,exports){
  22293. module.exports = _dereq_("core-js-pure/stable/object/get-prototype-of");
  22294. },{"core-js-pure/stable/object/get-prototype-of":583}],89:[function(_dereq_,module,exports){
  22295. module.exports = _dereq_("core-js-pure/stable/object/keys");
  22296. },{"core-js-pure/stable/object/keys":584}],90:[function(_dereq_,module,exports){
  22297. module.exports = _dereq_("core-js-pure/stable/object/set-prototype-of");
  22298. },{"core-js-pure/stable/object/set-prototype-of":585}],91:[function(_dereq_,module,exports){
  22299. module.exports = _dereq_("core-js-pure/stable/parse-int");
  22300. },{"core-js-pure/stable/parse-int":586}],92:[function(_dereq_,module,exports){
  22301. module.exports = _dereq_("core-js-pure/stable/promise");
  22302. },{"core-js-pure/stable/promise":587}],93:[function(_dereq_,module,exports){
  22303. module.exports = _dereq_("core-js-pure/stable/reflect/construct");
  22304. },{"core-js-pure/stable/reflect/construct":588}],94:[function(_dereq_,module,exports){
  22305. module.exports = _dereq_("core-js-pure/stable/set-interval");
  22306. },{"core-js-pure/stable/set-interval":590}],95:[function(_dereq_,module,exports){
  22307. module.exports = _dereq_("core-js-pure/stable/set-timeout");
  22308. },{"core-js-pure/stable/set-timeout":591}],96:[function(_dereq_,module,exports){
  22309. module.exports = _dereq_("core-js-pure/stable/set");
  22310. },{"core-js-pure/stable/set":592}],97:[function(_dereq_,module,exports){
  22311. module.exports = _dereq_("core-js-pure/stable/symbol");
  22312. },{"core-js-pure/stable/symbol":593}],98:[function(_dereq_,module,exports){
  22313. module.exports = _dereq_("core-js-pure/stable/weak-map");
  22314. },{"core-js-pure/stable/weak-map":595}],99:[function(_dereq_,module,exports){
  22315. module.exports = _dereq_("core-js-pure/features/array/from");
  22316. },{"core-js-pure/features/array/from":224}],100:[function(_dereq_,module,exports){
  22317. module.exports = _dereq_("core-js-pure/features/array/is-array");
  22318. },{"core-js-pure/features/array/is-array":225}],101:[function(_dereq_,module,exports){
  22319. module.exports = _dereq_("core-js-pure/features/get-iterator-method");
  22320. },{"core-js-pure/features/get-iterator-method":226}],102:[function(_dereq_,module,exports){
  22321. module.exports = _dereq_("core-js-pure/features/instance/bind");
  22322. },{"core-js-pure/features/instance/bind":227}],103:[function(_dereq_,module,exports){
  22323. module.exports = _dereq_("core-js-pure/features/instance/index-of");
  22324. },{"core-js-pure/features/instance/index-of":228}],104:[function(_dereq_,module,exports){
  22325. module.exports = _dereq_("core-js-pure/features/instance/slice");
  22326. },{"core-js-pure/features/instance/slice":229}],105:[function(_dereq_,module,exports){
  22327. module.exports = _dereq_("core-js-pure/features/map");
  22328. },{"core-js-pure/features/map":230}],106:[function(_dereq_,module,exports){
  22329. module.exports = _dereq_("core-js-pure/features/object/create");
  22330. },{"core-js-pure/features/object/create":231}],107:[function(_dereq_,module,exports){
  22331. module.exports = _dereq_("core-js-pure/features/object/define-property");
  22332. },{"core-js-pure/features/object/define-property":232}],108:[function(_dereq_,module,exports){
  22333. module.exports = _dereq_("core-js-pure/features/object/get-own-property-descriptor");
  22334. },{"core-js-pure/features/object/get-own-property-descriptor":233}],109:[function(_dereq_,module,exports){
  22335. module.exports = _dereq_("core-js-pure/features/object/get-prototype-of");
  22336. },{"core-js-pure/features/object/get-prototype-of":234}],110:[function(_dereq_,module,exports){
  22337. module.exports = _dereq_("core-js-pure/features/object/set-prototype-of");
  22338. },{"core-js-pure/features/object/set-prototype-of":235}],111:[function(_dereq_,module,exports){
  22339. module.exports = _dereq_("core-js-pure/features/promise");
  22340. },{"core-js-pure/features/promise":236}],112:[function(_dereq_,module,exports){
  22341. module.exports = _dereq_("core-js-pure/features/reflect/construct");
  22342. },{"core-js-pure/features/reflect/construct":237}],113:[function(_dereq_,module,exports){
  22343. module.exports = _dereq_("core-js-pure/features/reflect/get");
  22344. },{"core-js-pure/features/reflect/get":238}],114:[function(_dereq_,module,exports){
  22345. module.exports = _dereq_("core-js-pure/features/symbol");
  22346. },{"core-js-pure/features/symbol":239}],115:[function(_dereq_,module,exports){
  22347. module.exports = _dereq_("core-js-pure/features/symbol/iterator");
  22348. },{"core-js-pure/features/symbol/iterator":240}],116:[function(_dereq_,module,exports){
  22349. function _arrayLikeToArray(arr, len) {
  22350. if (len == null || len > arr.length) len = arr.length;
  22351. for (var i = 0, arr2 = new Array(len); i < len; i++) {
  22352. arr2[i] = arr[i];
  22353. }
  22354. return arr2;
  22355. }
  22356. module.exports = _arrayLikeToArray, module.exports.__esModule = true, module.exports["default"] = module.exports;
  22357. },{}],117:[function(_dereq_,module,exports){
  22358. var _Array$isArray = _dereq_("@babel/runtime-corejs3/core-js/array/is-array");
  22359. function _arrayWithHoles(arr) {
  22360. if (_Array$isArray(arr)) return arr;
  22361. }
  22362. module.exports = _arrayWithHoles, module.exports.__esModule = true, module.exports["default"] = module.exports;
  22363. },{"@babel/runtime-corejs3/core-js/array/is-array":100}],118:[function(_dereq_,module,exports){
  22364. var _Array$isArray = _dereq_("@babel/runtime-corejs3/core-js/array/is-array");
  22365. var arrayLikeToArray = _dereq_("./arrayLikeToArray.js");
  22366. function _arrayWithoutHoles(arr) {
  22367. if (_Array$isArray(arr)) return arrayLikeToArray(arr);
  22368. }
  22369. module.exports = _arrayWithoutHoles, module.exports.__esModule = true, module.exports["default"] = module.exports;
  22370. },{"./arrayLikeToArray.js":116,"@babel/runtime-corejs3/core-js/array/is-array":100}],119:[function(_dereq_,module,exports){
  22371. function _assertThisInitialized(self) {
  22372. if (self === void 0) {
  22373. throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
  22374. }
  22375. return self;
  22376. }
  22377. module.exports = _assertThisInitialized, module.exports.__esModule = true, module.exports["default"] = module.exports;
  22378. },{}],120:[function(_dereq_,module,exports){
  22379. var _Promise = _dereq_("@babel/runtime-corejs3/core-js/promise");
  22380. function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {
  22381. try {
  22382. var info = gen[key](arg);
  22383. var value = info.value;
  22384. } catch (error) {
  22385. reject(error);
  22386. return;
  22387. }
  22388. if (info.done) {
  22389. resolve(value);
  22390. } else {
  22391. _Promise.resolve(value).then(_next, _throw);
  22392. }
  22393. }
  22394. function _asyncToGenerator(fn) {
  22395. return function () {
  22396. var self = this,
  22397. args = arguments;
  22398. return new _Promise(function (resolve, reject) {
  22399. var gen = fn.apply(self, args);
  22400. function _next(value) {
  22401. asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value);
  22402. }
  22403. function _throw(err) {
  22404. asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err);
  22405. }
  22406. _next(undefined);
  22407. });
  22408. };
  22409. }
  22410. module.exports = _asyncToGenerator, module.exports.__esModule = true, module.exports["default"] = module.exports;
  22411. },{"@babel/runtime-corejs3/core-js/promise":111}],121:[function(_dereq_,module,exports){
  22412. function _classCallCheck(instance, Constructor) {
  22413. if (!(instance instanceof Constructor)) {
  22414. throw new TypeError("Cannot call a class as a function");
  22415. }
  22416. }
  22417. module.exports = _classCallCheck, module.exports.__esModule = true, module.exports["default"] = module.exports;
  22418. },{}],122:[function(_dereq_,module,exports){
  22419. var _Reflect$construct = _dereq_("@babel/runtime-corejs3/core-js/reflect/construct");
  22420. var _bindInstanceProperty = _dereq_("@babel/runtime-corejs3/core-js/instance/bind");
  22421. var setPrototypeOf = _dereq_("./setPrototypeOf.js");
  22422. var isNativeReflectConstruct = _dereq_("./isNativeReflectConstruct.js");
  22423. function _construct(Parent, args, Class) {
  22424. if (isNativeReflectConstruct()) {
  22425. module.exports = _construct = _Reflect$construct, module.exports.__esModule = true, module.exports["default"] = module.exports;
  22426. } else {
  22427. module.exports = _construct = function _construct(Parent, args, Class) {
  22428. var a = [null];
  22429. a.push.apply(a, args);
  22430. var Constructor = _bindInstanceProperty(Function).apply(Parent, a);
  22431. var instance = new Constructor();
  22432. if (Class) setPrototypeOf(instance, Class.prototype);
  22433. return instance;
  22434. }, module.exports.__esModule = true, module.exports["default"] = module.exports;
  22435. }
  22436. return _construct.apply(null, arguments);
  22437. }
  22438. module.exports = _construct, module.exports.__esModule = true, module.exports["default"] = module.exports;
  22439. },{"./isNativeReflectConstruct.js":130,"./setPrototypeOf.js":136,"@babel/runtime-corejs3/core-js/instance/bind":102,"@babel/runtime-corejs3/core-js/reflect/construct":112}],123:[function(_dereq_,module,exports){
  22440. var _Object$defineProperty = _dereq_("@babel/runtime-corejs3/core-js/object/define-property");
  22441. function _defineProperties(target, props) {
  22442. for (var i = 0; i < props.length; i++) {
  22443. var descriptor = props[i];
  22444. descriptor.enumerable = descriptor.enumerable || false;
  22445. descriptor.configurable = true;
  22446. if ("value" in descriptor) descriptor.writable = true;
  22447. _Object$defineProperty(target, descriptor.key, descriptor);
  22448. }
  22449. }
  22450. function _createClass(Constructor, protoProps, staticProps) {
  22451. if (protoProps) _defineProperties(Constructor.prototype, protoProps);
  22452. if (staticProps) _defineProperties(Constructor, staticProps);
  22453. _Object$defineProperty(Constructor, "prototype", {
  22454. writable: false
  22455. });
  22456. return Constructor;
  22457. }
  22458. module.exports = _createClass, module.exports.__esModule = true, module.exports["default"] = module.exports;
  22459. },{"@babel/runtime-corejs3/core-js/object/define-property":107}],124:[function(_dereq_,module,exports){
  22460. var _Object$defineProperty = _dereq_("@babel/runtime-corejs3/core-js/object/define-property");
  22461. function _defineProperty(obj, key, value) {
  22462. if (key in obj) {
  22463. _Object$defineProperty(obj, key, {
  22464. value: value,
  22465. enumerable: true,
  22466. configurable: true,
  22467. writable: true
  22468. });
  22469. } else {
  22470. obj[key] = value;
  22471. }
  22472. return obj;
  22473. }
  22474. module.exports = _defineProperty, module.exports.__esModule = true, module.exports["default"] = module.exports;
  22475. },{"@babel/runtime-corejs3/core-js/object/define-property":107}],125:[function(_dereq_,module,exports){
  22476. var _Reflect$get = _dereq_("@babel/runtime-corejs3/core-js/reflect/get");
  22477. var _Object$getOwnPropertyDescriptor = _dereq_("@babel/runtime-corejs3/core-js/object/get-own-property-descriptor");
  22478. var superPropBase = _dereq_("./superPropBase.js");
  22479. function _get() {
  22480. if (typeof Reflect !== "undefined" && _Reflect$get) {
  22481. module.exports = _get = _Reflect$get, module.exports.__esModule = true, module.exports["default"] = module.exports;
  22482. } else {
  22483. module.exports = _get = function _get(target, property, receiver) {
  22484. var base = superPropBase(target, property);
  22485. if (!base) return;
  22486. var desc = _Object$getOwnPropertyDescriptor(base, property);
  22487. if (desc.get) {
  22488. return desc.get.call(arguments.length < 3 ? target : receiver);
  22489. }
  22490. return desc.value;
  22491. }, module.exports.__esModule = true, module.exports["default"] = module.exports;
  22492. }
  22493. return _get.apply(this, arguments);
  22494. }
  22495. module.exports = _get, module.exports.__esModule = true, module.exports["default"] = module.exports;
  22496. },{"./superPropBase.js":138,"@babel/runtime-corejs3/core-js/object/get-own-property-descriptor":108,"@babel/runtime-corejs3/core-js/reflect/get":113}],126:[function(_dereq_,module,exports){
  22497. var _Object$setPrototypeOf = _dereq_("@babel/runtime-corejs3/core-js/object/set-prototype-of");
  22498. var _Object$getPrototypeOf = _dereq_("@babel/runtime-corejs3/core-js/object/get-prototype-of");
  22499. function _getPrototypeOf(o) {
  22500. module.exports = _getPrototypeOf = _Object$setPrototypeOf ? _Object$getPrototypeOf : function _getPrototypeOf(o) {
  22501. return o.__proto__ || _Object$getPrototypeOf(o);
  22502. }, module.exports.__esModule = true, module.exports["default"] = module.exports;
  22503. return _getPrototypeOf(o);
  22504. }
  22505. module.exports = _getPrototypeOf, module.exports.__esModule = true, module.exports["default"] = module.exports;
  22506. },{"@babel/runtime-corejs3/core-js/object/get-prototype-of":109,"@babel/runtime-corejs3/core-js/object/set-prototype-of":110}],127:[function(_dereq_,module,exports){
  22507. var _Object$create = _dereq_("@babel/runtime-corejs3/core-js/object/create");
  22508. var _Object$defineProperty = _dereq_("@babel/runtime-corejs3/core-js/object/define-property");
  22509. var setPrototypeOf = _dereq_("./setPrototypeOf.js");
  22510. function _inherits(subClass, superClass) {
  22511. if (typeof superClass !== "function" && superClass !== null) {
  22512. throw new TypeError("Super expression must either be null or a function");
  22513. }
  22514. subClass.prototype = _Object$create(superClass && superClass.prototype, {
  22515. constructor: {
  22516. value: subClass,
  22517. writable: true,
  22518. configurable: true
  22519. }
  22520. });
  22521. _Object$defineProperty(subClass, "prototype", {
  22522. writable: false
  22523. });
  22524. if (superClass) setPrototypeOf(subClass, superClass);
  22525. }
  22526. module.exports = _inherits, module.exports.__esModule = true, module.exports["default"] = module.exports;
  22527. },{"./setPrototypeOf.js":136,"@babel/runtime-corejs3/core-js/object/create":106,"@babel/runtime-corejs3/core-js/object/define-property":107}],128:[function(_dereq_,module,exports){
  22528. function _interopRequireDefault(obj) {
  22529. return obj && obj.__esModule ? obj : {
  22530. "default": obj
  22531. };
  22532. }
  22533. module.exports = _interopRequireDefault, module.exports.__esModule = true, module.exports["default"] = module.exports;
  22534. },{}],129:[function(_dereq_,module,exports){
  22535. var _indexOfInstanceProperty = _dereq_("@babel/runtime-corejs3/core-js/instance/index-of");
  22536. function _isNativeFunction(fn) {
  22537. var _context;
  22538. return _indexOfInstanceProperty(_context = Function.toString.call(fn)).call(_context, "[native code]") !== -1;
  22539. }
  22540. module.exports = _isNativeFunction, module.exports.__esModule = true, module.exports["default"] = module.exports;
  22541. },{"@babel/runtime-corejs3/core-js/instance/index-of":103}],130:[function(_dereq_,module,exports){
  22542. var _Reflect$construct = _dereq_("@babel/runtime-corejs3/core-js/reflect/construct");
  22543. function _isNativeReflectConstruct() {
  22544. if (typeof Reflect === "undefined" || !_Reflect$construct) return false;
  22545. if (_Reflect$construct.sham) return false;
  22546. if (typeof Proxy === "function") return true;
  22547. try {
  22548. Boolean.prototype.valueOf.call(_Reflect$construct(Boolean, [], function () {}));
  22549. return true;
  22550. } catch (e) {
  22551. return false;
  22552. }
  22553. }
  22554. module.exports = _isNativeReflectConstruct, module.exports.__esModule = true, module.exports["default"] = module.exports;
  22555. },{"@babel/runtime-corejs3/core-js/reflect/construct":112}],131:[function(_dereq_,module,exports){
  22556. var _Symbol = _dereq_("@babel/runtime-corejs3/core-js/symbol");
  22557. var _getIteratorMethod = _dereq_("@babel/runtime-corejs3/core-js/get-iterator-method");
  22558. var _Array$from = _dereq_("@babel/runtime-corejs3/core-js/array/from");
  22559. function _iterableToArray(iter) {
  22560. if (typeof _Symbol !== "undefined" && _getIteratorMethod(iter) != null || iter["@@iterator"] != null) return _Array$from(iter);
  22561. }
  22562. module.exports = _iterableToArray, module.exports.__esModule = true, module.exports["default"] = module.exports;
  22563. },{"@babel/runtime-corejs3/core-js/array/from":99,"@babel/runtime-corejs3/core-js/get-iterator-method":101,"@babel/runtime-corejs3/core-js/symbol":114}],132:[function(_dereq_,module,exports){
  22564. var _Symbol = _dereq_("@babel/runtime-corejs3/core-js/symbol");
  22565. var _getIteratorMethod = _dereq_("@babel/runtime-corejs3/core-js/get-iterator-method");
  22566. function _iterableToArrayLimit(arr, i) {
  22567. var _i = arr == null ? null : typeof _Symbol !== "undefined" && _getIteratorMethod(arr) || arr["@@iterator"];
  22568. if (_i == null) return;
  22569. var _arr = [];
  22570. var _n = true;
  22571. var _d = false;
  22572. var _s, _e;
  22573. try {
  22574. for (_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true) {
  22575. _arr.push(_s.value);
  22576. if (i && _arr.length === i) break;
  22577. }
  22578. } catch (err) {
  22579. _d = true;
  22580. _e = err;
  22581. } finally {
  22582. try {
  22583. if (!_n && _i["return"] != null) _i["return"]();
  22584. } finally {
  22585. if (_d) throw _e;
  22586. }
  22587. }
  22588. return _arr;
  22589. }
  22590. module.exports = _iterableToArrayLimit, module.exports.__esModule = true, module.exports["default"] = module.exports;
  22591. },{"@babel/runtime-corejs3/core-js/get-iterator-method":101,"@babel/runtime-corejs3/core-js/symbol":114}],133:[function(_dereq_,module,exports){
  22592. function _nonIterableRest() {
  22593. throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
  22594. }
  22595. module.exports = _nonIterableRest, module.exports.__esModule = true, module.exports["default"] = module.exports;
  22596. },{}],134:[function(_dereq_,module,exports){
  22597. function _nonIterableSpread() {
  22598. throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
  22599. }
  22600. module.exports = _nonIterableSpread, module.exports.__esModule = true, module.exports["default"] = module.exports;
  22601. },{}],135:[function(_dereq_,module,exports){
  22602. var _typeof = _dereq_("./typeof.js")["default"];
  22603. var assertThisInitialized = _dereq_("./assertThisInitialized.js");
  22604. function _possibleConstructorReturn(self, call) {
  22605. if (call && (_typeof(call) === "object" || typeof call === "function")) {
  22606. return call;
  22607. } else if (call !== void 0) {
  22608. throw new TypeError("Derived constructors may only return object or undefined");
  22609. }
  22610. return assertThisInitialized(self);
  22611. }
  22612. module.exports = _possibleConstructorReturn, module.exports.__esModule = true, module.exports["default"] = module.exports;
  22613. },{"./assertThisInitialized.js":119,"./typeof.js":140}],136:[function(_dereq_,module,exports){
  22614. var _Object$setPrototypeOf = _dereq_("@babel/runtime-corejs3/core-js/object/set-prototype-of");
  22615. function _setPrototypeOf(o, p) {
  22616. module.exports = _setPrototypeOf = _Object$setPrototypeOf || function _setPrototypeOf(o, p) {
  22617. o.__proto__ = p;
  22618. return o;
  22619. }, module.exports.__esModule = true, module.exports["default"] = module.exports;
  22620. return _setPrototypeOf(o, p);
  22621. }
  22622. module.exports = _setPrototypeOf, module.exports.__esModule = true, module.exports["default"] = module.exports;
  22623. },{"@babel/runtime-corejs3/core-js/object/set-prototype-of":110}],137:[function(_dereq_,module,exports){
  22624. var arrayWithHoles = _dereq_("./arrayWithHoles.js");
  22625. var iterableToArrayLimit = _dereq_("./iterableToArrayLimit.js");
  22626. var unsupportedIterableToArray = _dereq_("./unsupportedIterableToArray.js");
  22627. var nonIterableRest = _dereq_("./nonIterableRest.js");
  22628. function _slicedToArray(arr, i) {
  22629. return arrayWithHoles(arr) || iterableToArrayLimit(arr, i) || unsupportedIterableToArray(arr, i) || nonIterableRest();
  22630. }
  22631. module.exports = _slicedToArray, module.exports.__esModule = true, module.exports["default"] = module.exports;
  22632. },{"./arrayWithHoles.js":117,"./iterableToArrayLimit.js":132,"./nonIterableRest.js":133,"./unsupportedIterableToArray.js":141}],138:[function(_dereq_,module,exports){
  22633. var getPrototypeOf = _dereq_("./getPrototypeOf.js");
  22634. function _superPropBase(object, property) {
  22635. while (!Object.prototype.hasOwnProperty.call(object, property)) {
  22636. object = getPrototypeOf(object);
  22637. if (object === null) break;
  22638. }
  22639. return object;
  22640. }
  22641. module.exports = _superPropBase, module.exports.__esModule = true, module.exports["default"] = module.exports;
  22642. },{"./getPrototypeOf.js":126}],139:[function(_dereq_,module,exports){
  22643. var arrayWithoutHoles = _dereq_("./arrayWithoutHoles.js");
  22644. var iterableToArray = _dereq_("./iterableToArray.js");
  22645. var unsupportedIterableToArray = _dereq_("./unsupportedIterableToArray.js");
  22646. var nonIterableSpread = _dereq_("./nonIterableSpread.js");
  22647. function _toConsumableArray(arr) {
  22648. return arrayWithoutHoles(arr) || iterableToArray(arr) || unsupportedIterableToArray(arr) || nonIterableSpread();
  22649. }
  22650. module.exports = _toConsumableArray, module.exports.__esModule = true, module.exports["default"] = module.exports;
  22651. },{"./arrayWithoutHoles.js":118,"./iterableToArray.js":131,"./nonIterableSpread.js":134,"./unsupportedIterableToArray.js":141}],140:[function(_dereq_,module,exports){
  22652. var _Symbol = _dereq_("@babel/runtime-corejs3/core-js/symbol");
  22653. var _Symbol$iterator = _dereq_("@babel/runtime-corejs3/core-js/symbol/iterator");
  22654. function _typeof(obj) {
  22655. "@babel/helpers - typeof";
  22656. return (module.exports = _typeof = "function" == typeof _Symbol && "symbol" == typeof _Symbol$iterator ? function (obj) {
  22657. return typeof obj;
  22658. } : function (obj) {
  22659. return obj && "function" == typeof _Symbol && obj.constructor === _Symbol && obj !== _Symbol.prototype ? "symbol" : typeof obj;
  22660. }, module.exports.__esModule = true, module.exports["default"] = module.exports), _typeof(obj);
  22661. }
  22662. module.exports = _typeof, module.exports.__esModule = true, module.exports["default"] = module.exports;
  22663. },{"@babel/runtime-corejs3/core-js/symbol":114,"@babel/runtime-corejs3/core-js/symbol/iterator":115}],141:[function(_dereq_,module,exports){
  22664. var _sliceInstanceProperty = _dereq_("@babel/runtime-corejs3/core-js/instance/slice");
  22665. var _Array$from = _dereq_("@babel/runtime-corejs3/core-js/array/from");
  22666. var arrayLikeToArray = _dereq_("./arrayLikeToArray.js");
  22667. function _unsupportedIterableToArray(o, minLen) {
  22668. var _context;
  22669. if (!o) return;
  22670. if (typeof o === "string") return arrayLikeToArray(o, minLen);
  22671. var n = _sliceInstanceProperty(_context = Object.prototype.toString.call(o)).call(_context, 8, -1);
  22672. if (n === "Object" && o.constructor) n = o.constructor.name;
  22673. if (n === "Map" || n === "Set") return _Array$from(o);
  22674. if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return arrayLikeToArray(o, minLen);
  22675. }
  22676. module.exports = _unsupportedIterableToArray, module.exports.__esModule = true, module.exports["default"] = module.exports;
  22677. },{"./arrayLikeToArray.js":116,"@babel/runtime-corejs3/core-js/array/from":99,"@babel/runtime-corejs3/core-js/instance/slice":104}],142:[function(_dereq_,module,exports){
  22678. var _Map = _dereq_("@babel/runtime-corejs3/core-js/map");
  22679. var _Object$create = _dereq_("@babel/runtime-corejs3/core-js/object/create");
  22680. var getPrototypeOf = _dereq_("./getPrototypeOf.js");
  22681. var setPrototypeOf = _dereq_("./setPrototypeOf.js");
  22682. var isNativeFunction = _dereq_("./isNativeFunction.js");
  22683. var construct = _dereq_("./construct.js");
  22684. function _wrapNativeSuper(Class) {
  22685. var _cache = typeof _Map === "function" ? new _Map() : undefined;
  22686. module.exports = _wrapNativeSuper = function _wrapNativeSuper(Class) {
  22687. if (Class === null || !isNativeFunction(Class)) return Class;
  22688. if (typeof Class !== "function") {
  22689. throw new TypeError("Super expression must either be null or a function");
  22690. }
  22691. if (typeof _cache !== "undefined") {
  22692. if (_cache.has(Class)) return _cache.get(Class);
  22693. _cache.set(Class, Wrapper);
  22694. }
  22695. function Wrapper() {
  22696. return construct(Class, arguments, getPrototypeOf(this).constructor);
  22697. }
  22698. Wrapper.prototype = _Object$create(Class.prototype, {
  22699. constructor: {
  22700. value: Wrapper,
  22701. enumerable: false,
  22702. writable: true,
  22703. configurable: true
  22704. }
  22705. });
  22706. return setPrototypeOf(Wrapper, Class);
  22707. }, module.exports.__esModule = true, module.exports["default"] = module.exports;
  22708. return _wrapNativeSuper(Class);
  22709. }
  22710. module.exports = _wrapNativeSuper, module.exports.__esModule = true, module.exports["default"] = module.exports;
  22711. },{"./construct.js":122,"./getPrototypeOf.js":126,"./isNativeFunction.js":129,"./setPrototypeOf.js":136,"@babel/runtime-corejs3/core-js/map":105,"@babel/runtime-corejs3/core-js/object/create":106}],143:[function(_dereq_,module,exports){
  22712. /**
  22713. * Copyright (c) 2014-present, Facebook, Inc.
  22714. *
  22715. * This source code is licensed under the MIT license found in the
  22716. * LICENSE file in the root directory of this source tree.
  22717. */
  22718. var runtime = (function (exports) {
  22719. "use strict";
  22720. var Op = Object.prototype;
  22721. var hasOwn = Op.hasOwnProperty;
  22722. var undefined; // More compressible than void 0.
  22723. var $Symbol = typeof Symbol === "function" ? Symbol : {};
  22724. var iteratorSymbol = $Symbol.iterator || "@@iterator";
  22725. var asyncIteratorSymbol = $Symbol.asyncIterator || "@@asyncIterator";
  22726. var toStringTagSymbol = $Symbol.toStringTag || "@@toStringTag";
  22727. function define(obj, key, value) {
  22728. Object.defineProperty(obj, key, {
  22729. value: value,
  22730. enumerable: true,
  22731. configurable: true,
  22732. writable: true
  22733. });
  22734. return obj[key];
  22735. }
  22736. try {
  22737. // IE 8 has a broken Object.defineProperty that only works on DOM objects.
  22738. define({}, "");
  22739. } catch (err) {
  22740. define = function(obj, key, value) {
  22741. return obj[key] = value;
  22742. };
  22743. }
  22744. function wrap(innerFn, outerFn, self, tryLocsList) {
  22745. // If outerFn provided and outerFn.prototype is a Generator, then outerFn.prototype instanceof Generator.
  22746. var protoGenerator = outerFn && outerFn.prototype instanceof Generator ? outerFn : Generator;
  22747. var generator = Object.create(protoGenerator.prototype);
  22748. var context = new Context(tryLocsList || []);
  22749. // The ._invoke method unifies the implementations of the .next,
  22750. // .throw, and .return methods.
  22751. generator._invoke = makeInvokeMethod(innerFn, self, context);
  22752. return generator;
  22753. }
  22754. exports.wrap = wrap;
  22755. // Try/catch helper to minimize deoptimizations. Returns a completion
  22756. // record like context.tryEntries[i].completion. This interface could
  22757. // have been (and was previously) designed to take a closure to be
  22758. // invoked without arguments, but in all the cases we care about we
  22759. // already have an existing method we want to call, so there's no need
  22760. // to create a new function object. We can even get away with assuming
  22761. // the method takes exactly one argument, since that happens to be true
  22762. // in every case, so we don't have to touch the arguments object. The
  22763. // only additional allocation required is the completion record, which
  22764. // has a stable shape and so hopefully should be cheap to allocate.
  22765. function tryCatch(fn, obj, arg) {
  22766. try {
  22767. return { type: "normal", arg: fn.call(obj, arg) };
  22768. } catch (err) {
  22769. return { type: "throw", arg: err };
  22770. }
  22771. }
  22772. var GenStateSuspendedStart = "suspendedStart";
  22773. var GenStateSuspendedYield = "suspendedYield";
  22774. var GenStateExecuting = "executing";
  22775. var GenStateCompleted = "completed";
  22776. // Returning this object from the innerFn has the same effect as
  22777. // breaking out of the dispatch switch statement.
  22778. var ContinueSentinel = {};
  22779. // Dummy constructor functions that we use as the .constructor and
  22780. // .constructor.prototype properties for functions that return Generator
  22781. // objects. For full spec compliance, you may wish to configure your
  22782. // minifier not to mangle the names of these two functions.
  22783. function Generator() {}
  22784. function GeneratorFunction() {}
  22785. function GeneratorFunctionPrototype() {}
  22786. // This is a polyfill for %IteratorPrototype% for environments that
  22787. // don't natively support it.
  22788. var IteratorPrototype = {};
  22789. define(IteratorPrototype, iteratorSymbol, function () {
  22790. return this;
  22791. });
  22792. var getProto = Object.getPrototypeOf;
  22793. var NativeIteratorPrototype = getProto && getProto(getProto(values([])));
  22794. if (NativeIteratorPrototype &&
  22795. NativeIteratorPrototype !== Op &&
  22796. hasOwn.call(NativeIteratorPrototype, iteratorSymbol)) {
  22797. // This environment has a native %IteratorPrototype%; use it instead
  22798. // of the polyfill.
  22799. IteratorPrototype = NativeIteratorPrototype;
  22800. }
  22801. var Gp = GeneratorFunctionPrototype.prototype =
  22802. Generator.prototype = Object.create(IteratorPrototype);
  22803. GeneratorFunction.prototype = GeneratorFunctionPrototype;
  22804. define(Gp, "constructor", GeneratorFunctionPrototype);
  22805. define(GeneratorFunctionPrototype, "constructor", GeneratorFunction);
  22806. GeneratorFunction.displayName = define(
  22807. GeneratorFunctionPrototype,
  22808. toStringTagSymbol,
  22809. "GeneratorFunction"
  22810. );
  22811. // Helper for defining the .next, .throw, and .return methods of the
  22812. // Iterator interface in terms of a single ._invoke method.
  22813. function defineIteratorMethods(prototype) {
  22814. ["next", "throw", "return"].forEach(function(method) {
  22815. define(prototype, method, function(arg) {
  22816. return this._invoke(method, arg);
  22817. });
  22818. });
  22819. }
  22820. exports.isGeneratorFunction = function(genFun) {
  22821. var ctor = typeof genFun === "function" && genFun.constructor;
  22822. return ctor
  22823. ? ctor === GeneratorFunction ||
  22824. // For the native GeneratorFunction constructor, the best we can
  22825. // do is to check its .name property.
  22826. (ctor.displayName || ctor.name) === "GeneratorFunction"
  22827. : false;
  22828. };
  22829. exports.mark = function(genFun) {
  22830. if (Object.setPrototypeOf) {
  22831. Object.setPrototypeOf(genFun, GeneratorFunctionPrototype);
  22832. } else {
  22833. genFun.__proto__ = GeneratorFunctionPrototype;
  22834. define(genFun, toStringTagSymbol, "GeneratorFunction");
  22835. }
  22836. genFun.prototype = Object.create(Gp);
  22837. return genFun;
  22838. };
  22839. // Within the body of any async function, `await x` is transformed to
  22840. // `yield regeneratorRuntime.awrap(x)`, so that the runtime can test
  22841. // `hasOwn.call(value, "__await")` to determine if the yielded value is
  22842. // meant to be awaited.
  22843. exports.awrap = function(arg) {
  22844. return { __await: arg };
  22845. };
  22846. function AsyncIterator(generator, PromiseImpl) {
  22847. function invoke(method, arg, resolve, reject) {
  22848. var record = tryCatch(generator[method], generator, arg);
  22849. if (record.type === "throw") {
  22850. reject(record.arg);
  22851. } else {
  22852. var result = record.arg;
  22853. var value = result.value;
  22854. if (value &&
  22855. typeof value === "object" &&
  22856. hasOwn.call(value, "__await")) {
  22857. return PromiseImpl.resolve(value.__await).then(function(value) {
  22858. invoke("next", value, resolve, reject);
  22859. }, function(err) {
  22860. invoke("throw", err, resolve, reject);
  22861. });
  22862. }
  22863. return PromiseImpl.resolve(value).then(function(unwrapped) {
  22864. // When a yielded Promise is resolved, its final value becomes
  22865. // the .value of the Promise<{value,done}> result for the
  22866. // current iteration.
  22867. result.value = unwrapped;
  22868. resolve(result);
  22869. }, function(error) {
  22870. // If a rejected Promise was yielded, throw the rejection back
  22871. // into the async generator function so it can be handled there.
  22872. return invoke("throw", error, resolve, reject);
  22873. });
  22874. }
  22875. }
  22876. var previousPromise;
  22877. function enqueue(method, arg) {
  22878. function callInvokeWithMethodAndArg() {
  22879. return new PromiseImpl(function(resolve, reject) {
  22880. invoke(method, arg, resolve, reject);
  22881. });
  22882. }
  22883. return previousPromise =
  22884. // If enqueue has been called before, then we want to wait until
  22885. // all previous Promises have been resolved before calling invoke,
  22886. // so that results are always delivered in the correct order. If
  22887. // enqueue has not been called before, then it is important to
  22888. // call invoke immediately, without waiting on a callback to fire,
  22889. // so that the async generator function has the opportunity to do
  22890. // any necessary setup in a predictable way. This predictability
  22891. // is why the Promise constructor synchronously invokes its
  22892. // executor callback, and why async functions synchronously
  22893. // execute code before the first await. Since we implement simple
  22894. // async functions in terms of async generators, it is especially
  22895. // important to get this right, even though it requires care.
  22896. previousPromise ? previousPromise.then(
  22897. callInvokeWithMethodAndArg,
  22898. // Avoid propagating failures to Promises returned by later
  22899. // invocations of the iterator.
  22900. callInvokeWithMethodAndArg
  22901. ) : callInvokeWithMethodAndArg();
  22902. }
  22903. // Define the unified helper method that is used to implement .next,
  22904. // .throw, and .return (see defineIteratorMethods).
  22905. this._invoke = enqueue;
  22906. }
  22907. defineIteratorMethods(AsyncIterator.prototype);
  22908. define(AsyncIterator.prototype, asyncIteratorSymbol, function () {
  22909. return this;
  22910. });
  22911. exports.AsyncIterator = AsyncIterator;
  22912. // Note that simple async functions are implemented on top of
  22913. // AsyncIterator objects; they just return a Promise for the value of
  22914. // the final result produced by the iterator.
  22915. exports.async = function(innerFn, outerFn, self, tryLocsList, PromiseImpl) {
  22916. if (PromiseImpl === void 0) PromiseImpl = Promise;
  22917. var iter = new AsyncIterator(
  22918. wrap(innerFn, outerFn, self, tryLocsList),
  22919. PromiseImpl
  22920. );
  22921. return exports.isGeneratorFunction(outerFn)
  22922. ? iter // If outerFn is a generator, return the full iterator.
  22923. : iter.next().then(function(result) {
  22924. return result.done ? result.value : iter.next();
  22925. });
  22926. };
  22927. function makeInvokeMethod(innerFn, self, context) {
  22928. var state = GenStateSuspendedStart;
  22929. return function invoke(method, arg) {
  22930. if (state === GenStateExecuting) {
  22931. throw new Error("Generator is already running");
  22932. }
  22933. if (state === GenStateCompleted) {
  22934. if (method === "throw") {
  22935. throw arg;
  22936. }
  22937. // Be forgiving, per 25.3.3.3.3 of the spec:
  22938. // https://people.mozilla.org/~jorendorff/es6-draft.html#sec-generatorresume
  22939. return doneResult();
  22940. }
  22941. context.method = method;
  22942. context.arg = arg;
  22943. while (true) {
  22944. var delegate = context.delegate;
  22945. if (delegate) {
  22946. var delegateResult = maybeInvokeDelegate(delegate, context);
  22947. if (delegateResult) {
  22948. if (delegateResult === ContinueSentinel) continue;
  22949. return delegateResult;
  22950. }
  22951. }
  22952. if (context.method === "next") {
  22953. // Setting context._sent for legacy support of Babel's
  22954. // function.sent implementation.
  22955. context.sent = context._sent = context.arg;
  22956. } else if (context.method === "throw") {
  22957. if (state === GenStateSuspendedStart) {
  22958. state = GenStateCompleted;
  22959. throw context.arg;
  22960. }
  22961. context.dispatchException(context.arg);
  22962. } else if (context.method === "return") {
  22963. context.abrupt("return", context.arg);
  22964. }
  22965. state = GenStateExecuting;
  22966. var record = tryCatch(innerFn, self, context);
  22967. if (record.type === "normal") {
  22968. // If an exception is thrown from innerFn, we leave state ===
  22969. // GenStateExecuting and loop back for another invocation.
  22970. state = context.done
  22971. ? GenStateCompleted
  22972. : GenStateSuspendedYield;
  22973. if (record.arg === ContinueSentinel) {
  22974. continue;
  22975. }
  22976. return {
  22977. value: record.arg,
  22978. done: context.done
  22979. };
  22980. } else if (record.type === "throw") {
  22981. state = GenStateCompleted;
  22982. // Dispatch the exception by looping back around to the
  22983. // context.dispatchException(context.arg) call above.
  22984. context.method = "throw";
  22985. context.arg = record.arg;
  22986. }
  22987. }
  22988. };
  22989. }
  22990. // Call delegate.iterator[context.method](context.arg) and handle the
  22991. // result, either by returning a { value, done } result from the
  22992. // delegate iterator, or by modifying context.method and context.arg,
  22993. // setting context.delegate to null, and returning the ContinueSentinel.
  22994. function maybeInvokeDelegate(delegate, context) {
  22995. var method = delegate.iterator[context.method];
  22996. if (method === undefined) {
  22997. // A .throw or .return when the delegate iterator has no .throw
  22998. // method always terminates the yield* loop.
  22999. context.delegate = null;
  23000. if (context.method === "throw") {
  23001. // Note: ["return"] must be used for ES3 parsing compatibility.
  23002. if (delegate.iterator["return"]) {
  23003. // If the delegate iterator has a return method, give it a
  23004. // chance to clean up.
  23005. context.method = "return";
  23006. context.arg = undefined;
  23007. maybeInvokeDelegate(delegate, context);
  23008. if (context.method === "throw") {
  23009. // If maybeInvokeDelegate(context) changed context.method from
  23010. // "return" to "throw", let that override the TypeError below.
  23011. return ContinueSentinel;
  23012. }
  23013. }
  23014. context.method = "throw";
  23015. context.arg = new TypeError(
  23016. "The iterator does not provide a 'throw' method");
  23017. }
  23018. return ContinueSentinel;
  23019. }
  23020. var record = tryCatch(method, delegate.iterator, context.arg);
  23021. if (record.type === "throw") {
  23022. context.method = "throw";
  23023. context.arg = record.arg;
  23024. context.delegate = null;
  23025. return ContinueSentinel;
  23026. }
  23027. var info = record.arg;
  23028. if (! info) {
  23029. context.method = "throw";
  23030. context.arg = new TypeError("iterator result is not an object");
  23031. context.delegate = null;
  23032. return ContinueSentinel;
  23033. }
  23034. if (info.done) {
  23035. // Assign the result of the finished delegate to the temporary
  23036. // variable specified by delegate.resultName (see delegateYield).
  23037. context[delegate.resultName] = info.value;
  23038. // Resume execution at the desired location (see delegateYield).
  23039. context.next = delegate.nextLoc;
  23040. // If context.method was "throw" but the delegate handled the
  23041. // exception, let the outer generator proceed normally. If
  23042. // context.method was "next", forget context.arg since it has been
  23043. // "consumed" by the delegate iterator. If context.method was
  23044. // "return", allow the original .return call to continue in the
  23045. // outer generator.
  23046. if (context.method !== "return") {
  23047. context.method = "next";
  23048. context.arg = undefined;
  23049. }
  23050. } else {
  23051. // Re-yield the result returned by the delegate method.
  23052. return info;
  23053. }
  23054. // The delegate iterator is finished, so forget it and continue with
  23055. // the outer generator.
  23056. context.delegate = null;
  23057. return ContinueSentinel;
  23058. }
  23059. // Define Generator.prototype.{next,throw,return} in terms of the
  23060. // unified ._invoke helper method.
  23061. defineIteratorMethods(Gp);
  23062. define(Gp, toStringTagSymbol, "Generator");
  23063. // A Generator should always return itself as the iterator object when the
  23064. // @@iterator function is called on it. Some browsers' implementations of the
  23065. // iterator prototype chain incorrectly implement this, causing the Generator
  23066. // object to not be returned from this call. This ensures that doesn't happen.
  23067. // See https://github.com/facebook/regenerator/issues/274 for more details.
  23068. define(Gp, iteratorSymbol, function() {
  23069. return this;
  23070. });
  23071. define(Gp, "toString", function() {
  23072. return "[object Generator]";
  23073. });
  23074. function pushTryEntry(locs) {
  23075. var entry = { tryLoc: locs[0] };
  23076. if (1 in locs) {
  23077. entry.catchLoc = locs[1];
  23078. }
  23079. if (2 in locs) {
  23080. entry.finallyLoc = locs[2];
  23081. entry.afterLoc = locs[3];
  23082. }
  23083. this.tryEntries.push(entry);
  23084. }
  23085. function resetTryEntry(entry) {
  23086. var record = entry.completion || {};
  23087. record.type = "normal";
  23088. delete record.arg;
  23089. entry.completion = record;
  23090. }
  23091. function Context(tryLocsList) {
  23092. // The root entry object (effectively a try statement without a catch
  23093. // or a finally block) gives us a place to store values thrown from
  23094. // locations where there is no enclosing try statement.
  23095. this.tryEntries = [{ tryLoc: "root" }];
  23096. tryLocsList.forEach(pushTryEntry, this);
  23097. this.reset(true);
  23098. }
  23099. exports.keys = function(object) {
  23100. var keys = [];
  23101. for (var key in object) {
  23102. keys.push(key);
  23103. }
  23104. keys.reverse();
  23105. // Rather than returning an object with a next method, we keep
  23106. // things simple and return the next function itself.
  23107. return function next() {
  23108. while (keys.length) {
  23109. var key = keys.pop();
  23110. if (key in object) {
  23111. next.value = key;
  23112. next.done = false;
  23113. return next;
  23114. }
  23115. }
  23116. // To avoid creating an additional object, we just hang the .value
  23117. // and .done properties off the next function object itself. This
  23118. // also ensures that the minifier will not anonymize the function.
  23119. next.done = true;
  23120. return next;
  23121. };
  23122. };
  23123. function values(iterable) {
  23124. if (iterable) {
  23125. var iteratorMethod = iterable[iteratorSymbol];
  23126. if (iteratorMethod) {
  23127. return iteratorMethod.call(iterable);
  23128. }
  23129. if (typeof iterable.next === "function") {
  23130. return iterable;
  23131. }
  23132. if (!isNaN(iterable.length)) {
  23133. var i = -1, next = function next() {
  23134. while (++i < iterable.length) {
  23135. if (hasOwn.call(iterable, i)) {
  23136. next.value = iterable[i];
  23137. next.done = false;
  23138. return next;
  23139. }
  23140. }
  23141. next.value = undefined;
  23142. next.done = true;
  23143. return next;
  23144. };
  23145. return next.next = next;
  23146. }
  23147. }
  23148. // Return an iterator with no values.
  23149. return { next: doneResult };
  23150. }
  23151. exports.values = values;
  23152. function doneResult() {
  23153. return { value: undefined, done: true };
  23154. }
  23155. Context.prototype = {
  23156. constructor: Context,
  23157. reset: function(skipTempReset) {
  23158. this.prev = 0;
  23159. this.next = 0;
  23160. // Resetting context._sent for legacy support of Babel's
  23161. // function.sent implementation.
  23162. this.sent = this._sent = undefined;
  23163. this.done = false;
  23164. this.delegate = null;
  23165. this.method = "next";
  23166. this.arg = undefined;
  23167. this.tryEntries.forEach(resetTryEntry);
  23168. if (!skipTempReset) {
  23169. for (var name in this) {
  23170. // Not sure about the optimal order of these conditions:
  23171. if (name.charAt(0) === "t" &&
  23172. hasOwn.call(this, name) &&
  23173. !isNaN(+name.slice(1))) {
  23174. this[name] = undefined;
  23175. }
  23176. }
  23177. }
  23178. },
  23179. stop: function() {
  23180. this.done = true;
  23181. var rootEntry = this.tryEntries[0];
  23182. var rootRecord = rootEntry.completion;
  23183. if (rootRecord.type === "throw") {
  23184. throw rootRecord.arg;
  23185. }
  23186. return this.rval;
  23187. },
  23188. dispatchException: function(exception) {
  23189. if (this.done) {
  23190. throw exception;
  23191. }
  23192. var context = this;
  23193. function handle(loc, caught) {
  23194. record.type = "throw";
  23195. record.arg = exception;
  23196. context.next = loc;
  23197. if (caught) {
  23198. // If the dispatched exception was caught by a catch block,
  23199. // then let that catch block handle the exception normally.
  23200. context.method = "next";
  23201. context.arg = undefined;
  23202. }
  23203. return !! caught;
  23204. }
  23205. for (var i = this.tryEntries.length - 1; i >= 0; --i) {
  23206. var entry = this.tryEntries[i];
  23207. var record = entry.completion;
  23208. if (entry.tryLoc === "root") {
  23209. // Exception thrown outside of any try block that could handle
  23210. // it, so set the completion value of the entire function to
  23211. // throw the exception.
  23212. return handle("end");
  23213. }
  23214. if (entry.tryLoc <= this.prev) {
  23215. var hasCatch = hasOwn.call(entry, "catchLoc");
  23216. var hasFinally = hasOwn.call(entry, "finallyLoc");
  23217. if (hasCatch && hasFinally) {
  23218. if (this.prev < entry.catchLoc) {
  23219. return handle(entry.catchLoc, true);
  23220. } else if (this.prev < entry.finallyLoc) {
  23221. return handle(entry.finallyLoc);
  23222. }
  23223. } else if (hasCatch) {
  23224. if (this.prev < entry.catchLoc) {
  23225. return handle(entry.catchLoc, true);
  23226. }
  23227. } else if (hasFinally) {
  23228. if (this.prev < entry.finallyLoc) {
  23229. return handle(entry.finallyLoc);
  23230. }
  23231. } else {
  23232. throw new Error("try statement without catch or finally");
  23233. }
  23234. }
  23235. }
  23236. },
  23237. abrupt: function(type, arg) {
  23238. for (var i = this.tryEntries.length - 1; i >= 0; --i) {
  23239. var entry = this.tryEntries[i];
  23240. if (entry.tryLoc <= this.prev &&
  23241. hasOwn.call(entry, "finallyLoc") &&
  23242. this.prev < entry.finallyLoc) {
  23243. var finallyEntry = entry;
  23244. break;
  23245. }
  23246. }
  23247. if (finallyEntry &&
  23248. (type === "break" ||
  23249. type === "continue") &&
  23250. finallyEntry.tryLoc <= arg &&
  23251. arg <= finallyEntry.finallyLoc) {
  23252. // Ignore the finally entry if control is not jumping to a
  23253. // location outside the try/catch block.
  23254. finallyEntry = null;
  23255. }
  23256. var record = finallyEntry ? finallyEntry.completion : {};
  23257. record.type = type;
  23258. record.arg = arg;
  23259. if (finallyEntry) {
  23260. this.method = "next";
  23261. this.next = finallyEntry.finallyLoc;
  23262. return ContinueSentinel;
  23263. }
  23264. return this.complete(record);
  23265. },
  23266. complete: function(record, afterLoc) {
  23267. if (record.type === "throw") {
  23268. throw record.arg;
  23269. }
  23270. if (record.type === "break" ||
  23271. record.type === "continue") {
  23272. this.next = record.arg;
  23273. } else if (record.type === "return") {
  23274. this.rval = this.arg = record.arg;
  23275. this.method = "return";
  23276. this.next = "end";
  23277. } else if (record.type === "normal" && afterLoc) {
  23278. this.next = afterLoc;
  23279. }
  23280. return ContinueSentinel;
  23281. },
  23282. finish: function(finallyLoc) {
  23283. for (var i = this.tryEntries.length - 1; i >= 0; --i) {
  23284. var entry = this.tryEntries[i];
  23285. if (entry.finallyLoc === finallyLoc) {
  23286. this.complete(entry.completion, entry.afterLoc);
  23287. resetTryEntry(entry);
  23288. return ContinueSentinel;
  23289. }
  23290. }
  23291. },
  23292. "catch": function(tryLoc) {
  23293. for (var i = this.tryEntries.length - 1; i >= 0; --i) {
  23294. var entry = this.tryEntries[i];
  23295. if (entry.tryLoc === tryLoc) {
  23296. var record = entry.completion;
  23297. if (record.type === "throw") {
  23298. var thrown = record.arg;
  23299. resetTryEntry(entry);
  23300. }
  23301. return thrown;
  23302. }
  23303. }
  23304. // The context.catch method must only be called with a location
  23305. // argument that corresponds to a known catch block.
  23306. throw new Error("illegal catch attempt");
  23307. },
  23308. delegateYield: function(iterable, resultName, nextLoc) {
  23309. this.delegate = {
  23310. iterator: values(iterable),
  23311. resultName: resultName,
  23312. nextLoc: nextLoc
  23313. };
  23314. if (this.method === "next") {
  23315. // Deliberately forget the last sent value so that we don't
  23316. // accidentally pass it on to the delegate.
  23317. this.arg = undefined;
  23318. }
  23319. return ContinueSentinel;
  23320. }
  23321. };
  23322. // Regardless of whether this script is executing as a CommonJS module
  23323. // or not, return the runtime object so that we can declare the variable
  23324. // regeneratorRuntime in the outer scope, which allows this module to be
  23325. // injected easily by `bin/regenerator --include-runtime script.js`.
  23326. return exports;
  23327. }(
  23328. // If this script is executing as a CommonJS module, use module.exports
  23329. // as the regeneratorRuntime namespace. Otherwise create a new empty
  23330. // object. Either way, the resulting object will be used to initialize
  23331. // the regeneratorRuntime variable at the top of this file.
  23332. typeof module === "object" ? module.exports : {}
  23333. ));
  23334. try {
  23335. regeneratorRuntime = runtime;
  23336. } catch (accidentalStrictMode) {
  23337. // This module should not be running in strict mode, so the above
  23338. // assignment should always work unless something is misconfigured. Just
  23339. // in case runtime.js accidentally runs in strict mode, in modern engines
  23340. // we can explicitly access globalThis. In older engines we can escape
  23341. // strict mode using a global Function call. This could conceivably fail
  23342. // if a Content Security Policy forbids using Function, but in that case
  23343. // the proper solution is to fix the accidental strict mode problem. If
  23344. // you've misconfigured your bundler to force strict mode and applied a
  23345. // CSP to forbid Function, and you're not willing to fix either of those
  23346. // problems, please detail your unique predicament in a GitHub issue.
  23347. if (typeof globalThis === "object") {
  23348. globalThis.regeneratorRuntime = runtime;
  23349. } else {
  23350. Function("r", "regeneratorRuntime = r")(runtime);
  23351. }
  23352. }
  23353. },{}],144:[function(_dereq_,module,exports){
  23354. module.exports = _dereq_("regenerator-runtime");
  23355. },{"regenerator-runtime":143}],145:[function(_dereq_,module,exports){
  23356. },{}],146:[function(_dereq_,module,exports){
  23357. var parent = _dereq_('../../stable/array/from');
  23358. module.exports = parent;
  23359. },{"../../stable/array/from":545}],147:[function(_dereq_,module,exports){
  23360. var parent = _dereq_('../../stable/array/is-array');
  23361. module.exports = parent;
  23362. },{"../../stable/array/is-array":546}],148:[function(_dereq_,module,exports){
  23363. var parent = _dereq_('../stable/get-iterator-method');
  23364. module.exports = parent;
  23365. },{"../stable/get-iterator-method":551}],149:[function(_dereq_,module,exports){
  23366. var parent = _dereq_('../../stable/instance/bind');
  23367. module.exports = parent;
  23368. },{"../../stable/instance/bind":552}],150:[function(_dereq_,module,exports){
  23369. var parent = _dereq_('../../stable/instance/index-of');
  23370. module.exports = parent;
  23371. },{"../../stable/instance/index-of":561}],151:[function(_dereq_,module,exports){
  23372. var parent = _dereq_('../../stable/instance/slice');
  23373. module.exports = parent;
  23374. },{"../../stable/instance/slice":566}],152:[function(_dereq_,module,exports){
  23375. var parent = _dereq_('../../stable/map');
  23376. module.exports = parent;
  23377. },{"../../stable/map":572}],153:[function(_dereq_,module,exports){
  23378. var parent = _dereq_('../../stable/object/create');
  23379. module.exports = parent;
  23380. },{"../../stable/object/create":575}],154:[function(_dereq_,module,exports){
  23381. var parent = _dereq_('../../stable/object/define-property');
  23382. module.exports = parent;
  23383. },{"../../stable/object/define-property":577}],155:[function(_dereq_,module,exports){
  23384. var parent = _dereq_('../../stable/object/get-own-property-descriptor');
  23385. module.exports = parent;
  23386. },{"../../stable/object/get-own-property-descriptor":580}],156:[function(_dereq_,module,exports){
  23387. var parent = _dereq_('../../stable/object/get-prototype-of');
  23388. module.exports = parent;
  23389. },{"../../stable/object/get-prototype-of":583}],157:[function(_dereq_,module,exports){
  23390. var parent = _dereq_('../../stable/object/set-prototype-of');
  23391. module.exports = parent;
  23392. },{"../../stable/object/set-prototype-of":585}],158:[function(_dereq_,module,exports){
  23393. var parent = _dereq_('../../stable/promise');
  23394. module.exports = parent;
  23395. },{"../../stable/promise":587}],159:[function(_dereq_,module,exports){
  23396. var parent = _dereq_('../../stable/reflect/construct');
  23397. module.exports = parent;
  23398. },{"../../stable/reflect/construct":588}],160:[function(_dereq_,module,exports){
  23399. var parent = _dereq_('../../stable/reflect/get');
  23400. module.exports = parent;
  23401. },{"../../stable/reflect/get":589}],161:[function(_dereq_,module,exports){
  23402. var parent = _dereq_('../../stable/symbol');
  23403. module.exports = parent;
  23404. },{"../../stable/symbol":593}],162:[function(_dereq_,module,exports){
  23405. var parent = _dereq_('../../stable/symbol/iterator');
  23406. module.exports = parent;
  23407. },{"../../stable/symbol/iterator":594}],163:[function(_dereq_,module,exports){
  23408. _dereq_('../../modules/es.string.iterator');
  23409. _dereq_('../../modules/es.array.from');
  23410. var path = _dereq_('../../internals/path');
  23411. module.exports = path.Array.from;
  23412. },{"../../internals/path":390,"../../modules/es.array.from":439,"../../modules/es.string.iterator":487}],164:[function(_dereq_,module,exports){
  23413. _dereq_('../../modules/es.array.is-array');
  23414. var path = _dereq_('../../internals/path');
  23415. module.exports = path.Array.isArray;
  23416. },{"../../internals/path":390,"../../modules/es.array.is-array":442}],165:[function(_dereq_,module,exports){
  23417. _dereq_('../../../modules/es.array.concat');
  23418. var entryVirtual = _dereq_('../../../internals/entry-virtual');
  23419. module.exports = entryVirtual('Array').concat;
  23420. },{"../../../internals/entry-virtual":314,"../../../modules/es.array.concat":433}],166:[function(_dereq_,module,exports){
  23421. _dereq_('../../../modules/es.array.iterator');
  23422. _dereq_('../../../modules/es.object.to-string');
  23423. var entryVirtual = _dereq_('../../../internals/entry-virtual');
  23424. module.exports = entryVirtual('Array').entries;
  23425. },{"../../../internals/entry-virtual":314,"../../../modules/es.array.iterator":443,"../../../modules/es.object.to-string":469}],167:[function(_dereq_,module,exports){
  23426. _dereq_('../../../modules/es.array.every');
  23427. var entryVirtual = _dereq_('../../../internals/entry-virtual');
  23428. module.exports = entryVirtual('Array').every;
  23429. },{"../../../internals/entry-virtual":314,"../../../modules/es.array.every":434}],168:[function(_dereq_,module,exports){
  23430. _dereq_('../../../modules/es.array.filter');
  23431. var entryVirtual = _dereq_('../../../internals/entry-virtual');
  23432. module.exports = entryVirtual('Array').filter;
  23433. },{"../../../internals/entry-virtual":314,"../../../modules/es.array.filter":435}],169:[function(_dereq_,module,exports){
  23434. _dereq_('../../../modules/es.array.find-index');
  23435. var entryVirtual = _dereq_('../../../internals/entry-virtual');
  23436. module.exports = entryVirtual('Array').findIndex;
  23437. },{"../../../internals/entry-virtual":314,"../../../modules/es.array.find-index":436}],170:[function(_dereq_,module,exports){
  23438. _dereq_('../../../modules/es.array.find');
  23439. var entryVirtual = _dereq_('../../../internals/entry-virtual');
  23440. module.exports = entryVirtual('Array').find;
  23441. },{"../../../internals/entry-virtual":314,"../../../modules/es.array.find":437}],171:[function(_dereq_,module,exports){
  23442. _dereq_('../../../modules/es.array.for-each');
  23443. var entryVirtual = _dereq_('../../../internals/entry-virtual');
  23444. module.exports = entryVirtual('Array').forEach;
  23445. },{"../../../internals/entry-virtual":314,"../../../modules/es.array.for-each":438}],172:[function(_dereq_,module,exports){
  23446. _dereq_('../../../modules/es.array.includes');
  23447. var entryVirtual = _dereq_('../../../internals/entry-virtual');
  23448. module.exports = entryVirtual('Array').includes;
  23449. },{"../../../internals/entry-virtual":314,"../../../modules/es.array.includes":440}],173:[function(_dereq_,module,exports){
  23450. _dereq_('../../../modules/es.array.index-of');
  23451. var entryVirtual = _dereq_('../../../internals/entry-virtual');
  23452. module.exports = entryVirtual('Array').indexOf;
  23453. },{"../../../internals/entry-virtual":314,"../../../modules/es.array.index-of":441}],174:[function(_dereq_,module,exports){
  23454. _dereq_('../../../modules/es.array.iterator');
  23455. _dereq_('../../../modules/es.object.to-string');
  23456. var entryVirtual = _dereq_('../../../internals/entry-virtual');
  23457. module.exports = entryVirtual('Array').keys;
  23458. },{"../../../internals/entry-virtual":314,"../../../modules/es.array.iterator":443,"../../../modules/es.object.to-string":469}],175:[function(_dereq_,module,exports){
  23459. _dereq_('../../../modules/es.array.map');
  23460. var entryVirtual = _dereq_('../../../internals/entry-virtual');
  23461. module.exports = entryVirtual('Array').map;
  23462. },{"../../../internals/entry-virtual":314,"../../../modules/es.array.map":444}],176:[function(_dereq_,module,exports){
  23463. _dereq_('../../../modules/es.array.reduce');
  23464. var entryVirtual = _dereq_('../../../internals/entry-virtual');
  23465. module.exports = entryVirtual('Array').reduce;
  23466. },{"../../../internals/entry-virtual":314,"../../../modules/es.array.reduce":445}],177:[function(_dereq_,module,exports){
  23467. _dereq_('../../../modules/es.array.reverse');
  23468. var entryVirtual = _dereq_('../../../internals/entry-virtual');
  23469. module.exports = entryVirtual('Array').reverse;
  23470. },{"../../../internals/entry-virtual":314,"../../../modules/es.array.reverse":446}],178:[function(_dereq_,module,exports){
  23471. _dereq_('../../../modules/es.array.slice');
  23472. var entryVirtual = _dereq_('../../../internals/entry-virtual');
  23473. module.exports = entryVirtual('Array').slice;
  23474. },{"../../../internals/entry-virtual":314,"../../../modules/es.array.slice":447}],179:[function(_dereq_,module,exports){
  23475. _dereq_('../../../modules/es.array.sort');
  23476. var entryVirtual = _dereq_('../../../internals/entry-virtual');
  23477. module.exports = entryVirtual('Array').sort;
  23478. },{"../../../internals/entry-virtual":314,"../../../modules/es.array.sort":448}],180:[function(_dereq_,module,exports){
  23479. _dereq_('../../../modules/es.array.splice');
  23480. var entryVirtual = _dereq_('../../../internals/entry-virtual');
  23481. module.exports = entryVirtual('Array').splice;
  23482. },{"../../../internals/entry-virtual":314,"../../../modules/es.array.splice":449}],181:[function(_dereq_,module,exports){
  23483. _dereq_('../../../modules/es.array.iterator');
  23484. _dereq_('../../../modules/es.object.to-string');
  23485. var entryVirtual = _dereq_('../../../internals/entry-virtual');
  23486. module.exports = entryVirtual('Array').values;
  23487. },{"../../../internals/entry-virtual":314,"../../../modules/es.array.iterator":443,"../../../modules/es.object.to-string":469}],182:[function(_dereq_,module,exports){
  23488. _dereq_('../../../modules/es.function.bind');
  23489. var entryVirtual = _dereq_('../../../internals/entry-virtual');
  23490. module.exports = entryVirtual('Function').bind;
  23491. },{"../../../internals/entry-virtual":314,"../../../modules/es.function.bind":450}],183:[function(_dereq_,module,exports){
  23492. _dereq_('../modules/es.array.iterator');
  23493. _dereq_('../modules/es.string.iterator');
  23494. var getIteratorMethod = _dereq_('../internals/get-iterator-method');
  23495. module.exports = getIteratorMethod;
  23496. },{"../internals/get-iterator-method":329,"../modules/es.array.iterator":443,"../modules/es.string.iterator":487}],184:[function(_dereq_,module,exports){
  23497. var isPrototypeOf = _dereq_('../../internals/object-is-prototype-of');
  23498. var method = _dereq_('../function/virtual/bind');
  23499. var FunctionPrototype = Function.prototype;
  23500. module.exports = function (it) {
  23501. var own = it.bind;
  23502. return it === FunctionPrototype || (isPrototypeOf(FunctionPrototype, it) && own === FunctionPrototype.bind) ? method : own;
  23503. };
  23504. },{"../../internals/object-is-prototype-of":381,"../function/virtual/bind":182}],185:[function(_dereq_,module,exports){
  23505. var isPrototypeOf = _dereq_('../../internals/object-is-prototype-of');
  23506. var method = _dereq_('../array/virtual/concat');
  23507. var ArrayPrototype = Array.prototype;
  23508. module.exports = function (it) {
  23509. var own = it.concat;
  23510. return it === ArrayPrototype || (isPrototypeOf(ArrayPrototype, it) && own === ArrayPrototype.concat) ? method : own;
  23511. };
  23512. },{"../../internals/object-is-prototype-of":381,"../array/virtual/concat":165}],186:[function(_dereq_,module,exports){
  23513. var isPrototypeOf = _dereq_('../../internals/object-is-prototype-of');
  23514. var method = _dereq_('../array/virtual/every');
  23515. var ArrayPrototype = Array.prototype;
  23516. module.exports = function (it) {
  23517. var own = it.every;
  23518. return it === ArrayPrototype || (isPrototypeOf(ArrayPrototype, it) && own === ArrayPrototype.every) ? method : own;
  23519. };
  23520. },{"../../internals/object-is-prototype-of":381,"../array/virtual/every":167}],187:[function(_dereq_,module,exports){
  23521. var isPrototypeOf = _dereq_('../../internals/object-is-prototype-of');
  23522. var method = _dereq_('../array/virtual/filter');
  23523. var ArrayPrototype = Array.prototype;
  23524. module.exports = function (it) {
  23525. var own = it.filter;
  23526. return it === ArrayPrototype || (isPrototypeOf(ArrayPrototype, it) && own === ArrayPrototype.filter) ? method : own;
  23527. };
  23528. },{"../../internals/object-is-prototype-of":381,"../array/virtual/filter":168}],188:[function(_dereq_,module,exports){
  23529. var isPrototypeOf = _dereq_('../../internals/object-is-prototype-of');
  23530. var method = _dereq_('../array/virtual/find-index');
  23531. var ArrayPrototype = Array.prototype;
  23532. module.exports = function (it) {
  23533. var own = it.findIndex;
  23534. return it === ArrayPrototype || (isPrototypeOf(ArrayPrototype, it) && own === ArrayPrototype.findIndex) ? method : own;
  23535. };
  23536. },{"../../internals/object-is-prototype-of":381,"../array/virtual/find-index":169}],189:[function(_dereq_,module,exports){
  23537. var isPrototypeOf = _dereq_('../../internals/object-is-prototype-of');
  23538. var method = _dereq_('../array/virtual/find');
  23539. var ArrayPrototype = Array.prototype;
  23540. module.exports = function (it) {
  23541. var own = it.find;
  23542. return it === ArrayPrototype || (isPrototypeOf(ArrayPrototype, it) && own === ArrayPrototype.find) ? method : own;
  23543. };
  23544. },{"../../internals/object-is-prototype-of":381,"../array/virtual/find":170}],190:[function(_dereq_,module,exports){
  23545. var isPrototypeOf = _dereq_('../../internals/object-is-prototype-of');
  23546. var arrayMethod = _dereq_('../array/virtual/includes');
  23547. var stringMethod = _dereq_('../string/virtual/includes');
  23548. var ArrayPrototype = Array.prototype;
  23549. var StringPrototype = String.prototype;
  23550. module.exports = function (it) {
  23551. var own = it.includes;
  23552. if (it === ArrayPrototype || (isPrototypeOf(ArrayPrototype, it) && own === ArrayPrototype.includes)) return arrayMethod;
  23553. if (typeof it == 'string' || it === StringPrototype || (isPrototypeOf(StringPrototype, it) && own === StringPrototype.includes)) {
  23554. return stringMethod;
  23555. } return own;
  23556. };
  23557. },{"../../internals/object-is-prototype-of":381,"../array/virtual/includes":172,"../string/virtual/includes":219}],191:[function(_dereq_,module,exports){
  23558. var isPrototypeOf = _dereq_('../../internals/object-is-prototype-of');
  23559. var method = _dereq_('../array/virtual/index-of');
  23560. var ArrayPrototype = Array.prototype;
  23561. module.exports = function (it) {
  23562. var own = it.indexOf;
  23563. return it === ArrayPrototype || (isPrototypeOf(ArrayPrototype, it) && own === ArrayPrototype.indexOf) ? method : own;
  23564. };
  23565. },{"../../internals/object-is-prototype-of":381,"../array/virtual/index-of":173}],192:[function(_dereq_,module,exports){
  23566. var isPrototypeOf = _dereq_('../../internals/object-is-prototype-of');
  23567. var method = _dereq_('../array/virtual/map');
  23568. var ArrayPrototype = Array.prototype;
  23569. module.exports = function (it) {
  23570. var own = it.map;
  23571. return it === ArrayPrototype || (isPrototypeOf(ArrayPrototype, it) && own === ArrayPrototype.map) ? method : own;
  23572. };
  23573. },{"../../internals/object-is-prototype-of":381,"../array/virtual/map":175}],193:[function(_dereq_,module,exports){
  23574. var isPrototypeOf = _dereq_('../../internals/object-is-prototype-of');
  23575. var method = _dereq_('../array/virtual/reduce');
  23576. var ArrayPrototype = Array.prototype;
  23577. module.exports = function (it) {
  23578. var own = it.reduce;
  23579. return it === ArrayPrototype || (isPrototypeOf(ArrayPrototype, it) && own === ArrayPrototype.reduce) ? method : own;
  23580. };
  23581. },{"../../internals/object-is-prototype-of":381,"../array/virtual/reduce":176}],194:[function(_dereq_,module,exports){
  23582. var isPrototypeOf = _dereq_('../../internals/object-is-prototype-of');
  23583. var method = _dereq_('../array/virtual/reverse');
  23584. var ArrayPrototype = Array.prototype;
  23585. module.exports = function (it) {
  23586. var own = it.reverse;
  23587. return it === ArrayPrototype || (isPrototypeOf(ArrayPrototype, it) && own === ArrayPrototype.reverse) ? method : own;
  23588. };
  23589. },{"../../internals/object-is-prototype-of":381,"../array/virtual/reverse":177}],195:[function(_dereq_,module,exports){
  23590. var isPrototypeOf = _dereq_('../../internals/object-is-prototype-of');
  23591. var method = _dereq_('../array/virtual/slice');
  23592. var ArrayPrototype = Array.prototype;
  23593. module.exports = function (it) {
  23594. var own = it.slice;
  23595. return it === ArrayPrototype || (isPrototypeOf(ArrayPrototype, it) && own === ArrayPrototype.slice) ? method : own;
  23596. };
  23597. },{"../../internals/object-is-prototype-of":381,"../array/virtual/slice":178}],196:[function(_dereq_,module,exports){
  23598. var isPrototypeOf = _dereq_('../../internals/object-is-prototype-of');
  23599. var method = _dereq_('../array/virtual/sort');
  23600. var ArrayPrototype = Array.prototype;
  23601. module.exports = function (it) {
  23602. var own = it.sort;
  23603. return it === ArrayPrototype || (isPrototypeOf(ArrayPrototype, it) && own === ArrayPrototype.sort) ? method : own;
  23604. };
  23605. },{"../../internals/object-is-prototype-of":381,"../array/virtual/sort":179}],197:[function(_dereq_,module,exports){
  23606. var isPrototypeOf = _dereq_('../../internals/object-is-prototype-of');
  23607. var method = _dereq_('../array/virtual/splice');
  23608. var ArrayPrototype = Array.prototype;
  23609. module.exports = function (it) {
  23610. var own = it.splice;
  23611. return it === ArrayPrototype || (isPrototypeOf(ArrayPrototype, it) && own === ArrayPrototype.splice) ? method : own;
  23612. };
  23613. },{"../../internals/object-is-prototype-of":381,"../array/virtual/splice":180}],198:[function(_dereq_,module,exports){
  23614. var isPrototypeOf = _dereq_('../../internals/object-is-prototype-of');
  23615. var method = _dereq_('../string/virtual/starts-with');
  23616. var StringPrototype = String.prototype;
  23617. module.exports = function (it) {
  23618. var own = it.startsWith;
  23619. return typeof it == 'string' || it === StringPrototype
  23620. || (isPrototypeOf(StringPrototype, it) && own === StringPrototype.startsWith) ? method : own;
  23621. };
  23622. },{"../../internals/object-is-prototype-of":381,"../string/virtual/starts-with":220}],199:[function(_dereq_,module,exports){
  23623. _dereq_('../../modules/es.json.stringify');
  23624. var path = _dereq_('../../internals/path');
  23625. var apply = _dereq_('../../internals/function-apply');
  23626. // eslint-disable-next-line es-x/no-json -- safe
  23627. if (!path.JSON) path.JSON = { stringify: JSON.stringify };
  23628. // eslint-disable-next-line no-unused-vars -- required for `.length`
  23629. module.exports = function stringify(it, replacer, space) {
  23630. return apply(path.JSON.stringify, null, arguments);
  23631. };
  23632. },{"../../internals/function-apply":321,"../../internals/path":390,"../../modules/es.json.stringify":451}],200:[function(_dereq_,module,exports){
  23633. _dereq_('../../modules/es.array.iterator');
  23634. _dereq_('../../modules/es.map');
  23635. _dereq_('../../modules/es.object.to-string');
  23636. _dereq_('../../modules/es.string.iterator');
  23637. var path = _dereq_('../../internals/path');
  23638. module.exports = path.Map;
  23639. },{"../../internals/path":390,"../../modules/es.array.iterator":443,"../../modules/es.map":454,"../../modules/es.object.to-string":469,"../../modules/es.string.iterator":487}],201:[function(_dereq_,module,exports){
  23640. _dereq_('../../modules/es.number.is-integer');
  23641. var path = _dereq_('../../internals/path');
  23642. module.exports = path.Number.isInteger;
  23643. },{"../../internals/path":390,"../../modules/es.number.is-integer":456}],202:[function(_dereq_,module,exports){
  23644. _dereq_('../../modules/es.object.assign');
  23645. var path = _dereq_('../../internals/path');
  23646. module.exports = path.Object.assign;
  23647. },{"../../internals/path":390,"../../modules/es.object.assign":457}],203:[function(_dereq_,module,exports){
  23648. _dereq_('../../modules/es.object.create');
  23649. var path = _dereq_('../../internals/path');
  23650. var Object = path.Object;
  23651. module.exports = function create(P, D) {
  23652. return Object.create(P, D);
  23653. };
  23654. },{"../../internals/path":390,"../../modules/es.object.create":458}],204:[function(_dereq_,module,exports){
  23655. _dereq_('../../modules/es.object.define-properties');
  23656. var path = _dereq_('../../internals/path');
  23657. var Object = path.Object;
  23658. var defineProperties = module.exports = function defineProperties(T, D) {
  23659. return Object.defineProperties(T, D);
  23660. };
  23661. if (Object.defineProperties.sham) defineProperties.sham = true;
  23662. },{"../../internals/path":390,"../../modules/es.object.define-properties":459}],205:[function(_dereq_,module,exports){
  23663. _dereq_('../../modules/es.object.define-property');
  23664. var path = _dereq_('../../internals/path');
  23665. var Object = path.Object;
  23666. var defineProperty = module.exports = function defineProperty(it, key, desc) {
  23667. return Object.defineProperty(it, key, desc);
  23668. };
  23669. if (Object.defineProperty.sham) defineProperty.sham = true;
  23670. },{"../../internals/path":390,"../../modules/es.object.define-property":460}],206:[function(_dereq_,module,exports){
  23671. _dereq_('../../modules/es.object.entries');
  23672. var path = _dereq_('../../internals/path');
  23673. module.exports = path.Object.entries;
  23674. },{"../../internals/path":390,"../../modules/es.object.entries":461}],207:[function(_dereq_,module,exports){
  23675. _dereq_('../../modules/es.object.freeze');
  23676. var path = _dereq_('../../internals/path');
  23677. module.exports = path.Object.freeze;
  23678. },{"../../internals/path":390,"../../modules/es.object.freeze":462}],208:[function(_dereq_,module,exports){
  23679. _dereq_('../../modules/es.object.get-own-property-descriptor');
  23680. var path = _dereq_('../../internals/path');
  23681. var Object = path.Object;
  23682. var getOwnPropertyDescriptor = module.exports = function getOwnPropertyDescriptor(it, key) {
  23683. return Object.getOwnPropertyDescriptor(it, key);
  23684. };
  23685. if (Object.getOwnPropertyDescriptor.sham) getOwnPropertyDescriptor.sham = true;
  23686. },{"../../internals/path":390,"../../modules/es.object.get-own-property-descriptor":463}],209:[function(_dereq_,module,exports){
  23687. _dereq_('../../modules/es.object.get-own-property-descriptors');
  23688. var path = _dereq_('../../internals/path');
  23689. module.exports = path.Object.getOwnPropertyDescriptors;
  23690. },{"../../internals/path":390,"../../modules/es.object.get-own-property-descriptors":464}],210:[function(_dereq_,module,exports){
  23691. _dereq_('../../modules/es.symbol');
  23692. var path = _dereq_('../../internals/path');
  23693. module.exports = path.Object.getOwnPropertySymbols;
  23694. },{"../../internals/path":390,"../../modules/es.symbol":496}],211:[function(_dereq_,module,exports){
  23695. _dereq_('../../modules/es.object.get-prototype-of');
  23696. var path = _dereq_('../../internals/path');
  23697. module.exports = path.Object.getPrototypeOf;
  23698. },{"../../internals/path":390,"../../modules/es.object.get-prototype-of":466}],212:[function(_dereq_,module,exports){
  23699. _dereq_('../../modules/es.object.keys');
  23700. var path = _dereq_('../../internals/path');
  23701. module.exports = path.Object.keys;
  23702. },{"../../internals/path":390,"../../modules/es.object.keys":467}],213:[function(_dereq_,module,exports){
  23703. _dereq_('../../modules/es.object.set-prototype-of');
  23704. var path = _dereq_('../../internals/path');
  23705. module.exports = path.Object.setPrototypeOf;
  23706. },{"../../internals/path":390,"../../modules/es.object.set-prototype-of":468}],214:[function(_dereq_,module,exports){
  23707. _dereq_('../modules/es.parse-int');
  23708. var path = _dereq_('../internals/path');
  23709. module.exports = path.parseInt;
  23710. },{"../internals/path":390,"../modules/es.parse-int":470}],215:[function(_dereq_,module,exports){
  23711. _dereq_('../../modules/es.aggregate-error');
  23712. _dereq_('../../modules/es.array.iterator');
  23713. _dereq_('../../modules/es.object.to-string');
  23714. _dereq_('../../modules/es.promise');
  23715. _dereq_('../../modules/es.promise.all-settled');
  23716. _dereq_('../../modules/es.promise.any');
  23717. _dereq_('../../modules/es.promise.finally');
  23718. _dereq_('../../modules/es.string.iterator');
  23719. var path = _dereq_('../../internals/path');
  23720. module.exports = path.Promise;
  23721. },{"../../internals/path":390,"../../modules/es.aggregate-error":432,"../../modules/es.array.iterator":443,"../../modules/es.object.to-string":469,"../../modules/es.promise":477,"../../modules/es.promise.all-settled":471,"../../modules/es.promise.any":473,"../../modules/es.promise.finally":476,"../../modules/es.string.iterator":487}],216:[function(_dereq_,module,exports){
  23722. _dereq_('../../modules/es.reflect.construct');
  23723. var path = _dereq_('../../internals/path');
  23724. module.exports = path.Reflect.construct;
  23725. },{"../../internals/path":390,"../../modules/es.reflect.construct":481}],217:[function(_dereq_,module,exports){
  23726. _dereq_('../../modules/es.reflect.get');
  23727. var path = _dereq_('../../internals/path');
  23728. module.exports = path.Reflect.get;
  23729. },{"../../internals/path":390,"../../modules/es.reflect.get":482}],218:[function(_dereq_,module,exports){
  23730. _dereq_('../../modules/es.array.iterator');
  23731. _dereq_('../../modules/es.object.to-string');
  23732. _dereq_('../../modules/es.set');
  23733. _dereq_('../../modules/es.string.iterator');
  23734. var path = _dereq_('../../internals/path');
  23735. module.exports = path.Set;
  23736. },{"../../internals/path":390,"../../modules/es.array.iterator":443,"../../modules/es.object.to-string":469,"../../modules/es.set":485,"../../modules/es.string.iterator":487}],219:[function(_dereq_,module,exports){
  23737. _dereq_('../../../modules/es.string.includes');
  23738. var entryVirtual = _dereq_('../../../internals/entry-virtual');
  23739. module.exports = entryVirtual('String').includes;
  23740. },{"../../../internals/entry-virtual":314,"../../../modules/es.string.includes":486}],220:[function(_dereq_,module,exports){
  23741. _dereq_('../../../modules/es.string.starts-with');
  23742. var entryVirtual = _dereq_('../../../internals/entry-virtual');
  23743. module.exports = entryVirtual('String').startsWith;
  23744. },{"../../../internals/entry-virtual":314,"../../../modules/es.string.starts-with":488}],221:[function(_dereq_,module,exports){
  23745. _dereq_('../../modules/es.array.concat');
  23746. _dereq_('../../modules/es.object.to-string');
  23747. _dereq_('../../modules/es.symbol');
  23748. _dereq_('../../modules/es.symbol.async-iterator');
  23749. _dereq_('../../modules/es.symbol.description');
  23750. _dereq_('../../modules/es.symbol.has-instance');
  23751. _dereq_('../../modules/es.symbol.is-concat-spreadable');
  23752. _dereq_('../../modules/es.symbol.iterator');
  23753. _dereq_('../../modules/es.symbol.match');
  23754. _dereq_('../../modules/es.symbol.match-all');
  23755. _dereq_('../../modules/es.symbol.replace');
  23756. _dereq_('../../modules/es.symbol.search');
  23757. _dereq_('../../modules/es.symbol.species');
  23758. _dereq_('../../modules/es.symbol.split');
  23759. _dereq_('../../modules/es.symbol.to-primitive');
  23760. _dereq_('../../modules/es.symbol.to-string-tag');
  23761. _dereq_('../../modules/es.symbol.unscopables');
  23762. _dereq_('../../modules/es.json.to-string-tag');
  23763. _dereq_('../../modules/es.math.to-string-tag');
  23764. _dereq_('../../modules/es.reflect.to-string-tag');
  23765. var path = _dereq_('../../internals/path');
  23766. module.exports = path.Symbol;
  23767. },{"../../internals/path":390,"../../modules/es.array.concat":433,"../../modules/es.json.to-string-tag":452,"../../modules/es.math.to-string-tag":455,"../../modules/es.object.to-string":469,"../../modules/es.reflect.to-string-tag":483,"../../modules/es.symbol":496,"../../modules/es.symbol.async-iterator":489,"../../modules/es.symbol.description":491,"../../modules/es.symbol.has-instance":493,"../../modules/es.symbol.is-concat-spreadable":494,"../../modules/es.symbol.iterator":495,"../../modules/es.symbol.match":499,"../../modules/es.symbol.match-all":498,"../../modules/es.symbol.replace":500,"../../modules/es.symbol.search":501,"../../modules/es.symbol.species":502,"../../modules/es.symbol.split":503,"../../modules/es.symbol.to-primitive":504,"../../modules/es.symbol.to-string-tag":505,"../../modules/es.symbol.unscopables":506}],222:[function(_dereq_,module,exports){
  23768. _dereq_('../../modules/es.array.iterator');
  23769. _dereq_('../../modules/es.object.to-string');
  23770. _dereq_('../../modules/es.string.iterator');
  23771. _dereq_('../../modules/es.symbol.iterator');
  23772. var WrappedWellKnownSymbolModule = _dereq_('../../internals/well-known-symbol-wrapped');
  23773. module.exports = WrappedWellKnownSymbolModule.f('iterator');
  23774. },{"../../internals/well-known-symbol-wrapped":428,"../../modules/es.array.iterator":443,"../../modules/es.object.to-string":469,"../../modules/es.string.iterator":487,"../../modules/es.symbol.iterator":495}],223:[function(_dereq_,module,exports){
  23775. _dereq_('../../modules/es.array.iterator');
  23776. _dereq_('../../modules/es.object.to-string');
  23777. _dereq_('../../modules/es.weak-map');
  23778. var path = _dereq_('../../internals/path');
  23779. module.exports = path.WeakMap;
  23780. },{"../../internals/path":390,"../../modules/es.array.iterator":443,"../../modules/es.object.to-string":469,"../../modules/es.weak-map":508}],224:[function(_dereq_,module,exports){
  23781. module.exports = _dereq_('../../full/array/from');
  23782. },{"../../full/array/from":241}],225:[function(_dereq_,module,exports){
  23783. module.exports = _dereq_('../../full/array/is-array');
  23784. },{"../../full/array/is-array":242}],226:[function(_dereq_,module,exports){
  23785. module.exports = _dereq_('../full/get-iterator-method');
  23786. },{"../full/get-iterator-method":243}],227:[function(_dereq_,module,exports){
  23787. module.exports = _dereq_('../../full/instance/bind');
  23788. },{"../../full/instance/bind":244}],228:[function(_dereq_,module,exports){
  23789. module.exports = _dereq_('../../full/instance/index-of');
  23790. },{"../../full/instance/index-of":245}],229:[function(_dereq_,module,exports){
  23791. module.exports = _dereq_('../../full/instance/slice');
  23792. },{"../../full/instance/slice":246}],230:[function(_dereq_,module,exports){
  23793. module.exports = _dereq_('../../full/map');
  23794. },{"../../full/map":247}],231:[function(_dereq_,module,exports){
  23795. module.exports = _dereq_('../../full/object/create');
  23796. },{"../../full/object/create":248}],232:[function(_dereq_,module,exports){
  23797. module.exports = _dereq_('../../full/object/define-property');
  23798. },{"../../full/object/define-property":249}],233:[function(_dereq_,module,exports){
  23799. module.exports = _dereq_('../../full/object/get-own-property-descriptor');
  23800. },{"../../full/object/get-own-property-descriptor":250}],234:[function(_dereq_,module,exports){
  23801. module.exports = _dereq_('../../full/object/get-prototype-of');
  23802. },{"../../full/object/get-prototype-of":251}],235:[function(_dereq_,module,exports){
  23803. module.exports = _dereq_('../../full/object/set-prototype-of');
  23804. },{"../../full/object/set-prototype-of":252}],236:[function(_dereq_,module,exports){
  23805. module.exports = _dereq_('../../full/promise');
  23806. },{"../../full/promise":253}],237:[function(_dereq_,module,exports){
  23807. module.exports = _dereq_('../../full/reflect/construct');
  23808. },{"../../full/reflect/construct":254}],238:[function(_dereq_,module,exports){
  23809. module.exports = _dereq_('../../full/reflect/get');
  23810. },{"../../full/reflect/get":255}],239:[function(_dereq_,module,exports){
  23811. module.exports = _dereq_('../../full/symbol');
  23812. },{"../../full/symbol":256}],240:[function(_dereq_,module,exports){
  23813. module.exports = _dereq_('../../full/symbol/iterator');
  23814. },{"../../full/symbol/iterator":257}],241:[function(_dereq_,module,exports){
  23815. var parent = _dereq_('../../actual/array/from');
  23816. module.exports = parent;
  23817. },{"../../actual/array/from":146}],242:[function(_dereq_,module,exports){
  23818. var parent = _dereq_('../../actual/array/is-array');
  23819. module.exports = parent;
  23820. },{"../../actual/array/is-array":147}],243:[function(_dereq_,module,exports){
  23821. var parent = _dereq_('../actual/get-iterator-method');
  23822. module.exports = parent;
  23823. },{"../actual/get-iterator-method":148}],244:[function(_dereq_,module,exports){
  23824. var parent = _dereq_('../../actual/instance/bind');
  23825. module.exports = parent;
  23826. },{"../../actual/instance/bind":149}],245:[function(_dereq_,module,exports){
  23827. var parent = _dereq_('../../actual/instance/index-of');
  23828. module.exports = parent;
  23829. },{"../../actual/instance/index-of":150}],246:[function(_dereq_,module,exports){
  23830. var parent = _dereq_('../../actual/instance/slice');
  23831. module.exports = parent;
  23832. },{"../../actual/instance/slice":151}],247:[function(_dereq_,module,exports){
  23833. var parent = _dereq_('../../actual/map');
  23834. _dereq_('../../modules/esnext.map.from');
  23835. _dereq_('../../modules/esnext.map.of');
  23836. _dereq_('../../modules/esnext.map.delete-all');
  23837. _dereq_('../../modules/esnext.map.emplace');
  23838. _dereq_('../../modules/esnext.map.every');
  23839. _dereq_('../../modules/esnext.map.filter');
  23840. _dereq_('../../modules/esnext.map.find');
  23841. _dereq_('../../modules/esnext.map.find-key');
  23842. _dereq_('../../modules/esnext.map.group-by');
  23843. _dereq_('../../modules/esnext.map.includes');
  23844. _dereq_('../../modules/esnext.map.key-by');
  23845. _dereq_('../../modules/esnext.map.key-of');
  23846. _dereq_('../../modules/esnext.map.map-keys');
  23847. _dereq_('../../modules/esnext.map.map-values');
  23848. _dereq_('../../modules/esnext.map.merge');
  23849. _dereq_('../../modules/esnext.map.reduce');
  23850. _dereq_('../../modules/esnext.map.some');
  23851. _dereq_('../../modules/esnext.map.update');
  23852. // TODO: remove from `core-js@4`
  23853. _dereq_('../../modules/esnext.map.upsert');
  23854. // TODO: remove from `core-js@4`
  23855. _dereq_('../../modules/esnext.map.update-or-insert');
  23856. module.exports = parent;
  23857. },{"../../actual/map":152,"../../modules/esnext.map.delete-all":510,"../../modules/esnext.map.emplace":511,"../../modules/esnext.map.every":512,"../../modules/esnext.map.filter":513,"../../modules/esnext.map.find":515,"../../modules/esnext.map.find-key":514,"../../modules/esnext.map.from":516,"../../modules/esnext.map.group-by":517,"../../modules/esnext.map.includes":518,"../../modules/esnext.map.key-by":519,"../../modules/esnext.map.key-of":520,"../../modules/esnext.map.map-keys":521,"../../modules/esnext.map.map-values":522,"../../modules/esnext.map.merge":523,"../../modules/esnext.map.of":524,"../../modules/esnext.map.reduce":525,"../../modules/esnext.map.some":526,"../../modules/esnext.map.update":528,"../../modules/esnext.map.update-or-insert":527,"../../modules/esnext.map.upsert":529}],248:[function(_dereq_,module,exports){
  23858. var parent = _dereq_('../../actual/object/create');
  23859. module.exports = parent;
  23860. },{"../../actual/object/create":153}],249:[function(_dereq_,module,exports){
  23861. var parent = _dereq_('../../actual/object/define-property');
  23862. module.exports = parent;
  23863. },{"../../actual/object/define-property":154}],250:[function(_dereq_,module,exports){
  23864. var parent = _dereq_('../../actual/object/get-own-property-descriptor');
  23865. module.exports = parent;
  23866. },{"../../actual/object/get-own-property-descriptor":155}],251:[function(_dereq_,module,exports){
  23867. var parent = _dereq_('../../actual/object/get-prototype-of');
  23868. module.exports = parent;
  23869. },{"../../actual/object/get-prototype-of":156}],252:[function(_dereq_,module,exports){
  23870. var parent = _dereq_('../../actual/object/set-prototype-of');
  23871. module.exports = parent;
  23872. },{"../../actual/object/set-prototype-of":157}],253:[function(_dereq_,module,exports){
  23873. var parent = _dereq_('../../actual/promise');
  23874. _dereq_('../../modules/esnext.aggregate-error');
  23875. // TODO: Remove from `core-js@4`
  23876. _dereq_('../../modules/esnext.promise.all-settled');
  23877. _dereq_('../../modules/esnext.promise.try');
  23878. _dereq_('../../modules/esnext.promise.any');
  23879. module.exports = parent;
  23880. },{"../../actual/promise":158,"../../modules/esnext.aggregate-error":509,"../../modules/esnext.promise.all-settled":530,"../../modules/esnext.promise.any":531,"../../modules/esnext.promise.try":532}],254:[function(_dereq_,module,exports){
  23881. var parent = _dereq_('../../actual/reflect/construct');
  23882. module.exports = parent;
  23883. },{"../../actual/reflect/construct":159}],255:[function(_dereq_,module,exports){
  23884. var parent = _dereq_('../../actual/reflect/get');
  23885. module.exports = parent;
  23886. },{"../../actual/reflect/get":160}],256:[function(_dereq_,module,exports){
  23887. var parent = _dereq_('../../actual/symbol');
  23888. _dereq_('../../modules/esnext.symbol.async-dispose');
  23889. _dereq_('../../modules/esnext.symbol.dispose');
  23890. _dereq_('../../modules/esnext.symbol.matcher');
  23891. _dereq_('../../modules/esnext.symbol.metadata-key');
  23892. _dereq_('../../modules/esnext.symbol.observable');
  23893. // TODO: Remove from `core-js@4`
  23894. _dereq_('../../modules/esnext.symbol.metadata');
  23895. _dereq_('../../modules/esnext.symbol.pattern-match');
  23896. _dereq_('../../modules/esnext.symbol.replace-all');
  23897. module.exports = parent;
  23898. },{"../../actual/symbol":161,"../../modules/esnext.symbol.async-dispose":533,"../../modules/esnext.symbol.dispose":534,"../../modules/esnext.symbol.matcher":535,"../../modules/esnext.symbol.metadata":537,"../../modules/esnext.symbol.metadata-key":536,"../../modules/esnext.symbol.observable":538,"../../modules/esnext.symbol.pattern-match":539,"../../modules/esnext.symbol.replace-all":540}],257:[function(_dereq_,module,exports){
  23899. var parent = _dereq_('../../actual/symbol/iterator');
  23900. module.exports = parent;
  23901. },{"../../actual/symbol/iterator":162}],258:[function(_dereq_,module,exports){
  23902. var isCallable = _dereq_('../internals/is-callable');
  23903. var tryToString = _dereq_('../internals/try-to-string');
  23904. var $TypeError = TypeError;
  23905. // `Assert: IsCallable(argument) is true`
  23906. module.exports = function (argument) {
  23907. if (isCallable(argument)) return argument;
  23908. throw $TypeError(tryToString(argument) + ' is not a function');
  23909. };
  23910. },{"../internals/is-callable":346,"../internals/try-to-string":421}],259:[function(_dereq_,module,exports){
  23911. var isConstructor = _dereq_('../internals/is-constructor');
  23912. var tryToString = _dereq_('../internals/try-to-string');
  23913. var $TypeError = TypeError;
  23914. // `Assert: IsConstructor(argument) is true`
  23915. module.exports = function (argument) {
  23916. if (isConstructor(argument)) return argument;
  23917. throw $TypeError(tryToString(argument) + ' is not a constructor');
  23918. };
  23919. },{"../internals/is-constructor":347,"../internals/try-to-string":421}],260:[function(_dereq_,module,exports){
  23920. var isCallable = _dereq_('../internals/is-callable');
  23921. var $String = String;
  23922. var $TypeError = TypeError;
  23923. module.exports = function (argument) {
  23924. if (typeof argument == 'object' || isCallable(argument)) return argument;
  23925. throw $TypeError("Can't set " + $String(argument) + ' as a prototype');
  23926. };
  23927. },{"../internals/is-callable":346}],261:[function(_dereq_,module,exports){
  23928. module.exports = function () { /* empty */ };
  23929. },{}],262:[function(_dereq_,module,exports){
  23930. var isPrototypeOf = _dereq_('../internals/object-is-prototype-of');
  23931. var $TypeError = TypeError;
  23932. module.exports = function (it, Prototype) {
  23933. if (isPrototypeOf(Prototype, it)) return it;
  23934. throw $TypeError('Incorrect invocation');
  23935. };
  23936. },{"../internals/object-is-prototype-of":381}],263:[function(_dereq_,module,exports){
  23937. var isObject = _dereq_('../internals/is-object');
  23938. var $String = String;
  23939. var $TypeError = TypeError;
  23940. // `Assert: Type(argument) is Object`
  23941. module.exports = function (argument) {
  23942. if (isObject(argument)) return argument;
  23943. throw $TypeError($String(argument) + ' is not an object');
  23944. };
  23945. },{"../internals/is-object":352}],264:[function(_dereq_,module,exports){
  23946. // FF26- bug: ArrayBuffers are non-extensible, but Object.isExtensible does not report it
  23947. var fails = _dereq_('../internals/fails');
  23948. module.exports = fails(function () {
  23949. if (typeof ArrayBuffer == 'function') {
  23950. var buffer = new ArrayBuffer(8);
  23951. // eslint-disable-next-line es-x/no-object-isextensible, es-x/no-object-defineproperty -- safe
  23952. if (Object.isExtensible(buffer)) Object.defineProperty(buffer, 'a', { value: 8 });
  23953. }
  23954. });
  23955. },{"../internals/fails":319}],265:[function(_dereq_,module,exports){
  23956. 'use strict';
  23957. var $forEach = _dereq_('../internals/array-iteration').forEach;
  23958. var arrayMethodIsStrict = _dereq_('../internals/array-method-is-strict');
  23959. var STRICT_METHOD = arrayMethodIsStrict('forEach');
  23960. // `Array.prototype.forEach` method implementation
  23961. // https://tc39.es/ecma262/#sec-array.prototype.foreach
  23962. module.exports = !STRICT_METHOD ? function forEach(callbackfn /* , thisArg */) {
  23963. return $forEach(this, callbackfn, arguments.length > 1 ? arguments[1] : undefined);
  23964. // eslint-disable-next-line es-x/no-array-prototype-foreach -- safe
  23965. } : [].forEach;
  23966. },{"../internals/array-iteration":268,"../internals/array-method-is-strict":270}],266:[function(_dereq_,module,exports){
  23967. 'use strict';
  23968. var bind = _dereq_('../internals/function-bind-context');
  23969. var call = _dereq_('../internals/function-call');
  23970. var toObject = _dereq_('../internals/to-object');
  23971. var callWithSafeIterationClosing = _dereq_('../internals/call-with-safe-iteration-closing');
  23972. var isArrayIteratorMethod = _dereq_('../internals/is-array-iterator-method');
  23973. var isConstructor = _dereq_('../internals/is-constructor');
  23974. var lengthOfArrayLike = _dereq_('../internals/length-of-array-like');
  23975. var createProperty = _dereq_('../internals/create-property');
  23976. var getIterator = _dereq_('../internals/get-iterator');
  23977. var getIteratorMethod = _dereq_('../internals/get-iterator-method');
  23978. var $Array = Array;
  23979. // `Array.from` method implementation
  23980. // https://tc39.es/ecma262/#sec-array.from
  23981. module.exports = function from(arrayLike /* , mapfn = undefined, thisArg = undefined */) {
  23982. var O = toObject(arrayLike);
  23983. var IS_CONSTRUCTOR = isConstructor(this);
  23984. var argumentsLength = arguments.length;
  23985. var mapfn = argumentsLength > 1 ? arguments[1] : undefined;
  23986. var mapping = mapfn !== undefined;
  23987. if (mapping) mapfn = bind(mapfn, argumentsLength > 2 ? arguments[2] : undefined);
  23988. var iteratorMethod = getIteratorMethod(O);
  23989. var index = 0;
  23990. var length, result, step, iterator, next, value;
  23991. // if the target is not iterable or it's an array with the default iterator - use a simple case
  23992. if (iteratorMethod && !(this === $Array && isArrayIteratorMethod(iteratorMethod))) {
  23993. iterator = getIterator(O, iteratorMethod);
  23994. next = iterator.next;
  23995. result = IS_CONSTRUCTOR ? new this() : [];
  23996. for (;!(step = call(next, iterator)).done; index++) {
  23997. value = mapping ? callWithSafeIterationClosing(iterator, mapfn, [step.value, index], true) : step.value;
  23998. createProperty(result, index, value);
  23999. }
  24000. } else {
  24001. length = lengthOfArrayLike(O);
  24002. result = IS_CONSTRUCTOR ? new this(length) : $Array(length);
  24003. for (;length > index; index++) {
  24004. value = mapping ? mapfn(O[index], index) : O[index];
  24005. createProperty(result, index, value);
  24006. }
  24007. }
  24008. result.length = index;
  24009. return result;
  24010. };
  24011. },{"../internals/call-with-safe-iteration-closing":278,"../internals/create-property":294,"../internals/function-bind-context":322,"../internals/function-call":325,"../internals/get-iterator":330,"../internals/get-iterator-method":329,"../internals/is-array-iterator-method":344,"../internals/is-constructor":347,"../internals/length-of-array-like":362,"../internals/to-object":416}],267:[function(_dereq_,module,exports){
  24012. var toIndexedObject = _dereq_('../internals/to-indexed-object');
  24013. var toAbsoluteIndex = _dereq_('../internals/to-absolute-index');
  24014. var lengthOfArrayLike = _dereq_('../internals/length-of-array-like');
  24015. // `Array.prototype.{ indexOf, includes }` methods implementation
  24016. var createMethod = function (IS_INCLUDES) {
  24017. return function ($this, el, fromIndex) {
  24018. var O = toIndexedObject($this);
  24019. var length = lengthOfArrayLike(O);
  24020. var index = toAbsoluteIndex(fromIndex, length);
  24021. var value;
  24022. // Array#includes uses SameValueZero equality algorithm
  24023. // eslint-disable-next-line no-self-compare -- NaN check
  24024. if (IS_INCLUDES && el != el) while (length > index) {
  24025. value = O[index++];
  24026. // eslint-disable-next-line no-self-compare -- NaN check
  24027. if (value != value) return true;
  24028. // Array#indexOf ignores holes, Array#includes - not
  24029. } else for (;length > index; index++) {
  24030. if ((IS_INCLUDES || index in O) && O[index] === el) return IS_INCLUDES || index || 0;
  24031. } return !IS_INCLUDES && -1;
  24032. };
  24033. };
  24034. module.exports = {
  24035. // `Array.prototype.includes` method
  24036. // https://tc39.es/ecma262/#sec-array.prototype.includes
  24037. includes: createMethod(true),
  24038. // `Array.prototype.indexOf` method
  24039. // https://tc39.es/ecma262/#sec-array.prototype.indexof
  24040. indexOf: createMethod(false)
  24041. };
  24042. },{"../internals/length-of-array-like":362,"../internals/to-absolute-index":412,"../internals/to-indexed-object":413}],268:[function(_dereq_,module,exports){
  24043. var bind = _dereq_('../internals/function-bind-context');
  24044. var uncurryThis = _dereq_('../internals/function-uncurry-this');
  24045. var IndexedObject = _dereq_('../internals/indexed-object');
  24046. var toObject = _dereq_('../internals/to-object');
  24047. var lengthOfArrayLike = _dereq_('../internals/length-of-array-like');
  24048. var arraySpeciesCreate = _dereq_('../internals/array-species-create');
  24049. var push = uncurryThis([].push);
  24050. // `Array.prototype.{ forEach, map, filter, some, every, find, findIndex, filterReject }` methods implementation
  24051. var createMethod = function (TYPE) {
  24052. var IS_MAP = TYPE == 1;
  24053. var IS_FILTER = TYPE == 2;
  24054. var IS_SOME = TYPE == 3;
  24055. var IS_EVERY = TYPE == 4;
  24056. var IS_FIND_INDEX = TYPE == 6;
  24057. var IS_FILTER_REJECT = TYPE == 7;
  24058. var NO_HOLES = TYPE == 5 || IS_FIND_INDEX;
  24059. return function ($this, callbackfn, that, specificCreate) {
  24060. var O = toObject($this);
  24061. var self = IndexedObject(O);
  24062. var boundFunction = bind(callbackfn, that);
  24063. var length = lengthOfArrayLike(self);
  24064. var index = 0;
  24065. var create = specificCreate || arraySpeciesCreate;
  24066. var target = IS_MAP ? create($this, length) : IS_FILTER || IS_FILTER_REJECT ? create($this, 0) : undefined;
  24067. var value, result;
  24068. for (;length > index; index++) if (NO_HOLES || index in self) {
  24069. value = self[index];
  24070. result = boundFunction(value, index, O);
  24071. if (TYPE) {
  24072. if (IS_MAP) target[index] = result; // map
  24073. else if (result) switch (TYPE) {
  24074. case 3: return true; // some
  24075. case 5: return value; // find
  24076. case 6: return index; // findIndex
  24077. case 2: push(target, value); // filter
  24078. } else switch (TYPE) {
  24079. case 4: return false; // every
  24080. case 7: push(target, value); // filterReject
  24081. }
  24082. }
  24083. }
  24084. return IS_FIND_INDEX ? -1 : IS_SOME || IS_EVERY ? IS_EVERY : target;
  24085. };
  24086. };
  24087. module.exports = {
  24088. // `Array.prototype.forEach` method
  24089. // https://tc39.es/ecma262/#sec-array.prototype.foreach
  24090. forEach: createMethod(0),
  24091. // `Array.prototype.map` method
  24092. // https://tc39.es/ecma262/#sec-array.prototype.map
  24093. map: createMethod(1),
  24094. // `Array.prototype.filter` method
  24095. // https://tc39.es/ecma262/#sec-array.prototype.filter
  24096. filter: createMethod(2),
  24097. // `Array.prototype.some` method
  24098. // https://tc39.es/ecma262/#sec-array.prototype.some
  24099. some: createMethod(3),
  24100. // `Array.prototype.every` method
  24101. // https://tc39.es/ecma262/#sec-array.prototype.every
  24102. every: createMethod(4),
  24103. // `Array.prototype.find` method
  24104. // https://tc39.es/ecma262/#sec-array.prototype.find
  24105. find: createMethod(5),
  24106. // `Array.prototype.findIndex` method
  24107. // https://tc39.es/ecma262/#sec-array.prototype.findIndex
  24108. findIndex: createMethod(6),
  24109. // `Array.prototype.filterReject` method
  24110. // https://github.com/tc39/proposal-array-filtering
  24111. filterReject: createMethod(7)
  24112. };
  24113. },{"../internals/array-species-create":277,"../internals/function-bind-context":322,"../internals/function-uncurry-this":327,"../internals/indexed-object":339,"../internals/length-of-array-like":362,"../internals/to-object":416}],269:[function(_dereq_,module,exports){
  24114. var fails = _dereq_('../internals/fails');
  24115. var wellKnownSymbol = _dereq_('../internals/well-known-symbol');
  24116. var V8_VERSION = _dereq_('../internals/engine-v8-version');
  24117. var SPECIES = wellKnownSymbol('species');
  24118. module.exports = function (METHOD_NAME) {
  24119. // We can't use this feature detection in V8 since it causes
  24120. // deoptimization and serious performance degradation
  24121. // https://github.com/zloirock/core-js/issues/677
  24122. return V8_VERSION >= 51 || !fails(function () {
  24123. var array = [];
  24124. var constructor = array.constructor = {};
  24125. constructor[SPECIES] = function () {
  24126. return { foo: 1 };
  24127. };
  24128. return array[METHOD_NAME](Boolean).foo !== 1;
  24129. });
  24130. };
  24131. },{"../internals/engine-v8-version":312,"../internals/fails":319,"../internals/well-known-symbol":429}],270:[function(_dereq_,module,exports){
  24132. 'use strict';
  24133. var fails = _dereq_('../internals/fails');
  24134. module.exports = function (METHOD_NAME, argument) {
  24135. var method = [][METHOD_NAME];
  24136. return !!method && fails(function () {
  24137. // eslint-disable-next-line no-useless-call -- required for testing
  24138. method.call(null, argument || function () { return 1; }, 1);
  24139. });
  24140. };
  24141. },{"../internals/fails":319}],271:[function(_dereq_,module,exports){
  24142. var aCallable = _dereq_('../internals/a-callable');
  24143. var toObject = _dereq_('../internals/to-object');
  24144. var IndexedObject = _dereq_('../internals/indexed-object');
  24145. var lengthOfArrayLike = _dereq_('../internals/length-of-array-like');
  24146. var $TypeError = TypeError;
  24147. // `Array.prototype.{ reduce, reduceRight }` methods implementation
  24148. var createMethod = function (IS_RIGHT) {
  24149. return function (that, callbackfn, argumentsLength, memo) {
  24150. aCallable(callbackfn);
  24151. var O = toObject(that);
  24152. var self = IndexedObject(O);
  24153. var length = lengthOfArrayLike(O);
  24154. var index = IS_RIGHT ? length - 1 : 0;
  24155. var i = IS_RIGHT ? -1 : 1;
  24156. if (argumentsLength < 2) while (true) {
  24157. if (index in self) {
  24158. memo = self[index];
  24159. index += i;
  24160. break;
  24161. }
  24162. index += i;
  24163. if (IS_RIGHT ? index < 0 : length <= index) {
  24164. throw $TypeError('Reduce of empty array with no initial value');
  24165. }
  24166. }
  24167. for (;IS_RIGHT ? index >= 0 : length > index; index += i) if (index in self) {
  24168. memo = callbackfn(memo, self[index], index, O);
  24169. }
  24170. return memo;
  24171. };
  24172. };
  24173. module.exports = {
  24174. // `Array.prototype.reduce` method
  24175. // https://tc39.es/ecma262/#sec-array.prototype.reduce
  24176. left: createMethod(false),
  24177. // `Array.prototype.reduceRight` method
  24178. // https://tc39.es/ecma262/#sec-array.prototype.reduceright
  24179. right: createMethod(true)
  24180. };
  24181. },{"../internals/a-callable":258,"../internals/indexed-object":339,"../internals/length-of-array-like":362,"../internals/to-object":416}],272:[function(_dereq_,module,exports){
  24182. 'use strict';
  24183. var DESCRIPTORS = _dereq_('../internals/descriptors');
  24184. var isArray = _dereq_('../internals/is-array');
  24185. var $TypeError = TypeError;
  24186. // eslint-disable-next-line es-x/no-object-getownpropertydescriptor -- safe
  24187. var getOwnPropertyDescriptor = Object.getOwnPropertyDescriptor;
  24188. // Safari < 13 does not throw an error in this case
  24189. var SILENT_ON_NON_WRITABLE_LENGTH_SET = DESCRIPTORS && !function () {
  24190. // makes no sense without proper strict mode support
  24191. if (this !== undefined) return true;
  24192. try {
  24193. // eslint-disable-next-line es-x/no-object-defineproperty -- safe
  24194. Object.defineProperty([], 'length', { writable: false }).length = 1;
  24195. } catch (error) {
  24196. return error instanceof TypeError;
  24197. }
  24198. }();
  24199. module.exports = SILENT_ON_NON_WRITABLE_LENGTH_SET ? function (O, length) {
  24200. if (isArray(O) && !getOwnPropertyDescriptor(O, 'length').writable) {
  24201. throw $TypeError('Cannot set read only .length');
  24202. } return O.length = length;
  24203. } : function (O, length) {
  24204. return O.length = length;
  24205. };
  24206. },{"../internals/descriptors":299,"../internals/is-array":345}],273:[function(_dereq_,module,exports){
  24207. var toAbsoluteIndex = _dereq_('../internals/to-absolute-index');
  24208. var lengthOfArrayLike = _dereq_('../internals/length-of-array-like');
  24209. var createProperty = _dereq_('../internals/create-property');
  24210. var $Array = Array;
  24211. var max = Math.max;
  24212. module.exports = function (O, start, end) {
  24213. var length = lengthOfArrayLike(O);
  24214. var k = toAbsoluteIndex(start, length);
  24215. var fin = toAbsoluteIndex(end === undefined ? length : end, length);
  24216. var result = $Array(max(fin - k, 0));
  24217. for (var n = 0; k < fin; k++, n++) createProperty(result, n, O[k]);
  24218. result.length = n;
  24219. return result;
  24220. };
  24221. },{"../internals/create-property":294,"../internals/length-of-array-like":362,"../internals/to-absolute-index":412}],274:[function(_dereq_,module,exports){
  24222. var uncurryThis = _dereq_('../internals/function-uncurry-this');
  24223. module.exports = uncurryThis([].slice);
  24224. },{"../internals/function-uncurry-this":327}],275:[function(_dereq_,module,exports){
  24225. var arraySlice = _dereq_('../internals/array-slice-simple');
  24226. var floor = Math.floor;
  24227. var mergeSort = function (array, comparefn) {
  24228. var length = array.length;
  24229. var middle = floor(length / 2);
  24230. return length < 8 ? insertionSort(array, comparefn) : merge(
  24231. array,
  24232. mergeSort(arraySlice(array, 0, middle), comparefn),
  24233. mergeSort(arraySlice(array, middle), comparefn),
  24234. comparefn
  24235. );
  24236. };
  24237. var insertionSort = function (array, comparefn) {
  24238. var length = array.length;
  24239. var i = 1;
  24240. var element, j;
  24241. while (i < length) {
  24242. j = i;
  24243. element = array[i];
  24244. while (j && comparefn(array[j - 1], element) > 0) {
  24245. array[j] = array[--j];
  24246. }
  24247. if (j !== i++) array[j] = element;
  24248. } return array;
  24249. };
  24250. var merge = function (array, left, right, comparefn) {
  24251. var llength = left.length;
  24252. var rlength = right.length;
  24253. var lindex = 0;
  24254. var rindex = 0;
  24255. while (lindex < llength || rindex < rlength) {
  24256. array[lindex + rindex] = (lindex < llength && rindex < rlength)
  24257. ? comparefn(left[lindex], right[rindex]) <= 0 ? left[lindex++] : right[rindex++]
  24258. : lindex < llength ? left[lindex++] : right[rindex++];
  24259. } return array;
  24260. };
  24261. module.exports = mergeSort;
  24262. },{"../internals/array-slice-simple":273}],276:[function(_dereq_,module,exports){
  24263. var isArray = _dereq_('../internals/is-array');
  24264. var isConstructor = _dereq_('../internals/is-constructor');
  24265. var isObject = _dereq_('../internals/is-object');
  24266. var wellKnownSymbol = _dereq_('../internals/well-known-symbol');
  24267. var SPECIES = wellKnownSymbol('species');
  24268. var $Array = Array;
  24269. // a part of `ArraySpeciesCreate` abstract operation
  24270. // https://tc39.es/ecma262/#sec-arrayspeciescreate
  24271. module.exports = function (originalArray) {
  24272. var C;
  24273. if (isArray(originalArray)) {
  24274. C = originalArray.constructor;
  24275. // cross-realm fallback
  24276. if (isConstructor(C) && (C === $Array || isArray(C.prototype))) C = undefined;
  24277. else if (isObject(C)) {
  24278. C = C[SPECIES];
  24279. if (C === null) C = undefined;
  24280. }
  24281. } return C === undefined ? $Array : C;
  24282. };
  24283. },{"../internals/is-array":345,"../internals/is-constructor":347,"../internals/is-object":352,"../internals/well-known-symbol":429}],277:[function(_dereq_,module,exports){
  24284. var arraySpeciesConstructor = _dereq_('../internals/array-species-constructor');
  24285. // `ArraySpeciesCreate` abstract operation
  24286. // https://tc39.es/ecma262/#sec-arrayspeciescreate
  24287. module.exports = function (originalArray, length) {
  24288. return new (arraySpeciesConstructor(originalArray))(length === 0 ? 0 : length);
  24289. };
  24290. },{"../internals/array-species-constructor":276}],278:[function(_dereq_,module,exports){
  24291. var anObject = _dereq_('../internals/an-object');
  24292. var iteratorClose = _dereq_('../internals/iterator-close');
  24293. // call something on iterator step with safe closing on error
  24294. module.exports = function (iterator, fn, value, ENTRIES) {
  24295. try {
  24296. return ENTRIES ? fn(anObject(value)[0], value[1]) : fn(value);
  24297. } catch (error) {
  24298. iteratorClose(iterator, 'throw', error);
  24299. }
  24300. };
  24301. },{"../internals/an-object":263,"../internals/iterator-close":357}],279:[function(_dereq_,module,exports){
  24302. var wellKnownSymbol = _dereq_('../internals/well-known-symbol');
  24303. var ITERATOR = wellKnownSymbol('iterator');
  24304. var SAFE_CLOSING = false;
  24305. try {
  24306. var called = 0;
  24307. var iteratorWithReturn = {
  24308. next: function () {
  24309. return { done: !!called++ };
  24310. },
  24311. 'return': function () {
  24312. SAFE_CLOSING = true;
  24313. }
  24314. };
  24315. iteratorWithReturn[ITERATOR] = function () {
  24316. return this;
  24317. };
  24318. // eslint-disable-next-line es-x/no-array-from, no-throw-literal -- required for testing
  24319. Array.from(iteratorWithReturn, function () { throw 2; });
  24320. } catch (error) { /* empty */ }
  24321. module.exports = function (exec, SKIP_CLOSING) {
  24322. if (!SKIP_CLOSING && !SAFE_CLOSING) return false;
  24323. var ITERATION_SUPPORT = false;
  24324. try {
  24325. var object = {};
  24326. object[ITERATOR] = function () {
  24327. return {
  24328. next: function () {
  24329. return { done: ITERATION_SUPPORT = true };
  24330. }
  24331. };
  24332. };
  24333. exec(object);
  24334. } catch (error) { /* empty */ }
  24335. return ITERATION_SUPPORT;
  24336. };
  24337. },{"../internals/well-known-symbol":429}],280:[function(_dereq_,module,exports){
  24338. var uncurryThis = _dereq_('../internals/function-uncurry-this');
  24339. var toString = uncurryThis({}.toString);
  24340. var stringSlice = uncurryThis(''.slice);
  24341. module.exports = function (it) {
  24342. return stringSlice(toString(it), 8, -1);
  24343. };
  24344. },{"../internals/function-uncurry-this":327}],281:[function(_dereq_,module,exports){
  24345. var TO_STRING_TAG_SUPPORT = _dereq_('../internals/to-string-tag-support');
  24346. var isCallable = _dereq_('../internals/is-callable');
  24347. var classofRaw = _dereq_('../internals/classof-raw');
  24348. var wellKnownSymbol = _dereq_('../internals/well-known-symbol');
  24349. var TO_STRING_TAG = wellKnownSymbol('toStringTag');
  24350. var $Object = Object;
  24351. // ES3 wrong here
  24352. var CORRECT_ARGUMENTS = classofRaw(function () { return arguments; }()) == 'Arguments';
  24353. // fallback for IE11 Script Access Denied error
  24354. var tryGet = function (it, key) {
  24355. try {
  24356. return it[key];
  24357. } catch (error) { /* empty */ }
  24358. };
  24359. // getting tag from ES6+ `Object.prototype.toString`
  24360. module.exports = TO_STRING_TAG_SUPPORT ? classofRaw : function (it) {
  24361. var O, tag, result;
  24362. return it === undefined ? 'Undefined' : it === null ? 'Null'
  24363. // @@toStringTag case
  24364. : typeof (tag = tryGet(O = $Object(it), TO_STRING_TAG)) == 'string' ? tag
  24365. // builtinTag case
  24366. : CORRECT_ARGUMENTS ? classofRaw(O)
  24367. // ES3 arguments fallback
  24368. : (result = classofRaw(O)) == 'Object' && isCallable(O.callee) ? 'Arguments' : result;
  24369. };
  24370. },{"../internals/classof-raw":280,"../internals/is-callable":346,"../internals/to-string-tag-support":419,"../internals/well-known-symbol":429}],282:[function(_dereq_,module,exports){
  24371. 'use strict';
  24372. var call = _dereq_('../internals/function-call');
  24373. var aCallable = _dereq_('../internals/a-callable');
  24374. var anObject = _dereq_('../internals/an-object');
  24375. // https://github.com/tc39/collection-methods
  24376. module.exports = function deleteAll(/* ...elements */) {
  24377. var collection = anObject(this);
  24378. var remover = aCallable(collection['delete']);
  24379. var allDeleted = true;
  24380. var wasDeleted;
  24381. for (var k = 0, len = arguments.length; k < len; k++) {
  24382. wasDeleted = call(remover, collection, arguments[k]);
  24383. allDeleted = allDeleted && wasDeleted;
  24384. }
  24385. return !!allDeleted;
  24386. };
  24387. },{"../internals/a-callable":258,"../internals/an-object":263,"../internals/function-call":325}],283:[function(_dereq_,module,exports){
  24388. 'use strict';
  24389. // https://tc39.github.io/proposal-setmap-offrom/
  24390. var bind = _dereq_('../internals/function-bind-context');
  24391. var call = _dereq_('../internals/function-call');
  24392. var aCallable = _dereq_('../internals/a-callable');
  24393. var aConstructor = _dereq_('../internals/a-constructor');
  24394. var isNullOrUndefined = _dereq_('../internals/is-null-or-undefined');
  24395. var iterate = _dereq_('../internals/iterate');
  24396. var push = [].push;
  24397. module.exports = function from(source /* , mapFn, thisArg */) {
  24398. var length = arguments.length;
  24399. var mapFn = length > 1 ? arguments[1] : undefined;
  24400. var mapping, array, n, boundFunction;
  24401. aConstructor(this);
  24402. mapping = mapFn !== undefined;
  24403. if (mapping) aCallable(mapFn);
  24404. if (isNullOrUndefined(source)) return new this();
  24405. array = [];
  24406. if (mapping) {
  24407. n = 0;
  24408. boundFunction = bind(mapFn, length > 2 ? arguments[2] : undefined);
  24409. iterate(source, function (nextItem) {
  24410. call(push, array, boundFunction(nextItem, n++));
  24411. });
  24412. } else {
  24413. iterate(source, push, { that: array });
  24414. }
  24415. return new this(array);
  24416. };
  24417. },{"../internals/a-callable":258,"../internals/a-constructor":259,"../internals/function-bind-context":322,"../internals/function-call":325,"../internals/is-null-or-undefined":351,"../internals/iterate":356}],284:[function(_dereq_,module,exports){
  24418. 'use strict';
  24419. var arraySlice = _dereq_('../internals/array-slice');
  24420. // https://tc39.github.io/proposal-setmap-offrom/
  24421. module.exports = function of() {
  24422. return new this(arraySlice(arguments));
  24423. };
  24424. },{"../internals/array-slice":274}],285:[function(_dereq_,module,exports){
  24425. 'use strict';
  24426. var defineProperty = _dereq_('../internals/object-define-property').f;
  24427. var create = _dereq_('../internals/object-create');
  24428. var defineBuiltIns = _dereq_('../internals/define-built-ins');
  24429. var bind = _dereq_('../internals/function-bind-context');
  24430. var anInstance = _dereq_('../internals/an-instance');
  24431. var isNullOrUndefined = _dereq_('../internals/is-null-or-undefined');
  24432. var iterate = _dereq_('../internals/iterate');
  24433. var defineIterator = _dereq_('../internals/iterator-define');
  24434. var createIterResultObject = _dereq_('../internals/create-iter-result-object');
  24435. var setSpecies = _dereq_('../internals/set-species');
  24436. var DESCRIPTORS = _dereq_('../internals/descriptors');
  24437. var fastKey = _dereq_('../internals/internal-metadata').fastKey;
  24438. var InternalStateModule = _dereq_('../internals/internal-state');
  24439. var setInternalState = InternalStateModule.set;
  24440. var internalStateGetterFor = InternalStateModule.getterFor;
  24441. module.exports = {
  24442. getConstructor: function (wrapper, CONSTRUCTOR_NAME, IS_MAP, ADDER) {
  24443. var Constructor = wrapper(function (that, iterable) {
  24444. anInstance(that, Prototype);
  24445. setInternalState(that, {
  24446. type: CONSTRUCTOR_NAME,
  24447. index: create(null),
  24448. first: undefined,
  24449. last: undefined,
  24450. size: 0
  24451. });
  24452. if (!DESCRIPTORS) that.size = 0;
  24453. if (!isNullOrUndefined(iterable)) iterate(iterable, that[ADDER], { that: that, AS_ENTRIES: IS_MAP });
  24454. });
  24455. var Prototype = Constructor.prototype;
  24456. var getInternalState = internalStateGetterFor(CONSTRUCTOR_NAME);
  24457. var define = function (that, key, value) {
  24458. var state = getInternalState(that);
  24459. var entry = getEntry(that, key);
  24460. var previous, index;
  24461. // change existing entry
  24462. if (entry) {
  24463. entry.value = value;
  24464. // create new entry
  24465. } else {
  24466. state.last = entry = {
  24467. index: index = fastKey(key, true),
  24468. key: key,
  24469. value: value,
  24470. previous: previous = state.last,
  24471. next: undefined,
  24472. removed: false
  24473. };
  24474. if (!state.first) state.first = entry;
  24475. if (previous) previous.next = entry;
  24476. if (DESCRIPTORS) state.size++;
  24477. else that.size++;
  24478. // add to index
  24479. if (index !== 'F') state.index[index] = entry;
  24480. } return that;
  24481. };
  24482. var getEntry = function (that, key) {
  24483. var state = getInternalState(that);
  24484. // fast case
  24485. var index = fastKey(key);
  24486. var entry;
  24487. if (index !== 'F') return state.index[index];
  24488. // frozen object case
  24489. for (entry = state.first; entry; entry = entry.next) {
  24490. if (entry.key == key) return entry;
  24491. }
  24492. };
  24493. defineBuiltIns(Prototype, {
  24494. // `{ Map, Set }.prototype.clear()` methods
  24495. // https://tc39.es/ecma262/#sec-map.prototype.clear
  24496. // https://tc39.es/ecma262/#sec-set.prototype.clear
  24497. clear: function clear() {
  24498. var that = this;
  24499. var state = getInternalState(that);
  24500. var data = state.index;
  24501. var entry = state.first;
  24502. while (entry) {
  24503. entry.removed = true;
  24504. if (entry.previous) entry.previous = entry.previous.next = undefined;
  24505. delete data[entry.index];
  24506. entry = entry.next;
  24507. }
  24508. state.first = state.last = undefined;
  24509. if (DESCRIPTORS) state.size = 0;
  24510. else that.size = 0;
  24511. },
  24512. // `{ Map, Set }.prototype.delete(key)` methods
  24513. // https://tc39.es/ecma262/#sec-map.prototype.delete
  24514. // https://tc39.es/ecma262/#sec-set.prototype.delete
  24515. 'delete': function (key) {
  24516. var that = this;
  24517. var state = getInternalState(that);
  24518. var entry = getEntry(that, key);
  24519. if (entry) {
  24520. var next = entry.next;
  24521. var prev = entry.previous;
  24522. delete state.index[entry.index];
  24523. entry.removed = true;
  24524. if (prev) prev.next = next;
  24525. if (next) next.previous = prev;
  24526. if (state.first == entry) state.first = next;
  24527. if (state.last == entry) state.last = prev;
  24528. if (DESCRIPTORS) state.size--;
  24529. else that.size--;
  24530. } return !!entry;
  24531. },
  24532. // `{ Map, Set }.prototype.forEach(callbackfn, thisArg = undefined)` methods
  24533. // https://tc39.es/ecma262/#sec-map.prototype.foreach
  24534. // https://tc39.es/ecma262/#sec-set.prototype.foreach
  24535. forEach: function forEach(callbackfn /* , that = undefined */) {
  24536. var state = getInternalState(this);
  24537. var boundFunction = bind(callbackfn, arguments.length > 1 ? arguments[1] : undefined);
  24538. var entry;
  24539. while (entry = entry ? entry.next : state.first) {
  24540. boundFunction(entry.value, entry.key, this);
  24541. // revert to the last existing entry
  24542. while (entry && entry.removed) entry = entry.previous;
  24543. }
  24544. },
  24545. // `{ Map, Set}.prototype.has(key)` methods
  24546. // https://tc39.es/ecma262/#sec-map.prototype.has
  24547. // https://tc39.es/ecma262/#sec-set.prototype.has
  24548. has: function has(key) {
  24549. return !!getEntry(this, key);
  24550. }
  24551. });
  24552. defineBuiltIns(Prototype, IS_MAP ? {
  24553. // `Map.prototype.get(key)` method
  24554. // https://tc39.es/ecma262/#sec-map.prototype.get
  24555. get: function get(key) {
  24556. var entry = getEntry(this, key);
  24557. return entry && entry.value;
  24558. },
  24559. // `Map.prototype.set(key, value)` method
  24560. // https://tc39.es/ecma262/#sec-map.prototype.set
  24561. set: function set(key, value) {
  24562. return define(this, key === 0 ? 0 : key, value);
  24563. }
  24564. } : {
  24565. // `Set.prototype.add(value)` method
  24566. // https://tc39.es/ecma262/#sec-set.prototype.add
  24567. add: function add(value) {
  24568. return define(this, value = value === 0 ? 0 : value, value);
  24569. }
  24570. });
  24571. if (DESCRIPTORS) defineProperty(Prototype, 'size', {
  24572. get: function () {
  24573. return getInternalState(this).size;
  24574. }
  24575. });
  24576. return Constructor;
  24577. },
  24578. setStrong: function (Constructor, CONSTRUCTOR_NAME, IS_MAP) {
  24579. var ITERATOR_NAME = CONSTRUCTOR_NAME + ' Iterator';
  24580. var getInternalCollectionState = internalStateGetterFor(CONSTRUCTOR_NAME);
  24581. var getInternalIteratorState = internalStateGetterFor(ITERATOR_NAME);
  24582. // `{ Map, Set }.prototype.{ keys, values, entries, @@iterator }()` methods
  24583. // https://tc39.es/ecma262/#sec-map.prototype.entries
  24584. // https://tc39.es/ecma262/#sec-map.prototype.keys
  24585. // https://tc39.es/ecma262/#sec-map.prototype.values
  24586. // https://tc39.es/ecma262/#sec-map.prototype-@@iterator
  24587. // https://tc39.es/ecma262/#sec-set.prototype.entries
  24588. // https://tc39.es/ecma262/#sec-set.prototype.keys
  24589. // https://tc39.es/ecma262/#sec-set.prototype.values
  24590. // https://tc39.es/ecma262/#sec-set.prototype-@@iterator
  24591. defineIterator(Constructor, CONSTRUCTOR_NAME, function (iterated, kind) {
  24592. setInternalState(this, {
  24593. type: ITERATOR_NAME,
  24594. target: iterated,
  24595. state: getInternalCollectionState(iterated),
  24596. kind: kind,
  24597. last: undefined
  24598. });
  24599. }, function () {
  24600. var state = getInternalIteratorState(this);
  24601. var kind = state.kind;
  24602. var entry = state.last;
  24603. // revert to the last existing entry
  24604. while (entry && entry.removed) entry = entry.previous;
  24605. // get next entry
  24606. if (!state.target || !(state.last = entry = entry ? entry.next : state.state.first)) {
  24607. // or finish the iteration
  24608. state.target = undefined;
  24609. return createIterResultObject(undefined, true);
  24610. }
  24611. // return step by kind
  24612. if (kind == 'keys') return createIterResultObject(entry.key, false);
  24613. if (kind == 'values') return createIterResultObject(entry.value, false);
  24614. return createIterResultObject([entry.key, entry.value], false);
  24615. }, IS_MAP ? 'entries' : 'values', !IS_MAP, true);
  24616. // `{ Map, Set }.prototype[@@species]` accessors
  24617. // https://tc39.es/ecma262/#sec-get-map-@@species
  24618. // https://tc39.es/ecma262/#sec-get-set-@@species
  24619. setSpecies(CONSTRUCTOR_NAME);
  24620. }
  24621. };
  24622. },{"../internals/an-instance":262,"../internals/create-iter-result-object":291,"../internals/define-built-ins":296,"../internals/descriptors":299,"../internals/function-bind-context":322,"../internals/internal-metadata":342,"../internals/internal-state":343,"../internals/is-null-or-undefined":351,"../internals/iterate":356,"../internals/iterator-define":359,"../internals/object-create":372,"../internals/object-define-property":374,"../internals/set-species":400}],286:[function(_dereq_,module,exports){
  24623. 'use strict';
  24624. var uncurryThis = _dereq_('../internals/function-uncurry-this');
  24625. var defineBuiltIns = _dereq_('../internals/define-built-ins');
  24626. var getWeakData = _dereq_('../internals/internal-metadata').getWeakData;
  24627. var anInstance = _dereq_('../internals/an-instance');
  24628. var anObject = _dereq_('../internals/an-object');
  24629. var isNullOrUndefined = _dereq_('../internals/is-null-or-undefined');
  24630. var isObject = _dereq_('../internals/is-object');
  24631. var iterate = _dereq_('../internals/iterate');
  24632. var ArrayIterationModule = _dereq_('../internals/array-iteration');
  24633. var hasOwn = _dereq_('../internals/has-own-property');
  24634. var InternalStateModule = _dereq_('../internals/internal-state');
  24635. var setInternalState = InternalStateModule.set;
  24636. var internalStateGetterFor = InternalStateModule.getterFor;
  24637. var find = ArrayIterationModule.find;
  24638. var findIndex = ArrayIterationModule.findIndex;
  24639. var splice = uncurryThis([].splice);
  24640. var id = 0;
  24641. // fallback for uncaught frozen keys
  24642. var uncaughtFrozenStore = function (store) {
  24643. return store.frozen || (store.frozen = new UncaughtFrozenStore());
  24644. };
  24645. var UncaughtFrozenStore = function () {
  24646. this.entries = [];
  24647. };
  24648. var findUncaughtFrozen = function (store, key) {
  24649. return find(store.entries, function (it) {
  24650. return it[0] === key;
  24651. });
  24652. };
  24653. UncaughtFrozenStore.prototype = {
  24654. get: function (key) {
  24655. var entry = findUncaughtFrozen(this, key);
  24656. if (entry) return entry[1];
  24657. },
  24658. has: function (key) {
  24659. return !!findUncaughtFrozen(this, key);
  24660. },
  24661. set: function (key, value) {
  24662. var entry = findUncaughtFrozen(this, key);
  24663. if (entry) entry[1] = value;
  24664. else this.entries.push([key, value]);
  24665. },
  24666. 'delete': function (key) {
  24667. var index = findIndex(this.entries, function (it) {
  24668. return it[0] === key;
  24669. });
  24670. if (~index) splice(this.entries, index, 1);
  24671. return !!~index;
  24672. }
  24673. };
  24674. module.exports = {
  24675. getConstructor: function (wrapper, CONSTRUCTOR_NAME, IS_MAP, ADDER) {
  24676. var Constructor = wrapper(function (that, iterable) {
  24677. anInstance(that, Prototype);
  24678. setInternalState(that, {
  24679. type: CONSTRUCTOR_NAME,
  24680. id: id++,
  24681. frozen: undefined
  24682. });
  24683. if (!isNullOrUndefined(iterable)) iterate(iterable, that[ADDER], { that: that, AS_ENTRIES: IS_MAP });
  24684. });
  24685. var Prototype = Constructor.prototype;
  24686. var getInternalState = internalStateGetterFor(CONSTRUCTOR_NAME);
  24687. var define = function (that, key, value) {
  24688. var state = getInternalState(that);
  24689. var data = getWeakData(anObject(key), true);
  24690. if (data === true) uncaughtFrozenStore(state).set(key, value);
  24691. else data[state.id] = value;
  24692. return that;
  24693. };
  24694. defineBuiltIns(Prototype, {
  24695. // `{ WeakMap, WeakSet }.prototype.delete(key)` methods
  24696. // https://tc39.es/ecma262/#sec-weakmap.prototype.delete
  24697. // https://tc39.es/ecma262/#sec-weakset.prototype.delete
  24698. 'delete': function (key) {
  24699. var state = getInternalState(this);
  24700. if (!isObject(key)) return false;
  24701. var data = getWeakData(key);
  24702. if (data === true) return uncaughtFrozenStore(state)['delete'](key);
  24703. return data && hasOwn(data, state.id) && delete data[state.id];
  24704. },
  24705. // `{ WeakMap, WeakSet }.prototype.has(key)` methods
  24706. // https://tc39.es/ecma262/#sec-weakmap.prototype.has
  24707. // https://tc39.es/ecma262/#sec-weakset.prototype.has
  24708. has: function has(key) {
  24709. var state = getInternalState(this);
  24710. if (!isObject(key)) return false;
  24711. var data = getWeakData(key);
  24712. if (data === true) return uncaughtFrozenStore(state).has(key);
  24713. return data && hasOwn(data, state.id);
  24714. }
  24715. });
  24716. defineBuiltIns(Prototype, IS_MAP ? {
  24717. // `WeakMap.prototype.get(key)` method
  24718. // https://tc39.es/ecma262/#sec-weakmap.prototype.get
  24719. get: function get(key) {
  24720. var state = getInternalState(this);
  24721. if (isObject(key)) {
  24722. var data = getWeakData(key);
  24723. if (data === true) return uncaughtFrozenStore(state).get(key);
  24724. return data ? data[state.id] : undefined;
  24725. }
  24726. },
  24727. // `WeakMap.prototype.set(key, value)` method
  24728. // https://tc39.es/ecma262/#sec-weakmap.prototype.set
  24729. set: function set(key, value) {
  24730. return define(this, key, value);
  24731. }
  24732. } : {
  24733. // `WeakSet.prototype.add(value)` method
  24734. // https://tc39.es/ecma262/#sec-weakset.prototype.add
  24735. add: function add(value) {
  24736. return define(this, value, true);
  24737. }
  24738. });
  24739. return Constructor;
  24740. }
  24741. };
  24742. },{"../internals/an-instance":262,"../internals/an-object":263,"../internals/array-iteration":268,"../internals/define-built-ins":296,"../internals/function-uncurry-this":327,"../internals/has-own-property":334,"../internals/internal-metadata":342,"../internals/internal-state":343,"../internals/is-null-or-undefined":351,"../internals/is-object":352,"../internals/iterate":356}],287:[function(_dereq_,module,exports){
  24743. 'use strict';
  24744. var $ = _dereq_('../internals/export');
  24745. var global = _dereq_('../internals/global');
  24746. var InternalMetadataModule = _dereq_('../internals/internal-metadata');
  24747. var fails = _dereq_('../internals/fails');
  24748. var createNonEnumerableProperty = _dereq_('../internals/create-non-enumerable-property');
  24749. var iterate = _dereq_('../internals/iterate');
  24750. var anInstance = _dereq_('../internals/an-instance');
  24751. var isCallable = _dereq_('../internals/is-callable');
  24752. var isObject = _dereq_('../internals/is-object');
  24753. var setToStringTag = _dereq_('../internals/set-to-string-tag');
  24754. var defineProperty = _dereq_('../internals/object-define-property').f;
  24755. var forEach = _dereq_('../internals/array-iteration').forEach;
  24756. var DESCRIPTORS = _dereq_('../internals/descriptors');
  24757. var InternalStateModule = _dereq_('../internals/internal-state');
  24758. var setInternalState = InternalStateModule.set;
  24759. var internalStateGetterFor = InternalStateModule.getterFor;
  24760. module.exports = function (CONSTRUCTOR_NAME, wrapper, common) {
  24761. var IS_MAP = CONSTRUCTOR_NAME.indexOf('Map') !== -1;
  24762. var IS_WEAK = CONSTRUCTOR_NAME.indexOf('Weak') !== -1;
  24763. var ADDER = IS_MAP ? 'set' : 'add';
  24764. var NativeConstructor = global[CONSTRUCTOR_NAME];
  24765. var NativePrototype = NativeConstructor && NativeConstructor.prototype;
  24766. var exported = {};
  24767. var Constructor;
  24768. if (!DESCRIPTORS || !isCallable(NativeConstructor)
  24769. || !(IS_WEAK || NativePrototype.forEach && !fails(function () { new NativeConstructor().entries().next(); }))
  24770. ) {
  24771. // create collection constructor
  24772. Constructor = common.getConstructor(wrapper, CONSTRUCTOR_NAME, IS_MAP, ADDER);
  24773. InternalMetadataModule.enable();
  24774. } else {
  24775. Constructor = wrapper(function (target, iterable) {
  24776. setInternalState(anInstance(target, Prototype), {
  24777. type: CONSTRUCTOR_NAME,
  24778. collection: new NativeConstructor()
  24779. });
  24780. if (iterable != undefined) iterate(iterable, target[ADDER], { that: target, AS_ENTRIES: IS_MAP });
  24781. });
  24782. var Prototype = Constructor.prototype;
  24783. var getInternalState = internalStateGetterFor(CONSTRUCTOR_NAME);
  24784. forEach(['add', 'clear', 'delete', 'forEach', 'get', 'has', 'set', 'keys', 'values', 'entries'], function (KEY) {
  24785. var IS_ADDER = KEY == 'add' || KEY == 'set';
  24786. if (KEY in NativePrototype && !(IS_WEAK && KEY == 'clear')) {
  24787. createNonEnumerableProperty(Prototype, KEY, function (a, b) {
  24788. var collection = getInternalState(this).collection;
  24789. if (!IS_ADDER && IS_WEAK && !isObject(a)) return KEY == 'get' ? undefined : false;
  24790. var result = collection[KEY](a === 0 ? 0 : a, b);
  24791. return IS_ADDER ? this : result;
  24792. });
  24793. }
  24794. });
  24795. IS_WEAK || defineProperty(Prototype, 'size', {
  24796. configurable: true,
  24797. get: function () {
  24798. return getInternalState(this).collection.size;
  24799. }
  24800. });
  24801. }
  24802. setToStringTag(Constructor, CONSTRUCTOR_NAME, false, true);
  24803. exported[CONSTRUCTOR_NAME] = Constructor;
  24804. $({ global: true, forced: true }, exported);
  24805. if (!IS_WEAK) common.setStrong(Constructor, CONSTRUCTOR_NAME, IS_MAP);
  24806. return Constructor;
  24807. };
  24808. },{"../internals/an-instance":262,"../internals/array-iteration":268,"../internals/create-non-enumerable-property":292,"../internals/descriptors":299,"../internals/export":318,"../internals/fails":319,"../internals/global":333,"../internals/internal-metadata":342,"../internals/internal-state":343,"../internals/is-callable":346,"../internals/is-object":352,"../internals/iterate":356,"../internals/object-define-property":374,"../internals/set-to-string-tag":401}],288:[function(_dereq_,module,exports){
  24809. var hasOwn = _dereq_('../internals/has-own-property');
  24810. var ownKeys = _dereq_('../internals/own-keys');
  24811. var getOwnPropertyDescriptorModule = _dereq_('../internals/object-get-own-property-descriptor');
  24812. var definePropertyModule = _dereq_('../internals/object-define-property');
  24813. module.exports = function (target, source, exceptions) {
  24814. var keys = ownKeys(source);
  24815. var defineProperty = definePropertyModule.f;
  24816. var getOwnPropertyDescriptor = getOwnPropertyDescriptorModule.f;
  24817. for (var i = 0; i < keys.length; i++) {
  24818. var key = keys[i];
  24819. if (!hasOwn(target, key) && !(exceptions && hasOwn(exceptions, key))) {
  24820. defineProperty(target, key, getOwnPropertyDescriptor(source, key));
  24821. }
  24822. }
  24823. };
  24824. },{"../internals/has-own-property":334,"../internals/object-define-property":374,"../internals/object-get-own-property-descriptor":375,"../internals/own-keys":389}],289:[function(_dereq_,module,exports){
  24825. var wellKnownSymbol = _dereq_('../internals/well-known-symbol');
  24826. var MATCH = wellKnownSymbol('match');
  24827. module.exports = function (METHOD_NAME) {
  24828. var regexp = /./;
  24829. try {
  24830. '/./'[METHOD_NAME](regexp);
  24831. } catch (error1) {
  24832. try {
  24833. regexp[MATCH] = false;
  24834. return '/./'[METHOD_NAME](regexp);
  24835. } catch (error2) { /* empty */ }
  24836. } return false;
  24837. };
  24838. },{"../internals/well-known-symbol":429}],290:[function(_dereq_,module,exports){
  24839. var fails = _dereq_('../internals/fails');
  24840. module.exports = !fails(function () {
  24841. function F() { /* empty */ }
  24842. F.prototype.constructor = null;
  24843. // eslint-disable-next-line es-x/no-object-getprototypeof -- required for testing
  24844. return Object.getPrototypeOf(new F()) !== F.prototype;
  24845. });
  24846. },{"../internals/fails":319}],291:[function(_dereq_,module,exports){
  24847. // `CreateIterResultObject` abstract operation
  24848. // https://tc39.es/ecma262/#sec-createiterresultobject
  24849. module.exports = function (value, done) {
  24850. return { value: value, done: done };
  24851. };
  24852. },{}],292:[function(_dereq_,module,exports){
  24853. var DESCRIPTORS = _dereq_('../internals/descriptors');
  24854. var definePropertyModule = _dereq_('../internals/object-define-property');
  24855. var createPropertyDescriptor = _dereq_('../internals/create-property-descriptor');
  24856. module.exports = DESCRIPTORS ? function (object, key, value) {
  24857. return definePropertyModule.f(object, key, createPropertyDescriptor(1, value));
  24858. } : function (object, key, value) {
  24859. object[key] = value;
  24860. return object;
  24861. };
  24862. },{"../internals/create-property-descriptor":293,"../internals/descriptors":299,"../internals/object-define-property":374}],293:[function(_dereq_,module,exports){
  24863. module.exports = function (bitmap, value) {
  24864. return {
  24865. enumerable: !(bitmap & 1),
  24866. configurable: !(bitmap & 2),
  24867. writable: !(bitmap & 4),
  24868. value: value
  24869. };
  24870. };
  24871. },{}],294:[function(_dereq_,module,exports){
  24872. 'use strict';
  24873. var toPropertyKey = _dereq_('../internals/to-property-key');
  24874. var definePropertyModule = _dereq_('../internals/object-define-property');
  24875. var createPropertyDescriptor = _dereq_('../internals/create-property-descriptor');
  24876. module.exports = function (object, key, value) {
  24877. var propertyKey = toPropertyKey(key);
  24878. if (propertyKey in object) definePropertyModule.f(object, propertyKey, createPropertyDescriptor(0, value));
  24879. else object[propertyKey] = value;
  24880. };
  24881. },{"../internals/create-property-descriptor":293,"../internals/object-define-property":374,"../internals/to-property-key":418}],295:[function(_dereq_,module,exports){
  24882. var createNonEnumerableProperty = _dereq_('../internals/create-non-enumerable-property');
  24883. module.exports = function (target, key, value, options) {
  24884. if (options && options.enumerable) target[key] = value;
  24885. else createNonEnumerableProperty(target, key, value);
  24886. return target;
  24887. };
  24888. },{"../internals/create-non-enumerable-property":292}],296:[function(_dereq_,module,exports){
  24889. var defineBuiltIn = _dereq_('../internals/define-built-in');
  24890. module.exports = function (target, src, options) {
  24891. for (var key in src) {
  24892. if (options && options.unsafe && target[key]) target[key] = src[key];
  24893. else defineBuiltIn(target, key, src[key], options);
  24894. } return target;
  24895. };
  24896. },{"../internals/define-built-in":295}],297:[function(_dereq_,module,exports){
  24897. var global = _dereq_('../internals/global');
  24898. // eslint-disable-next-line es-x/no-object-defineproperty -- safe
  24899. var defineProperty = Object.defineProperty;
  24900. module.exports = function (key, value) {
  24901. try {
  24902. defineProperty(global, key, { value: value, configurable: true, writable: true });
  24903. } catch (error) {
  24904. global[key] = value;
  24905. } return value;
  24906. };
  24907. },{"../internals/global":333}],298:[function(_dereq_,module,exports){
  24908. 'use strict';
  24909. var tryToString = _dereq_('../internals/try-to-string');
  24910. var $TypeError = TypeError;
  24911. module.exports = function (O, P) {
  24912. if (!delete O[P]) throw $TypeError('Cannot delete property ' + tryToString(P) + ' of ' + tryToString(O));
  24913. };
  24914. },{"../internals/try-to-string":421}],299:[function(_dereq_,module,exports){
  24915. var fails = _dereq_('../internals/fails');
  24916. // Detect IE8's incomplete defineProperty implementation
  24917. module.exports = !fails(function () {
  24918. // eslint-disable-next-line es-x/no-object-defineproperty -- required for testing
  24919. return Object.defineProperty({}, 1, { get: function () { return 7; } })[1] != 7;
  24920. });
  24921. },{"../internals/fails":319}],300:[function(_dereq_,module,exports){
  24922. var global = _dereq_('../internals/global');
  24923. var isObject = _dereq_('../internals/is-object');
  24924. var document = global.document;
  24925. // typeof document.createElement is 'object' in old IE
  24926. var EXISTS = isObject(document) && isObject(document.createElement);
  24927. module.exports = function (it) {
  24928. return EXISTS ? document.createElement(it) : {};
  24929. };
  24930. },{"../internals/global":333,"../internals/is-object":352}],301:[function(_dereq_,module,exports){
  24931. var $TypeError = TypeError;
  24932. var MAX_SAFE_INTEGER = 0x1FFFFFFFFFFFFF; // 2 ** 53 - 1 == 9007199254740991
  24933. module.exports = function (it) {
  24934. if (it > MAX_SAFE_INTEGER) throw $TypeError('Maximum allowed index exceeded');
  24935. return it;
  24936. };
  24937. },{}],302:[function(_dereq_,module,exports){
  24938. // iterable DOM collections
  24939. // flag - `iterable` interface - 'entries', 'keys', 'values', 'forEach' methods
  24940. module.exports = {
  24941. CSSRuleList: 0,
  24942. CSSStyleDeclaration: 0,
  24943. CSSValueList: 0,
  24944. ClientRectList: 0,
  24945. DOMRectList: 0,
  24946. DOMStringList: 0,
  24947. DOMTokenList: 1,
  24948. DataTransferItemList: 0,
  24949. FileList: 0,
  24950. HTMLAllCollection: 0,
  24951. HTMLCollection: 0,
  24952. HTMLFormElement: 0,
  24953. HTMLSelectElement: 0,
  24954. MediaList: 0,
  24955. MimeTypeArray: 0,
  24956. NamedNodeMap: 0,
  24957. NodeList: 1,
  24958. PaintRequestList: 0,
  24959. Plugin: 0,
  24960. PluginArray: 0,
  24961. SVGLengthList: 0,
  24962. SVGNumberList: 0,
  24963. SVGPathSegList: 0,
  24964. SVGPointList: 0,
  24965. SVGStringList: 0,
  24966. SVGTransformList: 0,
  24967. SourceBufferList: 0,
  24968. StyleSheetList: 0,
  24969. TextTrackCueList: 0,
  24970. TextTrackList: 0,
  24971. TouchList: 0
  24972. };
  24973. },{}],303:[function(_dereq_,module,exports){
  24974. var userAgent = _dereq_('../internals/engine-user-agent');
  24975. var firefox = userAgent.match(/firefox\/(\d+)/i);
  24976. module.exports = !!firefox && +firefox[1];
  24977. },{"../internals/engine-user-agent":311}],304:[function(_dereq_,module,exports){
  24978. var IS_DENO = _dereq_('../internals/engine-is-deno');
  24979. var IS_NODE = _dereq_('../internals/engine-is-node');
  24980. module.exports = !IS_DENO && !IS_NODE
  24981. && typeof window == 'object'
  24982. && typeof document == 'object';
  24983. },{"../internals/engine-is-deno":305,"../internals/engine-is-node":309}],305:[function(_dereq_,module,exports){
  24984. /* global Deno -- Deno case */
  24985. module.exports = typeof Deno == 'object' && Deno && typeof Deno.version == 'object';
  24986. },{}],306:[function(_dereq_,module,exports){
  24987. var UA = _dereq_('../internals/engine-user-agent');
  24988. module.exports = /MSIE|Trident/.test(UA);
  24989. },{"../internals/engine-user-agent":311}],307:[function(_dereq_,module,exports){
  24990. var userAgent = _dereq_('../internals/engine-user-agent');
  24991. var global = _dereq_('../internals/global');
  24992. module.exports = /ipad|iphone|ipod/i.test(userAgent) && global.Pebble !== undefined;
  24993. },{"../internals/engine-user-agent":311,"../internals/global":333}],308:[function(_dereq_,module,exports){
  24994. var userAgent = _dereq_('../internals/engine-user-agent');
  24995. module.exports = /(?:ipad|iphone|ipod).*applewebkit/i.test(userAgent);
  24996. },{"../internals/engine-user-agent":311}],309:[function(_dereq_,module,exports){
  24997. var classof = _dereq_('../internals/classof-raw');
  24998. var global = _dereq_('../internals/global');
  24999. module.exports = classof(global.process) == 'process';
  25000. },{"../internals/classof-raw":280,"../internals/global":333}],310:[function(_dereq_,module,exports){
  25001. var userAgent = _dereq_('../internals/engine-user-agent');
  25002. module.exports = /web0s(?!.*chrome)/i.test(userAgent);
  25003. },{"../internals/engine-user-agent":311}],311:[function(_dereq_,module,exports){
  25004. var getBuiltIn = _dereq_('../internals/get-built-in');
  25005. module.exports = getBuiltIn('navigator', 'userAgent') || '';
  25006. },{"../internals/get-built-in":328}],312:[function(_dereq_,module,exports){
  25007. var global = _dereq_('../internals/global');
  25008. var userAgent = _dereq_('../internals/engine-user-agent');
  25009. var process = global.process;
  25010. var Deno = global.Deno;
  25011. var versions = process && process.versions || Deno && Deno.version;
  25012. var v8 = versions && versions.v8;
  25013. var match, version;
  25014. if (v8) {
  25015. match = v8.split('.');
  25016. // in old Chrome, versions of V8 isn't V8 = Chrome / 10
  25017. // but their correct versions are not interesting for us
  25018. version = match[0] > 0 && match[0] < 4 ? 1 : +(match[0] + match[1]);
  25019. }
  25020. // BrowserFS NodeJS `process` polyfill incorrectly set `.v8` to `0.0`
  25021. // so check `userAgent` even if `.v8` exists, but 0
  25022. if (!version && userAgent) {
  25023. match = userAgent.match(/Edge\/(\d+)/);
  25024. if (!match || match[1] >= 74) {
  25025. match = userAgent.match(/Chrome\/(\d+)/);
  25026. if (match) version = +match[1];
  25027. }
  25028. }
  25029. module.exports = version;
  25030. },{"../internals/engine-user-agent":311,"../internals/global":333}],313:[function(_dereq_,module,exports){
  25031. var userAgent = _dereq_('../internals/engine-user-agent');
  25032. var webkit = userAgent.match(/AppleWebKit\/(\d+)\./);
  25033. module.exports = !!webkit && +webkit[1];
  25034. },{"../internals/engine-user-agent":311}],314:[function(_dereq_,module,exports){
  25035. var path = _dereq_('../internals/path');
  25036. module.exports = function (CONSTRUCTOR) {
  25037. return path[CONSTRUCTOR + 'Prototype'];
  25038. };
  25039. },{"../internals/path":390}],315:[function(_dereq_,module,exports){
  25040. // IE8- don't enum bug keys
  25041. module.exports = [
  25042. 'constructor',
  25043. 'hasOwnProperty',
  25044. 'isPrototypeOf',
  25045. 'propertyIsEnumerable',
  25046. 'toLocaleString',
  25047. 'toString',
  25048. 'valueOf'
  25049. ];
  25050. },{}],316:[function(_dereq_,module,exports){
  25051. var uncurryThis = _dereq_('../internals/function-uncurry-this');
  25052. var $Error = Error;
  25053. var replace = uncurryThis(''.replace);
  25054. var TEST = (function (arg) { return String($Error(arg).stack); })('zxcasd');
  25055. var V8_OR_CHAKRA_STACK_ENTRY = /\n\s*at [^:]*:[^\n]*/;
  25056. var IS_V8_OR_CHAKRA_STACK = V8_OR_CHAKRA_STACK_ENTRY.test(TEST);
  25057. module.exports = function (stack, dropEntries) {
  25058. if (IS_V8_OR_CHAKRA_STACK && typeof stack == 'string' && !$Error.prepareStackTrace) {
  25059. while (dropEntries--) stack = replace(stack, V8_OR_CHAKRA_STACK_ENTRY, '');
  25060. } return stack;
  25061. };
  25062. },{"../internals/function-uncurry-this":327}],317:[function(_dereq_,module,exports){
  25063. var fails = _dereq_('../internals/fails');
  25064. var createPropertyDescriptor = _dereq_('../internals/create-property-descriptor');
  25065. module.exports = !fails(function () {
  25066. var error = Error('a');
  25067. if (!('stack' in error)) return true;
  25068. // eslint-disable-next-line es-x/no-object-defineproperty -- safe
  25069. Object.defineProperty(error, 'stack', createPropertyDescriptor(1, 7));
  25070. return error.stack !== 7;
  25071. });
  25072. },{"../internals/create-property-descriptor":293,"../internals/fails":319}],318:[function(_dereq_,module,exports){
  25073. 'use strict';
  25074. var global = _dereq_('../internals/global');
  25075. var apply = _dereq_('../internals/function-apply');
  25076. var uncurryThis = _dereq_('../internals/function-uncurry-this');
  25077. var isCallable = _dereq_('../internals/is-callable');
  25078. var getOwnPropertyDescriptor = _dereq_('../internals/object-get-own-property-descriptor').f;
  25079. var isForced = _dereq_('../internals/is-forced');
  25080. var path = _dereq_('../internals/path');
  25081. var bind = _dereq_('../internals/function-bind-context');
  25082. var createNonEnumerableProperty = _dereq_('../internals/create-non-enumerable-property');
  25083. var hasOwn = _dereq_('../internals/has-own-property');
  25084. var wrapConstructor = function (NativeConstructor) {
  25085. var Wrapper = function (a, b, c) {
  25086. if (this instanceof Wrapper) {
  25087. switch (arguments.length) {
  25088. case 0: return new NativeConstructor();
  25089. case 1: return new NativeConstructor(a);
  25090. case 2: return new NativeConstructor(a, b);
  25091. } return new NativeConstructor(a, b, c);
  25092. } return apply(NativeConstructor, this, arguments);
  25093. };
  25094. Wrapper.prototype = NativeConstructor.prototype;
  25095. return Wrapper;
  25096. };
  25097. /*
  25098. options.target - name of the target object
  25099. options.global - target is the global object
  25100. options.stat - export as static methods of target
  25101. options.proto - export as prototype methods of target
  25102. options.real - real prototype method for the `pure` version
  25103. options.forced - export even if the native feature is available
  25104. options.bind - bind methods to the target, required for the `pure` version
  25105. options.wrap - wrap constructors to preventing global pollution, required for the `pure` version
  25106. options.unsafe - use the simple assignment of property instead of delete + defineProperty
  25107. options.sham - add a flag to not completely full polyfills
  25108. options.enumerable - export as enumerable property
  25109. options.dontCallGetSet - prevent calling a getter on target
  25110. options.name - the .name of the function if it does not match the key
  25111. */
  25112. module.exports = function (options, source) {
  25113. var TARGET = options.target;
  25114. var GLOBAL = options.global;
  25115. var STATIC = options.stat;
  25116. var PROTO = options.proto;
  25117. var nativeSource = GLOBAL ? global : STATIC ? global[TARGET] : (global[TARGET] || {}).prototype;
  25118. var target = GLOBAL ? path : path[TARGET] || createNonEnumerableProperty(path, TARGET, {})[TARGET];
  25119. var targetPrototype = target.prototype;
  25120. var FORCED, USE_NATIVE, VIRTUAL_PROTOTYPE;
  25121. var key, sourceProperty, targetProperty, nativeProperty, resultProperty, descriptor;
  25122. for (key in source) {
  25123. FORCED = isForced(GLOBAL ? key : TARGET + (STATIC ? '.' : '#') + key, options.forced);
  25124. // contains in native
  25125. USE_NATIVE = !FORCED && nativeSource && hasOwn(nativeSource, key);
  25126. targetProperty = target[key];
  25127. if (USE_NATIVE) if (options.dontCallGetSet) {
  25128. descriptor = getOwnPropertyDescriptor(nativeSource, key);
  25129. nativeProperty = descriptor && descriptor.value;
  25130. } else nativeProperty = nativeSource[key];
  25131. // export native or implementation
  25132. sourceProperty = (USE_NATIVE && nativeProperty) ? nativeProperty : source[key];
  25133. if (USE_NATIVE && typeof targetProperty == typeof sourceProperty) continue;
  25134. // bind timers to global for call from export context
  25135. if (options.bind && USE_NATIVE) resultProperty = bind(sourceProperty, global);
  25136. // wrap global constructors for prevent changs in this version
  25137. else if (options.wrap && USE_NATIVE) resultProperty = wrapConstructor(sourceProperty);
  25138. // make static versions for prototype methods
  25139. else if (PROTO && isCallable(sourceProperty)) resultProperty = uncurryThis(sourceProperty);
  25140. // default case
  25141. else resultProperty = sourceProperty;
  25142. // add a flag to not completely full polyfills
  25143. if (options.sham || (sourceProperty && sourceProperty.sham) || (targetProperty && targetProperty.sham)) {
  25144. createNonEnumerableProperty(resultProperty, 'sham', true);
  25145. }
  25146. createNonEnumerableProperty(target, key, resultProperty);
  25147. if (PROTO) {
  25148. VIRTUAL_PROTOTYPE = TARGET + 'Prototype';
  25149. if (!hasOwn(path, VIRTUAL_PROTOTYPE)) {
  25150. createNonEnumerableProperty(path, VIRTUAL_PROTOTYPE, {});
  25151. }
  25152. // export virtual prototype methods
  25153. createNonEnumerableProperty(path[VIRTUAL_PROTOTYPE], key, sourceProperty);
  25154. // export real prototype methods
  25155. if (options.real && targetPrototype && !targetPrototype[key]) {
  25156. createNonEnumerableProperty(targetPrototype, key, sourceProperty);
  25157. }
  25158. }
  25159. }
  25160. };
  25161. },{"../internals/create-non-enumerable-property":292,"../internals/function-apply":321,"../internals/function-bind-context":322,"../internals/function-uncurry-this":327,"../internals/global":333,"../internals/has-own-property":334,"../internals/is-callable":346,"../internals/is-forced":349,"../internals/object-get-own-property-descriptor":375,"../internals/path":390}],319:[function(_dereq_,module,exports){
  25162. module.exports = function (exec) {
  25163. try {
  25164. return !!exec();
  25165. } catch (error) {
  25166. return true;
  25167. }
  25168. };
  25169. },{}],320:[function(_dereq_,module,exports){
  25170. var fails = _dereq_('../internals/fails');
  25171. module.exports = !fails(function () {
  25172. // eslint-disable-next-line es-x/no-object-isextensible, es-x/no-object-preventextensions -- required for testing
  25173. return Object.isExtensible(Object.preventExtensions({}));
  25174. });
  25175. },{"../internals/fails":319}],321:[function(_dereq_,module,exports){
  25176. var NATIVE_BIND = _dereq_('../internals/function-bind-native');
  25177. var FunctionPrototype = Function.prototype;
  25178. var apply = FunctionPrototype.apply;
  25179. var call = FunctionPrototype.call;
  25180. // eslint-disable-next-line es-x/no-reflect -- safe
  25181. module.exports = typeof Reflect == 'object' && Reflect.apply || (NATIVE_BIND ? call.bind(apply) : function () {
  25182. return call.apply(apply, arguments);
  25183. });
  25184. },{"../internals/function-bind-native":323}],322:[function(_dereq_,module,exports){
  25185. var uncurryThis = _dereq_('../internals/function-uncurry-this');
  25186. var aCallable = _dereq_('../internals/a-callable');
  25187. var NATIVE_BIND = _dereq_('../internals/function-bind-native');
  25188. var bind = uncurryThis(uncurryThis.bind);
  25189. // optional / simple context binding
  25190. module.exports = function (fn, that) {
  25191. aCallable(fn);
  25192. return that === undefined ? fn : NATIVE_BIND ? bind(fn, that) : function (/* ...args */) {
  25193. return fn.apply(that, arguments);
  25194. };
  25195. };
  25196. },{"../internals/a-callable":258,"../internals/function-bind-native":323,"../internals/function-uncurry-this":327}],323:[function(_dereq_,module,exports){
  25197. var fails = _dereq_('../internals/fails');
  25198. module.exports = !fails(function () {
  25199. // eslint-disable-next-line es-x/no-function-prototype-bind -- safe
  25200. var test = (function () { /* empty */ }).bind();
  25201. // eslint-disable-next-line no-prototype-builtins -- safe
  25202. return typeof test != 'function' || test.hasOwnProperty('prototype');
  25203. });
  25204. },{"../internals/fails":319}],324:[function(_dereq_,module,exports){
  25205. 'use strict';
  25206. var uncurryThis = _dereq_('../internals/function-uncurry-this');
  25207. var aCallable = _dereq_('../internals/a-callable');
  25208. var isObject = _dereq_('../internals/is-object');
  25209. var hasOwn = _dereq_('../internals/has-own-property');
  25210. var arraySlice = _dereq_('../internals/array-slice');
  25211. var NATIVE_BIND = _dereq_('../internals/function-bind-native');
  25212. var $Function = Function;
  25213. var concat = uncurryThis([].concat);
  25214. var join = uncurryThis([].join);
  25215. var factories = {};
  25216. var construct = function (C, argsLength, args) {
  25217. if (!hasOwn(factories, argsLength)) {
  25218. for (var list = [], i = 0; i < argsLength; i++) list[i] = 'a[' + i + ']';
  25219. factories[argsLength] = $Function('C,a', 'return new C(' + join(list, ',') + ')');
  25220. } return factories[argsLength](C, args);
  25221. };
  25222. // `Function.prototype.bind` method implementation
  25223. // https://tc39.es/ecma262/#sec-function.prototype.bind
  25224. module.exports = NATIVE_BIND ? $Function.bind : function bind(that /* , ...args */) {
  25225. var F = aCallable(this);
  25226. var Prototype = F.prototype;
  25227. var partArgs = arraySlice(arguments, 1);
  25228. var boundFunction = function bound(/* args... */) {
  25229. var args = concat(partArgs, arraySlice(arguments));
  25230. return this instanceof boundFunction ? construct(F, args.length, args) : F.apply(that, args);
  25231. };
  25232. if (isObject(Prototype)) boundFunction.prototype = Prototype;
  25233. return boundFunction;
  25234. };
  25235. },{"../internals/a-callable":258,"../internals/array-slice":274,"../internals/function-bind-native":323,"../internals/function-uncurry-this":327,"../internals/has-own-property":334,"../internals/is-object":352}],325:[function(_dereq_,module,exports){
  25236. var NATIVE_BIND = _dereq_('../internals/function-bind-native');
  25237. var call = Function.prototype.call;
  25238. module.exports = NATIVE_BIND ? call.bind(call) : function () {
  25239. return call.apply(call, arguments);
  25240. };
  25241. },{"../internals/function-bind-native":323}],326:[function(_dereq_,module,exports){
  25242. var DESCRIPTORS = _dereq_('../internals/descriptors');
  25243. var hasOwn = _dereq_('../internals/has-own-property');
  25244. var FunctionPrototype = Function.prototype;
  25245. // eslint-disable-next-line es-x/no-object-getownpropertydescriptor -- safe
  25246. var getDescriptor = DESCRIPTORS && Object.getOwnPropertyDescriptor;
  25247. var EXISTS = hasOwn(FunctionPrototype, 'name');
  25248. // additional protection from minified / mangled / dropped function names
  25249. var PROPER = EXISTS && (function something() { /* empty */ }).name === 'something';
  25250. var CONFIGURABLE = EXISTS && (!DESCRIPTORS || (DESCRIPTORS && getDescriptor(FunctionPrototype, 'name').configurable));
  25251. module.exports = {
  25252. EXISTS: EXISTS,
  25253. PROPER: PROPER,
  25254. CONFIGURABLE: CONFIGURABLE
  25255. };
  25256. },{"../internals/descriptors":299,"../internals/has-own-property":334}],327:[function(_dereq_,module,exports){
  25257. var NATIVE_BIND = _dereq_('../internals/function-bind-native');
  25258. var FunctionPrototype = Function.prototype;
  25259. var bind = FunctionPrototype.bind;
  25260. var call = FunctionPrototype.call;
  25261. var uncurryThis = NATIVE_BIND && bind.bind(call, call);
  25262. module.exports = NATIVE_BIND ? function (fn) {
  25263. return fn && uncurryThis(fn);
  25264. } : function (fn) {
  25265. return fn && function () {
  25266. return call.apply(fn, arguments);
  25267. };
  25268. };
  25269. },{"../internals/function-bind-native":323}],328:[function(_dereq_,module,exports){
  25270. var path = _dereq_('../internals/path');
  25271. var global = _dereq_('../internals/global');
  25272. var isCallable = _dereq_('../internals/is-callable');
  25273. var aFunction = function (variable) {
  25274. return isCallable(variable) ? variable : undefined;
  25275. };
  25276. module.exports = function (namespace, method) {
  25277. return arguments.length < 2 ? aFunction(path[namespace]) || aFunction(global[namespace])
  25278. : path[namespace] && path[namespace][method] || global[namespace] && global[namespace][method];
  25279. };
  25280. },{"../internals/global":333,"../internals/is-callable":346,"../internals/path":390}],329:[function(_dereq_,module,exports){
  25281. var classof = _dereq_('../internals/classof');
  25282. var getMethod = _dereq_('../internals/get-method');
  25283. var isNullOrUndefined = _dereq_('../internals/is-null-or-undefined');
  25284. var Iterators = _dereq_('../internals/iterators');
  25285. var wellKnownSymbol = _dereq_('../internals/well-known-symbol');
  25286. var ITERATOR = wellKnownSymbol('iterator');
  25287. module.exports = function (it) {
  25288. if (!isNullOrUndefined(it)) return getMethod(it, ITERATOR)
  25289. || getMethod(it, '@@iterator')
  25290. || Iterators[classof(it)];
  25291. };
  25292. },{"../internals/classof":281,"../internals/get-method":332,"../internals/is-null-or-undefined":351,"../internals/iterators":361,"../internals/well-known-symbol":429}],330:[function(_dereq_,module,exports){
  25293. var call = _dereq_('../internals/function-call');
  25294. var aCallable = _dereq_('../internals/a-callable');
  25295. var anObject = _dereq_('../internals/an-object');
  25296. var tryToString = _dereq_('../internals/try-to-string');
  25297. var getIteratorMethod = _dereq_('../internals/get-iterator-method');
  25298. var $TypeError = TypeError;
  25299. module.exports = function (argument, usingIterator) {
  25300. var iteratorMethod = arguments.length < 2 ? getIteratorMethod(argument) : usingIterator;
  25301. if (aCallable(iteratorMethod)) return anObject(call(iteratorMethod, argument));
  25302. throw $TypeError(tryToString(argument) + ' is not iterable');
  25303. };
  25304. },{"../internals/a-callable":258,"../internals/an-object":263,"../internals/function-call":325,"../internals/get-iterator-method":329,"../internals/try-to-string":421}],331:[function(_dereq_,module,exports){
  25305. var getIterator = _dereq_('../internals/get-iterator');
  25306. module.exports = getIterator;
  25307. },{"../internals/get-iterator":330}],332:[function(_dereq_,module,exports){
  25308. var aCallable = _dereq_('../internals/a-callable');
  25309. var isNullOrUndefined = _dereq_('../internals/is-null-or-undefined');
  25310. // `GetMethod` abstract operation
  25311. // https://tc39.es/ecma262/#sec-getmethod
  25312. module.exports = function (V, P) {
  25313. var func = V[P];
  25314. return isNullOrUndefined(func) ? undefined : aCallable(func);
  25315. };
  25316. },{"../internals/a-callable":258,"../internals/is-null-or-undefined":351}],333:[function(_dereq_,module,exports){
  25317. (function (global){(function (){
  25318. var check = function (it) {
  25319. return it && it.Math == Math && it;
  25320. };
  25321. // https://github.com/zloirock/core-js/issues/86#issuecomment-115759028
  25322. module.exports =
  25323. // eslint-disable-next-line es-x/no-global-this -- safe
  25324. check(typeof globalThis == 'object' && globalThis) ||
  25325. check(typeof window == 'object' && window) ||
  25326. // eslint-disable-next-line no-restricted-globals -- safe
  25327. check(typeof self == 'object' && self) ||
  25328. check(typeof global == 'object' && global) ||
  25329. // eslint-disable-next-line no-new-func -- fallback
  25330. (function () { return this; })() || Function('return this')();
  25331. }).call(this)}).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {})
  25332. },{}],334:[function(_dereq_,module,exports){
  25333. var uncurryThis = _dereq_('../internals/function-uncurry-this');
  25334. var toObject = _dereq_('../internals/to-object');
  25335. var hasOwnProperty = uncurryThis({}.hasOwnProperty);
  25336. // `HasOwnProperty` abstract operation
  25337. // https://tc39.es/ecma262/#sec-hasownproperty
  25338. // eslint-disable-next-line es-x/no-object-hasown -- safe
  25339. module.exports = Object.hasOwn || function hasOwn(it, key) {
  25340. return hasOwnProperty(toObject(it), key);
  25341. };
  25342. },{"../internals/function-uncurry-this":327,"../internals/to-object":416}],335:[function(_dereq_,module,exports){
  25343. module.exports = {};
  25344. },{}],336:[function(_dereq_,module,exports){
  25345. var global = _dereq_('../internals/global');
  25346. module.exports = function (a, b) {
  25347. var console = global.console;
  25348. if (console && console.error) {
  25349. arguments.length == 1 ? console.error(a) : console.error(a, b);
  25350. }
  25351. };
  25352. },{"../internals/global":333}],337:[function(_dereq_,module,exports){
  25353. var getBuiltIn = _dereq_('../internals/get-built-in');
  25354. module.exports = getBuiltIn('document', 'documentElement');
  25355. },{"../internals/get-built-in":328}],338:[function(_dereq_,module,exports){
  25356. var DESCRIPTORS = _dereq_('../internals/descriptors');
  25357. var fails = _dereq_('../internals/fails');
  25358. var createElement = _dereq_('../internals/document-create-element');
  25359. // Thanks to IE8 for its funny defineProperty
  25360. module.exports = !DESCRIPTORS && !fails(function () {
  25361. // eslint-disable-next-line es-x/no-object-defineproperty -- required for testing
  25362. return Object.defineProperty(createElement('div'), 'a', {
  25363. get: function () { return 7; }
  25364. }).a != 7;
  25365. });
  25366. },{"../internals/descriptors":299,"../internals/document-create-element":300,"../internals/fails":319}],339:[function(_dereq_,module,exports){
  25367. var uncurryThis = _dereq_('../internals/function-uncurry-this');
  25368. var fails = _dereq_('../internals/fails');
  25369. var classof = _dereq_('../internals/classof-raw');
  25370. var $Object = Object;
  25371. var split = uncurryThis(''.split);
  25372. // fallback for non-array-like ES3 and non-enumerable old V8 strings
  25373. module.exports = fails(function () {
  25374. // throws an error in rhino, see https://github.com/mozilla/rhino/issues/346
  25375. // eslint-disable-next-line no-prototype-builtins -- safe
  25376. return !$Object('z').propertyIsEnumerable(0);
  25377. }) ? function (it) {
  25378. return classof(it) == 'String' ? split(it, '') : $Object(it);
  25379. } : $Object;
  25380. },{"../internals/classof-raw":280,"../internals/fails":319,"../internals/function-uncurry-this":327}],340:[function(_dereq_,module,exports){
  25381. var uncurryThis = _dereq_('../internals/function-uncurry-this');
  25382. var isCallable = _dereq_('../internals/is-callable');
  25383. var store = _dereq_('../internals/shared-store');
  25384. var functionToString = uncurryThis(Function.toString);
  25385. // this helper broken in `core-js@3.4.1-3.4.4`, so we can't use `shared` helper
  25386. if (!isCallable(store.inspectSource)) {
  25387. store.inspectSource = function (it) {
  25388. return functionToString(it);
  25389. };
  25390. }
  25391. module.exports = store.inspectSource;
  25392. },{"../internals/function-uncurry-this":327,"../internals/is-callable":346,"../internals/shared-store":403}],341:[function(_dereq_,module,exports){
  25393. var isObject = _dereq_('../internals/is-object');
  25394. var createNonEnumerableProperty = _dereq_('../internals/create-non-enumerable-property');
  25395. // `InstallErrorCause` abstract operation
  25396. // https://tc39.es/proposal-error-cause/#sec-errorobjects-install-error-cause
  25397. module.exports = function (O, options) {
  25398. if (isObject(options) && 'cause' in options) {
  25399. createNonEnumerableProperty(O, 'cause', options.cause);
  25400. }
  25401. };
  25402. },{"../internals/create-non-enumerable-property":292,"../internals/is-object":352}],342:[function(_dereq_,module,exports){
  25403. var $ = _dereq_('../internals/export');
  25404. var uncurryThis = _dereq_('../internals/function-uncurry-this');
  25405. var hiddenKeys = _dereq_('../internals/hidden-keys');
  25406. var isObject = _dereq_('../internals/is-object');
  25407. var hasOwn = _dereq_('../internals/has-own-property');
  25408. var defineProperty = _dereq_('../internals/object-define-property').f;
  25409. var getOwnPropertyNamesModule = _dereq_('../internals/object-get-own-property-names');
  25410. var getOwnPropertyNamesExternalModule = _dereq_('../internals/object-get-own-property-names-external');
  25411. var isExtensible = _dereq_('../internals/object-is-extensible');
  25412. var uid = _dereq_('../internals/uid');
  25413. var FREEZING = _dereq_('../internals/freezing');
  25414. var REQUIRED = false;
  25415. var METADATA = uid('meta');
  25416. var id = 0;
  25417. var setMetadata = function (it) {
  25418. defineProperty(it, METADATA, { value: {
  25419. objectID: 'O' + id++, // object ID
  25420. weakData: {} // weak collections IDs
  25421. } });
  25422. };
  25423. var fastKey = function (it, create) {
  25424. // return a primitive with prefix
  25425. if (!isObject(it)) return typeof it == 'symbol' ? it : (typeof it == 'string' ? 'S' : 'P') + it;
  25426. if (!hasOwn(it, METADATA)) {
  25427. // can't set metadata to uncaught frozen object
  25428. if (!isExtensible(it)) return 'F';
  25429. // not necessary to add metadata
  25430. if (!create) return 'E';
  25431. // add missing metadata
  25432. setMetadata(it);
  25433. // return object ID
  25434. } return it[METADATA].objectID;
  25435. };
  25436. var getWeakData = function (it, create) {
  25437. if (!hasOwn(it, METADATA)) {
  25438. // can't set metadata to uncaught frozen object
  25439. if (!isExtensible(it)) return true;
  25440. // not necessary to add metadata
  25441. if (!create) return false;
  25442. // add missing metadata
  25443. setMetadata(it);
  25444. // return the store of weak collections IDs
  25445. } return it[METADATA].weakData;
  25446. };
  25447. // add metadata on freeze-family methods calling
  25448. var onFreeze = function (it) {
  25449. if (FREEZING && REQUIRED && isExtensible(it) && !hasOwn(it, METADATA)) setMetadata(it);
  25450. return it;
  25451. };
  25452. var enable = function () {
  25453. meta.enable = function () { /* empty */ };
  25454. REQUIRED = true;
  25455. var getOwnPropertyNames = getOwnPropertyNamesModule.f;
  25456. var splice = uncurryThis([].splice);
  25457. var test = {};
  25458. test[METADATA] = 1;
  25459. // prevent exposing of metadata key
  25460. if (getOwnPropertyNames(test).length) {
  25461. getOwnPropertyNamesModule.f = function (it) {
  25462. var result = getOwnPropertyNames(it);
  25463. for (var i = 0, length = result.length; i < length; i++) {
  25464. if (result[i] === METADATA) {
  25465. splice(result, i, 1);
  25466. break;
  25467. }
  25468. } return result;
  25469. };
  25470. $({ target: 'Object', stat: true, forced: true }, {
  25471. getOwnPropertyNames: getOwnPropertyNamesExternalModule.f
  25472. });
  25473. }
  25474. };
  25475. var meta = module.exports = {
  25476. enable: enable,
  25477. fastKey: fastKey,
  25478. getWeakData: getWeakData,
  25479. onFreeze: onFreeze
  25480. };
  25481. hiddenKeys[METADATA] = true;
  25482. },{"../internals/export":318,"../internals/freezing":320,"../internals/function-uncurry-this":327,"../internals/has-own-property":334,"../internals/hidden-keys":335,"../internals/is-object":352,"../internals/object-define-property":374,"../internals/object-get-own-property-names":377,"../internals/object-get-own-property-names-external":376,"../internals/object-is-extensible":380,"../internals/uid":422}],343:[function(_dereq_,module,exports){
  25483. var NATIVE_WEAK_MAP = _dereq_('../internals/weak-map-basic-detection');
  25484. var global = _dereq_('../internals/global');
  25485. var uncurryThis = _dereq_('../internals/function-uncurry-this');
  25486. var isObject = _dereq_('../internals/is-object');
  25487. var createNonEnumerableProperty = _dereq_('../internals/create-non-enumerable-property');
  25488. var hasOwn = _dereq_('../internals/has-own-property');
  25489. var shared = _dereq_('../internals/shared-store');
  25490. var sharedKey = _dereq_('../internals/shared-key');
  25491. var hiddenKeys = _dereq_('../internals/hidden-keys');
  25492. var OBJECT_ALREADY_INITIALIZED = 'Object already initialized';
  25493. var TypeError = global.TypeError;
  25494. var WeakMap = global.WeakMap;
  25495. var set, get, has;
  25496. var enforce = function (it) {
  25497. return has(it) ? get(it) : set(it, {});
  25498. };
  25499. var getterFor = function (TYPE) {
  25500. return function (it) {
  25501. var state;
  25502. if (!isObject(it) || (state = get(it)).type !== TYPE) {
  25503. throw TypeError('Incompatible receiver, ' + TYPE + ' required');
  25504. } return state;
  25505. };
  25506. };
  25507. if (NATIVE_WEAK_MAP || shared.state) {
  25508. var store = shared.state || (shared.state = new WeakMap());
  25509. var wmget = uncurryThis(store.get);
  25510. var wmhas = uncurryThis(store.has);
  25511. var wmset = uncurryThis(store.set);
  25512. set = function (it, metadata) {
  25513. if (wmhas(store, it)) throw TypeError(OBJECT_ALREADY_INITIALIZED);
  25514. metadata.facade = it;
  25515. wmset(store, it, metadata);
  25516. return metadata;
  25517. };
  25518. get = function (it) {
  25519. return wmget(store, it) || {};
  25520. };
  25521. has = function (it) {
  25522. return wmhas(store, it);
  25523. };
  25524. } else {
  25525. var STATE = sharedKey('state');
  25526. hiddenKeys[STATE] = true;
  25527. set = function (it, metadata) {
  25528. if (hasOwn(it, STATE)) throw TypeError(OBJECT_ALREADY_INITIALIZED);
  25529. metadata.facade = it;
  25530. createNonEnumerableProperty(it, STATE, metadata);
  25531. return metadata;
  25532. };
  25533. get = function (it) {
  25534. return hasOwn(it, STATE) ? it[STATE] : {};
  25535. };
  25536. has = function (it) {
  25537. return hasOwn(it, STATE);
  25538. };
  25539. }
  25540. module.exports = {
  25541. set: set,
  25542. get: get,
  25543. has: has,
  25544. enforce: enforce,
  25545. getterFor: getterFor
  25546. };
  25547. },{"../internals/create-non-enumerable-property":292,"../internals/function-uncurry-this":327,"../internals/global":333,"../internals/has-own-property":334,"../internals/hidden-keys":335,"../internals/is-object":352,"../internals/shared-key":402,"../internals/shared-store":403,"../internals/weak-map-basic-detection":426}],344:[function(_dereq_,module,exports){
  25548. var wellKnownSymbol = _dereq_('../internals/well-known-symbol');
  25549. var Iterators = _dereq_('../internals/iterators');
  25550. var ITERATOR = wellKnownSymbol('iterator');
  25551. var ArrayPrototype = Array.prototype;
  25552. // check on default Array iterator
  25553. module.exports = function (it) {
  25554. return it !== undefined && (Iterators.Array === it || ArrayPrototype[ITERATOR] === it);
  25555. };
  25556. },{"../internals/iterators":361,"../internals/well-known-symbol":429}],345:[function(_dereq_,module,exports){
  25557. var classof = _dereq_('../internals/classof-raw');
  25558. // `IsArray` abstract operation
  25559. // https://tc39.es/ecma262/#sec-isarray
  25560. // eslint-disable-next-line es-x/no-array-isarray -- safe
  25561. module.exports = Array.isArray || function isArray(argument) {
  25562. return classof(argument) == 'Array';
  25563. };
  25564. },{"../internals/classof-raw":280}],346:[function(_dereq_,module,exports){
  25565. // `IsCallable` abstract operation
  25566. // https://tc39.es/ecma262/#sec-iscallable
  25567. module.exports = function (argument) {
  25568. return typeof argument == 'function';
  25569. };
  25570. },{}],347:[function(_dereq_,module,exports){
  25571. var uncurryThis = _dereq_('../internals/function-uncurry-this');
  25572. var fails = _dereq_('../internals/fails');
  25573. var isCallable = _dereq_('../internals/is-callable');
  25574. var classof = _dereq_('../internals/classof');
  25575. var getBuiltIn = _dereq_('../internals/get-built-in');
  25576. var inspectSource = _dereq_('../internals/inspect-source');
  25577. var noop = function () { /* empty */ };
  25578. var empty = [];
  25579. var construct = getBuiltIn('Reflect', 'construct');
  25580. var constructorRegExp = /^\s*(?:class|function)\b/;
  25581. var exec = uncurryThis(constructorRegExp.exec);
  25582. var INCORRECT_TO_STRING = !constructorRegExp.exec(noop);
  25583. var isConstructorModern = function isConstructor(argument) {
  25584. if (!isCallable(argument)) return false;
  25585. try {
  25586. construct(noop, empty, argument);
  25587. return true;
  25588. } catch (error) {
  25589. return false;
  25590. }
  25591. };
  25592. var isConstructorLegacy = function isConstructor(argument) {
  25593. if (!isCallable(argument)) return false;
  25594. switch (classof(argument)) {
  25595. case 'AsyncFunction':
  25596. case 'GeneratorFunction':
  25597. case 'AsyncGeneratorFunction': return false;
  25598. }
  25599. try {
  25600. // we can't check .prototype since constructors produced by .bind haven't it
  25601. // `Function#toString` throws on some built-it function in some legacy engines
  25602. // (for example, `DOMQuad` and similar in FF41-)
  25603. return INCORRECT_TO_STRING || !!exec(constructorRegExp, inspectSource(argument));
  25604. } catch (error) {
  25605. return true;
  25606. }
  25607. };
  25608. isConstructorLegacy.sham = true;
  25609. // `IsConstructor` abstract operation
  25610. // https://tc39.es/ecma262/#sec-isconstructor
  25611. module.exports = !construct || fails(function () {
  25612. var called;
  25613. return isConstructorModern(isConstructorModern.call)
  25614. || !isConstructorModern(Object)
  25615. || !isConstructorModern(function () { called = true; })
  25616. || called;
  25617. }) ? isConstructorLegacy : isConstructorModern;
  25618. },{"../internals/classof":281,"../internals/fails":319,"../internals/function-uncurry-this":327,"../internals/get-built-in":328,"../internals/inspect-source":340,"../internals/is-callable":346}],348:[function(_dereq_,module,exports){
  25619. var hasOwn = _dereq_('../internals/has-own-property');
  25620. module.exports = function (descriptor) {
  25621. return descriptor !== undefined && (hasOwn(descriptor, 'value') || hasOwn(descriptor, 'writable'));
  25622. };
  25623. },{"../internals/has-own-property":334}],349:[function(_dereq_,module,exports){
  25624. var fails = _dereq_('../internals/fails');
  25625. var isCallable = _dereq_('../internals/is-callable');
  25626. var replacement = /#|\.prototype\./;
  25627. var isForced = function (feature, detection) {
  25628. var value = data[normalize(feature)];
  25629. return value == POLYFILL ? true
  25630. : value == NATIVE ? false
  25631. : isCallable(detection) ? fails(detection)
  25632. : !!detection;
  25633. };
  25634. var normalize = isForced.normalize = function (string) {
  25635. return String(string).replace(replacement, '.').toLowerCase();
  25636. };
  25637. var data = isForced.data = {};
  25638. var NATIVE = isForced.NATIVE = 'N';
  25639. var POLYFILL = isForced.POLYFILL = 'P';
  25640. module.exports = isForced;
  25641. },{"../internals/fails":319,"../internals/is-callable":346}],350:[function(_dereq_,module,exports){
  25642. var isObject = _dereq_('../internals/is-object');
  25643. var floor = Math.floor;
  25644. // `IsIntegralNumber` abstract operation
  25645. // https://tc39.es/ecma262/#sec-isintegralnumber
  25646. // eslint-disable-next-line es-x/no-number-isinteger -- safe
  25647. module.exports = Number.isInteger || function isInteger(it) {
  25648. return !isObject(it) && isFinite(it) && floor(it) === it;
  25649. };
  25650. },{"../internals/is-object":352}],351:[function(_dereq_,module,exports){
  25651. // we can't use just `it == null` since of `document.all` special case
  25652. // https://tc39.es/ecma262/#sec-IsHTMLDDA-internal-slot-aec
  25653. module.exports = function (it) {
  25654. return it === null || it === undefined;
  25655. };
  25656. },{}],352:[function(_dereq_,module,exports){
  25657. var isCallable = _dereq_('../internals/is-callable');
  25658. var documentAll = typeof document == 'object' && document.all;
  25659. // https://tc39.es/ecma262/#sec-IsHTMLDDA-internal-slot
  25660. var SPECIAL_DOCUMENT_ALL = typeof documentAll == 'undefined' && documentAll !== undefined;
  25661. module.exports = SPECIAL_DOCUMENT_ALL ? function (it) {
  25662. return typeof it == 'object' ? it !== null : isCallable(it) || it === documentAll;
  25663. } : function (it) {
  25664. return typeof it == 'object' ? it !== null : isCallable(it);
  25665. };
  25666. },{"../internals/is-callable":346}],353:[function(_dereq_,module,exports){
  25667. module.exports = true;
  25668. },{}],354:[function(_dereq_,module,exports){
  25669. var isObject = _dereq_('../internals/is-object');
  25670. var classof = _dereq_('../internals/classof-raw');
  25671. var wellKnownSymbol = _dereq_('../internals/well-known-symbol');
  25672. var MATCH = wellKnownSymbol('match');
  25673. // `IsRegExp` abstract operation
  25674. // https://tc39.es/ecma262/#sec-isregexp
  25675. module.exports = function (it) {
  25676. var isRegExp;
  25677. return isObject(it) && ((isRegExp = it[MATCH]) !== undefined ? !!isRegExp : classof(it) == 'RegExp');
  25678. };
  25679. },{"../internals/classof-raw":280,"../internals/is-object":352,"../internals/well-known-symbol":429}],355:[function(_dereq_,module,exports){
  25680. var getBuiltIn = _dereq_('../internals/get-built-in');
  25681. var isCallable = _dereq_('../internals/is-callable');
  25682. var isPrototypeOf = _dereq_('../internals/object-is-prototype-of');
  25683. var USE_SYMBOL_AS_UID = _dereq_('../internals/use-symbol-as-uid');
  25684. var $Object = Object;
  25685. module.exports = USE_SYMBOL_AS_UID ? function (it) {
  25686. return typeof it == 'symbol';
  25687. } : function (it) {
  25688. var $Symbol = getBuiltIn('Symbol');
  25689. return isCallable($Symbol) && isPrototypeOf($Symbol.prototype, $Object(it));
  25690. };
  25691. },{"../internals/get-built-in":328,"../internals/is-callable":346,"../internals/object-is-prototype-of":381,"../internals/use-symbol-as-uid":423}],356:[function(_dereq_,module,exports){
  25692. var bind = _dereq_('../internals/function-bind-context');
  25693. var call = _dereq_('../internals/function-call');
  25694. var anObject = _dereq_('../internals/an-object');
  25695. var tryToString = _dereq_('../internals/try-to-string');
  25696. var isArrayIteratorMethod = _dereq_('../internals/is-array-iterator-method');
  25697. var lengthOfArrayLike = _dereq_('../internals/length-of-array-like');
  25698. var isPrototypeOf = _dereq_('../internals/object-is-prototype-of');
  25699. var getIterator = _dereq_('../internals/get-iterator');
  25700. var getIteratorMethod = _dereq_('../internals/get-iterator-method');
  25701. var iteratorClose = _dereq_('../internals/iterator-close');
  25702. var $TypeError = TypeError;
  25703. var Result = function (stopped, result) {
  25704. this.stopped = stopped;
  25705. this.result = result;
  25706. };
  25707. var ResultPrototype = Result.prototype;
  25708. module.exports = function (iterable, unboundFunction, options) {
  25709. var that = options && options.that;
  25710. var AS_ENTRIES = !!(options && options.AS_ENTRIES);
  25711. var IS_RECORD = !!(options && options.IS_RECORD);
  25712. var IS_ITERATOR = !!(options && options.IS_ITERATOR);
  25713. var INTERRUPTED = !!(options && options.INTERRUPTED);
  25714. var fn = bind(unboundFunction, that);
  25715. var iterator, iterFn, index, length, result, next, step;
  25716. var stop = function (condition) {
  25717. if (iterator) iteratorClose(iterator, 'normal', condition);
  25718. return new Result(true, condition);
  25719. };
  25720. var callFn = function (value) {
  25721. if (AS_ENTRIES) {
  25722. anObject(value);
  25723. return INTERRUPTED ? fn(value[0], value[1], stop) : fn(value[0], value[1]);
  25724. } return INTERRUPTED ? fn(value, stop) : fn(value);
  25725. };
  25726. if (IS_RECORD) {
  25727. iterator = iterable.iterator;
  25728. } else if (IS_ITERATOR) {
  25729. iterator = iterable;
  25730. } else {
  25731. iterFn = getIteratorMethod(iterable);
  25732. if (!iterFn) throw $TypeError(tryToString(iterable) + ' is not iterable');
  25733. // optimisation for array iterators
  25734. if (isArrayIteratorMethod(iterFn)) {
  25735. for (index = 0, length = lengthOfArrayLike(iterable); length > index; index++) {
  25736. result = callFn(iterable[index]);
  25737. if (result && isPrototypeOf(ResultPrototype, result)) return result;
  25738. } return new Result(false);
  25739. }
  25740. iterator = getIterator(iterable, iterFn);
  25741. }
  25742. next = IS_RECORD ? iterable.next : iterator.next;
  25743. while (!(step = call(next, iterator)).done) {
  25744. try {
  25745. result = callFn(step.value);
  25746. } catch (error) {
  25747. iteratorClose(iterator, 'throw', error);
  25748. }
  25749. if (typeof result == 'object' && result && isPrototypeOf(ResultPrototype, result)) return result;
  25750. } return new Result(false);
  25751. };
  25752. },{"../internals/an-object":263,"../internals/function-bind-context":322,"../internals/function-call":325,"../internals/get-iterator":330,"../internals/get-iterator-method":329,"../internals/is-array-iterator-method":344,"../internals/iterator-close":357,"../internals/length-of-array-like":362,"../internals/object-is-prototype-of":381,"../internals/try-to-string":421}],357:[function(_dereq_,module,exports){
  25753. var call = _dereq_('../internals/function-call');
  25754. var anObject = _dereq_('../internals/an-object');
  25755. var getMethod = _dereq_('../internals/get-method');
  25756. module.exports = function (iterator, kind, value) {
  25757. var innerResult, innerError;
  25758. anObject(iterator);
  25759. try {
  25760. innerResult = getMethod(iterator, 'return');
  25761. if (!innerResult) {
  25762. if (kind === 'throw') throw value;
  25763. return value;
  25764. }
  25765. innerResult = call(innerResult, iterator);
  25766. } catch (error) {
  25767. innerError = true;
  25768. innerResult = error;
  25769. }
  25770. if (kind === 'throw') throw value;
  25771. if (innerError) throw innerResult;
  25772. anObject(innerResult);
  25773. return value;
  25774. };
  25775. },{"../internals/an-object":263,"../internals/function-call":325,"../internals/get-method":332}],358:[function(_dereq_,module,exports){
  25776. 'use strict';
  25777. var IteratorPrototype = _dereq_('../internals/iterators-core').IteratorPrototype;
  25778. var create = _dereq_('../internals/object-create');
  25779. var createPropertyDescriptor = _dereq_('../internals/create-property-descriptor');
  25780. var setToStringTag = _dereq_('../internals/set-to-string-tag');
  25781. var Iterators = _dereq_('../internals/iterators');
  25782. var returnThis = function () { return this; };
  25783. module.exports = function (IteratorConstructor, NAME, next, ENUMERABLE_NEXT) {
  25784. var TO_STRING_TAG = NAME + ' Iterator';
  25785. IteratorConstructor.prototype = create(IteratorPrototype, { next: createPropertyDescriptor(+!ENUMERABLE_NEXT, next) });
  25786. setToStringTag(IteratorConstructor, TO_STRING_TAG, false, true);
  25787. Iterators[TO_STRING_TAG] = returnThis;
  25788. return IteratorConstructor;
  25789. };
  25790. },{"../internals/create-property-descriptor":293,"../internals/iterators":361,"../internals/iterators-core":360,"../internals/object-create":372,"../internals/set-to-string-tag":401}],359:[function(_dereq_,module,exports){
  25791. 'use strict';
  25792. var $ = _dereq_('../internals/export');
  25793. var call = _dereq_('../internals/function-call');
  25794. var IS_PURE = _dereq_('../internals/is-pure');
  25795. var FunctionName = _dereq_('../internals/function-name');
  25796. var isCallable = _dereq_('../internals/is-callable');
  25797. var createIteratorConstructor = _dereq_('../internals/iterator-create-constructor');
  25798. var getPrototypeOf = _dereq_('../internals/object-get-prototype-of');
  25799. var setPrototypeOf = _dereq_('../internals/object-set-prototype-of');
  25800. var setToStringTag = _dereq_('../internals/set-to-string-tag');
  25801. var createNonEnumerableProperty = _dereq_('../internals/create-non-enumerable-property');
  25802. var defineBuiltIn = _dereq_('../internals/define-built-in');
  25803. var wellKnownSymbol = _dereq_('../internals/well-known-symbol');
  25804. var Iterators = _dereq_('../internals/iterators');
  25805. var IteratorsCore = _dereq_('../internals/iterators-core');
  25806. var PROPER_FUNCTION_NAME = FunctionName.PROPER;
  25807. var CONFIGURABLE_FUNCTION_NAME = FunctionName.CONFIGURABLE;
  25808. var IteratorPrototype = IteratorsCore.IteratorPrototype;
  25809. var BUGGY_SAFARI_ITERATORS = IteratorsCore.BUGGY_SAFARI_ITERATORS;
  25810. var ITERATOR = wellKnownSymbol('iterator');
  25811. var KEYS = 'keys';
  25812. var VALUES = 'values';
  25813. var ENTRIES = 'entries';
  25814. var returnThis = function () { return this; };
  25815. module.exports = function (Iterable, NAME, IteratorConstructor, next, DEFAULT, IS_SET, FORCED) {
  25816. createIteratorConstructor(IteratorConstructor, NAME, next);
  25817. var getIterationMethod = function (KIND) {
  25818. if (KIND === DEFAULT && defaultIterator) return defaultIterator;
  25819. if (!BUGGY_SAFARI_ITERATORS && KIND in IterablePrototype) return IterablePrototype[KIND];
  25820. switch (KIND) {
  25821. case KEYS: return function keys() { return new IteratorConstructor(this, KIND); };
  25822. case VALUES: return function values() { return new IteratorConstructor(this, KIND); };
  25823. case ENTRIES: return function entries() { return new IteratorConstructor(this, KIND); };
  25824. } return function () { return new IteratorConstructor(this); };
  25825. };
  25826. var TO_STRING_TAG = NAME + ' Iterator';
  25827. var INCORRECT_VALUES_NAME = false;
  25828. var IterablePrototype = Iterable.prototype;
  25829. var nativeIterator = IterablePrototype[ITERATOR]
  25830. || IterablePrototype['@@iterator']
  25831. || DEFAULT && IterablePrototype[DEFAULT];
  25832. var defaultIterator = !BUGGY_SAFARI_ITERATORS && nativeIterator || getIterationMethod(DEFAULT);
  25833. var anyNativeIterator = NAME == 'Array' ? IterablePrototype.entries || nativeIterator : nativeIterator;
  25834. var CurrentIteratorPrototype, methods, KEY;
  25835. // fix native
  25836. if (anyNativeIterator) {
  25837. CurrentIteratorPrototype = getPrototypeOf(anyNativeIterator.call(new Iterable()));
  25838. if (CurrentIteratorPrototype !== Object.prototype && CurrentIteratorPrototype.next) {
  25839. if (!IS_PURE && getPrototypeOf(CurrentIteratorPrototype) !== IteratorPrototype) {
  25840. if (setPrototypeOf) {
  25841. setPrototypeOf(CurrentIteratorPrototype, IteratorPrototype);
  25842. } else if (!isCallable(CurrentIteratorPrototype[ITERATOR])) {
  25843. defineBuiltIn(CurrentIteratorPrototype, ITERATOR, returnThis);
  25844. }
  25845. }
  25846. // Set @@toStringTag to native iterators
  25847. setToStringTag(CurrentIteratorPrototype, TO_STRING_TAG, true, true);
  25848. if (IS_PURE) Iterators[TO_STRING_TAG] = returnThis;
  25849. }
  25850. }
  25851. // fix Array.prototype.{ values, @@iterator }.name in V8 / FF
  25852. if (PROPER_FUNCTION_NAME && DEFAULT == VALUES && nativeIterator && nativeIterator.name !== VALUES) {
  25853. if (!IS_PURE && CONFIGURABLE_FUNCTION_NAME) {
  25854. createNonEnumerableProperty(IterablePrototype, 'name', VALUES);
  25855. } else {
  25856. INCORRECT_VALUES_NAME = true;
  25857. defaultIterator = function values() { return call(nativeIterator, this); };
  25858. }
  25859. }
  25860. // export additional methods
  25861. if (DEFAULT) {
  25862. methods = {
  25863. values: getIterationMethod(VALUES),
  25864. keys: IS_SET ? defaultIterator : getIterationMethod(KEYS),
  25865. entries: getIterationMethod(ENTRIES)
  25866. };
  25867. if (FORCED) for (KEY in methods) {
  25868. if (BUGGY_SAFARI_ITERATORS || INCORRECT_VALUES_NAME || !(KEY in IterablePrototype)) {
  25869. defineBuiltIn(IterablePrototype, KEY, methods[KEY]);
  25870. }
  25871. } else $({ target: NAME, proto: true, forced: BUGGY_SAFARI_ITERATORS || INCORRECT_VALUES_NAME }, methods);
  25872. }
  25873. // define iterator
  25874. if ((!IS_PURE || FORCED) && IterablePrototype[ITERATOR] !== defaultIterator) {
  25875. defineBuiltIn(IterablePrototype, ITERATOR, defaultIterator, { name: DEFAULT });
  25876. }
  25877. Iterators[NAME] = defaultIterator;
  25878. return methods;
  25879. };
  25880. },{"../internals/create-non-enumerable-property":292,"../internals/define-built-in":295,"../internals/export":318,"../internals/function-call":325,"../internals/function-name":326,"../internals/is-callable":346,"../internals/is-pure":353,"../internals/iterator-create-constructor":358,"../internals/iterators":361,"../internals/iterators-core":360,"../internals/object-get-prototype-of":379,"../internals/object-set-prototype-of":385,"../internals/set-to-string-tag":401,"../internals/well-known-symbol":429}],360:[function(_dereq_,module,exports){
  25881. 'use strict';
  25882. var fails = _dereq_('../internals/fails');
  25883. var isCallable = _dereq_('../internals/is-callable');
  25884. var isObject = _dereq_('../internals/is-object');
  25885. var create = _dereq_('../internals/object-create');
  25886. var getPrototypeOf = _dereq_('../internals/object-get-prototype-of');
  25887. var defineBuiltIn = _dereq_('../internals/define-built-in');
  25888. var wellKnownSymbol = _dereq_('../internals/well-known-symbol');
  25889. var IS_PURE = _dereq_('../internals/is-pure');
  25890. var ITERATOR = wellKnownSymbol('iterator');
  25891. var BUGGY_SAFARI_ITERATORS = false;
  25892. // `%IteratorPrototype%` object
  25893. // https://tc39.es/ecma262/#sec-%iteratorprototype%-object
  25894. var IteratorPrototype, PrototypeOfArrayIteratorPrototype, arrayIterator;
  25895. /* eslint-disable es-x/no-array-prototype-keys -- safe */
  25896. if ([].keys) {
  25897. arrayIterator = [].keys();
  25898. // Safari 8 has buggy iterators w/o `next`
  25899. if (!('next' in arrayIterator)) BUGGY_SAFARI_ITERATORS = true;
  25900. else {
  25901. PrototypeOfArrayIteratorPrototype = getPrototypeOf(getPrototypeOf(arrayIterator));
  25902. if (PrototypeOfArrayIteratorPrototype !== Object.prototype) IteratorPrototype = PrototypeOfArrayIteratorPrototype;
  25903. }
  25904. }
  25905. var NEW_ITERATOR_PROTOTYPE = !isObject(IteratorPrototype) || fails(function () {
  25906. var test = {};
  25907. // FF44- legacy iterators case
  25908. return IteratorPrototype[ITERATOR].call(test) !== test;
  25909. });
  25910. if (NEW_ITERATOR_PROTOTYPE) IteratorPrototype = {};
  25911. else if (IS_PURE) IteratorPrototype = create(IteratorPrototype);
  25912. // `%IteratorPrototype%[@@iterator]()` method
  25913. // https://tc39.es/ecma262/#sec-%iteratorprototype%-@@iterator
  25914. if (!isCallable(IteratorPrototype[ITERATOR])) {
  25915. defineBuiltIn(IteratorPrototype, ITERATOR, function () {
  25916. return this;
  25917. });
  25918. }
  25919. module.exports = {
  25920. IteratorPrototype: IteratorPrototype,
  25921. BUGGY_SAFARI_ITERATORS: BUGGY_SAFARI_ITERATORS
  25922. };
  25923. },{"../internals/define-built-in":295,"../internals/fails":319,"../internals/is-callable":346,"../internals/is-object":352,"../internals/is-pure":353,"../internals/object-create":372,"../internals/object-get-prototype-of":379,"../internals/well-known-symbol":429}],361:[function(_dereq_,module,exports){
  25924. arguments[4][335][0].apply(exports,arguments)
  25925. },{"dup":335}],362:[function(_dereq_,module,exports){
  25926. var toLength = _dereq_('../internals/to-length');
  25927. // `LengthOfArrayLike` abstract operation
  25928. // https://tc39.es/ecma262/#sec-lengthofarraylike
  25929. module.exports = function (obj) {
  25930. return toLength(obj.length);
  25931. };
  25932. },{"../internals/to-length":415}],363:[function(_dereq_,module,exports){
  25933. 'use strict';
  25934. var call = _dereq_('../internals/function-call');
  25935. var aCallable = _dereq_('../internals/a-callable');
  25936. var anObject = _dereq_('../internals/an-object');
  25937. // `Map.prototype.emplace` method
  25938. // https://github.com/thumbsupep/proposal-upsert
  25939. module.exports = function emplace(key, handler) {
  25940. var map = anObject(this);
  25941. var get = aCallable(map.get);
  25942. var has = aCallable(map.has);
  25943. var set = aCallable(map.set);
  25944. var value, inserted;
  25945. if (call(has, map, key)) {
  25946. value = call(get, map, key);
  25947. if ('update' in handler) {
  25948. value = handler.update(value, key, map);
  25949. call(set, map, key, value);
  25950. } return value;
  25951. }
  25952. inserted = handler.insert(key, map);
  25953. call(set, map, key, inserted);
  25954. return inserted;
  25955. };
  25956. },{"../internals/a-callable":258,"../internals/an-object":263,"../internals/function-call":325}],364:[function(_dereq_,module,exports){
  25957. 'use strict';
  25958. var call = _dereq_('../internals/function-call');
  25959. var aCallable = _dereq_('../internals/a-callable');
  25960. var isCallable = _dereq_('../internals/is-callable');
  25961. var anObject = _dereq_('../internals/an-object');
  25962. var $TypeError = TypeError;
  25963. // `Map.prototype.upsert` method
  25964. // https://github.com/thumbsupep/proposal-upsert
  25965. module.exports = function upsert(key, updateFn /* , insertFn */) {
  25966. var map = anObject(this);
  25967. var get = aCallable(map.get);
  25968. var has = aCallable(map.has);
  25969. var set = aCallable(map.set);
  25970. var insertFn = arguments.length > 2 ? arguments[2] : undefined;
  25971. var value;
  25972. if (!isCallable(updateFn) && !isCallable(insertFn)) {
  25973. throw $TypeError('At least one callback required');
  25974. }
  25975. if (call(has, map, key)) {
  25976. value = call(get, map, key);
  25977. if (isCallable(updateFn)) {
  25978. value = updateFn(value);
  25979. call(set, map, key, value);
  25980. }
  25981. } else if (isCallable(insertFn)) {
  25982. value = insertFn();
  25983. call(set, map, key, value);
  25984. } return value;
  25985. };
  25986. },{"../internals/a-callable":258,"../internals/an-object":263,"../internals/function-call":325,"../internals/is-callable":346}],365:[function(_dereq_,module,exports){
  25987. var ceil = Math.ceil;
  25988. var floor = Math.floor;
  25989. // `Math.trunc` method
  25990. // https://tc39.es/ecma262/#sec-math.trunc
  25991. // eslint-disable-next-line es-x/no-math-trunc -- safe
  25992. module.exports = Math.trunc || function trunc(x) {
  25993. var n = +x;
  25994. return (n > 0 ? floor : ceil)(n);
  25995. };
  25996. },{}],366:[function(_dereq_,module,exports){
  25997. var global = _dereq_('../internals/global');
  25998. var bind = _dereq_('../internals/function-bind-context');
  25999. var getOwnPropertyDescriptor = _dereq_('../internals/object-get-own-property-descriptor').f;
  26000. var macrotask = _dereq_('../internals/task').set;
  26001. var IS_IOS = _dereq_('../internals/engine-is-ios');
  26002. var IS_IOS_PEBBLE = _dereq_('../internals/engine-is-ios-pebble');
  26003. var IS_WEBOS_WEBKIT = _dereq_('../internals/engine-is-webos-webkit');
  26004. var IS_NODE = _dereq_('../internals/engine-is-node');
  26005. var MutationObserver = global.MutationObserver || global.WebKitMutationObserver;
  26006. var document = global.document;
  26007. var process = global.process;
  26008. var Promise = global.Promise;
  26009. // Node.js 11 shows ExperimentalWarning on getting `queueMicrotask`
  26010. var queueMicrotaskDescriptor = getOwnPropertyDescriptor(global, 'queueMicrotask');
  26011. var queueMicrotask = queueMicrotaskDescriptor && queueMicrotaskDescriptor.value;
  26012. var flush, head, last, notify, toggle, node, promise, then;
  26013. // modern engines have queueMicrotask method
  26014. if (!queueMicrotask) {
  26015. flush = function () {
  26016. var parent, fn;
  26017. if (IS_NODE && (parent = process.domain)) parent.exit();
  26018. while (head) {
  26019. fn = head.fn;
  26020. head = head.next;
  26021. try {
  26022. fn();
  26023. } catch (error) {
  26024. if (head) notify();
  26025. else last = undefined;
  26026. throw error;
  26027. }
  26028. } last = undefined;
  26029. if (parent) parent.enter();
  26030. };
  26031. // browsers with MutationObserver, except iOS - https://github.com/zloirock/core-js/issues/339
  26032. // also except WebOS Webkit https://github.com/zloirock/core-js/issues/898
  26033. if (!IS_IOS && !IS_NODE && !IS_WEBOS_WEBKIT && MutationObserver && document) {
  26034. toggle = true;
  26035. node = document.createTextNode('');
  26036. new MutationObserver(flush).observe(node, { characterData: true });
  26037. notify = function () {
  26038. node.data = toggle = !toggle;
  26039. };
  26040. // environments with maybe non-completely correct, but existent Promise
  26041. } else if (!IS_IOS_PEBBLE && Promise && Promise.resolve) {
  26042. // Promise.resolve without an argument throws an error in LG WebOS 2
  26043. promise = Promise.resolve(undefined);
  26044. // workaround of WebKit ~ iOS Safari 10.1 bug
  26045. promise.constructor = Promise;
  26046. then = bind(promise.then, promise);
  26047. notify = function () {
  26048. then(flush);
  26049. };
  26050. // Node.js without promises
  26051. } else if (IS_NODE) {
  26052. notify = function () {
  26053. process.nextTick(flush);
  26054. };
  26055. // for other environments - macrotask based on:
  26056. // - setImmediate
  26057. // - MessageChannel
  26058. // - window.postMessage
  26059. // - onreadystatechange
  26060. // - setTimeout
  26061. } else {
  26062. // strange IE + webpack dev server bug - use .bind(global)
  26063. macrotask = bind(macrotask, global);
  26064. notify = function () {
  26065. macrotask(flush);
  26066. };
  26067. }
  26068. }
  26069. module.exports = queueMicrotask || function (fn) {
  26070. var task = { fn: fn, next: undefined };
  26071. if (last) last.next = task;
  26072. if (!head) {
  26073. head = task;
  26074. notify();
  26075. } last = task;
  26076. };
  26077. },{"../internals/engine-is-ios":308,"../internals/engine-is-ios-pebble":307,"../internals/engine-is-node":309,"../internals/engine-is-webos-webkit":310,"../internals/function-bind-context":322,"../internals/global":333,"../internals/object-get-own-property-descriptor":375,"../internals/task":411}],367:[function(_dereq_,module,exports){
  26078. 'use strict';
  26079. var aCallable = _dereq_('../internals/a-callable');
  26080. var $TypeError = TypeError;
  26081. var PromiseCapability = function (C) {
  26082. var resolve, reject;
  26083. this.promise = new C(function ($$resolve, $$reject) {
  26084. if (resolve !== undefined || reject !== undefined) throw $TypeError('Bad Promise constructor');
  26085. resolve = $$resolve;
  26086. reject = $$reject;
  26087. });
  26088. this.resolve = aCallable(resolve);
  26089. this.reject = aCallable(reject);
  26090. };
  26091. // `NewPromiseCapability` abstract operation
  26092. // https://tc39.es/ecma262/#sec-newpromisecapability
  26093. module.exports.f = function (C) {
  26094. return new PromiseCapability(C);
  26095. };
  26096. },{"../internals/a-callable":258}],368:[function(_dereq_,module,exports){
  26097. var toString = _dereq_('../internals/to-string');
  26098. module.exports = function (argument, $default) {
  26099. return argument === undefined ? arguments.length < 2 ? '' : $default : toString(argument);
  26100. };
  26101. },{"../internals/to-string":420}],369:[function(_dereq_,module,exports){
  26102. var isRegExp = _dereq_('../internals/is-regexp');
  26103. var $TypeError = TypeError;
  26104. module.exports = function (it) {
  26105. if (isRegExp(it)) {
  26106. throw $TypeError("The method doesn't accept regular expressions");
  26107. } return it;
  26108. };
  26109. },{"../internals/is-regexp":354}],370:[function(_dereq_,module,exports){
  26110. var global = _dereq_('../internals/global');
  26111. var fails = _dereq_('../internals/fails');
  26112. var uncurryThis = _dereq_('../internals/function-uncurry-this');
  26113. var toString = _dereq_('../internals/to-string');
  26114. var trim = _dereq_('../internals/string-trim').trim;
  26115. var whitespaces = _dereq_('../internals/whitespaces');
  26116. var $parseInt = global.parseInt;
  26117. var Symbol = global.Symbol;
  26118. var ITERATOR = Symbol && Symbol.iterator;
  26119. var hex = /^[+-]?0x/i;
  26120. var exec = uncurryThis(hex.exec);
  26121. var FORCED = $parseInt(whitespaces + '08') !== 8 || $parseInt(whitespaces + '0x16') !== 22
  26122. // MS Edge 18- broken with boxed symbols
  26123. || (ITERATOR && !fails(function () { $parseInt(Object(ITERATOR)); }));
  26124. // `parseInt` method
  26125. // https://tc39.es/ecma262/#sec-parseint-string-radix
  26126. module.exports = FORCED ? function parseInt(string, radix) {
  26127. var S = trim(toString(string));
  26128. return $parseInt(S, (radix >>> 0) || (exec(hex, S) ? 16 : 10));
  26129. } : $parseInt;
  26130. },{"../internals/fails":319,"../internals/function-uncurry-this":327,"../internals/global":333,"../internals/string-trim":407,"../internals/to-string":420,"../internals/whitespaces":430}],371:[function(_dereq_,module,exports){
  26131. 'use strict';
  26132. var DESCRIPTORS = _dereq_('../internals/descriptors');
  26133. var uncurryThis = _dereq_('../internals/function-uncurry-this');
  26134. var call = _dereq_('../internals/function-call');
  26135. var fails = _dereq_('../internals/fails');
  26136. var objectKeys = _dereq_('../internals/object-keys');
  26137. var getOwnPropertySymbolsModule = _dereq_('../internals/object-get-own-property-symbols');
  26138. var propertyIsEnumerableModule = _dereq_('../internals/object-property-is-enumerable');
  26139. var toObject = _dereq_('../internals/to-object');
  26140. var IndexedObject = _dereq_('../internals/indexed-object');
  26141. // eslint-disable-next-line es-x/no-object-assign -- safe
  26142. var $assign = Object.assign;
  26143. // eslint-disable-next-line es-x/no-object-defineproperty -- required for testing
  26144. var defineProperty = Object.defineProperty;
  26145. var concat = uncurryThis([].concat);
  26146. // `Object.assign` method
  26147. // https://tc39.es/ecma262/#sec-object.assign
  26148. module.exports = !$assign || fails(function () {
  26149. // should have correct order of operations (Edge bug)
  26150. if (DESCRIPTORS && $assign({ b: 1 }, $assign(defineProperty({}, 'a', {
  26151. enumerable: true,
  26152. get: function () {
  26153. defineProperty(this, 'b', {
  26154. value: 3,
  26155. enumerable: false
  26156. });
  26157. }
  26158. }), { b: 2 })).b !== 1) return true;
  26159. // should work with symbols and should have deterministic property order (V8 bug)
  26160. var A = {};
  26161. var B = {};
  26162. // eslint-disable-next-line es-x/no-symbol -- safe
  26163. var symbol = Symbol();
  26164. var alphabet = 'abcdefghijklmnopqrst';
  26165. A[symbol] = 7;
  26166. alphabet.split('').forEach(function (chr) { B[chr] = chr; });
  26167. return $assign({}, A)[symbol] != 7 || objectKeys($assign({}, B)).join('') != alphabet;
  26168. }) ? function assign(target, source) { // eslint-disable-line no-unused-vars -- required for `.length`
  26169. var T = toObject(target);
  26170. var argumentsLength = arguments.length;
  26171. var index = 1;
  26172. var getOwnPropertySymbols = getOwnPropertySymbolsModule.f;
  26173. var propertyIsEnumerable = propertyIsEnumerableModule.f;
  26174. while (argumentsLength > index) {
  26175. var S = IndexedObject(arguments[index++]);
  26176. var keys = getOwnPropertySymbols ? concat(objectKeys(S), getOwnPropertySymbols(S)) : objectKeys(S);
  26177. var length = keys.length;
  26178. var j = 0;
  26179. var key;
  26180. while (length > j) {
  26181. key = keys[j++];
  26182. if (!DESCRIPTORS || call(propertyIsEnumerable, S, key)) T[key] = S[key];
  26183. }
  26184. } return T;
  26185. } : $assign;
  26186. },{"../internals/descriptors":299,"../internals/fails":319,"../internals/function-call":325,"../internals/function-uncurry-this":327,"../internals/indexed-object":339,"../internals/object-get-own-property-symbols":378,"../internals/object-keys":383,"../internals/object-property-is-enumerable":384,"../internals/to-object":416}],372:[function(_dereq_,module,exports){
  26187. /* global ActiveXObject -- old IE, WSH */
  26188. var anObject = _dereq_('../internals/an-object');
  26189. var definePropertiesModule = _dereq_('../internals/object-define-properties');
  26190. var enumBugKeys = _dereq_('../internals/enum-bug-keys');
  26191. var hiddenKeys = _dereq_('../internals/hidden-keys');
  26192. var html = _dereq_('../internals/html');
  26193. var documentCreateElement = _dereq_('../internals/document-create-element');
  26194. var sharedKey = _dereq_('../internals/shared-key');
  26195. var GT = '>';
  26196. var LT = '<';
  26197. var PROTOTYPE = 'prototype';
  26198. var SCRIPT = 'script';
  26199. var IE_PROTO = sharedKey('IE_PROTO');
  26200. var EmptyConstructor = function () { /* empty */ };
  26201. var scriptTag = function (content) {
  26202. return LT + SCRIPT + GT + content + LT + '/' + SCRIPT + GT;
  26203. };
  26204. // Create object with fake `null` prototype: use ActiveX Object with cleared prototype
  26205. var NullProtoObjectViaActiveX = function (activeXDocument) {
  26206. activeXDocument.write(scriptTag(''));
  26207. activeXDocument.close();
  26208. var temp = activeXDocument.parentWindow.Object;
  26209. activeXDocument = null; // avoid memory leak
  26210. return temp;
  26211. };
  26212. // Create object with fake `null` prototype: use iframe Object with cleared prototype
  26213. var NullProtoObjectViaIFrame = function () {
  26214. // Thrash, waste and sodomy: IE GC bug
  26215. var iframe = documentCreateElement('iframe');
  26216. var JS = 'java' + SCRIPT + ':';
  26217. var iframeDocument;
  26218. iframe.style.display = 'none';
  26219. html.appendChild(iframe);
  26220. // https://github.com/zloirock/core-js/issues/475
  26221. iframe.src = String(JS);
  26222. iframeDocument = iframe.contentWindow.document;
  26223. iframeDocument.open();
  26224. iframeDocument.write(scriptTag('document.F=Object'));
  26225. iframeDocument.close();
  26226. return iframeDocument.F;
  26227. };
  26228. // Check for document.domain and active x support
  26229. // No need to use active x approach when document.domain is not set
  26230. // see https://github.com/es-shims/es5-shim/issues/150
  26231. // variation of https://github.com/kitcambridge/es5-shim/commit/4f738ac066346
  26232. // avoid IE GC bug
  26233. var activeXDocument;
  26234. var NullProtoObject = function () {
  26235. try {
  26236. activeXDocument = new ActiveXObject('htmlfile');
  26237. } catch (error) { /* ignore */ }
  26238. NullProtoObject = typeof document != 'undefined'
  26239. ? document.domain && activeXDocument
  26240. ? NullProtoObjectViaActiveX(activeXDocument) // old IE
  26241. : NullProtoObjectViaIFrame()
  26242. : NullProtoObjectViaActiveX(activeXDocument); // WSH
  26243. var length = enumBugKeys.length;
  26244. while (length--) delete NullProtoObject[PROTOTYPE][enumBugKeys[length]];
  26245. return NullProtoObject();
  26246. };
  26247. hiddenKeys[IE_PROTO] = true;
  26248. // `Object.create` method
  26249. // https://tc39.es/ecma262/#sec-object.create
  26250. // eslint-disable-next-line es-x/no-object-create -- safe
  26251. module.exports = Object.create || function create(O, Properties) {
  26252. var result;
  26253. if (O !== null) {
  26254. EmptyConstructor[PROTOTYPE] = anObject(O);
  26255. result = new EmptyConstructor();
  26256. EmptyConstructor[PROTOTYPE] = null;
  26257. // add "__proto__" for Object.getPrototypeOf polyfill
  26258. result[IE_PROTO] = O;
  26259. } else result = NullProtoObject();
  26260. return Properties === undefined ? result : definePropertiesModule.f(result, Properties);
  26261. };
  26262. },{"../internals/an-object":263,"../internals/document-create-element":300,"../internals/enum-bug-keys":315,"../internals/hidden-keys":335,"../internals/html":337,"../internals/object-define-properties":373,"../internals/shared-key":402}],373:[function(_dereq_,module,exports){
  26263. var DESCRIPTORS = _dereq_('../internals/descriptors');
  26264. var V8_PROTOTYPE_DEFINE_BUG = _dereq_('../internals/v8-prototype-define-bug');
  26265. var definePropertyModule = _dereq_('../internals/object-define-property');
  26266. var anObject = _dereq_('../internals/an-object');
  26267. var toIndexedObject = _dereq_('../internals/to-indexed-object');
  26268. var objectKeys = _dereq_('../internals/object-keys');
  26269. // `Object.defineProperties` method
  26270. // https://tc39.es/ecma262/#sec-object.defineproperties
  26271. // eslint-disable-next-line es-x/no-object-defineproperties -- safe
  26272. exports.f = DESCRIPTORS && !V8_PROTOTYPE_DEFINE_BUG ? Object.defineProperties : function defineProperties(O, Properties) {
  26273. anObject(O);
  26274. var props = toIndexedObject(Properties);
  26275. var keys = objectKeys(Properties);
  26276. var length = keys.length;
  26277. var index = 0;
  26278. var key;
  26279. while (length > index) definePropertyModule.f(O, key = keys[index++], props[key]);
  26280. return O;
  26281. };
  26282. },{"../internals/an-object":263,"../internals/descriptors":299,"../internals/object-define-property":374,"../internals/object-keys":383,"../internals/to-indexed-object":413,"../internals/v8-prototype-define-bug":424}],374:[function(_dereq_,module,exports){
  26283. var DESCRIPTORS = _dereq_('../internals/descriptors');
  26284. var IE8_DOM_DEFINE = _dereq_('../internals/ie8-dom-define');
  26285. var V8_PROTOTYPE_DEFINE_BUG = _dereq_('../internals/v8-prototype-define-bug');
  26286. var anObject = _dereq_('../internals/an-object');
  26287. var toPropertyKey = _dereq_('../internals/to-property-key');
  26288. var $TypeError = TypeError;
  26289. // eslint-disable-next-line es-x/no-object-defineproperty -- safe
  26290. var $defineProperty = Object.defineProperty;
  26291. // eslint-disable-next-line es-x/no-object-getownpropertydescriptor -- safe
  26292. var $getOwnPropertyDescriptor = Object.getOwnPropertyDescriptor;
  26293. var ENUMERABLE = 'enumerable';
  26294. var CONFIGURABLE = 'configurable';
  26295. var WRITABLE = 'writable';
  26296. // `Object.defineProperty` method
  26297. // https://tc39.es/ecma262/#sec-object.defineproperty
  26298. exports.f = DESCRIPTORS ? V8_PROTOTYPE_DEFINE_BUG ? function defineProperty(O, P, Attributes) {
  26299. anObject(O);
  26300. P = toPropertyKey(P);
  26301. anObject(Attributes);
  26302. if (typeof O === 'function' && P === 'prototype' && 'value' in Attributes && WRITABLE in Attributes && !Attributes[WRITABLE]) {
  26303. var current = $getOwnPropertyDescriptor(O, P);
  26304. if (current && current[WRITABLE]) {
  26305. O[P] = Attributes.value;
  26306. Attributes = {
  26307. configurable: CONFIGURABLE in Attributes ? Attributes[CONFIGURABLE] : current[CONFIGURABLE],
  26308. enumerable: ENUMERABLE in Attributes ? Attributes[ENUMERABLE] : current[ENUMERABLE],
  26309. writable: false
  26310. };
  26311. }
  26312. } return $defineProperty(O, P, Attributes);
  26313. } : $defineProperty : function defineProperty(O, P, Attributes) {
  26314. anObject(O);
  26315. P = toPropertyKey(P);
  26316. anObject(Attributes);
  26317. if (IE8_DOM_DEFINE) try {
  26318. return $defineProperty(O, P, Attributes);
  26319. } catch (error) { /* empty */ }
  26320. if ('get' in Attributes || 'set' in Attributes) throw $TypeError('Accessors not supported');
  26321. if ('value' in Attributes) O[P] = Attributes.value;
  26322. return O;
  26323. };
  26324. },{"../internals/an-object":263,"../internals/descriptors":299,"../internals/ie8-dom-define":338,"../internals/to-property-key":418,"../internals/v8-prototype-define-bug":424}],375:[function(_dereq_,module,exports){
  26325. var DESCRIPTORS = _dereq_('../internals/descriptors');
  26326. var call = _dereq_('../internals/function-call');
  26327. var propertyIsEnumerableModule = _dereq_('../internals/object-property-is-enumerable');
  26328. var createPropertyDescriptor = _dereq_('../internals/create-property-descriptor');
  26329. var toIndexedObject = _dereq_('../internals/to-indexed-object');
  26330. var toPropertyKey = _dereq_('../internals/to-property-key');
  26331. var hasOwn = _dereq_('../internals/has-own-property');
  26332. var IE8_DOM_DEFINE = _dereq_('../internals/ie8-dom-define');
  26333. // eslint-disable-next-line es-x/no-object-getownpropertydescriptor -- safe
  26334. var $getOwnPropertyDescriptor = Object.getOwnPropertyDescriptor;
  26335. // `Object.getOwnPropertyDescriptor` method
  26336. // https://tc39.es/ecma262/#sec-object.getownpropertydescriptor
  26337. exports.f = DESCRIPTORS ? $getOwnPropertyDescriptor : function getOwnPropertyDescriptor(O, P) {
  26338. O = toIndexedObject(O);
  26339. P = toPropertyKey(P);
  26340. if (IE8_DOM_DEFINE) try {
  26341. return $getOwnPropertyDescriptor(O, P);
  26342. } catch (error) { /* empty */ }
  26343. if (hasOwn(O, P)) return createPropertyDescriptor(!call(propertyIsEnumerableModule.f, O, P), O[P]);
  26344. };
  26345. },{"../internals/create-property-descriptor":293,"../internals/descriptors":299,"../internals/function-call":325,"../internals/has-own-property":334,"../internals/ie8-dom-define":338,"../internals/object-property-is-enumerable":384,"../internals/to-indexed-object":413,"../internals/to-property-key":418}],376:[function(_dereq_,module,exports){
  26346. /* eslint-disable es-x/no-object-getownpropertynames -- safe */
  26347. var classof = _dereq_('../internals/classof-raw');
  26348. var toIndexedObject = _dereq_('../internals/to-indexed-object');
  26349. var $getOwnPropertyNames = _dereq_('../internals/object-get-own-property-names').f;
  26350. var arraySlice = _dereq_('../internals/array-slice-simple');
  26351. var windowNames = typeof window == 'object' && window && Object.getOwnPropertyNames
  26352. ? Object.getOwnPropertyNames(window) : [];
  26353. var getWindowNames = function (it) {
  26354. try {
  26355. return $getOwnPropertyNames(it);
  26356. } catch (error) {
  26357. return arraySlice(windowNames);
  26358. }
  26359. };
  26360. // fallback for IE11 buggy Object.getOwnPropertyNames with iframe and window
  26361. module.exports.f = function getOwnPropertyNames(it) {
  26362. return windowNames && classof(it) == 'Window'
  26363. ? getWindowNames(it)
  26364. : $getOwnPropertyNames(toIndexedObject(it));
  26365. };
  26366. },{"../internals/array-slice-simple":273,"../internals/classof-raw":280,"../internals/object-get-own-property-names":377,"../internals/to-indexed-object":413}],377:[function(_dereq_,module,exports){
  26367. var internalObjectKeys = _dereq_('../internals/object-keys-internal');
  26368. var enumBugKeys = _dereq_('../internals/enum-bug-keys');
  26369. var hiddenKeys = enumBugKeys.concat('length', 'prototype');
  26370. // `Object.getOwnPropertyNames` method
  26371. // https://tc39.es/ecma262/#sec-object.getownpropertynames
  26372. // eslint-disable-next-line es-x/no-object-getownpropertynames -- safe
  26373. exports.f = Object.getOwnPropertyNames || function getOwnPropertyNames(O) {
  26374. return internalObjectKeys(O, hiddenKeys);
  26375. };
  26376. },{"../internals/enum-bug-keys":315,"../internals/object-keys-internal":382}],378:[function(_dereq_,module,exports){
  26377. // eslint-disable-next-line es-x/no-object-getownpropertysymbols -- safe
  26378. exports.f = Object.getOwnPropertySymbols;
  26379. },{}],379:[function(_dereq_,module,exports){
  26380. var hasOwn = _dereq_('../internals/has-own-property');
  26381. var isCallable = _dereq_('../internals/is-callable');
  26382. var toObject = _dereq_('../internals/to-object');
  26383. var sharedKey = _dereq_('../internals/shared-key');
  26384. var CORRECT_PROTOTYPE_GETTER = _dereq_('../internals/correct-prototype-getter');
  26385. var IE_PROTO = sharedKey('IE_PROTO');
  26386. var $Object = Object;
  26387. var ObjectPrototype = $Object.prototype;
  26388. // `Object.getPrototypeOf` method
  26389. // https://tc39.es/ecma262/#sec-object.getprototypeof
  26390. // eslint-disable-next-line es-x/no-object-getprototypeof -- safe
  26391. module.exports = CORRECT_PROTOTYPE_GETTER ? $Object.getPrototypeOf : function (O) {
  26392. var object = toObject(O);
  26393. if (hasOwn(object, IE_PROTO)) return object[IE_PROTO];
  26394. var constructor = object.constructor;
  26395. if (isCallable(constructor) && object instanceof constructor) {
  26396. return constructor.prototype;
  26397. } return object instanceof $Object ? ObjectPrototype : null;
  26398. };
  26399. },{"../internals/correct-prototype-getter":290,"../internals/has-own-property":334,"../internals/is-callable":346,"../internals/shared-key":402,"../internals/to-object":416}],380:[function(_dereq_,module,exports){
  26400. var fails = _dereq_('../internals/fails');
  26401. var isObject = _dereq_('../internals/is-object');
  26402. var classof = _dereq_('../internals/classof-raw');
  26403. var ARRAY_BUFFER_NON_EXTENSIBLE = _dereq_('../internals/array-buffer-non-extensible');
  26404. // eslint-disable-next-line es-x/no-object-isextensible -- safe
  26405. var $isExtensible = Object.isExtensible;
  26406. var FAILS_ON_PRIMITIVES = fails(function () { $isExtensible(1); });
  26407. // `Object.isExtensible` method
  26408. // https://tc39.es/ecma262/#sec-object.isextensible
  26409. module.exports = (FAILS_ON_PRIMITIVES || ARRAY_BUFFER_NON_EXTENSIBLE) ? function isExtensible(it) {
  26410. if (!isObject(it)) return false;
  26411. if (ARRAY_BUFFER_NON_EXTENSIBLE && classof(it) == 'ArrayBuffer') return false;
  26412. return $isExtensible ? $isExtensible(it) : true;
  26413. } : $isExtensible;
  26414. },{"../internals/array-buffer-non-extensible":264,"../internals/classof-raw":280,"../internals/fails":319,"../internals/is-object":352}],381:[function(_dereq_,module,exports){
  26415. var uncurryThis = _dereq_('../internals/function-uncurry-this');
  26416. module.exports = uncurryThis({}.isPrototypeOf);
  26417. },{"../internals/function-uncurry-this":327}],382:[function(_dereq_,module,exports){
  26418. var uncurryThis = _dereq_('../internals/function-uncurry-this');
  26419. var hasOwn = _dereq_('../internals/has-own-property');
  26420. var toIndexedObject = _dereq_('../internals/to-indexed-object');
  26421. var indexOf = _dereq_('../internals/array-includes').indexOf;
  26422. var hiddenKeys = _dereq_('../internals/hidden-keys');
  26423. var push = uncurryThis([].push);
  26424. module.exports = function (object, names) {
  26425. var O = toIndexedObject(object);
  26426. var i = 0;
  26427. var result = [];
  26428. var key;
  26429. for (key in O) !hasOwn(hiddenKeys, key) && hasOwn(O, key) && push(result, key);
  26430. // Don't enum bug & hidden keys
  26431. while (names.length > i) if (hasOwn(O, key = names[i++])) {
  26432. ~indexOf(result, key) || push(result, key);
  26433. }
  26434. return result;
  26435. };
  26436. },{"../internals/array-includes":267,"../internals/function-uncurry-this":327,"../internals/has-own-property":334,"../internals/hidden-keys":335,"../internals/to-indexed-object":413}],383:[function(_dereq_,module,exports){
  26437. var internalObjectKeys = _dereq_('../internals/object-keys-internal');
  26438. var enumBugKeys = _dereq_('../internals/enum-bug-keys');
  26439. // `Object.keys` method
  26440. // https://tc39.es/ecma262/#sec-object.keys
  26441. // eslint-disable-next-line es-x/no-object-keys -- safe
  26442. module.exports = Object.keys || function keys(O) {
  26443. return internalObjectKeys(O, enumBugKeys);
  26444. };
  26445. },{"../internals/enum-bug-keys":315,"../internals/object-keys-internal":382}],384:[function(_dereq_,module,exports){
  26446. 'use strict';
  26447. var $propertyIsEnumerable = {}.propertyIsEnumerable;
  26448. // eslint-disable-next-line es-x/no-object-getownpropertydescriptor -- safe
  26449. var getOwnPropertyDescriptor = Object.getOwnPropertyDescriptor;
  26450. // Nashorn ~ JDK8 bug
  26451. var NASHORN_BUG = getOwnPropertyDescriptor && !$propertyIsEnumerable.call({ 1: 2 }, 1);
  26452. // `Object.prototype.propertyIsEnumerable` method implementation
  26453. // https://tc39.es/ecma262/#sec-object.prototype.propertyisenumerable
  26454. exports.f = NASHORN_BUG ? function propertyIsEnumerable(V) {
  26455. var descriptor = getOwnPropertyDescriptor(this, V);
  26456. return !!descriptor && descriptor.enumerable;
  26457. } : $propertyIsEnumerable;
  26458. },{}],385:[function(_dereq_,module,exports){
  26459. /* eslint-disable no-proto -- safe */
  26460. var uncurryThis = _dereq_('../internals/function-uncurry-this');
  26461. var anObject = _dereq_('../internals/an-object');
  26462. var aPossiblePrototype = _dereq_('../internals/a-possible-prototype');
  26463. // `Object.setPrototypeOf` method
  26464. // https://tc39.es/ecma262/#sec-object.setprototypeof
  26465. // Works with __proto__ only. Old v8 can't work with null proto objects.
  26466. // eslint-disable-next-line es-x/no-object-setprototypeof -- safe
  26467. module.exports = Object.setPrototypeOf || ('__proto__' in {} ? function () {
  26468. var CORRECT_SETTER = false;
  26469. var test = {};
  26470. var setter;
  26471. try {
  26472. // eslint-disable-next-line es-x/no-object-getownpropertydescriptor -- safe
  26473. setter = uncurryThis(Object.getOwnPropertyDescriptor(Object.prototype, '__proto__').set);
  26474. setter(test, []);
  26475. CORRECT_SETTER = test instanceof Array;
  26476. } catch (error) { /* empty */ }
  26477. return function setPrototypeOf(O, proto) {
  26478. anObject(O);
  26479. aPossiblePrototype(proto);
  26480. if (CORRECT_SETTER) setter(O, proto);
  26481. else O.__proto__ = proto;
  26482. return O;
  26483. };
  26484. }() : undefined);
  26485. },{"../internals/a-possible-prototype":260,"../internals/an-object":263,"../internals/function-uncurry-this":327}],386:[function(_dereq_,module,exports){
  26486. var DESCRIPTORS = _dereq_('../internals/descriptors');
  26487. var uncurryThis = _dereq_('../internals/function-uncurry-this');
  26488. var objectKeys = _dereq_('../internals/object-keys');
  26489. var toIndexedObject = _dereq_('../internals/to-indexed-object');
  26490. var $propertyIsEnumerable = _dereq_('../internals/object-property-is-enumerable').f;
  26491. var propertyIsEnumerable = uncurryThis($propertyIsEnumerable);
  26492. var push = uncurryThis([].push);
  26493. // `Object.{ entries, values }` methods implementation
  26494. var createMethod = function (TO_ENTRIES) {
  26495. return function (it) {
  26496. var O = toIndexedObject(it);
  26497. var keys = objectKeys(O);
  26498. var length = keys.length;
  26499. var i = 0;
  26500. var result = [];
  26501. var key;
  26502. while (length > i) {
  26503. key = keys[i++];
  26504. if (!DESCRIPTORS || propertyIsEnumerable(O, key)) {
  26505. push(result, TO_ENTRIES ? [key, O[key]] : O[key]);
  26506. }
  26507. }
  26508. return result;
  26509. };
  26510. };
  26511. module.exports = {
  26512. // `Object.entries` method
  26513. // https://tc39.es/ecma262/#sec-object.entries
  26514. entries: createMethod(true),
  26515. // `Object.values` method
  26516. // https://tc39.es/ecma262/#sec-object.values
  26517. values: createMethod(false)
  26518. };
  26519. },{"../internals/descriptors":299,"../internals/function-uncurry-this":327,"../internals/object-keys":383,"../internals/object-property-is-enumerable":384,"../internals/to-indexed-object":413}],387:[function(_dereq_,module,exports){
  26520. 'use strict';
  26521. var TO_STRING_TAG_SUPPORT = _dereq_('../internals/to-string-tag-support');
  26522. var classof = _dereq_('../internals/classof');
  26523. // `Object.prototype.toString` method implementation
  26524. // https://tc39.es/ecma262/#sec-object.prototype.tostring
  26525. module.exports = TO_STRING_TAG_SUPPORT ? {}.toString : function toString() {
  26526. return '[object ' + classof(this) + ']';
  26527. };
  26528. },{"../internals/classof":281,"../internals/to-string-tag-support":419}],388:[function(_dereq_,module,exports){
  26529. var call = _dereq_('../internals/function-call');
  26530. var isCallable = _dereq_('../internals/is-callable');
  26531. var isObject = _dereq_('../internals/is-object');
  26532. var $TypeError = TypeError;
  26533. // `OrdinaryToPrimitive` abstract operation
  26534. // https://tc39.es/ecma262/#sec-ordinarytoprimitive
  26535. module.exports = function (input, pref) {
  26536. var fn, val;
  26537. if (pref === 'string' && isCallable(fn = input.toString) && !isObject(val = call(fn, input))) return val;
  26538. if (isCallable(fn = input.valueOf) && !isObject(val = call(fn, input))) return val;
  26539. if (pref !== 'string' && isCallable(fn = input.toString) && !isObject(val = call(fn, input))) return val;
  26540. throw $TypeError("Can't convert object to primitive value");
  26541. };
  26542. },{"../internals/function-call":325,"../internals/is-callable":346,"../internals/is-object":352}],389:[function(_dereq_,module,exports){
  26543. var getBuiltIn = _dereq_('../internals/get-built-in');
  26544. var uncurryThis = _dereq_('../internals/function-uncurry-this');
  26545. var getOwnPropertyNamesModule = _dereq_('../internals/object-get-own-property-names');
  26546. var getOwnPropertySymbolsModule = _dereq_('../internals/object-get-own-property-symbols');
  26547. var anObject = _dereq_('../internals/an-object');
  26548. var concat = uncurryThis([].concat);
  26549. // all object keys, includes non-enumerable and symbols
  26550. module.exports = getBuiltIn('Reflect', 'ownKeys') || function ownKeys(it) {
  26551. var keys = getOwnPropertyNamesModule.f(anObject(it));
  26552. var getOwnPropertySymbols = getOwnPropertySymbolsModule.f;
  26553. return getOwnPropertySymbols ? concat(keys, getOwnPropertySymbols(it)) : keys;
  26554. };
  26555. },{"../internals/an-object":263,"../internals/function-uncurry-this":327,"../internals/get-built-in":328,"../internals/object-get-own-property-names":377,"../internals/object-get-own-property-symbols":378}],390:[function(_dereq_,module,exports){
  26556. arguments[4][335][0].apply(exports,arguments)
  26557. },{"dup":335}],391:[function(_dereq_,module,exports){
  26558. module.exports = function (exec) {
  26559. try {
  26560. return { error: false, value: exec() };
  26561. } catch (error) {
  26562. return { error: true, value: error };
  26563. }
  26564. };
  26565. },{}],392:[function(_dereq_,module,exports){
  26566. var global = _dereq_('../internals/global');
  26567. var NativePromiseConstructor = _dereq_('../internals/promise-native-constructor');
  26568. var isCallable = _dereq_('../internals/is-callable');
  26569. var isForced = _dereq_('../internals/is-forced');
  26570. var inspectSource = _dereq_('../internals/inspect-source');
  26571. var wellKnownSymbol = _dereq_('../internals/well-known-symbol');
  26572. var IS_BROWSER = _dereq_('../internals/engine-is-browser');
  26573. var IS_DENO = _dereq_('../internals/engine-is-deno');
  26574. var IS_PURE = _dereq_('../internals/is-pure');
  26575. var V8_VERSION = _dereq_('../internals/engine-v8-version');
  26576. var NativePromisePrototype = NativePromiseConstructor && NativePromiseConstructor.prototype;
  26577. var SPECIES = wellKnownSymbol('species');
  26578. var SUBCLASSING = false;
  26579. var NATIVE_PROMISE_REJECTION_EVENT = isCallable(global.PromiseRejectionEvent);
  26580. var FORCED_PROMISE_CONSTRUCTOR = isForced('Promise', function () {
  26581. var PROMISE_CONSTRUCTOR_SOURCE = inspectSource(NativePromiseConstructor);
  26582. var GLOBAL_CORE_JS_PROMISE = PROMISE_CONSTRUCTOR_SOURCE !== String(NativePromiseConstructor);
  26583. // V8 6.6 (Node 10 and Chrome 66) have a bug with resolving custom thenables
  26584. // https://bugs.chromium.org/p/chromium/issues/detail?id=830565
  26585. // We can't detect it synchronously, so just check versions
  26586. if (!GLOBAL_CORE_JS_PROMISE && V8_VERSION === 66) return true;
  26587. // We need Promise#{ catch, finally } in the pure version for preventing prototype pollution
  26588. if (IS_PURE && !(NativePromisePrototype['catch'] && NativePromisePrototype['finally'])) return true;
  26589. // We can't use @@species feature detection in V8 since it causes
  26590. // deoptimization and performance degradation
  26591. // https://github.com/zloirock/core-js/issues/679
  26592. if (!V8_VERSION || V8_VERSION < 51 || !/native code/.test(PROMISE_CONSTRUCTOR_SOURCE)) {
  26593. // Detect correctness of subclassing with @@species support
  26594. var promise = new NativePromiseConstructor(function (resolve) { resolve(1); });
  26595. var FakePromise = function (exec) {
  26596. exec(function () { /* empty */ }, function () { /* empty */ });
  26597. };
  26598. var constructor = promise.constructor = {};
  26599. constructor[SPECIES] = FakePromise;
  26600. SUBCLASSING = promise.then(function () { /* empty */ }) instanceof FakePromise;
  26601. if (!SUBCLASSING) return true;
  26602. // Unhandled rejections tracking support, NodeJS Promise without it fails @@species test
  26603. } return !GLOBAL_CORE_JS_PROMISE && (IS_BROWSER || IS_DENO) && !NATIVE_PROMISE_REJECTION_EVENT;
  26604. });
  26605. module.exports = {
  26606. CONSTRUCTOR: FORCED_PROMISE_CONSTRUCTOR,
  26607. REJECTION_EVENT: NATIVE_PROMISE_REJECTION_EVENT,
  26608. SUBCLASSING: SUBCLASSING
  26609. };
  26610. },{"../internals/engine-is-browser":304,"../internals/engine-is-deno":305,"../internals/engine-v8-version":312,"../internals/global":333,"../internals/inspect-source":340,"../internals/is-callable":346,"../internals/is-forced":349,"../internals/is-pure":353,"../internals/promise-native-constructor":393,"../internals/well-known-symbol":429}],393:[function(_dereq_,module,exports){
  26611. var global = _dereq_('../internals/global');
  26612. module.exports = global.Promise;
  26613. },{"../internals/global":333}],394:[function(_dereq_,module,exports){
  26614. var anObject = _dereq_('../internals/an-object');
  26615. var isObject = _dereq_('../internals/is-object');
  26616. var newPromiseCapability = _dereq_('../internals/new-promise-capability');
  26617. module.exports = function (C, x) {
  26618. anObject(C);
  26619. if (isObject(x) && x.constructor === C) return x;
  26620. var promiseCapability = newPromiseCapability.f(C);
  26621. var resolve = promiseCapability.resolve;
  26622. resolve(x);
  26623. return promiseCapability.promise;
  26624. };
  26625. },{"../internals/an-object":263,"../internals/is-object":352,"../internals/new-promise-capability":367}],395:[function(_dereq_,module,exports){
  26626. var NativePromiseConstructor = _dereq_('../internals/promise-native-constructor');
  26627. var checkCorrectnessOfIteration = _dereq_('../internals/check-correctness-of-iteration');
  26628. var FORCED_PROMISE_CONSTRUCTOR = _dereq_('../internals/promise-constructor-detection').CONSTRUCTOR;
  26629. module.exports = FORCED_PROMISE_CONSTRUCTOR || !checkCorrectnessOfIteration(function (iterable) {
  26630. NativePromiseConstructor.all(iterable).then(undefined, function () { /* empty */ });
  26631. });
  26632. },{"../internals/check-correctness-of-iteration":279,"../internals/promise-constructor-detection":392,"../internals/promise-native-constructor":393}],396:[function(_dereq_,module,exports){
  26633. var Queue = function () {
  26634. this.head = null;
  26635. this.tail = null;
  26636. };
  26637. Queue.prototype = {
  26638. add: function (item) {
  26639. var entry = { item: item, next: null };
  26640. if (this.head) this.tail.next = entry;
  26641. else this.head = entry;
  26642. this.tail = entry;
  26643. },
  26644. get: function () {
  26645. var entry = this.head;
  26646. if (entry) {
  26647. this.head = entry.next;
  26648. if (this.tail === entry) this.tail = null;
  26649. return entry.item;
  26650. }
  26651. }
  26652. };
  26653. module.exports = Queue;
  26654. },{}],397:[function(_dereq_,module,exports){
  26655. var isNullOrUndefined = _dereq_('../internals/is-null-or-undefined');
  26656. var $TypeError = TypeError;
  26657. // `RequireObjectCoercible` abstract operation
  26658. // https://tc39.es/ecma262/#sec-requireobjectcoercible
  26659. module.exports = function (it) {
  26660. if (isNullOrUndefined(it)) throw $TypeError("Can't call method on " + it);
  26661. return it;
  26662. };
  26663. },{"../internals/is-null-or-undefined":351}],398:[function(_dereq_,module,exports){
  26664. // `SameValueZero` abstract operation
  26665. // https://tc39.es/ecma262/#sec-samevaluezero
  26666. module.exports = function (x, y) {
  26667. // eslint-disable-next-line no-self-compare -- NaN check
  26668. return x === y || x != x && y != y;
  26669. };
  26670. },{}],399:[function(_dereq_,module,exports){
  26671. var global = _dereq_('../internals/global');
  26672. var apply = _dereq_('../internals/function-apply');
  26673. var isCallable = _dereq_('../internals/is-callable');
  26674. var userAgent = _dereq_('../internals/engine-user-agent');
  26675. var arraySlice = _dereq_('../internals/array-slice');
  26676. var validateArgumentsLength = _dereq_('../internals/validate-arguments-length');
  26677. var MSIE = /MSIE .\./.test(userAgent); // <- dirty ie9- check
  26678. var Function = global.Function;
  26679. var wrap = function (scheduler) {
  26680. return MSIE ? function (handler, timeout /* , ...arguments */) {
  26681. var boundArgs = validateArgumentsLength(arguments.length, 1) > 2;
  26682. var fn = isCallable(handler) ? handler : Function(handler);
  26683. var args = boundArgs ? arraySlice(arguments, 2) : undefined;
  26684. return scheduler(boundArgs ? function () {
  26685. apply(fn, this, args);
  26686. } : fn, timeout);
  26687. } : scheduler;
  26688. };
  26689. // ie9- setTimeout & setInterval additional parameters fix
  26690. // https://html.spec.whatwg.org/multipage/timers-and-user-prompts.html#timers
  26691. module.exports = {
  26692. // `setTimeout` method
  26693. // https://html.spec.whatwg.org/multipage/timers-and-user-prompts.html#dom-settimeout
  26694. setTimeout: wrap(global.setTimeout),
  26695. // `setInterval` method
  26696. // https://html.spec.whatwg.org/multipage/timers-and-user-prompts.html#dom-setinterval
  26697. setInterval: wrap(global.setInterval)
  26698. };
  26699. },{"../internals/array-slice":274,"../internals/engine-user-agent":311,"../internals/function-apply":321,"../internals/global":333,"../internals/is-callable":346,"../internals/validate-arguments-length":425}],400:[function(_dereq_,module,exports){
  26700. 'use strict';
  26701. var getBuiltIn = _dereq_('../internals/get-built-in');
  26702. var definePropertyModule = _dereq_('../internals/object-define-property');
  26703. var wellKnownSymbol = _dereq_('../internals/well-known-symbol');
  26704. var DESCRIPTORS = _dereq_('../internals/descriptors');
  26705. var SPECIES = wellKnownSymbol('species');
  26706. module.exports = function (CONSTRUCTOR_NAME) {
  26707. var Constructor = getBuiltIn(CONSTRUCTOR_NAME);
  26708. var defineProperty = definePropertyModule.f;
  26709. if (DESCRIPTORS && Constructor && !Constructor[SPECIES]) {
  26710. defineProperty(Constructor, SPECIES, {
  26711. configurable: true,
  26712. get: function () { return this; }
  26713. });
  26714. }
  26715. };
  26716. },{"../internals/descriptors":299,"../internals/get-built-in":328,"../internals/object-define-property":374,"../internals/well-known-symbol":429}],401:[function(_dereq_,module,exports){
  26717. var TO_STRING_TAG_SUPPORT = _dereq_('../internals/to-string-tag-support');
  26718. var defineProperty = _dereq_('../internals/object-define-property').f;
  26719. var createNonEnumerableProperty = _dereq_('../internals/create-non-enumerable-property');
  26720. var hasOwn = _dereq_('../internals/has-own-property');
  26721. var toString = _dereq_('../internals/object-to-string');
  26722. var wellKnownSymbol = _dereq_('../internals/well-known-symbol');
  26723. var TO_STRING_TAG = wellKnownSymbol('toStringTag');
  26724. module.exports = function (it, TAG, STATIC, SET_METHOD) {
  26725. if (it) {
  26726. var target = STATIC ? it : it.prototype;
  26727. if (!hasOwn(target, TO_STRING_TAG)) {
  26728. defineProperty(target, TO_STRING_TAG, { configurable: true, value: TAG });
  26729. }
  26730. if (SET_METHOD && !TO_STRING_TAG_SUPPORT) {
  26731. createNonEnumerableProperty(target, 'toString', toString);
  26732. }
  26733. }
  26734. };
  26735. },{"../internals/create-non-enumerable-property":292,"../internals/has-own-property":334,"../internals/object-define-property":374,"../internals/object-to-string":387,"../internals/to-string-tag-support":419,"../internals/well-known-symbol":429}],402:[function(_dereq_,module,exports){
  26736. var shared = _dereq_('../internals/shared');
  26737. var uid = _dereq_('../internals/uid');
  26738. var keys = shared('keys');
  26739. module.exports = function (key) {
  26740. return keys[key] || (keys[key] = uid(key));
  26741. };
  26742. },{"../internals/shared":404,"../internals/uid":422}],403:[function(_dereq_,module,exports){
  26743. var global = _dereq_('../internals/global');
  26744. var defineGlobalProperty = _dereq_('../internals/define-global-property');
  26745. var SHARED = '__core-js_shared__';
  26746. var store = global[SHARED] || defineGlobalProperty(SHARED, {});
  26747. module.exports = store;
  26748. },{"../internals/define-global-property":297,"../internals/global":333}],404:[function(_dereq_,module,exports){
  26749. var IS_PURE = _dereq_('../internals/is-pure');
  26750. var store = _dereq_('../internals/shared-store');
  26751. (module.exports = function (key, value) {
  26752. return store[key] || (store[key] = value !== undefined ? value : {});
  26753. })('versions', []).push({
  26754. version: '3.25.1',
  26755. mode: IS_PURE ? 'pure' : 'global',
  26756. copyright: '© 2014-2022 Denis Pushkarev (zloirock.ru)',
  26757. license: 'https://github.com/zloirock/core-js/blob/v3.25.1/LICENSE',
  26758. source: 'https://github.com/zloirock/core-js'
  26759. });
  26760. },{"../internals/is-pure":353,"../internals/shared-store":403}],405:[function(_dereq_,module,exports){
  26761. var anObject = _dereq_('../internals/an-object');
  26762. var aConstructor = _dereq_('../internals/a-constructor');
  26763. var isNullOrUndefined = _dereq_('../internals/is-null-or-undefined');
  26764. var wellKnownSymbol = _dereq_('../internals/well-known-symbol');
  26765. var SPECIES = wellKnownSymbol('species');
  26766. // `SpeciesConstructor` abstract operation
  26767. // https://tc39.es/ecma262/#sec-speciesconstructor
  26768. module.exports = function (O, defaultConstructor) {
  26769. var C = anObject(O).constructor;
  26770. var S;
  26771. return C === undefined || isNullOrUndefined(S = anObject(C)[SPECIES]) ? defaultConstructor : aConstructor(S);
  26772. };
  26773. },{"../internals/a-constructor":259,"../internals/an-object":263,"../internals/is-null-or-undefined":351,"../internals/well-known-symbol":429}],406:[function(_dereq_,module,exports){
  26774. var uncurryThis = _dereq_('../internals/function-uncurry-this');
  26775. var toIntegerOrInfinity = _dereq_('../internals/to-integer-or-infinity');
  26776. var toString = _dereq_('../internals/to-string');
  26777. var requireObjectCoercible = _dereq_('../internals/require-object-coercible');
  26778. var charAt = uncurryThis(''.charAt);
  26779. var charCodeAt = uncurryThis(''.charCodeAt);
  26780. var stringSlice = uncurryThis(''.slice);
  26781. var createMethod = function (CONVERT_TO_STRING) {
  26782. return function ($this, pos) {
  26783. var S = toString(requireObjectCoercible($this));
  26784. var position = toIntegerOrInfinity(pos);
  26785. var size = S.length;
  26786. var first, second;
  26787. if (position < 0 || position >= size) return CONVERT_TO_STRING ? '' : undefined;
  26788. first = charCodeAt(S, position);
  26789. return first < 0xD800 || first > 0xDBFF || position + 1 === size
  26790. || (second = charCodeAt(S, position + 1)) < 0xDC00 || second > 0xDFFF
  26791. ? CONVERT_TO_STRING
  26792. ? charAt(S, position)
  26793. : first
  26794. : CONVERT_TO_STRING
  26795. ? stringSlice(S, position, position + 2)
  26796. : (first - 0xD800 << 10) + (second - 0xDC00) + 0x10000;
  26797. };
  26798. };
  26799. module.exports = {
  26800. // `String.prototype.codePointAt` method
  26801. // https://tc39.es/ecma262/#sec-string.prototype.codepointat
  26802. codeAt: createMethod(false),
  26803. // `String.prototype.at` method
  26804. // https://github.com/mathiasbynens/String.prototype.at
  26805. charAt: createMethod(true)
  26806. };
  26807. },{"../internals/function-uncurry-this":327,"../internals/require-object-coercible":397,"../internals/to-integer-or-infinity":414,"../internals/to-string":420}],407:[function(_dereq_,module,exports){
  26808. var uncurryThis = _dereq_('../internals/function-uncurry-this');
  26809. var requireObjectCoercible = _dereq_('../internals/require-object-coercible');
  26810. var toString = _dereq_('../internals/to-string');
  26811. var whitespaces = _dereq_('../internals/whitespaces');
  26812. var replace = uncurryThis(''.replace);
  26813. var whitespace = '[' + whitespaces + ']';
  26814. var ltrim = RegExp('^' + whitespace + whitespace + '*');
  26815. var rtrim = RegExp(whitespace + whitespace + '*$');
  26816. // `String.prototype.{ trim, trimStart, trimEnd, trimLeft, trimRight }` methods implementation
  26817. var createMethod = function (TYPE) {
  26818. return function ($this) {
  26819. var string = toString(requireObjectCoercible($this));
  26820. if (TYPE & 1) string = replace(string, ltrim, '');
  26821. if (TYPE & 2) string = replace(string, rtrim, '');
  26822. return string;
  26823. };
  26824. };
  26825. module.exports = {
  26826. // `String.prototype.{ trimLeft, trimStart }` methods
  26827. // https://tc39.es/ecma262/#sec-string.prototype.trimstart
  26828. start: createMethod(1),
  26829. // `String.prototype.{ trimRight, trimEnd }` methods
  26830. // https://tc39.es/ecma262/#sec-string.prototype.trimend
  26831. end: createMethod(2),
  26832. // `String.prototype.trim` method
  26833. // https://tc39.es/ecma262/#sec-string.prototype.trim
  26834. trim: createMethod(3)
  26835. };
  26836. },{"../internals/function-uncurry-this":327,"../internals/require-object-coercible":397,"../internals/to-string":420,"../internals/whitespaces":430}],408:[function(_dereq_,module,exports){
  26837. /* eslint-disable es-x/no-symbol -- required for testing */
  26838. var V8_VERSION = _dereq_('../internals/engine-v8-version');
  26839. var fails = _dereq_('../internals/fails');
  26840. // eslint-disable-next-line es-x/no-object-getownpropertysymbols -- required for testing
  26841. module.exports = !!Object.getOwnPropertySymbols && !fails(function () {
  26842. var symbol = Symbol();
  26843. // Chrome 38 Symbol has incorrect toString conversion
  26844. // `get-own-property-symbols` polyfill symbols converted to object are not Symbol instances
  26845. return !String(symbol) || !(Object(symbol) instanceof Symbol) ||
  26846. // Chrome 38-40 symbols are not inherited from DOM collections prototypes to instances
  26847. !Symbol.sham && V8_VERSION && V8_VERSION < 41;
  26848. });
  26849. },{"../internals/engine-v8-version":312,"../internals/fails":319}],409:[function(_dereq_,module,exports){
  26850. var call = _dereq_('../internals/function-call');
  26851. var getBuiltIn = _dereq_('../internals/get-built-in');
  26852. var wellKnownSymbol = _dereq_('../internals/well-known-symbol');
  26853. var defineBuiltIn = _dereq_('../internals/define-built-in');
  26854. module.exports = function () {
  26855. var Symbol = getBuiltIn('Symbol');
  26856. var SymbolPrototype = Symbol && Symbol.prototype;
  26857. var valueOf = SymbolPrototype && SymbolPrototype.valueOf;
  26858. var TO_PRIMITIVE = wellKnownSymbol('toPrimitive');
  26859. if (SymbolPrototype && !SymbolPrototype[TO_PRIMITIVE]) {
  26860. // `Symbol.prototype[@@toPrimitive]` method
  26861. // https://tc39.es/ecma262/#sec-symbol.prototype-@@toprimitive
  26862. // eslint-disable-next-line no-unused-vars -- required for .length
  26863. defineBuiltIn(SymbolPrototype, TO_PRIMITIVE, function (hint) {
  26864. return call(valueOf, this);
  26865. }, { arity: 1 });
  26866. }
  26867. };
  26868. },{"../internals/define-built-in":295,"../internals/function-call":325,"../internals/get-built-in":328,"../internals/well-known-symbol":429}],410:[function(_dereq_,module,exports){
  26869. var NATIVE_SYMBOL = _dereq_('../internals/symbol-constructor-detection');
  26870. /* eslint-disable es-x/no-symbol -- safe */
  26871. module.exports = NATIVE_SYMBOL && !!Symbol['for'] && !!Symbol.keyFor;
  26872. },{"../internals/symbol-constructor-detection":408}],411:[function(_dereq_,module,exports){
  26873. var global = _dereq_('../internals/global');
  26874. var apply = _dereq_('../internals/function-apply');
  26875. var bind = _dereq_('../internals/function-bind-context');
  26876. var isCallable = _dereq_('../internals/is-callable');
  26877. var hasOwn = _dereq_('../internals/has-own-property');
  26878. var fails = _dereq_('../internals/fails');
  26879. var html = _dereq_('../internals/html');
  26880. var arraySlice = _dereq_('../internals/array-slice');
  26881. var createElement = _dereq_('../internals/document-create-element');
  26882. var validateArgumentsLength = _dereq_('../internals/validate-arguments-length');
  26883. var IS_IOS = _dereq_('../internals/engine-is-ios');
  26884. var IS_NODE = _dereq_('../internals/engine-is-node');
  26885. var set = global.setImmediate;
  26886. var clear = global.clearImmediate;
  26887. var process = global.process;
  26888. var Dispatch = global.Dispatch;
  26889. var Function = global.Function;
  26890. var MessageChannel = global.MessageChannel;
  26891. var String = global.String;
  26892. var counter = 0;
  26893. var queue = {};
  26894. var ONREADYSTATECHANGE = 'onreadystatechange';
  26895. var location, defer, channel, port;
  26896. try {
  26897. // Deno throws a ReferenceError on `location` access without `--location` flag
  26898. location = global.location;
  26899. } catch (error) { /* empty */ }
  26900. var run = function (id) {
  26901. if (hasOwn(queue, id)) {
  26902. var fn = queue[id];
  26903. delete queue[id];
  26904. fn();
  26905. }
  26906. };
  26907. var runner = function (id) {
  26908. return function () {
  26909. run(id);
  26910. };
  26911. };
  26912. var listener = function (event) {
  26913. run(event.data);
  26914. };
  26915. var post = function (id) {
  26916. // old engines have not location.origin
  26917. global.postMessage(String(id), location.protocol + '//' + location.host);
  26918. };
  26919. // Node.js 0.9+ & IE10+ has setImmediate, otherwise:
  26920. if (!set || !clear) {
  26921. set = function setImmediate(handler) {
  26922. validateArgumentsLength(arguments.length, 1);
  26923. var fn = isCallable(handler) ? handler : Function(handler);
  26924. var args = arraySlice(arguments, 1);
  26925. queue[++counter] = function () {
  26926. apply(fn, undefined, args);
  26927. };
  26928. defer(counter);
  26929. return counter;
  26930. };
  26931. clear = function clearImmediate(id) {
  26932. delete queue[id];
  26933. };
  26934. // Node.js 0.8-
  26935. if (IS_NODE) {
  26936. defer = function (id) {
  26937. process.nextTick(runner(id));
  26938. };
  26939. // Sphere (JS game engine) Dispatch API
  26940. } else if (Dispatch && Dispatch.now) {
  26941. defer = function (id) {
  26942. Dispatch.now(runner(id));
  26943. };
  26944. // Browsers with MessageChannel, includes WebWorkers
  26945. // except iOS - https://github.com/zloirock/core-js/issues/624
  26946. } else if (MessageChannel && !IS_IOS) {
  26947. channel = new MessageChannel();
  26948. port = channel.port2;
  26949. channel.port1.onmessage = listener;
  26950. defer = bind(port.postMessage, port);
  26951. // Browsers with postMessage, skip WebWorkers
  26952. // IE8 has postMessage, but it's sync & typeof its postMessage is 'object'
  26953. } else if (
  26954. global.addEventListener &&
  26955. isCallable(global.postMessage) &&
  26956. !global.importScripts &&
  26957. location && location.protocol !== 'file:' &&
  26958. !fails(post)
  26959. ) {
  26960. defer = post;
  26961. global.addEventListener('message', listener, false);
  26962. // IE8-
  26963. } else if (ONREADYSTATECHANGE in createElement('script')) {
  26964. defer = function (id) {
  26965. html.appendChild(createElement('script'))[ONREADYSTATECHANGE] = function () {
  26966. html.removeChild(this);
  26967. run(id);
  26968. };
  26969. };
  26970. // Rest old browsers
  26971. } else {
  26972. defer = function (id) {
  26973. setTimeout(runner(id), 0);
  26974. };
  26975. }
  26976. }
  26977. module.exports = {
  26978. set: set,
  26979. clear: clear
  26980. };
  26981. },{"../internals/array-slice":274,"../internals/document-create-element":300,"../internals/engine-is-ios":308,"../internals/engine-is-node":309,"../internals/fails":319,"../internals/function-apply":321,"../internals/function-bind-context":322,"../internals/global":333,"../internals/has-own-property":334,"../internals/html":337,"../internals/is-callable":346,"../internals/validate-arguments-length":425}],412:[function(_dereq_,module,exports){
  26982. var toIntegerOrInfinity = _dereq_('../internals/to-integer-or-infinity');
  26983. var max = Math.max;
  26984. var min = Math.min;
  26985. // Helper for a popular repeating case of the spec:
  26986. // Let integer be ? ToInteger(index).
  26987. // If integer < 0, let result be max((length + integer), 0); else let result be min(integer, length).
  26988. module.exports = function (index, length) {
  26989. var integer = toIntegerOrInfinity(index);
  26990. return integer < 0 ? max(integer + length, 0) : min(integer, length);
  26991. };
  26992. },{"../internals/to-integer-or-infinity":414}],413:[function(_dereq_,module,exports){
  26993. // toObject with fallback for non-array-like ES3 strings
  26994. var IndexedObject = _dereq_('../internals/indexed-object');
  26995. var requireObjectCoercible = _dereq_('../internals/require-object-coercible');
  26996. module.exports = function (it) {
  26997. return IndexedObject(requireObjectCoercible(it));
  26998. };
  26999. },{"../internals/indexed-object":339,"../internals/require-object-coercible":397}],414:[function(_dereq_,module,exports){
  27000. var trunc = _dereq_('../internals/math-trunc');
  27001. // `ToIntegerOrInfinity` abstract operation
  27002. // https://tc39.es/ecma262/#sec-tointegerorinfinity
  27003. module.exports = function (argument) {
  27004. var number = +argument;
  27005. // eslint-disable-next-line no-self-compare -- NaN check
  27006. return number !== number || number === 0 ? 0 : trunc(number);
  27007. };
  27008. },{"../internals/math-trunc":365}],415:[function(_dereq_,module,exports){
  27009. var toIntegerOrInfinity = _dereq_('../internals/to-integer-or-infinity');
  27010. var min = Math.min;
  27011. // `ToLength` abstract operation
  27012. // https://tc39.es/ecma262/#sec-tolength
  27013. module.exports = function (argument) {
  27014. return argument > 0 ? min(toIntegerOrInfinity(argument), 0x1FFFFFFFFFFFFF) : 0; // 2 ** 53 - 1 == 9007199254740991
  27015. };
  27016. },{"../internals/to-integer-or-infinity":414}],416:[function(_dereq_,module,exports){
  27017. var requireObjectCoercible = _dereq_('../internals/require-object-coercible');
  27018. var $Object = Object;
  27019. // `ToObject` abstract operation
  27020. // https://tc39.es/ecma262/#sec-toobject
  27021. module.exports = function (argument) {
  27022. return $Object(requireObjectCoercible(argument));
  27023. };
  27024. },{"../internals/require-object-coercible":397}],417:[function(_dereq_,module,exports){
  27025. var call = _dereq_('../internals/function-call');
  27026. var isObject = _dereq_('../internals/is-object');
  27027. var isSymbol = _dereq_('../internals/is-symbol');
  27028. var getMethod = _dereq_('../internals/get-method');
  27029. var ordinaryToPrimitive = _dereq_('../internals/ordinary-to-primitive');
  27030. var wellKnownSymbol = _dereq_('../internals/well-known-symbol');
  27031. var $TypeError = TypeError;
  27032. var TO_PRIMITIVE = wellKnownSymbol('toPrimitive');
  27033. // `ToPrimitive` abstract operation
  27034. // https://tc39.es/ecma262/#sec-toprimitive
  27035. module.exports = function (input, pref) {
  27036. if (!isObject(input) || isSymbol(input)) return input;
  27037. var exoticToPrim = getMethod(input, TO_PRIMITIVE);
  27038. var result;
  27039. if (exoticToPrim) {
  27040. if (pref === undefined) pref = 'default';
  27041. result = call(exoticToPrim, input, pref);
  27042. if (!isObject(result) || isSymbol(result)) return result;
  27043. throw $TypeError("Can't convert object to primitive value");
  27044. }
  27045. if (pref === undefined) pref = 'number';
  27046. return ordinaryToPrimitive(input, pref);
  27047. };
  27048. },{"../internals/function-call":325,"../internals/get-method":332,"../internals/is-object":352,"../internals/is-symbol":355,"../internals/ordinary-to-primitive":388,"../internals/well-known-symbol":429}],418:[function(_dereq_,module,exports){
  27049. var toPrimitive = _dereq_('../internals/to-primitive');
  27050. var isSymbol = _dereq_('../internals/is-symbol');
  27051. // `ToPropertyKey` abstract operation
  27052. // https://tc39.es/ecma262/#sec-topropertykey
  27053. module.exports = function (argument) {
  27054. var key = toPrimitive(argument, 'string');
  27055. return isSymbol(key) ? key : key + '';
  27056. };
  27057. },{"../internals/is-symbol":355,"../internals/to-primitive":417}],419:[function(_dereq_,module,exports){
  27058. var wellKnownSymbol = _dereq_('../internals/well-known-symbol');
  27059. var TO_STRING_TAG = wellKnownSymbol('toStringTag');
  27060. var test = {};
  27061. test[TO_STRING_TAG] = 'z';
  27062. module.exports = String(test) === '[object z]';
  27063. },{"../internals/well-known-symbol":429}],420:[function(_dereq_,module,exports){
  27064. var classof = _dereq_('../internals/classof');
  27065. var $String = String;
  27066. module.exports = function (argument) {
  27067. if (classof(argument) === 'Symbol') throw TypeError('Cannot convert a Symbol value to a string');
  27068. return $String(argument);
  27069. };
  27070. },{"../internals/classof":281}],421:[function(_dereq_,module,exports){
  27071. var $String = String;
  27072. module.exports = function (argument) {
  27073. try {
  27074. return $String(argument);
  27075. } catch (error) {
  27076. return 'Object';
  27077. }
  27078. };
  27079. },{}],422:[function(_dereq_,module,exports){
  27080. var uncurryThis = _dereq_('../internals/function-uncurry-this');
  27081. var id = 0;
  27082. var postfix = Math.random();
  27083. var toString = uncurryThis(1.0.toString);
  27084. module.exports = function (key) {
  27085. return 'Symbol(' + (key === undefined ? '' : key) + ')_' + toString(++id + postfix, 36);
  27086. };
  27087. },{"../internals/function-uncurry-this":327}],423:[function(_dereq_,module,exports){
  27088. /* eslint-disable es-x/no-symbol -- required for testing */
  27089. var NATIVE_SYMBOL = _dereq_('../internals/symbol-constructor-detection');
  27090. module.exports = NATIVE_SYMBOL
  27091. && !Symbol.sham
  27092. && typeof Symbol.iterator == 'symbol';
  27093. },{"../internals/symbol-constructor-detection":408}],424:[function(_dereq_,module,exports){
  27094. var DESCRIPTORS = _dereq_('../internals/descriptors');
  27095. var fails = _dereq_('../internals/fails');
  27096. // V8 ~ Chrome 36-
  27097. // https://bugs.chromium.org/p/v8/issues/detail?id=3334
  27098. module.exports = DESCRIPTORS && fails(function () {
  27099. // eslint-disable-next-line es-x/no-object-defineproperty -- required for testing
  27100. return Object.defineProperty(function () { /* empty */ }, 'prototype', {
  27101. value: 42,
  27102. writable: false
  27103. }).prototype != 42;
  27104. });
  27105. },{"../internals/descriptors":299,"../internals/fails":319}],425:[function(_dereq_,module,exports){
  27106. var $TypeError = TypeError;
  27107. module.exports = function (passed, required) {
  27108. if (passed < required) throw $TypeError('Not enough arguments');
  27109. return passed;
  27110. };
  27111. },{}],426:[function(_dereq_,module,exports){
  27112. var global = _dereq_('../internals/global');
  27113. var isCallable = _dereq_('../internals/is-callable');
  27114. var WeakMap = global.WeakMap;
  27115. module.exports = isCallable(WeakMap) && /native code/.test(String(WeakMap));
  27116. },{"../internals/global":333,"../internals/is-callable":346}],427:[function(_dereq_,module,exports){
  27117. var path = _dereq_('../internals/path');
  27118. var hasOwn = _dereq_('../internals/has-own-property');
  27119. var wrappedWellKnownSymbolModule = _dereq_('../internals/well-known-symbol-wrapped');
  27120. var defineProperty = _dereq_('../internals/object-define-property').f;
  27121. module.exports = function (NAME) {
  27122. var Symbol = path.Symbol || (path.Symbol = {});
  27123. if (!hasOwn(Symbol, NAME)) defineProperty(Symbol, NAME, {
  27124. value: wrappedWellKnownSymbolModule.f(NAME)
  27125. });
  27126. };
  27127. },{"../internals/has-own-property":334,"../internals/object-define-property":374,"../internals/path":390,"../internals/well-known-symbol-wrapped":428}],428:[function(_dereq_,module,exports){
  27128. var wellKnownSymbol = _dereq_('../internals/well-known-symbol');
  27129. exports.f = wellKnownSymbol;
  27130. },{"../internals/well-known-symbol":429}],429:[function(_dereq_,module,exports){
  27131. var global = _dereq_('../internals/global');
  27132. var shared = _dereq_('../internals/shared');
  27133. var hasOwn = _dereq_('../internals/has-own-property');
  27134. var uid = _dereq_('../internals/uid');
  27135. var NATIVE_SYMBOL = _dereq_('../internals/symbol-constructor-detection');
  27136. var USE_SYMBOL_AS_UID = _dereq_('../internals/use-symbol-as-uid');
  27137. var WellKnownSymbolsStore = shared('wks');
  27138. var Symbol = global.Symbol;
  27139. var symbolFor = Symbol && Symbol['for'];
  27140. var createWellKnownSymbol = USE_SYMBOL_AS_UID ? Symbol : Symbol && Symbol.withoutSetter || uid;
  27141. module.exports = function (name) {
  27142. if (!hasOwn(WellKnownSymbolsStore, name) || !(NATIVE_SYMBOL || typeof WellKnownSymbolsStore[name] == 'string')) {
  27143. var description = 'Symbol.' + name;
  27144. if (NATIVE_SYMBOL && hasOwn(Symbol, name)) {
  27145. WellKnownSymbolsStore[name] = Symbol[name];
  27146. } else if (USE_SYMBOL_AS_UID && symbolFor) {
  27147. WellKnownSymbolsStore[name] = symbolFor(description);
  27148. } else {
  27149. WellKnownSymbolsStore[name] = createWellKnownSymbol(description);
  27150. }
  27151. } return WellKnownSymbolsStore[name];
  27152. };
  27153. },{"../internals/global":333,"../internals/has-own-property":334,"../internals/shared":404,"../internals/symbol-constructor-detection":408,"../internals/uid":422,"../internals/use-symbol-as-uid":423}],430:[function(_dereq_,module,exports){
  27154. // a string of all valid unicode whitespaces
  27155. module.exports = '\u0009\u000A\u000B\u000C\u000D\u0020\u00A0\u1680\u2000\u2001\u2002' +
  27156. '\u2003\u2004\u2005\u2006\u2007\u2008\u2009\u200A\u202F\u205F\u3000\u2028\u2029\uFEFF';
  27157. },{}],431:[function(_dereq_,module,exports){
  27158. 'use strict';
  27159. var $ = _dereq_('../internals/export');
  27160. var isPrototypeOf = _dereq_('../internals/object-is-prototype-of');
  27161. var getPrototypeOf = _dereq_('../internals/object-get-prototype-of');
  27162. var setPrototypeOf = _dereq_('../internals/object-set-prototype-of');
  27163. var copyConstructorProperties = _dereq_('../internals/copy-constructor-properties');
  27164. var create = _dereq_('../internals/object-create');
  27165. var createNonEnumerableProperty = _dereq_('../internals/create-non-enumerable-property');
  27166. var createPropertyDescriptor = _dereq_('../internals/create-property-descriptor');
  27167. var clearErrorStack = _dereq_('../internals/error-stack-clear');
  27168. var installErrorCause = _dereq_('../internals/install-error-cause');
  27169. var iterate = _dereq_('../internals/iterate');
  27170. var normalizeStringArgument = _dereq_('../internals/normalize-string-argument');
  27171. var wellKnownSymbol = _dereq_('../internals/well-known-symbol');
  27172. var ERROR_STACK_INSTALLABLE = _dereq_('../internals/error-stack-installable');
  27173. var TO_STRING_TAG = wellKnownSymbol('toStringTag');
  27174. var $Error = Error;
  27175. var push = [].push;
  27176. var $AggregateError = function AggregateError(errors, message /* , options */) {
  27177. var options = arguments.length > 2 ? arguments[2] : undefined;
  27178. var isInstance = isPrototypeOf(AggregateErrorPrototype, this);
  27179. var that;
  27180. if (setPrototypeOf) {
  27181. that = setPrototypeOf($Error(), isInstance ? getPrototypeOf(this) : AggregateErrorPrototype);
  27182. } else {
  27183. that = isInstance ? this : create(AggregateErrorPrototype);
  27184. createNonEnumerableProperty(that, TO_STRING_TAG, 'Error');
  27185. }
  27186. if (message !== undefined) createNonEnumerableProperty(that, 'message', normalizeStringArgument(message));
  27187. if (ERROR_STACK_INSTALLABLE) createNonEnumerableProperty(that, 'stack', clearErrorStack(that.stack, 1));
  27188. installErrorCause(that, options);
  27189. var errorsArray = [];
  27190. iterate(errors, push, { that: errorsArray });
  27191. createNonEnumerableProperty(that, 'errors', errorsArray);
  27192. return that;
  27193. };
  27194. if (setPrototypeOf) setPrototypeOf($AggregateError, $Error);
  27195. else copyConstructorProperties($AggregateError, $Error, { name: true });
  27196. var AggregateErrorPrototype = $AggregateError.prototype = create($Error.prototype, {
  27197. constructor: createPropertyDescriptor(1, $AggregateError),
  27198. message: createPropertyDescriptor(1, ''),
  27199. name: createPropertyDescriptor(1, 'AggregateError')
  27200. });
  27201. // `AggregateError` constructor
  27202. // https://tc39.es/ecma262/#sec-aggregate-error-constructor
  27203. $({ global: true, constructor: true, arity: 2 }, {
  27204. AggregateError: $AggregateError
  27205. });
  27206. },{"../internals/copy-constructor-properties":288,"../internals/create-non-enumerable-property":292,"../internals/create-property-descriptor":293,"../internals/error-stack-clear":316,"../internals/error-stack-installable":317,"../internals/export":318,"../internals/install-error-cause":341,"../internals/iterate":356,"../internals/normalize-string-argument":368,"../internals/object-create":372,"../internals/object-get-prototype-of":379,"../internals/object-is-prototype-of":381,"../internals/object-set-prototype-of":385,"../internals/well-known-symbol":429}],432:[function(_dereq_,module,exports){
  27207. // TODO: Remove this module from `core-js@4` since it's replaced to module below
  27208. _dereq_('../modules/es.aggregate-error.constructor');
  27209. },{"../modules/es.aggregate-error.constructor":431}],433:[function(_dereq_,module,exports){
  27210. 'use strict';
  27211. var $ = _dereq_('../internals/export');
  27212. var fails = _dereq_('../internals/fails');
  27213. var isArray = _dereq_('../internals/is-array');
  27214. var isObject = _dereq_('../internals/is-object');
  27215. var toObject = _dereq_('../internals/to-object');
  27216. var lengthOfArrayLike = _dereq_('../internals/length-of-array-like');
  27217. var doesNotExceedSafeInteger = _dereq_('../internals/does-not-exceed-safe-integer');
  27218. var createProperty = _dereq_('../internals/create-property');
  27219. var arraySpeciesCreate = _dereq_('../internals/array-species-create');
  27220. var arrayMethodHasSpeciesSupport = _dereq_('../internals/array-method-has-species-support');
  27221. var wellKnownSymbol = _dereq_('../internals/well-known-symbol');
  27222. var V8_VERSION = _dereq_('../internals/engine-v8-version');
  27223. var IS_CONCAT_SPREADABLE = wellKnownSymbol('isConcatSpreadable');
  27224. // We can't use this feature detection in V8 since it causes
  27225. // deoptimization and serious performance degradation
  27226. // https://github.com/zloirock/core-js/issues/679
  27227. var IS_CONCAT_SPREADABLE_SUPPORT = V8_VERSION >= 51 || !fails(function () {
  27228. var array = [];
  27229. array[IS_CONCAT_SPREADABLE] = false;
  27230. return array.concat()[0] !== array;
  27231. });
  27232. var SPECIES_SUPPORT = arrayMethodHasSpeciesSupport('concat');
  27233. var isConcatSpreadable = function (O) {
  27234. if (!isObject(O)) return false;
  27235. var spreadable = O[IS_CONCAT_SPREADABLE];
  27236. return spreadable !== undefined ? !!spreadable : isArray(O);
  27237. };
  27238. var FORCED = !IS_CONCAT_SPREADABLE_SUPPORT || !SPECIES_SUPPORT;
  27239. // `Array.prototype.concat` method
  27240. // https://tc39.es/ecma262/#sec-array.prototype.concat
  27241. // with adding support of @@isConcatSpreadable and @@species
  27242. $({ target: 'Array', proto: true, arity: 1, forced: FORCED }, {
  27243. // eslint-disable-next-line no-unused-vars -- required for `.length`
  27244. concat: function concat(arg) {
  27245. var O = toObject(this);
  27246. var A = arraySpeciesCreate(O, 0);
  27247. var n = 0;
  27248. var i, k, length, len, E;
  27249. for (i = -1, length = arguments.length; i < length; i++) {
  27250. E = i === -1 ? O : arguments[i];
  27251. if (isConcatSpreadable(E)) {
  27252. len = lengthOfArrayLike(E);
  27253. doesNotExceedSafeInteger(n + len);
  27254. for (k = 0; k < len; k++, n++) if (k in E) createProperty(A, n, E[k]);
  27255. } else {
  27256. doesNotExceedSafeInteger(n + 1);
  27257. createProperty(A, n++, E);
  27258. }
  27259. }
  27260. A.length = n;
  27261. return A;
  27262. }
  27263. });
  27264. },{"../internals/array-method-has-species-support":269,"../internals/array-species-create":277,"../internals/create-property":294,"../internals/does-not-exceed-safe-integer":301,"../internals/engine-v8-version":312,"../internals/export":318,"../internals/fails":319,"../internals/is-array":345,"../internals/is-object":352,"../internals/length-of-array-like":362,"../internals/to-object":416,"../internals/well-known-symbol":429}],434:[function(_dereq_,module,exports){
  27265. 'use strict';
  27266. var $ = _dereq_('../internals/export');
  27267. var $every = _dereq_('../internals/array-iteration').every;
  27268. var arrayMethodIsStrict = _dereq_('../internals/array-method-is-strict');
  27269. var STRICT_METHOD = arrayMethodIsStrict('every');
  27270. // `Array.prototype.every` method
  27271. // https://tc39.es/ecma262/#sec-array.prototype.every
  27272. $({ target: 'Array', proto: true, forced: !STRICT_METHOD }, {
  27273. every: function every(callbackfn /* , thisArg */) {
  27274. return $every(this, callbackfn, arguments.length > 1 ? arguments[1] : undefined);
  27275. }
  27276. });
  27277. },{"../internals/array-iteration":268,"../internals/array-method-is-strict":270,"../internals/export":318}],435:[function(_dereq_,module,exports){
  27278. 'use strict';
  27279. var $ = _dereq_('../internals/export');
  27280. var $filter = _dereq_('../internals/array-iteration').filter;
  27281. var arrayMethodHasSpeciesSupport = _dereq_('../internals/array-method-has-species-support');
  27282. var HAS_SPECIES_SUPPORT = arrayMethodHasSpeciesSupport('filter');
  27283. // `Array.prototype.filter` method
  27284. // https://tc39.es/ecma262/#sec-array.prototype.filter
  27285. // with adding support of @@species
  27286. $({ target: 'Array', proto: true, forced: !HAS_SPECIES_SUPPORT }, {
  27287. filter: function filter(callbackfn /* , thisArg */) {
  27288. return $filter(this, callbackfn, arguments.length > 1 ? arguments[1] : undefined);
  27289. }
  27290. });
  27291. },{"../internals/array-iteration":268,"../internals/array-method-has-species-support":269,"../internals/export":318}],436:[function(_dereq_,module,exports){
  27292. 'use strict';
  27293. var $ = _dereq_('../internals/export');
  27294. var $findIndex = _dereq_('../internals/array-iteration').findIndex;
  27295. var addToUnscopables = _dereq_('../internals/add-to-unscopables');
  27296. var FIND_INDEX = 'findIndex';
  27297. var SKIPS_HOLES = true;
  27298. // Shouldn't skip holes
  27299. if (FIND_INDEX in []) Array(1)[FIND_INDEX](function () { SKIPS_HOLES = false; });
  27300. // `Array.prototype.findIndex` method
  27301. // https://tc39.es/ecma262/#sec-array.prototype.findindex
  27302. $({ target: 'Array', proto: true, forced: SKIPS_HOLES }, {
  27303. findIndex: function findIndex(callbackfn /* , that = undefined */) {
  27304. return $findIndex(this, callbackfn, arguments.length > 1 ? arguments[1] : undefined);
  27305. }
  27306. });
  27307. // https://tc39.es/ecma262/#sec-array.prototype-@@unscopables
  27308. addToUnscopables(FIND_INDEX);
  27309. },{"../internals/add-to-unscopables":261,"../internals/array-iteration":268,"../internals/export":318}],437:[function(_dereq_,module,exports){
  27310. 'use strict';
  27311. var $ = _dereq_('../internals/export');
  27312. var $find = _dereq_('../internals/array-iteration').find;
  27313. var addToUnscopables = _dereq_('../internals/add-to-unscopables');
  27314. var FIND = 'find';
  27315. var SKIPS_HOLES = true;
  27316. // Shouldn't skip holes
  27317. if (FIND in []) Array(1)[FIND](function () { SKIPS_HOLES = false; });
  27318. // `Array.prototype.find` method
  27319. // https://tc39.es/ecma262/#sec-array.prototype.find
  27320. $({ target: 'Array', proto: true, forced: SKIPS_HOLES }, {
  27321. find: function find(callbackfn /* , that = undefined */) {
  27322. return $find(this, callbackfn, arguments.length > 1 ? arguments[1] : undefined);
  27323. }
  27324. });
  27325. // https://tc39.es/ecma262/#sec-array.prototype-@@unscopables
  27326. addToUnscopables(FIND);
  27327. },{"../internals/add-to-unscopables":261,"../internals/array-iteration":268,"../internals/export":318}],438:[function(_dereq_,module,exports){
  27328. 'use strict';
  27329. var $ = _dereq_('../internals/export');
  27330. var forEach = _dereq_('../internals/array-for-each');
  27331. // `Array.prototype.forEach` method
  27332. // https://tc39.es/ecma262/#sec-array.prototype.foreach
  27333. // eslint-disable-next-line es-x/no-array-prototype-foreach -- safe
  27334. $({ target: 'Array', proto: true, forced: [].forEach != forEach }, {
  27335. forEach: forEach
  27336. });
  27337. },{"../internals/array-for-each":265,"../internals/export":318}],439:[function(_dereq_,module,exports){
  27338. var $ = _dereq_('../internals/export');
  27339. var from = _dereq_('../internals/array-from');
  27340. var checkCorrectnessOfIteration = _dereq_('../internals/check-correctness-of-iteration');
  27341. var INCORRECT_ITERATION = !checkCorrectnessOfIteration(function (iterable) {
  27342. // eslint-disable-next-line es-x/no-array-from -- required for testing
  27343. Array.from(iterable);
  27344. });
  27345. // `Array.from` method
  27346. // https://tc39.es/ecma262/#sec-array.from
  27347. $({ target: 'Array', stat: true, forced: INCORRECT_ITERATION }, {
  27348. from: from
  27349. });
  27350. },{"../internals/array-from":266,"../internals/check-correctness-of-iteration":279,"../internals/export":318}],440:[function(_dereq_,module,exports){
  27351. 'use strict';
  27352. var $ = _dereq_('../internals/export');
  27353. var $includes = _dereq_('../internals/array-includes').includes;
  27354. var fails = _dereq_('../internals/fails');
  27355. var addToUnscopables = _dereq_('../internals/add-to-unscopables');
  27356. // FF99+ bug
  27357. var BROKEN_ON_SPARSE = fails(function () {
  27358. return !Array(1).includes();
  27359. });
  27360. // `Array.prototype.includes` method
  27361. // https://tc39.es/ecma262/#sec-array.prototype.includes
  27362. $({ target: 'Array', proto: true, forced: BROKEN_ON_SPARSE }, {
  27363. includes: function includes(el /* , fromIndex = 0 */) {
  27364. return $includes(this, el, arguments.length > 1 ? arguments[1] : undefined);
  27365. }
  27366. });
  27367. // https://tc39.es/ecma262/#sec-array.prototype-@@unscopables
  27368. addToUnscopables('includes');
  27369. },{"../internals/add-to-unscopables":261,"../internals/array-includes":267,"../internals/export":318,"../internals/fails":319}],441:[function(_dereq_,module,exports){
  27370. 'use strict';
  27371. /* eslint-disable es-x/no-array-prototype-indexof -- required for testing */
  27372. var $ = _dereq_('../internals/export');
  27373. var uncurryThis = _dereq_('../internals/function-uncurry-this');
  27374. var $indexOf = _dereq_('../internals/array-includes').indexOf;
  27375. var arrayMethodIsStrict = _dereq_('../internals/array-method-is-strict');
  27376. var nativeIndexOf = uncurryThis([].indexOf);
  27377. var NEGATIVE_ZERO = !!nativeIndexOf && 1 / nativeIndexOf([1], 1, -0) < 0;
  27378. var STRICT_METHOD = arrayMethodIsStrict('indexOf');
  27379. // `Array.prototype.indexOf` method
  27380. // https://tc39.es/ecma262/#sec-array.prototype.indexof
  27381. $({ target: 'Array', proto: true, forced: NEGATIVE_ZERO || !STRICT_METHOD }, {
  27382. indexOf: function indexOf(searchElement /* , fromIndex = 0 */) {
  27383. var fromIndex = arguments.length > 1 ? arguments[1] : undefined;
  27384. return NEGATIVE_ZERO
  27385. // convert -0 to +0
  27386. ? nativeIndexOf(this, searchElement, fromIndex) || 0
  27387. : $indexOf(this, searchElement, fromIndex);
  27388. }
  27389. });
  27390. },{"../internals/array-includes":267,"../internals/array-method-is-strict":270,"../internals/export":318,"../internals/function-uncurry-this":327}],442:[function(_dereq_,module,exports){
  27391. var $ = _dereq_('../internals/export');
  27392. var isArray = _dereq_('../internals/is-array');
  27393. // `Array.isArray` method
  27394. // https://tc39.es/ecma262/#sec-array.isarray
  27395. $({ target: 'Array', stat: true }, {
  27396. isArray: isArray
  27397. });
  27398. },{"../internals/export":318,"../internals/is-array":345}],443:[function(_dereq_,module,exports){
  27399. 'use strict';
  27400. var toIndexedObject = _dereq_('../internals/to-indexed-object');
  27401. var addToUnscopables = _dereq_('../internals/add-to-unscopables');
  27402. var Iterators = _dereq_('../internals/iterators');
  27403. var InternalStateModule = _dereq_('../internals/internal-state');
  27404. var defineProperty = _dereq_('../internals/object-define-property').f;
  27405. var defineIterator = _dereq_('../internals/iterator-define');
  27406. var createIterResultObject = _dereq_('../internals/create-iter-result-object');
  27407. var IS_PURE = _dereq_('../internals/is-pure');
  27408. var DESCRIPTORS = _dereq_('../internals/descriptors');
  27409. var ARRAY_ITERATOR = 'Array Iterator';
  27410. var setInternalState = InternalStateModule.set;
  27411. var getInternalState = InternalStateModule.getterFor(ARRAY_ITERATOR);
  27412. // `Array.prototype.entries` method
  27413. // https://tc39.es/ecma262/#sec-array.prototype.entries
  27414. // `Array.prototype.keys` method
  27415. // https://tc39.es/ecma262/#sec-array.prototype.keys
  27416. // `Array.prototype.values` method
  27417. // https://tc39.es/ecma262/#sec-array.prototype.values
  27418. // `Array.prototype[@@iterator]` method
  27419. // https://tc39.es/ecma262/#sec-array.prototype-@@iterator
  27420. // `CreateArrayIterator` internal method
  27421. // https://tc39.es/ecma262/#sec-createarrayiterator
  27422. module.exports = defineIterator(Array, 'Array', function (iterated, kind) {
  27423. setInternalState(this, {
  27424. type: ARRAY_ITERATOR,
  27425. target: toIndexedObject(iterated), // target
  27426. index: 0, // next index
  27427. kind: kind // kind
  27428. });
  27429. // `%ArrayIteratorPrototype%.next` method
  27430. // https://tc39.es/ecma262/#sec-%arrayiteratorprototype%.next
  27431. }, function () {
  27432. var state = getInternalState(this);
  27433. var target = state.target;
  27434. var kind = state.kind;
  27435. var index = state.index++;
  27436. if (!target || index >= target.length) {
  27437. state.target = undefined;
  27438. return createIterResultObject(undefined, true);
  27439. }
  27440. if (kind == 'keys') return createIterResultObject(index, false);
  27441. if (kind == 'values') return createIterResultObject(target[index], false);
  27442. return createIterResultObject([index, target[index]], false);
  27443. }, 'values');
  27444. // argumentsList[@@iterator] is %ArrayProto_values%
  27445. // https://tc39.es/ecma262/#sec-createunmappedargumentsobject
  27446. // https://tc39.es/ecma262/#sec-createmappedargumentsobject
  27447. var values = Iterators.Arguments = Iterators.Array;
  27448. // https://tc39.es/ecma262/#sec-array.prototype-@@unscopables
  27449. addToUnscopables('keys');
  27450. addToUnscopables('values');
  27451. addToUnscopables('entries');
  27452. // V8 ~ Chrome 45- bug
  27453. if (!IS_PURE && DESCRIPTORS && values.name !== 'values') try {
  27454. defineProperty(values, 'name', { value: 'values' });
  27455. } catch (error) { /* empty */ }
  27456. },{"../internals/add-to-unscopables":261,"../internals/create-iter-result-object":291,"../internals/descriptors":299,"../internals/internal-state":343,"../internals/is-pure":353,"../internals/iterator-define":359,"../internals/iterators":361,"../internals/object-define-property":374,"../internals/to-indexed-object":413}],444:[function(_dereq_,module,exports){
  27457. 'use strict';
  27458. var $ = _dereq_('../internals/export');
  27459. var $map = _dereq_('../internals/array-iteration').map;
  27460. var arrayMethodHasSpeciesSupport = _dereq_('../internals/array-method-has-species-support');
  27461. var HAS_SPECIES_SUPPORT = arrayMethodHasSpeciesSupport('map');
  27462. // `Array.prototype.map` method
  27463. // https://tc39.es/ecma262/#sec-array.prototype.map
  27464. // with adding support of @@species
  27465. $({ target: 'Array', proto: true, forced: !HAS_SPECIES_SUPPORT }, {
  27466. map: function map(callbackfn /* , thisArg */) {
  27467. return $map(this, callbackfn, arguments.length > 1 ? arguments[1] : undefined);
  27468. }
  27469. });
  27470. },{"../internals/array-iteration":268,"../internals/array-method-has-species-support":269,"../internals/export":318}],445:[function(_dereq_,module,exports){
  27471. 'use strict';
  27472. var $ = _dereq_('../internals/export');
  27473. var $reduce = _dereq_('../internals/array-reduce').left;
  27474. var arrayMethodIsStrict = _dereq_('../internals/array-method-is-strict');
  27475. var CHROME_VERSION = _dereq_('../internals/engine-v8-version');
  27476. var IS_NODE = _dereq_('../internals/engine-is-node');
  27477. var STRICT_METHOD = arrayMethodIsStrict('reduce');
  27478. // Chrome 80-82 has a critical bug
  27479. // https://bugs.chromium.org/p/chromium/issues/detail?id=1049982
  27480. var CHROME_BUG = !IS_NODE && CHROME_VERSION > 79 && CHROME_VERSION < 83;
  27481. // `Array.prototype.reduce` method
  27482. // https://tc39.es/ecma262/#sec-array.prototype.reduce
  27483. $({ target: 'Array', proto: true, forced: !STRICT_METHOD || CHROME_BUG }, {
  27484. reduce: function reduce(callbackfn /* , initialValue */) {
  27485. var length = arguments.length;
  27486. return $reduce(this, callbackfn, length, length > 1 ? arguments[1] : undefined);
  27487. }
  27488. });
  27489. },{"../internals/array-method-is-strict":270,"../internals/array-reduce":271,"../internals/engine-is-node":309,"../internals/engine-v8-version":312,"../internals/export":318}],446:[function(_dereq_,module,exports){
  27490. 'use strict';
  27491. var $ = _dereq_('../internals/export');
  27492. var uncurryThis = _dereq_('../internals/function-uncurry-this');
  27493. var isArray = _dereq_('../internals/is-array');
  27494. var nativeReverse = uncurryThis([].reverse);
  27495. var test = [1, 2];
  27496. // `Array.prototype.reverse` method
  27497. // https://tc39.es/ecma262/#sec-array.prototype.reverse
  27498. // fix for Safari 12.0 bug
  27499. // https://bugs.webkit.org/show_bug.cgi?id=188794
  27500. $({ target: 'Array', proto: true, forced: String(test) === String(test.reverse()) }, {
  27501. reverse: function reverse() {
  27502. // eslint-disable-next-line no-self-assign -- dirty hack
  27503. if (isArray(this)) this.length = this.length;
  27504. return nativeReverse(this);
  27505. }
  27506. });
  27507. },{"../internals/export":318,"../internals/function-uncurry-this":327,"../internals/is-array":345}],447:[function(_dereq_,module,exports){
  27508. 'use strict';
  27509. var $ = _dereq_('../internals/export');
  27510. var isArray = _dereq_('../internals/is-array');
  27511. var isConstructor = _dereq_('../internals/is-constructor');
  27512. var isObject = _dereq_('../internals/is-object');
  27513. var toAbsoluteIndex = _dereq_('../internals/to-absolute-index');
  27514. var lengthOfArrayLike = _dereq_('../internals/length-of-array-like');
  27515. var toIndexedObject = _dereq_('../internals/to-indexed-object');
  27516. var createProperty = _dereq_('../internals/create-property');
  27517. var wellKnownSymbol = _dereq_('../internals/well-known-symbol');
  27518. var arrayMethodHasSpeciesSupport = _dereq_('../internals/array-method-has-species-support');
  27519. var nativeSlice = _dereq_('../internals/array-slice');
  27520. var HAS_SPECIES_SUPPORT = arrayMethodHasSpeciesSupport('slice');
  27521. var SPECIES = wellKnownSymbol('species');
  27522. var $Array = Array;
  27523. var max = Math.max;
  27524. // `Array.prototype.slice` method
  27525. // https://tc39.es/ecma262/#sec-array.prototype.slice
  27526. // fallback for not array-like ES3 strings and DOM objects
  27527. $({ target: 'Array', proto: true, forced: !HAS_SPECIES_SUPPORT }, {
  27528. slice: function slice(start, end) {
  27529. var O = toIndexedObject(this);
  27530. var length = lengthOfArrayLike(O);
  27531. var k = toAbsoluteIndex(start, length);
  27532. var fin = toAbsoluteIndex(end === undefined ? length : end, length);
  27533. // inline `ArraySpeciesCreate` for usage native `Array#slice` where it's possible
  27534. var Constructor, result, n;
  27535. if (isArray(O)) {
  27536. Constructor = O.constructor;
  27537. // cross-realm fallback
  27538. if (isConstructor(Constructor) && (Constructor === $Array || isArray(Constructor.prototype))) {
  27539. Constructor = undefined;
  27540. } else if (isObject(Constructor)) {
  27541. Constructor = Constructor[SPECIES];
  27542. if (Constructor === null) Constructor = undefined;
  27543. }
  27544. if (Constructor === $Array || Constructor === undefined) {
  27545. return nativeSlice(O, k, fin);
  27546. }
  27547. }
  27548. result = new (Constructor === undefined ? $Array : Constructor)(max(fin - k, 0));
  27549. for (n = 0; k < fin; k++, n++) if (k in O) createProperty(result, n, O[k]);
  27550. result.length = n;
  27551. return result;
  27552. }
  27553. });
  27554. },{"../internals/array-method-has-species-support":269,"../internals/array-slice":274,"../internals/create-property":294,"../internals/export":318,"../internals/is-array":345,"../internals/is-constructor":347,"../internals/is-object":352,"../internals/length-of-array-like":362,"../internals/to-absolute-index":412,"../internals/to-indexed-object":413,"../internals/well-known-symbol":429}],448:[function(_dereq_,module,exports){
  27555. 'use strict';
  27556. var $ = _dereq_('../internals/export');
  27557. var uncurryThis = _dereq_('../internals/function-uncurry-this');
  27558. var aCallable = _dereq_('../internals/a-callable');
  27559. var toObject = _dereq_('../internals/to-object');
  27560. var lengthOfArrayLike = _dereq_('../internals/length-of-array-like');
  27561. var deletePropertyOrThrow = _dereq_('../internals/delete-property-or-throw');
  27562. var toString = _dereq_('../internals/to-string');
  27563. var fails = _dereq_('../internals/fails');
  27564. var internalSort = _dereq_('../internals/array-sort');
  27565. var arrayMethodIsStrict = _dereq_('../internals/array-method-is-strict');
  27566. var FF = _dereq_('../internals/engine-ff-version');
  27567. var IE_OR_EDGE = _dereq_('../internals/engine-is-ie-or-edge');
  27568. var V8 = _dereq_('../internals/engine-v8-version');
  27569. var WEBKIT = _dereq_('../internals/engine-webkit-version');
  27570. var test = [];
  27571. var nativeSort = uncurryThis(test.sort);
  27572. var push = uncurryThis(test.push);
  27573. // IE8-
  27574. var FAILS_ON_UNDEFINED = fails(function () {
  27575. test.sort(undefined);
  27576. });
  27577. // V8 bug
  27578. var FAILS_ON_NULL = fails(function () {
  27579. test.sort(null);
  27580. });
  27581. // Old WebKit
  27582. var STRICT_METHOD = arrayMethodIsStrict('sort');
  27583. var STABLE_SORT = !fails(function () {
  27584. // feature detection can be too slow, so check engines versions
  27585. if (V8) return V8 < 70;
  27586. if (FF && FF > 3) return;
  27587. if (IE_OR_EDGE) return true;
  27588. if (WEBKIT) return WEBKIT < 603;
  27589. var result = '';
  27590. var code, chr, value, index;
  27591. // generate an array with more 512 elements (Chakra and old V8 fails only in this case)
  27592. for (code = 65; code < 76; code++) {
  27593. chr = String.fromCharCode(code);
  27594. switch (code) {
  27595. case 66: case 69: case 70: case 72: value = 3; break;
  27596. case 68: case 71: value = 4; break;
  27597. default: value = 2;
  27598. }
  27599. for (index = 0; index < 47; index++) {
  27600. test.push({ k: chr + index, v: value });
  27601. }
  27602. }
  27603. test.sort(function (a, b) { return b.v - a.v; });
  27604. for (index = 0; index < test.length; index++) {
  27605. chr = test[index].k.charAt(0);
  27606. if (result.charAt(result.length - 1) !== chr) result += chr;
  27607. }
  27608. return result !== 'DGBEFHACIJK';
  27609. });
  27610. var FORCED = FAILS_ON_UNDEFINED || !FAILS_ON_NULL || !STRICT_METHOD || !STABLE_SORT;
  27611. var getSortCompare = function (comparefn) {
  27612. return function (x, y) {
  27613. if (y === undefined) return -1;
  27614. if (x === undefined) return 1;
  27615. if (comparefn !== undefined) return +comparefn(x, y) || 0;
  27616. return toString(x) > toString(y) ? 1 : -1;
  27617. };
  27618. };
  27619. // `Array.prototype.sort` method
  27620. // https://tc39.es/ecma262/#sec-array.prototype.sort
  27621. $({ target: 'Array', proto: true, forced: FORCED }, {
  27622. sort: function sort(comparefn) {
  27623. if (comparefn !== undefined) aCallable(comparefn);
  27624. var array = toObject(this);
  27625. if (STABLE_SORT) return comparefn === undefined ? nativeSort(array) : nativeSort(array, comparefn);
  27626. var items = [];
  27627. var arrayLength = lengthOfArrayLike(array);
  27628. var itemsLength, index;
  27629. for (index = 0; index < arrayLength; index++) {
  27630. if (index in array) push(items, array[index]);
  27631. }
  27632. internalSort(items, getSortCompare(comparefn));
  27633. itemsLength = lengthOfArrayLike(items);
  27634. index = 0;
  27635. while (index < itemsLength) array[index] = items[index++];
  27636. while (index < arrayLength) deletePropertyOrThrow(array, index++);
  27637. return array;
  27638. }
  27639. });
  27640. },{"../internals/a-callable":258,"../internals/array-method-is-strict":270,"../internals/array-sort":275,"../internals/delete-property-or-throw":298,"../internals/engine-ff-version":303,"../internals/engine-is-ie-or-edge":306,"../internals/engine-v8-version":312,"../internals/engine-webkit-version":313,"../internals/export":318,"../internals/fails":319,"../internals/function-uncurry-this":327,"../internals/length-of-array-like":362,"../internals/to-object":416,"../internals/to-string":420}],449:[function(_dereq_,module,exports){
  27641. 'use strict';
  27642. var $ = _dereq_('../internals/export');
  27643. var toObject = _dereq_('../internals/to-object');
  27644. var toAbsoluteIndex = _dereq_('../internals/to-absolute-index');
  27645. var toIntegerOrInfinity = _dereq_('../internals/to-integer-or-infinity');
  27646. var lengthOfArrayLike = _dereq_('../internals/length-of-array-like');
  27647. var setArrayLength = _dereq_('../internals/array-set-length');
  27648. var doesNotExceedSafeInteger = _dereq_('../internals/does-not-exceed-safe-integer');
  27649. var arraySpeciesCreate = _dereq_('../internals/array-species-create');
  27650. var createProperty = _dereq_('../internals/create-property');
  27651. var deletePropertyOrThrow = _dereq_('../internals/delete-property-or-throw');
  27652. var arrayMethodHasSpeciesSupport = _dereq_('../internals/array-method-has-species-support');
  27653. var HAS_SPECIES_SUPPORT = arrayMethodHasSpeciesSupport('splice');
  27654. var max = Math.max;
  27655. var min = Math.min;
  27656. // `Array.prototype.splice` method
  27657. // https://tc39.es/ecma262/#sec-array.prototype.splice
  27658. // with adding support of @@species
  27659. $({ target: 'Array', proto: true, forced: !HAS_SPECIES_SUPPORT }, {
  27660. splice: function splice(start, deleteCount /* , ...items */) {
  27661. var O = toObject(this);
  27662. var len = lengthOfArrayLike(O);
  27663. var actualStart = toAbsoluteIndex(start, len);
  27664. var argumentsLength = arguments.length;
  27665. var insertCount, actualDeleteCount, A, k, from, to;
  27666. if (argumentsLength === 0) {
  27667. insertCount = actualDeleteCount = 0;
  27668. } else if (argumentsLength === 1) {
  27669. insertCount = 0;
  27670. actualDeleteCount = len - actualStart;
  27671. } else {
  27672. insertCount = argumentsLength - 2;
  27673. actualDeleteCount = min(max(toIntegerOrInfinity(deleteCount), 0), len - actualStart);
  27674. }
  27675. doesNotExceedSafeInteger(len + insertCount - actualDeleteCount);
  27676. A = arraySpeciesCreate(O, actualDeleteCount);
  27677. for (k = 0; k < actualDeleteCount; k++) {
  27678. from = actualStart + k;
  27679. if (from in O) createProperty(A, k, O[from]);
  27680. }
  27681. A.length = actualDeleteCount;
  27682. if (insertCount < actualDeleteCount) {
  27683. for (k = actualStart; k < len - actualDeleteCount; k++) {
  27684. from = k + actualDeleteCount;
  27685. to = k + insertCount;
  27686. if (from in O) O[to] = O[from];
  27687. else deletePropertyOrThrow(O, to);
  27688. }
  27689. for (k = len; k > len - actualDeleteCount + insertCount; k--) deletePropertyOrThrow(O, k - 1);
  27690. } else if (insertCount > actualDeleteCount) {
  27691. for (k = len - actualDeleteCount; k > actualStart; k--) {
  27692. from = k + actualDeleteCount - 1;
  27693. to = k + insertCount - 1;
  27694. if (from in O) O[to] = O[from];
  27695. else deletePropertyOrThrow(O, to);
  27696. }
  27697. }
  27698. for (k = 0; k < insertCount; k++) {
  27699. O[k + actualStart] = arguments[k + 2];
  27700. }
  27701. setArrayLength(O, len - actualDeleteCount + insertCount);
  27702. return A;
  27703. }
  27704. });
  27705. },{"../internals/array-method-has-species-support":269,"../internals/array-set-length":272,"../internals/array-species-create":277,"../internals/create-property":294,"../internals/delete-property-or-throw":298,"../internals/does-not-exceed-safe-integer":301,"../internals/export":318,"../internals/length-of-array-like":362,"../internals/to-absolute-index":412,"../internals/to-integer-or-infinity":414,"../internals/to-object":416}],450:[function(_dereq_,module,exports){
  27706. // TODO: Remove from `core-js@4`
  27707. var $ = _dereq_('../internals/export');
  27708. var bind = _dereq_('../internals/function-bind');
  27709. // `Function.prototype.bind` method
  27710. // https://tc39.es/ecma262/#sec-function.prototype.bind
  27711. $({ target: 'Function', proto: true, forced: Function.bind !== bind }, {
  27712. bind: bind
  27713. });
  27714. },{"../internals/export":318,"../internals/function-bind":324}],451:[function(_dereq_,module,exports){
  27715. var $ = _dereq_('../internals/export');
  27716. var getBuiltIn = _dereq_('../internals/get-built-in');
  27717. var apply = _dereq_('../internals/function-apply');
  27718. var call = _dereq_('../internals/function-call');
  27719. var uncurryThis = _dereq_('../internals/function-uncurry-this');
  27720. var fails = _dereq_('../internals/fails');
  27721. var isArray = _dereq_('../internals/is-array');
  27722. var isCallable = _dereq_('../internals/is-callable');
  27723. var isObject = _dereq_('../internals/is-object');
  27724. var isSymbol = _dereq_('../internals/is-symbol');
  27725. var arraySlice = _dereq_('../internals/array-slice');
  27726. var NATIVE_SYMBOL = _dereq_('../internals/symbol-constructor-detection');
  27727. var $stringify = getBuiltIn('JSON', 'stringify');
  27728. var exec = uncurryThis(/./.exec);
  27729. var charAt = uncurryThis(''.charAt);
  27730. var charCodeAt = uncurryThis(''.charCodeAt);
  27731. var replace = uncurryThis(''.replace);
  27732. var numberToString = uncurryThis(1.0.toString);
  27733. var tester = /[\uD800-\uDFFF]/g;
  27734. var low = /^[\uD800-\uDBFF]$/;
  27735. var hi = /^[\uDC00-\uDFFF]$/;
  27736. var WRONG_SYMBOLS_CONVERSION = !NATIVE_SYMBOL || fails(function () {
  27737. var symbol = getBuiltIn('Symbol')();
  27738. // MS Edge converts symbol values to JSON as {}
  27739. return $stringify([symbol]) != '[null]'
  27740. // WebKit converts symbol values to JSON as null
  27741. || $stringify({ a: symbol }) != '{}'
  27742. // V8 throws on boxed symbols
  27743. || $stringify(Object(symbol)) != '{}';
  27744. });
  27745. // https://github.com/tc39/proposal-well-formed-stringify
  27746. var ILL_FORMED_UNICODE = fails(function () {
  27747. return $stringify('\uDF06\uD834') !== '"\\udf06\\ud834"'
  27748. || $stringify('\uDEAD') !== '"\\udead"';
  27749. });
  27750. var stringifyWithSymbolsFix = function (it, replacer) {
  27751. var args = arraySlice(arguments);
  27752. var $replacer = replacer;
  27753. if (!isObject(replacer) && it === undefined || isSymbol(it)) return; // IE8 returns string on undefined
  27754. if (!isArray(replacer)) replacer = function (key, value) {
  27755. if (isCallable($replacer)) value = call($replacer, this, key, value);
  27756. if (!isSymbol(value)) return value;
  27757. };
  27758. args[1] = replacer;
  27759. return apply($stringify, null, args);
  27760. };
  27761. var fixIllFormed = function (match, offset, string) {
  27762. var prev = charAt(string, offset - 1);
  27763. var next = charAt(string, offset + 1);
  27764. if ((exec(low, match) && !exec(hi, next)) || (exec(hi, match) && !exec(low, prev))) {
  27765. return '\\u' + numberToString(charCodeAt(match, 0), 16);
  27766. } return match;
  27767. };
  27768. if ($stringify) {
  27769. // `JSON.stringify` method
  27770. // https://tc39.es/ecma262/#sec-json.stringify
  27771. $({ target: 'JSON', stat: true, arity: 3, forced: WRONG_SYMBOLS_CONVERSION || ILL_FORMED_UNICODE }, {
  27772. // eslint-disable-next-line no-unused-vars -- required for `.length`
  27773. stringify: function stringify(it, replacer, space) {
  27774. var args = arraySlice(arguments);
  27775. var result = apply(WRONG_SYMBOLS_CONVERSION ? stringifyWithSymbolsFix : $stringify, null, args);
  27776. return ILL_FORMED_UNICODE && typeof result == 'string' ? replace(result, tester, fixIllFormed) : result;
  27777. }
  27778. });
  27779. }
  27780. },{"../internals/array-slice":274,"../internals/export":318,"../internals/fails":319,"../internals/function-apply":321,"../internals/function-call":325,"../internals/function-uncurry-this":327,"../internals/get-built-in":328,"../internals/is-array":345,"../internals/is-callable":346,"../internals/is-object":352,"../internals/is-symbol":355,"../internals/symbol-constructor-detection":408}],452:[function(_dereq_,module,exports){
  27781. var global = _dereq_('../internals/global');
  27782. var setToStringTag = _dereq_('../internals/set-to-string-tag');
  27783. // JSON[@@toStringTag] property
  27784. // https://tc39.es/ecma262/#sec-json-@@tostringtag
  27785. setToStringTag(global.JSON, 'JSON', true);
  27786. },{"../internals/global":333,"../internals/set-to-string-tag":401}],453:[function(_dereq_,module,exports){
  27787. 'use strict';
  27788. var collection = _dereq_('../internals/collection');
  27789. var collectionStrong = _dereq_('../internals/collection-strong');
  27790. // `Map` constructor
  27791. // https://tc39.es/ecma262/#sec-map-objects
  27792. collection('Map', function (init) {
  27793. return function Map() { return init(this, arguments.length ? arguments[0] : undefined); };
  27794. }, collectionStrong);
  27795. },{"../internals/collection":287,"../internals/collection-strong":285}],454:[function(_dereq_,module,exports){
  27796. // TODO: Remove this module from `core-js@4` since it's replaced to module below
  27797. _dereq_('../modules/es.map.constructor');
  27798. },{"../modules/es.map.constructor":453}],455:[function(_dereq_,module,exports){
  27799. // empty
  27800. },{}],456:[function(_dereq_,module,exports){
  27801. var $ = _dereq_('../internals/export');
  27802. var isIntegralNumber = _dereq_('../internals/is-integral-number');
  27803. // `Number.isInteger` method
  27804. // https://tc39.es/ecma262/#sec-number.isinteger
  27805. $({ target: 'Number', stat: true }, {
  27806. isInteger: isIntegralNumber
  27807. });
  27808. },{"../internals/export":318,"../internals/is-integral-number":350}],457:[function(_dereq_,module,exports){
  27809. var $ = _dereq_('../internals/export');
  27810. var assign = _dereq_('../internals/object-assign');
  27811. // `Object.assign` method
  27812. // https://tc39.es/ecma262/#sec-object.assign
  27813. // eslint-disable-next-line es-x/no-object-assign -- required for testing
  27814. $({ target: 'Object', stat: true, arity: 2, forced: Object.assign !== assign }, {
  27815. assign: assign
  27816. });
  27817. },{"../internals/export":318,"../internals/object-assign":371}],458:[function(_dereq_,module,exports){
  27818. // TODO: Remove from `core-js@4`
  27819. var $ = _dereq_('../internals/export');
  27820. var DESCRIPTORS = _dereq_('../internals/descriptors');
  27821. var create = _dereq_('../internals/object-create');
  27822. // `Object.create` method
  27823. // https://tc39.es/ecma262/#sec-object.create
  27824. $({ target: 'Object', stat: true, sham: !DESCRIPTORS }, {
  27825. create: create
  27826. });
  27827. },{"../internals/descriptors":299,"../internals/export":318,"../internals/object-create":372}],459:[function(_dereq_,module,exports){
  27828. var $ = _dereq_('../internals/export');
  27829. var DESCRIPTORS = _dereq_('../internals/descriptors');
  27830. var defineProperties = _dereq_('../internals/object-define-properties').f;
  27831. // `Object.defineProperties` method
  27832. // https://tc39.es/ecma262/#sec-object.defineproperties
  27833. // eslint-disable-next-line es-x/no-object-defineproperties -- safe
  27834. $({ target: 'Object', stat: true, forced: Object.defineProperties !== defineProperties, sham: !DESCRIPTORS }, {
  27835. defineProperties: defineProperties
  27836. });
  27837. },{"../internals/descriptors":299,"../internals/export":318,"../internals/object-define-properties":373}],460:[function(_dereq_,module,exports){
  27838. var $ = _dereq_('../internals/export');
  27839. var DESCRIPTORS = _dereq_('../internals/descriptors');
  27840. var defineProperty = _dereq_('../internals/object-define-property').f;
  27841. // `Object.defineProperty` method
  27842. // https://tc39.es/ecma262/#sec-object.defineproperty
  27843. // eslint-disable-next-line es-x/no-object-defineproperty -- safe
  27844. $({ target: 'Object', stat: true, forced: Object.defineProperty !== defineProperty, sham: !DESCRIPTORS }, {
  27845. defineProperty: defineProperty
  27846. });
  27847. },{"../internals/descriptors":299,"../internals/export":318,"../internals/object-define-property":374}],461:[function(_dereq_,module,exports){
  27848. var $ = _dereq_('../internals/export');
  27849. var $entries = _dereq_('../internals/object-to-array').entries;
  27850. // `Object.entries` method
  27851. // https://tc39.es/ecma262/#sec-object.entries
  27852. $({ target: 'Object', stat: true }, {
  27853. entries: function entries(O) {
  27854. return $entries(O);
  27855. }
  27856. });
  27857. },{"../internals/export":318,"../internals/object-to-array":386}],462:[function(_dereq_,module,exports){
  27858. var $ = _dereq_('../internals/export');
  27859. var FREEZING = _dereq_('../internals/freezing');
  27860. var fails = _dereq_('../internals/fails');
  27861. var isObject = _dereq_('../internals/is-object');
  27862. var onFreeze = _dereq_('../internals/internal-metadata').onFreeze;
  27863. // eslint-disable-next-line es-x/no-object-freeze -- safe
  27864. var $freeze = Object.freeze;
  27865. var FAILS_ON_PRIMITIVES = fails(function () { $freeze(1); });
  27866. // `Object.freeze` method
  27867. // https://tc39.es/ecma262/#sec-object.freeze
  27868. $({ target: 'Object', stat: true, forced: FAILS_ON_PRIMITIVES, sham: !FREEZING }, {
  27869. freeze: function freeze(it) {
  27870. return $freeze && isObject(it) ? $freeze(onFreeze(it)) : it;
  27871. }
  27872. });
  27873. },{"../internals/export":318,"../internals/fails":319,"../internals/freezing":320,"../internals/internal-metadata":342,"../internals/is-object":352}],463:[function(_dereq_,module,exports){
  27874. var $ = _dereq_('../internals/export');
  27875. var fails = _dereq_('../internals/fails');
  27876. var toIndexedObject = _dereq_('../internals/to-indexed-object');
  27877. var nativeGetOwnPropertyDescriptor = _dereq_('../internals/object-get-own-property-descriptor').f;
  27878. var DESCRIPTORS = _dereq_('../internals/descriptors');
  27879. var FAILS_ON_PRIMITIVES = fails(function () { nativeGetOwnPropertyDescriptor(1); });
  27880. var FORCED = !DESCRIPTORS || FAILS_ON_PRIMITIVES;
  27881. // `Object.getOwnPropertyDescriptor` method
  27882. // https://tc39.es/ecma262/#sec-object.getownpropertydescriptor
  27883. $({ target: 'Object', stat: true, forced: FORCED, sham: !DESCRIPTORS }, {
  27884. getOwnPropertyDescriptor: function getOwnPropertyDescriptor(it, key) {
  27885. return nativeGetOwnPropertyDescriptor(toIndexedObject(it), key);
  27886. }
  27887. });
  27888. },{"../internals/descriptors":299,"../internals/export":318,"../internals/fails":319,"../internals/object-get-own-property-descriptor":375,"../internals/to-indexed-object":413}],464:[function(_dereq_,module,exports){
  27889. var $ = _dereq_('../internals/export');
  27890. var DESCRIPTORS = _dereq_('../internals/descriptors');
  27891. var ownKeys = _dereq_('../internals/own-keys');
  27892. var toIndexedObject = _dereq_('../internals/to-indexed-object');
  27893. var getOwnPropertyDescriptorModule = _dereq_('../internals/object-get-own-property-descriptor');
  27894. var createProperty = _dereq_('../internals/create-property');
  27895. // `Object.getOwnPropertyDescriptors` method
  27896. // https://tc39.es/ecma262/#sec-object.getownpropertydescriptors
  27897. $({ target: 'Object', stat: true, sham: !DESCRIPTORS }, {
  27898. getOwnPropertyDescriptors: function getOwnPropertyDescriptors(object) {
  27899. var O = toIndexedObject(object);
  27900. var getOwnPropertyDescriptor = getOwnPropertyDescriptorModule.f;
  27901. var keys = ownKeys(O);
  27902. var result = {};
  27903. var index = 0;
  27904. var key, descriptor;
  27905. while (keys.length > index) {
  27906. descriptor = getOwnPropertyDescriptor(O, key = keys[index++]);
  27907. if (descriptor !== undefined) createProperty(result, key, descriptor);
  27908. }
  27909. return result;
  27910. }
  27911. });
  27912. },{"../internals/create-property":294,"../internals/descriptors":299,"../internals/export":318,"../internals/object-get-own-property-descriptor":375,"../internals/own-keys":389,"../internals/to-indexed-object":413}],465:[function(_dereq_,module,exports){
  27913. var $ = _dereq_('../internals/export');
  27914. var NATIVE_SYMBOL = _dereq_('../internals/symbol-constructor-detection');
  27915. var fails = _dereq_('../internals/fails');
  27916. var getOwnPropertySymbolsModule = _dereq_('../internals/object-get-own-property-symbols');
  27917. var toObject = _dereq_('../internals/to-object');
  27918. // V8 ~ Chrome 38 and 39 `Object.getOwnPropertySymbols` fails on primitives
  27919. // https://bugs.chromium.org/p/v8/issues/detail?id=3443
  27920. var FORCED = !NATIVE_SYMBOL || fails(function () { getOwnPropertySymbolsModule.f(1); });
  27921. // `Object.getOwnPropertySymbols` method
  27922. // https://tc39.es/ecma262/#sec-object.getownpropertysymbols
  27923. $({ target: 'Object', stat: true, forced: FORCED }, {
  27924. getOwnPropertySymbols: function getOwnPropertySymbols(it) {
  27925. var $getOwnPropertySymbols = getOwnPropertySymbolsModule.f;
  27926. return $getOwnPropertySymbols ? $getOwnPropertySymbols(toObject(it)) : [];
  27927. }
  27928. });
  27929. },{"../internals/export":318,"../internals/fails":319,"../internals/object-get-own-property-symbols":378,"../internals/symbol-constructor-detection":408,"../internals/to-object":416}],466:[function(_dereq_,module,exports){
  27930. var $ = _dereq_('../internals/export');
  27931. var fails = _dereq_('../internals/fails');
  27932. var toObject = _dereq_('../internals/to-object');
  27933. var nativeGetPrototypeOf = _dereq_('../internals/object-get-prototype-of');
  27934. var CORRECT_PROTOTYPE_GETTER = _dereq_('../internals/correct-prototype-getter');
  27935. var FAILS_ON_PRIMITIVES = fails(function () { nativeGetPrototypeOf(1); });
  27936. // `Object.getPrototypeOf` method
  27937. // https://tc39.es/ecma262/#sec-object.getprototypeof
  27938. $({ target: 'Object', stat: true, forced: FAILS_ON_PRIMITIVES, sham: !CORRECT_PROTOTYPE_GETTER }, {
  27939. getPrototypeOf: function getPrototypeOf(it) {
  27940. return nativeGetPrototypeOf(toObject(it));
  27941. }
  27942. });
  27943. },{"../internals/correct-prototype-getter":290,"../internals/export":318,"../internals/fails":319,"../internals/object-get-prototype-of":379,"../internals/to-object":416}],467:[function(_dereq_,module,exports){
  27944. var $ = _dereq_('../internals/export');
  27945. var toObject = _dereq_('../internals/to-object');
  27946. var nativeKeys = _dereq_('../internals/object-keys');
  27947. var fails = _dereq_('../internals/fails');
  27948. var FAILS_ON_PRIMITIVES = fails(function () { nativeKeys(1); });
  27949. // `Object.keys` method
  27950. // https://tc39.es/ecma262/#sec-object.keys
  27951. $({ target: 'Object', stat: true, forced: FAILS_ON_PRIMITIVES }, {
  27952. keys: function keys(it) {
  27953. return nativeKeys(toObject(it));
  27954. }
  27955. });
  27956. },{"../internals/export":318,"../internals/fails":319,"../internals/object-keys":383,"../internals/to-object":416}],468:[function(_dereq_,module,exports){
  27957. var $ = _dereq_('../internals/export');
  27958. var setPrototypeOf = _dereq_('../internals/object-set-prototype-of');
  27959. // `Object.setPrototypeOf` method
  27960. // https://tc39.es/ecma262/#sec-object.setprototypeof
  27961. $({ target: 'Object', stat: true }, {
  27962. setPrototypeOf: setPrototypeOf
  27963. });
  27964. },{"../internals/export":318,"../internals/object-set-prototype-of":385}],469:[function(_dereq_,module,exports){
  27965. arguments[4][455][0].apply(exports,arguments)
  27966. },{"dup":455}],470:[function(_dereq_,module,exports){
  27967. var $ = _dereq_('../internals/export');
  27968. var $parseInt = _dereq_('../internals/number-parse-int');
  27969. // `parseInt` method
  27970. // https://tc39.es/ecma262/#sec-parseint-string-radix
  27971. $({ global: true, forced: parseInt != $parseInt }, {
  27972. parseInt: $parseInt
  27973. });
  27974. },{"../internals/export":318,"../internals/number-parse-int":370}],471:[function(_dereq_,module,exports){
  27975. 'use strict';
  27976. var $ = _dereq_('../internals/export');
  27977. var call = _dereq_('../internals/function-call');
  27978. var aCallable = _dereq_('../internals/a-callable');
  27979. var newPromiseCapabilityModule = _dereq_('../internals/new-promise-capability');
  27980. var perform = _dereq_('../internals/perform');
  27981. var iterate = _dereq_('../internals/iterate');
  27982. // `Promise.allSettled` method
  27983. // https://tc39.es/ecma262/#sec-promise.allsettled
  27984. $({ target: 'Promise', stat: true }, {
  27985. allSettled: function allSettled(iterable) {
  27986. var C = this;
  27987. var capability = newPromiseCapabilityModule.f(C);
  27988. var resolve = capability.resolve;
  27989. var reject = capability.reject;
  27990. var result = perform(function () {
  27991. var promiseResolve = aCallable(C.resolve);
  27992. var values = [];
  27993. var counter = 0;
  27994. var remaining = 1;
  27995. iterate(iterable, function (promise) {
  27996. var index = counter++;
  27997. var alreadyCalled = false;
  27998. remaining++;
  27999. call(promiseResolve, C, promise).then(function (value) {
  28000. if (alreadyCalled) return;
  28001. alreadyCalled = true;
  28002. values[index] = { status: 'fulfilled', value: value };
  28003. --remaining || resolve(values);
  28004. }, function (error) {
  28005. if (alreadyCalled) return;
  28006. alreadyCalled = true;
  28007. values[index] = { status: 'rejected', reason: error };
  28008. --remaining || resolve(values);
  28009. });
  28010. });
  28011. --remaining || resolve(values);
  28012. });
  28013. if (result.error) reject(result.value);
  28014. return capability.promise;
  28015. }
  28016. });
  28017. },{"../internals/a-callable":258,"../internals/export":318,"../internals/function-call":325,"../internals/iterate":356,"../internals/new-promise-capability":367,"../internals/perform":391}],472:[function(_dereq_,module,exports){
  28018. 'use strict';
  28019. var $ = _dereq_('../internals/export');
  28020. var call = _dereq_('../internals/function-call');
  28021. var aCallable = _dereq_('../internals/a-callable');
  28022. var newPromiseCapabilityModule = _dereq_('../internals/new-promise-capability');
  28023. var perform = _dereq_('../internals/perform');
  28024. var iterate = _dereq_('../internals/iterate');
  28025. var PROMISE_STATICS_INCORRECT_ITERATION = _dereq_('../internals/promise-statics-incorrect-iteration');
  28026. // `Promise.all` method
  28027. // https://tc39.es/ecma262/#sec-promise.all
  28028. $({ target: 'Promise', stat: true, forced: PROMISE_STATICS_INCORRECT_ITERATION }, {
  28029. all: function all(iterable) {
  28030. var C = this;
  28031. var capability = newPromiseCapabilityModule.f(C);
  28032. var resolve = capability.resolve;
  28033. var reject = capability.reject;
  28034. var result = perform(function () {
  28035. var $promiseResolve = aCallable(C.resolve);
  28036. var values = [];
  28037. var counter = 0;
  28038. var remaining = 1;
  28039. iterate(iterable, function (promise) {
  28040. var index = counter++;
  28041. var alreadyCalled = false;
  28042. remaining++;
  28043. call($promiseResolve, C, promise).then(function (value) {
  28044. if (alreadyCalled) return;
  28045. alreadyCalled = true;
  28046. values[index] = value;
  28047. --remaining || resolve(values);
  28048. }, reject);
  28049. });
  28050. --remaining || resolve(values);
  28051. });
  28052. if (result.error) reject(result.value);
  28053. return capability.promise;
  28054. }
  28055. });
  28056. },{"../internals/a-callable":258,"../internals/export":318,"../internals/function-call":325,"../internals/iterate":356,"../internals/new-promise-capability":367,"../internals/perform":391,"../internals/promise-statics-incorrect-iteration":395}],473:[function(_dereq_,module,exports){
  28057. 'use strict';
  28058. var $ = _dereq_('../internals/export');
  28059. var call = _dereq_('../internals/function-call');
  28060. var aCallable = _dereq_('../internals/a-callable');
  28061. var getBuiltIn = _dereq_('../internals/get-built-in');
  28062. var newPromiseCapabilityModule = _dereq_('../internals/new-promise-capability');
  28063. var perform = _dereq_('../internals/perform');
  28064. var iterate = _dereq_('../internals/iterate');
  28065. var PROMISE_ANY_ERROR = 'No one promise resolved';
  28066. // `Promise.any` method
  28067. // https://tc39.es/ecma262/#sec-promise.any
  28068. $({ target: 'Promise', stat: true }, {
  28069. any: function any(iterable) {
  28070. var C = this;
  28071. var AggregateError = getBuiltIn('AggregateError');
  28072. var capability = newPromiseCapabilityModule.f(C);
  28073. var resolve = capability.resolve;
  28074. var reject = capability.reject;
  28075. var result = perform(function () {
  28076. var promiseResolve = aCallable(C.resolve);
  28077. var errors = [];
  28078. var counter = 0;
  28079. var remaining = 1;
  28080. var alreadyResolved = false;
  28081. iterate(iterable, function (promise) {
  28082. var index = counter++;
  28083. var alreadyRejected = false;
  28084. remaining++;
  28085. call(promiseResolve, C, promise).then(function (value) {
  28086. if (alreadyRejected || alreadyResolved) return;
  28087. alreadyResolved = true;
  28088. resolve(value);
  28089. }, function (error) {
  28090. if (alreadyRejected || alreadyResolved) return;
  28091. alreadyRejected = true;
  28092. errors[index] = error;
  28093. --remaining || reject(new AggregateError(errors, PROMISE_ANY_ERROR));
  28094. });
  28095. });
  28096. --remaining || reject(new AggregateError(errors, PROMISE_ANY_ERROR));
  28097. });
  28098. if (result.error) reject(result.value);
  28099. return capability.promise;
  28100. }
  28101. });
  28102. },{"../internals/a-callable":258,"../internals/export":318,"../internals/function-call":325,"../internals/get-built-in":328,"../internals/iterate":356,"../internals/new-promise-capability":367,"../internals/perform":391}],474:[function(_dereq_,module,exports){
  28103. 'use strict';
  28104. var $ = _dereq_('../internals/export');
  28105. var IS_PURE = _dereq_('../internals/is-pure');
  28106. var FORCED_PROMISE_CONSTRUCTOR = _dereq_('../internals/promise-constructor-detection').CONSTRUCTOR;
  28107. var NativePromiseConstructor = _dereq_('../internals/promise-native-constructor');
  28108. var getBuiltIn = _dereq_('../internals/get-built-in');
  28109. var isCallable = _dereq_('../internals/is-callable');
  28110. var defineBuiltIn = _dereq_('../internals/define-built-in');
  28111. var NativePromisePrototype = NativePromiseConstructor && NativePromiseConstructor.prototype;
  28112. // `Promise.prototype.catch` method
  28113. // https://tc39.es/ecma262/#sec-promise.prototype.catch
  28114. $({ target: 'Promise', proto: true, forced: FORCED_PROMISE_CONSTRUCTOR, real: true }, {
  28115. 'catch': function (onRejected) {
  28116. return this.then(undefined, onRejected);
  28117. }
  28118. });
  28119. // makes sure that native promise-based APIs `Promise#catch` properly works with patched `Promise#then`
  28120. if (!IS_PURE && isCallable(NativePromiseConstructor)) {
  28121. var method = getBuiltIn('Promise').prototype['catch'];
  28122. if (NativePromisePrototype['catch'] !== method) {
  28123. defineBuiltIn(NativePromisePrototype, 'catch', method, { unsafe: true });
  28124. }
  28125. }
  28126. },{"../internals/define-built-in":295,"../internals/export":318,"../internals/get-built-in":328,"../internals/is-callable":346,"../internals/is-pure":353,"../internals/promise-constructor-detection":392,"../internals/promise-native-constructor":393}],475:[function(_dereq_,module,exports){
  28127. 'use strict';
  28128. var $ = _dereq_('../internals/export');
  28129. var IS_PURE = _dereq_('../internals/is-pure');
  28130. var IS_NODE = _dereq_('../internals/engine-is-node');
  28131. var global = _dereq_('../internals/global');
  28132. var call = _dereq_('../internals/function-call');
  28133. var defineBuiltIn = _dereq_('../internals/define-built-in');
  28134. var setPrototypeOf = _dereq_('../internals/object-set-prototype-of');
  28135. var setToStringTag = _dereq_('../internals/set-to-string-tag');
  28136. var setSpecies = _dereq_('../internals/set-species');
  28137. var aCallable = _dereq_('../internals/a-callable');
  28138. var isCallable = _dereq_('../internals/is-callable');
  28139. var isObject = _dereq_('../internals/is-object');
  28140. var anInstance = _dereq_('../internals/an-instance');
  28141. var speciesConstructor = _dereq_('../internals/species-constructor');
  28142. var task = _dereq_('../internals/task').set;
  28143. var microtask = _dereq_('../internals/microtask');
  28144. var hostReportErrors = _dereq_('../internals/host-report-errors');
  28145. var perform = _dereq_('../internals/perform');
  28146. var Queue = _dereq_('../internals/queue');
  28147. var InternalStateModule = _dereq_('../internals/internal-state');
  28148. var NativePromiseConstructor = _dereq_('../internals/promise-native-constructor');
  28149. var PromiseConstructorDetection = _dereq_('../internals/promise-constructor-detection');
  28150. var newPromiseCapabilityModule = _dereq_('../internals/new-promise-capability');
  28151. var PROMISE = 'Promise';
  28152. var FORCED_PROMISE_CONSTRUCTOR = PromiseConstructorDetection.CONSTRUCTOR;
  28153. var NATIVE_PROMISE_REJECTION_EVENT = PromiseConstructorDetection.REJECTION_EVENT;
  28154. var NATIVE_PROMISE_SUBCLASSING = PromiseConstructorDetection.SUBCLASSING;
  28155. var getInternalPromiseState = InternalStateModule.getterFor(PROMISE);
  28156. var setInternalState = InternalStateModule.set;
  28157. var NativePromisePrototype = NativePromiseConstructor && NativePromiseConstructor.prototype;
  28158. var PromiseConstructor = NativePromiseConstructor;
  28159. var PromisePrototype = NativePromisePrototype;
  28160. var TypeError = global.TypeError;
  28161. var document = global.document;
  28162. var process = global.process;
  28163. var newPromiseCapability = newPromiseCapabilityModule.f;
  28164. var newGenericPromiseCapability = newPromiseCapability;
  28165. var DISPATCH_EVENT = !!(document && document.createEvent && global.dispatchEvent);
  28166. var UNHANDLED_REJECTION = 'unhandledrejection';
  28167. var REJECTION_HANDLED = 'rejectionhandled';
  28168. var PENDING = 0;
  28169. var FULFILLED = 1;
  28170. var REJECTED = 2;
  28171. var HANDLED = 1;
  28172. var UNHANDLED = 2;
  28173. var Internal, OwnPromiseCapability, PromiseWrapper, nativeThen;
  28174. // helpers
  28175. var isThenable = function (it) {
  28176. var then;
  28177. return isObject(it) && isCallable(then = it.then) ? then : false;
  28178. };
  28179. var callReaction = function (reaction, state) {
  28180. var value = state.value;
  28181. var ok = state.state == FULFILLED;
  28182. var handler = ok ? reaction.ok : reaction.fail;
  28183. var resolve = reaction.resolve;
  28184. var reject = reaction.reject;
  28185. var domain = reaction.domain;
  28186. var result, then, exited;
  28187. try {
  28188. if (handler) {
  28189. if (!ok) {
  28190. if (state.rejection === UNHANDLED) onHandleUnhandled(state);
  28191. state.rejection = HANDLED;
  28192. }
  28193. if (handler === true) result = value;
  28194. else {
  28195. if (domain) domain.enter();
  28196. result = handler(value); // can throw
  28197. if (domain) {
  28198. domain.exit();
  28199. exited = true;
  28200. }
  28201. }
  28202. if (result === reaction.promise) {
  28203. reject(TypeError('Promise-chain cycle'));
  28204. } else if (then = isThenable(result)) {
  28205. call(then, result, resolve, reject);
  28206. } else resolve(result);
  28207. } else reject(value);
  28208. } catch (error) {
  28209. if (domain && !exited) domain.exit();
  28210. reject(error);
  28211. }
  28212. };
  28213. var notify = function (state, isReject) {
  28214. if (state.notified) return;
  28215. state.notified = true;
  28216. microtask(function () {
  28217. var reactions = state.reactions;
  28218. var reaction;
  28219. while (reaction = reactions.get()) {
  28220. callReaction(reaction, state);
  28221. }
  28222. state.notified = false;
  28223. if (isReject && !state.rejection) onUnhandled(state);
  28224. });
  28225. };
  28226. var dispatchEvent = function (name, promise, reason) {
  28227. var event, handler;
  28228. if (DISPATCH_EVENT) {
  28229. event = document.createEvent('Event');
  28230. event.promise = promise;
  28231. event.reason = reason;
  28232. event.initEvent(name, false, true);
  28233. global.dispatchEvent(event);
  28234. } else event = { promise: promise, reason: reason };
  28235. if (!NATIVE_PROMISE_REJECTION_EVENT && (handler = global['on' + name])) handler(event);
  28236. else if (name === UNHANDLED_REJECTION) hostReportErrors('Unhandled promise rejection', reason);
  28237. };
  28238. var onUnhandled = function (state) {
  28239. call(task, global, function () {
  28240. var promise = state.facade;
  28241. var value = state.value;
  28242. var IS_UNHANDLED = isUnhandled(state);
  28243. var result;
  28244. if (IS_UNHANDLED) {
  28245. result = perform(function () {
  28246. if (IS_NODE) {
  28247. process.emit('unhandledRejection', value, promise);
  28248. } else dispatchEvent(UNHANDLED_REJECTION, promise, value);
  28249. });
  28250. // Browsers should not trigger `rejectionHandled` event if it was handled here, NodeJS - should
  28251. state.rejection = IS_NODE || isUnhandled(state) ? UNHANDLED : HANDLED;
  28252. if (result.error) throw result.value;
  28253. }
  28254. });
  28255. };
  28256. var isUnhandled = function (state) {
  28257. return state.rejection !== HANDLED && !state.parent;
  28258. };
  28259. var onHandleUnhandled = function (state) {
  28260. call(task, global, function () {
  28261. var promise = state.facade;
  28262. if (IS_NODE) {
  28263. process.emit('rejectionHandled', promise);
  28264. } else dispatchEvent(REJECTION_HANDLED, promise, state.value);
  28265. });
  28266. };
  28267. var bind = function (fn, state, unwrap) {
  28268. return function (value) {
  28269. fn(state, value, unwrap);
  28270. };
  28271. };
  28272. var internalReject = function (state, value, unwrap) {
  28273. if (state.done) return;
  28274. state.done = true;
  28275. if (unwrap) state = unwrap;
  28276. state.value = value;
  28277. state.state = REJECTED;
  28278. notify(state, true);
  28279. };
  28280. var internalResolve = function (state, value, unwrap) {
  28281. if (state.done) return;
  28282. state.done = true;
  28283. if (unwrap) state = unwrap;
  28284. try {
  28285. if (state.facade === value) throw TypeError("Promise can't be resolved itself");
  28286. var then = isThenable(value);
  28287. if (then) {
  28288. microtask(function () {
  28289. var wrapper = { done: false };
  28290. try {
  28291. call(then, value,
  28292. bind(internalResolve, wrapper, state),
  28293. bind(internalReject, wrapper, state)
  28294. );
  28295. } catch (error) {
  28296. internalReject(wrapper, error, state);
  28297. }
  28298. });
  28299. } else {
  28300. state.value = value;
  28301. state.state = FULFILLED;
  28302. notify(state, false);
  28303. }
  28304. } catch (error) {
  28305. internalReject({ done: false }, error, state);
  28306. }
  28307. };
  28308. // constructor polyfill
  28309. if (FORCED_PROMISE_CONSTRUCTOR) {
  28310. // 25.4.3.1 Promise(executor)
  28311. PromiseConstructor = function Promise(executor) {
  28312. anInstance(this, PromisePrototype);
  28313. aCallable(executor);
  28314. call(Internal, this);
  28315. var state = getInternalPromiseState(this);
  28316. try {
  28317. executor(bind(internalResolve, state), bind(internalReject, state));
  28318. } catch (error) {
  28319. internalReject(state, error);
  28320. }
  28321. };
  28322. PromisePrototype = PromiseConstructor.prototype;
  28323. // eslint-disable-next-line no-unused-vars -- required for `.length`
  28324. Internal = function Promise(executor) {
  28325. setInternalState(this, {
  28326. type: PROMISE,
  28327. done: false,
  28328. notified: false,
  28329. parent: false,
  28330. reactions: new Queue(),
  28331. rejection: false,
  28332. state: PENDING,
  28333. value: undefined
  28334. });
  28335. };
  28336. // `Promise.prototype.then` method
  28337. // https://tc39.es/ecma262/#sec-promise.prototype.then
  28338. Internal.prototype = defineBuiltIn(PromisePrototype, 'then', function then(onFulfilled, onRejected) {
  28339. var state = getInternalPromiseState(this);
  28340. var reaction = newPromiseCapability(speciesConstructor(this, PromiseConstructor));
  28341. state.parent = true;
  28342. reaction.ok = isCallable(onFulfilled) ? onFulfilled : true;
  28343. reaction.fail = isCallable(onRejected) && onRejected;
  28344. reaction.domain = IS_NODE ? process.domain : undefined;
  28345. if (state.state == PENDING) state.reactions.add(reaction);
  28346. else microtask(function () {
  28347. callReaction(reaction, state);
  28348. });
  28349. return reaction.promise;
  28350. });
  28351. OwnPromiseCapability = function () {
  28352. var promise = new Internal();
  28353. var state = getInternalPromiseState(promise);
  28354. this.promise = promise;
  28355. this.resolve = bind(internalResolve, state);
  28356. this.reject = bind(internalReject, state);
  28357. };
  28358. newPromiseCapabilityModule.f = newPromiseCapability = function (C) {
  28359. return C === PromiseConstructor || C === PromiseWrapper
  28360. ? new OwnPromiseCapability(C)
  28361. : newGenericPromiseCapability(C);
  28362. };
  28363. if (!IS_PURE && isCallable(NativePromiseConstructor) && NativePromisePrototype !== Object.prototype) {
  28364. nativeThen = NativePromisePrototype.then;
  28365. if (!NATIVE_PROMISE_SUBCLASSING) {
  28366. // make `Promise#then` return a polyfilled `Promise` for native promise-based APIs
  28367. defineBuiltIn(NativePromisePrototype, 'then', function then(onFulfilled, onRejected) {
  28368. var that = this;
  28369. return new PromiseConstructor(function (resolve, reject) {
  28370. call(nativeThen, that, resolve, reject);
  28371. }).then(onFulfilled, onRejected);
  28372. // https://github.com/zloirock/core-js/issues/640
  28373. }, { unsafe: true });
  28374. }
  28375. // make `.constructor === Promise` work for native promise-based APIs
  28376. try {
  28377. delete NativePromisePrototype.constructor;
  28378. } catch (error) { /* empty */ }
  28379. // make `instanceof Promise` work for native promise-based APIs
  28380. if (setPrototypeOf) {
  28381. setPrototypeOf(NativePromisePrototype, PromisePrototype);
  28382. }
  28383. }
  28384. }
  28385. $({ global: true, constructor: true, wrap: true, forced: FORCED_PROMISE_CONSTRUCTOR }, {
  28386. Promise: PromiseConstructor
  28387. });
  28388. setToStringTag(PromiseConstructor, PROMISE, false, true);
  28389. setSpecies(PROMISE);
  28390. },{"../internals/a-callable":258,"../internals/an-instance":262,"../internals/define-built-in":295,"../internals/engine-is-node":309,"../internals/export":318,"../internals/function-call":325,"../internals/global":333,"../internals/host-report-errors":336,"../internals/internal-state":343,"../internals/is-callable":346,"../internals/is-object":352,"../internals/is-pure":353,"../internals/microtask":366,"../internals/new-promise-capability":367,"../internals/object-set-prototype-of":385,"../internals/perform":391,"../internals/promise-constructor-detection":392,"../internals/promise-native-constructor":393,"../internals/queue":396,"../internals/set-species":400,"../internals/set-to-string-tag":401,"../internals/species-constructor":405,"../internals/task":411}],476:[function(_dereq_,module,exports){
  28391. 'use strict';
  28392. var $ = _dereq_('../internals/export');
  28393. var IS_PURE = _dereq_('../internals/is-pure');
  28394. var NativePromiseConstructor = _dereq_('../internals/promise-native-constructor');
  28395. var fails = _dereq_('../internals/fails');
  28396. var getBuiltIn = _dereq_('../internals/get-built-in');
  28397. var isCallable = _dereq_('../internals/is-callable');
  28398. var speciesConstructor = _dereq_('../internals/species-constructor');
  28399. var promiseResolve = _dereq_('../internals/promise-resolve');
  28400. var defineBuiltIn = _dereq_('../internals/define-built-in');
  28401. var NativePromisePrototype = NativePromiseConstructor && NativePromiseConstructor.prototype;
  28402. // Safari bug https://bugs.webkit.org/show_bug.cgi?id=200829
  28403. var NON_GENERIC = !!NativePromiseConstructor && fails(function () {
  28404. // eslint-disable-next-line unicorn/no-thenable -- required for testing
  28405. NativePromisePrototype['finally'].call({ then: function () { /* empty */ } }, function () { /* empty */ });
  28406. });
  28407. // `Promise.prototype.finally` method
  28408. // https://tc39.es/ecma262/#sec-promise.prototype.finally
  28409. $({ target: 'Promise', proto: true, real: true, forced: NON_GENERIC }, {
  28410. 'finally': function (onFinally) {
  28411. var C = speciesConstructor(this, getBuiltIn('Promise'));
  28412. var isFunction = isCallable(onFinally);
  28413. return this.then(
  28414. isFunction ? function (x) {
  28415. return promiseResolve(C, onFinally()).then(function () { return x; });
  28416. } : onFinally,
  28417. isFunction ? function (e) {
  28418. return promiseResolve(C, onFinally()).then(function () { throw e; });
  28419. } : onFinally
  28420. );
  28421. }
  28422. });
  28423. // makes sure that native promise-based APIs `Promise#finally` properly works with patched `Promise#then`
  28424. if (!IS_PURE && isCallable(NativePromiseConstructor)) {
  28425. var method = getBuiltIn('Promise').prototype['finally'];
  28426. if (NativePromisePrototype['finally'] !== method) {
  28427. defineBuiltIn(NativePromisePrototype, 'finally', method, { unsafe: true });
  28428. }
  28429. }
  28430. },{"../internals/define-built-in":295,"../internals/export":318,"../internals/fails":319,"../internals/get-built-in":328,"../internals/is-callable":346,"../internals/is-pure":353,"../internals/promise-native-constructor":393,"../internals/promise-resolve":394,"../internals/species-constructor":405}],477:[function(_dereq_,module,exports){
  28431. // TODO: Remove this module from `core-js@4` since it's split to modules listed below
  28432. _dereq_('../modules/es.promise.constructor');
  28433. _dereq_('../modules/es.promise.all');
  28434. _dereq_('../modules/es.promise.catch');
  28435. _dereq_('../modules/es.promise.race');
  28436. _dereq_('../modules/es.promise.reject');
  28437. _dereq_('../modules/es.promise.resolve');
  28438. },{"../modules/es.promise.all":472,"../modules/es.promise.catch":474,"../modules/es.promise.constructor":475,"../modules/es.promise.race":478,"../modules/es.promise.reject":479,"../modules/es.promise.resolve":480}],478:[function(_dereq_,module,exports){
  28439. 'use strict';
  28440. var $ = _dereq_('../internals/export');
  28441. var call = _dereq_('../internals/function-call');
  28442. var aCallable = _dereq_('../internals/a-callable');
  28443. var newPromiseCapabilityModule = _dereq_('../internals/new-promise-capability');
  28444. var perform = _dereq_('../internals/perform');
  28445. var iterate = _dereq_('../internals/iterate');
  28446. var PROMISE_STATICS_INCORRECT_ITERATION = _dereq_('../internals/promise-statics-incorrect-iteration');
  28447. // `Promise.race` method
  28448. // https://tc39.es/ecma262/#sec-promise.race
  28449. $({ target: 'Promise', stat: true, forced: PROMISE_STATICS_INCORRECT_ITERATION }, {
  28450. race: function race(iterable) {
  28451. var C = this;
  28452. var capability = newPromiseCapabilityModule.f(C);
  28453. var reject = capability.reject;
  28454. var result = perform(function () {
  28455. var $promiseResolve = aCallable(C.resolve);
  28456. iterate(iterable, function (promise) {
  28457. call($promiseResolve, C, promise).then(capability.resolve, reject);
  28458. });
  28459. });
  28460. if (result.error) reject(result.value);
  28461. return capability.promise;
  28462. }
  28463. });
  28464. },{"../internals/a-callable":258,"../internals/export":318,"../internals/function-call":325,"../internals/iterate":356,"../internals/new-promise-capability":367,"../internals/perform":391,"../internals/promise-statics-incorrect-iteration":395}],479:[function(_dereq_,module,exports){
  28465. 'use strict';
  28466. var $ = _dereq_('../internals/export');
  28467. var call = _dereq_('../internals/function-call');
  28468. var newPromiseCapabilityModule = _dereq_('../internals/new-promise-capability');
  28469. var FORCED_PROMISE_CONSTRUCTOR = _dereq_('../internals/promise-constructor-detection').CONSTRUCTOR;
  28470. // `Promise.reject` method
  28471. // https://tc39.es/ecma262/#sec-promise.reject
  28472. $({ target: 'Promise', stat: true, forced: FORCED_PROMISE_CONSTRUCTOR }, {
  28473. reject: function reject(r) {
  28474. var capability = newPromiseCapabilityModule.f(this);
  28475. call(capability.reject, undefined, r);
  28476. return capability.promise;
  28477. }
  28478. });
  28479. },{"../internals/export":318,"../internals/function-call":325,"../internals/new-promise-capability":367,"../internals/promise-constructor-detection":392}],480:[function(_dereq_,module,exports){
  28480. 'use strict';
  28481. var $ = _dereq_('../internals/export');
  28482. var getBuiltIn = _dereq_('../internals/get-built-in');
  28483. var IS_PURE = _dereq_('../internals/is-pure');
  28484. var NativePromiseConstructor = _dereq_('../internals/promise-native-constructor');
  28485. var FORCED_PROMISE_CONSTRUCTOR = _dereq_('../internals/promise-constructor-detection').CONSTRUCTOR;
  28486. var promiseResolve = _dereq_('../internals/promise-resolve');
  28487. var PromiseConstructorWrapper = getBuiltIn('Promise');
  28488. var CHECK_WRAPPER = IS_PURE && !FORCED_PROMISE_CONSTRUCTOR;
  28489. // `Promise.resolve` method
  28490. // https://tc39.es/ecma262/#sec-promise.resolve
  28491. $({ target: 'Promise', stat: true, forced: IS_PURE || FORCED_PROMISE_CONSTRUCTOR }, {
  28492. resolve: function resolve(x) {
  28493. return promiseResolve(CHECK_WRAPPER && this === PromiseConstructorWrapper ? NativePromiseConstructor : this, x);
  28494. }
  28495. });
  28496. },{"../internals/export":318,"../internals/get-built-in":328,"../internals/is-pure":353,"../internals/promise-constructor-detection":392,"../internals/promise-native-constructor":393,"../internals/promise-resolve":394}],481:[function(_dereq_,module,exports){
  28497. var $ = _dereq_('../internals/export');
  28498. var getBuiltIn = _dereq_('../internals/get-built-in');
  28499. var apply = _dereq_('../internals/function-apply');
  28500. var bind = _dereq_('../internals/function-bind');
  28501. var aConstructor = _dereq_('../internals/a-constructor');
  28502. var anObject = _dereq_('../internals/an-object');
  28503. var isObject = _dereq_('../internals/is-object');
  28504. var create = _dereq_('../internals/object-create');
  28505. var fails = _dereq_('../internals/fails');
  28506. var nativeConstruct = getBuiltIn('Reflect', 'construct');
  28507. var ObjectPrototype = Object.prototype;
  28508. var push = [].push;
  28509. // `Reflect.construct` method
  28510. // https://tc39.es/ecma262/#sec-reflect.construct
  28511. // MS Edge supports only 2 arguments and argumentsList argument is optional
  28512. // FF Nightly sets third argument as `new.target`, but does not create `this` from it
  28513. var NEW_TARGET_BUG = fails(function () {
  28514. function F() { /* empty */ }
  28515. return !(nativeConstruct(function () { /* empty */ }, [], F) instanceof F);
  28516. });
  28517. var ARGS_BUG = !fails(function () {
  28518. nativeConstruct(function () { /* empty */ });
  28519. });
  28520. var FORCED = NEW_TARGET_BUG || ARGS_BUG;
  28521. $({ target: 'Reflect', stat: true, forced: FORCED, sham: FORCED }, {
  28522. construct: function construct(Target, args /* , newTarget */) {
  28523. aConstructor(Target);
  28524. anObject(args);
  28525. var newTarget = arguments.length < 3 ? Target : aConstructor(arguments[2]);
  28526. if (ARGS_BUG && !NEW_TARGET_BUG) return nativeConstruct(Target, args, newTarget);
  28527. if (Target == newTarget) {
  28528. // w/o altered newTarget, optimization for 0-4 arguments
  28529. switch (args.length) {
  28530. case 0: return new Target();
  28531. case 1: return new Target(args[0]);
  28532. case 2: return new Target(args[0], args[1]);
  28533. case 3: return new Target(args[0], args[1], args[2]);
  28534. case 4: return new Target(args[0], args[1], args[2], args[3]);
  28535. }
  28536. // w/o altered newTarget, lot of arguments case
  28537. var $args = [null];
  28538. apply(push, $args, args);
  28539. return new (apply(bind, Target, $args))();
  28540. }
  28541. // with altered newTarget, not support built-in constructors
  28542. var proto = newTarget.prototype;
  28543. var instance = create(isObject(proto) ? proto : ObjectPrototype);
  28544. var result = apply(Target, instance, args);
  28545. return isObject(result) ? result : instance;
  28546. }
  28547. });
  28548. },{"../internals/a-constructor":259,"../internals/an-object":263,"../internals/export":318,"../internals/fails":319,"../internals/function-apply":321,"../internals/function-bind":324,"../internals/get-built-in":328,"../internals/is-object":352,"../internals/object-create":372}],482:[function(_dereq_,module,exports){
  28549. var $ = _dereq_('../internals/export');
  28550. var call = _dereq_('../internals/function-call');
  28551. var isObject = _dereq_('../internals/is-object');
  28552. var anObject = _dereq_('../internals/an-object');
  28553. var isDataDescriptor = _dereq_('../internals/is-data-descriptor');
  28554. var getOwnPropertyDescriptorModule = _dereq_('../internals/object-get-own-property-descriptor');
  28555. var getPrototypeOf = _dereq_('../internals/object-get-prototype-of');
  28556. // `Reflect.get` method
  28557. // https://tc39.es/ecma262/#sec-reflect.get
  28558. function get(target, propertyKey /* , receiver */) {
  28559. var receiver = arguments.length < 3 ? target : arguments[2];
  28560. var descriptor, prototype;
  28561. if (anObject(target) === receiver) return target[propertyKey];
  28562. descriptor = getOwnPropertyDescriptorModule.f(target, propertyKey);
  28563. if (descriptor) return isDataDescriptor(descriptor)
  28564. ? descriptor.value
  28565. : descriptor.get === undefined ? undefined : call(descriptor.get, receiver);
  28566. if (isObject(prototype = getPrototypeOf(target))) return get(prototype, propertyKey, receiver);
  28567. }
  28568. $({ target: 'Reflect', stat: true }, {
  28569. get: get
  28570. });
  28571. },{"../internals/an-object":263,"../internals/export":318,"../internals/function-call":325,"../internals/is-data-descriptor":348,"../internals/is-object":352,"../internals/object-get-own-property-descriptor":375,"../internals/object-get-prototype-of":379}],483:[function(_dereq_,module,exports){
  28572. arguments[4][455][0].apply(exports,arguments)
  28573. },{"dup":455}],484:[function(_dereq_,module,exports){
  28574. 'use strict';
  28575. var collection = _dereq_('../internals/collection');
  28576. var collectionStrong = _dereq_('../internals/collection-strong');
  28577. // `Set` constructor
  28578. // https://tc39.es/ecma262/#sec-set-objects
  28579. collection('Set', function (init) {
  28580. return function Set() { return init(this, arguments.length ? arguments[0] : undefined); };
  28581. }, collectionStrong);
  28582. },{"../internals/collection":287,"../internals/collection-strong":285}],485:[function(_dereq_,module,exports){
  28583. // TODO: Remove this module from `core-js@4` since it's replaced to module below
  28584. _dereq_('../modules/es.set.constructor');
  28585. },{"../modules/es.set.constructor":484}],486:[function(_dereq_,module,exports){
  28586. 'use strict';
  28587. var $ = _dereq_('../internals/export');
  28588. var uncurryThis = _dereq_('../internals/function-uncurry-this');
  28589. var notARegExp = _dereq_('../internals/not-a-regexp');
  28590. var requireObjectCoercible = _dereq_('../internals/require-object-coercible');
  28591. var toString = _dereq_('../internals/to-string');
  28592. var correctIsRegExpLogic = _dereq_('../internals/correct-is-regexp-logic');
  28593. var stringIndexOf = uncurryThis(''.indexOf);
  28594. // `String.prototype.includes` method
  28595. // https://tc39.es/ecma262/#sec-string.prototype.includes
  28596. $({ target: 'String', proto: true, forced: !correctIsRegExpLogic('includes') }, {
  28597. includes: function includes(searchString /* , position = 0 */) {
  28598. return !!~stringIndexOf(
  28599. toString(requireObjectCoercible(this)),
  28600. toString(notARegExp(searchString)),
  28601. arguments.length > 1 ? arguments[1] : undefined
  28602. );
  28603. }
  28604. });
  28605. },{"../internals/correct-is-regexp-logic":289,"../internals/export":318,"../internals/function-uncurry-this":327,"../internals/not-a-regexp":369,"../internals/require-object-coercible":397,"../internals/to-string":420}],487:[function(_dereq_,module,exports){
  28606. 'use strict';
  28607. var charAt = _dereq_('../internals/string-multibyte').charAt;
  28608. var toString = _dereq_('../internals/to-string');
  28609. var InternalStateModule = _dereq_('../internals/internal-state');
  28610. var defineIterator = _dereq_('../internals/iterator-define');
  28611. var createIterResultObject = _dereq_('../internals/create-iter-result-object');
  28612. var STRING_ITERATOR = 'String Iterator';
  28613. var setInternalState = InternalStateModule.set;
  28614. var getInternalState = InternalStateModule.getterFor(STRING_ITERATOR);
  28615. // `String.prototype[@@iterator]` method
  28616. // https://tc39.es/ecma262/#sec-string.prototype-@@iterator
  28617. defineIterator(String, 'String', function (iterated) {
  28618. setInternalState(this, {
  28619. type: STRING_ITERATOR,
  28620. string: toString(iterated),
  28621. index: 0
  28622. });
  28623. // `%StringIteratorPrototype%.next` method
  28624. // https://tc39.es/ecma262/#sec-%stringiteratorprototype%.next
  28625. }, function next() {
  28626. var state = getInternalState(this);
  28627. var string = state.string;
  28628. var index = state.index;
  28629. var point;
  28630. if (index >= string.length) return createIterResultObject(undefined, true);
  28631. point = charAt(string, index);
  28632. state.index += point.length;
  28633. return createIterResultObject(point, false);
  28634. });
  28635. },{"../internals/create-iter-result-object":291,"../internals/internal-state":343,"../internals/iterator-define":359,"../internals/string-multibyte":406,"../internals/to-string":420}],488:[function(_dereq_,module,exports){
  28636. 'use strict';
  28637. var $ = _dereq_('../internals/export');
  28638. var uncurryThis = _dereq_('../internals/function-uncurry-this');
  28639. var getOwnPropertyDescriptor = _dereq_('../internals/object-get-own-property-descriptor').f;
  28640. var toLength = _dereq_('../internals/to-length');
  28641. var toString = _dereq_('../internals/to-string');
  28642. var notARegExp = _dereq_('../internals/not-a-regexp');
  28643. var requireObjectCoercible = _dereq_('../internals/require-object-coercible');
  28644. var correctIsRegExpLogic = _dereq_('../internals/correct-is-regexp-logic');
  28645. var IS_PURE = _dereq_('../internals/is-pure');
  28646. // eslint-disable-next-line es-x/no-string-prototype-startswith -- safe
  28647. var nativeStartsWith = uncurryThis(''.startsWith);
  28648. var stringSlice = uncurryThis(''.slice);
  28649. var min = Math.min;
  28650. var CORRECT_IS_REGEXP_LOGIC = correctIsRegExpLogic('startsWith');
  28651. // https://github.com/zloirock/core-js/pull/702
  28652. var MDN_POLYFILL_BUG = !IS_PURE && !CORRECT_IS_REGEXP_LOGIC && !!function () {
  28653. var descriptor = getOwnPropertyDescriptor(String.prototype, 'startsWith');
  28654. return descriptor && !descriptor.writable;
  28655. }();
  28656. // `String.prototype.startsWith` method
  28657. // https://tc39.es/ecma262/#sec-string.prototype.startswith
  28658. $({ target: 'String', proto: true, forced: !MDN_POLYFILL_BUG && !CORRECT_IS_REGEXP_LOGIC }, {
  28659. startsWith: function startsWith(searchString /* , position = 0 */) {
  28660. var that = toString(requireObjectCoercible(this));
  28661. notARegExp(searchString);
  28662. var index = toLength(min(arguments.length > 1 ? arguments[1] : undefined, that.length));
  28663. var search = toString(searchString);
  28664. return nativeStartsWith
  28665. ? nativeStartsWith(that, search, index)
  28666. : stringSlice(that, index, index + search.length) === search;
  28667. }
  28668. });
  28669. },{"../internals/correct-is-regexp-logic":289,"../internals/export":318,"../internals/function-uncurry-this":327,"../internals/is-pure":353,"../internals/not-a-regexp":369,"../internals/object-get-own-property-descriptor":375,"../internals/require-object-coercible":397,"../internals/to-length":415,"../internals/to-string":420}],489:[function(_dereq_,module,exports){
  28670. var defineWellKnownSymbol = _dereq_('../internals/well-known-symbol-define');
  28671. // `Symbol.asyncIterator` well-known symbol
  28672. // https://tc39.es/ecma262/#sec-symbol.asynciterator
  28673. defineWellKnownSymbol('asyncIterator');
  28674. },{"../internals/well-known-symbol-define":427}],490:[function(_dereq_,module,exports){
  28675. 'use strict';
  28676. var $ = _dereq_('../internals/export');
  28677. var global = _dereq_('../internals/global');
  28678. var call = _dereq_('../internals/function-call');
  28679. var uncurryThis = _dereq_('../internals/function-uncurry-this');
  28680. var IS_PURE = _dereq_('../internals/is-pure');
  28681. var DESCRIPTORS = _dereq_('../internals/descriptors');
  28682. var NATIVE_SYMBOL = _dereq_('../internals/symbol-constructor-detection');
  28683. var fails = _dereq_('../internals/fails');
  28684. var hasOwn = _dereq_('../internals/has-own-property');
  28685. var isPrototypeOf = _dereq_('../internals/object-is-prototype-of');
  28686. var anObject = _dereq_('../internals/an-object');
  28687. var toIndexedObject = _dereq_('../internals/to-indexed-object');
  28688. var toPropertyKey = _dereq_('../internals/to-property-key');
  28689. var $toString = _dereq_('../internals/to-string');
  28690. var createPropertyDescriptor = _dereq_('../internals/create-property-descriptor');
  28691. var nativeObjectCreate = _dereq_('../internals/object-create');
  28692. var objectKeys = _dereq_('../internals/object-keys');
  28693. var getOwnPropertyNamesModule = _dereq_('../internals/object-get-own-property-names');
  28694. var getOwnPropertyNamesExternal = _dereq_('../internals/object-get-own-property-names-external');
  28695. var getOwnPropertySymbolsModule = _dereq_('../internals/object-get-own-property-symbols');
  28696. var getOwnPropertyDescriptorModule = _dereq_('../internals/object-get-own-property-descriptor');
  28697. var definePropertyModule = _dereq_('../internals/object-define-property');
  28698. var definePropertiesModule = _dereq_('../internals/object-define-properties');
  28699. var propertyIsEnumerableModule = _dereq_('../internals/object-property-is-enumerable');
  28700. var defineBuiltIn = _dereq_('../internals/define-built-in');
  28701. var shared = _dereq_('../internals/shared');
  28702. var sharedKey = _dereq_('../internals/shared-key');
  28703. var hiddenKeys = _dereq_('../internals/hidden-keys');
  28704. var uid = _dereq_('../internals/uid');
  28705. var wellKnownSymbol = _dereq_('../internals/well-known-symbol');
  28706. var wrappedWellKnownSymbolModule = _dereq_('../internals/well-known-symbol-wrapped');
  28707. var defineWellKnownSymbol = _dereq_('../internals/well-known-symbol-define');
  28708. var defineSymbolToPrimitive = _dereq_('../internals/symbol-define-to-primitive');
  28709. var setToStringTag = _dereq_('../internals/set-to-string-tag');
  28710. var InternalStateModule = _dereq_('../internals/internal-state');
  28711. var $forEach = _dereq_('../internals/array-iteration').forEach;
  28712. var HIDDEN = sharedKey('hidden');
  28713. var SYMBOL = 'Symbol';
  28714. var PROTOTYPE = 'prototype';
  28715. var setInternalState = InternalStateModule.set;
  28716. var getInternalState = InternalStateModule.getterFor(SYMBOL);
  28717. var ObjectPrototype = Object[PROTOTYPE];
  28718. var $Symbol = global.Symbol;
  28719. var SymbolPrototype = $Symbol && $Symbol[PROTOTYPE];
  28720. var TypeError = global.TypeError;
  28721. var QObject = global.QObject;
  28722. var nativeGetOwnPropertyDescriptor = getOwnPropertyDescriptorModule.f;
  28723. var nativeDefineProperty = definePropertyModule.f;
  28724. var nativeGetOwnPropertyNames = getOwnPropertyNamesExternal.f;
  28725. var nativePropertyIsEnumerable = propertyIsEnumerableModule.f;
  28726. var push = uncurryThis([].push);
  28727. var AllSymbols = shared('symbols');
  28728. var ObjectPrototypeSymbols = shared('op-symbols');
  28729. var WellKnownSymbolsStore = shared('wks');
  28730. // Don't use setters in Qt Script, https://github.com/zloirock/core-js/issues/173
  28731. var USE_SETTER = !QObject || !QObject[PROTOTYPE] || !QObject[PROTOTYPE].findChild;
  28732. // fallback for old Android, https://code.google.com/p/v8/issues/detail?id=687
  28733. var setSymbolDescriptor = DESCRIPTORS && fails(function () {
  28734. return nativeObjectCreate(nativeDefineProperty({}, 'a', {
  28735. get: function () { return nativeDefineProperty(this, 'a', { value: 7 }).a; }
  28736. })).a != 7;
  28737. }) ? function (O, P, Attributes) {
  28738. var ObjectPrototypeDescriptor = nativeGetOwnPropertyDescriptor(ObjectPrototype, P);
  28739. if (ObjectPrototypeDescriptor) delete ObjectPrototype[P];
  28740. nativeDefineProperty(O, P, Attributes);
  28741. if (ObjectPrototypeDescriptor && O !== ObjectPrototype) {
  28742. nativeDefineProperty(ObjectPrototype, P, ObjectPrototypeDescriptor);
  28743. }
  28744. } : nativeDefineProperty;
  28745. var wrap = function (tag, description) {
  28746. var symbol = AllSymbols[tag] = nativeObjectCreate(SymbolPrototype);
  28747. setInternalState(symbol, {
  28748. type: SYMBOL,
  28749. tag: tag,
  28750. description: description
  28751. });
  28752. if (!DESCRIPTORS) symbol.description = description;
  28753. return symbol;
  28754. };
  28755. var $defineProperty = function defineProperty(O, P, Attributes) {
  28756. if (O === ObjectPrototype) $defineProperty(ObjectPrototypeSymbols, P, Attributes);
  28757. anObject(O);
  28758. var key = toPropertyKey(P);
  28759. anObject(Attributes);
  28760. if (hasOwn(AllSymbols, key)) {
  28761. if (!Attributes.enumerable) {
  28762. if (!hasOwn(O, HIDDEN)) nativeDefineProperty(O, HIDDEN, createPropertyDescriptor(1, {}));
  28763. O[HIDDEN][key] = true;
  28764. } else {
  28765. if (hasOwn(O, HIDDEN) && O[HIDDEN][key]) O[HIDDEN][key] = false;
  28766. Attributes = nativeObjectCreate(Attributes, { enumerable: createPropertyDescriptor(0, false) });
  28767. } return setSymbolDescriptor(O, key, Attributes);
  28768. } return nativeDefineProperty(O, key, Attributes);
  28769. };
  28770. var $defineProperties = function defineProperties(O, Properties) {
  28771. anObject(O);
  28772. var properties = toIndexedObject(Properties);
  28773. var keys = objectKeys(properties).concat($getOwnPropertySymbols(properties));
  28774. $forEach(keys, function (key) {
  28775. if (!DESCRIPTORS || call($propertyIsEnumerable, properties, key)) $defineProperty(O, key, properties[key]);
  28776. });
  28777. return O;
  28778. };
  28779. var $create = function create(O, Properties) {
  28780. return Properties === undefined ? nativeObjectCreate(O) : $defineProperties(nativeObjectCreate(O), Properties);
  28781. };
  28782. var $propertyIsEnumerable = function propertyIsEnumerable(V) {
  28783. var P = toPropertyKey(V);
  28784. var enumerable = call(nativePropertyIsEnumerable, this, P);
  28785. if (this === ObjectPrototype && hasOwn(AllSymbols, P) && !hasOwn(ObjectPrototypeSymbols, P)) return false;
  28786. return enumerable || !hasOwn(this, P) || !hasOwn(AllSymbols, P) || hasOwn(this, HIDDEN) && this[HIDDEN][P]
  28787. ? enumerable : true;
  28788. };
  28789. var $getOwnPropertyDescriptor = function getOwnPropertyDescriptor(O, P) {
  28790. var it = toIndexedObject(O);
  28791. var key = toPropertyKey(P);
  28792. if (it === ObjectPrototype && hasOwn(AllSymbols, key) && !hasOwn(ObjectPrototypeSymbols, key)) return;
  28793. var descriptor = nativeGetOwnPropertyDescriptor(it, key);
  28794. if (descriptor && hasOwn(AllSymbols, key) && !(hasOwn(it, HIDDEN) && it[HIDDEN][key])) {
  28795. descriptor.enumerable = true;
  28796. }
  28797. return descriptor;
  28798. };
  28799. var $getOwnPropertyNames = function getOwnPropertyNames(O) {
  28800. var names = nativeGetOwnPropertyNames(toIndexedObject(O));
  28801. var result = [];
  28802. $forEach(names, function (key) {
  28803. if (!hasOwn(AllSymbols, key) && !hasOwn(hiddenKeys, key)) push(result, key);
  28804. });
  28805. return result;
  28806. };
  28807. var $getOwnPropertySymbols = function (O) {
  28808. var IS_OBJECT_PROTOTYPE = O === ObjectPrototype;
  28809. var names = nativeGetOwnPropertyNames(IS_OBJECT_PROTOTYPE ? ObjectPrototypeSymbols : toIndexedObject(O));
  28810. var result = [];
  28811. $forEach(names, function (key) {
  28812. if (hasOwn(AllSymbols, key) && (!IS_OBJECT_PROTOTYPE || hasOwn(ObjectPrototype, key))) {
  28813. push(result, AllSymbols[key]);
  28814. }
  28815. });
  28816. return result;
  28817. };
  28818. // `Symbol` constructor
  28819. // https://tc39.es/ecma262/#sec-symbol-constructor
  28820. if (!NATIVE_SYMBOL) {
  28821. $Symbol = function Symbol() {
  28822. if (isPrototypeOf(SymbolPrototype, this)) throw TypeError('Symbol is not a constructor');
  28823. var description = !arguments.length || arguments[0] === undefined ? undefined : $toString(arguments[0]);
  28824. var tag = uid(description);
  28825. var setter = function (value) {
  28826. if (this === ObjectPrototype) call(setter, ObjectPrototypeSymbols, value);
  28827. if (hasOwn(this, HIDDEN) && hasOwn(this[HIDDEN], tag)) this[HIDDEN][tag] = false;
  28828. setSymbolDescriptor(this, tag, createPropertyDescriptor(1, value));
  28829. };
  28830. if (DESCRIPTORS && USE_SETTER) setSymbolDescriptor(ObjectPrototype, tag, { configurable: true, set: setter });
  28831. return wrap(tag, description);
  28832. };
  28833. SymbolPrototype = $Symbol[PROTOTYPE];
  28834. defineBuiltIn(SymbolPrototype, 'toString', function toString() {
  28835. return getInternalState(this).tag;
  28836. });
  28837. defineBuiltIn($Symbol, 'withoutSetter', function (description) {
  28838. return wrap(uid(description), description);
  28839. });
  28840. propertyIsEnumerableModule.f = $propertyIsEnumerable;
  28841. definePropertyModule.f = $defineProperty;
  28842. definePropertiesModule.f = $defineProperties;
  28843. getOwnPropertyDescriptorModule.f = $getOwnPropertyDescriptor;
  28844. getOwnPropertyNamesModule.f = getOwnPropertyNamesExternal.f = $getOwnPropertyNames;
  28845. getOwnPropertySymbolsModule.f = $getOwnPropertySymbols;
  28846. wrappedWellKnownSymbolModule.f = function (name) {
  28847. return wrap(wellKnownSymbol(name), name);
  28848. };
  28849. if (DESCRIPTORS) {
  28850. // https://github.com/tc39/proposal-Symbol-description
  28851. nativeDefineProperty(SymbolPrototype, 'description', {
  28852. configurable: true,
  28853. get: function description() {
  28854. return getInternalState(this).description;
  28855. }
  28856. });
  28857. if (!IS_PURE) {
  28858. defineBuiltIn(ObjectPrototype, 'propertyIsEnumerable', $propertyIsEnumerable, { unsafe: true });
  28859. }
  28860. }
  28861. }
  28862. $({ global: true, constructor: true, wrap: true, forced: !NATIVE_SYMBOL, sham: !NATIVE_SYMBOL }, {
  28863. Symbol: $Symbol
  28864. });
  28865. $forEach(objectKeys(WellKnownSymbolsStore), function (name) {
  28866. defineWellKnownSymbol(name);
  28867. });
  28868. $({ target: SYMBOL, stat: true, forced: !NATIVE_SYMBOL }, {
  28869. useSetter: function () { USE_SETTER = true; },
  28870. useSimple: function () { USE_SETTER = false; }
  28871. });
  28872. $({ target: 'Object', stat: true, forced: !NATIVE_SYMBOL, sham: !DESCRIPTORS }, {
  28873. // `Object.create` method
  28874. // https://tc39.es/ecma262/#sec-object.create
  28875. create: $create,
  28876. // `Object.defineProperty` method
  28877. // https://tc39.es/ecma262/#sec-object.defineproperty
  28878. defineProperty: $defineProperty,
  28879. // `Object.defineProperties` method
  28880. // https://tc39.es/ecma262/#sec-object.defineproperties
  28881. defineProperties: $defineProperties,
  28882. // `Object.getOwnPropertyDescriptor` method
  28883. // https://tc39.es/ecma262/#sec-object.getownpropertydescriptors
  28884. getOwnPropertyDescriptor: $getOwnPropertyDescriptor
  28885. });
  28886. $({ target: 'Object', stat: true, forced: !NATIVE_SYMBOL }, {
  28887. // `Object.getOwnPropertyNames` method
  28888. // https://tc39.es/ecma262/#sec-object.getownpropertynames
  28889. getOwnPropertyNames: $getOwnPropertyNames
  28890. });
  28891. // `Symbol.prototype[@@toPrimitive]` method
  28892. // https://tc39.es/ecma262/#sec-symbol.prototype-@@toprimitive
  28893. defineSymbolToPrimitive();
  28894. // `Symbol.prototype[@@toStringTag]` property
  28895. // https://tc39.es/ecma262/#sec-symbol.prototype-@@tostringtag
  28896. setToStringTag($Symbol, SYMBOL);
  28897. hiddenKeys[HIDDEN] = true;
  28898. },{"../internals/an-object":263,"../internals/array-iteration":268,"../internals/create-property-descriptor":293,"../internals/define-built-in":295,"../internals/descriptors":299,"../internals/export":318,"../internals/fails":319,"../internals/function-call":325,"../internals/function-uncurry-this":327,"../internals/global":333,"../internals/has-own-property":334,"../internals/hidden-keys":335,"../internals/internal-state":343,"../internals/is-pure":353,"../internals/object-create":372,"../internals/object-define-properties":373,"../internals/object-define-property":374,"../internals/object-get-own-property-descriptor":375,"../internals/object-get-own-property-names":377,"../internals/object-get-own-property-names-external":376,"../internals/object-get-own-property-symbols":378,"../internals/object-is-prototype-of":381,"../internals/object-keys":383,"../internals/object-property-is-enumerable":384,"../internals/set-to-string-tag":401,"../internals/shared":404,"../internals/shared-key":402,"../internals/symbol-constructor-detection":408,"../internals/symbol-define-to-primitive":409,"../internals/to-indexed-object":413,"../internals/to-property-key":418,"../internals/to-string":420,"../internals/uid":422,"../internals/well-known-symbol":429,"../internals/well-known-symbol-define":427,"../internals/well-known-symbol-wrapped":428}],491:[function(_dereq_,module,exports){
  28899. arguments[4][455][0].apply(exports,arguments)
  28900. },{"dup":455}],492:[function(_dereq_,module,exports){
  28901. var $ = _dereq_('../internals/export');
  28902. var getBuiltIn = _dereq_('../internals/get-built-in');
  28903. var hasOwn = _dereq_('../internals/has-own-property');
  28904. var toString = _dereq_('../internals/to-string');
  28905. var shared = _dereq_('../internals/shared');
  28906. var NATIVE_SYMBOL_REGISTRY = _dereq_('../internals/symbol-registry-detection');
  28907. var StringToSymbolRegistry = shared('string-to-symbol-registry');
  28908. var SymbolToStringRegistry = shared('symbol-to-string-registry');
  28909. // `Symbol.for` method
  28910. // https://tc39.es/ecma262/#sec-symbol.for
  28911. $({ target: 'Symbol', stat: true, forced: !NATIVE_SYMBOL_REGISTRY }, {
  28912. 'for': function (key) {
  28913. var string = toString(key);
  28914. if (hasOwn(StringToSymbolRegistry, string)) return StringToSymbolRegistry[string];
  28915. var symbol = getBuiltIn('Symbol')(string);
  28916. StringToSymbolRegistry[string] = symbol;
  28917. SymbolToStringRegistry[symbol] = string;
  28918. return symbol;
  28919. }
  28920. });
  28921. },{"../internals/export":318,"../internals/get-built-in":328,"../internals/has-own-property":334,"../internals/shared":404,"../internals/symbol-registry-detection":410,"../internals/to-string":420}],493:[function(_dereq_,module,exports){
  28922. var defineWellKnownSymbol = _dereq_('../internals/well-known-symbol-define');
  28923. // `Symbol.hasInstance` well-known symbol
  28924. // https://tc39.es/ecma262/#sec-symbol.hasinstance
  28925. defineWellKnownSymbol('hasInstance');
  28926. },{"../internals/well-known-symbol-define":427}],494:[function(_dereq_,module,exports){
  28927. var defineWellKnownSymbol = _dereq_('../internals/well-known-symbol-define');
  28928. // `Symbol.isConcatSpreadable` well-known symbol
  28929. // https://tc39.es/ecma262/#sec-symbol.isconcatspreadable
  28930. defineWellKnownSymbol('isConcatSpreadable');
  28931. },{"../internals/well-known-symbol-define":427}],495:[function(_dereq_,module,exports){
  28932. var defineWellKnownSymbol = _dereq_('../internals/well-known-symbol-define');
  28933. // `Symbol.iterator` well-known symbol
  28934. // https://tc39.es/ecma262/#sec-symbol.iterator
  28935. defineWellKnownSymbol('iterator');
  28936. },{"../internals/well-known-symbol-define":427}],496:[function(_dereq_,module,exports){
  28937. // TODO: Remove this module from `core-js@4` since it's split to modules listed below
  28938. _dereq_('../modules/es.symbol.constructor');
  28939. _dereq_('../modules/es.symbol.for');
  28940. _dereq_('../modules/es.symbol.key-for');
  28941. _dereq_('../modules/es.json.stringify');
  28942. _dereq_('../modules/es.object.get-own-property-symbols');
  28943. },{"../modules/es.json.stringify":451,"../modules/es.object.get-own-property-symbols":465,"../modules/es.symbol.constructor":490,"../modules/es.symbol.for":492,"../modules/es.symbol.key-for":497}],497:[function(_dereq_,module,exports){
  28944. var $ = _dereq_('../internals/export');
  28945. var hasOwn = _dereq_('../internals/has-own-property');
  28946. var isSymbol = _dereq_('../internals/is-symbol');
  28947. var tryToString = _dereq_('../internals/try-to-string');
  28948. var shared = _dereq_('../internals/shared');
  28949. var NATIVE_SYMBOL_REGISTRY = _dereq_('../internals/symbol-registry-detection');
  28950. var SymbolToStringRegistry = shared('symbol-to-string-registry');
  28951. // `Symbol.keyFor` method
  28952. // https://tc39.es/ecma262/#sec-symbol.keyfor
  28953. $({ target: 'Symbol', stat: true, forced: !NATIVE_SYMBOL_REGISTRY }, {
  28954. keyFor: function keyFor(sym) {
  28955. if (!isSymbol(sym)) throw TypeError(tryToString(sym) + ' is not a symbol');
  28956. if (hasOwn(SymbolToStringRegistry, sym)) return SymbolToStringRegistry[sym];
  28957. }
  28958. });
  28959. },{"../internals/export":318,"../internals/has-own-property":334,"../internals/is-symbol":355,"../internals/shared":404,"../internals/symbol-registry-detection":410,"../internals/try-to-string":421}],498:[function(_dereq_,module,exports){
  28960. var defineWellKnownSymbol = _dereq_('../internals/well-known-symbol-define');
  28961. // `Symbol.matchAll` well-known symbol
  28962. // https://tc39.es/ecma262/#sec-symbol.matchall
  28963. defineWellKnownSymbol('matchAll');
  28964. },{"../internals/well-known-symbol-define":427}],499:[function(_dereq_,module,exports){
  28965. var defineWellKnownSymbol = _dereq_('../internals/well-known-symbol-define');
  28966. // `Symbol.match` well-known symbol
  28967. // https://tc39.es/ecma262/#sec-symbol.match
  28968. defineWellKnownSymbol('match');
  28969. },{"../internals/well-known-symbol-define":427}],500:[function(_dereq_,module,exports){
  28970. var defineWellKnownSymbol = _dereq_('../internals/well-known-symbol-define');
  28971. // `Symbol.replace` well-known symbol
  28972. // https://tc39.es/ecma262/#sec-symbol.replace
  28973. defineWellKnownSymbol('replace');
  28974. },{"../internals/well-known-symbol-define":427}],501:[function(_dereq_,module,exports){
  28975. var defineWellKnownSymbol = _dereq_('../internals/well-known-symbol-define');
  28976. // `Symbol.search` well-known symbol
  28977. // https://tc39.es/ecma262/#sec-symbol.search
  28978. defineWellKnownSymbol('search');
  28979. },{"../internals/well-known-symbol-define":427}],502:[function(_dereq_,module,exports){
  28980. var defineWellKnownSymbol = _dereq_('../internals/well-known-symbol-define');
  28981. // `Symbol.species` well-known symbol
  28982. // https://tc39.es/ecma262/#sec-symbol.species
  28983. defineWellKnownSymbol('species');
  28984. },{"../internals/well-known-symbol-define":427}],503:[function(_dereq_,module,exports){
  28985. var defineWellKnownSymbol = _dereq_('../internals/well-known-symbol-define');
  28986. // `Symbol.split` well-known symbol
  28987. // https://tc39.es/ecma262/#sec-symbol.split
  28988. defineWellKnownSymbol('split');
  28989. },{"../internals/well-known-symbol-define":427}],504:[function(_dereq_,module,exports){
  28990. var defineWellKnownSymbol = _dereq_('../internals/well-known-symbol-define');
  28991. var defineSymbolToPrimitive = _dereq_('../internals/symbol-define-to-primitive');
  28992. // `Symbol.toPrimitive` well-known symbol
  28993. // https://tc39.es/ecma262/#sec-symbol.toprimitive
  28994. defineWellKnownSymbol('toPrimitive');
  28995. // `Symbol.prototype[@@toPrimitive]` method
  28996. // https://tc39.es/ecma262/#sec-symbol.prototype-@@toprimitive
  28997. defineSymbolToPrimitive();
  28998. },{"../internals/symbol-define-to-primitive":409,"../internals/well-known-symbol-define":427}],505:[function(_dereq_,module,exports){
  28999. var getBuiltIn = _dereq_('../internals/get-built-in');
  29000. var defineWellKnownSymbol = _dereq_('../internals/well-known-symbol-define');
  29001. var setToStringTag = _dereq_('../internals/set-to-string-tag');
  29002. // `Symbol.toStringTag` well-known symbol
  29003. // https://tc39.es/ecma262/#sec-symbol.tostringtag
  29004. defineWellKnownSymbol('toStringTag');
  29005. // `Symbol.prototype[@@toStringTag]` property
  29006. // https://tc39.es/ecma262/#sec-symbol.prototype-@@tostringtag
  29007. setToStringTag(getBuiltIn('Symbol'), 'Symbol');
  29008. },{"../internals/get-built-in":328,"../internals/set-to-string-tag":401,"../internals/well-known-symbol-define":427}],506:[function(_dereq_,module,exports){
  29009. var defineWellKnownSymbol = _dereq_('../internals/well-known-symbol-define');
  29010. // `Symbol.unscopables` well-known symbol
  29011. // https://tc39.es/ecma262/#sec-symbol.unscopables
  29012. defineWellKnownSymbol('unscopables');
  29013. },{"../internals/well-known-symbol-define":427}],507:[function(_dereq_,module,exports){
  29014. 'use strict';
  29015. var global = _dereq_('../internals/global');
  29016. var uncurryThis = _dereq_('../internals/function-uncurry-this');
  29017. var defineBuiltIns = _dereq_('../internals/define-built-ins');
  29018. var InternalMetadataModule = _dereq_('../internals/internal-metadata');
  29019. var collection = _dereq_('../internals/collection');
  29020. var collectionWeak = _dereq_('../internals/collection-weak');
  29021. var isObject = _dereq_('../internals/is-object');
  29022. var isExtensible = _dereq_('../internals/object-is-extensible');
  29023. var enforceInternalState = _dereq_('../internals/internal-state').enforce;
  29024. var NATIVE_WEAK_MAP = _dereq_('../internals/weak-map-basic-detection');
  29025. var IS_IE11 = !global.ActiveXObject && 'ActiveXObject' in global;
  29026. var InternalWeakMap;
  29027. var wrapper = function (init) {
  29028. return function WeakMap() {
  29029. return init(this, arguments.length ? arguments[0] : undefined);
  29030. };
  29031. };
  29032. // `WeakMap` constructor
  29033. // https://tc39.es/ecma262/#sec-weakmap-constructor
  29034. var $WeakMap = collection('WeakMap', wrapper, collectionWeak);
  29035. // IE11 WeakMap frozen keys fix
  29036. // We can't use feature detection because it crash some old IE builds
  29037. // https://github.com/zloirock/core-js/issues/485
  29038. if (NATIVE_WEAK_MAP && IS_IE11) {
  29039. InternalWeakMap = collectionWeak.getConstructor(wrapper, 'WeakMap', true);
  29040. InternalMetadataModule.enable();
  29041. var WeakMapPrototype = $WeakMap.prototype;
  29042. var nativeDelete = uncurryThis(WeakMapPrototype['delete']);
  29043. var nativeHas = uncurryThis(WeakMapPrototype.has);
  29044. var nativeGet = uncurryThis(WeakMapPrototype.get);
  29045. var nativeSet = uncurryThis(WeakMapPrototype.set);
  29046. defineBuiltIns(WeakMapPrototype, {
  29047. 'delete': function (key) {
  29048. if (isObject(key) && !isExtensible(key)) {
  29049. var state = enforceInternalState(this);
  29050. if (!state.frozen) state.frozen = new InternalWeakMap();
  29051. return nativeDelete(this, key) || state.frozen['delete'](key);
  29052. } return nativeDelete(this, key);
  29053. },
  29054. has: function has(key) {
  29055. if (isObject(key) && !isExtensible(key)) {
  29056. var state = enforceInternalState(this);
  29057. if (!state.frozen) state.frozen = new InternalWeakMap();
  29058. return nativeHas(this, key) || state.frozen.has(key);
  29059. } return nativeHas(this, key);
  29060. },
  29061. get: function get(key) {
  29062. if (isObject(key) && !isExtensible(key)) {
  29063. var state = enforceInternalState(this);
  29064. if (!state.frozen) state.frozen = new InternalWeakMap();
  29065. return nativeHas(this, key) ? nativeGet(this, key) : state.frozen.get(key);
  29066. } return nativeGet(this, key);
  29067. },
  29068. set: function set(key, value) {
  29069. if (isObject(key) && !isExtensible(key)) {
  29070. var state = enforceInternalState(this);
  29071. if (!state.frozen) state.frozen = new InternalWeakMap();
  29072. nativeHas(this, key) ? nativeSet(this, key, value) : state.frozen.set(key, value);
  29073. } else nativeSet(this, key, value);
  29074. return this;
  29075. }
  29076. });
  29077. }
  29078. },{"../internals/collection":287,"../internals/collection-weak":286,"../internals/define-built-ins":296,"../internals/function-uncurry-this":327,"../internals/global":333,"../internals/internal-metadata":342,"../internals/internal-state":343,"../internals/is-object":352,"../internals/object-is-extensible":380,"../internals/weak-map-basic-detection":426}],508:[function(_dereq_,module,exports){
  29079. // TODO: Remove this module from `core-js@4` since it's replaced to module below
  29080. _dereq_('../modules/es.weak-map.constructor');
  29081. },{"../modules/es.weak-map.constructor":507}],509:[function(_dereq_,module,exports){
  29082. // TODO: Remove from `core-js@4`
  29083. _dereq_('../modules/es.aggregate-error');
  29084. },{"../modules/es.aggregate-error":432}],510:[function(_dereq_,module,exports){
  29085. 'use strict';
  29086. var $ = _dereq_('../internals/export');
  29087. var deleteAll = _dereq_('../internals/collection-delete-all');
  29088. // `Map.prototype.deleteAll` method
  29089. // https://github.com/tc39/proposal-collection-methods
  29090. $({ target: 'Map', proto: true, real: true, forced: true }, {
  29091. deleteAll: deleteAll
  29092. });
  29093. },{"../internals/collection-delete-all":282,"../internals/export":318}],511:[function(_dereq_,module,exports){
  29094. 'use strict';
  29095. var $ = _dereq_('../internals/export');
  29096. var emplace = _dereq_('../internals/map-emplace');
  29097. // `Map.prototype.emplace` method
  29098. // https://github.com/thumbsupep/proposal-upsert
  29099. $({ target: 'Map', proto: true, real: true, forced: true }, {
  29100. emplace: emplace
  29101. });
  29102. },{"../internals/export":318,"../internals/map-emplace":363}],512:[function(_dereq_,module,exports){
  29103. 'use strict';
  29104. var $ = _dereq_('../internals/export');
  29105. var anObject = _dereq_('../internals/an-object');
  29106. var bind = _dereq_('../internals/function-bind-context');
  29107. var getMapIterator = _dereq_('../internals/get-map-iterator');
  29108. var iterate = _dereq_('../internals/iterate');
  29109. // `Map.prototype.every` method
  29110. // https://github.com/tc39/proposal-collection-methods
  29111. $({ target: 'Map', proto: true, real: true, forced: true }, {
  29112. every: function every(callbackfn /* , thisArg */) {
  29113. var map = anObject(this);
  29114. var iterator = getMapIterator(map);
  29115. var boundFunction = bind(callbackfn, arguments.length > 1 ? arguments[1] : undefined);
  29116. return !iterate(iterator, function (key, value, stop) {
  29117. if (!boundFunction(value, key, map)) return stop();
  29118. }, { AS_ENTRIES: true, IS_ITERATOR: true, INTERRUPTED: true }).stopped;
  29119. }
  29120. });
  29121. },{"../internals/an-object":263,"../internals/export":318,"../internals/function-bind-context":322,"../internals/get-map-iterator":331,"../internals/iterate":356}],513:[function(_dereq_,module,exports){
  29122. 'use strict';
  29123. var $ = _dereq_('../internals/export');
  29124. var getBuiltIn = _dereq_('../internals/get-built-in');
  29125. var bind = _dereq_('../internals/function-bind-context');
  29126. var call = _dereq_('../internals/function-call');
  29127. var aCallable = _dereq_('../internals/a-callable');
  29128. var anObject = _dereq_('../internals/an-object');
  29129. var speciesConstructor = _dereq_('../internals/species-constructor');
  29130. var getMapIterator = _dereq_('../internals/get-map-iterator');
  29131. var iterate = _dereq_('../internals/iterate');
  29132. // `Map.prototype.filter` method
  29133. // https://github.com/tc39/proposal-collection-methods
  29134. $({ target: 'Map', proto: true, real: true, forced: true }, {
  29135. filter: function filter(callbackfn /* , thisArg */) {
  29136. var map = anObject(this);
  29137. var iterator = getMapIterator(map);
  29138. var boundFunction = bind(callbackfn, arguments.length > 1 ? arguments[1] : undefined);
  29139. var newMap = new (speciesConstructor(map, getBuiltIn('Map')))();
  29140. var setter = aCallable(newMap.set);
  29141. iterate(iterator, function (key, value) {
  29142. if (boundFunction(value, key, map)) call(setter, newMap, key, value);
  29143. }, { AS_ENTRIES: true, IS_ITERATOR: true });
  29144. return newMap;
  29145. }
  29146. });
  29147. },{"../internals/a-callable":258,"../internals/an-object":263,"../internals/export":318,"../internals/function-bind-context":322,"../internals/function-call":325,"../internals/get-built-in":328,"../internals/get-map-iterator":331,"../internals/iterate":356,"../internals/species-constructor":405}],514:[function(_dereq_,module,exports){
  29148. 'use strict';
  29149. var $ = _dereq_('../internals/export');
  29150. var anObject = _dereq_('../internals/an-object');
  29151. var bind = _dereq_('../internals/function-bind-context');
  29152. var getMapIterator = _dereq_('../internals/get-map-iterator');
  29153. var iterate = _dereq_('../internals/iterate');
  29154. // `Map.prototype.findKey` method
  29155. // https://github.com/tc39/proposal-collection-methods
  29156. $({ target: 'Map', proto: true, real: true, forced: true }, {
  29157. findKey: function findKey(callbackfn /* , thisArg */) {
  29158. var map = anObject(this);
  29159. var iterator = getMapIterator(map);
  29160. var boundFunction = bind(callbackfn, arguments.length > 1 ? arguments[1] : undefined);
  29161. return iterate(iterator, function (key, value, stop) {
  29162. if (boundFunction(value, key, map)) return stop(key);
  29163. }, { AS_ENTRIES: true, IS_ITERATOR: true, INTERRUPTED: true }).result;
  29164. }
  29165. });
  29166. },{"../internals/an-object":263,"../internals/export":318,"../internals/function-bind-context":322,"../internals/get-map-iterator":331,"../internals/iterate":356}],515:[function(_dereq_,module,exports){
  29167. 'use strict';
  29168. var $ = _dereq_('../internals/export');
  29169. var anObject = _dereq_('../internals/an-object');
  29170. var bind = _dereq_('../internals/function-bind-context');
  29171. var getMapIterator = _dereq_('../internals/get-map-iterator');
  29172. var iterate = _dereq_('../internals/iterate');
  29173. // `Map.prototype.find` method
  29174. // https://github.com/tc39/proposal-collection-methods
  29175. $({ target: 'Map', proto: true, real: true, forced: true }, {
  29176. find: function find(callbackfn /* , thisArg */) {
  29177. var map = anObject(this);
  29178. var iterator = getMapIterator(map);
  29179. var boundFunction = bind(callbackfn, arguments.length > 1 ? arguments[1] : undefined);
  29180. return iterate(iterator, function (key, value, stop) {
  29181. if (boundFunction(value, key, map)) return stop(value);
  29182. }, { AS_ENTRIES: true, IS_ITERATOR: true, INTERRUPTED: true }).result;
  29183. }
  29184. });
  29185. },{"../internals/an-object":263,"../internals/export":318,"../internals/function-bind-context":322,"../internals/get-map-iterator":331,"../internals/iterate":356}],516:[function(_dereq_,module,exports){
  29186. var $ = _dereq_('../internals/export');
  29187. var from = _dereq_('../internals/collection-from');
  29188. // `Map.from` method
  29189. // https://tc39.github.io/proposal-setmap-offrom/#sec-map.from
  29190. $({ target: 'Map', stat: true, forced: true }, {
  29191. from: from
  29192. });
  29193. },{"../internals/collection-from":283,"../internals/export":318}],517:[function(_dereq_,module,exports){
  29194. 'use strict';
  29195. var $ = _dereq_('../internals/export');
  29196. var call = _dereq_('../internals/function-call');
  29197. var uncurryThis = _dereq_('../internals/function-uncurry-this');
  29198. var aCallable = _dereq_('../internals/a-callable');
  29199. var getIterator = _dereq_('../internals/get-iterator');
  29200. var iterate = _dereq_('../internals/iterate');
  29201. var push = uncurryThis([].push);
  29202. // `Map.groupBy` method
  29203. // https://github.com/tc39/proposal-collection-methods
  29204. $({ target: 'Map', stat: true, forced: true }, {
  29205. groupBy: function groupBy(iterable, keyDerivative) {
  29206. aCallable(keyDerivative);
  29207. var iterator = getIterator(iterable);
  29208. var newMap = new this();
  29209. var has = aCallable(newMap.has);
  29210. var get = aCallable(newMap.get);
  29211. var set = aCallable(newMap.set);
  29212. iterate(iterator, function (element) {
  29213. var derivedKey = keyDerivative(element);
  29214. if (!call(has, newMap, derivedKey)) call(set, newMap, derivedKey, [element]);
  29215. else push(call(get, newMap, derivedKey), element);
  29216. }, { IS_ITERATOR: true });
  29217. return newMap;
  29218. }
  29219. });
  29220. },{"../internals/a-callable":258,"../internals/export":318,"../internals/function-call":325,"../internals/function-uncurry-this":327,"../internals/get-iterator":330,"../internals/iterate":356}],518:[function(_dereq_,module,exports){
  29221. 'use strict';
  29222. var $ = _dereq_('../internals/export');
  29223. var anObject = _dereq_('../internals/an-object');
  29224. var getMapIterator = _dereq_('../internals/get-map-iterator');
  29225. var sameValueZero = _dereq_('../internals/same-value-zero');
  29226. var iterate = _dereq_('../internals/iterate');
  29227. // `Map.prototype.includes` method
  29228. // https://github.com/tc39/proposal-collection-methods
  29229. $({ target: 'Map', proto: true, real: true, forced: true }, {
  29230. includes: function includes(searchElement) {
  29231. return iterate(getMapIterator(anObject(this)), function (key, value, stop) {
  29232. if (sameValueZero(value, searchElement)) return stop();
  29233. }, { AS_ENTRIES: true, IS_ITERATOR: true, INTERRUPTED: true }).stopped;
  29234. }
  29235. });
  29236. },{"../internals/an-object":263,"../internals/export":318,"../internals/get-map-iterator":331,"../internals/iterate":356,"../internals/same-value-zero":398}],519:[function(_dereq_,module,exports){
  29237. 'use strict';
  29238. var $ = _dereq_('../internals/export');
  29239. var call = _dereq_('../internals/function-call');
  29240. var iterate = _dereq_('../internals/iterate');
  29241. var aCallable = _dereq_('../internals/a-callable');
  29242. // `Map.keyBy` method
  29243. // https://github.com/tc39/proposal-collection-methods
  29244. $({ target: 'Map', stat: true, forced: true }, {
  29245. keyBy: function keyBy(iterable, keyDerivative) {
  29246. var newMap = new this();
  29247. aCallable(keyDerivative);
  29248. var setter = aCallable(newMap.set);
  29249. iterate(iterable, function (element) {
  29250. call(setter, newMap, keyDerivative(element), element);
  29251. });
  29252. return newMap;
  29253. }
  29254. });
  29255. },{"../internals/a-callable":258,"../internals/export":318,"../internals/function-call":325,"../internals/iterate":356}],520:[function(_dereq_,module,exports){
  29256. 'use strict';
  29257. var $ = _dereq_('../internals/export');
  29258. var anObject = _dereq_('../internals/an-object');
  29259. var getMapIterator = _dereq_('../internals/get-map-iterator');
  29260. var iterate = _dereq_('../internals/iterate');
  29261. // `Map.prototype.keyOf` method
  29262. // https://github.com/tc39/proposal-collection-methods
  29263. $({ target: 'Map', proto: true, real: true, forced: true }, {
  29264. keyOf: function keyOf(searchElement) {
  29265. return iterate(getMapIterator(anObject(this)), function (key, value, stop) {
  29266. if (value === searchElement) return stop(key);
  29267. }, { AS_ENTRIES: true, IS_ITERATOR: true, INTERRUPTED: true }).result;
  29268. }
  29269. });
  29270. },{"../internals/an-object":263,"../internals/export":318,"../internals/get-map-iterator":331,"../internals/iterate":356}],521:[function(_dereq_,module,exports){
  29271. 'use strict';
  29272. var $ = _dereq_('../internals/export');
  29273. var getBuiltIn = _dereq_('../internals/get-built-in');
  29274. var bind = _dereq_('../internals/function-bind-context');
  29275. var call = _dereq_('../internals/function-call');
  29276. var aCallable = _dereq_('../internals/a-callable');
  29277. var anObject = _dereq_('../internals/an-object');
  29278. var speciesConstructor = _dereq_('../internals/species-constructor');
  29279. var getMapIterator = _dereq_('../internals/get-map-iterator');
  29280. var iterate = _dereq_('../internals/iterate');
  29281. // `Map.prototype.mapKeys` method
  29282. // https://github.com/tc39/proposal-collection-methods
  29283. $({ target: 'Map', proto: true, real: true, forced: true }, {
  29284. mapKeys: function mapKeys(callbackfn /* , thisArg */) {
  29285. var map = anObject(this);
  29286. var iterator = getMapIterator(map);
  29287. var boundFunction = bind(callbackfn, arguments.length > 1 ? arguments[1] : undefined);
  29288. var newMap = new (speciesConstructor(map, getBuiltIn('Map')))();
  29289. var setter = aCallable(newMap.set);
  29290. iterate(iterator, function (key, value) {
  29291. call(setter, newMap, boundFunction(value, key, map), value);
  29292. }, { AS_ENTRIES: true, IS_ITERATOR: true });
  29293. return newMap;
  29294. }
  29295. });
  29296. },{"../internals/a-callable":258,"../internals/an-object":263,"../internals/export":318,"../internals/function-bind-context":322,"../internals/function-call":325,"../internals/get-built-in":328,"../internals/get-map-iterator":331,"../internals/iterate":356,"../internals/species-constructor":405}],522:[function(_dereq_,module,exports){
  29297. 'use strict';
  29298. var $ = _dereq_('../internals/export');
  29299. var getBuiltIn = _dereq_('../internals/get-built-in');
  29300. var bind = _dereq_('../internals/function-bind-context');
  29301. var call = _dereq_('../internals/function-call');
  29302. var aCallable = _dereq_('../internals/a-callable');
  29303. var anObject = _dereq_('../internals/an-object');
  29304. var speciesConstructor = _dereq_('../internals/species-constructor');
  29305. var getMapIterator = _dereq_('../internals/get-map-iterator');
  29306. var iterate = _dereq_('../internals/iterate');
  29307. // `Map.prototype.mapValues` method
  29308. // https://github.com/tc39/proposal-collection-methods
  29309. $({ target: 'Map', proto: true, real: true, forced: true }, {
  29310. mapValues: function mapValues(callbackfn /* , thisArg */) {
  29311. var map = anObject(this);
  29312. var iterator = getMapIterator(map);
  29313. var boundFunction = bind(callbackfn, arguments.length > 1 ? arguments[1] : undefined);
  29314. var newMap = new (speciesConstructor(map, getBuiltIn('Map')))();
  29315. var setter = aCallable(newMap.set);
  29316. iterate(iterator, function (key, value) {
  29317. call(setter, newMap, key, boundFunction(value, key, map));
  29318. }, { AS_ENTRIES: true, IS_ITERATOR: true });
  29319. return newMap;
  29320. }
  29321. });
  29322. },{"../internals/a-callable":258,"../internals/an-object":263,"../internals/export":318,"../internals/function-bind-context":322,"../internals/function-call":325,"../internals/get-built-in":328,"../internals/get-map-iterator":331,"../internals/iterate":356,"../internals/species-constructor":405}],523:[function(_dereq_,module,exports){
  29323. 'use strict';
  29324. var $ = _dereq_('../internals/export');
  29325. var aCallable = _dereq_('../internals/a-callable');
  29326. var anObject = _dereq_('../internals/an-object');
  29327. var iterate = _dereq_('../internals/iterate');
  29328. // `Map.prototype.merge` method
  29329. // https://github.com/tc39/proposal-collection-methods
  29330. $({ target: 'Map', proto: true, real: true, arity: 1, forced: true }, {
  29331. // eslint-disable-next-line no-unused-vars -- required for `.length`
  29332. merge: function merge(iterable /* ...iterables */) {
  29333. var map = anObject(this);
  29334. var setter = aCallable(map.set);
  29335. var argumentsLength = arguments.length;
  29336. var i = 0;
  29337. while (i < argumentsLength) {
  29338. iterate(arguments[i++], setter, { that: map, AS_ENTRIES: true });
  29339. }
  29340. return map;
  29341. }
  29342. });
  29343. },{"../internals/a-callable":258,"../internals/an-object":263,"../internals/export":318,"../internals/iterate":356}],524:[function(_dereq_,module,exports){
  29344. var $ = _dereq_('../internals/export');
  29345. var of = _dereq_('../internals/collection-of');
  29346. // `Map.of` method
  29347. // https://tc39.github.io/proposal-setmap-offrom/#sec-map.of
  29348. $({ target: 'Map', stat: true, forced: true }, {
  29349. of: of
  29350. });
  29351. },{"../internals/collection-of":284,"../internals/export":318}],525:[function(_dereq_,module,exports){
  29352. 'use strict';
  29353. var $ = _dereq_('../internals/export');
  29354. var anObject = _dereq_('../internals/an-object');
  29355. var aCallable = _dereq_('../internals/a-callable');
  29356. var getMapIterator = _dereq_('../internals/get-map-iterator');
  29357. var iterate = _dereq_('../internals/iterate');
  29358. var $TypeError = TypeError;
  29359. // `Map.prototype.reduce` method
  29360. // https://github.com/tc39/proposal-collection-methods
  29361. $({ target: 'Map', proto: true, real: true, forced: true }, {
  29362. reduce: function reduce(callbackfn /* , initialValue */) {
  29363. var map = anObject(this);
  29364. var iterator = getMapIterator(map);
  29365. var noInitial = arguments.length < 2;
  29366. var accumulator = noInitial ? undefined : arguments[1];
  29367. aCallable(callbackfn);
  29368. iterate(iterator, function (key, value) {
  29369. if (noInitial) {
  29370. noInitial = false;
  29371. accumulator = value;
  29372. } else {
  29373. accumulator = callbackfn(accumulator, value, key, map);
  29374. }
  29375. }, { AS_ENTRIES: true, IS_ITERATOR: true });
  29376. if (noInitial) throw $TypeError('Reduce of empty map with no initial value');
  29377. return accumulator;
  29378. }
  29379. });
  29380. },{"../internals/a-callable":258,"../internals/an-object":263,"../internals/export":318,"../internals/get-map-iterator":331,"../internals/iterate":356}],526:[function(_dereq_,module,exports){
  29381. 'use strict';
  29382. var $ = _dereq_('../internals/export');
  29383. var anObject = _dereq_('../internals/an-object');
  29384. var bind = _dereq_('../internals/function-bind-context');
  29385. var getMapIterator = _dereq_('../internals/get-map-iterator');
  29386. var iterate = _dereq_('../internals/iterate');
  29387. // `Set.prototype.some` method
  29388. // https://github.com/tc39/proposal-collection-methods
  29389. $({ target: 'Map', proto: true, real: true, forced: true }, {
  29390. some: function some(callbackfn /* , thisArg */) {
  29391. var map = anObject(this);
  29392. var iterator = getMapIterator(map);
  29393. var boundFunction = bind(callbackfn, arguments.length > 1 ? arguments[1] : undefined);
  29394. return iterate(iterator, function (key, value, stop) {
  29395. if (boundFunction(value, key, map)) return stop();
  29396. }, { AS_ENTRIES: true, IS_ITERATOR: true, INTERRUPTED: true }).stopped;
  29397. }
  29398. });
  29399. },{"../internals/an-object":263,"../internals/export":318,"../internals/function-bind-context":322,"../internals/get-map-iterator":331,"../internals/iterate":356}],527:[function(_dereq_,module,exports){
  29400. 'use strict';
  29401. // TODO: remove from `core-js@4`
  29402. var $ = _dereq_('../internals/export');
  29403. var upsert = _dereq_('../internals/map-upsert');
  29404. // `Map.prototype.updateOrInsert` method (replaced by `Map.prototype.emplace`)
  29405. // https://github.com/thumbsupep/proposal-upsert
  29406. $({ target: 'Map', proto: true, real: true, name: 'upsert', forced: true }, {
  29407. updateOrInsert: upsert
  29408. });
  29409. },{"../internals/export":318,"../internals/map-upsert":364}],528:[function(_dereq_,module,exports){
  29410. 'use strict';
  29411. var $ = _dereq_('../internals/export');
  29412. var call = _dereq_('../internals/function-call');
  29413. var anObject = _dereq_('../internals/an-object');
  29414. var aCallable = _dereq_('../internals/a-callable');
  29415. var $TypeError = TypeError;
  29416. // `Set.prototype.update` method
  29417. // https://github.com/tc39/proposal-collection-methods
  29418. $({ target: 'Map', proto: true, real: true, forced: true }, {
  29419. update: function update(key, callback /* , thunk */) {
  29420. var map = anObject(this);
  29421. var get = aCallable(map.get);
  29422. var has = aCallable(map.has);
  29423. var set = aCallable(map.set);
  29424. var length = arguments.length;
  29425. aCallable(callback);
  29426. var isPresentInMap = call(has, map, key);
  29427. if (!isPresentInMap && length < 3) {
  29428. throw $TypeError('Updating absent value');
  29429. }
  29430. var value = isPresentInMap ? call(get, map, key) : aCallable(length > 2 ? arguments[2] : undefined)(key, map);
  29431. call(set, map, key, callback(value, key, map));
  29432. return map;
  29433. }
  29434. });
  29435. },{"../internals/a-callable":258,"../internals/an-object":263,"../internals/export":318,"../internals/function-call":325}],529:[function(_dereq_,module,exports){
  29436. 'use strict';
  29437. // TODO: remove from `core-js@4`
  29438. var $ = _dereq_('../internals/export');
  29439. var upsert = _dereq_('../internals/map-upsert');
  29440. // `Map.prototype.upsert` method (replaced by `Map.prototype.emplace`)
  29441. // https://github.com/thumbsupep/proposal-upsert
  29442. $({ target: 'Map', proto: true, real: true, forced: true }, {
  29443. upsert: upsert
  29444. });
  29445. },{"../internals/export":318,"../internals/map-upsert":364}],530:[function(_dereq_,module,exports){
  29446. // TODO: Remove from `core-js@4`
  29447. _dereq_('../modules/es.promise.all-settled.js');
  29448. },{"../modules/es.promise.all-settled.js":471}],531:[function(_dereq_,module,exports){
  29449. // TODO: Remove from `core-js@4`
  29450. _dereq_('../modules/es.promise.any');
  29451. },{"../modules/es.promise.any":473}],532:[function(_dereq_,module,exports){
  29452. 'use strict';
  29453. // TODO: Remove from `core-js@4`
  29454. var $ = _dereq_('../internals/export');
  29455. var newPromiseCapabilityModule = _dereq_('../internals/new-promise-capability');
  29456. var perform = _dereq_('../internals/perform');
  29457. // `Promise.try` method
  29458. // https://github.com/tc39/proposal-promise-try
  29459. $({ target: 'Promise', stat: true, forced: true }, {
  29460. 'try': function (callbackfn) {
  29461. var promiseCapability = newPromiseCapabilityModule.f(this);
  29462. var result = perform(callbackfn);
  29463. (result.error ? promiseCapability.reject : promiseCapability.resolve)(result.value);
  29464. return promiseCapability.promise;
  29465. }
  29466. });
  29467. },{"../internals/export":318,"../internals/new-promise-capability":367,"../internals/perform":391}],533:[function(_dereq_,module,exports){
  29468. var defineWellKnownSymbol = _dereq_('../internals/well-known-symbol-define');
  29469. // `Symbol.asyncDispose` well-known symbol
  29470. // https://github.com/tc39/proposal-using-statement
  29471. defineWellKnownSymbol('asyncDispose');
  29472. },{"../internals/well-known-symbol-define":427}],534:[function(_dereq_,module,exports){
  29473. var defineWellKnownSymbol = _dereq_('../internals/well-known-symbol-define');
  29474. // `Symbol.dispose` well-known symbol
  29475. // https://github.com/tc39/proposal-using-statement
  29476. defineWellKnownSymbol('dispose');
  29477. },{"../internals/well-known-symbol-define":427}],535:[function(_dereq_,module,exports){
  29478. var defineWellKnownSymbol = _dereq_('../internals/well-known-symbol-define');
  29479. // `Symbol.matcher` well-known symbol
  29480. // https://github.com/tc39/proposal-pattern-matching
  29481. defineWellKnownSymbol('matcher');
  29482. },{"../internals/well-known-symbol-define":427}],536:[function(_dereq_,module,exports){
  29483. var defineWellKnownSymbol = _dereq_('../internals/well-known-symbol-define');
  29484. // `Symbol.metadataKey` well-known symbol
  29485. // https://github.com/tc39/proposal-decorator-metadata
  29486. defineWellKnownSymbol('metadataKey');
  29487. },{"../internals/well-known-symbol-define":427}],537:[function(_dereq_,module,exports){
  29488. // TODO: Remove from `core-js@4`
  29489. var defineWellKnownSymbol = _dereq_('../internals/well-known-symbol-define');
  29490. // `Symbol.metadata` well-known symbol
  29491. // https://github.com/tc39/proposal-decorators
  29492. defineWellKnownSymbol('metadata');
  29493. },{"../internals/well-known-symbol-define":427}],538:[function(_dereq_,module,exports){
  29494. var defineWellKnownSymbol = _dereq_('../internals/well-known-symbol-define');
  29495. // `Symbol.observable` well-known symbol
  29496. // https://github.com/tc39/proposal-observable
  29497. defineWellKnownSymbol('observable');
  29498. },{"../internals/well-known-symbol-define":427}],539:[function(_dereq_,module,exports){
  29499. // TODO: remove from `core-js@4`
  29500. var defineWellKnownSymbol = _dereq_('../internals/well-known-symbol-define');
  29501. // `Symbol.patternMatch` well-known symbol
  29502. // https://github.com/tc39/proposal-pattern-matching
  29503. defineWellKnownSymbol('patternMatch');
  29504. },{"../internals/well-known-symbol-define":427}],540:[function(_dereq_,module,exports){
  29505. // TODO: remove from `core-js@4`
  29506. var defineWellKnownSymbol = _dereq_('../internals/well-known-symbol-define');
  29507. defineWellKnownSymbol('replaceAll');
  29508. },{"../internals/well-known-symbol-define":427}],541:[function(_dereq_,module,exports){
  29509. _dereq_('../modules/es.array.iterator');
  29510. var DOMIterables = _dereq_('../internals/dom-iterables');
  29511. var global = _dereq_('../internals/global');
  29512. var classof = _dereq_('../internals/classof');
  29513. var createNonEnumerableProperty = _dereq_('../internals/create-non-enumerable-property');
  29514. var Iterators = _dereq_('../internals/iterators');
  29515. var wellKnownSymbol = _dereq_('../internals/well-known-symbol');
  29516. var TO_STRING_TAG = wellKnownSymbol('toStringTag');
  29517. for (var COLLECTION_NAME in DOMIterables) {
  29518. var Collection = global[COLLECTION_NAME];
  29519. var CollectionPrototype = Collection && Collection.prototype;
  29520. if (CollectionPrototype && classof(CollectionPrototype) !== TO_STRING_TAG) {
  29521. createNonEnumerableProperty(CollectionPrototype, TO_STRING_TAG, COLLECTION_NAME);
  29522. }
  29523. Iterators[COLLECTION_NAME] = Iterators.Array;
  29524. }
  29525. },{"../internals/classof":281,"../internals/create-non-enumerable-property":292,"../internals/dom-iterables":302,"../internals/global":333,"../internals/iterators":361,"../internals/well-known-symbol":429,"../modules/es.array.iterator":443}],542:[function(_dereq_,module,exports){
  29526. var $ = _dereq_('../internals/export');
  29527. var global = _dereq_('../internals/global');
  29528. var setInterval = _dereq_('../internals/schedulers-fix').setInterval;
  29529. // ie9- setInterval additional parameters fix
  29530. // https://html.spec.whatwg.org/multipage/timers-and-user-prompts.html#dom-setinterval
  29531. $({ global: true, bind: true, forced: global.setInterval !== setInterval }, {
  29532. setInterval: setInterval
  29533. });
  29534. },{"../internals/export":318,"../internals/global":333,"../internals/schedulers-fix":399}],543:[function(_dereq_,module,exports){
  29535. var $ = _dereq_('../internals/export');
  29536. var global = _dereq_('../internals/global');
  29537. var setTimeout = _dereq_('../internals/schedulers-fix').setTimeout;
  29538. // ie9- setTimeout additional parameters fix
  29539. // https://html.spec.whatwg.org/multipage/timers-and-user-prompts.html#dom-settimeout
  29540. $({ global: true, bind: true, forced: global.setTimeout !== setTimeout }, {
  29541. setTimeout: setTimeout
  29542. });
  29543. },{"../internals/export":318,"../internals/global":333,"../internals/schedulers-fix":399}],544:[function(_dereq_,module,exports){
  29544. // TODO: Remove this module from `core-js@4` since it's split to modules listed below
  29545. _dereq_('../modules/web.set-interval');
  29546. _dereq_('../modules/web.set-timeout');
  29547. },{"../modules/web.set-interval":542,"../modules/web.set-timeout":543}],545:[function(_dereq_,module,exports){
  29548. var parent = _dereq_('../../es/array/from');
  29549. module.exports = parent;
  29550. },{"../../es/array/from":163}],546:[function(_dereq_,module,exports){
  29551. var parent = _dereq_('../../es/array/is-array');
  29552. module.exports = parent;
  29553. },{"../../es/array/is-array":164}],547:[function(_dereq_,module,exports){
  29554. var parent = _dereq_('../../../es/array/virtual/entries');
  29555. module.exports = parent;
  29556. },{"../../../es/array/virtual/entries":166}],548:[function(_dereq_,module,exports){
  29557. var parent = _dereq_('../../../es/array/virtual/for-each');
  29558. module.exports = parent;
  29559. },{"../../../es/array/virtual/for-each":171}],549:[function(_dereq_,module,exports){
  29560. var parent = _dereq_('../../../es/array/virtual/keys');
  29561. module.exports = parent;
  29562. },{"../../../es/array/virtual/keys":174}],550:[function(_dereq_,module,exports){
  29563. var parent = _dereq_('../../../es/array/virtual/values');
  29564. module.exports = parent;
  29565. },{"../../../es/array/virtual/values":181}],551:[function(_dereq_,module,exports){
  29566. var parent = _dereq_('../es/get-iterator-method');
  29567. _dereq_('../modules/web.dom-collections.iterator');
  29568. module.exports = parent;
  29569. },{"../es/get-iterator-method":183,"../modules/web.dom-collections.iterator":541}],552:[function(_dereq_,module,exports){
  29570. var parent = _dereq_('../../es/instance/bind');
  29571. module.exports = parent;
  29572. },{"../../es/instance/bind":184}],553:[function(_dereq_,module,exports){
  29573. var parent = _dereq_('../../es/instance/concat');
  29574. module.exports = parent;
  29575. },{"../../es/instance/concat":185}],554:[function(_dereq_,module,exports){
  29576. _dereq_('../../modules/web.dom-collections.iterator');
  29577. var classof = _dereq_('../../internals/classof');
  29578. var hasOwn = _dereq_('../../internals/has-own-property');
  29579. var isPrototypeOf = _dereq_('../../internals/object-is-prototype-of');
  29580. var method = _dereq_('../array/virtual/entries');
  29581. var ArrayPrototype = Array.prototype;
  29582. var DOMIterables = {
  29583. DOMTokenList: true,
  29584. NodeList: true
  29585. };
  29586. module.exports = function (it) {
  29587. var own = it.entries;
  29588. return it === ArrayPrototype || (isPrototypeOf(ArrayPrototype, it) && own === ArrayPrototype.entries)
  29589. || hasOwn(DOMIterables, classof(it)) ? method : own;
  29590. };
  29591. },{"../../internals/classof":281,"../../internals/has-own-property":334,"../../internals/object-is-prototype-of":381,"../../modules/web.dom-collections.iterator":541,"../array/virtual/entries":547}],555:[function(_dereq_,module,exports){
  29592. var parent = _dereq_('../../es/instance/every');
  29593. module.exports = parent;
  29594. },{"../../es/instance/every":186}],556:[function(_dereq_,module,exports){
  29595. var parent = _dereq_('../../es/instance/filter');
  29596. module.exports = parent;
  29597. },{"../../es/instance/filter":187}],557:[function(_dereq_,module,exports){
  29598. var parent = _dereq_('../../es/instance/find-index');
  29599. module.exports = parent;
  29600. },{"../../es/instance/find-index":188}],558:[function(_dereq_,module,exports){
  29601. var parent = _dereq_('../../es/instance/find');
  29602. module.exports = parent;
  29603. },{"../../es/instance/find":189}],559:[function(_dereq_,module,exports){
  29604. _dereq_('../../modules/web.dom-collections.iterator');
  29605. var classof = _dereq_('../../internals/classof');
  29606. var hasOwn = _dereq_('../../internals/has-own-property');
  29607. var isPrototypeOf = _dereq_('../../internals/object-is-prototype-of');
  29608. var method = _dereq_('../array/virtual/for-each');
  29609. var ArrayPrototype = Array.prototype;
  29610. var DOMIterables = {
  29611. DOMTokenList: true,
  29612. NodeList: true
  29613. };
  29614. module.exports = function (it) {
  29615. var own = it.forEach;
  29616. return it === ArrayPrototype || (isPrototypeOf(ArrayPrototype, it) && own === ArrayPrototype.forEach)
  29617. || hasOwn(DOMIterables, classof(it)) ? method : own;
  29618. };
  29619. },{"../../internals/classof":281,"../../internals/has-own-property":334,"../../internals/object-is-prototype-of":381,"../../modules/web.dom-collections.iterator":541,"../array/virtual/for-each":548}],560:[function(_dereq_,module,exports){
  29620. var parent = _dereq_('../../es/instance/includes');
  29621. module.exports = parent;
  29622. },{"../../es/instance/includes":190}],561:[function(_dereq_,module,exports){
  29623. var parent = _dereq_('../../es/instance/index-of');
  29624. module.exports = parent;
  29625. },{"../../es/instance/index-of":191}],562:[function(_dereq_,module,exports){
  29626. _dereq_('../../modules/web.dom-collections.iterator');
  29627. var classof = _dereq_('../../internals/classof');
  29628. var hasOwn = _dereq_('../../internals/has-own-property');
  29629. var isPrototypeOf = _dereq_('../../internals/object-is-prototype-of');
  29630. var method = _dereq_('../array/virtual/keys');
  29631. var ArrayPrototype = Array.prototype;
  29632. var DOMIterables = {
  29633. DOMTokenList: true,
  29634. NodeList: true
  29635. };
  29636. module.exports = function (it) {
  29637. var own = it.keys;
  29638. return it === ArrayPrototype || (isPrototypeOf(ArrayPrototype, it) && own === ArrayPrototype.keys)
  29639. || hasOwn(DOMIterables, classof(it)) ? method : own;
  29640. };
  29641. },{"../../internals/classof":281,"../../internals/has-own-property":334,"../../internals/object-is-prototype-of":381,"../../modules/web.dom-collections.iterator":541,"../array/virtual/keys":549}],563:[function(_dereq_,module,exports){
  29642. var parent = _dereq_('../../es/instance/map');
  29643. module.exports = parent;
  29644. },{"../../es/instance/map":192}],564:[function(_dereq_,module,exports){
  29645. var parent = _dereq_('../../es/instance/reduce');
  29646. module.exports = parent;
  29647. },{"../../es/instance/reduce":193}],565:[function(_dereq_,module,exports){
  29648. var parent = _dereq_('../../es/instance/reverse');
  29649. module.exports = parent;
  29650. },{"../../es/instance/reverse":194}],566:[function(_dereq_,module,exports){
  29651. var parent = _dereq_('../../es/instance/slice');
  29652. module.exports = parent;
  29653. },{"../../es/instance/slice":195}],567:[function(_dereq_,module,exports){
  29654. var parent = _dereq_('../../es/instance/sort');
  29655. module.exports = parent;
  29656. },{"../../es/instance/sort":196}],568:[function(_dereq_,module,exports){
  29657. var parent = _dereq_('../../es/instance/splice');
  29658. module.exports = parent;
  29659. },{"../../es/instance/splice":197}],569:[function(_dereq_,module,exports){
  29660. var parent = _dereq_('../../es/instance/starts-with');
  29661. module.exports = parent;
  29662. },{"../../es/instance/starts-with":198}],570:[function(_dereq_,module,exports){
  29663. _dereq_('../../modules/web.dom-collections.iterator');
  29664. var classof = _dereq_('../../internals/classof');
  29665. var hasOwn = _dereq_('../../internals/has-own-property');
  29666. var isPrototypeOf = _dereq_('../../internals/object-is-prototype-of');
  29667. var method = _dereq_('../array/virtual/values');
  29668. var ArrayPrototype = Array.prototype;
  29669. var DOMIterables = {
  29670. DOMTokenList: true,
  29671. NodeList: true
  29672. };
  29673. module.exports = function (it) {
  29674. var own = it.values;
  29675. return it === ArrayPrototype || (isPrototypeOf(ArrayPrototype, it) && own === ArrayPrototype.values)
  29676. || hasOwn(DOMIterables, classof(it)) ? method : own;
  29677. };
  29678. },{"../../internals/classof":281,"../../internals/has-own-property":334,"../../internals/object-is-prototype-of":381,"../../modules/web.dom-collections.iterator":541,"../array/virtual/values":550}],571:[function(_dereq_,module,exports){
  29679. var parent = _dereq_('../../es/json/stringify');
  29680. module.exports = parent;
  29681. },{"../../es/json/stringify":199}],572:[function(_dereq_,module,exports){
  29682. var parent = _dereq_('../../es/map');
  29683. _dereq_('../../modules/web.dom-collections.iterator');
  29684. module.exports = parent;
  29685. },{"../../es/map":200,"../../modules/web.dom-collections.iterator":541}],573:[function(_dereq_,module,exports){
  29686. var parent = _dereq_('../../es/number/is-integer');
  29687. module.exports = parent;
  29688. },{"../../es/number/is-integer":201}],574:[function(_dereq_,module,exports){
  29689. var parent = _dereq_('../../es/object/assign');
  29690. module.exports = parent;
  29691. },{"../../es/object/assign":202}],575:[function(_dereq_,module,exports){
  29692. var parent = _dereq_('../../es/object/create');
  29693. module.exports = parent;
  29694. },{"../../es/object/create":203}],576:[function(_dereq_,module,exports){
  29695. var parent = _dereq_('../../es/object/define-properties');
  29696. module.exports = parent;
  29697. },{"../../es/object/define-properties":204}],577:[function(_dereq_,module,exports){
  29698. var parent = _dereq_('../../es/object/define-property');
  29699. module.exports = parent;
  29700. },{"../../es/object/define-property":205}],578:[function(_dereq_,module,exports){
  29701. var parent = _dereq_('../../es/object/entries');
  29702. module.exports = parent;
  29703. },{"../../es/object/entries":206}],579:[function(_dereq_,module,exports){
  29704. var parent = _dereq_('../../es/object/freeze');
  29705. module.exports = parent;
  29706. },{"../../es/object/freeze":207}],580:[function(_dereq_,module,exports){
  29707. var parent = _dereq_('../../es/object/get-own-property-descriptor');
  29708. module.exports = parent;
  29709. },{"../../es/object/get-own-property-descriptor":208}],581:[function(_dereq_,module,exports){
  29710. var parent = _dereq_('../../es/object/get-own-property-descriptors');
  29711. module.exports = parent;
  29712. },{"../../es/object/get-own-property-descriptors":209}],582:[function(_dereq_,module,exports){
  29713. var parent = _dereq_('../../es/object/get-own-property-symbols');
  29714. module.exports = parent;
  29715. },{"../../es/object/get-own-property-symbols":210}],583:[function(_dereq_,module,exports){
  29716. var parent = _dereq_('../../es/object/get-prototype-of');
  29717. module.exports = parent;
  29718. },{"../../es/object/get-prototype-of":211}],584:[function(_dereq_,module,exports){
  29719. var parent = _dereq_('../../es/object/keys');
  29720. module.exports = parent;
  29721. },{"../../es/object/keys":212}],585:[function(_dereq_,module,exports){
  29722. var parent = _dereq_('../../es/object/set-prototype-of');
  29723. module.exports = parent;
  29724. },{"../../es/object/set-prototype-of":213}],586:[function(_dereq_,module,exports){
  29725. var parent = _dereq_('../es/parse-int');
  29726. module.exports = parent;
  29727. },{"../es/parse-int":214}],587:[function(_dereq_,module,exports){
  29728. var parent = _dereq_('../../es/promise');
  29729. _dereq_('../../modules/web.dom-collections.iterator');
  29730. module.exports = parent;
  29731. },{"../../es/promise":215,"../../modules/web.dom-collections.iterator":541}],588:[function(_dereq_,module,exports){
  29732. var parent = _dereq_('../../es/reflect/construct');
  29733. module.exports = parent;
  29734. },{"../../es/reflect/construct":216}],589:[function(_dereq_,module,exports){
  29735. var parent = _dereq_('../../es/reflect/get');
  29736. module.exports = parent;
  29737. },{"../../es/reflect/get":217}],590:[function(_dereq_,module,exports){
  29738. _dereq_('../modules/web.timers');
  29739. var path = _dereq_('../internals/path');
  29740. module.exports = path.setInterval;
  29741. },{"../internals/path":390,"../modules/web.timers":544}],591:[function(_dereq_,module,exports){
  29742. _dereq_('../modules/web.timers');
  29743. var path = _dereq_('../internals/path');
  29744. module.exports = path.setTimeout;
  29745. },{"../internals/path":390,"../modules/web.timers":544}],592:[function(_dereq_,module,exports){
  29746. var parent = _dereq_('../../es/set');
  29747. _dereq_('../../modules/web.dom-collections.iterator');
  29748. module.exports = parent;
  29749. },{"../../es/set":218,"../../modules/web.dom-collections.iterator":541}],593:[function(_dereq_,module,exports){
  29750. var parent = _dereq_('../../es/symbol');
  29751. _dereq_('../../modules/web.dom-collections.iterator');
  29752. module.exports = parent;
  29753. },{"../../es/symbol":221,"../../modules/web.dom-collections.iterator":541}],594:[function(_dereq_,module,exports){
  29754. var parent = _dereq_('../../es/symbol/iterator');
  29755. _dereq_('../../modules/web.dom-collections.iterator');
  29756. module.exports = parent;
  29757. },{"../../es/symbol/iterator":222,"../../modules/web.dom-collections.iterator":541}],595:[function(_dereq_,module,exports){
  29758. var parent = _dereq_('../../es/weak-map');
  29759. _dereq_('../../modules/web.dom-collections.iterator');
  29760. module.exports = parent;
  29761. },{"../../es/weak-map":223,"../../modules/web.dom-collections.iterator":541}],596:[function(_dereq_,module,exports){
  29762. ;(function (root, factory, undef) {
  29763. if (typeof exports === "object") {
  29764. // CommonJS
  29765. module.exports = exports = factory(_dereq_("./core"), _dereq_("./enc-base64"), _dereq_("./md5"), _dereq_("./evpkdf"), _dereq_("./cipher-core"));
  29766. }
  29767. else if (typeof define === "function" && define.amd) {
  29768. // AMD
  29769. define(["./core", "./enc-base64", "./md5", "./evpkdf", "./cipher-core"], factory);
  29770. }
  29771. else {
  29772. // Global (browser)
  29773. factory(root.CryptoJS);
  29774. }
  29775. }(this, function (CryptoJS) {
  29776. (function () {
  29777. // Shortcuts
  29778. var C = CryptoJS;
  29779. var C_lib = C.lib;
  29780. var BlockCipher = C_lib.BlockCipher;
  29781. var C_algo = C.algo;
  29782. // Lookup tables
  29783. var SBOX = [];
  29784. var INV_SBOX = [];
  29785. var SUB_MIX_0 = [];
  29786. var SUB_MIX_1 = [];
  29787. var SUB_MIX_2 = [];
  29788. var SUB_MIX_3 = [];
  29789. var INV_SUB_MIX_0 = [];
  29790. var INV_SUB_MIX_1 = [];
  29791. var INV_SUB_MIX_2 = [];
  29792. var INV_SUB_MIX_3 = [];
  29793. // Compute lookup tables
  29794. (function () {
  29795. // Compute double table
  29796. var d = [];
  29797. for (var i = 0; i < 256; i++) {
  29798. if (i < 128) {
  29799. d[i] = i << 1;
  29800. } else {
  29801. d[i] = (i << 1) ^ 0x11b;
  29802. }
  29803. }
  29804. // Walk GF(2^8)
  29805. var x = 0;
  29806. var xi = 0;
  29807. for (var i = 0; i < 256; i++) {
  29808. // Compute sbox
  29809. var sx = xi ^ (xi << 1) ^ (xi << 2) ^ (xi << 3) ^ (xi << 4);
  29810. sx = (sx >>> 8) ^ (sx & 0xff) ^ 0x63;
  29811. SBOX[x] = sx;
  29812. INV_SBOX[sx] = x;
  29813. // Compute multiplication
  29814. var x2 = d[x];
  29815. var x4 = d[x2];
  29816. var x8 = d[x4];
  29817. // Compute sub bytes, mix columns tables
  29818. var t = (d[sx] * 0x101) ^ (sx * 0x1010100);
  29819. SUB_MIX_0[x] = (t << 24) | (t >>> 8);
  29820. SUB_MIX_1[x] = (t << 16) | (t >>> 16);
  29821. SUB_MIX_2[x] = (t << 8) | (t >>> 24);
  29822. SUB_MIX_3[x] = t;
  29823. // Compute inv sub bytes, inv mix columns tables
  29824. var t = (x8 * 0x1010101) ^ (x4 * 0x10001) ^ (x2 * 0x101) ^ (x * 0x1010100);
  29825. INV_SUB_MIX_0[sx] = (t << 24) | (t >>> 8);
  29826. INV_SUB_MIX_1[sx] = (t << 16) | (t >>> 16);
  29827. INV_SUB_MIX_2[sx] = (t << 8) | (t >>> 24);
  29828. INV_SUB_MIX_3[sx] = t;
  29829. // Compute next counter
  29830. if (!x) {
  29831. x = xi = 1;
  29832. } else {
  29833. x = x2 ^ d[d[d[x8 ^ x2]]];
  29834. xi ^= d[d[xi]];
  29835. }
  29836. }
  29837. }());
  29838. // Precomputed Rcon lookup
  29839. var RCON = [0x00, 0x01, 0x02, 0x04, 0x08, 0x10, 0x20, 0x40, 0x80, 0x1b, 0x36];
  29840. /**
  29841. * AES block cipher algorithm.
  29842. */
  29843. var AES = C_algo.AES = BlockCipher.extend({
  29844. _doReset: function () {
  29845. var t;
  29846. // Skip reset of nRounds has been set before and key did not change
  29847. if (this._nRounds && this._keyPriorReset === this._key) {
  29848. return;
  29849. }
  29850. // Shortcuts
  29851. var key = this._keyPriorReset = this._key;
  29852. var keyWords = key.words;
  29853. var keySize = key.sigBytes / 4;
  29854. // Compute number of rounds
  29855. var nRounds = this._nRounds = keySize + 6;
  29856. // Compute number of key schedule rows
  29857. var ksRows = (nRounds + 1) * 4;
  29858. // Compute key schedule
  29859. var keySchedule = this._keySchedule = [];
  29860. for (var ksRow = 0; ksRow < ksRows; ksRow++) {
  29861. if (ksRow < keySize) {
  29862. keySchedule[ksRow] = keyWords[ksRow];
  29863. } else {
  29864. t = keySchedule[ksRow - 1];
  29865. if (!(ksRow % keySize)) {
  29866. // Rot word
  29867. t = (t << 8) | (t >>> 24);
  29868. // Sub word
  29869. t = (SBOX[t >>> 24] << 24) | (SBOX[(t >>> 16) & 0xff] << 16) | (SBOX[(t >>> 8) & 0xff] << 8) | SBOX[t & 0xff];
  29870. // Mix Rcon
  29871. t ^= RCON[(ksRow / keySize) | 0] << 24;
  29872. } else if (keySize > 6 && ksRow % keySize == 4) {
  29873. // Sub word
  29874. t = (SBOX[t >>> 24] << 24) | (SBOX[(t >>> 16) & 0xff] << 16) | (SBOX[(t >>> 8) & 0xff] << 8) | SBOX[t & 0xff];
  29875. }
  29876. keySchedule[ksRow] = keySchedule[ksRow - keySize] ^ t;
  29877. }
  29878. }
  29879. // Compute inv key schedule
  29880. var invKeySchedule = this._invKeySchedule = [];
  29881. for (var invKsRow = 0; invKsRow < ksRows; invKsRow++) {
  29882. var ksRow = ksRows - invKsRow;
  29883. if (invKsRow % 4) {
  29884. var t = keySchedule[ksRow];
  29885. } else {
  29886. var t = keySchedule[ksRow - 4];
  29887. }
  29888. if (invKsRow < 4 || ksRow <= 4) {
  29889. invKeySchedule[invKsRow] = t;
  29890. } else {
  29891. invKeySchedule[invKsRow] = INV_SUB_MIX_0[SBOX[t >>> 24]] ^ INV_SUB_MIX_1[SBOX[(t >>> 16) & 0xff]] ^
  29892. INV_SUB_MIX_2[SBOX[(t >>> 8) & 0xff]] ^ INV_SUB_MIX_3[SBOX[t & 0xff]];
  29893. }
  29894. }
  29895. },
  29896. encryptBlock: function (M, offset) {
  29897. this._doCryptBlock(M, offset, this._keySchedule, SUB_MIX_0, SUB_MIX_1, SUB_MIX_2, SUB_MIX_3, SBOX);
  29898. },
  29899. decryptBlock: function (M, offset) {
  29900. // Swap 2nd and 4th rows
  29901. var t = M[offset + 1];
  29902. M[offset + 1] = M[offset + 3];
  29903. M[offset + 3] = t;
  29904. this._doCryptBlock(M, offset, this._invKeySchedule, INV_SUB_MIX_0, INV_SUB_MIX_1, INV_SUB_MIX_2, INV_SUB_MIX_3, INV_SBOX);
  29905. // Inv swap 2nd and 4th rows
  29906. var t = M[offset + 1];
  29907. M[offset + 1] = M[offset + 3];
  29908. M[offset + 3] = t;
  29909. },
  29910. _doCryptBlock: function (M, offset, keySchedule, SUB_MIX_0, SUB_MIX_1, SUB_MIX_2, SUB_MIX_3, SBOX) {
  29911. // Shortcut
  29912. var nRounds = this._nRounds;
  29913. // Get input, add round key
  29914. var s0 = M[offset] ^ keySchedule[0];
  29915. var s1 = M[offset + 1] ^ keySchedule[1];
  29916. var s2 = M[offset + 2] ^ keySchedule[2];
  29917. var s3 = M[offset + 3] ^ keySchedule[3];
  29918. // Key schedule row counter
  29919. var ksRow = 4;
  29920. // Rounds
  29921. for (var round = 1; round < nRounds; round++) {
  29922. // Shift rows, sub bytes, mix columns, add round key
  29923. 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++];
  29924. 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++];
  29925. 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++];
  29926. 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++];
  29927. // Update state
  29928. s0 = t0;
  29929. s1 = t1;
  29930. s2 = t2;
  29931. s3 = t3;
  29932. }
  29933. // Shift rows, sub bytes, add round key
  29934. var t0 = ((SBOX[s0 >>> 24] << 24) | (SBOX[(s1 >>> 16) & 0xff] << 16) | (SBOX[(s2 >>> 8) & 0xff] << 8) | SBOX[s3 & 0xff]) ^ keySchedule[ksRow++];
  29935. var t1 = ((SBOX[s1 >>> 24] << 24) | (SBOX[(s2 >>> 16) & 0xff] << 16) | (SBOX[(s3 >>> 8) & 0xff] << 8) | SBOX[s0 & 0xff]) ^ keySchedule[ksRow++];
  29936. var t2 = ((SBOX[s2 >>> 24] << 24) | (SBOX[(s3 >>> 16) & 0xff] << 16) | (SBOX[(s0 >>> 8) & 0xff] << 8) | SBOX[s1 & 0xff]) ^ keySchedule[ksRow++];
  29937. var t3 = ((SBOX[s3 >>> 24] << 24) | (SBOX[(s0 >>> 16) & 0xff] << 16) | (SBOX[(s1 >>> 8) & 0xff] << 8) | SBOX[s2 & 0xff]) ^ keySchedule[ksRow++];
  29938. // Set output
  29939. M[offset] = t0;
  29940. M[offset + 1] = t1;
  29941. M[offset + 2] = t2;
  29942. M[offset + 3] = t3;
  29943. },
  29944. keySize: 256/32
  29945. });
  29946. /**
  29947. * Shortcut functions to the cipher's object interface.
  29948. *
  29949. * @example
  29950. *
  29951. * var ciphertext = CryptoJS.AES.encrypt(message, key, cfg);
  29952. * var plaintext = CryptoJS.AES.decrypt(ciphertext, key, cfg);
  29953. */
  29954. C.AES = BlockCipher._createHelper(AES);
  29955. }());
  29956. return CryptoJS.AES;
  29957. }));
  29958. },{"./cipher-core":597,"./core":598,"./enc-base64":599,"./evpkdf":601,"./md5":603}],597:[function(_dereq_,module,exports){
  29959. ;(function (root, factory, undef) {
  29960. if (typeof exports === "object") {
  29961. // CommonJS
  29962. module.exports = exports = factory(_dereq_("./core"), _dereq_("./evpkdf"));
  29963. }
  29964. else if (typeof define === "function" && define.amd) {
  29965. // AMD
  29966. define(["./core", "./evpkdf"], factory);
  29967. }
  29968. else {
  29969. // Global (browser)
  29970. factory(root.CryptoJS);
  29971. }
  29972. }(this, function (CryptoJS) {
  29973. /**
  29974. * Cipher core components.
  29975. */
  29976. CryptoJS.lib.Cipher || (function (undefined) {
  29977. // Shortcuts
  29978. var C = CryptoJS;
  29979. var C_lib = C.lib;
  29980. var Base = C_lib.Base;
  29981. var WordArray = C_lib.WordArray;
  29982. var BufferedBlockAlgorithm = C_lib.BufferedBlockAlgorithm;
  29983. var C_enc = C.enc;
  29984. var Utf8 = C_enc.Utf8;
  29985. var Base64 = C_enc.Base64;
  29986. var C_algo = C.algo;
  29987. var EvpKDF = C_algo.EvpKDF;
  29988. /**
  29989. * Abstract base cipher template.
  29990. *
  29991. * @property {number} keySize This cipher's key size. Default: 4 (128 bits)
  29992. * @property {number} ivSize This cipher's IV size. Default: 4 (128 bits)
  29993. * @property {number} _ENC_XFORM_MODE A constant representing encryption mode.
  29994. * @property {number} _DEC_XFORM_MODE A constant representing decryption mode.
  29995. */
  29996. var Cipher = C_lib.Cipher = BufferedBlockAlgorithm.extend({
  29997. /**
  29998. * Configuration options.
  29999. *
  30000. * @property {WordArray} iv The IV to use for this operation.
  30001. */
  30002. cfg: Base.extend(),
  30003. /**
  30004. * Creates this cipher in encryption mode.
  30005. *
  30006. * @param {WordArray} key The key.
  30007. * @param {Object} cfg (Optional) The configuration options to use for this operation.
  30008. *
  30009. * @return {Cipher} A cipher instance.
  30010. *
  30011. * @static
  30012. *
  30013. * @example
  30014. *
  30015. * var cipher = CryptoJS.algo.AES.createEncryptor(keyWordArray, { iv: ivWordArray });
  30016. */
  30017. createEncryptor: function (key, cfg) {
  30018. return this.create(this._ENC_XFORM_MODE, key, cfg);
  30019. },
  30020. /**
  30021. * Creates this cipher in decryption mode.
  30022. *
  30023. * @param {WordArray} key The key.
  30024. * @param {Object} cfg (Optional) The configuration options to use for this operation.
  30025. *
  30026. * @return {Cipher} A cipher instance.
  30027. *
  30028. * @static
  30029. *
  30030. * @example
  30031. *
  30032. * var cipher = CryptoJS.algo.AES.createDecryptor(keyWordArray, { iv: ivWordArray });
  30033. */
  30034. createDecryptor: function (key, cfg) {
  30035. return this.create(this._DEC_XFORM_MODE, key, cfg);
  30036. },
  30037. /**
  30038. * Initializes a newly created cipher.
  30039. *
  30040. * @param {number} xformMode Either the encryption or decryption transormation mode constant.
  30041. * @param {WordArray} key The key.
  30042. * @param {Object} cfg (Optional) The configuration options to use for this operation.
  30043. *
  30044. * @example
  30045. *
  30046. * var cipher = CryptoJS.algo.AES.create(CryptoJS.algo.AES._ENC_XFORM_MODE, keyWordArray, { iv: ivWordArray });
  30047. */
  30048. init: function (xformMode, key, cfg) {
  30049. // Apply config defaults
  30050. this.cfg = this.cfg.extend(cfg);
  30051. // Store transform mode and key
  30052. this._xformMode = xformMode;
  30053. this._key = key;
  30054. // Set initial values
  30055. this.reset();
  30056. },
  30057. /**
  30058. * Resets this cipher to its initial state.
  30059. *
  30060. * @example
  30061. *
  30062. * cipher.reset();
  30063. */
  30064. reset: function () {
  30065. // Reset data buffer
  30066. BufferedBlockAlgorithm.reset.call(this);
  30067. // Perform concrete-cipher logic
  30068. this._doReset();
  30069. },
  30070. /**
  30071. * Adds data to be encrypted or decrypted.
  30072. *
  30073. * @param {WordArray|string} dataUpdate The data to encrypt or decrypt.
  30074. *
  30075. * @return {WordArray} The data after processing.
  30076. *
  30077. * @example
  30078. *
  30079. * var encrypted = cipher.process('data');
  30080. * var encrypted = cipher.process(wordArray);
  30081. */
  30082. process: function (dataUpdate) {
  30083. // Append
  30084. this._append(dataUpdate);
  30085. // Process available blocks
  30086. return this._process();
  30087. },
  30088. /**
  30089. * Finalizes the encryption or decryption process.
  30090. * Note that the finalize operation is effectively a destructive, read-once operation.
  30091. *
  30092. * @param {WordArray|string} dataUpdate The final data to encrypt or decrypt.
  30093. *
  30094. * @return {WordArray} The data after final processing.
  30095. *
  30096. * @example
  30097. *
  30098. * var encrypted = cipher.finalize();
  30099. * var encrypted = cipher.finalize('data');
  30100. * var encrypted = cipher.finalize(wordArray);
  30101. */
  30102. finalize: function (dataUpdate) {
  30103. // Final data update
  30104. if (dataUpdate) {
  30105. this._append(dataUpdate);
  30106. }
  30107. // Perform concrete-cipher logic
  30108. var finalProcessedData = this._doFinalize();
  30109. return finalProcessedData;
  30110. },
  30111. keySize: 128/32,
  30112. ivSize: 128/32,
  30113. _ENC_XFORM_MODE: 1,
  30114. _DEC_XFORM_MODE: 2,
  30115. /**
  30116. * Creates shortcut functions to a cipher's object interface.
  30117. *
  30118. * @param {Cipher} cipher The cipher to create a helper for.
  30119. *
  30120. * @return {Object} An object with encrypt and decrypt shortcut functions.
  30121. *
  30122. * @static
  30123. *
  30124. * @example
  30125. *
  30126. * var AES = CryptoJS.lib.Cipher._createHelper(CryptoJS.algo.AES);
  30127. */
  30128. _createHelper: (function () {
  30129. function selectCipherStrategy(key) {
  30130. if (typeof key == 'string') {
  30131. return PasswordBasedCipher;
  30132. } else {
  30133. return SerializableCipher;
  30134. }
  30135. }
  30136. return function (cipher) {
  30137. return {
  30138. encrypt: function (message, key, cfg) {
  30139. return selectCipherStrategy(key).encrypt(cipher, message, key, cfg);
  30140. },
  30141. decrypt: function (ciphertext, key, cfg) {
  30142. return selectCipherStrategy(key).decrypt(cipher, ciphertext, key, cfg);
  30143. }
  30144. };
  30145. };
  30146. }())
  30147. });
  30148. /**
  30149. * Abstract base stream cipher template.
  30150. *
  30151. * @property {number} blockSize The number of 32-bit words this cipher operates on. Default: 1 (32 bits)
  30152. */
  30153. var StreamCipher = C_lib.StreamCipher = Cipher.extend({
  30154. _doFinalize: function () {
  30155. // Process partial blocks
  30156. var finalProcessedBlocks = this._process(!!'flush');
  30157. return finalProcessedBlocks;
  30158. },
  30159. blockSize: 1
  30160. });
  30161. /**
  30162. * Mode namespace.
  30163. */
  30164. var C_mode = C.mode = {};
  30165. /**
  30166. * Abstract base block cipher mode template.
  30167. */
  30168. var BlockCipherMode = C_lib.BlockCipherMode = Base.extend({
  30169. /**
  30170. * Creates this mode for encryption.
  30171. *
  30172. * @param {Cipher} cipher A block cipher instance.
  30173. * @param {Array} iv The IV words.
  30174. *
  30175. * @static
  30176. *
  30177. * @example
  30178. *
  30179. * var mode = CryptoJS.mode.CBC.createEncryptor(cipher, iv.words);
  30180. */
  30181. createEncryptor: function (cipher, iv) {
  30182. return this.Encryptor.create(cipher, iv);
  30183. },
  30184. /**
  30185. * Creates this mode for decryption.
  30186. *
  30187. * @param {Cipher} cipher A block cipher instance.
  30188. * @param {Array} iv The IV words.
  30189. *
  30190. * @static
  30191. *
  30192. * @example
  30193. *
  30194. * var mode = CryptoJS.mode.CBC.createDecryptor(cipher, iv.words);
  30195. */
  30196. createDecryptor: function (cipher, iv) {
  30197. return this.Decryptor.create(cipher, iv);
  30198. },
  30199. /**
  30200. * Initializes a newly created mode.
  30201. *
  30202. * @param {Cipher} cipher A block cipher instance.
  30203. * @param {Array} iv The IV words.
  30204. *
  30205. * @example
  30206. *
  30207. * var mode = CryptoJS.mode.CBC.Encryptor.create(cipher, iv.words);
  30208. */
  30209. init: function (cipher, iv) {
  30210. this._cipher = cipher;
  30211. this._iv = iv;
  30212. }
  30213. });
  30214. /**
  30215. * Cipher Block Chaining mode.
  30216. */
  30217. var CBC = C_mode.CBC = (function () {
  30218. /**
  30219. * Abstract base CBC mode.
  30220. */
  30221. var CBC = BlockCipherMode.extend();
  30222. /**
  30223. * CBC encryptor.
  30224. */
  30225. CBC.Encryptor = CBC.extend({
  30226. /**
  30227. * Processes the data block at offset.
  30228. *
  30229. * @param {Array} words The data words to operate on.
  30230. * @param {number} offset The offset where the block starts.
  30231. *
  30232. * @example
  30233. *
  30234. * mode.processBlock(data.words, offset);
  30235. */
  30236. processBlock: function (words, offset) {
  30237. // Shortcuts
  30238. var cipher = this._cipher;
  30239. var blockSize = cipher.blockSize;
  30240. // XOR and encrypt
  30241. xorBlock.call(this, words, offset, blockSize);
  30242. cipher.encryptBlock(words, offset);
  30243. // Remember this block to use with next block
  30244. this._prevBlock = words.slice(offset, offset + blockSize);
  30245. }
  30246. });
  30247. /**
  30248. * CBC decryptor.
  30249. */
  30250. CBC.Decryptor = CBC.extend({
  30251. /**
  30252. * Processes the data block at offset.
  30253. *
  30254. * @param {Array} words The data words to operate on.
  30255. * @param {number} offset The offset where the block starts.
  30256. *
  30257. * @example
  30258. *
  30259. * mode.processBlock(data.words, offset);
  30260. */
  30261. processBlock: function (words, offset) {
  30262. // Shortcuts
  30263. var cipher = this._cipher;
  30264. var blockSize = cipher.blockSize;
  30265. // Remember this block to use with next block
  30266. var thisBlock = words.slice(offset, offset + blockSize);
  30267. // Decrypt and XOR
  30268. cipher.decryptBlock(words, offset);
  30269. xorBlock.call(this, words, offset, blockSize);
  30270. // This block becomes the previous block
  30271. this._prevBlock = thisBlock;
  30272. }
  30273. });
  30274. function xorBlock(words, offset, blockSize) {
  30275. var block;
  30276. // Shortcut
  30277. var iv = this._iv;
  30278. // Choose mixing block
  30279. if (iv) {
  30280. block = iv;
  30281. // Remove IV for subsequent blocks
  30282. this._iv = undefined;
  30283. } else {
  30284. block = this._prevBlock;
  30285. }
  30286. // XOR blocks
  30287. for (var i = 0; i < blockSize; i++) {
  30288. words[offset + i] ^= block[i];
  30289. }
  30290. }
  30291. return CBC;
  30292. }());
  30293. /**
  30294. * Padding namespace.
  30295. */
  30296. var C_pad = C.pad = {};
  30297. /**
  30298. * PKCS #5/7 padding strategy.
  30299. */
  30300. var Pkcs7 = C_pad.Pkcs7 = {
  30301. /**
  30302. * Pads data using the algorithm defined in PKCS #5/7.
  30303. *
  30304. * @param {WordArray} data The data to pad.
  30305. * @param {number} blockSize The multiple that the data should be padded to.
  30306. *
  30307. * @static
  30308. *
  30309. * @example
  30310. *
  30311. * CryptoJS.pad.Pkcs7.pad(wordArray, 4);
  30312. */
  30313. pad: function (data, blockSize) {
  30314. // Shortcut
  30315. var blockSizeBytes = blockSize * 4;
  30316. // Count padding bytes
  30317. var nPaddingBytes = blockSizeBytes - data.sigBytes % blockSizeBytes;
  30318. // Create padding word
  30319. var paddingWord = (nPaddingBytes << 24) | (nPaddingBytes << 16) | (nPaddingBytes << 8) | nPaddingBytes;
  30320. // Create padding
  30321. var paddingWords = [];
  30322. for (var i = 0; i < nPaddingBytes; i += 4) {
  30323. paddingWords.push(paddingWord);
  30324. }
  30325. var padding = WordArray.create(paddingWords, nPaddingBytes);
  30326. // Add padding
  30327. data.concat(padding);
  30328. },
  30329. /**
  30330. * Unpads data that had been padded using the algorithm defined in PKCS #5/7.
  30331. *
  30332. * @param {WordArray} data The data to unpad.
  30333. *
  30334. * @static
  30335. *
  30336. * @example
  30337. *
  30338. * CryptoJS.pad.Pkcs7.unpad(wordArray);
  30339. */
  30340. unpad: function (data) {
  30341. // Get number of padding bytes from last byte
  30342. var nPaddingBytes = data.words[(data.sigBytes - 1) >>> 2] & 0xff;
  30343. // Remove padding
  30344. data.sigBytes -= nPaddingBytes;
  30345. }
  30346. };
  30347. /**
  30348. * Abstract base block cipher template.
  30349. *
  30350. * @property {number} blockSize The number of 32-bit words this cipher operates on. Default: 4 (128 bits)
  30351. */
  30352. var BlockCipher = C_lib.BlockCipher = Cipher.extend({
  30353. /**
  30354. * Configuration options.
  30355. *
  30356. * @property {Mode} mode The block mode to use. Default: CBC
  30357. * @property {Padding} padding The padding strategy to use. Default: Pkcs7
  30358. */
  30359. cfg: Cipher.cfg.extend({
  30360. mode: CBC,
  30361. padding: Pkcs7
  30362. }),
  30363. reset: function () {
  30364. var modeCreator;
  30365. // Reset cipher
  30366. Cipher.reset.call(this);
  30367. // Shortcuts
  30368. var cfg = this.cfg;
  30369. var iv = cfg.iv;
  30370. var mode = cfg.mode;
  30371. // Reset block mode
  30372. if (this._xformMode == this._ENC_XFORM_MODE) {
  30373. modeCreator = mode.createEncryptor;
  30374. } else /* if (this._xformMode == this._DEC_XFORM_MODE) */ {
  30375. modeCreator = mode.createDecryptor;
  30376. // Keep at least one block in the buffer for unpadding
  30377. this._minBufferSize = 1;
  30378. }
  30379. if (this._mode && this._mode.__creator == modeCreator) {
  30380. this._mode.init(this, iv && iv.words);
  30381. } else {
  30382. this._mode = modeCreator.call(mode, this, iv && iv.words);
  30383. this._mode.__creator = modeCreator;
  30384. }
  30385. },
  30386. _doProcessBlock: function (words, offset) {
  30387. this._mode.processBlock(words, offset);
  30388. },
  30389. _doFinalize: function () {
  30390. var finalProcessedBlocks;
  30391. // Shortcut
  30392. var padding = this.cfg.padding;
  30393. // Finalize
  30394. if (this._xformMode == this._ENC_XFORM_MODE) {
  30395. // Pad data
  30396. padding.pad(this._data, this.blockSize);
  30397. // Process final blocks
  30398. finalProcessedBlocks = this._process(!!'flush');
  30399. } else /* if (this._xformMode == this._DEC_XFORM_MODE) */ {
  30400. // Process final blocks
  30401. finalProcessedBlocks = this._process(!!'flush');
  30402. // Unpad data
  30403. padding.unpad(finalProcessedBlocks);
  30404. }
  30405. return finalProcessedBlocks;
  30406. },
  30407. blockSize: 128/32
  30408. });
  30409. /**
  30410. * A collection of cipher parameters.
  30411. *
  30412. * @property {WordArray} ciphertext The raw ciphertext.
  30413. * @property {WordArray} key The key to this ciphertext.
  30414. * @property {WordArray} iv The IV used in the ciphering operation.
  30415. * @property {WordArray} salt The salt used with a key derivation function.
  30416. * @property {Cipher} algorithm The cipher algorithm.
  30417. * @property {Mode} mode The block mode used in the ciphering operation.
  30418. * @property {Padding} padding The padding scheme used in the ciphering operation.
  30419. * @property {number} blockSize The block size of the cipher.
  30420. * @property {Format} formatter The default formatting strategy to convert this cipher params object to a string.
  30421. */
  30422. var CipherParams = C_lib.CipherParams = Base.extend({
  30423. /**
  30424. * Initializes a newly created cipher params object.
  30425. *
  30426. * @param {Object} cipherParams An object with any of the possible cipher parameters.
  30427. *
  30428. * @example
  30429. *
  30430. * var cipherParams = CryptoJS.lib.CipherParams.create({
  30431. * ciphertext: ciphertextWordArray,
  30432. * key: keyWordArray,
  30433. * iv: ivWordArray,
  30434. * salt: saltWordArray,
  30435. * algorithm: CryptoJS.algo.AES,
  30436. * mode: CryptoJS.mode.CBC,
  30437. * padding: CryptoJS.pad.PKCS7,
  30438. * blockSize: 4,
  30439. * formatter: CryptoJS.format.OpenSSL
  30440. * });
  30441. */
  30442. init: function (cipherParams) {
  30443. this.mixIn(cipherParams);
  30444. },
  30445. /**
  30446. * Converts this cipher params object to a string.
  30447. *
  30448. * @param {Format} formatter (Optional) The formatting strategy to use.
  30449. *
  30450. * @return {string} The stringified cipher params.
  30451. *
  30452. * @throws Error If neither the formatter nor the default formatter is set.
  30453. *
  30454. * @example
  30455. *
  30456. * var string = cipherParams + '';
  30457. * var string = cipherParams.toString();
  30458. * var string = cipherParams.toString(CryptoJS.format.OpenSSL);
  30459. */
  30460. toString: function (formatter) {
  30461. return (formatter || this.formatter).stringify(this);
  30462. }
  30463. });
  30464. /**
  30465. * Format namespace.
  30466. */
  30467. var C_format = C.format = {};
  30468. /**
  30469. * OpenSSL formatting strategy.
  30470. */
  30471. var OpenSSLFormatter = C_format.OpenSSL = {
  30472. /**
  30473. * Converts a cipher params object to an OpenSSL-compatible string.
  30474. *
  30475. * @param {CipherParams} cipherParams The cipher params object.
  30476. *
  30477. * @return {string} The OpenSSL-compatible string.
  30478. *
  30479. * @static
  30480. *
  30481. * @example
  30482. *
  30483. * var openSSLString = CryptoJS.format.OpenSSL.stringify(cipherParams);
  30484. */
  30485. stringify: function (cipherParams) {
  30486. var wordArray;
  30487. // Shortcuts
  30488. var ciphertext = cipherParams.ciphertext;
  30489. var salt = cipherParams.salt;
  30490. // Format
  30491. if (salt) {
  30492. wordArray = WordArray.create([0x53616c74, 0x65645f5f]).concat(salt).concat(ciphertext);
  30493. } else {
  30494. wordArray = ciphertext;
  30495. }
  30496. return wordArray.toString(Base64);
  30497. },
  30498. /**
  30499. * Converts an OpenSSL-compatible string to a cipher params object.
  30500. *
  30501. * @param {string} openSSLStr The OpenSSL-compatible string.
  30502. *
  30503. * @return {CipherParams} The cipher params object.
  30504. *
  30505. * @static
  30506. *
  30507. * @example
  30508. *
  30509. * var cipherParams = CryptoJS.format.OpenSSL.parse(openSSLString);
  30510. */
  30511. parse: function (openSSLStr) {
  30512. var salt;
  30513. // Parse base64
  30514. var ciphertext = Base64.parse(openSSLStr);
  30515. // Shortcut
  30516. var ciphertextWords = ciphertext.words;
  30517. // Test for salt
  30518. if (ciphertextWords[0] == 0x53616c74 && ciphertextWords[1] == 0x65645f5f) {
  30519. // Extract salt
  30520. salt = WordArray.create(ciphertextWords.slice(2, 4));
  30521. // Remove salt from ciphertext
  30522. ciphertextWords.splice(0, 4);
  30523. ciphertext.sigBytes -= 16;
  30524. }
  30525. return CipherParams.create({ ciphertext: ciphertext, salt: salt });
  30526. }
  30527. };
  30528. /**
  30529. * A cipher wrapper that returns ciphertext as a serializable cipher params object.
  30530. */
  30531. var SerializableCipher = C_lib.SerializableCipher = Base.extend({
  30532. /**
  30533. * Configuration options.
  30534. *
  30535. * @property {Formatter} format The formatting strategy to convert cipher param objects to and from a string. Default: OpenSSL
  30536. */
  30537. cfg: Base.extend({
  30538. format: OpenSSLFormatter
  30539. }),
  30540. /**
  30541. * Encrypts a message.
  30542. *
  30543. * @param {Cipher} cipher The cipher algorithm to use.
  30544. * @param {WordArray|string} message The message to encrypt.
  30545. * @param {WordArray} key The key.
  30546. * @param {Object} cfg (Optional) The configuration options to use for this operation.
  30547. *
  30548. * @return {CipherParams} A cipher params object.
  30549. *
  30550. * @static
  30551. *
  30552. * @example
  30553. *
  30554. * var ciphertextParams = CryptoJS.lib.SerializableCipher.encrypt(CryptoJS.algo.AES, message, key);
  30555. * var ciphertextParams = CryptoJS.lib.SerializableCipher.encrypt(CryptoJS.algo.AES, message, key, { iv: iv });
  30556. * var ciphertextParams = CryptoJS.lib.SerializableCipher.encrypt(CryptoJS.algo.AES, message, key, { iv: iv, format: CryptoJS.format.OpenSSL });
  30557. */
  30558. encrypt: function (cipher, message, key, cfg) {
  30559. // Apply config defaults
  30560. cfg = this.cfg.extend(cfg);
  30561. // Encrypt
  30562. var encryptor = cipher.createEncryptor(key, cfg);
  30563. var ciphertext = encryptor.finalize(message);
  30564. // Shortcut
  30565. var cipherCfg = encryptor.cfg;
  30566. // Create and return serializable cipher params
  30567. return CipherParams.create({
  30568. ciphertext: ciphertext,
  30569. key: key,
  30570. iv: cipherCfg.iv,
  30571. algorithm: cipher,
  30572. mode: cipherCfg.mode,
  30573. padding: cipherCfg.padding,
  30574. blockSize: cipher.blockSize,
  30575. formatter: cfg.format
  30576. });
  30577. },
  30578. /**
  30579. * Decrypts serialized ciphertext.
  30580. *
  30581. * @param {Cipher} cipher The cipher algorithm to use.
  30582. * @param {CipherParams|string} ciphertext The ciphertext to decrypt.
  30583. * @param {WordArray} key The key.
  30584. * @param {Object} cfg (Optional) The configuration options to use for this operation.
  30585. *
  30586. * @return {WordArray} The plaintext.
  30587. *
  30588. * @static
  30589. *
  30590. * @example
  30591. *
  30592. * var plaintext = CryptoJS.lib.SerializableCipher.decrypt(CryptoJS.algo.AES, formattedCiphertext, key, { iv: iv, format: CryptoJS.format.OpenSSL });
  30593. * var plaintext = CryptoJS.lib.SerializableCipher.decrypt(CryptoJS.algo.AES, ciphertextParams, key, { iv: iv, format: CryptoJS.format.OpenSSL });
  30594. */
  30595. decrypt: function (cipher, ciphertext, key, cfg) {
  30596. // Apply config defaults
  30597. cfg = this.cfg.extend(cfg);
  30598. // Convert string to CipherParams
  30599. ciphertext = this._parse(ciphertext, cfg.format);
  30600. // Decrypt
  30601. var plaintext = cipher.createDecryptor(key, cfg).finalize(ciphertext.ciphertext);
  30602. return plaintext;
  30603. },
  30604. /**
  30605. * Converts serialized ciphertext to CipherParams,
  30606. * else assumed CipherParams already and returns ciphertext unchanged.
  30607. *
  30608. * @param {CipherParams|string} ciphertext The ciphertext.
  30609. * @param {Formatter} format The formatting strategy to use to parse serialized ciphertext.
  30610. *
  30611. * @return {CipherParams} The unserialized ciphertext.
  30612. *
  30613. * @static
  30614. *
  30615. * @example
  30616. *
  30617. * var ciphertextParams = CryptoJS.lib.SerializableCipher._parse(ciphertextStringOrParams, format);
  30618. */
  30619. _parse: function (ciphertext, format) {
  30620. if (typeof ciphertext == 'string') {
  30621. return format.parse(ciphertext, this);
  30622. } else {
  30623. return ciphertext;
  30624. }
  30625. }
  30626. });
  30627. /**
  30628. * Key derivation function namespace.
  30629. */
  30630. var C_kdf = C.kdf = {};
  30631. /**
  30632. * OpenSSL key derivation function.
  30633. */
  30634. var OpenSSLKdf = C_kdf.OpenSSL = {
  30635. /**
  30636. * Derives a key and IV from a password.
  30637. *
  30638. * @param {string} password The password to derive from.
  30639. * @param {number} keySize The size in words of the key to generate.
  30640. * @param {number} ivSize The size in words of the IV to generate.
  30641. * @param {WordArray|string} salt (Optional) A 64-bit salt to use. If omitted, a salt will be generated randomly.
  30642. *
  30643. * @return {CipherParams} A cipher params object with the key, IV, and salt.
  30644. *
  30645. * @static
  30646. *
  30647. * @example
  30648. *
  30649. * var derivedParams = CryptoJS.kdf.OpenSSL.execute('Password', 256/32, 128/32);
  30650. * var derivedParams = CryptoJS.kdf.OpenSSL.execute('Password', 256/32, 128/32, 'saltsalt');
  30651. */
  30652. execute: function (password, keySize, ivSize, salt) {
  30653. // Generate random salt
  30654. if (!salt) {
  30655. salt = WordArray.random(64/8);
  30656. }
  30657. // Derive key and IV
  30658. var key = EvpKDF.create({ keySize: keySize + ivSize }).compute(password, salt);
  30659. // Separate key and IV
  30660. var iv = WordArray.create(key.words.slice(keySize), ivSize * 4);
  30661. key.sigBytes = keySize * 4;
  30662. // Return params
  30663. return CipherParams.create({ key: key, iv: iv, salt: salt });
  30664. }
  30665. };
  30666. /**
  30667. * A serializable cipher wrapper that derives the key from a password,
  30668. * and returns ciphertext as a serializable cipher params object.
  30669. */
  30670. var PasswordBasedCipher = C_lib.PasswordBasedCipher = SerializableCipher.extend({
  30671. /**
  30672. * Configuration options.
  30673. *
  30674. * @property {KDF} kdf The key derivation function to use to generate a key and IV from a password. Default: OpenSSL
  30675. */
  30676. cfg: SerializableCipher.cfg.extend({
  30677. kdf: OpenSSLKdf
  30678. }),
  30679. /**
  30680. * Encrypts a message using a password.
  30681. *
  30682. * @param {Cipher} cipher The cipher algorithm to use.
  30683. * @param {WordArray|string} message The message to encrypt.
  30684. * @param {string} password The password.
  30685. * @param {Object} cfg (Optional) The configuration options to use for this operation.
  30686. *
  30687. * @return {CipherParams} A cipher params object.
  30688. *
  30689. * @static
  30690. *
  30691. * @example
  30692. *
  30693. * var ciphertextParams = CryptoJS.lib.PasswordBasedCipher.encrypt(CryptoJS.algo.AES, message, 'password');
  30694. * var ciphertextParams = CryptoJS.lib.PasswordBasedCipher.encrypt(CryptoJS.algo.AES, message, 'password', { format: CryptoJS.format.OpenSSL });
  30695. */
  30696. encrypt: function (cipher, message, password, cfg) {
  30697. // Apply config defaults
  30698. cfg = this.cfg.extend(cfg);
  30699. // Derive key and other params
  30700. var derivedParams = cfg.kdf.execute(password, cipher.keySize, cipher.ivSize);
  30701. // Add IV to config
  30702. cfg.iv = derivedParams.iv;
  30703. // Encrypt
  30704. var ciphertext = SerializableCipher.encrypt.call(this, cipher, message, derivedParams.key, cfg);
  30705. // Mix in derived params
  30706. ciphertext.mixIn(derivedParams);
  30707. return ciphertext;
  30708. },
  30709. /**
  30710. * Decrypts serialized ciphertext using a password.
  30711. *
  30712. * @param {Cipher} cipher The cipher algorithm to use.
  30713. * @param {CipherParams|string} ciphertext The ciphertext to decrypt.
  30714. * @param {string} password The password.
  30715. * @param {Object} cfg (Optional) The configuration options to use for this operation.
  30716. *
  30717. * @return {WordArray} The plaintext.
  30718. *
  30719. * @static
  30720. *
  30721. * @example
  30722. *
  30723. * var plaintext = CryptoJS.lib.PasswordBasedCipher.decrypt(CryptoJS.algo.AES, formattedCiphertext, 'password', { format: CryptoJS.format.OpenSSL });
  30724. * var plaintext = CryptoJS.lib.PasswordBasedCipher.decrypt(CryptoJS.algo.AES, ciphertextParams, 'password', { format: CryptoJS.format.OpenSSL });
  30725. */
  30726. decrypt: function (cipher, ciphertext, password, cfg) {
  30727. // Apply config defaults
  30728. cfg = this.cfg.extend(cfg);
  30729. // Convert string to CipherParams
  30730. ciphertext = this._parse(ciphertext, cfg.format);
  30731. // Derive key and other params
  30732. var derivedParams = cfg.kdf.execute(password, cipher.keySize, cipher.ivSize, ciphertext.salt);
  30733. // Add IV to config
  30734. cfg.iv = derivedParams.iv;
  30735. // Decrypt
  30736. var plaintext = SerializableCipher.decrypt.call(this, cipher, ciphertext, derivedParams.key, cfg);
  30737. return plaintext;
  30738. }
  30739. });
  30740. }());
  30741. }));
  30742. },{"./core":598,"./evpkdf":601}],598:[function(_dereq_,module,exports){
  30743. (function (global){(function (){
  30744. ;(function (root, factory) {
  30745. if (typeof exports === "object") {
  30746. // CommonJS
  30747. module.exports = exports = factory();
  30748. }
  30749. else if (typeof define === "function" && define.amd) {
  30750. // AMD
  30751. define([], factory);
  30752. }
  30753. else {
  30754. // Global (browser)
  30755. root.CryptoJS = factory();
  30756. }
  30757. }(this, function () {
  30758. /*globals window, global, require*/
  30759. /**
  30760. * CryptoJS core components.
  30761. */
  30762. var CryptoJS = CryptoJS || (function (Math, undefined) {
  30763. var crypto;
  30764. // Native crypto from window (Browser)
  30765. if (typeof window !== 'undefined' && window.crypto) {
  30766. crypto = window.crypto;
  30767. }
  30768. // Native crypto in web worker (Browser)
  30769. if (typeof self !== 'undefined' && self.crypto) {
  30770. crypto = self.crypto;
  30771. }
  30772. // Native crypto from worker
  30773. if (typeof globalThis !== 'undefined' && globalThis.crypto) {
  30774. crypto = globalThis.crypto;
  30775. }
  30776. // Native (experimental IE 11) crypto from window (Browser)
  30777. if (!crypto && typeof window !== 'undefined' && window.msCrypto) {
  30778. crypto = window.msCrypto;
  30779. }
  30780. // Native crypto from global (NodeJS)
  30781. if (!crypto && typeof global !== 'undefined' && global.crypto) {
  30782. crypto = global.crypto;
  30783. }
  30784. // Native crypto import via require (NodeJS)
  30785. if (!crypto && typeof _dereq_ === 'function') {
  30786. try {
  30787. crypto = _dereq_('crypto');
  30788. } catch (err) {}
  30789. }
  30790. /*
  30791. * Cryptographically secure pseudorandom number generator
  30792. *
  30793. * As Math.random() is cryptographically not safe to use
  30794. */
  30795. var cryptoSecureRandomInt = function () {
  30796. if (crypto) {
  30797. // Use getRandomValues method (Browser)
  30798. if (typeof crypto.getRandomValues === 'function') {
  30799. try {
  30800. return crypto.getRandomValues(new Uint32Array(1))[0];
  30801. } catch (err) {}
  30802. }
  30803. // Use randomBytes method (NodeJS)
  30804. if (typeof crypto.randomBytes === 'function') {
  30805. try {
  30806. return crypto.randomBytes(4).readInt32LE();
  30807. } catch (err) {}
  30808. }
  30809. }
  30810. throw new Error('Native crypto module could not be used to get secure random number.');
  30811. };
  30812. /*
  30813. * Local polyfill of Object.create
  30814. */
  30815. var create = Object.create || (function () {
  30816. function F() {}
  30817. return function (obj) {
  30818. var subtype;
  30819. F.prototype = obj;
  30820. subtype = new F();
  30821. F.prototype = null;
  30822. return subtype;
  30823. };
  30824. }());
  30825. /**
  30826. * CryptoJS namespace.
  30827. */
  30828. var C = {};
  30829. /**
  30830. * Library namespace.
  30831. */
  30832. var C_lib = C.lib = {};
  30833. /**
  30834. * Base object for prototypal inheritance.
  30835. */
  30836. var Base = C_lib.Base = (function () {
  30837. return {
  30838. /**
  30839. * Creates a new object that inherits from this object.
  30840. *
  30841. * @param {Object} overrides Properties to copy into the new object.
  30842. *
  30843. * @return {Object} The new object.
  30844. *
  30845. * @static
  30846. *
  30847. * @example
  30848. *
  30849. * var MyType = CryptoJS.lib.Base.extend({
  30850. * field: 'value',
  30851. *
  30852. * method: function () {
  30853. * }
  30854. * });
  30855. */
  30856. extend: function (overrides) {
  30857. // Spawn
  30858. var subtype = create(this);
  30859. // Augment
  30860. if (overrides) {
  30861. subtype.mixIn(overrides);
  30862. }
  30863. // Create default initializer
  30864. if (!subtype.hasOwnProperty('init') || this.init === subtype.init) {
  30865. subtype.init = function () {
  30866. subtype.$super.init.apply(this, arguments);
  30867. };
  30868. }
  30869. // Initializer's prototype is the subtype object
  30870. subtype.init.prototype = subtype;
  30871. // Reference supertype
  30872. subtype.$super = this;
  30873. return subtype;
  30874. },
  30875. /**
  30876. * Extends this object and runs the init method.
  30877. * Arguments to create() will be passed to init().
  30878. *
  30879. * @return {Object} The new object.
  30880. *
  30881. * @static
  30882. *
  30883. * @example
  30884. *
  30885. * var instance = MyType.create();
  30886. */
  30887. create: function () {
  30888. var instance = this.extend();
  30889. instance.init.apply(instance, arguments);
  30890. return instance;
  30891. },
  30892. /**
  30893. * Initializes a newly created object.
  30894. * Override this method to add some logic when your objects are created.
  30895. *
  30896. * @example
  30897. *
  30898. * var MyType = CryptoJS.lib.Base.extend({
  30899. * init: function () {
  30900. * // ...
  30901. * }
  30902. * });
  30903. */
  30904. init: function () {
  30905. },
  30906. /**
  30907. * Copies properties into this object.
  30908. *
  30909. * @param {Object} properties The properties to mix in.
  30910. *
  30911. * @example
  30912. *
  30913. * MyType.mixIn({
  30914. * field: 'value'
  30915. * });
  30916. */
  30917. mixIn: function (properties) {
  30918. for (var propertyName in properties) {
  30919. if (properties.hasOwnProperty(propertyName)) {
  30920. this[propertyName] = properties[propertyName];
  30921. }
  30922. }
  30923. // IE won't copy toString using the loop above
  30924. if (properties.hasOwnProperty('toString')) {
  30925. this.toString = properties.toString;
  30926. }
  30927. },
  30928. /**
  30929. * Creates a copy of this object.
  30930. *
  30931. * @return {Object} The clone.
  30932. *
  30933. * @example
  30934. *
  30935. * var clone = instance.clone();
  30936. */
  30937. clone: function () {
  30938. return this.init.prototype.extend(this);
  30939. }
  30940. };
  30941. }());
  30942. /**
  30943. * An array of 32-bit words.
  30944. *
  30945. * @property {Array} words The array of 32-bit words.
  30946. * @property {number} sigBytes The number of significant bytes in this word array.
  30947. */
  30948. var WordArray = C_lib.WordArray = Base.extend({
  30949. /**
  30950. * Initializes a newly created word array.
  30951. *
  30952. * @param {Array} words (Optional) An array of 32-bit words.
  30953. * @param {number} sigBytes (Optional) The number of significant bytes in the words.
  30954. *
  30955. * @example
  30956. *
  30957. * var wordArray = CryptoJS.lib.WordArray.create();
  30958. * var wordArray = CryptoJS.lib.WordArray.create([0x00010203, 0x04050607]);
  30959. * var wordArray = CryptoJS.lib.WordArray.create([0x00010203, 0x04050607], 6);
  30960. */
  30961. init: function (words, sigBytes) {
  30962. words = this.words = words || [];
  30963. if (sigBytes != undefined) {
  30964. this.sigBytes = sigBytes;
  30965. } else {
  30966. this.sigBytes = words.length * 4;
  30967. }
  30968. },
  30969. /**
  30970. * Converts this word array to a string.
  30971. *
  30972. * @param {Encoder} encoder (Optional) The encoding strategy to use. Default: CryptoJS.enc.Hex
  30973. *
  30974. * @return {string} The stringified word array.
  30975. *
  30976. * @example
  30977. *
  30978. * var string = wordArray + '';
  30979. * var string = wordArray.toString();
  30980. * var string = wordArray.toString(CryptoJS.enc.Utf8);
  30981. */
  30982. toString: function (encoder) {
  30983. return (encoder || Hex).stringify(this);
  30984. },
  30985. /**
  30986. * Concatenates a word array to this word array.
  30987. *
  30988. * @param {WordArray} wordArray The word array to append.
  30989. *
  30990. * @return {WordArray} This word array.
  30991. *
  30992. * @example
  30993. *
  30994. * wordArray1.concat(wordArray2);
  30995. */
  30996. concat: function (wordArray) {
  30997. // Shortcuts
  30998. var thisWords = this.words;
  30999. var thatWords = wordArray.words;
  31000. var thisSigBytes = this.sigBytes;
  31001. var thatSigBytes = wordArray.sigBytes;
  31002. // Clamp excess bits
  31003. this.clamp();
  31004. // Concat
  31005. if (thisSigBytes % 4) {
  31006. // Copy one byte at a time
  31007. for (var i = 0; i < thatSigBytes; i++) {
  31008. var thatByte = (thatWords[i >>> 2] >>> (24 - (i % 4) * 8)) & 0xff;
  31009. thisWords[(thisSigBytes + i) >>> 2] |= thatByte << (24 - ((thisSigBytes + i) % 4) * 8);
  31010. }
  31011. } else {
  31012. // Copy one word at a time
  31013. for (var j = 0; j < thatSigBytes; j += 4) {
  31014. thisWords[(thisSigBytes + j) >>> 2] = thatWords[j >>> 2];
  31015. }
  31016. }
  31017. this.sigBytes += thatSigBytes;
  31018. // Chainable
  31019. return this;
  31020. },
  31021. /**
  31022. * Removes insignificant bits.
  31023. *
  31024. * @example
  31025. *
  31026. * wordArray.clamp();
  31027. */
  31028. clamp: function () {
  31029. // Shortcuts
  31030. var words = this.words;
  31031. var sigBytes = this.sigBytes;
  31032. // Clamp
  31033. words[sigBytes >>> 2] &= 0xffffffff << (32 - (sigBytes % 4) * 8);
  31034. words.length = Math.ceil(sigBytes / 4);
  31035. },
  31036. /**
  31037. * Creates a copy of this word array.
  31038. *
  31039. * @return {WordArray} The clone.
  31040. *
  31041. * @example
  31042. *
  31043. * var clone = wordArray.clone();
  31044. */
  31045. clone: function () {
  31046. var clone = Base.clone.call(this);
  31047. clone.words = this.words.slice(0);
  31048. return clone;
  31049. },
  31050. /**
  31051. * Creates a word array filled with random bytes.
  31052. *
  31053. * @param {number} nBytes The number of random bytes to generate.
  31054. *
  31055. * @return {WordArray} The random word array.
  31056. *
  31057. * @static
  31058. *
  31059. * @example
  31060. *
  31061. * var wordArray = CryptoJS.lib.WordArray.random(16);
  31062. */
  31063. random: function (nBytes) {
  31064. var words = [];
  31065. for (var i = 0; i < nBytes; i += 4) {
  31066. words.push(cryptoSecureRandomInt());
  31067. }
  31068. return new WordArray.init(words, nBytes);
  31069. }
  31070. });
  31071. /**
  31072. * Encoder namespace.
  31073. */
  31074. var C_enc = C.enc = {};
  31075. /**
  31076. * Hex encoding strategy.
  31077. */
  31078. var Hex = C_enc.Hex = {
  31079. /**
  31080. * Converts a word array to a hex string.
  31081. *
  31082. * @param {WordArray} wordArray The word array.
  31083. *
  31084. * @return {string} The hex string.
  31085. *
  31086. * @static
  31087. *
  31088. * @example
  31089. *
  31090. * var hexString = CryptoJS.enc.Hex.stringify(wordArray);
  31091. */
  31092. stringify: function (wordArray) {
  31093. // Shortcuts
  31094. var words = wordArray.words;
  31095. var sigBytes = wordArray.sigBytes;
  31096. // Convert
  31097. var hexChars = [];
  31098. for (var i = 0; i < sigBytes; i++) {
  31099. var bite = (words[i >>> 2] >>> (24 - (i % 4) * 8)) & 0xff;
  31100. hexChars.push((bite >>> 4).toString(16));
  31101. hexChars.push((bite & 0x0f).toString(16));
  31102. }
  31103. return hexChars.join('');
  31104. },
  31105. /**
  31106. * Converts a hex string to a word array.
  31107. *
  31108. * @param {string} hexStr The hex string.
  31109. *
  31110. * @return {WordArray} The word array.
  31111. *
  31112. * @static
  31113. *
  31114. * @example
  31115. *
  31116. * var wordArray = CryptoJS.enc.Hex.parse(hexString);
  31117. */
  31118. parse: function (hexStr) {
  31119. // Shortcut
  31120. var hexStrLength = hexStr.length;
  31121. // Convert
  31122. var words = [];
  31123. for (var i = 0; i < hexStrLength; i += 2) {
  31124. words[i >>> 3] |= parseInt(hexStr.substr(i, 2), 16) << (24 - (i % 8) * 4);
  31125. }
  31126. return new WordArray.init(words, hexStrLength / 2);
  31127. }
  31128. };
  31129. /**
  31130. * Latin1 encoding strategy.
  31131. */
  31132. var Latin1 = C_enc.Latin1 = {
  31133. /**
  31134. * Converts a word array to a Latin1 string.
  31135. *
  31136. * @param {WordArray} wordArray The word array.
  31137. *
  31138. * @return {string} The Latin1 string.
  31139. *
  31140. * @static
  31141. *
  31142. * @example
  31143. *
  31144. * var latin1String = CryptoJS.enc.Latin1.stringify(wordArray);
  31145. */
  31146. stringify: function (wordArray) {
  31147. // Shortcuts
  31148. var words = wordArray.words;
  31149. var sigBytes = wordArray.sigBytes;
  31150. // Convert
  31151. var latin1Chars = [];
  31152. for (var i = 0; i < sigBytes; i++) {
  31153. var bite = (words[i >>> 2] >>> (24 - (i % 4) * 8)) & 0xff;
  31154. latin1Chars.push(String.fromCharCode(bite));
  31155. }
  31156. return latin1Chars.join('');
  31157. },
  31158. /**
  31159. * Converts a Latin1 string to a word array.
  31160. *
  31161. * @param {string} latin1Str The Latin1 string.
  31162. *
  31163. * @return {WordArray} The word array.
  31164. *
  31165. * @static
  31166. *
  31167. * @example
  31168. *
  31169. * var wordArray = CryptoJS.enc.Latin1.parse(latin1String);
  31170. */
  31171. parse: function (latin1Str) {
  31172. // Shortcut
  31173. var latin1StrLength = latin1Str.length;
  31174. // Convert
  31175. var words = [];
  31176. for (var i = 0; i < latin1StrLength; i++) {
  31177. words[i >>> 2] |= (latin1Str.charCodeAt(i) & 0xff) << (24 - (i % 4) * 8);
  31178. }
  31179. return new WordArray.init(words, latin1StrLength);
  31180. }
  31181. };
  31182. /**
  31183. * UTF-8 encoding strategy.
  31184. */
  31185. var Utf8 = C_enc.Utf8 = {
  31186. /**
  31187. * Converts a word array to a UTF-8 string.
  31188. *
  31189. * @param {WordArray} wordArray The word array.
  31190. *
  31191. * @return {string} The UTF-8 string.
  31192. *
  31193. * @static
  31194. *
  31195. * @example
  31196. *
  31197. * var utf8String = CryptoJS.enc.Utf8.stringify(wordArray);
  31198. */
  31199. stringify: function (wordArray) {
  31200. try {
  31201. return decodeURIComponent(escape(Latin1.stringify(wordArray)));
  31202. } catch (e) {
  31203. throw new Error('Malformed UTF-8 data');
  31204. }
  31205. },
  31206. /**
  31207. * Converts a UTF-8 string to a word array.
  31208. *
  31209. * @param {string} utf8Str The UTF-8 string.
  31210. *
  31211. * @return {WordArray} The word array.
  31212. *
  31213. * @static
  31214. *
  31215. * @example
  31216. *
  31217. * var wordArray = CryptoJS.enc.Utf8.parse(utf8String);
  31218. */
  31219. parse: function (utf8Str) {
  31220. return Latin1.parse(unescape(encodeURIComponent(utf8Str)));
  31221. }
  31222. };
  31223. /**
  31224. * Abstract buffered block algorithm template.
  31225. *
  31226. * The property blockSize must be implemented in a concrete subtype.
  31227. *
  31228. * @property {number} _minBufferSize The number of blocks that should be kept unprocessed in the buffer. Default: 0
  31229. */
  31230. var BufferedBlockAlgorithm = C_lib.BufferedBlockAlgorithm = Base.extend({
  31231. /**
  31232. * Resets this block algorithm's data buffer to its initial state.
  31233. *
  31234. * @example
  31235. *
  31236. * bufferedBlockAlgorithm.reset();
  31237. */
  31238. reset: function () {
  31239. // Initial values
  31240. this._data = new WordArray.init();
  31241. this._nDataBytes = 0;
  31242. },
  31243. /**
  31244. * Adds new data to this block algorithm's buffer.
  31245. *
  31246. * @param {WordArray|string} data The data to append. Strings are converted to a WordArray using UTF-8.
  31247. *
  31248. * @example
  31249. *
  31250. * bufferedBlockAlgorithm._append('data');
  31251. * bufferedBlockAlgorithm._append(wordArray);
  31252. */
  31253. _append: function (data) {
  31254. // Convert string to WordArray, else assume WordArray already
  31255. if (typeof data == 'string') {
  31256. data = Utf8.parse(data);
  31257. }
  31258. // Append
  31259. this._data.concat(data);
  31260. this._nDataBytes += data.sigBytes;
  31261. },
  31262. /**
  31263. * Processes available data blocks.
  31264. *
  31265. * This method invokes _doProcessBlock(offset), which must be implemented by a concrete subtype.
  31266. *
  31267. * @param {boolean} doFlush Whether all blocks and partial blocks should be processed.
  31268. *
  31269. * @return {WordArray} The processed data.
  31270. *
  31271. * @example
  31272. *
  31273. * var processedData = bufferedBlockAlgorithm._process();
  31274. * var processedData = bufferedBlockAlgorithm._process(!!'flush');
  31275. */
  31276. _process: function (doFlush) {
  31277. var processedWords;
  31278. // Shortcuts
  31279. var data = this._data;
  31280. var dataWords = data.words;
  31281. var dataSigBytes = data.sigBytes;
  31282. var blockSize = this.blockSize;
  31283. var blockSizeBytes = blockSize * 4;
  31284. // Count blocks ready
  31285. var nBlocksReady = dataSigBytes / blockSizeBytes;
  31286. if (doFlush) {
  31287. // Round up to include partial blocks
  31288. nBlocksReady = Math.ceil(nBlocksReady);
  31289. } else {
  31290. // Round down to include only full blocks,
  31291. // less the number of blocks that must remain in the buffer
  31292. nBlocksReady = Math.max((nBlocksReady | 0) - this._minBufferSize, 0);
  31293. }
  31294. // Count words ready
  31295. var nWordsReady = nBlocksReady * blockSize;
  31296. // Count bytes ready
  31297. var nBytesReady = Math.min(nWordsReady * 4, dataSigBytes);
  31298. // Process blocks
  31299. if (nWordsReady) {
  31300. for (var offset = 0; offset < nWordsReady; offset += blockSize) {
  31301. // Perform concrete-algorithm logic
  31302. this._doProcessBlock(dataWords, offset);
  31303. }
  31304. // Remove processed words
  31305. processedWords = dataWords.splice(0, nWordsReady);
  31306. data.sigBytes -= nBytesReady;
  31307. }
  31308. // Return processed words
  31309. return new WordArray.init(processedWords, nBytesReady);
  31310. },
  31311. /**
  31312. * Creates a copy of this object.
  31313. *
  31314. * @return {Object} The clone.
  31315. *
  31316. * @example
  31317. *
  31318. * var clone = bufferedBlockAlgorithm.clone();
  31319. */
  31320. clone: function () {
  31321. var clone = Base.clone.call(this);
  31322. clone._data = this._data.clone();
  31323. return clone;
  31324. },
  31325. _minBufferSize: 0
  31326. });
  31327. /**
  31328. * Abstract hasher template.
  31329. *
  31330. * @property {number} blockSize The number of 32-bit words this hasher operates on. Default: 16 (512 bits)
  31331. */
  31332. var Hasher = C_lib.Hasher = BufferedBlockAlgorithm.extend({
  31333. /**
  31334. * Configuration options.
  31335. */
  31336. cfg: Base.extend(),
  31337. /**
  31338. * Initializes a newly created hasher.
  31339. *
  31340. * @param {Object} cfg (Optional) The configuration options to use for this hash computation.
  31341. *
  31342. * @example
  31343. *
  31344. * var hasher = CryptoJS.algo.SHA256.create();
  31345. */
  31346. init: function (cfg) {
  31347. // Apply config defaults
  31348. this.cfg = this.cfg.extend(cfg);
  31349. // Set initial values
  31350. this.reset();
  31351. },
  31352. /**
  31353. * Resets this hasher to its initial state.
  31354. *
  31355. * @example
  31356. *
  31357. * hasher.reset();
  31358. */
  31359. reset: function () {
  31360. // Reset data buffer
  31361. BufferedBlockAlgorithm.reset.call(this);
  31362. // Perform concrete-hasher logic
  31363. this._doReset();
  31364. },
  31365. /**
  31366. * Updates this hasher with a message.
  31367. *
  31368. * @param {WordArray|string} messageUpdate The message to append.
  31369. *
  31370. * @return {Hasher} This hasher.
  31371. *
  31372. * @example
  31373. *
  31374. * hasher.update('message');
  31375. * hasher.update(wordArray);
  31376. */
  31377. update: function (messageUpdate) {
  31378. // Append
  31379. this._append(messageUpdate);
  31380. // Update the hash
  31381. this._process();
  31382. // Chainable
  31383. return this;
  31384. },
  31385. /**
  31386. * Finalizes the hash computation.
  31387. * Note that the finalize operation is effectively a destructive, read-once operation.
  31388. *
  31389. * @param {WordArray|string} messageUpdate (Optional) A final message update.
  31390. *
  31391. * @return {WordArray} The hash.
  31392. *
  31393. * @example
  31394. *
  31395. * var hash = hasher.finalize();
  31396. * var hash = hasher.finalize('message');
  31397. * var hash = hasher.finalize(wordArray);
  31398. */
  31399. finalize: function (messageUpdate) {
  31400. // Final message update
  31401. if (messageUpdate) {
  31402. this._append(messageUpdate);
  31403. }
  31404. // Perform concrete-hasher logic
  31405. var hash = this._doFinalize();
  31406. return hash;
  31407. },
  31408. blockSize: 512/32,
  31409. /**
  31410. * Creates a shortcut function to a hasher's object interface.
  31411. *
  31412. * @param {Hasher} hasher The hasher to create a helper for.
  31413. *
  31414. * @return {Function} The shortcut function.
  31415. *
  31416. * @static
  31417. *
  31418. * @example
  31419. *
  31420. * var SHA256 = CryptoJS.lib.Hasher._createHelper(CryptoJS.algo.SHA256);
  31421. */
  31422. _createHelper: function (hasher) {
  31423. return function (message, cfg) {
  31424. return new hasher.init(cfg).finalize(message);
  31425. };
  31426. },
  31427. /**
  31428. * Creates a shortcut function to the HMAC's object interface.
  31429. *
  31430. * @param {Hasher} hasher The hasher to use in this HMAC helper.
  31431. *
  31432. * @return {Function} The shortcut function.
  31433. *
  31434. * @static
  31435. *
  31436. * @example
  31437. *
  31438. * var HmacSHA256 = CryptoJS.lib.Hasher._createHmacHelper(CryptoJS.algo.SHA256);
  31439. */
  31440. _createHmacHelper: function (hasher) {
  31441. return function (message, key) {
  31442. return new C_algo.HMAC.init(hasher, key).finalize(message);
  31443. };
  31444. }
  31445. });
  31446. /**
  31447. * Algorithm namespace.
  31448. */
  31449. var C_algo = C.algo = {};
  31450. return C;
  31451. }(Math));
  31452. return CryptoJS;
  31453. }));
  31454. }).call(this)}).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {})
  31455. },{"crypto":undefined}],599:[function(_dereq_,module,exports){
  31456. ;(function (root, factory) {
  31457. if (typeof exports === "object") {
  31458. // CommonJS
  31459. module.exports = exports = factory(_dereq_("./core"));
  31460. }
  31461. else if (typeof define === "function" && define.amd) {
  31462. // AMD
  31463. define(["./core"], factory);
  31464. }
  31465. else {
  31466. // Global (browser)
  31467. factory(root.CryptoJS);
  31468. }
  31469. }(this, function (CryptoJS) {
  31470. (function () {
  31471. // Shortcuts
  31472. var C = CryptoJS;
  31473. var C_lib = C.lib;
  31474. var WordArray = C_lib.WordArray;
  31475. var C_enc = C.enc;
  31476. /**
  31477. * Base64 encoding strategy.
  31478. */
  31479. var Base64 = C_enc.Base64 = {
  31480. /**
  31481. * Converts a word array to a Base64 string.
  31482. *
  31483. * @param {WordArray} wordArray The word array.
  31484. *
  31485. * @return {string} The Base64 string.
  31486. *
  31487. * @static
  31488. *
  31489. * @example
  31490. *
  31491. * var base64String = CryptoJS.enc.Base64.stringify(wordArray);
  31492. */
  31493. stringify: function (wordArray) {
  31494. // Shortcuts
  31495. var words = wordArray.words;
  31496. var sigBytes = wordArray.sigBytes;
  31497. var map = this._map;
  31498. // Clamp excess bits
  31499. wordArray.clamp();
  31500. // Convert
  31501. var base64Chars = [];
  31502. for (var i = 0; i < sigBytes; i += 3) {
  31503. var byte1 = (words[i >>> 2] >>> (24 - (i % 4) * 8)) & 0xff;
  31504. var byte2 = (words[(i + 1) >>> 2] >>> (24 - ((i + 1) % 4) * 8)) & 0xff;
  31505. var byte3 = (words[(i + 2) >>> 2] >>> (24 - ((i + 2) % 4) * 8)) & 0xff;
  31506. var triplet = (byte1 << 16) | (byte2 << 8) | byte3;
  31507. for (var j = 0; (j < 4) && (i + j * 0.75 < sigBytes); j++) {
  31508. base64Chars.push(map.charAt((triplet >>> (6 * (3 - j))) & 0x3f));
  31509. }
  31510. }
  31511. // Add padding
  31512. var paddingChar = map.charAt(64);
  31513. if (paddingChar) {
  31514. while (base64Chars.length % 4) {
  31515. base64Chars.push(paddingChar);
  31516. }
  31517. }
  31518. return base64Chars.join('');
  31519. },
  31520. /**
  31521. * Converts a Base64 string to a word array.
  31522. *
  31523. * @param {string} base64Str The Base64 string.
  31524. *
  31525. * @return {WordArray} The word array.
  31526. *
  31527. * @static
  31528. *
  31529. * @example
  31530. *
  31531. * var wordArray = CryptoJS.enc.Base64.parse(base64String);
  31532. */
  31533. parse: function (base64Str) {
  31534. // Shortcuts
  31535. var base64StrLength = base64Str.length;
  31536. var map = this._map;
  31537. var reverseMap = this._reverseMap;
  31538. if (!reverseMap) {
  31539. reverseMap = this._reverseMap = [];
  31540. for (var j = 0; j < map.length; j++) {
  31541. reverseMap[map.charCodeAt(j)] = j;
  31542. }
  31543. }
  31544. // Ignore padding
  31545. var paddingChar = map.charAt(64);
  31546. if (paddingChar) {
  31547. var paddingIndex = base64Str.indexOf(paddingChar);
  31548. if (paddingIndex !== -1) {
  31549. base64StrLength = paddingIndex;
  31550. }
  31551. }
  31552. // Convert
  31553. return parseLoop(base64Str, base64StrLength, reverseMap);
  31554. },
  31555. _map: 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/='
  31556. };
  31557. function parseLoop(base64Str, base64StrLength, reverseMap) {
  31558. var words = [];
  31559. var nBytes = 0;
  31560. for (var i = 0; i < base64StrLength; i++) {
  31561. if (i % 4) {
  31562. var bits1 = reverseMap[base64Str.charCodeAt(i - 1)] << ((i % 4) * 2);
  31563. var bits2 = reverseMap[base64Str.charCodeAt(i)] >>> (6 - (i % 4) * 2);
  31564. var bitsCombined = bits1 | bits2;
  31565. words[nBytes >>> 2] |= bitsCombined << (24 - (nBytes % 4) * 8);
  31566. nBytes++;
  31567. }
  31568. }
  31569. return WordArray.create(words, nBytes);
  31570. }
  31571. }());
  31572. return CryptoJS.enc.Base64;
  31573. }));
  31574. },{"./core":598}],600:[function(_dereq_,module,exports){
  31575. ;(function (root, factory) {
  31576. if (typeof exports === "object") {
  31577. // CommonJS
  31578. module.exports = exports = factory(_dereq_("./core"));
  31579. }
  31580. else if (typeof define === "function" && define.amd) {
  31581. // AMD
  31582. define(["./core"], factory);
  31583. }
  31584. else {
  31585. // Global (browser)
  31586. factory(root.CryptoJS);
  31587. }
  31588. }(this, function (CryptoJS) {
  31589. return CryptoJS.enc.Utf8;
  31590. }));
  31591. },{"./core":598}],601:[function(_dereq_,module,exports){
  31592. ;(function (root, factory, undef) {
  31593. if (typeof exports === "object") {
  31594. // CommonJS
  31595. module.exports = exports = factory(_dereq_("./core"), _dereq_("./sha1"), _dereq_("./hmac"));
  31596. }
  31597. else if (typeof define === "function" && define.amd) {
  31598. // AMD
  31599. define(["./core", "./sha1", "./hmac"], factory);
  31600. }
  31601. else {
  31602. // Global (browser)
  31603. factory(root.CryptoJS);
  31604. }
  31605. }(this, function (CryptoJS) {
  31606. (function () {
  31607. // Shortcuts
  31608. var C = CryptoJS;
  31609. var C_lib = C.lib;
  31610. var Base = C_lib.Base;
  31611. var WordArray = C_lib.WordArray;
  31612. var C_algo = C.algo;
  31613. var MD5 = C_algo.MD5;
  31614. /**
  31615. * This key derivation function is meant to conform with EVP_BytesToKey.
  31616. * www.openssl.org/docs/crypto/EVP_BytesToKey.html
  31617. */
  31618. var EvpKDF = C_algo.EvpKDF = Base.extend({
  31619. /**
  31620. * Configuration options.
  31621. *
  31622. * @property {number} keySize The key size in words to generate. Default: 4 (128 bits)
  31623. * @property {Hasher} hasher The hash algorithm to use. Default: MD5
  31624. * @property {number} iterations The number of iterations to perform. Default: 1
  31625. */
  31626. cfg: Base.extend({
  31627. keySize: 128/32,
  31628. hasher: MD5,
  31629. iterations: 1
  31630. }),
  31631. /**
  31632. * Initializes a newly created key derivation function.
  31633. *
  31634. * @param {Object} cfg (Optional) The configuration options to use for the derivation.
  31635. *
  31636. * @example
  31637. *
  31638. * var kdf = CryptoJS.algo.EvpKDF.create();
  31639. * var kdf = CryptoJS.algo.EvpKDF.create({ keySize: 8 });
  31640. * var kdf = CryptoJS.algo.EvpKDF.create({ keySize: 8, iterations: 1000 });
  31641. */
  31642. init: function (cfg) {
  31643. this.cfg = this.cfg.extend(cfg);
  31644. },
  31645. /**
  31646. * Derives a key from a password.
  31647. *
  31648. * @param {WordArray|string} password The password.
  31649. * @param {WordArray|string} salt A salt.
  31650. *
  31651. * @return {WordArray} The derived key.
  31652. *
  31653. * @example
  31654. *
  31655. * var key = kdf.compute(password, salt);
  31656. */
  31657. compute: function (password, salt) {
  31658. var block;
  31659. // Shortcut
  31660. var cfg = this.cfg;
  31661. // Init hasher
  31662. var hasher = cfg.hasher.create();
  31663. // Initial values
  31664. var derivedKey = WordArray.create();
  31665. // Shortcuts
  31666. var derivedKeyWords = derivedKey.words;
  31667. var keySize = cfg.keySize;
  31668. var iterations = cfg.iterations;
  31669. // Generate key
  31670. while (derivedKeyWords.length < keySize) {
  31671. if (block) {
  31672. hasher.update(block);
  31673. }
  31674. block = hasher.update(password).finalize(salt);
  31675. hasher.reset();
  31676. // Iterations
  31677. for (var i = 1; i < iterations; i++) {
  31678. block = hasher.finalize(block);
  31679. hasher.reset();
  31680. }
  31681. derivedKey.concat(block);
  31682. }
  31683. derivedKey.sigBytes = keySize * 4;
  31684. return derivedKey;
  31685. }
  31686. });
  31687. /**
  31688. * Derives a key from a password.
  31689. *
  31690. * @param {WordArray|string} password The password.
  31691. * @param {WordArray|string} salt A salt.
  31692. * @param {Object} cfg (Optional) The configuration options to use for this computation.
  31693. *
  31694. * @return {WordArray} The derived key.
  31695. *
  31696. * @static
  31697. *
  31698. * @example
  31699. *
  31700. * var key = CryptoJS.EvpKDF(password, salt);
  31701. * var key = CryptoJS.EvpKDF(password, salt, { keySize: 8 });
  31702. * var key = CryptoJS.EvpKDF(password, salt, { keySize: 8, iterations: 1000 });
  31703. */
  31704. C.EvpKDF = function (password, salt, cfg) {
  31705. return EvpKDF.create(cfg).compute(password, salt);
  31706. };
  31707. }());
  31708. return CryptoJS.EvpKDF;
  31709. }));
  31710. },{"./core":598,"./hmac":602,"./sha1":604}],602:[function(_dereq_,module,exports){
  31711. ;(function (root, factory) {
  31712. if (typeof exports === "object") {
  31713. // CommonJS
  31714. module.exports = exports = factory(_dereq_("./core"));
  31715. }
  31716. else if (typeof define === "function" && define.amd) {
  31717. // AMD
  31718. define(["./core"], factory);
  31719. }
  31720. else {
  31721. // Global (browser)
  31722. factory(root.CryptoJS);
  31723. }
  31724. }(this, function (CryptoJS) {
  31725. (function () {
  31726. // Shortcuts
  31727. var C = CryptoJS;
  31728. var C_lib = C.lib;
  31729. var Base = C_lib.Base;
  31730. var C_enc = C.enc;
  31731. var Utf8 = C_enc.Utf8;
  31732. var C_algo = C.algo;
  31733. /**
  31734. * HMAC algorithm.
  31735. */
  31736. var HMAC = C_algo.HMAC = Base.extend({
  31737. /**
  31738. * Initializes a newly created HMAC.
  31739. *
  31740. * @param {Hasher} hasher The hash algorithm to use.
  31741. * @param {WordArray|string} key The secret key.
  31742. *
  31743. * @example
  31744. *
  31745. * var hmacHasher = CryptoJS.algo.HMAC.create(CryptoJS.algo.SHA256, key);
  31746. */
  31747. init: function (hasher, key) {
  31748. // Init hasher
  31749. hasher = this._hasher = new hasher.init();
  31750. // Convert string to WordArray, else assume WordArray already
  31751. if (typeof key == 'string') {
  31752. key = Utf8.parse(key);
  31753. }
  31754. // Shortcuts
  31755. var hasherBlockSize = hasher.blockSize;
  31756. var hasherBlockSizeBytes = hasherBlockSize * 4;
  31757. // Allow arbitrary length keys
  31758. if (key.sigBytes > hasherBlockSizeBytes) {
  31759. key = hasher.finalize(key);
  31760. }
  31761. // Clamp excess bits
  31762. key.clamp();
  31763. // Clone key for inner and outer pads
  31764. var oKey = this._oKey = key.clone();
  31765. var iKey = this._iKey = key.clone();
  31766. // Shortcuts
  31767. var oKeyWords = oKey.words;
  31768. var iKeyWords = iKey.words;
  31769. // XOR keys with pad constants
  31770. for (var i = 0; i < hasherBlockSize; i++) {
  31771. oKeyWords[i] ^= 0x5c5c5c5c;
  31772. iKeyWords[i] ^= 0x36363636;
  31773. }
  31774. oKey.sigBytes = iKey.sigBytes = hasherBlockSizeBytes;
  31775. // Set initial values
  31776. this.reset();
  31777. },
  31778. /**
  31779. * Resets this HMAC to its initial state.
  31780. *
  31781. * @example
  31782. *
  31783. * hmacHasher.reset();
  31784. */
  31785. reset: function () {
  31786. // Shortcut
  31787. var hasher = this._hasher;
  31788. // Reset
  31789. hasher.reset();
  31790. hasher.update(this._iKey);
  31791. },
  31792. /**
  31793. * Updates this HMAC with a message.
  31794. *
  31795. * @param {WordArray|string} messageUpdate The message to append.
  31796. *
  31797. * @return {HMAC} This HMAC instance.
  31798. *
  31799. * @example
  31800. *
  31801. * hmacHasher.update('message');
  31802. * hmacHasher.update(wordArray);
  31803. */
  31804. update: function (messageUpdate) {
  31805. this._hasher.update(messageUpdate);
  31806. // Chainable
  31807. return this;
  31808. },
  31809. /**
  31810. * Finalizes the HMAC computation.
  31811. * Note that the finalize operation is effectively a destructive, read-once operation.
  31812. *
  31813. * @param {WordArray|string} messageUpdate (Optional) A final message update.
  31814. *
  31815. * @return {WordArray} The HMAC.
  31816. *
  31817. * @example
  31818. *
  31819. * var hmac = hmacHasher.finalize();
  31820. * var hmac = hmacHasher.finalize('message');
  31821. * var hmac = hmacHasher.finalize(wordArray);
  31822. */
  31823. finalize: function (messageUpdate) {
  31824. // Shortcut
  31825. var hasher = this._hasher;
  31826. // Compute HMAC
  31827. var innerHash = hasher.finalize(messageUpdate);
  31828. hasher.reset();
  31829. var hmac = hasher.finalize(this._oKey.clone().concat(innerHash));
  31830. return hmac;
  31831. }
  31832. });
  31833. }());
  31834. }));
  31835. },{"./core":598}],603:[function(_dereq_,module,exports){
  31836. ;(function (root, factory) {
  31837. if (typeof exports === "object") {
  31838. // CommonJS
  31839. module.exports = exports = factory(_dereq_("./core"));
  31840. }
  31841. else if (typeof define === "function" && define.amd) {
  31842. // AMD
  31843. define(["./core"], factory);
  31844. }
  31845. else {
  31846. // Global (browser)
  31847. factory(root.CryptoJS);
  31848. }
  31849. }(this, function (CryptoJS) {
  31850. (function (Math) {
  31851. // Shortcuts
  31852. var C = CryptoJS;
  31853. var C_lib = C.lib;
  31854. var WordArray = C_lib.WordArray;
  31855. var Hasher = C_lib.Hasher;
  31856. var C_algo = C.algo;
  31857. // Constants table
  31858. var T = [];
  31859. // Compute constants
  31860. (function () {
  31861. for (var i = 0; i < 64; i++) {
  31862. T[i] = (Math.abs(Math.sin(i + 1)) * 0x100000000) | 0;
  31863. }
  31864. }());
  31865. /**
  31866. * MD5 hash algorithm.
  31867. */
  31868. var MD5 = C_algo.MD5 = Hasher.extend({
  31869. _doReset: function () {
  31870. this._hash = new WordArray.init([
  31871. 0x67452301, 0xefcdab89,
  31872. 0x98badcfe, 0x10325476
  31873. ]);
  31874. },
  31875. _doProcessBlock: function (M, offset) {
  31876. // Swap endian
  31877. for (var i = 0; i < 16; i++) {
  31878. // Shortcuts
  31879. var offset_i = offset + i;
  31880. var M_offset_i = M[offset_i];
  31881. M[offset_i] = (
  31882. (((M_offset_i << 8) | (M_offset_i >>> 24)) & 0x00ff00ff) |
  31883. (((M_offset_i << 24) | (M_offset_i >>> 8)) & 0xff00ff00)
  31884. );
  31885. }
  31886. // Shortcuts
  31887. var H = this._hash.words;
  31888. var M_offset_0 = M[offset + 0];
  31889. var M_offset_1 = M[offset + 1];
  31890. var M_offset_2 = M[offset + 2];
  31891. var M_offset_3 = M[offset + 3];
  31892. var M_offset_4 = M[offset + 4];
  31893. var M_offset_5 = M[offset + 5];
  31894. var M_offset_6 = M[offset + 6];
  31895. var M_offset_7 = M[offset + 7];
  31896. var M_offset_8 = M[offset + 8];
  31897. var M_offset_9 = M[offset + 9];
  31898. var M_offset_10 = M[offset + 10];
  31899. var M_offset_11 = M[offset + 11];
  31900. var M_offset_12 = M[offset + 12];
  31901. var M_offset_13 = M[offset + 13];
  31902. var M_offset_14 = M[offset + 14];
  31903. var M_offset_15 = M[offset + 15];
  31904. // Working varialbes
  31905. var a = H[0];
  31906. var b = H[1];
  31907. var c = H[2];
  31908. var d = H[3];
  31909. // Computation
  31910. a = FF(a, b, c, d, M_offset_0, 7, T[0]);
  31911. d = FF(d, a, b, c, M_offset_1, 12, T[1]);
  31912. c = FF(c, d, a, b, M_offset_2, 17, T[2]);
  31913. b = FF(b, c, d, a, M_offset_3, 22, T[3]);
  31914. a = FF(a, b, c, d, M_offset_4, 7, T[4]);
  31915. d = FF(d, a, b, c, M_offset_5, 12, T[5]);
  31916. c = FF(c, d, a, b, M_offset_6, 17, T[6]);
  31917. b = FF(b, c, d, a, M_offset_7, 22, T[7]);
  31918. a = FF(a, b, c, d, M_offset_8, 7, T[8]);
  31919. d = FF(d, a, b, c, M_offset_9, 12, T[9]);
  31920. c = FF(c, d, a, b, M_offset_10, 17, T[10]);
  31921. b = FF(b, c, d, a, M_offset_11, 22, T[11]);
  31922. a = FF(a, b, c, d, M_offset_12, 7, T[12]);
  31923. d = FF(d, a, b, c, M_offset_13, 12, T[13]);
  31924. c = FF(c, d, a, b, M_offset_14, 17, T[14]);
  31925. b = FF(b, c, d, a, M_offset_15, 22, T[15]);
  31926. a = GG(a, b, c, d, M_offset_1, 5, T[16]);
  31927. d = GG(d, a, b, c, M_offset_6, 9, T[17]);
  31928. c = GG(c, d, a, b, M_offset_11, 14, T[18]);
  31929. b = GG(b, c, d, a, M_offset_0, 20, T[19]);
  31930. a = GG(a, b, c, d, M_offset_5, 5, T[20]);
  31931. d = GG(d, a, b, c, M_offset_10, 9, T[21]);
  31932. c = GG(c, d, a, b, M_offset_15, 14, T[22]);
  31933. b = GG(b, c, d, a, M_offset_4, 20, T[23]);
  31934. a = GG(a, b, c, d, M_offset_9, 5, T[24]);
  31935. d = GG(d, a, b, c, M_offset_14, 9, T[25]);
  31936. c = GG(c, d, a, b, M_offset_3, 14, T[26]);
  31937. b = GG(b, c, d, a, M_offset_8, 20, T[27]);
  31938. a = GG(a, b, c, d, M_offset_13, 5, T[28]);
  31939. d = GG(d, a, b, c, M_offset_2, 9, T[29]);
  31940. c = GG(c, d, a, b, M_offset_7, 14, T[30]);
  31941. b = GG(b, c, d, a, M_offset_12, 20, T[31]);
  31942. a = HH(a, b, c, d, M_offset_5, 4, T[32]);
  31943. d = HH(d, a, b, c, M_offset_8, 11, T[33]);
  31944. c = HH(c, d, a, b, M_offset_11, 16, T[34]);
  31945. b = HH(b, c, d, a, M_offset_14, 23, T[35]);
  31946. a = HH(a, b, c, d, M_offset_1, 4, T[36]);
  31947. d = HH(d, a, b, c, M_offset_4, 11, T[37]);
  31948. c = HH(c, d, a, b, M_offset_7, 16, T[38]);
  31949. b = HH(b, c, d, a, M_offset_10, 23, T[39]);
  31950. a = HH(a, b, c, d, M_offset_13, 4, T[40]);
  31951. d = HH(d, a, b, c, M_offset_0, 11, T[41]);
  31952. c = HH(c, d, a, b, M_offset_3, 16, T[42]);
  31953. b = HH(b, c, d, a, M_offset_6, 23, T[43]);
  31954. a = HH(a, b, c, d, M_offset_9, 4, T[44]);
  31955. d = HH(d, a, b, c, M_offset_12, 11, T[45]);
  31956. c = HH(c, d, a, b, M_offset_15, 16, T[46]);
  31957. b = HH(b, c, d, a, M_offset_2, 23, T[47]);
  31958. a = II(a, b, c, d, M_offset_0, 6, T[48]);
  31959. d = II(d, a, b, c, M_offset_7, 10, T[49]);
  31960. c = II(c, d, a, b, M_offset_14, 15, T[50]);
  31961. b = II(b, c, d, a, M_offset_5, 21, T[51]);
  31962. a = II(a, b, c, d, M_offset_12, 6, T[52]);
  31963. d = II(d, a, b, c, M_offset_3, 10, T[53]);
  31964. c = II(c, d, a, b, M_offset_10, 15, T[54]);
  31965. b = II(b, c, d, a, M_offset_1, 21, T[55]);
  31966. a = II(a, b, c, d, M_offset_8, 6, T[56]);
  31967. d = II(d, a, b, c, M_offset_15, 10, T[57]);
  31968. c = II(c, d, a, b, M_offset_6, 15, T[58]);
  31969. b = II(b, c, d, a, M_offset_13, 21, T[59]);
  31970. a = II(a, b, c, d, M_offset_4, 6, T[60]);
  31971. d = II(d, a, b, c, M_offset_11, 10, T[61]);
  31972. c = II(c, d, a, b, M_offset_2, 15, T[62]);
  31973. b = II(b, c, d, a, M_offset_9, 21, T[63]);
  31974. // Intermediate hash value
  31975. H[0] = (H[0] + a) | 0;
  31976. H[1] = (H[1] + b) | 0;
  31977. H[2] = (H[2] + c) | 0;
  31978. H[3] = (H[3] + d) | 0;
  31979. },
  31980. _doFinalize: function () {
  31981. // Shortcuts
  31982. var data = this._data;
  31983. var dataWords = data.words;
  31984. var nBitsTotal = this._nDataBytes * 8;
  31985. var nBitsLeft = data.sigBytes * 8;
  31986. // Add padding
  31987. dataWords[nBitsLeft >>> 5] |= 0x80 << (24 - nBitsLeft % 32);
  31988. var nBitsTotalH = Math.floor(nBitsTotal / 0x100000000);
  31989. var nBitsTotalL = nBitsTotal;
  31990. dataWords[(((nBitsLeft + 64) >>> 9) << 4) + 15] = (
  31991. (((nBitsTotalH << 8) | (nBitsTotalH >>> 24)) & 0x00ff00ff) |
  31992. (((nBitsTotalH << 24) | (nBitsTotalH >>> 8)) & 0xff00ff00)
  31993. );
  31994. dataWords[(((nBitsLeft + 64) >>> 9) << 4) + 14] = (
  31995. (((nBitsTotalL << 8) | (nBitsTotalL >>> 24)) & 0x00ff00ff) |
  31996. (((nBitsTotalL << 24) | (nBitsTotalL >>> 8)) & 0xff00ff00)
  31997. );
  31998. data.sigBytes = (dataWords.length + 1) * 4;
  31999. // Hash final blocks
  32000. this._process();
  32001. // Shortcuts
  32002. var hash = this._hash;
  32003. var H = hash.words;
  32004. // Swap endian
  32005. for (var i = 0; i < 4; i++) {
  32006. // Shortcut
  32007. var H_i = H[i];
  32008. H[i] = (((H_i << 8) | (H_i >>> 24)) & 0x00ff00ff) |
  32009. (((H_i << 24) | (H_i >>> 8)) & 0xff00ff00);
  32010. }
  32011. // Return final computed hash
  32012. return hash;
  32013. },
  32014. clone: function () {
  32015. var clone = Hasher.clone.call(this);
  32016. clone._hash = this._hash.clone();
  32017. return clone;
  32018. }
  32019. });
  32020. function FF(a, b, c, d, x, s, t) {
  32021. var n = a + ((b & c) | (~b & d)) + x + t;
  32022. return ((n << s) | (n >>> (32 - s))) + b;
  32023. }
  32024. function GG(a, b, c, d, x, s, t) {
  32025. var n = a + ((b & d) | (c & ~d)) + x + t;
  32026. return ((n << s) | (n >>> (32 - s))) + b;
  32027. }
  32028. function HH(a, b, c, d, x, s, t) {
  32029. var n = a + (b ^ c ^ d) + x + t;
  32030. return ((n << s) | (n >>> (32 - s))) + b;
  32031. }
  32032. function II(a, b, c, d, x, s, t) {
  32033. var n = a + (c ^ (b | ~d)) + x + t;
  32034. return ((n << s) | (n >>> (32 - s))) + b;
  32035. }
  32036. /**
  32037. * Shortcut function to the hasher's object interface.
  32038. *
  32039. * @param {WordArray|string} message The message to hash.
  32040. *
  32041. * @return {WordArray} The hash.
  32042. *
  32043. * @static
  32044. *
  32045. * @example
  32046. *
  32047. * var hash = CryptoJS.MD5('message');
  32048. * var hash = CryptoJS.MD5(wordArray);
  32049. */
  32050. C.MD5 = Hasher._createHelper(MD5);
  32051. /**
  32052. * Shortcut function to the HMAC's object interface.
  32053. *
  32054. * @param {WordArray|string} message The message to hash.
  32055. * @param {WordArray|string} key The secret key.
  32056. *
  32057. * @return {WordArray} The HMAC.
  32058. *
  32059. * @static
  32060. *
  32061. * @example
  32062. *
  32063. * var hmac = CryptoJS.HmacMD5(message, key);
  32064. */
  32065. C.HmacMD5 = Hasher._createHmacHelper(MD5);
  32066. }(Math));
  32067. return CryptoJS.MD5;
  32068. }));
  32069. },{"./core":598}],604:[function(_dereq_,module,exports){
  32070. ;(function (root, factory) {
  32071. if (typeof exports === "object") {
  32072. // CommonJS
  32073. module.exports = exports = factory(_dereq_("./core"));
  32074. }
  32075. else if (typeof define === "function" && define.amd) {
  32076. // AMD
  32077. define(["./core"], factory);
  32078. }
  32079. else {
  32080. // Global (browser)
  32081. factory(root.CryptoJS);
  32082. }
  32083. }(this, function (CryptoJS) {
  32084. (function () {
  32085. // Shortcuts
  32086. var C = CryptoJS;
  32087. var C_lib = C.lib;
  32088. var WordArray = C_lib.WordArray;
  32089. var Hasher = C_lib.Hasher;
  32090. var C_algo = C.algo;
  32091. // Reusable object
  32092. var W = [];
  32093. /**
  32094. * SHA-1 hash algorithm.
  32095. */
  32096. var SHA1 = C_algo.SHA1 = Hasher.extend({
  32097. _doReset: function () {
  32098. this._hash = new WordArray.init([
  32099. 0x67452301, 0xefcdab89,
  32100. 0x98badcfe, 0x10325476,
  32101. 0xc3d2e1f0
  32102. ]);
  32103. },
  32104. _doProcessBlock: function (M, offset) {
  32105. // Shortcut
  32106. var H = this._hash.words;
  32107. // Working variables
  32108. var a = H[0];
  32109. var b = H[1];
  32110. var c = H[2];
  32111. var d = H[3];
  32112. var e = H[4];
  32113. // Computation
  32114. for (var i = 0; i < 80; i++) {
  32115. if (i < 16) {
  32116. W[i] = M[offset + i] | 0;
  32117. } else {
  32118. var n = W[i - 3] ^ W[i - 8] ^ W[i - 14] ^ W[i - 16];
  32119. W[i] = (n << 1) | (n >>> 31);
  32120. }
  32121. var t = ((a << 5) | (a >>> 27)) + e + W[i];
  32122. if (i < 20) {
  32123. t += ((b & c) | (~b & d)) + 0x5a827999;
  32124. } else if (i < 40) {
  32125. t += (b ^ c ^ d) + 0x6ed9eba1;
  32126. } else if (i < 60) {
  32127. t += ((b & c) | (b & d) | (c & d)) - 0x70e44324;
  32128. } else /* if (i < 80) */ {
  32129. t += (b ^ c ^ d) - 0x359d3e2a;
  32130. }
  32131. e = d;
  32132. d = c;
  32133. c = (b << 30) | (b >>> 2);
  32134. b = a;
  32135. a = t;
  32136. }
  32137. // Intermediate hash value
  32138. H[0] = (H[0] + a) | 0;
  32139. H[1] = (H[1] + b) | 0;
  32140. H[2] = (H[2] + c) | 0;
  32141. H[3] = (H[3] + d) | 0;
  32142. H[4] = (H[4] + e) | 0;
  32143. },
  32144. _doFinalize: function () {
  32145. // Shortcuts
  32146. var data = this._data;
  32147. var dataWords = data.words;
  32148. var nBitsTotal = this._nDataBytes * 8;
  32149. var nBitsLeft = data.sigBytes * 8;
  32150. // Add padding
  32151. dataWords[nBitsLeft >>> 5] |= 0x80 << (24 - nBitsLeft % 32);
  32152. dataWords[(((nBitsLeft + 64) >>> 9) << 4) + 14] = Math.floor(nBitsTotal / 0x100000000);
  32153. dataWords[(((nBitsLeft + 64) >>> 9) << 4) + 15] = nBitsTotal;
  32154. data.sigBytes = dataWords.length * 4;
  32155. // Hash final blocks
  32156. this._process();
  32157. // Return final computed hash
  32158. return this._hash;
  32159. },
  32160. clone: function () {
  32161. var clone = Hasher.clone.call(this);
  32162. clone._hash = this._hash.clone();
  32163. return clone;
  32164. }
  32165. });
  32166. /**
  32167. * Shortcut function to the hasher's object interface.
  32168. *
  32169. * @param {WordArray|string} message The message to hash.
  32170. *
  32171. * @return {WordArray} The hash.
  32172. *
  32173. * @static
  32174. *
  32175. * @example
  32176. *
  32177. * var hash = CryptoJS.SHA1('message');
  32178. * var hash = CryptoJS.SHA1(wordArray);
  32179. */
  32180. C.SHA1 = Hasher._createHelper(SHA1);
  32181. /**
  32182. * Shortcut function to the HMAC's object interface.
  32183. *
  32184. * @param {WordArray|string} message The message to hash.
  32185. * @param {WordArray|string} key The secret key.
  32186. *
  32187. * @return {WordArray} The HMAC.
  32188. *
  32189. * @static
  32190. *
  32191. * @example
  32192. *
  32193. * var hmac = CryptoJS.HmacSHA1(message, key);
  32194. */
  32195. C.HmacSHA1 = Hasher._createHmacHelper(SHA1);
  32196. }());
  32197. return CryptoJS.SHA1;
  32198. }));
  32199. },{"./core":598}],605:[function(_dereq_,module,exports){
  32200. // Copyright Joyent, Inc. and other Node contributors.
  32201. //
  32202. // Permission is hereby granted, free of charge, to any person obtaining a
  32203. // copy of this software and associated documentation files (the
  32204. // "Software"), to deal in the Software without restriction, including
  32205. // without limitation the rights to use, copy, modify, merge, publish,
  32206. // distribute, sublicense, and/or sell copies of the Software, and to permit
  32207. // persons to whom the Software is furnished to do so, subject to the
  32208. // following conditions:
  32209. //
  32210. // The above copyright notice and this permission notice shall be included
  32211. // in all copies or substantial portions of the Software.
  32212. //
  32213. // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
  32214. // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
  32215. // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
  32216. // NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
  32217. // DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
  32218. // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
  32219. // USE OR OTHER DEALINGS IN THE SOFTWARE.
  32220. var objectCreate = Object.create || objectCreatePolyfill
  32221. var objectKeys = Object.keys || objectKeysPolyfill
  32222. var bind = Function.prototype.bind || functionBindPolyfill
  32223. function EventEmitter() {
  32224. if (!this._events || !Object.prototype.hasOwnProperty.call(this, '_events')) {
  32225. this._events = objectCreate(null);
  32226. this._eventsCount = 0;
  32227. }
  32228. this._maxListeners = this._maxListeners || undefined;
  32229. }
  32230. module.exports = EventEmitter;
  32231. // Backwards-compat with node 0.10.x
  32232. EventEmitter.EventEmitter = EventEmitter;
  32233. EventEmitter.prototype._events = undefined;
  32234. EventEmitter.prototype._maxListeners = undefined;
  32235. // By default EventEmitters will print a warning if more than 10 listeners are
  32236. // added to it. This is a useful default which helps finding memory leaks.
  32237. var defaultMaxListeners = 10;
  32238. var hasDefineProperty;
  32239. try {
  32240. var o = {};
  32241. if (Object.defineProperty) Object.defineProperty(o, 'x', { value: 0 });
  32242. hasDefineProperty = o.x === 0;
  32243. } catch (err) { hasDefineProperty = false }
  32244. if (hasDefineProperty) {
  32245. Object.defineProperty(EventEmitter, 'defaultMaxListeners', {
  32246. enumerable: true,
  32247. get: function() {
  32248. return defaultMaxListeners;
  32249. },
  32250. set: function(arg) {
  32251. // check whether the input is a positive number (whose value is zero or
  32252. // greater and not a NaN).
  32253. if (typeof arg !== 'number' || arg < 0 || arg !== arg)
  32254. throw new TypeError('"defaultMaxListeners" must be a positive number');
  32255. defaultMaxListeners = arg;
  32256. }
  32257. });
  32258. } else {
  32259. EventEmitter.defaultMaxListeners = defaultMaxListeners;
  32260. }
  32261. // Obviously not all Emitters should be limited to 10. This function allows
  32262. // that to be increased. Set to zero for unlimited.
  32263. EventEmitter.prototype.setMaxListeners = function setMaxListeners(n) {
  32264. if (typeof n !== 'number' || n < 0 || isNaN(n))
  32265. throw new TypeError('"n" argument must be a positive number');
  32266. this._maxListeners = n;
  32267. return this;
  32268. };
  32269. function $getMaxListeners(that) {
  32270. if (that._maxListeners === undefined)
  32271. return EventEmitter.defaultMaxListeners;
  32272. return that._maxListeners;
  32273. }
  32274. EventEmitter.prototype.getMaxListeners = function getMaxListeners() {
  32275. return $getMaxListeners(this);
  32276. };
  32277. // These standalone emit* functions are used to optimize calling of event
  32278. // handlers for fast cases because emit() itself often has a variable number of
  32279. // arguments and can be deoptimized because of that. These functions always have
  32280. // the same number of arguments and thus do not get deoptimized, so the code
  32281. // inside them can execute faster.
  32282. function emitNone(handler, isFn, self) {
  32283. if (isFn)
  32284. handler.call(self);
  32285. else {
  32286. var len = handler.length;
  32287. var listeners = arrayClone(handler, len);
  32288. for (var i = 0; i < len; ++i)
  32289. listeners[i].call(self);
  32290. }
  32291. }
  32292. function emitOne(handler, isFn, self, arg1) {
  32293. if (isFn)
  32294. handler.call(self, arg1);
  32295. else {
  32296. var len = handler.length;
  32297. var listeners = arrayClone(handler, len);
  32298. for (var i = 0; i < len; ++i)
  32299. listeners[i].call(self, arg1);
  32300. }
  32301. }
  32302. function emitTwo(handler, isFn, self, arg1, arg2) {
  32303. if (isFn)
  32304. handler.call(self, arg1, arg2);
  32305. else {
  32306. var len = handler.length;
  32307. var listeners = arrayClone(handler, len);
  32308. for (var i = 0; i < len; ++i)
  32309. listeners[i].call(self, arg1, arg2);
  32310. }
  32311. }
  32312. function emitThree(handler, isFn, self, arg1, arg2, arg3) {
  32313. if (isFn)
  32314. handler.call(self, arg1, arg2, arg3);
  32315. else {
  32316. var len = handler.length;
  32317. var listeners = arrayClone(handler, len);
  32318. for (var i = 0; i < len; ++i)
  32319. listeners[i].call(self, arg1, arg2, arg3);
  32320. }
  32321. }
  32322. function emitMany(handler, isFn, self, args) {
  32323. if (isFn)
  32324. handler.apply(self, args);
  32325. else {
  32326. var len = handler.length;
  32327. var listeners = arrayClone(handler, len);
  32328. for (var i = 0; i < len; ++i)
  32329. listeners[i].apply(self, args);
  32330. }
  32331. }
  32332. EventEmitter.prototype.emit = function emit(type) {
  32333. var er, handler, len, args, i, events;
  32334. var doError = (type === 'error');
  32335. events = this._events;
  32336. if (events)
  32337. doError = (doError && events.error == null);
  32338. else if (!doError)
  32339. return false;
  32340. // If there is no 'error' event listener then throw.
  32341. if (doError) {
  32342. if (arguments.length > 1)
  32343. er = arguments[1];
  32344. if (er instanceof Error) {
  32345. throw er; // Unhandled 'error' event
  32346. } else {
  32347. // At least give some kind of context to the user
  32348. var err = new Error('Unhandled "error" event. (' + er + ')');
  32349. err.context = er;
  32350. throw err;
  32351. }
  32352. return false;
  32353. }
  32354. handler = events[type];
  32355. if (!handler)
  32356. return false;
  32357. var isFn = typeof handler === 'function';
  32358. len = arguments.length;
  32359. switch (len) {
  32360. // fast cases
  32361. case 1:
  32362. emitNone(handler, isFn, this);
  32363. break;
  32364. case 2:
  32365. emitOne(handler, isFn, this, arguments[1]);
  32366. break;
  32367. case 3:
  32368. emitTwo(handler, isFn, this, arguments[1], arguments[2]);
  32369. break;
  32370. case 4:
  32371. emitThree(handler, isFn, this, arguments[1], arguments[2], arguments[3]);
  32372. break;
  32373. // slower
  32374. default:
  32375. args = new Array(len - 1);
  32376. for (i = 1; i < len; i++)
  32377. args[i - 1] = arguments[i];
  32378. emitMany(handler, isFn, this, args);
  32379. }
  32380. return true;
  32381. };
  32382. function _addListener(target, type, listener, prepend) {
  32383. var m;
  32384. var events;
  32385. var existing;
  32386. if (typeof listener !== 'function')
  32387. throw new TypeError('"listener" argument must be a function');
  32388. events = target._events;
  32389. if (!events) {
  32390. events = target._events = objectCreate(null);
  32391. target._eventsCount = 0;
  32392. } else {
  32393. // To avoid recursion in the case that type === "newListener"! Before
  32394. // adding it to the listeners, first emit "newListener".
  32395. if (events.newListener) {
  32396. target.emit('newListener', type,
  32397. listener.listener ? listener.listener : listener);
  32398. // Re-assign `events` because a newListener handler could have caused the
  32399. // this._events to be assigned to a new object
  32400. events = target._events;
  32401. }
  32402. existing = events[type];
  32403. }
  32404. if (!existing) {
  32405. // Optimize the case of one listener. Don't need the extra array object.
  32406. existing = events[type] = listener;
  32407. ++target._eventsCount;
  32408. } else {
  32409. if (typeof existing === 'function') {
  32410. // Adding the second element, need to change to array.
  32411. existing = events[type] =
  32412. prepend ? [listener, existing] : [existing, listener];
  32413. } else {
  32414. // If we've already got an array, just append.
  32415. if (prepend) {
  32416. existing.unshift(listener);
  32417. } else {
  32418. existing.push(listener);
  32419. }
  32420. }
  32421. // Check for listener leak
  32422. if (!existing.warned) {
  32423. m = $getMaxListeners(target);
  32424. if (m && m > 0 && existing.length > m) {
  32425. existing.warned = true;
  32426. var w = new Error('Possible EventEmitter memory leak detected. ' +
  32427. existing.length + ' "' + String(type) + '" listeners ' +
  32428. 'added. Use emitter.setMaxListeners() to ' +
  32429. 'increase limit.');
  32430. w.name = 'MaxListenersExceededWarning';
  32431. w.emitter = target;
  32432. w.type = type;
  32433. w.count = existing.length;
  32434. if (typeof console === 'object' && console.warn) {
  32435. console.warn('%s: %s', w.name, w.message);
  32436. }
  32437. }
  32438. }
  32439. }
  32440. return target;
  32441. }
  32442. EventEmitter.prototype.addListener = function addListener(type, listener) {
  32443. return _addListener(this, type, listener, false);
  32444. };
  32445. EventEmitter.prototype.on = EventEmitter.prototype.addListener;
  32446. EventEmitter.prototype.prependListener =
  32447. function prependListener(type, listener) {
  32448. return _addListener(this, type, listener, true);
  32449. };
  32450. function onceWrapper() {
  32451. if (!this.fired) {
  32452. this.target.removeListener(this.type, this.wrapFn);
  32453. this.fired = true;
  32454. switch (arguments.length) {
  32455. case 0:
  32456. return this.listener.call(this.target);
  32457. case 1:
  32458. return this.listener.call(this.target, arguments[0]);
  32459. case 2:
  32460. return this.listener.call(this.target, arguments[0], arguments[1]);
  32461. case 3:
  32462. return this.listener.call(this.target, arguments[0], arguments[1],
  32463. arguments[2]);
  32464. default:
  32465. var args = new Array(arguments.length);
  32466. for (var i = 0; i < args.length; ++i)
  32467. args[i] = arguments[i];
  32468. this.listener.apply(this.target, args);
  32469. }
  32470. }
  32471. }
  32472. function _onceWrap(target, type, listener) {
  32473. var state = { fired: false, wrapFn: undefined, target: target, type: type, listener: listener };
  32474. var wrapped = bind.call(onceWrapper, state);
  32475. wrapped.listener = listener;
  32476. state.wrapFn = wrapped;
  32477. return wrapped;
  32478. }
  32479. EventEmitter.prototype.once = function once(type, listener) {
  32480. if (typeof listener !== 'function')
  32481. throw new TypeError('"listener" argument must be a function');
  32482. this.on(type, _onceWrap(this, type, listener));
  32483. return this;
  32484. };
  32485. EventEmitter.prototype.prependOnceListener =
  32486. function prependOnceListener(type, listener) {
  32487. if (typeof listener !== 'function')
  32488. throw new TypeError('"listener" argument must be a function');
  32489. this.prependListener(type, _onceWrap(this, type, listener));
  32490. return this;
  32491. };
  32492. // Emits a 'removeListener' event if and only if the listener was removed.
  32493. EventEmitter.prototype.removeListener =
  32494. function removeListener(type, listener) {
  32495. var list, events, position, i, originalListener;
  32496. if (typeof listener !== 'function')
  32497. throw new TypeError('"listener" argument must be a function');
  32498. events = this._events;
  32499. if (!events)
  32500. return this;
  32501. list = events[type];
  32502. if (!list)
  32503. return this;
  32504. if (list === listener || list.listener === listener) {
  32505. if (--this._eventsCount === 0)
  32506. this._events = objectCreate(null);
  32507. else {
  32508. delete events[type];
  32509. if (events.removeListener)
  32510. this.emit('removeListener', type, list.listener || listener);
  32511. }
  32512. } else if (typeof list !== 'function') {
  32513. position = -1;
  32514. for (i = list.length - 1; i >= 0; i--) {
  32515. if (list[i] === listener || list[i].listener === listener) {
  32516. originalListener = list[i].listener;
  32517. position = i;
  32518. break;
  32519. }
  32520. }
  32521. if (position < 0)
  32522. return this;
  32523. if (position === 0)
  32524. list.shift();
  32525. else
  32526. spliceOne(list, position);
  32527. if (list.length === 1)
  32528. events[type] = list[0];
  32529. if (events.removeListener)
  32530. this.emit('removeListener', type, originalListener || listener);
  32531. }
  32532. return this;
  32533. };
  32534. EventEmitter.prototype.removeAllListeners =
  32535. function removeAllListeners(type) {
  32536. var listeners, events, i;
  32537. events = this._events;
  32538. if (!events)
  32539. return this;
  32540. // not listening for removeListener, no need to emit
  32541. if (!events.removeListener) {
  32542. if (arguments.length === 0) {
  32543. this._events = objectCreate(null);
  32544. this._eventsCount = 0;
  32545. } else if (events[type]) {
  32546. if (--this._eventsCount === 0)
  32547. this._events = objectCreate(null);
  32548. else
  32549. delete events[type];
  32550. }
  32551. return this;
  32552. }
  32553. // emit removeListener for all listeners on all events
  32554. if (arguments.length === 0) {
  32555. var keys = objectKeys(events);
  32556. var key;
  32557. for (i = 0; i < keys.length; ++i) {
  32558. key = keys[i];
  32559. if (key === 'removeListener') continue;
  32560. this.removeAllListeners(key);
  32561. }
  32562. this.removeAllListeners('removeListener');
  32563. this._events = objectCreate(null);
  32564. this._eventsCount = 0;
  32565. return this;
  32566. }
  32567. listeners = events[type];
  32568. if (typeof listeners === 'function') {
  32569. this.removeListener(type, listeners);
  32570. } else if (listeners) {
  32571. // LIFO order
  32572. for (i = listeners.length - 1; i >= 0; i--) {
  32573. this.removeListener(type, listeners[i]);
  32574. }
  32575. }
  32576. return this;
  32577. };
  32578. function _listeners(target, type, unwrap) {
  32579. var events = target._events;
  32580. if (!events)
  32581. return [];
  32582. var evlistener = events[type];
  32583. if (!evlistener)
  32584. return [];
  32585. if (typeof evlistener === 'function')
  32586. return unwrap ? [evlistener.listener || evlistener] : [evlistener];
  32587. return unwrap ? unwrapListeners(evlistener) : arrayClone(evlistener, evlistener.length);
  32588. }
  32589. EventEmitter.prototype.listeners = function listeners(type) {
  32590. return _listeners(this, type, true);
  32591. };
  32592. EventEmitter.prototype.rawListeners = function rawListeners(type) {
  32593. return _listeners(this, type, false);
  32594. };
  32595. EventEmitter.listenerCount = function(emitter, type) {
  32596. if (typeof emitter.listenerCount === 'function') {
  32597. return emitter.listenerCount(type);
  32598. } else {
  32599. return listenerCount.call(emitter, type);
  32600. }
  32601. };
  32602. EventEmitter.prototype.listenerCount = listenerCount;
  32603. function listenerCount(type) {
  32604. var events = this._events;
  32605. if (events) {
  32606. var evlistener = events[type];
  32607. if (typeof evlistener === 'function') {
  32608. return 1;
  32609. } else if (evlistener) {
  32610. return evlistener.length;
  32611. }
  32612. }
  32613. return 0;
  32614. }
  32615. EventEmitter.prototype.eventNames = function eventNames() {
  32616. return this._eventsCount > 0 ? Reflect.ownKeys(this._events) : [];
  32617. };
  32618. // About 1.5x faster than the two-arg version of Array#splice().
  32619. function spliceOne(list, index) {
  32620. for (var i = index, k = i + 1, n = list.length; k < n; i += 1, k += 1)
  32621. list[i] = list[k];
  32622. list.pop();
  32623. }
  32624. function arrayClone(arr, n) {
  32625. var copy = new Array(n);
  32626. for (var i = 0; i < n; ++i)
  32627. copy[i] = arr[i];
  32628. return copy;
  32629. }
  32630. function unwrapListeners(arr) {
  32631. var ret = new Array(arr.length);
  32632. for (var i = 0; i < ret.length; ++i) {
  32633. ret[i] = arr[i].listener || arr[i];
  32634. }
  32635. return ret;
  32636. }
  32637. function objectCreatePolyfill(proto) {
  32638. var F = function() {};
  32639. F.prototype = proto;
  32640. return new F;
  32641. }
  32642. function objectKeysPolyfill(obj) {
  32643. var keys = [];
  32644. for (var k in obj) if (Object.prototype.hasOwnProperty.call(obj, k)) {
  32645. keys.push(k);
  32646. }
  32647. return k;
  32648. }
  32649. function functionBindPolyfill(context) {
  32650. var fn = this;
  32651. return function () {
  32652. return fn.apply(context, arguments);
  32653. };
  32654. }
  32655. },{}],606:[function(_dereq_,module,exports){
  32656. 'use strict';
  32657. function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
  32658. Object.defineProperty(exports, '__esModule', {
  32659. value: true
  32660. });
  32661. var safariFix = _dereq_('safari-14-idb-fix');
  32662. function _interopDefaultLegacy(e) {
  32663. return e && _typeof(e) === 'object' && 'default' in e ? e : {
  32664. 'default': e
  32665. };
  32666. }
  32667. var safariFix__default = /*#__PURE__*/_interopDefaultLegacy(safariFix);
  32668. function promisifyRequest(request) {
  32669. return new Promise(function (resolve, reject) {
  32670. // @ts-ignore - file size hacks
  32671. request.oncomplete = request.onsuccess = function () {
  32672. return resolve(request.result);
  32673. }; // @ts-ignore - file size hacks
  32674. request.onabort = request.onerror = function () {
  32675. return reject(request.error);
  32676. };
  32677. });
  32678. }
  32679. function createStore(dbName, storeName) {
  32680. var dbp = safariFix__default['default']().then(function () {
  32681. var request = indexedDB.open(dbName);
  32682. request.onupgradeneeded = function () {
  32683. return request.result.createObjectStore(storeName);
  32684. };
  32685. return promisifyRequest(request);
  32686. });
  32687. return function (txMode, callback) {
  32688. return dbp.then(function (db) {
  32689. return callback(db.transaction(storeName, txMode).objectStore(storeName));
  32690. });
  32691. };
  32692. }
  32693. var defaultGetStoreFunc;
  32694. function defaultGetStore() {
  32695. if (!defaultGetStoreFunc) {
  32696. defaultGetStoreFunc = createStore('keyval-store', 'keyval');
  32697. }
  32698. return defaultGetStoreFunc;
  32699. }
  32700. /**
  32701. * Get a value by its key.
  32702. *
  32703. * @param key
  32704. * @param customStore Method to get a custom store. Use with caution (see the docs).
  32705. */
  32706. function get(key) {
  32707. var customStore = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : defaultGetStore();
  32708. return customStore('readonly', function (store) {
  32709. return promisifyRequest(store.get(key));
  32710. });
  32711. }
  32712. /**
  32713. * Set a value with a key.
  32714. *
  32715. * @param key
  32716. * @param value
  32717. * @param customStore Method to get a custom store. Use with caution (see the docs).
  32718. */
  32719. function set(key, value) {
  32720. var customStore = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : defaultGetStore();
  32721. return customStore('readwrite', function (store) {
  32722. store.put(value, key);
  32723. return promisifyRequest(store.transaction);
  32724. });
  32725. }
  32726. /**
  32727. * Set multiple values at once. This is faster than calling set() multiple times.
  32728. * It's also atomic – if one of the pairs can't be added, none will be added.
  32729. *
  32730. * @param entries Array of entries, where each entry is an array of `[key, value]`.
  32731. * @param customStore Method to get a custom store. Use with caution (see the docs).
  32732. */
  32733. function setMany(entries) {
  32734. var customStore = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : defaultGetStore();
  32735. return customStore('readwrite', function (store) {
  32736. entries.forEach(function (entry) {
  32737. return store.put(entry[1], entry[0]);
  32738. });
  32739. return promisifyRequest(store.transaction);
  32740. });
  32741. }
  32742. /**
  32743. * Get multiple values by their keys
  32744. *
  32745. * @param keys
  32746. * @param customStore Method to get a custom store. Use with caution (see the docs).
  32747. */
  32748. function getMany(keys) {
  32749. var customStore = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : defaultGetStore();
  32750. return customStore('readonly', function (store) {
  32751. return Promise.all(keys.map(function (key) {
  32752. return promisifyRequest(store.get(key));
  32753. }));
  32754. });
  32755. }
  32756. /**
  32757. * Update a value. This lets you see the old value and update it as an atomic operation.
  32758. *
  32759. * @param key
  32760. * @param updater A callback that takes the old value and returns a new value.
  32761. * @param customStore Method to get a custom store. Use with caution (see the docs).
  32762. */
  32763. function update(key, updater) {
  32764. var customStore = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : defaultGetStore();
  32765. return customStore('readwrite', function (store) {
  32766. return (// Need to create the promise manually.
  32767. // If I try to chain promises, the transaction closes in browsers
  32768. // that use a promise polyfill (IE10/11).
  32769. new Promise(function (resolve, reject) {
  32770. store.get(key).onsuccess = function () {
  32771. try {
  32772. store.put(updater(this.result), key);
  32773. resolve(promisifyRequest(store.transaction));
  32774. } catch (err) {
  32775. reject(err);
  32776. }
  32777. };
  32778. })
  32779. );
  32780. });
  32781. }
  32782. /**
  32783. * Delete a particular key from the store.
  32784. *
  32785. * @param key
  32786. * @param customStore Method to get a custom store. Use with caution (see the docs).
  32787. */
  32788. function del(key) {
  32789. var customStore = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : defaultGetStore();
  32790. return customStore('readwrite', function (store) {
  32791. store.delete(key);
  32792. return promisifyRequest(store.transaction);
  32793. });
  32794. }
  32795. /**
  32796. * Delete multiple keys at once.
  32797. *
  32798. * @param keys List of keys to delete.
  32799. * @param customStore Method to get a custom store. Use with caution (see the docs).
  32800. */
  32801. function delMany(keys) {
  32802. var customStore = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : defaultGetStore();
  32803. return customStore('readwrite', function (store) {
  32804. keys.forEach(function (key) {
  32805. return store.delete(key);
  32806. });
  32807. return promisifyRequest(store.transaction);
  32808. });
  32809. }
  32810. /**
  32811. * Clear all values in the store.
  32812. *
  32813. * @param customStore Method to get a custom store. Use with caution (see the docs).
  32814. */
  32815. function clear() {
  32816. var customStore = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : defaultGetStore();
  32817. return customStore('readwrite', function (store) {
  32818. store.clear();
  32819. return promisifyRequest(store.transaction);
  32820. });
  32821. }
  32822. function eachCursor(customStore, callback) {
  32823. return customStore('readonly', function (store) {
  32824. // This would be store.getAllKeys(), but it isn't supported by Edge or Safari.
  32825. // And openKeyCursor isn't supported by Safari.
  32826. store.openCursor().onsuccess = function () {
  32827. if (!this.result) return;
  32828. callback(this.result);
  32829. this.result.continue();
  32830. };
  32831. return promisifyRequest(store.transaction);
  32832. });
  32833. }
  32834. /**
  32835. * Get all keys in the store.
  32836. *
  32837. * @param customStore Method to get a custom store. Use with caution (see the docs).
  32838. */
  32839. function keys() {
  32840. var customStore = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : defaultGetStore();
  32841. var items = [];
  32842. return eachCursor(customStore, function (cursor) {
  32843. return items.push(cursor.key);
  32844. }).then(function () {
  32845. return items;
  32846. });
  32847. }
  32848. /**
  32849. * Get all values in the store.
  32850. *
  32851. * @param customStore Method to get a custom store. Use with caution (see the docs).
  32852. */
  32853. function values() {
  32854. var customStore = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : defaultGetStore();
  32855. var items = [];
  32856. return eachCursor(customStore, function (cursor) {
  32857. return items.push(cursor.value);
  32858. }).then(function () {
  32859. return items;
  32860. });
  32861. }
  32862. /**
  32863. * Get all entries in the store. Each entry is an array of `[key, value]`.
  32864. *
  32865. * @param customStore Method to get a custom store. Use with caution (see the docs).
  32866. */
  32867. function entries() {
  32868. var customStore = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : defaultGetStore();
  32869. var items = [];
  32870. return eachCursor(customStore, function (cursor) {
  32871. return items.push([cursor.key, cursor.value]);
  32872. }).then(function () {
  32873. return items;
  32874. });
  32875. }
  32876. exports.clear = clear;
  32877. exports.createStore = createStore;
  32878. exports.del = del;
  32879. exports.delMany = delMany;
  32880. exports.entries = entries;
  32881. exports.get = get;
  32882. exports.getMany = getMany;
  32883. exports.keys = keys;
  32884. exports.promisifyRequest = promisifyRequest;
  32885. exports.set = set;
  32886. exports.setMany = setMany;
  32887. exports.update = update;
  32888. exports.values = values;
  32889. },{"safari-14-idb-fix":607}],607:[function(_dereq_,module,exports){
  32890. /**
  32891. * Work around Safari 14 IndexedDB open bug.
  32892. *
  32893. * Safari has a horrible bug where IDB requests can hang while the browser is starting up. https://bugs.webkit.org/show_bug.cgi?id=226547
  32894. * The only solution is to keep nudging it until it's awake.
  32895. */
  32896. function idbReady() {
  32897. var isSafari = !navigator.userAgentData &&
  32898. /Safari\//.test(navigator.userAgent) &&
  32899. !/Chrom(e|ium)\//.test(navigator.userAgent);
  32900. // No point putting other browsers or older versions of Safari through this mess.
  32901. if (!isSafari || !indexedDB.databases)
  32902. return Promise.resolve();
  32903. var intervalId;
  32904. return new Promise(function (resolve) {
  32905. var tryIdb = function () { return indexedDB.databases().finally(resolve); };
  32906. intervalId = setInterval(tryIdb, 100);
  32907. tryIdb();
  32908. }).finally(function () { return clearInterval(intervalId); });
  32909. }
  32910. module.exports = idbReady;
  32911. },{}],608:[function(_dereq_,module,exports){
  32912. /**
  32913. * Convert array of 16 byte values to UUID string format of the form:
  32914. * XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX
  32915. */
  32916. var byteToHex = [];
  32917. for (var i = 0; i < 256; ++i) {
  32918. byteToHex[i] = (i + 0x100).toString(16).substr(1);
  32919. }
  32920. function bytesToUuid(buf, offset) {
  32921. var i = offset || 0;
  32922. var bth = byteToHex;
  32923. // join used to fix memory issue caused by concatenation: https://bugs.chromium.org/p/v8/issues/detail?id=3175#c4
  32924. return ([
  32925. bth[buf[i++]], bth[buf[i++]],
  32926. bth[buf[i++]], bth[buf[i++]], '-',
  32927. bth[buf[i++]], bth[buf[i++]], '-',
  32928. bth[buf[i++]], bth[buf[i++]], '-',
  32929. bth[buf[i++]], bth[buf[i++]], '-',
  32930. bth[buf[i++]], bth[buf[i++]],
  32931. bth[buf[i++]], bth[buf[i++]],
  32932. bth[buf[i++]], bth[buf[i++]]
  32933. ]).join('');
  32934. }
  32935. module.exports = bytesToUuid;
  32936. },{}],609:[function(_dereq_,module,exports){
  32937. // Unique ID creation requires a high quality random # generator. In the
  32938. // browser this is a little complicated due to unknown quality of Math.random()
  32939. // and inconsistent support for the `crypto` API. We do the best we can via
  32940. // feature-detection
  32941. // getRandomValues needs to be invoked in a context where "this" is a Crypto
  32942. // implementation. Also, find the complete implementation of crypto on IE11.
  32943. var getRandomValues = (typeof(crypto) != 'undefined' && crypto.getRandomValues && crypto.getRandomValues.bind(crypto)) ||
  32944. (typeof(msCrypto) != 'undefined' && typeof window.msCrypto.getRandomValues == 'function' && msCrypto.getRandomValues.bind(msCrypto));
  32945. if (getRandomValues) {
  32946. // WHATWG crypto RNG - http://wiki.whatwg.org/wiki/Crypto
  32947. var rnds8 = new Uint8Array(16); // eslint-disable-line no-undef
  32948. module.exports = function whatwgRNG() {
  32949. getRandomValues(rnds8);
  32950. return rnds8;
  32951. };
  32952. } else {
  32953. // Math.random()-based (RNG)
  32954. //
  32955. // If all else fails, use Math.random(). It's fast, but is of unspecified
  32956. // quality.
  32957. var rnds = new Array(16);
  32958. module.exports = function mathRNG() {
  32959. for (var i = 0, r; i < 16; i++) {
  32960. if ((i & 0x03) === 0) r = Math.random() * 0x100000000;
  32961. rnds[i] = r >>> ((i & 0x03) << 3) & 0xff;
  32962. }
  32963. return rnds;
  32964. };
  32965. }
  32966. },{}],610:[function(_dereq_,module,exports){
  32967. var rng = _dereq_('./lib/rng');
  32968. var bytesToUuid = _dereq_('./lib/bytesToUuid');
  32969. function v4(options, buf, offset) {
  32970. var i = buf && offset || 0;
  32971. if (typeof(options) == 'string') {
  32972. buf = options === 'binary' ? new Array(16) : null;
  32973. options = null;
  32974. }
  32975. options = options || {};
  32976. var rnds = options.random || (options.rng || rng)();
  32977. // Per 4.4, set bits for version and `clock_seq_hi_and_reserved`
  32978. rnds[6] = (rnds[6] & 0x0f) | 0x40;
  32979. rnds[8] = (rnds[8] & 0x3f) | 0x80;
  32980. // Copy bytes to buffer, if provided
  32981. if (buf) {
  32982. for (var ii = 0; ii < 16; ++ii) {
  32983. buf[i + ii] = rnds[ii];
  32984. }
  32985. }
  32986. return buf || bytesToUuid(rnds);
  32987. }
  32988. module.exports = v4;
  32989. },{"./lib/bytesToUuid":608,"./lib/rng":609}]},{},[18])(18)
  32990. });