parse.js 985 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143101441014510146101471014810149101501015110152101531015410155101561015710158101591016010161101621016310164101651016610167101681016910170101711017210173101741017510176101771017810179101801018110182101831018410185101861018710188101891019010191101921019310194101951019610197101981019910200102011020210203102041020510206102071020810209102101021110212102131021410215102161021710218102191022010221102221022310224102251022610227102281022910230102311023210233102341023510236102371023810239102401024110242102431024410245102461024710248102491025010251102521025310254102551025610257102581025910260102611026210263102641026510266102671026810269102701027110272102731027410275102761027710278102791028010281102821028310284102851028610287102881028910290102911029210293102941029510296102971029810299103001030110302103031030410305103061030710308103091031010311103121031310314103151031610317103181031910320103211032210323103241032510326103271032810329103301033110332103331033410335103361033710338103391034010341103421034310344103451034610347103481034910350103511035210353103541035510356103571035810359103601036110362103631036410365103661036710368103691037010371103721037310374103751037610377103781037910380103811038210383103841038510386103871038810389103901039110392103931039410395103961039710398103991040010401104021040310404104051040610407104081040910410104111041210413104141041510416104171041810419104201042110422104231042410425104261042710428104291043010431104321043310434104351043610437104381043910440104411044210443104441044510446104471044810449104501045110452104531045410455104561045710458104591046010461104621046310464104651046610467104681046910470104711047210473104741047510476104771047810479104801048110482104831048410485104861048710488104891049010491104921049310494104951049610497104981049910500105011050210503105041050510506105071050810509105101051110512105131051410515105161051710518105191052010521105221052310524105251052610527105281052910530105311053210533105341053510536105371053810539105401054110542105431054410545105461054710548105491055010551105521055310554105551055610557105581055910560105611056210563105641056510566105671056810569105701057110572105731057410575105761057710578105791058010581105821058310584105851058610587105881058910590105911059210593105941059510596105971059810599106001060110602106031060410605106061060710608106091061010611106121061310614106151061610617106181061910620106211062210623106241062510626106271062810629106301063110632106331063410635106361063710638106391064010641106421064310644106451064610647106481064910650106511065210653106541065510656106571065810659106601066110662106631066410665106661066710668106691067010671106721067310674106751067610677106781067910680106811068210683106841068510686106871068810689106901069110692106931069410695106961069710698106991070010701107021070310704107051070610707107081070910710107111071210713107141071510716107171071810719107201072110722107231072410725107261072710728107291073010731107321073310734107351073610737107381073910740107411074210743107441074510746107471074810749107501075110752107531075410755107561075710758107591076010761107621076310764107651076610767107681076910770107711077210773107741077510776107771077810779107801078110782107831078410785107861078710788107891079010791107921079310794107951079610797107981079910800108011080210803108041080510806108071080810809108101081110812108131081410815108161081710818108191082010821108221082310824108251082610827108281082910830108311083210833108341083510836108371083810839108401084110842108431084410845108461084710848108491085010851108521085310854108551085610857108581085910860108611086210863108641086510866108671086810869108701087110872108731087410875108761087710878108791088010881108821088310884108851088610887108881088910890108911089210893108941089510896108971089810899109001090110902109031090410905109061090710908109091091010911109121091310914109151091610917109181091910920109211092210923109241092510926109271092810929109301093110932109331093410935109361093710938109391094010941109421094310944109451094610947109481094910950109511095210953109541095510956109571095810959109601096110962109631096410965109661096710968109691097010971109721097310974109751097610977109781097910980109811098210983109841098510986109871098810989109901099110992109931099410995109961099710998109991100011001110021100311004110051100611007110081100911010110111101211013110141101511016110171101811019110201102111022110231102411025110261102711028110291103011031110321103311034110351103611037110381103911040110411104211043110441104511046110471104811049110501105111052110531105411055110561105711058110591106011061110621106311064110651106611067110681106911070110711107211073110741107511076110771107811079110801108111082110831108411085110861108711088110891109011091110921109311094110951109611097110981109911100111011110211103111041110511106111071110811109111101111111112111131111411115111161111711118111191112011121111221112311124111251112611127111281112911130111311113211133111341113511136111371113811139111401114111142111431114411145111461114711148111491115011151111521115311154111551115611157111581115911160111611116211163111641116511166111671116811169111701117111172111731117411175111761117711178111791118011181111821118311184111851118611187111881118911190111911119211193111941119511196111971119811199112001120111202112031120411205112061120711208112091121011211112121121311214112151121611217112181121911220112211122211223112241122511226112271122811229112301123111232112331123411235112361123711238112391124011241112421124311244112451124611247112481124911250112511125211253112541125511256112571125811259112601126111262112631126411265112661126711268112691127011271112721127311274112751127611277112781127911280112811128211283112841128511286112871128811289112901129111292112931129411295112961129711298112991130011301113021130311304113051130611307113081130911310113111131211313113141131511316113171131811319113201132111322113231132411325113261132711328113291133011331113321133311334113351133611337113381133911340113411134211343113441134511346113471134811349113501135111352113531135411355113561135711358113591136011361113621136311364113651136611367113681136911370113711137211373113741137511376113771137811379113801138111382113831138411385113861138711388113891139011391113921139311394113951139611397113981139911400114011140211403114041140511406114071140811409114101141111412114131141411415114161141711418114191142011421114221142311424114251142611427114281142911430114311143211433114341143511436114371143811439114401144111442114431144411445114461144711448114491145011451114521145311454114551145611457114581145911460114611146211463114641146511466114671146811469114701147111472114731147411475114761147711478114791148011481114821148311484114851148611487114881148911490114911149211493114941149511496114971149811499115001150111502115031150411505115061150711508115091151011511115121151311514115151151611517115181151911520115211152211523115241152511526115271152811529115301153111532115331153411535115361153711538115391154011541115421154311544115451154611547115481154911550115511155211553115541155511556115571155811559115601156111562115631156411565115661156711568115691157011571115721157311574115751157611577115781157911580115811158211583115841158511586115871158811589115901159111592115931159411595115961159711598115991160011601116021160311604116051160611607116081160911610116111161211613116141161511616116171161811619116201162111622116231162411625116261162711628116291163011631116321163311634116351163611637116381163911640116411164211643116441164511646116471164811649116501165111652116531165411655116561165711658116591166011661116621166311664116651166611667116681166911670116711167211673116741167511676116771167811679116801168111682116831168411685116861168711688116891169011691116921169311694116951169611697116981169911700117011170211703117041170511706117071170811709117101171111712117131171411715117161171711718117191172011721117221172311724117251172611727117281172911730117311173211733117341173511736117371173811739117401174111742117431174411745117461174711748117491175011751117521175311754117551175611757117581175911760117611176211763117641176511766117671176811769117701177111772117731177411775117761177711778117791178011781117821178311784117851178611787117881178911790117911179211793117941179511796117971179811799118001180111802118031180411805118061180711808118091181011811118121181311814118151181611817118181181911820118211182211823118241182511826118271182811829118301183111832118331183411835118361183711838118391184011841118421184311844118451184611847118481184911850118511185211853118541185511856118571185811859118601186111862118631186411865118661186711868118691187011871118721187311874118751187611877118781187911880118811188211883118841188511886118871188811889118901189111892118931189411895118961189711898118991190011901119021190311904119051190611907119081190911910119111191211913119141191511916119171191811919119201192111922119231192411925119261192711928119291193011931119321193311934119351193611937119381193911940119411194211943119441194511946119471194811949119501195111952119531195411955119561195711958119591196011961119621196311964119651196611967119681196911970119711197211973119741197511976119771197811979119801198111982119831198411985119861198711988119891199011991119921199311994119951199611997119981199912000120011200212003120041200512006120071200812009120101201112012120131201412015120161201712018120191202012021120221202312024120251202612027120281202912030120311203212033120341203512036120371203812039120401204112042120431204412045120461204712048120491205012051120521205312054120551205612057120581205912060120611206212063120641206512066120671206812069120701207112072120731207412075120761207712078120791208012081120821208312084120851208612087120881208912090120911209212093120941209512096120971209812099121001210112102121031210412105121061210712108121091211012111121121211312114121151211612117121181211912120121211212212123121241212512126121271212812129121301213112132121331213412135121361213712138121391214012141121421214312144121451214612147121481214912150121511215212153121541215512156121571215812159121601216112162121631216412165121661216712168121691217012171121721217312174121751217612177121781217912180121811218212183121841218512186121871218812189121901219112192121931219412195121961219712198121991220012201122021220312204122051220612207122081220912210122111221212213122141221512216122171221812219122201222112222122231222412225122261222712228122291223012231122321223312234122351223612237122381223912240122411224212243122441224512246122471224812249122501225112252122531225412255122561225712258122591226012261122621226312264122651226612267122681226912270122711227212273122741227512276122771227812279122801228112282122831228412285122861228712288122891229012291122921229312294122951229612297122981229912300123011230212303123041230512306123071230812309123101231112312123131231412315123161231712318123191232012321123221232312324123251232612327123281232912330123311233212333123341233512336123371233812339123401234112342123431234412345123461234712348123491235012351123521235312354123551235612357123581235912360123611236212363123641236512366123671236812369123701237112372123731237412375123761237712378123791238012381123821238312384123851238612387123881238912390123911239212393123941239512396123971239812399124001240112402124031240412405124061240712408124091241012411124121241312414124151241612417124181241912420124211242212423124241242512426124271242812429124301243112432124331243412435124361243712438124391244012441124421244312444124451244612447124481244912450124511245212453124541245512456124571245812459124601246112462124631246412465124661246712468124691247012471124721247312474124751247612477124781247912480124811248212483124841248512486124871248812489124901249112492124931249412495124961249712498124991250012501125021250312504125051250612507125081250912510125111251212513125141251512516125171251812519125201252112522125231252412525125261252712528125291253012531125321253312534125351253612537125381253912540125411254212543125441254512546125471254812549125501255112552125531255412555125561255712558125591256012561125621256312564125651256612567125681256912570125711257212573125741257512576125771257812579125801258112582125831258412585125861258712588125891259012591125921259312594125951259612597125981259912600126011260212603126041260512606126071260812609126101261112612126131261412615126161261712618126191262012621126221262312624126251262612627126281262912630126311263212633126341263512636126371263812639126401264112642126431264412645126461264712648126491265012651126521265312654126551265612657126581265912660126611266212663126641266512666126671266812669126701267112672126731267412675126761267712678126791268012681126821268312684126851268612687126881268912690126911269212693126941269512696126971269812699127001270112702127031270412705127061270712708127091271012711127121271312714127151271612717127181271912720127211272212723127241272512726127271272812729127301273112732127331273412735127361273712738127391274012741127421274312744127451274612747127481274912750127511275212753127541275512756127571275812759127601276112762127631276412765127661276712768127691277012771127721277312774127751277612777127781277912780127811278212783127841278512786127871278812789127901279112792127931279412795127961279712798127991280012801128021280312804128051280612807128081280912810128111281212813128141281512816128171281812819128201282112822128231282412825128261282712828128291283012831128321283312834128351283612837128381283912840128411284212843128441284512846128471284812849128501285112852128531285412855128561285712858128591286012861128621286312864128651286612867128681286912870128711287212873128741287512876128771287812879128801288112882128831288412885128861288712888128891289012891128921289312894128951289612897128981289912900129011290212903129041290512906129071290812909129101291112912129131291412915129161291712918129191292012921129221292312924129251292612927129281292912930129311293212933129341293512936129371293812939129401294112942129431294412945129461294712948129491295012951129521295312954129551295612957129581295912960129611296212963129641296512966129671296812969129701297112972129731297412975129761297712978129791298012981129821298312984129851298612987129881298912990129911299212993129941299512996129971299812999130001300113002130031300413005130061300713008130091301013011130121301313014130151301613017130181301913020130211302213023130241302513026130271302813029130301303113032130331303413035130361303713038130391304013041130421304313044130451304613047130481304913050130511305213053130541305513056130571305813059130601306113062130631306413065130661306713068130691307013071130721307313074130751307613077130781307913080130811308213083130841308513086130871308813089130901309113092130931309413095130961309713098130991310013101131021310313104131051310613107131081310913110131111311213113131141311513116131171311813119131201312113122131231312413125131261312713128131291313013131131321313313134131351313613137131381313913140131411314213143131441314513146131471314813149131501315113152131531315413155131561315713158131591316013161131621316313164131651316613167131681316913170131711317213173131741317513176131771317813179131801318113182131831318413185131861318713188131891319013191131921319313194131951319613197131981319913200132011320213203132041320513206132071320813209132101321113212132131321413215132161321713218132191322013221132221322313224132251322613227132281322913230132311323213233132341323513236132371323813239132401324113242132431324413245132461324713248132491325013251132521325313254132551325613257132581325913260132611326213263132641326513266132671326813269132701327113272132731327413275132761327713278132791328013281132821328313284132851328613287132881328913290132911329213293132941329513296132971329813299133001330113302133031330413305133061330713308133091331013311133121331313314133151331613317133181331913320133211332213323133241332513326133271332813329133301333113332133331333413335133361333713338133391334013341133421334313344133451334613347133481334913350133511335213353133541335513356133571335813359133601336113362133631336413365133661336713368133691337013371133721337313374133751337613377133781337913380133811338213383133841338513386133871338813389133901339113392133931339413395133961339713398133991340013401134021340313404134051340613407134081340913410134111341213413134141341513416134171341813419134201342113422134231342413425134261342713428134291343013431134321343313434134351343613437134381343913440134411344213443134441344513446134471344813449134501345113452134531345413455134561345713458134591346013461134621346313464134651346613467134681346913470134711347213473134741347513476134771347813479134801348113482134831348413485134861348713488134891349013491134921349313494134951349613497134981349913500135011350213503135041350513506135071350813509135101351113512135131351413515135161351713518135191352013521135221352313524135251352613527135281352913530135311353213533135341353513536135371353813539135401354113542135431354413545135461354713548135491355013551135521355313554135551355613557135581355913560135611356213563135641356513566135671356813569135701357113572135731357413575135761357713578135791358013581135821358313584135851358613587135881358913590135911359213593135941359513596135971359813599136001360113602136031360413605136061360713608136091361013611136121361313614136151361613617136181361913620136211362213623136241362513626136271362813629136301363113632136331363413635136361363713638136391364013641136421364313644136451364613647136481364913650136511365213653136541365513656136571365813659136601366113662136631366413665136661366713668136691367013671136721367313674136751367613677136781367913680136811368213683136841368513686136871368813689136901369113692136931369413695136961369713698136991370013701137021370313704137051370613707137081370913710137111371213713137141371513716137171371813719137201372113722137231372413725137261372713728137291373013731137321373313734137351373613737137381373913740137411374213743137441374513746137471374813749137501375113752137531375413755137561375713758137591376013761137621376313764137651376613767137681376913770137711377213773137741377513776137771377813779137801378113782137831378413785137861378713788137891379013791137921379313794137951379613797137981379913800138011380213803138041380513806138071380813809138101381113812138131381413815138161381713818138191382013821138221382313824138251382613827138281382913830138311383213833138341383513836138371383813839138401384113842138431384413845138461384713848138491385013851138521385313854138551385613857138581385913860138611386213863138641386513866138671386813869138701387113872138731387413875138761387713878138791388013881138821388313884138851388613887138881388913890138911389213893138941389513896138971389813899139001390113902139031390413905139061390713908139091391013911139121391313914139151391613917139181391913920139211392213923139241392513926139271392813929139301393113932139331393413935139361393713938139391394013941139421394313944139451394613947139481394913950139511395213953139541395513956139571395813959139601396113962139631396413965139661396713968139691397013971139721397313974139751397613977139781397913980139811398213983139841398513986139871398813989139901399113992139931399413995139961399713998139991400014001140021400314004140051400614007140081400914010140111401214013140141401514016140171401814019140201402114022140231402414025140261402714028140291403014031140321403314034140351403614037140381403914040140411404214043140441404514046140471404814049140501405114052140531405414055140561405714058140591406014061140621406314064140651406614067140681406914070140711407214073140741407514076140771407814079140801408114082140831408414085140861408714088140891409014091140921409314094140951409614097140981409914100141011410214103141041410514106141071410814109141101411114112141131411414115141161411714118141191412014121141221412314124141251412614127141281412914130141311413214133141341413514136141371413814139141401414114142141431414414145141461414714148141491415014151141521415314154141551415614157141581415914160141611416214163141641416514166141671416814169141701417114172141731417414175141761417714178141791418014181141821418314184141851418614187141881418914190141911419214193141941419514196141971419814199142001420114202142031420414205142061420714208142091421014211142121421314214142151421614217142181421914220142211422214223142241422514226142271422814229142301423114232142331423414235142361423714238142391424014241142421424314244142451424614247142481424914250142511425214253142541425514256142571425814259142601426114262142631426414265142661426714268142691427014271142721427314274142751427614277142781427914280142811428214283142841428514286142871428814289142901429114292142931429414295142961429714298142991430014301143021430314304143051430614307143081430914310143111431214313143141431514316143171431814319143201432114322143231432414325143261432714328143291433014331143321433314334143351433614337143381433914340143411434214343143441434514346143471434814349143501435114352143531435414355143561435714358143591436014361143621436314364143651436614367143681436914370143711437214373143741437514376143771437814379143801438114382143831438414385143861438714388143891439014391143921439314394143951439614397143981439914400144011440214403144041440514406144071440814409144101441114412144131441414415144161441714418144191442014421144221442314424144251442614427144281442914430144311443214433144341443514436144371443814439144401444114442144431444414445144461444714448144491445014451144521445314454144551445614457144581445914460144611446214463144641446514466144671446814469144701447114472144731447414475144761447714478144791448014481144821448314484144851448614487144881448914490144911449214493144941449514496144971449814499145001450114502145031450414505145061450714508145091451014511145121451314514145151451614517145181451914520145211452214523145241452514526145271452814529145301453114532145331453414535145361453714538145391454014541145421454314544145451454614547145481454914550145511455214553145541455514556145571455814559145601456114562145631456414565145661456714568145691457014571145721457314574145751457614577145781457914580145811458214583145841458514586145871458814589145901459114592145931459414595145961459714598145991460014601146021460314604146051460614607146081460914610146111461214613146141461514616146171461814619146201462114622146231462414625146261462714628146291463014631146321463314634146351463614637146381463914640146411464214643146441464514646146471464814649146501465114652146531465414655146561465714658146591466014661146621466314664146651466614667146681466914670146711467214673146741467514676146771467814679146801468114682146831468414685146861468714688146891469014691146921469314694146951469614697146981469914700147011470214703147041470514706147071470814709147101471114712147131471414715147161471714718147191472014721147221472314724147251472614727147281472914730147311473214733147341473514736147371473814739147401474114742147431474414745147461474714748147491475014751147521475314754147551475614757147581475914760147611476214763147641476514766147671476814769147701477114772147731477414775147761477714778147791478014781147821478314784147851478614787147881478914790147911479214793147941479514796147971479814799148001480114802148031480414805148061480714808148091481014811148121481314814148151481614817148181481914820148211482214823148241482514826148271482814829148301483114832148331483414835148361483714838148391484014841148421484314844148451484614847148481484914850148511485214853148541485514856148571485814859148601486114862148631486414865148661486714868148691487014871148721487314874148751487614877148781487914880148811488214883148841488514886148871488814889148901489114892148931489414895148961489714898148991490014901149021490314904149051490614907149081490914910149111491214913149141491514916149171491814919149201492114922149231492414925149261492714928149291493014931149321493314934149351493614937149381493914940149411494214943149441494514946149471494814949149501495114952149531495414955149561495714958149591496014961149621496314964149651496614967149681496914970149711497214973149741497514976149771497814979149801498114982149831498414985149861498714988149891499014991149921499314994149951499614997149981499915000150011500215003150041500515006150071500815009150101501115012150131501415015150161501715018150191502015021150221502315024150251502615027150281502915030150311503215033150341503515036150371503815039150401504115042150431504415045150461504715048150491505015051150521505315054150551505615057150581505915060150611506215063150641506515066150671506815069150701507115072150731507415075150761507715078150791508015081150821508315084150851508615087150881508915090150911509215093150941509515096150971509815099151001510115102151031510415105151061510715108151091511015111151121511315114151151511615117151181511915120151211512215123151241512515126151271512815129151301513115132151331513415135151361513715138151391514015141151421514315144151451514615147151481514915150151511515215153151541515515156151571515815159151601516115162151631516415165151661516715168151691517015171151721517315174151751517615177151781517915180151811518215183151841518515186151871518815189151901519115192151931519415195151961519715198151991520015201152021520315204152051520615207152081520915210152111521215213152141521515216152171521815219152201522115222152231522415225152261522715228152291523015231152321523315234152351523615237152381523915240152411524215243152441524515246152471524815249152501525115252152531525415255152561525715258152591526015261152621526315264152651526615267152681526915270152711527215273152741527515276152771527815279152801528115282152831528415285152861528715288152891529015291152921529315294152951529615297152981529915300153011530215303153041530515306153071530815309153101531115312153131531415315153161531715318153191532015321153221532315324153251532615327153281532915330153311533215333153341533515336153371533815339153401534115342153431534415345153461534715348153491535015351153521535315354153551535615357153581535915360153611536215363153641536515366153671536815369153701537115372153731537415375153761537715378153791538015381153821538315384153851538615387153881538915390153911539215393153941539515396153971539815399154001540115402154031540415405154061540715408154091541015411154121541315414154151541615417154181541915420154211542215423154241542515426154271542815429154301543115432154331543415435154361543715438154391544015441154421544315444154451544615447154481544915450154511545215453154541545515456154571545815459154601546115462154631546415465154661546715468154691547015471154721547315474154751547615477154781547915480154811548215483154841548515486154871548815489154901549115492154931549415495154961549715498154991550015501155021550315504155051550615507155081550915510155111551215513155141551515516155171551815519155201552115522155231552415525155261552715528155291553015531155321553315534155351553615537155381553915540155411554215543155441554515546155471554815549155501555115552155531555415555155561555715558155591556015561155621556315564155651556615567155681556915570155711557215573155741557515576155771557815579155801558115582155831558415585155861558715588155891559015591155921559315594155951559615597155981559915600156011560215603156041560515606156071560815609156101561115612156131561415615156161561715618156191562015621156221562315624156251562615627156281562915630156311563215633156341563515636156371563815639156401564115642156431564415645156461564715648156491565015651156521565315654156551565615657156581565915660156611566215663156641566515666156671566815669156701567115672156731567415675156761567715678156791568015681156821568315684156851568615687156881568915690156911569215693156941569515696156971569815699157001570115702157031570415705157061570715708157091571015711157121571315714157151571615717157181571915720157211572215723157241572515726157271572815729157301573115732157331573415735157361573715738157391574015741157421574315744157451574615747157481574915750157511575215753157541575515756157571575815759157601576115762157631576415765157661576715768157691577015771157721577315774157751577615777157781577915780157811578215783157841578515786157871578815789157901579115792157931579415795157961579715798157991580015801158021580315804158051580615807158081580915810158111581215813158141581515816158171581815819158201582115822158231582415825158261582715828158291583015831158321583315834158351583615837158381583915840158411584215843158441584515846158471584815849158501585115852158531585415855158561585715858158591586015861158621586315864158651586615867158681586915870158711587215873158741587515876158771587815879158801588115882158831588415885158861588715888158891589015891158921589315894158951589615897158981589915900159011590215903159041590515906159071590815909159101591115912159131591415915159161591715918159191592015921159221592315924159251592615927159281592915930159311593215933159341593515936159371593815939159401594115942159431594415945159461594715948159491595015951159521595315954159551595615957159581595915960159611596215963159641596515966159671596815969159701597115972159731597415975159761597715978159791598015981159821598315984159851598615987159881598915990159911599215993159941599515996159971599815999160001600116002160031600416005160061600716008160091601016011160121601316014160151601616017160181601916020160211602216023160241602516026160271602816029160301603116032160331603416035160361603716038160391604016041160421604316044160451604616047160481604916050160511605216053160541605516056160571605816059160601606116062160631606416065160661606716068160691607016071160721607316074160751607616077160781607916080160811608216083160841608516086160871608816089160901609116092160931609416095160961609716098160991610016101161021610316104161051610616107161081610916110161111611216113161141611516116161171611816119161201612116122161231612416125161261612716128161291613016131161321613316134161351613616137161381613916140161411614216143161441614516146161471614816149161501615116152161531615416155161561615716158161591616016161161621616316164161651616616167161681616916170161711617216173161741617516176161771617816179161801618116182161831618416185161861618716188161891619016191161921619316194161951619616197161981619916200162011620216203162041620516206162071620816209162101621116212162131621416215162161621716218162191622016221162221622316224162251622616227162281622916230162311623216233162341623516236162371623816239162401624116242162431624416245162461624716248162491625016251162521625316254162551625616257162581625916260162611626216263162641626516266162671626816269162701627116272162731627416275162761627716278162791628016281162821628316284162851628616287162881628916290162911629216293162941629516296162971629816299163001630116302163031630416305163061630716308163091631016311163121631316314163151631616317163181631916320163211632216323163241632516326163271632816329163301633116332163331633416335163361633716338163391634016341163421634316344163451634616347163481634916350163511635216353163541635516356163571635816359163601636116362163631636416365163661636716368163691637016371163721637316374163751637616377163781637916380163811638216383163841638516386163871638816389163901639116392163931639416395163961639716398163991640016401164021640316404164051640616407164081640916410164111641216413164141641516416164171641816419164201642116422164231642416425164261642716428164291643016431164321643316434164351643616437164381643916440164411644216443164441644516446164471644816449164501645116452164531645416455164561645716458164591646016461164621646316464164651646616467164681646916470164711647216473164741647516476164771647816479164801648116482164831648416485164861648716488164891649016491164921649316494164951649616497164981649916500165011650216503165041650516506165071650816509165101651116512165131651416515165161651716518165191652016521165221652316524165251652616527165281652916530165311653216533165341653516536165371653816539165401654116542165431654416545165461654716548165491655016551165521655316554165551655616557165581655916560165611656216563165641656516566165671656816569165701657116572165731657416575165761657716578165791658016581165821658316584165851658616587165881658916590165911659216593165941659516596165971659816599166001660116602166031660416605166061660716608166091661016611166121661316614166151661616617166181661916620166211662216623166241662516626166271662816629166301663116632166331663416635166361663716638166391664016641166421664316644166451664616647166481664916650166511665216653166541665516656166571665816659166601666116662166631666416665166661666716668166691667016671166721667316674166751667616677166781667916680166811668216683166841668516686166871668816689166901669116692166931669416695166961669716698166991670016701167021670316704167051670616707167081670916710167111671216713167141671516716167171671816719167201672116722167231672416725167261672716728167291673016731167321673316734167351673616737167381673916740167411674216743167441674516746167471674816749167501675116752167531675416755167561675716758167591676016761167621676316764167651676616767167681676916770167711677216773167741677516776167771677816779167801678116782167831678416785167861678716788167891679016791167921679316794167951679616797167981679916800168011680216803168041680516806168071680816809168101681116812168131681416815168161681716818168191682016821168221682316824168251682616827168281682916830168311683216833168341683516836168371683816839168401684116842168431684416845168461684716848168491685016851168521685316854168551685616857168581685916860168611686216863168641686516866168671686816869168701687116872168731687416875168761687716878168791688016881168821688316884168851688616887168881688916890168911689216893168941689516896168971689816899169001690116902169031690416905169061690716908169091691016911169121691316914169151691616917169181691916920169211692216923169241692516926169271692816929169301693116932169331693416935169361693716938169391694016941169421694316944169451694616947169481694916950169511695216953169541695516956169571695816959169601696116962169631696416965169661696716968169691697016971169721697316974169751697616977169781697916980169811698216983169841698516986169871698816989169901699116992169931699416995169961699716998169991700017001170021700317004170051700617007170081700917010170111701217013170141701517016170171701817019170201702117022170231702417025170261702717028170291703017031170321703317034170351703617037170381703917040170411704217043170441704517046170471704817049170501705117052170531705417055170561705717058170591706017061170621706317064170651706617067170681706917070170711707217073170741707517076170771707817079170801708117082170831708417085170861708717088170891709017091170921709317094170951709617097170981709917100171011710217103171041710517106171071710817109171101711117112171131711417115171161711717118171191712017121171221712317124171251712617127171281712917130171311713217133171341713517136171371713817139171401714117142171431714417145171461714717148171491715017151171521715317154171551715617157171581715917160171611716217163171641716517166171671716817169171701717117172171731717417175171761717717178171791718017181171821718317184171851718617187171881718917190171911719217193171941719517196171971719817199172001720117202172031720417205172061720717208172091721017211172121721317214172151721617217172181721917220172211722217223172241722517226172271722817229172301723117232172331723417235172361723717238172391724017241172421724317244172451724617247172481724917250172511725217253172541725517256172571725817259172601726117262172631726417265172661726717268172691727017271172721727317274172751727617277172781727917280172811728217283172841728517286172871728817289172901729117292172931729417295172961729717298172991730017301173021730317304173051730617307173081730917310173111731217313173141731517316173171731817319173201732117322173231732417325173261732717328173291733017331173321733317334173351733617337173381733917340173411734217343173441734517346173471734817349173501735117352173531735417355173561735717358173591736017361173621736317364173651736617367173681736917370173711737217373173741737517376173771737817379173801738117382173831738417385173861738717388173891739017391173921739317394173951739617397173981739917400174011740217403174041740517406174071740817409174101741117412174131741417415174161741717418174191742017421174221742317424174251742617427174281742917430174311743217433174341743517436174371743817439174401744117442174431744417445174461744717448174491745017451174521745317454174551745617457174581745917460174611746217463174641746517466174671746817469174701747117472174731747417475174761747717478174791748017481174821748317484174851748617487174881748917490174911749217493174941749517496174971749817499175001750117502175031750417505175061750717508175091751017511175121751317514175151751617517175181751917520175211752217523175241752517526175271752817529175301753117532175331753417535175361753717538175391754017541175421754317544175451754617547175481754917550175511755217553175541755517556175571755817559175601756117562175631756417565175661756717568175691757017571175721757317574175751757617577175781757917580175811758217583175841758517586175871758817589175901759117592175931759417595175961759717598175991760017601176021760317604176051760617607176081760917610176111761217613176141761517616176171761817619176201762117622176231762417625176261762717628176291763017631176321763317634176351763617637176381763917640176411764217643176441764517646176471764817649176501765117652176531765417655176561765717658176591766017661176621766317664176651766617667176681766917670176711767217673176741767517676176771767817679176801768117682176831768417685176861768717688176891769017691176921769317694176951769617697176981769917700177011770217703177041770517706177071770817709177101771117712177131771417715177161771717718177191772017721177221772317724177251772617727177281772917730177311773217733177341773517736177371773817739177401774117742177431774417745177461774717748177491775017751177521775317754177551775617757177581775917760177611776217763177641776517766177671776817769177701777117772177731777417775177761777717778177791778017781177821778317784177851778617787177881778917790177911779217793177941779517796177971779817799178001780117802178031780417805178061780717808178091781017811178121781317814178151781617817178181781917820178211782217823178241782517826178271782817829178301783117832178331783417835178361783717838178391784017841178421784317844178451784617847178481784917850178511785217853178541785517856178571785817859178601786117862178631786417865178661786717868178691787017871178721787317874178751787617877178781787917880178811788217883178841788517886178871788817889178901789117892178931789417895178961789717898178991790017901179021790317904179051790617907179081790917910179111791217913179141791517916179171791817919179201792117922179231792417925179261792717928179291793017931179321793317934179351793617937179381793917940179411794217943179441794517946179471794817949179501795117952179531795417955179561795717958179591796017961179621796317964179651796617967179681796917970179711797217973179741797517976179771797817979179801798117982179831798417985179861798717988179891799017991179921799317994179951799617997179981799918000180011800218003180041800518006180071800818009180101801118012180131801418015180161801718018180191802018021180221802318024180251802618027180281802918030180311803218033180341803518036180371803818039180401804118042180431804418045180461804718048180491805018051180521805318054180551805618057180581805918060180611806218063180641806518066180671806818069180701807118072180731807418075180761807718078180791808018081180821808318084180851808618087180881808918090180911809218093180941809518096180971809818099181001810118102181031810418105181061810718108181091811018111181121811318114181151811618117181181811918120181211812218123181241812518126181271812818129181301813118132181331813418135181361813718138181391814018141181421814318144181451814618147181481814918150181511815218153181541815518156181571815818159181601816118162181631816418165181661816718168181691817018171181721817318174181751817618177181781817918180181811818218183181841818518186181871818818189181901819118192181931819418195181961819718198181991820018201182021820318204182051820618207182081820918210182111821218213182141821518216182171821818219182201822118222182231822418225182261822718228182291823018231182321823318234182351823618237182381823918240182411824218243182441824518246182471824818249182501825118252182531825418255182561825718258182591826018261182621826318264182651826618267182681826918270182711827218273182741827518276182771827818279182801828118282182831828418285182861828718288182891829018291182921829318294182951829618297182981829918300183011830218303183041830518306183071830818309183101831118312183131831418315183161831718318183191832018321183221832318324183251832618327183281832918330183311833218333183341833518336183371833818339183401834118342183431834418345183461834718348183491835018351183521835318354183551835618357183581835918360183611836218363183641836518366183671836818369183701837118372183731837418375183761837718378183791838018381183821838318384183851838618387183881838918390183911839218393183941839518396183971839818399184001840118402184031840418405184061840718408184091841018411184121841318414184151841618417184181841918420184211842218423184241842518426184271842818429184301843118432184331843418435184361843718438184391844018441184421844318444184451844618447184481844918450184511845218453184541845518456184571845818459184601846118462184631846418465184661846718468184691847018471184721847318474184751847618477184781847918480184811848218483184841848518486184871848818489184901849118492184931849418495184961849718498184991850018501185021850318504185051850618507185081850918510185111851218513185141851518516185171851818519185201852118522185231852418525185261852718528185291853018531185321853318534185351853618537185381853918540185411854218543185441854518546185471854818549185501855118552185531855418555185561855718558185591856018561185621856318564185651856618567185681856918570185711857218573185741857518576185771857818579185801858118582185831858418585185861858718588185891859018591185921859318594185951859618597185981859918600186011860218603186041860518606186071860818609186101861118612186131861418615186161861718618186191862018621186221862318624186251862618627186281862918630186311863218633186341863518636186371863818639186401864118642186431864418645186461864718648186491865018651186521865318654186551865618657186581865918660186611866218663186641866518666186671866818669186701867118672186731867418675186761867718678186791868018681186821868318684186851868618687186881868918690186911869218693186941869518696186971869818699187001870118702187031870418705187061870718708187091871018711187121871318714187151871618717187181871918720187211872218723187241872518726187271872818729187301873118732187331873418735187361873718738187391874018741187421874318744187451874618747187481874918750187511875218753187541875518756187571875818759187601876118762187631876418765187661876718768187691877018771187721877318774187751877618777187781877918780187811878218783187841878518786187871878818789187901879118792187931879418795187961879718798187991880018801188021880318804188051880618807188081880918810188111881218813188141881518816188171881818819188201882118822188231882418825188261882718828188291883018831188321883318834188351883618837188381883918840188411884218843188441884518846188471884818849188501885118852188531885418855188561885718858188591886018861188621886318864188651886618867188681886918870188711887218873188741887518876188771887818879188801888118882188831888418885188861888718888188891889018891188921889318894188951889618897188981889918900189011890218903189041890518906189071890818909189101891118912189131891418915189161891718918189191892018921189221892318924189251892618927189281892918930189311893218933189341893518936189371893818939189401894118942189431894418945189461894718948189491895018951189521895318954189551895618957189581895918960189611896218963189641896518966189671896818969189701897118972189731897418975189761897718978189791898018981189821898318984189851898618987189881898918990189911899218993189941899518996189971899818999190001900119002190031900419005190061900719008190091901019011190121901319014190151901619017190181901919020190211902219023190241902519026190271902819029190301903119032190331903419035190361903719038190391904019041190421904319044190451904619047190481904919050190511905219053190541905519056190571905819059190601906119062190631906419065190661906719068190691907019071190721907319074190751907619077190781907919080190811908219083190841908519086190871908819089190901909119092190931909419095190961909719098190991910019101191021910319104191051910619107191081910919110191111911219113191141911519116191171911819119191201912119122191231912419125191261912719128191291913019131191321913319134191351913619137191381913919140191411914219143191441914519146191471914819149191501915119152191531915419155191561915719158191591916019161191621916319164191651916619167191681916919170191711917219173191741917519176191771917819179191801918119182191831918419185191861918719188191891919019191191921919319194191951919619197191981919919200192011920219203192041920519206192071920819209192101921119212192131921419215192161921719218192191922019221192221922319224192251922619227192281922919230192311923219233192341923519236192371923819239192401924119242192431924419245192461924719248192491925019251192521925319254192551925619257192581925919260192611926219263192641926519266192671926819269192701927119272192731927419275192761927719278192791928019281192821928319284192851928619287192881928919290192911929219293192941929519296192971929819299193001930119302193031930419305193061930719308193091931019311193121931319314193151931619317193181931919320193211932219323193241932519326193271932819329193301933119332193331933419335193361933719338193391934019341193421934319344193451934619347193481934919350193511935219353193541935519356193571935819359193601936119362193631936419365193661936719368193691937019371193721937319374193751937619377193781937919380193811938219383193841938519386193871938819389193901939119392193931939419395193961939719398193991940019401194021940319404194051940619407194081940919410194111941219413194141941519416194171941819419194201942119422194231942419425194261942719428194291943019431194321943319434194351943619437194381943919440194411944219443194441944519446194471944819449194501945119452194531945419455194561945719458194591946019461194621946319464194651946619467194681946919470194711947219473194741947519476194771947819479194801948119482194831948419485194861948719488194891949019491194921949319494194951949619497194981949919500195011950219503195041950519506195071950819509195101951119512195131951419515195161951719518195191952019521195221952319524195251952619527195281952919530195311953219533195341953519536195371953819539195401954119542195431954419545195461954719548195491955019551195521955319554195551955619557195581955919560195611956219563195641956519566195671956819569195701957119572195731957419575195761957719578195791958019581195821958319584195851958619587195881958919590195911959219593195941959519596195971959819599196001960119602196031960419605196061960719608196091961019611196121961319614196151961619617196181961919620196211962219623196241962519626196271962819629196301963119632196331963419635196361963719638196391964019641196421964319644196451964619647196481964919650196511965219653196541965519656196571965819659196601966119662196631966419665196661966719668196691967019671196721967319674196751967619677196781967919680196811968219683196841968519686196871968819689196901969119692196931969419695196961969719698196991970019701197021970319704197051970619707197081970919710197111971219713197141971519716197171971819719197201972119722197231972419725197261972719728197291973019731197321973319734197351973619737197381973919740197411974219743197441974519746197471974819749197501975119752197531975419755197561975719758197591976019761197621976319764197651976619767197681976919770197711977219773197741977519776197771977819779197801978119782197831978419785197861978719788197891979019791197921979319794197951979619797197981979919800198011980219803198041980519806198071980819809198101981119812198131981419815198161981719818198191982019821198221982319824198251982619827198281982919830198311983219833198341983519836198371983819839198401984119842198431984419845198461984719848198491985019851198521985319854198551985619857198581985919860198611986219863198641986519866198671986819869198701987119872198731987419875198761987719878198791988019881198821988319884198851988619887198881988919890198911989219893198941989519896198971989819899199001990119902199031990419905199061990719908199091991019911199121991319914199151991619917199181991919920199211992219923199241992519926199271992819929199301993119932199331993419935199361993719938199391994019941199421994319944199451994619947199481994919950199511995219953199541995519956199571995819959199601996119962199631996419965199661996719968199691997019971199721997319974199751997619977199781997919980199811998219983199841998519986199871998819989199901999119992199931999419995199961999719998199992000020001200022000320004200052000620007200082000920010200112001220013200142001520016200172001820019200202002120022200232002420025200262002720028200292003020031200322003320034200352003620037200382003920040200412004220043200442004520046200472004820049200502005120052200532005420055200562005720058200592006020061200622006320064200652006620067200682006920070200712007220073200742007520076200772007820079200802008120082200832008420085200862008720088200892009020091200922009320094200952009620097200982009920100201012010220103201042010520106201072010820109201102011120112201132011420115201162011720118201192012020121201222012320124201252012620127201282012920130201312013220133201342013520136201372013820139201402014120142201432014420145201462014720148201492015020151201522015320154201552015620157201582015920160201612016220163201642016520166201672016820169201702017120172201732017420175201762017720178201792018020181201822018320184201852018620187201882018920190201912019220193201942019520196201972019820199202002020120202202032020420205202062020720208202092021020211202122021320214202152021620217202182021920220202212022220223202242022520226202272022820229202302023120232202332023420235202362023720238202392024020241202422024320244202452024620247202482024920250202512025220253202542025520256202572025820259202602026120262202632026420265202662026720268202692027020271202722027320274202752027620277202782027920280202812028220283202842028520286202872028820289202902029120292202932029420295202962029720298202992030020301203022030320304203052030620307203082030920310203112031220313203142031520316203172031820319203202032120322203232032420325203262032720328203292033020331203322033320334203352033620337203382033920340203412034220343203442034520346203472034820349203502035120352203532035420355203562035720358203592036020361203622036320364203652036620367203682036920370203712037220373203742037520376203772037820379203802038120382203832038420385203862038720388203892039020391203922039320394203952039620397203982039920400204012040220403204042040520406204072040820409204102041120412204132041420415204162041720418204192042020421204222042320424204252042620427204282042920430204312043220433204342043520436204372043820439204402044120442204432044420445204462044720448204492045020451204522045320454204552045620457204582045920460204612046220463204642046520466204672046820469204702047120472204732047420475204762047720478204792048020481204822048320484204852048620487204882048920490204912049220493204942049520496204972049820499205002050120502205032050420505205062050720508205092051020511205122051320514205152051620517205182051920520205212052220523205242052520526205272052820529205302053120532205332053420535205362053720538205392054020541205422054320544205452054620547205482054920550205512055220553205542055520556205572055820559205602056120562205632056420565205662056720568205692057020571205722057320574205752057620577205782057920580205812058220583205842058520586205872058820589205902059120592205932059420595205962059720598205992060020601206022060320604206052060620607206082060920610206112061220613206142061520616206172061820619206202062120622206232062420625206262062720628206292063020631206322063320634206352063620637206382063920640206412064220643206442064520646206472064820649206502065120652206532065420655206562065720658206592066020661206622066320664206652066620667206682066920670206712067220673206742067520676206772067820679206802068120682206832068420685206862068720688206892069020691206922069320694206952069620697206982069920700207012070220703207042070520706207072070820709207102071120712207132071420715207162071720718207192072020721207222072320724207252072620727207282072920730207312073220733207342073520736207372073820739207402074120742207432074420745207462074720748207492075020751207522075320754207552075620757207582075920760207612076220763207642076520766207672076820769207702077120772207732077420775207762077720778207792078020781207822078320784207852078620787207882078920790207912079220793207942079520796207972079820799208002080120802208032080420805208062080720808208092081020811208122081320814208152081620817208182081920820208212082220823208242082520826208272082820829208302083120832208332083420835208362083720838208392084020841208422084320844208452084620847208482084920850208512085220853208542085520856208572085820859208602086120862208632086420865208662086720868208692087020871208722087320874208752087620877208782087920880208812088220883208842088520886208872088820889208902089120892208932089420895208962089720898208992090020901209022090320904209052090620907209082090920910209112091220913209142091520916209172091820919209202092120922209232092420925209262092720928209292093020931209322093320934209352093620937209382093920940209412094220943209442094520946209472094820949209502095120952209532095420955209562095720958209592096020961209622096320964209652096620967209682096920970209712097220973209742097520976209772097820979209802098120982209832098420985209862098720988209892099020991209922099320994209952099620997209982099921000210012100221003210042100521006210072100821009210102101121012210132101421015210162101721018210192102021021210222102321024210252102621027210282102921030210312103221033210342103521036210372103821039210402104121042210432104421045210462104721048210492105021051210522105321054210552105621057210582105921060210612106221063210642106521066210672106821069210702107121072210732107421075210762107721078210792108021081210822108321084210852108621087210882108921090210912109221093210942109521096210972109821099211002110121102211032110421105211062110721108211092111021111211122111321114211152111621117211182111921120211212112221123211242112521126211272112821129211302113121132211332113421135211362113721138211392114021141211422114321144211452114621147211482114921150211512115221153211542115521156211572115821159211602116121162211632116421165211662116721168211692117021171211722117321174211752117621177211782117921180211812118221183211842118521186211872118821189211902119121192211932119421195211962119721198211992120021201212022120321204212052120621207212082120921210212112121221213212142121521216212172121821219212202122121222212232122421225212262122721228212292123021231212322123321234212352123621237212382123921240212412124221243212442124521246212472124821249212502125121252212532125421255212562125721258212592126021261212622126321264212652126621267212682126921270212712127221273212742127521276212772127821279212802128121282212832128421285212862128721288212892129021291212922129321294212952129621297212982129921300213012130221303213042130521306213072130821309213102131121312213132131421315213162131721318213192132021321213222132321324213252132621327213282132921330213312133221333213342133521336213372133821339213402134121342213432134421345213462134721348213492135021351213522135321354213552135621357213582135921360213612136221363213642136521366213672136821369213702137121372213732137421375213762137721378213792138021381213822138321384213852138621387213882138921390213912139221393213942139521396213972139821399214002140121402214032140421405214062140721408214092141021411214122141321414214152141621417214182141921420214212142221423214242142521426214272142821429214302143121432214332143421435214362143721438214392144021441214422144321444214452144621447214482144921450214512145221453214542145521456214572145821459214602146121462214632146421465214662146721468214692147021471214722147321474214752147621477214782147921480214812148221483214842148521486214872148821489214902149121492214932149421495214962149721498214992150021501215022150321504215052150621507215082150921510215112151221513215142151521516215172151821519215202152121522215232152421525215262152721528215292153021531215322153321534215352153621537215382153921540215412154221543215442154521546215472154821549215502155121552215532155421555215562155721558215592156021561215622156321564215652156621567215682156921570215712157221573215742157521576215772157821579215802158121582215832158421585215862158721588215892159021591215922159321594215952159621597215982159921600216012160221603216042160521606216072160821609216102161121612216132161421615216162161721618216192162021621216222162321624216252162621627216282162921630216312163221633216342163521636216372163821639216402164121642216432164421645216462164721648216492165021651216522165321654216552165621657216582165921660216612166221663216642166521666216672166821669216702167121672216732167421675216762167721678216792168021681216822168321684216852168621687216882168921690216912169221693216942169521696216972169821699217002170121702217032170421705217062170721708217092171021711217122171321714217152171621717217182171921720217212172221723217242172521726217272172821729217302173121732217332173421735217362173721738217392174021741217422174321744217452174621747217482174921750217512175221753217542175521756217572175821759217602176121762217632176421765217662176721768217692177021771217722177321774217752177621777217782177921780217812178221783217842178521786217872178821789217902179121792217932179421795217962179721798217992180021801218022180321804218052180621807218082180921810218112181221813218142181521816218172181821819218202182121822218232182421825218262182721828218292183021831218322183321834218352183621837218382183921840218412184221843218442184521846218472184821849218502185121852218532185421855218562185721858218592186021861218622186321864218652186621867218682186921870218712187221873218742187521876218772187821879218802188121882218832188421885218862188721888218892189021891218922189321894218952189621897218982189921900219012190221903219042190521906219072190821909219102191121912219132191421915219162191721918219192192021921219222192321924219252192621927219282192921930219312193221933219342193521936219372193821939219402194121942219432194421945219462194721948219492195021951219522195321954219552195621957219582195921960219612196221963219642196521966219672196821969219702197121972219732197421975219762197721978219792198021981219822198321984219852198621987219882198921990219912199221993219942199521996219972199821999220002200122002220032200422005220062200722008220092201022011220122201322014220152201622017220182201922020220212202222023220242202522026220272202822029220302203122032220332203422035220362203722038220392204022041220422204322044220452204622047220482204922050220512205222053220542205522056220572205822059220602206122062220632206422065220662206722068220692207022071220722207322074220752207622077220782207922080220812208222083220842208522086220872208822089220902209122092220932209422095220962209722098220992210022101221022210322104221052210622107221082210922110221112211222113221142211522116221172211822119221202212122122221232212422125221262212722128221292213022131221322213322134221352213622137221382213922140221412214222143221442214522146221472214822149221502215122152221532215422155221562215722158221592216022161221622216322164221652216622167221682216922170221712217222173221742217522176221772217822179221802218122182221832218422185221862218722188221892219022191221922219322194221952219622197221982219922200222012220222203222042220522206222072220822209222102221122212222132221422215222162221722218222192222022221222222222322224222252222622227222282222922230222312223222233222342223522236222372223822239222402224122242222432224422245222462224722248222492225022251222522225322254222552225622257222582225922260222612226222263222642226522266222672226822269222702227122272222732227422275222762227722278222792228022281222822228322284222852228622287222882228922290222912229222293222942229522296222972229822299223002230122302223032230422305223062230722308223092231022311223122231322314223152231622317223182231922320223212232222323223242232522326223272232822329223302233122332223332233422335223362233722338223392234022341223422234322344223452234622347223482234922350223512235222353223542235522356223572235822359223602236122362223632236422365223662236722368223692237022371223722237322374223752237622377223782237922380223812238222383223842238522386223872238822389223902239122392223932239422395223962239722398223992240022401224022240322404224052240622407224082240922410224112241222413224142241522416224172241822419224202242122422224232242422425224262242722428224292243022431224322243322434224352243622437224382243922440224412244222443224442244522446224472244822449224502245122452224532245422455224562245722458224592246022461224622246322464224652246622467224682246922470224712247222473224742247522476224772247822479224802248122482224832248422485224862248722488224892249022491224922249322494224952249622497224982249922500225012250222503225042250522506225072250822509225102251122512225132251422515225162251722518225192252022521225222252322524225252252622527225282252922530225312253222533225342253522536225372253822539225402254122542225432254422545225462254722548225492255022551225522255322554225552255622557225582255922560225612256222563225642256522566225672256822569225702257122572225732257422575225762257722578225792258022581225822258322584225852258622587225882258922590225912259222593225942259522596225972259822599226002260122602226032260422605226062260722608226092261022611226122261322614226152261622617226182261922620226212262222623226242262522626226272262822629226302263122632226332263422635226362263722638226392264022641226422264322644226452264622647226482264922650226512265222653226542265522656226572265822659226602266122662226632266422665226662266722668226692267022671226722267322674226752267622677226782267922680226812268222683226842268522686226872268822689226902269122692226932269422695226962269722698226992270022701227022270322704227052270622707227082270922710227112271222713227142271522716227172271822719227202272122722227232272422725227262272722728227292273022731227322273322734227352273622737227382273922740227412274222743227442274522746227472274822749227502275122752227532275422755227562275722758227592276022761227622276322764227652276622767227682276922770227712277222773227742277522776227772277822779227802278122782227832278422785227862278722788227892279022791227922279322794227952279622797227982279922800228012280222803228042280522806228072280822809228102281122812228132281422815228162281722818228192282022821228222282322824228252282622827228282282922830228312283222833228342283522836228372283822839228402284122842228432284422845228462284722848228492285022851228522285322854228552285622857228582285922860228612286222863228642286522866228672286822869228702287122872228732287422875228762287722878228792288022881228822288322884228852288622887228882288922890228912289222893228942289522896228972289822899229002290122902229032290422905229062290722908229092291022911229122291322914229152291622917229182291922920229212292222923229242292522926229272292822929229302293122932229332293422935229362293722938229392294022941229422294322944229452294622947229482294922950229512295222953229542295522956229572295822959229602296122962229632296422965229662296722968229692297022971229722297322974229752297622977229782297922980229812298222983229842298522986229872298822989229902299122992229932299422995229962299722998229992300023001230022300323004230052300623007230082300923010230112301223013230142301523016230172301823019230202302123022230232302423025230262302723028230292303023031230322303323034230352303623037230382303923040230412304223043230442304523046230472304823049230502305123052230532305423055230562305723058230592306023061230622306323064230652306623067230682306923070230712307223073230742307523076230772307823079230802308123082230832308423085230862308723088230892309023091230922309323094230952309623097230982309923100231012310223103231042310523106231072310823109231102311123112231132311423115231162311723118231192312023121231222312323124231252312623127231282312923130231312313223133231342313523136231372313823139231402314123142231432314423145231462314723148231492315023151231522315323154231552315623157231582315923160231612316223163231642316523166231672316823169231702317123172231732317423175231762317723178231792318023181231822318323184231852318623187231882318923190231912319223193231942319523196231972319823199232002320123202232032320423205232062320723208232092321023211232122321323214232152321623217232182321923220232212322223223232242322523226232272322823229232302323123232232332323423235232362323723238232392324023241232422324323244232452324623247232482324923250232512325223253232542325523256232572325823259232602326123262232632326423265232662326723268232692327023271232722327323274232752327623277232782327923280232812328223283232842328523286232872328823289232902329123292232932329423295232962329723298232992330023301233022330323304233052330623307233082330923310233112331223313233142331523316233172331823319233202332123322233232332423325233262332723328233292333023331233322333323334233352333623337233382333923340233412334223343233442334523346233472334823349233502335123352233532335423355233562335723358233592336023361233622336323364233652336623367233682336923370233712337223373233742337523376233772337823379233802338123382233832338423385233862338723388233892339023391233922339323394233952339623397233982339923400234012340223403234042340523406234072340823409234102341123412234132341423415234162341723418234192342023421234222342323424234252342623427234282342923430234312343223433234342343523436234372343823439234402344123442234432344423445234462344723448234492345023451234522345323454234552345623457234582345923460234612346223463234642346523466234672346823469234702347123472234732347423475234762347723478234792348023481234822348323484234852348623487234882348923490234912349223493234942349523496234972349823499235002350123502235032350423505235062350723508235092351023511235122351323514235152351623517235182351923520235212352223523235242352523526235272352823529235302353123532235332353423535235362353723538235392354023541235422354323544235452354623547235482354923550235512355223553235542355523556235572355823559235602356123562235632356423565235662356723568235692357023571235722357323574235752357623577235782357923580235812358223583235842358523586235872358823589235902359123592235932359423595235962359723598235992360023601236022360323604236052360623607236082360923610236112361223613236142361523616236172361823619236202362123622236232362423625236262362723628236292363023631236322363323634236352363623637236382363923640236412364223643236442364523646236472364823649236502365123652236532365423655236562365723658236592366023661236622366323664236652366623667236682366923670236712367223673236742367523676236772367823679236802368123682236832368423685236862368723688236892369023691236922369323694236952369623697236982369923700237012370223703237042370523706237072370823709237102371123712237132371423715237162371723718237192372023721237222372323724237252372623727237282372923730237312373223733237342373523736237372373823739237402374123742237432374423745237462374723748237492375023751237522375323754237552375623757237582375923760237612376223763237642376523766237672376823769237702377123772237732377423775237762377723778237792378023781237822378323784237852378623787237882378923790237912379223793237942379523796237972379823799238002380123802238032380423805238062380723808238092381023811238122381323814238152381623817238182381923820238212382223823238242382523826238272382823829238302383123832238332383423835238362383723838238392384023841238422384323844238452384623847238482384923850238512385223853238542385523856238572385823859238602386123862238632386423865238662386723868238692387023871238722387323874238752387623877238782387923880238812388223883238842388523886238872388823889238902389123892238932389423895238962389723898238992390023901239022390323904239052390623907239082390923910239112391223913239142391523916239172391823919239202392123922239232392423925239262392723928239292393023931239322393323934239352393623937239382393923940239412394223943239442394523946239472394823949239502395123952239532395423955239562395723958239592396023961239622396323964239652396623967239682396923970239712397223973239742397523976239772397823979239802398123982239832398423985239862398723988239892399023991239922399323994239952399623997239982399924000240012400224003240042400524006240072400824009240102401124012240132401424015240162401724018240192402024021240222402324024240252402624027240282402924030240312403224033240342403524036240372403824039240402404124042240432404424045240462404724048240492405024051240522405324054240552405624057240582405924060240612406224063240642406524066240672406824069240702407124072240732407424075240762407724078240792408024081240822408324084240852408624087240882408924090240912409224093240942409524096240972409824099241002410124102241032410424105241062410724108241092411024111241122411324114241152411624117241182411924120241212412224123241242412524126241272412824129241302413124132241332413424135241362413724138241392414024141241422414324144241452414624147241482414924150241512415224153241542415524156241572415824159241602416124162241632416424165241662416724168241692417024171241722417324174241752417624177241782417924180241812418224183241842418524186241872418824189241902419124192241932419424195241962419724198241992420024201242022420324204242052420624207242082420924210242112421224213242142421524216242172421824219242202422124222242232422424225242262422724228242292423024231242322423324234242352423624237242382423924240242412424224243242442424524246242472424824249242502425124252242532425424255242562425724258242592426024261242622426324264242652426624267242682426924270242712427224273242742427524276242772427824279242802428124282242832428424285242862428724288242892429024291242922429324294242952429624297242982429924300243012430224303243042430524306243072430824309243102431124312243132431424315243162431724318243192432024321243222432324324243252432624327243282432924330243312433224333243342433524336243372433824339243402434124342243432434424345243462434724348243492435024351243522435324354243552435624357243582435924360243612436224363243642436524366243672436824369243702437124372243732437424375243762437724378243792438024381243822438324384243852438624387243882438924390243912439224393243942439524396243972439824399244002440124402244032440424405244062440724408244092441024411244122441324414244152441624417244182441924420244212442224423244242442524426244272442824429244302443124432244332443424435244362443724438244392444024441244422444324444244452444624447244482444924450244512445224453244542445524456244572445824459244602446124462244632446424465244662446724468244692447024471244722447324474244752447624477244782447924480244812448224483244842448524486244872448824489244902449124492244932449424495244962449724498244992450024501245022450324504245052450624507245082450924510245112451224513245142451524516245172451824519245202452124522245232452424525245262452724528245292453024531245322453324534245352453624537245382453924540245412454224543245442454524546245472454824549245502455124552245532455424555245562455724558245592456024561245622456324564245652456624567245682456924570245712457224573245742457524576245772457824579245802458124582245832458424585245862458724588245892459024591245922459324594245952459624597245982459924600246012460224603246042460524606246072460824609246102461124612246132461424615246162461724618246192462024621246222462324624246252462624627246282462924630246312463224633246342463524636246372463824639246402464124642246432464424645246462464724648246492465024651246522465324654246552465624657246582465924660246612466224663246642466524666246672466824669246702467124672246732467424675246762467724678246792468024681246822468324684246852468624687246882468924690246912469224693246942469524696246972469824699247002470124702247032470424705247062470724708247092471024711247122471324714247152471624717247182471924720247212472224723247242472524726247272472824729247302473124732247332473424735247362473724738247392474024741247422474324744247452474624747247482474924750247512475224753247542475524756247572475824759247602476124762247632476424765247662476724768247692477024771247722477324774247752477624777247782477924780247812478224783247842478524786247872478824789247902479124792247932479424795247962479724798247992480024801248022480324804248052480624807248082480924810248112481224813248142481524816248172481824819248202482124822248232482424825248262482724828248292483024831248322483324834248352483624837248382483924840248412484224843248442484524846248472484824849248502485124852248532485424855248562485724858248592486024861248622486324864248652486624867248682486924870248712487224873248742487524876248772487824879248802488124882248832488424885248862488724888248892489024891248922489324894248952489624897248982489924900249012490224903249042490524906249072490824909249102491124912249132491424915249162491724918249192492024921249222492324924249252492624927249282492924930249312493224933249342493524936249372493824939249402494124942249432494424945249462494724948249492495024951249522495324954249552495624957249582495924960249612496224963249642496524966249672496824969249702497124972249732497424975249762497724978249792498024981249822498324984249852498624987249882498924990249912499224993249942499524996249972499824999250002500125002250032500425005250062500725008250092501025011250122501325014250152501625017250182501925020250212502225023250242502525026250272502825029250302503125032250332503425035250362503725038250392504025041250422504325044250452504625047250482504925050250512505225053250542505525056250572505825059250602506125062250632506425065250662506725068250692507025071250722507325074250752507625077250782507925080250812508225083250842508525086250872508825089250902509125092250932509425095250962509725098250992510025101251022510325104251052510625107251082510925110251112511225113251142511525116251172511825119251202512125122251232512425125251262512725128251292513025131251322513325134251352513625137251382513925140251412514225143251442514525146251472514825149251502515125152251532515425155251562515725158251592516025161251622516325164251652516625167251682516925170251712517225173251742517525176251772517825179251802518125182251832518425185251862518725188251892519025191251922519325194251952519625197251982519925200252012520225203252042520525206252072520825209252102521125212252132521425215252162521725218252192522025221252222522325224252252522625227252282522925230252312523225233252342523525236252372523825239252402524125242252432524425245252462524725248252492525025251252522525325254252552525625257252582525925260252612526225263252642526525266252672526825269252702527125272252732527425275252762527725278252792528025281252822528325284252852528625287252882528925290252912529225293252942529525296252972529825299253002530125302253032530425305253062530725308253092531025311253122531325314253152531625317253182531925320253212532225323253242532525326253272532825329253302533125332253332533425335253362533725338253392534025341253422534325344253452534625347253482534925350253512535225353253542535525356253572535825359253602536125362253632536425365253662536725368253692537025371253722537325374253752537625377253782537925380253812538225383253842538525386253872538825389253902539125392253932539425395253962539725398253992540025401254022540325404254052540625407254082540925410254112541225413254142541525416254172541825419254202542125422254232542425425254262542725428254292543025431254322543325434254352543625437254382543925440254412544225443254442544525446254472544825449254502545125452254532545425455254562545725458254592546025461254622546325464254652546625467254682546925470254712547225473254742547525476254772547825479254802548125482254832548425485254862548725488254892549025491254922549325494254952549625497254982549925500255012550225503255042550525506255072550825509255102551125512255132551425515255162551725518255192552025521255222552325524255252552625527255282552925530255312553225533255342553525536255372553825539255402554125542255432554425545255462554725548255492555025551255522555325554255552555625557255582555925560255612556225563255642556525566255672556825569255702557125572255732557425575255762557725578255792558025581255822558325584255852558625587255882558925590255912559225593255942559525596255972559825599256002560125602256032560425605256062560725608256092561025611256122561325614256152561625617256182561925620256212562225623256242562525626256272562825629256302563125632256332563425635256362563725638256392564025641256422564325644256452564625647256482564925650256512565225653256542565525656256572565825659256602566125662256632566425665256662566725668256692567025671256722567325674256752567625677256782567925680256812568225683256842568525686256872568825689256902569125692256932569425695256962569725698256992570025701257022570325704257052570625707257082570925710257112571225713257142571525716257172571825719257202572125722257232572425725257262572725728257292573025731257322573325734257352573625737257382573925740257412574225743257442574525746257472574825749257502575125752257532575425755257562575725758257592576025761257622576325764257652576625767257682576925770257712577225773257742577525776257772577825779257802578125782257832578425785257862578725788257892579025791257922579325794257952579625797257982579925800258012580225803258042580525806258072580825809258102581125812258132581425815258162581725818258192582025821258222582325824258252582625827258282582925830258312583225833258342583525836258372583825839258402584125842258432584425845258462584725848258492585025851258522585325854258552585625857258582585925860258612586225863258642586525866258672586825869258702587125872258732587425875258762587725878258792588025881258822588325884258852588625887258882588925890258912589225893258942589525896258972589825899259002590125902259032590425905259062590725908259092591025911259122591325914259152591625917259182591925920259212592225923259242592525926259272592825929259302593125932259332593425935259362593725938259392594025941259422594325944259452594625947259482594925950259512595225953259542595525956259572595825959259602596125962259632596425965259662596725968259692597025971259722597325974259752597625977259782597925980259812598225983259842598525986259872598825989259902599125992259932599425995259962599725998259992600026001260022600326004260052600626007260082600926010260112601226013260142601526016260172601826019260202602126022260232602426025260262602726028260292603026031260322603326034260352603626037260382603926040260412604226043260442604526046260472604826049260502605126052260532605426055260562605726058260592606026061260622606326064260652606626067260682606926070260712607226073260742607526076260772607826079260802608126082260832608426085260862608726088260892609026091260922609326094260952609626097260982609926100261012610226103261042610526106261072610826109261102611126112261132611426115261162611726118261192612026121261222612326124261252612626127261282612926130261312613226133261342613526136261372613826139261402614126142261432614426145261462614726148261492615026151261522615326154261552615626157261582615926160261612616226163261642616526166261672616826169261702617126172261732617426175261762617726178261792618026181261822618326184261852618626187261882618926190261912619226193261942619526196261972619826199262002620126202262032620426205262062620726208262092621026211262122621326214262152621626217262182621926220262212622226223262242622526226262272622826229262302623126232262332623426235262362623726238262392624026241262422624326244262452624626247262482624926250262512625226253262542625526256262572625826259262602626126262262632626426265262662626726268262692627026271262722627326274262752627626277262782627926280262812628226283262842628526286262872628826289262902629126292262932629426295262962629726298262992630026301263022630326304263052630626307263082630926310263112631226313263142631526316263172631826319263202632126322263232632426325263262632726328263292633026331263322633326334263352633626337263382633926340263412634226343263442634526346263472634826349263502635126352263532635426355263562635726358263592636026361263622636326364263652636626367263682636926370263712637226373263742637526376263772637826379263802638126382263832638426385263862638726388263892639026391263922639326394263952639626397263982639926400264012640226403264042640526406264072640826409264102641126412264132641426415264162641726418264192642026421264222642326424264252642626427264282642926430264312643226433264342643526436264372643826439264402644126442264432644426445264462644726448264492645026451264522645326454264552645626457264582645926460264612646226463264642646526466264672646826469264702647126472264732647426475264762647726478264792648026481264822648326484264852648626487264882648926490264912649226493264942649526496264972649826499265002650126502265032650426505265062650726508265092651026511265122651326514265152651626517265182651926520265212652226523265242652526526265272652826529265302653126532265332653426535265362653726538265392654026541265422654326544265452654626547265482654926550265512655226553265542655526556265572655826559265602656126562265632656426565265662656726568265692657026571265722657326574265752657626577265782657926580265812658226583265842658526586265872658826589265902659126592265932659426595265962659726598265992660026601266022660326604266052660626607266082660926610266112661226613266142661526616266172661826619266202662126622266232662426625266262662726628266292663026631266322663326634266352663626637266382663926640266412664226643266442664526646266472664826649266502665126652266532665426655266562665726658266592666026661266622666326664266652666626667266682666926670266712667226673266742667526676266772667826679266802668126682266832668426685266862668726688266892669026691266922669326694266952669626697266982669926700267012670226703267042670526706267072670826709267102671126712267132671426715267162671726718267192672026721267222672326724267252672626727267282672926730267312673226733267342673526736267372673826739267402674126742267432674426745267462674726748267492675026751267522675326754267552675626757267582675926760267612676226763267642676526766267672676826769267702677126772267732677426775267762677726778267792678026781267822678326784267852678626787267882678926790267912679226793267942679526796267972679826799268002680126802268032680426805268062680726808268092681026811268122681326814268152681626817268182681926820268212682226823268242682526826268272682826829268302683126832268332683426835268362683726838268392684026841268422684326844268452684626847268482684926850268512685226853268542685526856268572685826859268602686126862268632686426865268662686726868268692687026871268722687326874268752687626877268782687926880268812688226883268842688526886268872688826889268902689126892268932689426895268962689726898268992690026901269022690326904269052690626907269082690926910269112691226913269142691526916269172691826919269202692126922269232692426925269262692726928269292693026931269322693326934269352693626937269382693926940269412694226943269442694526946269472694826949269502695126952269532695426955269562695726958269592696026961269622696326964269652696626967269682696926970269712697226973269742697526976269772697826979269802698126982269832698426985269862698726988269892699026991269922699326994269952699626997269982699927000270012700227003270042700527006270072700827009270102701127012270132701427015270162701727018270192702027021270222702327024270252702627027270282702927030270312703227033270342703527036270372703827039270402704127042270432704427045270462704727048270492705027051270522705327054270552705627057270582705927060270612706227063270642706527066270672706827069270702707127072270732707427075270762707727078270792708027081270822708327084270852708627087270882708927090270912709227093270942709527096270972709827099271002710127102271032710427105271062710727108271092711027111271122711327114271152711627117271182711927120271212712227123271242712527126271272712827129271302713127132271332713427135271362713727138271392714027141271422714327144271452714627147271482714927150271512715227153271542715527156271572715827159271602716127162271632716427165271662716727168271692717027171271722717327174271752717627177271782717927180271812718227183271842718527186271872718827189271902719127192271932719427195271962719727198271992720027201272022720327204272052720627207272082720927210272112721227213272142721527216272172721827219272202722127222272232722427225272262722727228272292723027231272322723327234272352723627237272382723927240272412724227243272442724527246272472724827249272502725127252272532725427255272562725727258272592726027261272622726327264272652726627267272682726927270272712727227273272742727527276272772727827279272802728127282272832728427285272862728727288272892729027291272922729327294272952729627297272982729927300273012730227303273042730527306273072730827309273102731127312273132731427315273162731727318273192732027321273222732327324273252732627327273282732927330273312733227333273342733527336273372733827339273402734127342273432734427345273462734727348273492735027351273522735327354273552735627357273582735927360
  1. /**
  2. * Parse JavaScript SDK v5.3.0
  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 _Object$defineProperty = _dereq_("@babel/runtime-corejs3/core-js-stable/object/define-property");
  10. var _interopRequireDefault = _dereq_("@babel/runtime-corejs3/helpers/interopRequireDefault");
  11. _Object$defineProperty(exports, "__esModule", {
  12. value: true
  13. });
  14. exports.track = track;
  15. var _CoreManager = _interopRequireDefault(_dereq_("./CoreManager"));
  16. /**
  17. * Parse.Analytics provides an interface to Parse's logging and analytics
  18. * backend.
  19. *
  20. * @class Parse.Analytics
  21. * @static
  22. * @hideconstructor
  23. */
  24. /**
  25. * Tracks the occurrence of a custom event with additional dimensions.
  26. * Parse will store a data point at the time of invocation with the given
  27. * event name.
  28. *
  29. * Dimensions will allow segmentation of the occurrences of this custom
  30. * event. Keys and values should be {@code String}s, and will throw
  31. * otherwise.
  32. *
  33. * To track a user signup along with additional metadata, consider the
  34. * following:
  35. * <pre>
  36. * var dimensions = {
  37. * gender: 'm',
  38. * source: 'web',
  39. * dayType: 'weekend'
  40. * };
  41. * Parse.Analytics.track('signup', dimensions);
  42. * </pre>
  43. *
  44. * There is a default limit of 8 dimensions per event tracked.
  45. *
  46. * @function track
  47. * @name Parse.Analytics.track
  48. * @param {string} name The name of the custom event to report to Parse as
  49. * having happened.
  50. * @param {object} dimensions The dictionary of information by which to
  51. * segment this event.
  52. * @returns {Promise} A promise that is resolved when the round-trip
  53. * to the server completes.
  54. */
  55. function track(name, dimensions) {
  56. name = name || '';
  57. name = name.replace(/^\s*/, '');
  58. name = name.replace(/\s*$/, '');
  59. if (name.length === 0) {
  60. throw new TypeError('A name for the custom event must be provided');
  61. }
  62. for (const key in dimensions) {
  63. if (typeof key !== 'string' || typeof dimensions[key] !== 'string') {
  64. throw new TypeError('track() dimensions expects keys and values of type "string".');
  65. }
  66. }
  67. return _CoreManager.default.getAnalyticsController().track(name, dimensions);
  68. }
  69. const DefaultController = {
  70. track(name, dimensions) {
  71. const RESTController = _CoreManager.default.getRESTController();
  72. return RESTController.request('POST', 'events/' + name, {
  73. dimensions
  74. });
  75. }
  76. };
  77. _CoreManager.default.setAnalyticsController(DefaultController);
  78. },{"./CoreManager":4,"@babel/runtime-corejs3/core-js-stable/object/define-property":90,"@babel/runtime-corejs3/helpers/interopRequireDefault":103}],2:[function(_dereq_,module,exports){
  79. "use strict";
  80. var _Object$defineProperty = _dereq_("@babel/runtime-corejs3/core-js-stable/object/define-property");
  81. var _interopRequireDefault = _dereq_("@babel/runtime-corejs3/helpers/interopRequireDefault");
  82. _Object$defineProperty(exports, "__esModule", {
  83. value: true
  84. });
  85. exports.default = void 0;
  86. var _ParseUser = _interopRequireDefault(_dereq_("./ParseUser"));
  87. var _uuid = _interopRequireDefault(_dereq_("./uuid"));
  88. let registered = false;
  89. /**
  90. * Provides utility functions for working with Anonymously logged-in users. <br />
  91. * Anonymous users have some unique characteristics:
  92. * <ul>
  93. * <li>Anonymous users don't need a user name or password.</li>
  94. * <ul>
  95. * <li>Once logged out, an anonymous user cannot be recovered.</li>
  96. * </ul>
  97. * <li>signUp converts an anonymous user to a standard user with the given username and password.</li>
  98. * <ul>
  99. * <li>Data associated with the anonymous user is retained.</li>
  100. * </ul>
  101. * <li>logIn switches users without converting the anonymous user.</li>
  102. * <ul>
  103. * <li>Data associated with the anonymous user will be lost.</li>
  104. * </ul>
  105. * <li>Service logIn (e.g. Facebook, Twitter) will attempt to convert
  106. * the anonymous user into a standard user by linking it to the service.</li>
  107. * <ul>
  108. * <li>If a user already exists that is linked to the service, it will instead switch to the existing user.</li>
  109. * </ul>
  110. * <li>Service linking (e.g. Facebook, Twitter) will convert the anonymous user
  111. * into a standard user by linking it to the service.</li>
  112. * </ul>
  113. *
  114. * @class Parse.AnonymousUtils
  115. * @static
  116. */
  117. const AnonymousUtils = {
  118. /**
  119. * Gets whether the user has their account linked to anonymous user.
  120. *
  121. * @function isLinked
  122. * @name Parse.AnonymousUtils.isLinked
  123. * @param {Parse.User} user User to check for.
  124. * The user must be logged in on this device.
  125. * @returns {boolean} <code>true</code> if the user has their account
  126. * linked to an anonymous user.
  127. * @static
  128. */
  129. isLinked(user) {
  130. const provider = this._getAuthProvider();
  131. return user._isLinked(provider.getAuthType());
  132. },
  133. /**
  134. * Logs in a user Anonymously.
  135. *
  136. * @function logIn
  137. * @name Parse.AnonymousUtils.logIn
  138. * @param {object} options MasterKey / SessionToken.
  139. * @returns {Promise} Logged in user
  140. * @static
  141. */
  142. logIn(options) {
  143. const provider = this._getAuthProvider();
  144. return _ParseUser.default.logInWith(provider.getAuthType(), provider.getAuthData(), options);
  145. },
  146. /**
  147. * Links Anonymous User to an existing PFUser.
  148. *
  149. * @function link
  150. * @name Parse.AnonymousUtils.link
  151. * @param {Parse.User} user User to link. This must be the current user.
  152. * @param {object} options MasterKey / SessionToken.
  153. * @returns {Promise} Linked with User
  154. * @static
  155. */
  156. link(user, options) {
  157. const provider = this._getAuthProvider();
  158. return user.linkWith(provider.getAuthType(), provider.getAuthData(), options);
  159. },
  160. /**
  161. * Returns true if Authentication Provider has been registered for use.
  162. *
  163. * @function isRegistered
  164. * @name Parse.AnonymousUtils.isRegistered
  165. * @returns {boolean}
  166. * @static
  167. */
  168. isRegistered() {
  169. return registered;
  170. },
  171. _getAuthProvider() {
  172. const provider = {
  173. restoreAuthentication() {
  174. return true;
  175. },
  176. getAuthType() {
  177. return 'anonymous';
  178. },
  179. getAuthData() {
  180. return {
  181. authData: {
  182. id: (0, _uuid.default)()
  183. }
  184. };
  185. }
  186. };
  187. if (!registered) {
  188. _ParseUser.default._registerAuthenticationProvider(provider);
  189. registered = true;
  190. }
  191. return provider;
  192. }
  193. };
  194. var _default = exports.default = AnonymousUtils;
  195. },{"./ParseUser":38,"./uuid":64,"@babel/runtime-corejs3/core-js-stable/object/define-property":90,"@babel/runtime-corejs3/helpers/interopRequireDefault":103}],3:[function(_dereq_,module,exports){
  196. "use strict";
  197. var _Object$defineProperty = _dereq_("@babel/runtime-corejs3/core-js-stable/object/define-property");
  198. var _interopRequireDefault = _dereq_("@babel/runtime-corejs3/helpers/interopRequireDefault");
  199. _Object$defineProperty(exports, "__esModule", {
  200. value: true
  201. });
  202. exports.getJobStatus = getJobStatus;
  203. exports.getJobsData = getJobsData;
  204. exports.run = run;
  205. exports.startJob = startJob;
  206. var _keys = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/object/keys"));
  207. var _promise = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/promise"));
  208. var _CoreManager = _interopRequireDefault(_dereq_("./CoreManager"));
  209. var _decode = _interopRequireDefault(_dereq_("./decode"));
  210. var _encode = _interopRequireDefault(_dereq_("./encode"));
  211. var _ParseError = _interopRequireDefault(_dereq_("./ParseError"));
  212. var _ParseQuery = _interopRequireDefault(_dereq_("./ParseQuery"));
  213. /**
  214. * Contains functions for calling and declaring
  215. * <a href="/docs/cloud_code_guide#functions">cloud functions</a>.
  216. * <p><strong><em>
  217. * Some functions are only available from Cloud Code.
  218. * </em></strong></p>
  219. *
  220. * @class Parse.Cloud
  221. * @static
  222. * @hideconstructor
  223. */
  224. /**
  225. * Makes a call to a cloud function.
  226. *
  227. * @function run
  228. * @name Parse.Cloud.run
  229. * @param {string} name The function name.
  230. * @param {object} data The parameters to send to the cloud function.
  231. * @param {object} options
  232. * @returns {Promise} A promise that will be resolved with the result
  233. * of the function.
  234. */
  235. function run(name, data, options) {
  236. options = options || {};
  237. if (typeof name !== 'string' || name.length === 0) {
  238. throw new TypeError('Cloud function name must be a string.');
  239. }
  240. const requestOptions = {};
  241. if (options.useMasterKey) {
  242. requestOptions.useMasterKey = options.useMasterKey;
  243. }
  244. if (options.sessionToken) {
  245. requestOptions.sessionToken = options.sessionToken;
  246. }
  247. if (options.installationId) {
  248. requestOptions.installationId = options.installationId;
  249. }
  250. if (options.context && typeof options.context === 'object') {
  251. requestOptions.context = options.context;
  252. }
  253. return _CoreManager.default.getCloudController().run(name, data, requestOptions);
  254. }
  255. /**
  256. * Gets data for the current set of cloud jobs.
  257. *
  258. * @function getJobsData
  259. * @name Parse.Cloud.getJobsData
  260. * @returns {Promise} A promise that will be resolved with the result
  261. * of the function.
  262. */
  263. function getJobsData() {
  264. return _CoreManager.default.getCloudController().getJobsData({
  265. useMasterKey: true
  266. });
  267. }
  268. /**
  269. * Starts a given cloud job, which will process asynchronously.
  270. *
  271. * @function startJob
  272. * @name Parse.Cloud.startJob
  273. * @param {string} name The function name.
  274. * @param {object} data The parameters to send to the cloud function.
  275. * @returns {Promise} A promise that will be resolved with the jobStatusId
  276. * of the job.
  277. */
  278. function startJob(name, data) {
  279. if (typeof name !== 'string' || name.length === 0) {
  280. throw new TypeError('Cloud job name must be a string.');
  281. }
  282. return _CoreManager.default.getCloudController().startJob(name, data, {
  283. useMasterKey: true
  284. });
  285. }
  286. /**
  287. * Gets job status by Id
  288. *
  289. * @function getJobStatus
  290. * @name Parse.Cloud.getJobStatus
  291. * @param {string} jobStatusId The Id of Job Status.
  292. * @returns {Parse.Object} Status of Job.
  293. */
  294. function getJobStatus(jobStatusId) {
  295. const query = new _ParseQuery.default('_JobStatus');
  296. return query.get(jobStatusId, {
  297. useMasterKey: true
  298. });
  299. }
  300. const DefaultController = {
  301. run(name, data, options) {
  302. const RESTController = _CoreManager.default.getRESTController();
  303. const payload = (0, _encode.default)(data, true);
  304. const request = RESTController.request('POST', 'functions/' + name, payload, options);
  305. return request.then(res => {
  306. if (typeof res === 'object' && (0, _keys.default)(res).length > 0 && !res.hasOwnProperty('result')) {
  307. throw new _ParseError.default(_ParseError.default.INVALID_JSON, 'The server returned an invalid response.');
  308. }
  309. const decoded = (0, _decode.default)(res);
  310. if (decoded && decoded.hasOwnProperty('result')) {
  311. return _promise.default.resolve(decoded.result);
  312. }
  313. return _promise.default.resolve(undefined);
  314. });
  315. },
  316. getJobsData(options) {
  317. const RESTController = _CoreManager.default.getRESTController();
  318. return RESTController.request('GET', 'cloud_code/jobs/data', null, options);
  319. },
  320. async startJob(name, data, options) {
  321. const RESTController = _CoreManager.default.getRESTController();
  322. const payload = (0, _encode.default)(data, true);
  323. options.returnStatus = true;
  324. const response = await RESTController.request('POST', 'jobs/' + name, payload, options);
  325. return response._headers?.['X-Parse-Job-Status-Id'];
  326. }
  327. };
  328. _CoreManager.default.setCloudController(DefaultController);
  329. },{"./CoreManager":4,"./ParseError":24,"./ParseQuery":33,"./decode":55,"./encode":56,"@babel/runtime-corejs3/core-js-stable/object/define-property":90,"@babel/runtime-corejs3/core-js-stable/object/keys":95,"@babel/runtime-corejs3/core-js-stable/promise":97,"@babel/runtime-corejs3/helpers/interopRequireDefault":103}],4:[function(_dereq_,module,exports){
  330. (function (process){(function (){
  331. "use strict";
  332. var _Object$defineProperty = _dereq_("@babel/runtime-corejs3/core-js-stable/object/define-property");
  333. var _interopRequireDefault = _dereq_("@babel/runtime-corejs3/helpers/interopRequireDefault");
  334. _Object$defineProperty(exports, "__esModule", {
  335. value: true
  336. });
  337. exports.default = void 0;
  338. var _forEach = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/instance/for-each"));
  339. /** Based on https://github.com/react-native-async-storage/async-storage/blob/main/packages/default-storage-backend/src/types.ts */
  340. const config = {
  341. IS_NODE: typeof process !== 'undefined' && !!process.versions && !!process.versions.node && !process.versions.electron,
  342. REQUEST_ATTEMPT_LIMIT: 5,
  343. REQUEST_BATCH_SIZE: 20,
  344. REQUEST_HEADERS: {},
  345. SERVER_URL: 'https://api.parse.com/1',
  346. SERVER_AUTH_TYPE: null,
  347. SERVER_AUTH_TOKEN: null,
  348. LIVEQUERY_SERVER_URL: null,
  349. ENCRYPTED_KEY: null,
  350. VERSION: 'js' + "5.3.0",
  351. APPLICATION_ID: null,
  352. JAVASCRIPT_KEY: null,
  353. MASTER_KEY: null,
  354. USE_MASTER_KEY: false,
  355. PERFORM_USER_REWRITE: true,
  356. FORCE_REVOCABLE_SESSION: false,
  357. ENCRYPTED_USER: false,
  358. IDEMPOTENCY: false,
  359. ALLOW_CUSTOM_OBJECT_ID: false,
  360. PARSE_ERRORS: []
  361. };
  362. function requireMethods(name, methods, controller) {
  363. (0, _forEach.default)(methods).call(methods, func => {
  364. if (typeof controller[func] !== 'function') {
  365. throw new Error(`${name} must implement ${func}()`);
  366. }
  367. });
  368. }
  369. const CoreManager = {
  370. get: function (key) {
  371. if (config.hasOwnProperty(key)) {
  372. return config[key];
  373. }
  374. throw new Error('Configuration key not found: ' + key);
  375. },
  376. set: function (key, value) {
  377. config[key] = value;
  378. },
  379. setIfNeeded: function (key, value) {
  380. if (!config.hasOwnProperty(key)) {
  381. config[key] = value;
  382. }
  383. return config[key];
  384. },
  385. /* Specialized Controller Setters/Getters */
  386. setAnalyticsController(controller) {
  387. requireMethods('AnalyticsController', ['track'], controller);
  388. config['AnalyticsController'] = controller;
  389. },
  390. getAnalyticsController() {
  391. return config['AnalyticsController'];
  392. },
  393. setCloudController(controller) {
  394. requireMethods('CloudController', ['run', 'getJobsData', 'startJob'], controller);
  395. config['CloudController'] = controller;
  396. },
  397. getCloudController() {
  398. return config['CloudController'];
  399. },
  400. setConfigController(controller) {
  401. requireMethods('ConfigController', ['current', 'get', 'save'], controller);
  402. config['ConfigController'] = controller;
  403. },
  404. getConfigController() {
  405. return config['ConfigController'];
  406. },
  407. setCryptoController(controller) {
  408. requireMethods('CryptoController', ['encrypt', 'decrypt'], controller);
  409. config['CryptoController'] = controller;
  410. },
  411. getCryptoController() {
  412. return config['CryptoController'];
  413. },
  414. setEventEmitter(eventEmitter) {
  415. config['EventEmitter'] = eventEmitter;
  416. },
  417. getEventEmitter() {
  418. return config['EventEmitter'];
  419. },
  420. setFileController(controller) {
  421. requireMethods('FileController', ['saveFile', 'saveBase64'], controller);
  422. config['FileController'] = controller;
  423. },
  424. setEventuallyQueue(controller) {
  425. requireMethods('EventuallyQueue', ['poll', 'save', 'destroy'], controller);
  426. config['EventuallyQueue'] = controller;
  427. },
  428. getEventuallyQueue() {
  429. return config['EventuallyQueue'];
  430. },
  431. getFileController() {
  432. return config['FileController'];
  433. },
  434. setInstallationController(controller) {
  435. requireMethods('InstallationController', ['currentInstallationId', 'currentInstallation', 'updateInstallationOnDisk'], controller);
  436. config['InstallationController'] = controller;
  437. },
  438. getInstallationController() {
  439. return config['InstallationController'];
  440. },
  441. setLiveQuery(liveQuery) {
  442. config['LiveQuery'] = liveQuery;
  443. },
  444. getLiveQuery() {
  445. return config['LiveQuery'];
  446. },
  447. setObjectController(controller) {
  448. requireMethods('ObjectController', ['save', 'fetch', 'destroy'], controller);
  449. config['ObjectController'] = controller;
  450. },
  451. getObjectController() {
  452. return config['ObjectController'];
  453. },
  454. setObjectStateController(controller) {
  455. requireMethods('ObjectStateController', ['getState', 'initializeState', 'removeState', 'getServerData', 'setServerData', 'getPendingOps', 'setPendingOp', 'pushPendingState', 'popPendingState', 'mergeFirstPendingState', 'getObjectCache', 'estimateAttribute', 'estimateAttributes', 'commitServerChanges', 'enqueueTask', 'clearAllState'], controller);
  456. config['ObjectStateController'] = controller;
  457. },
  458. getObjectStateController() {
  459. return config['ObjectStateController'];
  460. },
  461. setPushController(controller) {
  462. requireMethods('PushController', ['send'], controller);
  463. config['PushController'] = controller;
  464. },
  465. getPushController() {
  466. return config['PushController'];
  467. },
  468. setQueryController(controller) {
  469. requireMethods('QueryController', ['find', 'aggregate'], controller);
  470. config['QueryController'] = controller;
  471. },
  472. getQueryController() {
  473. return config['QueryController'];
  474. },
  475. setRESTController(controller) {
  476. requireMethods('RESTController', ['request', 'ajax'], controller);
  477. config['RESTController'] = controller;
  478. },
  479. getRESTController() {
  480. return config['RESTController'];
  481. },
  482. setSchemaController(controller) {
  483. requireMethods('SchemaController', ['get', 'create', 'update', 'delete', 'send', 'purge'], controller);
  484. config['SchemaController'] = controller;
  485. },
  486. getSchemaController() {
  487. return config['SchemaController'];
  488. },
  489. setSessionController(controller) {
  490. requireMethods('SessionController', ['getSession'], controller);
  491. config['SessionController'] = controller;
  492. },
  493. getSessionController() {
  494. return config['SessionController'];
  495. },
  496. setStorageController(controller) {
  497. if (controller.async) {
  498. requireMethods('An async StorageController', ['getItemAsync', 'setItemAsync', 'removeItemAsync', 'getAllKeysAsync'], controller);
  499. } else {
  500. requireMethods('A synchronous StorageController', ['getItem', 'setItem', 'removeItem', 'getAllKeys'], controller);
  501. }
  502. config['StorageController'] = controller;
  503. },
  504. setLocalDatastoreController(controller) {
  505. requireMethods('LocalDatastoreController', ['pinWithName', 'fromPinWithName', 'unPinWithName', 'getAllContents', 'clear'], controller);
  506. config['LocalDatastoreController'] = controller;
  507. },
  508. getLocalDatastoreController() {
  509. return config['LocalDatastoreController'];
  510. },
  511. setLocalDatastore(store) {
  512. config['LocalDatastore'] = store;
  513. },
  514. getLocalDatastore() {
  515. return config['LocalDatastore'];
  516. },
  517. getStorageController() {
  518. return config['StorageController'];
  519. },
  520. setAsyncStorage(storage) {
  521. config['AsyncStorage'] = storage;
  522. },
  523. getAsyncStorage() {
  524. return config['AsyncStorage'];
  525. },
  526. setWebSocketController(controller) {
  527. config['WebSocketController'] = controller;
  528. },
  529. getWebSocketController() {
  530. return config['WebSocketController'];
  531. },
  532. setUserController(controller) {
  533. requireMethods('UserController', ['setCurrentUser', 'currentUser', 'currentUserAsync', 'signUp', 'logIn', 'become', 'logOut', 'me', 'requestPasswordReset', 'upgradeToRevocableSession', 'requestEmailVerification', 'verifyPassword', 'linkWith'], controller);
  534. config['UserController'] = controller;
  535. },
  536. getUserController() {
  537. return config['UserController'];
  538. },
  539. setLiveQueryController(controller) {
  540. requireMethods('LiveQueryController', ['setDefaultLiveQueryClient', 'getDefaultLiveQueryClient', '_clearCachedDefaultClient'], controller);
  541. config['LiveQueryController'] = controller;
  542. },
  543. getLiveQueryController() {
  544. return config['LiveQueryController'];
  545. },
  546. setHooksController(controller) {
  547. requireMethods('HooksController', ['create', 'get', 'update', 'remove'], controller);
  548. config['HooksController'] = controller;
  549. },
  550. getHooksController() {
  551. return config['HooksController'];
  552. },
  553. setParseOp(op) {
  554. config['ParseOp'] = op;
  555. },
  556. getParseOp() {
  557. return config['ParseOp'];
  558. },
  559. setParseObject(object) {
  560. config['ParseObject'] = object;
  561. },
  562. getParseObject() {
  563. return config['ParseObject'];
  564. },
  565. setParseQuery(query) {
  566. config['ParseQuery'] = query;
  567. },
  568. getParseQuery() {
  569. return config['ParseQuery'];
  570. },
  571. setParseRole(role) {
  572. config['ParseRole'] = role;
  573. },
  574. getParseRole() {
  575. return config['ParseRole'];
  576. },
  577. setParseUser(user) {
  578. config['ParseUser'] = user;
  579. },
  580. getParseUser() {
  581. return config['ParseUser'];
  582. }
  583. };
  584. module.exports = CoreManager;
  585. var _default = exports.default = CoreManager;
  586. }).call(this)}).call(this,_dereq_('_process'))
  587. },{"@babel/runtime-corejs3/core-js-stable/instance/for-each":74,"@babel/runtime-corejs3/core-js-stable/object/define-property":90,"@babel/runtime-corejs3/helpers/interopRequireDefault":103,"_process":107}],5:[function(_dereq_,module,exports){
  588. "use strict";
  589. var _Object$defineProperty = _dereq_("@babel/runtime-corejs3/core-js-stable/object/define-property");
  590. var _interopRequireDefault = _dereq_("@babel/runtime-corejs3/helpers/interopRequireDefault");
  591. _Object$defineProperty(exports, "__esModule", {
  592. value: true
  593. });
  594. exports.default = void 0;
  595. var _stringify = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/json/stringify"));
  596. let AES;
  597. let ENC;
  598. AES = _dereq_('crypto-js/aes');
  599. ENC = _dereq_('crypto-js/enc-utf8');
  600. const CryptoController = {
  601. encrypt(obj, secretKey) {
  602. const encrypted = AES.encrypt((0, _stringify.default)(obj), secretKey);
  603. return encrypted.toString();
  604. },
  605. decrypt(encryptedText, secretKey) {
  606. const decryptedStr = AES.decrypt(encryptedText, secretKey).toString(ENC);
  607. return decryptedStr;
  608. }
  609. };
  610. module.exports = CryptoController;
  611. var _default = exports.default = CryptoController;
  612. },{"@babel/runtime-corejs3/core-js-stable/json/stringify":85,"@babel/runtime-corejs3/core-js-stable/object/define-property":90,"@babel/runtime-corejs3/helpers/interopRequireDefault":103,"crypto-js/aes":476,"crypto-js/enc-utf8":480}],6:[function(_dereq_,module,exports){
  613. "use strict";
  614. var _Object$defineProperty = _dereq_("@babel/runtime-corejs3/core-js-stable/object/define-property");
  615. _Object$defineProperty(exports, "__esModule", {
  616. value: true
  617. });
  618. exports.default = void 0;
  619. /**
  620. * This is a simple wrapper to unify EventEmitter implementations across platforms.
  621. */
  622. let EventEmitter;
  623. try {
  624. EventEmitter = _dereq_('events').EventEmitter;
  625. } catch (_) {
  626. // EventEmitter unavailable
  627. }
  628. module.exports = EventEmitter;
  629. var _default = exports.default = EventEmitter;
  630. },{"@babel/runtime-corejs3/core-js-stable/object/define-property":90,"events":485}],7:[function(_dereq_,module,exports){
  631. "use strict";
  632. var _Object$defineProperty = _dereq_("@babel/runtime-corejs3/core-js-stable/object/define-property");
  633. var _interopRequireDefault = _dereq_("@babel/runtime-corejs3/helpers/interopRequireDefault");
  634. _Object$defineProperty(exports, "__esModule", {
  635. value: true
  636. });
  637. exports.default = void 0;
  638. var _stringify = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/json/stringify"));
  639. var _splice = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/instance/splice"));
  640. var _findIndex = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/instance/find-index"));
  641. var _setInterval2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/set-interval"));
  642. var _find = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/instance/find"));
  643. var _CoreManager = _interopRequireDefault(_dereq_("./CoreManager"));
  644. var _ParseError = _interopRequireDefault(_dereq_("./ParseError"));
  645. var _ParseObject = _interopRequireDefault(_dereq_("./ParseObject"));
  646. var _ParseQuery = _interopRequireDefault(_dereq_("./ParseQuery"));
  647. var _Storage = _interopRequireDefault(_dereq_("./Storage"));
  648. const QUEUE_KEY = 'Parse/Eventually/Queue';
  649. let queueCache = [];
  650. let dirtyCache = true;
  651. let polling = undefined;
  652. /**
  653. * Provides utility functions to queue objects that will be
  654. * saved to the server at a later date.
  655. *
  656. * @class Parse.EventuallyQueue
  657. * @static
  658. */
  659. const EventuallyQueue = {
  660. /**
  661. * Add object to queue with save operation.
  662. *
  663. * @function save
  664. * @name Parse.EventuallyQueue.save
  665. * @param {ParseObject} object Parse.Object to be saved eventually
  666. * @param {object} [serverOptions] See {@link https://parseplatform.org/Parse-SDK-JS/api/master/Parse.Object.html#save Parse.Object.save} options.
  667. * @returns {Promise} A promise that is fulfilled if object is added to queue.
  668. * @static
  669. * @see Parse.Object#saveEventually
  670. */
  671. save(object) {
  672. let serverOptions = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
  673. return this.enqueue('save', object, serverOptions);
  674. },
  675. /**
  676. * Add object to queue with save operation.
  677. *
  678. * @function destroy
  679. * @name Parse.EventuallyQueue.destroy
  680. * @param {ParseObject} object Parse.Object to be destroyed eventually
  681. * @param {object} [serverOptions] See {@link https://parseplatform.org/Parse-SDK-JS/api/master/Parse.Object.html#destroy Parse.Object.destroy} options
  682. * @returns {Promise} A promise that is fulfilled if object is added to queue.
  683. * @static
  684. * @see Parse.Object#destroyEventually
  685. */
  686. destroy(object) {
  687. let serverOptions = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
  688. return this.enqueue('destroy', object, serverOptions);
  689. },
  690. /**
  691. * Generate unique identifier to avoid duplicates and maintain previous state.
  692. *
  693. * @param {string} action save / destroy
  694. * @param {object} object Parse.Object to be queued
  695. * @returns {string}
  696. * @static
  697. * @ignore
  698. */
  699. generateQueueId(action, object) {
  700. object._getId();
  701. const {
  702. className,
  703. id,
  704. _localId
  705. } = object;
  706. const uniqueId = object.get('hash') || _localId;
  707. return [action, className, id, uniqueId].join('_');
  708. },
  709. /**
  710. * Build queue object and add to queue.
  711. *
  712. * @param {string} action save / destroy
  713. * @param {object} object Parse.Object to be queued
  714. * @param {object} [serverOptions]
  715. * @returns {Promise} A promise that is fulfilled if object is added to queue.
  716. * @static
  717. * @ignore
  718. */
  719. async enqueue(action, object, serverOptions) {
  720. const queueData = await this.getQueue();
  721. const queueId = this.generateQueueId(action, object);
  722. let index = this.queueItemExists(queueData, queueId);
  723. if (index > -1) {
  724. // Add cached values to new object if they don't exist
  725. for (const prop in queueData[index].object) {
  726. if (typeof object.get(prop) === 'undefined') {
  727. object.set(prop, queueData[index].object[prop]);
  728. }
  729. }
  730. } else {
  731. index = queueData.length;
  732. }
  733. queueData[index] = {
  734. queueId,
  735. action,
  736. object: object.toJSON(),
  737. serverOptions,
  738. id: object.id,
  739. className: object.className,
  740. hash: object.get('hash'),
  741. createdAt: new Date()
  742. };
  743. return this.setQueue(queueData);
  744. },
  745. store(data) {
  746. return _Storage.default.setItemAsync(QUEUE_KEY, (0, _stringify.default)(data));
  747. },
  748. load() {
  749. return _Storage.default.getItemAsync(QUEUE_KEY);
  750. },
  751. /**
  752. * Sets the in-memory queue from local storage and returns.
  753. *
  754. * @function getQueue
  755. * @name Parse.EventuallyQueue.getQueue
  756. * @returns {Promise<QueueObject[]>}
  757. * @static
  758. */
  759. async getQueue() {
  760. if (dirtyCache) {
  761. queueCache = JSON.parse((await this.load()) || '[]');
  762. dirtyCache = false;
  763. }
  764. return queueCache;
  765. },
  766. /**
  767. * Saves the queue to local storage
  768. *
  769. * @param {Queue} queue Queue containing Parse.Object data.
  770. * @returns {Promise} A promise that is fulfilled when queue is stored.
  771. * @static
  772. * @ignore
  773. */
  774. setQueue(queue) {
  775. queueCache = queue;
  776. return this.store(queueCache);
  777. },
  778. /**
  779. * Removes Parse.Object data from queue.
  780. *
  781. * @param {string} queueId Unique identifier for Parse.Object data.
  782. * @returns {Promise} A promise that is fulfilled when queue is stored.
  783. * @static
  784. * @ignore
  785. */
  786. async remove(queueId) {
  787. const queueData = await this.getQueue();
  788. const index = this.queueItemExists(queueData, queueId);
  789. if (index > -1) {
  790. (0, _splice.default)(queueData).call(queueData, index, 1);
  791. await this.setQueue(queueData);
  792. }
  793. },
  794. /**
  795. * Removes all objects from queue.
  796. *
  797. * @function clear
  798. * @name Parse.EventuallyQueue.clear
  799. * @returns {Promise} A promise that is fulfilled when queue is cleared.
  800. * @static
  801. */
  802. clear() {
  803. queueCache = [];
  804. return this.store([]);
  805. },
  806. /**
  807. * Return the index of a queueId in the queue. Returns -1 if not found.
  808. *
  809. * @param {Queue} queue Queue containing Parse.Object data.
  810. * @param {string} queueId Unique identifier for Parse.Object data.
  811. * @returns {number}
  812. * @static
  813. * @ignore
  814. */
  815. queueItemExists(queue, queueId) {
  816. return (0, _findIndex.default)(queue).call(queue, data => data.queueId === queueId);
  817. },
  818. /**
  819. * Return the number of objects in the queue.
  820. *
  821. * @function length
  822. * @name Parse.EventuallyQueue.length
  823. * @returns {Promise<number>}
  824. * @static
  825. */
  826. async length() {
  827. const queueData = await this.getQueue();
  828. return queueData.length;
  829. },
  830. /**
  831. * Sends the queue to the server.
  832. *
  833. * @function sendQueue
  834. * @name Parse.EventuallyQueue.sendQueue
  835. * @returns {Promise<boolean>} Returns true if queue was sent successfully.
  836. * @static
  837. */
  838. async sendQueue() {
  839. const queue = await this.getQueue();
  840. const queueData = [...queue];
  841. if (queueData.length === 0) {
  842. return false;
  843. }
  844. for (let i = 0; i < queueData.length; i += 1) {
  845. const queueObject = queueData[i];
  846. const {
  847. id,
  848. hash,
  849. className
  850. } = queueObject;
  851. const ObjectType = _ParseObject.default.extend(className);
  852. if (id) {
  853. await this.process.byId(ObjectType, queueObject);
  854. } else if (hash) {
  855. await this.process.byHash(ObjectType, queueObject);
  856. } else {
  857. await this.process.create(ObjectType, queueObject);
  858. }
  859. }
  860. return true;
  861. },
  862. /**
  863. * Build queue object and add to queue.
  864. *
  865. * @param {ParseObject} object Parse.Object to be processed
  866. * @param {QueueObject} queueObject Parse.Object data from the queue
  867. * @returns {Promise} A promise that is fulfilled when operation is performed.
  868. * @static
  869. * @ignore
  870. */
  871. async sendQueueCallback(object, queueObject) {
  872. if (!object) {
  873. return this.remove(queueObject.queueId);
  874. }
  875. switch (queueObject.action) {
  876. case 'save':
  877. // Queued update was overwritten by other request. Do not save
  878. if (typeof object.updatedAt !== 'undefined' && object.updatedAt > new Date(queueObject.object.createdAt)) {
  879. return this.remove(queueObject.queueId);
  880. }
  881. try {
  882. await object.save(queueObject.object, queueObject.serverOptions);
  883. await this.remove(queueObject.queueId);
  884. } catch (e) {
  885. if (e.code !== _ParseError.default.CONNECTION_FAILED) {
  886. await this.remove(queueObject.queueId);
  887. }
  888. }
  889. break;
  890. case 'destroy':
  891. try {
  892. await object.destroy(queueObject.serverOptions);
  893. await this.remove(queueObject.queueId);
  894. } catch (e) {
  895. if (e.code !== _ParseError.default.CONNECTION_FAILED) {
  896. await this.remove(queueObject.queueId);
  897. }
  898. }
  899. break;
  900. }
  901. },
  902. /**
  903. * Start polling server for network connection.
  904. * Will send queue if connection is established.
  905. *
  906. * @function poll
  907. * @name Parse.EventuallyQueue.poll
  908. * @param [ms] Milliseconds to ping the server. Default 2000ms
  909. * @static
  910. */
  911. poll() {
  912. let ms = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 2000;
  913. if (polling) {
  914. return;
  915. }
  916. polling = (0, _setInterval2.default)(() => {
  917. const RESTController = _CoreManager.default.getRESTController();
  918. RESTController.request('GET', 'health').then(_ref => {
  919. let {
  920. status
  921. } = _ref;
  922. if (status === 'ok') {
  923. this.stopPoll();
  924. return this.sendQueue();
  925. }
  926. }).catch(e => e);
  927. }, ms);
  928. },
  929. /**
  930. * Turns off polling.
  931. *
  932. * @function stopPoll
  933. * @name Parse.EventuallyQueue.stopPoll
  934. * @static
  935. */
  936. stopPoll() {
  937. clearInterval(polling);
  938. polling = undefined;
  939. },
  940. /**
  941. * Return true if pinging the server.
  942. *
  943. * @function isPolling
  944. * @name Parse.EventuallyQueue.isPolling
  945. * @returns {boolean}
  946. * @static
  947. */
  948. isPolling() {
  949. return !!polling;
  950. },
  951. _setPolling(flag) {
  952. polling = flag;
  953. },
  954. process: {
  955. create(ObjectType, queueObject) {
  956. const object = new ObjectType();
  957. return EventuallyQueue.sendQueueCallback(object, queueObject);
  958. },
  959. async byId(ObjectType, queueObject) {
  960. const {
  961. sessionToken
  962. } = queueObject.serverOptions;
  963. const query = new _ParseQuery.default(ObjectType);
  964. query.equalTo('objectId', queueObject.id);
  965. const results = await (0, _find.default)(query).call(query, {
  966. sessionToken
  967. });
  968. return EventuallyQueue.sendQueueCallback(results[0], queueObject);
  969. },
  970. async byHash(ObjectType, queueObject) {
  971. const {
  972. sessionToken
  973. } = queueObject.serverOptions;
  974. const query = new _ParseQuery.default(ObjectType);
  975. query.equalTo('hash', queueObject.hash);
  976. const results = await (0, _find.default)(query).call(query, {
  977. sessionToken
  978. });
  979. if (results.length > 0) {
  980. return EventuallyQueue.sendQueueCallback(results[0], queueObject);
  981. }
  982. return EventuallyQueue.process.create(ObjectType, queueObject);
  983. }
  984. }
  985. };
  986. module.exports = EventuallyQueue;
  987. var _default = exports.default = EventuallyQueue;
  988. },{"./CoreManager":4,"./ParseError":24,"./ParseObject":30,"./ParseQuery":33,"./Storage":43,"@babel/runtime-corejs3/core-js-stable/instance/find":73,"@babel/runtime-corejs3/core-js-stable/instance/find-index":72,"@babel/runtime-corejs3/core-js-stable/instance/splice":82,"@babel/runtime-corejs3/core-js-stable/json/stringify":85,"@babel/runtime-corejs3/core-js-stable/object/define-property":90,"@babel/runtime-corejs3/core-js-stable/set-interval":98,"@babel/runtime-corejs3/helpers/interopRequireDefault":103}],8:[function(_dereq_,module,exports){
  989. "use strict";
  990. var _Object$defineProperty = _dereq_("@babel/runtime-corejs3/core-js-stable/object/define-property");
  991. var _interopRequireDefault = _dereq_("@babel/runtime-corejs3/helpers/interopRequireDefault");
  992. _Object$defineProperty(exports, "__esModule", {
  993. value: true
  994. });
  995. exports.default = void 0;
  996. var _ParseUser = _interopRequireDefault(_dereq_("./ParseUser"));
  997. /* global FB */
  998. let initialized = false;
  999. let requestedPermissions;
  1000. let initOptions;
  1001. const provider = {
  1002. authenticate(options) {
  1003. if (typeof FB === 'undefined') {
  1004. options.error(this, 'Facebook SDK not found.');
  1005. }
  1006. FB.login(response => {
  1007. if (response.authResponse) {
  1008. if (options.success) {
  1009. options.success(this, {
  1010. id: response.authResponse.userID,
  1011. access_token: response.authResponse.accessToken,
  1012. expiration_date: new Date(response.authResponse.expiresIn * 1000 + new Date().getTime()).toJSON()
  1013. });
  1014. }
  1015. } else {
  1016. if (options.error) {
  1017. options.error(this, response);
  1018. }
  1019. }
  1020. }, {
  1021. scope: requestedPermissions
  1022. });
  1023. },
  1024. restoreAuthentication(authData) {
  1025. if (authData) {
  1026. const newOptions = {};
  1027. if (initOptions) {
  1028. for (const key in initOptions) {
  1029. newOptions[key] = initOptions[key];
  1030. }
  1031. }
  1032. // Suppress checks for login status from the browser.
  1033. newOptions.status = false;
  1034. // If the user doesn't match the one known by the FB SDK, log out.
  1035. // Most of the time, the users will match -- it's only in cases where
  1036. // the FB SDK knows of a different user than the one being restored
  1037. // from a Parse User that logged in with username/password.
  1038. const existingResponse = FB.getAuthResponse();
  1039. if (existingResponse && existingResponse.userID !== authData.id) {
  1040. FB.logout();
  1041. }
  1042. FB.init(newOptions);
  1043. }
  1044. return true;
  1045. },
  1046. getAuthType() {
  1047. return 'facebook';
  1048. },
  1049. deauthenticate() {
  1050. this.restoreAuthentication(null);
  1051. }
  1052. };
  1053. /**
  1054. * Provides a set of utilities for using Parse with Facebook.
  1055. *
  1056. * @class Parse.FacebookUtils
  1057. * @static
  1058. * @hideconstructor
  1059. */
  1060. const FacebookUtils = {
  1061. /**
  1062. * Initializes Parse Facebook integration. Call this function after you
  1063. * have loaded the Facebook Javascript SDK with the same parameters
  1064. * as you would pass to<code>
  1065. * <a href=
  1066. * "https://developers.facebook.com/docs/reference/javascript/FB.init/">
  1067. * FB.init()</a></code>. Parse.FacebookUtils will invoke FB.init() for you
  1068. * with these arguments.
  1069. *
  1070. * @function init
  1071. * @name Parse.FacebookUtils.init
  1072. * @param {object} options Facebook options argument as described here:
  1073. * <a href=
  1074. * "https://developers.facebook.com/docs/reference/javascript/FB.init/">
  1075. * FB.init()</a>. The status flag will be coerced to 'false' because it
  1076. * interferes with Parse Facebook integration. Call FB.getLoginStatus()
  1077. * explicitly if this behavior is required by your application.
  1078. */
  1079. init(options) {
  1080. if (typeof FB === 'undefined') {
  1081. throw new Error('The Facebook JavaScript SDK must be loaded before calling init.');
  1082. }
  1083. initOptions = {};
  1084. if (options) {
  1085. for (const key in options) {
  1086. initOptions[key] = options[key];
  1087. }
  1088. }
  1089. if (initOptions.status && typeof console !== 'undefined') {
  1090. const warn = console.warn || console.log || function () {}; // eslint-disable-line no-console
  1091. 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.');
  1092. }
  1093. initOptions.status = false;
  1094. FB.init(initOptions);
  1095. _ParseUser.default._registerAuthenticationProvider(provider);
  1096. initialized = true;
  1097. },
  1098. /**
  1099. * Gets whether the user has their account linked to Facebook.
  1100. *
  1101. * @function isLinked
  1102. * @name Parse.FacebookUtils.isLinked
  1103. * @param {Parse.User} user User to check for a facebook link.
  1104. * The user must be logged in on this device.
  1105. * @returns {boolean} <code>true</code> if the user has their account
  1106. * linked to Facebook.
  1107. */
  1108. isLinked(user) {
  1109. return user._isLinked('facebook');
  1110. },
  1111. /**
  1112. * Logs in a user using Facebook. This method delegates to the Facebook
  1113. * SDK to authenticate the user, and then automatically logs in (or
  1114. * creates, in the case where it is a new user) a Parse.User.
  1115. *
  1116. * Standard API:
  1117. *
  1118. * <code>logIn(permission: string, authData: Object);</code>
  1119. *
  1120. * Advanced API: Used for handling your own oAuth tokens
  1121. * {@link https://docs.parseplatform.org/rest/guide/#linking-users}
  1122. *
  1123. * <code>logIn(authData: Object, options?: Object);</code>
  1124. *
  1125. * @function logIn
  1126. * @name Parse.FacebookUtils.logIn
  1127. * @param {(string | object)} permissions The permissions required for Facebook
  1128. * log in. This is a comma-separated string of permissions.
  1129. * Alternatively, supply a Facebook authData object as described in our
  1130. * REST API docs if you want to handle getting facebook auth tokens
  1131. * yourself.
  1132. * @param {object} options MasterKey / SessionToken. Alternatively can be used for authData if permissions is a string
  1133. * @returns {Promise}
  1134. */
  1135. logIn(permissions, options) {
  1136. if (!permissions || typeof permissions === 'string') {
  1137. if (!initialized) {
  1138. throw new Error('You must initialize FacebookUtils before calling logIn.');
  1139. }
  1140. requestedPermissions = permissions;
  1141. return _ParseUser.default.logInWith('facebook', options);
  1142. }
  1143. return _ParseUser.default.logInWith('facebook', {
  1144. authData: permissions
  1145. }, options);
  1146. },
  1147. /**
  1148. * Links Facebook to an existing PFUser. This method delegates to the
  1149. * Facebook SDK to authenticate the user, and then automatically links
  1150. * the account to the Parse.User.
  1151. *
  1152. * Standard API:
  1153. *
  1154. * <code>link(user: Parse.User, permission: string, authData?: Object);</code>
  1155. *
  1156. * Advanced API: Used for handling your own oAuth tokens
  1157. * {@link https://docs.parseplatform.org/rest/guide/#linking-users}
  1158. *
  1159. * <code>link(user: Parse.User, authData: Object, options?: FullOptions);</code>
  1160. *
  1161. * @function link
  1162. * @name Parse.FacebookUtils.link
  1163. * @param {Parse.User} user User to link to Facebook. This must be the
  1164. * current user.
  1165. * @param {(string | object)} permissions The permissions required for Facebook
  1166. * log in. This is a comma-separated string of permissions.
  1167. * Alternatively, supply a Facebook authData object as described in our
  1168. * REST API docs if you want to handle getting facebook auth tokens
  1169. * yourself.
  1170. * @param {object} options MasterKey / SessionToken. Alternatively can be used for authData if permissions is a string
  1171. * @returns {Promise}
  1172. */
  1173. link(user, permissions, options) {
  1174. if (!permissions || typeof permissions === 'string') {
  1175. if (!initialized) {
  1176. throw new Error('You must initialize FacebookUtils before calling link.');
  1177. }
  1178. requestedPermissions = permissions;
  1179. return user.linkWith('facebook', options);
  1180. }
  1181. return user.linkWith('facebook', {
  1182. authData: permissions
  1183. }, options);
  1184. },
  1185. /**
  1186. * Unlinks the Parse.User from a Facebook account.
  1187. *
  1188. * @function unlink
  1189. * @name Parse.FacebookUtils.unlink
  1190. * @param {Parse.User} user User to unlink from Facebook. This must be the
  1191. * current user.
  1192. * @param {object} options Standard options object with success and error
  1193. * callbacks.
  1194. * @returns {Promise}
  1195. */
  1196. unlink: function (user, options) {
  1197. if (!initialized) {
  1198. throw new Error('You must initialize FacebookUtils before calling unlink.');
  1199. }
  1200. return user._unlinkFrom('facebook', options);
  1201. },
  1202. // Used for testing purposes
  1203. _getAuthProvider() {
  1204. return provider;
  1205. }
  1206. };
  1207. var _default = exports.default = FacebookUtils;
  1208. },{"./ParseUser":38,"@babel/runtime-corejs3/core-js-stable/object/define-property":90,"@babel/runtime-corejs3/helpers/interopRequireDefault":103}],9:[function(_dereq_,module,exports){
  1209. "use strict";
  1210. var _keysInstanceProperty = _dereq_("@babel/runtime-corejs3/core-js-stable/instance/keys");
  1211. var _Object$defineProperty = _dereq_("@babel/runtime-corejs3/core-js-stable/object/define-property");
  1212. _Object$defineProperty(exports, "__esModule", {
  1213. value: true
  1214. });
  1215. exports.default = void 0;
  1216. var _idbKeyval = _dereq_("idb-keyval");
  1217. /* global window */
  1218. let IndexedDBStorageController;
  1219. if (typeof window !== 'undefined' && window.indexedDB) {
  1220. try {
  1221. const ParseStore = (0, _idbKeyval.createStore)('parseDB', 'parseStore');
  1222. IndexedDBStorageController = {
  1223. async: 1,
  1224. getItemAsync(path) {
  1225. return (0, _idbKeyval.get)(path, ParseStore);
  1226. },
  1227. setItemAsync(path, value) {
  1228. return (0, _idbKeyval.set)(path, value, ParseStore);
  1229. },
  1230. removeItemAsync(path) {
  1231. return (0, _idbKeyval.del)(path, ParseStore);
  1232. },
  1233. getAllKeysAsync() {
  1234. return (0, _keysInstanceProperty(_idbKeyval))(ParseStore);
  1235. },
  1236. clear() {
  1237. return (0, _idbKeyval.clear)(ParseStore);
  1238. }
  1239. };
  1240. } catch (_) {
  1241. // IndexedDB not accessible
  1242. IndexedDBStorageController = undefined;
  1243. }
  1244. } else {
  1245. // IndexedDB not supported
  1246. IndexedDBStorageController = undefined;
  1247. }
  1248. module.exports = IndexedDBStorageController;
  1249. var _default = exports.default = IndexedDBStorageController;
  1250. },{"@babel/runtime-corejs3/core-js-stable/instance/keys":77,"@babel/runtime-corejs3/core-js-stable/object/define-property":90,"idb-keyval":486}],10:[function(_dereq_,module,exports){
  1251. "use strict";
  1252. var _Object$defineProperty = _dereq_("@babel/runtime-corejs3/core-js-stable/object/define-property");
  1253. var _interopRequireDefault = _dereq_("@babel/runtime-corejs3/helpers/interopRequireDefault");
  1254. _Object$defineProperty(exports, "__esModule", {
  1255. value: true
  1256. });
  1257. exports.default = void 0;
  1258. var _stringify = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/json/stringify"));
  1259. var _CoreManager = _interopRequireDefault(_dereq_("./CoreManager"));
  1260. var _Storage = _interopRequireDefault(_dereq_("./Storage"));
  1261. var _ParseInstallation = _interopRequireDefault(_dereq_("./ParseInstallation"));
  1262. var _uuid = _interopRequireDefault(_dereq_("./uuid"));
  1263. const CURRENT_INSTALLATION_KEY = 'currentInstallation';
  1264. const CURRENT_INSTALLATION_ID_KEY = 'currentInstallationId';
  1265. let iidCache = null;
  1266. let currentInstallationCache = null;
  1267. let currentInstallationCacheMatchesDisk = false;
  1268. const InstallationController = {
  1269. async updateInstallationOnDisk(installation) {
  1270. const path = _Storage.default.generatePath(CURRENT_INSTALLATION_KEY);
  1271. await _Storage.default.setItemAsync(path, (0, _stringify.default)(installation.toJSON()));
  1272. this._setCurrentInstallationCache(installation);
  1273. },
  1274. async currentInstallationId() {
  1275. if (typeof iidCache === 'string') {
  1276. return iidCache;
  1277. }
  1278. const path = _Storage.default.generatePath(CURRENT_INSTALLATION_ID_KEY);
  1279. let iid = await _Storage.default.getItemAsync(path);
  1280. if (!iid) {
  1281. iid = (0, _uuid.default)();
  1282. return _Storage.default.setItemAsync(path, iid).then(() => {
  1283. iidCache = iid;
  1284. return iid;
  1285. });
  1286. }
  1287. iidCache = iid;
  1288. return iid;
  1289. },
  1290. async currentInstallation() {
  1291. if (currentInstallationCache) {
  1292. return currentInstallationCache;
  1293. }
  1294. if (currentInstallationCacheMatchesDisk) {
  1295. return null;
  1296. }
  1297. const path = _Storage.default.generatePath(CURRENT_INSTALLATION_KEY);
  1298. let installationData = await _Storage.default.getItemAsync(path);
  1299. currentInstallationCacheMatchesDisk = true;
  1300. if (installationData) {
  1301. installationData = JSON.parse(installationData);
  1302. installationData.className = '_Installation';
  1303. const current = _ParseInstallation.default.fromJSON(installationData);
  1304. currentInstallationCache = current;
  1305. return current;
  1306. }
  1307. const installationId = await this.currentInstallationId();
  1308. const installation = new _ParseInstallation.default();
  1309. installation.set('deviceType', _ParseInstallation.default.DEVICE_TYPES.WEB);
  1310. installation.set('installationId', installationId);
  1311. installation.set('parseVersion', _CoreManager.default.get('VERSION'));
  1312. currentInstallationCache = installation;
  1313. await _Storage.default.setItemAsync(path, (0, _stringify.default)(installation.toJSON()));
  1314. return installation;
  1315. },
  1316. _clearCache() {
  1317. iidCache = null;
  1318. currentInstallationCache = null;
  1319. currentInstallationCacheMatchesDisk = false;
  1320. },
  1321. _setInstallationIdCache(iid) {
  1322. iidCache = iid;
  1323. },
  1324. _setCurrentInstallationCache(installation) {
  1325. let matchesDisk = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true;
  1326. currentInstallationCache = installation;
  1327. currentInstallationCacheMatchesDisk = matchesDisk;
  1328. }
  1329. };
  1330. module.exports = InstallationController;
  1331. var _default = exports.default = InstallationController;
  1332. },{"./CoreManager":4,"./ParseInstallation":28,"./Storage":43,"./uuid":64,"@babel/runtime-corejs3/core-js-stable/json/stringify":85,"@babel/runtime-corejs3/core-js-stable/object/define-property":90,"@babel/runtime-corejs3/helpers/interopRequireDefault":103}],11:[function(_dereq_,module,exports){
  1333. "use strict";
  1334. var _Object$defineProperty = _dereq_("@babel/runtime-corejs3/core-js-stable/object/define-property");
  1335. var _interopRequireDefault = _dereq_("@babel/runtime-corejs3/helpers/interopRequireDefault");
  1336. _Object$defineProperty(exports, "__esModule", {
  1337. value: true
  1338. });
  1339. exports.default = void 0;
  1340. var _indexOf = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/instance/index-of"));
  1341. var _map = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/map"));
  1342. var _keys = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/instance/keys"));
  1343. var _stringify = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/json/stringify"));
  1344. var _forEach = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/instance/for-each"));
  1345. var _values = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/instance/values"));
  1346. var _setTimeout2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/set-timeout"));
  1347. var _bind = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/instance/bind"));
  1348. var _defineProperty2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/helpers/defineProperty"));
  1349. var _CoreManager = _interopRequireDefault(_dereq_("./CoreManager"));
  1350. var _ParseObject = _interopRequireDefault(_dereq_("./ParseObject"));
  1351. var _LiveQuerySubscription = _interopRequireDefault(_dereq_("./LiveQuerySubscription"));
  1352. var _promiseUtils = _dereq_("./promiseUtils");
  1353. var _ParseError = _interopRequireDefault(_dereq_("./ParseError"));
  1354. // The LiveQuery client inner state
  1355. const CLIENT_STATE = {
  1356. INITIALIZED: 'initialized',
  1357. CONNECTING: 'connecting',
  1358. CONNECTED: 'connected',
  1359. CLOSED: 'closed',
  1360. RECONNECTING: 'reconnecting',
  1361. DISCONNECTED: 'disconnected'
  1362. };
  1363. // The event type the LiveQuery client should sent to server
  1364. const OP_TYPES = {
  1365. CONNECT: 'connect',
  1366. SUBSCRIBE: 'subscribe',
  1367. UNSUBSCRIBE: 'unsubscribe',
  1368. ERROR: 'error'
  1369. };
  1370. // The event we get back from LiveQuery server
  1371. const OP_EVENTS = {
  1372. CONNECTED: 'connected',
  1373. SUBSCRIBED: 'subscribed',
  1374. UNSUBSCRIBED: 'unsubscribed',
  1375. ERROR: 'error',
  1376. CREATE: 'create',
  1377. UPDATE: 'update',
  1378. ENTER: 'enter',
  1379. LEAVE: 'leave',
  1380. DELETE: 'delete'
  1381. };
  1382. // The event the LiveQuery client should emit
  1383. const CLIENT_EMMITER_TYPES = {
  1384. CLOSE: 'close',
  1385. ERROR: 'error',
  1386. OPEN: 'open'
  1387. };
  1388. // The event the LiveQuery subscription should emit
  1389. const SUBSCRIPTION_EMMITER_TYPES = {
  1390. OPEN: 'open',
  1391. CLOSE: 'close',
  1392. ERROR: 'error',
  1393. CREATE: 'create',
  1394. UPDATE: 'update',
  1395. ENTER: 'enter',
  1396. LEAVE: 'leave',
  1397. DELETE: 'delete'
  1398. };
  1399. // Exponentially-growing random delay
  1400. const generateInterval = k => {
  1401. return Math.random() * Math.min(30, Math.pow(2, k) - 1) * 1000;
  1402. };
  1403. /**
  1404. * Creates a new LiveQueryClient.
  1405. * <a href="https://nodejs.org/api/events.html#events_class_eventemitter">cloud functions</a>.
  1406. *
  1407. * A wrapper of a standard WebSocket client. We add several useful methods to
  1408. * help you connect/disconnect to LiveQueryServer, subscribe/unsubscribe a ParseQuery easily.
  1409. *
  1410. * javascriptKey and masterKey are used for verifying the LiveQueryClient when it tries
  1411. * to connect to the LiveQuery server
  1412. *
  1413. * We expose three events to help you monitor the status of the LiveQueryClient.
  1414. *
  1415. * <pre>
  1416. * const LiveQueryClient = Parse.LiveQueryClient;
  1417. * const client = new LiveQueryClient({
  1418. * applicationId: '',
  1419. * serverURL: '',
  1420. * javascriptKey: '',
  1421. * masterKey: ''
  1422. * });
  1423. * </pre>
  1424. *
  1425. * Open - When we establish the WebSocket connection to the LiveQuery server, you'll get this event.
  1426. * <pre>
  1427. * client.on('open', () => {
  1428. *
  1429. * });</pre>
  1430. *
  1431. * Close - When we lose the WebSocket connection to the LiveQuery server, you'll get this event.
  1432. * <pre>
  1433. * client.on('close', () => {
  1434. *
  1435. * });</pre>
  1436. *
  1437. * Error - When some network error or LiveQuery server error happens, you'll get this event.
  1438. * <pre>
  1439. * client.on('error', (error) => {
  1440. *
  1441. * });</pre>
  1442. *
  1443. * @alias Parse.LiveQueryClient
  1444. */
  1445. class LiveQueryClient {
  1446. /**
  1447. * @param {object} options
  1448. * @param {string} options.applicationId - applicationId of your Parse app
  1449. * @param {string} options.serverURL - <b>the URL of your LiveQuery server</b>
  1450. * @param {string} options.javascriptKey (optional)
  1451. * @param {string} options.masterKey (optional) Your Parse Master Key. (Node.js only!)
  1452. * @param {string} options.sessionToken (optional)
  1453. * @param {string} options.installationId (optional)
  1454. */
  1455. constructor(_ref) {
  1456. var _this = this;
  1457. let {
  1458. applicationId,
  1459. serverURL,
  1460. javascriptKey,
  1461. masterKey,
  1462. sessionToken,
  1463. installationId
  1464. } = _ref;
  1465. (0, _defineProperty2.default)(this, "attempts", void 0);
  1466. (0, _defineProperty2.default)(this, "id", void 0);
  1467. (0, _defineProperty2.default)(this, "requestId", void 0);
  1468. (0, _defineProperty2.default)(this, "applicationId", void 0);
  1469. (0, _defineProperty2.default)(this, "serverURL", void 0);
  1470. (0, _defineProperty2.default)(this, "javascriptKey", void 0);
  1471. (0, _defineProperty2.default)(this, "masterKey", void 0);
  1472. (0, _defineProperty2.default)(this, "sessionToken", void 0);
  1473. (0, _defineProperty2.default)(this, "installationId", void 0);
  1474. (0, _defineProperty2.default)(this, "additionalProperties", void 0);
  1475. (0, _defineProperty2.default)(this, "connectPromise", void 0);
  1476. (0, _defineProperty2.default)(this, "subscriptions", void 0);
  1477. (0, _defineProperty2.default)(this, "socket", void 0);
  1478. (0, _defineProperty2.default)(this, "state", void 0);
  1479. (0, _defineProperty2.default)(this, "reconnectHandle", void 0);
  1480. (0, _defineProperty2.default)(this, "emitter", void 0);
  1481. (0, _defineProperty2.default)(this, "on", void 0);
  1482. (0, _defineProperty2.default)(this, "emit", void 0);
  1483. if (!serverURL || (0, _indexOf.default)(serverURL).call(serverURL, 'ws') !== 0) {
  1484. throw new Error('You need to set a proper Parse LiveQuery server url before using LiveQueryClient');
  1485. }
  1486. this.reconnectHandle = null;
  1487. this.attempts = 1;
  1488. this.id = 0;
  1489. this.requestId = 1;
  1490. this.serverURL = serverURL;
  1491. this.applicationId = applicationId;
  1492. this.javascriptKey = javascriptKey || undefined;
  1493. this.masterKey = masterKey || undefined;
  1494. this.sessionToken = sessionToken || undefined;
  1495. this.installationId = installationId || undefined;
  1496. this.additionalProperties = true;
  1497. this.connectPromise = (0, _promiseUtils.resolvingPromise)();
  1498. this.subscriptions = new _map.default();
  1499. this.state = CLIENT_STATE.INITIALIZED;
  1500. const EventEmitter = _CoreManager.default.getEventEmitter();
  1501. this.emitter = new EventEmitter();
  1502. this.on = (eventName, listener) => this.emitter.on(eventName, listener);
  1503. this.emit = function (eventName) {
  1504. for (var _len = arguments.length, args = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
  1505. args[_key - 1] = arguments[_key];
  1506. }
  1507. return _this.emitter.emit(eventName, ...args);
  1508. };
  1509. // adding listener so process does not crash
  1510. // best practice is for developer to register their own listener
  1511. this.on('error', () => {});
  1512. }
  1513. shouldOpen() {
  1514. return this.state === CLIENT_STATE.INITIALIZED || this.state === CLIENT_STATE.DISCONNECTED;
  1515. }
  1516. /**
  1517. * Subscribes to a ParseQuery
  1518. *
  1519. * If you provide the sessionToken, when the LiveQuery server gets ParseObject's
  1520. * updates from parse server, it'll try to check whether the sessionToken fulfills
  1521. * the ParseObject's ACL. The LiveQuery server will only send updates to clients whose
  1522. * sessionToken is fit for the ParseObject's ACL. You can check the LiveQuery protocol
  1523. * <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
  1524. * from our Standard API.
  1525. *
  1526. * @param {ParseQuery} query - the ParseQuery you want to subscribe to
  1527. * @param {string} sessionToken (optional)
  1528. * @returns {LiveQuerySubscription | undefined}
  1529. */
  1530. subscribe(query, sessionToken) {
  1531. if (!query) {
  1532. return;
  1533. }
  1534. const className = query.className;
  1535. const queryJSON = query.toJSON();
  1536. const where = queryJSON.where;
  1537. const keys = (0, _keys.default)(queryJSON)?.split(',');
  1538. const watch = queryJSON.watch?.split(',');
  1539. const subscribeRequest = {
  1540. op: OP_TYPES.SUBSCRIBE,
  1541. requestId: this.requestId,
  1542. query: {
  1543. className,
  1544. where,
  1545. keys,
  1546. watch
  1547. },
  1548. sessionToken: undefined
  1549. };
  1550. if (sessionToken) {
  1551. subscribeRequest.sessionToken = sessionToken;
  1552. }
  1553. const subscription = new _LiveQuerySubscription.default(this.requestId, query, sessionToken);
  1554. this.subscriptions.set(this.requestId, subscription);
  1555. this.requestId += 1;
  1556. this.connectPromise.then(() => {
  1557. this.socket.send((0, _stringify.default)(subscribeRequest));
  1558. }).catch(error => {
  1559. subscription.subscribePromise.reject(error);
  1560. });
  1561. return subscription;
  1562. }
  1563. /**
  1564. * After calling unsubscribe you'll stop receiving events from the subscription object.
  1565. *
  1566. * @param {object} subscription - subscription you would like to unsubscribe from.
  1567. * @returns {Promise | undefined}
  1568. */
  1569. async unsubscribe(subscription) {
  1570. if (!subscription) {
  1571. return;
  1572. }
  1573. const unsubscribeRequest = {
  1574. op: OP_TYPES.UNSUBSCRIBE,
  1575. requestId: subscription.id
  1576. };
  1577. return this.connectPromise.then(() => {
  1578. return this.socket.send((0, _stringify.default)(unsubscribeRequest));
  1579. }).then(() => {
  1580. return subscription.unsubscribePromise;
  1581. });
  1582. }
  1583. /**
  1584. * After open is called, the LiveQueryClient will try to send a connect request
  1585. * to the LiveQuery server.
  1586. *
  1587. */
  1588. open() {
  1589. const WebSocketImplementation = _CoreManager.default.getWebSocketController();
  1590. if (!WebSocketImplementation) {
  1591. this.emit(CLIENT_EMMITER_TYPES.ERROR, 'Can not find WebSocket implementation');
  1592. return;
  1593. }
  1594. if (this.state !== CLIENT_STATE.RECONNECTING) {
  1595. this.state = CLIENT_STATE.CONNECTING;
  1596. }
  1597. this.socket = new WebSocketImplementation(this.serverURL);
  1598. this.socket.closingPromise = (0, _promiseUtils.resolvingPromise)();
  1599. // Bind WebSocket callbacks
  1600. this.socket.onopen = () => {
  1601. this._handleWebSocketOpen();
  1602. };
  1603. this.socket.onmessage = event => {
  1604. this._handleWebSocketMessage(event);
  1605. };
  1606. this.socket.onclose = event => {
  1607. this.socket.closingPromise?.resolve(event);
  1608. this._handleWebSocketClose();
  1609. };
  1610. this.socket.onerror = error => {
  1611. this._handleWebSocketError(error);
  1612. };
  1613. }
  1614. resubscribe() {
  1615. var _context;
  1616. (0, _forEach.default)(_context = this.subscriptions).call(_context, (subscription, requestId) => {
  1617. const query = subscription.query;
  1618. const queryJSON = query.toJSON();
  1619. const where = queryJSON.where;
  1620. const keys = (0, _keys.default)(queryJSON)?.split(',');
  1621. const watch = queryJSON.watch?.split(',');
  1622. const className = query.className;
  1623. const sessionToken = subscription.sessionToken;
  1624. const subscribeRequest = {
  1625. op: OP_TYPES.SUBSCRIBE,
  1626. requestId,
  1627. query: {
  1628. className,
  1629. where,
  1630. keys,
  1631. watch
  1632. },
  1633. sessionToken: undefined
  1634. };
  1635. if (sessionToken) {
  1636. subscribeRequest.sessionToken = sessionToken;
  1637. }
  1638. this.connectPromise.then(() => {
  1639. this.socket.send((0, _stringify.default)(subscribeRequest));
  1640. });
  1641. });
  1642. }
  1643. /**
  1644. * This method will close the WebSocket connection to this LiveQueryClient,
  1645. * cancel the auto reconnect and unsubscribe all subscriptions based on it.
  1646. *
  1647. * @returns {Promise | undefined} CloseEvent {@link https://developer.mozilla.org/en-US/docs/Web/API/WebSocket/close_event}
  1648. */
  1649. async close() {
  1650. if (this.state === CLIENT_STATE.INITIALIZED || this.state === CLIENT_STATE.DISCONNECTED) {
  1651. return;
  1652. }
  1653. this.state = CLIENT_STATE.DISCONNECTED;
  1654. this.socket?.close();
  1655. // Notify each subscription about the close
  1656. for (const subscription of (0, _values.default)(_context2 = this.subscriptions).call(_context2)) {
  1657. var _context2;
  1658. subscription.subscribed = false;
  1659. subscription.emit(SUBSCRIPTION_EMMITER_TYPES.CLOSE);
  1660. }
  1661. this._handleReset();
  1662. this.emit(CLIENT_EMMITER_TYPES.CLOSE);
  1663. return this.socket?.closingPromise;
  1664. }
  1665. // ensure we start with valid state if connect is called again after close
  1666. _handleReset() {
  1667. this.attempts = 1;
  1668. this.id = 0;
  1669. this.requestId = 1;
  1670. this.connectPromise = (0, _promiseUtils.resolvingPromise)();
  1671. this.subscriptions = new _map.default();
  1672. }
  1673. _handleWebSocketOpen() {
  1674. const connectRequest = {
  1675. op: OP_TYPES.CONNECT,
  1676. applicationId: this.applicationId,
  1677. javascriptKey: this.javascriptKey,
  1678. masterKey: this.masterKey,
  1679. sessionToken: this.sessionToken,
  1680. installationId: undefined
  1681. };
  1682. if (this.additionalProperties) {
  1683. connectRequest.installationId = this.installationId;
  1684. }
  1685. this.socket.send((0, _stringify.default)(connectRequest));
  1686. }
  1687. _handleWebSocketMessage(event) {
  1688. let data = event.data;
  1689. if (typeof data === 'string') {
  1690. data = JSON.parse(data);
  1691. }
  1692. let subscription = null;
  1693. if (data.requestId) {
  1694. subscription = this.subscriptions.get(data.requestId) || null;
  1695. }
  1696. const response = {
  1697. clientId: data.clientId,
  1698. installationId: data.installationId
  1699. };
  1700. switch (data.op) {
  1701. case OP_EVENTS.CONNECTED:
  1702. if (this.state === CLIENT_STATE.RECONNECTING) {
  1703. this.resubscribe();
  1704. }
  1705. this.emit(CLIENT_EMMITER_TYPES.OPEN);
  1706. this.id = data.clientId;
  1707. this.connectPromise.resolve();
  1708. this.state = CLIENT_STATE.CONNECTED;
  1709. break;
  1710. case OP_EVENTS.SUBSCRIBED:
  1711. if (subscription) {
  1712. this.attempts = 1;
  1713. subscription.subscribed = true;
  1714. subscription.subscribePromise.resolve();
  1715. (0, _setTimeout2.default)(() => subscription.emit(SUBSCRIPTION_EMMITER_TYPES.OPEN, response), 200);
  1716. }
  1717. break;
  1718. case OP_EVENTS.ERROR:
  1719. {
  1720. const parseError = new _ParseError.default(data.code, data.error);
  1721. if (!this.id) {
  1722. this.connectPromise.reject(parseError);
  1723. this.state = CLIENT_STATE.DISCONNECTED;
  1724. }
  1725. if (data.requestId) {
  1726. if (subscription) {
  1727. subscription.subscribePromise.reject(parseError);
  1728. (0, _setTimeout2.default)(() => subscription.emit(SUBSCRIPTION_EMMITER_TYPES.ERROR, data.error), 200);
  1729. }
  1730. } else {
  1731. this.emit(CLIENT_EMMITER_TYPES.ERROR, data.error);
  1732. }
  1733. if (data.error === 'Additional properties not allowed') {
  1734. this.additionalProperties = false;
  1735. }
  1736. if (data.reconnect) {
  1737. this._handleReconnect();
  1738. }
  1739. break;
  1740. }
  1741. case OP_EVENTS.UNSUBSCRIBED:
  1742. {
  1743. if (subscription) {
  1744. this.subscriptions.delete(data.requestId);
  1745. subscription.subscribed = false;
  1746. subscription.unsubscribePromise.resolve();
  1747. }
  1748. break;
  1749. }
  1750. default:
  1751. {
  1752. // create, update, enter, leave, delete cases
  1753. if (!subscription) {
  1754. break;
  1755. }
  1756. let override = false;
  1757. if (data.original) {
  1758. override = true;
  1759. delete data.original.__type;
  1760. // Check for removed fields
  1761. for (const field in data.original) {
  1762. if (!(field in data.object)) {
  1763. data.object[field] = undefined;
  1764. }
  1765. }
  1766. data.original = _ParseObject.default.fromJSON(data.original, false);
  1767. }
  1768. delete data.object.__type;
  1769. const parseObject = _ParseObject.default.fromJSON(data.object, !(subscription.query && subscription.query._select) ? override : false);
  1770. if (data.original) {
  1771. subscription.emit(data.op, parseObject, data.original, response);
  1772. } else {
  1773. subscription.emit(data.op, parseObject, response);
  1774. }
  1775. const localDatastore = _CoreManager.default.getLocalDatastore();
  1776. if (override && localDatastore.isEnabled) {
  1777. localDatastore._updateObjectIfPinned(parseObject).then(() => {});
  1778. }
  1779. }
  1780. }
  1781. }
  1782. _handleWebSocketClose() {
  1783. if (this.state === CLIENT_STATE.DISCONNECTED) {
  1784. return;
  1785. }
  1786. this.state = CLIENT_STATE.CLOSED;
  1787. this.emit(CLIENT_EMMITER_TYPES.CLOSE);
  1788. // Notify each subscription about the close
  1789. for (const subscription of (0, _values.default)(_context3 = this.subscriptions).call(_context3)) {
  1790. var _context3;
  1791. subscription.emit(SUBSCRIPTION_EMMITER_TYPES.CLOSE);
  1792. }
  1793. this._handleReconnect();
  1794. }
  1795. _handleWebSocketError(error) {
  1796. this.emit(CLIENT_EMMITER_TYPES.ERROR, error);
  1797. for (const subscription of (0, _values.default)(_context4 = this.subscriptions).call(_context4)) {
  1798. var _context4;
  1799. subscription.emit(SUBSCRIPTION_EMMITER_TYPES.ERROR, error);
  1800. }
  1801. this._handleReconnect();
  1802. }
  1803. _handleReconnect() {
  1804. var _context5;
  1805. // if closed or currently reconnecting we stop attempting to reconnect
  1806. if (this.state === CLIENT_STATE.DISCONNECTED) {
  1807. return;
  1808. }
  1809. this.state = CLIENT_STATE.RECONNECTING;
  1810. const time = generateInterval(this.attempts);
  1811. // handle case when both close/error occur at frequent rates we ensure we do not reconnect unnecessarily.
  1812. // we're unable to distinguish different between close/error when we're unable to reconnect therefore
  1813. // we try to reconnect in both cases
  1814. // server side ws and browser WebSocket behave differently in when close/error get triggered
  1815. if (this.reconnectHandle) {
  1816. clearTimeout(this.reconnectHandle);
  1817. }
  1818. this.reconnectHandle = (0, _setTimeout2.default)((0, _bind.default)(_context5 = () => {
  1819. this.attempts++;
  1820. this.connectPromise = (0, _promiseUtils.resolvingPromise)();
  1821. this.open();
  1822. }).call(_context5, this), time);
  1823. }
  1824. }
  1825. var _default = exports.default = LiveQueryClient;
  1826. },{"./CoreManager":4,"./LiveQuerySubscription":12,"./ParseError":24,"./ParseObject":30,"./promiseUtils":61,"@babel/runtime-corejs3/core-js-stable/instance/bind":67,"@babel/runtime-corejs3/core-js-stable/instance/for-each":74,"@babel/runtime-corejs3/core-js-stable/instance/index-of":76,"@babel/runtime-corejs3/core-js-stable/instance/keys":77,"@babel/runtime-corejs3/core-js-stable/instance/values":84,"@babel/runtime-corejs3/core-js-stable/json/stringify":85,"@babel/runtime-corejs3/core-js-stable/map":86,"@babel/runtime-corejs3/core-js-stable/object/define-property":90,"@babel/runtime-corejs3/core-js-stable/set-timeout":99,"@babel/runtime-corejs3/helpers/defineProperty":102,"@babel/runtime-corejs3/helpers/interopRequireDefault":103}],12:[function(_dereq_,module,exports){
  1827. "use strict";
  1828. var _Object$defineProperty = _dereq_("@babel/runtime-corejs3/core-js-stable/object/define-property");
  1829. var _interopRequireDefault = _dereq_("@babel/runtime-corejs3/helpers/interopRequireDefault");
  1830. _Object$defineProperty(exports, "__esModule", {
  1831. value: true
  1832. });
  1833. exports.default = void 0;
  1834. var _defineProperty2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/helpers/defineProperty"));
  1835. var _CoreManager = _interopRequireDefault(_dereq_("./CoreManager"));
  1836. var _promiseUtils = _dereq_("./promiseUtils");
  1837. /**
  1838. * Creates a new LiveQuery Subscription.
  1839. * <a href="https://nodejs.org/api/events.html#events_class_eventemitter">cloud functions</a>.
  1840. *
  1841. * <p>Response Object - Contains data from the client that made the request
  1842. * <ul>
  1843. * <li>clientId</li>
  1844. * <li>installationId - requires Parse Server 4.0.0+</li>
  1845. * </ul>
  1846. * </p>
  1847. *
  1848. * <p>Open Event - When you call query.subscribe(), we send a subscribe request to
  1849. * the LiveQuery server, when we get the confirmation from the LiveQuery server,
  1850. * this event will be emitted. When the client loses WebSocket connection to the
  1851. * LiveQuery server, we will try to auto reconnect the LiveQuery server. If we
  1852. * reconnect the LiveQuery server and successfully resubscribe the ParseQuery,
  1853. * you'll also get this event.
  1854. *
  1855. * <pre>
  1856. * subscription.on('open', (response) => {
  1857. *
  1858. * });</pre></p>
  1859. *
  1860. * <p>Create Event - When a new ParseObject is created and it fulfills the ParseQuery you subscribe,
  1861. * you'll get this event. The object is the ParseObject which is created.
  1862. *
  1863. * <pre>
  1864. * subscription.on('create', (object, response) => {
  1865. *
  1866. * });</pre></p>
  1867. *
  1868. * <p>Update Event - When an existing ParseObject (original) which fulfills the ParseQuery you subscribe
  1869. * is updated (The ParseObject fulfills the ParseQuery before and after changes),
  1870. * you'll get this event. The object is the ParseObject which is updated.
  1871. * Its content is the latest value of the ParseObject.
  1872. *
  1873. * Parse-Server 3.1.3+ Required for original object parameter
  1874. *
  1875. * <pre>
  1876. * subscription.on('update', (object, original, response) => {
  1877. *
  1878. * });</pre></p>
  1879. *
  1880. * <p>Enter Event - When an existing ParseObject's (original) old value doesn't fulfill the ParseQuery
  1881. * but its new value fulfills the ParseQuery, you'll get this event. The object is the
  1882. * ParseObject which enters the ParseQuery. Its content is the latest value of the ParseObject.
  1883. *
  1884. * Parse-Server 3.1.3+ Required for original object parameter
  1885. *
  1886. * <pre>
  1887. * subscription.on('enter', (object, original, response) => {
  1888. *
  1889. * });</pre></p>
  1890. *
  1891. *
  1892. * <p>Update Event - When an existing ParseObject's old value fulfills the ParseQuery but its new value
  1893. * doesn't fulfill the ParseQuery, you'll get this event. The object is the ParseObject
  1894. * which leaves the ParseQuery. Its content is the latest value of the ParseObject.
  1895. *
  1896. * <pre>
  1897. * subscription.on('leave', (object, response) => {
  1898. *
  1899. * });</pre></p>
  1900. *
  1901. *
  1902. * <p>Delete Event - When an existing ParseObject which fulfills the ParseQuery is deleted, you'll
  1903. * get this event. The object is the ParseObject which is deleted.
  1904. *
  1905. * <pre>
  1906. * subscription.on('delete', (object, response) => {
  1907. *
  1908. * });</pre></p>
  1909. *
  1910. *
  1911. * <p>Close Event - When the client loses the WebSocket connection to the LiveQuery
  1912. * server and we stop receiving events, you'll get this event.
  1913. *
  1914. * <pre>
  1915. * subscription.on('close', () => {
  1916. *
  1917. * });</pre></p>
  1918. */
  1919. class Subscription {
  1920. /*
  1921. * @param {string | number} id - subscription id
  1922. * @param {string} query - query to subscribe to
  1923. * @param {string} sessionToken - optional session token
  1924. */
  1925. constructor(id, query, sessionToken) {
  1926. var _this = this;
  1927. (0, _defineProperty2.default)(this, "id", void 0);
  1928. (0, _defineProperty2.default)(this, "query", void 0);
  1929. (0, _defineProperty2.default)(this, "sessionToken", void 0);
  1930. (0, _defineProperty2.default)(this, "subscribePromise", void 0);
  1931. (0, _defineProperty2.default)(this, "unsubscribePromise", void 0);
  1932. (0, _defineProperty2.default)(this, "subscribed", void 0);
  1933. (0, _defineProperty2.default)(this, "emitter", void 0);
  1934. (0, _defineProperty2.default)(this, "on", void 0);
  1935. (0, _defineProperty2.default)(this, "emit", void 0);
  1936. this.id = id;
  1937. this.query = query;
  1938. this.sessionToken = sessionToken;
  1939. this.subscribePromise = (0, _promiseUtils.resolvingPromise)();
  1940. this.unsubscribePromise = (0, _promiseUtils.resolvingPromise)();
  1941. this.subscribed = false;
  1942. const EventEmitter = _CoreManager.default.getEventEmitter();
  1943. this.emitter = new EventEmitter();
  1944. this.on = (eventName, listener) => this.emitter.on(eventName, listener);
  1945. this.emit = function (eventName) {
  1946. for (var _len = arguments.length, args = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
  1947. args[_key - 1] = arguments[_key];
  1948. }
  1949. return _this.emitter.emit(eventName, ...args);
  1950. };
  1951. // adding listener so process does not crash
  1952. // best practice is for developer to register their own listener
  1953. this.on('error', () => {});
  1954. }
  1955. /**
  1956. * Close the subscription
  1957. *
  1958. * @returns {Promise}
  1959. */
  1960. unsubscribe() {
  1961. return _CoreManager.default.getLiveQueryController().getDefaultLiveQueryClient().then(liveQueryClient => {
  1962. this.emit('close');
  1963. return liveQueryClient.unsubscribe(this);
  1964. });
  1965. }
  1966. }
  1967. var _default = exports.default = Subscription;
  1968. },{"./CoreManager":4,"./promiseUtils":61,"@babel/runtime-corejs3/core-js-stable/object/define-property":90,"@babel/runtime-corejs3/helpers/defineProperty":102,"@babel/runtime-corejs3/helpers/interopRequireDefault":103}],13:[function(_dereq_,module,exports){
  1969. "use strict";
  1970. var _Object$defineProperty = _dereq_("@babel/runtime-corejs3/core-js-stable/object/define-property");
  1971. var _interopRequireDefault = _dereq_("@babel/runtime-corejs3/helpers/interopRequireDefault");
  1972. _Object$defineProperty(exports, "__esModule", {
  1973. value: true
  1974. });
  1975. exports.default = void 0;
  1976. var _promise = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/promise"));
  1977. var _set = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/set"));
  1978. var _keys = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/object/keys"));
  1979. var _filter = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/instance/filter"));
  1980. var _includes = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/instance/includes"));
  1981. var _startsWith = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/instance/starts-with"));
  1982. var _isArray = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/array/is-array"));
  1983. var _map = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/instance/map"));
  1984. var _concat = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/instance/concat"));
  1985. var _from = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/array/from"));
  1986. var _find = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/instance/find"));
  1987. var _CoreManager = _interopRequireDefault(_dereq_("./CoreManager"));
  1988. var _LocalDatastoreController = _interopRequireDefault(_dereq_("./LocalDatastoreController"));
  1989. var _ParseQuery = _interopRequireDefault(_dereq_("./ParseQuery"));
  1990. var _LocalDatastoreUtils = _dereq_("./LocalDatastoreUtils");
  1991. /**
  1992. * Provides a local datastore which can be used to store and retrieve <code>Parse.Object</code>. <br />
  1993. * To enable this functionality, call <code>Parse.enableLocalDatastore()</code>.
  1994. *
  1995. * Pin object to add to local datastore
  1996. *
  1997. * <pre>await object.pin();</pre>
  1998. * <pre>await object.pinWithName('pinName');</pre>
  1999. *
  2000. * Query pinned objects
  2001. *
  2002. * <pre>query.fromLocalDatastore();</pre>
  2003. * <pre>query.fromPin();</pre>
  2004. * <pre>query.fromPinWithName();</pre>
  2005. *
  2006. * <pre>const localObjects = await query.find();</pre>
  2007. *
  2008. * @class Parse.LocalDatastore
  2009. * @static
  2010. */
  2011. const LocalDatastore = {
  2012. isEnabled: false,
  2013. isSyncing: false,
  2014. fromPinWithName(name) {
  2015. const controller = _CoreManager.default.getLocalDatastoreController();
  2016. return controller.fromPinWithName(name);
  2017. },
  2018. async pinWithName(name, value) {
  2019. const controller = _CoreManager.default.getLocalDatastoreController();
  2020. return controller.pinWithName(name, value);
  2021. },
  2022. async unPinWithName(name) {
  2023. const controller = _CoreManager.default.getLocalDatastoreController();
  2024. return controller.unPinWithName(name);
  2025. },
  2026. _getAllContents() {
  2027. const controller = _CoreManager.default.getLocalDatastoreController();
  2028. return controller.getAllContents();
  2029. },
  2030. // Use for testing
  2031. async _getRawStorage() {
  2032. const controller = _CoreManager.default.getLocalDatastoreController();
  2033. return controller.getRawStorage();
  2034. },
  2035. async _clear() {
  2036. const controller = _CoreManager.default.getLocalDatastoreController();
  2037. return controller.clear();
  2038. },
  2039. // Pin the object and children recursively
  2040. // Saves the object and children key to Pin Name
  2041. async _handlePinAllWithName(name, objects) {
  2042. const pinName = this.getPinName(name);
  2043. const toPinPromises = [];
  2044. const objectKeys = [];
  2045. for (const parent of objects) {
  2046. const children = this._getChildren(parent);
  2047. const parentKey = this.getKeyForObject(parent);
  2048. const json = parent._toFullJSON(undefined, true);
  2049. if (parent._localId) {
  2050. json._localId = parent._localId;
  2051. }
  2052. children[parentKey] = json;
  2053. for (const objectKey in children) {
  2054. objectKeys.push(objectKey);
  2055. toPinPromises.push(this.pinWithName(objectKey, [children[objectKey]]));
  2056. }
  2057. }
  2058. const fromPinPromise = this.fromPinWithName(pinName);
  2059. const [pinned] = await _promise.default.all([fromPinPromise, toPinPromises]);
  2060. const toPin = [...new _set.default([...(pinned || []), ...objectKeys])];
  2061. return this.pinWithName(pinName, toPin);
  2062. },
  2063. // Removes object and children keys from pin name
  2064. // Keeps the object and children pinned
  2065. async _handleUnPinAllWithName(name, objects) {
  2066. const localDatastore = await this._getAllContents();
  2067. const pinName = this.getPinName(name);
  2068. const promises = [];
  2069. let objectKeys = [];
  2070. for (const parent of objects) {
  2071. const children = this._getChildren(parent);
  2072. const parentKey = this.getKeyForObject(parent);
  2073. objectKeys.push(parentKey, ...(0, _keys.default)(children));
  2074. }
  2075. objectKeys = [...new _set.default(objectKeys)];
  2076. let pinned = localDatastore[pinName] || [];
  2077. pinned = (0, _filter.default)(pinned).call(pinned, item => !(0, _includes.default)(objectKeys).call(objectKeys, item));
  2078. if (pinned.length == 0) {
  2079. promises.push(this.unPinWithName(pinName));
  2080. delete localDatastore[pinName];
  2081. } else {
  2082. promises.push(this.pinWithName(pinName, pinned));
  2083. localDatastore[pinName] = pinned;
  2084. }
  2085. for (const objectKey of objectKeys) {
  2086. let hasReference = false;
  2087. for (const key in localDatastore) {
  2088. if (key === _LocalDatastoreUtils.DEFAULT_PIN || (0, _startsWith.default)(key).call(key, _LocalDatastoreUtils.PIN_PREFIX)) {
  2089. const pinnedObjects = localDatastore[key] || [];
  2090. if ((0, _includes.default)(pinnedObjects).call(pinnedObjects, objectKey)) {
  2091. hasReference = true;
  2092. break;
  2093. }
  2094. }
  2095. }
  2096. if (!hasReference) {
  2097. promises.push(this.unPinWithName(objectKey));
  2098. }
  2099. }
  2100. return _promise.default.all(promises);
  2101. },
  2102. // Retrieve all pointer fields from object recursively
  2103. _getChildren(object) {
  2104. const encountered = {};
  2105. const json = object._toFullJSON(undefined, true);
  2106. for (const key in json) {
  2107. if (json[key] && json[key].__type && json[key].__type === 'Object') {
  2108. this._traverse(json[key], encountered);
  2109. }
  2110. }
  2111. return encountered;
  2112. },
  2113. _traverse(object, encountered) {
  2114. if (!object.objectId) {
  2115. return;
  2116. } else {
  2117. const objectKey = this.getKeyForObject(object);
  2118. if (encountered[objectKey]) {
  2119. return;
  2120. }
  2121. encountered[objectKey] = object;
  2122. }
  2123. for (const key in object) {
  2124. let json = object[key];
  2125. if (!object[key]) {
  2126. json = object;
  2127. }
  2128. if (json.__type && json.__type === 'Object') {
  2129. this._traverse(json, encountered);
  2130. }
  2131. }
  2132. },
  2133. // Transform keys in pin name to objects
  2134. async _serializeObjectsFromPinName(name) {
  2135. var _context;
  2136. const localDatastore = await this._getAllContents();
  2137. const allObjects = [];
  2138. for (const key in localDatastore) {
  2139. if ((0, _startsWith.default)(key).call(key, _LocalDatastoreUtils.OBJECT_PREFIX)) {
  2140. allObjects.push(localDatastore[key][0]);
  2141. }
  2142. }
  2143. if (!name) {
  2144. return allObjects;
  2145. }
  2146. const pinName = this.getPinName(name);
  2147. const pinned = localDatastore[pinName];
  2148. if (!(0, _isArray.default)(pinned)) {
  2149. return [];
  2150. }
  2151. const promises = (0, _map.default)(pinned).call(pinned, objectKey => this.fromPinWithName(objectKey));
  2152. let objects = await _promise.default.all(promises);
  2153. objects = (0, _concat.default)(_context = []).call(_context, ...objects);
  2154. return (0, _filter.default)(objects).call(objects, object => object != null);
  2155. },
  2156. // Replaces object pointers with pinned pointers
  2157. // The object pointers may contain old data
  2158. // Uses Breadth First Search Algorithm
  2159. async _serializeObject(objectKey, localDatastore) {
  2160. let LDS = localDatastore;
  2161. if (!LDS) {
  2162. LDS = await this._getAllContents();
  2163. }
  2164. if (!LDS[objectKey] || LDS[objectKey].length === 0) {
  2165. return null;
  2166. }
  2167. const root = LDS[objectKey][0];
  2168. const queue = [];
  2169. const meta = {};
  2170. let uniqueId = 0;
  2171. meta[uniqueId] = root;
  2172. queue.push(uniqueId);
  2173. while (queue.length !== 0) {
  2174. const nodeId = queue.shift();
  2175. const subTreeRoot = meta[nodeId];
  2176. for (const field in subTreeRoot) {
  2177. const value = subTreeRoot[field];
  2178. if (value.__type && value.__type === 'Object') {
  2179. const key = this.getKeyForObject(value);
  2180. if (LDS[key] && LDS[key].length > 0) {
  2181. const pointer = LDS[key][0];
  2182. uniqueId++;
  2183. meta[uniqueId] = pointer;
  2184. subTreeRoot[field] = pointer;
  2185. queue.push(uniqueId);
  2186. }
  2187. }
  2188. }
  2189. }
  2190. return root;
  2191. },
  2192. // Called when an object is save / fetched
  2193. // Update object pin value
  2194. async _updateObjectIfPinned(object) {
  2195. if (!this.isEnabled) {
  2196. return;
  2197. }
  2198. const objectKey = this.getKeyForObject(object);
  2199. const pinned = await this.fromPinWithName(objectKey);
  2200. if (!pinned || pinned.length === 0) {
  2201. return;
  2202. }
  2203. return this.pinWithName(objectKey, [object._toFullJSON()]);
  2204. },
  2205. // Called when object is destroyed
  2206. // Unpin object and remove all references from pin names
  2207. // TODO: Destroy children?
  2208. async _destroyObjectIfPinned(object) {
  2209. if (!this.isEnabled) {
  2210. return;
  2211. }
  2212. const localDatastore = await this._getAllContents();
  2213. const objectKey = this.getKeyForObject(object);
  2214. const pin = localDatastore[objectKey];
  2215. if (!pin) {
  2216. return;
  2217. }
  2218. const promises = [this.unPinWithName(objectKey)];
  2219. delete localDatastore[objectKey];
  2220. for (const key in localDatastore) {
  2221. if (key === _LocalDatastoreUtils.DEFAULT_PIN || (0, _startsWith.default)(key).call(key, _LocalDatastoreUtils.PIN_PREFIX)) {
  2222. let pinned = localDatastore[key] || [];
  2223. if ((0, _includes.default)(pinned).call(pinned, objectKey)) {
  2224. pinned = (0, _filter.default)(pinned).call(pinned, item => item !== objectKey);
  2225. if (pinned.length == 0) {
  2226. promises.push(this.unPinWithName(key));
  2227. delete localDatastore[key];
  2228. } else {
  2229. promises.push(this.pinWithName(key, pinned));
  2230. localDatastore[key] = pinned;
  2231. }
  2232. }
  2233. }
  2234. }
  2235. return _promise.default.all(promises);
  2236. },
  2237. // Update pin and references of the unsaved object
  2238. async _updateLocalIdForObject(localId, object) {
  2239. if (!this.isEnabled) {
  2240. return;
  2241. }
  2242. const localKey = `${_LocalDatastoreUtils.OBJECT_PREFIX}${object.className}_${localId}`;
  2243. const objectKey = this.getKeyForObject(object);
  2244. const unsaved = await this.fromPinWithName(localKey);
  2245. if (!unsaved || unsaved.length === 0) {
  2246. return;
  2247. }
  2248. const promises = [this.unPinWithName(localKey), this.pinWithName(objectKey, unsaved)];
  2249. const localDatastore = await this._getAllContents();
  2250. for (const key in localDatastore) {
  2251. if (key === _LocalDatastoreUtils.DEFAULT_PIN || (0, _startsWith.default)(key).call(key, _LocalDatastoreUtils.PIN_PREFIX)) {
  2252. let pinned = localDatastore[key] || [];
  2253. if ((0, _includes.default)(pinned).call(pinned, localKey)) {
  2254. pinned = (0, _filter.default)(pinned).call(pinned, item => item !== localKey);
  2255. pinned.push(objectKey);
  2256. promises.push(this.pinWithName(key, pinned));
  2257. localDatastore[key] = pinned;
  2258. }
  2259. }
  2260. }
  2261. return _promise.default.all(promises);
  2262. },
  2263. /**
  2264. * Updates Local Datastore from Server
  2265. *
  2266. * <pre>
  2267. * await Parse.LocalDatastore.updateFromServer();
  2268. * </pre>
  2269. *
  2270. * @function updateFromServer
  2271. * @name Parse.LocalDatastore.updateFromServer
  2272. * @static
  2273. */
  2274. async updateFromServer() {
  2275. var _context2;
  2276. if (!this.checkIfEnabled() || this.isSyncing) {
  2277. return;
  2278. }
  2279. const localDatastore = await this._getAllContents();
  2280. const keys = [];
  2281. for (const key in localDatastore) {
  2282. if ((0, _startsWith.default)(key).call(key, _LocalDatastoreUtils.OBJECT_PREFIX)) {
  2283. keys.push(key);
  2284. }
  2285. }
  2286. if (keys.length === 0) {
  2287. return;
  2288. }
  2289. this.isSyncing = true;
  2290. const pointersHash = {};
  2291. for (const key of keys) {
  2292. // Ignore the OBJECT_PREFIX
  2293. let [,, className, objectId] = key.split('_');
  2294. // User key is split into [ 'Parse', 'LDS', '', 'User', 'objectId' ]
  2295. if (key.split('_').length === 5 && key.split('_')[3] === 'User') {
  2296. className = '_User';
  2297. objectId = key.split('_')[4];
  2298. }
  2299. if ((0, _startsWith.default)(objectId).call(objectId, 'local')) {
  2300. continue;
  2301. }
  2302. if (!(className in pointersHash)) {
  2303. pointersHash[className] = new _set.default();
  2304. }
  2305. pointersHash[className].add(objectId);
  2306. }
  2307. const queryPromises = (0, _map.default)(_context2 = (0, _keys.default)(pointersHash)).call(_context2, className => {
  2308. const objectIds = (0, _from.default)(pointersHash[className]);
  2309. const query = new _ParseQuery.default(className);
  2310. query.limit(objectIds.length);
  2311. if (objectIds.length === 1) {
  2312. query.equalTo('objectId', objectIds[0]);
  2313. } else {
  2314. query.containedIn('objectId', objectIds);
  2315. }
  2316. return (0, _find.default)(query).call(query);
  2317. });
  2318. try {
  2319. const responses = await _promise.default.all(queryPromises);
  2320. const objects = (0, _concat.default)([]).apply([], responses);
  2321. const pinPromises = (0, _map.default)(objects).call(objects, object => {
  2322. const objectKey = this.getKeyForObject(object);
  2323. return this.pinWithName(objectKey, object._toFullJSON());
  2324. });
  2325. await _promise.default.all(pinPromises);
  2326. this.isSyncing = false;
  2327. } catch (error) {
  2328. console.error('Error syncing LocalDatastore: ', error);
  2329. this.isSyncing = false;
  2330. }
  2331. },
  2332. getKeyForObject(object) {
  2333. const objectId = object.objectId || object._getId();
  2334. return `${_LocalDatastoreUtils.OBJECT_PREFIX}${object.className}_${objectId}`;
  2335. },
  2336. getPinName(pinName) {
  2337. if (!pinName || pinName === _LocalDatastoreUtils.DEFAULT_PIN) {
  2338. return _LocalDatastoreUtils.DEFAULT_PIN;
  2339. }
  2340. return _LocalDatastoreUtils.PIN_PREFIX + pinName;
  2341. },
  2342. checkIfEnabled() {
  2343. if (!this.isEnabled) {
  2344. console.error('Parse.enableLocalDatastore() must be called first');
  2345. }
  2346. return this.isEnabled;
  2347. }
  2348. };
  2349. module.exports = LocalDatastore;
  2350. var _default = exports.default = LocalDatastore;
  2351. _CoreManager.default.setLocalDatastoreController(_LocalDatastoreController.default);
  2352. _CoreManager.default.setLocalDatastore(LocalDatastore);
  2353. },{"./CoreManager":4,"./LocalDatastoreController":15,"./LocalDatastoreUtils":17,"./ParseQuery":33,"@babel/runtime-corejs3/core-js-stable/array/from":65,"@babel/runtime-corejs3/core-js-stable/array/is-array":66,"@babel/runtime-corejs3/core-js-stable/instance/concat":68,"@babel/runtime-corejs3/core-js-stable/instance/filter":71,"@babel/runtime-corejs3/core-js-stable/instance/find":73,"@babel/runtime-corejs3/core-js-stable/instance/includes":75,"@babel/runtime-corejs3/core-js-stable/instance/map":78,"@babel/runtime-corejs3/core-js-stable/instance/starts-with":83,"@babel/runtime-corejs3/core-js-stable/object/define-property":90,"@babel/runtime-corejs3/core-js-stable/object/keys":95,"@babel/runtime-corejs3/core-js-stable/promise":97,"@babel/runtime-corejs3/core-js-stable/set":100,"@babel/runtime-corejs3/helpers/interopRequireDefault":103}],14:[function(_dereq_,module,exports){
  2354. "use strict";
  2355. var _Object$defineProperty = _dereq_("@babel/runtime-corejs3/core-js-stable/object/define-property");
  2356. var _interopRequireDefault = _dereq_("@babel/runtime-corejs3/helpers/interopRequireDefault");
  2357. _Object$defineProperty(exports, "__esModule", {
  2358. value: true
  2359. });
  2360. exports.default = void 0;
  2361. var _stringify = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/json/stringify"));
  2362. var _reduce = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/instance/reduce"));
  2363. var _promise = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/promise"));
  2364. var _map = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/instance/map"));
  2365. var _LocalDatastoreUtils = _dereq_("./LocalDatastoreUtils");
  2366. var _Storage = _interopRequireDefault(_dereq_("./Storage"));
  2367. const LocalDatastoreController = {
  2368. async fromPinWithName(name) {
  2369. const values = await _Storage.default.getItemAsync(name);
  2370. if (!values) {
  2371. return [];
  2372. }
  2373. const objects = JSON.parse(values);
  2374. return objects;
  2375. },
  2376. pinWithName(name, value) {
  2377. const values = (0, _stringify.default)(value);
  2378. return _Storage.default.setItemAsync(name, values);
  2379. },
  2380. unPinWithName(name) {
  2381. return _Storage.default.removeItemAsync(name);
  2382. },
  2383. async getAllContents() {
  2384. const keys = await _Storage.default.getAllKeysAsync();
  2385. return (0, _reduce.default)(keys).call(keys, async (previousPromise, key) => {
  2386. const LDS = await previousPromise;
  2387. if ((0, _LocalDatastoreUtils.isLocalDatastoreKey)(key)) {
  2388. const value = await _Storage.default.getItemAsync(key);
  2389. try {
  2390. LDS[key] = JSON.parse(value);
  2391. } catch (error) {
  2392. console.error('Error getAllContents: ', error);
  2393. }
  2394. }
  2395. return LDS;
  2396. }, _promise.default.resolve({}));
  2397. },
  2398. // Used for testing
  2399. async getRawStorage() {
  2400. const keys = await _Storage.default.getAllKeysAsync();
  2401. return (0, _reduce.default)(keys).call(keys, async (previousPromise, key) => {
  2402. const LDS = await previousPromise;
  2403. const value = await _Storage.default.getItemAsync(key);
  2404. LDS[key] = value;
  2405. return LDS;
  2406. }, _promise.default.resolve({}));
  2407. },
  2408. async clear() {
  2409. const keys = await _Storage.default.getAllKeysAsync();
  2410. const toRemove = [];
  2411. for (const key of keys) {
  2412. if ((0, _LocalDatastoreUtils.isLocalDatastoreKey)(key)) {
  2413. toRemove.push(key);
  2414. }
  2415. }
  2416. const promises = (0, _map.default)(toRemove).call(toRemove, this.unPinWithName);
  2417. return _promise.default.all(promises);
  2418. }
  2419. };
  2420. module.exports = LocalDatastoreController;
  2421. var _default = exports.default = LocalDatastoreController;
  2422. },{"./LocalDatastoreUtils":17,"./Storage":43,"@babel/runtime-corejs3/core-js-stable/instance/map":78,"@babel/runtime-corejs3/core-js-stable/instance/reduce":79,"@babel/runtime-corejs3/core-js-stable/json/stringify":85,"@babel/runtime-corejs3/core-js-stable/object/define-property":90,"@babel/runtime-corejs3/core-js-stable/promise":97,"@babel/runtime-corejs3/helpers/interopRequireDefault":103}],15:[function(_dereq_,module,exports){
  2423. "use strict";
  2424. var _Object$defineProperty = _dereq_("@babel/runtime-corejs3/core-js-stable/object/define-property");
  2425. var _interopRequireDefault = _dereq_("@babel/runtime-corejs3/helpers/interopRequireDefault");
  2426. _Object$defineProperty(exports, "__esModule", {
  2427. value: true
  2428. });
  2429. exports.default = void 0;
  2430. var _LocalDatastoreController = _interopRequireDefault(_dereq_("./LocalDatastoreController.react-native"));
  2431. var _LocalDatastoreController2 = _interopRequireDefault(_dereq_("./LocalDatastoreController.default"));
  2432. let LocalDatastoreController = _LocalDatastoreController2.default;
  2433. module.exports = LocalDatastoreController;
  2434. var _default = exports.default = LocalDatastoreController;
  2435. },{"./LocalDatastoreController.default":14,"./LocalDatastoreController.react-native":16,"@babel/runtime-corejs3/core-js-stable/object/define-property":90,"@babel/runtime-corejs3/helpers/interopRequireDefault":103}],16:[function(_dereq_,module,exports){
  2436. "use strict";
  2437. var _Object$defineProperty = _dereq_("@babel/runtime-corejs3/core-js-stable/object/define-property");
  2438. var _interopRequireDefault = _dereq_("@babel/runtime-corejs3/helpers/interopRequireDefault");
  2439. _Object$defineProperty(exports, "__esModule", {
  2440. value: true
  2441. });
  2442. exports.default = void 0;
  2443. var _stringify = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/json/stringify"));
  2444. var _forEach = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/instance/for-each"));
  2445. var _map = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/instance/map"));
  2446. var _LocalDatastoreUtils = _dereq_("./LocalDatastoreUtils");
  2447. var _StorageController = _interopRequireDefault(_dereq_("./StorageController.react-native"));
  2448. const LocalDatastoreController = {
  2449. async fromPinWithName(name) {
  2450. const values = await _StorageController.default.getItemAsync(name);
  2451. if (!values) {
  2452. return [];
  2453. }
  2454. const objects = JSON.parse(values);
  2455. return objects;
  2456. },
  2457. async pinWithName(name, value) {
  2458. try {
  2459. const values = (0, _stringify.default)(value);
  2460. await _StorageController.default.setItemAsync(name, values);
  2461. } catch (e) {
  2462. // Quota exceeded, possibly due to Safari Private Browsing mode
  2463. console.error(e.message);
  2464. }
  2465. },
  2466. unPinWithName(name) {
  2467. return _StorageController.default.removeItemAsync(name);
  2468. },
  2469. async getAllContents() {
  2470. const keys = await _StorageController.default.getAllKeysAsync();
  2471. const batch = [];
  2472. for (let i = 0; i < keys.length; i += 1) {
  2473. const key = keys[i];
  2474. if ((0, _LocalDatastoreUtils.isLocalDatastoreKey)(key)) {
  2475. batch.push(key);
  2476. }
  2477. }
  2478. const LDS = {};
  2479. let results = [];
  2480. try {
  2481. results = await _StorageController.default.multiGet(batch);
  2482. } catch (error) {
  2483. console.error('Error getAllContents: ', error);
  2484. return {};
  2485. }
  2486. (0, _forEach.default)(results).call(results, pair => {
  2487. const [key, value] = pair;
  2488. try {
  2489. LDS[key] = JSON.parse(value);
  2490. } catch (error) {
  2491. LDS[key] = null;
  2492. }
  2493. });
  2494. return LDS;
  2495. },
  2496. // Used for testing
  2497. async getRawStorage() {
  2498. var _context;
  2499. const keys = await _StorageController.default.getAllKeysAsync();
  2500. const storage = {};
  2501. const results = await _StorageController.default.multiGet(keys);
  2502. (0, _map.default)(_context = results).call(_context, pair => {
  2503. const [key, value] = pair;
  2504. storage[key] = value;
  2505. });
  2506. return storage;
  2507. },
  2508. async clear() {
  2509. const keys = await _StorageController.default.getAllKeysAsync();
  2510. const batch = [];
  2511. for (let i = 0; i < keys.length; i += 1) {
  2512. const key = keys[i];
  2513. if ((0, _LocalDatastoreUtils.isLocalDatastoreKey)(key)) {
  2514. batch.push(key);
  2515. }
  2516. }
  2517. await _StorageController.default.multiRemove(batch).catch(error => console.error('Error clearing local datastore: ', error));
  2518. }
  2519. };
  2520. module.exports = LocalDatastoreController;
  2521. var _default = exports.default = LocalDatastoreController;
  2522. },{"./LocalDatastoreUtils":17,"./StorageController.react-native":47,"@babel/runtime-corejs3/core-js-stable/instance/for-each":74,"@babel/runtime-corejs3/core-js-stable/instance/map":78,"@babel/runtime-corejs3/core-js-stable/json/stringify":85,"@babel/runtime-corejs3/core-js-stable/object/define-property":90,"@babel/runtime-corejs3/helpers/interopRequireDefault":103}],17:[function(_dereq_,module,exports){
  2523. "use strict";
  2524. var _Object$defineProperty = _dereq_("@babel/runtime-corejs3/core-js-stable/object/define-property");
  2525. var _interopRequireDefault = _dereq_("@babel/runtime-corejs3/helpers/interopRequireDefault");
  2526. _Object$defineProperty(exports, "__esModule", {
  2527. value: true
  2528. });
  2529. exports.PIN_PREFIX = exports.OBJECT_PREFIX = exports.DEFAULT_PIN = void 0;
  2530. exports.isLocalDatastoreKey = isLocalDatastoreKey;
  2531. var _startsWith = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/instance/starts-with"));
  2532. const DEFAULT_PIN = exports.DEFAULT_PIN = '_default';
  2533. const PIN_PREFIX = exports.PIN_PREFIX = 'parsePin_';
  2534. const OBJECT_PREFIX = exports.OBJECT_PREFIX = 'Parse_LDS_';
  2535. function isLocalDatastoreKey(key) {
  2536. return !!(key && (key === DEFAULT_PIN || (0, _startsWith.default)(key).call(key, PIN_PREFIX) || (0, _startsWith.default)(key).call(key, OBJECT_PREFIX)));
  2537. }
  2538. },{"@babel/runtime-corejs3/core-js-stable/instance/starts-with":83,"@babel/runtime-corejs3/core-js-stable/object/define-property":90,"@babel/runtime-corejs3/helpers/interopRequireDefault":103}],18:[function(_dereq_,module,exports){
  2539. "use strict";
  2540. var _Object$defineProperty = _dereq_("@babel/runtime-corejs3/core-js-stable/object/define-property");
  2541. var _interopRequireDefault = _dereq_("@babel/runtime-corejs3/helpers/interopRequireDefault");
  2542. _Object$defineProperty(exports, "__esModule", {
  2543. value: true
  2544. });
  2545. exports.commitServerChanges = commitServerChanges;
  2546. exports.defaultState = defaultState;
  2547. exports.estimateAttribute = estimateAttribute;
  2548. exports.estimateAttributes = estimateAttributes;
  2549. exports.mergeFirstPendingState = mergeFirstPendingState;
  2550. exports.popPendingState = popPendingState;
  2551. exports.pushPendingState = pushPendingState;
  2552. exports.setPendingOp = setPendingOp;
  2553. exports.setServerData = setServerData;
  2554. var _includes = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/instance/includes"));
  2555. var _isArray = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/array/is-array"));
  2556. var _stringify = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/json/stringify"));
  2557. var _encode = _interopRequireDefault(_dereq_("./encode"));
  2558. var _CoreManager = _interopRequireDefault(_dereq_("./CoreManager"));
  2559. var _ParseFile = _interopRequireDefault(_dereq_("./ParseFile"));
  2560. var _ParseRelation = _interopRequireDefault(_dereq_("./ParseRelation"));
  2561. var _TaskQueue = _interopRequireDefault(_dereq_("./TaskQueue"));
  2562. var _ParseOp = _dereq_("./ParseOp");
  2563. function defaultState() {
  2564. return {
  2565. serverData: {},
  2566. pendingOps: [{}],
  2567. objectCache: {},
  2568. tasks: new _TaskQueue.default(),
  2569. existed: false
  2570. };
  2571. }
  2572. function setServerData(serverData, attributes) {
  2573. for (const attr in attributes) {
  2574. if (typeof attributes[attr] !== 'undefined') {
  2575. serverData[attr] = attributes[attr];
  2576. } else {
  2577. delete serverData[attr];
  2578. }
  2579. }
  2580. }
  2581. function setPendingOp(pendingOps, attr, op) {
  2582. const last = pendingOps.length - 1;
  2583. if (op) {
  2584. pendingOps[last][attr] = op;
  2585. } else {
  2586. delete pendingOps[last][attr];
  2587. }
  2588. }
  2589. function pushPendingState(pendingOps) {
  2590. pendingOps.push({});
  2591. }
  2592. function popPendingState(pendingOps) {
  2593. const first = pendingOps.shift();
  2594. if (!pendingOps.length) {
  2595. pendingOps[0] = {};
  2596. }
  2597. return first;
  2598. }
  2599. function mergeFirstPendingState(pendingOps) {
  2600. const first = popPendingState(pendingOps);
  2601. const next = pendingOps[0];
  2602. for (const attr in first) {
  2603. if (next[attr] && first[attr]) {
  2604. const merged = next[attr].mergeWith(first[attr]);
  2605. if (merged) {
  2606. next[attr] = merged;
  2607. }
  2608. } else {
  2609. next[attr] = first[attr];
  2610. }
  2611. }
  2612. }
  2613. function estimateAttribute(serverData, pendingOps, object, attr) {
  2614. let value = serverData[attr];
  2615. for (let i = 0; i < pendingOps.length; i++) {
  2616. if (pendingOps[i][attr]) {
  2617. if (pendingOps[i][attr] instanceof _ParseOp.RelationOp) {
  2618. if (object.id) {
  2619. value = pendingOps[i][attr].applyTo(value, object, attr);
  2620. }
  2621. } else {
  2622. value = pendingOps[i][attr].applyTo(value);
  2623. }
  2624. }
  2625. }
  2626. return value;
  2627. }
  2628. function estimateAttributes(serverData, pendingOps, object) {
  2629. const data = {};
  2630. for (var attr in serverData) {
  2631. data[attr] = serverData[attr];
  2632. }
  2633. for (let i = 0; i < pendingOps.length; i++) {
  2634. for (attr in pendingOps[i]) {
  2635. if (pendingOps[i][attr] instanceof _ParseOp.RelationOp) {
  2636. if (object.id) {
  2637. data[attr] = pendingOps[i][attr].applyTo(data[attr], object, attr);
  2638. }
  2639. } else {
  2640. if ((0, _includes.default)(attr).call(attr, '.')) {
  2641. // similar to nestedSet function
  2642. const fields = attr.split('.');
  2643. const last = fields[fields.length - 1];
  2644. let object = data;
  2645. for (let i = 0; i < fields.length - 1; i++) {
  2646. const key = fields[i];
  2647. if (!(key in object)) {
  2648. const nextKey = fields[i + 1];
  2649. if (!isNaN(nextKey)) {
  2650. object[key] = [];
  2651. } else {
  2652. object[key] = {};
  2653. }
  2654. } else {
  2655. if ((0, _isArray.default)(object[key])) {
  2656. object[key] = [...object[key]];
  2657. } else {
  2658. object[key] = {
  2659. ...object[key]
  2660. };
  2661. }
  2662. }
  2663. object = object[key];
  2664. }
  2665. object[last] = pendingOps[i][attr].applyTo(object[last]);
  2666. } else {
  2667. data[attr] = pendingOps[i][attr].applyTo(data[attr]);
  2668. }
  2669. }
  2670. }
  2671. }
  2672. return data;
  2673. }
  2674. /**
  2675. * Allows setting properties/variables deep in an object.
  2676. * Converts a.b into { a: { b: value } } for dot notation on Objects
  2677. * Converts a.0.b into { a: [{ b: value }] } for dot notation on Arrays
  2678. *
  2679. * @param obj The object to assign the value to
  2680. * @param key The key to assign. If it's in a deeper path, then use dot notation (`prop1.prop2.prop3`)
  2681. * Note that intermediate object(s) in the nested path are automatically created if they don't exist.
  2682. * @param value The value to assign. If it's an `undefined` then the key is deleted.
  2683. */
  2684. function nestedSet(obj, key, value) {
  2685. const paths = key.split('.');
  2686. for (let i = 0; i < paths.length - 1; i++) {
  2687. const path = paths[i];
  2688. if (!(path in obj)) {
  2689. const nextPath = paths[i + 1];
  2690. if (!isNaN(nextPath)) {
  2691. obj[path] = [];
  2692. } else {
  2693. obj[path] = {};
  2694. }
  2695. }
  2696. obj = obj[path];
  2697. }
  2698. if (typeof value === 'undefined') {
  2699. delete obj[paths[paths.length - 1]];
  2700. } else {
  2701. obj[paths[paths.length - 1]] = value;
  2702. }
  2703. }
  2704. function commitServerChanges(serverData, objectCache, changes) {
  2705. const ParseObject = _CoreManager.default.getParseObject();
  2706. for (const attr in changes) {
  2707. const val = changes[attr];
  2708. nestedSet(serverData, attr, val);
  2709. if (val && typeof val === 'object' && !(val instanceof ParseObject) && !(val instanceof _ParseFile.default) && !(val instanceof _ParseRelation.default)) {
  2710. const json = (0, _encode.default)(val, false, true);
  2711. objectCache[attr] = (0, _stringify.default)(json);
  2712. }
  2713. }
  2714. }
  2715. },{"./CoreManager":4,"./ParseFile":25,"./ParseOp":31,"./ParseRelation":34,"./TaskQueue":49,"./encode":56,"@babel/runtime-corejs3/core-js-stable/array/is-array":66,"@babel/runtime-corejs3/core-js-stable/instance/includes":75,"@babel/runtime-corejs3/core-js-stable/json/stringify":85,"@babel/runtime-corejs3/core-js-stable/object/define-property":90,"@babel/runtime-corejs3/helpers/interopRequireDefault":103}],19:[function(_dereq_,module,exports){
  2716. "use strict";
  2717. var _Object$defineProperty = _dereq_("@babel/runtime-corejs3/core-js-stable/object/define-property");
  2718. var _interopRequireDefault = _dereq_("@babel/runtime-corejs3/helpers/interopRequireDefault");
  2719. _Object$defineProperty(exports, "__esModule", {
  2720. value: true
  2721. });
  2722. exports.default = void 0;
  2723. var _isArray = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/array/is-array"));
  2724. var _indexOf = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/instance/index-of"));
  2725. var _filter = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/instance/filter"));
  2726. var _slice = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/instance/slice"));
  2727. var _isInteger = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/number/is-integer"));
  2728. var _map = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/instance/map"));
  2729. var _forEach = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/instance/for-each"));
  2730. var _keys = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/object/keys"));
  2731. var _equals = _interopRequireDefault(_dereq_("./equals"));
  2732. var _decode = _interopRequireDefault(_dereq_("./decode"));
  2733. var _ParseError = _interopRequireDefault(_dereq_("./ParseError"));
  2734. var _ParsePolygon = _interopRequireDefault(_dereq_("./ParsePolygon"));
  2735. var _ParseGeoPoint = _interopRequireDefault(_dereq_("./ParseGeoPoint"));
  2736. /**
  2737. * contains -- Determines if an object is contained in a list with special handling for Parse pointers.
  2738. *
  2739. * @param haystack
  2740. * @param needle
  2741. * @private
  2742. * @returns {boolean}
  2743. */
  2744. function contains(haystack, needle) {
  2745. if (needle && needle.__type && (needle.__type === 'Pointer' || needle.__type === 'Object')) {
  2746. for (const i in haystack) {
  2747. const ptr = haystack[i];
  2748. if (typeof ptr === 'string' && ptr === needle.objectId) {
  2749. return true;
  2750. }
  2751. if (ptr.className === needle.className && ptr.objectId === needle.objectId) {
  2752. return true;
  2753. }
  2754. }
  2755. return false;
  2756. }
  2757. if ((0, _isArray.default)(needle)) {
  2758. for (const need of needle) {
  2759. if (contains(haystack, need)) {
  2760. return true;
  2761. }
  2762. }
  2763. }
  2764. return (0, _indexOf.default)(haystack).call(haystack, needle) > -1;
  2765. }
  2766. function transformObject(object) {
  2767. if (object._toFullJSON) {
  2768. return object._toFullJSON();
  2769. }
  2770. return object;
  2771. }
  2772. /**
  2773. * matchesQuery -- Determines if an object would be returned by a Parse Query
  2774. * It's a lightweight, where-clause only implementation of a full query engine.
  2775. * Since we find queries that match objects, rather than objects that match
  2776. * queries, we can avoid building a full-blown query tool.
  2777. *
  2778. * @param className
  2779. * @param object
  2780. * @param objects
  2781. * @param query
  2782. * @private
  2783. * @returns {boolean}
  2784. */
  2785. function matchesQuery(className, object, objects, query) {
  2786. if (object.className !== className) {
  2787. return false;
  2788. }
  2789. let obj = object;
  2790. let q = query;
  2791. if (object.toJSON) {
  2792. obj = object.toJSON();
  2793. }
  2794. if (query.toJSON) {
  2795. q = query.toJSON().where;
  2796. }
  2797. obj.className = className;
  2798. for (const field in q) {
  2799. if (!matchesKeyConstraints(className, obj, objects, field, q[field])) {
  2800. return false;
  2801. }
  2802. }
  2803. return true;
  2804. }
  2805. function equalObjectsGeneric(obj, compareTo, eqlFn) {
  2806. if ((0, _isArray.default)(obj)) {
  2807. for (let i = 0; i < obj.length; i++) {
  2808. if (eqlFn(obj[i], compareTo)) {
  2809. return true;
  2810. }
  2811. }
  2812. return false;
  2813. }
  2814. return eqlFn(obj, compareTo);
  2815. }
  2816. /**
  2817. * @typedef RelativeTimeToDateResult
  2818. * @property {string} status The conversion status, `error` if conversion failed or
  2819. * `success` if conversion succeeded.
  2820. * @property {string} info The error message if conversion failed, or the relative
  2821. * time indication (`past`, `present`, `future`) if conversion succeeded.
  2822. * @property {Date|undefined} result The converted date, or `undefined` if conversion
  2823. * failed.
  2824. */
  2825. /**
  2826. * Converts human readable relative date string, for example, 'in 10 days' to a date
  2827. * relative to now.
  2828. *
  2829. * @param {string} text The text to convert.
  2830. * @param {Date} [now] The date from which add or subtract. Default is now.
  2831. * @returns {RelativeTimeToDateResult}
  2832. */
  2833. function relativeTimeToDate(text) {
  2834. let now = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : new Date();
  2835. text = text.toLowerCase();
  2836. let parts = text.split(' ');
  2837. // Filter out whitespace
  2838. parts = (0, _filter.default)(parts).call(parts, part => part !== '');
  2839. const future = parts[0] === 'in';
  2840. const past = parts[parts.length - 1] === 'ago';
  2841. if (!future && !past && text !== 'now') {
  2842. return {
  2843. status: 'error',
  2844. info: "Time should either start with 'in' or end with 'ago'"
  2845. };
  2846. }
  2847. if (future && past) {
  2848. return {
  2849. status: 'error',
  2850. info: "Time cannot have both 'in' and 'ago'"
  2851. };
  2852. }
  2853. // strip the 'ago' or 'in'
  2854. if (future) {
  2855. parts = (0, _slice.default)(parts).call(parts, 1);
  2856. } else {
  2857. // past
  2858. parts = (0, _slice.default)(parts).call(parts, 0, parts.length - 1);
  2859. }
  2860. if (parts.length % 2 !== 0 && text !== 'now') {
  2861. return {
  2862. status: 'error',
  2863. info: 'Invalid time string. Dangling unit or number.'
  2864. };
  2865. }
  2866. const pairs = [];
  2867. while (parts.length) {
  2868. pairs.push([parts.shift(), parts.shift()]);
  2869. }
  2870. let seconds = 0;
  2871. for (const [num, interval] of pairs) {
  2872. const val = Number(num);
  2873. if (!(0, _isInteger.default)(val)) {
  2874. return {
  2875. status: 'error',
  2876. info: `'${num}' is not an integer.`
  2877. };
  2878. }
  2879. switch (interval) {
  2880. case 'yr':
  2881. case 'yrs':
  2882. case 'year':
  2883. case 'years':
  2884. seconds += val * 31536000; // 365 * 24 * 60 * 60
  2885. break;
  2886. case 'wk':
  2887. case 'wks':
  2888. case 'week':
  2889. case 'weeks':
  2890. seconds += val * 604800; // 7 * 24 * 60 * 60
  2891. break;
  2892. case 'd':
  2893. case 'day':
  2894. case 'days':
  2895. seconds += val * 86400; // 24 * 60 * 60
  2896. break;
  2897. case 'hr':
  2898. case 'hrs':
  2899. case 'hour':
  2900. case 'hours':
  2901. seconds += val * 3600; // 60 * 60
  2902. break;
  2903. case 'min':
  2904. case 'mins':
  2905. case 'minute':
  2906. case 'minutes':
  2907. seconds += val * 60;
  2908. break;
  2909. case 'sec':
  2910. case 'secs':
  2911. case 'second':
  2912. case 'seconds':
  2913. seconds += val;
  2914. break;
  2915. default:
  2916. return {
  2917. status: 'error',
  2918. info: `Invalid interval: '${interval}'`
  2919. };
  2920. }
  2921. }
  2922. const milliseconds = seconds * 1000;
  2923. if (future) {
  2924. return {
  2925. status: 'success',
  2926. info: 'future',
  2927. result: new Date(now.valueOf() + milliseconds)
  2928. };
  2929. } else if (past) {
  2930. return {
  2931. status: 'success',
  2932. info: 'past',
  2933. result: new Date(now.valueOf() - milliseconds)
  2934. };
  2935. } else {
  2936. return {
  2937. status: 'success',
  2938. info: 'present',
  2939. result: new Date(now.valueOf())
  2940. };
  2941. }
  2942. }
  2943. /**
  2944. * Determines whether an object matches a single key's constraints
  2945. *
  2946. * @param className
  2947. * @param object
  2948. * @param objects
  2949. * @param key
  2950. * @param constraints
  2951. * @private
  2952. * @returns {boolean}
  2953. */
  2954. function matchesKeyConstraints(className, object, objects, key, constraints) {
  2955. if (constraints === null) {
  2956. return false;
  2957. }
  2958. if ((0, _indexOf.default)(key).call(key, '.') >= 0) {
  2959. // Key references a subobject
  2960. const keyComponents = key.split('.');
  2961. const subObjectKey = keyComponents[0];
  2962. const keyRemainder = (0, _slice.default)(keyComponents).call(keyComponents, 1).join('.');
  2963. return matchesKeyConstraints(className, object[subObjectKey] || {}, objects, keyRemainder, constraints);
  2964. }
  2965. let i;
  2966. if (key === '$or') {
  2967. for (i = 0; i < constraints.length; i++) {
  2968. if (matchesQuery(className, object, objects, constraints[i])) {
  2969. return true;
  2970. }
  2971. }
  2972. return false;
  2973. }
  2974. if (key === '$and') {
  2975. for (i = 0; i < constraints.length; i++) {
  2976. if (!matchesQuery(className, object, objects, constraints[i])) {
  2977. return false;
  2978. }
  2979. }
  2980. return true;
  2981. }
  2982. if (key === '$nor') {
  2983. for (i = 0; i < constraints.length; i++) {
  2984. if (matchesQuery(className, object, objects, constraints[i])) {
  2985. return false;
  2986. }
  2987. }
  2988. return true;
  2989. }
  2990. if (key === '$relatedTo') {
  2991. // Bail! We can't handle relational queries locally
  2992. return false;
  2993. }
  2994. if (!/^[A-Za-z][0-9A-Za-z_]*$/.test(key)) {
  2995. throw new _ParseError.default(_ParseError.default.INVALID_KEY_NAME, `Invalid Key: ${key}`);
  2996. }
  2997. // Equality (or Array contains) cases
  2998. if (typeof constraints !== 'object') {
  2999. if ((0, _isArray.default)(object[key])) {
  3000. var _context;
  3001. return (0, _indexOf.default)(_context = object[key]).call(_context, constraints) > -1;
  3002. }
  3003. return object[key] === constraints;
  3004. }
  3005. let compareTo;
  3006. if (constraints.__type) {
  3007. if (constraints.__type === 'Pointer') {
  3008. return equalObjectsGeneric(object[key], constraints, function (obj, ptr) {
  3009. return typeof obj !== 'undefined' && ptr.className === obj.className && ptr.objectId === obj.objectId;
  3010. });
  3011. }
  3012. return equalObjectsGeneric((0, _decode.default)(object[key]), (0, _decode.default)(constraints), _equals.default);
  3013. }
  3014. // More complex cases
  3015. for (const condition in constraints) {
  3016. compareTo = constraints[condition];
  3017. if (compareTo?.__type) {
  3018. compareTo = (0, _decode.default)(compareTo);
  3019. }
  3020. // is it a $relativeTime? convert to date
  3021. if (compareTo?.['$relativeTime']) {
  3022. const parserResult = relativeTimeToDate(compareTo['$relativeTime']);
  3023. if (parserResult.status !== 'success') {
  3024. throw new _ParseError.default(_ParseError.default.INVALID_JSON, `bad $relativeTime (${key}) value. ${parserResult.info}`);
  3025. }
  3026. compareTo = parserResult.result;
  3027. }
  3028. // Compare Date Object or Date String
  3029. if (toString.call(compareTo) === '[object Date]' || typeof compareTo === 'string' &&
  3030. // @ts-ignore
  3031. new Date(compareTo) !== 'Invalid Date' &&
  3032. // @ts-ignore
  3033. !isNaN(new Date(compareTo))) {
  3034. object[key] = new Date(object[key].iso ? object[key].iso : object[key]);
  3035. }
  3036. switch (condition) {
  3037. case '$lt':
  3038. if (object[key] >= compareTo) {
  3039. return false;
  3040. }
  3041. break;
  3042. case '$lte':
  3043. if (object[key] > compareTo) {
  3044. return false;
  3045. }
  3046. break;
  3047. case '$gt':
  3048. if (object[key] <= compareTo) {
  3049. return false;
  3050. }
  3051. break;
  3052. case '$gte':
  3053. if (object[key] < compareTo) {
  3054. return false;
  3055. }
  3056. break;
  3057. case '$ne':
  3058. if ((0, _equals.default)(object[key], compareTo)) {
  3059. return false;
  3060. }
  3061. break;
  3062. case '$in':
  3063. if (!contains(compareTo, object[key])) {
  3064. return false;
  3065. }
  3066. break;
  3067. case '$nin':
  3068. if (contains(compareTo, object[key])) {
  3069. return false;
  3070. }
  3071. break;
  3072. case '$all':
  3073. for (i = 0; i < compareTo.length; i++) {
  3074. var _context2;
  3075. if ((0, _indexOf.default)(_context2 = object[key]).call(_context2, compareTo[i]) < 0) {
  3076. return false;
  3077. }
  3078. }
  3079. break;
  3080. case '$exists':
  3081. {
  3082. const propertyExists = typeof object[key] !== 'undefined';
  3083. const existenceIsRequired = constraints['$exists'];
  3084. if (typeof constraints['$exists'] !== 'boolean') {
  3085. // The SDK will never submit a non-boolean for $exists, but if someone
  3086. // tries to submit a non-boolean for $exits outside the SDKs, just ignore it.
  3087. break;
  3088. }
  3089. if (!propertyExists && existenceIsRequired || propertyExists && !existenceIsRequired) {
  3090. return false;
  3091. }
  3092. break;
  3093. }
  3094. case '$regex':
  3095. {
  3096. if (typeof compareTo === 'object') {
  3097. return compareTo.test(object[key]);
  3098. }
  3099. // JS doesn't support perl-style escaping
  3100. let expString = '';
  3101. let escapeEnd = -2;
  3102. let escapeStart = (0, _indexOf.default)(compareTo).call(compareTo, '\\Q');
  3103. while (escapeStart > -1) {
  3104. // Add the unescaped portion
  3105. expString += compareTo.substring(escapeEnd + 2, escapeStart);
  3106. escapeEnd = (0, _indexOf.default)(compareTo).call(compareTo, '\\E', escapeStart);
  3107. if (escapeEnd > -1) {
  3108. expString += compareTo.substring(escapeStart + 2, escapeEnd).replace(/\\\\\\\\E/g, '\\E').replace(/\W/g, '\\$&');
  3109. }
  3110. escapeStart = (0, _indexOf.default)(compareTo).call(compareTo, '\\Q', escapeEnd);
  3111. }
  3112. expString += compareTo.substring(Math.max(escapeStart, escapeEnd + 2));
  3113. let modifiers = constraints.$options || '';
  3114. modifiers = modifiers.replace('x', '').replace('s', '');
  3115. // Parse Server / Mongo support x and s modifiers but JS RegExp doesn't
  3116. const exp = new RegExp(expString, modifiers);
  3117. if (!exp.test(object[key])) {
  3118. return false;
  3119. }
  3120. break;
  3121. }
  3122. case '$nearSphere':
  3123. {
  3124. if (!compareTo || !object[key]) {
  3125. return false;
  3126. }
  3127. const distance = compareTo.radiansTo(object[key]);
  3128. const max = constraints.$maxDistance || Infinity;
  3129. return distance <= max;
  3130. }
  3131. case '$within':
  3132. {
  3133. if (!compareTo || !object[key]) {
  3134. return false;
  3135. }
  3136. const southWest = compareTo.$box[0];
  3137. const northEast = compareTo.$box[1];
  3138. if (southWest.latitude > northEast.latitude || southWest.longitude > northEast.longitude) {
  3139. // Invalid box, crosses the date line
  3140. return false;
  3141. }
  3142. return object[key].latitude > southWest.latitude && object[key].latitude < northEast.latitude && object[key].longitude > southWest.longitude && object[key].longitude < northEast.longitude;
  3143. }
  3144. case '$options':
  3145. // Not a query type, but a way to add options to $regex. Ignore and
  3146. // avoid the default
  3147. break;
  3148. case '$maxDistance':
  3149. // Not a query type, but a way to add a cap to $nearSphere. Ignore and
  3150. // avoid the default
  3151. break;
  3152. case '$select':
  3153. {
  3154. const subQueryObjects = (0, _filter.default)(objects).call(objects, (obj, index, arr) => {
  3155. return matchesQuery(compareTo.query.className, obj, arr, compareTo.query.where);
  3156. });
  3157. for (let i = 0; i < subQueryObjects.length; i += 1) {
  3158. const subObject = transformObject(subQueryObjects[i]);
  3159. return (0, _equals.default)(object[key], subObject[compareTo.key]);
  3160. }
  3161. return false;
  3162. }
  3163. case '$dontSelect':
  3164. {
  3165. const subQueryObjects = (0, _filter.default)(objects).call(objects, (obj, index, arr) => {
  3166. return matchesQuery(compareTo.query.className, obj, arr, compareTo.query.where);
  3167. });
  3168. for (let i = 0; i < subQueryObjects.length; i += 1) {
  3169. const subObject = transformObject(subQueryObjects[i]);
  3170. return !(0, _equals.default)(object[key], subObject[compareTo.key]);
  3171. }
  3172. return false;
  3173. }
  3174. case '$inQuery':
  3175. {
  3176. const subQueryObjects = (0, _filter.default)(objects).call(objects, (obj, index, arr) => {
  3177. return matchesQuery(compareTo.className, obj, arr, compareTo.where);
  3178. });
  3179. for (let i = 0; i < subQueryObjects.length; i += 1) {
  3180. const subObject = transformObject(subQueryObjects[i]);
  3181. if (object[key].className === subObject.className && object[key].objectId === subObject.objectId) {
  3182. return true;
  3183. }
  3184. }
  3185. return false;
  3186. }
  3187. case '$notInQuery':
  3188. {
  3189. const subQueryObjects = (0, _filter.default)(objects).call(objects, (obj, index, arr) => {
  3190. return matchesQuery(compareTo.className, obj, arr, compareTo.where);
  3191. });
  3192. for (let i = 0; i < subQueryObjects.length; i += 1) {
  3193. const subObject = transformObject(subQueryObjects[i]);
  3194. if (object[key].className === subObject.className && object[key].objectId === subObject.objectId) {
  3195. return false;
  3196. }
  3197. }
  3198. return true;
  3199. }
  3200. case '$containedBy':
  3201. {
  3202. for (const value of object[key]) {
  3203. if (!contains(compareTo, value)) {
  3204. return false;
  3205. }
  3206. }
  3207. return true;
  3208. }
  3209. case '$geoWithin':
  3210. {
  3211. if (compareTo.$polygon) {
  3212. var _context3;
  3213. const points = (0, _map.default)(_context3 = compareTo.$polygon).call(_context3, geoPoint => [geoPoint.latitude, geoPoint.longitude]);
  3214. const polygon = new _ParsePolygon.default(points);
  3215. return polygon.containsPoint(object[key]);
  3216. }
  3217. if (compareTo.$centerSphere) {
  3218. const [WGS84Point, maxDistance] = compareTo.$centerSphere;
  3219. const centerPoint = new _ParseGeoPoint.default({
  3220. latitude: WGS84Point[1],
  3221. longitude: WGS84Point[0]
  3222. });
  3223. const point = new _ParseGeoPoint.default(object[key]);
  3224. const distance = point.radiansTo(centerPoint);
  3225. return distance <= maxDistance;
  3226. }
  3227. return false;
  3228. }
  3229. case '$geoIntersects':
  3230. {
  3231. const polygon = new _ParsePolygon.default(object[key].coordinates);
  3232. const point = new _ParseGeoPoint.default(compareTo.$point);
  3233. return polygon.containsPoint(point);
  3234. }
  3235. default:
  3236. return false;
  3237. }
  3238. }
  3239. return true;
  3240. }
  3241. function validateQuery(query) {
  3242. var _context4;
  3243. let q = query;
  3244. if (query.toJSON) {
  3245. q = query.toJSON().where;
  3246. }
  3247. const specialQuerykeys = ['$and', '$or', '$nor', '_rperm', '_wperm', '_perishable_token', '_email_verify_token', '_email_verify_token_expires_at', '_account_lockout_expires_at', '_failed_login_count'];
  3248. (0, _forEach.default)(_context4 = (0, _keys.default)(q)).call(_context4, key => {
  3249. if (q && q[key] && q[key].$regex) {
  3250. if (typeof q[key].$options === 'string') {
  3251. if (!q[key].$options.match(/^[imxs]+$/)) {
  3252. throw new _ParseError.default(_ParseError.default.INVALID_QUERY, `Bad $options value for query: ${q[key].$options}`);
  3253. }
  3254. }
  3255. }
  3256. if ((0, _indexOf.default)(specialQuerykeys).call(specialQuerykeys, key) < 0 && !key.match(/^[a-zA-Z][a-zA-Z0-9_\.]*$/)) {
  3257. throw new _ParseError.default(_ParseError.default.INVALID_KEY_NAME, `Invalid key name: ${key}`);
  3258. }
  3259. });
  3260. }
  3261. const OfflineQuery = {
  3262. matchesQuery: matchesQuery,
  3263. validateQuery: validateQuery
  3264. };
  3265. module.exports = OfflineQuery;
  3266. var _default = exports.default = OfflineQuery;
  3267. },{"./ParseError":24,"./ParseGeoPoint":26,"./ParsePolygon":32,"./decode":55,"./equals":57,"@babel/runtime-corejs3/core-js-stable/array/is-array":66,"@babel/runtime-corejs3/core-js-stable/instance/filter":71,"@babel/runtime-corejs3/core-js-stable/instance/for-each":74,"@babel/runtime-corejs3/core-js-stable/instance/index-of":76,"@babel/runtime-corejs3/core-js-stable/instance/map":78,"@babel/runtime-corejs3/core-js-stable/instance/slice":80,"@babel/runtime-corejs3/core-js-stable/number/is-integer":87,"@babel/runtime-corejs3/core-js-stable/object/define-property":90,"@babel/runtime-corejs3/core-js-stable/object/keys":95,"@babel/runtime-corejs3/helpers/interopRequireDefault":103}],20:[function(_dereq_,module,exports){
  3268. (function (process){(function (){
  3269. "use strict";
  3270. var _WeakMap = _dereq_("@babel/runtime-corejs3/core-js-stable/weak-map");
  3271. var _Object$defineProperty = _dereq_("@babel/runtime-corejs3/core-js-stable/object/define-property");
  3272. var _Object$getOwnPropertyDescriptor = _dereq_("@babel/runtime-corejs3/core-js-stable/object/get-own-property-descriptor");
  3273. var _interopRequireDefault = _dereq_("@babel/runtime-corejs3/helpers/interopRequireDefault");
  3274. _Object$defineProperty(exports, "__esModule", {
  3275. value: true
  3276. });
  3277. exports.default = void 0;
  3278. var _promise = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/promise"));
  3279. var _decode2 = _interopRequireDefault(_dereq_("./decode"));
  3280. var _encode2 = _interopRequireDefault(_dereq_("./encode"));
  3281. var _CryptoController = _interopRequireDefault(_dereq_("./CryptoController"));
  3282. var _EventuallyQueue = _interopRequireDefault(_dereq_("./EventuallyQueue"));
  3283. var _IndexedDBStorageController = _interopRequireDefault(_dereq_("./IndexedDBStorageController"));
  3284. var _InstallationController = _interopRequireDefault(_dereq_("./InstallationController"));
  3285. var ParseOp = _interopRequireWildcard(_dereq_("./ParseOp"));
  3286. var _RESTController = _interopRequireDefault(_dereq_("./RESTController"));
  3287. var _ParseACL = _interopRequireDefault(_dereq_("./ParseACL"));
  3288. var Analytics = _interopRequireWildcard(_dereq_("./Analytics"));
  3289. var _AnonymousUtils = _interopRequireDefault(_dereq_("./AnonymousUtils"));
  3290. var Cloud = _interopRequireWildcard(_dereq_("./Cloud"));
  3291. var _ParseCLP = _interopRequireDefault(_dereq_("./ParseCLP"));
  3292. var _CoreManager = _interopRequireDefault(_dereq_("./CoreManager"));
  3293. var _EventEmitter = _interopRequireDefault(_dereq_("./EventEmitter"));
  3294. var _ParseConfig = _interopRequireDefault(_dereq_("./ParseConfig"));
  3295. var _ParseError = _interopRequireDefault(_dereq_("./ParseError"));
  3296. var _FacebookUtils = _interopRequireDefault(_dereq_("./FacebookUtils"));
  3297. var _ParseFile = _interopRequireDefault(_dereq_("./ParseFile"));
  3298. var Hooks = _interopRequireWildcard(_dereq_("./ParseHooks"));
  3299. var _ParseGeoPoint = _interopRequireDefault(_dereq_("./ParseGeoPoint"));
  3300. var _ParsePolygon = _interopRequireDefault(_dereq_("./ParsePolygon"));
  3301. var _ParseInstallation = _interopRequireDefault(_dereq_("./ParseInstallation"));
  3302. var _LocalDatastore = _interopRequireDefault(_dereq_("./LocalDatastore"));
  3303. var _ParseObject = _interopRequireDefault(_dereq_("./ParseObject"));
  3304. var Push = _interopRequireWildcard(_dereq_("./Push"));
  3305. var _ParseQuery = _interopRequireDefault(_dereq_("./ParseQuery"));
  3306. var _ParseRelation = _interopRequireDefault(_dereq_("./ParseRelation"));
  3307. var _ParseRole = _interopRequireDefault(_dereq_("./ParseRole"));
  3308. var _ParseSchema = _interopRequireDefault(_dereq_("./ParseSchema"));
  3309. var _ParseSession = _interopRequireDefault(_dereq_("./ParseSession"));
  3310. var _Storage = _interopRequireDefault(_dereq_("./Storage"));
  3311. var _ParseUser = _interopRequireDefault(_dereq_("./ParseUser"));
  3312. var _ParseLiveQuery = _interopRequireDefault(_dereq_("./ParseLiveQuery"));
  3313. var _LiveQueryClient = _interopRequireDefault(_dereq_("./LiveQueryClient"));
  3314. var _LocalDatastoreController = _interopRequireDefault(_dereq_("./LocalDatastoreController"));
  3315. var _StorageController = _interopRequireDefault(_dereq_("./StorageController"));
  3316. var _WebSocketController = _interopRequireDefault(_dereq_("./WebSocketController"));
  3317. function _getRequireWildcardCache(e) {
  3318. if ("function" != typeof _WeakMap) return null;
  3319. var r = new _WeakMap(),
  3320. t = new _WeakMap();
  3321. return (_getRequireWildcardCache = function (e) {
  3322. return e ? t : r;
  3323. })(e);
  3324. }
  3325. function _interopRequireWildcard(e, r) {
  3326. if (!r && e && e.__esModule) return e;
  3327. if (null === e || "object" != typeof e && "function" != typeof e) return {
  3328. default: e
  3329. };
  3330. var t = _getRequireWildcardCache(r);
  3331. if (t && t.has(e)) return t.get(e);
  3332. var n = {
  3333. __proto__: null
  3334. };
  3335. for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) {
  3336. var i = _Object$defineProperty && _Object$getOwnPropertyDescriptor ? _Object$getOwnPropertyDescriptor(e, u) : null;
  3337. i && (i.get || i.set) ? _Object$defineProperty(n, u, i) : n[u] = e[u];
  3338. }
  3339. return n.default = e, t && t.set(e, n), n;
  3340. }
  3341. /**
  3342. * Contains all Parse API classes and functions.
  3343. *
  3344. * @static
  3345. * @global
  3346. * @class
  3347. * @hideconstructor
  3348. */
  3349. const Parse = {
  3350. ACL: _ParseACL.default,
  3351. Analytics: Analytics,
  3352. AnonymousUtils: _AnonymousUtils.default,
  3353. Cloud: Cloud,
  3354. CLP: _ParseCLP.default,
  3355. CoreManager: _CoreManager.default,
  3356. Config: _ParseConfig.default,
  3357. Error: _ParseError.default,
  3358. FacebookUtils: _FacebookUtils.default,
  3359. File: _ParseFile.default,
  3360. GeoPoint: _ParseGeoPoint.default,
  3361. Polygon: _ParsePolygon.default,
  3362. Installation: _ParseInstallation.default,
  3363. LocalDatastore: _LocalDatastore.default,
  3364. Object: _ParseObject.default,
  3365. Op: {
  3366. Set: ParseOp.SetOp,
  3367. Unset: ParseOp.UnsetOp,
  3368. Increment: ParseOp.IncrementOp,
  3369. Add: ParseOp.AddOp,
  3370. Remove: ParseOp.RemoveOp,
  3371. AddUnique: ParseOp.AddUniqueOp,
  3372. Relation: ParseOp.RelationOp
  3373. },
  3374. Push: Push,
  3375. Query: _ParseQuery.default,
  3376. Relation: _ParseRelation.default,
  3377. Role: _ParseRole.default,
  3378. Schema: _ParseSchema.default,
  3379. Session: _ParseSession.default,
  3380. Storage: _Storage.default,
  3381. User: _ParseUser.default,
  3382. LiveQueryClient: _LiveQueryClient.default,
  3383. IndexedDB: undefined,
  3384. Hooks: undefined,
  3385. Parse: undefined,
  3386. /**
  3387. * @member {EventuallyQueue} Parse.EventuallyQueue
  3388. * @static
  3389. */
  3390. set EventuallyQueue(queue) {
  3391. _CoreManager.default.setEventuallyQueue(queue);
  3392. },
  3393. get EventuallyQueue() {
  3394. return _CoreManager.default.getEventuallyQueue();
  3395. },
  3396. /**
  3397. * Call this method first to set up your authentication tokens for Parse.
  3398. *
  3399. * @param {string} applicationId Your Parse Application ID.
  3400. * @param {string} [javaScriptKey] Your Parse JavaScript Key (Not needed for parse-server)
  3401. * @param {string} [masterKey] Your Parse Master Key. (Node.js only!)
  3402. * @static
  3403. */
  3404. initialize(applicationId, javaScriptKey) {
  3405. if ("browser" === 'browser' && _CoreManager.default.get('IS_NODE') && !process.env.SERVER_RENDERING) {
  3406. /* eslint-disable no-console */
  3407. 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.");
  3408. /* eslint-enable no-console */
  3409. }
  3410. Parse._initialize(applicationId, javaScriptKey);
  3411. },
  3412. _initialize(applicationId, javaScriptKey, masterKey) {
  3413. _CoreManager.default.set('APPLICATION_ID', applicationId);
  3414. _CoreManager.default.set('JAVASCRIPT_KEY', javaScriptKey);
  3415. _CoreManager.default.set('MASTER_KEY', masterKey);
  3416. _CoreManager.default.set('USE_MASTER_KEY', false);
  3417. _CoreManager.default.setIfNeeded('EventEmitter', _EventEmitter.default);
  3418. _CoreManager.default.setIfNeeded('LiveQuery', new _ParseLiveQuery.default());
  3419. _CoreManager.default.setIfNeeded('CryptoController', _CryptoController.default);
  3420. _CoreManager.default.setIfNeeded('EventuallyQueue', _EventuallyQueue.default);
  3421. _CoreManager.default.setIfNeeded('InstallationController', _InstallationController.default);
  3422. _CoreManager.default.setIfNeeded('LocalDatastoreController', _LocalDatastoreController.default);
  3423. _CoreManager.default.setIfNeeded('StorageController', _StorageController.default);
  3424. _CoreManager.default.setIfNeeded('WebSocketController', _WebSocketController.default);
  3425. Parse.IndexedDB = _CoreManager.default.setIfNeeded('IndexedDBStorageController', _IndexedDBStorageController.default);
  3426. },
  3427. /**
  3428. * Call this method to set your AsyncStorage engine
  3429. * Starting Parse@1.11, the ParseSDK do not provide a React AsyncStorage as the ReactNative module
  3430. * is not provided at a stable path and changes over versions.
  3431. *
  3432. * @param {AsyncStorage} storage a react native async storage.
  3433. * @static
  3434. */
  3435. setAsyncStorage(storage) {
  3436. _CoreManager.default.setAsyncStorage(storage);
  3437. },
  3438. /**
  3439. * Call this method to set your LocalDatastoreStorage engine
  3440. * If using React-Native use {@link Parse.setAsyncStorage Parse.setAsyncStorage()}
  3441. *
  3442. * @param {LocalDatastoreController} controller a data storage.
  3443. * @static
  3444. */
  3445. setLocalDatastoreController(controller) {
  3446. _CoreManager.default.setLocalDatastoreController(controller);
  3447. },
  3448. /**
  3449. * Returns information regarding the current server's health
  3450. *
  3451. * @returns {Promise}
  3452. * @static
  3453. */
  3454. getServerHealth() {
  3455. return _CoreManager.default.getRESTController().request('GET', 'health');
  3456. },
  3457. /**
  3458. * @member {string} Parse.applicationId
  3459. * @static
  3460. */
  3461. set applicationId(value) {
  3462. _CoreManager.default.set('APPLICATION_ID', value);
  3463. },
  3464. get applicationId() {
  3465. return _CoreManager.default.get('APPLICATION_ID');
  3466. },
  3467. /**
  3468. * @member {string} Parse.javaScriptKey
  3469. * @static
  3470. */
  3471. set javaScriptKey(value) {
  3472. _CoreManager.default.set('JAVASCRIPT_KEY', value);
  3473. },
  3474. get javaScriptKey() {
  3475. return _CoreManager.default.get('JAVASCRIPT_KEY');
  3476. },
  3477. /**
  3478. * @member {string} Parse.masterKey
  3479. * @static
  3480. */
  3481. set masterKey(value) {
  3482. _CoreManager.default.set('MASTER_KEY', value);
  3483. },
  3484. get masterKey() {
  3485. return _CoreManager.default.get('MASTER_KEY');
  3486. },
  3487. /**
  3488. * @member {string} Parse.serverURL
  3489. * @static
  3490. */
  3491. set serverURL(value) {
  3492. _CoreManager.default.set('SERVER_URL', value);
  3493. },
  3494. get serverURL() {
  3495. return _CoreManager.default.get('SERVER_URL');
  3496. },
  3497. /**
  3498. * @member {string} Parse.serverAuthToken
  3499. * @static
  3500. */
  3501. set serverAuthToken(value) {
  3502. _CoreManager.default.set('SERVER_AUTH_TOKEN', value);
  3503. },
  3504. get serverAuthToken() {
  3505. return _CoreManager.default.get('SERVER_AUTH_TOKEN');
  3506. },
  3507. /**
  3508. * @member {string} Parse.serverAuthType
  3509. * @static
  3510. */
  3511. set serverAuthType(value) {
  3512. _CoreManager.default.set('SERVER_AUTH_TYPE', value);
  3513. },
  3514. get serverAuthType() {
  3515. return _CoreManager.default.get('SERVER_AUTH_TYPE');
  3516. },
  3517. /**
  3518. * @member {ParseLiveQuery} Parse.LiveQuery
  3519. * @static
  3520. */
  3521. set LiveQuery(liveQuery) {
  3522. _CoreManager.default.setLiveQuery(liveQuery);
  3523. },
  3524. get LiveQuery() {
  3525. return _CoreManager.default.getLiveQuery();
  3526. },
  3527. /**
  3528. * @member {string} Parse.liveQueryServerURL
  3529. * @static
  3530. */
  3531. set liveQueryServerURL(value) {
  3532. _CoreManager.default.set('LIVEQUERY_SERVER_URL', value);
  3533. },
  3534. get liveQueryServerURL() {
  3535. return _CoreManager.default.get('LIVEQUERY_SERVER_URL');
  3536. },
  3537. /**
  3538. * @member {boolean} Parse.encryptedUser
  3539. * @static
  3540. */
  3541. set encryptedUser(value) {
  3542. _CoreManager.default.set('ENCRYPTED_USER', value);
  3543. },
  3544. get encryptedUser() {
  3545. return _CoreManager.default.get('ENCRYPTED_USER');
  3546. },
  3547. /**
  3548. * @member {string} Parse.secret
  3549. * @static
  3550. */
  3551. set secret(value) {
  3552. _CoreManager.default.set('ENCRYPTED_KEY', value);
  3553. },
  3554. get secret() {
  3555. return _CoreManager.default.get('ENCRYPTED_KEY');
  3556. },
  3557. /**
  3558. * @member {boolean} Parse.idempotency
  3559. * @static
  3560. */
  3561. set idempotency(value) {
  3562. _CoreManager.default.set('IDEMPOTENCY', value);
  3563. },
  3564. get idempotency() {
  3565. return _CoreManager.default.get('IDEMPOTENCY');
  3566. },
  3567. /**
  3568. * @member {boolean} Parse.allowCustomObjectId
  3569. * @static
  3570. */
  3571. set allowCustomObjectId(value) {
  3572. _CoreManager.default.set('ALLOW_CUSTOM_OBJECT_ID', value);
  3573. },
  3574. get allowCustomObjectId() {
  3575. return _CoreManager.default.get('ALLOW_CUSTOM_OBJECT_ID');
  3576. },
  3577. _request() {
  3578. for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
  3579. args[_key] = arguments[_key];
  3580. }
  3581. return _CoreManager.default.getRESTController().request.apply(null, args);
  3582. },
  3583. _ajax() {
  3584. for (var _len2 = arguments.length, args = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
  3585. args[_key2] = arguments[_key2];
  3586. }
  3587. return _CoreManager.default.getRESTController().ajax.apply(null, args);
  3588. },
  3589. // We attempt to match the signatures of the legacy versions of these methods
  3590. _decode(_, value) {
  3591. return (0, _decode2.default)(value);
  3592. },
  3593. _encode(value, _, disallowObjects) {
  3594. return (0, _encode2.default)(value, disallowObjects);
  3595. },
  3596. _getInstallationId() {
  3597. return _CoreManager.default.getInstallationController().currentInstallationId();
  3598. },
  3599. /**
  3600. * Enable pinning in your application.
  3601. * This must be called after `Parse.initialize` in your application.
  3602. *
  3603. * @param [polling] Allow pinging the server /health endpoint. Default true
  3604. * @param [ms] Milliseconds to ping the server. Default 2000ms
  3605. * @static
  3606. */
  3607. enableLocalDatastore() {
  3608. let polling = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : true;
  3609. let ms = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 2000;
  3610. if (!this.applicationId) {
  3611. console.log("'enableLocalDataStore' must be called after 'initialize'");
  3612. return;
  3613. }
  3614. if (!this.LocalDatastore.isEnabled) {
  3615. this.LocalDatastore.isEnabled = true;
  3616. if (polling) {
  3617. _CoreManager.default.getEventuallyQueue().poll(ms);
  3618. }
  3619. }
  3620. },
  3621. /**
  3622. * Flag that indicates whether Local Datastore is enabled.
  3623. *
  3624. * @static
  3625. * @returns {boolean}
  3626. */
  3627. isLocalDatastoreEnabled() {
  3628. return this.LocalDatastore.isEnabled;
  3629. },
  3630. /**
  3631. * Gets all contents from Local Datastore
  3632. *
  3633. * <pre>
  3634. * await Parse.dumpLocalDatastore();
  3635. * </pre>
  3636. *
  3637. * @static
  3638. * @returns {object}
  3639. */
  3640. dumpLocalDatastore() {
  3641. if (!this.LocalDatastore.isEnabled) {
  3642. console.log('Parse.enableLocalDatastore() must be called first'); // eslint-disable-line no-console
  3643. return _promise.default.resolve({});
  3644. } else {
  3645. return Parse.LocalDatastore._getAllContents();
  3646. }
  3647. },
  3648. /**
  3649. * Enable the current user encryption.
  3650. * This must be called before login any user.
  3651. *
  3652. * @static
  3653. */
  3654. enableEncryptedUser() {
  3655. this.encryptedUser = true;
  3656. },
  3657. /**
  3658. * Flag that indicates whether Encrypted User is enabled.
  3659. *
  3660. * @static
  3661. * @returns {boolean}
  3662. */
  3663. isEncryptedUserEnabled() {
  3664. return this.encryptedUser;
  3665. }
  3666. };
  3667. _CoreManager.default.setRESTController(_RESTController.default);
  3668. // For legacy requires, of the form `var Parse = require('parse').Parse`
  3669. Parse.Parse = Parse;
  3670. module.exports = Parse;
  3671. var _default = exports.default = Parse;
  3672. }).call(this)}).call(this,_dereq_('_process'))
  3673. },{"./Analytics":1,"./AnonymousUtils":2,"./Cloud":3,"./CoreManager":4,"./CryptoController":5,"./EventEmitter":6,"./EventuallyQueue":7,"./FacebookUtils":8,"./IndexedDBStorageController":9,"./InstallationController":10,"./LiveQueryClient":11,"./LocalDatastore":13,"./LocalDatastoreController":15,"./ParseACL":21,"./ParseCLP":22,"./ParseConfig":23,"./ParseError":24,"./ParseFile":25,"./ParseGeoPoint":26,"./ParseHooks":27,"./ParseInstallation":28,"./ParseLiveQuery":29,"./ParseObject":30,"./ParseOp":31,"./ParsePolygon":32,"./ParseQuery":33,"./ParseRelation":34,"./ParseRole":35,"./ParseSchema":36,"./ParseSession":37,"./ParseUser":38,"./Push":39,"./RESTController":40,"./Storage":43,"./StorageController":46,"./WebSocketController":51,"./decode":55,"./encode":56,"@babel/runtime-corejs3/core-js-stable/object/define-property":90,"@babel/runtime-corejs3/core-js-stable/object/get-own-property-descriptor":93,"@babel/runtime-corejs3/core-js-stable/promise":97,"@babel/runtime-corejs3/core-js-stable/weak-map":101,"@babel/runtime-corejs3/helpers/interopRequireDefault":103,"_process":107}],21:[function(_dereq_,module,exports){
  3674. "use strict";
  3675. var _Object$defineProperty = _dereq_("@babel/runtime-corejs3/core-js-stable/object/define-property");
  3676. var _interopRequireDefault = _dereq_("@babel/runtime-corejs3/helpers/interopRequireDefault");
  3677. _Object$defineProperty(exports, "__esModule", {
  3678. value: true
  3679. });
  3680. exports.default = void 0;
  3681. var _keys = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/object/keys"));
  3682. var _defineProperty2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/helpers/defineProperty"));
  3683. var _CoreManager = _interopRequireDefault(_dereq_("./CoreManager"));
  3684. const PUBLIC_KEY = '*';
  3685. /**
  3686. * Creates a new ACL.
  3687. * If no argument is given, the ACL has no permissions for anyone.
  3688. * If the argument is a Parse.User, the ACL will have read and write
  3689. * permission for only that user.
  3690. * If the argument is any other JSON object, that object will be interpretted
  3691. * as a serialized ACL created with toJSON().
  3692. *
  3693. * <p>An ACL, or Access Control List can be added to any
  3694. * <code>Parse.Object</code> to restrict access to only a subset of users
  3695. * of your application.</p>
  3696. *
  3697. * @alias Parse.ACL
  3698. */
  3699. class ParseACL {
  3700. /**
  3701. * @param {(Parse.User | object)} arg1 The user to initialize the ACL for
  3702. */
  3703. constructor(arg1) {
  3704. (0, _defineProperty2.default)(this, "permissionsById", void 0);
  3705. this.permissionsById = {};
  3706. if (arg1 && typeof arg1 === 'object') {
  3707. const ParseUser = _CoreManager.default.getParseUser();
  3708. if (arg1 instanceof ParseUser) {
  3709. this.setReadAccess(arg1, true);
  3710. this.setWriteAccess(arg1, true);
  3711. } else {
  3712. for (const userId in arg1) {
  3713. const accessList = arg1[userId];
  3714. this.permissionsById[userId] = {};
  3715. for (const permission in accessList) {
  3716. const allowed = accessList[permission];
  3717. if (permission !== 'read' && permission !== 'write') {
  3718. throw new TypeError('Tried to create an ACL with an invalid permission type.');
  3719. }
  3720. if (typeof allowed !== 'boolean') {
  3721. throw new TypeError('Tried to create an ACL with an invalid permission value.');
  3722. }
  3723. this.permissionsById[userId][permission] = allowed;
  3724. }
  3725. }
  3726. }
  3727. } else if (typeof arg1 === 'function') {
  3728. throw new TypeError('ParseACL constructed with a function. Did you forget ()?');
  3729. }
  3730. }
  3731. /**
  3732. * Returns a JSON-encoded version of the ACL.
  3733. *
  3734. * @returns {object}
  3735. */
  3736. toJSON() {
  3737. const permissions = {};
  3738. for (const p in this.permissionsById) {
  3739. permissions[p] = this.permissionsById[p];
  3740. }
  3741. return permissions;
  3742. }
  3743. /**
  3744. * Returns whether this ACL is equal to another object
  3745. *
  3746. * @param {ParseACL} other The other object's ACL to compare to
  3747. * @returns {boolean}
  3748. */
  3749. equals(other) {
  3750. if (!(other instanceof ParseACL)) {
  3751. return false;
  3752. }
  3753. const users = (0, _keys.default)(this.permissionsById);
  3754. const otherUsers = (0, _keys.default)(other.permissionsById);
  3755. if (users.length !== otherUsers.length) {
  3756. return false;
  3757. }
  3758. for (const u in this.permissionsById) {
  3759. if (!other.permissionsById[u]) {
  3760. return false;
  3761. }
  3762. if (this.permissionsById[u].read !== other.permissionsById[u].read) {
  3763. return false;
  3764. }
  3765. if (this.permissionsById[u].write !== other.permissionsById[u].write) {
  3766. return false;
  3767. }
  3768. }
  3769. return true;
  3770. }
  3771. _setAccess(accessType, userId, allowed) {
  3772. const ParseRole = _CoreManager.default.getParseRole();
  3773. const ParseUser = _CoreManager.default.getParseUser();
  3774. if (userId instanceof ParseUser) {
  3775. userId = userId.id;
  3776. } else if (userId instanceof ParseRole) {
  3777. const name = userId.getName();
  3778. if (!name) {
  3779. throw new TypeError('Role must have a name');
  3780. }
  3781. userId = 'role:' + name;
  3782. }
  3783. if (typeof userId !== 'string') {
  3784. throw new TypeError('userId must be a string.');
  3785. }
  3786. if (typeof allowed !== 'boolean') {
  3787. throw new TypeError('allowed must be either true or false.');
  3788. }
  3789. let permissions = this.permissionsById[userId];
  3790. if (!permissions) {
  3791. if (!allowed) {
  3792. // The user already doesn't have this permission, so no action is needed
  3793. return;
  3794. } else {
  3795. permissions = {};
  3796. this.permissionsById[userId] = permissions;
  3797. }
  3798. }
  3799. if (allowed) {
  3800. this.permissionsById[userId][accessType] = true;
  3801. } else {
  3802. delete permissions[accessType];
  3803. if ((0, _keys.default)(permissions).length === 0) {
  3804. delete this.permissionsById[userId];
  3805. }
  3806. }
  3807. }
  3808. _getAccess(accessType, userId) {
  3809. const ParseRole = _CoreManager.default.getParseRole();
  3810. const ParseUser = _CoreManager.default.getParseUser();
  3811. if (userId instanceof ParseUser) {
  3812. userId = userId.id;
  3813. if (!userId) {
  3814. throw new Error('Cannot get access for a ParseUser without an ID');
  3815. }
  3816. } else if (userId instanceof ParseRole) {
  3817. const name = userId.getName();
  3818. if (!name) {
  3819. throw new TypeError('Role must have a name');
  3820. }
  3821. userId = 'role:' + name;
  3822. }
  3823. const permissions = this.permissionsById[userId];
  3824. if (!permissions) {
  3825. return false;
  3826. }
  3827. return !!permissions[accessType];
  3828. }
  3829. /**
  3830. * Sets whether the given user is allowed to read this object.
  3831. *
  3832. * @param userId An instance of Parse.User or its objectId.
  3833. * @param {boolean} allowed Whether that user should have read access.
  3834. */
  3835. setReadAccess(userId, allowed) {
  3836. this._setAccess('read', userId, allowed);
  3837. }
  3838. /**
  3839. * Get whether the given user id is *explicitly* allowed to read this object.
  3840. * Even if this returns false, the user may still be able to access it if
  3841. * getPublicReadAccess returns true or a role that the user belongs to has
  3842. * write access.
  3843. *
  3844. * @param userId An instance of Parse.User or its objectId, or a Parse.Role.
  3845. * @returns {boolean}
  3846. */
  3847. getReadAccess(userId) {
  3848. return this._getAccess('read', userId);
  3849. }
  3850. /**
  3851. * Sets whether the given user id is allowed to write this object.
  3852. *
  3853. * @param userId An instance of Parse.User or its objectId, or a Parse.Role..
  3854. * @param {boolean} allowed Whether that user should have write access.
  3855. */
  3856. setWriteAccess(userId, allowed) {
  3857. this._setAccess('write', userId, allowed);
  3858. }
  3859. /**
  3860. * Gets whether the given user id is *explicitly* allowed to write this object.
  3861. * Even if this returns false, the user may still be able to write it if
  3862. * getPublicWriteAccess returns true or a role that the user belongs to has
  3863. * write access.
  3864. *
  3865. * @param userId An instance of Parse.User or its objectId, or a Parse.Role.
  3866. * @returns {boolean}
  3867. */
  3868. getWriteAccess(userId) {
  3869. return this._getAccess('write', userId);
  3870. }
  3871. /**
  3872. * Sets whether the public is allowed to read this object.
  3873. *
  3874. * @param {boolean} allowed
  3875. */
  3876. setPublicReadAccess(allowed) {
  3877. this.setReadAccess(PUBLIC_KEY, allowed);
  3878. }
  3879. /**
  3880. * Gets whether the public is allowed to read this object.
  3881. *
  3882. * @returns {boolean}
  3883. */
  3884. getPublicReadAccess() {
  3885. return this.getReadAccess(PUBLIC_KEY);
  3886. }
  3887. /**
  3888. * Sets whether the public is allowed to write this object.
  3889. *
  3890. * @param {boolean} allowed
  3891. */
  3892. setPublicWriteAccess(allowed) {
  3893. this.setWriteAccess(PUBLIC_KEY, allowed);
  3894. }
  3895. /**
  3896. * Gets whether the public is allowed to write this object.
  3897. *
  3898. * @returns {boolean}
  3899. */
  3900. getPublicWriteAccess() {
  3901. return this.getWriteAccess(PUBLIC_KEY);
  3902. }
  3903. /**
  3904. * Gets whether users belonging to the given role are allowed
  3905. * to read this object. Even if this returns false, the role may
  3906. * still be able to write it if a parent role has read access.
  3907. *
  3908. * @param role The name of the role, or a Parse.Role object.
  3909. * @returns {boolean} true if the role has read access. false otherwise.
  3910. * @throws {TypeError} If role is neither a Parse.Role nor a String.
  3911. */
  3912. getRoleReadAccess(role) {
  3913. const ParseRole = _CoreManager.default.getParseRole();
  3914. if (role instanceof ParseRole) {
  3915. // Normalize to the String name
  3916. role = role.getName();
  3917. }
  3918. if (typeof role !== 'string') {
  3919. throw new TypeError('role must be a ParseRole or a String');
  3920. }
  3921. return this.getReadAccess('role:' + role);
  3922. }
  3923. /**
  3924. * Gets whether users belonging to the given role are allowed
  3925. * to write this object. Even if this returns false, the role may
  3926. * still be able to write it if a parent role has write access.
  3927. *
  3928. * @param role The name of the role, or a Parse.Role object.
  3929. * @returns {boolean} true if the role has write access. false otherwise.
  3930. * @throws {TypeError} If role is neither a Parse.Role nor a String.
  3931. */
  3932. getRoleWriteAccess(role) {
  3933. const ParseRole = _CoreManager.default.getParseRole();
  3934. if (role instanceof ParseRole) {
  3935. // Normalize to the String name
  3936. role = role.getName();
  3937. }
  3938. if (typeof role !== 'string') {
  3939. throw new TypeError('role must be a ParseRole or a String');
  3940. }
  3941. return this.getWriteAccess('role:' + role);
  3942. }
  3943. /**
  3944. * Sets whether users belonging to the given role are allowed
  3945. * to read this object.
  3946. *
  3947. * @param role The name of the role, or a Parse.Role object.
  3948. * @param {boolean} allowed Whether the given role can read this object.
  3949. * @throws {TypeError} If role is neither a Parse.Role nor a String.
  3950. */
  3951. setRoleReadAccess(role, allowed) {
  3952. const ParseRole = _CoreManager.default.getParseRole();
  3953. if (role instanceof ParseRole) {
  3954. // Normalize to the String name
  3955. role = role.getName();
  3956. }
  3957. if (typeof role !== 'string') {
  3958. throw new TypeError('role must be a ParseRole or a String');
  3959. }
  3960. this.setReadAccess('role:' + role, allowed);
  3961. }
  3962. /**
  3963. * Sets whether users belonging to the given role are allowed
  3964. * to write this object.
  3965. *
  3966. * @param role The name of the role, or a Parse.Role object.
  3967. * @param {boolean} allowed Whether the given role can write this object.
  3968. * @throws {TypeError} If role is neither a Parse.Role nor a String.
  3969. */
  3970. setRoleWriteAccess(role, allowed) {
  3971. const ParseRole = _CoreManager.default.getParseRole();
  3972. if (role instanceof ParseRole) {
  3973. // Normalize to the String name
  3974. role = role.getName();
  3975. }
  3976. if (typeof role !== 'string') {
  3977. throw new TypeError('role must be a ParseRole or a String');
  3978. }
  3979. this.setWriteAccess('role:' + role, allowed);
  3980. }
  3981. }
  3982. var _default = exports.default = ParseACL;
  3983. },{"./CoreManager":4,"@babel/runtime-corejs3/core-js-stable/object/define-property":90,"@babel/runtime-corejs3/core-js-stable/object/keys":95,"@babel/runtime-corejs3/helpers/defineProperty":102,"@babel/runtime-corejs3/helpers/interopRequireDefault":103}],22:[function(_dereq_,module,exports){
  3984. "use strict";
  3985. var _Object$defineProperty = _dereq_("@babel/runtime-corejs3/core-js-stable/object/define-property");
  3986. var _interopRequireDefault = _dereq_("@babel/runtime-corejs3/helpers/interopRequireDefault");
  3987. _Object$defineProperty(exports, "__esModule", {
  3988. value: true
  3989. });
  3990. exports.default = void 0;
  3991. var _defineProperty2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/helpers/defineProperty"));
  3992. var _map = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/map"));
  3993. var _entries = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/instance/entries"));
  3994. var _assign = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/object/assign"));
  3995. var _slice = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/instance/slice"));
  3996. var _includes = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/instance/includes"));
  3997. var _every = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/instance/every"));
  3998. var _keys = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/object/keys"));
  3999. var _isArray = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/array/is-array"));
  4000. var _ParseRole = _interopRequireDefault(_dereq_("./ParseRole"));
  4001. var _ParseUser = _interopRequireDefault(_dereq_("./ParseUser"));
  4002. const PUBLIC_KEY = '*';
  4003. const VALID_PERMISSIONS = new _map.default();
  4004. VALID_PERMISSIONS.set('get', {});
  4005. VALID_PERMISSIONS.set('find', {});
  4006. VALID_PERMISSIONS.set('count', {});
  4007. VALID_PERMISSIONS.set('create', {});
  4008. VALID_PERMISSIONS.set('update', {});
  4009. VALID_PERMISSIONS.set('delete', {});
  4010. VALID_PERMISSIONS.set('addField', {});
  4011. const VALID_PERMISSIONS_EXTENDED = new _map.default();
  4012. VALID_PERMISSIONS_EXTENDED.set('protectedFields', {});
  4013. /**
  4014. * Creates a new CLP.
  4015. * If no argument is given, the CLP has no permissions for anyone.
  4016. * If the argument is a Parse.User or Parse.Role, the CLP will have read and write
  4017. * permission for only that user or role.
  4018. * If the argument is any other JSON object, that object will be interpretted
  4019. * as a serialized CLP created with toJSON().
  4020. *
  4021. * <p>A CLP, or Class Level Permissions can be added to any
  4022. * <code>Parse.Schema</code> to restrict access to only a subset of users
  4023. * of your application.</p>
  4024. *
  4025. * <p>
  4026. * For get/count/find/create/update/delete/addField using the following functions:
  4027. *
  4028. * Entity is type Parse.User or Parse.Role or string
  4029. * Role is type Parse.Role or Name of Parse.Role
  4030. *
  4031. * getGetRequiresAuthentication()
  4032. * setGetRequiresAuthentication(allowed: boolean)
  4033. * getGetPointerFields()
  4034. * setGetPointerFields(pointerFields: string[])
  4035. * getGetAccess(entity: Entity)
  4036. * setGetAccess(entity: Entity, allowed: boolean)
  4037. * getPublicGetAccess()
  4038. * setPublicGetAccess(allowed: boolean)
  4039. * getRoleGetAccess(role: Role)
  4040. * setRoleGetAccess(role: Role, allowed: boolean)
  4041. * getFindRequiresAuthentication()
  4042. * setFindRequiresAuthentication(allowed: boolean)
  4043. * getFindPointerFields()
  4044. * setFindPointerFields(pointerFields: string[])
  4045. * getFindAccess(entity: Entity)
  4046. * setFindAccess(entity: Entity, allowed: boolean)
  4047. * getPublicFindAccess()
  4048. * setPublicFindAccess(allowed: boolean)
  4049. * getRoleFindAccess(role: Role)
  4050. * setRoleFindAccess(role: Role, allowed: boolean)
  4051. * getCountRequiresAuthentication()
  4052. * setCountRequiresAuthentication(allowed: boolean)
  4053. * getCountPointerFields()
  4054. * setCountPointerFields(pointerFields: string[])
  4055. * getCountAccess(entity: Entity)
  4056. * setCountAccess(entity: Entity, allowed: boolean)
  4057. * getPublicCountAccess()
  4058. * setPublicCountAccess(allowed: boolean)
  4059. * getRoleCountAccess(role: Role)
  4060. * setRoleCountAccess(role: Role, allowed: boolean)
  4061. * getCreateRequiresAuthentication()
  4062. * setCreateRequiresAuthentication(allowed: boolean)
  4063. * getCreatePointerFields()
  4064. * setCreatePointerFields(pointerFields: string[])
  4065. * getCreateAccess(entity: Entity)
  4066. * setCreateAccess(entity: Entity, allowed: boolean)
  4067. * getPublicCreateAccess()
  4068. * setPublicCreateAccess(allowed: Boolean)
  4069. * getRoleCreateAccess(role: Role)
  4070. * setRoleCreateAccess(role: Role, allowed: boolean)
  4071. * getUpdateRequiresAuthentication()
  4072. * setUpdateRequiresAuthentication(allowed: boolean)
  4073. * getUpdatePointerFields()
  4074. * setUpdatePointerFields(pointerFields: string[])
  4075. * getUpdateAccess(entity: Entity)
  4076. * setUpdateAccess(entity: Entity, allowed: boolean)
  4077. * getPublicUpdateAccess()
  4078. * setPublicUpdateAccess(allowed: boolean)
  4079. * getRoleUpdateAccess(role: Role)
  4080. * setRoleUpdateAccess(role: Role, allowed: boolean)
  4081. * getDeleteRequiresAuthentication()
  4082. * setDeleteRequiresAuthentication(allowed: boolean)
  4083. * getDeletePointerFields()
  4084. * setDeletePointerFields(pointerFields: string[])
  4085. * getDeleteAccess(entity: Entity)
  4086. * setDeleteAccess(entity: Entity, allowed: boolean)
  4087. * getPublicDeleteAccess()
  4088. * setPublicDeleteAccess(allowed: boolean)
  4089. * getRoleDeleteAccess(role: Role)
  4090. * setRoleDeleteAccess(role: Role, allowed: boolean)
  4091. * getAddFieldRequiresAuthentication()
  4092. * setAddFieldRequiresAuthentication(allowed: boolean)
  4093. * getAddFieldPointerFields()
  4094. * setAddFieldPointerFields(pointerFields: string[])
  4095. * getAddFieldAccess(entity: Entity)
  4096. * setAddFieldAccess(entity: Entity, allowed: boolean)
  4097. * getPublicAddFieldAccess()
  4098. * setPublicAddFieldAccess(allowed: boolean)
  4099. * getRoleAddFieldAccess(role: Role)
  4100. * setRoleAddFieldAccess(role: Role, allowed: boolean)
  4101. * </p>
  4102. *
  4103. * @alias Parse.CLP
  4104. */
  4105. class ParseCLP {
  4106. /**
  4107. * @param {(Parse.User | Parse.Role | object)} userId The user to initialize the CLP for
  4108. */
  4109. constructor(userId) {
  4110. (0, _defineProperty2.default)(this, "permissionsMap", void 0);
  4111. this.permissionsMap = {};
  4112. // Initialize permissions Map with default permissions
  4113. for (const [operation, group] of (0, _entries.default)(VALID_PERMISSIONS).call(VALID_PERMISSIONS)) {
  4114. this.permissionsMap[operation] = (0, _assign.default)({}, group);
  4115. const action = operation.charAt(0).toUpperCase() + (0, _slice.default)(operation).call(operation, 1);
  4116. this[`get${action}RequiresAuthentication`] = function () {
  4117. return this._getAccess(operation, 'requiresAuthentication');
  4118. };
  4119. this[`set${action}RequiresAuthentication`] = function (allowed) {
  4120. this._setAccess(operation, 'requiresAuthentication', allowed);
  4121. };
  4122. this[`get${action}PointerFields`] = function () {
  4123. return this._getAccess(operation, 'pointerFields', false);
  4124. };
  4125. this[`set${action}PointerFields`] = function (pointerFields) {
  4126. this._setArrayAccess(operation, 'pointerFields', pointerFields);
  4127. };
  4128. this[`get${action}Access`] = function (entity) {
  4129. return this._getAccess(operation, entity);
  4130. };
  4131. this[`set${action}Access`] = function (entity, allowed) {
  4132. this._setAccess(operation, entity, allowed);
  4133. };
  4134. this[`getPublic${action}Access`] = function () {
  4135. return this[`get${action}Access`](PUBLIC_KEY);
  4136. };
  4137. this[`setPublic${action}Access`] = function (allowed) {
  4138. this[`set${action}Access`](PUBLIC_KEY, allowed);
  4139. };
  4140. this[`getRole${action}Access`] = function (role) {
  4141. return this[`get${action}Access`](this._getRoleName(role));
  4142. };
  4143. this[`setRole${action}Access`] = function (role, allowed) {
  4144. this[`set${action}Access`](this._getRoleName(role), allowed);
  4145. };
  4146. }
  4147. // Initialize permissions Map with default extended permissions
  4148. for (const [operation, group] of (0, _entries.default)(VALID_PERMISSIONS_EXTENDED).call(VALID_PERMISSIONS_EXTENDED)) {
  4149. this.permissionsMap[operation] = (0, _assign.default)({}, group);
  4150. }
  4151. if (userId && typeof userId === 'object') {
  4152. if (userId instanceof _ParseUser.default) {
  4153. this.setReadAccess(userId, true);
  4154. this.setWriteAccess(userId, true);
  4155. } else if (userId instanceof _ParseRole.default) {
  4156. this.setRoleReadAccess(userId, true);
  4157. this.setRoleWriteAccess(userId, true);
  4158. } else {
  4159. for (const permission in userId) {
  4160. var _context;
  4161. const users = userId[permission];
  4162. const isValidPermission = !!VALID_PERMISSIONS.get(permission);
  4163. const isValidPermissionExtended = !!VALID_PERMISSIONS_EXTENDED.get(permission);
  4164. const isValidGroupPermission = (0, _includes.default)(_context = ['readUserFields', 'writeUserFields']).call(_context, permission);
  4165. if (typeof permission !== 'string' || !(isValidPermission || isValidPermissionExtended || isValidGroupPermission)) {
  4166. throw new TypeError('Tried to create an CLP with an invalid permission type.');
  4167. }
  4168. if (isValidGroupPermission) {
  4169. if ((0, _every.default)(users).call(users, pointer => typeof pointer === 'string')) {
  4170. this.permissionsMap[permission] = users;
  4171. continue;
  4172. } else {
  4173. throw new TypeError('Tried to create an CLP with an invalid permission value.');
  4174. }
  4175. }
  4176. for (const user in users) {
  4177. const allowed = users[user];
  4178. if (typeof allowed !== 'boolean' && !isValidPermissionExtended && user !== 'pointerFields') {
  4179. throw new TypeError('Tried to create an CLP with an invalid permission value.');
  4180. }
  4181. this.permissionsMap[permission][user] = allowed;
  4182. }
  4183. }
  4184. }
  4185. } else if (typeof userId === 'function') {
  4186. throw new TypeError('ParseCLP constructed with a function. Did you forget ()?');
  4187. }
  4188. }
  4189. /**
  4190. * Returns a JSON-encoded version of the CLP.
  4191. *
  4192. * @returns {object}
  4193. */
  4194. toJSON() {
  4195. return {
  4196. ...this.permissionsMap
  4197. };
  4198. }
  4199. /**
  4200. * Returns whether this CLP is equal to another object
  4201. *
  4202. * @param other The other object to compare to
  4203. * @returns {boolean}
  4204. */
  4205. equals(other) {
  4206. if (!(other instanceof ParseCLP)) {
  4207. return false;
  4208. }
  4209. const permissions = (0, _keys.default)(this.permissionsMap);
  4210. const otherPermissions = (0, _keys.default)(other.permissionsMap);
  4211. if (permissions.length !== otherPermissions.length) {
  4212. return false;
  4213. }
  4214. for (const permission in this.permissionsMap) {
  4215. if (!other.permissionsMap[permission]) {
  4216. return false;
  4217. }
  4218. const users = (0, _keys.default)(this.permissionsMap[permission]);
  4219. const otherUsers = (0, _keys.default)(other.permissionsMap[permission]);
  4220. if (users.length !== otherUsers.length) {
  4221. return false;
  4222. }
  4223. for (const user in this.permissionsMap[permission]) {
  4224. if (!other.permissionsMap[permission][user]) {
  4225. return false;
  4226. }
  4227. if (this.permissionsMap[permission][user] !== other.permissionsMap[permission][user]) {
  4228. return false;
  4229. }
  4230. }
  4231. }
  4232. return true;
  4233. }
  4234. _getRoleName(role) {
  4235. let name = role;
  4236. if (role instanceof _ParseRole.default) {
  4237. // Normalize to the String name
  4238. name = role.getName();
  4239. }
  4240. if (typeof name !== 'string') {
  4241. throw new TypeError('role must be a Parse.Role or a String');
  4242. }
  4243. return `role:${name}`;
  4244. }
  4245. _parseEntity(entity) {
  4246. let userId = entity;
  4247. if (userId instanceof _ParseUser.default) {
  4248. userId = userId.id;
  4249. if (!userId) {
  4250. throw new Error('Cannot get access for a Parse.User without an id.');
  4251. }
  4252. } else if (userId instanceof _ParseRole.default) {
  4253. userId = this._getRoleName(userId);
  4254. }
  4255. if (typeof userId !== 'string') {
  4256. throw new TypeError('userId must be a string.');
  4257. }
  4258. return userId;
  4259. }
  4260. _setAccess(permission, userId, allowed) {
  4261. userId = this._parseEntity(userId);
  4262. if (typeof allowed !== 'boolean') {
  4263. throw new TypeError('allowed must be either true or false.');
  4264. }
  4265. const permissions = this.permissionsMap[permission][userId];
  4266. if (!permissions) {
  4267. if (!allowed) {
  4268. // The user already doesn't have this permission, so no action is needed
  4269. return;
  4270. } else {
  4271. this.permissionsMap[permission][userId] = {};
  4272. }
  4273. }
  4274. if (allowed) {
  4275. this.permissionsMap[permission][userId] = true;
  4276. } else {
  4277. delete this.permissionsMap[permission][userId];
  4278. }
  4279. }
  4280. _getAccess(permission, userId) {
  4281. let returnBoolean = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : true;
  4282. userId = this._parseEntity(userId);
  4283. const permissions = this.permissionsMap[permission][userId];
  4284. if (returnBoolean) {
  4285. if (!permissions) {
  4286. return false;
  4287. }
  4288. return !!this.permissionsMap[permission][userId];
  4289. }
  4290. return permissions;
  4291. }
  4292. _setArrayAccess(permission, userId, fields) {
  4293. userId = this._parseEntity(userId);
  4294. const permissions = this.permissionsMap[permission][userId];
  4295. if (!permissions) {
  4296. this.permissionsMap[permission][userId] = [];
  4297. }
  4298. if (!fields || (0, _isArray.default)(fields) && fields.length === 0) {
  4299. delete this.permissionsMap[permission][userId];
  4300. } else if ((0, _isArray.default)(fields) && (0, _every.default)(fields).call(fields, field => typeof field === 'string')) {
  4301. this.permissionsMap[permission][userId] = fields;
  4302. } else {
  4303. throw new TypeError('fields must be an array of strings or undefined.');
  4304. }
  4305. }
  4306. _setGroupPointerPermission(operation, pointerFields) {
  4307. const fields = this.permissionsMap[operation];
  4308. if (!fields) {
  4309. this.permissionsMap[operation] = [];
  4310. }
  4311. if (!pointerFields || (0, _isArray.default)(pointerFields) && pointerFields.length === 0) {
  4312. delete this.permissionsMap[operation];
  4313. } else if ((0, _isArray.default)(pointerFields) && (0, _every.default)(pointerFields).call(pointerFields, field => typeof field === 'string')) {
  4314. this.permissionsMap[operation] = pointerFields;
  4315. } else {
  4316. throw new TypeError(`${operation}.pointerFields must be an array of strings or undefined.`);
  4317. }
  4318. }
  4319. _getGroupPointerPermissions(operation) {
  4320. return this.permissionsMap[operation] || [];
  4321. }
  4322. /**
  4323. * Sets user pointer fields to allow permission for get/count/find operations.
  4324. *
  4325. * @param {string[]} pointerFields User pointer fields
  4326. */
  4327. setReadUserFields(pointerFields) {
  4328. this._setGroupPointerPermission('readUserFields', pointerFields);
  4329. }
  4330. /**
  4331. * @returns {string[]} User pointer fields
  4332. */
  4333. getReadUserFields() {
  4334. return this._getGroupPointerPermissions('readUserFields') || [];
  4335. }
  4336. /**
  4337. * Sets user pointer fields to allow permission for create/delete/update/addField operations
  4338. *
  4339. * @param {string[]} pointerFields User pointer fields
  4340. */
  4341. setWriteUserFields(pointerFields) {
  4342. this._setGroupPointerPermission('writeUserFields', pointerFields);
  4343. }
  4344. /**
  4345. * @returns {string[]} User pointer fields
  4346. */
  4347. getWriteUserFields() {
  4348. return this._getGroupPointerPermissions('writeUserFields') || [];
  4349. }
  4350. /**
  4351. * Sets whether the given user is allowed to retrieve fields from this class.
  4352. *
  4353. * @param userId An instance of Parse.User or its objectId.
  4354. * @param {string[]} fields fields to be protected
  4355. */
  4356. setProtectedFields(userId, fields) {
  4357. this._setArrayAccess('protectedFields', userId, fields);
  4358. }
  4359. /**
  4360. * Returns array of fields are accessable to this user.
  4361. *
  4362. * @param userId An instance of Parse.User or its objectId, or a Parse.Role.
  4363. * @returns {string[]}
  4364. */
  4365. getProtectedFields(userId) {
  4366. return this._getAccess('protectedFields', userId, false);
  4367. }
  4368. /**
  4369. * Sets whether the given user is allowed to read from this class.
  4370. *
  4371. * @param userId An instance of Parse.User or its objectId.
  4372. * @param {boolean} allowed whether that user should have read access.
  4373. */
  4374. setReadAccess(userId, allowed) {
  4375. this._setAccess('find', userId, allowed);
  4376. this._setAccess('get', userId, allowed);
  4377. this._setAccess('count', userId, allowed);
  4378. }
  4379. /**
  4380. * Get whether the given user id is *explicitly* allowed to read from this class.
  4381. * Even if this returns false, the user may still be able to access it if
  4382. * getPublicReadAccess returns true or a role that the user belongs to has
  4383. * write access.
  4384. *
  4385. * @param userId An instance of Parse.User or its objectId, or a Parse.Role.
  4386. * @returns {boolean}
  4387. */
  4388. getReadAccess(userId) {
  4389. return this._getAccess('find', userId) && this._getAccess('get', userId) && this._getAccess('count', userId);
  4390. }
  4391. /**
  4392. * Sets whether the given user id is allowed to write to this class.
  4393. *
  4394. * @param userId An instance of Parse.User or its objectId, or a Parse.Role..
  4395. * @param {boolean} allowed Whether that user should have write access.
  4396. */
  4397. setWriteAccess(userId, allowed) {
  4398. this._setAccess('create', userId, allowed);
  4399. this._setAccess('update', userId, allowed);
  4400. this._setAccess('delete', userId, allowed);
  4401. this._setAccess('addField', userId, allowed);
  4402. }
  4403. /**
  4404. * Gets whether the given user id is *explicitly* allowed to write to this class.
  4405. * Even if this returns false, the user may still be able to write it if
  4406. * getPublicWriteAccess returns true or a role that the user belongs to has
  4407. * write access.
  4408. *
  4409. * @param userId An instance of Parse.User or its objectId, or a Parse.Role.
  4410. * @returns {boolean}
  4411. */
  4412. getWriteAccess(userId) {
  4413. return this._getAccess('create', userId) && this._getAccess('update', userId) && this._getAccess('delete', userId) && this._getAccess('addField', userId);
  4414. }
  4415. /**
  4416. * Sets whether the public is allowed to read from this class.
  4417. *
  4418. * @param {boolean} allowed
  4419. */
  4420. setPublicReadAccess(allowed) {
  4421. this.setReadAccess(PUBLIC_KEY, allowed);
  4422. }
  4423. /**
  4424. * Gets whether the public is allowed to read from this class.
  4425. *
  4426. * @returns {boolean}
  4427. */
  4428. getPublicReadAccess() {
  4429. return this.getReadAccess(PUBLIC_KEY);
  4430. }
  4431. /**
  4432. * Sets whether the public is allowed to write to this class.
  4433. *
  4434. * @param {boolean} allowed
  4435. */
  4436. setPublicWriteAccess(allowed) {
  4437. this.setWriteAccess(PUBLIC_KEY, allowed);
  4438. }
  4439. /**
  4440. * Gets whether the public is allowed to write to this class.
  4441. *
  4442. * @returns {boolean}
  4443. */
  4444. getPublicWriteAccess() {
  4445. return this.getWriteAccess(PUBLIC_KEY);
  4446. }
  4447. /**
  4448. * Sets whether the public is allowed to protect fields in this class.
  4449. *
  4450. * @param {string[]} fields
  4451. */
  4452. setPublicProtectedFields(fields) {
  4453. this.setProtectedFields(PUBLIC_KEY, fields);
  4454. }
  4455. /**
  4456. * Gets whether the public is allowed to read fields from this class.
  4457. *
  4458. * @returns {string[]}
  4459. */
  4460. getPublicProtectedFields() {
  4461. return this.getProtectedFields(PUBLIC_KEY);
  4462. }
  4463. /**
  4464. * Gets whether users belonging to the given role are allowed
  4465. * to read from this class. Even if this returns false, the role may
  4466. * still be able to write it if a parent role has read access.
  4467. *
  4468. * @param role The name of the role, or a Parse.Role object.
  4469. * @returns {boolean} true if the role has read access. false otherwise.
  4470. * @throws {TypeError} If role is neither a Parse.Role nor a String.
  4471. */
  4472. getRoleReadAccess(role) {
  4473. return this.getReadAccess(this._getRoleName(role));
  4474. }
  4475. /**
  4476. * Gets whether users belonging to the given role are allowed
  4477. * to write to this user. Even if this returns false, the role may
  4478. * still be able to write it if a parent role has write access.
  4479. *
  4480. * @param role The name of the role, or a Parse.Role object.
  4481. * @returns {boolean} true if the role has write access. false otherwise.
  4482. * @throws {TypeError} If role is neither a Parse.Role nor a String.
  4483. */
  4484. getRoleWriteAccess(role) {
  4485. return this.getWriteAccess(this._getRoleName(role));
  4486. }
  4487. /**
  4488. * Sets whether users belonging to the given role are allowed
  4489. * to read from this class.
  4490. *
  4491. * @param role The name of the role, or a Parse.Role object.
  4492. * @param {boolean} allowed Whether the given role can read this object.
  4493. * @throws {TypeError} If role is neither a Parse.Role nor a String.
  4494. */
  4495. setRoleReadAccess(role, allowed) {
  4496. this.setReadAccess(this._getRoleName(role), allowed);
  4497. }
  4498. /**
  4499. * Sets whether users belonging to the given role are allowed
  4500. * to write to this class.
  4501. *
  4502. * @param role The name of the role, or a Parse.Role object.
  4503. * @param {boolean} allowed Whether the given role can write this object.
  4504. * @throws {TypeError} If role is neither a Parse.Role nor a String.
  4505. */
  4506. setRoleWriteAccess(role, allowed) {
  4507. this.setWriteAccess(this._getRoleName(role), allowed);
  4508. }
  4509. /**
  4510. * Gets whether users belonging to the given role are allowed
  4511. * to count to this user. Even if this returns false, the role may
  4512. * still be able to count it if a parent role has count access.
  4513. *
  4514. * @param role The name of the role, or a Parse.Role object.
  4515. * @returns {string[]}
  4516. * @throws {TypeError} If role is neither a Parse.Role nor a String.
  4517. */
  4518. getRoleProtectedFields(role) {
  4519. return this.getProtectedFields(this._getRoleName(role));
  4520. }
  4521. /**
  4522. * Sets whether users belonging to the given role are allowed
  4523. * to set access field in this class.
  4524. *
  4525. * @param role The name of the role, or a Parse.Role object.
  4526. * @param {string[]} fields Fields to be protected by Role.
  4527. * @throws {TypeError} If role is neither a Parse.Role nor a String.
  4528. */
  4529. setRoleProtectedFields(role, fields) {
  4530. this.setProtectedFields(this._getRoleName(role), fields);
  4531. }
  4532. }
  4533. var _default = exports.default = ParseCLP;
  4534. },{"./ParseRole":35,"./ParseUser":38,"@babel/runtime-corejs3/core-js-stable/array/is-array":66,"@babel/runtime-corejs3/core-js-stable/instance/entries":69,"@babel/runtime-corejs3/core-js-stable/instance/every":70,"@babel/runtime-corejs3/core-js-stable/instance/includes":75,"@babel/runtime-corejs3/core-js-stable/instance/slice":80,"@babel/runtime-corejs3/core-js-stable/map":86,"@babel/runtime-corejs3/core-js-stable/object/assign":88,"@babel/runtime-corejs3/core-js-stable/object/define-property":90,"@babel/runtime-corejs3/core-js-stable/object/keys":95,"@babel/runtime-corejs3/helpers/defineProperty":102,"@babel/runtime-corejs3/helpers/interopRequireDefault":103}],23:[function(_dereq_,module,exports){
  4535. "use strict";
  4536. var _Object$defineProperty = _dereq_("@babel/runtime-corejs3/core-js-stable/object/define-property");
  4537. var _interopRequireDefault = _dereq_("@babel/runtime-corejs3/helpers/interopRequireDefault");
  4538. _Object$defineProperty(exports, "__esModule", {
  4539. value: true
  4540. });
  4541. exports.default = void 0;
  4542. var _promise = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/promise"));
  4543. var _stringify = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/json/stringify"));
  4544. var _defineProperty2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/helpers/defineProperty"));
  4545. var _CoreManager = _interopRequireDefault(_dereq_("./CoreManager"));
  4546. var _decode = _interopRequireDefault(_dereq_("./decode"));
  4547. var _encode = _interopRequireDefault(_dereq_("./encode"));
  4548. var _escape = _interopRequireDefault(_dereq_("./escape"));
  4549. var _ParseError = _interopRequireDefault(_dereq_("./ParseError"));
  4550. var _Storage = _interopRequireDefault(_dereq_("./Storage"));
  4551. /**
  4552. * Parse.Config is a local representation of configuration data that
  4553. * can be set from the Parse dashboard.
  4554. *
  4555. * @alias Parse.Config
  4556. */
  4557. class ParseConfig {
  4558. constructor() {
  4559. (0, _defineProperty2.default)(this, "attributes", void 0);
  4560. (0, _defineProperty2.default)(this, "_escapedAttributes", void 0);
  4561. this.attributes = {};
  4562. this._escapedAttributes = {};
  4563. }
  4564. /**
  4565. * Gets the value of an attribute.
  4566. *
  4567. * @param {string} attr The name of an attribute.
  4568. * @returns {*}
  4569. */
  4570. get(attr) {
  4571. return this.attributes[attr];
  4572. }
  4573. /**
  4574. * Gets the HTML-escaped value of an attribute.
  4575. *
  4576. * @param {string} attr The name of an attribute.
  4577. * @returns {string}
  4578. */
  4579. escape(attr) {
  4580. const html = this._escapedAttributes[attr];
  4581. if (html) {
  4582. return html;
  4583. }
  4584. const val = this.attributes[attr];
  4585. let escaped = '';
  4586. if (val != null) {
  4587. escaped = (0, _escape.default)(val.toString());
  4588. }
  4589. this._escapedAttributes[attr] = escaped;
  4590. return escaped;
  4591. }
  4592. /**
  4593. * Retrieves the most recently-fetched configuration object, either from
  4594. * memory or from local storage if necessary.
  4595. *
  4596. * @static
  4597. * @returns {Parse.Config} The most recently-fetched Parse.Config if it
  4598. * exists, else an empty Parse.Config.
  4599. */
  4600. static current() {
  4601. const controller = _CoreManager.default.getConfigController();
  4602. return controller.current();
  4603. }
  4604. /**
  4605. * Gets a new configuration object from the server.
  4606. *
  4607. * @static
  4608. * @param {object} options
  4609. * Valid options are:<ul>
  4610. * <li>useMasterKey: In Cloud Code and Node only, causes the Master Key to
  4611. * be used for this request.
  4612. * </ul>
  4613. * @returns {Promise} A promise that is resolved with a newly-created
  4614. * configuration object when the get completes.
  4615. */
  4616. static get() {
  4617. let options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
  4618. const controller = _CoreManager.default.getConfigController();
  4619. return controller.get(options);
  4620. }
  4621. /**
  4622. * Save value keys to the server.
  4623. *
  4624. * @static
  4625. * @param {object} attrs The config parameters and values.
  4626. * @param {object} masterKeyOnlyFlags The flags that define whether config parameters listed
  4627. * in `attrs` should be retrievable only by using the master key.
  4628. * For example: `param1: true` makes `param1` only retrievable by using the master key.
  4629. * If a parameter is not provided or set to `false`, it can be retrieved without
  4630. * using the master key.
  4631. * @returns {Promise} A promise that is resolved with a newly-created
  4632. * configuration object or with the current with the update.
  4633. */
  4634. static save(attrs, masterKeyOnlyFlags) {
  4635. const controller = _CoreManager.default.getConfigController();
  4636. //To avoid a mismatch with the local and the cloud config we get a new version
  4637. return controller.save(attrs, masterKeyOnlyFlags).then(() => {
  4638. return controller.get({
  4639. useMasterKey: true
  4640. });
  4641. }, error => {
  4642. return _promise.default.reject(error);
  4643. });
  4644. }
  4645. /**
  4646. * Used for testing
  4647. *
  4648. * @private
  4649. */
  4650. static _clearCache() {
  4651. currentConfig = null;
  4652. }
  4653. }
  4654. let currentConfig = null;
  4655. const CURRENT_CONFIG_KEY = 'currentConfig';
  4656. function decodePayload(data) {
  4657. try {
  4658. const json = JSON.parse(data);
  4659. if (json && typeof json === 'object') {
  4660. return (0, _decode.default)(json);
  4661. }
  4662. } catch (e) {
  4663. return null;
  4664. }
  4665. }
  4666. const DefaultController = {
  4667. current() {
  4668. if (currentConfig) {
  4669. return currentConfig;
  4670. }
  4671. const config = new ParseConfig();
  4672. const storagePath = _Storage.default.generatePath(CURRENT_CONFIG_KEY);
  4673. if (!_Storage.default.async()) {
  4674. const configData = _Storage.default.getItem(storagePath);
  4675. if (configData) {
  4676. const attributes = decodePayload(configData);
  4677. if (attributes) {
  4678. config.attributes = attributes;
  4679. currentConfig = config;
  4680. }
  4681. }
  4682. return config;
  4683. }
  4684. // Return a promise for async storage controllers
  4685. return _Storage.default.getItemAsync(storagePath).then(configData => {
  4686. if (configData) {
  4687. const attributes = decodePayload(configData);
  4688. if (attributes) {
  4689. config.attributes = attributes;
  4690. currentConfig = config;
  4691. }
  4692. }
  4693. return config;
  4694. });
  4695. },
  4696. get() {
  4697. let options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
  4698. const RESTController = _CoreManager.default.getRESTController();
  4699. return RESTController.request('GET', 'config', {}, options).then(response => {
  4700. if (!response || !response.params) {
  4701. const error = new _ParseError.default(_ParseError.default.INVALID_JSON, 'Config JSON response invalid.');
  4702. return _promise.default.reject(error);
  4703. }
  4704. const config = new ParseConfig();
  4705. config.attributes = {};
  4706. for (const attr in response.params) {
  4707. config.attributes[attr] = (0, _decode.default)(response.params[attr]);
  4708. }
  4709. currentConfig = config;
  4710. return _Storage.default.setItemAsync(_Storage.default.generatePath(CURRENT_CONFIG_KEY), (0, _stringify.default)(response.params)).then(() => {
  4711. return config;
  4712. });
  4713. });
  4714. },
  4715. save(attrs, masterKeyOnlyFlags) {
  4716. const RESTController = _CoreManager.default.getRESTController();
  4717. const encodedAttrs = {};
  4718. for (const key in attrs) {
  4719. encodedAttrs[key] = (0, _encode.default)(attrs[key]);
  4720. }
  4721. return RESTController.request('PUT', 'config', {
  4722. params: encodedAttrs,
  4723. masterKeyOnly: masterKeyOnlyFlags
  4724. }, {
  4725. useMasterKey: true
  4726. }).then(response => {
  4727. if (response && response.result) {
  4728. return _promise.default.resolve();
  4729. } else {
  4730. const error = new _ParseError.default(_ParseError.default.INTERNAL_SERVER_ERROR, 'Error occured updating Config.');
  4731. return _promise.default.reject(error);
  4732. }
  4733. });
  4734. }
  4735. };
  4736. _CoreManager.default.setConfigController(DefaultController);
  4737. var _default = exports.default = ParseConfig;
  4738. },{"./CoreManager":4,"./ParseError":24,"./Storage":43,"./decode":55,"./encode":56,"./escape":58,"@babel/runtime-corejs3/core-js-stable/json/stringify":85,"@babel/runtime-corejs3/core-js-stable/object/define-property":90,"@babel/runtime-corejs3/core-js-stable/promise":97,"@babel/runtime-corejs3/helpers/defineProperty":102,"@babel/runtime-corejs3/helpers/interopRequireDefault":103}],24:[function(_dereq_,module,exports){
  4739. "use strict";
  4740. var _Object$defineProperty2 = _dereq_("@babel/runtime-corejs3/core-js-stable/object/define-property");
  4741. var _interopRequireDefault = _dereq_("@babel/runtime-corejs3/helpers/interopRequireDefault");
  4742. _Object$defineProperty2(exports, "__esModule", {
  4743. value: true
  4744. });
  4745. exports.default = void 0;
  4746. var _forEach = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/instance/for-each"));
  4747. var _defineProperty2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/object/define-property"));
  4748. var _defineProperty3 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/helpers/defineProperty"));
  4749. var _CoreManager = _interopRequireDefault(_dereq_("./CoreManager"));
  4750. /**
  4751. * Constructs a new Parse.Error object with the given code and message.
  4752. *
  4753. * Parse.CoreManager.set('PARSE_ERRORS', [{ code, message }]) can be use to override error messages.
  4754. *
  4755. * @alias Parse.Error
  4756. */
  4757. class ParseError extends Error {
  4758. /**
  4759. * @param {number} code An error code constant from <code>Parse.Error</code>.
  4760. * @param {string} message A detailed description of the error.
  4761. */
  4762. constructor(code, message) {
  4763. var _context;
  4764. super(message);
  4765. (0, _defineProperty3.default)(this, "code", void 0);
  4766. (0, _defineProperty3.default)(this, "message", void 0);
  4767. (0, _defineProperty3.default)(this, "object", void 0);
  4768. (0, _defineProperty3.default)(this, "errors", void 0);
  4769. this.code = code;
  4770. let customMessage = message;
  4771. (0, _forEach.default)(_context = _CoreManager.default.get('PARSE_ERRORS')).call(_context, error => {
  4772. if (error.code === code && error.code) {
  4773. customMessage = error.message;
  4774. }
  4775. });
  4776. (0, _defineProperty2.default)(this, 'message', {
  4777. enumerable: true,
  4778. value: customMessage
  4779. });
  4780. }
  4781. toString() {
  4782. return 'ParseError: ' + this.code + ' ' + this.message;
  4783. }
  4784. /**
  4785. * Error code indicating some error other than those enumerated here.
  4786. *
  4787. * @property {number} OTHER_CAUSE
  4788. * @static
  4789. */
  4790. }
  4791. (0, _defineProperty3.default)(ParseError, "OTHER_CAUSE", -1);
  4792. /**
  4793. * Error code indicating that something has gone wrong with the server.
  4794. *
  4795. * @property {number} INTERNAL_SERVER_ERROR
  4796. * @static
  4797. */
  4798. (0, _defineProperty3.default)(ParseError, "INTERNAL_SERVER_ERROR", 1);
  4799. /**
  4800. * Error code indicating the connection to the Parse servers failed.
  4801. *
  4802. * @property {number} CONNECTION_FAILED
  4803. * @static
  4804. */
  4805. (0, _defineProperty3.default)(ParseError, "CONNECTION_FAILED", 100);
  4806. /**
  4807. * Error code indicating the specified object doesn't exist.
  4808. *
  4809. * @property {number} OBJECT_NOT_FOUND
  4810. * @static
  4811. */
  4812. (0, _defineProperty3.default)(ParseError, "OBJECT_NOT_FOUND", 101);
  4813. /**
  4814. * Error code indicating you tried to query with a datatype that doesn't
  4815. * support it, like exact matching an array or object.
  4816. *
  4817. * @property {number} INVALID_QUERY
  4818. * @static
  4819. */
  4820. (0, _defineProperty3.default)(ParseError, "INVALID_QUERY", 102);
  4821. /**
  4822. * Error code indicating a missing or invalid classname. Classnames are
  4823. * case-sensitive. They must start with a letter, and a-zA-Z0-9_ are the
  4824. * only valid characters.
  4825. *
  4826. * @property {number} INVALID_CLASS_NAME
  4827. * @static
  4828. */
  4829. (0, _defineProperty3.default)(ParseError, "INVALID_CLASS_NAME", 103);
  4830. /**
  4831. * Error code indicating an unspecified object id.
  4832. *
  4833. * @property {number} MISSING_OBJECT_ID
  4834. * @static
  4835. */
  4836. (0, _defineProperty3.default)(ParseError, "MISSING_OBJECT_ID", 104);
  4837. /**
  4838. * Error code indicating an invalid key name. Keys are case-sensitive. They
  4839. * must start with a letter, and a-zA-Z0-9_ are the only valid characters.
  4840. *
  4841. * @property {number} INVALID_KEY_NAME
  4842. * @static
  4843. */
  4844. (0, _defineProperty3.default)(ParseError, "INVALID_KEY_NAME", 105);
  4845. /**
  4846. * Error code indicating a malformed pointer. You should not see this unless
  4847. * you have been mucking about changing internal Parse code.
  4848. *
  4849. * @property {number} INVALID_POINTER
  4850. * @static
  4851. */
  4852. (0, _defineProperty3.default)(ParseError, "INVALID_POINTER", 106);
  4853. /**
  4854. * Error code indicating that badly formed JSON was received upstream. This
  4855. * either indicates you have done something unusual with modifying how
  4856. * things encode to JSON, or the network is failing badly.
  4857. *
  4858. * @property {number} INVALID_JSON
  4859. * @static
  4860. */
  4861. (0, _defineProperty3.default)(ParseError, "INVALID_JSON", 107);
  4862. /**
  4863. * Error code indicating that the feature you tried to access is only
  4864. * available internally for testing purposes.
  4865. *
  4866. * @property {number} COMMAND_UNAVAILABLE
  4867. * @static
  4868. */
  4869. (0, _defineProperty3.default)(ParseError, "COMMAND_UNAVAILABLE", 108);
  4870. /**
  4871. * You must call Parse.initialize before using the Parse library.
  4872. *
  4873. * @property {number} NOT_INITIALIZED
  4874. * @static
  4875. */
  4876. (0, _defineProperty3.default)(ParseError, "NOT_INITIALIZED", 109);
  4877. /**
  4878. * Error code indicating that a field was set to an inconsistent type.
  4879. *
  4880. * @property {number} INCORRECT_TYPE
  4881. * @static
  4882. */
  4883. (0, _defineProperty3.default)(ParseError, "INCORRECT_TYPE", 111);
  4884. /**
  4885. * Error code indicating an invalid channel name. A channel name is either
  4886. * an empty string (the broadcast channel) or contains only a-zA-Z0-9_
  4887. * characters and starts with a letter.
  4888. *
  4889. * @property {number} INVALID_CHANNEL_NAME
  4890. * @static
  4891. */
  4892. (0, _defineProperty3.default)(ParseError, "INVALID_CHANNEL_NAME", 112);
  4893. /**
  4894. * Error code indicating that push is misconfigured.
  4895. *
  4896. * @property {number} PUSH_MISCONFIGURED
  4897. * @static
  4898. */
  4899. (0, _defineProperty3.default)(ParseError, "PUSH_MISCONFIGURED", 115);
  4900. /**
  4901. * Error code indicating that the object is too large.
  4902. *
  4903. * @property {number} OBJECT_TOO_LARGE
  4904. * @static
  4905. */
  4906. (0, _defineProperty3.default)(ParseError, "OBJECT_TOO_LARGE", 116);
  4907. /**
  4908. * Error code indicating that the operation isn't allowed for clients.
  4909. *
  4910. * @property {number} OPERATION_FORBIDDEN
  4911. * @static
  4912. */
  4913. (0, _defineProperty3.default)(ParseError, "OPERATION_FORBIDDEN", 119);
  4914. /**
  4915. * Error code indicating the result was not found in the cache.
  4916. *
  4917. * @property {number} CACHE_MISS
  4918. * @static
  4919. */
  4920. (0, _defineProperty3.default)(ParseError, "CACHE_MISS", 120);
  4921. /**
  4922. * Error code indicating that an invalid key was used in a nested
  4923. * JSONObject.
  4924. *
  4925. * @property {number} INVALID_NESTED_KEY
  4926. * @static
  4927. */
  4928. (0, _defineProperty3.default)(ParseError, "INVALID_NESTED_KEY", 121);
  4929. /**
  4930. * Error code indicating that an invalid filename was used for ParseFile.
  4931. * A valid file name contains only a-zA-Z0-9_. characters and is between 1
  4932. * and 128 characters.
  4933. *
  4934. * @property {number} INVALID_FILE_NAME
  4935. * @static
  4936. */
  4937. (0, _defineProperty3.default)(ParseError, "INVALID_FILE_NAME", 122);
  4938. /**
  4939. * Error code indicating an invalid ACL was provided.
  4940. *
  4941. * @property {number} INVALID_ACL
  4942. * @static
  4943. */
  4944. (0, _defineProperty3.default)(ParseError, "INVALID_ACL", 123);
  4945. /**
  4946. * Error code indicating that the request timed out on the server. Typically
  4947. * this indicates that the request is too expensive to run.
  4948. *
  4949. * @property {number} TIMEOUT
  4950. * @static
  4951. */
  4952. (0, _defineProperty3.default)(ParseError, "TIMEOUT", 124);
  4953. /**
  4954. * Error code indicating that the email address was invalid.
  4955. *
  4956. * @property {number} INVALID_EMAIL_ADDRESS
  4957. * @static
  4958. */
  4959. (0, _defineProperty3.default)(ParseError, "INVALID_EMAIL_ADDRESS", 125);
  4960. /**
  4961. * Error code indicating a missing content type.
  4962. *
  4963. * @property {number} MISSING_CONTENT_TYPE
  4964. * @static
  4965. */
  4966. (0, _defineProperty3.default)(ParseError, "MISSING_CONTENT_TYPE", 126);
  4967. /**
  4968. * Error code indicating a missing content length.
  4969. *
  4970. * @property {number} MISSING_CONTENT_LENGTH
  4971. * @static
  4972. */
  4973. (0, _defineProperty3.default)(ParseError, "MISSING_CONTENT_LENGTH", 127);
  4974. /**
  4975. * Error code indicating an invalid content length.
  4976. *
  4977. * @property {number} INVALID_CONTENT_LENGTH
  4978. * @static
  4979. */
  4980. (0, _defineProperty3.default)(ParseError, "INVALID_CONTENT_LENGTH", 128);
  4981. /**
  4982. * Error code indicating a file that was too large.
  4983. *
  4984. * @property {number} FILE_TOO_LARGE
  4985. * @static
  4986. */
  4987. (0, _defineProperty3.default)(ParseError, "FILE_TOO_LARGE", 129);
  4988. /**
  4989. * Error code indicating an error saving a file.
  4990. *
  4991. * @property {number} FILE_SAVE_ERROR
  4992. * @static
  4993. */
  4994. (0, _defineProperty3.default)(ParseError, "FILE_SAVE_ERROR", 130);
  4995. /**
  4996. * Error code indicating that a unique field was given a value that is
  4997. * already taken.
  4998. *
  4999. * @property {number} DUPLICATE_VALUE
  5000. * @static
  5001. */
  5002. (0, _defineProperty3.default)(ParseError, "DUPLICATE_VALUE", 137);
  5003. /**
  5004. * Error code indicating that a role's name is invalid.
  5005. *
  5006. * @property {number} INVALID_ROLE_NAME
  5007. * @static
  5008. */
  5009. (0, _defineProperty3.default)(ParseError, "INVALID_ROLE_NAME", 139);
  5010. /**
  5011. * Error code indicating that an application quota was exceeded. Upgrade to
  5012. * resolve.
  5013. *
  5014. * @property {number} EXCEEDED_QUOTA
  5015. * @static
  5016. */
  5017. (0, _defineProperty3.default)(ParseError, "EXCEEDED_QUOTA", 140);
  5018. /**
  5019. * Error code indicating that a Cloud Code script failed.
  5020. *
  5021. * @property {number} SCRIPT_FAILED
  5022. * @static
  5023. */
  5024. (0, _defineProperty3.default)(ParseError, "SCRIPT_FAILED", 141);
  5025. /**
  5026. * Error code indicating that a Cloud Code validation failed.
  5027. *
  5028. * @property {number} VALIDATION_ERROR
  5029. * @static
  5030. */
  5031. (0, _defineProperty3.default)(ParseError, "VALIDATION_ERROR", 142);
  5032. /**
  5033. * Error code indicating that invalid image data was provided.
  5034. *
  5035. * @property {number} INVALID_IMAGE_DATA
  5036. * @static
  5037. */
  5038. (0, _defineProperty3.default)(ParseError, "INVALID_IMAGE_DATA", 143);
  5039. /**
  5040. * Error code indicating an unsaved file.
  5041. *
  5042. * @property {number} UNSAVED_FILE_ERROR
  5043. * @static
  5044. */
  5045. (0, _defineProperty3.default)(ParseError, "UNSAVED_FILE_ERROR", 151);
  5046. /**
  5047. * Error code indicating an invalid push time.
  5048. *
  5049. * @property {number} INVALID_PUSH_TIME_ERROR
  5050. * @static
  5051. */
  5052. (0, _defineProperty3.default)(ParseError, "INVALID_PUSH_TIME_ERROR", 152);
  5053. /**
  5054. * Error code indicating an error deleting a file.
  5055. *
  5056. * @property {number} FILE_DELETE_ERROR
  5057. * @static
  5058. */
  5059. (0, _defineProperty3.default)(ParseError, "FILE_DELETE_ERROR", 153);
  5060. /**
  5061. * Error code indicating an error deleting an unnamed file.
  5062. *
  5063. * @property {number} FILE_DELETE_UNNAMED_ERROR
  5064. * @static
  5065. */
  5066. (0, _defineProperty3.default)(ParseError, "FILE_DELETE_UNNAMED_ERROR", 161);
  5067. /**
  5068. * Error code indicating that the application has exceeded its request
  5069. * limit.
  5070. *
  5071. * @property {number} REQUEST_LIMIT_EXCEEDED
  5072. * @static
  5073. */
  5074. (0, _defineProperty3.default)(ParseError, "REQUEST_LIMIT_EXCEEDED", 155);
  5075. /**
  5076. * Error code indicating that the request was a duplicate and has been discarded due to
  5077. * idempotency rules.
  5078. *
  5079. * @property {number} DUPLICATE_REQUEST
  5080. * @static
  5081. */
  5082. (0, _defineProperty3.default)(ParseError, "DUPLICATE_REQUEST", 159);
  5083. /**
  5084. * Error code indicating an invalid event name.
  5085. *
  5086. * @property {number} INVALID_EVENT_NAME
  5087. * @static
  5088. */
  5089. (0, _defineProperty3.default)(ParseError, "INVALID_EVENT_NAME", 160);
  5090. /**
  5091. * Error code indicating that a field had an invalid value.
  5092. *
  5093. * @property {number} INVALID_VALUE
  5094. * @static
  5095. */
  5096. (0, _defineProperty3.default)(ParseError, "INVALID_VALUE", 162);
  5097. /**
  5098. * Error code indicating that the username is missing or empty.
  5099. *
  5100. * @property {number} USERNAME_MISSING
  5101. * @static
  5102. */
  5103. (0, _defineProperty3.default)(ParseError, "USERNAME_MISSING", 200);
  5104. /**
  5105. * Error code indicating that the password is missing or empty.
  5106. *
  5107. * @property {number} PASSWORD_MISSING
  5108. * @static
  5109. */
  5110. (0, _defineProperty3.default)(ParseError, "PASSWORD_MISSING", 201);
  5111. /**
  5112. * Error code indicating that the username has already been taken.
  5113. *
  5114. * @property {number} USERNAME_TAKEN
  5115. * @static
  5116. */
  5117. (0, _defineProperty3.default)(ParseError, "USERNAME_TAKEN", 202);
  5118. /**
  5119. * Error code indicating that the email has already been taken.
  5120. *
  5121. * @property {number} EMAIL_TAKEN
  5122. * @static
  5123. */
  5124. (0, _defineProperty3.default)(ParseError, "EMAIL_TAKEN", 203);
  5125. /**
  5126. * Error code indicating that the email is missing, but must be specified.
  5127. *
  5128. * @property {number} EMAIL_MISSING
  5129. * @static
  5130. */
  5131. (0, _defineProperty3.default)(ParseError, "EMAIL_MISSING", 204);
  5132. /**
  5133. * Error code indicating that a user with the specified email was not found.
  5134. *
  5135. * @property {number} EMAIL_NOT_FOUND
  5136. * @static
  5137. */
  5138. (0, _defineProperty3.default)(ParseError, "EMAIL_NOT_FOUND", 205);
  5139. /**
  5140. * Error code indicating that a user object without a valid session could
  5141. * not be altered.
  5142. *
  5143. * @property {number} SESSION_MISSING
  5144. * @static
  5145. */
  5146. (0, _defineProperty3.default)(ParseError, "SESSION_MISSING", 206);
  5147. /**
  5148. * Error code indicating that a user can only be created through signup.
  5149. *
  5150. * @property {number} MUST_CREATE_USER_THROUGH_SIGNUP
  5151. * @static
  5152. */
  5153. (0, _defineProperty3.default)(ParseError, "MUST_CREATE_USER_THROUGH_SIGNUP", 207);
  5154. /**
  5155. * Error code indicating that an an account being linked is already linked
  5156. * to another user.
  5157. *
  5158. * @property {number} ACCOUNT_ALREADY_LINKED
  5159. * @static
  5160. */
  5161. (0, _defineProperty3.default)(ParseError, "ACCOUNT_ALREADY_LINKED", 208);
  5162. /**
  5163. * Error code indicating that the current session token is invalid.
  5164. *
  5165. * @property {number} INVALID_SESSION_TOKEN
  5166. * @static
  5167. */
  5168. (0, _defineProperty3.default)(ParseError, "INVALID_SESSION_TOKEN", 209);
  5169. /**
  5170. * Error code indicating an error enabling or verifying MFA
  5171. *
  5172. * @property {number} MFA_ERROR
  5173. * @static
  5174. */
  5175. (0, _defineProperty3.default)(ParseError, "MFA_ERROR", 210);
  5176. /**
  5177. * Error code indicating that a valid MFA token must be provided
  5178. *
  5179. * @property {number} MFA_TOKEN_REQUIRED
  5180. * @static
  5181. */
  5182. (0, _defineProperty3.default)(ParseError, "MFA_TOKEN_REQUIRED", 211);
  5183. /**
  5184. * Error code indicating that a user cannot be linked to an account because
  5185. * that account's id could not be found.
  5186. *
  5187. * @property {number} LINKED_ID_MISSING
  5188. * @static
  5189. */
  5190. (0, _defineProperty3.default)(ParseError, "LINKED_ID_MISSING", 250);
  5191. /**
  5192. * Error code indicating that a user with a linked (e.g. Facebook) account
  5193. * has an invalid session.
  5194. *
  5195. * @property {number} INVALID_LINKED_SESSION
  5196. * @static
  5197. */
  5198. (0, _defineProperty3.default)(ParseError, "INVALID_LINKED_SESSION", 251);
  5199. /**
  5200. * Error code indicating that a service being linked (e.g. Facebook or
  5201. * Twitter) is unsupported.
  5202. *
  5203. * @property {number} UNSUPPORTED_SERVICE
  5204. * @static
  5205. */
  5206. (0, _defineProperty3.default)(ParseError, "UNSUPPORTED_SERVICE", 252);
  5207. /**
  5208. * Error code indicating an invalid operation occured on schema
  5209. *
  5210. * @property {number} INVALID_SCHEMA_OPERATION
  5211. * @static
  5212. */
  5213. (0, _defineProperty3.default)(ParseError, "INVALID_SCHEMA_OPERATION", 255);
  5214. /**
  5215. * Error code indicating that there were multiple errors. Aggregate errors
  5216. * have an "errors" property, which is an array of error objects with more
  5217. * detail about each error that occurred.
  5218. *
  5219. * @property {number} AGGREGATE_ERROR
  5220. * @static
  5221. */
  5222. (0, _defineProperty3.default)(ParseError, "AGGREGATE_ERROR", 600);
  5223. /**
  5224. * Error code indicating the client was unable to read an input file.
  5225. *
  5226. * @property {number} FILE_READ_ERROR
  5227. * @static
  5228. */
  5229. (0, _defineProperty3.default)(ParseError, "FILE_READ_ERROR", 601);
  5230. /**
  5231. * Error code indicating a real error code is unavailable because
  5232. * we had to use an XDomainRequest object to allow CORS requests in
  5233. * Internet Explorer, which strips the body from HTTP responses that have
  5234. * a non-2XX status code.
  5235. *
  5236. * @property {number} X_DOMAIN_REQUEST
  5237. * @static
  5238. */
  5239. (0, _defineProperty3.default)(ParseError, "X_DOMAIN_REQUEST", 602);
  5240. var _default = exports.default = ParseError;
  5241. },{"./CoreManager":4,"@babel/runtime-corejs3/core-js-stable/instance/for-each":74,"@babel/runtime-corejs3/core-js-stable/object/define-property":90,"@babel/runtime-corejs3/helpers/defineProperty":102,"@babel/runtime-corejs3/helpers/interopRequireDefault":103}],25:[function(_dereq_,module,exports){
  5242. "use strict";
  5243. var _Object$defineProperty = _dereq_("@babel/runtime-corejs3/core-js-stable/object/define-property");
  5244. var _interopRequireDefault = _dereq_("@babel/runtime-corejs3/helpers/interopRequireDefault");
  5245. _Object$defineProperty(exports, "__esModule", {
  5246. value: true
  5247. });
  5248. exports.default = void 0;
  5249. var _isArray = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/array/is-array"));
  5250. var _slice = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/instance/slice"));
  5251. var _forEach = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/instance/for-each"));
  5252. var _keys = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/object/keys"));
  5253. var _promise = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/promise"));
  5254. var _indexOf = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/instance/index-of"));
  5255. var _defineProperty2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/helpers/defineProperty"));
  5256. var _CoreManager = _interopRequireDefault(_dereq_("./CoreManager"));
  5257. var _ParseError = _interopRequireDefault(_dereq_("./ParseError"));
  5258. var _Xhr = _interopRequireDefault(_dereq_("./Xhr.weapp"));
  5259. /* global XMLHttpRequest, Blob */
  5260. let XHR = null;
  5261. if (typeof XMLHttpRequest !== 'undefined') {
  5262. XHR = XMLHttpRequest;
  5263. }
  5264. function b64Digit(number) {
  5265. if (number < 26) {
  5266. return String.fromCharCode(65 + number);
  5267. }
  5268. if (number < 52) {
  5269. return String.fromCharCode(97 + (number - 26));
  5270. }
  5271. if (number < 62) {
  5272. return String.fromCharCode(48 + (number - 52));
  5273. }
  5274. if (number === 62) {
  5275. return '+';
  5276. }
  5277. if (number === 63) {
  5278. return '/';
  5279. }
  5280. throw new TypeError('Tried to encode large digit ' + number + ' in base64.');
  5281. }
  5282. /**
  5283. * A Parse.File is a local representation of a file that is saved to the Parse
  5284. * cloud.
  5285. *
  5286. * @alias Parse.File
  5287. */
  5288. class ParseFile {
  5289. /**
  5290. * @param name {String} The file's name. This will be prefixed by a unique
  5291. * value once the file has finished saving. The file name must begin with
  5292. * an alphanumeric character, and consist of alphanumeric characters,
  5293. * periods, spaces, underscores, or dashes.
  5294. * @param data {Array} The data for the file, as either:
  5295. * 1. an Array of byte value Numbers, or
  5296. * 2. an Object like { base64: "..." } with a base64-encoded String.
  5297. * 3. an Object like { uri: "..." } with a uri String.
  5298. * 4. a File object selected with a file upload control. (3) only works
  5299. * in Firefox 3.6+, Safari 6.0.2+, Chrome 7+, and IE 10+.
  5300. * For example:
  5301. * <pre>
  5302. * var fileUploadControl = $("#profilePhotoFileUpload")[0];
  5303. * if (fileUploadControl.files.length > 0) {
  5304. * var file = fileUploadControl.files[0];
  5305. * var name = "photo.jpg";
  5306. * var parseFile = new Parse.File(name, file);
  5307. * parseFile.save().then(function() {
  5308. * // The file has been saved to Parse.
  5309. * }, function(error) {
  5310. * // The file either could not be read, or could not be saved to Parse.
  5311. * });
  5312. * }</pre>
  5313. * @param type {String} Optional Content-Type header to use for the file. If
  5314. * this is omitted, the content type will be inferred from the name's
  5315. * extension.
  5316. * @param metadata {object} Optional key value pairs to be stored with file object
  5317. * @param tags {object} Optional key value pairs to be stored with file object
  5318. */
  5319. constructor(name, data, type, metadata, tags) {
  5320. (0, _defineProperty2.default)(this, "_name", void 0);
  5321. (0, _defineProperty2.default)(this, "_url", void 0);
  5322. (0, _defineProperty2.default)(this, "_source", void 0);
  5323. (0, _defineProperty2.default)(this, "_previousSave", void 0);
  5324. (0, _defineProperty2.default)(this, "_data", void 0);
  5325. (0, _defineProperty2.default)(this, "_requestTask", void 0);
  5326. (0, _defineProperty2.default)(this, "_metadata", void 0);
  5327. (0, _defineProperty2.default)(this, "_tags", void 0);
  5328. const specifiedType = type || '';
  5329. this._name = name;
  5330. this._metadata = metadata || {};
  5331. this._tags = tags || {};
  5332. if (data !== undefined) {
  5333. if ((0, _isArray.default)(data)) {
  5334. this._data = ParseFile.encodeBase64(data);
  5335. this._source = {
  5336. format: 'base64',
  5337. base64: this._data,
  5338. type: specifiedType
  5339. };
  5340. } else if (typeof Blob !== 'undefined' && data instanceof Blob) {
  5341. this._source = {
  5342. format: 'file',
  5343. file: data,
  5344. type: specifiedType
  5345. };
  5346. } else if (data && typeof data.uri === 'string' && data.uri !== undefined) {
  5347. this._source = {
  5348. format: 'uri',
  5349. uri: data.uri,
  5350. type: specifiedType
  5351. };
  5352. } else if (data && typeof data.base64 === 'string') {
  5353. var _context, _context2, _context3;
  5354. const base64 = (0, _slice.default)(_context = data.base64.split(',')).call(_context, -1)[0];
  5355. const 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';
  5356. this._data = base64;
  5357. this._source = {
  5358. format: 'base64',
  5359. base64,
  5360. type: dataType
  5361. };
  5362. } else {
  5363. throw new TypeError('Cannot create a Parse.File with that data.');
  5364. }
  5365. }
  5366. }
  5367. /**
  5368. * Return the data for the file, downloading it if not already present.
  5369. * Data is present if initialized with Byte Array, Base64 or Saved with Uri.
  5370. * Data is cleared if saved with File object selected with a file upload control
  5371. *
  5372. * @returns {Promise} Promise that is resolve with base64 data
  5373. */
  5374. async getData() {
  5375. if (this._data) {
  5376. return this._data;
  5377. }
  5378. if (!this._url) {
  5379. throw new Error('Cannot retrieve data for unsaved ParseFile.');
  5380. }
  5381. const controller = _CoreManager.default.getFileController();
  5382. const result = await controller.download(this._url, {
  5383. requestTask: task => this._requestTask = task
  5384. });
  5385. this._data = result.base64;
  5386. return this._data;
  5387. }
  5388. /**
  5389. * Gets the name of the file. Before save is called, this is the filename
  5390. * given by the user. After save is called, that name gets prefixed with a
  5391. * unique identifier.
  5392. *
  5393. * @returns {string}
  5394. */
  5395. name() {
  5396. return this._name;
  5397. }
  5398. /**
  5399. * Gets the url of the file. It is only available after you save the file or
  5400. * after you get the file from a Parse.Object.
  5401. *
  5402. * @param {object} options An object to specify url options
  5403. * @param {boolean} [options.forceSecure] force the url to be secure
  5404. * @returns {string | undefined}
  5405. */
  5406. url(options) {
  5407. options = options || {};
  5408. if (!this._url) {
  5409. return;
  5410. }
  5411. if (options.forceSecure) {
  5412. return this._url.replace(/^http:\/\//i, 'https://');
  5413. } else {
  5414. return this._url;
  5415. }
  5416. }
  5417. /**
  5418. * Gets the metadata of the file.
  5419. *
  5420. * @returns {object}
  5421. */
  5422. metadata() {
  5423. return this._metadata;
  5424. }
  5425. /**
  5426. * Gets the tags of the file.
  5427. *
  5428. * @returns {object}
  5429. */
  5430. tags() {
  5431. return this._tags;
  5432. }
  5433. /**
  5434. * Saves the file to the Parse cloud.
  5435. *
  5436. * @param {object} options
  5437. * Valid options are:<ul>
  5438. * <li>useMasterKey: In Cloud Code and Node only, causes the Master Key to
  5439. * be used for this request.
  5440. * <li>sessionToken: A valid session token, used for making a request on
  5441. * behalf of a specific user.
  5442. * <li>progress: In Browser only, callback for upload progress. For example:
  5443. * <pre>
  5444. * let parseFile = new Parse.File(name, file);
  5445. * parseFile.save({
  5446. * progress: (progressValue, loaded, total, { type }) => {
  5447. * if (type === "upload" && progressValue !== null) {
  5448. * // Update the UI using progressValue
  5449. * }
  5450. * }
  5451. * });
  5452. * </pre>
  5453. * </ul>
  5454. * @returns {Promise | undefined} Promise that is resolved when the save finishes.
  5455. */
  5456. save(options) {
  5457. options = options || {};
  5458. options.requestTask = task => this._requestTask = task;
  5459. options.metadata = this._metadata;
  5460. options.tags = this._tags;
  5461. const controller = _CoreManager.default.getFileController();
  5462. if (!this._previousSave) {
  5463. if (this._source.format === 'file') {
  5464. this._previousSave = controller.saveFile(this._name, this._source, options).then(res => {
  5465. this._name = res.name;
  5466. this._url = res.url;
  5467. this._data = null;
  5468. this._requestTask = null;
  5469. return this;
  5470. });
  5471. } else if (this._source.format === 'uri') {
  5472. this._previousSave = controller.download(this._source.uri, options).then(result => {
  5473. if (!(result && result.base64)) {
  5474. return {};
  5475. }
  5476. const newSource = {
  5477. format: 'base64',
  5478. base64: result.base64,
  5479. type: result.contentType
  5480. };
  5481. this._data = result.base64;
  5482. this._requestTask = null;
  5483. return controller.saveBase64(this._name, newSource, options);
  5484. }).then(res => {
  5485. this._name = res.name;
  5486. this._url = res.url;
  5487. this._requestTask = null;
  5488. return this;
  5489. });
  5490. } else {
  5491. this._previousSave = controller.saveBase64(this._name, this._source, options).then(res => {
  5492. this._name = res.name;
  5493. this._url = res.url;
  5494. this._requestTask = null;
  5495. return this;
  5496. });
  5497. }
  5498. }
  5499. if (this._previousSave) {
  5500. return this._previousSave;
  5501. }
  5502. }
  5503. /**
  5504. * Aborts the request if it has already been sent.
  5505. */
  5506. cancel() {
  5507. if (this._requestTask && typeof this._requestTask.abort === 'function') {
  5508. this._requestTask._aborted = true;
  5509. this._requestTask.abort();
  5510. }
  5511. this._requestTask = null;
  5512. }
  5513. /**
  5514. * Deletes the file from the Parse cloud.
  5515. * In Cloud Code and Node only with Master Key.
  5516. *
  5517. * @param {object} options
  5518. * Valid options are:<ul>
  5519. * <li>useMasterKey: In Cloud Code and Node only, causes the Master Key to
  5520. * be used for this request.
  5521. * <pre>
  5522. * @returns {Promise} Promise that is resolved when the delete finishes.
  5523. */
  5524. destroy() {
  5525. let options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
  5526. if (!this._name) {
  5527. throw new _ParseError.default(_ParseError.default.FILE_DELETE_UNNAMED_ERROR, 'Cannot delete an unnamed file.');
  5528. }
  5529. const destroyOptions = {
  5530. useMasterKey: true
  5531. };
  5532. if (options.hasOwnProperty('useMasterKey')) {
  5533. destroyOptions.useMasterKey = !!options.useMasterKey;
  5534. }
  5535. const controller = _CoreManager.default.getFileController();
  5536. return controller.deleteFile(this._name, destroyOptions).then(() => {
  5537. this._data = undefined;
  5538. this._requestTask = null;
  5539. return this;
  5540. });
  5541. }
  5542. toJSON() {
  5543. return {
  5544. __type: 'File',
  5545. name: this._name,
  5546. url: this._url
  5547. };
  5548. }
  5549. equals(other) {
  5550. if (this === other) {
  5551. return true;
  5552. }
  5553. // Unsaved Files are never equal, since they will be saved to different URLs
  5554. return other instanceof ParseFile && this.name() === other.name() && this.url() === other.url() && typeof this.url() !== 'undefined';
  5555. }
  5556. /**
  5557. * Sets metadata to be saved with file object. Overwrites existing metadata
  5558. *
  5559. * @param {object} metadata Key value pairs to be stored with file object
  5560. */
  5561. setMetadata(metadata) {
  5562. if (metadata && typeof metadata === 'object') {
  5563. var _context4;
  5564. (0, _forEach.default)(_context4 = (0, _keys.default)(metadata)).call(_context4, key => {
  5565. this.addMetadata(key, metadata[key]);
  5566. });
  5567. }
  5568. }
  5569. /**
  5570. * Sets metadata to be saved with file object. Adds to existing metadata.
  5571. *
  5572. * @param {string} key key to store the metadata
  5573. * @param {*} value metadata
  5574. */
  5575. addMetadata(key, value) {
  5576. if (typeof key === 'string') {
  5577. this._metadata[key] = value;
  5578. }
  5579. }
  5580. /**
  5581. * Sets tags to be saved with file object. Overwrites existing tags
  5582. *
  5583. * @param {object} tags Key value pairs to be stored with file object
  5584. */
  5585. setTags(tags) {
  5586. if (tags && typeof tags === 'object') {
  5587. var _context5;
  5588. (0, _forEach.default)(_context5 = (0, _keys.default)(tags)).call(_context5, key => {
  5589. this.addTag(key, tags[key]);
  5590. });
  5591. }
  5592. }
  5593. /**
  5594. * Sets tags to be saved with file object. Adds to existing tags.
  5595. *
  5596. * @param {string} key key to store tags
  5597. * @param {*} value tag
  5598. */
  5599. addTag(key, value) {
  5600. if (typeof key === 'string') {
  5601. this._tags[key] = value;
  5602. }
  5603. }
  5604. static fromJSON(obj) {
  5605. if (obj.__type !== 'File') {
  5606. throw new TypeError('JSON object does not represent a ParseFile');
  5607. }
  5608. const file = new ParseFile(obj.name);
  5609. file._url = obj.url;
  5610. return file;
  5611. }
  5612. static encodeBase64(bytes) {
  5613. const chunks = [];
  5614. chunks.length = Math.ceil(bytes.length / 3);
  5615. for (let i = 0; i < chunks.length; i++) {
  5616. const b1 = bytes[i * 3];
  5617. const b2 = bytes[i * 3 + 1] || 0;
  5618. const b3 = bytes[i * 3 + 2] || 0;
  5619. const has2 = i * 3 + 1 < bytes.length;
  5620. const has3 = i * 3 + 2 < bytes.length;
  5621. 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('');
  5622. }
  5623. return chunks.join('');
  5624. }
  5625. }
  5626. const DefaultController = {
  5627. saveFile: async function (name, source, options) {
  5628. if (source.format !== 'file') {
  5629. throw new Error('saveFile can only be used with File-type sources.');
  5630. }
  5631. const base64Data = await new _promise.default((res, rej) => {
  5632. // eslint-disable-next-line no-undef
  5633. const reader = new FileReader();
  5634. reader.onload = () => res(reader.result);
  5635. reader.onerror = error => rej(error);
  5636. reader.readAsDataURL(source.file);
  5637. });
  5638. // we only want the data after the comma
  5639. // For example: "data:application/pdf;base64,JVBERi0xLjQKJ..." we would only want "JVBERi0xLjQKJ..."
  5640. const [first, second] = base64Data.split(',');
  5641. // in the event there is no 'data:application/pdf;base64,' at the beginning of the base64 string
  5642. // use the entire string instead
  5643. const data = second ? second : first;
  5644. const newSource = {
  5645. format: 'base64',
  5646. base64: data,
  5647. type: source.type || (source.file ? source.file.type : undefined)
  5648. };
  5649. return await DefaultController.saveBase64(name, newSource, options);
  5650. },
  5651. saveBase64: function (name, source) {
  5652. let options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
  5653. if (source.format !== 'base64') {
  5654. throw new Error('saveBase64 can only be used with Base64-type sources.');
  5655. }
  5656. const data = {
  5657. base64: source.base64,
  5658. fileData: {
  5659. metadata: {
  5660. ...options.metadata
  5661. },
  5662. tags: {
  5663. ...options.tags
  5664. }
  5665. }
  5666. };
  5667. delete options.metadata;
  5668. delete options.tags;
  5669. if (source.type) {
  5670. data._ContentType = source.type;
  5671. }
  5672. return _CoreManager.default.getRESTController().request('POST', 'files/' + name, data, options);
  5673. },
  5674. download: function (uri, options) {
  5675. if (XHR) {
  5676. return this.downloadAjax(uri, options);
  5677. } else {
  5678. return _promise.default.reject('Cannot make a request: No definition of XMLHttpRequest was found.');
  5679. }
  5680. },
  5681. downloadAjax: function (uri, options) {
  5682. return new _promise.default((resolve, reject) => {
  5683. const xhr = new XHR();
  5684. xhr.open('GET', uri, true);
  5685. xhr.responseType = 'arraybuffer';
  5686. xhr.onerror = function (e) {
  5687. reject(e);
  5688. };
  5689. xhr.onreadystatechange = function () {
  5690. if (xhr.readyState !== xhr.DONE) {
  5691. return;
  5692. }
  5693. if (!this.response) {
  5694. return resolve({});
  5695. }
  5696. const bytes = new Uint8Array(this.response);
  5697. resolve({
  5698. base64: ParseFile.encodeBase64(bytes),
  5699. contentType: xhr.getResponseHeader('content-type')
  5700. });
  5701. };
  5702. options.requestTask(xhr);
  5703. xhr.send();
  5704. });
  5705. },
  5706. deleteFile: function (name, options) {
  5707. const headers = {
  5708. 'X-Parse-Application-ID': _CoreManager.default.get('APPLICATION_ID')
  5709. };
  5710. if (options.useMasterKey) {
  5711. headers['X-Parse-Master-Key'] = _CoreManager.default.get('MASTER_KEY');
  5712. }
  5713. let url = _CoreManager.default.get('SERVER_URL');
  5714. if (url[url.length - 1] !== '/') {
  5715. url += '/';
  5716. }
  5717. url += 'files/' + name;
  5718. return _CoreManager.default.getRESTController().ajax('DELETE', url, '', headers).catch(response => {
  5719. // TODO: return JSON object in server
  5720. if (!response || response === 'SyntaxError: Unexpected end of JSON input') {
  5721. return _promise.default.resolve();
  5722. } else {
  5723. return _CoreManager.default.getRESTController().handleError(response);
  5724. }
  5725. });
  5726. },
  5727. _setXHR(xhr) {
  5728. XHR = xhr;
  5729. },
  5730. _getXHR() {
  5731. return XHR;
  5732. }
  5733. };
  5734. _CoreManager.default.setFileController(DefaultController);
  5735. var _default = exports.default = ParseFile;
  5736. exports.b64Digit = b64Digit;
  5737. },{"./CoreManager":4,"./ParseError":24,"./Xhr.weapp":52,"@babel/runtime-corejs3/core-js-stable/array/is-array":66,"@babel/runtime-corejs3/core-js-stable/instance/for-each":74,"@babel/runtime-corejs3/core-js-stable/instance/index-of":76,"@babel/runtime-corejs3/core-js-stable/instance/slice":80,"@babel/runtime-corejs3/core-js-stable/object/define-property":90,"@babel/runtime-corejs3/core-js-stable/object/keys":95,"@babel/runtime-corejs3/core-js-stable/promise":97,"@babel/runtime-corejs3/helpers/defineProperty":102,"@babel/runtime-corejs3/helpers/interopRequireDefault":103}],26:[function(_dereq_,module,exports){
  5738. "use strict";
  5739. var _Object$defineProperty = _dereq_("@babel/runtime-corejs3/core-js-stable/object/define-property");
  5740. var _interopRequireDefault = _dereq_("@babel/runtime-corejs3/helpers/interopRequireDefault");
  5741. _Object$defineProperty(exports, "__esModule", {
  5742. value: true
  5743. });
  5744. exports.default = void 0;
  5745. var _isArray = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/array/is-array"));
  5746. var _promise = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/promise"));
  5747. var _defineProperty2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/helpers/defineProperty"));
  5748. /**
  5749. * Creates a new GeoPoint with any of the following forms:<br>
  5750. * <pre>
  5751. * new GeoPoint(otherGeoPoint)
  5752. * new GeoPoint(30, 30)
  5753. * new GeoPoint([30, 30])
  5754. * new GeoPoint({latitude: 30, longitude: 30})
  5755. * new GeoPoint() // defaults to (0, 0)
  5756. * </pre>
  5757. * <p>Represents a latitude / longitude point that may be associated
  5758. * with a key in a ParseObject or used as a reference point for geo queries.
  5759. * This allows proximity-based queries on the key.</p>
  5760. *
  5761. * <p>Only one key in a class may contain a GeoPoint.</p>
  5762. *
  5763. * <p>Example:<pre>
  5764. * var point = new Parse.GeoPoint(30.0, -20.0);
  5765. * var object = new Parse.Object("PlaceObject");
  5766. * object.set("location", point);
  5767. * object.save();</pre></p>
  5768. *
  5769. * @alias Parse.GeoPoint
  5770. */
  5771. /* global navigator */
  5772. class ParseGeoPoint {
  5773. /**
  5774. * @param {(number[] | object | number)} arg1 Either a list of coordinate pairs, an object with `latitude`, `longitude`, or the latitude or the point.
  5775. * @param {number} arg2 The longitude of the GeoPoint
  5776. */
  5777. constructor(arg1, arg2) {
  5778. (0, _defineProperty2.default)(this, "_latitude", void 0);
  5779. (0, _defineProperty2.default)(this, "_longitude", void 0);
  5780. if ((0, _isArray.default)(arg1)) {
  5781. ParseGeoPoint._validate(arg1[0], arg1[1]);
  5782. this._latitude = arg1[0];
  5783. this._longitude = arg1[1];
  5784. } else if (typeof arg1 === 'object') {
  5785. ParseGeoPoint._validate(arg1.latitude, arg1.longitude);
  5786. this._latitude = arg1.latitude;
  5787. this._longitude = arg1.longitude;
  5788. } else if (arg1 !== undefined && arg2 !== undefined) {
  5789. ParseGeoPoint._validate(arg1, arg2);
  5790. this._latitude = arg1;
  5791. this._longitude = arg2;
  5792. } else {
  5793. this._latitude = 0;
  5794. this._longitude = 0;
  5795. }
  5796. }
  5797. /**
  5798. * North-south portion of the coordinate, in range [-90, 90].
  5799. * Throws an exception if set out of range in a modern browser.
  5800. *
  5801. * @property {number} latitude
  5802. * @returns {number}
  5803. */
  5804. get latitude() {
  5805. return this._latitude;
  5806. }
  5807. set latitude(val) {
  5808. ParseGeoPoint._validate(val, this.longitude);
  5809. this._latitude = val;
  5810. }
  5811. /**
  5812. * East-west portion of the coordinate, in range [-180, 180].
  5813. * Throws if set out of range in a modern browser.
  5814. *
  5815. * @property {number} longitude
  5816. * @returns {number}
  5817. */
  5818. get longitude() {
  5819. return this._longitude;
  5820. }
  5821. set longitude(val) {
  5822. ParseGeoPoint._validate(this.latitude, val);
  5823. this._longitude = val;
  5824. }
  5825. /**
  5826. * Returns a JSON representation of the GeoPoint, suitable for Parse.
  5827. *
  5828. * @returns {object}
  5829. */
  5830. toJSON() {
  5831. ParseGeoPoint._validate(this._latitude, this._longitude);
  5832. return {
  5833. __type: 'GeoPoint',
  5834. latitude: this._latitude,
  5835. longitude: this._longitude
  5836. };
  5837. }
  5838. equals(other) {
  5839. return other instanceof ParseGeoPoint && this.latitude === other.latitude && this.longitude === other.longitude;
  5840. }
  5841. /**
  5842. * Returns the distance from this GeoPoint to another in radians.
  5843. *
  5844. * @param {Parse.GeoPoint} point the other Parse.GeoPoint.
  5845. * @returns {number}
  5846. */
  5847. radiansTo(point) {
  5848. const d2r = Math.PI / 180.0;
  5849. const lat1rad = this.latitude * d2r;
  5850. const long1rad = this.longitude * d2r;
  5851. const lat2rad = point.latitude * d2r;
  5852. const long2rad = point.longitude * d2r;
  5853. const sinDeltaLatDiv2 = Math.sin((lat1rad - lat2rad) / 2);
  5854. const sinDeltaLongDiv2 = Math.sin((long1rad - long2rad) / 2);
  5855. // Square of half the straight line chord distance between both points.
  5856. let a = sinDeltaLatDiv2 * sinDeltaLatDiv2 + Math.cos(lat1rad) * Math.cos(lat2rad) * sinDeltaLongDiv2 * sinDeltaLongDiv2;
  5857. a = Math.min(1.0, a);
  5858. return 2 * Math.asin(Math.sqrt(a));
  5859. }
  5860. /**
  5861. * Returns the distance from this GeoPoint to another in kilometers.
  5862. *
  5863. * @param {Parse.GeoPoint} point the other Parse.GeoPoint.
  5864. * @returns {number}
  5865. */
  5866. kilometersTo(point) {
  5867. return this.radiansTo(point) * 6371.0;
  5868. }
  5869. /**
  5870. * Returns the distance from this GeoPoint to another in miles.
  5871. *
  5872. * @param {Parse.GeoPoint} point the other Parse.GeoPoint.
  5873. * @returns {number}
  5874. */
  5875. milesTo(point) {
  5876. return this.radiansTo(point) * 3958.8;
  5877. }
  5878. /*
  5879. * Throws an exception if the given lat-long is out of bounds.
  5880. */
  5881. static _validate(latitude, longitude) {
  5882. if (isNaN(latitude) || isNaN(longitude) || typeof latitude !== 'number' || typeof longitude !== 'number') {
  5883. throw new TypeError('GeoPoint latitude and longitude must be valid numbers');
  5884. }
  5885. if (latitude < -90.0) {
  5886. throw new TypeError('GeoPoint latitude out of bounds: ' + latitude + ' < -90.0.');
  5887. }
  5888. if (latitude > 90.0) {
  5889. throw new TypeError('GeoPoint latitude out of bounds: ' + latitude + ' > 90.0.');
  5890. }
  5891. if (longitude < -180.0) {
  5892. throw new TypeError('GeoPoint longitude out of bounds: ' + longitude + ' < -180.0.');
  5893. }
  5894. if (longitude > 180.0) {
  5895. throw new TypeError('GeoPoint longitude out of bounds: ' + longitude + ' > 180.0.');
  5896. }
  5897. }
  5898. /**
  5899. * Creates a GeoPoint with the user's current location, if available.
  5900. *
  5901. * @param {object} options The options.
  5902. * @param {boolean} [options.enableHighAccuracy] A boolean value that indicates the application would like to receive the best possible results.
  5903. * If true and if the device is able to provide a more accurate position, it will do so.
  5904. * Note that this can result in slower response times or increased power consumption (with a GPS chip on a mobile device for example).
  5905. * On the other hand, if false, the device can take the liberty to save resources by responding more quickly and/or using less power. Default: false.
  5906. * @param {number} [options.timeout] A positive long value representing the maximum length of time (in milliseconds) the device is allowed to take in order to return a position.
  5907. * The default value is Infinity, meaning that getCurrentPosition() won't return until the position is available.
  5908. * @param {number} [options.maximumAge] A positive long value indicating the maximum age in milliseconds of a possible cached position that is acceptable to return.
  5909. * If set to 0, it means that the device cannot use a cached position and must attempt to retrieve the real current position.
  5910. * If set to Infinity the device must return a cached position regardless of its age. Default: 0.
  5911. * @static
  5912. * @returns {Promise<Parse.GeoPoint>} User's current location
  5913. */
  5914. static current(options) {
  5915. return new _promise.default((resolve, reject) => {
  5916. navigator.geolocation.getCurrentPosition(location => {
  5917. resolve(new ParseGeoPoint(location.coords.latitude, location.coords.longitude));
  5918. }, reject, options);
  5919. });
  5920. }
  5921. }
  5922. var _default = exports.default = ParseGeoPoint;
  5923. },{"@babel/runtime-corejs3/core-js-stable/array/is-array":66,"@babel/runtime-corejs3/core-js-stable/object/define-property":90,"@babel/runtime-corejs3/core-js-stable/promise":97,"@babel/runtime-corejs3/helpers/defineProperty":102,"@babel/runtime-corejs3/helpers/interopRequireDefault":103}],27:[function(_dereq_,module,exports){
  5924. "use strict";
  5925. var _Object$defineProperty = _dereq_("@babel/runtime-corejs3/core-js-stable/object/define-property");
  5926. var _interopRequireDefault = _dereq_("@babel/runtime-corejs3/helpers/interopRequireDefault");
  5927. _Object$defineProperty(exports, "__esModule", {
  5928. value: true
  5929. });
  5930. exports.create = create;
  5931. exports.createFunction = createFunction;
  5932. exports.createTrigger = createTrigger;
  5933. exports.getFunction = getFunction;
  5934. exports.getFunctions = getFunctions;
  5935. exports.getTrigger = getTrigger;
  5936. exports.getTriggers = getTriggers;
  5937. exports.remove = remove;
  5938. exports.removeFunction = removeFunction;
  5939. exports.removeTrigger = removeTrigger;
  5940. exports.update = update;
  5941. exports.updateFunction = updateFunction;
  5942. exports.updateTrigger = updateTrigger;
  5943. var _promise = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/promise"));
  5944. var _CoreManager = _interopRequireDefault(_dereq_("./CoreManager"));
  5945. var _decode = _interopRequireDefault(_dereq_("./decode"));
  5946. var _ParseError = _interopRequireDefault(_dereq_("./ParseError"));
  5947. function getFunctions() {
  5948. return _CoreManager.default.getHooksController().get('functions');
  5949. }
  5950. function getTriggers() {
  5951. return _CoreManager.default.getHooksController().get('triggers');
  5952. }
  5953. function getFunction(name) {
  5954. return _CoreManager.default.getHooksController().get('functions', name);
  5955. }
  5956. function getTrigger(className, triggerName) {
  5957. return _CoreManager.default.getHooksController().get('triggers', className, triggerName);
  5958. }
  5959. function createFunction(functionName, url) {
  5960. return create({
  5961. functionName: functionName,
  5962. url: url
  5963. });
  5964. }
  5965. function createTrigger(className, triggerName, url) {
  5966. return create({
  5967. className: className,
  5968. triggerName: triggerName,
  5969. url: url
  5970. });
  5971. }
  5972. function create(hook) {
  5973. return _CoreManager.default.getHooksController().create(hook);
  5974. }
  5975. function updateFunction(functionName, url) {
  5976. return update({
  5977. functionName: functionName,
  5978. url: url
  5979. });
  5980. }
  5981. function updateTrigger(className, triggerName, url) {
  5982. return update({
  5983. className: className,
  5984. triggerName: triggerName,
  5985. url: url
  5986. });
  5987. }
  5988. function update(hook) {
  5989. return _CoreManager.default.getHooksController().update(hook);
  5990. }
  5991. function removeFunction(functionName) {
  5992. return remove({
  5993. functionName: functionName
  5994. });
  5995. }
  5996. function removeTrigger(className, triggerName) {
  5997. return remove({
  5998. className: className,
  5999. triggerName: triggerName
  6000. });
  6001. }
  6002. function remove(hook) {
  6003. return _CoreManager.default.getHooksController().remove(hook);
  6004. }
  6005. const DefaultController = {
  6006. get(type, functionName, triggerName) {
  6007. let url = '/hooks/' + type;
  6008. if (functionName) {
  6009. url += '/' + functionName;
  6010. if (triggerName) {
  6011. url += '/' + triggerName;
  6012. }
  6013. }
  6014. return this.sendRequest('GET', url);
  6015. },
  6016. create(hook) {
  6017. let url;
  6018. if (hook.functionName && hook.url) {
  6019. url = '/hooks/functions';
  6020. } else if (hook.className && hook.triggerName && hook.url) {
  6021. url = '/hooks/triggers';
  6022. } else {
  6023. return _promise.default.reject({
  6024. error: 'invalid hook declaration',
  6025. code: 143
  6026. });
  6027. }
  6028. return this.sendRequest('POST', url, hook);
  6029. },
  6030. remove(hook) {
  6031. let url;
  6032. if (hook.functionName) {
  6033. url = '/hooks/functions/' + hook.functionName;
  6034. delete hook.functionName;
  6035. } else if (hook.className && hook.triggerName) {
  6036. url = '/hooks/triggers/' + hook.className + '/' + hook.triggerName;
  6037. delete hook.className;
  6038. delete hook.triggerName;
  6039. } else {
  6040. return _promise.default.reject({
  6041. error: 'invalid hook declaration',
  6042. code: 143
  6043. });
  6044. }
  6045. return this.sendRequest('PUT', url, {
  6046. __op: 'Delete'
  6047. });
  6048. },
  6049. update(hook) {
  6050. let url;
  6051. if (hook.functionName && hook.url) {
  6052. url = '/hooks/functions/' + hook.functionName;
  6053. delete hook.functionName;
  6054. } else if (hook.className && hook.triggerName && hook.url) {
  6055. url = '/hooks/triggers/' + hook.className + '/' + hook.triggerName;
  6056. delete hook.className;
  6057. delete hook.triggerName;
  6058. } else {
  6059. return _promise.default.reject({
  6060. error: 'invalid hook declaration',
  6061. code: 143
  6062. });
  6063. }
  6064. return this.sendRequest('PUT', url, hook);
  6065. },
  6066. sendRequest(method, url, body) {
  6067. return _CoreManager.default.getRESTController().request(method, url, body, {
  6068. useMasterKey: true
  6069. }).then(res => {
  6070. const decoded = (0, _decode.default)(res);
  6071. if (decoded) {
  6072. return _promise.default.resolve(decoded);
  6073. }
  6074. return _promise.default.reject(new _ParseError.default(_ParseError.default.INVALID_JSON, 'The server returned an invalid response.'));
  6075. });
  6076. }
  6077. };
  6078. _CoreManager.default.setHooksController(DefaultController);
  6079. },{"./CoreManager":4,"./ParseError":24,"./decode":55,"@babel/runtime-corejs3/core-js-stable/object/define-property":90,"@babel/runtime-corejs3/core-js-stable/promise":97,"@babel/runtime-corejs3/helpers/interopRequireDefault":103}],28:[function(_dereq_,module,exports){
  6080. "use strict";
  6081. var _Object$defineProperty = _dereq_("@babel/runtime-corejs3/core-js-stable/object/define-property");
  6082. var _interopRequireDefault = _dereq_("@babel/runtime-corejs3/helpers/interopRequireDefault");
  6083. _Object$defineProperty(exports, "__esModule", {
  6084. value: true
  6085. });
  6086. exports.default = void 0;
  6087. var _entries = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/object/entries"));
  6088. var _CoreManager = _interopRequireDefault(_dereq_("./CoreManager"));
  6089. var _ParseError = _interopRequireDefault(_dereq_("./ParseError"));
  6090. var _ParseObject = _interopRequireDefault(_dereq_("./ParseObject"));
  6091. const DEVICE_TYPES = {
  6092. IOS: 'ios',
  6093. MACOS: 'macos',
  6094. TVOS: 'tvos',
  6095. FCM: 'fcm',
  6096. ANDROID: 'android',
  6097. WEB: 'web'
  6098. };
  6099. /**
  6100. * Parse.Installation is a local representation of installation data that can be saved and retrieved from the Parse cloud.
  6101. * This class is a subclass of a Parse.Object, and retains the same functionality of a Parse.Object, but also extends it with installation-specific features.
  6102. *
  6103. * <p>A valid Parse.Installation can only be instantiated via <code>Parse.Installation.currentInstallation()</code>
  6104. *
  6105. * Parse.Installation objects which have a valid <code>deviceToken</code> and are saved to the Parse cloud can be used to target push notifications.
  6106. * </p>
  6107. *
  6108. * @alias Parse.Installation
  6109. */
  6110. class ParseInstallation extends _ParseObject.default {
  6111. /**
  6112. * @param {object} attributes The initial set of data to store in the object.
  6113. */
  6114. constructor(attributes) {
  6115. super('_Installation');
  6116. if (attributes && typeof attributes === 'object') {
  6117. if (!this.set(attributes)) {
  6118. throw new Error("Can't create an invalid Installation");
  6119. }
  6120. }
  6121. }
  6122. /**
  6123. * A unique identifier for this installation’s client application. In iOS, this is the Bundle Identifier.
  6124. *
  6125. * @property {string} appIdentifier
  6126. * @static
  6127. * @returns {string}
  6128. */
  6129. get appIdentifier() {
  6130. return this.get('appIdentifier');
  6131. }
  6132. /**
  6133. * The version string of the client application to which this installation belongs.
  6134. *
  6135. * @property {string} appVersion
  6136. * @static
  6137. * @returns {string}
  6138. */
  6139. get appVersion() {
  6140. return this.get('appVersion');
  6141. }
  6142. /**
  6143. * The display name of the client application to which this installation belongs.
  6144. *
  6145. * @property {string} appName
  6146. * @static
  6147. * @returns {string}
  6148. */
  6149. get appName() {
  6150. return this.get('appName');
  6151. }
  6152. /**
  6153. * The current value of the icon badge for iOS apps.
  6154. * Changes to this value on the server will be used
  6155. * for future badge-increment push notifications.
  6156. *
  6157. * @property {number} badge
  6158. * @static
  6159. * @returns {number}
  6160. */
  6161. get badge() {
  6162. return this.get('badge');
  6163. }
  6164. /**
  6165. * An array of the channels to which a device is currently subscribed.
  6166. *
  6167. * @property {string[]} channels
  6168. * @static
  6169. * @returns {string[]}
  6170. */
  6171. get channels() {
  6172. return this.get('channels');
  6173. }
  6174. /**
  6175. * Token used to deliver push notifications to the device.
  6176. *
  6177. * @property {string} deviceToken
  6178. * @static
  6179. * @returns {string}
  6180. */
  6181. get deviceToken() {
  6182. return this.get('deviceToken');
  6183. }
  6184. /**
  6185. * The type of device, “ios”, “android”, “web”, etc.
  6186. *
  6187. * @property {string} deviceType
  6188. * @static
  6189. * @returns {string}
  6190. */
  6191. get deviceType() {
  6192. return this.get('deviceType');
  6193. }
  6194. /**
  6195. * Gets the GCM sender identifier for this installation
  6196. *
  6197. * @property {string} GCMSenderId
  6198. * @static
  6199. * @returns {string}
  6200. */
  6201. get GCMSenderId() {
  6202. return this.get('GCMSenderId');
  6203. }
  6204. /**
  6205. * Universally Unique Identifier (UUID) for the device used by Parse. It must be unique across all of an app’s installations.
  6206. *
  6207. * @property {string} installationId
  6208. * @static
  6209. * @returns {string}
  6210. */
  6211. get installationId() {
  6212. return this.get('installationId');
  6213. }
  6214. /**
  6215. * Gets the local identifier for this installation
  6216. *
  6217. * @property {string} localeIdentifier
  6218. * @static
  6219. * @returns {string}
  6220. */
  6221. get localeIdentifier() {
  6222. return this.get('localeIdentifier');
  6223. }
  6224. /**
  6225. * Gets the parse server version for this installation
  6226. *
  6227. * @property {string} parseVersion
  6228. * @static
  6229. * @returns {string}
  6230. */
  6231. get parseVersion() {
  6232. return this.get('parseVersion');
  6233. }
  6234. /**
  6235. * This field is reserved for directing Parse to the push delivery network to be used.
  6236. *
  6237. * @property {string} pushType
  6238. * @static
  6239. * @returns {string}
  6240. */
  6241. get pushType() {
  6242. return this.get('pushType');
  6243. }
  6244. /**
  6245. * Gets the time zone for this installation
  6246. *
  6247. * @property {string} timeZone
  6248. * @static
  6249. * @returns {string}
  6250. */
  6251. get timeZone() {
  6252. return this.get('timeZone');
  6253. }
  6254. /**
  6255. * Returns the device types for used for Push Notifications.
  6256. *
  6257. * <pre>
  6258. * Parse.Installation.DEVICE_TYPES.IOS
  6259. * Parse.Installation.DEVICE_TYPES.MACOS
  6260. * Parse.Installation.DEVICE_TYPES.TVOS
  6261. * Parse.Installation.DEVICE_TYPES.FCM
  6262. * Parse.Installation.DEVICE_TYPES.ANDROID
  6263. * Parse.Installation.DEVICE_TYPES.WEB
  6264. * </pre
  6265. *
  6266. * @property {object} DEVICE_TYPES
  6267. * @static
  6268. * @returns {object}
  6269. */
  6270. static get DEVICE_TYPES() {
  6271. return DEVICE_TYPES;
  6272. }
  6273. /**
  6274. * Wrap the default fetch behavior with functionality to update local storage.
  6275. * If the installation is deleted on the server, retry the fetch as a save operation.
  6276. *
  6277. * @param {...any} args
  6278. * @returns {Promise}
  6279. */
  6280. async fetch() {
  6281. for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
  6282. args[_key] = arguments[_key];
  6283. }
  6284. try {
  6285. await super.fetch.apply(this, args);
  6286. } catch (e) {
  6287. if (e.code !== _ParseError.default.OBJECT_NOT_FOUND) {
  6288. throw e;
  6289. }
  6290. // The installation was deleted from the server.
  6291. // We always want fetch to succeed.
  6292. delete this.id;
  6293. this._getId(); // Generate localId
  6294. this._markAllFieldsDirty();
  6295. await super.save.apply(this, args);
  6296. }
  6297. await _CoreManager.default.getInstallationController().updateInstallationOnDisk(this);
  6298. return this;
  6299. }
  6300. /**
  6301. * Wrap the default save behavior with functionality to update the local storage.
  6302. * If the installation is deleted on the server, retry saving a new installation.
  6303. *
  6304. * @param {...any} args
  6305. * @returns {Promise}
  6306. */
  6307. async save() {
  6308. for (var _len2 = arguments.length, args = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
  6309. args[_key2] = arguments[_key2];
  6310. }
  6311. try {
  6312. await super.save.apply(this, args);
  6313. } catch (e) {
  6314. if (e.code !== _ParseError.default.OBJECT_NOT_FOUND) {
  6315. throw e;
  6316. }
  6317. // The installation was deleted from the server.
  6318. // We always want save to succeed.
  6319. delete this.id;
  6320. this._getId(); // Generate localId
  6321. this._markAllFieldsDirty();
  6322. await super.save.apply(this, args);
  6323. }
  6324. await _CoreManager.default.getInstallationController().updateInstallationOnDisk(this);
  6325. return this;
  6326. }
  6327. _markAllFieldsDirty() {
  6328. for (const [key, value] of (0, _entries.default)(this.attributes)) {
  6329. this.set(key, value);
  6330. }
  6331. }
  6332. /**
  6333. * Get the current Parse.Installation from disk. If doesn't exists, create an new installation.
  6334. *
  6335. * <pre>
  6336. * const installation = await Parse.Installation.currentInstallation();
  6337. * installation.set('deviceToken', '123');
  6338. * await installation.save();
  6339. * </pre>
  6340. *
  6341. * @returns {Promise} A promise that resolves to the local installation object.
  6342. */
  6343. static currentInstallation() {
  6344. return _CoreManager.default.getInstallationController().currentInstallation();
  6345. }
  6346. }
  6347. _ParseObject.default.registerSubclass('_Installation', ParseInstallation);
  6348. module.exports = ParseInstallation;
  6349. var _default = exports.default = ParseInstallation;
  6350. },{"./CoreManager":4,"./ParseError":24,"./ParseObject":30,"@babel/runtime-corejs3/core-js-stable/object/define-property":90,"@babel/runtime-corejs3/core-js-stable/object/entries":91,"@babel/runtime-corejs3/helpers/interopRequireDefault":103}],29:[function(_dereq_,module,exports){
  6351. "use strict";
  6352. var _Object$defineProperty = _dereq_("@babel/runtime-corejs3/core-js-stable/object/define-property");
  6353. var _interopRequireDefault = _dereq_("@babel/runtime-corejs3/helpers/interopRequireDefault");
  6354. _Object$defineProperty(exports, "__esModule", {
  6355. value: true
  6356. });
  6357. exports.default = void 0;
  6358. var _promise = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/promise"));
  6359. var _indexOf = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/instance/index-of"));
  6360. var _defineProperty2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/helpers/defineProperty"));
  6361. var _LiveQueryClient = _interopRequireDefault(_dereq_("./LiveQueryClient"));
  6362. var _CoreManager = _interopRequireDefault(_dereq_("./CoreManager"));
  6363. function getLiveQueryClient() {
  6364. return _CoreManager.default.getLiveQueryController().getDefaultLiveQueryClient();
  6365. }
  6366. /**
  6367. * We expose three events to help you monitor the status of the WebSocket connection:
  6368. *
  6369. * <p>Open - When we establish the WebSocket connection to the LiveQuery server, you'll get this event.
  6370. *
  6371. * <pre>
  6372. * Parse.LiveQuery.on('open', () => {
  6373. *
  6374. * });</pre></p>
  6375. *
  6376. * <p>Close - When we lose the WebSocket connection to the LiveQuery server, you'll get this event.
  6377. *
  6378. * <pre>
  6379. * Parse.LiveQuery.on('close', () => {
  6380. *
  6381. * });</pre></p>
  6382. *
  6383. * <p>Error - When some network error or LiveQuery server error happens, you'll get this event.
  6384. *
  6385. * <pre>
  6386. * Parse.LiveQuery.on('error', (error) => {
  6387. *
  6388. * });</pre></p>
  6389. *
  6390. * @class Parse.LiveQuery
  6391. * @static
  6392. */
  6393. class LiveQuery {
  6394. constructor() {
  6395. var _this = this;
  6396. (0, _defineProperty2.default)(this, "emitter", void 0);
  6397. (0, _defineProperty2.default)(this, "on", void 0);
  6398. (0, _defineProperty2.default)(this, "emit", void 0);
  6399. const EventEmitter = _CoreManager.default.getEventEmitter();
  6400. this.emitter = new EventEmitter();
  6401. this.on = (eventName, listener) => this.emitter.on(eventName, listener);
  6402. this.emit = function (eventName) {
  6403. for (var _len = arguments.length, args = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
  6404. args[_key - 1] = arguments[_key];
  6405. }
  6406. return _this.emitter.emit(eventName, ...args);
  6407. };
  6408. // adding listener so process does not crash
  6409. // best practice is for developer to register their own listener
  6410. this.on('error', () => {});
  6411. }
  6412. /**
  6413. * After open is called, the LiveQuery will try to send a connect request
  6414. * to the LiveQuery server.
  6415. */
  6416. async open() {
  6417. const liveQueryClient = await getLiveQueryClient();
  6418. liveQueryClient.open();
  6419. }
  6420. /**
  6421. * When you're done using LiveQuery, you can call Parse.LiveQuery.close().
  6422. * This function will close the WebSocket connection to the LiveQuery server,
  6423. * cancel the auto reconnect, and unsubscribe all subscriptions based on it.
  6424. * If you call query.subscribe() after this, we'll create a new WebSocket
  6425. * connection to the LiveQuery server.
  6426. */
  6427. async close() {
  6428. const liveQueryClient = await getLiveQueryClient();
  6429. liveQueryClient.close();
  6430. }
  6431. }
  6432. var _default = exports.default = LiveQuery;
  6433. let defaultLiveQueryClient;
  6434. const DefaultLiveQueryController = {
  6435. setDefaultLiveQueryClient(liveQueryClient) {
  6436. defaultLiveQueryClient = liveQueryClient;
  6437. },
  6438. async getDefaultLiveQueryClient() {
  6439. if (defaultLiveQueryClient) {
  6440. return defaultLiveQueryClient;
  6441. }
  6442. const [currentUser, installationId] = await _promise.default.all([_CoreManager.default.getUserController().currentUserAsync(), _CoreManager.default.getInstallationController().currentInstallationId()]);
  6443. const sessionToken = currentUser ? currentUser.getSessionToken() : undefined;
  6444. let liveQueryServerURL = _CoreManager.default.get('LIVEQUERY_SERVER_URL');
  6445. if (liveQueryServerURL && (0, _indexOf.default)(liveQueryServerURL).call(liveQueryServerURL, 'ws') !== 0) {
  6446. throw new Error('You need to set a proper Parse LiveQuery server url before using LiveQueryClient');
  6447. }
  6448. // If we can not find Parse.liveQueryServerURL, we try to extract it from Parse.serverURL
  6449. if (!liveQueryServerURL) {
  6450. const serverURL = _CoreManager.default.get('SERVER_URL');
  6451. const protocol = (0, _indexOf.default)(serverURL).call(serverURL, 'https') === 0 ? 'wss://' : 'ws://';
  6452. const host = serverURL.replace(/^https?:\/\//, '');
  6453. liveQueryServerURL = protocol + host;
  6454. _CoreManager.default.set('LIVEQUERY_SERVER_URL', liveQueryServerURL);
  6455. }
  6456. const applicationId = _CoreManager.default.get('APPLICATION_ID');
  6457. const javascriptKey = _CoreManager.default.get('JAVASCRIPT_KEY');
  6458. const masterKey = _CoreManager.default.get('MASTER_KEY');
  6459. defaultLiveQueryClient = new _LiveQueryClient.default({
  6460. applicationId,
  6461. serverURL: liveQueryServerURL,
  6462. javascriptKey,
  6463. masterKey,
  6464. sessionToken,
  6465. installationId
  6466. });
  6467. const LiveQuery = _CoreManager.default.getLiveQuery();
  6468. defaultLiveQueryClient.on('error', error => {
  6469. LiveQuery.emit('error', error);
  6470. });
  6471. defaultLiveQueryClient.on('open', () => {
  6472. LiveQuery.emit('open');
  6473. });
  6474. defaultLiveQueryClient.on('close', () => {
  6475. LiveQuery.emit('close');
  6476. });
  6477. return defaultLiveQueryClient;
  6478. },
  6479. _clearCachedDefaultClient() {
  6480. defaultLiveQueryClient = null;
  6481. }
  6482. };
  6483. _CoreManager.default.setLiveQueryController(DefaultLiveQueryController);
  6484. },{"./CoreManager":4,"./LiveQueryClient":11,"@babel/runtime-corejs3/core-js-stable/instance/index-of":76,"@babel/runtime-corejs3/core-js-stable/object/define-property":90,"@babel/runtime-corejs3/core-js-stable/promise":97,"@babel/runtime-corejs3/helpers/defineProperty":102,"@babel/runtime-corejs3/helpers/interopRequireDefault":103}],30:[function(_dereq_,module,exports){
  6485. "use strict";
  6486. var _WeakMap = _dereq_("@babel/runtime-corejs3/core-js-stable/weak-map");
  6487. var _Object$defineProperty2 = _dereq_("@babel/runtime-corejs3/core-js-stable/object/define-property");
  6488. var _Object$getOwnPropertyDescriptor = _dereq_("@babel/runtime-corejs3/core-js-stable/object/get-own-property-descriptor");
  6489. var _interopRequireDefault = _dereq_("@babel/runtime-corejs3/helpers/interopRequireDefault");
  6490. _Object$defineProperty2(exports, "__esModule", {
  6491. value: true
  6492. });
  6493. exports.default = void 0;
  6494. var _defineProperty2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/helpers/defineProperty"));
  6495. var _indexOf = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/instance/index-of"));
  6496. var _freeze = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/object/freeze"));
  6497. var _keys = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/object/keys"));
  6498. var _forEach = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/instance/for-each"));
  6499. var _stringify = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/json/stringify"));
  6500. var _includes = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/instance/includes"));
  6501. var _getPrototypeOf = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/object/get-prototype-of"));
  6502. var _concat = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/instance/concat"));
  6503. var _isArray = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/array/is-array"));
  6504. var _promise = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/promise"));
  6505. var _create = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/object/create"));
  6506. var _defineProperty3 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/object/define-property"));
  6507. var _find = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/instance/find"));
  6508. var _map = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/instance/map"));
  6509. var _CoreManager = _interopRequireDefault(_dereq_("./CoreManager"));
  6510. var _canBeSerialized = _interopRequireDefault(_dereq_("./canBeSerialized"));
  6511. var _decode = _interopRequireDefault(_dereq_("./decode"));
  6512. var _encode = _interopRequireDefault(_dereq_("./encode"));
  6513. var _escape = _interopRequireDefault(_dereq_("./escape"));
  6514. var _ParseACL = _interopRequireDefault(_dereq_("./ParseACL"));
  6515. var _parseDate = _interopRequireDefault(_dereq_("./parseDate"));
  6516. var _ParseError = _interopRequireDefault(_dereq_("./ParseError"));
  6517. var _ParseFile = _interopRequireDefault(_dereq_("./ParseFile"));
  6518. var _promiseUtils = _dereq_("./promiseUtils");
  6519. var _LocalDatastoreUtils = _dereq_("./LocalDatastoreUtils");
  6520. var _uuid = _interopRequireDefault(_dereq_("./uuid"));
  6521. var _ParseOp = _dereq_("./ParseOp");
  6522. var _ParseRelation = _interopRequireDefault(_dereq_("./ParseRelation"));
  6523. var SingleInstanceStateController = _interopRequireWildcard(_dereq_("./SingleInstanceStateController"));
  6524. var _unique = _interopRequireDefault(_dereq_("./unique"));
  6525. var UniqueInstanceStateController = _interopRequireWildcard(_dereq_("./UniqueInstanceStateController"));
  6526. var _unsavedChildren = _interopRequireDefault(_dereq_("./unsavedChildren"));
  6527. function _getRequireWildcardCache(e) {
  6528. if ("function" != typeof _WeakMap) return null;
  6529. var r = new _WeakMap(),
  6530. t = new _WeakMap();
  6531. return (_getRequireWildcardCache = function (e) {
  6532. return e ? t : r;
  6533. })(e);
  6534. }
  6535. function _interopRequireWildcard(e, r) {
  6536. if (!r && e && e.__esModule) return e;
  6537. if (null === e || "object" != typeof e && "function" != typeof e) return {
  6538. default: e
  6539. };
  6540. var t = _getRequireWildcardCache(r);
  6541. if (t && t.has(e)) return t.get(e);
  6542. var n = {
  6543. __proto__: null
  6544. };
  6545. for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) {
  6546. var i = _Object$defineProperty2 && _Object$getOwnPropertyDescriptor ? _Object$getOwnPropertyDescriptor(e, u) : null;
  6547. i && (i.get || i.set) ? _Object$defineProperty2(n, u, i) : n[u] = e[u];
  6548. }
  6549. return n.default = e, t && t.set(e, n), n;
  6550. }
  6551. // Mapping of class names to constructors, so we can populate objects from the
  6552. // server with appropriate subclasses of ParseObject
  6553. const classMap = {};
  6554. // Global counter for generating unique Ids for non-single-instance objects
  6555. let objectCount = 0;
  6556. // On web clients, objects are single-instance: any two objects with the same Id
  6557. // will have the same attributes. However, this may be dangerous default
  6558. // behavior in a server scenario
  6559. let singleInstance = !_CoreManager.default.get('IS_NODE');
  6560. if (singleInstance) {
  6561. _CoreManager.default.setObjectStateController(SingleInstanceStateController);
  6562. } else {
  6563. _CoreManager.default.setObjectStateController(UniqueInstanceStateController);
  6564. }
  6565. function getServerUrlPath() {
  6566. let serverUrl = _CoreManager.default.get('SERVER_URL');
  6567. if (serverUrl[serverUrl.length - 1] !== '/') {
  6568. serverUrl += '/';
  6569. }
  6570. const url = serverUrl.replace(/https?:\/\//, '');
  6571. return url.substr((0, _indexOf.default)(url).call(url, '/'));
  6572. }
  6573. /**
  6574. * Creates a new model with defined attributes.
  6575. *
  6576. * <p>You won't normally call this method directly. It is recommended that
  6577. * you use a subclass of <code>Parse.Object</code> instead, created by calling
  6578. * <code>extend</code>.</p>
  6579. *
  6580. * <p>However, if you don't want to use a subclass, or aren't sure which
  6581. * subclass is appropriate, you can use this form:<pre>
  6582. * var object = new Parse.Object("ClassName");
  6583. * </pre>
  6584. * That is basically equivalent to:<pre>
  6585. * var MyClass = Parse.Object.extend("ClassName");
  6586. * var object = new MyClass();
  6587. * </pre></p>
  6588. *
  6589. * @alias Parse.Object
  6590. */
  6591. class ParseObject {
  6592. /**
  6593. * @param {string} className The class name for the object
  6594. * @param {object} attributes The initial set of data to store in the object.
  6595. * @param {object} options The options for this object instance.
  6596. * @param {boolean} [options.ignoreValidation] Set to `true` ignore any attribute validation errors.
  6597. */
  6598. constructor(className, attributes, options) {
  6599. /**
  6600. * The ID of this object, unique within its class.
  6601. *
  6602. * @property {string} id
  6603. */
  6604. (0, _defineProperty2.default)(this, "id", void 0);
  6605. (0, _defineProperty2.default)(this, "_localId", void 0);
  6606. (0, _defineProperty2.default)(this, "_objCount", void 0);
  6607. (0, _defineProperty2.default)(this, "className", void 0);
  6608. // Enable legacy initializers
  6609. if (typeof this.initialize === 'function') {
  6610. this.initialize.apply(this, arguments);
  6611. }
  6612. let toSet = null;
  6613. this._objCount = objectCount++;
  6614. if (typeof className === 'string') {
  6615. this.className = className;
  6616. if (attributes && typeof attributes === 'object') {
  6617. toSet = attributes;
  6618. }
  6619. } else if (className && typeof className === 'object') {
  6620. this.className = className.className;
  6621. toSet = {};
  6622. for (const attr in className) {
  6623. if (attr !== 'className') {
  6624. toSet[attr] = className[attr];
  6625. }
  6626. }
  6627. if (attributes && typeof attributes === 'object') {
  6628. options = attributes;
  6629. }
  6630. }
  6631. if (toSet && !this.set(toSet, options)) {
  6632. throw new Error("Can't create an invalid Parse Object");
  6633. }
  6634. }
  6635. /* Prototype getters / setters */
  6636. get attributes() {
  6637. const stateController = _CoreManager.default.getObjectStateController();
  6638. return (0, _freeze.default)(stateController.estimateAttributes(this._getStateIdentifier()));
  6639. }
  6640. /**
  6641. * The first time this object was saved on the server.
  6642. *
  6643. * @property {Date} createdAt
  6644. * @returns {Date}
  6645. */
  6646. get createdAt() {
  6647. return this._getServerData().createdAt;
  6648. }
  6649. /**
  6650. * The last time this object was updated on the server.
  6651. *
  6652. * @property {Date} updatedAt
  6653. * @returns {Date}
  6654. */
  6655. get updatedAt() {
  6656. return this._getServerData().updatedAt;
  6657. }
  6658. /* Private methods */
  6659. /**
  6660. * Returns a local or server Id used uniquely identify this object
  6661. *
  6662. * @returns {string}
  6663. */
  6664. _getId() {
  6665. if (typeof this.id === 'string') {
  6666. return this.id;
  6667. }
  6668. if (typeof this._localId === 'string') {
  6669. return this._localId;
  6670. }
  6671. const localId = 'local' + (0, _uuid.default)();
  6672. this._localId = localId;
  6673. return localId;
  6674. }
  6675. /**
  6676. * Returns a unique identifier used to pull data from the State Controller.
  6677. *
  6678. * @returns {Parse.Object|object}
  6679. */
  6680. _getStateIdentifier() {
  6681. if (singleInstance) {
  6682. let id = this.id;
  6683. if (!id) {
  6684. id = this._getId();
  6685. }
  6686. return {
  6687. id: id,
  6688. className: this.className
  6689. };
  6690. } else {
  6691. return this;
  6692. }
  6693. }
  6694. _getServerData() {
  6695. const stateController = _CoreManager.default.getObjectStateController();
  6696. return stateController.getServerData(this._getStateIdentifier());
  6697. }
  6698. _clearServerData() {
  6699. const serverData = this._getServerData();
  6700. const unset = {};
  6701. for (const attr in serverData) {
  6702. unset[attr] = undefined;
  6703. }
  6704. const stateController = _CoreManager.default.getObjectStateController();
  6705. stateController.setServerData(this._getStateIdentifier(), unset);
  6706. }
  6707. _getPendingOps() {
  6708. const stateController = _CoreManager.default.getObjectStateController();
  6709. return stateController.getPendingOps(this._getStateIdentifier());
  6710. }
  6711. /**
  6712. * @param {Array<string>} [keysToClear] - if specified, only ops matching
  6713. * these fields will be cleared
  6714. */
  6715. _clearPendingOps(keysToClear) {
  6716. const pending = this._getPendingOps();
  6717. const latest = pending[pending.length - 1];
  6718. const keys = keysToClear || (0, _keys.default)(latest);
  6719. (0, _forEach.default)(keys).call(keys, key => {
  6720. delete latest[key];
  6721. });
  6722. }
  6723. _getDirtyObjectAttributes() {
  6724. const attributes = this.attributes;
  6725. const stateController = _CoreManager.default.getObjectStateController();
  6726. const objectCache = stateController.getObjectCache(this._getStateIdentifier());
  6727. const dirty = {};
  6728. for (const attr in attributes) {
  6729. const val = attributes[attr];
  6730. if (val && typeof val === 'object' && !(val instanceof ParseObject) && !(val instanceof _ParseFile.default) && !(val instanceof _ParseRelation.default)) {
  6731. // Due to the way browsers construct maps, the key order will not change
  6732. // unless the object is changed
  6733. try {
  6734. const json = (0, _encode.default)(val, false, true);
  6735. const stringified = (0, _stringify.default)(json);
  6736. if (objectCache[attr] !== stringified) {
  6737. dirty[attr] = val;
  6738. }
  6739. } catch (e) {
  6740. // Error occurred, possibly by a nested unsaved pointer in a mutable container
  6741. // No matter how it happened, it indicates a change in the attribute
  6742. dirty[attr] = val;
  6743. }
  6744. }
  6745. }
  6746. return dirty;
  6747. }
  6748. _toFullJSON(seen, offline) {
  6749. const json = this.toJSON(seen, offline);
  6750. json.__type = 'Object';
  6751. json.className = this.className;
  6752. return json;
  6753. }
  6754. _getSaveJSON() {
  6755. const pending = this._getPendingOps();
  6756. const dirtyObjects = this._getDirtyObjectAttributes();
  6757. const json = {};
  6758. for (var attr in dirtyObjects) {
  6759. let isDotNotation = false;
  6760. for (let i = 0; i < pending.length; i += 1) {
  6761. for (const field in pending[i]) {
  6762. // Dot notation operations are handled later
  6763. if ((0, _includes.default)(field).call(field, '.')) {
  6764. const fieldName = field.split('.')[0];
  6765. if (fieldName === attr) {
  6766. isDotNotation = true;
  6767. break;
  6768. }
  6769. }
  6770. }
  6771. }
  6772. if (!isDotNotation) {
  6773. json[attr] = new _ParseOp.SetOp(dirtyObjects[attr]).toJSON();
  6774. }
  6775. }
  6776. for (attr in pending[0]) {
  6777. json[attr] = pending[0][attr].toJSON();
  6778. }
  6779. return json;
  6780. }
  6781. _getSaveParams() {
  6782. let method = this.id ? 'PUT' : 'POST';
  6783. const body = this._getSaveJSON();
  6784. let path = 'classes/' + this.className;
  6785. if (_CoreManager.default.get('ALLOW_CUSTOM_OBJECT_ID')) {
  6786. if (!this.createdAt) {
  6787. method = 'POST';
  6788. body.objectId = this.id;
  6789. } else {
  6790. method = 'PUT';
  6791. path += '/' + this.id;
  6792. }
  6793. } else if (this.id) {
  6794. path += '/' + this.id;
  6795. } else if (this.className === '_User') {
  6796. path = 'users';
  6797. }
  6798. return {
  6799. method,
  6800. body,
  6801. path
  6802. };
  6803. }
  6804. _finishFetch(serverData) {
  6805. if (!this.id && serverData.objectId) {
  6806. this.id = serverData.objectId;
  6807. }
  6808. const stateController = _CoreManager.default.getObjectStateController();
  6809. stateController.initializeState(this._getStateIdentifier());
  6810. const decoded = {};
  6811. for (const attr in serverData) {
  6812. if (attr === 'ACL') {
  6813. decoded[attr] = new _ParseACL.default(serverData[attr]);
  6814. } else if (attr !== 'objectId') {
  6815. decoded[attr] = (0, _decode.default)(serverData[attr]);
  6816. if (decoded[attr] instanceof _ParseRelation.default) {
  6817. decoded[attr]._ensureParentAndKey(this, attr);
  6818. }
  6819. }
  6820. }
  6821. if (decoded.createdAt && typeof decoded.createdAt === 'string') {
  6822. decoded.createdAt = (0, _parseDate.default)(decoded.createdAt);
  6823. }
  6824. if (decoded.updatedAt && typeof decoded.updatedAt === 'string') {
  6825. decoded.updatedAt = (0, _parseDate.default)(decoded.updatedAt);
  6826. }
  6827. if (!decoded.updatedAt && decoded.createdAt) {
  6828. decoded.updatedAt = decoded.createdAt;
  6829. }
  6830. stateController.commitServerChanges(this._getStateIdentifier(), decoded);
  6831. }
  6832. _setExisted(existed) {
  6833. const stateController = _CoreManager.default.getObjectStateController();
  6834. const state = stateController.getState(this._getStateIdentifier());
  6835. if (state) {
  6836. state.existed = existed;
  6837. }
  6838. }
  6839. _migrateId(serverId) {
  6840. if (this._localId && serverId) {
  6841. if (singleInstance) {
  6842. const stateController = _CoreManager.default.getObjectStateController();
  6843. const oldState = stateController.removeState(this._getStateIdentifier());
  6844. this.id = serverId;
  6845. delete this._localId;
  6846. if (oldState) {
  6847. stateController.initializeState(this._getStateIdentifier(), oldState);
  6848. }
  6849. } else {
  6850. this.id = serverId;
  6851. delete this._localId;
  6852. }
  6853. }
  6854. }
  6855. _handleSaveResponse(response, status) {
  6856. const changes = {};
  6857. const stateController = _CoreManager.default.getObjectStateController();
  6858. const pending = stateController.popPendingState(this._getStateIdentifier());
  6859. for (var attr in pending) {
  6860. if (pending[attr] instanceof _ParseOp.RelationOp) {
  6861. changes[attr] = pending[attr].applyTo(undefined, this, attr);
  6862. } else if (!(attr in response)) {
  6863. // Only SetOps and UnsetOps should not come back with results
  6864. changes[attr] = pending[attr].applyTo(undefined);
  6865. }
  6866. }
  6867. for (attr in response) {
  6868. if ((attr === 'createdAt' || attr === 'updatedAt') && typeof response[attr] === 'string') {
  6869. changes[attr] = (0, _parseDate.default)(response[attr]);
  6870. } else if (attr === 'ACL') {
  6871. changes[attr] = new _ParseACL.default(response[attr]);
  6872. } else if (attr !== 'objectId') {
  6873. const val = (0, _decode.default)(response[attr]);
  6874. if (val && (0, _getPrototypeOf.default)(val) === Object.prototype) {
  6875. changes[attr] = {
  6876. ...this.attributes[attr],
  6877. ...val
  6878. };
  6879. } else {
  6880. changes[attr] = val;
  6881. }
  6882. if (changes[attr] instanceof _ParseOp.UnsetOp) {
  6883. changes[attr] = undefined;
  6884. }
  6885. }
  6886. }
  6887. if (changes.createdAt && !changes.updatedAt) {
  6888. changes.updatedAt = changes.createdAt;
  6889. }
  6890. this._migrateId(response.objectId);
  6891. if (status !== 201) {
  6892. this._setExisted(true);
  6893. }
  6894. stateController.commitServerChanges(this._getStateIdentifier(), changes);
  6895. }
  6896. _handleSaveError() {
  6897. const stateController = _CoreManager.default.getObjectStateController();
  6898. stateController.mergeFirstPendingState(this._getStateIdentifier());
  6899. }
  6900. static _getClassMap() {
  6901. return classMap;
  6902. }
  6903. /* Public methods */
  6904. initialize() {
  6905. // NOOP
  6906. }
  6907. /**
  6908. * Returns a JSON version of the object suitable for saving to Parse.
  6909. *
  6910. * @param seen
  6911. * @param offline
  6912. * @returns {object}
  6913. */
  6914. toJSON(seen, offline) {
  6915. const seenEntry = this.id ? this.className + ':' + this.id : this;
  6916. seen = seen || [seenEntry];
  6917. const json = {};
  6918. const attrs = this.attributes;
  6919. for (const attr in attrs) {
  6920. if ((attr === 'createdAt' || attr === 'updatedAt') && attrs[attr].toJSON) {
  6921. json[attr] = attrs[attr].toJSON();
  6922. } else {
  6923. json[attr] = (0, _encode.default)(attrs[attr], false, false, seen, offline);
  6924. }
  6925. }
  6926. const pending = this._getPendingOps();
  6927. for (const attr in pending[0]) {
  6928. if ((0, _indexOf.default)(attr).call(attr, '.') < 0) {
  6929. json[attr] = pending[0][attr].toJSON(offline);
  6930. }
  6931. }
  6932. if (this.id) {
  6933. json.objectId = this.id;
  6934. }
  6935. return json;
  6936. }
  6937. /**
  6938. * Determines whether this ParseObject is equal to another ParseObject
  6939. *
  6940. * @param {object} other - An other object ot compare
  6941. * @returns {boolean}
  6942. */
  6943. equals(other) {
  6944. if (this === other) {
  6945. return true;
  6946. }
  6947. return other instanceof ParseObject && this.className === other.className && this.id === other.id && typeof this.id !== 'undefined';
  6948. }
  6949. /**
  6950. * Returns true if this object has been modified since its last
  6951. * save/refresh. If an attribute is specified, it returns true only if that
  6952. * particular attribute has been modified since the last save/refresh.
  6953. *
  6954. * @param {string} attr An attribute name (optional).
  6955. * @returns {boolean}
  6956. */
  6957. dirty(attr) {
  6958. if (!this.id) {
  6959. return true;
  6960. }
  6961. const pendingOps = this._getPendingOps();
  6962. const dirtyObjects = this._getDirtyObjectAttributes();
  6963. if (attr) {
  6964. if (dirtyObjects.hasOwnProperty(attr)) {
  6965. return true;
  6966. }
  6967. for (let i = 0; i < pendingOps.length; i++) {
  6968. if (pendingOps[i].hasOwnProperty(attr)) {
  6969. return true;
  6970. }
  6971. }
  6972. return false;
  6973. }
  6974. if ((0, _keys.default)(pendingOps[0]).length !== 0) {
  6975. return true;
  6976. }
  6977. if ((0, _keys.default)(dirtyObjects).length !== 0) {
  6978. return true;
  6979. }
  6980. return false;
  6981. }
  6982. /**
  6983. * Returns an array of keys that have been modified since last save/refresh
  6984. *
  6985. * @returns {string[]}
  6986. */
  6987. dirtyKeys() {
  6988. const pendingOps = this._getPendingOps();
  6989. const keys = {};
  6990. for (let i = 0; i < pendingOps.length; i++) {
  6991. for (const attr in pendingOps[i]) {
  6992. keys[attr] = true;
  6993. }
  6994. }
  6995. const dirtyObjects = this._getDirtyObjectAttributes();
  6996. for (const attr in dirtyObjects) {
  6997. keys[attr] = true;
  6998. }
  6999. return (0, _keys.default)(keys);
  7000. }
  7001. /**
  7002. * Returns true if the object has been fetched.
  7003. *
  7004. * @returns {boolean}
  7005. */
  7006. isDataAvailable() {
  7007. const serverData = this._getServerData();
  7008. return !!(0, _keys.default)(serverData).length;
  7009. }
  7010. /**
  7011. * Gets a Pointer referencing this Object.
  7012. *
  7013. * @returns {Pointer}
  7014. */
  7015. toPointer() {
  7016. if (!this.id) {
  7017. throw new Error('Cannot create a pointer to an unsaved ParseObject');
  7018. }
  7019. return {
  7020. __type: 'Pointer',
  7021. className: this.className,
  7022. objectId: this.id
  7023. };
  7024. }
  7025. /**
  7026. * Gets a Pointer referencing this Object.
  7027. *
  7028. * @returns {Pointer}
  7029. */
  7030. toOfflinePointer() {
  7031. if (!this._localId) {
  7032. throw new Error('Cannot create a offline pointer to a saved ParseObject');
  7033. }
  7034. return {
  7035. __type: 'Object',
  7036. className: this.className,
  7037. _localId: this._localId
  7038. };
  7039. }
  7040. /**
  7041. * Gets the value of an attribute.
  7042. *
  7043. * @param {string} attr The string name of an attribute.
  7044. * @returns {*}
  7045. */
  7046. get(attr) {
  7047. return this.attributes[attr];
  7048. }
  7049. /**
  7050. * Gets a relation on the given class for the attribute.
  7051. *
  7052. * @param {string} attr The attribute to get the relation for.
  7053. * @returns {Parse.Relation}
  7054. */
  7055. relation(attr) {
  7056. const value = this.get(attr);
  7057. if (value) {
  7058. if (!(value instanceof _ParseRelation.default)) {
  7059. throw new Error('Called relation() on non-relation field ' + attr);
  7060. }
  7061. value._ensureParentAndKey(this, attr);
  7062. return value;
  7063. }
  7064. return new _ParseRelation.default(this, attr);
  7065. }
  7066. /**
  7067. * Gets the HTML-escaped value of an attribute.
  7068. *
  7069. * @param {string} attr The string name of an attribute.
  7070. * @returns {string}
  7071. */
  7072. escape(attr) {
  7073. let val = this.attributes[attr];
  7074. if (val == null) {
  7075. return '';
  7076. }
  7077. if (typeof val !== 'string') {
  7078. if (typeof val.toString !== 'function') {
  7079. return '';
  7080. }
  7081. val = val.toString();
  7082. }
  7083. return (0, _escape.default)(val);
  7084. }
  7085. /**
  7086. * Returns <code>true</code> if the attribute contains a value that is not
  7087. * null or undefined.
  7088. *
  7089. * @param {string} attr The string name of the attribute.
  7090. * @returns {boolean}
  7091. */
  7092. has(attr) {
  7093. const attributes = this.attributes;
  7094. if (attributes.hasOwnProperty(attr)) {
  7095. return attributes[attr] != null;
  7096. }
  7097. return false;
  7098. }
  7099. /**
  7100. * Sets a hash of model attributes on the object.
  7101. *
  7102. * <p>You can call it with an object containing keys and values, with one
  7103. * key and value, or dot notation. For example:<pre>
  7104. * gameTurn.set({
  7105. * player: player1,
  7106. * diceRoll: 2
  7107. * }, {
  7108. * error: function(gameTurnAgain, error) {
  7109. * // The set failed validation.
  7110. * }
  7111. * });
  7112. *
  7113. * game.set("currentPlayer", player2, {
  7114. * error: function(gameTurnAgain, error) {
  7115. * // The set failed validation.
  7116. * }
  7117. * });
  7118. *
  7119. * game.set("finished", true);</pre></p>
  7120. *
  7121. * game.set("player.score", 10);</pre></p>
  7122. *
  7123. * @param {(string|object)} key The key to set.
  7124. * @param {(string|object)} value The value to give it.
  7125. * @param {object} options A set of options for the set.
  7126. * The only supported option is <code>error</code>.
  7127. * @returns {(ParseObject|boolean)} true if the set succeeded.
  7128. */
  7129. set(key, value, options) {
  7130. let changes = {};
  7131. const newOps = {};
  7132. if (key && typeof key === 'object') {
  7133. changes = key;
  7134. options = value;
  7135. } else if (typeof key === 'string') {
  7136. changes[key] = value;
  7137. } else {
  7138. return this;
  7139. }
  7140. options = options || {};
  7141. let readonly = [];
  7142. if (typeof this.constructor.readOnlyAttributes === 'function') {
  7143. readonly = (0, _concat.default)(readonly).call(readonly, this.constructor.readOnlyAttributes());
  7144. }
  7145. for (const k in changes) {
  7146. if (k === 'createdAt' || k === 'updatedAt') {
  7147. // This property is read-only, but for legacy reasons we silently
  7148. // ignore it
  7149. continue;
  7150. }
  7151. if ((0, _indexOf.default)(readonly).call(readonly, k) > -1) {
  7152. throw new Error('Cannot modify readonly attribute: ' + k);
  7153. }
  7154. if (options.unset) {
  7155. newOps[k] = new _ParseOp.UnsetOp();
  7156. } else if (changes[k] instanceof _ParseOp.Op) {
  7157. newOps[k] = changes[k];
  7158. } else if (changes[k] && typeof changes[k] === 'object' && typeof changes[k].__op === 'string') {
  7159. newOps[k] = (0, _ParseOp.opFromJSON)(changes[k]);
  7160. } else if (k === 'objectId' || k === 'id') {
  7161. if (typeof changes[k] === 'string') {
  7162. this.id = changes[k];
  7163. }
  7164. } else if (k === 'ACL' && typeof changes[k] === 'object' && !(changes[k] instanceof _ParseACL.default)) {
  7165. newOps[k] = new _ParseOp.SetOp(new _ParseACL.default(changes[k]));
  7166. } else if (changes[k] instanceof _ParseRelation.default) {
  7167. const relation = new _ParseRelation.default(this, k);
  7168. relation.targetClassName = changes[k].targetClassName;
  7169. newOps[k] = new _ParseOp.SetOp(relation);
  7170. } else {
  7171. newOps[k] = new _ParseOp.SetOp(changes[k]);
  7172. }
  7173. }
  7174. const currentAttributes = this.attributes;
  7175. // Calculate new values
  7176. const newValues = {};
  7177. for (const attr in newOps) {
  7178. if (newOps[attr] instanceof _ParseOp.RelationOp) {
  7179. newValues[attr] = newOps[attr].applyTo(currentAttributes[attr], this, attr);
  7180. } else if (!(newOps[attr] instanceof _ParseOp.UnsetOp)) {
  7181. newValues[attr] = newOps[attr].applyTo(currentAttributes[attr]);
  7182. }
  7183. }
  7184. // Validate changes
  7185. if (!options.ignoreValidation) {
  7186. const validation = this.validate(newValues);
  7187. if (validation) {
  7188. if (typeof options.error === 'function') {
  7189. options.error(this, validation);
  7190. }
  7191. return false;
  7192. }
  7193. }
  7194. // Consolidate Ops
  7195. const pendingOps = this._getPendingOps();
  7196. const last = pendingOps.length - 1;
  7197. const stateController = _CoreManager.default.getObjectStateController();
  7198. for (const attr in newOps) {
  7199. const nextOp = newOps[attr].mergeWith(pendingOps[last][attr]);
  7200. stateController.setPendingOp(this._getStateIdentifier(), attr, nextOp);
  7201. }
  7202. return this;
  7203. }
  7204. /**
  7205. * Remove an attribute from the model. This is a noop if the attribute doesn't
  7206. * exist.
  7207. *
  7208. * @param {string} attr The string name of an attribute.
  7209. * @param options
  7210. * @returns {(ParseObject | boolean)}
  7211. */
  7212. unset(attr, options) {
  7213. options = options || {};
  7214. options.unset = true;
  7215. return this.set(attr, null, options);
  7216. }
  7217. /**
  7218. * Atomically increments the value of the given attribute the next time the
  7219. * object is saved. If no amount is specified, 1 is used by default.
  7220. *
  7221. * @param attr {String} The key.
  7222. * @param amount {Number} The amount to increment by (optional).
  7223. * @returns {(ParseObject|boolean)}
  7224. */
  7225. increment(attr, amount) {
  7226. if (typeof amount === 'undefined') {
  7227. amount = 1;
  7228. }
  7229. if (typeof amount !== 'number') {
  7230. throw new Error('Cannot increment by a non-numeric amount.');
  7231. }
  7232. return this.set(attr, new _ParseOp.IncrementOp(amount));
  7233. }
  7234. /**
  7235. * Atomically decrements the value of the given attribute the next time the
  7236. * object is saved. If no amount is specified, 1 is used by default.
  7237. *
  7238. * @param attr {String} The key.
  7239. * @param amount {Number} The amount to decrement by (optional).
  7240. * @returns {(ParseObject | boolean)}
  7241. */
  7242. decrement(attr, amount) {
  7243. if (typeof amount === 'undefined') {
  7244. amount = 1;
  7245. }
  7246. if (typeof amount !== 'number') {
  7247. throw new Error('Cannot decrement by a non-numeric amount.');
  7248. }
  7249. return this.set(attr, new _ParseOp.IncrementOp(amount * -1));
  7250. }
  7251. /**
  7252. * Atomically add an object to the end of the array associated with a given
  7253. * key.
  7254. *
  7255. * @param attr {String} The key.
  7256. * @param item {} The item to add.
  7257. * @returns {(ParseObject | boolean)}
  7258. */
  7259. add(attr, item) {
  7260. return this.set(attr, new _ParseOp.AddOp([item]));
  7261. }
  7262. /**
  7263. * Atomically add the objects to the end of the array associated with a given
  7264. * key.
  7265. *
  7266. * @param attr {String} The key.
  7267. * @param items {Object[]} The items to add.
  7268. * @returns {(ParseObject | boolean)}
  7269. */
  7270. addAll(attr, items) {
  7271. return this.set(attr, new _ParseOp.AddOp(items));
  7272. }
  7273. /**
  7274. * Atomically add an object to the array associated with a given key, only
  7275. * if it is not already present in the array. The position of the insert is
  7276. * not guaranteed.
  7277. *
  7278. * @param attr {String} The key.
  7279. * @param item {} The object to add.
  7280. * @returns {(ParseObject | boolean)}
  7281. */
  7282. addUnique(attr, item) {
  7283. return this.set(attr, new _ParseOp.AddUniqueOp([item]));
  7284. }
  7285. /**
  7286. * Atomically add the objects to the array associated with a given key, only
  7287. * if it is not already present in the array. The position of the insert is
  7288. * not guaranteed.
  7289. *
  7290. * @param attr {String} The key.
  7291. * @param items {Object[]} The objects to add.
  7292. * @returns {(ParseObject | boolean)}
  7293. */
  7294. addAllUnique(attr, items) {
  7295. return this.set(attr, new _ParseOp.AddUniqueOp(items));
  7296. }
  7297. /**
  7298. * Atomically remove all instances of an object from the array associated
  7299. * with a given key.
  7300. *
  7301. * @param attr {String} The key.
  7302. * @param item {} The object to remove.
  7303. * @returns {(ParseObject | boolean)}
  7304. */
  7305. remove(attr, item) {
  7306. return this.set(attr, new _ParseOp.RemoveOp([item]));
  7307. }
  7308. /**
  7309. * Atomically remove all instances of the objects from the array associated
  7310. * with a given key.
  7311. *
  7312. * @param attr {String} The key.
  7313. * @param items {Object[]} The object to remove.
  7314. * @returns {(ParseObject | boolean)}
  7315. */
  7316. removeAll(attr, items) {
  7317. return this.set(attr, new _ParseOp.RemoveOp(items));
  7318. }
  7319. /**
  7320. * Returns an instance of a subclass of Parse.Op describing what kind of
  7321. * modification has been performed on this field since the last time it was
  7322. * saved. For example, after calling object.increment("x"), calling
  7323. * object.op("x") would return an instance of Parse.Op.Increment.
  7324. *
  7325. * @param attr {String} The key.
  7326. * @returns {Parse.Op | undefined} The operation, or undefined if none.
  7327. */
  7328. op(attr) {
  7329. const pending = this._getPendingOps();
  7330. for (let i = pending.length; i--;) {
  7331. if (pending[i][attr]) {
  7332. return pending[i][attr];
  7333. }
  7334. }
  7335. }
  7336. /**
  7337. * Creates a new model with identical attributes to this one.
  7338. *
  7339. * @returns {Parse.Object}
  7340. */
  7341. clone() {
  7342. const clone = new this.constructor(this.className);
  7343. let attributes = this.attributes;
  7344. if (typeof this.constructor.readOnlyAttributes === 'function') {
  7345. const readonly = this.constructor.readOnlyAttributes() || [];
  7346. // Attributes are frozen, so we have to rebuild an object,
  7347. // rather than delete readonly keys
  7348. const copy = {};
  7349. for (const a in attributes) {
  7350. if ((0, _indexOf.default)(readonly).call(readonly, a) < 0) {
  7351. copy[a] = attributes[a];
  7352. }
  7353. }
  7354. attributes = copy;
  7355. }
  7356. if (clone.set) {
  7357. clone.set(attributes);
  7358. }
  7359. return clone;
  7360. }
  7361. /**
  7362. * Creates a new instance of this object. Not to be confused with clone()
  7363. *
  7364. * @returns {Parse.Object}
  7365. */
  7366. newInstance() {
  7367. const clone = new this.constructor(this.className);
  7368. clone.id = this.id;
  7369. if (singleInstance) {
  7370. // Just return an object with the right id
  7371. return clone;
  7372. }
  7373. const stateController = _CoreManager.default.getObjectStateController();
  7374. if (stateController) {
  7375. stateController.duplicateState(this._getStateIdentifier(), clone._getStateIdentifier());
  7376. }
  7377. return clone;
  7378. }
  7379. /**
  7380. * Returns true if this object has never been saved to Parse.
  7381. *
  7382. * @returns {boolean}
  7383. */
  7384. isNew() {
  7385. return !this.id;
  7386. }
  7387. /**
  7388. * Returns true if this object was created by the Parse server when the
  7389. * object might have already been there (e.g. in the case of a Facebook
  7390. * login)
  7391. *
  7392. * @returns {boolean}
  7393. */
  7394. existed() {
  7395. if (!this.id) {
  7396. return false;
  7397. }
  7398. const stateController = _CoreManager.default.getObjectStateController();
  7399. const state = stateController.getState(this._getStateIdentifier());
  7400. if (state) {
  7401. return state.existed;
  7402. }
  7403. return false;
  7404. }
  7405. /**
  7406. * Returns true if this object exists on the Server
  7407. *
  7408. * @param {object} options
  7409. * Valid options are:<ul>
  7410. * <li>useMasterKey: In Cloud Code and Node only, causes the Master Key to
  7411. * be used for this request.
  7412. * <li>sessionToken: A valid session token, used for making a request on
  7413. * behalf of a specific user.
  7414. * </ul>
  7415. * @returns {Promise<boolean>} A boolean promise that is fulfilled if object exists.
  7416. */
  7417. async exists(options) {
  7418. if (!this.id) {
  7419. return false;
  7420. }
  7421. try {
  7422. const ParseQuery = _CoreManager.default.getParseQuery();
  7423. const query = new ParseQuery(this.className);
  7424. await query.get(this.id, options);
  7425. return true;
  7426. } catch (e) {
  7427. if (e.code === _ParseError.default.OBJECT_NOT_FOUND) {
  7428. return false;
  7429. }
  7430. throw e;
  7431. }
  7432. }
  7433. /**
  7434. * Checks if the model is currently in a valid state.
  7435. *
  7436. * @returns {boolean}
  7437. */
  7438. isValid() {
  7439. return !this.validate(this.attributes);
  7440. }
  7441. /**
  7442. * You should not call this function directly unless you subclass
  7443. * <code>Parse.Object</code>, in which case you can override this method
  7444. * to provide additional validation on <code>set</code> and
  7445. * <code>save</code>. Your implementation should return
  7446. *
  7447. * @param {object} attrs The current data to validate.
  7448. * @returns {Parse.Error|boolean} False if the data is valid. An error object otherwise.
  7449. * @see Parse.Object#set
  7450. */
  7451. validate(attrs) {
  7452. if (attrs.hasOwnProperty('ACL') && !(attrs.ACL instanceof _ParseACL.default)) {
  7453. return new _ParseError.default(_ParseError.default.OTHER_CAUSE, 'ACL must be a Parse ACL.');
  7454. }
  7455. for (const key in attrs) {
  7456. if (!/^[A-Za-z][0-9A-Za-z_.]*$/.test(key)) {
  7457. return new _ParseError.default(_ParseError.default.INVALID_KEY_NAME);
  7458. }
  7459. }
  7460. return false;
  7461. }
  7462. /**
  7463. * Returns the ACL for this object.
  7464. *
  7465. * @returns {Parse.ACL|null} An instance of Parse.ACL.
  7466. * @see Parse.Object#get
  7467. */
  7468. getACL() {
  7469. const acl = this.get('ACL');
  7470. if (acl instanceof _ParseACL.default) {
  7471. return acl;
  7472. }
  7473. return null;
  7474. }
  7475. /**
  7476. * Sets the ACL to be used for this object.
  7477. *
  7478. * @param {Parse.ACL} acl An instance of Parse.ACL.
  7479. * @param {object} options
  7480. * @returns {(ParseObject | boolean)} Whether the set passed validation.
  7481. * @see Parse.Object#set
  7482. */
  7483. setACL(acl, options) {
  7484. return this.set('ACL', acl, options);
  7485. }
  7486. /**
  7487. * Clears any (or specific) changes to this object made since the last call to save()
  7488. *
  7489. * @param {string} [keys] - specify which fields to revert
  7490. */
  7491. revert() {
  7492. let keysToRevert;
  7493. for (var _len = arguments.length, keys = new Array(_len), _key = 0; _key < _len; _key++) {
  7494. keys[_key] = arguments[_key];
  7495. }
  7496. if (keys.length) {
  7497. keysToRevert = [];
  7498. for (const key of keys) {
  7499. if (typeof key === 'string') {
  7500. keysToRevert.push(key);
  7501. } else {
  7502. throw new Error('Parse.Object#revert expects either no, or a list of string, arguments.');
  7503. }
  7504. }
  7505. }
  7506. this._clearPendingOps(keysToRevert);
  7507. }
  7508. /**
  7509. * Clears all attributes on a model
  7510. *
  7511. * @returns {(ParseObject | boolean)}
  7512. */
  7513. clear() {
  7514. const attributes = this.attributes;
  7515. const erasable = {};
  7516. let readonly = ['createdAt', 'updatedAt'];
  7517. if (typeof this.constructor.readOnlyAttributes === 'function') {
  7518. readonly = (0, _concat.default)(readonly).call(readonly, this.constructor.readOnlyAttributes());
  7519. }
  7520. for (const attr in attributes) {
  7521. if ((0, _indexOf.default)(readonly).call(readonly, attr) < 0) {
  7522. erasable[attr] = true;
  7523. }
  7524. }
  7525. return this.set(erasable, {
  7526. unset: true
  7527. });
  7528. }
  7529. /**
  7530. * Fetch the model from the server. If the server's representation of the
  7531. * model differs from its current attributes, they will be overriden.
  7532. *
  7533. * @param {object} options
  7534. * Valid options are:<ul>
  7535. * <li>useMasterKey: In Cloud Code and Node only, causes the Master Key to
  7536. * be used for this request.
  7537. * <li>sessionToken: A valid session token, used for making a request on
  7538. * behalf of a specific user.
  7539. * <li>include: The name(s) of the key(s) to include. Can be a string, an array of strings,
  7540. * or an array of array of strings.
  7541. * <li>context: A dictionary that is accessible in Cloud Code `beforeFind` trigger.
  7542. * </ul>
  7543. * @returns {Promise} A promise that is fulfilled when the fetch
  7544. * completes.
  7545. */
  7546. fetch(options) {
  7547. options = options || {};
  7548. const fetchOptions = {};
  7549. if (options.hasOwnProperty('useMasterKey')) {
  7550. fetchOptions.useMasterKey = options.useMasterKey;
  7551. }
  7552. if (options.hasOwnProperty('sessionToken')) {
  7553. fetchOptions.sessionToken = options.sessionToken;
  7554. }
  7555. if (options.hasOwnProperty('context') && typeof options.context === 'object') {
  7556. fetchOptions.context = options.context;
  7557. }
  7558. if (options.hasOwnProperty('include')) {
  7559. fetchOptions.include = [];
  7560. if ((0, _isArray.default)(options.include)) {
  7561. var _context;
  7562. (0, _forEach.default)(_context = options.include).call(_context, key => {
  7563. if ((0, _isArray.default)(key)) {
  7564. var _context2;
  7565. fetchOptions.include = (0, _concat.default)(_context2 = fetchOptions.include).call(_context2, key);
  7566. } else {
  7567. fetchOptions.include.push(key);
  7568. }
  7569. });
  7570. } else {
  7571. fetchOptions.include.push(options.include);
  7572. }
  7573. }
  7574. const controller = _CoreManager.default.getObjectController();
  7575. return controller.fetch(this, true, fetchOptions);
  7576. }
  7577. /**
  7578. * Fetch the model from the server. If the server's representation of the
  7579. * model differs from its current attributes, they will be overriden.
  7580. *
  7581. * Includes nested Parse.Objects for the provided key. You can use dot
  7582. * notation to specify which fields in the included object are also fetched.
  7583. *
  7584. * @param {string | Array<string | Array<string>>} keys The name(s) of the key(s) to include.
  7585. * @param {object} options
  7586. * Valid options are:<ul>
  7587. * <li>useMasterKey: In Cloud Code and Node only, causes the Master Key to
  7588. * be used for this request.
  7589. * <li>sessionToken: A valid session token, used for making a request on
  7590. * behalf of a specific user.
  7591. * </ul>
  7592. * @returns {Promise} A promise that is fulfilled when the fetch
  7593. * completes.
  7594. */
  7595. fetchWithInclude(keys, options) {
  7596. options = options || {};
  7597. options.include = keys;
  7598. return this.fetch(options);
  7599. }
  7600. /**
  7601. * Saves this object to the server at some unspecified time in the future,
  7602. * even if Parse is currently inaccessible.
  7603. *
  7604. * Use this when you may not have a solid network connection, and don't need to know when the save completes.
  7605. * If there is some problem with the object such that it can't be saved, it will be silently discarded.
  7606. *
  7607. * Objects saved with this method will be stored locally in an on-disk cache until they can be delivered to Parse.
  7608. * They will be sent immediately if possible. Otherwise, they will be sent the next time a network connection is
  7609. * available. Objects saved this way will persist even after the app is closed, in which case they will be sent the
  7610. * next time the app is opened.
  7611. *
  7612. * @param {object} [options]
  7613. * Used to pass option parameters to method if arg1 and arg2 were both passed as strings.
  7614. * Valid options are:
  7615. * <ul>
  7616. * <li>sessionToken: A valid session token, used for making a request on
  7617. * behalf of a specific user.
  7618. * <li>cascadeSave: If `false`, nested objects will not be saved (default is `true`).
  7619. * <li>context: A dictionary that is accessible in Cloud Code `beforeSave` and `afterSave` triggers.
  7620. * </ul>
  7621. * @returns {Promise} A promise that is fulfilled when the save
  7622. * completes.
  7623. */
  7624. async saveEventually(options) {
  7625. try {
  7626. await this.save(null, options);
  7627. } catch (e) {
  7628. if (e.code === _ParseError.default.CONNECTION_FAILED) {
  7629. await _CoreManager.default.getEventuallyQueue().save(this, options);
  7630. _CoreManager.default.getEventuallyQueue().poll();
  7631. }
  7632. }
  7633. return this;
  7634. }
  7635. /**
  7636. * Set a hash of model attributes, and save the model to the server.
  7637. * updatedAt will be updated when the request returns.
  7638. * You can either call it as:<pre>
  7639. * object.save();</pre>
  7640. * or<pre>
  7641. * object.save(attrs);</pre>
  7642. * or<pre>
  7643. * object.save(null, options);</pre>
  7644. * or<pre>
  7645. * object.save(attrs, options);</pre>
  7646. * or<pre>
  7647. * object.save(key, value);</pre>
  7648. * or<pre>
  7649. * object.save(key, value, options);</pre>
  7650. *
  7651. * Example 1: <pre>
  7652. * gameTurn.save({
  7653. * player: "Jake Cutter",
  7654. * diceRoll: 2
  7655. * }).then(function(gameTurnAgain) {
  7656. * // The save was successful.
  7657. * }, function(error) {
  7658. * // The save failed. Error is an instance of Parse.Error.
  7659. * });</pre>
  7660. *
  7661. * Example 2: <pre>
  7662. * gameTurn.save("player", "Jake Cutter");</pre>
  7663. *
  7664. * @param {string | object | null} [arg1]
  7665. * Valid options are:<ul>
  7666. * <li>`Object` - Key/value pairs to update on the object.</li>
  7667. * <li>`String` Key - Key of attribute to update (requires arg2 to also be string)</li>
  7668. * <li>`null` - Passing null for arg1 allows you to save the object with options passed in arg2.</li>
  7669. * </ul>
  7670. * @param {string | object} [arg2]
  7671. * <ul>
  7672. * <li>`String` Value - If arg1 was passed as a key, arg2 is the value that should be set on that key.</li>
  7673. * <li>`Object` Options - Valid options are:
  7674. * <ul>
  7675. * <li>useMasterKey: In Cloud Code and Node only, causes the Master Key to
  7676. * be used for this request.
  7677. * <li>sessionToken: A valid session token, used for making a request on
  7678. * behalf of a specific user.
  7679. * <li>cascadeSave: If `false`, nested objects will not be saved (default is `true`).
  7680. * <li>context: A dictionary that is accessible in Cloud Code `beforeSave` and `afterSave` triggers.
  7681. * </ul>
  7682. * </li>
  7683. * </ul>
  7684. * @param {object} [arg3]
  7685. * Used to pass option parameters to method if arg1 and arg2 were both passed as strings.
  7686. * Valid options are:
  7687. * <ul>
  7688. * <li>useMasterKey: In Cloud Code and Node only, causes the Master Key to
  7689. * be used for this request.
  7690. * <li>sessionToken: A valid session token, used for making a request on
  7691. * behalf of a specific user.
  7692. * <li>cascadeSave: If `false`, nested objects will not be saved (default is `true`).
  7693. * <li>context: A dictionary that is accessible in Cloud Code `beforeSave` and `afterSave` triggers.
  7694. * </ul>
  7695. * @returns {Promise} A promise that is fulfilled when the save
  7696. * completes.
  7697. */
  7698. save(arg1, arg2, arg3) {
  7699. let attrs;
  7700. let options;
  7701. if (typeof arg1 === 'object' || typeof arg1 === 'undefined') {
  7702. attrs = arg1;
  7703. if (typeof arg2 === 'object') {
  7704. options = arg2;
  7705. }
  7706. } else {
  7707. attrs = {};
  7708. attrs[arg1] = arg2;
  7709. options = arg3;
  7710. }
  7711. options = options || {};
  7712. if (attrs) {
  7713. let validationError;
  7714. options.error = (_, validation) => {
  7715. validationError = validation;
  7716. };
  7717. const success = this.set(attrs, options);
  7718. if (!success) {
  7719. return _promise.default.reject(validationError);
  7720. }
  7721. }
  7722. const saveOptions = {};
  7723. if (options.hasOwnProperty('useMasterKey')) {
  7724. saveOptions.useMasterKey = !!options.useMasterKey;
  7725. }
  7726. if (options.hasOwnProperty('sessionToken') && typeof options.sessionToken === 'string') {
  7727. saveOptions.sessionToken = options.sessionToken;
  7728. }
  7729. if (options.hasOwnProperty('installationId') && typeof options.installationId === 'string') {
  7730. saveOptions.installationId = options.installationId;
  7731. }
  7732. if (options.hasOwnProperty('context') && typeof options.context === 'object') {
  7733. saveOptions.context = options.context;
  7734. }
  7735. const controller = _CoreManager.default.getObjectController();
  7736. const unsaved = options.cascadeSave !== false ? (0, _unsavedChildren.default)(this) : null;
  7737. return controller.save(unsaved, saveOptions).then(() => {
  7738. return controller.save(this, saveOptions);
  7739. });
  7740. }
  7741. /**
  7742. * Deletes this object from the server at some unspecified time in the future,
  7743. * even if Parse is currently inaccessible.
  7744. *
  7745. * Use this when you may not have a solid network connection,
  7746. * and don't need to know when the delete completes. If there is some problem with the object
  7747. * such that it can't be deleted, the request will be silently discarded.
  7748. *
  7749. * Delete instructions made with this method will be stored locally in an on-disk cache until they can be transmitted
  7750. * to Parse. They will be sent immediately if possible. Otherwise, they will be sent the next time a network connection
  7751. * is available. Delete requests will persist even after the app is closed, in which case they will be sent the
  7752. * next time the app is opened.
  7753. *
  7754. * @param {object} [options]
  7755. * Valid options are:<ul>
  7756. * <li>sessionToken: A valid session token, used for making a request on
  7757. * behalf of a specific user.
  7758. * <li>context: A dictionary that is accessible in Cloud Code `beforeDelete` and `afterDelete` triggers.
  7759. * </ul>
  7760. * @returns {Promise} A promise that is fulfilled when the destroy
  7761. * completes.
  7762. */
  7763. async destroyEventually(options) {
  7764. try {
  7765. await this.destroy(options);
  7766. } catch (e) {
  7767. if (e.code === _ParseError.default.CONNECTION_FAILED) {
  7768. await _CoreManager.default.getEventuallyQueue().destroy(this, options);
  7769. _CoreManager.default.getEventuallyQueue().poll();
  7770. }
  7771. }
  7772. return this;
  7773. }
  7774. /**
  7775. * Destroy this model on the server if it was already persisted.
  7776. *
  7777. * @param {object} options
  7778. * Valid options are:<ul>
  7779. * <li>useMasterKey: In Cloud Code and Node only, causes the Master Key to
  7780. * be used for this request.
  7781. * <li>sessionToken: A valid session token, used for making a request on
  7782. * behalf of a specific user.
  7783. * <li>context: A dictionary that is accessible in Cloud Code `beforeDelete` and `afterDelete` triggers.
  7784. * </ul>
  7785. * @returns {Promise} A promise that is fulfilled when the destroy
  7786. * completes.
  7787. */
  7788. destroy(options) {
  7789. options = options || {};
  7790. const destroyOptions = {};
  7791. if (options.hasOwnProperty('useMasterKey')) {
  7792. destroyOptions.useMasterKey = options.useMasterKey;
  7793. }
  7794. if (options.hasOwnProperty('sessionToken')) {
  7795. destroyOptions.sessionToken = options.sessionToken;
  7796. }
  7797. if (options.hasOwnProperty('context') && typeof options.context === 'object') {
  7798. destroyOptions.context = options.context;
  7799. }
  7800. if (!this.id) {
  7801. return _promise.default.resolve();
  7802. }
  7803. return _CoreManager.default.getObjectController().destroy(this, destroyOptions);
  7804. }
  7805. /**
  7806. * Asynchronously stores the object and every object it points to in the local datastore,
  7807. * recursively, using a default pin name: _default.
  7808. *
  7809. * If those other objects have not been fetched from Parse, they will not be stored.
  7810. * However, if they have changed data, all the changes will be retained.
  7811. *
  7812. * <pre>
  7813. * await object.pin();
  7814. * </pre>
  7815. *
  7816. * To retrieve object:
  7817. * <code>query.fromLocalDatastore()</code> or <code>query.fromPin()</code>
  7818. *
  7819. * @returns {Promise} A promise that is fulfilled when the pin completes.
  7820. */
  7821. pin() {
  7822. return ParseObject.pinAllWithName(_LocalDatastoreUtils.DEFAULT_PIN, [this]);
  7823. }
  7824. /**
  7825. * Asynchronously removes the object and every object it points to in the local datastore,
  7826. * recursively, using a default pin name: _default.
  7827. *
  7828. * <pre>
  7829. * await object.unPin();
  7830. * </pre>
  7831. *
  7832. * @returns {Promise} A promise that is fulfilled when the unPin completes.
  7833. */
  7834. unPin() {
  7835. return ParseObject.unPinAllWithName(_LocalDatastoreUtils.DEFAULT_PIN, [this]);
  7836. }
  7837. /**
  7838. * Asynchronously returns if the object is pinned
  7839. *
  7840. * <pre>
  7841. * const isPinned = await object.isPinned();
  7842. * </pre>
  7843. *
  7844. * @returns {Promise<boolean>} A boolean promise that is fulfilled if object is pinned.
  7845. */
  7846. async isPinned() {
  7847. const localDatastore = _CoreManager.default.getLocalDatastore();
  7848. if (!localDatastore.isEnabled) {
  7849. return _promise.default.reject('Parse.enableLocalDatastore() must be called first');
  7850. }
  7851. const objectKey = localDatastore.getKeyForObject(this);
  7852. const pin = await localDatastore.fromPinWithName(objectKey);
  7853. return pin.length > 0;
  7854. }
  7855. /**
  7856. * Asynchronously stores the objects and every object they point to in the local datastore, recursively.
  7857. *
  7858. * If those other objects have not been fetched from Parse, they will not be stored.
  7859. * However, if they have changed data, all the changes will be retained.
  7860. *
  7861. * <pre>
  7862. * await object.pinWithName(name);
  7863. * </pre>
  7864. *
  7865. * To retrieve object:
  7866. * <code>query.fromLocalDatastore()</code> or <code>query.fromPinWithName(name)</code>
  7867. *
  7868. * @param {string} name Name of Pin.
  7869. * @returns {Promise} A promise that is fulfilled when the pin completes.
  7870. */
  7871. pinWithName(name) {
  7872. return ParseObject.pinAllWithName(name, [this]);
  7873. }
  7874. /**
  7875. * Asynchronously removes the object and every object it points to in the local datastore, recursively.
  7876. *
  7877. * <pre>
  7878. * await object.unPinWithName(name);
  7879. * </pre>
  7880. *
  7881. * @param {string} name Name of Pin.
  7882. * @returns {Promise} A promise that is fulfilled when the unPin completes.
  7883. */
  7884. unPinWithName(name) {
  7885. return ParseObject.unPinAllWithName(name, [this]);
  7886. }
  7887. /**
  7888. * Asynchronously loads data from the local datastore into this object.
  7889. *
  7890. * <pre>
  7891. * await object.fetchFromLocalDatastore();
  7892. * </pre>
  7893. *
  7894. * You can create an unfetched pointer with <code>Parse.Object.createWithoutData()</code>
  7895. * and then call <code>fetchFromLocalDatastore()</code> on it.
  7896. *
  7897. * @returns {Promise} A promise that is fulfilled when the fetch completes.
  7898. */
  7899. async fetchFromLocalDatastore() {
  7900. const localDatastore = _CoreManager.default.getLocalDatastore();
  7901. if (!localDatastore.isEnabled) {
  7902. throw new Error('Parse.enableLocalDatastore() must be called first');
  7903. }
  7904. const objectKey = localDatastore.getKeyForObject(this);
  7905. const pinned = await localDatastore._serializeObject(objectKey);
  7906. if (!pinned) {
  7907. throw new Error('Cannot fetch an unsaved ParseObject');
  7908. }
  7909. const result = ParseObject.fromJSON(pinned);
  7910. this._finishFetch(result.toJSON());
  7911. return this;
  7912. }
  7913. /* Static methods */
  7914. static _clearAllState() {
  7915. const stateController = _CoreManager.default.getObjectStateController();
  7916. stateController.clearAllState();
  7917. }
  7918. /**
  7919. * Fetches the given list of Parse.Object.
  7920. * If any error is encountered, stops and calls the error handler.
  7921. *
  7922. * <pre>
  7923. * Parse.Object.fetchAll([object1, object2, ...])
  7924. * .then((list) => {
  7925. * // All the objects were fetched.
  7926. * }, (error) => {
  7927. * // An error occurred while fetching one of the objects.
  7928. * });
  7929. * </pre>
  7930. *
  7931. * @param {Array} list A list of <code>Parse.Object</code>.
  7932. * @param {object} options
  7933. * Valid options are:<ul>
  7934. * <li>useMasterKey: In Cloud Code and Node only, causes the Master Key to
  7935. * be used for this request.
  7936. * <li>sessionToken: A valid session token, used for making a request on
  7937. * behalf of a specific user.
  7938. * <li>include: The name(s) of the key(s) to include. Can be a string, an array of strings,
  7939. * or an array of array of strings.
  7940. * </ul>
  7941. * @static
  7942. * @returns {Parse.Object[]}
  7943. */
  7944. static fetchAll(list) {
  7945. let options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
  7946. const queryOptions = {};
  7947. if (options.hasOwnProperty('useMasterKey')) {
  7948. queryOptions.useMasterKey = options.useMasterKey;
  7949. }
  7950. if (options.hasOwnProperty('sessionToken')) {
  7951. queryOptions.sessionToken = options.sessionToken;
  7952. }
  7953. if (options.hasOwnProperty('include')) {
  7954. queryOptions.include = ParseObject.handleIncludeOptions(options);
  7955. }
  7956. return _CoreManager.default.getObjectController().fetch(list, true, queryOptions);
  7957. }
  7958. /**
  7959. * Fetches the given list of Parse.Object.
  7960. *
  7961. * Includes nested Parse.Objects for the provided key. You can use dot
  7962. * notation to specify which fields in the included object are also fetched.
  7963. *
  7964. * If any error is encountered, stops and calls the error handler.
  7965. *
  7966. * <pre>
  7967. * Parse.Object.fetchAllWithInclude([object1, object2, ...], [pointer1, pointer2, ...])
  7968. * .then((list) => {
  7969. * // All the objects were fetched.
  7970. * }, (error) => {
  7971. * // An error occurred while fetching one of the objects.
  7972. * });
  7973. * </pre>
  7974. *
  7975. * @param {Array} list A list of <code>Parse.Object</code>.
  7976. * @param {string | Array<string | Array<string>>} keys The name(s) of the key(s) to include.
  7977. * @param {object} options
  7978. * Valid options are:<ul>
  7979. * <li>useMasterKey: In Cloud Code and Node only, causes the Master Key to
  7980. * be used for this request.
  7981. * <li>sessionToken: A valid session token, used for making a request on
  7982. * behalf of a specific user.
  7983. * </ul>
  7984. * @static
  7985. * @returns {Parse.Object[]}
  7986. */
  7987. static fetchAllWithInclude(list, keys, options) {
  7988. options = options || {};
  7989. options.include = keys;
  7990. return ParseObject.fetchAll(list, options);
  7991. }
  7992. /**
  7993. * Fetches the given list of Parse.Object if needed.
  7994. * If any error is encountered, stops and calls the error handler.
  7995. *
  7996. * Includes nested Parse.Objects for the provided key. You can use dot
  7997. * notation to specify which fields in the included object are also fetched.
  7998. *
  7999. * If any error is encountered, stops and calls the error handler.
  8000. *
  8001. * <pre>
  8002. * Parse.Object.fetchAllIfNeededWithInclude([object1, object2, ...], [pointer1, pointer2, ...])
  8003. * .then((list) => {
  8004. * // All the objects were fetched.
  8005. * }, (error) => {
  8006. * // An error occurred while fetching one of the objects.
  8007. * });
  8008. * </pre>
  8009. *
  8010. * @param {Array} list A list of <code>Parse.Object</code>.
  8011. * @param {string | Array<string | Array<string>>} keys The name(s) of the key(s) to include.
  8012. * @param {object} options
  8013. * Valid options are:<ul>
  8014. * <li>useMasterKey: In Cloud Code and Node only, causes the Master Key to
  8015. * be used for this request.
  8016. * <li>sessionToken: A valid session token, used for making a request on
  8017. * behalf of a specific user.
  8018. * </ul>
  8019. * @static
  8020. * @returns {Parse.Object[]}
  8021. */
  8022. static fetchAllIfNeededWithInclude(list, keys, options) {
  8023. options = options || {};
  8024. options.include = keys;
  8025. return ParseObject.fetchAllIfNeeded(list, options);
  8026. }
  8027. /**
  8028. * Fetches the given list of Parse.Object if needed.
  8029. * If any error is encountered, stops and calls the error handler.
  8030. *
  8031. * <pre>
  8032. * Parse.Object.fetchAllIfNeeded([object1, ...])
  8033. * .then((list) => {
  8034. * // Objects were fetched and updated.
  8035. * }, (error) => {
  8036. * // An error occurred while fetching one of the objects.
  8037. * });
  8038. * </pre>
  8039. *
  8040. * @param {Array} list A list of <code>Parse.Object</code>.
  8041. * @param {object} options
  8042. * @static
  8043. * @returns {Parse.Object[]}
  8044. */
  8045. static fetchAllIfNeeded(list, options) {
  8046. options = options || {};
  8047. const queryOptions = {};
  8048. if (options.hasOwnProperty('useMasterKey')) {
  8049. queryOptions.useMasterKey = options.useMasterKey;
  8050. }
  8051. if (options.hasOwnProperty('sessionToken')) {
  8052. queryOptions.sessionToken = options.sessionToken;
  8053. }
  8054. if (options.hasOwnProperty('include')) {
  8055. queryOptions.include = ParseObject.handleIncludeOptions(options);
  8056. }
  8057. return _CoreManager.default.getObjectController().fetch(list, false, queryOptions);
  8058. }
  8059. static handleIncludeOptions(options) {
  8060. let include = [];
  8061. if ((0, _isArray.default)(options.include)) {
  8062. var _context3;
  8063. (0, _forEach.default)(_context3 = options.include).call(_context3, key => {
  8064. if ((0, _isArray.default)(key)) {
  8065. include = (0, _concat.default)(include).call(include, key);
  8066. } else {
  8067. include.push(key);
  8068. }
  8069. });
  8070. } else {
  8071. include.push(options.include);
  8072. }
  8073. return include;
  8074. }
  8075. /**
  8076. * Destroy the given list of models on the server if it was already persisted.
  8077. *
  8078. * <p>Unlike saveAll, if an error occurs while deleting an individual model,
  8079. * this method will continue trying to delete the rest of the models if
  8080. * possible, except in the case of a fatal error like a connection error.
  8081. *
  8082. * <p>In particular, the Parse.Error object returned in the case of error may
  8083. * be one of two types:
  8084. *
  8085. * <ul>
  8086. * <li>A Parse.Error.AGGREGATE_ERROR. This object's "errors" property is an
  8087. * array of other Parse.Error objects. Each error object in this array
  8088. * has an "object" property that references the object that could not be
  8089. * deleted (for instance, because that object could not be found).</li>
  8090. * <li>A non-aggregate Parse.Error. This indicates a serious error that
  8091. * caused the delete operation to be aborted partway through (for
  8092. * instance, a connection failure in the middle of the delete).</li>
  8093. * </ul>
  8094. *
  8095. * <pre>
  8096. * Parse.Object.destroyAll([object1, object2, ...])
  8097. * .then((list) => {
  8098. * // All the objects were deleted.
  8099. * }, (error) => {
  8100. * // An error occurred while deleting one or more of the objects.
  8101. * // If this is an aggregate error, then we can inspect each error
  8102. * // object individually to determine the reason why a particular
  8103. * // object was not deleted.
  8104. * if (error.code === Parse.Error.AGGREGATE_ERROR) {
  8105. * for (var i = 0; i < error.errors.length; i++) {
  8106. * console.log("Couldn't delete " + error.errors[i].object.id +
  8107. * "due to " + error.errors[i].message);
  8108. * }
  8109. * } else {
  8110. * console.log("Delete aborted because of " + error.message);
  8111. * }
  8112. * });
  8113. * </pre>
  8114. *
  8115. * @param {Array} list A list of <code>Parse.Object</code>.
  8116. * @param {object} options
  8117. * @static
  8118. * @returns {Promise} A promise that is fulfilled when the destroyAll
  8119. * completes.
  8120. */
  8121. static destroyAll(list) {
  8122. let options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
  8123. const destroyOptions = {};
  8124. if (options.hasOwnProperty('useMasterKey')) {
  8125. destroyOptions.useMasterKey = options.useMasterKey;
  8126. }
  8127. if (options.hasOwnProperty('sessionToken')) {
  8128. destroyOptions.sessionToken = options.sessionToken;
  8129. }
  8130. if (options.hasOwnProperty('batchSize') && typeof options.batchSize === 'number') {
  8131. destroyOptions.batchSize = options.batchSize;
  8132. }
  8133. if (options.hasOwnProperty('context') && typeof options.context === 'object') {
  8134. destroyOptions.context = options.context;
  8135. }
  8136. return _CoreManager.default.getObjectController().destroy(list, destroyOptions);
  8137. }
  8138. /**
  8139. * Saves the given list of Parse.Object.
  8140. * If any error is encountered, stops and calls the error handler.
  8141. *
  8142. * <pre>
  8143. * Parse.Object.saveAll([object1, object2, ...])
  8144. * .then((list) => {
  8145. * // All the objects were saved.
  8146. * }, (error) => {
  8147. * // An error occurred while saving one of the objects.
  8148. * });
  8149. * </pre>
  8150. *
  8151. * @param {Array} list A list of <code>Parse.Object</code>.
  8152. * @param {object} options
  8153. * @static
  8154. * @returns {Parse.Object[]}
  8155. */
  8156. static saveAll(list) {
  8157. let options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
  8158. const saveOptions = {};
  8159. if (options.hasOwnProperty('useMasterKey')) {
  8160. saveOptions.useMasterKey = options.useMasterKey;
  8161. }
  8162. if (options.hasOwnProperty('sessionToken')) {
  8163. saveOptions.sessionToken = options.sessionToken;
  8164. }
  8165. if (options.hasOwnProperty('batchSize') && typeof options.batchSize === 'number') {
  8166. saveOptions.batchSize = options.batchSize;
  8167. }
  8168. if (options.hasOwnProperty('context') && typeof options.context === 'object') {
  8169. saveOptions.context = options.context;
  8170. }
  8171. return _CoreManager.default.getObjectController().save(list, saveOptions);
  8172. }
  8173. /**
  8174. * Creates a reference to a subclass of Parse.Object with the given id. This
  8175. * does not exist on Parse.Object, only on subclasses.
  8176. *
  8177. * <p>A shortcut for: <pre>
  8178. * var Foo = Parse.Object.extend("Foo");
  8179. * var pointerToFoo = new Foo();
  8180. * pointerToFoo.id = "myObjectId";
  8181. * </pre>
  8182. *
  8183. * @param {string} id The ID of the object to create a reference to.
  8184. * @static
  8185. * @returns {Parse.Object} A Parse.Object reference.
  8186. */
  8187. static createWithoutData(id) {
  8188. const obj = new this();
  8189. obj.id = id;
  8190. return obj;
  8191. }
  8192. /**
  8193. * Creates a new instance of a Parse Object from a JSON representation.
  8194. *
  8195. * @param {object} json The JSON map of the Object's data
  8196. * @param {boolean} override In single instance mode, all old server data
  8197. * is overwritten if this is set to true
  8198. * @param {boolean} dirty Whether the Parse.Object should set JSON keys to dirty
  8199. * @static
  8200. * @returns {Parse.Object} A Parse.Object reference
  8201. */
  8202. static fromJSON(json, override, dirty) {
  8203. if (!json.className) {
  8204. throw new Error('Cannot create an object without a className');
  8205. }
  8206. const constructor = classMap[json.className];
  8207. const o = constructor ? new constructor(json.className) : new ParseObject(json.className);
  8208. const otherAttributes = {};
  8209. for (const attr in json) {
  8210. if (attr !== 'className' && attr !== '__type') {
  8211. otherAttributes[attr] = json[attr];
  8212. if (dirty) {
  8213. o.set(attr, json[attr]);
  8214. }
  8215. }
  8216. }
  8217. if (override) {
  8218. // id needs to be set before clearServerData can work
  8219. if (otherAttributes.objectId) {
  8220. o.id = otherAttributes.objectId;
  8221. }
  8222. let preserved = null;
  8223. if (typeof o._preserveFieldsOnFetch === 'function') {
  8224. preserved = o._preserveFieldsOnFetch();
  8225. }
  8226. o._clearServerData();
  8227. if (preserved) {
  8228. o._finishFetch(preserved);
  8229. }
  8230. }
  8231. o._finishFetch(otherAttributes);
  8232. if (json.objectId) {
  8233. o._setExisted(true);
  8234. }
  8235. return o;
  8236. }
  8237. /**
  8238. * Registers a subclass of Parse.Object with a specific class name.
  8239. * When objects of that class are retrieved from a query, they will be
  8240. * instantiated with this subclass.
  8241. * This is only necessary when using ES6 subclassing.
  8242. *
  8243. * @param {string} className The class name of the subclass
  8244. * @param {Function} constructor The subclass
  8245. */
  8246. static registerSubclass(className, constructor) {
  8247. if (typeof className !== 'string') {
  8248. throw new TypeError('The first argument must be a valid class name.');
  8249. }
  8250. if (typeof constructor === 'undefined') {
  8251. throw new TypeError('You must supply a subclass constructor.');
  8252. }
  8253. if (typeof constructor !== 'function') {
  8254. throw new TypeError('You must register the subclass constructor. ' + 'Did you attempt to register an instance of the subclass?');
  8255. }
  8256. classMap[className] = constructor;
  8257. if (!constructor.className) {
  8258. constructor.className = className;
  8259. }
  8260. }
  8261. /**
  8262. * Unegisters a subclass of Parse.Object with a specific class name.
  8263. *
  8264. * @param {string} className The class name of the subclass
  8265. */
  8266. static unregisterSubclass(className) {
  8267. if (typeof className !== 'string') {
  8268. throw new TypeError('The first argument must be a valid class name.');
  8269. }
  8270. delete classMap[className];
  8271. }
  8272. /**
  8273. * Creates a new subclass of Parse.Object for the given Parse class name.
  8274. *
  8275. * <p>Every extension of a Parse class will inherit from the most recent
  8276. * previous extension of that class. When a Parse.Object is automatically
  8277. * created by parsing JSON, it will use the most recent extension of that
  8278. * class.</p>
  8279. *
  8280. * <p>You should call either:<pre>
  8281. * var MyClass = Parse.Object.extend("MyClass", {
  8282. * <i>Instance methods</i>,
  8283. * initialize: function(attrs, options) {
  8284. * this.someInstanceProperty = [],
  8285. * <i>Other instance properties</i>
  8286. * }
  8287. * }, {
  8288. * <i>Class properties</i>
  8289. * });</pre>
  8290. * or, for Backbone compatibility:<pre>
  8291. * var MyClass = Parse.Object.extend({
  8292. * className: "MyClass",
  8293. * <i>Instance methods</i>,
  8294. * initialize: function(attrs, options) {
  8295. * this.someInstanceProperty = [],
  8296. * <i>Other instance properties</i>
  8297. * }
  8298. * }, {
  8299. * <i>Class properties</i>
  8300. * });</pre></p>
  8301. *
  8302. * @param {string} className The name of the Parse class backing this model.
  8303. * @param {object} [protoProps] Instance properties to add to instances of the
  8304. * class returned from this method.
  8305. * @param {object} [classProps] Class properties to add the class returned from
  8306. * this method.
  8307. * @returns {Parse.Object} A new subclass of Parse.Object.
  8308. */
  8309. static extend(className, protoProps, classProps) {
  8310. if (typeof className !== 'string') {
  8311. if (className && typeof className.className === 'string') {
  8312. return ParseObject.extend(className.className, className, protoProps);
  8313. } else {
  8314. throw new Error("Parse.Object.extend's first argument should be the className.");
  8315. }
  8316. }
  8317. let adjustedClassName = className;
  8318. if (adjustedClassName === 'User' && _CoreManager.default.get('PERFORM_USER_REWRITE')) {
  8319. adjustedClassName = '_User';
  8320. }
  8321. let parentProto = ParseObject.prototype;
  8322. if (this.hasOwnProperty('__super__') && this.__super__) {
  8323. parentProto = this.prototype;
  8324. }
  8325. let ParseObjectSubclass = function (attributes, options) {
  8326. this.className = adjustedClassName;
  8327. this._objCount = objectCount++;
  8328. // Enable legacy initializers
  8329. if (typeof this.initialize === 'function') {
  8330. this.initialize.apply(this, arguments);
  8331. }
  8332. if (this._initializers) {
  8333. for (const initializer of this._initializers) {
  8334. initializer.apply(this, arguments);
  8335. }
  8336. }
  8337. if (attributes && typeof attributes === 'object') {
  8338. if (!this.set(attributes || {}, options)) {
  8339. throw new Error("Can't create an invalid Parse Object");
  8340. }
  8341. }
  8342. };
  8343. if (classMap[adjustedClassName]) {
  8344. ParseObjectSubclass = classMap[adjustedClassName];
  8345. } else {
  8346. ParseObjectSubclass.extend = function (name, protoProps, classProps) {
  8347. if (typeof name === 'string') {
  8348. return ParseObject.extend.call(ParseObjectSubclass, name, protoProps, classProps);
  8349. }
  8350. return ParseObject.extend.call(ParseObjectSubclass, adjustedClassName, name, protoProps);
  8351. };
  8352. ParseObjectSubclass.createWithoutData = ParseObject.createWithoutData;
  8353. ParseObjectSubclass.className = adjustedClassName;
  8354. ParseObjectSubclass.__super__ = parentProto;
  8355. ParseObjectSubclass.prototype = (0, _create.default)(parentProto, {
  8356. constructor: {
  8357. value: ParseObjectSubclass,
  8358. enumerable: false,
  8359. writable: true,
  8360. configurable: true
  8361. }
  8362. });
  8363. }
  8364. if (protoProps) {
  8365. for (const prop in protoProps) {
  8366. if (prop === 'initialize') {
  8367. (0, _defineProperty3.default)(ParseObjectSubclass.prototype, '_initializers', {
  8368. value: [...(ParseObjectSubclass.prototype._initializers || []), protoProps[prop]],
  8369. enumerable: false,
  8370. writable: true,
  8371. configurable: true
  8372. });
  8373. continue;
  8374. }
  8375. if (prop !== 'className') {
  8376. (0, _defineProperty3.default)(ParseObjectSubclass.prototype, prop, {
  8377. value: protoProps[prop],
  8378. enumerable: false,
  8379. writable: true,
  8380. configurable: true
  8381. });
  8382. }
  8383. }
  8384. }
  8385. if (classProps) {
  8386. for (const prop in classProps) {
  8387. if (prop !== 'className') {
  8388. (0, _defineProperty3.default)(ParseObjectSubclass, prop, {
  8389. value: classProps[prop],
  8390. enumerable: false,
  8391. writable: true,
  8392. configurable: true
  8393. });
  8394. }
  8395. }
  8396. }
  8397. classMap[adjustedClassName] = ParseObjectSubclass;
  8398. return ParseObjectSubclass;
  8399. }
  8400. /**
  8401. * Enable single instance objects, where any local objects with the same Id
  8402. * share the same attributes, and stay synchronized with each other.
  8403. * This is disabled by default in server environments, since it can lead to
  8404. * security issues.
  8405. *
  8406. * @static
  8407. */
  8408. static enableSingleInstance() {
  8409. singleInstance = true;
  8410. _CoreManager.default.setObjectStateController(SingleInstanceStateController);
  8411. }
  8412. /**
  8413. * Disable single instance objects, where any local objects with the same Id
  8414. * share the same attributes, and stay synchronized with each other.
  8415. * When disabled, you can have two instances of the same object in memory
  8416. * without them sharing attributes.
  8417. *
  8418. * @static
  8419. */
  8420. static disableSingleInstance() {
  8421. singleInstance = false;
  8422. _CoreManager.default.setObjectStateController(UniqueInstanceStateController);
  8423. }
  8424. /**
  8425. * Asynchronously stores the objects and every object they point to in the local datastore,
  8426. * recursively, using a default pin name: _default.
  8427. *
  8428. * If those other objects have not been fetched from Parse, they will not be stored.
  8429. * However, if they have changed data, all the changes will be retained.
  8430. *
  8431. * <pre>
  8432. * await Parse.Object.pinAll([...]);
  8433. * </pre>
  8434. *
  8435. * To retrieve object:
  8436. * <code>query.fromLocalDatastore()</code> or <code>query.fromPin()</code>
  8437. *
  8438. * @param {Array} objects A list of <code>Parse.Object</code>.
  8439. * @returns {Promise} A promise that is fulfilled when the pin completes.
  8440. * @static
  8441. */
  8442. static pinAll(objects) {
  8443. const localDatastore = _CoreManager.default.getLocalDatastore();
  8444. if (!localDatastore.isEnabled) {
  8445. return _promise.default.reject('Parse.enableLocalDatastore() must be called first');
  8446. }
  8447. return ParseObject.pinAllWithName(_LocalDatastoreUtils.DEFAULT_PIN, objects);
  8448. }
  8449. /**
  8450. * Asynchronously stores the objects and every object they point to in the local datastore, recursively.
  8451. *
  8452. * If those other objects have not been fetched from Parse, they will not be stored.
  8453. * However, if they have changed data, all the changes will be retained.
  8454. *
  8455. * <pre>
  8456. * await Parse.Object.pinAllWithName(name, [obj1, obj2, ...]);
  8457. * </pre>
  8458. *
  8459. * To retrieve object:
  8460. * <code>query.fromLocalDatastore()</code> or <code>query.fromPinWithName(name)</code>
  8461. *
  8462. * @param {string} name Name of Pin.
  8463. * @param {Array} objects A list of <code>Parse.Object</code>.
  8464. * @returns {Promise} A promise that is fulfilled when the pin completes.
  8465. * @static
  8466. */
  8467. static pinAllWithName(name, objects) {
  8468. const localDatastore = _CoreManager.default.getLocalDatastore();
  8469. if (!localDatastore.isEnabled) {
  8470. return _promise.default.reject('Parse.enableLocalDatastore() must be called first');
  8471. }
  8472. return localDatastore._handlePinAllWithName(name, objects);
  8473. }
  8474. /**
  8475. * Asynchronously removes the objects and every object they point to in the local datastore,
  8476. * recursively, using a default pin name: _default.
  8477. *
  8478. * <pre>
  8479. * await Parse.Object.unPinAll([...]);
  8480. * </pre>
  8481. *
  8482. * @param {Array} objects A list of <code>Parse.Object</code>.
  8483. * @returns {Promise} A promise that is fulfilled when the unPin completes.
  8484. * @static
  8485. */
  8486. static unPinAll(objects) {
  8487. const localDatastore = _CoreManager.default.getLocalDatastore();
  8488. if (!localDatastore.isEnabled) {
  8489. return _promise.default.reject('Parse.enableLocalDatastore() must be called first');
  8490. }
  8491. return ParseObject.unPinAllWithName(_LocalDatastoreUtils.DEFAULT_PIN, objects);
  8492. }
  8493. /**
  8494. * Asynchronously removes the objects and every object they point to in the local datastore, recursively.
  8495. *
  8496. * <pre>
  8497. * await Parse.Object.unPinAllWithName(name, [obj1, obj2, ...]);
  8498. * </pre>
  8499. *
  8500. * @param {string} name Name of Pin.
  8501. * @param {Array} objects A list of <code>Parse.Object</code>.
  8502. * @returns {Promise} A promise that is fulfilled when the unPin completes.
  8503. * @static
  8504. */
  8505. static unPinAllWithName(name, objects) {
  8506. const localDatastore = _CoreManager.default.getLocalDatastore();
  8507. if (!localDatastore.isEnabled) {
  8508. return _promise.default.reject('Parse.enableLocalDatastore() must be called first');
  8509. }
  8510. return localDatastore._handleUnPinAllWithName(name, objects);
  8511. }
  8512. /**
  8513. * Asynchronously removes all objects in the local datastore using a default pin name: _default.
  8514. *
  8515. * <pre>
  8516. * await Parse.Object.unPinAllObjects();
  8517. * </pre>
  8518. *
  8519. * @returns {Promise} A promise that is fulfilled when the unPin completes.
  8520. * @static
  8521. */
  8522. static unPinAllObjects() {
  8523. const localDatastore = _CoreManager.default.getLocalDatastore();
  8524. if (!localDatastore.isEnabled) {
  8525. return _promise.default.reject('Parse.enableLocalDatastore() must be called first');
  8526. }
  8527. return localDatastore.unPinWithName(_LocalDatastoreUtils.DEFAULT_PIN);
  8528. }
  8529. /**
  8530. * Asynchronously removes all objects with the specified pin name.
  8531. * Deletes the pin name also.
  8532. *
  8533. * <pre>
  8534. * await Parse.Object.unPinAllObjectsWithName(name);
  8535. * </pre>
  8536. *
  8537. * @param {string} name Name of Pin.
  8538. * @returns {Promise} A promise that is fulfilled when the unPin completes.
  8539. * @static
  8540. */
  8541. static unPinAllObjectsWithName(name) {
  8542. const localDatastore = _CoreManager.default.getLocalDatastore();
  8543. if (!localDatastore.isEnabled) {
  8544. return _promise.default.reject('Parse.enableLocalDatastore() must be called first');
  8545. }
  8546. return localDatastore.unPinWithName(_LocalDatastoreUtils.PIN_PREFIX + name);
  8547. }
  8548. }
  8549. const DefaultController = {
  8550. fetch(target, forceFetch, options) {
  8551. const localDatastore = _CoreManager.default.getLocalDatastore();
  8552. if ((0, _isArray.default)(target)) {
  8553. if (target.length < 1) {
  8554. return _promise.default.resolve([]);
  8555. }
  8556. const objs = [];
  8557. const ids = [];
  8558. let className = null;
  8559. const results = [];
  8560. let error = null;
  8561. (0, _forEach.default)(target).call(target, el => {
  8562. if (error) {
  8563. return;
  8564. }
  8565. if (!className) {
  8566. className = el.className;
  8567. }
  8568. if (className !== el.className) {
  8569. error = new _ParseError.default(_ParseError.default.INVALID_CLASS_NAME, 'All objects should be of the same class');
  8570. }
  8571. if (!el.id) {
  8572. error = new _ParseError.default(_ParseError.default.MISSING_OBJECT_ID, 'All objects must have an ID');
  8573. }
  8574. if (forceFetch || !el.isDataAvailable()) {
  8575. ids.push(el.id);
  8576. objs.push(el);
  8577. }
  8578. results.push(el);
  8579. });
  8580. if (error) {
  8581. return _promise.default.reject(error);
  8582. }
  8583. const ParseQuery = _CoreManager.default.getParseQuery();
  8584. const query = new ParseQuery(className);
  8585. query.containedIn('objectId', ids);
  8586. if (options && options.include) {
  8587. query.include(options.include);
  8588. }
  8589. query._limit = ids.length;
  8590. return (0, _find.default)(query).call(query, options).then(async objects => {
  8591. const idMap = {};
  8592. (0, _forEach.default)(objects).call(objects, o => {
  8593. idMap[o.id] = o;
  8594. });
  8595. for (let i = 0; i < objs.length; i++) {
  8596. const obj = objs[i];
  8597. if (!obj || !obj.id || !idMap[obj.id]) {
  8598. if (forceFetch) {
  8599. return _promise.default.reject(new _ParseError.default(_ParseError.default.OBJECT_NOT_FOUND, 'All objects must exist on the server.'));
  8600. }
  8601. }
  8602. }
  8603. if (!singleInstance) {
  8604. // If single instance objects are disabled, we need to replace the
  8605. for (let i = 0; i < results.length; i++) {
  8606. const obj = results[i];
  8607. if (obj && obj.id && idMap[obj.id]) {
  8608. const id = obj.id;
  8609. obj._finishFetch(idMap[id].toJSON());
  8610. results[i] = idMap[id];
  8611. }
  8612. }
  8613. }
  8614. for (const object of results) {
  8615. await localDatastore._updateObjectIfPinned(object);
  8616. }
  8617. return _promise.default.resolve(results);
  8618. });
  8619. } else if (target instanceof ParseObject) {
  8620. if (!target.id) {
  8621. return _promise.default.reject(new _ParseError.default(_ParseError.default.MISSING_OBJECT_ID, 'Object does not have an ID'));
  8622. }
  8623. const RESTController = _CoreManager.default.getRESTController();
  8624. const params = {};
  8625. if (options && options.include) {
  8626. params.include = options.include.join();
  8627. }
  8628. return RESTController.request('GET', 'classes/' + target.className + '/' + target._getId(), params, options).then(async response => {
  8629. target._clearPendingOps();
  8630. target._clearServerData();
  8631. target._finishFetch(response);
  8632. await localDatastore._updateObjectIfPinned(target);
  8633. return target;
  8634. });
  8635. }
  8636. return _promise.default.resolve(undefined);
  8637. },
  8638. async destroy(target, options) {
  8639. const batchSize = options && options.batchSize ? options.batchSize : _CoreManager.default.get('REQUEST_BATCH_SIZE');
  8640. const localDatastore = _CoreManager.default.getLocalDatastore();
  8641. const RESTController = _CoreManager.default.getRESTController();
  8642. if ((0, _isArray.default)(target)) {
  8643. if (target.length < 1) {
  8644. return _promise.default.resolve([]);
  8645. }
  8646. const batches = [[]];
  8647. (0, _forEach.default)(target).call(target, obj => {
  8648. if (!obj.id) {
  8649. return;
  8650. }
  8651. batches[batches.length - 1].push(obj);
  8652. if (batches[batches.length - 1].length >= batchSize) {
  8653. batches.push([]);
  8654. }
  8655. });
  8656. if (batches[batches.length - 1].length === 0) {
  8657. // If the last batch is empty, remove it
  8658. batches.pop();
  8659. }
  8660. let deleteCompleted = _promise.default.resolve();
  8661. const errors = [];
  8662. (0, _forEach.default)(batches).call(batches, batch => {
  8663. deleteCompleted = deleteCompleted.then(() => {
  8664. return RESTController.request('POST', 'batch', {
  8665. requests: (0, _map.default)(batch).call(batch, obj => {
  8666. return {
  8667. method: 'DELETE',
  8668. path: getServerUrlPath() + 'classes/' + obj.className + '/' + obj._getId(),
  8669. body: {}
  8670. };
  8671. })
  8672. }, options).then(results => {
  8673. for (let i = 0; i < results.length; i++) {
  8674. if (results[i] && results[i].hasOwnProperty('error')) {
  8675. const err = new _ParseError.default(results[i].error.code, results[i].error.error);
  8676. err.object = batch[i];
  8677. errors.push(err);
  8678. }
  8679. }
  8680. });
  8681. });
  8682. });
  8683. return deleteCompleted.then(async () => {
  8684. if (errors.length) {
  8685. const aggregate = new _ParseError.default(_ParseError.default.AGGREGATE_ERROR);
  8686. aggregate.errors = errors;
  8687. return _promise.default.reject(aggregate);
  8688. }
  8689. for (const object of target) {
  8690. await localDatastore._destroyObjectIfPinned(object);
  8691. }
  8692. return _promise.default.resolve(target);
  8693. });
  8694. } else if (target instanceof ParseObject) {
  8695. return RESTController.request('DELETE', 'classes/' + target.className + '/' + target._getId(), {}, options).then(async () => {
  8696. await localDatastore._destroyObjectIfPinned(target);
  8697. return _promise.default.resolve(target);
  8698. });
  8699. }
  8700. return _promise.default.resolve(target);
  8701. },
  8702. save(target, options) {
  8703. const batchSize = options && options.batchSize ? options.batchSize : _CoreManager.default.get('REQUEST_BATCH_SIZE');
  8704. const localDatastore = _CoreManager.default.getLocalDatastore();
  8705. const mapIdForPin = {};
  8706. const RESTController = _CoreManager.default.getRESTController();
  8707. const stateController = _CoreManager.default.getObjectStateController();
  8708. const allowCustomObjectId = _CoreManager.default.get('ALLOW_CUSTOM_OBJECT_ID');
  8709. options = options || {};
  8710. options.returnStatus = options.returnStatus || true;
  8711. if ((0, _isArray.default)(target)) {
  8712. if (target.length < 1) {
  8713. return _promise.default.resolve([]);
  8714. }
  8715. let unsaved = (0, _concat.default)(target).call(target);
  8716. for (let i = 0; i < target.length; i++) {
  8717. const target_i = target[i];
  8718. if (target_i instanceof ParseObject) {
  8719. unsaved = (0, _concat.default)(unsaved).call(unsaved, (0, _unsavedChildren.default)(target_i, true));
  8720. }
  8721. }
  8722. unsaved = (0, _unique.default)(unsaved);
  8723. const filesSaved = [];
  8724. let pending = [];
  8725. (0, _forEach.default)(unsaved).call(unsaved, el => {
  8726. if (el instanceof _ParseFile.default) {
  8727. filesSaved.push(el.save(options));
  8728. } else if (el instanceof ParseObject) {
  8729. pending.push(el);
  8730. }
  8731. });
  8732. return _promise.default.all(filesSaved).then(() => {
  8733. let objectError = null;
  8734. return (0, _promiseUtils.continueWhile)(() => {
  8735. return pending.length > 0;
  8736. }, () => {
  8737. const batch = [];
  8738. const nextPending = [];
  8739. (0, _forEach.default)(pending).call(pending, el => {
  8740. if (allowCustomObjectId && Object.prototype.hasOwnProperty.call(el, 'id') && !el.id) {
  8741. throw new _ParseError.default(_ParseError.default.MISSING_OBJECT_ID, 'objectId must not be empty or null');
  8742. }
  8743. if (batch.length < batchSize && (0, _canBeSerialized.default)(el)) {
  8744. batch.push(el);
  8745. } else {
  8746. nextPending.push(el);
  8747. }
  8748. });
  8749. pending = nextPending;
  8750. if (batch.length < 1) {
  8751. return _promise.default.reject(new _ParseError.default(_ParseError.default.OTHER_CAUSE, 'Tried to save a batch with a cycle.'));
  8752. }
  8753. // Queue up tasks for each object in the batch.
  8754. // When every task is ready, the API request will execute
  8755. const batchReturned = (0, _promiseUtils.resolvingPromise)();
  8756. const batchReady = [];
  8757. const batchTasks = [];
  8758. (0, _forEach.default)(batch).call(batch, (obj, index) => {
  8759. const ready = (0, _promiseUtils.resolvingPromise)();
  8760. batchReady.push(ready);
  8761. stateController.pushPendingState(obj._getStateIdentifier());
  8762. batchTasks.push(stateController.enqueueTask(obj._getStateIdentifier(), function () {
  8763. ready.resolve();
  8764. return batchReturned.then(responses => {
  8765. if (responses[index].hasOwnProperty('success')) {
  8766. const objectId = responses[index].success.objectId;
  8767. const status = responses[index]._status;
  8768. delete responses[index]._status;
  8769. delete responses[index]._headers;
  8770. delete responses[index]._xhr;
  8771. mapIdForPin[objectId] = obj._localId;
  8772. obj._handleSaveResponse(responses[index].success, status);
  8773. } else {
  8774. if (!objectError && responses[index].hasOwnProperty('error')) {
  8775. const serverError = responses[index].error;
  8776. objectError = new _ParseError.default(serverError.code, serverError.error);
  8777. // Cancel the rest of the save
  8778. pending = [];
  8779. }
  8780. obj._handleSaveError();
  8781. }
  8782. });
  8783. }));
  8784. });
  8785. (0, _promiseUtils.when)(batchReady).then(() => {
  8786. // Kick off the batch request
  8787. return RESTController.request('POST', 'batch', {
  8788. requests: (0, _map.default)(batch).call(batch, obj => {
  8789. const params = obj._getSaveParams();
  8790. params.path = getServerUrlPath() + params.path;
  8791. return params;
  8792. })
  8793. }, options);
  8794. }).then(batchReturned.resolve, error => {
  8795. batchReturned.reject(new _ParseError.default(_ParseError.default.INCORRECT_TYPE, error.message));
  8796. });
  8797. return (0, _promiseUtils.when)(batchTasks);
  8798. }).then(async () => {
  8799. if (objectError) {
  8800. return _promise.default.reject(objectError);
  8801. }
  8802. for (const object of target) {
  8803. // Make sure that it is a ParseObject before updating it into the localDataStore
  8804. if (object instanceof ParseObject) {
  8805. await localDatastore._updateLocalIdForObject(mapIdForPin[object.id], object);
  8806. await localDatastore._updateObjectIfPinned(object);
  8807. }
  8808. }
  8809. return _promise.default.resolve(target);
  8810. });
  8811. });
  8812. } else if (target instanceof ParseObject) {
  8813. if (allowCustomObjectId && Object.prototype.hasOwnProperty.call(target, 'id') && !target.id) {
  8814. throw new _ParseError.default(_ParseError.default.MISSING_OBJECT_ID, 'objectId must not be empty or null');
  8815. }
  8816. // generate _localId in case if cascadeSave=false
  8817. target._getId();
  8818. const localId = target._localId;
  8819. // copying target lets guarantee the pointer isn't modified elsewhere
  8820. const targetCopy = target;
  8821. const task = function () {
  8822. const params = targetCopy._getSaveParams();
  8823. return RESTController.request(params.method, params.path, params.body, options).then(response => {
  8824. const status = response._status;
  8825. delete response._status;
  8826. delete response._headers;
  8827. delete response._xhr;
  8828. targetCopy._handleSaveResponse(response, status);
  8829. }, error => {
  8830. targetCopy._handleSaveError();
  8831. return _promise.default.reject(error);
  8832. });
  8833. };
  8834. stateController.pushPendingState(target._getStateIdentifier());
  8835. return stateController.enqueueTask(target._getStateIdentifier(), task).then(async () => {
  8836. await localDatastore._updateLocalIdForObject(localId, target);
  8837. await localDatastore._updateObjectIfPinned(target);
  8838. return target;
  8839. }, error => {
  8840. return _promise.default.reject(error);
  8841. });
  8842. }
  8843. return _promise.default.resolve(undefined);
  8844. }
  8845. };
  8846. _CoreManager.default.setParseObject(ParseObject);
  8847. _CoreManager.default.setObjectController(DefaultController);
  8848. var _default = exports.default = ParseObject;
  8849. },{"./CoreManager":4,"./LocalDatastoreUtils":17,"./ParseACL":21,"./ParseError":24,"./ParseFile":25,"./ParseOp":31,"./ParseRelation":34,"./SingleInstanceStateController":41,"./UniqueInstanceStateController":50,"./canBeSerialized":54,"./decode":55,"./encode":56,"./escape":58,"./parseDate":60,"./promiseUtils":61,"./unique":62,"./unsavedChildren":63,"./uuid":64,"@babel/runtime-corejs3/core-js-stable/array/is-array":66,"@babel/runtime-corejs3/core-js-stable/instance/concat":68,"@babel/runtime-corejs3/core-js-stable/instance/find":73,"@babel/runtime-corejs3/core-js-stable/instance/for-each":74,"@babel/runtime-corejs3/core-js-stable/instance/includes":75,"@babel/runtime-corejs3/core-js-stable/instance/index-of":76,"@babel/runtime-corejs3/core-js-stable/instance/map":78,"@babel/runtime-corejs3/core-js-stable/json/stringify":85,"@babel/runtime-corejs3/core-js-stable/object/create":89,"@babel/runtime-corejs3/core-js-stable/object/define-property":90,"@babel/runtime-corejs3/core-js-stable/object/freeze":92,"@babel/runtime-corejs3/core-js-stable/object/get-own-property-descriptor":93,"@babel/runtime-corejs3/core-js-stable/object/get-prototype-of":94,"@babel/runtime-corejs3/core-js-stable/object/keys":95,"@babel/runtime-corejs3/core-js-stable/promise":97,"@babel/runtime-corejs3/core-js-stable/weak-map":101,"@babel/runtime-corejs3/helpers/defineProperty":102,"@babel/runtime-corejs3/helpers/interopRequireDefault":103}],31:[function(_dereq_,module,exports){
  8850. "use strict";
  8851. var _Object$defineProperty = _dereq_("@babel/runtime-corejs3/core-js-stable/object/define-property");
  8852. var _interopRequireDefault = _dereq_("@babel/runtime-corejs3/helpers/interopRequireDefault");
  8853. _Object$defineProperty(exports, "__esModule", {
  8854. value: true
  8855. });
  8856. exports.UnsetOp = exports.SetOp = exports.RemoveOp = exports.RelationOp = exports.Op = exports.IncrementOp = exports.AddUniqueOp = exports.AddOp = void 0;
  8857. exports.opFromJSON = opFromJSON;
  8858. var _defineProperty2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/helpers/defineProperty"));
  8859. var _isArray = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/array/is-array"));
  8860. var _concat = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/instance/concat"));
  8861. var _forEach = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/instance/for-each"));
  8862. var _indexOf = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/instance/index-of"));
  8863. var _splice = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/instance/splice"));
  8864. var _map = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/instance/map"));
  8865. var _arrayContainsObject = _interopRequireDefault(_dereq_("./arrayContainsObject"));
  8866. var _decode = _interopRequireDefault(_dereq_("./decode"));
  8867. var _encode = _interopRequireDefault(_dereq_("./encode"));
  8868. var _CoreManager = _interopRequireDefault(_dereq_("./CoreManager"));
  8869. var _ParseRelation = _interopRequireDefault(_dereq_("./ParseRelation"));
  8870. var _unique = _interopRequireDefault(_dereq_("./unique"));
  8871. function opFromJSON(json) {
  8872. if (!json || !json.__op) {
  8873. return null;
  8874. }
  8875. switch (json.__op) {
  8876. case 'Delete':
  8877. return new UnsetOp();
  8878. case 'Increment':
  8879. return new IncrementOp(json.amount);
  8880. case 'Add':
  8881. return new AddOp((0, _decode.default)(json.objects));
  8882. case 'AddUnique':
  8883. return new AddUniqueOp((0, _decode.default)(json.objects));
  8884. case 'Remove':
  8885. return new RemoveOp((0, _decode.default)(json.objects));
  8886. case 'AddRelation':
  8887. {
  8888. const toAdd = (0, _decode.default)(json.objects);
  8889. if (!(0, _isArray.default)(toAdd)) {
  8890. return new RelationOp([], []);
  8891. }
  8892. return new RelationOp(toAdd, []);
  8893. }
  8894. case 'RemoveRelation':
  8895. {
  8896. const toRemove = (0, _decode.default)(json.objects);
  8897. if (!(0, _isArray.default)(toRemove)) {
  8898. return new RelationOp([], []);
  8899. }
  8900. return new RelationOp([], toRemove);
  8901. }
  8902. case 'Batch':
  8903. {
  8904. let toAdd = [];
  8905. let toRemove = [];
  8906. for (let i = 0; i < json.ops.length; i++) {
  8907. if (json.ops[i].__op === 'AddRelation') {
  8908. toAdd = (0, _concat.default)(toAdd).call(toAdd, (0, _decode.default)(json.ops[i].objects));
  8909. } else if (json.ops[i].__op === 'RemoveRelation') {
  8910. toRemove = (0, _concat.default)(toRemove).call(toRemove, (0, _decode.default)(json.ops[i].objects));
  8911. }
  8912. }
  8913. return new RelationOp(toAdd, toRemove);
  8914. }
  8915. }
  8916. return null;
  8917. }
  8918. class Op {
  8919. // Empty parent class
  8920. applyTo() {} /* eslint-disable-line @typescript-eslint/no-unused-vars */
  8921. mergeWith() {} /* eslint-disable-line @typescript-eslint/no-unused-vars */
  8922. toJSON() {} /* eslint-disable-line @typescript-eslint/no-unused-vars */
  8923. }
  8924. exports.Op = Op;
  8925. class SetOp extends Op {
  8926. constructor(value) {
  8927. super();
  8928. (0, _defineProperty2.default)(this, "_value", void 0);
  8929. this._value = value;
  8930. }
  8931. applyTo() {
  8932. return this._value;
  8933. }
  8934. mergeWith() {
  8935. return new SetOp(this._value);
  8936. }
  8937. toJSON(offline) {
  8938. return (0, _encode.default)(this._value, false, true, undefined, offline);
  8939. }
  8940. }
  8941. exports.SetOp = SetOp;
  8942. class UnsetOp extends Op {
  8943. applyTo() {
  8944. return undefined;
  8945. }
  8946. mergeWith() {
  8947. return new UnsetOp();
  8948. }
  8949. toJSON() {
  8950. return {
  8951. __op: 'Delete'
  8952. };
  8953. }
  8954. }
  8955. exports.UnsetOp = UnsetOp;
  8956. class IncrementOp extends Op {
  8957. constructor(amount) {
  8958. super();
  8959. (0, _defineProperty2.default)(this, "_amount", void 0);
  8960. if (typeof amount !== 'number') {
  8961. throw new TypeError('Increment Op must be initialized with a numeric amount.');
  8962. }
  8963. this._amount = amount;
  8964. }
  8965. applyTo(value) {
  8966. if (typeof value === 'undefined') {
  8967. return this._amount;
  8968. }
  8969. if (typeof value !== 'number') {
  8970. throw new TypeError('Cannot increment a non-numeric value.');
  8971. }
  8972. return this._amount + value;
  8973. }
  8974. mergeWith(previous) {
  8975. if (!previous) {
  8976. return this;
  8977. }
  8978. if (previous instanceof SetOp) {
  8979. return new SetOp(this.applyTo(previous._value));
  8980. }
  8981. if (previous instanceof UnsetOp) {
  8982. return new SetOp(this._amount);
  8983. }
  8984. if (previous instanceof IncrementOp) {
  8985. return new IncrementOp(this.applyTo(previous._amount));
  8986. }
  8987. throw new Error('Cannot merge Increment Op with the previous Op');
  8988. }
  8989. toJSON() {
  8990. return {
  8991. __op: 'Increment',
  8992. amount: this._amount
  8993. };
  8994. }
  8995. }
  8996. exports.IncrementOp = IncrementOp;
  8997. class AddOp extends Op {
  8998. constructor(value) {
  8999. super();
  9000. (0, _defineProperty2.default)(this, "_value", void 0);
  9001. this._value = (0, _isArray.default)(value) ? value : [value];
  9002. }
  9003. applyTo(value) {
  9004. if (value == null) {
  9005. return this._value;
  9006. }
  9007. if ((0, _isArray.default)(value)) {
  9008. return (0, _concat.default)(value).call(value, this._value);
  9009. }
  9010. throw new Error('Cannot add elements to a non-array value');
  9011. }
  9012. mergeWith(previous) {
  9013. if (!previous) {
  9014. return this;
  9015. }
  9016. if (previous instanceof SetOp) {
  9017. return new SetOp(this.applyTo(previous._value));
  9018. }
  9019. if (previous instanceof UnsetOp) {
  9020. return new SetOp(this._value);
  9021. }
  9022. if (previous instanceof AddOp) {
  9023. return new AddOp(this.applyTo(previous._value));
  9024. }
  9025. throw new Error('Cannot merge Add Op with the previous Op');
  9026. }
  9027. toJSON() {
  9028. return {
  9029. __op: 'Add',
  9030. objects: (0, _encode.default)(this._value, false, true)
  9031. };
  9032. }
  9033. }
  9034. exports.AddOp = AddOp;
  9035. class AddUniqueOp extends Op {
  9036. constructor(value) {
  9037. super();
  9038. (0, _defineProperty2.default)(this, "_value", void 0);
  9039. this._value = (0, _unique.default)((0, _isArray.default)(value) ? value : [value]);
  9040. }
  9041. applyTo(value) {
  9042. if (value == null) {
  9043. return this._value || [];
  9044. }
  9045. if ((0, _isArray.default)(value)) {
  9046. var _context;
  9047. const ParseObject = _CoreManager.default.getParseObject();
  9048. const toAdd = [];
  9049. (0, _forEach.default)(_context = this._value).call(_context, v => {
  9050. if (v instanceof ParseObject) {
  9051. if (!(0, _arrayContainsObject.default)(value, v)) {
  9052. toAdd.push(v);
  9053. }
  9054. } else {
  9055. if ((0, _indexOf.default)(value).call(value, v) < 0) {
  9056. toAdd.push(v);
  9057. }
  9058. }
  9059. });
  9060. return (0, _concat.default)(value).call(value, toAdd);
  9061. }
  9062. throw new Error('Cannot add elements to a non-array value');
  9063. }
  9064. mergeWith(previous) {
  9065. if (!previous) {
  9066. return this;
  9067. }
  9068. if (previous instanceof SetOp) {
  9069. return new SetOp(this.applyTo(previous._value));
  9070. }
  9071. if (previous instanceof UnsetOp) {
  9072. return new SetOp(this._value);
  9073. }
  9074. if (previous instanceof AddUniqueOp) {
  9075. return new AddUniqueOp(this.applyTo(previous._value));
  9076. }
  9077. throw new Error('Cannot merge AddUnique Op with the previous Op');
  9078. }
  9079. toJSON() {
  9080. return {
  9081. __op: 'AddUnique',
  9082. objects: (0, _encode.default)(this._value, false, true)
  9083. };
  9084. }
  9085. }
  9086. exports.AddUniqueOp = AddUniqueOp;
  9087. class RemoveOp extends Op {
  9088. constructor(value) {
  9089. super();
  9090. (0, _defineProperty2.default)(this, "_value", void 0);
  9091. this._value = (0, _unique.default)((0, _isArray.default)(value) ? value : [value]);
  9092. }
  9093. applyTo(value) {
  9094. if (value == null) {
  9095. return [];
  9096. }
  9097. if ((0, _isArray.default)(value)) {
  9098. const ParseObject = _CoreManager.default.getParseObject();
  9099. // var i = value.indexOf(this._value);
  9100. const removed = (0, _concat.default)(value).call(value, []);
  9101. for (let i = 0; i < this._value.length; i++) {
  9102. let index = (0, _indexOf.default)(removed).call(removed, this._value[i]);
  9103. while (index > -1) {
  9104. (0, _splice.default)(removed).call(removed, index, 1);
  9105. index = (0, _indexOf.default)(removed).call(removed, this._value[i]);
  9106. }
  9107. if (this._value[i] instanceof ParseObject && this._value[i].id) {
  9108. for (let j = 0; j < removed.length; j++) {
  9109. if (removed[j] instanceof ParseObject && this._value[i].id === removed[j].id) {
  9110. (0, _splice.default)(removed).call(removed, j, 1);
  9111. j--;
  9112. }
  9113. }
  9114. }
  9115. }
  9116. return removed;
  9117. }
  9118. throw new Error('Cannot remove elements from a non-array value');
  9119. }
  9120. mergeWith(previous) {
  9121. if (!previous) {
  9122. return this;
  9123. }
  9124. if (previous instanceof SetOp) {
  9125. return new SetOp(this.applyTo(previous._value));
  9126. }
  9127. if (previous instanceof UnsetOp) {
  9128. return new UnsetOp();
  9129. }
  9130. if (previous instanceof RemoveOp) {
  9131. var _context2;
  9132. const ParseObject = _CoreManager.default.getParseObject();
  9133. const uniques = (0, _concat.default)(_context2 = previous._value).call(_context2, []);
  9134. for (let i = 0; i < this._value.length; i++) {
  9135. if (this._value[i] instanceof ParseObject) {
  9136. if (!(0, _arrayContainsObject.default)(uniques, this._value[i])) {
  9137. uniques.push(this._value[i]);
  9138. }
  9139. } else {
  9140. if ((0, _indexOf.default)(uniques).call(uniques, this._value[i]) < 0) {
  9141. uniques.push(this._value[i]);
  9142. }
  9143. }
  9144. }
  9145. return new RemoveOp(uniques);
  9146. }
  9147. throw new Error('Cannot merge Remove Op with the previous Op');
  9148. }
  9149. toJSON() {
  9150. return {
  9151. __op: 'Remove',
  9152. objects: (0, _encode.default)(this._value, false, true)
  9153. };
  9154. }
  9155. }
  9156. exports.RemoveOp = RemoveOp;
  9157. class RelationOp extends Op {
  9158. constructor(adds, removes) {
  9159. super();
  9160. (0, _defineProperty2.default)(this, "_targetClassName", void 0);
  9161. (0, _defineProperty2.default)(this, "relationsToAdd", void 0);
  9162. (0, _defineProperty2.default)(this, "relationsToRemove", void 0);
  9163. this._targetClassName = null;
  9164. if ((0, _isArray.default)(adds)) {
  9165. this.relationsToAdd = (0, _unique.default)((0, _map.default)(adds).call(adds, this._extractId, this));
  9166. }
  9167. if ((0, _isArray.default)(removes)) {
  9168. this.relationsToRemove = (0, _unique.default)((0, _map.default)(removes).call(removes, this._extractId, this));
  9169. }
  9170. }
  9171. _extractId(obj) {
  9172. if (typeof obj === 'string') {
  9173. return obj;
  9174. }
  9175. if (!obj.id) {
  9176. throw new Error('You cannot add or remove an unsaved Parse Object from a relation');
  9177. }
  9178. if (!this._targetClassName) {
  9179. this._targetClassName = obj.className;
  9180. }
  9181. if (this._targetClassName !== obj.className) {
  9182. throw new Error('Tried to create a Relation with 2 different object types: ' + this._targetClassName + ' and ' + obj.className + '.');
  9183. }
  9184. return obj.id;
  9185. }
  9186. applyTo(value, parent, key) {
  9187. if (!value) {
  9188. if (!parent || !key) {
  9189. throw new Error('Cannot apply a RelationOp without either a previous value, or an object and a key');
  9190. }
  9191. const relation = new _ParseRelation.default(parent, key);
  9192. relation.targetClassName = this._targetClassName;
  9193. return relation;
  9194. }
  9195. if (value instanceof _ParseRelation.default) {
  9196. if (this._targetClassName) {
  9197. if (value.targetClassName) {
  9198. if (this._targetClassName !== value.targetClassName) {
  9199. throw new Error('Related object must be a ' + value.targetClassName + ', but a ' + this._targetClassName + ' was passed in.');
  9200. }
  9201. } else {
  9202. value.targetClassName = this._targetClassName;
  9203. }
  9204. }
  9205. return value;
  9206. } else {
  9207. throw new Error('Relation cannot be applied to a non-relation field');
  9208. }
  9209. }
  9210. mergeWith(previous) {
  9211. if (!previous) {
  9212. return this;
  9213. } else if (previous instanceof UnsetOp) {
  9214. throw new Error('You cannot modify a relation after deleting it.');
  9215. } else if (previous instanceof SetOp && previous._value instanceof _ParseRelation.default) {
  9216. return this;
  9217. } else if (previous instanceof RelationOp) {
  9218. var _context3, _context4, _context5, _context6, _context7, _context8;
  9219. if (previous._targetClassName && previous._targetClassName !== this._targetClassName) {
  9220. throw new Error('Related object must be of class ' + previous._targetClassName + ', but ' + (this._targetClassName || 'null') + ' was passed in.');
  9221. }
  9222. const newAdd = (0, _concat.default)(_context3 = previous.relationsToAdd).call(_context3, []);
  9223. (0, _forEach.default)(_context4 = this.relationsToRemove).call(_context4, r => {
  9224. const index = (0, _indexOf.default)(newAdd).call(newAdd, r);
  9225. if (index > -1) {
  9226. (0, _splice.default)(newAdd).call(newAdd, index, 1);
  9227. }
  9228. });
  9229. (0, _forEach.default)(_context5 = this.relationsToAdd).call(_context5, r => {
  9230. const index = (0, _indexOf.default)(newAdd).call(newAdd, r);
  9231. if (index < 0) {
  9232. newAdd.push(r);
  9233. }
  9234. });
  9235. const newRemove = (0, _concat.default)(_context6 = previous.relationsToRemove).call(_context6, []);
  9236. (0, _forEach.default)(_context7 = this.relationsToAdd).call(_context7, r => {
  9237. const index = (0, _indexOf.default)(newRemove).call(newRemove, r);
  9238. if (index > -1) {
  9239. (0, _splice.default)(newRemove).call(newRemove, index, 1);
  9240. }
  9241. });
  9242. (0, _forEach.default)(_context8 = this.relationsToRemove).call(_context8, r => {
  9243. const index = (0, _indexOf.default)(newRemove).call(newRemove, r);
  9244. if (index < 0) {
  9245. newRemove.push(r);
  9246. }
  9247. });
  9248. const newRelation = new RelationOp(newAdd, newRemove);
  9249. newRelation._targetClassName = this._targetClassName;
  9250. return newRelation;
  9251. }
  9252. throw new Error('Cannot merge Relation Op with the previous Op');
  9253. }
  9254. toJSON() {
  9255. const idToPointer = id => {
  9256. return {
  9257. __type: 'Pointer',
  9258. className: this._targetClassName,
  9259. objectId: id
  9260. };
  9261. };
  9262. let pointers = null;
  9263. let adds = null;
  9264. let removes = null;
  9265. if (this.relationsToAdd.length > 0) {
  9266. var _context9;
  9267. pointers = (0, _map.default)(_context9 = this.relationsToAdd).call(_context9, idToPointer);
  9268. adds = {
  9269. __op: 'AddRelation',
  9270. objects: pointers
  9271. };
  9272. }
  9273. if (this.relationsToRemove.length > 0) {
  9274. var _context10;
  9275. pointers = (0, _map.default)(_context10 = this.relationsToRemove).call(_context10, idToPointer);
  9276. removes = {
  9277. __op: 'RemoveRelation',
  9278. objects: pointers
  9279. };
  9280. }
  9281. if (adds && removes) {
  9282. return {
  9283. __op: 'Batch',
  9284. ops: [adds, removes]
  9285. };
  9286. }
  9287. return adds || removes || {};
  9288. }
  9289. }
  9290. exports.RelationOp = RelationOp;
  9291. _CoreManager.default.setParseOp({
  9292. Op,
  9293. opFromJSON,
  9294. SetOp,
  9295. UnsetOp,
  9296. IncrementOp,
  9297. AddOp,
  9298. RelationOp,
  9299. RemoveOp,
  9300. AddUniqueOp
  9301. });
  9302. },{"./CoreManager":4,"./ParseRelation":34,"./arrayContainsObject":53,"./decode":55,"./encode":56,"./unique":62,"@babel/runtime-corejs3/core-js-stable/array/is-array":66,"@babel/runtime-corejs3/core-js-stable/instance/concat":68,"@babel/runtime-corejs3/core-js-stable/instance/for-each":74,"@babel/runtime-corejs3/core-js-stable/instance/index-of":76,"@babel/runtime-corejs3/core-js-stable/instance/map":78,"@babel/runtime-corejs3/core-js-stable/instance/splice":82,"@babel/runtime-corejs3/core-js-stable/object/define-property":90,"@babel/runtime-corejs3/helpers/defineProperty":102,"@babel/runtime-corejs3/helpers/interopRequireDefault":103}],32:[function(_dereq_,module,exports){
  9303. "use strict";
  9304. var _Object$defineProperty = _dereq_("@babel/runtime-corejs3/core-js-stable/object/define-property");
  9305. var _interopRequireDefault = _dereq_("@babel/runtime-corejs3/helpers/interopRequireDefault");
  9306. _Object$defineProperty(exports, "__esModule", {
  9307. value: true
  9308. });
  9309. exports.default = void 0;
  9310. var _isArray = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/array/is-array"));
  9311. var _defineProperty2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/helpers/defineProperty"));
  9312. var _ParseGeoPoint = _interopRequireDefault(_dereq_("./ParseGeoPoint"));
  9313. /**
  9314. * Creates a new Polygon with any of the following forms:<br>
  9315. * <pre>
  9316. * new Polygon([[0,0],[0,1],[1,1],[1,0]])
  9317. * new Polygon([GeoPoint, GeoPoint, GeoPoint])
  9318. * </pre>
  9319. *
  9320. * <p>Represents a coordinates that may be associated
  9321. * with a key in a ParseObject or used as a reference point for geo queries.
  9322. * This allows proximity-based queries on the key.</p>
  9323. *
  9324. * <p>Example:<pre>
  9325. * var polygon = new Parse.Polygon([[0,0],[0,1],[1,1],[1,0]]);
  9326. * var object = new Parse.Object("PlaceObject");
  9327. * object.set("area", polygon);
  9328. * object.save();</pre></p>
  9329. *
  9330. * @alias Parse.Polygon
  9331. */
  9332. class ParsePolygon {
  9333. /**
  9334. * @param {(Coordinates | Parse.GeoPoint[])} coordinates An Array of coordinate pairs
  9335. */
  9336. constructor(coordinates) {
  9337. (0, _defineProperty2.default)(this, "_coordinates", void 0);
  9338. this._coordinates = ParsePolygon._validate(coordinates);
  9339. }
  9340. /**
  9341. * Coordinates value for this Polygon.
  9342. * Throws an exception if not valid type.
  9343. *
  9344. * @property {(Coordinates | Parse.GeoPoint[])} coordinates list of coordinates
  9345. * @returns {Coordinates}
  9346. */
  9347. get coordinates() {
  9348. return this._coordinates;
  9349. }
  9350. set coordinates(coords) {
  9351. this._coordinates = ParsePolygon._validate(coords);
  9352. }
  9353. /**
  9354. * Returns a JSON representation of the Polygon, suitable for Parse.
  9355. *
  9356. * @returns {object}
  9357. */
  9358. toJSON() {
  9359. ParsePolygon._validate(this._coordinates);
  9360. return {
  9361. __type: 'Polygon',
  9362. coordinates: this._coordinates
  9363. };
  9364. }
  9365. /**
  9366. * Checks if two polygons are equal
  9367. *
  9368. * @param {(Parse.Polygon | object)} other
  9369. * @returns {boolean}
  9370. */
  9371. equals(other) {
  9372. if (!(other instanceof ParsePolygon) || this.coordinates.length !== other.coordinates.length) {
  9373. return false;
  9374. }
  9375. let isEqual = true;
  9376. for (let i = 1; i < this._coordinates.length; i += 1) {
  9377. if (this._coordinates[i][0] != other.coordinates[i][0] || this._coordinates[i][1] != other.coordinates[i][1]) {
  9378. isEqual = false;
  9379. break;
  9380. }
  9381. }
  9382. return isEqual;
  9383. }
  9384. /**
  9385. *
  9386. * @param {Parse.GeoPoint} point
  9387. * @returns {boolean} Returns if the point is contained in the polygon
  9388. */
  9389. containsPoint(point) {
  9390. let minX = this._coordinates[0][0];
  9391. let maxX = this._coordinates[0][0];
  9392. let minY = this._coordinates[0][1];
  9393. let maxY = this._coordinates[0][1];
  9394. for (let i = 1; i < this._coordinates.length; i += 1) {
  9395. const p = this._coordinates[i];
  9396. minX = Math.min(p[0], minX);
  9397. maxX = Math.max(p[0], maxX);
  9398. minY = Math.min(p[1], minY);
  9399. maxY = Math.max(p[1], maxY);
  9400. }
  9401. const outside = point.latitude < minX || point.latitude > maxX || point.longitude < minY || point.longitude > maxY;
  9402. if (outside) {
  9403. return false;
  9404. }
  9405. let inside = false;
  9406. for (let i = 0, j = this._coordinates.length - 1; i < this._coordinates.length; j = i++) {
  9407. const startX = this._coordinates[i][0];
  9408. const startY = this._coordinates[i][1];
  9409. const endX = this._coordinates[j][0];
  9410. const endY = this._coordinates[j][1];
  9411. const intersect = startY > point.longitude != endY > point.longitude && point.latitude < (endX - startX) * (point.longitude - startY) / (endY - startY) + startX;
  9412. if (intersect) {
  9413. inside = !inside;
  9414. }
  9415. }
  9416. return inside;
  9417. }
  9418. /**
  9419. * Validates that the list of coordinates can form a valid polygon
  9420. *
  9421. * @param {Array} coords the list of coordinates to validate as a polygon
  9422. * @throws {TypeError}
  9423. * @returns {number[][]} Array of coordinates if validated.
  9424. */
  9425. static _validate(coords) {
  9426. if (!(0, _isArray.default)(coords)) {
  9427. throw new TypeError('Coordinates must be an Array');
  9428. }
  9429. if (coords.length < 3) {
  9430. throw new TypeError('Polygon must have at least 3 GeoPoints or Points');
  9431. }
  9432. const points = [];
  9433. for (let i = 0; i < coords.length; i += 1) {
  9434. const coord = coords[i];
  9435. let geoPoint;
  9436. if (coord instanceof _ParseGeoPoint.default) {
  9437. geoPoint = coord;
  9438. } else if ((0, _isArray.default)(coord) && coord.length === 2) {
  9439. geoPoint = new _ParseGeoPoint.default(coord[0], coord[1]);
  9440. } else {
  9441. throw new TypeError('Coordinates must be an Array of GeoPoints or Points');
  9442. }
  9443. points.push([geoPoint.latitude, geoPoint.longitude]);
  9444. }
  9445. return points;
  9446. }
  9447. }
  9448. var _default = exports.default = ParsePolygon;
  9449. },{"./ParseGeoPoint":26,"@babel/runtime-corejs3/core-js-stable/array/is-array":66,"@babel/runtime-corejs3/core-js-stable/object/define-property":90,"@babel/runtime-corejs3/helpers/defineProperty":102,"@babel/runtime-corejs3/helpers/interopRequireDefault":103}],33:[function(_dereq_,module,exports){
  9450. "use strict";
  9451. var _Object$defineProperty = _dereq_("@babel/runtime-corejs3/core-js-stable/object/define-property");
  9452. var _interopRequireDefault = _dereq_("@babel/runtime-corejs3/helpers/interopRequireDefault");
  9453. _Object$defineProperty(exports, "__esModule", {
  9454. value: true
  9455. });
  9456. exports.default = void 0;
  9457. var _defineProperty2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/helpers/defineProperty"));
  9458. var _forEach = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/instance/for-each"));
  9459. var _indexOf = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/instance/index-of"));
  9460. var _keys = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/object/keys"));
  9461. var _slice = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/instance/slice"));
  9462. var _map = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/instance/map"));
  9463. var _filter = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/instance/filter"));
  9464. var _keys2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/instance/keys"));
  9465. var _concat = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/instance/concat"));
  9466. var _includes = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/instance/includes"));
  9467. var _sort = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/instance/sort"));
  9468. var _splice = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/instance/splice"));
  9469. var _promise = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/promise"));
  9470. var _find = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/instance/find"));
  9471. var _isArray = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/array/is-array"));
  9472. var _entries = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/object/entries"));
  9473. var _CoreManager = _interopRequireDefault(_dereq_("./CoreManager"));
  9474. var _encode = _interopRequireDefault(_dereq_("./encode"));
  9475. var _promiseUtils = _dereq_("./promiseUtils");
  9476. var _ParseError = _interopRequireDefault(_dereq_("./ParseError"));
  9477. var _ParseGeoPoint = _interopRequireDefault(_dereq_("./ParseGeoPoint"));
  9478. var _ParseObject = _interopRequireDefault(_dereq_("./ParseObject"));
  9479. var _OfflineQuery = _interopRequireDefault(_dereq_("./OfflineQuery"));
  9480. var _LocalDatastoreUtils = _dereq_("./LocalDatastoreUtils");
  9481. /**
  9482. * Converts a string into a regex that matches it.
  9483. * Surrounding with \Q .. \E does this, we just need to escape any \E's in
  9484. * the text separately.
  9485. *
  9486. * @param s
  9487. * @private
  9488. * @returns {string}
  9489. */
  9490. function quote(s) {
  9491. return '\\Q' + s.replace('\\E', '\\E\\\\E\\Q') + '\\E';
  9492. }
  9493. /**
  9494. * Extracts the class name from queries. If not all queries have the same
  9495. * class name an error will be thrown.
  9496. *
  9497. * @param queries
  9498. * @private
  9499. * @returns {string}
  9500. */
  9501. function _getClassNameFromQueries(queries) {
  9502. let className = null;
  9503. (0, _forEach.default)(queries).call(queries, q => {
  9504. if (!className) {
  9505. className = q.className;
  9506. }
  9507. if (className !== q.className) {
  9508. throw new Error('All queries must be for the same class.');
  9509. }
  9510. });
  9511. return className;
  9512. }
  9513. /*
  9514. * Handles pre-populating the result data of a query with select fields,
  9515. * making sure that the data object contains keys for all objects that have
  9516. * been requested with a select, so that our cached state updates correctly.
  9517. */
  9518. function handleSelectResult(data, select) {
  9519. const serverDataMask = {};
  9520. (0, _forEach.default)(select).call(select, field => {
  9521. const hasSubObjectSelect = (0, _indexOf.default)(field).call(field, '.') !== -1;
  9522. if (!hasSubObjectSelect && !data.hasOwnProperty(field)) {
  9523. // this field was selected, but is missing from the retrieved data
  9524. data[field] = undefined;
  9525. } else if (hasSubObjectSelect) {
  9526. // this field references a sub-object,
  9527. // so we need to walk down the path components
  9528. const pathComponents = field.split('.');
  9529. let obj = data;
  9530. let serverMask = serverDataMask;
  9531. (0, _forEach.default)(pathComponents).call(pathComponents, (component, index, arr) => {
  9532. // add keys if the expected data is missing
  9533. if (obj && !obj.hasOwnProperty(component)) {
  9534. obj[component] = undefined;
  9535. }
  9536. if (obj && typeof obj === 'object') {
  9537. obj = obj[component];
  9538. }
  9539. //add this path component to the server mask so we can fill it in later if needed
  9540. if (index < arr.length - 1) {
  9541. if (!serverMask[component]) {
  9542. serverMask[component] = {};
  9543. }
  9544. serverMask = serverMask[component];
  9545. }
  9546. });
  9547. }
  9548. });
  9549. if ((0, _keys.default)(serverDataMask).length > 0) {
  9550. // When selecting from sub-objects, we don't want to blow away the missing
  9551. // information that we may have retrieved before. We've already added any
  9552. // missing selected keys to sub-objects, but we still need to add in the
  9553. // data for any previously retrieved sub-objects that were not selected.
  9554. const serverData = _CoreManager.default.getObjectStateController().getServerData({
  9555. id: data.objectId,
  9556. className: data.className
  9557. });
  9558. copyMissingDataWithMask(serverData, data, serverDataMask, false);
  9559. }
  9560. }
  9561. function copyMissingDataWithMask(src, dest, mask, copyThisLevel) {
  9562. //copy missing elements at this level
  9563. if (copyThisLevel) {
  9564. for (const key in src) {
  9565. if (src.hasOwnProperty(key) && !dest.hasOwnProperty(key)) {
  9566. dest[key] = src[key];
  9567. }
  9568. }
  9569. }
  9570. for (const key in mask) {
  9571. if (dest[key] !== undefined && dest[key] !== null && src !== undefined && src !== null) {
  9572. //traverse into objects as needed
  9573. copyMissingDataWithMask(src[key], dest[key], mask[key], true);
  9574. }
  9575. }
  9576. }
  9577. function handleOfflineSort(a, b, sorts) {
  9578. let order = sorts[0];
  9579. const operator = (0, _slice.default)(order).call(order, 0, 1);
  9580. const isDescending = operator === '-';
  9581. if (isDescending) {
  9582. order = order.substring(1);
  9583. }
  9584. if (order === '_created_at') {
  9585. order = 'createdAt';
  9586. }
  9587. if (order === '_updated_at') {
  9588. order = 'updatedAt';
  9589. }
  9590. if (!/^[A-Za-z][0-9A-Za-z_]*$/.test(order) || order === 'password') {
  9591. throw new _ParseError.default(_ParseError.default.INVALID_KEY_NAME, `Invalid Key: ${order}`);
  9592. }
  9593. const field1 = a.get(order);
  9594. const field2 = b.get(order);
  9595. if (field1 < field2) {
  9596. return isDescending ? 1 : -1;
  9597. }
  9598. if (field1 > field2) {
  9599. return isDescending ? -1 : 1;
  9600. }
  9601. if (sorts.length > 1) {
  9602. const remainingSorts = (0, _slice.default)(sorts).call(sorts, 1);
  9603. return handleOfflineSort(a, b, remainingSorts);
  9604. }
  9605. return 0;
  9606. }
  9607. /**
  9608. * Creates a new parse Parse.Query for the given Parse.Object subclass.
  9609. *
  9610. * <p>Parse.Query defines a query that is used to fetch Parse.Objects. The
  9611. * most common use case is finding all objects that match a query through the
  9612. * <code>find</code> method. for example, this sample code fetches all objects
  9613. * of class <code>myclass</code>. it calls a different function depending on
  9614. * whether the fetch succeeded or not.
  9615. *
  9616. * <pre>
  9617. * var query = new Parse.Query(myclass);
  9618. * query.find().then((results) => {
  9619. * // results is an array of parse.object.
  9620. * }).catch((error) => {
  9621. * // error is an instance of parse.error.
  9622. * });</pre></p>
  9623. *
  9624. * <p>a Parse.Query can also be used to retrieve a single object whose id is
  9625. * known, through the get method. for example, this sample code fetches an
  9626. * object of class <code>myclass</code> and id <code>myid</code>. it calls a
  9627. * different function depending on whether the fetch succeeded or not.
  9628. *
  9629. * <pre>
  9630. * var query = new Parse.Query(myclass);
  9631. * query.get(myid).then((object) => {
  9632. * // object is an instance of parse.object.
  9633. * }).catch((error) => {
  9634. * // error is an instance of parse.error.
  9635. * });</pre></p>
  9636. *
  9637. * <p>a Parse.Query can also be used to count the number of objects that match
  9638. * the query without retrieving all of those objects. for example, this
  9639. * sample code counts the number of objects of the class <code>myclass</code>
  9640. * <pre>
  9641. * var query = new Parse.Query(myclass);
  9642. * query.count().then((number) => {
  9643. * // there are number instances of myclass.
  9644. * }).catch((error) => {
  9645. * // error is an instance of Parse.Error.
  9646. * });</pre></p>
  9647. *
  9648. * @alias Parse.Query
  9649. */
  9650. class ParseQuery {
  9651. /**
  9652. * @param {(string | Parse.Object)} objectClass An instance of a subclass of Parse.Object, or a Parse className string.
  9653. */
  9654. constructor(objectClass) {
  9655. /**
  9656. * @property {string} className
  9657. */
  9658. (0, _defineProperty2.default)(this, "className", void 0);
  9659. (0, _defineProperty2.default)(this, "_where", void 0);
  9660. (0, _defineProperty2.default)(this, "_watch", void 0);
  9661. (0, _defineProperty2.default)(this, "_include", void 0);
  9662. (0, _defineProperty2.default)(this, "_exclude", void 0);
  9663. (0, _defineProperty2.default)(this, "_select", void 0);
  9664. (0, _defineProperty2.default)(this, "_limit", void 0);
  9665. (0, _defineProperty2.default)(this, "_skip", void 0);
  9666. (0, _defineProperty2.default)(this, "_count", void 0);
  9667. (0, _defineProperty2.default)(this, "_order", void 0);
  9668. (0, _defineProperty2.default)(this, "_readPreference", void 0);
  9669. (0, _defineProperty2.default)(this, "_includeReadPreference", void 0);
  9670. (0, _defineProperty2.default)(this, "_subqueryReadPreference", void 0);
  9671. (0, _defineProperty2.default)(this, "_queriesLocalDatastore", void 0);
  9672. (0, _defineProperty2.default)(this, "_localDatastorePinName", void 0);
  9673. (0, _defineProperty2.default)(this, "_extraOptions", void 0);
  9674. (0, _defineProperty2.default)(this, "_hint", void 0);
  9675. (0, _defineProperty2.default)(this, "_explain", void 0);
  9676. (0, _defineProperty2.default)(this, "_xhrRequest", void 0);
  9677. (0, _defineProperty2.default)(this, "_comment", void 0);
  9678. if (typeof objectClass === 'string') {
  9679. if (objectClass === 'User' && _CoreManager.default.get('PERFORM_USER_REWRITE')) {
  9680. this.className = '_User';
  9681. } else {
  9682. this.className = objectClass;
  9683. }
  9684. } else if (objectClass instanceof _ParseObject.default) {
  9685. this.className = objectClass.className;
  9686. } else if (typeof objectClass === 'function') {
  9687. const objClass = objectClass;
  9688. if (typeof objClass.className === 'string') {
  9689. this.className = objClass.className;
  9690. } else {
  9691. const obj = new objClass();
  9692. this.className = obj.className;
  9693. }
  9694. } else {
  9695. throw new TypeError('A ParseQuery must be constructed with a ParseObject or class name.');
  9696. }
  9697. this._where = {};
  9698. this._watch = [];
  9699. this._include = [];
  9700. this._exclude = [];
  9701. this._count = false;
  9702. this._limit = -1; // negative limit is not sent in the server request
  9703. this._skip = 0;
  9704. this._readPreference = null;
  9705. this._includeReadPreference = null;
  9706. this._subqueryReadPreference = null;
  9707. this._queriesLocalDatastore = false;
  9708. this._localDatastorePinName = null;
  9709. this._extraOptions = {};
  9710. this._xhrRequest = {
  9711. task: null,
  9712. onchange: () => {}
  9713. };
  9714. this._comment = null;
  9715. }
  9716. /**
  9717. * Adds constraint that at least one of the passed in queries matches.
  9718. *
  9719. * @param {Array} queries
  9720. * @returns {Parse.Query} Returns the query, so you can chain this call.
  9721. */
  9722. _orQuery(queries) {
  9723. const queryJSON = (0, _map.default)(queries).call(queries, q => {
  9724. return q.toJSON().where;
  9725. });
  9726. this._where.$or = queryJSON;
  9727. return this;
  9728. }
  9729. /**
  9730. * Adds constraint that all of the passed in queries match.
  9731. *
  9732. * @param {Array} queries
  9733. * @returns {Parse.Query} Returns the query, so you can chain this call.
  9734. */
  9735. _andQuery(queries) {
  9736. const queryJSON = (0, _map.default)(queries).call(queries, q => {
  9737. return q.toJSON().where;
  9738. });
  9739. this._where.$and = queryJSON;
  9740. return this;
  9741. }
  9742. /**
  9743. * Adds constraint that none of the passed in queries match.
  9744. *
  9745. * @param {Array} queries
  9746. * @returns {Parse.Query} Returns the query, so you can chain this call.
  9747. */
  9748. _norQuery(queries) {
  9749. const queryJSON = (0, _map.default)(queries).call(queries, q => {
  9750. return q.toJSON().where;
  9751. });
  9752. this._where.$nor = queryJSON;
  9753. return this;
  9754. }
  9755. /**
  9756. * Helper for condition queries
  9757. *
  9758. * @param key
  9759. * @param condition
  9760. * @param value
  9761. * @returns {Parse.Query}
  9762. */
  9763. _addCondition(key, condition, value) {
  9764. if (!this._where[key] || typeof this._where[key] === 'string') {
  9765. this._where[key] = {};
  9766. }
  9767. this._where[key][condition] = (0, _encode.default)(value, false, true);
  9768. return this;
  9769. }
  9770. /**
  9771. * Converts string for regular expression at the beginning
  9772. *
  9773. * @param string
  9774. * @returns {string}
  9775. */
  9776. _regexStartWith(string) {
  9777. return '^' + quote(string);
  9778. }
  9779. async _handleOfflineQuery(params) {
  9780. var _context;
  9781. _OfflineQuery.default.validateQuery(this);
  9782. const localDatastore = _CoreManager.default.getLocalDatastore();
  9783. const objects = await localDatastore._serializeObjectsFromPinName(this._localDatastorePinName);
  9784. let results = (0, _filter.default)(_context = (0, _map.default)(objects).call(objects, (json, index, arr) => {
  9785. const object = _ParseObject.default.fromJSON(json, false);
  9786. if (json._localId && !json.objectId) {
  9787. object._localId = json._localId;
  9788. }
  9789. if (!_OfflineQuery.default.matchesQuery(this.className, object, arr, this)) {
  9790. return null;
  9791. }
  9792. return object;
  9793. })).call(_context, object => object !== null);
  9794. if ((0, _keys2.default)(params)) {
  9795. let keys = (0, _keys2.default)(params).split(',');
  9796. keys = (0, _concat.default)(keys).call(keys, ['className', 'objectId', 'createdAt', 'updatedAt', 'ACL']);
  9797. results = (0, _map.default)(results).call(results, object => {
  9798. var _context2;
  9799. const json = object._toFullJSON();
  9800. (0, _forEach.default)(_context2 = (0, _keys.default)(json)).call(_context2, key => {
  9801. if (!(0, _includes.default)(keys).call(keys, key)) {
  9802. delete json[key];
  9803. }
  9804. });
  9805. return _ParseObject.default.fromJSON(json, false);
  9806. });
  9807. }
  9808. if (params.order) {
  9809. const sorts = params.order.split(',');
  9810. (0, _sort.default)(results).call(results, (a, b) => {
  9811. return handleOfflineSort(a, b, sorts);
  9812. });
  9813. }
  9814. let count; // count total before applying limit/skip
  9815. if (params.count) {
  9816. count = results.length; // total count from response
  9817. }
  9818. if (params.skip) {
  9819. if (params.skip >= results.length) {
  9820. results = [];
  9821. } else {
  9822. results = (0, _splice.default)(results).call(results, params.skip, results.length);
  9823. }
  9824. }
  9825. let limit = results.length;
  9826. if (params.limit !== 0 && params.limit < results.length) {
  9827. limit = params.limit;
  9828. }
  9829. results = (0, _splice.default)(results).call(results, 0, limit);
  9830. if (typeof count === 'number') {
  9831. return {
  9832. results,
  9833. count
  9834. };
  9835. }
  9836. return results;
  9837. }
  9838. /**
  9839. * Returns a JSON representation of this query.
  9840. *
  9841. * @returns {object} The JSON representation of the query.
  9842. */
  9843. toJSON() {
  9844. const params = {
  9845. where: this._where
  9846. };
  9847. if (this._watch.length) {
  9848. params.watch = this._watch.join(',');
  9849. }
  9850. if (this._include.length) {
  9851. params.include = this._include.join(',');
  9852. }
  9853. if (this._exclude.length) {
  9854. params.excludeKeys = this._exclude.join(',');
  9855. }
  9856. if (this._select) {
  9857. params.keys = this._select.join(',');
  9858. }
  9859. if (this._count) {
  9860. params.count = 1;
  9861. }
  9862. if (this._limit >= 0) {
  9863. params.limit = this._limit;
  9864. }
  9865. if (this._skip > 0) {
  9866. params.skip = this._skip;
  9867. }
  9868. if (this._order) {
  9869. params.order = this._order.join(',');
  9870. }
  9871. if (this._readPreference) {
  9872. params.readPreference = this._readPreference;
  9873. }
  9874. if (this._includeReadPreference) {
  9875. params.includeReadPreference = this._includeReadPreference;
  9876. }
  9877. if (this._subqueryReadPreference) {
  9878. params.subqueryReadPreference = this._subqueryReadPreference;
  9879. }
  9880. if (this._hint) {
  9881. params.hint = this._hint;
  9882. }
  9883. if (this._explain) {
  9884. params.explain = true;
  9885. }
  9886. if (this._comment) {
  9887. params.comment = this._comment;
  9888. }
  9889. for (const key in this._extraOptions) {
  9890. params[key] = this._extraOptions[key];
  9891. }
  9892. return params;
  9893. }
  9894. /**
  9895. * Return a query with conditions from json, can be useful to send query from server side to client
  9896. * Not static, all query conditions was set before calling this method will be deleted.
  9897. * For example on the server side we have
  9898. * var query = new Parse.Query("className");
  9899. * query.equalTo(key: value);
  9900. * query.limit(100);
  9901. * ... (others queries)
  9902. * Create JSON representation of Query Object
  9903. * var jsonFromServer = query.fromJSON();
  9904. *
  9905. * On client side getting query:
  9906. * var query = new Parse.Query("className");
  9907. * query.fromJSON(jsonFromServer);
  9908. *
  9909. * and continue to query...
  9910. * query.skip(100).find().then(...);
  9911. *
  9912. * @param {QueryJSON} json from Parse.Query.toJSON() method
  9913. * @returns {Parse.Query} Returns the query, so you can chain this call.
  9914. */
  9915. withJSON(json) {
  9916. if (json.where) {
  9917. this._where = json.where;
  9918. }
  9919. if (json.watch) {
  9920. this._watch = json.watch.split(',');
  9921. }
  9922. if (json.include) {
  9923. this._include = json.include.split(',');
  9924. }
  9925. if ((0, _keys2.default)(json)) {
  9926. this._select = (0, _keys2.default)(json).split(',');
  9927. }
  9928. if (json.excludeKeys) {
  9929. this._exclude = json.excludeKeys.split(',');
  9930. }
  9931. if (json.count) {
  9932. this._count = json.count === 1;
  9933. }
  9934. if (json.limit) {
  9935. this._limit = json.limit;
  9936. }
  9937. if (json.skip) {
  9938. this._skip = json.skip;
  9939. }
  9940. if (json.order) {
  9941. this._order = json.order.split(',');
  9942. }
  9943. if (json.readPreference) {
  9944. this._readPreference = json.readPreference;
  9945. }
  9946. if (json.includeReadPreference) {
  9947. this._includeReadPreference = json.includeReadPreference;
  9948. }
  9949. if (json.subqueryReadPreference) {
  9950. this._subqueryReadPreference = json.subqueryReadPreference;
  9951. }
  9952. if (json.hint) {
  9953. this._hint = json.hint;
  9954. }
  9955. if (json.explain) {
  9956. this._explain = !!json.explain;
  9957. }
  9958. if (json.comment) {
  9959. this._comment = json.comment;
  9960. }
  9961. for (const key in json) {
  9962. if (json.hasOwnProperty(key)) {
  9963. var _context3;
  9964. if ((0, _indexOf.default)(_context3 = ['where', 'include', 'keys', 'count', 'limit', 'skip', 'order', 'readPreference', 'includeReadPreference', 'subqueryReadPreference', 'hint', 'explain', 'comment']).call(_context3, key) === -1) {
  9965. this._extraOptions[key] = json[key];
  9966. }
  9967. }
  9968. }
  9969. return this;
  9970. }
  9971. /**
  9972. * Static method to restore Parse.Query by json representation
  9973. * Internally calling Parse.Query.withJSON
  9974. *
  9975. * @param {string} className
  9976. * @param {QueryJSON} json from Parse.Query.toJSON() method
  9977. * @returns {Parse.Query} new created query
  9978. */
  9979. static fromJSON(className, json) {
  9980. const query = new ParseQuery(className);
  9981. return query.withJSON(json);
  9982. }
  9983. /**
  9984. * Constructs a Parse.Object whose id is already known by fetching data from
  9985. * the server. Unlike the <code>first</code> method, it never returns undefined.
  9986. *
  9987. * @param {string} objectId The id of the object to be fetched.
  9988. * @param {object} options
  9989. * Valid options are:<ul>
  9990. * <li>useMasterKey: In Cloud Code and Node only, causes the Master Key to
  9991. * be used for this request.
  9992. * <li>sessionToken: A valid session token, used for making a request on
  9993. * behalf of a specific user.
  9994. * <li>context: A dictionary that is accessible in Cloud Code `beforeFind` trigger.
  9995. * <li>json: Return raw json without converting to Parse.Object
  9996. * </ul>
  9997. * @returns {Promise} A promise that is resolved with the result when
  9998. * the query completes.
  9999. */
  10000. get(objectId, options) {
  10001. this.equalTo('objectId', objectId);
  10002. const firstOptions = {};
  10003. if (options && options.hasOwnProperty('useMasterKey')) {
  10004. firstOptions.useMasterKey = options.useMasterKey;
  10005. }
  10006. if (options && options.hasOwnProperty('sessionToken')) {
  10007. firstOptions.sessionToken = options.sessionToken;
  10008. }
  10009. if (options && options.hasOwnProperty('context') && typeof options.context === 'object') {
  10010. firstOptions.context = options.context;
  10011. }
  10012. if (options && options.hasOwnProperty('json')) {
  10013. firstOptions.json = options.json;
  10014. }
  10015. return this.first(firstOptions).then(response => {
  10016. if (response) {
  10017. return response;
  10018. }
  10019. const errorObject = new _ParseError.default(_ParseError.default.OBJECT_NOT_FOUND, 'Object not found.');
  10020. return _promise.default.reject(errorObject);
  10021. });
  10022. }
  10023. /**
  10024. * Retrieves a list of ParseObjects that satisfy this query.
  10025. *
  10026. * @param {object} options Valid options
  10027. * are:<ul>
  10028. * <li>useMasterKey: In Cloud Code and Node only, causes the Master Key to
  10029. * be used for this request.
  10030. * <li>sessionToken: A valid session token, used for making a request on
  10031. * behalf of a specific user.
  10032. * <li>context: A dictionary that is accessible in Cloud Code `beforeFind` trigger.
  10033. * <li>json: Return raw json without converting to Parse.Object
  10034. * </ul>
  10035. * @returns {Promise} A promise that is resolved with the results when
  10036. * the query completes.
  10037. */
  10038. find(options) {
  10039. options = options || {};
  10040. const findOptions = {};
  10041. if (options.hasOwnProperty('useMasterKey')) {
  10042. findOptions.useMasterKey = options.useMasterKey;
  10043. }
  10044. if (options.hasOwnProperty('sessionToken')) {
  10045. findOptions.sessionToken = options.sessionToken;
  10046. }
  10047. if (options.hasOwnProperty('context') && typeof options.context === 'object') {
  10048. findOptions.context = options.context;
  10049. }
  10050. this._setRequestTask(findOptions);
  10051. const controller = _CoreManager.default.getQueryController();
  10052. const select = this._select;
  10053. if (this._queriesLocalDatastore) {
  10054. return this._handleOfflineQuery(this.toJSON());
  10055. }
  10056. return (0, _find.default)(controller).call(controller, this.className, this.toJSON(), findOptions).then(response => {
  10057. // Return generic object when explain is used
  10058. if (this._explain) {
  10059. return response.results;
  10060. }
  10061. const results = response.results?.map(data => {
  10062. // In cases of relations, the server may send back a className
  10063. // on the top level of the payload
  10064. const override = response.className || this.className;
  10065. if (!data.className) {
  10066. data.className = override;
  10067. }
  10068. // Make sure the data object contains keys for all objects that
  10069. // have been requested with a select, so that our cached state
  10070. // updates correctly.
  10071. if (select) {
  10072. handleSelectResult(data, select);
  10073. }
  10074. if (options.json) {
  10075. return data;
  10076. } else {
  10077. return _ParseObject.default.fromJSON(data, !select);
  10078. }
  10079. });
  10080. const count = response.count;
  10081. if (typeof count === 'number') {
  10082. return {
  10083. results,
  10084. count
  10085. };
  10086. } else {
  10087. return results;
  10088. }
  10089. });
  10090. }
  10091. /**
  10092. * Retrieves a complete list of ParseObjects that satisfy this query.
  10093. * Using `eachBatch` under the hood to fetch all the valid objects.
  10094. *
  10095. * @param {object} options Valid options are:<ul>
  10096. * <li>batchSize: How many objects to yield in each batch (default: 100)
  10097. * <li>useMasterKey: In Cloud Code and Node only, causes the Master Key to
  10098. * be used for this request.
  10099. * <li>sessionToken: A valid session token, used for making a request on
  10100. * behalf of a specific user.
  10101. * </ul>
  10102. * @returns {Promise} A promise that is resolved with the results when
  10103. * the query completes.
  10104. */
  10105. async findAll(options) {
  10106. let result = [];
  10107. await this.eachBatch(objects => {
  10108. result = [...result, ...objects];
  10109. }, options);
  10110. return result;
  10111. }
  10112. /**
  10113. * Counts the number of objects that match this query.
  10114. *
  10115. * @param {object} options
  10116. * @param {boolean} [options.useMasterKey]
  10117. * @param {string} [options.sessionToken]
  10118. * Valid options are:<ul>
  10119. * <li>useMasterKey: In Cloud Code and Node only, causes the Master Key to
  10120. * be used for this request.
  10121. * <li>sessionToken: A valid session token, used for making a request on
  10122. * behalf of a specific user.
  10123. * </ul>
  10124. * @returns {Promise} A promise that is resolved with the count when
  10125. * the query completes.
  10126. */
  10127. count(options) {
  10128. options = options || {};
  10129. const findOptions = {};
  10130. if (options.hasOwnProperty('useMasterKey')) {
  10131. findOptions.useMasterKey = options.useMasterKey;
  10132. }
  10133. if (options.hasOwnProperty('sessionToken')) {
  10134. findOptions.sessionToken = options.sessionToken;
  10135. }
  10136. this._setRequestTask(findOptions);
  10137. const controller = _CoreManager.default.getQueryController();
  10138. const params = this.toJSON();
  10139. params.limit = 0;
  10140. params.count = 1;
  10141. return (0, _find.default)(controller).call(controller, this.className, params, findOptions).then(result => {
  10142. return result.count;
  10143. });
  10144. }
  10145. /**
  10146. * Executes a distinct query and returns unique values
  10147. *
  10148. * @param {string} key A field to find distinct values
  10149. * @param {object} options
  10150. * @param {string} [options.sessionToken] A valid session token, used for making a request on behalf of a specific user.
  10151. * @returns {Promise} A promise that is resolved with the query completes.
  10152. */
  10153. distinct(key, options) {
  10154. options = options || {};
  10155. const distinctOptions = {
  10156. useMasterKey: true
  10157. };
  10158. if (options.hasOwnProperty('sessionToken')) {
  10159. distinctOptions.sessionToken = options.sessionToken;
  10160. }
  10161. this._setRequestTask(distinctOptions);
  10162. const controller = _CoreManager.default.getQueryController();
  10163. const params = {
  10164. distinct: key,
  10165. where: this._where,
  10166. hint: this._hint
  10167. };
  10168. return controller.aggregate(this.className, params, distinctOptions).then(results => {
  10169. return results.results;
  10170. });
  10171. }
  10172. /**
  10173. * Executes an aggregate query and returns aggregate results
  10174. *
  10175. * @param {(Array|object)} pipeline Array or Object of stages to process query
  10176. * @param {object} options
  10177. * @param {string} [options.sessionToken] A valid session token, used for making a request on behalf of a specific user.
  10178. * @returns {Promise} A promise that is resolved with the query completes.
  10179. */
  10180. aggregate(pipeline, options) {
  10181. options = options || {};
  10182. const aggregateOptions = {
  10183. useMasterKey: true
  10184. };
  10185. if (options.hasOwnProperty('sessionToken')) {
  10186. aggregateOptions.sessionToken = options.sessionToken;
  10187. }
  10188. this._setRequestTask(aggregateOptions);
  10189. const controller = _CoreManager.default.getQueryController();
  10190. if (!(0, _isArray.default)(pipeline) && typeof pipeline !== 'object') {
  10191. throw new Error('Invalid pipeline must be Array or Object');
  10192. }
  10193. if ((0, _keys.default)(this._where || {}).length) {
  10194. if (!(0, _isArray.default)(pipeline)) {
  10195. pipeline = [pipeline];
  10196. }
  10197. pipeline.unshift({
  10198. $match: this._where
  10199. });
  10200. }
  10201. const params = {
  10202. pipeline,
  10203. hint: this._hint,
  10204. explain: this._explain,
  10205. readPreference: this._readPreference
  10206. };
  10207. return controller.aggregate(this.className, params, aggregateOptions).then(results => {
  10208. return results.results;
  10209. });
  10210. }
  10211. /**
  10212. * Retrieves at most one Parse.Object that satisfies this query.
  10213. *
  10214. * Returns the object if there is one, otherwise undefined.
  10215. *
  10216. * @param {object} options Valid options are:<ul>
  10217. * <li>useMasterKey: In Cloud Code and Node only, causes the Master Key to
  10218. * be used for this request.
  10219. * <li>sessionToken: A valid session token, used for making a request on
  10220. * behalf of a specific user.
  10221. * <li>context: A dictionary that is accessible in Cloud Code `beforeFind` trigger.
  10222. * <li>json: Return raw json without converting to Parse.Object
  10223. * </ul>
  10224. * @returns {Promise} A promise that is resolved with the object when
  10225. * the query completes.
  10226. */
  10227. first() {
  10228. let options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
  10229. const findOptions = {};
  10230. if (options.hasOwnProperty('useMasterKey')) {
  10231. findOptions.useMasterKey = options.useMasterKey;
  10232. }
  10233. if (options.hasOwnProperty('sessionToken')) {
  10234. findOptions.sessionToken = options.sessionToken;
  10235. }
  10236. if (options.hasOwnProperty('context') && typeof options.context === 'object') {
  10237. findOptions.context = options.context;
  10238. }
  10239. this._setRequestTask(findOptions);
  10240. const controller = _CoreManager.default.getQueryController();
  10241. const params = this.toJSON();
  10242. params.limit = 1;
  10243. const select = this._select;
  10244. if (this._queriesLocalDatastore) {
  10245. return this._handleOfflineQuery(params).then(objects => {
  10246. if (!objects[0]) {
  10247. return undefined;
  10248. }
  10249. return objects[0];
  10250. });
  10251. }
  10252. return (0, _find.default)(controller).call(controller, this.className, params, findOptions).then(response => {
  10253. const objects = response.results;
  10254. if (!objects[0]) {
  10255. return undefined;
  10256. }
  10257. if (!objects[0].className) {
  10258. objects[0].className = this.className;
  10259. }
  10260. // Make sure the data object contains keys for all objects that
  10261. // have been requested with a select, so that our cached state
  10262. // updates correctly.
  10263. if (select) {
  10264. handleSelectResult(objects[0], select);
  10265. }
  10266. if (options.json) {
  10267. return objects[0];
  10268. } else {
  10269. return _ParseObject.default.fromJSON(objects[0], !select);
  10270. }
  10271. });
  10272. }
  10273. /**
  10274. * Iterates over objects matching a query, calling a callback for each batch.
  10275. * If the callback returns a promise, the iteration will not continue until
  10276. * that promise has been fulfilled. If the callback returns a rejected
  10277. * promise, then iteration will stop with that error. The items are processed
  10278. * in an unspecified order. The query may not have any sort order, and may
  10279. * not use limit or skip.
  10280. *
  10281. * @param {Function} callback Callback that will be called with each result
  10282. * of the query.
  10283. * @param {object} options Valid options are:<ul>
  10284. * <li>batchSize: How many objects to yield in each batch (default: 100)
  10285. * <li>useMasterKey: In Cloud Code and Node only, causes the Master Key to
  10286. * be used for this request.
  10287. * <li>sessionToken: A valid session token, used for making a request on
  10288. * behalf of a specific user.
  10289. * <li>context: A dictionary that is accessible in Cloud Code `beforeFind` trigger.
  10290. * </ul>
  10291. * @returns {Promise} A promise that will be fulfilled once the
  10292. * iteration has completed.
  10293. */
  10294. eachBatch(callback, options) {
  10295. options = options || {};
  10296. if (this._order || this._skip || this._limit >= 0) {
  10297. return _promise.default.reject('Cannot iterate on a query with sort, skip, or limit.');
  10298. }
  10299. const query = new ParseQuery(this.className);
  10300. query._limit = options.batchSize || 100;
  10301. query._include = [...this._include];
  10302. query._exclude = [...this._exclude];
  10303. if (this._select) {
  10304. query._select = [...this._select];
  10305. }
  10306. query._hint = this._hint;
  10307. query._where = {};
  10308. for (const attr in this._where) {
  10309. const val = this._where[attr];
  10310. if ((0, _isArray.default)(val)) {
  10311. query._where[attr] = (0, _map.default)(val).call(val, v => {
  10312. return v;
  10313. });
  10314. } else if (val && typeof val === 'object') {
  10315. const conditionMap = {};
  10316. query._where[attr] = conditionMap;
  10317. for (const cond in val) {
  10318. conditionMap[cond] = val[cond];
  10319. }
  10320. } else {
  10321. query._where[attr] = val;
  10322. }
  10323. }
  10324. query.ascending('objectId');
  10325. const findOptions = {};
  10326. if (options.hasOwnProperty('useMasterKey')) {
  10327. findOptions.useMasterKey = options.useMasterKey;
  10328. }
  10329. if (options.hasOwnProperty('sessionToken')) {
  10330. findOptions.sessionToken = options.sessionToken;
  10331. }
  10332. if (options.hasOwnProperty('context') && typeof options.context === 'object') {
  10333. findOptions.context = options.context;
  10334. }
  10335. if (options.hasOwnProperty('json')) {
  10336. findOptions.json = options.json;
  10337. }
  10338. let finished = false;
  10339. let previousResults = [];
  10340. return (0, _promiseUtils.continueWhile)(() => {
  10341. return !finished;
  10342. }, async () => {
  10343. const [results] = await _promise.default.all([(0, _find.default)(query).call(query, findOptions), _promise.default.resolve(previousResults.length > 0 && callback(previousResults))]);
  10344. if (results.length >= query._limit) {
  10345. query.greaterThan('objectId', results[results.length - 1].id);
  10346. previousResults = results;
  10347. } else if (results.length > 0) {
  10348. await _promise.default.resolve(callback(results));
  10349. finished = true;
  10350. } else {
  10351. finished = true;
  10352. }
  10353. });
  10354. }
  10355. /**
  10356. * Iterates over each result of a query, calling a callback for each one. If
  10357. * the callback returns a promise, the iteration will not continue until
  10358. * that promise has been fulfilled. If the callback returns a rejected
  10359. * promise, then iteration will stop with that error. The items are
  10360. * processed in an unspecified order. The query may not have any sort order,
  10361. * and may not use limit or skip.
  10362. *
  10363. * @param {Function} callback Callback that will be called with each result
  10364. * of the query.
  10365. * @param {object} options Valid options are:<ul>
  10366. * <li>useMasterKey: In Cloud Code and Node only, causes the Master Key to
  10367. * be used for this request.
  10368. * <li>sessionToken: A valid session token, used for making a request on
  10369. * behalf of a specific user.
  10370. * <li>json: Return raw json without converting to Parse.Object
  10371. * </ul>
  10372. * @returns {Promise} A promise that will be fulfilled once the
  10373. * iteration has completed.
  10374. */
  10375. each(callback, options) {
  10376. return this.eachBatch(results => {
  10377. let callbacksDone = _promise.default.resolve();
  10378. (0, _forEach.default)(results).call(results, result => {
  10379. callbacksDone = callbacksDone.then(() => {
  10380. return callback(result);
  10381. });
  10382. });
  10383. return callbacksDone;
  10384. }, options);
  10385. }
  10386. /**
  10387. * Adds a hint to force index selection. (https://docs.mongodb.com/manual/reference/operator/meta/hint/)
  10388. *
  10389. * @param {(string|object)} value String or Object of index that should be used when executing query
  10390. * @returns {Parse.Query} Returns the query, so you can chain this call.
  10391. */
  10392. hint(value) {
  10393. if (typeof value === 'undefined') {
  10394. delete this._hint;
  10395. }
  10396. this._hint = value;
  10397. return this;
  10398. }
  10399. /**
  10400. * Investigates the query execution plan. Useful for optimizing queries. (https://docs.mongodb.com/manual/reference/operator/meta/explain/)
  10401. *
  10402. * @param {boolean} explain Used to toggle the information on the query plan.
  10403. * @returns {Parse.Query} Returns the query, so you can chain this call.
  10404. */
  10405. explain() {
  10406. let explain = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : true;
  10407. if (typeof explain !== 'boolean') {
  10408. throw new Error('You can only set explain to a boolean value');
  10409. }
  10410. this._explain = explain;
  10411. return this;
  10412. }
  10413. /**
  10414. * Iterates over each result of a query, calling a callback for each one. If
  10415. * the callback returns a promise, the iteration will not continue until
  10416. * that promise has been fulfilled. If the callback returns a rejected
  10417. * promise, then iteration will stop with that error. The items are
  10418. * processed in an unspecified order. The query may not have any sort order,
  10419. * and may not use limit or skip.
  10420. *
  10421. * @param {Function} callback Callback <ul>
  10422. * <li>currentObject: The current Parse.Object being processed in the array.</li>
  10423. * <li>index: The index of the current Parse.Object being processed in the array.</li>
  10424. * <li>query: The query map was called upon.</li>
  10425. * </ul>
  10426. * @param {object} options Valid options are:<ul>
  10427. * <li>useMasterKey: In Cloud Code and Node only, causes the Master Key to
  10428. * be used for this request.
  10429. * <li>sessionToken: A valid session token, used for making a request on
  10430. * behalf of a specific user.
  10431. * </ul>
  10432. * @returns {Promise} A promise that will be fulfilled once the
  10433. * iteration has completed.
  10434. */
  10435. async map(callback, options) {
  10436. const array = [];
  10437. let index = 0;
  10438. await this.each(object => {
  10439. return _promise.default.resolve(callback(object, index, this)).then(result => {
  10440. array.push(result);
  10441. index += 1;
  10442. });
  10443. }, options);
  10444. return array;
  10445. }
  10446. /**
  10447. * Iterates over each result of a query, calling a callback for each one. If
  10448. * the callback returns a promise, the iteration will not continue until
  10449. * that promise has been fulfilled. If the callback returns a rejected
  10450. * promise, then iteration will stop with that error. The items are
  10451. * processed in an unspecified order. The query may not have any sort order,
  10452. * and may not use limit or skip.
  10453. *
  10454. * @param {Function} callback Callback <ul>
  10455. * <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>
  10456. * <li>currentObject: The current Parse.Object being processed in the array.</li>
  10457. * <li>index: The index of the current Parse.Object being processed in the array.</li>
  10458. * </ul>
  10459. * @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.
  10460. * @param {object} options Valid options are:<ul>
  10461. * <li>useMasterKey: In Cloud Code and Node only, causes the Master Key to
  10462. * be used for this request.
  10463. * <li>sessionToken: A valid session token, used for making a request on
  10464. * behalf of a specific user.
  10465. * </ul>
  10466. * @returns {Promise} A promise that will be fulfilled once the
  10467. * iteration has completed.
  10468. */
  10469. async reduce(callback, initialValue, options) {
  10470. let accumulator = initialValue;
  10471. let index = 0;
  10472. await this.each(object => {
  10473. // If no initial value was given, we take the first object from the query
  10474. // as the initial value and don't call the callback with it.
  10475. if (index === 0 && initialValue === undefined) {
  10476. accumulator = object;
  10477. index += 1;
  10478. return;
  10479. }
  10480. return _promise.default.resolve(callback(accumulator, object, index)).then(result => {
  10481. accumulator = result;
  10482. index += 1;
  10483. });
  10484. }, options);
  10485. if (index === 0 && initialValue === undefined) {
  10486. // Match Array.reduce behavior: "Calling reduce() on an empty array
  10487. // without an initialValue will throw a TypeError".
  10488. throw new TypeError('Reducing empty query result set with no initial value');
  10489. }
  10490. return accumulator;
  10491. }
  10492. /**
  10493. * Iterates over each result of a query, calling a callback for each one. If
  10494. * the callback returns a promise, the iteration will not continue until
  10495. * that promise has been fulfilled. If the callback returns a rejected
  10496. * promise, then iteration will stop with that error. The items are
  10497. * processed in an unspecified order. The query may not have any sort order,
  10498. * and may not use limit or skip.
  10499. *
  10500. * @param {Function} callback Callback <ul>
  10501. * <li>currentObject: The current Parse.Object being processed in the array.</li>
  10502. * <li>index: The index of the current Parse.Object being processed in the array.</li>
  10503. * <li>query: The query filter was called upon.</li>
  10504. * </ul>
  10505. * @param {object} options Valid options are:<ul>
  10506. * <li>useMasterKey: In Cloud Code and Node only, causes the Master Key to
  10507. * be used for this request.
  10508. * <li>sessionToken: A valid session token, used for making a request on
  10509. * behalf of a specific user.
  10510. * </ul>
  10511. * @returns {Promise} A promise that will be fulfilled once the
  10512. * iteration has completed.
  10513. */
  10514. async filter(callback, options) {
  10515. const array = [];
  10516. let index = 0;
  10517. await this.each(object => {
  10518. return _promise.default.resolve(callback(object, index, this)).then(flag => {
  10519. if (flag) {
  10520. array.push(object);
  10521. }
  10522. index += 1;
  10523. });
  10524. }, options);
  10525. return array;
  10526. }
  10527. /* Query Conditions */
  10528. /**
  10529. * Adds a constraint to the query that requires a particular key's value to
  10530. * be equal to the provided value.
  10531. *
  10532. * @param {string} key The key to check.
  10533. * @param value The value that the Parse.Object must contain.
  10534. * @returns {Parse.Query} Returns the query, so you can chain this call.
  10535. */
  10536. equalTo(key, value) {
  10537. if (key && typeof key === 'object') {
  10538. var _context4;
  10539. (0, _forEach.default)(_context4 = (0, _entries.default)(key)).call(_context4, _ref => {
  10540. let [k, val] = _ref;
  10541. return this.equalTo(k, val);
  10542. });
  10543. return this;
  10544. }
  10545. if (typeof value === 'undefined') {
  10546. return this.doesNotExist(key);
  10547. }
  10548. this._where[key] = (0, _encode.default)(value, false, true);
  10549. return this;
  10550. }
  10551. /**
  10552. * Adds a constraint to the query that requires a particular key's value to
  10553. * be not equal to the provided value.
  10554. *
  10555. * @param {string} key The key to check.
  10556. * @param value The value that must not be equalled.
  10557. * @returns {Parse.Query} Returns the query, so you can chain this call.
  10558. */
  10559. notEqualTo(key, value) {
  10560. if (key && typeof key === 'object') {
  10561. var _context5;
  10562. (0, _forEach.default)(_context5 = (0, _entries.default)(key)).call(_context5, _ref2 => {
  10563. let [k, val] = _ref2;
  10564. return this.notEqualTo(k, val);
  10565. });
  10566. return this;
  10567. }
  10568. return this._addCondition(key, '$ne', value);
  10569. }
  10570. /**
  10571. * Adds a constraint to the query that requires a particular key's value to
  10572. * be less than the provided value.
  10573. *
  10574. * @param {string} key The key to check.
  10575. * @param value The value that provides an upper bound.
  10576. * @returns {Parse.Query} Returns the query, so you can chain this call.
  10577. */
  10578. lessThan(key, value) {
  10579. return this._addCondition(key, '$lt', value);
  10580. }
  10581. /**
  10582. * Adds a constraint to the query that requires a particular key's value to
  10583. * be greater than the provided value.
  10584. *
  10585. * @param {string} key The key to check.
  10586. * @param value The value that provides an lower bound.
  10587. * @returns {Parse.Query} Returns the query, so you can chain this call.
  10588. */
  10589. greaterThan(key, value) {
  10590. return this._addCondition(key, '$gt', value);
  10591. }
  10592. /**
  10593. * Adds a constraint to the query that requires a particular key's value to
  10594. * be less than or equal to the provided value.
  10595. *
  10596. * @param {string} key The key to check.
  10597. * @param value The value that provides an upper bound.
  10598. * @returns {Parse.Query} Returns the query, so you can chain this call.
  10599. */
  10600. lessThanOrEqualTo(key, value) {
  10601. return this._addCondition(key, '$lte', value);
  10602. }
  10603. /**
  10604. * Adds a constraint to the query that requires a particular key's value to
  10605. * be greater than or equal to the provided value.
  10606. *
  10607. * @param {string} key The key to check.
  10608. * @param {*} value The value that provides an lower bound.
  10609. * @returns {Parse.Query} Returns the query, so you can chain this call.
  10610. */
  10611. greaterThanOrEqualTo(key, value) {
  10612. return this._addCondition(key, '$gte', value);
  10613. }
  10614. /**
  10615. * Adds a constraint to the query that requires a particular key's value to
  10616. * be contained in the provided list of values.
  10617. *
  10618. * @param {string} key The key to check.
  10619. * @param {Array<*>} value The values that will match.
  10620. * @returns {Parse.Query} Returns the query, so you can chain this call.
  10621. */
  10622. containedIn(key, value) {
  10623. return this._addCondition(key, '$in', value);
  10624. }
  10625. /**
  10626. * Adds a constraint to the query that requires a particular key's value to
  10627. * not be contained in the provided list of values.
  10628. *
  10629. * @param {string} key The key to check.
  10630. * @param {Array<*>} value The values that will not match.
  10631. * @returns {Parse.Query} Returns the query, so you can chain this call.
  10632. */
  10633. notContainedIn(key, value) {
  10634. return this._addCondition(key, '$nin', value);
  10635. }
  10636. /**
  10637. * Adds a constraint to the query that requires a particular key's value to
  10638. * be contained by the provided list of values. Get objects where all array elements match.
  10639. *
  10640. * @param {string} key The key to check.
  10641. * @param {Array} values The values that will match.
  10642. * @returns {Parse.Query} Returns the query, so you can chain this call.
  10643. */
  10644. containedBy(key, values) {
  10645. return this._addCondition(key, '$containedBy', values);
  10646. }
  10647. /**
  10648. * Adds a constraint to the query that requires a particular key's value to
  10649. * contain each one of the provided list of values.
  10650. *
  10651. * @param {string} key The key to check. This key's value must be an array.
  10652. * @param {Array} values The values that will match.
  10653. * @returns {Parse.Query} Returns the query, so you can chain this call.
  10654. */
  10655. containsAll(key, values) {
  10656. return this._addCondition(key, '$all', values);
  10657. }
  10658. /**
  10659. * Adds a constraint to the query that requires a particular key's value to
  10660. * contain each one of the provided list of values starting with given strings.
  10661. *
  10662. * @param {string} key The key to check. This key's value must be an array.
  10663. * @param {Array<string>} values The string values that will match as starting string.
  10664. * @returns {Parse.Query} Returns the query, so you can chain this call.
  10665. */
  10666. containsAllStartingWith(key, values) {
  10667. if (!(0, _isArray.default)(values)) {
  10668. values = [values];
  10669. }
  10670. const regexObject = (0, _map.default)(values).call(values, value => {
  10671. return {
  10672. $regex: this._regexStartWith(value)
  10673. };
  10674. });
  10675. return this.containsAll(key, regexObject);
  10676. }
  10677. /**
  10678. * Adds a constraint for finding objects that contain the given key.
  10679. *
  10680. * @param {string} key The key that should exist.
  10681. * @returns {Parse.Query} Returns the query, so you can chain this call.
  10682. */
  10683. exists(key) {
  10684. return this._addCondition(key, '$exists', true);
  10685. }
  10686. /**
  10687. * Adds a constraint for finding objects that do not contain a given key.
  10688. *
  10689. * @param {string} key The key that should not exist
  10690. * @returns {Parse.Query} Returns the query, so you can chain this call.
  10691. */
  10692. doesNotExist(key) {
  10693. return this._addCondition(key, '$exists', false);
  10694. }
  10695. /**
  10696. * Adds a regular expression constraint for finding string values that match
  10697. * the provided regular expression.
  10698. * This may be slow for large datasets.
  10699. *
  10700. * @param {string} key The key that the string to match is stored in.
  10701. * @param {RegExp | string} regex The regular expression pattern to match.
  10702. * @param {string} modifiers The regular expression mode.
  10703. * @returns {Parse.Query} Returns the query, so you can chain this call.
  10704. */
  10705. matches(key, regex, modifiers) {
  10706. this._addCondition(key, '$regex', regex);
  10707. if (!modifiers) {
  10708. modifiers = '';
  10709. }
  10710. if (typeof regex !== 'string') {
  10711. if (regex.ignoreCase) {
  10712. modifiers += 'i';
  10713. }
  10714. if (regex.multiline) {
  10715. modifiers += 'm';
  10716. }
  10717. }
  10718. if (modifiers.length) {
  10719. this._addCondition(key, '$options', modifiers);
  10720. }
  10721. return this;
  10722. }
  10723. /**
  10724. * Adds a constraint that requires that a key's value matches a Parse.Query
  10725. * constraint.
  10726. *
  10727. * @param {string} key The key that the contains the object to match the
  10728. * query.
  10729. * @param {Parse.Query} query The query that should match.
  10730. * @returns {Parse.Query} Returns the query, so you can chain this call.
  10731. */
  10732. matchesQuery(key, query) {
  10733. const queryJSON = query.toJSON();
  10734. queryJSON.className = query.className;
  10735. return this._addCondition(key, '$inQuery', queryJSON);
  10736. }
  10737. /**
  10738. * Adds a constraint that requires that a key's value not matches a
  10739. * Parse.Query constraint.
  10740. *
  10741. * @param {string} key The key that the contains the object to match the
  10742. * query.
  10743. * @param {Parse.Query} query The query that should not match.
  10744. * @returns {Parse.Query} Returns the query, so you can chain this call.
  10745. */
  10746. doesNotMatchQuery(key, query) {
  10747. const queryJSON = query.toJSON();
  10748. queryJSON.className = query.className;
  10749. return this._addCondition(key, '$notInQuery', queryJSON);
  10750. }
  10751. /**
  10752. * Adds a constraint that requires that a key's value matches a value in
  10753. * an object returned by a different Parse.Query.
  10754. *
  10755. * @param {string} key The key that contains the value that is being
  10756. * matched.
  10757. * @param {string} queryKey The key in the objects returned by the query to
  10758. * match against.
  10759. * @param {Parse.Query} query The query to run.
  10760. * @returns {Parse.Query} Returns the query, so you can chain this call.
  10761. */
  10762. matchesKeyInQuery(key, queryKey, query) {
  10763. const queryJSON = query.toJSON();
  10764. queryJSON.className = query.className;
  10765. return this._addCondition(key, '$select', {
  10766. key: queryKey,
  10767. query: queryJSON
  10768. });
  10769. }
  10770. /**
  10771. * Adds a constraint that requires that a key's value not match a value in
  10772. * an object returned by a different Parse.Query.
  10773. *
  10774. * @param {string} key The key that contains the value that is being
  10775. * excluded.
  10776. * @param {string} queryKey The key in the objects returned by the query to
  10777. * match against.
  10778. * @param {Parse.Query} query The query to run.
  10779. * @returns {Parse.Query} Returns the query, so you can chain this call.
  10780. */
  10781. doesNotMatchKeyInQuery(key, queryKey, query) {
  10782. const queryJSON = query.toJSON();
  10783. queryJSON.className = query.className;
  10784. return this._addCondition(key, '$dontSelect', {
  10785. key: queryKey,
  10786. query: queryJSON
  10787. });
  10788. }
  10789. /**
  10790. * Adds a constraint for finding string values that contain a provided
  10791. * string. This may be slow for large datasets.
  10792. *
  10793. * @param {string} key The key that the string to match is stored in.
  10794. * @param {string} substring The substring that the value must contain.
  10795. * @returns {Parse.Query} Returns the query, so you can chain this call.
  10796. */
  10797. contains(key, substring) {
  10798. if (typeof substring !== 'string') {
  10799. throw new Error('The value being searched for must be a string.');
  10800. }
  10801. return this._addCondition(key, '$regex', quote(substring));
  10802. }
  10803. /**
  10804. * Adds a constraint for finding string values that contain a provided
  10805. * string. This may be slow for large datasets. Requires Parse-Server > 2.5.0
  10806. *
  10807. * In order to sort you must use select and ascending ($score is required)
  10808. * <pre>
  10809. * query.fullText('field', 'term');
  10810. * query.ascending('$score');
  10811. * query.select('$score');
  10812. * </pre>
  10813. *
  10814. * To retrieve the weight / rank
  10815. * <pre>
  10816. * object->get('score');
  10817. * </pre>
  10818. *
  10819. * You can define optionals by providing an object as a third parameter
  10820. * <pre>
  10821. * query.fullText('field', 'term', { language: 'es', diacriticSensitive: true });
  10822. * </pre>
  10823. *
  10824. * @param {string} key The key that the string to match is stored in.
  10825. * @param {string} value The string to search
  10826. * @param {object} options (Optional)
  10827. * @param {string} options.language The language that determines the list of stop words for the search and the rules for the stemmer and tokenizer.
  10828. * @param {boolean} options.caseSensitive A boolean flag to enable or disable case sensitive search.
  10829. * @param {boolean} options.diacriticSensitive A boolean flag to enable or disable diacritic sensitive search.
  10830. * @returns {Parse.Query} Returns the query, so you can chain this call.
  10831. */
  10832. fullText(key, value) {
  10833. let options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
  10834. options = options || {};
  10835. if (!key) {
  10836. throw new Error('A key is required.');
  10837. }
  10838. if (!value) {
  10839. throw new Error('A search term is required');
  10840. }
  10841. if (typeof value !== 'string') {
  10842. throw new Error('The value being searched for must be a string.');
  10843. }
  10844. const fullOptions = {};
  10845. fullOptions.$term = value;
  10846. for (const option in options) {
  10847. switch (option) {
  10848. case 'language':
  10849. fullOptions.$language = options[option];
  10850. break;
  10851. case 'caseSensitive':
  10852. fullOptions.$caseSensitive = options[option];
  10853. break;
  10854. case 'diacriticSensitive':
  10855. fullOptions.$diacriticSensitive = options[option];
  10856. break;
  10857. default:
  10858. throw new Error(`Unknown option: ${option}`);
  10859. }
  10860. }
  10861. return this._addCondition(key, '$text', {
  10862. $search: fullOptions
  10863. });
  10864. }
  10865. /**
  10866. * Method to sort the full text search by text score
  10867. *
  10868. * @returns {Parse.Query} Returns the query, so you can chain this call.
  10869. */
  10870. sortByTextScore() {
  10871. this.ascending('$score');
  10872. this.select(['$score']);
  10873. return this;
  10874. }
  10875. /**
  10876. * Adds a constraint for finding string values that start with a provided
  10877. * string. This query will use the backend index, so it will be fast even
  10878. * for large datasets.
  10879. *
  10880. * @param {string} key The key that the string to match is stored in.
  10881. * @param {string} prefix The substring that the value must start with.
  10882. * @param {string} modifiers The regular expression mode.
  10883. * @returns {Parse.Query} Returns the query, so you can chain this call.
  10884. */
  10885. startsWith(key, prefix, modifiers) {
  10886. if (typeof prefix !== 'string') {
  10887. throw new Error('The value being searched for must be a string.');
  10888. }
  10889. return this.matches(key, this._regexStartWith(prefix), modifiers);
  10890. }
  10891. /**
  10892. * Adds a constraint for finding string values that end with a provided
  10893. * string. This will be slow for large datasets.
  10894. *
  10895. * @param {string} key The key that the string to match is stored in.
  10896. * @param {string} suffix The substring that the value must end with.
  10897. * @param {string} modifiers The regular expression mode.
  10898. * @returns {Parse.Query} Returns the query, so you can chain this call.
  10899. */
  10900. endsWith(key, suffix, modifiers) {
  10901. if (typeof suffix !== 'string') {
  10902. throw new Error('The value being searched for must be a string.');
  10903. }
  10904. return this.matches(key, quote(suffix) + '$', modifiers);
  10905. }
  10906. /**
  10907. * Adds a proximity based constraint for finding objects with key point
  10908. * values near the point given.
  10909. *
  10910. * @param {string} key The key that the Parse.GeoPoint is stored in.
  10911. * @param {Parse.GeoPoint} point The reference Parse.GeoPoint that is used.
  10912. * @returns {Parse.Query} Returns the query, so you can chain this call.
  10913. */
  10914. near(key, point) {
  10915. if (!(point instanceof _ParseGeoPoint.default)) {
  10916. // Try to cast it as a GeoPoint
  10917. point = new _ParseGeoPoint.default(point);
  10918. }
  10919. return this._addCondition(key, '$nearSphere', point);
  10920. }
  10921. /**
  10922. * Adds a proximity based constraint for finding objects with key point
  10923. * values near the point given and within the maximum distance given.
  10924. *
  10925. * @param {string} key The key that the Parse.GeoPoint is stored in.
  10926. * @param {Parse.GeoPoint} point The reference Parse.GeoPoint that is used.
  10927. * @param {number} maxDistance Maximum distance (in radians) of results to return.
  10928. * @param {boolean} sorted A Bool value that is true if results should be
  10929. * sorted by distance ascending, false is no sorting is required,
  10930. * defaults to true.
  10931. * @returns {Parse.Query} Returns the query, so you can chain this call.
  10932. */
  10933. withinRadians(key, point, maxDistance, sorted) {
  10934. if (sorted || sorted === undefined) {
  10935. this.near(key, point);
  10936. return this._addCondition(key, '$maxDistance', maxDistance);
  10937. } else {
  10938. return this._addCondition(key, '$geoWithin', {
  10939. $centerSphere: [[point.longitude, point.latitude], maxDistance]
  10940. });
  10941. }
  10942. }
  10943. /**
  10944. * Adds a proximity based constraint for finding objects with key point
  10945. * values near the point given and within the maximum distance given.
  10946. * Radius of earth used is 3958.8 miles.
  10947. *
  10948. * @param {string} key The key that the Parse.GeoPoint is stored in.
  10949. * @param {Parse.GeoPoint} point The reference Parse.GeoPoint that is used.
  10950. * @param {number} maxDistance Maximum distance (in miles) of results to return.
  10951. * @param {boolean} sorted A Bool value that is true if results should be
  10952. * sorted by distance ascending, false is no sorting is required,
  10953. * defaults to true.
  10954. * @returns {Parse.Query} Returns the query, so you can chain this call.
  10955. */
  10956. withinMiles(key, point, maxDistance, sorted) {
  10957. return this.withinRadians(key, point, maxDistance / 3958.8, sorted);
  10958. }
  10959. /**
  10960. * Adds a proximity based constraint for finding objects with key point
  10961. * values near the point given and within the maximum distance given.
  10962. * Radius of earth used is 6371.0 kilometers.
  10963. *
  10964. * @param {string} key The key that the Parse.GeoPoint is stored in.
  10965. * @param {Parse.GeoPoint} point The reference Parse.GeoPoint that is used.
  10966. * @param {number} maxDistance Maximum distance (in kilometers) of results to return.
  10967. * @param {boolean} sorted A Bool value that is true if results should be
  10968. * sorted by distance ascending, false is no sorting is required,
  10969. * defaults to true.
  10970. * @returns {Parse.Query} Returns the query, so you can chain this call.
  10971. */
  10972. withinKilometers(key, point, maxDistance, sorted) {
  10973. return this.withinRadians(key, point, maxDistance / 6371.0, sorted);
  10974. }
  10975. /**
  10976. * Adds a constraint to the query that requires a particular key's
  10977. * coordinates be contained within a given rectangular geographic bounding
  10978. * box.
  10979. *
  10980. * @param {string} key The key to be constrained.
  10981. * @param {Parse.GeoPoint} southwest
  10982. * The lower-left inclusive corner of the box.
  10983. * @param {Parse.GeoPoint} northeast
  10984. * The upper-right inclusive corner of the box.
  10985. * @returns {Parse.Query} Returns the query, so you can chain this call.
  10986. */
  10987. withinGeoBox(key, southwest, northeast) {
  10988. if (!(southwest instanceof _ParseGeoPoint.default)) {
  10989. southwest = new _ParseGeoPoint.default(southwest);
  10990. }
  10991. if (!(northeast instanceof _ParseGeoPoint.default)) {
  10992. northeast = new _ParseGeoPoint.default(northeast);
  10993. }
  10994. this._addCondition(key, '$within', {
  10995. $box: [southwest, northeast]
  10996. });
  10997. return this;
  10998. }
  10999. /**
  11000. * Adds a constraint to the query that requires a particular key's
  11001. * coordinates be contained within and on the bounds of a given polygon.
  11002. * Supports closed and open (last point is connected to first) paths
  11003. *
  11004. * Polygon must have at least 3 points
  11005. *
  11006. * @param {string} key The key to be constrained.
  11007. * @param {Array} points Array of Coordinates / GeoPoints
  11008. * @returns {Parse.Query} Returns the query, so you can chain this call.
  11009. */
  11010. withinPolygon(key, points) {
  11011. return this._addCondition(key, '$geoWithin', {
  11012. $polygon: points
  11013. });
  11014. }
  11015. /**
  11016. * Add a constraint to the query that requires a particular key's
  11017. * coordinates that contains a ParseGeoPoint
  11018. *
  11019. * @param {string} key The key to be constrained.
  11020. * @param {Parse.GeoPoint} point
  11021. * @returns {Parse.Query} Returns the query, so you can chain this call.
  11022. */
  11023. polygonContains(key, point) {
  11024. return this._addCondition(key, '$geoIntersects', {
  11025. $point: point
  11026. });
  11027. }
  11028. /* Query Orderings */
  11029. /**
  11030. * Sorts the results in ascending order by the given key.
  11031. *
  11032. * @param {(string|string[])} keys The key to order by, which is a
  11033. * string of comma separated values, or an Array of keys, or multiple keys.
  11034. * @returns {Parse.Query} Returns the query, so you can chain this call.
  11035. */
  11036. ascending() {
  11037. this._order = [];
  11038. for (var _len = arguments.length, keys = new Array(_len), _key = 0; _key < _len; _key++) {
  11039. keys[_key] = arguments[_key];
  11040. }
  11041. return this.addAscending.apply(this, keys);
  11042. }
  11043. /**
  11044. * Sorts the results in ascending order by the given key,
  11045. * but can also add secondary sort descriptors without overwriting _order.
  11046. *
  11047. * @param {(string|string[])} keys The key to order by, which is a
  11048. * string of comma separated values, or an Array of keys, or multiple keys.
  11049. * @returns {Parse.Query} Returns the query, so you can chain this call.
  11050. */
  11051. addAscending() {
  11052. if (!this._order) {
  11053. this._order = [];
  11054. }
  11055. for (var _len2 = arguments.length, keys = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
  11056. keys[_key2] = arguments[_key2];
  11057. }
  11058. (0, _forEach.default)(keys).call(keys, key => {
  11059. var _context6;
  11060. if ((0, _isArray.default)(key)) {
  11061. key = key.join();
  11062. }
  11063. this._order = (0, _concat.default)(_context6 = this._order).call(_context6, key.replace(/\s/g, '').split(','));
  11064. });
  11065. return this;
  11066. }
  11067. /**
  11068. * Sorts the results in descending order by the given key.
  11069. *
  11070. * @param {(string|string[])} keys The key to order by, which is a
  11071. * string of comma separated values, or an Array of keys, or multiple keys.
  11072. * @returns {Parse.Query} Returns the query, so you can chain this call.
  11073. */
  11074. descending() {
  11075. this._order = [];
  11076. for (var _len3 = arguments.length, keys = new Array(_len3), _key3 = 0; _key3 < _len3; _key3++) {
  11077. keys[_key3] = arguments[_key3];
  11078. }
  11079. return this.addDescending.apply(this, keys);
  11080. }
  11081. /**
  11082. * Sorts the results in descending order by the given key,
  11083. * but can also add secondary sort descriptors without overwriting _order.
  11084. *
  11085. * @param {(string|string[])} keys The key to order by, which is a
  11086. * string of comma separated values, or an Array of keys, or multiple keys.
  11087. * @returns {Parse.Query} Returns the query, so you can chain this call.
  11088. */
  11089. addDescending() {
  11090. if (!this._order) {
  11091. this._order = [];
  11092. }
  11093. for (var _len4 = arguments.length, keys = new Array(_len4), _key4 = 0; _key4 < _len4; _key4++) {
  11094. keys[_key4] = arguments[_key4];
  11095. }
  11096. (0, _forEach.default)(keys).call(keys, key => {
  11097. var _context7, _context8;
  11098. if ((0, _isArray.default)(key)) {
  11099. key = key.join();
  11100. }
  11101. this._order = (0, _concat.default)(_context7 = this._order).call(_context7, (0, _map.default)(_context8 = key.replace(/\s/g, '').split(',')).call(_context8, k => {
  11102. return '-' + k;
  11103. }));
  11104. });
  11105. return this;
  11106. }
  11107. /* Query Options */
  11108. /**
  11109. * Sets the number of results to skip before returning any results.
  11110. * This is useful for pagination.
  11111. * Default is to skip zero results.
  11112. *
  11113. * @param {number} n the number of results to skip.
  11114. * @returns {Parse.Query} Returns the query, so you can chain this call.
  11115. */
  11116. skip(n) {
  11117. if (typeof n !== 'number' || n < 0) {
  11118. throw new Error('You can only skip by a positive number');
  11119. }
  11120. this._skip = n;
  11121. return this;
  11122. }
  11123. /**
  11124. * Sets the limit of the number of results to return. The default limit is 100.
  11125. *
  11126. * @param {number} n the number of results to limit to.
  11127. * @returns {Parse.Query} Returns the query, so you can chain this call.
  11128. */
  11129. limit(n) {
  11130. if (typeof n !== 'number') {
  11131. throw new Error('You can only set the limit to a numeric value');
  11132. }
  11133. this._limit = n;
  11134. return this;
  11135. }
  11136. /**
  11137. * Sets the flag to include with response the total number of objects satisfying this query,
  11138. * despite limits/skip. Might be useful for pagination.
  11139. * Note that result of this query will be wrapped as an object with
  11140. * `results`: holding {ParseObject} array and `count`: integer holding total number
  11141. *
  11142. * @param {boolean} includeCount false - disable, true - enable.
  11143. * @returns {Parse.Query} Returns the query, so you can chain this call.
  11144. */
  11145. withCount() {
  11146. let includeCount = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : true;
  11147. if (typeof includeCount !== 'boolean') {
  11148. throw new Error('You can only set withCount to a boolean value');
  11149. }
  11150. this._count = includeCount;
  11151. return this;
  11152. }
  11153. /**
  11154. * Includes nested Parse.Objects for the provided key. You can use dot
  11155. * notation to specify which fields in the included object are also fetched.
  11156. *
  11157. * You can include all nested Parse.Objects by passing in '*'.
  11158. * Requires Parse Server 3.0.0+
  11159. * <pre>query.include('*');</pre>
  11160. *
  11161. * @param {...string|Array<string>} keys The name(s) of the key(s) to include.
  11162. * @returns {Parse.Query} Returns the query, so you can chain this call.
  11163. */
  11164. include() {
  11165. for (var _len5 = arguments.length, keys = new Array(_len5), _key5 = 0; _key5 < _len5; _key5++) {
  11166. keys[_key5] = arguments[_key5];
  11167. }
  11168. (0, _forEach.default)(keys).call(keys, key => {
  11169. if ((0, _isArray.default)(key)) {
  11170. var _context9;
  11171. this._include = (0, _concat.default)(_context9 = this._include).call(_context9, key);
  11172. } else {
  11173. this._include.push(key);
  11174. }
  11175. });
  11176. return this;
  11177. }
  11178. /**
  11179. * Includes all nested Parse.Objects one level deep.
  11180. *
  11181. * Requires Parse Server 3.0.0+
  11182. *
  11183. * @returns {Parse.Query} Returns the query, so you can chain this call.
  11184. */
  11185. includeAll() {
  11186. return this.include('*');
  11187. }
  11188. /**
  11189. * Restricts the fields of the returned Parse.Objects to include only the
  11190. * provided keys. If this is called multiple times, then all of the keys
  11191. * specified in each of the calls will be included.
  11192. *
  11193. * @param {...string|Array<string>} keys The name(s) of the key(s) to include.
  11194. * @returns {Parse.Query} Returns the query, so you can chain this call.
  11195. */
  11196. select() {
  11197. if (!this._select) {
  11198. this._select = [];
  11199. }
  11200. for (var _len6 = arguments.length, keys = new Array(_len6), _key6 = 0; _key6 < _len6; _key6++) {
  11201. keys[_key6] = arguments[_key6];
  11202. }
  11203. (0, _forEach.default)(keys).call(keys, key => {
  11204. if ((0, _isArray.default)(key)) {
  11205. var _context10;
  11206. this._select = (0, _concat.default)(_context10 = this._select).call(_context10, key);
  11207. } else {
  11208. this._select.push(key);
  11209. }
  11210. });
  11211. return this;
  11212. }
  11213. /**
  11214. * Restricts the fields of the returned Parse.Objects to all keys except the
  11215. * provided keys. Exclude takes precedence over select and include.
  11216. *
  11217. * Requires Parse Server 3.6.0+
  11218. *
  11219. * @param {...string|Array<string>} keys The name(s) of the key(s) to exclude.
  11220. * @returns {Parse.Query} Returns the query, so you can chain this call.
  11221. */
  11222. exclude() {
  11223. for (var _len7 = arguments.length, keys = new Array(_len7), _key7 = 0; _key7 < _len7; _key7++) {
  11224. keys[_key7] = arguments[_key7];
  11225. }
  11226. (0, _forEach.default)(keys).call(keys, key => {
  11227. if ((0, _isArray.default)(key)) {
  11228. var _context11;
  11229. this._exclude = (0, _concat.default)(_context11 = this._exclude).call(_context11, key);
  11230. } else {
  11231. this._exclude.push(key);
  11232. }
  11233. });
  11234. return this;
  11235. }
  11236. /**
  11237. * Restricts live query to trigger only for watched fields.
  11238. *
  11239. * Requires Parse Server 6.0.0+
  11240. *
  11241. * @param {...string|Array<string>} keys The name(s) of the key(s) to watch.
  11242. * @returns {Parse.Query} Returns the query, so you can chain this call.
  11243. */
  11244. watch() {
  11245. for (var _len8 = arguments.length, keys = new Array(_len8), _key8 = 0; _key8 < _len8; _key8++) {
  11246. keys[_key8] = arguments[_key8];
  11247. }
  11248. (0, _forEach.default)(keys).call(keys, key => {
  11249. if ((0, _isArray.default)(key)) {
  11250. var _context12;
  11251. this._watch = (0, _concat.default)(_context12 = this._watch).call(_context12, key);
  11252. } else {
  11253. this._watch.push(key);
  11254. }
  11255. });
  11256. return this;
  11257. }
  11258. /**
  11259. * Changes the read preference that the backend will use when performing the query to the database.
  11260. *
  11261. * @param {string} readPreference The read preference for the main query.
  11262. * @param {string} includeReadPreference The read preference for the queries to include pointers.
  11263. * @param {string} subqueryReadPreference The read preference for the sub queries.
  11264. * @returns {Parse.Query} Returns the query, so you can chain this call.
  11265. */
  11266. readPreference(readPreference, includeReadPreference, subqueryReadPreference) {
  11267. this._readPreference = readPreference;
  11268. this._includeReadPreference = includeReadPreference || null;
  11269. this._subqueryReadPreference = subqueryReadPreference || null;
  11270. return this;
  11271. }
  11272. /**
  11273. * Subscribe this query to get liveQuery updates
  11274. *
  11275. * @param {string} sessionToken (optional) Defaults to the currentUser
  11276. * @returns {Promise<LiveQuerySubscription>} Returns the liveQuerySubscription, it's an event emitter
  11277. * which can be used to get liveQuery updates.
  11278. */
  11279. async subscribe(sessionToken) {
  11280. const currentUser = await _CoreManager.default.getUserController().currentUserAsync();
  11281. if (!sessionToken) {
  11282. sessionToken = currentUser ? currentUser.getSessionToken() || undefined : undefined;
  11283. }
  11284. const liveQueryClient = await _CoreManager.default.getLiveQueryController().getDefaultLiveQueryClient();
  11285. if (liveQueryClient.shouldOpen()) {
  11286. liveQueryClient.open();
  11287. }
  11288. const subscription = liveQueryClient.subscribe(this, sessionToken);
  11289. return subscription.subscribePromise.then(() => {
  11290. return subscription;
  11291. });
  11292. }
  11293. /**
  11294. * Constructs a Parse.Query that is the OR of the passed in queries. For
  11295. * example:
  11296. * <pre>var compoundQuery = Parse.Query.or(query1, query2, query3);</pre>
  11297. *
  11298. * will create a compoundQuery that is an or of the query1, query2, and
  11299. * query3.
  11300. *
  11301. * @param {...Parse.Query} queries The list of queries to OR.
  11302. * @static
  11303. * @returns {Parse.Query} The query that is the OR of the passed in queries.
  11304. */
  11305. static or() {
  11306. for (var _len9 = arguments.length, queries = new Array(_len9), _key9 = 0; _key9 < _len9; _key9++) {
  11307. queries[_key9] = arguments[_key9];
  11308. }
  11309. const className = _getClassNameFromQueries(queries);
  11310. const query = new ParseQuery(className);
  11311. query._orQuery(queries);
  11312. return query;
  11313. }
  11314. /**
  11315. * Constructs a Parse.Query that is the AND of the passed in queries. For
  11316. * example:
  11317. * <pre>var compoundQuery = Parse.Query.and(query1, query2, query3);</pre>
  11318. *
  11319. * will create a compoundQuery that is an and of the query1, query2, and
  11320. * query3.
  11321. *
  11322. * @param {...Parse.Query} queries The list of queries to AND.
  11323. * @static
  11324. * @returns {Parse.Query} The query that is the AND of the passed in queries.
  11325. */
  11326. static and() {
  11327. for (var _len10 = arguments.length, queries = new Array(_len10), _key10 = 0; _key10 < _len10; _key10++) {
  11328. queries[_key10] = arguments[_key10];
  11329. }
  11330. const className = _getClassNameFromQueries(queries);
  11331. const query = new ParseQuery(className);
  11332. query._andQuery(queries);
  11333. return query;
  11334. }
  11335. /**
  11336. * Constructs a Parse.Query that is the NOR of the passed in queries. For
  11337. * example:
  11338. * <pre>const compoundQuery = Parse.Query.nor(query1, query2, query3);</pre>
  11339. *
  11340. * will create a compoundQuery that is a nor of the query1, query2, and
  11341. * query3.
  11342. *
  11343. * @param {...Parse.Query} queries The list of queries to NOR.
  11344. * @static
  11345. * @returns {Parse.Query} The query that is the NOR of the passed in queries.
  11346. */
  11347. static nor() {
  11348. for (var _len11 = arguments.length, queries = new Array(_len11), _key11 = 0; _key11 < _len11; _key11++) {
  11349. queries[_key11] = arguments[_key11];
  11350. }
  11351. const className = _getClassNameFromQueries(queries);
  11352. const query = new ParseQuery(className);
  11353. query._norQuery(queries);
  11354. return query;
  11355. }
  11356. /**
  11357. * Change the source of this query to the server.
  11358. *
  11359. * @returns {Parse.Query} Returns the query, so you can chain this call.
  11360. */
  11361. fromNetwork() {
  11362. this._queriesLocalDatastore = false;
  11363. this._localDatastorePinName = null;
  11364. return this;
  11365. }
  11366. /**
  11367. * Changes the source of this query to all pinned objects.
  11368. *
  11369. * @returns {Parse.Query} Returns the query, so you can chain this call.
  11370. */
  11371. fromLocalDatastore() {
  11372. return this.fromPinWithName(null);
  11373. }
  11374. /**
  11375. * Changes the source of this query to the default group of pinned objects.
  11376. *
  11377. * @returns {Parse.Query} Returns the query, so you can chain this call.
  11378. */
  11379. fromPin() {
  11380. return this.fromPinWithName(_LocalDatastoreUtils.DEFAULT_PIN);
  11381. }
  11382. /**
  11383. * Changes the source of this query to a specific group of pinned objects.
  11384. *
  11385. * @param {string} name The name of query source.
  11386. * @returns {Parse.Query} Returns the query, so you can chain this call.
  11387. */
  11388. fromPinWithName(name) {
  11389. const localDatastore = _CoreManager.default.getLocalDatastore();
  11390. if (localDatastore.checkIfEnabled()) {
  11391. this._queriesLocalDatastore = true;
  11392. this._localDatastorePinName = name;
  11393. }
  11394. return this;
  11395. }
  11396. /**
  11397. * Cancels the current network request (if any is running).
  11398. *
  11399. * @returns {Parse.Query} Returns the query, so you can chain this call.
  11400. */
  11401. cancel() {
  11402. if (this._xhrRequest.task && typeof this._xhrRequest.task.abort === 'function') {
  11403. this._xhrRequest.task._aborted = true;
  11404. this._xhrRequest.task.abort();
  11405. this._xhrRequest.task = null;
  11406. this._xhrRequest.onchange = () => {};
  11407. return this;
  11408. }
  11409. this._xhrRequest.onchange = () => this.cancel();
  11410. return this;
  11411. }
  11412. _setRequestTask(options) {
  11413. options.requestTask = task => {
  11414. this._xhrRequest.task = task;
  11415. this._xhrRequest.onchange();
  11416. };
  11417. }
  11418. /**
  11419. * Sets a comment to the query so that the query
  11420. * can be identified when using a the profiler for MongoDB.
  11421. *
  11422. * @param {string} value a comment can make your profile data easier to interpret and trace.
  11423. * @returns {Parse.Query} Returns the query, so you can chain this call.
  11424. */
  11425. comment(value) {
  11426. if (value == null) {
  11427. delete this._comment;
  11428. return this;
  11429. }
  11430. if (typeof value !== 'string') {
  11431. throw new Error('The value of a comment to be sent with this query must be a string.');
  11432. }
  11433. this._comment = value;
  11434. return this;
  11435. }
  11436. }
  11437. const DefaultController = {
  11438. find(className, params, options) {
  11439. const RESTController = _CoreManager.default.getRESTController();
  11440. return RESTController.request('GET', 'classes/' + className, params, options);
  11441. },
  11442. aggregate(className, params, options) {
  11443. const RESTController = _CoreManager.default.getRESTController();
  11444. return RESTController.request('GET', 'aggregate/' + className, params, options);
  11445. }
  11446. };
  11447. _CoreManager.default.setParseQuery(ParseQuery);
  11448. _CoreManager.default.setQueryController(DefaultController);
  11449. var _default = exports.default = ParseQuery;
  11450. },{"./CoreManager":4,"./LocalDatastoreUtils":17,"./OfflineQuery":19,"./ParseError":24,"./ParseGeoPoint":26,"./ParseObject":30,"./encode":56,"./promiseUtils":61,"@babel/runtime-corejs3/core-js-stable/array/is-array":66,"@babel/runtime-corejs3/core-js-stable/instance/concat":68,"@babel/runtime-corejs3/core-js-stable/instance/filter":71,"@babel/runtime-corejs3/core-js-stable/instance/find":73,"@babel/runtime-corejs3/core-js-stable/instance/for-each":74,"@babel/runtime-corejs3/core-js-stable/instance/includes":75,"@babel/runtime-corejs3/core-js-stable/instance/index-of":76,"@babel/runtime-corejs3/core-js-stable/instance/keys":77,"@babel/runtime-corejs3/core-js-stable/instance/map":78,"@babel/runtime-corejs3/core-js-stable/instance/slice":80,"@babel/runtime-corejs3/core-js-stable/instance/sort":81,"@babel/runtime-corejs3/core-js-stable/instance/splice":82,"@babel/runtime-corejs3/core-js-stable/object/define-property":90,"@babel/runtime-corejs3/core-js-stable/object/entries":91,"@babel/runtime-corejs3/core-js-stable/object/keys":95,"@babel/runtime-corejs3/core-js-stable/promise":97,"@babel/runtime-corejs3/helpers/defineProperty":102,"@babel/runtime-corejs3/helpers/interopRequireDefault":103}],34:[function(_dereq_,module,exports){
  11451. "use strict";
  11452. var _Object$defineProperty = _dereq_("@babel/runtime-corejs3/core-js-stable/object/define-property");
  11453. var _interopRequireDefault = _dereq_("@babel/runtime-corejs3/helpers/interopRequireDefault");
  11454. _Object$defineProperty(exports, "__esModule", {
  11455. value: true
  11456. });
  11457. exports.default = void 0;
  11458. var _isArray = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/array/is-array"));
  11459. var _defineProperty2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/helpers/defineProperty"));
  11460. var _CoreManager = _interopRequireDefault(_dereq_("./CoreManager"));
  11461. /**
  11462. * Creates a new Relation for the given parent object and key. This
  11463. * constructor should rarely be used directly, but rather created by
  11464. * Parse.Object.relation.
  11465. *
  11466. * <p>
  11467. * A class that is used to access all of the children of a many-to-many
  11468. * relationship. Each instance of Parse.Relation is associated with a
  11469. * particular parent object and key.
  11470. * </p>
  11471. *
  11472. * @alias Parse.Relation
  11473. */
  11474. class ParseRelation {
  11475. /**
  11476. * @param {Parse.Object} parent The parent of this relation.
  11477. * @param {string} key The key for this relation on the parent.
  11478. */
  11479. constructor(parent, key) {
  11480. (0, _defineProperty2.default)(this, "parent", void 0);
  11481. (0, _defineProperty2.default)(this, "key", void 0);
  11482. (0, _defineProperty2.default)(this, "targetClassName", void 0);
  11483. this.parent = parent;
  11484. this.key = key;
  11485. this.targetClassName = null;
  11486. }
  11487. /*
  11488. * Makes sure that this relation has the right parent and key.
  11489. */
  11490. _ensureParentAndKey(parent, key) {
  11491. this.key = this.key || key;
  11492. if (this.key !== key) {
  11493. throw new Error('Internal Error. Relation retrieved from two different keys.');
  11494. }
  11495. if (this.parent) {
  11496. if (this.parent.className !== parent.className) {
  11497. throw new Error('Internal Error. Relation retrieved from two different Objects.');
  11498. }
  11499. if (this.parent.id) {
  11500. if (this.parent.id !== parent.id) {
  11501. throw new Error('Internal Error. Relation retrieved from two different Objects.');
  11502. }
  11503. } else if (parent.id) {
  11504. this.parent = parent;
  11505. }
  11506. } else {
  11507. this.parent = parent;
  11508. }
  11509. }
  11510. /**
  11511. * Adds a Parse.Object or an array of Parse.Objects to the relation.
  11512. *
  11513. * @param {(Parse.Object|Array)} objects The item or items to add.
  11514. * @returns {Parse.Object} The parent of the relation.
  11515. */
  11516. add(objects) {
  11517. if (!(0, _isArray.default)(objects)) {
  11518. objects = [objects];
  11519. }
  11520. const {
  11521. RelationOp
  11522. } = _CoreManager.default.getParseOp();
  11523. const change = new RelationOp(objects, []);
  11524. const parent = this.parent;
  11525. if (!parent) {
  11526. throw new Error('Cannot add to a Relation without a parent');
  11527. }
  11528. if (objects.length === 0) {
  11529. return parent;
  11530. }
  11531. parent.set(this.key, change);
  11532. this.targetClassName = change._targetClassName;
  11533. return parent;
  11534. }
  11535. /**
  11536. * Removes a Parse.Object or an array of Parse.Objects from this relation.
  11537. *
  11538. * @param {(Parse.Object|Array)} objects The item or items to remove.
  11539. */
  11540. remove(objects) {
  11541. if (!(0, _isArray.default)(objects)) {
  11542. objects = [objects];
  11543. }
  11544. const {
  11545. RelationOp
  11546. } = _CoreManager.default.getParseOp();
  11547. const change = new RelationOp([], objects);
  11548. if (!this.parent) {
  11549. throw new Error('Cannot remove from a Relation without a parent');
  11550. }
  11551. if (objects.length === 0) {
  11552. return;
  11553. }
  11554. this.parent.set(this.key, change);
  11555. this.targetClassName = change._targetClassName;
  11556. }
  11557. /**
  11558. * Returns a JSON version of the object suitable for saving to disk.
  11559. *
  11560. * @returns {object} JSON representation of Relation
  11561. */
  11562. toJSON() {
  11563. return {
  11564. __type: 'Relation',
  11565. className: this.targetClassName
  11566. };
  11567. }
  11568. /**
  11569. * Returns a Parse.Query that is limited to objects in this
  11570. * relation.
  11571. *
  11572. * @returns {Parse.Query} Relation Query
  11573. */
  11574. query() {
  11575. let query;
  11576. const parent = this.parent;
  11577. if (!parent) {
  11578. throw new Error('Cannot construct a query for a Relation without a parent');
  11579. }
  11580. const ParseQuery = _CoreManager.default.getParseQuery();
  11581. if (!this.targetClassName) {
  11582. query = new ParseQuery(parent.className);
  11583. query._extraOptions.redirectClassNameForKey = this.key;
  11584. } else {
  11585. query = new ParseQuery(this.targetClassName);
  11586. }
  11587. query._addCondition('$relatedTo', 'object', {
  11588. __type: 'Pointer',
  11589. className: parent.className,
  11590. objectId: parent.id
  11591. });
  11592. query._addCondition('$relatedTo', 'key', this.key);
  11593. return query;
  11594. }
  11595. }
  11596. var _default = exports.default = ParseRelation;
  11597. },{"./CoreManager":4,"@babel/runtime-corejs3/core-js-stable/array/is-array":66,"@babel/runtime-corejs3/core-js-stable/object/define-property":90,"@babel/runtime-corejs3/helpers/defineProperty":102,"@babel/runtime-corejs3/helpers/interopRequireDefault":103}],35:[function(_dereq_,module,exports){
  11598. "use strict";
  11599. var _Object$defineProperty = _dereq_("@babel/runtime-corejs3/core-js-stable/object/define-property");
  11600. var _interopRequireDefault = _dereq_("@babel/runtime-corejs3/helpers/interopRequireDefault");
  11601. _Object$defineProperty(exports, "__esModule", {
  11602. value: true
  11603. });
  11604. exports.default = void 0;
  11605. var _CoreManager = _interopRequireDefault(_dereq_("./CoreManager"));
  11606. var _ParseACL = _interopRequireDefault(_dereq_("./ParseACL"));
  11607. var _ParseError = _interopRequireDefault(_dereq_("./ParseError"));
  11608. var _ParseObject = _interopRequireDefault(_dereq_("./ParseObject"));
  11609. /**
  11610. * Represents a Role on the Parse server. Roles represent groupings of
  11611. * Users for the purposes of granting permissions (e.g. specifying an ACL
  11612. * for an Object). Roles are specified by their sets of child users and
  11613. * child roles, all of which are granted any permissions that the parent
  11614. * role has.
  11615. *
  11616. * <p>Roles must have a name (which cannot be changed after creation of the
  11617. * role), and must specify an ACL.</p>
  11618. *
  11619. * @alias Parse.Role
  11620. * @augments Parse.Object
  11621. */
  11622. class ParseRole extends _ParseObject.default {
  11623. /**
  11624. * @param {string} name The name of the Role to create.
  11625. * @param {Parse.ACL} acl The ACL for this role. Roles must have an ACL.
  11626. * A Parse.Role is a local representation of a role persisted to the Parse
  11627. * cloud.
  11628. */
  11629. constructor(name, acl) {
  11630. super('_Role');
  11631. if (typeof name === 'string' && acl instanceof _ParseACL.default) {
  11632. this.setName(name);
  11633. this.setACL(acl);
  11634. }
  11635. }
  11636. /**
  11637. * Gets the name of the role. You can alternatively call role.get("name")
  11638. *
  11639. * @returns {string} the name of the role.
  11640. */
  11641. getName() {
  11642. const name = this.get('name');
  11643. if (name == null || typeof name === 'string') {
  11644. return name;
  11645. }
  11646. return '';
  11647. }
  11648. /**
  11649. * Sets the name for a role. This value must be set before the role has
  11650. * been saved to the server, and cannot be set once the role has been
  11651. * saved.
  11652. *
  11653. * <p>
  11654. * A role's name can only contain alphanumeric characters, _, -, and
  11655. * spaces.
  11656. * </p>
  11657. *
  11658. * <p>This is equivalent to calling role.set("name", name)</p>
  11659. *
  11660. * @param {string} name The name of the role.
  11661. * @param {object} options Standard options object with success and error
  11662. * callbacks.
  11663. * @returns {(ParseObject|boolean)} true if the set succeeded.
  11664. */
  11665. setName(name, options) {
  11666. this._validateName(name);
  11667. return this.set('name', name, options);
  11668. }
  11669. /**
  11670. * Gets the Parse.Relation for the Parse.Users that are direct
  11671. * children of this role. These users are granted any privileges that this
  11672. * role has been granted (e.g. read or write access through ACLs). You can
  11673. * add or remove users from the role through this relation.
  11674. *
  11675. * <p>This is equivalent to calling role.relation("users")</p>
  11676. *
  11677. * @returns {Parse.Relation} the relation for the users belonging to this
  11678. * role.
  11679. */
  11680. getUsers() {
  11681. return this.relation('users');
  11682. }
  11683. /**
  11684. * Gets the Parse.Relation for the Parse.Roles that are direct
  11685. * children of this role. These roles' users are granted any privileges that
  11686. * this role has been granted (e.g. read or write access through ACLs). You
  11687. * can add or remove child roles from this role through this relation.
  11688. *
  11689. * <p>This is equivalent to calling role.relation("roles")</p>
  11690. *
  11691. * @returns {Parse.Relation} the relation for the roles belonging to this
  11692. * role.
  11693. */
  11694. getRoles() {
  11695. return this.relation('roles');
  11696. }
  11697. _validateName(newName) {
  11698. if (typeof newName !== 'string') {
  11699. throw new _ParseError.default(_ParseError.default.OTHER_CAUSE, "A role's name must be a String.");
  11700. }
  11701. if (!/^[0-9a-zA-Z\-_ ]+$/.test(newName)) {
  11702. throw new _ParseError.default(_ParseError.default.OTHER_CAUSE, "A role's name can be only contain alphanumeric characters, _, " + '-, and spaces.');
  11703. }
  11704. }
  11705. validate(attrs, options) {
  11706. const isInvalid = super.validate(attrs, options);
  11707. if (isInvalid) {
  11708. return isInvalid;
  11709. }
  11710. if ('name' in attrs && attrs.name !== this.getName()) {
  11711. const newName = attrs.name;
  11712. if (this.id && this.id !== attrs.objectId) {
  11713. // Check to see if the objectId being set matches this.id
  11714. // This happens during a fetch -- the id is set before calling fetch
  11715. // Let the name be set in this case
  11716. return new _ParseError.default(_ParseError.default.OTHER_CAUSE, "A role's name can only be set before it has been saved.");
  11717. }
  11718. try {
  11719. this._validateName(newName);
  11720. } catch (e) {
  11721. return e;
  11722. }
  11723. }
  11724. return false;
  11725. }
  11726. }
  11727. _CoreManager.default.setParseRole(ParseRole);
  11728. _ParseObject.default.registerSubclass('_Role', ParseRole);
  11729. var _default = exports.default = ParseRole;
  11730. },{"./CoreManager":4,"./ParseACL":21,"./ParseError":24,"./ParseObject":30,"@babel/runtime-corejs3/core-js-stable/object/define-property":90,"@babel/runtime-corejs3/helpers/interopRequireDefault":103}],36:[function(_dereq_,module,exports){
  11731. "use strict";
  11732. var _Object$defineProperty = _dereq_("@babel/runtime-corejs3/core-js-stable/object/define-property");
  11733. var _interopRequireDefault = _dereq_("@babel/runtime-corejs3/helpers/interopRequireDefault");
  11734. _Object$defineProperty(exports, "__esModule", {
  11735. value: true
  11736. });
  11737. exports.default = void 0;
  11738. var _indexOf = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/instance/index-of"));
  11739. var _defineProperty2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/helpers/defineProperty"));
  11740. var _CoreManager = _interopRequireDefault(_dereq_("./CoreManager"));
  11741. var _ParseObject = _interopRequireDefault(_dereq_("./ParseObject"));
  11742. var _ParseCLP = _interopRequireDefault(_dereq_("./ParseCLP"));
  11743. const FIELD_TYPES = ['String', 'Number', 'Boolean', 'Bytes', 'Date', 'File', 'GeoPoint', 'Polygon', 'Array', 'Object', 'Pointer', 'Relation'];
  11744. /**
  11745. * A Parse.Schema object is for handling schema data from Parse.
  11746. * <p>All the schemas methods require MasterKey.
  11747. *
  11748. * When adding fields, you may set required and default values. (Requires Parse Server 3.7.0+)
  11749. *
  11750. * <pre>
  11751. * const options = { required: true, defaultValue: 'hello world' };
  11752. * const schema = new Parse.Schema('MyClass');
  11753. * schema.addString('field', options);
  11754. * schema.addIndex('index_name', { 'field': 1 });
  11755. * schema.save();
  11756. * </pre>
  11757. * </p>
  11758. *
  11759. * @alias Parse.Schema
  11760. */
  11761. class ParseSchema {
  11762. /**
  11763. * @param {string} className Parse Class string.
  11764. */
  11765. constructor(className) {
  11766. (0, _defineProperty2.default)(this, "className", void 0);
  11767. (0, _defineProperty2.default)(this, "_fields", void 0);
  11768. (0, _defineProperty2.default)(this, "_indexes", void 0);
  11769. (0, _defineProperty2.default)(this, "_clp", void 0);
  11770. if (typeof className === 'string') {
  11771. if (className === 'User' && _CoreManager.default.get('PERFORM_USER_REWRITE')) {
  11772. this.className = '_User';
  11773. } else {
  11774. this.className = className;
  11775. }
  11776. }
  11777. this._fields = {};
  11778. this._indexes = {};
  11779. }
  11780. /**
  11781. * Static method to get all schemas
  11782. *
  11783. * @returns {Promise} A promise that is resolved with the result when
  11784. * the query completes.
  11785. */
  11786. static all() {
  11787. const controller = _CoreManager.default.getSchemaController();
  11788. return controller.get('').then(response => {
  11789. if (response.results.length === 0) {
  11790. throw new Error('Schema not found.');
  11791. }
  11792. return response.results;
  11793. });
  11794. }
  11795. /**
  11796. * Get the Schema from Parse
  11797. *
  11798. * @returns {Promise} A promise that is resolved with the result when
  11799. * the query completes.
  11800. */
  11801. get() {
  11802. this.assertClassName();
  11803. const controller = _CoreManager.default.getSchemaController();
  11804. return controller.get(this.className).then(response => {
  11805. if (!response) {
  11806. throw new Error('Schema not found.');
  11807. }
  11808. return response;
  11809. });
  11810. }
  11811. /**
  11812. * Create a new Schema on Parse
  11813. *
  11814. * @returns {Promise} A promise that is resolved with the result when
  11815. * the query completes.
  11816. */
  11817. save() {
  11818. this.assertClassName();
  11819. const controller = _CoreManager.default.getSchemaController();
  11820. const params = {
  11821. className: this.className,
  11822. fields: this._fields,
  11823. indexes: this._indexes,
  11824. classLevelPermissions: this._clp
  11825. };
  11826. return controller.create(this.className, params);
  11827. }
  11828. /**
  11829. * Update a Schema on Parse
  11830. *
  11831. * @returns {Promise} A promise that is resolved with the result when
  11832. * the query completes.
  11833. */
  11834. update() {
  11835. this.assertClassName();
  11836. const controller = _CoreManager.default.getSchemaController();
  11837. const params = {
  11838. className: this.className,
  11839. fields: this._fields,
  11840. indexes: this._indexes,
  11841. classLevelPermissions: this._clp
  11842. };
  11843. this._fields = {};
  11844. this._indexes = {};
  11845. return controller.update(this.className, params);
  11846. }
  11847. /**
  11848. * Removing a Schema from Parse
  11849. * Can only be used on Schema without objects
  11850. *
  11851. * @returns {Promise} A promise that is resolved with the result when
  11852. * the query completes.
  11853. */
  11854. delete() {
  11855. this.assertClassName();
  11856. const controller = _CoreManager.default.getSchemaController();
  11857. return controller.delete(this.className);
  11858. }
  11859. /**
  11860. * Removes all objects from a Schema (class) in Parse.
  11861. * EXERCISE CAUTION, running this will delete all objects for this schema and cannot be reversed
  11862. *
  11863. * @returns {Promise} A promise that is resolved with the result when
  11864. * the query completes.
  11865. */
  11866. purge() {
  11867. this.assertClassName();
  11868. const controller = _CoreManager.default.getSchemaController();
  11869. return controller.purge(this.className);
  11870. }
  11871. /**
  11872. * Assert if ClassName has been filled
  11873. *
  11874. * @private
  11875. */
  11876. assertClassName() {
  11877. if (!this.className) {
  11878. throw new Error('You must set a Class Name before making any request.');
  11879. }
  11880. }
  11881. /**
  11882. * Sets Class Level Permissions when creating / updating a Schema.
  11883. * EXERCISE CAUTION, running this may override CLP for this schema and cannot be reversed
  11884. *
  11885. * @param {object | Parse.CLP} clp Class Level Permissions
  11886. * @returns {Parse.Schema} Returns the schema, so you can chain this call.
  11887. */
  11888. setCLP(clp) {
  11889. if (clp instanceof _ParseCLP.default) {
  11890. this._clp = clp.toJSON();
  11891. } else {
  11892. this._clp = clp;
  11893. }
  11894. return this;
  11895. }
  11896. /**
  11897. * Adding a Field to Create / Update a Schema
  11898. *
  11899. * @param {string} name Name of the field that will be created on Parse
  11900. * @param {string} type Can be a (String|Number|Boolean|Date|Parse.File|Parse.GeoPoint|Array|Object|Pointer|Parse.Relation)
  11901. * @param {object} options
  11902. * Valid options are:<ul>
  11903. * <li>required: If field is not set, save operation fails (Requires Parse Server 3.7.0+)
  11904. * <li>defaultValue: If field is not set, a default value is selected (Requires Parse Server 3.7.0+)
  11905. * <li>targetClass: Required if type is Pointer or Parse.Relation
  11906. * </ul>
  11907. * @returns {Parse.Schema} Returns the schema, so you can chain this call.
  11908. */
  11909. addField(name, type) {
  11910. let options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
  11911. type = type || 'String';
  11912. if (!name) {
  11913. throw new Error('field name may not be null.');
  11914. }
  11915. if ((0, _indexOf.default)(FIELD_TYPES).call(FIELD_TYPES, type) === -1) {
  11916. throw new Error(`${type} is not a valid type.`);
  11917. }
  11918. if (type === 'Pointer') {
  11919. return this.addPointer(name, options.targetClass, options);
  11920. }
  11921. if (type === 'Relation') {
  11922. return this.addRelation(name, options.targetClass);
  11923. }
  11924. const fieldOptions = {
  11925. type
  11926. };
  11927. if (typeof options.required === 'boolean') {
  11928. fieldOptions.required = options.required;
  11929. }
  11930. if (options.defaultValue !== undefined) {
  11931. fieldOptions.defaultValue = options.defaultValue;
  11932. }
  11933. if (type === 'Date') {
  11934. if (options && options.defaultValue) {
  11935. fieldOptions.defaultValue = {
  11936. __type: 'Date',
  11937. iso: new Date(options.defaultValue)
  11938. };
  11939. }
  11940. }
  11941. if (type === 'Bytes') {
  11942. if (options && options.defaultValue) {
  11943. fieldOptions.defaultValue = {
  11944. __type: 'Bytes',
  11945. base64: options.defaultValue
  11946. };
  11947. }
  11948. }
  11949. this._fields[name] = fieldOptions;
  11950. return this;
  11951. }
  11952. /**
  11953. * Adding an Index to Create / Update a Schema
  11954. *
  11955. * @param {string} name Name of the index
  11956. * @param {object} index { field: value }
  11957. * @returns {Parse.Schema} Returns the schema, so you can chain this call.
  11958. *
  11959. * <pre>
  11960. * schema.addIndex('index_name', { 'field': 1 });
  11961. * </pre>
  11962. */
  11963. addIndex(name, index) {
  11964. if (!name) {
  11965. throw new Error('index name may not be null.');
  11966. }
  11967. if (!index) {
  11968. throw new Error('index may not be null.');
  11969. }
  11970. this._indexes[name] = index;
  11971. return this;
  11972. }
  11973. /**
  11974. * Adding String Field
  11975. *
  11976. * @param {string} name Name of the field that will be created on Parse
  11977. * @param {object} options See {@link https://parseplatform.org/Parse-SDK-JS/api/master/Parse.Schema.html#addField addField}
  11978. * @returns {Parse.Schema} Returns the schema, so you can chain this call.
  11979. */
  11980. addString(name, options) {
  11981. return this.addField(name, 'String', options);
  11982. }
  11983. /**
  11984. * Adding Number Field
  11985. *
  11986. * @param {string} name Name of the field that will be created on Parse
  11987. * @param {object} options See {@link https://parseplatform.org/Parse-SDK-JS/api/master/Parse.Schema.html#addField addField}
  11988. * @returns {Parse.Schema} Returns the schema, so you can chain this call.
  11989. */
  11990. addNumber(name, options) {
  11991. return this.addField(name, 'Number', options);
  11992. }
  11993. /**
  11994. * Adding Boolean Field
  11995. *
  11996. * @param {string} name Name of the field that will be created on Parse
  11997. * @param {object} options See {@link https://parseplatform.org/Parse-SDK-JS/api/master/Parse.Schema.html#addField addField}
  11998. * @returns {Parse.Schema} Returns the schema, so you can chain this call.
  11999. */
  12000. addBoolean(name, options) {
  12001. return this.addField(name, 'Boolean', options);
  12002. }
  12003. /**
  12004. * Adding Bytes Field
  12005. *
  12006. * @param {string} name Name of the field that will be created on Parse
  12007. * @param {object} options See {@link https://parseplatform.org/Parse-SDK-JS/api/master/Parse.Schema.html#addField addField}
  12008. * @returns {Parse.Schema} Returns the schema, so you can chain this call.
  12009. */
  12010. addBytes(name, options) {
  12011. return this.addField(name, 'Bytes', options);
  12012. }
  12013. /**
  12014. * Adding Date Field
  12015. *
  12016. * @param {string} name Name of the field that will be created on Parse
  12017. * @param {object} options See {@link https://parseplatform.org/Parse-SDK-JS/api/master/Parse.Schema.html#addField addField}
  12018. * @returns {Parse.Schema} Returns the schema, so you can chain this call.
  12019. */
  12020. addDate(name, options) {
  12021. return this.addField(name, 'Date', options);
  12022. }
  12023. /**
  12024. * Adding File Field
  12025. *
  12026. * @param {string} name Name of the field that will be created on Parse
  12027. * @param {object} options See {@link https://parseplatform.org/Parse-SDK-JS/api/master/Parse.Schema.html#addField addField}
  12028. * @returns {Parse.Schema} Returns the schema, so you can chain this call.
  12029. */
  12030. addFile(name, options) {
  12031. return this.addField(name, 'File', options);
  12032. }
  12033. /**
  12034. * Adding GeoPoint Field
  12035. *
  12036. * @param {string} name Name of the field that will be created on Parse
  12037. * @param {object} options See {@link https://parseplatform.org/Parse-SDK-JS/api/master/Parse.Schema.html#addField addField}
  12038. * @returns {Parse.Schema} Returns the schema, so you can chain this call.
  12039. */
  12040. addGeoPoint(name, options) {
  12041. return this.addField(name, 'GeoPoint', options);
  12042. }
  12043. /**
  12044. * Adding Polygon Field
  12045. *
  12046. * @param {string} name Name of the field that will be created on Parse
  12047. * @param {object} options See {@link https://parseplatform.org/Parse-SDK-JS/api/master/Parse.Schema.html#addField addField}
  12048. * @returns {Parse.Schema} Returns the schema, so you can chain this call.
  12049. */
  12050. addPolygon(name, options) {
  12051. return this.addField(name, 'Polygon', options);
  12052. }
  12053. /**
  12054. * Adding Array Field
  12055. *
  12056. * @param {string} name Name of the field that will be created on Parse
  12057. * @param {object} options See {@link https://parseplatform.org/Parse-SDK-JS/api/master/Parse.Schema.html#addField addField}
  12058. * @returns {Parse.Schema} Returns the schema, so you can chain this call.
  12059. */
  12060. addArray(name, options) {
  12061. return this.addField(name, 'Array', options);
  12062. }
  12063. /**
  12064. * Adding Object Field
  12065. *
  12066. * @param {string} name Name of the field that will be created on Parse
  12067. * @param {object} options See {@link https://parseplatform.org/Parse-SDK-JS/api/master/Parse.Schema.html#addField addField}
  12068. * @returns {Parse.Schema} Returns the schema, so you can chain this call.
  12069. */
  12070. addObject(name, options) {
  12071. return this.addField(name, 'Object', options);
  12072. }
  12073. /**
  12074. * Adding Pointer Field
  12075. *
  12076. * @param {string} name Name of the field that will be created on Parse
  12077. * @param {string} targetClass Name of the target Pointer Class
  12078. * @param {object} options See {@link https://parseplatform.org/Parse-SDK-JS/api/master/Parse.Schema.html#addField addField}
  12079. * @returns {Parse.Schema} Returns the schema, so you can chain this call.
  12080. */
  12081. addPointer(name, targetClass) {
  12082. let options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
  12083. if (!name) {
  12084. throw new Error('field name may not be null.');
  12085. }
  12086. if (!targetClass) {
  12087. throw new Error('You need to set the targetClass of the Pointer.');
  12088. }
  12089. const fieldOptions = {
  12090. type: 'Pointer',
  12091. targetClass
  12092. };
  12093. if (typeof options.required === 'boolean') {
  12094. fieldOptions.required = options.required;
  12095. }
  12096. if (options.defaultValue !== undefined) {
  12097. fieldOptions.defaultValue = options.defaultValue;
  12098. if (options.defaultValue instanceof _ParseObject.default) {
  12099. fieldOptions.defaultValue = options.defaultValue.toPointer();
  12100. }
  12101. }
  12102. this._fields[name] = fieldOptions;
  12103. return this;
  12104. }
  12105. /**
  12106. * Adding Relation Field
  12107. *
  12108. * @param {string} name Name of the field that will be created on Parse
  12109. * @param {string} targetClass Name of the target Pointer Class
  12110. * @returns {Parse.Schema} Returns the schema, so you can chain this call.
  12111. */
  12112. addRelation(name, targetClass) {
  12113. if (!name) {
  12114. throw new Error('field name may not be null.');
  12115. }
  12116. if (!targetClass) {
  12117. throw new Error('You need to set the targetClass of the Relation.');
  12118. }
  12119. this._fields[name] = {
  12120. type: 'Relation',
  12121. targetClass
  12122. };
  12123. return this;
  12124. }
  12125. /**
  12126. * Deleting a Field to Update on a Schema
  12127. *
  12128. * @param {string} name Name of the field
  12129. * @returns {Parse.Schema} Returns the schema, so you can chain this call.
  12130. */
  12131. deleteField(name) {
  12132. this._fields[name] = {
  12133. __op: 'Delete'
  12134. };
  12135. return this;
  12136. }
  12137. /**
  12138. * Deleting an Index to Update on a Schema
  12139. *
  12140. * @param {string} name Name of the field
  12141. * @returns {Parse.Schema} Returns the schema, so you can chain this call.
  12142. */
  12143. deleteIndex(name) {
  12144. this._indexes[name] = {
  12145. __op: 'Delete'
  12146. };
  12147. return this;
  12148. }
  12149. }
  12150. const DefaultController = {
  12151. send(className, method) {
  12152. let params = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
  12153. const RESTController = _CoreManager.default.getRESTController();
  12154. return RESTController.request(method, `schemas/${className}`, params, {
  12155. useMasterKey: true
  12156. });
  12157. },
  12158. get(className) {
  12159. return this.send(className, 'GET');
  12160. },
  12161. create(className, params) {
  12162. return this.send(className, 'POST', params);
  12163. },
  12164. update(className, params) {
  12165. return this.send(className, 'PUT', params);
  12166. },
  12167. delete(className) {
  12168. return this.send(className, 'DELETE');
  12169. },
  12170. purge(className) {
  12171. const RESTController = _CoreManager.default.getRESTController();
  12172. return RESTController.request('DELETE', `purge/${className}`, {}, {
  12173. useMasterKey: true
  12174. });
  12175. }
  12176. };
  12177. _CoreManager.default.setSchemaController(DefaultController);
  12178. var _default = exports.default = ParseSchema;
  12179. },{"./CoreManager":4,"./ParseCLP":22,"./ParseObject":30,"@babel/runtime-corejs3/core-js-stable/instance/index-of":76,"@babel/runtime-corejs3/core-js-stable/object/define-property":90,"@babel/runtime-corejs3/helpers/defineProperty":102,"@babel/runtime-corejs3/helpers/interopRequireDefault":103}],37:[function(_dereq_,module,exports){
  12180. "use strict";
  12181. var _Object$defineProperty = _dereq_("@babel/runtime-corejs3/core-js-stable/object/define-property");
  12182. var _interopRequireDefault = _dereq_("@babel/runtime-corejs3/helpers/interopRequireDefault");
  12183. _Object$defineProperty(exports, "__esModule", {
  12184. value: true
  12185. });
  12186. exports.default = void 0;
  12187. var _promise = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/promise"));
  12188. var _CoreManager = _interopRequireDefault(_dereq_("./CoreManager"));
  12189. var _isRevocableSession = _interopRequireDefault(_dereq_("./isRevocableSession"));
  12190. var _ParseObject = _interopRequireDefault(_dereq_("./ParseObject"));
  12191. var _ParseUser = _interopRequireDefault(_dereq_("./ParseUser"));
  12192. /**
  12193. * <p>A Parse.Session object is a local representation of a revocable session.
  12194. * This class is a subclass of a Parse.Object, and retains the same
  12195. * functionality of a Parse.Object.</p>
  12196. *
  12197. * @alias Parse.Session
  12198. * @augments Parse.Object
  12199. */
  12200. class ParseSession extends _ParseObject.default {
  12201. /**
  12202. * @param {object} attributes The initial set of data to store in the user.
  12203. */
  12204. constructor(attributes) {
  12205. super('_Session');
  12206. if (attributes && typeof attributes === 'object') {
  12207. if (!this.set(attributes || {})) {
  12208. throw new Error("Can't create an invalid Session");
  12209. }
  12210. }
  12211. }
  12212. /**
  12213. * Returns the session token string.
  12214. *
  12215. * @returns {string}
  12216. */
  12217. getSessionToken() {
  12218. const token = this.get('sessionToken');
  12219. if (typeof token === 'string') {
  12220. return token;
  12221. }
  12222. return '';
  12223. }
  12224. static readOnlyAttributes() {
  12225. return ['createdWith', 'expiresAt', 'installationId', 'restricted', 'sessionToken', 'user'];
  12226. }
  12227. /**
  12228. * Retrieves the Session object for the currently logged in session.
  12229. *
  12230. * @param {object} options useMasterKey
  12231. * @static
  12232. * @returns {Promise} A promise that is resolved with the Parse.Session
  12233. * object after it has been fetched. If there is no current user, the
  12234. * promise will be rejected.
  12235. */
  12236. static current(options) {
  12237. options = options || {};
  12238. const controller = _CoreManager.default.getSessionController();
  12239. const sessionOptions = {};
  12240. if (options.hasOwnProperty('useMasterKey')) {
  12241. sessionOptions.useMasterKey = options.useMasterKey;
  12242. }
  12243. return _ParseUser.default.currentAsync().then(user => {
  12244. if (!user) {
  12245. return _promise.default.reject('There is no current user.');
  12246. }
  12247. sessionOptions.sessionToken = user.getSessionToken();
  12248. return controller.getSession(sessionOptions);
  12249. });
  12250. }
  12251. /**
  12252. * Determines whether the current session token is revocable.
  12253. * This method is useful for migrating Express.js or Node.js web apps to
  12254. * use revocable sessions. If you are migrating an app that uses the Parse
  12255. * SDK in the browser only, please use Parse.User.enableRevocableSession()
  12256. * instead, so that sessions can be automatically upgraded.
  12257. *
  12258. * @static
  12259. * @returns {boolean}
  12260. */
  12261. static isCurrentSessionRevocable() {
  12262. const currentUser = _ParseUser.default.current();
  12263. if (currentUser) {
  12264. return (0, _isRevocableSession.default)(currentUser.getSessionToken() || '');
  12265. }
  12266. return false;
  12267. }
  12268. }
  12269. _ParseObject.default.registerSubclass('_Session', ParseSession);
  12270. const DefaultController = {
  12271. getSession(options) {
  12272. const RESTController = _CoreManager.default.getRESTController();
  12273. const session = new ParseSession();
  12274. return RESTController.request('GET', 'sessions/me', {}, options).then(sessionData => {
  12275. session._finishFetch(sessionData);
  12276. session._setExisted(true);
  12277. return session;
  12278. });
  12279. }
  12280. };
  12281. _CoreManager.default.setSessionController(DefaultController);
  12282. var _default = exports.default = ParseSession;
  12283. },{"./CoreManager":4,"./ParseObject":30,"./ParseUser":38,"./isRevocableSession":59,"@babel/runtime-corejs3/core-js-stable/object/define-property":90,"@babel/runtime-corejs3/core-js-stable/promise":97,"@babel/runtime-corejs3/helpers/interopRequireDefault":103}],38:[function(_dereq_,module,exports){
  12284. "use strict";
  12285. var _Object$defineProperty2 = _dereq_("@babel/runtime-corejs3/core-js-stable/object/define-property");
  12286. var _interopRequireDefault = _dereq_("@babel/runtime-corejs3/helpers/interopRequireDefault");
  12287. _Object$defineProperty2(exports, "__esModule", {
  12288. value: true
  12289. });
  12290. exports.default = void 0;
  12291. var _promise = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/promise"));
  12292. var _defineProperty = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/object/define-property"));
  12293. var _stringify = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/json/stringify"));
  12294. var _CoreManager = _interopRequireDefault(_dereq_("./CoreManager"));
  12295. var _isRevocableSession = _interopRequireDefault(_dereq_("./isRevocableSession"));
  12296. var _ParseError = _interopRequireDefault(_dereq_("./ParseError"));
  12297. var _ParseObject = _interopRequireDefault(_dereq_("./ParseObject"));
  12298. var _Storage = _interopRequireDefault(_dereq_("./Storage"));
  12299. const CURRENT_USER_KEY = 'currentUser';
  12300. let canUseCurrentUser = !_CoreManager.default.get('IS_NODE');
  12301. let currentUserCacheMatchesDisk = false;
  12302. let currentUserCache = null;
  12303. const authProviders = {};
  12304. /**
  12305. * <p>A Parse.User object is a local representation of a user persisted to the
  12306. * Parse cloud. This class is a subclass of a Parse.Object, and retains the
  12307. * same functionality of a Parse.Object, but also extends it with various
  12308. * user specific methods, like authentication, signing up, and validation of
  12309. * uniqueness.</p>
  12310. *
  12311. * @alias Parse.User
  12312. * @augments Parse.Object
  12313. */
  12314. class ParseUser extends _ParseObject.default {
  12315. /**
  12316. * @param {object} attributes The initial set of data to store in the user.
  12317. */
  12318. constructor(attributes) {
  12319. super('_User');
  12320. if (attributes && typeof attributes === 'object') {
  12321. if (!this.set(attributes || {})) {
  12322. throw new Error("Can't create an invalid Parse User");
  12323. }
  12324. }
  12325. }
  12326. /**
  12327. * Request a revocable session token to replace the older style of token.
  12328. *
  12329. * @param {object} options
  12330. * @returns {Promise} A promise that is resolved when the replacement
  12331. * token has been fetched.
  12332. */
  12333. _upgradeToRevocableSession(options) {
  12334. options = options || {};
  12335. const upgradeOptions = {};
  12336. if (options.hasOwnProperty('useMasterKey')) {
  12337. upgradeOptions.useMasterKey = options.useMasterKey;
  12338. }
  12339. const controller = _CoreManager.default.getUserController();
  12340. return controller.upgradeToRevocableSession(this, upgradeOptions);
  12341. }
  12342. /**
  12343. * 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
  12344. * your users to sign up or log into your application using their existing identities.
  12345. * Since 2.9.0
  12346. *
  12347. * @see {@link https://docs.parseplatform.org/js/guide/#linking-users Linking Users}
  12348. * @param {string | AuthProvider} provider Name of auth provider or {@link https://parseplatform.org/Parse-SDK-JS/api/master/AuthProvider.html AuthProvider}
  12349. * @param {object} options
  12350. * @param {object} [options.authData] AuthData to link with
  12351. * <ul>
  12352. * <li>If provider is string, options is {@link http://docs.parseplatform.org/parse-server/guide/#supported-3rd-party-authentications authData}
  12353. * <li>If provider is AuthProvider, options is saveOpts
  12354. * </ul>
  12355. * @param {object} saveOpts useMasterKey / sessionToken
  12356. * @returns {Promise} A promise that is fulfilled with the user is linked
  12357. */
  12358. linkWith(provider, options) {
  12359. let saveOpts = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
  12360. saveOpts.sessionToken = saveOpts.sessionToken || this.getSessionToken() || '';
  12361. let authType;
  12362. if (typeof provider === 'string') {
  12363. authType = provider;
  12364. if (authProviders[provider]) {
  12365. provider = authProviders[provider];
  12366. } else {
  12367. const authProvider = {
  12368. restoreAuthentication() {
  12369. return true;
  12370. },
  12371. getAuthType() {
  12372. return authType;
  12373. }
  12374. };
  12375. authProviders[authProvider.getAuthType()] = authProvider;
  12376. provider = authProvider;
  12377. }
  12378. } else {
  12379. authType = provider.getAuthType();
  12380. }
  12381. if (options && options.hasOwnProperty('authData')) {
  12382. const authData = this.get('authData') || {};
  12383. if (typeof authData !== 'object') {
  12384. throw new Error('Invalid type: authData field should be an object');
  12385. }
  12386. authData[authType] = options.authData;
  12387. const oldAnonymousData = authData.anonymous;
  12388. this.stripAnonymity();
  12389. const controller = _CoreManager.default.getUserController();
  12390. return controller.linkWith(this, authData, saveOpts).catch(e => {
  12391. delete authData[authType];
  12392. this.restoreAnonimity(oldAnonymousData);
  12393. throw e;
  12394. });
  12395. } else {
  12396. return new _promise.default((resolve, reject) => {
  12397. provider.authenticate({
  12398. success: (provider, result) => {
  12399. const opts = {};
  12400. opts.authData = result;
  12401. this.linkWith(provider, opts, saveOpts).then(() => {
  12402. resolve(this);
  12403. }, error => {
  12404. reject(error);
  12405. });
  12406. },
  12407. error: (provider, error) => {
  12408. reject(error);
  12409. }
  12410. });
  12411. });
  12412. }
  12413. }
  12414. /**
  12415. * @param provider
  12416. * @param options
  12417. * @param {object} [options.authData]
  12418. * @param saveOpts
  12419. * @deprecated since 2.9.0 see {@link https://parseplatform.org/Parse-SDK-JS/api/master/Parse.User.html#linkWith linkWith}
  12420. * @returns {Promise}
  12421. */
  12422. _linkWith(provider, options) {
  12423. let saveOpts = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
  12424. return this.linkWith(provider, options, saveOpts);
  12425. }
  12426. /**
  12427. * Synchronizes auth data for a provider (e.g. puts the access token in the
  12428. * right place to be used by the Facebook SDK).
  12429. *
  12430. * @param provider
  12431. */
  12432. _synchronizeAuthData(provider) {
  12433. if (!this.isCurrent() || !provider) {
  12434. return;
  12435. }
  12436. let authType;
  12437. if (typeof provider === 'string') {
  12438. authType = provider;
  12439. provider = authProviders[authType];
  12440. } else {
  12441. authType = provider.getAuthType();
  12442. }
  12443. const authData = this.get('authData');
  12444. if (!provider || !authData || typeof authData !== 'object') {
  12445. return;
  12446. }
  12447. const success = provider.restoreAuthentication(authData[authType]);
  12448. if (!success) {
  12449. this._unlinkFrom(provider);
  12450. }
  12451. }
  12452. /**
  12453. * Synchronizes authData for all providers.
  12454. */
  12455. _synchronizeAllAuthData() {
  12456. const authData = this.get('authData');
  12457. if (typeof authData !== 'object') {
  12458. return;
  12459. }
  12460. for (const key in authData) {
  12461. this._synchronizeAuthData(key);
  12462. }
  12463. }
  12464. /**
  12465. * Removes null values from authData (which exist temporarily for unlinking)
  12466. */
  12467. _cleanupAuthData() {
  12468. if (!this.isCurrent()) {
  12469. return;
  12470. }
  12471. const authData = this.get('authData');
  12472. if (typeof authData !== 'object') {
  12473. return;
  12474. }
  12475. for (const key in authData) {
  12476. if (!authData[key]) {
  12477. delete authData[key];
  12478. }
  12479. }
  12480. }
  12481. /**
  12482. * Unlinks a user from a service.
  12483. *
  12484. * @param {string | AuthProvider} provider Name of auth provider or {@link https://parseplatform.org/Parse-SDK-JS/api/master/AuthProvider.html AuthProvider}
  12485. * @param {object} options MasterKey / SessionToken
  12486. * @returns {Promise} A promise that is fulfilled when the unlinking
  12487. * finishes.
  12488. */
  12489. _unlinkFrom(provider, options) {
  12490. return this.linkWith(provider, {
  12491. authData: null
  12492. }, options).then(() => {
  12493. this._synchronizeAuthData(provider);
  12494. return _promise.default.resolve(this);
  12495. });
  12496. }
  12497. /**
  12498. * Checks whether a user is linked to a service.
  12499. *
  12500. * @param {object} provider service to link to
  12501. * @returns {boolean} true if link was successful
  12502. */
  12503. _isLinked(provider) {
  12504. let authType;
  12505. if (typeof provider === 'string') {
  12506. authType = provider;
  12507. } else {
  12508. authType = provider.getAuthType();
  12509. }
  12510. const authData = this.get('authData') || {};
  12511. if (typeof authData !== 'object') {
  12512. return false;
  12513. }
  12514. return !!authData[authType];
  12515. }
  12516. /**
  12517. * Deauthenticates all providers.
  12518. */
  12519. _logOutWithAll() {
  12520. const authData = this.get('authData');
  12521. if (typeof authData !== 'object') {
  12522. return;
  12523. }
  12524. for (const key in authData) {
  12525. this._logOutWith(key);
  12526. }
  12527. }
  12528. /**
  12529. * Deauthenticates a single provider (e.g. removing access tokens from the
  12530. * Facebook SDK).
  12531. *
  12532. * @param {object} provider service to logout of
  12533. */
  12534. _logOutWith(provider) {
  12535. if (!this.isCurrent()) {
  12536. return;
  12537. }
  12538. if (typeof provider === 'string') {
  12539. provider = authProviders[provider];
  12540. }
  12541. if (provider && provider.deauthenticate) {
  12542. provider.deauthenticate();
  12543. }
  12544. }
  12545. /**
  12546. * Class instance method used to maintain specific keys when a fetch occurs.
  12547. * Used to ensure that the session token is not lost.
  12548. *
  12549. * @returns {object} sessionToken
  12550. */
  12551. _preserveFieldsOnFetch() {
  12552. return {
  12553. sessionToken: this.get('sessionToken')
  12554. };
  12555. }
  12556. /**
  12557. * Returns true if <code>current</code> would return this user.
  12558. *
  12559. * @returns {boolean} true if user is cached on disk
  12560. */
  12561. isCurrent() {
  12562. const current = ParseUser.current();
  12563. return !!current && current.id === this.id;
  12564. }
  12565. /**
  12566. * Returns true if <code>current</code> would return this user.
  12567. *
  12568. * @returns {Promise<boolean>} true if user is cached on disk
  12569. */
  12570. async isCurrentAsync() {
  12571. const current = await ParseUser.currentAsync();
  12572. return !!current && current.id === this.id;
  12573. }
  12574. stripAnonymity() {
  12575. const authData = this.get('authData');
  12576. if (authData && typeof authData === 'object' && authData.hasOwnProperty('anonymous')) {
  12577. // We need to set anonymous to null instead of deleting it in order to remove it from Parse.
  12578. authData.anonymous = null;
  12579. }
  12580. }
  12581. restoreAnonimity(anonymousData) {
  12582. if (anonymousData) {
  12583. const authData = this.get('authData');
  12584. authData.anonymous = anonymousData;
  12585. }
  12586. }
  12587. /**
  12588. * Returns get("username").
  12589. *
  12590. * @returns {string}
  12591. */
  12592. getUsername() {
  12593. const username = this.get('username');
  12594. if (username == null || typeof username === 'string') {
  12595. return username;
  12596. }
  12597. return '';
  12598. }
  12599. /**
  12600. * Calls set("username", username, options) and returns the result.
  12601. *
  12602. * @param {string} username
  12603. */
  12604. setUsername(username) {
  12605. this.stripAnonymity();
  12606. this.set('username', username);
  12607. }
  12608. /**
  12609. * Calls set("password", password, options) and returns the result.
  12610. *
  12611. * @param {string} password User's Password
  12612. */
  12613. setPassword(password) {
  12614. this.set('password', password);
  12615. }
  12616. /**
  12617. * Returns get("email").
  12618. *
  12619. * @returns {string} User's Email
  12620. */
  12621. getEmail() {
  12622. const email = this.get('email');
  12623. if (email == null || typeof email === 'string') {
  12624. return email;
  12625. }
  12626. return '';
  12627. }
  12628. /**
  12629. * Calls set("email", email) and returns the result.
  12630. *
  12631. * @param {string} email
  12632. * @returns {boolean}
  12633. */
  12634. setEmail(email) {
  12635. return this.set('email', email);
  12636. }
  12637. /**
  12638. * Returns the session token for this user, if the user has been logged in,
  12639. * or if it is the result of a query with the master key. Otherwise, returns
  12640. * undefined.
  12641. *
  12642. * @returns {string} the session token, or undefined
  12643. */
  12644. getSessionToken() {
  12645. const token = this.get('sessionToken');
  12646. if (token == null || typeof token === 'string') {
  12647. return token;
  12648. }
  12649. return '';
  12650. }
  12651. /**
  12652. * Checks whether this user is the current user and has been authenticated.
  12653. *
  12654. * @returns {boolean} whether this user is the current user and is logged in.
  12655. */
  12656. authenticated() {
  12657. const current = ParseUser.current();
  12658. return !!this.get('sessionToken') && !!current && current.id === this.id;
  12659. }
  12660. /**
  12661. * Signs up a new user. You should call this instead of save for
  12662. * new Parse.Users. This will create a new Parse.User on the server, and
  12663. * also persist the session on disk so that you can access the user using
  12664. * <code>current</code>.
  12665. *
  12666. * <p>A username and password must be set before calling signUp.</p>
  12667. *
  12668. * @param {object} attrs Extra fields to set on the new user, or null.
  12669. * @param {object} options
  12670. * @returns {Promise} A promise that is fulfilled when the signup
  12671. * finishes.
  12672. */
  12673. signUp(attrs, options) {
  12674. options = options || {};
  12675. const signupOptions = {};
  12676. if (options.hasOwnProperty('useMasterKey')) {
  12677. signupOptions.useMasterKey = options.useMasterKey;
  12678. }
  12679. if (options.hasOwnProperty('installationId')) {
  12680. signupOptions.installationId = options.installationId;
  12681. }
  12682. if (options.hasOwnProperty('context') && Object.prototype.toString.call(options.context) === '[object Object]') {
  12683. signupOptions.context = options.context;
  12684. }
  12685. const controller = _CoreManager.default.getUserController();
  12686. return controller.signUp(this, attrs, signupOptions);
  12687. }
  12688. /**
  12689. * Logs in a Parse.User. On success, this saves the session to disk,
  12690. * so you can retrieve the currently logged in user using
  12691. * <code>current</code>.
  12692. *
  12693. * <p>A username and password must be set before calling logIn.</p>
  12694. *
  12695. * @param {object} options
  12696. * @returns {Promise} A promise that is fulfilled with the user when
  12697. * the login is complete.
  12698. */
  12699. logIn() {
  12700. let options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
  12701. options = options || {};
  12702. const loginOptions = {
  12703. usePost: true
  12704. };
  12705. if (options.hasOwnProperty('useMasterKey')) {
  12706. loginOptions.useMasterKey = options.useMasterKey;
  12707. }
  12708. if (options.hasOwnProperty('installationId')) {
  12709. loginOptions.installationId = options.installationId;
  12710. }
  12711. if (options.hasOwnProperty('usePost')) {
  12712. loginOptions.usePost = options.usePost;
  12713. }
  12714. if (options.hasOwnProperty('context') && Object.prototype.toString.call(options.context) === '[object Object]') {
  12715. loginOptions.context = options.context;
  12716. }
  12717. const controller = _CoreManager.default.getUserController();
  12718. return controller.logIn(this, loginOptions);
  12719. }
  12720. /**
  12721. * Wrap the default save behavior with functionality to save to local
  12722. * storage if this is current user.
  12723. *
  12724. * @param {...any} args
  12725. * @returns {Promise}
  12726. */
  12727. async save() {
  12728. for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
  12729. args[_key] = arguments[_key];
  12730. }
  12731. await super.save.apply(this, args);
  12732. const current = await this.isCurrentAsync();
  12733. if (current) {
  12734. return _CoreManager.default.getUserController().updateUserOnDisk(this);
  12735. }
  12736. return this;
  12737. }
  12738. /**
  12739. * Wrap the default destroy behavior with functionality that logs out
  12740. * the current user when it is destroyed
  12741. *
  12742. * @param {...any} args
  12743. * @returns {Parse.User}
  12744. */
  12745. async destroy() {
  12746. for (var _len2 = arguments.length, args = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
  12747. args[_key2] = arguments[_key2];
  12748. }
  12749. await super.destroy.apply(this, args);
  12750. const current = await this.isCurrentAsync();
  12751. if (current) {
  12752. return _CoreManager.default.getUserController().removeUserFromDisk();
  12753. }
  12754. return this;
  12755. }
  12756. /**
  12757. * Wrap the default fetch behavior with functionality to save to local
  12758. * storage if this is current user.
  12759. *
  12760. * @param {...any} args
  12761. * @returns {Parse.User}
  12762. */
  12763. async fetch() {
  12764. for (var _len3 = arguments.length, args = new Array(_len3), _key3 = 0; _key3 < _len3; _key3++) {
  12765. args[_key3] = arguments[_key3];
  12766. }
  12767. await super.fetch.apply(this, args);
  12768. const current = await this.isCurrentAsync();
  12769. if (current) {
  12770. return _CoreManager.default.getUserController().updateUserOnDisk(this);
  12771. }
  12772. return this;
  12773. }
  12774. /**
  12775. * Wrap the default fetchWithInclude behavior with functionality to save to local
  12776. * storage if this is current user.
  12777. *
  12778. * @param {...any} args
  12779. * @returns {Parse.User}
  12780. */
  12781. async fetchWithInclude() {
  12782. for (var _len4 = arguments.length, args = new Array(_len4), _key4 = 0; _key4 < _len4; _key4++) {
  12783. args[_key4] = arguments[_key4];
  12784. }
  12785. await super.fetchWithInclude.apply(this, args);
  12786. const current = await this.isCurrentAsync();
  12787. if (current) {
  12788. return _CoreManager.default.getUserController().updateUserOnDisk(this);
  12789. }
  12790. return this;
  12791. }
  12792. /**
  12793. * Verify whether a given password is the password of the current user.
  12794. *
  12795. * @param {string} password The password to be verified.
  12796. * @param {object} options The options.
  12797. * @param {boolean} [options.ignoreEmailVerification] Set to `true` to bypass email verification and verify
  12798. * the password regardless of whether the email has been verified. This requires the master key.
  12799. * @returns {Promise} A promise that is fulfilled with a user when the password is correct.
  12800. */
  12801. verifyPassword(password, options) {
  12802. const username = this.getUsername() || '';
  12803. return ParseUser.verifyPassword(username, password, options);
  12804. }
  12805. static readOnlyAttributes() {
  12806. return ['sessionToken'];
  12807. }
  12808. /**
  12809. * Adds functionality to the existing Parse.User class.
  12810. *
  12811. * @param {object} protoProps A set of properties to add to the prototype
  12812. * @param {object} classProps A set of static properties to add to the class
  12813. * @static
  12814. * @returns {Parse.User} The newly extended Parse.User class
  12815. */
  12816. static extend(protoProps, classProps) {
  12817. if (protoProps) {
  12818. for (const prop in protoProps) {
  12819. if (prop !== 'className') {
  12820. (0, _defineProperty.default)(ParseUser.prototype, prop, {
  12821. value: protoProps[prop],
  12822. enumerable: false,
  12823. writable: true,
  12824. configurable: true
  12825. });
  12826. }
  12827. }
  12828. }
  12829. if (classProps) {
  12830. for (const prop in classProps) {
  12831. if (prop !== 'className') {
  12832. (0, _defineProperty.default)(ParseUser, prop, {
  12833. value: classProps[prop],
  12834. enumerable: false,
  12835. writable: true,
  12836. configurable: true
  12837. });
  12838. }
  12839. }
  12840. }
  12841. return ParseUser;
  12842. }
  12843. /**
  12844. * Retrieves the currently logged in ParseUser with a valid session,
  12845. * either from memory or localStorage, if necessary.
  12846. *
  12847. * @static
  12848. * @returns {Parse.Object} The currently logged in Parse.User.
  12849. */
  12850. static current() {
  12851. if (!canUseCurrentUser) {
  12852. return null;
  12853. }
  12854. const controller = _CoreManager.default.getUserController();
  12855. return controller.currentUser();
  12856. }
  12857. /**
  12858. * Retrieves the currently logged in ParseUser from asynchronous Storage.
  12859. *
  12860. * @static
  12861. * @returns {Promise} A Promise that is resolved with the currently
  12862. * logged in Parse User
  12863. */
  12864. static currentAsync() {
  12865. if (!canUseCurrentUser) {
  12866. return _promise.default.resolve(null);
  12867. }
  12868. const controller = _CoreManager.default.getUserController();
  12869. return controller.currentUserAsync();
  12870. }
  12871. /**
  12872. * Signs up a new user with a username (or email) and password.
  12873. * This will create a new Parse.User on the server, and also persist the
  12874. * session in localStorage so that you can access the user using
  12875. * {@link #current}.
  12876. *
  12877. * @param {string} username The username (or email) to sign up with.
  12878. * @param {string} password The password to sign up with.
  12879. * @param {object} attrs Extra fields to set on the new user.
  12880. * @param {object} options
  12881. * @static
  12882. * @returns {Promise} A promise that is fulfilled with the user when
  12883. * the signup completes.
  12884. */
  12885. static signUp(username, password, attrs, options) {
  12886. attrs = attrs || {};
  12887. attrs.username = username;
  12888. attrs.password = password;
  12889. const user = new this(attrs);
  12890. return user.signUp({}, options);
  12891. }
  12892. /**
  12893. * Logs in a user with a username (or email) and password. On success, this
  12894. * saves the session to disk, so you can retrieve the currently logged in
  12895. * user using <code>current</code>.
  12896. *
  12897. * @param {string} username The username (or email) to log in with.
  12898. * @param {string} password The password to log in with.
  12899. * @param {object} options
  12900. * @static
  12901. * @returns {Promise} A promise that is fulfilled with the user when
  12902. * the login completes.
  12903. */
  12904. static logIn(username, password, options) {
  12905. if (typeof username !== 'string') {
  12906. return _promise.default.reject(new _ParseError.default(_ParseError.default.OTHER_CAUSE, 'Username must be a string.'));
  12907. } else if (typeof password !== 'string') {
  12908. return _promise.default.reject(new _ParseError.default(_ParseError.default.OTHER_CAUSE, 'Password must be a string.'));
  12909. }
  12910. const user = new this();
  12911. user._finishFetch({
  12912. username: username,
  12913. password: password
  12914. });
  12915. return user.logIn(options);
  12916. }
  12917. /**
  12918. * Logs in a user with a username (or email) and password, and authData. On success, this
  12919. * saves the session to disk, so you can retrieve the currently logged in
  12920. * user using <code>current</code>.
  12921. *
  12922. * @param {string} username The username (or email) to log in with.
  12923. * @param {string} password The password to log in with.
  12924. * @param {object} authData The authData to log in with.
  12925. * @param {object} options
  12926. * @static
  12927. * @returns {Promise} A promise that is fulfilled with the user when
  12928. * the login completes.
  12929. */
  12930. static logInWithAdditionalAuth(username, password, authData, options) {
  12931. if (typeof username !== 'string') {
  12932. return _promise.default.reject(new _ParseError.default(_ParseError.default.OTHER_CAUSE, 'Username must be a string.'));
  12933. }
  12934. if (typeof password !== 'string') {
  12935. return _promise.default.reject(new _ParseError.default(_ParseError.default.OTHER_CAUSE, 'Password must be a string.'));
  12936. }
  12937. if (Object.prototype.toString.call(authData) !== '[object Object]') {
  12938. return _promise.default.reject(new _ParseError.default(_ParseError.default.OTHER_CAUSE, 'Auth must be an object.'));
  12939. }
  12940. const user = new this();
  12941. user._finishFetch({
  12942. username: username,
  12943. password: password,
  12944. authData
  12945. });
  12946. return user.logIn(options);
  12947. }
  12948. /**
  12949. * Logs in a user with an objectId. On success, this saves the session
  12950. * to disk, so you can retrieve the currently logged in user using
  12951. * <code>current</code>.
  12952. *
  12953. * @param {string} userId The objectId for the user.
  12954. * @static
  12955. * @returns {Promise} A promise that is fulfilled with the user when
  12956. * the login completes.
  12957. */
  12958. static loginAs(userId) {
  12959. if (!userId) {
  12960. throw new _ParseError.default(_ParseError.default.USERNAME_MISSING, 'Cannot log in as user with an empty user id');
  12961. }
  12962. const controller = _CoreManager.default.getUserController();
  12963. const user = new this();
  12964. return controller.loginAs(user, userId);
  12965. }
  12966. /**
  12967. * Logs in a user with a session token. On success, this saves the session
  12968. * to disk, so you can retrieve the currently logged in user using
  12969. * <code>current</code>.
  12970. *
  12971. * @param {string} sessionToken The sessionToken to log in with.
  12972. * @param {object} options
  12973. * @static
  12974. * @returns {Promise} A promise that is fulfilled with the user when
  12975. * the login completes.
  12976. */
  12977. static become(sessionToken, options) {
  12978. if (!canUseCurrentUser) {
  12979. throw new Error('It is not memory-safe to become a user in a server environment');
  12980. }
  12981. options = options || {};
  12982. const becomeOptions = {
  12983. sessionToken: sessionToken
  12984. };
  12985. if (options.hasOwnProperty('useMasterKey')) {
  12986. becomeOptions.useMasterKey = options.useMasterKey;
  12987. }
  12988. const controller = _CoreManager.default.getUserController();
  12989. const user = new this();
  12990. return controller.become(user, becomeOptions);
  12991. }
  12992. /**
  12993. * Retrieves a user with a session token.
  12994. *
  12995. * @param {string} sessionToken The sessionToken to get user with.
  12996. * @param {object} options
  12997. * @static
  12998. * @returns {Promise} A promise that is fulfilled with the user is fetched.
  12999. */
  13000. static me(sessionToken) {
  13001. let options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
  13002. const controller = _CoreManager.default.getUserController();
  13003. const meOptions = {
  13004. sessionToken: sessionToken
  13005. };
  13006. if (options.useMasterKey) {
  13007. meOptions.useMasterKey = options.useMasterKey;
  13008. }
  13009. const user = new this();
  13010. return controller.me(user, meOptions);
  13011. }
  13012. /**
  13013. * Logs in a user with a session token. On success, this saves the session
  13014. * to disk, so you can retrieve the currently logged in user using
  13015. * <code>current</code>. If there is no session token the user will not logged in.
  13016. *
  13017. * @param {object} userJSON The JSON map of the User's data
  13018. * @static
  13019. * @returns {Promise} A promise that is fulfilled with the user when
  13020. * the login completes.
  13021. */
  13022. static hydrate(userJSON) {
  13023. const controller = _CoreManager.default.getUserController();
  13024. const user = new this();
  13025. return controller.hydrate(user, userJSON);
  13026. }
  13027. /**
  13028. * Static version of {@link https://parseplatform.org/Parse-SDK-JS/api/master/Parse.User.html#linkWith linkWith}
  13029. *
  13030. * @param provider
  13031. * @param options
  13032. * @param {object} [options.authData]
  13033. * @param saveOpts
  13034. * @static
  13035. * @returns {Promise}
  13036. */
  13037. static logInWith(provider, options, saveOpts) {
  13038. const user = new this();
  13039. return user.linkWith(provider, options, saveOpts);
  13040. }
  13041. /**
  13042. * Logs out the currently logged in user session. This will remove the
  13043. * session from disk, log out of linked services, and future calls to
  13044. * <code>current</code> will return <code>null</code>.
  13045. *
  13046. * @param {object} options
  13047. * @static
  13048. * @returns {Promise} A promise that is resolved when the session is
  13049. * destroyed on the server.
  13050. */
  13051. static logOut() {
  13052. let options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
  13053. const controller = _CoreManager.default.getUserController();
  13054. return controller.logOut(options);
  13055. }
  13056. /**
  13057. * Requests a password reset email to be sent to the specified email address
  13058. * associated with the user account. This email allows the user to securely
  13059. * reset their password on the Parse site.
  13060. *
  13061. * @param {string} email The email address associated with the user that
  13062. * forgot their password.
  13063. * @param {object} options
  13064. * @static
  13065. * @returns {Promise}
  13066. */
  13067. static requestPasswordReset(email, options) {
  13068. options = options || {};
  13069. const requestOptions = {};
  13070. if (options.hasOwnProperty('useMasterKey')) {
  13071. requestOptions.useMasterKey = options.useMasterKey;
  13072. }
  13073. const controller = _CoreManager.default.getUserController();
  13074. return controller.requestPasswordReset(email, requestOptions);
  13075. }
  13076. /**
  13077. * Request an email verification.
  13078. *
  13079. * @param {string} email The email address associated with the user that
  13080. * needs to verify their email.
  13081. * @param {object} options
  13082. * @static
  13083. * @returns {Promise}
  13084. */
  13085. static requestEmailVerification(email, options) {
  13086. options = options || {};
  13087. const requestOptions = {};
  13088. if (options.hasOwnProperty('useMasterKey')) {
  13089. requestOptions.useMasterKey = options.useMasterKey;
  13090. }
  13091. const controller = _CoreManager.default.getUserController();
  13092. return controller.requestEmailVerification(email, requestOptions);
  13093. }
  13094. /**
  13095. * Verify whether a given password is the password of the current user.
  13096. * @static
  13097. *
  13098. * @param {string} username The username of the user whose password should be verified.
  13099. * @param {string} password The password to be verified.
  13100. * @param {object} options The options.
  13101. * @param {boolean} [options.ignoreEmailVerification] Set to `true` to bypass email verification and verify
  13102. * the password regardless of whether the email has been verified. This requires the master key.
  13103. * @returns {Promise} A promise that is fulfilled with a user when the password is correct.
  13104. */
  13105. static verifyPassword(username, password, options) {
  13106. if (typeof username !== 'string') {
  13107. return _promise.default.reject(new _ParseError.default(_ParseError.default.OTHER_CAUSE, 'Username must be a string.'));
  13108. }
  13109. if (typeof password !== 'string') {
  13110. return _promise.default.reject(new _ParseError.default(_ParseError.default.OTHER_CAUSE, 'Password must be a string.'));
  13111. }
  13112. const controller = _CoreManager.default.getUserController();
  13113. return controller.verifyPassword(username, password, options || {});
  13114. }
  13115. /**
  13116. * Allow someone to define a custom User class without className
  13117. * being rewritten to _User. The default behavior is to rewrite
  13118. * User to _User for legacy reasons. This allows developers to
  13119. * override that behavior.
  13120. *
  13121. * @param {boolean} isAllowed Whether or not to allow custom User class
  13122. * @static
  13123. */
  13124. static allowCustomUserClass(isAllowed) {
  13125. _CoreManager.default.set('PERFORM_USER_REWRITE', !isAllowed);
  13126. }
  13127. /**
  13128. * Allows a legacy application to start using revocable sessions. If the
  13129. * current session token is not revocable, a request will be made for a new,
  13130. * revocable session.
  13131. * It is not necessary to call this method from cloud code unless you are
  13132. * handling user signup or login from the server side. In a cloud code call,
  13133. * this function will not attempt to upgrade the current token.
  13134. *
  13135. * @param {object} options
  13136. * @static
  13137. * @returns {Promise} A promise that is resolved when the process has
  13138. * completed. If a replacement session token is requested, the promise
  13139. * will be resolved after a new token has been fetched.
  13140. */
  13141. static enableRevocableSession(options) {
  13142. options = options || {};
  13143. _CoreManager.default.set('FORCE_REVOCABLE_SESSION', true);
  13144. if (canUseCurrentUser) {
  13145. const current = ParseUser.current();
  13146. if (current) {
  13147. return current._upgradeToRevocableSession(options);
  13148. }
  13149. }
  13150. return _promise.default.resolve();
  13151. }
  13152. /**
  13153. * Enables the use of become or the current user in a server
  13154. * environment. These features are disabled by default, since they depend on
  13155. * global objects that are not memory-safe for most servers.
  13156. *
  13157. * @static
  13158. */
  13159. static enableUnsafeCurrentUser() {
  13160. canUseCurrentUser = true;
  13161. }
  13162. /**
  13163. * Disables the use of become or the current user in any environment.
  13164. * These features are disabled on servers by default, since they depend on
  13165. * global objects that are not memory-safe for most servers.
  13166. *
  13167. * @static
  13168. */
  13169. static disableUnsafeCurrentUser() {
  13170. canUseCurrentUser = false;
  13171. }
  13172. /**
  13173. * When registering users with {@link https://parseplatform.org/Parse-SDK-JS/api/master/Parse.User.html#linkWith linkWith} a basic auth provider
  13174. * is automatically created for you.
  13175. *
  13176. * For advanced authentication, you can register an Auth provider to
  13177. * implement custom authentication, deauthentication.
  13178. *
  13179. * @param provider
  13180. * @see {@link https://parseplatform.org/Parse-SDK-JS/api/master/AuthProvider.html AuthProvider}
  13181. * @see {@link https://docs.parseplatform.org/js/guide/#custom-authentication-module Custom Authentication Module}
  13182. * @static
  13183. */
  13184. static _registerAuthenticationProvider(provider) {
  13185. authProviders[provider.getAuthType()] = provider;
  13186. // Synchronize the current user with the auth provider.
  13187. ParseUser.currentAsync().then(current => {
  13188. if (current) {
  13189. current._synchronizeAuthData(provider.getAuthType());
  13190. }
  13191. });
  13192. }
  13193. /**
  13194. * @param provider
  13195. * @param options
  13196. * @param {object} [options.authData]
  13197. * @param saveOpts
  13198. * @deprecated since 2.9.0 see {@link https://parseplatform.org/Parse-SDK-JS/api/master/Parse.User.html#logInWith logInWith}
  13199. * @static
  13200. * @returns {Promise}
  13201. */
  13202. static _logInWith(provider, options, saveOpts) {
  13203. const user = new this();
  13204. return user.linkWith(provider, options, saveOpts);
  13205. }
  13206. static _clearCache() {
  13207. currentUserCache = null;
  13208. currentUserCacheMatchesDisk = false;
  13209. }
  13210. static _setCurrentUserCache(user) {
  13211. currentUserCache = user;
  13212. }
  13213. }
  13214. _ParseObject.default.registerSubclass('_User', ParseUser);
  13215. const DefaultController = {
  13216. updateUserOnDisk(user) {
  13217. const path = _Storage.default.generatePath(CURRENT_USER_KEY);
  13218. const json = user.toJSON();
  13219. delete json.password;
  13220. json.className = '_User';
  13221. let userData = (0, _stringify.default)(json);
  13222. if (_CoreManager.default.get('ENCRYPTED_USER')) {
  13223. const crypto = _CoreManager.default.getCryptoController();
  13224. userData = crypto.encrypt(json, _CoreManager.default.get('ENCRYPTED_KEY'));
  13225. }
  13226. return _Storage.default.setItemAsync(path, userData).then(() => {
  13227. return user;
  13228. });
  13229. },
  13230. removeUserFromDisk() {
  13231. const path = _Storage.default.generatePath(CURRENT_USER_KEY);
  13232. currentUserCacheMatchesDisk = true;
  13233. currentUserCache = null;
  13234. return _Storage.default.removeItemAsync(path);
  13235. },
  13236. setCurrentUser(user) {
  13237. currentUserCache = user;
  13238. user._cleanupAuthData();
  13239. user._synchronizeAllAuthData();
  13240. return DefaultController.updateUserOnDisk(user);
  13241. },
  13242. currentUser() {
  13243. if (currentUserCache) {
  13244. return currentUserCache;
  13245. }
  13246. if (currentUserCacheMatchesDisk) {
  13247. return null;
  13248. }
  13249. if (_Storage.default.async()) {
  13250. throw new Error('Cannot call currentUser() when using a platform with an async ' + 'storage system. Call currentUserAsync() instead.');
  13251. }
  13252. const path = _Storage.default.generatePath(CURRENT_USER_KEY);
  13253. let userData = _Storage.default.getItem(path);
  13254. currentUserCacheMatchesDisk = true;
  13255. if (!userData) {
  13256. currentUserCache = null;
  13257. return null;
  13258. }
  13259. if (_CoreManager.default.get('ENCRYPTED_USER')) {
  13260. const crypto = _CoreManager.default.getCryptoController();
  13261. userData = crypto.decrypt(userData, _CoreManager.default.get('ENCRYPTED_KEY'));
  13262. }
  13263. userData = JSON.parse(userData);
  13264. if (!userData.className) {
  13265. userData.className = '_User';
  13266. }
  13267. if (userData._id) {
  13268. if (userData.objectId !== userData._id) {
  13269. userData.objectId = userData._id;
  13270. }
  13271. delete userData._id;
  13272. }
  13273. if (userData._sessionToken) {
  13274. userData.sessionToken = userData._sessionToken;
  13275. delete userData._sessionToken;
  13276. }
  13277. const current = _ParseObject.default.fromJSON(userData);
  13278. currentUserCache = current;
  13279. current._synchronizeAllAuthData();
  13280. return current;
  13281. },
  13282. currentUserAsync() {
  13283. if (currentUserCache) {
  13284. return _promise.default.resolve(currentUserCache);
  13285. }
  13286. if (currentUserCacheMatchesDisk) {
  13287. return _promise.default.resolve(null);
  13288. }
  13289. const path = _Storage.default.generatePath(CURRENT_USER_KEY);
  13290. return _Storage.default.getItemAsync(path).then(userData => {
  13291. currentUserCacheMatchesDisk = true;
  13292. if (!userData) {
  13293. currentUserCache = null;
  13294. return _promise.default.resolve(null);
  13295. }
  13296. if (_CoreManager.default.get('ENCRYPTED_USER')) {
  13297. const crypto = _CoreManager.default.getCryptoController();
  13298. userData = crypto.decrypt(userData.toString(), _CoreManager.default.get('ENCRYPTED_KEY'));
  13299. }
  13300. userData = JSON.parse(userData);
  13301. if (!userData.className) {
  13302. userData.className = '_User';
  13303. }
  13304. if (userData._id) {
  13305. if (userData.objectId !== userData._id) {
  13306. userData.objectId = userData._id;
  13307. }
  13308. delete userData._id;
  13309. }
  13310. if (userData._sessionToken) {
  13311. userData.sessionToken = userData._sessionToken;
  13312. delete userData._sessionToken;
  13313. }
  13314. const current = _ParseObject.default.fromJSON(userData);
  13315. currentUserCache = current;
  13316. current._synchronizeAllAuthData();
  13317. return _promise.default.resolve(current);
  13318. });
  13319. },
  13320. signUp(user, attrs, options) {
  13321. const username = attrs && attrs.username || user.get('username');
  13322. const password = attrs && attrs.password || user.get('password');
  13323. if (!username || !username.length) {
  13324. return _promise.default.reject(new _ParseError.default(_ParseError.default.OTHER_CAUSE, 'Cannot sign up user with an empty username.'));
  13325. }
  13326. if (!password || !password.length) {
  13327. return _promise.default.reject(new _ParseError.default(_ParseError.default.OTHER_CAUSE, 'Cannot sign up user with an empty password.'));
  13328. }
  13329. return user.save(attrs, options).then(() => {
  13330. // Clear the password field
  13331. user._finishFetch({
  13332. password: undefined
  13333. });
  13334. if (canUseCurrentUser) {
  13335. return DefaultController.setCurrentUser(user);
  13336. }
  13337. return user;
  13338. });
  13339. },
  13340. logIn(user, options) {
  13341. const RESTController = _CoreManager.default.getRESTController();
  13342. const stateController = _CoreManager.default.getObjectStateController();
  13343. const auth = {
  13344. username: user.get('username'),
  13345. password: user.get('password'),
  13346. authData: user.get('authData')
  13347. };
  13348. return RESTController.request(options.usePost ? 'POST' : 'GET', 'login', auth, options).then(response => {
  13349. user._migrateId(response.objectId);
  13350. user._setExisted(true);
  13351. stateController.setPendingOp(user._getStateIdentifier(), 'username', undefined);
  13352. stateController.setPendingOp(user._getStateIdentifier(), 'password', undefined);
  13353. response.password = undefined;
  13354. user._finishFetch(response);
  13355. if (!canUseCurrentUser) {
  13356. // We can't set the current user, so just return the one we logged in
  13357. return _promise.default.resolve(user);
  13358. }
  13359. return DefaultController.setCurrentUser(user);
  13360. });
  13361. },
  13362. loginAs(user, userId) {
  13363. const RESTController = _CoreManager.default.getRESTController();
  13364. return RESTController.request('POST', 'loginAs', {
  13365. userId
  13366. }, {
  13367. useMasterKey: true
  13368. }).then(response => {
  13369. user._finishFetch(response);
  13370. user._setExisted(true);
  13371. if (!canUseCurrentUser) {
  13372. return _promise.default.resolve(user);
  13373. }
  13374. return DefaultController.setCurrentUser(user);
  13375. });
  13376. },
  13377. become(user, options) {
  13378. const RESTController = _CoreManager.default.getRESTController();
  13379. return RESTController.request('GET', 'users/me', {}, options).then(response => {
  13380. user._finishFetch(response);
  13381. user._setExisted(true);
  13382. return DefaultController.setCurrentUser(user);
  13383. });
  13384. },
  13385. hydrate(user, userJSON) {
  13386. user._finishFetch(userJSON);
  13387. user._setExisted(true);
  13388. if (userJSON.sessionToken && canUseCurrentUser) {
  13389. return DefaultController.setCurrentUser(user);
  13390. } else {
  13391. return _promise.default.resolve(user);
  13392. }
  13393. },
  13394. me(user, options) {
  13395. const RESTController = _CoreManager.default.getRESTController();
  13396. return RESTController.request('GET', 'users/me', {}, options).then(response => {
  13397. user._finishFetch(response);
  13398. user._setExisted(true);
  13399. return user;
  13400. });
  13401. },
  13402. logOut(options) {
  13403. const RESTController = _CoreManager.default.getRESTController();
  13404. if (options.sessionToken) {
  13405. return RESTController.request('POST', 'logout', {}, options);
  13406. }
  13407. return DefaultController.currentUserAsync().then(currentUser => {
  13408. const path = _Storage.default.generatePath(CURRENT_USER_KEY);
  13409. let promise = _Storage.default.removeItemAsync(path);
  13410. if (currentUser !== null) {
  13411. const currentSession = currentUser.getSessionToken();
  13412. if (currentSession && (0, _isRevocableSession.default)(currentSession)) {
  13413. promise = promise.then(() => {
  13414. return RESTController.request('POST', 'logout', {}, {
  13415. sessionToken: currentSession
  13416. });
  13417. });
  13418. }
  13419. currentUser._logOutWithAll();
  13420. currentUser._finishFetch({
  13421. sessionToken: undefined
  13422. });
  13423. }
  13424. currentUserCacheMatchesDisk = true;
  13425. currentUserCache = null;
  13426. return promise;
  13427. });
  13428. },
  13429. requestPasswordReset(email, options) {
  13430. const RESTController = _CoreManager.default.getRESTController();
  13431. return RESTController.request('POST', 'requestPasswordReset', {
  13432. email: email
  13433. }, options);
  13434. },
  13435. async upgradeToRevocableSession(user, options) {
  13436. const token = user.getSessionToken();
  13437. if (!token) {
  13438. return _promise.default.reject(new _ParseError.default(_ParseError.default.SESSION_MISSING, 'Cannot upgrade a user with no session token'));
  13439. }
  13440. options.sessionToken = token;
  13441. const RESTController = _CoreManager.default.getRESTController();
  13442. const result = await RESTController.request('POST', 'upgradeToRevocableSession', {}, options);
  13443. user._finishFetch({
  13444. sessionToken: result?.sessionToken || ''
  13445. });
  13446. const current = await user.isCurrentAsync();
  13447. if (current) {
  13448. return DefaultController.setCurrentUser(user);
  13449. }
  13450. return _promise.default.resolve(user);
  13451. },
  13452. linkWith(user, authData, options) {
  13453. return user.save({
  13454. authData
  13455. }, options).then(() => {
  13456. if (canUseCurrentUser) {
  13457. return DefaultController.setCurrentUser(user);
  13458. }
  13459. return user;
  13460. });
  13461. },
  13462. verifyPassword(username, password, options) {
  13463. const RESTController = _CoreManager.default.getRESTController();
  13464. const data = {
  13465. username,
  13466. password,
  13467. ...(options.ignoreEmailVerification !== undefined && {
  13468. ignoreEmailVerification: options.ignoreEmailVerification
  13469. })
  13470. };
  13471. return RESTController.request('GET', 'verifyPassword', data, options);
  13472. },
  13473. requestEmailVerification(email, options) {
  13474. const RESTController = _CoreManager.default.getRESTController();
  13475. return RESTController.request('POST', 'verificationEmailRequest', {
  13476. email: email
  13477. }, options);
  13478. }
  13479. };
  13480. _CoreManager.default.setParseUser(ParseUser);
  13481. _CoreManager.default.setUserController(DefaultController);
  13482. var _default = exports.default = ParseUser;
  13483. },{"./CoreManager":4,"./ParseError":24,"./ParseObject":30,"./Storage":43,"./isRevocableSession":59,"@babel/runtime-corejs3/core-js-stable/json/stringify":85,"@babel/runtime-corejs3/core-js-stable/object/define-property":90,"@babel/runtime-corejs3/core-js-stable/promise":97,"@babel/runtime-corejs3/helpers/interopRequireDefault":103}],39:[function(_dereq_,module,exports){
  13484. "use strict";
  13485. var _Object$defineProperty = _dereq_("@babel/runtime-corejs3/core-js-stable/object/define-property");
  13486. var _interopRequireDefault = _dereq_("@babel/runtime-corejs3/helpers/interopRequireDefault");
  13487. _Object$defineProperty(exports, "__esModule", {
  13488. value: true
  13489. });
  13490. exports.getPushStatus = getPushStatus;
  13491. exports.send = send;
  13492. var _CoreManager = _interopRequireDefault(_dereq_("./CoreManager"));
  13493. var _ParseQuery = _interopRequireDefault(_dereq_("./ParseQuery"));
  13494. /**
  13495. * Contains functions to deal with Push in Parse.
  13496. *
  13497. * @class Parse.Push
  13498. * @static
  13499. * @hideconstructor
  13500. */
  13501. /**
  13502. * Sends a push notification.
  13503. * **Available in Cloud Code only.**
  13504. *
  13505. * See {@link https://docs.parseplatform.org/js/guide/#push-notifications Push Notification Guide}
  13506. *
  13507. * @function send
  13508. * @name Parse.Push.send
  13509. * @param {object} data - The data of the push notification. Valid fields
  13510. * are:
  13511. * <ol>
  13512. * <li>channels - An Array of channels to push to.</li>
  13513. * <li>push_time - A Date object for when to send the push.</li>
  13514. * <li>expiration_time - A Date object for when to expire
  13515. * the push.</li>
  13516. * <li>expiration_interval - The seconds from now to expire the push.</li>
  13517. * <li>where - A Parse.Query over Parse.Installation that is used to match
  13518. * a set of installations to push to.</li>
  13519. * <li>data - The data to send as part of the push.</li>
  13520. * <ol>
  13521. * @param {object} options Valid options
  13522. * are:<ul>
  13523. * <li>useMasterKey: In Cloud Code and Node only, causes the Master Key to
  13524. * be used for this request.
  13525. * </ul>
  13526. * @returns {Promise} A promise that is fulfilled when the push request
  13527. * completes and returns `pushStatusId`.
  13528. */
  13529. function send(data) {
  13530. let options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
  13531. if (data.where && data.where instanceof _ParseQuery.default) {
  13532. data.where = data.where.toJSON().where;
  13533. }
  13534. if (data.push_time && typeof data.push_time === 'object') {
  13535. data.push_time = data.push_time.toJSON();
  13536. }
  13537. if (data.expiration_time && typeof data.expiration_time === 'object') {
  13538. data.expiration_time = data.expiration_time.toJSON();
  13539. }
  13540. if (data.expiration_time && data.expiration_interval) {
  13541. throw new Error('expiration_time and expiration_interval cannot both be set.');
  13542. }
  13543. const pushOptions = {
  13544. useMasterKey: true
  13545. };
  13546. if (options.hasOwnProperty('useMasterKey')) {
  13547. pushOptions.useMasterKey = options.useMasterKey;
  13548. }
  13549. return _CoreManager.default.getPushController().send(data, pushOptions);
  13550. }
  13551. /**
  13552. * Gets push status by Id
  13553. *
  13554. * @function getPushStatus
  13555. * @name Parse.Push.getPushStatus
  13556. * @param {string} pushStatusId The Id of Push Status.
  13557. * @param {object} options Valid options
  13558. * are:<ul>
  13559. * <li>useMasterKey: In Cloud Code and Node only, causes the Master Key to
  13560. * be used for this request.
  13561. * </ul>
  13562. * @returns {Parse.Object} Status of Push.
  13563. */
  13564. function getPushStatus(pushStatusId) {
  13565. let options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
  13566. const pushOptions = {
  13567. useMasterKey: true
  13568. };
  13569. if (options.hasOwnProperty('useMasterKey')) {
  13570. pushOptions.useMasterKey = options.useMasterKey;
  13571. }
  13572. const query = new _ParseQuery.default('_PushStatus');
  13573. return query.get(pushStatusId, pushOptions);
  13574. }
  13575. const DefaultController = {
  13576. async send(data, options) {
  13577. options.returnStatus = true;
  13578. const response = await _CoreManager.default.getRESTController().request('POST', 'push', data, options);
  13579. return response._headers?.['X-Parse-Push-Status-Id'];
  13580. }
  13581. };
  13582. _CoreManager.default.setPushController(DefaultController);
  13583. },{"./CoreManager":4,"./ParseQuery":33,"@babel/runtime-corejs3/core-js-stable/object/define-property":90,"@babel/runtime-corejs3/helpers/interopRequireDefault":103}],40:[function(_dereq_,module,exports){
  13584. (function (process){(function (){
  13585. "use strict";
  13586. var _Object$defineProperty = _dereq_("@babel/runtime-corejs3/core-js-stable/object/define-property");
  13587. var _interopRequireDefault = _dereq_("@babel/runtime-corejs3/helpers/interopRequireDefault");
  13588. _Object$defineProperty(exports, "__esModule", {
  13589. value: true
  13590. });
  13591. exports.default = void 0;
  13592. var _promise = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/promise"));
  13593. var _stringify = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/json/stringify"));
  13594. var _includes = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/instance/includes"));
  13595. var _forEach = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/instance/for-each"));
  13596. var _indexOf = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/instance/index-of"));
  13597. var _setTimeout2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/set-timeout"));
  13598. var _uuid = _interopRequireDefault(_dereq_("./uuid"));
  13599. var _CoreManager = _interopRequireDefault(_dereq_("./CoreManager"));
  13600. var _ParseError = _interopRequireDefault(_dereq_("./ParseError"));
  13601. var _promiseUtils = _dereq_("./promiseUtils");
  13602. var _Xhr = _interopRequireDefault(_dereq_("./Xhr.weapp"));
  13603. /* global XMLHttpRequest, XDomainRequest */
  13604. let XHR = null;
  13605. if (typeof XMLHttpRequest !== 'undefined') {
  13606. XHR = XMLHttpRequest;
  13607. }
  13608. let useXDomainRequest = false;
  13609. // @ts-ignore
  13610. if (typeof XDomainRequest !== 'undefined' && !('withCredentials' in new XMLHttpRequest())) {
  13611. useXDomainRequest = true;
  13612. }
  13613. function ajaxIE9(method, url, data, headers, options) {
  13614. return new _promise.default((resolve, reject) => {
  13615. // @ts-ignore
  13616. const xdr = new XDomainRequest();
  13617. xdr.onload = function () {
  13618. let response;
  13619. try {
  13620. response = JSON.parse(xdr.responseText);
  13621. } catch (e) {
  13622. reject(e);
  13623. }
  13624. if (response) {
  13625. resolve({
  13626. response
  13627. });
  13628. }
  13629. };
  13630. xdr.onerror = xdr.ontimeout = function () {
  13631. // Let's fake a real error message.
  13632. const fakeResponse = {
  13633. responseText: (0, _stringify.default)({
  13634. code: _ParseError.default.X_DOMAIN_REQUEST,
  13635. error: "IE's XDomainRequest does not supply error info."
  13636. })
  13637. };
  13638. reject(fakeResponse);
  13639. };
  13640. xdr.onprogress = function () {
  13641. if (options && typeof options.progress === 'function') {
  13642. options.progress(xdr.responseText);
  13643. }
  13644. };
  13645. xdr.open(method, url);
  13646. xdr.send(data);
  13647. // @ts-ignore
  13648. if (options && typeof options.requestTask === 'function') {
  13649. // @ts-ignore
  13650. options.requestTask(xdr);
  13651. }
  13652. });
  13653. }
  13654. const RESTController = {
  13655. ajax(method, url, data, headers, options) {
  13656. var _context;
  13657. if (useXDomainRequest) {
  13658. return ajaxIE9(method, url, data, headers, options);
  13659. }
  13660. const promise = (0, _promiseUtils.resolvingPromise)();
  13661. const isIdempotent = _CoreManager.default.get('IDEMPOTENCY') && (0, _includes.default)(_context = ['POST', 'PUT']).call(_context, method);
  13662. const requestId = isIdempotent ? (0, _uuid.default)() : '';
  13663. let attempts = 0;
  13664. const dispatch = function () {
  13665. if (XHR == null) {
  13666. throw new Error('Cannot make a request: No definition of XMLHttpRequest was found.');
  13667. }
  13668. let handled = false;
  13669. const xhr = new XHR();
  13670. xhr.onreadystatechange = function () {
  13671. if (xhr.readyState !== 4 || handled || xhr._aborted) {
  13672. return;
  13673. }
  13674. handled = true;
  13675. if (xhr.status >= 200 && xhr.status < 300) {
  13676. let response;
  13677. try {
  13678. response = JSON.parse(xhr.responseText);
  13679. const availableHeaders = typeof xhr.getAllResponseHeaders === 'function' ? xhr.getAllResponseHeaders() : '';
  13680. headers = {};
  13681. if (typeof xhr.getResponseHeader === 'function' && availableHeaders?.indexOf('access-control-expose-headers') >= 0) {
  13682. const responseHeaders = xhr.getResponseHeader('access-control-expose-headers').split(', ');
  13683. (0, _forEach.default)(responseHeaders).call(responseHeaders, header => {
  13684. if ((0, _indexOf.default)(availableHeaders).call(availableHeaders, header.toLowerCase()) >= 0) {
  13685. headers[header] = xhr.getResponseHeader(header.toLowerCase());
  13686. }
  13687. });
  13688. }
  13689. } catch (e) {
  13690. promise.reject(e.toString());
  13691. }
  13692. if (response) {
  13693. promise.resolve({
  13694. response,
  13695. headers,
  13696. status: xhr.status,
  13697. xhr
  13698. });
  13699. }
  13700. } else if (xhr.status >= 500 || xhr.status === 0) {
  13701. // retry on 5XX or node-xmlhttprequest error
  13702. if (++attempts < _CoreManager.default.get('REQUEST_ATTEMPT_LIMIT')) {
  13703. // Exponentially-growing random delay
  13704. const delay = Math.round(Math.random() * 125 * Math.pow(2, attempts));
  13705. (0, _setTimeout2.default)(dispatch, delay);
  13706. } else if (xhr.status === 0) {
  13707. promise.reject('Unable to connect to the Parse API');
  13708. } else {
  13709. // After the retry limit is reached, fail
  13710. promise.reject(xhr);
  13711. }
  13712. } else {
  13713. promise.reject(xhr);
  13714. }
  13715. };
  13716. headers = headers || {};
  13717. if (typeof headers['Content-Type'] !== 'string') {
  13718. headers['Content-Type'] = 'text/plain'; // Avoid pre-flight
  13719. }
  13720. if (_CoreManager.default.get('IS_NODE')) {
  13721. headers['User-Agent'] = 'Parse/' + _CoreManager.default.get('VERSION') + ' (NodeJS ' + process.versions.node + ')';
  13722. }
  13723. if (isIdempotent) {
  13724. headers['X-Parse-Request-Id'] = requestId;
  13725. }
  13726. if (_CoreManager.default.get('SERVER_AUTH_TYPE') && _CoreManager.default.get('SERVER_AUTH_TOKEN')) {
  13727. headers['Authorization'] = _CoreManager.default.get('SERVER_AUTH_TYPE') + ' ' + _CoreManager.default.get('SERVER_AUTH_TOKEN');
  13728. }
  13729. const customHeaders = _CoreManager.default.get('REQUEST_HEADERS');
  13730. for (const key in customHeaders) {
  13731. headers[key] = customHeaders[key];
  13732. }
  13733. if (options && typeof options.progress === 'function') {
  13734. const handleProgress = function (type, event) {
  13735. if (event.lengthComputable) {
  13736. options.progress(event.loaded / event.total, event.loaded, event.total, {
  13737. type
  13738. });
  13739. } else {
  13740. options.progress(null, null, null, {
  13741. type
  13742. });
  13743. }
  13744. };
  13745. xhr.onprogress = event => {
  13746. handleProgress('download', event);
  13747. };
  13748. if (xhr.upload) {
  13749. xhr.upload.onprogress = event => {
  13750. handleProgress('upload', event);
  13751. };
  13752. }
  13753. }
  13754. xhr.open(method, url, true);
  13755. for (const h in headers) {
  13756. xhr.setRequestHeader(h, headers[h]);
  13757. }
  13758. xhr.onabort = function () {
  13759. promise.resolve({
  13760. response: {
  13761. results: []
  13762. },
  13763. status: 0,
  13764. xhr
  13765. });
  13766. };
  13767. xhr.send(data);
  13768. // @ts-ignore
  13769. if (options && typeof options.requestTask === 'function') {
  13770. // @ts-ignore
  13771. options.requestTask(xhr);
  13772. }
  13773. };
  13774. dispatch();
  13775. return promise;
  13776. },
  13777. request(method, path, data, options) {
  13778. options = options || {};
  13779. let url = _CoreManager.default.get('SERVER_URL');
  13780. if (url[url.length - 1] !== '/') {
  13781. url += '/';
  13782. }
  13783. url += path;
  13784. const payload = {};
  13785. if (data && typeof data === 'object') {
  13786. for (const k in data) {
  13787. payload[k] = data[k];
  13788. }
  13789. }
  13790. // Add context
  13791. const context = options.context;
  13792. if (context !== undefined) {
  13793. payload._context = context;
  13794. }
  13795. if (method !== 'POST') {
  13796. payload._method = method;
  13797. method = 'POST';
  13798. }
  13799. payload._ApplicationId = _CoreManager.default.get('APPLICATION_ID');
  13800. const jsKey = _CoreManager.default.get('JAVASCRIPT_KEY');
  13801. if (jsKey) {
  13802. payload._JavaScriptKey = jsKey;
  13803. }
  13804. payload._ClientVersion = _CoreManager.default.get('VERSION');
  13805. let useMasterKey = options.useMasterKey;
  13806. if (typeof useMasterKey === 'undefined') {
  13807. useMasterKey = _CoreManager.default.get('USE_MASTER_KEY');
  13808. }
  13809. if (useMasterKey) {
  13810. if (_CoreManager.default.get('MASTER_KEY')) {
  13811. delete payload._JavaScriptKey;
  13812. payload._MasterKey = _CoreManager.default.get('MASTER_KEY');
  13813. } else {
  13814. throw new Error('Cannot use the Master Key, it has not been provided.');
  13815. }
  13816. }
  13817. if (_CoreManager.default.get('FORCE_REVOCABLE_SESSION')) {
  13818. payload._RevocableSession = '1';
  13819. }
  13820. const installationId = options.installationId;
  13821. let installationIdPromise;
  13822. if (installationId && typeof installationId === 'string') {
  13823. installationIdPromise = _promise.default.resolve(installationId);
  13824. } else {
  13825. const installationController = _CoreManager.default.getInstallationController();
  13826. installationIdPromise = installationController.currentInstallationId();
  13827. }
  13828. return installationIdPromise.then(iid => {
  13829. payload._InstallationId = iid;
  13830. const userController = _CoreManager.default.getUserController();
  13831. if (options && typeof options.sessionToken === 'string') {
  13832. return _promise.default.resolve(options.sessionToken);
  13833. } else if (userController) {
  13834. return userController.currentUserAsync().then(user => {
  13835. if (user) {
  13836. return _promise.default.resolve(user.getSessionToken());
  13837. }
  13838. return _promise.default.resolve(null);
  13839. });
  13840. }
  13841. return _promise.default.resolve(null);
  13842. }).then(token => {
  13843. if (token) {
  13844. payload._SessionToken = token;
  13845. }
  13846. const payloadString = (0, _stringify.default)(payload);
  13847. return RESTController.ajax(method, url, payloadString, {}, options).then(_ref => {
  13848. let {
  13849. response,
  13850. status,
  13851. headers,
  13852. xhr
  13853. } = _ref;
  13854. if (options.returnStatus) {
  13855. return {
  13856. ...response,
  13857. _status: status,
  13858. _headers: headers,
  13859. _xhr: xhr
  13860. };
  13861. } else {
  13862. return response;
  13863. }
  13864. });
  13865. }).catch(RESTController.handleError);
  13866. },
  13867. handleError(response) {
  13868. // Transform the error into an instance of ParseError by trying to parse
  13869. // the error string as JSON
  13870. let error;
  13871. if (response && response.responseText) {
  13872. try {
  13873. const errorJSON = JSON.parse(response.responseText);
  13874. error = new _ParseError.default(errorJSON.code, errorJSON.error);
  13875. } catch (e) {
  13876. // If we fail to parse the error text, that's okay.
  13877. error = new _ParseError.default(_ParseError.default.INVALID_JSON, 'Received an error with invalid JSON from Parse: ' + response.responseText);
  13878. }
  13879. } else {
  13880. const message = response.message ? response.message : response;
  13881. error = new _ParseError.default(_ParseError.default.CONNECTION_FAILED, 'XMLHttpRequest failed: ' + (0, _stringify.default)(message));
  13882. }
  13883. return _promise.default.reject(error);
  13884. },
  13885. _setXHR(xhr) {
  13886. XHR = xhr;
  13887. },
  13888. _getXHR() {
  13889. return XHR;
  13890. }
  13891. };
  13892. module.exports = RESTController;
  13893. var _default = exports.default = RESTController;
  13894. }).call(this)}).call(this,_dereq_('_process'))
  13895. },{"./CoreManager":4,"./ParseError":24,"./Xhr.weapp":52,"./promiseUtils":61,"./uuid":64,"@babel/runtime-corejs3/core-js-stable/instance/for-each":74,"@babel/runtime-corejs3/core-js-stable/instance/includes":75,"@babel/runtime-corejs3/core-js-stable/instance/index-of":76,"@babel/runtime-corejs3/core-js-stable/json/stringify":85,"@babel/runtime-corejs3/core-js-stable/object/define-property":90,"@babel/runtime-corejs3/core-js-stable/promise":97,"@babel/runtime-corejs3/core-js-stable/set-timeout":99,"@babel/runtime-corejs3/helpers/interopRequireDefault":103,"_process":107}],41:[function(_dereq_,module,exports){
  13896. "use strict";
  13897. var _WeakMap = _dereq_("@babel/runtime-corejs3/core-js-stable/weak-map");
  13898. var _Object$defineProperty = _dereq_("@babel/runtime-corejs3/core-js-stable/object/define-property");
  13899. var _Object$getOwnPropertyDescriptor = _dereq_("@babel/runtime-corejs3/core-js-stable/object/get-own-property-descriptor");
  13900. _Object$defineProperty(exports, "__esModule", {
  13901. value: true
  13902. });
  13903. exports.clearAllState = clearAllState;
  13904. exports.commitServerChanges = commitServerChanges;
  13905. exports.duplicateState = duplicateState;
  13906. exports.enqueueTask = enqueueTask;
  13907. exports.estimateAttribute = estimateAttribute;
  13908. exports.estimateAttributes = estimateAttributes;
  13909. exports.getObjectCache = getObjectCache;
  13910. exports.getPendingOps = getPendingOps;
  13911. exports.getServerData = getServerData;
  13912. exports.getState = getState;
  13913. exports.initializeState = initializeState;
  13914. exports.mergeFirstPendingState = mergeFirstPendingState;
  13915. exports.popPendingState = popPendingState;
  13916. exports.pushPendingState = pushPendingState;
  13917. exports.removeState = removeState;
  13918. exports.setPendingOp = setPendingOp;
  13919. exports.setServerData = setServerData;
  13920. var ObjectStateMutations = _interopRequireWildcard(_dereq_("./ObjectStateMutations"));
  13921. function _getRequireWildcardCache(e) {
  13922. if ("function" != typeof _WeakMap) return null;
  13923. var r = new _WeakMap(),
  13924. t = new _WeakMap();
  13925. return (_getRequireWildcardCache = function (e) {
  13926. return e ? t : r;
  13927. })(e);
  13928. }
  13929. function _interopRequireWildcard(e, r) {
  13930. if (!r && e && e.__esModule) return e;
  13931. if (null === e || "object" != typeof e && "function" != typeof e) return {
  13932. default: e
  13933. };
  13934. var t = _getRequireWildcardCache(r);
  13935. if (t && t.has(e)) return t.get(e);
  13936. var n = {
  13937. __proto__: null
  13938. };
  13939. for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) {
  13940. var i = _Object$defineProperty && _Object$getOwnPropertyDescriptor ? _Object$getOwnPropertyDescriptor(e, u) : null;
  13941. i && (i.get || i.set) ? _Object$defineProperty(n, u, i) : n[u] = e[u];
  13942. }
  13943. return n.default = e, t && t.set(e, n), n;
  13944. }
  13945. let objectState = {};
  13946. function getState(obj) {
  13947. const classData = objectState[obj.className];
  13948. if (classData) {
  13949. return classData[obj.id] || null;
  13950. }
  13951. return null;
  13952. }
  13953. function initializeState(obj, initial) {
  13954. let state = getState(obj);
  13955. if (state) {
  13956. return state;
  13957. }
  13958. if (!objectState[obj.className]) {
  13959. objectState[obj.className] = {};
  13960. }
  13961. if (!initial) {
  13962. initial = ObjectStateMutations.defaultState();
  13963. }
  13964. state = objectState[obj.className][obj.id] = initial;
  13965. return state;
  13966. }
  13967. function removeState(obj) {
  13968. const state = getState(obj);
  13969. if (state === null) {
  13970. return null;
  13971. }
  13972. delete objectState[obj.className][obj.id];
  13973. return state;
  13974. }
  13975. function getServerData(obj) {
  13976. const state = getState(obj);
  13977. if (state) {
  13978. return state.serverData;
  13979. }
  13980. return {};
  13981. }
  13982. function setServerData(obj, attributes) {
  13983. const serverData = initializeState(obj).serverData;
  13984. ObjectStateMutations.setServerData(serverData, attributes);
  13985. }
  13986. function getPendingOps(obj) {
  13987. const state = getState(obj);
  13988. if (state) {
  13989. return state.pendingOps;
  13990. }
  13991. return [{}];
  13992. }
  13993. function setPendingOp(obj, attr, op) {
  13994. const pendingOps = initializeState(obj).pendingOps;
  13995. ObjectStateMutations.setPendingOp(pendingOps, attr, op);
  13996. }
  13997. function pushPendingState(obj) {
  13998. const pendingOps = initializeState(obj).pendingOps;
  13999. ObjectStateMutations.pushPendingState(pendingOps);
  14000. }
  14001. function popPendingState(obj) {
  14002. const pendingOps = initializeState(obj).pendingOps;
  14003. return ObjectStateMutations.popPendingState(pendingOps);
  14004. }
  14005. function mergeFirstPendingState(obj) {
  14006. const pendingOps = getPendingOps(obj);
  14007. ObjectStateMutations.mergeFirstPendingState(pendingOps);
  14008. }
  14009. function getObjectCache(obj) {
  14010. const state = getState(obj);
  14011. if (state) {
  14012. return state.objectCache;
  14013. }
  14014. return {};
  14015. }
  14016. function estimateAttribute(obj, attr) {
  14017. const serverData = getServerData(obj);
  14018. const pendingOps = getPendingOps(obj);
  14019. return ObjectStateMutations.estimateAttribute(serverData, pendingOps, obj, attr);
  14020. }
  14021. function estimateAttributes(obj) {
  14022. const serverData = getServerData(obj);
  14023. const pendingOps = getPendingOps(obj);
  14024. return ObjectStateMutations.estimateAttributes(serverData, pendingOps, obj);
  14025. }
  14026. function commitServerChanges(obj, changes) {
  14027. const state = initializeState(obj);
  14028. ObjectStateMutations.commitServerChanges(state.serverData, state.objectCache, changes);
  14029. }
  14030. function enqueueTask(obj, task) {
  14031. const state = initializeState(obj);
  14032. return state.tasks.enqueue(task);
  14033. }
  14034. function clearAllState() {
  14035. objectState = {};
  14036. }
  14037. function duplicateState(source, dest) {
  14038. dest.id = source.id;
  14039. }
  14040. },{"./ObjectStateMutations":18,"@babel/runtime-corejs3/core-js-stable/object/define-property":90,"@babel/runtime-corejs3/core-js-stable/object/get-own-property-descriptor":93,"@babel/runtime-corejs3/core-js-stable/weak-map":101}],42:[function(_dereq_,module,exports){
  14041. "use strict";
  14042. var _Object$defineProperty = _dereq_("@babel/runtime-corejs3/core-js-stable/object/define-property");
  14043. var _interopRequireDefault = _dereq_("@babel/runtime-corejs3/helpers/interopRequireDefault");
  14044. _Object$defineProperty(exports, "__esModule", {
  14045. value: true
  14046. });
  14047. exports.default = void 0;
  14048. var _defineProperty2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/helpers/defineProperty"));
  14049. class SocketWeapp {
  14050. constructor(serverURL) {
  14051. (0, _defineProperty2.default)(this, "onopen", void 0);
  14052. (0, _defineProperty2.default)(this, "onmessage", void 0);
  14053. (0, _defineProperty2.default)(this, "onclose", void 0);
  14054. (0, _defineProperty2.default)(this, "onerror", void 0);
  14055. this.onopen = () => {};
  14056. this.onmessage = () => {};
  14057. this.onclose = () => {};
  14058. this.onerror = () => {};
  14059. // @ts-ignore
  14060. wx.onSocketOpen(() => {
  14061. this.onopen();
  14062. });
  14063. // @ts-ignore
  14064. wx.onSocketMessage(msg => {
  14065. // @ts-ignore
  14066. this.onmessage(msg);
  14067. });
  14068. // @ts-ignore
  14069. wx.onSocketClose(event => {
  14070. // @ts-ignore
  14071. this.onclose(event);
  14072. });
  14073. // @ts-ignore
  14074. wx.onSocketError(error => {
  14075. // @ts-ignore
  14076. this.onerror(error);
  14077. });
  14078. // @ts-ignore
  14079. wx.connectSocket({
  14080. url: serverURL
  14081. });
  14082. }
  14083. send(data) {
  14084. // @ts-ignore
  14085. wx.sendSocketMessage({
  14086. data
  14087. });
  14088. }
  14089. close() {
  14090. // @ts-ignore
  14091. wx.closeSocket();
  14092. }
  14093. }
  14094. module.exports = SocketWeapp;
  14095. var _default = exports.default = SocketWeapp;
  14096. },{"@babel/runtime-corejs3/core-js-stable/object/define-property":90,"@babel/runtime-corejs3/helpers/defineProperty":102,"@babel/runtime-corejs3/helpers/interopRequireDefault":103}],43:[function(_dereq_,module,exports){
  14097. "use strict";
  14098. var _Object$defineProperty = _dereq_("@babel/runtime-corejs3/core-js-stable/object/define-property");
  14099. var _interopRequireDefault = _dereq_("@babel/runtime-corejs3/helpers/interopRequireDefault");
  14100. _Object$defineProperty(exports, "__esModule", {
  14101. value: true
  14102. });
  14103. exports.default = void 0;
  14104. var _promise = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/promise"));
  14105. var _CoreManager = _interopRequireDefault(_dereq_("./CoreManager"));
  14106. const Storage = {
  14107. async() {
  14108. const controller = _CoreManager.default.getStorageController();
  14109. return !!controller.async;
  14110. },
  14111. getItem(path) {
  14112. const controller = _CoreManager.default.getStorageController();
  14113. if (controller.async === 1) {
  14114. throw new Error('Synchronous storage is not supported by the current storage controller');
  14115. }
  14116. return controller.getItem(path);
  14117. },
  14118. getItemAsync(path) {
  14119. const controller = _CoreManager.default.getStorageController();
  14120. if (controller.async === 1) {
  14121. return controller.getItemAsync(path);
  14122. }
  14123. return _promise.default.resolve(controller.getItem(path));
  14124. },
  14125. setItem(path, value) {
  14126. const controller = _CoreManager.default.getStorageController();
  14127. if (controller.async === 1) {
  14128. throw new Error('Synchronous storage is not supported by the current storage controller');
  14129. }
  14130. return controller.setItem(path, value);
  14131. },
  14132. setItemAsync(path, value) {
  14133. const controller = _CoreManager.default.getStorageController();
  14134. if (controller.async === 1) {
  14135. return controller.setItemAsync(path, value);
  14136. }
  14137. return _promise.default.resolve(controller.setItem(path, value));
  14138. },
  14139. removeItem(path) {
  14140. const controller = _CoreManager.default.getStorageController();
  14141. if (controller.async === 1) {
  14142. throw new Error('Synchronous storage is not supported by the current storage controller');
  14143. }
  14144. return controller.removeItem(path);
  14145. },
  14146. removeItemAsync(path) {
  14147. const controller = _CoreManager.default.getStorageController();
  14148. if (controller.async === 1) {
  14149. return controller.removeItemAsync(path);
  14150. }
  14151. return _promise.default.resolve(controller.removeItem(path));
  14152. },
  14153. getAllKeys() {
  14154. const controller = _CoreManager.default.getStorageController();
  14155. if (controller.async === 1) {
  14156. throw new Error('Synchronous storage is not supported by the current storage controller');
  14157. }
  14158. return controller.getAllKeys();
  14159. },
  14160. getAllKeysAsync() {
  14161. const controller = _CoreManager.default.getStorageController();
  14162. if (controller.async === 1) {
  14163. return controller.getAllKeysAsync();
  14164. }
  14165. return _promise.default.resolve(controller.getAllKeys());
  14166. },
  14167. generatePath(path) {
  14168. if (!_CoreManager.default.get('APPLICATION_ID')) {
  14169. throw new Error('You need to call Parse.initialize before using Parse.');
  14170. }
  14171. if (typeof path !== 'string') {
  14172. throw new Error('Tried to get a Storage path that was not a String.');
  14173. }
  14174. if (path[0] === '/') {
  14175. path = path.substr(1);
  14176. }
  14177. return 'Parse/' + _CoreManager.default.get('APPLICATION_ID') + '/' + path;
  14178. },
  14179. _clear() {
  14180. const controller = _CoreManager.default.getStorageController();
  14181. if (controller.hasOwnProperty('clear')) {
  14182. controller.clear();
  14183. }
  14184. }
  14185. };
  14186. module.exports = Storage;
  14187. var _default = exports.default = Storage;
  14188. },{"./CoreManager":4,"@babel/runtime-corejs3/core-js-stable/object/define-property":90,"@babel/runtime-corejs3/core-js-stable/promise":97,"@babel/runtime-corejs3/helpers/interopRequireDefault":103}],44:[function(_dereq_,module,exports){
  14189. "use strict";
  14190. var _Object$defineProperty = _dereq_("@babel/runtime-corejs3/core-js-stable/object/define-property");
  14191. _Object$defineProperty(exports, "__esModule", {
  14192. value: true
  14193. });
  14194. exports.default = void 0;
  14195. /* global localStorage */
  14196. const StorageController = {
  14197. async: 0,
  14198. getItem(path) {
  14199. return localStorage.getItem(path);
  14200. },
  14201. setItem(path, value) {
  14202. try {
  14203. localStorage.setItem(path, value);
  14204. } catch (e) {
  14205. // Quota exceeded, possibly due to Safari Private Browsing mode
  14206. console.log(e.message);
  14207. }
  14208. },
  14209. removeItem(path) {
  14210. localStorage.removeItem(path);
  14211. },
  14212. getAllKeys() {
  14213. const keys = [];
  14214. for (let i = 0; i < localStorage.length; i += 1) {
  14215. keys.push(localStorage.key(i));
  14216. }
  14217. return keys;
  14218. },
  14219. clear() {
  14220. localStorage.clear();
  14221. }
  14222. };
  14223. module.exports = StorageController;
  14224. var _default = exports.default = StorageController;
  14225. },{"@babel/runtime-corejs3/core-js-stable/object/define-property":90}],45:[function(_dereq_,module,exports){
  14226. "use strict";
  14227. var _Object$defineProperty = _dereq_("@babel/runtime-corejs3/core-js-stable/object/define-property");
  14228. var _interopRequireDefault = _dereq_("@babel/runtime-corejs3/helpers/interopRequireDefault");
  14229. _Object$defineProperty(exports, "__esModule", {
  14230. value: true
  14231. });
  14232. exports.default = void 0;
  14233. var _keys = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/object/keys"));
  14234. // When there is no native storage interface, we default to an in-memory map
  14235. const memMap = {};
  14236. const StorageController = {
  14237. async: 0,
  14238. getItem(path) {
  14239. if (memMap.hasOwnProperty(path)) {
  14240. return memMap[path];
  14241. }
  14242. return null;
  14243. },
  14244. setItem(path, value) {
  14245. memMap[path] = String(value);
  14246. },
  14247. removeItem(path) {
  14248. delete memMap[path];
  14249. },
  14250. getAllKeys() {
  14251. return (0, _keys.default)(memMap);
  14252. },
  14253. clear() {
  14254. for (const key in memMap) {
  14255. if (memMap.hasOwnProperty(key)) {
  14256. delete memMap[key];
  14257. }
  14258. }
  14259. }
  14260. };
  14261. module.exports = StorageController;
  14262. var _default = exports.default = StorageController;
  14263. },{"@babel/runtime-corejs3/core-js-stable/object/define-property":90,"@babel/runtime-corejs3/core-js-stable/object/keys":95,"@babel/runtime-corejs3/helpers/interopRequireDefault":103}],46:[function(_dereq_,module,exports){
  14264. "use strict";
  14265. var _Object$defineProperty = _dereq_("@babel/runtime-corejs3/core-js-stable/object/define-property");
  14266. var _interopRequireDefault = _dereq_("@babel/runtime-corejs3/helpers/interopRequireDefault");
  14267. _Object$defineProperty(exports, "__esModule", {
  14268. value: true
  14269. });
  14270. exports.default = void 0;
  14271. var _StorageController = _interopRequireDefault(_dereq_("./StorageController.react-native"));
  14272. var _StorageController2 = _interopRequireDefault(_dereq_("./StorageController.browser"));
  14273. var _StorageController3 = _interopRequireDefault(_dereq_("./StorageController.weapp"));
  14274. var _StorageController4 = _interopRequireDefault(_dereq_("./StorageController.default"));
  14275. let StorageController = _StorageController4.default;
  14276. StorageController = _StorageController2.default;
  14277. module.exports = StorageController;
  14278. var _default = exports.default = StorageController;
  14279. },{"./StorageController.browser":44,"./StorageController.default":45,"./StorageController.react-native":47,"./StorageController.weapp":48,"@babel/runtime-corejs3/core-js-stable/object/define-property":90,"@babel/runtime-corejs3/helpers/interopRequireDefault":103}],47:[function(_dereq_,module,exports){
  14280. "use strict";
  14281. var _Object$defineProperty = _dereq_("@babel/runtime-corejs3/core-js-stable/object/define-property");
  14282. var _interopRequireDefault = _dereq_("@babel/runtime-corejs3/helpers/interopRequireDefault");
  14283. _Object$defineProperty(exports, "__esModule", {
  14284. value: true
  14285. });
  14286. exports.default = void 0;
  14287. var _promise = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/promise"));
  14288. var _CoreManager = _interopRequireDefault(_dereq_("./CoreManager"));
  14289. const StorageController = {
  14290. async: 1,
  14291. getItemAsync(path) {
  14292. return new _promise.default((resolve, reject) => {
  14293. _CoreManager.default.getAsyncStorage().getItem(path, (err, value) => {
  14294. if (err) {
  14295. reject(err);
  14296. } else {
  14297. resolve(value || null);
  14298. }
  14299. });
  14300. });
  14301. },
  14302. setItemAsync(path, value) {
  14303. return new _promise.default((resolve, reject) => {
  14304. _CoreManager.default.getAsyncStorage().setItem(path, value, err => {
  14305. if (err) {
  14306. reject(err);
  14307. } else {
  14308. resolve();
  14309. }
  14310. });
  14311. });
  14312. },
  14313. removeItemAsync(path) {
  14314. return new _promise.default((resolve, reject) => {
  14315. _CoreManager.default.getAsyncStorage().removeItem(path, err => {
  14316. if (err) {
  14317. reject(err);
  14318. } else {
  14319. resolve();
  14320. }
  14321. });
  14322. });
  14323. },
  14324. getAllKeysAsync() {
  14325. return new _promise.default((resolve, reject) => {
  14326. _CoreManager.default.getAsyncStorage().getAllKeys((err, keys) => {
  14327. if (err) {
  14328. reject(err);
  14329. } else {
  14330. resolve(keys || []);
  14331. }
  14332. });
  14333. });
  14334. },
  14335. multiGet(keys) {
  14336. return new _promise.default((resolve, reject) => {
  14337. _CoreManager.default.getAsyncStorage().multiGet(keys, (err, result) => {
  14338. if (err) {
  14339. reject(err);
  14340. } else {
  14341. resolve(result || null);
  14342. }
  14343. });
  14344. });
  14345. },
  14346. multiRemove(keys) {
  14347. return new _promise.default((resolve, reject) => {
  14348. _CoreManager.default.getAsyncStorage().multiRemove(keys, err => {
  14349. if (err) {
  14350. reject(err);
  14351. } else {
  14352. resolve(keys);
  14353. }
  14354. });
  14355. });
  14356. },
  14357. clear() {
  14358. return _CoreManager.default.getAsyncStorage().clear();
  14359. }
  14360. };
  14361. module.exports = StorageController;
  14362. var _default = exports.default = StorageController;
  14363. },{"./CoreManager":4,"@babel/runtime-corejs3/core-js-stable/object/define-property":90,"@babel/runtime-corejs3/core-js-stable/promise":97,"@babel/runtime-corejs3/helpers/interopRequireDefault":103}],48:[function(_dereq_,module,exports){
  14364. "use strict";
  14365. var _Object$defineProperty = _dereq_("@babel/runtime-corejs3/core-js-stable/object/define-property");
  14366. var _interopRequireDefault = _dereq_("@babel/runtime-corejs3/helpers/interopRequireDefault");
  14367. _Object$defineProperty(exports, "__esModule", {
  14368. value: true
  14369. });
  14370. exports.default = void 0;
  14371. var _keys = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/instance/keys"));
  14372. const StorageController = {
  14373. async: 0,
  14374. getItem(path) {
  14375. // @ts-ignore
  14376. return wx.getStorageSync(path);
  14377. },
  14378. setItem(path, value) {
  14379. try {
  14380. // @ts-ignore
  14381. wx.setStorageSync(path, value);
  14382. } catch (e) {
  14383. // Quota exceeded
  14384. }
  14385. },
  14386. removeItem(path) {
  14387. // @ts-ignore
  14388. wx.removeStorageSync(path);
  14389. },
  14390. getAllKeys() {
  14391. // @ts-ignore
  14392. const res = wx.getStorageInfoSync();
  14393. return (0, _keys.default)(res);
  14394. },
  14395. clear() {
  14396. // @ts-ignore
  14397. wx.clearStorageSync();
  14398. }
  14399. };
  14400. module.exports = StorageController;
  14401. var _default = exports.default = StorageController;
  14402. },{"@babel/runtime-corejs3/core-js-stable/instance/keys":77,"@babel/runtime-corejs3/core-js-stable/object/define-property":90,"@babel/runtime-corejs3/helpers/interopRequireDefault":103}],49:[function(_dereq_,module,exports){
  14403. "use strict";
  14404. var _Object$defineProperty = _dereq_("@babel/runtime-corejs3/core-js-stable/object/define-property");
  14405. var _interopRequireDefault = _dereq_("@babel/runtime-corejs3/helpers/interopRequireDefault");
  14406. _Object$defineProperty(exports, "__esModule", {
  14407. value: true
  14408. });
  14409. exports.default = void 0;
  14410. var _defineProperty2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/helpers/defineProperty"));
  14411. var _promiseUtils = _dereq_("./promiseUtils");
  14412. class TaskQueue {
  14413. constructor() {
  14414. (0, _defineProperty2.default)(this, "queue", void 0);
  14415. this.queue = [];
  14416. }
  14417. enqueue(task) {
  14418. const taskComplete = (0, _promiseUtils.resolvingPromise)();
  14419. this.queue.push({
  14420. task: task,
  14421. _completion: taskComplete
  14422. });
  14423. if (this.queue.length === 1) {
  14424. task().then(() => {
  14425. this._dequeue();
  14426. taskComplete.resolve();
  14427. }, error => {
  14428. this._dequeue();
  14429. taskComplete.reject(error);
  14430. });
  14431. }
  14432. return taskComplete;
  14433. }
  14434. _dequeue() {
  14435. this.queue.shift();
  14436. if (this.queue.length) {
  14437. const next = this.queue[0];
  14438. next.task().then(() => {
  14439. this._dequeue();
  14440. next._completion.resolve();
  14441. }, error => {
  14442. this._dequeue();
  14443. next._completion.reject(error);
  14444. });
  14445. }
  14446. }
  14447. }
  14448. module.exports = TaskQueue;
  14449. var _default = exports.default = TaskQueue;
  14450. },{"./promiseUtils":61,"@babel/runtime-corejs3/core-js-stable/object/define-property":90,"@babel/runtime-corejs3/helpers/defineProperty":102,"@babel/runtime-corejs3/helpers/interopRequireDefault":103}],50:[function(_dereq_,module,exports){
  14451. "use strict";
  14452. var _WeakMap2 = _dereq_("@babel/runtime-corejs3/core-js-stable/weak-map");
  14453. var _Object$defineProperty = _dereq_("@babel/runtime-corejs3/core-js-stable/object/define-property");
  14454. var _Object$getOwnPropertyDescriptor = _dereq_("@babel/runtime-corejs3/core-js-stable/object/get-own-property-descriptor");
  14455. var _interopRequireDefault = _dereq_("@babel/runtime-corejs3/helpers/interopRequireDefault");
  14456. _Object$defineProperty(exports, "__esModule", {
  14457. value: true
  14458. });
  14459. exports.clearAllState = clearAllState;
  14460. exports.commitServerChanges = commitServerChanges;
  14461. exports.duplicateState = duplicateState;
  14462. exports.enqueueTask = enqueueTask;
  14463. exports.estimateAttribute = estimateAttribute;
  14464. exports.estimateAttributes = estimateAttributes;
  14465. exports.getObjectCache = getObjectCache;
  14466. exports.getPendingOps = getPendingOps;
  14467. exports.getServerData = getServerData;
  14468. exports.getState = getState;
  14469. exports.initializeState = initializeState;
  14470. exports.mergeFirstPendingState = mergeFirstPendingState;
  14471. exports.popPendingState = popPendingState;
  14472. exports.pushPendingState = pushPendingState;
  14473. exports.removeState = removeState;
  14474. exports.setPendingOp = setPendingOp;
  14475. exports.setServerData = setServerData;
  14476. var _weakMap = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/weak-map"));
  14477. var ObjectStateMutations = _interopRequireWildcard(_dereq_("./ObjectStateMutations"));
  14478. var _TaskQueue = _interopRequireDefault(_dereq_("./TaskQueue"));
  14479. function _getRequireWildcardCache(e) {
  14480. if ("function" != typeof _WeakMap2) return null;
  14481. var r = new _WeakMap2(),
  14482. t = new _WeakMap2();
  14483. return (_getRequireWildcardCache = function (e) {
  14484. return e ? t : r;
  14485. })(e);
  14486. }
  14487. function _interopRequireWildcard(e, r) {
  14488. if (!r && e && e.__esModule) return e;
  14489. if (null === e || "object" != typeof e && "function" != typeof e) return {
  14490. default: e
  14491. };
  14492. var t = _getRequireWildcardCache(r);
  14493. if (t && t.has(e)) return t.get(e);
  14494. var n = {
  14495. __proto__: null
  14496. };
  14497. for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) {
  14498. var i = _Object$defineProperty && _Object$getOwnPropertyDescriptor ? _Object$getOwnPropertyDescriptor(e, u) : null;
  14499. i && (i.get || i.set) ? _Object$defineProperty(n, u, i) : n[u] = e[u];
  14500. }
  14501. return n.default = e, t && t.set(e, n), n;
  14502. }
  14503. let objectState = new _weakMap.default();
  14504. function getState(obj) {
  14505. const classData = objectState.get(obj);
  14506. return classData || null;
  14507. }
  14508. function initializeState(obj, initial) {
  14509. let state = getState(obj);
  14510. if (state) {
  14511. return state;
  14512. }
  14513. if (!initial) {
  14514. initial = {
  14515. serverData: {},
  14516. pendingOps: [{}],
  14517. objectCache: {},
  14518. tasks: new _TaskQueue.default(),
  14519. existed: false
  14520. };
  14521. }
  14522. state = initial;
  14523. objectState.set(obj, state);
  14524. return state;
  14525. }
  14526. function removeState(obj) {
  14527. const state = getState(obj);
  14528. if (state === null) {
  14529. return null;
  14530. }
  14531. objectState.delete(obj);
  14532. return state;
  14533. }
  14534. function getServerData(obj) {
  14535. const state = getState(obj);
  14536. if (state) {
  14537. return state.serverData;
  14538. }
  14539. return {};
  14540. }
  14541. function setServerData(obj, attributes) {
  14542. const serverData = initializeState(obj).serverData;
  14543. ObjectStateMutations.setServerData(serverData, attributes);
  14544. }
  14545. function getPendingOps(obj) {
  14546. const state = getState(obj);
  14547. if (state) {
  14548. return state.pendingOps;
  14549. }
  14550. return [{}];
  14551. }
  14552. function setPendingOp(obj, attr, op) {
  14553. const pendingOps = initializeState(obj).pendingOps;
  14554. ObjectStateMutations.setPendingOp(pendingOps, attr, op);
  14555. }
  14556. function pushPendingState(obj) {
  14557. const pendingOps = initializeState(obj).pendingOps;
  14558. ObjectStateMutations.pushPendingState(pendingOps);
  14559. }
  14560. function popPendingState(obj) {
  14561. const pendingOps = initializeState(obj).pendingOps;
  14562. return ObjectStateMutations.popPendingState(pendingOps);
  14563. }
  14564. function mergeFirstPendingState(obj) {
  14565. const pendingOps = getPendingOps(obj);
  14566. ObjectStateMutations.mergeFirstPendingState(pendingOps);
  14567. }
  14568. function getObjectCache(obj) {
  14569. const state = getState(obj);
  14570. if (state) {
  14571. return state.objectCache;
  14572. }
  14573. return {};
  14574. }
  14575. function estimateAttribute(obj, attr) {
  14576. const serverData = getServerData(obj);
  14577. const pendingOps = getPendingOps(obj);
  14578. return ObjectStateMutations.estimateAttribute(serverData, pendingOps, obj, attr);
  14579. }
  14580. function estimateAttributes(obj) {
  14581. const serverData = getServerData(obj);
  14582. const pendingOps = getPendingOps(obj);
  14583. return ObjectStateMutations.estimateAttributes(serverData, pendingOps, obj);
  14584. }
  14585. function commitServerChanges(obj, changes) {
  14586. const state = initializeState(obj);
  14587. ObjectStateMutations.commitServerChanges(state.serverData, state.objectCache, changes);
  14588. }
  14589. function enqueueTask(obj, task) {
  14590. const state = initializeState(obj);
  14591. return state.tasks.enqueue(task);
  14592. }
  14593. function duplicateState(source, dest) {
  14594. const oldState = initializeState(source);
  14595. const newState = initializeState(dest);
  14596. for (const key in oldState.serverData) {
  14597. newState.serverData[key] = oldState.serverData[key];
  14598. }
  14599. for (let index = 0; index < oldState.pendingOps.length; index++) {
  14600. for (const key in oldState.pendingOps[index]) {
  14601. newState.pendingOps[index][key] = oldState.pendingOps[index][key];
  14602. }
  14603. }
  14604. for (const key in oldState.objectCache) {
  14605. newState.objectCache[key] = oldState.objectCache[key];
  14606. }
  14607. newState.existed = oldState.existed;
  14608. }
  14609. function clearAllState() {
  14610. objectState = new _weakMap.default();
  14611. }
  14612. },{"./ObjectStateMutations":18,"./TaskQueue":49,"@babel/runtime-corejs3/core-js-stable/object/define-property":90,"@babel/runtime-corejs3/core-js-stable/object/get-own-property-descriptor":93,"@babel/runtime-corejs3/core-js-stable/weak-map":101,"@babel/runtime-corejs3/helpers/interopRequireDefault":103}],51:[function(_dereq_,module,exports){
  14613. "use strict";
  14614. var _Object$defineProperty = _dereq_("@babel/runtime-corejs3/core-js-stable/object/define-property");
  14615. var _interopRequireDefault = _dereq_("@babel/runtime-corejs3/helpers/interopRequireDefault");
  14616. _Object$defineProperty(exports, "__esModule", {
  14617. value: true
  14618. });
  14619. exports.default = void 0;
  14620. var _ws = _interopRequireDefault(_dereq_("ws"));
  14621. var _Socket = _interopRequireDefault(_dereq_("./Socket.weapp"));
  14622. /* global WebSocket */
  14623. let WebSocketController;
  14624. try {
  14625. WebSocketController = typeof WebSocket === 'function' || typeof WebSocket === 'object' ? WebSocket : null;
  14626. } catch (_) {
  14627. // WebSocket unavailable
  14628. }
  14629. module.exports = WebSocketController;
  14630. var _default = exports.default = WebSocketController;
  14631. },{"./Socket.weapp":42,"@babel/runtime-corejs3/core-js-stable/object/define-property":90,"@babel/runtime-corejs3/helpers/interopRequireDefault":103,"ws":508}],52:[function(_dereq_,module,exports){
  14632. "use strict";
  14633. var _Object$defineProperty = _dereq_("@babel/runtime-corejs3/core-js-stable/object/define-property");
  14634. var _interopRequireDefault = _dereq_("@babel/runtime-corejs3/helpers/interopRequireDefault");
  14635. _Object$defineProperty(exports, "__esModule", {
  14636. value: true
  14637. });
  14638. exports.default = void 0;
  14639. var _stringify = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/json/stringify"));
  14640. var _defineProperty2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/helpers/defineProperty"));
  14641. class XhrWeapp {
  14642. constructor() {
  14643. (0, _defineProperty2.default)(this, "UNSENT", void 0);
  14644. (0, _defineProperty2.default)(this, "OPENED", void 0);
  14645. (0, _defineProperty2.default)(this, "HEADERS_RECEIVED", void 0);
  14646. (0, _defineProperty2.default)(this, "LOADING", void 0);
  14647. (0, _defineProperty2.default)(this, "DONE", void 0);
  14648. (0, _defineProperty2.default)(this, "header", void 0);
  14649. (0, _defineProperty2.default)(this, "readyState", void 0);
  14650. (0, _defineProperty2.default)(this, "status", void 0);
  14651. (0, _defineProperty2.default)(this, "response", void 0);
  14652. (0, _defineProperty2.default)(this, "responseType", void 0);
  14653. (0, _defineProperty2.default)(this, "responseText", void 0);
  14654. (0, _defineProperty2.default)(this, "responseHeader", void 0);
  14655. (0, _defineProperty2.default)(this, "method", void 0);
  14656. (0, _defineProperty2.default)(this, "url", void 0);
  14657. (0, _defineProperty2.default)(this, "onabort", void 0);
  14658. (0, _defineProperty2.default)(this, "onprogress", void 0);
  14659. (0, _defineProperty2.default)(this, "onerror", void 0);
  14660. (0, _defineProperty2.default)(this, "onreadystatechange", void 0);
  14661. (0, _defineProperty2.default)(this, "requestTask", void 0);
  14662. this.UNSENT = 0;
  14663. this.OPENED = 1;
  14664. this.HEADERS_RECEIVED = 2;
  14665. this.LOADING = 3;
  14666. this.DONE = 4;
  14667. this.header = {};
  14668. this.readyState = this.DONE;
  14669. this.status = 0;
  14670. this.response = '';
  14671. this.responseType = '';
  14672. this.responseText = '';
  14673. this.responseHeader = {};
  14674. this.method = '';
  14675. this.url = '';
  14676. this.onabort = () => {};
  14677. this.onprogress = () => {};
  14678. this.onerror = () => {};
  14679. this.onreadystatechange = () => {};
  14680. this.requestTask = null;
  14681. }
  14682. getAllResponseHeaders() {
  14683. let header = '';
  14684. for (const key in this.responseHeader) {
  14685. header += key + ':' + this.getResponseHeader(key) + '\r\n';
  14686. }
  14687. return header;
  14688. }
  14689. getResponseHeader(key) {
  14690. return this.responseHeader[key];
  14691. }
  14692. setRequestHeader(key, value) {
  14693. this.header[key] = value;
  14694. }
  14695. open(method, url) {
  14696. this.method = method;
  14697. this.url = url;
  14698. }
  14699. abort() {
  14700. if (!this.requestTask) {
  14701. return;
  14702. }
  14703. this.requestTask.abort();
  14704. this.status = 0;
  14705. this.response = undefined;
  14706. this.onabort();
  14707. this.onreadystatechange();
  14708. }
  14709. send(data) {
  14710. // @ts-ignore
  14711. this.requestTask = wx.request({
  14712. url: this.url,
  14713. method: this.method,
  14714. data: data,
  14715. header: this.header,
  14716. responseType: this.responseType,
  14717. success: res => {
  14718. this.status = res.statusCode;
  14719. this.response = res.data;
  14720. this.responseHeader = res.header;
  14721. this.responseText = (0, _stringify.default)(res.data);
  14722. this.requestTask = null;
  14723. this.onreadystatechange();
  14724. },
  14725. fail: err => {
  14726. this.requestTask = null;
  14727. // @ts-ignore
  14728. this.onerror(err);
  14729. }
  14730. });
  14731. this.requestTask.onProgressUpdate(res => {
  14732. const event = {
  14733. lengthComputable: res.totalBytesExpectedToWrite !== 0,
  14734. loaded: res.totalBytesWritten,
  14735. total: res.totalBytesExpectedToWrite
  14736. };
  14737. // @ts-ignore
  14738. this.onprogress(event);
  14739. });
  14740. }
  14741. }
  14742. module.exports = XhrWeapp;
  14743. var _default = exports.default = XhrWeapp;
  14744. },{"@babel/runtime-corejs3/core-js-stable/json/stringify":85,"@babel/runtime-corejs3/core-js-stable/object/define-property":90,"@babel/runtime-corejs3/helpers/defineProperty":102,"@babel/runtime-corejs3/helpers/interopRequireDefault":103}],53:[function(_dereq_,module,exports){
  14745. "use strict";
  14746. var _Object$defineProperty = _dereq_("@babel/runtime-corejs3/core-js-stable/object/define-property");
  14747. var _interopRequireDefault = _dereq_("@babel/runtime-corejs3/helpers/interopRequireDefault");
  14748. _Object$defineProperty(exports, "__esModule", {
  14749. value: true
  14750. });
  14751. exports.default = arrayContainsObject;
  14752. var _indexOf = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/instance/index-of"));
  14753. var _CoreManager = _interopRequireDefault(_dereq_("./CoreManager"));
  14754. function arrayContainsObject(array, object) {
  14755. if ((0, _indexOf.default)(array).call(array, object) > -1) {
  14756. return true;
  14757. }
  14758. const ParseObject = _CoreManager.default.getParseObject();
  14759. for (let i = 0; i < array.length; i++) {
  14760. if (array[i] instanceof ParseObject && array[i].className === object.className && array[i]._getId() === object._getId()) {
  14761. return true;
  14762. }
  14763. }
  14764. return false;
  14765. }
  14766. },{"./CoreManager":4,"@babel/runtime-corejs3/core-js-stable/instance/index-of":76,"@babel/runtime-corejs3/core-js-stable/object/define-property":90,"@babel/runtime-corejs3/helpers/interopRequireDefault":103}],54:[function(_dereq_,module,exports){
  14767. "use strict";
  14768. var _Object$defineProperty = _dereq_("@babel/runtime-corejs3/core-js-stable/object/define-property");
  14769. var _interopRequireDefault = _dereq_("@babel/runtime-corejs3/helpers/interopRequireDefault");
  14770. _Object$defineProperty(exports, "__esModule", {
  14771. value: true
  14772. });
  14773. exports.default = canBeSerialized;
  14774. var _isArray = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/array/is-array"));
  14775. var _CoreManager = _interopRequireDefault(_dereq_("./CoreManager"));
  14776. var _ParseFile = _interopRequireDefault(_dereq_("./ParseFile"));
  14777. var _ParseRelation = _interopRequireDefault(_dereq_("./ParseRelation"));
  14778. function canBeSerialized(obj) {
  14779. const ParseObject = _CoreManager.default.getParseObject();
  14780. if (!(obj instanceof ParseObject)) {
  14781. return true;
  14782. }
  14783. const attributes = obj.attributes;
  14784. for (const attr in attributes) {
  14785. const val = attributes[attr];
  14786. if (!canBeSerializedHelper(val)) {
  14787. return false;
  14788. }
  14789. }
  14790. return true;
  14791. }
  14792. function canBeSerializedHelper(value) {
  14793. if (typeof value !== 'object') {
  14794. return true;
  14795. }
  14796. if (value instanceof _ParseRelation.default) {
  14797. return true;
  14798. }
  14799. const ParseObject = _CoreManager.default.getParseObject();
  14800. if (value instanceof ParseObject) {
  14801. return !!value.id;
  14802. }
  14803. if (value instanceof _ParseFile.default) {
  14804. if (value.url()) {
  14805. return true;
  14806. }
  14807. return false;
  14808. }
  14809. if ((0, _isArray.default)(value)) {
  14810. for (let i = 0; i < value.length; i++) {
  14811. if (!canBeSerializedHelper(value[i])) {
  14812. return false;
  14813. }
  14814. }
  14815. return true;
  14816. }
  14817. for (const k in value) {
  14818. if (!canBeSerializedHelper(value[k])) {
  14819. return false;
  14820. }
  14821. }
  14822. return true;
  14823. }
  14824. },{"./CoreManager":4,"./ParseFile":25,"./ParseRelation":34,"@babel/runtime-corejs3/core-js-stable/array/is-array":66,"@babel/runtime-corejs3/core-js-stable/object/define-property":90,"@babel/runtime-corejs3/helpers/interopRequireDefault":103}],55:[function(_dereq_,module,exports){
  14825. "use strict";
  14826. var _Object$defineProperty = _dereq_("@babel/runtime-corejs3/core-js-stable/object/define-property");
  14827. var _interopRequireDefault = _dereq_("@babel/runtime-corejs3/helpers/interopRequireDefault");
  14828. _Object$defineProperty(exports, "__esModule", {
  14829. value: true
  14830. });
  14831. exports.default = decode;
  14832. var _isArray = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/array/is-array"));
  14833. var _forEach = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/instance/for-each"));
  14834. var _CoreManager = _interopRequireDefault(_dereq_("./CoreManager"));
  14835. var _ParseFile = _interopRequireDefault(_dereq_("./ParseFile"));
  14836. var _ParseGeoPoint = _interopRequireDefault(_dereq_("./ParseGeoPoint"));
  14837. var _ParsePolygon = _interopRequireDefault(_dereq_("./ParsePolygon"));
  14838. var _ParseRelation = _interopRequireDefault(_dereq_("./ParseRelation"));
  14839. function decode(value) {
  14840. if (value === null || typeof value !== 'object' || value instanceof Date) {
  14841. return value;
  14842. }
  14843. if ((0, _isArray.default)(value)) {
  14844. const dup = [];
  14845. (0, _forEach.default)(value).call(value, (v, i) => {
  14846. dup[i] = decode(v);
  14847. });
  14848. return dup;
  14849. }
  14850. if (typeof value.__op === 'string') {
  14851. const {
  14852. opFromJSON
  14853. } = _CoreManager.default.getParseOp();
  14854. return opFromJSON(value);
  14855. }
  14856. const ParseObject = _CoreManager.default.getParseObject();
  14857. if (value.__type === 'Pointer' && value.className) {
  14858. return ParseObject.fromJSON(value);
  14859. }
  14860. if (value.__type === 'Object' && value.className) {
  14861. return ParseObject.fromJSON(value);
  14862. }
  14863. if (value.__type === 'Relation') {
  14864. // The parent and key fields will be populated by the parent
  14865. const relation = new _ParseRelation.default(null, null);
  14866. relation.targetClassName = value.className;
  14867. return relation;
  14868. }
  14869. if (value.__type === 'Date') {
  14870. return new Date(value.iso);
  14871. }
  14872. if (value.__type === 'File') {
  14873. return _ParseFile.default.fromJSON(value);
  14874. }
  14875. if (value.__type === 'GeoPoint') {
  14876. return new _ParseGeoPoint.default({
  14877. latitude: value.latitude,
  14878. longitude: value.longitude
  14879. });
  14880. }
  14881. if (value.__type === 'Polygon') {
  14882. return new _ParsePolygon.default(value.coordinates);
  14883. }
  14884. const copy = {};
  14885. for (const k in value) {
  14886. copy[k] = decode(value[k]);
  14887. }
  14888. return copy;
  14889. }
  14890. },{"./CoreManager":4,"./ParseFile":25,"./ParseGeoPoint":26,"./ParsePolygon":32,"./ParseRelation":34,"@babel/runtime-corejs3/core-js-stable/array/is-array":66,"@babel/runtime-corejs3/core-js-stable/instance/for-each":74,"@babel/runtime-corejs3/core-js-stable/object/define-property":90,"@babel/runtime-corejs3/helpers/interopRequireDefault":103}],56:[function(_dereq_,module,exports){
  14891. "use strict";
  14892. var _Object$defineProperty = _dereq_("@babel/runtime-corejs3/core-js-stable/object/define-property");
  14893. var _interopRequireDefault = _dereq_("@babel/runtime-corejs3/helpers/interopRequireDefault");
  14894. _Object$defineProperty(exports, "__esModule", {
  14895. value: true
  14896. });
  14897. exports.default = _default;
  14898. var _indexOf = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/instance/index-of"));
  14899. var _keys = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/object/keys"));
  14900. var _startsWith = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/instance/starts-with"));
  14901. var _concat = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/instance/concat"));
  14902. var _isArray = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/array/is-array"));
  14903. var _map = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/instance/map"));
  14904. var _CoreManager = _interopRequireDefault(_dereq_("./CoreManager"));
  14905. var _ParseACL = _interopRequireDefault(_dereq_("./ParseACL"));
  14906. var _ParseFile = _interopRequireDefault(_dereq_("./ParseFile"));
  14907. var _ParseGeoPoint = _interopRequireDefault(_dereq_("./ParseGeoPoint"));
  14908. var _ParsePolygon = _interopRequireDefault(_dereq_("./ParsePolygon"));
  14909. var _ParseRelation = _interopRequireDefault(_dereq_("./ParseRelation"));
  14910. function encode(value, disallowObjects, forcePointers, seen, offline) {
  14911. const ParseObject = _CoreManager.default.getParseObject();
  14912. if (value instanceof ParseObject) {
  14913. if (disallowObjects) {
  14914. throw new Error('Parse Objects not allowed here');
  14915. }
  14916. const seenEntry = value.id ? value.className + ':' + value.id : value;
  14917. if (forcePointers || !seen || (0, _indexOf.default)(seen).call(seen, seenEntry) > -1 || value.dirty() || (0, _keys.default)(value._getServerData()).length < 1) {
  14918. var _context;
  14919. if (offline && (0, _startsWith.default)(_context = value._getId()).call(_context, 'local')) {
  14920. return value.toOfflinePointer();
  14921. }
  14922. return value.toPointer();
  14923. }
  14924. seen = (0, _concat.default)(seen).call(seen, seenEntry);
  14925. return value._toFullJSON(seen, offline);
  14926. }
  14927. const {
  14928. Op
  14929. } = _CoreManager.default.getParseOp();
  14930. if (value instanceof Op || value instanceof _ParseACL.default || value instanceof _ParseGeoPoint.default || value instanceof _ParsePolygon.default || value instanceof _ParseRelation.default) {
  14931. return value.toJSON();
  14932. }
  14933. if (value instanceof _ParseFile.default) {
  14934. if (!value.url()) {
  14935. throw new Error('Tried to encode an unsaved file.');
  14936. }
  14937. return value.toJSON();
  14938. }
  14939. if (Object.prototype.toString.call(value) === '[object Date]') {
  14940. if (isNaN(value)) {
  14941. throw new Error('Tried to encode an invalid date.');
  14942. }
  14943. return {
  14944. __type: 'Date',
  14945. iso: value.toJSON()
  14946. };
  14947. }
  14948. if (Object.prototype.toString.call(value) === '[object RegExp]' && typeof value.source === 'string') {
  14949. return value.source;
  14950. }
  14951. if ((0, _isArray.default)(value)) {
  14952. return (0, _map.default)(value).call(value, v => {
  14953. return encode(v, disallowObjects, forcePointers, seen, offline);
  14954. });
  14955. }
  14956. if (value && typeof value === 'object') {
  14957. const output = {};
  14958. for (const k in value) {
  14959. output[k] = encode(value[k], disallowObjects, forcePointers, seen, offline);
  14960. }
  14961. return output;
  14962. }
  14963. return value;
  14964. }
  14965. function _default(value, disallowObjects, forcePointers, seen, offline) {
  14966. return encode(value, !!disallowObjects, !!forcePointers, seen || [], offline);
  14967. }
  14968. },{"./CoreManager":4,"./ParseACL":21,"./ParseFile":25,"./ParseGeoPoint":26,"./ParsePolygon":32,"./ParseRelation":34,"@babel/runtime-corejs3/core-js-stable/array/is-array":66,"@babel/runtime-corejs3/core-js-stable/instance/concat":68,"@babel/runtime-corejs3/core-js-stable/instance/index-of":76,"@babel/runtime-corejs3/core-js-stable/instance/map":78,"@babel/runtime-corejs3/core-js-stable/instance/starts-with":83,"@babel/runtime-corejs3/core-js-stable/object/define-property":90,"@babel/runtime-corejs3/core-js-stable/object/keys":95,"@babel/runtime-corejs3/helpers/interopRequireDefault":103}],57:[function(_dereq_,module,exports){
  14969. "use strict";
  14970. var _Object$defineProperty = _dereq_("@babel/runtime-corejs3/core-js-stable/object/define-property");
  14971. var _interopRequireDefault = _dereq_("@babel/runtime-corejs3/helpers/interopRequireDefault");
  14972. _Object$defineProperty(exports, "__esModule", {
  14973. value: true
  14974. });
  14975. exports.default = equals;
  14976. var _isArray = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/array/is-array"));
  14977. var _keys = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/object/keys"));
  14978. var _CoreManager = _interopRequireDefault(_dereq_("./CoreManager"));
  14979. var _ParseACL = _interopRequireDefault(_dereq_("./ParseACL"));
  14980. var _ParseFile = _interopRequireDefault(_dereq_("./ParseFile"));
  14981. var _ParseGeoPoint = _interopRequireDefault(_dereq_("./ParseGeoPoint"));
  14982. function equals(a, b) {
  14983. const toString = Object.prototype.toString;
  14984. if (toString.call(a) === '[object Date]' || toString.call(b) === '[object Date]') {
  14985. const dateA = new Date(a);
  14986. const dateB = new Date(b);
  14987. return +dateA === +dateB;
  14988. }
  14989. if (typeof a !== typeof b) {
  14990. return false;
  14991. }
  14992. if (!a || typeof a !== 'object') {
  14993. // a is a primitive
  14994. return a === b;
  14995. }
  14996. if ((0, _isArray.default)(a) || (0, _isArray.default)(b)) {
  14997. if (!(0, _isArray.default)(a) || !(0, _isArray.default)(b)) {
  14998. return false;
  14999. }
  15000. if (a.length !== b.length) {
  15001. return false;
  15002. }
  15003. for (let i = a.length; i--;) {
  15004. if (!equals(a[i], b[i])) {
  15005. return false;
  15006. }
  15007. }
  15008. return true;
  15009. }
  15010. const ParseObject = _CoreManager.default.getParseObject();
  15011. if (a instanceof _ParseACL.default || a instanceof _ParseFile.default || a instanceof _ParseGeoPoint.default || a instanceof ParseObject) {
  15012. return a.equals(b);
  15013. }
  15014. if (b instanceof ParseObject) {
  15015. if (a.__type === 'Object' || a.__type === 'Pointer') {
  15016. return a.objectId === b.id && a.className === b.className;
  15017. }
  15018. }
  15019. if ((0, _keys.default)(a).length !== (0, _keys.default)(b).length) {
  15020. return false;
  15021. }
  15022. for (const k in a) {
  15023. if (!equals(a[k], b[k])) {
  15024. return false;
  15025. }
  15026. }
  15027. return true;
  15028. }
  15029. },{"./CoreManager":4,"./ParseACL":21,"./ParseFile":25,"./ParseGeoPoint":26,"@babel/runtime-corejs3/core-js-stable/array/is-array":66,"@babel/runtime-corejs3/core-js-stable/object/define-property":90,"@babel/runtime-corejs3/core-js-stable/object/keys":95,"@babel/runtime-corejs3/helpers/interopRequireDefault":103}],58:[function(_dereq_,module,exports){
  15030. "use strict";
  15031. var _Object$defineProperty = _dereq_("@babel/runtime-corejs3/core-js-stable/object/define-property");
  15032. _Object$defineProperty(exports, "__esModule", {
  15033. value: true
  15034. });
  15035. exports.default = escape;
  15036. const encoded = {
  15037. '&': '&amp;',
  15038. '<': '&lt;',
  15039. '>': '&gt;',
  15040. '/': '&#x2F;',
  15041. "'": '&#x27;',
  15042. '"': '&quot;'
  15043. };
  15044. function escape(str) {
  15045. return str.replace(/[&<>\/'"]/g, function (char) {
  15046. return encoded[char];
  15047. });
  15048. }
  15049. },{"@babel/runtime-corejs3/core-js-stable/object/define-property":90}],59:[function(_dereq_,module,exports){
  15050. "use strict";
  15051. var _Object$defineProperty = _dereq_("@babel/runtime-corejs3/core-js-stable/object/define-property");
  15052. var _interopRequireDefault = _dereq_("@babel/runtime-corejs3/helpers/interopRequireDefault");
  15053. _Object$defineProperty(exports, "__esModule", {
  15054. value: true
  15055. });
  15056. exports.default = isRevocableSession;
  15057. var _indexOf = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/instance/index-of"));
  15058. function isRevocableSession(token) {
  15059. return (0, _indexOf.default)(token).call(token, 'r:') > -1;
  15060. }
  15061. },{"@babel/runtime-corejs3/core-js-stable/instance/index-of":76,"@babel/runtime-corejs3/core-js-stable/object/define-property":90,"@babel/runtime-corejs3/helpers/interopRequireDefault":103}],60:[function(_dereq_,module,exports){
  15062. "use strict";
  15063. var _Object$defineProperty = _dereq_("@babel/runtime-corejs3/core-js-stable/object/define-property");
  15064. var _interopRequireDefault = _dereq_("@babel/runtime-corejs3/helpers/interopRequireDefault");
  15065. _Object$defineProperty(exports, "__esModule", {
  15066. value: true
  15067. });
  15068. exports.default = parseDate;
  15069. var _parseInt2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/parse-int"));
  15070. function parseDate(iso8601) {
  15071. const 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$');
  15072. const match = regexp.exec(iso8601);
  15073. if (!match) {
  15074. return null;
  15075. }
  15076. const year = (0, _parseInt2.default)(match[1]) || 0;
  15077. const month = ((0, _parseInt2.default)(match[2]) || 1) - 1;
  15078. const day = (0, _parseInt2.default)(match[3]) || 0;
  15079. const hour = (0, _parseInt2.default)(match[4]) || 0;
  15080. const minute = (0, _parseInt2.default)(match[5]) || 0;
  15081. const second = (0, _parseInt2.default)(match[6]) || 0;
  15082. const milli = (0, _parseInt2.default)(match[8]) || 0;
  15083. return new Date(Date.UTC(year, month, day, hour, minute, second, milli));
  15084. }
  15085. },{"@babel/runtime-corejs3/core-js-stable/object/define-property":90,"@babel/runtime-corejs3/core-js-stable/parse-int":96,"@babel/runtime-corejs3/helpers/interopRequireDefault":103}],61:[function(_dereq_,module,exports){
  15086. "use strict";
  15087. var _Object$defineProperty = _dereq_("@babel/runtime-corejs3/core-js-stable/object/define-property");
  15088. var _interopRequireDefault = _dereq_("@babel/runtime-corejs3/helpers/interopRequireDefault");
  15089. _Object$defineProperty(exports, "__esModule", {
  15090. value: true
  15091. });
  15092. exports.continueWhile = continueWhile;
  15093. exports.resolvingPromise = resolvingPromise;
  15094. exports.when = when;
  15095. var _promise = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/promise"));
  15096. var _isArray = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/array/is-array"));
  15097. // Create Deferred Promise
  15098. function resolvingPromise() {
  15099. let res;
  15100. let rej;
  15101. const promise = new _promise.default((resolve, reject) => {
  15102. res = resolve;
  15103. rej = reject;
  15104. });
  15105. const defer = promise;
  15106. defer.resolve = res;
  15107. defer.reject = rej;
  15108. return defer;
  15109. }
  15110. function when(promises) {
  15111. let objects;
  15112. const arrayArgument = (0, _isArray.default)(promises);
  15113. if (arrayArgument) {
  15114. objects = promises;
  15115. } else {
  15116. objects = arguments;
  15117. }
  15118. let total = objects.length;
  15119. let hadError = false;
  15120. const results = [];
  15121. const returnValue = arrayArgument ? [results] : results;
  15122. const errors = [];
  15123. results.length = objects.length;
  15124. errors.length = objects.length;
  15125. if (total === 0) {
  15126. return _promise.default.resolve(returnValue);
  15127. }
  15128. const promise = resolvingPromise();
  15129. const resolveOne = function () {
  15130. total--;
  15131. if (total <= 0) {
  15132. if (hadError) {
  15133. promise.reject(errors);
  15134. } else {
  15135. promise.resolve(returnValue);
  15136. }
  15137. }
  15138. };
  15139. const chain = function (object, index) {
  15140. if (object && typeof object.then === 'function') {
  15141. object.then(function (result) {
  15142. results[index] = result;
  15143. resolveOne();
  15144. }, function (error) {
  15145. errors[index] = error;
  15146. hadError = true;
  15147. resolveOne();
  15148. });
  15149. } else {
  15150. results[index] = object;
  15151. resolveOne();
  15152. }
  15153. };
  15154. for (let i = 0; i < objects.length; i++) {
  15155. chain(objects[i], i);
  15156. }
  15157. return promise;
  15158. }
  15159. function continueWhile(test, emitter) {
  15160. if (test()) {
  15161. return emitter().then(() => {
  15162. return continueWhile(test, emitter);
  15163. });
  15164. }
  15165. return _promise.default.resolve();
  15166. }
  15167. },{"@babel/runtime-corejs3/core-js-stable/array/is-array":66,"@babel/runtime-corejs3/core-js-stable/object/define-property":90,"@babel/runtime-corejs3/core-js-stable/promise":97,"@babel/runtime-corejs3/helpers/interopRequireDefault":103}],62:[function(_dereq_,module,exports){
  15168. "use strict";
  15169. var _Object$defineProperty = _dereq_("@babel/runtime-corejs3/core-js-stable/object/define-property");
  15170. var _interopRequireDefault = _dereq_("@babel/runtime-corejs3/helpers/interopRequireDefault");
  15171. _Object$defineProperty(exports, "__esModule", {
  15172. value: true
  15173. });
  15174. exports.default = unique;
  15175. var _forEach = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/instance/for-each"));
  15176. var _indexOf = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/instance/index-of"));
  15177. var _arrayContainsObject = _interopRequireDefault(_dereq_("./arrayContainsObject"));
  15178. var _CoreManager = _interopRequireDefault(_dereq_("./CoreManager"));
  15179. function unique(arr) {
  15180. const uniques = [];
  15181. (0, _forEach.default)(arr).call(arr, value => {
  15182. const ParseObject = _CoreManager.default.getParseObject();
  15183. if (value instanceof ParseObject) {
  15184. if (!(0, _arrayContainsObject.default)(uniques, value)) {
  15185. uniques.push(value);
  15186. }
  15187. } else {
  15188. if ((0, _indexOf.default)(uniques).call(uniques, value) < 0) {
  15189. uniques.push(value);
  15190. }
  15191. }
  15192. });
  15193. return uniques;
  15194. }
  15195. },{"./CoreManager":4,"./arrayContainsObject":53,"@babel/runtime-corejs3/core-js-stable/instance/for-each":74,"@babel/runtime-corejs3/core-js-stable/instance/index-of":76,"@babel/runtime-corejs3/core-js-stable/object/define-property":90,"@babel/runtime-corejs3/helpers/interopRequireDefault":103}],63:[function(_dereq_,module,exports){
  15196. "use strict";
  15197. var _Object$defineProperty = _dereq_("@babel/runtime-corejs3/core-js-stable/object/define-property");
  15198. var _interopRequireDefault = _dereq_("@babel/runtime-corejs3/helpers/interopRequireDefault");
  15199. _Object$defineProperty(exports, "__esModule", {
  15200. value: true
  15201. });
  15202. exports.default = unsavedChildren;
  15203. var _concat = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/instance/concat"));
  15204. var _indexOf = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/instance/index-of"));
  15205. var _isArray = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/array/is-array"));
  15206. var _forEach = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/instance/for-each"));
  15207. var _CoreManager = _interopRequireDefault(_dereq_("./CoreManager"));
  15208. var _ParseFile = _interopRequireDefault(_dereq_("./ParseFile"));
  15209. var _ParseRelation = _interopRequireDefault(_dereq_("./ParseRelation"));
  15210. /**
  15211. * Return an array of unsaved children, which are either Parse Objects or Files.
  15212. * If it encounters any dirty Objects without Ids, it will throw an exception.
  15213. *
  15214. * @param {Parse.Object} obj
  15215. * @param {boolean} allowDeepUnsaved
  15216. * @returns {Array}
  15217. */
  15218. function unsavedChildren(obj, allowDeepUnsaved) {
  15219. const encountered = {
  15220. objects: {},
  15221. files: []
  15222. };
  15223. const identifier = obj.className + ':' + obj._getId();
  15224. encountered.objects[identifier] = obj.dirty() ? obj : true;
  15225. const attributes = obj.attributes;
  15226. for (const attr in attributes) {
  15227. if (typeof attributes[attr] === 'object') {
  15228. traverse(attributes[attr], encountered, false, !!allowDeepUnsaved);
  15229. }
  15230. }
  15231. const unsaved = [];
  15232. for (const id in encountered.objects) {
  15233. if (id !== identifier && encountered.objects[id] !== true) {
  15234. unsaved.push(encountered.objects[id]);
  15235. }
  15236. }
  15237. return (0, _concat.default)(unsaved).call(unsaved, encountered.files);
  15238. }
  15239. function traverse(obj, encountered, shouldThrow, allowDeepUnsaved) {
  15240. const ParseObject = _CoreManager.default.getParseObject();
  15241. if (obj instanceof ParseObject) {
  15242. if (!obj.id && shouldThrow) {
  15243. throw new Error('Cannot create a pointer to an unsaved Object.');
  15244. }
  15245. const identifier = obj.className + ':' + obj._getId();
  15246. if (!encountered.objects[identifier]) {
  15247. encountered.objects[identifier] = obj.dirty() ? obj : true;
  15248. const attributes = obj.attributes;
  15249. for (const attr in attributes) {
  15250. if (typeof attributes[attr] === 'object') {
  15251. traverse(attributes[attr], encountered, !allowDeepUnsaved, allowDeepUnsaved);
  15252. }
  15253. }
  15254. }
  15255. return;
  15256. }
  15257. if (obj instanceof _ParseFile.default) {
  15258. var _context;
  15259. if (!obj.url() && (0, _indexOf.default)(_context = encountered.files).call(_context, obj) < 0) {
  15260. encountered.files.push(obj);
  15261. }
  15262. return;
  15263. }
  15264. if (obj instanceof _ParseRelation.default) {
  15265. return;
  15266. }
  15267. if ((0, _isArray.default)(obj)) {
  15268. (0, _forEach.default)(obj).call(obj, el => {
  15269. if (typeof el === 'object') {
  15270. traverse(el, encountered, shouldThrow, allowDeepUnsaved);
  15271. }
  15272. });
  15273. }
  15274. for (const k in obj) {
  15275. if (typeof obj[k] === 'object') {
  15276. traverse(obj[k], encountered, shouldThrow, allowDeepUnsaved);
  15277. }
  15278. }
  15279. }
  15280. },{"./CoreManager":4,"./ParseFile":25,"./ParseRelation":34,"@babel/runtime-corejs3/core-js-stable/array/is-array":66,"@babel/runtime-corejs3/core-js-stable/instance/concat":68,"@babel/runtime-corejs3/core-js-stable/instance/for-each":74,"@babel/runtime-corejs3/core-js-stable/instance/index-of":76,"@babel/runtime-corejs3/core-js-stable/object/define-property":90,"@babel/runtime-corejs3/helpers/interopRequireDefault":103}],64:[function(_dereq_,module,exports){
  15281. "use strict";
  15282. var _Object$defineProperty = _dereq_("@babel/runtime-corejs3/core-js-stable/object/define-property");
  15283. _Object$defineProperty(exports, "__esModule", {
  15284. value: true
  15285. });
  15286. exports.default = void 0;
  15287. var _uuid = _dereq_("uuid");
  15288. let uuid = _uuid.v4;
  15289. module.exports = uuid;
  15290. var _default = exports.default = uuid;
  15291. },{"@babel/runtime-corejs3/core-js-stable/object/define-property":90,"uuid":487}],65:[function(_dereq_,module,exports){
  15292. module.exports = _dereq_("core-js-pure/stable/array/from");
  15293. },{"core-js-pure/stable/array/from":432}],66:[function(_dereq_,module,exports){
  15294. module.exports = _dereq_("core-js-pure/stable/array/is-array");
  15295. },{"core-js-pure/stable/array/is-array":433}],67:[function(_dereq_,module,exports){
  15296. module.exports = _dereq_("core-js-pure/stable/instance/bind");
  15297. },{"core-js-pure/stable/instance/bind":438}],68:[function(_dereq_,module,exports){
  15298. module.exports = _dereq_("core-js-pure/stable/instance/concat");
  15299. },{"core-js-pure/stable/instance/concat":439}],69:[function(_dereq_,module,exports){
  15300. module.exports = _dereq_("core-js-pure/stable/instance/entries");
  15301. },{"core-js-pure/stable/instance/entries":440}],70:[function(_dereq_,module,exports){
  15302. module.exports = _dereq_("core-js-pure/stable/instance/every");
  15303. },{"core-js-pure/stable/instance/every":441}],71:[function(_dereq_,module,exports){
  15304. module.exports = _dereq_("core-js-pure/stable/instance/filter");
  15305. },{"core-js-pure/stable/instance/filter":442}],72:[function(_dereq_,module,exports){
  15306. module.exports = _dereq_("core-js-pure/stable/instance/find-index");
  15307. },{"core-js-pure/stable/instance/find-index":443}],73:[function(_dereq_,module,exports){
  15308. module.exports = _dereq_("core-js-pure/stable/instance/find");
  15309. },{"core-js-pure/stable/instance/find":444}],74:[function(_dereq_,module,exports){
  15310. module.exports = _dereq_("core-js-pure/stable/instance/for-each");
  15311. },{"core-js-pure/stable/instance/for-each":445}],75:[function(_dereq_,module,exports){
  15312. module.exports = _dereq_("core-js-pure/stable/instance/includes");
  15313. },{"core-js-pure/stable/instance/includes":446}],76:[function(_dereq_,module,exports){
  15314. module.exports = _dereq_("core-js-pure/stable/instance/index-of");
  15315. },{"core-js-pure/stable/instance/index-of":447}],77:[function(_dereq_,module,exports){
  15316. module.exports = _dereq_("core-js-pure/stable/instance/keys");
  15317. },{"core-js-pure/stable/instance/keys":448}],78:[function(_dereq_,module,exports){
  15318. module.exports = _dereq_("core-js-pure/stable/instance/map");
  15319. },{"core-js-pure/stable/instance/map":449}],79:[function(_dereq_,module,exports){
  15320. module.exports = _dereq_("core-js-pure/stable/instance/reduce");
  15321. },{"core-js-pure/stable/instance/reduce":450}],80:[function(_dereq_,module,exports){
  15322. module.exports = _dereq_("core-js-pure/stable/instance/slice");
  15323. },{"core-js-pure/stable/instance/slice":451}],81:[function(_dereq_,module,exports){
  15324. module.exports = _dereq_("core-js-pure/stable/instance/sort");
  15325. },{"core-js-pure/stable/instance/sort":452}],82:[function(_dereq_,module,exports){
  15326. module.exports = _dereq_("core-js-pure/stable/instance/splice");
  15327. },{"core-js-pure/stable/instance/splice":453}],83:[function(_dereq_,module,exports){
  15328. module.exports = _dereq_("core-js-pure/stable/instance/starts-with");
  15329. },{"core-js-pure/stable/instance/starts-with":454}],84:[function(_dereq_,module,exports){
  15330. module.exports = _dereq_("core-js-pure/stable/instance/values");
  15331. },{"core-js-pure/stable/instance/values":455}],85:[function(_dereq_,module,exports){
  15332. module.exports = _dereq_("core-js-pure/stable/json/stringify");
  15333. },{"core-js-pure/stable/json/stringify":456}],86:[function(_dereq_,module,exports){
  15334. module.exports = _dereq_("core-js-pure/stable/map");
  15335. },{"core-js-pure/stable/map":457}],87:[function(_dereq_,module,exports){
  15336. module.exports = _dereq_("core-js-pure/stable/number/is-integer");
  15337. },{"core-js-pure/stable/number/is-integer":458}],88:[function(_dereq_,module,exports){
  15338. module.exports = _dereq_("core-js-pure/stable/object/assign");
  15339. },{"core-js-pure/stable/object/assign":459}],89:[function(_dereq_,module,exports){
  15340. module.exports = _dereq_("core-js-pure/stable/object/create");
  15341. },{"core-js-pure/stable/object/create":460}],90:[function(_dereq_,module,exports){
  15342. module.exports = _dereq_("core-js-pure/stable/object/define-property");
  15343. },{"core-js-pure/stable/object/define-property":461}],91:[function(_dereq_,module,exports){
  15344. module.exports = _dereq_("core-js-pure/stable/object/entries");
  15345. },{"core-js-pure/stable/object/entries":462}],92:[function(_dereq_,module,exports){
  15346. module.exports = _dereq_("core-js-pure/stable/object/freeze");
  15347. },{"core-js-pure/stable/object/freeze":463}],93:[function(_dereq_,module,exports){
  15348. module.exports = _dereq_("core-js-pure/stable/object/get-own-property-descriptor");
  15349. },{"core-js-pure/stable/object/get-own-property-descriptor":464}],94:[function(_dereq_,module,exports){
  15350. module.exports = _dereq_("core-js-pure/stable/object/get-prototype-of");
  15351. },{"core-js-pure/stable/object/get-prototype-of":465}],95:[function(_dereq_,module,exports){
  15352. module.exports = _dereq_("core-js-pure/stable/object/keys");
  15353. },{"core-js-pure/stable/object/keys":466}],96:[function(_dereq_,module,exports){
  15354. module.exports = _dereq_("core-js-pure/stable/parse-int");
  15355. },{"core-js-pure/stable/parse-int":467}],97:[function(_dereq_,module,exports){
  15356. module.exports = _dereq_("core-js-pure/stable/promise");
  15357. },{"core-js-pure/stable/promise":468}],98:[function(_dereq_,module,exports){
  15358. module.exports = _dereq_("core-js-pure/stable/set-interval");
  15359. },{"core-js-pure/stable/set-interval":469}],99:[function(_dereq_,module,exports){
  15360. module.exports = _dereq_("core-js-pure/stable/set-timeout");
  15361. },{"core-js-pure/stable/set-timeout":470}],100:[function(_dereq_,module,exports){
  15362. module.exports = _dereq_("core-js-pure/stable/set");
  15363. },{"core-js-pure/stable/set":471}],101:[function(_dereq_,module,exports){
  15364. module.exports = _dereq_("core-js-pure/stable/weak-map");
  15365. },{"core-js-pure/stable/weak-map":475}],102:[function(_dereq_,module,exports){
  15366. var _Object$defineProperty = _dereq_("core-js-pure/features/object/define-property.js");
  15367. var toPropertyKey = _dereq_("./toPropertyKey.js");
  15368. function _defineProperty(e, r, t) {
  15369. return (r = toPropertyKey(r)) in e ? _Object$defineProperty(e, r, {
  15370. value: t,
  15371. enumerable: !0,
  15372. configurable: !0,
  15373. writable: !0
  15374. }) : e[r] = t, e;
  15375. }
  15376. module.exports = _defineProperty, module.exports.__esModule = true, module.exports["default"] = module.exports;
  15377. },{"./toPropertyKey.js":105,"core-js-pure/features/object/define-property.js":165}],103:[function(_dereq_,module,exports){
  15378. function _interopRequireDefault(e) {
  15379. return e && e.__esModule ? e : {
  15380. "default": e
  15381. };
  15382. }
  15383. module.exports = _interopRequireDefault, module.exports.__esModule = true, module.exports["default"] = module.exports;
  15384. },{}],104:[function(_dereq_,module,exports){
  15385. var _Symbol$toPrimitive = _dereq_("core-js-pure/features/symbol/to-primitive.js");
  15386. var _typeof = _dereq_("./typeof.js")["default"];
  15387. function toPrimitive(t, r) {
  15388. if ("object" != _typeof(t) || !t) return t;
  15389. var e = t[_Symbol$toPrimitive];
  15390. if (void 0 !== e) {
  15391. var i = e.call(t, r || "default");
  15392. if ("object" != _typeof(i)) return i;
  15393. throw new TypeError("@@toPrimitive must return a primitive value.");
  15394. }
  15395. return ("string" === r ? String : Number)(t);
  15396. }
  15397. module.exports = toPrimitive, module.exports.__esModule = true, module.exports["default"] = module.exports;
  15398. },{"./typeof.js":106,"core-js-pure/features/symbol/to-primitive.js":168}],105:[function(_dereq_,module,exports){
  15399. var _typeof = _dereq_("./typeof.js")["default"];
  15400. var toPrimitive = _dereq_("./toPrimitive.js");
  15401. function toPropertyKey(t) {
  15402. var i = toPrimitive(t, "string");
  15403. return "symbol" == _typeof(i) ? i : i + "";
  15404. }
  15405. module.exports = toPropertyKey, module.exports.__esModule = true, module.exports["default"] = module.exports;
  15406. },{"./toPrimitive.js":104,"./typeof.js":106}],106:[function(_dereq_,module,exports){
  15407. var _Symbol = _dereq_("core-js-pure/features/symbol/index.js");
  15408. var _Symbol$iterator = _dereq_("core-js-pure/features/symbol/iterator.js");
  15409. function _typeof(o) {
  15410. "@babel/helpers - typeof";
  15411. return (module.exports = _typeof = "function" == typeof _Symbol && "symbol" == typeof _Symbol$iterator ? function (o) {
  15412. return typeof o;
  15413. } : function (o) {
  15414. return o && "function" == typeof _Symbol && o.constructor === _Symbol && o !== _Symbol.prototype ? "symbol" : typeof o;
  15415. }, module.exports.__esModule = true, module.exports["default"] = module.exports), _typeof(o);
  15416. }
  15417. module.exports = _typeof, module.exports.__esModule = true, module.exports["default"] = module.exports;
  15418. },{"core-js-pure/features/symbol/index.js":166,"core-js-pure/features/symbol/iterator.js":167}],107:[function(_dereq_,module,exports){
  15419. },{}],108:[function(_dereq_,module,exports){
  15420. var parent = _dereq_('../../stable/object/define-property');
  15421. module.exports = parent;
  15422. },{"../../stable/object/define-property":461}],109:[function(_dereq_,module,exports){
  15423. var parent = _dereq_('../../stable/symbol');
  15424. _dereq_('../../modules/esnext.symbol.dispose');
  15425. module.exports = parent;
  15426. },{"../../modules/esnext.symbol.dispose":419,"../../stable/symbol":472}],110:[function(_dereq_,module,exports){
  15427. var parent = _dereq_('../../stable/symbol/iterator');
  15428. module.exports = parent;
  15429. },{"../../stable/symbol/iterator":473}],111:[function(_dereq_,module,exports){
  15430. var parent = _dereq_('../../stable/symbol/to-primitive');
  15431. module.exports = parent;
  15432. },{"../../stable/symbol/to-primitive":474}],112:[function(_dereq_,module,exports){
  15433. _dereq_('../../modules/es.string.iterator');
  15434. _dereq_('../../modules/es.array.from');
  15435. var path = _dereq_('../../internals/path');
  15436. module.exports = path.Array.from;
  15437. },{"../../internals/path":305,"../../modules/es.array.from":353,"../../modules/es.string.iterator":396}],113:[function(_dereq_,module,exports){
  15438. _dereq_('../../modules/es.array.is-array');
  15439. var path = _dereq_('../../internals/path');
  15440. module.exports = path.Array.isArray;
  15441. },{"../../internals/path":305,"../../modules/es.array.is-array":356}],114:[function(_dereq_,module,exports){
  15442. _dereq_('../../../modules/es.array.concat');
  15443. var entryVirtual = _dereq_('../../../internals/entry-virtual');
  15444. module.exports = entryVirtual('Array').concat;
  15445. },{"../../../internals/entry-virtual":229,"../../../modules/es.array.concat":347}],115:[function(_dereq_,module,exports){
  15446. _dereq_('../../../modules/es.array.iterator');
  15447. _dereq_('../../../modules/es.object.to-string');
  15448. var entryVirtual = _dereq_('../../../internals/entry-virtual');
  15449. module.exports = entryVirtual('Array').entries;
  15450. },{"../../../internals/entry-virtual":229,"../../../modules/es.array.iterator":357,"../../../modules/es.object.to-string":380}],116:[function(_dereq_,module,exports){
  15451. _dereq_('../../../modules/es.array.every');
  15452. var entryVirtual = _dereq_('../../../internals/entry-virtual');
  15453. module.exports = entryVirtual('Array').every;
  15454. },{"../../../internals/entry-virtual":229,"../../../modules/es.array.every":348}],117:[function(_dereq_,module,exports){
  15455. _dereq_('../../../modules/es.array.filter');
  15456. var entryVirtual = _dereq_('../../../internals/entry-virtual');
  15457. module.exports = entryVirtual('Array').filter;
  15458. },{"../../../internals/entry-virtual":229,"../../../modules/es.array.filter":349}],118:[function(_dereq_,module,exports){
  15459. _dereq_('../../../modules/es.array.find-index');
  15460. var entryVirtual = _dereq_('../../../internals/entry-virtual');
  15461. module.exports = entryVirtual('Array').findIndex;
  15462. },{"../../../internals/entry-virtual":229,"../../../modules/es.array.find-index":350}],119:[function(_dereq_,module,exports){
  15463. _dereq_('../../../modules/es.array.find');
  15464. var entryVirtual = _dereq_('../../../internals/entry-virtual');
  15465. module.exports = entryVirtual('Array').find;
  15466. },{"../../../internals/entry-virtual":229,"../../../modules/es.array.find":351}],120:[function(_dereq_,module,exports){
  15467. _dereq_('../../../modules/es.array.for-each');
  15468. var entryVirtual = _dereq_('../../../internals/entry-virtual');
  15469. module.exports = entryVirtual('Array').forEach;
  15470. },{"../../../internals/entry-virtual":229,"../../../modules/es.array.for-each":352}],121:[function(_dereq_,module,exports){
  15471. _dereq_('../../../modules/es.array.includes');
  15472. var entryVirtual = _dereq_('../../../internals/entry-virtual');
  15473. module.exports = entryVirtual('Array').includes;
  15474. },{"../../../internals/entry-virtual":229,"../../../modules/es.array.includes":354}],122:[function(_dereq_,module,exports){
  15475. _dereq_('../../../modules/es.array.index-of');
  15476. var entryVirtual = _dereq_('../../../internals/entry-virtual');
  15477. module.exports = entryVirtual('Array').indexOf;
  15478. },{"../../../internals/entry-virtual":229,"../../../modules/es.array.index-of":355}],123:[function(_dereq_,module,exports){
  15479. _dereq_('../../../modules/es.array.iterator');
  15480. _dereq_('../../../modules/es.object.to-string');
  15481. var entryVirtual = _dereq_('../../../internals/entry-virtual');
  15482. module.exports = entryVirtual('Array').keys;
  15483. },{"../../../internals/entry-virtual":229,"../../../modules/es.array.iterator":357,"../../../modules/es.object.to-string":380}],124:[function(_dereq_,module,exports){
  15484. _dereq_('../../../modules/es.array.map');
  15485. var entryVirtual = _dereq_('../../../internals/entry-virtual');
  15486. module.exports = entryVirtual('Array').map;
  15487. },{"../../../internals/entry-virtual":229,"../../../modules/es.array.map":358}],125:[function(_dereq_,module,exports){
  15488. _dereq_('../../../modules/es.array.reduce');
  15489. var entryVirtual = _dereq_('../../../internals/entry-virtual');
  15490. module.exports = entryVirtual('Array').reduce;
  15491. },{"../../../internals/entry-virtual":229,"../../../modules/es.array.reduce":359}],126:[function(_dereq_,module,exports){
  15492. _dereq_('../../../modules/es.array.slice');
  15493. var entryVirtual = _dereq_('../../../internals/entry-virtual');
  15494. module.exports = entryVirtual('Array').slice;
  15495. },{"../../../internals/entry-virtual":229,"../../../modules/es.array.slice":360}],127:[function(_dereq_,module,exports){
  15496. _dereq_('../../../modules/es.array.sort');
  15497. var entryVirtual = _dereq_('../../../internals/entry-virtual');
  15498. module.exports = entryVirtual('Array').sort;
  15499. },{"../../../internals/entry-virtual":229,"../../../modules/es.array.sort":361}],128:[function(_dereq_,module,exports){
  15500. _dereq_('../../../modules/es.array.splice');
  15501. var entryVirtual = _dereq_('../../../internals/entry-virtual');
  15502. module.exports = entryVirtual('Array').splice;
  15503. },{"../../../internals/entry-virtual":229,"../../../modules/es.array.splice":362}],129:[function(_dereq_,module,exports){
  15504. _dereq_('../../../modules/es.array.iterator');
  15505. _dereq_('../../../modules/es.object.to-string');
  15506. var entryVirtual = _dereq_('../../../internals/entry-virtual');
  15507. module.exports = entryVirtual('Array').values;
  15508. },{"../../../internals/entry-virtual":229,"../../../modules/es.array.iterator":357,"../../../modules/es.object.to-string":380}],130:[function(_dereq_,module,exports){
  15509. _dereq_('../../../modules/es.function.bind');
  15510. var entryVirtual = _dereq_('../../../internals/entry-virtual');
  15511. module.exports = entryVirtual('Function').bind;
  15512. },{"../../../internals/entry-virtual":229,"../../../modules/es.function.bind":364}],131:[function(_dereq_,module,exports){
  15513. var isPrototypeOf = _dereq_('../../internals/object-is-prototype-of');
  15514. var method = _dereq_('../function/virtual/bind');
  15515. var FunctionPrototype = Function.prototype;
  15516. module.exports = function (it) {
  15517. var own = it.bind;
  15518. return it === FunctionPrototype || (isPrototypeOf(FunctionPrototype, it) && own === FunctionPrototype.bind) ? method : own;
  15519. };
  15520. },{"../../internals/object-is-prototype-of":296,"../function/virtual/bind":130}],132:[function(_dereq_,module,exports){
  15521. var isPrototypeOf = _dereq_('../../internals/object-is-prototype-of');
  15522. var method = _dereq_('../array/virtual/concat');
  15523. var ArrayPrototype = Array.prototype;
  15524. module.exports = function (it) {
  15525. var own = it.concat;
  15526. return it === ArrayPrototype || (isPrototypeOf(ArrayPrototype, it) && own === ArrayPrototype.concat) ? method : own;
  15527. };
  15528. },{"../../internals/object-is-prototype-of":296,"../array/virtual/concat":114}],133:[function(_dereq_,module,exports){
  15529. var isPrototypeOf = _dereq_('../../internals/object-is-prototype-of');
  15530. var method = _dereq_('../array/virtual/every');
  15531. var ArrayPrototype = Array.prototype;
  15532. module.exports = function (it) {
  15533. var own = it.every;
  15534. return it === ArrayPrototype || (isPrototypeOf(ArrayPrototype, it) && own === ArrayPrototype.every) ? method : own;
  15535. };
  15536. },{"../../internals/object-is-prototype-of":296,"../array/virtual/every":116}],134:[function(_dereq_,module,exports){
  15537. var isPrototypeOf = _dereq_('../../internals/object-is-prototype-of');
  15538. var method = _dereq_('../array/virtual/filter');
  15539. var ArrayPrototype = Array.prototype;
  15540. module.exports = function (it) {
  15541. var own = it.filter;
  15542. return it === ArrayPrototype || (isPrototypeOf(ArrayPrototype, it) && own === ArrayPrototype.filter) ? method : own;
  15543. };
  15544. },{"../../internals/object-is-prototype-of":296,"../array/virtual/filter":117}],135:[function(_dereq_,module,exports){
  15545. var isPrototypeOf = _dereq_('../../internals/object-is-prototype-of');
  15546. var method = _dereq_('../array/virtual/find-index');
  15547. var ArrayPrototype = Array.prototype;
  15548. module.exports = function (it) {
  15549. var own = it.findIndex;
  15550. return it === ArrayPrototype || (isPrototypeOf(ArrayPrototype, it) && own === ArrayPrototype.findIndex) ? method : own;
  15551. };
  15552. },{"../../internals/object-is-prototype-of":296,"../array/virtual/find-index":118}],136:[function(_dereq_,module,exports){
  15553. var isPrototypeOf = _dereq_('../../internals/object-is-prototype-of');
  15554. var method = _dereq_('../array/virtual/find');
  15555. var ArrayPrototype = Array.prototype;
  15556. module.exports = function (it) {
  15557. var own = it.find;
  15558. return it === ArrayPrototype || (isPrototypeOf(ArrayPrototype, it) && own === ArrayPrototype.find) ? method : own;
  15559. };
  15560. },{"../../internals/object-is-prototype-of":296,"../array/virtual/find":119}],137:[function(_dereq_,module,exports){
  15561. var isPrototypeOf = _dereq_('../../internals/object-is-prototype-of');
  15562. var arrayMethod = _dereq_('../array/virtual/includes');
  15563. var stringMethod = _dereq_('../string/virtual/includes');
  15564. var ArrayPrototype = Array.prototype;
  15565. var StringPrototype = String.prototype;
  15566. module.exports = function (it) {
  15567. var own = it.includes;
  15568. if (it === ArrayPrototype || (isPrototypeOf(ArrayPrototype, it) && own === ArrayPrototype.includes)) return arrayMethod;
  15569. if (typeof it == 'string' || it === StringPrototype || (isPrototypeOf(StringPrototype, it) && own === StringPrototype.includes)) {
  15570. return stringMethod;
  15571. } return own;
  15572. };
  15573. },{"../../internals/object-is-prototype-of":296,"../array/virtual/includes":121,"../string/virtual/includes":159}],138:[function(_dereq_,module,exports){
  15574. var isPrototypeOf = _dereq_('../../internals/object-is-prototype-of');
  15575. var method = _dereq_('../array/virtual/index-of');
  15576. var ArrayPrototype = Array.prototype;
  15577. module.exports = function (it) {
  15578. var own = it.indexOf;
  15579. return it === ArrayPrototype || (isPrototypeOf(ArrayPrototype, it) && own === ArrayPrototype.indexOf) ? method : own;
  15580. };
  15581. },{"../../internals/object-is-prototype-of":296,"../array/virtual/index-of":122}],139:[function(_dereq_,module,exports){
  15582. var isPrototypeOf = _dereq_('../../internals/object-is-prototype-of');
  15583. var method = _dereq_('../array/virtual/map');
  15584. var ArrayPrototype = Array.prototype;
  15585. module.exports = function (it) {
  15586. var own = it.map;
  15587. return it === ArrayPrototype || (isPrototypeOf(ArrayPrototype, it) && own === ArrayPrototype.map) ? method : own;
  15588. };
  15589. },{"../../internals/object-is-prototype-of":296,"../array/virtual/map":124}],140:[function(_dereq_,module,exports){
  15590. var isPrototypeOf = _dereq_('../../internals/object-is-prototype-of');
  15591. var method = _dereq_('../array/virtual/reduce');
  15592. var ArrayPrototype = Array.prototype;
  15593. module.exports = function (it) {
  15594. var own = it.reduce;
  15595. return it === ArrayPrototype || (isPrototypeOf(ArrayPrototype, it) && own === ArrayPrototype.reduce) ? method : own;
  15596. };
  15597. },{"../../internals/object-is-prototype-of":296,"../array/virtual/reduce":125}],141:[function(_dereq_,module,exports){
  15598. var isPrototypeOf = _dereq_('../../internals/object-is-prototype-of');
  15599. var method = _dereq_('../array/virtual/slice');
  15600. var ArrayPrototype = Array.prototype;
  15601. module.exports = function (it) {
  15602. var own = it.slice;
  15603. return it === ArrayPrototype || (isPrototypeOf(ArrayPrototype, it) && own === ArrayPrototype.slice) ? method : own;
  15604. };
  15605. },{"../../internals/object-is-prototype-of":296,"../array/virtual/slice":126}],142:[function(_dereq_,module,exports){
  15606. var isPrototypeOf = _dereq_('../../internals/object-is-prototype-of');
  15607. var method = _dereq_('../array/virtual/sort');
  15608. var ArrayPrototype = Array.prototype;
  15609. module.exports = function (it) {
  15610. var own = it.sort;
  15611. return it === ArrayPrototype || (isPrototypeOf(ArrayPrototype, it) && own === ArrayPrototype.sort) ? method : own;
  15612. };
  15613. },{"../../internals/object-is-prototype-of":296,"../array/virtual/sort":127}],143:[function(_dereq_,module,exports){
  15614. var isPrototypeOf = _dereq_('../../internals/object-is-prototype-of');
  15615. var method = _dereq_('../array/virtual/splice');
  15616. var ArrayPrototype = Array.prototype;
  15617. module.exports = function (it) {
  15618. var own = it.splice;
  15619. return it === ArrayPrototype || (isPrototypeOf(ArrayPrototype, it) && own === ArrayPrototype.splice) ? method : own;
  15620. };
  15621. },{"../../internals/object-is-prototype-of":296,"../array/virtual/splice":128}],144:[function(_dereq_,module,exports){
  15622. var isPrototypeOf = _dereq_('../../internals/object-is-prototype-of');
  15623. var method = _dereq_('../string/virtual/starts-with');
  15624. var StringPrototype = String.prototype;
  15625. module.exports = function (it) {
  15626. var own = it.startsWith;
  15627. return typeof it == 'string' || it === StringPrototype
  15628. || (isPrototypeOf(StringPrototype, it) && own === StringPrototype.startsWith) ? method : own;
  15629. };
  15630. },{"../../internals/object-is-prototype-of":296,"../string/virtual/starts-with":160}],145:[function(_dereq_,module,exports){
  15631. _dereq_('../../modules/es.json.stringify');
  15632. var path = _dereq_('../../internals/path');
  15633. var apply = _dereq_('../../internals/function-apply');
  15634. // eslint-disable-next-line es/no-json -- safe
  15635. if (!path.JSON) path.JSON = { stringify: JSON.stringify };
  15636. // eslint-disable-next-line no-unused-vars -- required for `.length`
  15637. module.exports = function stringify(it, replacer, space) {
  15638. return apply(path.JSON.stringify, null, arguments);
  15639. };
  15640. },{"../../internals/function-apply":237,"../../internals/path":305,"../../modules/es.json.stringify":365}],146:[function(_dereq_,module,exports){
  15641. _dereq_('../../modules/es.array.iterator');
  15642. _dereq_('../../modules/es.map');
  15643. _dereq_('../../modules/es.object.to-string');
  15644. _dereq_('../../modules/es.string.iterator');
  15645. var path = _dereq_('../../internals/path');
  15646. module.exports = path.Map;
  15647. },{"../../internals/path":305,"../../modules/es.array.iterator":357,"../../modules/es.map":368,"../../modules/es.object.to-string":380,"../../modules/es.string.iterator":396}],147:[function(_dereq_,module,exports){
  15648. _dereq_('../../modules/es.number.is-integer');
  15649. var path = _dereq_('../../internals/path');
  15650. module.exports = path.Number.isInteger;
  15651. },{"../../internals/path":305,"../../modules/es.number.is-integer":370}],148:[function(_dereq_,module,exports){
  15652. _dereq_('../../modules/es.object.assign');
  15653. var path = _dereq_('../../internals/path');
  15654. module.exports = path.Object.assign;
  15655. },{"../../internals/path":305,"../../modules/es.object.assign":371}],149:[function(_dereq_,module,exports){
  15656. _dereq_('../../modules/es.object.create');
  15657. var path = _dereq_('../../internals/path');
  15658. var Object = path.Object;
  15659. module.exports = function create(P, D) {
  15660. return Object.create(P, D);
  15661. };
  15662. },{"../../internals/path":305,"../../modules/es.object.create":372}],150:[function(_dereq_,module,exports){
  15663. _dereq_('../../modules/es.object.define-property');
  15664. var path = _dereq_('../../internals/path');
  15665. var Object = path.Object;
  15666. var defineProperty = module.exports = function defineProperty(it, key, desc) {
  15667. return Object.defineProperty(it, key, desc);
  15668. };
  15669. if (Object.defineProperty.sham) defineProperty.sham = true;
  15670. },{"../../internals/path":305,"../../modules/es.object.define-property":373}],151:[function(_dereq_,module,exports){
  15671. _dereq_('../../modules/es.object.entries');
  15672. var path = _dereq_('../../internals/path');
  15673. module.exports = path.Object.entries;
  15674. },{"../../internals/path":305,"../../modules/es.object.entries":374}],152:[function(_dereq_,module,exports){
  15675. _dereq_('../../modules/es.object.freeze');
  15676. var path = _dereq_('../../internals/path');
  15677. module.exports = path.Object.freeze;
  15678. },{"../../internals/path":305,"../../modules/es.object.freeze":375}],153:[function(_dereq_,module,exports){
  15679. _dereq_('../../modules/es.object.get-own-property-descriptor');
  15680. var path = _dereq_('../../internals/path');
  15681. var Object = path.Object;
  15682. var getOwnPropertyDescriptor = module.exports = function getOwnPropertyDescriptor(it, key) {
  15683. return Object.getOwnPropertyDescriptor(it, key);
  15684. };
  15685. if (Object.getOwnPropertyDescriptor.sham) getOwnPropertyDescriptor.sham = true;
  15686. },{"../../internals/path":305,"../../modules/es.object.get-own-property-descriptor":376}],154:[function(_dereq_,module,exports){
  15687. _dereq_('../../modules/es.object.get-prototype-of');
  15688. var path = _dereq_('../../internals/path');
  15689. module.exports = path.Object.getPrototypeOf;
  15690. },{"../../internals/path":305,"../../modules/es.object.get-prototype-of":378}],155:[function(_dereq_,module,exports){
  15691. _dereq_('../../modules/es.object.keys');
  15692. var path = _dereq_('../../internals/path');
  15693. module.exports = path.Object.keys;
  15694. },{"../../internals/path":305,"../../modules/es.object.keys":379}],156:[function(_dereq_,module,exports){
  15695. _dereq_('../modules/es.parse-int');
  15696. var path = _dereq_('../internals/path');
  15697. module.exports = path.parseInt;
  15698. },{"../internals/path":305,"../modules/es.parse-int":381}],157:[function(_dereq_,module,exports){
  15699. _dereq_('../../modules/es.aggregate-error');
  15700. _dereq_('../../modules/es.array.iterator');
  15701. _dereq_('../../modules/es.object.to-string');
  15702. _dereq_('../../modules/es.promise');
  15703. _dereq_('../../modules/es.promise.all-settled');
  15704. _dereq_('../../modules/es.promise.any');
  15705. _dereq_('../../modules/es.promise.finally');
  15706. _dereq_('../../modules/es.string.iterator');
  15707. var path = _dereq_('../../internals/path');
  15708. module.exports = path.Promise;
  15709. },{"../../internals/path":305,"../../modules/es.aggregate-error":346,"../../modules/es.array.iterator":357,"../../modules/es.object.to-string":380,"../../modules/es.promise":388,"../../modules/es.promise.all-settled":382,"../../modules/es.promise.any":384,"../../modules/es.promise.finally":387,"../../modules/es.string.iterator":396}],158:[function(_dereq_,module,exports){
  15710. _dereq_('../../modules/es.array.iterator');
  15711. _dereq_('../../modules/es.object.to-string');
  15712. _dereq_('../../modules/es.set');
  15713. _dereq_('../../modules/es.string.iterator');
  15714. var path = _dereq_('../../internals/path');
  15715. module.exports = path.Set;
  15716. },{"../../internals/path":305,"../../modules/es.array.iterator":357,"../../modules/es.object.to-string":380,"../../modules/es.set":394,"../../modules/es.string.iterator":396}],159:[function(_dereq_,module,exports){
  15717. _dereq_('../../../modules/es.string.includes');
  15718. var entryVirtual = _dereq_('../../../internals/entry-virtual');
  15719. module.exports = entryVirtual('String').includes;
  15720. },{"../../../internals/entry-virtual":229,"../../../modules/es.string.includes":395}],160:[function(_dereq_,module,exports){
  15721. _dereq_('../../../modules/es.string.starts-with');
  15722. var entryVirtual = _dereq_('../../../internals/entry-virtual');
  15723. module.exports = entryVirtual('String').startsWith;
  15724. },{"../../../internals/entry-virtual":229,"../../../modules/es.string.starts-with":397}],161:[function(_dereq_,module,exports){
  15725. _dereq_('../../modules/es.array.concat');
  15726. _dereq_('../../modules/es.object.to-string');
  15727. _dereq_('../../modules/es.symbol');
  15728. _dereq_('../../modules/es.symbol.async-iterator');
  15729. _dereq_('../../modules/es.symbol.description');
  15730. _dereq_('../../modules/es.symbol.has-instance');
  15731. _dereq_('../../modules/es.symbol.is-concat-spreadable');
  15732. _dereq_('../../modules/es.symbol.iterator');
  15733. _dereq_('../../modules/es.symbol.match');
  15734. _dereq_('../../modules/es.symbol.match-all');
  15735. _dereq_('../../modules/es.symbol.replace');
  15736. _dereq_('../../modules/es.symbol.search');
  15737. _dereq_('../../modules/es.symbol.species');
  15738. _dereq_('../../modules/es.symbol.split');
  15739. _dereq_('../../modules/es.symbol.to-primitive');
  15740. _dereq_('../../modules/es.symbol.to-string-tag');
  15741. _dereq_('../../modules/es.symbol.unscopables');
  15742. _dereq_('../../modules/es.json.to-string-tag');
  15743. _dereq_('../../modules/es.math.to-string-tag');
  15744. _dereq_('../../modules/es.reflect.to-string-tag');
  15745. var path = _dereq_('../../internals/path');
  15746. module.exports = path.Symbol;
  15747. },{"../../internals/path":305,"../../modules/es.array.concat":347,"../../modules/es.json.to-string-tag":366,"../../modules/es.math.to-string-tag":369,"../../modules/es.object.to-string":380,"../../modules/es.reflect.to-string-tag":392,"../../modules/es.symbol":405,"../../modules/es.symbol.async-iterator":398,"../../modules/es.symbol.description":400,"../../modules/es.symbol.has-instance":402,"../../modules/es.symbol.is-concat-spreadable":403,"../../modules/es.symbol.iterator":404,"../../modules/es.symbol.match":408,"../../modules/es.symbol.match-all":407,"../../modules/es.symbol.replace":409,"../../modules/es.symbol.search":410,"../../modules/es.symbol.species":411,"../../modules/es.symbol.split":412,"../../modules/es.symbol.to-primitive":413,"../../modules/es.symbol.to-string-tag":414,"../../modules/es.symbol.unscopables":415}],162:[function(_dereq_,module,exports){
  15748. _dereq_('../../modules/es.array.iterator');
  15749. _dereq_('../../modules/es.object.to-string');
  15750. _dereq_('../../modules/es.string.iterator');
  15751. _dereq_('../../modules/es.symbol.iterator');
  15752. var WrappedWellKnownSymbolModule = _dereq_('../../internals/well-known-symbol-wrapped');
  15753. module.exports = WrappedWellKnownSymbolModule.f('iterator');
  15754. },{"../../internals/well-known-symbol-wrapped":342,"../../modules/es.array.iterator":357,"../../modules/es.object.to-string":380,"../../modules/es.string.iterator":396,"../../modules/es.symbol.iterator":404}],163:[function(_dereq_,module,exports){
  15755. _dereq_('../../modules/es.date.to-primitive');
  15756. _dereq_('../../modules/es.symbol.to-primitive');
  15757. var WrappedWellKnownSymbolModule = _dereq_('../../internals/well-known-symbol-wrapped');
  15758. module.exports = WrappedWellKnownSymbolModule.f('toPrimitive');
  15759. },{"../../internals/well-known-symbol-wrapped":342,"../../modules/es.date.to-primitive":363,"../../modules/es.symbol.to-primitive":413}],164:[function(_dereq_,module,exports){
  15760. _dereq_('../../modules/es.array.iterator');
  15761. _dereq_('../../modules/es.object.to-string');
  15762. _dereq_('../../modules/es.weak-map');
  15763. var path = _dereq_('../../internals/path');
  15764. module.exports = path.WeakMap;
  15765. },{"../../internals/path":305,"../../modules/es.array.iterator":357,"../../modules/es.object.to-string":380,"../../modules/es.weak-map":417}],165:[function(_dereq_,module,exports){
  15766. module.exports = _dereq_('../../full/object/define-property');
  15767. },{"../../full/object/define-property":169}],166:[function(_dereq_,module,exports){
  15768. module.exports = _dereq_('../../full/symbol');
  15769. },{"../../full/symbol":170}],167:[function(_dereq_,module,exports){
  15770. module.exports = _dereq_('../../full/symbol/iterator');
  15771. },{"../../full/symbol/iterator":171}],168:[function(_dereq_,module,exports){
  15772. module.exports = _dereq_('../../full/symbol/to-primitive');
  15773. },{"../../full/symbol/to-primitive":172}],169:[function(_dereq_,module,exports){
  15774. var parent = _dereq_('../../actual/object/define-property');
  15775. module.exports = parent;
  15776. },{"../../actual/object/define-property":108}],170:[function(_dereq_,module,exports){
  15777. var parent = _dereq_('../../actual/symbol');
  15778. _dereq_('../../modules/esnext.symbol.async-dispose');
  15779. _dereq_('../../modules/esnext.symbol.is-registered');
  15780. _dereq_('../../modules/esnext.symbol.is-well-known');
  15781. _dereq_('../../modules/esnext.symbol.matcher');
  15782. _dereq_('../../modules/esnext.symbol.metadata-key');
  15783. _dereq_('../../modules/esnext.symbol.observable');
  15784. // TODO: Remove from `core-js@4`
  15785. _dereq_('../../modules/esnext.symbol.metadata');
  15786. _dereq_('../../modules/esnext.symbol.pattern-match');
  15787. _dereq_('../../modules/esnext.symbol.replace-all');
  15788. module.exports = parent;
  15789. },{"../../actual/symbol":109,"../../modules/esnext.symbol.async-dispose":418,"../../modules/esnext.symbol.is-registered":420,"../../modules/esnext.symbol.is-well-known":421,"../../modules/esnext.symbol.matcher":422,"../../modules/esnext.symbol.metadata":424,"../../modules/esnext.symbol.metadata-key":423,"../../modules/esnext.symbol.observable":425,"../../modules/esnext.symbol.pattern-match":426,"../../modules/esnext.symbol.replace-all":427}],171:[function(_dereq_,module,exports){
  15790. var parent = _dereq_('../../actual/symbol/iterator');
  15791. module.exports = parent;
  15792. },{"../../actual/symbol/iterator":110}],172:[function(_dereq_,module,exports){
  15793. var parent = _dereq_('../../actual/symbol/to-primitive');
  15794. module.exports = parent;
  15795. },{"../../actual/symbol/to-primitive":111}],173:[function(_dereq_,module,exports){
  15796. var isCallable = _dereq_('../internals/is-callable');
  15797. var tryToString = _dereq_('../internals/try-to-string');
  15798. var $TypeError = TypeError;
  15799. // `Assert: IsCallable(argument) is true`
  15800. module.exports = function (argument) {
  15801. if (isCallable(argument)) return argument;
  15802. throw $TypeError(tryToString(argument) + ' is not a function');
  15803. };
  15804. },{"../internals/is-callable":264,"../internals/try-to-string":335}],174:[function(_dereq_,module,exports){
  15805. var isConstructor = _dereq_('../internals/is-constructor');
  15806. var tryToString = _dereq_('../internals/try-to-string');
  15807. var $TypeError = TypeError;
  15808. // `Assert: IsConstructor(argument) is true`
  15809. module.exports = function (argument) {
  15810. if (isConstructor(argument)) return argument;
  15811. throw $TypeError(tryToString(argument) + ' is not a constructor');
  15812. };
  15813. },{"../internals/is-constructor":265,"../internals/try-to-string":335}],175:[function(_dereq_,module,exports){
  15814. var isCallable = _dereq_('../internals/is-callable');
  15815. var $String = String;
  15816. var $TypeError = TypeError;
  15817. module.exports = function (argument) {
  15818. if (typeof argument == 'object' || isCallable(argument)) return argument;
  15819. throw $TypeError("Can't set " + $String(argument) + ' as a prototype');
  15820. };
  15821. },{"../internals/is-callable":264}],176:[function(_dereq_,module,exports){
  15822. module.exports = function () { /* empty */ };
  15823. },{}],177:[function(_dereq_,module,exports){
  15824. var isPrototypeOf = _dereq_('../internals/object-is-prototype-of');
  15825. var $TypeError = TypeError;
  15826. module.exports = function (it, Prototype) {
  15827. if (isPrototypeOf(Prototype, it)) return it;
  15828. throw $TypeError('Incorrect invocation');
  15829. };
  15830. },{"../internals/object-is-prototype-of":296}],178:[function(_dereq_,module,exports){
  15831. var isObject = _dereq_('../internals/is-object');
  15832. var $String = String;
  15833. var $TypeError = TypeError;
  15834. // `Assert: Type(argument) is Object`
  15835. module.exports = function (argument) {
  15836. if (isObject(argument)) return argument;
  15837. throw $TypeError($String(argument) + ' is not an object');
  15838. };
  15839. },{"../internals/is-object":269}],179:[function(_dereq_,module,exports){
  15840. // FF26- bug: ArrayBuffers are non-extensible, but Object.isExtensible does not report it
  15841. var fails = _dereq_('../internals/fails');
  15842. module.exports = fails(function () {
  15843. if (typeof ArrayBuffer == 'function') {
  15844. var buffer = new ArrayBuffer(8);
  15845. // eslint-disable-next-line es/no-object-isextensible, es/no-object-defineproperty -- safe
  15846. if (Object.isExtensible(buffer)) Object.defineProperty(buffer, 'a', { value: 8 });
  15847. }
  15848. });
  15849. },{"../internals/fails":235}],180:[function(_dereq_,module,exports){
  15850. 'use strict';
  15851. var $forEach = _dereq_('../internals/array-iteration').forEach;
  15852. var arrayMethodIsStrict = _dereq_('../internals/array-method-is-strict');
  15853. var STRICT_METHOD = arrayMethodIsStrict('forEach');
  15854. // `Array.prototype.forEach` method implementation
  15855. // https://tc39.es/ecma262/#sec-array.prototype.foreach
  15856. module.exports = !STRICT_METHOD ? function forEach(callbackfn /* , thisArg */) {
  15857. return $forEach(this, callbackfn, arguments.length > 1 ? arguments[1] : undefined);
  15858. // eslint-disable-next-line es/no-array-prototype-foreach -- safe
  15859. } : [].forEach;
  15860. },{"../internals/array-iteration":183,"../internals/array-method-is-strict":185}],181:[function(_dereq_,module,exports){
  15861. 'use strict';
  15862. var bind = _dereq_('../internals/function-bind-context');
  15863. var call = _dereq_('../internals/function-call');
  15864. var toObject = _dereq_('../internals/to-object');
  15865. var callWithSafeIterationClosing = _dereq_('../internals/call-with-safe-iteration-closing');
  15866. var isArrayIteratorMethod = _dereq_('../internals/is-array-iterator-method');
  15867. var isConstructor = _dereq_('../internals/is-constructor');
  15868. var lengthOfArrayLike = _dereq_('../internals/length-of-array-like');
  15869. var createProperty = _dereq_('../internals/create-property');
  15870. var getIterator = _dereq_('../internals/get-iterator');
  15871. var getIteratorMethod = _dereq_('../internals/get-iterator-method');
  15872. var $Array = Array;
  15873. // `Array.from` method implementation
  15874. // https://tc39.es/ecma262/#sec-array.from
  15875. module.exports = function from(arrayLike /* , mapfn = undefined, thisArg = undefined */) {
  15876. var O = toObject(arrayLike);
  15877. var IS_CONSTRUCTOR = isConstructor(this);
  15878. var argumentsLength = arguments.length;
  15879. var mapfn = argumentsLength > 1 ? arguments[1] : undefined;
  15880. var mapping = mapfn !== undefined;
  15881. if (mapping) mapfn = bind(mapfn, argumentsLength > 2 ? arguments[2] : undefined);
  15882. var iteratorMethod = getIteratorMethod(O);
  15883. var index = 0;
  15884. var length, result, step, iterator, next, value;
  15885. // if the target is not iterable or it's an array with the default iterator - use a simple case
  15886. if (iteratorMethod && !(this === $Array && isArrayIteratorMethod(iteratorMethod))) {
  15887. iterator = getIterator(O, iteratorMethod);
  15888. next = iterator.next;
  15889. result = IS_CONSTRUCTOR ? new this() : [];
  15890. for (;!(step = call(next, iterator)).done; index++) {
  15891. value = mapping ? callWithSafeIterationClosing(iterator, mapfn, [step.value, index], true) : step.value;
  15892. createProperty(result, index, value);
  15893. }
  15894. } else {
  15895. length = lengthOfArrayLike(O);
  15896. result = IS_CONSTRUCTOR ? new this(length) : $Array(length);
  15897. for (;length > index; index++) {
  15898. value = mapping ? mapfn(O[index], index) : O[index];
  15899. createProperty(result, index, value);
  15900. }
  15901. }
  15902. result.length = index;
  15903. return result;
  15904. };
  15905. },{"../internals/call-with-safe-iteration-closing":193,"../internals/create-property":206,"../internals/function-bind-context":238,"../internals/function-call":241,"../internals/get-iterator":248,"../internals/get-iterator-method":247,"../internals/is-array-iterator-method":262,"../internals/is-constructor":265,"../internals/length-of-array-like":279,"../internals/to-object":330}],182:[function(_dereq_,module,exports){
  15906. var toIndexedObject = _dereq_('../internals/to-indexed-object');
  15907. var toAbsoluteIndex = _dereq_('../internals/to-absolute-index');
  15908. var lengthOfArrayLike = _dereq_('../internals/length-of-array-like');
  15909. // `Array.prototype.{ indexOf, includes }` methods implementation
  15910. var createMethod = function (IS_INCLUDES) {
  15911. return function ($this, el, fromIndex) {
  15912. var O = toIndexedObject($this);
  15913. var length = lengthOfArrayLike(O);
  15914. var index = toAbsoluteIndex(fromIndex, length);
  15915. var value;
  15916. // Array#includes uses SameValueZero equality algorithm
  15917. // eslint-disable-next-line no-self-compare -- NaN check
  15918. if (IS_INCLUDES && el != el) while (length > index) {
  15919. value = O[index++];
  15920. // eslint-disable-next-line no-self-compare -- NaN check
  15921. if (value != value) return true;
  15922. // Array#indexOf ignores holes, Array#includes - not
  15923. } else for (;length > index; index++) {
  15924. if ((IS_INCLUDES || index in O) && O[index] === el) return IS_INCLUDES || index || 0;
  15925. } return !IS_INCLUDES && -1;
  15926. };
  15927. };
  15928. module.exports = {
  15929. // `Array.prototype.includes` method
  15930. // https://tc39.es/ecma262/#sec-array.prototype.includes
  15931. includes: createMethod(true),
  15932. // `Array.prototype.indexOf` method
  15933. // https://tc39.es/ecma262/#sec-array.prototype.indexof
  15934. indexOf: createMethod(false)
  15935. };
  15936. },{"../internals/length-of-array-like":279,"../internals/to-absolute-index":326,"../internals/to-indexed-object":327}],183:[function(_dereq_,module,exports){
  15937. var bind = _dereq_('../internals/function-bind-context');
  15938. var uncurryThis = _dereq_('../internals/function-uncurry-this');
  15939. var IndexedObject = _dereq_('../internals/indexed-object');
  15940. var toObject = _dereq_('../internals/to-object');
  15941. var lengthOfArrayLike = _dereq_('../internals/length-of-array-like');
  15942. var arraySpeciesCreate = _dereq_('../internals/array-species-create');
  15943. var push = uncurryThis([].push);
  15944. // `Array.prototype.{ forEach, map, filter, some, every, find, findIndex, filterReject }` methods implementation
  15945. var createMethod = function (TYPE) {
  15946. var IS_MAP = TYPE == 1;
  15947. var IS_FILTER = TYPE == 2;
  15948. var IS_SOME = TYPE == 3;
  15949. var IS_EVERY = TYPE == 4;
  15950. var IS_FIND_INDEX = TYPE == 6;
  15951. var IS_FILTER_REJECT = TYPE == 7;
  15952. var NO_HOLES = TYPE == 5 || IS_FIND_INDEX;
  15953. return function ($this, callbackfn, that, specificCreate) {
  15954. var O = toObject($this);
  15955. var self = IndexedObject(O);
  15956. var boundFunction = bind(callbackfn, that);
  15957. var length = lengthOfArrayLike(self);
  15958. var index = 0;
  15959. var create = specificCreate || arraySpeciesCreate;
  15960. var target = IS_MAP ? create($this, length) : IS_FILTER || IS_FILTER_REJECT ? create($this, 0) : undefined;
  15961. var value, result;
  15962. for (;length > index; index++) if (NO_HOLES || index in self) {
  15963. value = self[index];
  15964. result = boundFunction(value, index, O);
  15965. if (TYPE) {
  15966. if (IS_MAP) target[index] = result; // map
  15967. else if (result) switch (TYPE) {
  15968. case 3: return true; // some
  15969. case 5: return value; // find
  15970. case 6: return index; // findIndex
  15971. case 2: push(target, value); // filter
  15972. } else switch (TYPE) {
  15973. case 4: return false; // every
  15974. case 7: push(target, value); // filterReject
  15975. }
  15976. }
  15977. }
  15978. return IS_FIND_INDEX ? -1 : IS_SOME || IS_EVERY ? IS_EVERY : target;
  15979. };
  15980. };
  15981. module.exports = {
  15982. // `Array.prototype.forEach` method
  15983. // https://tc39.es/ecma262/#sec-array.prototype.foreach
  15984. forEach: createMethod(0),
  15985. // `Array.prototype.map` method
  15986. // https://tc39.es/ecma262/#sec-array.prototype.map
  15987. map: createMethod(1),
  15988. // `Array.prototype.filter` method
  15989. // https://tc39.es/ecma262/#sec-array.prototype.filter
  15990. filter: createMethod(2),
  15991. // `Array.prototype.some` method
  15992. // https://tc39.es/ecma262/#sec-array.prototype.some
  15993. some: createMethod(3),
  15994. // `Array.prototype.every` method
  15995. // https://tc39.es/ecma262/#sec-array.prototype.every
  15996. every: createMethod(4),
  15997. // `Array.prototype.find` method
  15998. // https://tc39.es/ecma262/#sec-array.prototype.find
  15999. find: createMethod(5),
  16000. // `Array.prototype.findIndex` method
  16001. // https://tc39.es/ecma262/#sec-array.prototype.findIndex
  16002. findIndex: createMethod(6),
  16003. // `Array.prototype.filterReject` method
  16004. // https://github.com/tc39/proposal-array-filtering
  16005. filterReject: createMethod(7)
  16006. };
  16007. },{"../internals/array-species-create":192,"../internals/function-bind-context":238,"../internals/function-uncurry-this":245,"../internals/indexed-object":257,"../internals/length-of-array-like":279,"../internals/to-object":330}],184:[function(_dereq_,module,exports){
  16008. var fails = _dereq_('../internals/fails');
  16009. var wellKnownSymbol = _dereq_('../internals/well-known-symbol');
  16010. var V8_VERSION = _dereq_('../internals/engine-v8-version');
  16011. var SPECIES = wellKnownSymbol('species');
  16012. module.exports = function (METHOD_NAME) {
  16013. // We can't use this feature detection in V8 since it causes
  16014. // deoptimization and serious performance degradation
  16015. // https://github.com/zloirock/core-js/issues/677
  16016. return V8_VERSION >= 51 || !fails(function () {
  16017. var array = [];
  16018. var constructor = array.constructor = {};
  16019. constructor[SPECIES] = function () {
  16020. return { foo: 1 };
  16021. };
  16022. return array[METHOD_NAME](Boolean).foo !== 1;
  16023. });
  16024. };
  16025. },{"../internals/engine-v8-version":227,"../internals/fails":235,"../internals/well-known-symbol":343}],185:[function(_dereq_,module,exports){
  16026. 'use strict';
  16027. var fails = _dereq_('../internals/fails');
  16028. module.exports = function (METHOD_NAME, argument) {
  16029. var method = [][METHOD_NAME];
  16030. return !!method && fails(function () {
  16031. // eslint-disable-next-line no-useless-call -- required for testing
  16032. method.call(null, argument || function () { return 1; }, 1);
  16033. });
  16034. };
  16035. },{"../internals/fails":235}],186:[function(_dereq_,module,exports){
  16036. var aCallable = _dereq_('../internals/a-callable');
  16037. var toObject = _dereq_('../internals/to-object');
  16038. var IndexedObject = _dereq_('../internals/indexed-object');
  16039. var lengthOfArrayLike = _dereq_('../internals/length-of-array-like');
  16040. var $TypeError = TypeError;
  16041. // `Array.prototype.{ reduce, reduceRight }` methods implementation
  16042. var createMethod = function (IS_RIGHT) {
  16043. return function (that, callbackfn, argumentsLength, memo) {
  16044. aCallable(callbackfn);
  16045. var O = toObject(that);
  16046. var self = IndexedObject(O);
  16047. var length = lengthOfArrayLike(O);
  16048. var index = IS_RIGHT ? length - 1 : 0;
  16049. var i = IS_RIGHT ? -1 : 1;
  16050. if (argumentsLength < 2) while (true) {
  16051. if (index in self) {
  16052. memo = self[index];
  16053. index += i;
  16054. break;
  16055. }
  16056. index += i;
  16057. if (IS_RIGHT ? index < 0 : length <= index) {
  16058. throw $TypeError('Reduce of empty array with no initial value');
  16059. }
  16060. }
  16061. for (;IS_RIGHT ? index >= 0 : length > index; index += i) if (index in self) {
  16062. memo = callbackfn(memo, self[index], index, O);
  16063. }
  16064. return memo;
  16065. };
  16066. };
  16067. module.exports = {
  16068. // `Array.prototype.reduce` method
  16069. // https://tc39.es/ecma262/#sec-array.prototype.reduce
  16070. left: createMethod(false),
  16071. // `Array.prototype.reduceRight` method
  16072. // https://tc39.es/ecma262/#sec-array.prototype.reduceright
  16073. right: createMethod(true)
  16074. };
  16075. },{"../internals/a-callable":173,"../internals/indexed-object":257,"../internals/length-of-array-like":279,"../internals/to-object":330}],187:[function(_dereq_,module,exports){
  16076. 'use strict';
  16077. var DESCRIPTORS = _dereq_('../internals/descriptors');
  16078. var isArray = _dereq_('../internals/is-array');
  16079. var $TypeError = TypeError;
  16080. // eslint-disable-next-line es/no-object-getownpropertydescriptor -- safe
  16081. var getOwnPropertyDescriptor = Object.getOwnPropertyDescriptor;
  16082. // Safari < 13 does not throw an error in this case
  16083. var SILENT_ON_NON_WRITABLE_LENGTH_SET = DESCRIPTORS && !function () {
  16084. // makes no sense without proper strict mode support
  16085. if (this !== undefined) return true;
  16086. try {
  16087. // eslint-disable-next-line es/no-object-defineproperty -- safe
  16088. Object.defineProperty([], 'length', { writable: false }).length = 1;
  16089. } catch (error) {
  16090. return error instanceof TypeError;
  16091. }
  16092. }();
  16093. module.exports = SILENT_ON_NON_WRITABLE_LENGTH_SET ? function (O, length) {
  16094. if (isArray(O) && !getOwnPropertyDescriptor(O, 'length').writable) {
  16095. throw $TypeError('Cannot set read only .length');
  16096. } return O.length = length;
  16097. } : function (O, length) {
  16098. return O.length = length;
  16099. };
  16100. },{"../internals/descriptors":212,"../internals/is-array":263}],188:[function(_dereq_,module,exports){
  16101. var toAbsoluteIndex = _dereq_('../internals/to-absolute-index');
  16102. var lengthOfArrayLike = _dereq_('../internals/length-of-array-like');
  16103. var createProperty = _dereq_('../internals/create-property');
  16104. var $Array = Array;
  16105. var max = Math.max;
  16106. module.exports = function (O, start, end) {
  16107. var length = lengthOfArrayLike(O);
  16108. var k = toAbsoluteIndex(start, length);
  16109. var fin = toAbsoluteIndex(end === undefined ? length : end, length);
  16110. var result = $Array(max(fin - k, 0));
  16111. for (var n = 0; k < fin; k++, n++) createProperty(result, n, O[k]);
  16112. result.length = n;
  16113. return result;
  16114. };
  16115. },{"../internals/create-property":206,"../internals/length-of-array-like":279,"../internals/to-absolute-index":326}],189:[function(_dereq_,module,exports){
  16116. var uncurryThis = _dereq_('../internals/function-uncurry-this');
  16117. module.exports = uncurryThis([].slice);
  16118. },{"../internals/function-uncurry-this":245}],190:[function(_dereq_,module,exports){
  16119. var arraySlice = _dereq_('../internals/array-slice-simple');
  16120. var floor = Math.floor;
  16121. var mergeSort = function (array, comparefn) {
  16122. var length = array.length;
  16123. var middle = floor(length / 2);
  16124. return length < 8 ? insertionSort(array, comparefn) : merge(
  16125. array,
  16126. mergeSort(arraySlice(array, 0, middle), comparefn),
  16127. mergeSort(arraySlice(array, middle), comparefn),
  16128. comparefn
  16129. );
  16130. };
  16131. var insertionSort = function (array, comparefn) {
  16132. var length = array.length;
  16133. var i = 1;
  16134. var element, j;
  16135. while (i < length) {
  16136. j = i;
  16137. element = array[i];
  16138. while (j && comparefn(array[j - 1], element) > 0) {
  16139. array[j] = array[--j];
  16140. }
  16141. if (j !== i++) array[j] = element;
  16142. } return array;
  16143. };
  16144. var merge = function (array, left, right, comparefn) {
  16145. var llength = left.length;
  16146. var rlength = right.length;
  16147. var lindex = 0;
  16148. var rindex = 0;
  16149. while (lindex < llength || rindex < rlength) {
  16150. array[lindex + rindex] = (lindex < llength && rindex < rlength)
  16151. ? comparefn(left[lindex], right[rindex]) <= 0 ? left[lindex++] : right[rindex++]
  16152. : lindex < llength ? left[lindex++] : right[rindex++];
  16153. } return array;
  16154. };
  16155. module.exports = mergeSort;
  16156. },{"../internals/array-slice-simple":188}],191:[function(_dereq_,module,exports){
  16157. var isArray = _dereq_('../internals/is-array');
  16158. var isConstructor = _dereq_('../internals/is-constructor');
  16159. var isObject = _dereq_('../internals/is-object');
  16160. var wellKnownSymbol = _dereq_('../internals/well-known-symbol');
  16161. var SPECIES = wellKnownSymbol('species');
  16162. var $Array = Array;
  16163. // a part of `ArraySpeciesCreate` abstract operation
  16164. // https://tc39.es/ecma262/#sec-arrayspeciescreate
  16165. module.exports = function (originalArray) {
  16166. var C;
  16167. if (isArray(originalArray)) {
  16168. C = originalArray.constructor;
  16169. // cross-realm fallback
  16170. if (isConstructor(C) && (C === $Array || isArray(C.prototype))) C = undefined;
  16171. else if (isObject(C)) {
  16172. C = C[SPECIES];
  16173. if (C === null) C = undefined;
  16174. }
  16175. } return C === undefined ? $Array : C;
  16176. };
  16177. },{"../internals/is-array":263,"../internals/is-constructor":265,"../internals/is-object":269,"../internals/well-known-symbol":343}],192:[function(_dereq_,module,exports){
  16178. var arraySpeciesConstructor = _dereq_('../internals/array-species-constructor');
  16179. // `ArraySpeciesCreate` abstract operation
  16180. // https://tc39.es/ecma262/#sec-arrayspeciescreate
  16181. module.exports = function (originalArray, length) {
  16182. return new (arraySpeciesConstructor(originalArray))(length === 0 ? 0 : length);
  16183. };
  16184. },{"../internals/array-species-constructor":191}],193:[function(_dereq_,module,exports){
  16185. var anObject = _dereq_('../internals/an-object');
  16186. var iteratorClose = _dereq_('../internals/iterator-close');
  16187. // call something on iterator step with safe closing on error
  16188. module.exports = function (iterator, fn, value, ENTRIES) {
  16189. try {
  16190. return ENTRIES ? fn(anObject(value)[0], value[1]) : fn(value);
  16191. } catch (error) {
  16192. iteratorClose(iterator, 'throw', error);
  16193. }
  16194. };
  16195. },{"../internals/an-object":178,"../internals/iterator-close":274}],194:[function(_dereq_,module,exports){
  16196. var wellKnownSymbol = _dereq_('../internals/well-known-symbol');
  16197. var ITERATOR = wellKnownSymbol('iterator');
  16198. var SAFE_CLOSING = false;
  16199. try {
  16200. var called = 0;
  16201. var iteratorWithReturn = {
  16202. next: function () {
  16203. return { done: !!called++ };
  16204. },
  16205. 'return': function () {
  16206. SAFE_CLOSING = true;
  16207. }
  16208. };
  16209. iteratorWithReturn[ITERATOR] = function () {
  16210. return this;
  16211. };
  16212. // eslint-disable-next-line es/no-array-from, no-throw-literal -- required for testing
  16213. Array.from(iteratorWithReturn, function () { throw 2; });
  16214. } catch (error) { /* empty */ }
  16215. module.exports = function (exec, SKIP_CLOSING) {
  16216. if (!SKIP_CLOSING && !SAFE_CLOSING) return false;
  16217. var ITERATION_SUPPORT = false;
  16218. try {
  16219. var object = {};
  16220. object[ITERATOR] = function () {
  16221. return {
  16222. next: function () {
  16223. return { done: ITERATION_SUPPORT = true };
  16224. }
  16225. };
  16226. };
  16227. exec(object);
  16228. } catch (error) { /* empty */ }
  16229. return ITERATION_SUPPORT;
  16230. };
  16231. },{"../internals/well-known-symbol":343}],195:[function(_dereq_,module,exports){
  16232. var uncurryThis = _dereq_('../internals/function-uncurry-this');
  16233. var toString = uncurryThis({}.toString);
  16234. var stringSlice = uncurryThis(''.slice);
  16235. module.exports = function (it) {
  16236. return stringSlice(toString(it), 8, -1);
  16237. };
  16238. },{"../internals/function-uncurry-this":245}],196:[function(_dereq_,module,exports){
  16239. var TO_STRING_TAG_SUPPORT = _dereq_('../internals/to-string-tag-support');
  16240. var isCallable = _dereq_('../internals/is-callable');
  16241. var classofRaw = _dereq_('../internals/classof-raw');
  16242. var wellKnownSymbol = _dereq_('../internals/well-known-symbol');
  16243. var TO_STRING_TAG = wellKnownSymbol('toStringTag');
  16244. var $Object = Object;
  16245. // ES3 wrong here
  16246. var CORRECT_ARGUMENTS = classofRaw(function () { return arguments; }()) == 'Arguments';
  16247. // fallback for IE11 Script Access Denied error
  16248. var tryGet = function (it, key) {
  16249. try {
  16250. return it[key];
  16251. } catch (error) { /* empty */ }
  16252. };
  16253. // getting tag from ES6+ `Object.prototype.toString`
  16254. module.exports = TO_STRING_TAG_SUPPORT ? classofRaw : function (it) {
  16255. var O, tag, result;
  16256. return it === undefined ? 'Undefined' : it === null ? 'Null'
  16257. // @@toStringTag case
  16258. : typeof (tag = tryGet(O = $Object(it), TO_STRING_TAG)) == 'string' ? tag
  16259. // builtinTag case
  16260. : CORRECT_ARGUMENTS ? classofRaw(O)
  16261. // ES3 arguments fallback
  16262. : (result = classofRaw(O)) == 'Object' && isCallable(O.callee) ? 'Arguments' : result;
  16263. };
  16264. },{"../internals/classof-raw":195,"../internals/is-callable":264,"../internals/to-string-tag-support":333,"../internals/well-known-symbol":343}],197:[function(_dereq_,module,exports){
  16265. 'use strict';
  16266. var create = _dereq_('../internals/object-create');
  16267. var defineBuiltInAccessor = _dereq_('../internals/define-built-in-accessor');
  16268. var defineBuiltIns = _dereq_('../internals/define-built-ins');
  16269. var bind = _dereq_('../internals/function-bind-context');
  16270. var anInstance = _dereq_('../internals/an-instance');
  16271. var isNullOrUndefined = _dereq_('../internals/is-null-or-undefined');
  16272. var iterate = _dereq_('../internals/iterate');
  16273. var defineIterator = _dereq_('../internals/iterator-define');
  16274. var createIterResultObject = _dereq_('../internals/create-iter-result-object');
  16275. var setSpecies = _dereq_('../internals/set-species');
  16276. var DESCRIPTORS = _dereq_('../internals/descriptors');
  16277. var fastKey = _dereq_('../internals/internal-metadata').fastKey;
  16278. var InternalStateModule = _dereq_('../internals/internal-state');
  16279. var setInternalState = InternalStateModule.set;
  16280. var internalStateGetterFor = InternalStateModule.getterFor;
  16281. module.exports = {
  16282. getConstructor: function (wrapper, CONSTRUCTOR_NAME, IS_MAP, ADDER) {
  16283. var Constructor = wrapper(function (that, iterable) {
  16284. anInstance(that, Prototype);
  16285. setInternalState(that, {
  16286. type: CONSTRUCTOR_NAME,
  16287. index: create(null),
  16288. first: undefined,
  16289. last: undefined,
  16290. size: 0
  16291. });
  16292. if (!DESCRIPTORS) that.size = 0;
  16293. if (!isNullOrUndefined(iterable)) iterate(iterable, that[ADDER], { that: that, AS_ENTRIES: IS_MAP });
  16294. });
  16295. var Prototype = Constructor.prototype;
  16296. var getInternalState = internalStateGetterFor(CONSTRUCTOR_NAME);
  16297. var define = function (that, key, value) {
  16298. var state = getInternalState(that);
  16299. var entry = getEntry(that, key);
  16300. var previous, index;
  16301. // change existing entry
  16302. if (entry) {
  16303. entry.value = value;
  16304. // create new entry
  16305. } else {
  16306. state.last = entry = {
  16307. index: index = fastKey(key, true),
  16308. key: key,
  16309. value: value,
  16310. previous: previous = state.last,
  16311. next: undefined,
  16312. removed: false
  16313. };
  16314. if (!state.first) state.first = entry;
  16315. if (previous) previous.next = entry;
  16316. if (DESCRIPTORS) state.size++;
  16317. else that.size++;
  16318. // add to index
  16319. if (index !== 'F') state.index[index] = entry;
  16320. } return that;
  16321. };
  16322. var getEntry = function (that, key) {
  16323. var state = getInternalState(that);
  16324. // fast case
  16325. var index = fastKey(key);
  16326. var entry;
  16327. if (index !== 'F') return state.index[index];
  16328. // frozen object case
  16329. for (entry = state.first; entry; entry = entry.next) {
  16330. if (entry.key == key) return entry;
  16331. }
  16332. };
  16333. defineBuiltIns(Prototype, {
  16334. // `{ Map, Set }.prototype.clear()` methods
  16335. // https://tc39.es/ecma262/#sec-map.prototype.clear
  16336. // https://tc39.es/ecma262/#sec-set.prototype.clear
  16337. clear: function clear() {
  16338. var that = this;
  16339. var state = getInternalState(that);
  16340. var data = state.index;
  16341. var entry = state.first;
  16342. while (entry) {
  16343. entry.removed = true;
  16344. if (entry.previous) entry.previous = entry.previous.next = undefined;
  16345. delete data[entry.index];
  16346. entry = entry.next;
  16347. }
  16348. state.first = state.last = undefined;
  16349. if (DESCRIPTORS) state.size = 0;
  16350. else that.size = 0;
  16351. },
  16352. // `{ Map, Set }.prototype.delete(key)` methods
  16353. // https://tc39.es/ecma262/#sec-map.prototype.delete
  16354. // https://tc39.es/ecma262/#sec-set.prototype.delete
  16355. 'delete': function (key) {
  16356. var that = this;
  16357. var state = getInternalState(that);
  16358. var entry = getEntry(that, key);
  16359. if (entry) {
  16360. var next = entry.next;
  16361. var prev = entry.previous;
  16362. delete state.index[entry.index];
  16363. entry.removed = true;
  16364. if (prev) prev.next = next;
  16365. if (next) next.previous = prev;
  16366. if (state.first == entry) state.first = next;
  16367. if (state.last == entry) state.last = prev;
  16368. if (DESCRIPTORS) state.size--;
  16369. else that.size--;
  16370. } return !!entry;
  16371. },
  16372. // `{ Map, Set }.prototype.forEach(callbackfn, thisArg = undefined)` methods
  16373. // https://tc39.es/ecma262/#sec-map.prototype.foreach
  16374. // https://tc39.es/ecma262/#sec-set.prototype.foreach
  16375. forEach: function forEach(callbackfn /* , that = undefined */) {
  16376. var state = getInternalState(this);
  16377. var boundFunction = bind(callbackfn, arguments.length > 1 ? arguments[1] : undefined);
  16378. var entry;
  16379. while (entry = entry ? entry.next : state.first) {
  16380. boundFunction(entry.value, entry.key, this);
  16381. // revert to the last existing entry
  16382. while (entry && entry.removed) entry = entry.previous;
  16383. }
  16384. },
  16385. // `{ Map, Set}.prototype.has(key)` methods
  16386. // https://tc39.es/ecma262/#sec-map.prototype.has
  16387. // https://tc39.es/ecma262/#sec-set.prototype.has
  16388. has: function has(key) {
  16389. return !!getEntry(this, key);
  16390. }
  16391. });
  16392. defineBuiltIns(Prototype, IS_MAP ? {
  16393. // `Map.prototype.get(key)` method
  16394. // https://tc39.es/ecma262/#sec-map.prototype.get
  16395. get: function get(key) {
  16396. var entry = getEntry(this, key);
  16397. return entry && entry.value;
  16398. },
  16399. // `Map.prototype.set(key, value)` method
  16400. // https://tc39.es/ecma262/#sec-map.prototype.set
  16401. set: function set(key, value) {
  16402. return define(this, key === 0 ? 0 : key, value);
  16403. }
  16404. } : {
  16405. // `Set.prototype.add(value)` method
  16406. // https://tc39.es/ecma262/#sec-set.prototype.add
  16407. add: function add(value) {
  16408. return define(this, value = value === 0 ? 0 : value, value);
  16409. }
  16410. });
  16411. if (DESCRIPTORS) defineBuiltInAccessor(Prototype, 'size', {
  16412. configurable: true,
  16413. get: function () {
  16414. return getInternalState(this).size;
  16415. }
  16416. });
  16417. return Constructor;
  16418. },
  16419. setStrong: function (Constructor, CONSTRUCTOR_NAME, IS_MAP) {
  16420. var ITERATOR_NAME = CONSTRUCTOR_NAME + ' Iterator';
  16421. var getInternalCollectionState = internalStateGetterFor(CONSTRUCTOR_NAME);
  16422. var getInternalIteratorState = internalStateGetterFor(ITERATOR_NAME);
  16423. // `{ Map, Set }.prototype.{ keys, values, entries, @@iterator }()` methods
  16424. // https://tc39.es/ecma262/#sec-map.prototype.entries
  16425. // https://tc39.es/ecma262/#sec-map.prototype.keys
  16426. // https://tc39.es/ecma262/#sec-map.prototype.values
  16427. // https://tc39.es/ecma262/#sec-map.prototype-@@iterator
  16428. // https://tc39.es/ecma262/#sec-set.prototype.entries
  16429. // https://tc39.es/ecma262/#sec-set.prototype.keys
  16430. // https://tc39.es/ecma262/#sec-set.prototype.values
  16431. // https://tc39.es/ecma262/#sec-set.prototype-@@iterator
  16432. defineIterator(Constructor, CONSTRUCTOR_NAME, function (iterated, kind) {
  16433. setInternalState(this, {
  16434. type: ITERATOR_NAME,
  16435. target: iterated,
  16436. state: getInternalCollectionState(iterated),
  16437. kind: kind,
  16438. last: undefined
  16439. });
  16440. }, function () {
  16441. var state = getInternalIteratorState(this);
  16442. var kind = state.kind;
  16443. var entry = state.last;
  16444. // revert to the last existing entry
  16445. while (entry && entry.removed) entry = entry.previous;
  16446. // get next entry
  16447. if (!state.target || !(state.last = entry = entry ? entry.next : state.state.first)) {
  16448. // or finish the iteration
  16449. state.target = undefined;
  16450. return createIterResultObject(undefined, true);
  16451. }
  16452. // return step by kind
  16453. if (kind == 'keys') return createIterResultObject(entry.key, false);
  16454. if (kind == 'values') return createIterResultObject(entry.value, false);
  16455. return createIterResultObject([entry.key, entry.value], false);
  16456. }, IS_MAP ? 'entries' : 'values', !IS_MAP, true);
  16457. // `{ Map, Set }.prototype[@@species]` accessors
  16458. // https://tc39.es/ecma262/#sec-get-map-@@species
  16459. // https://tc39.es/ecma262/#sec-get-set-@@species
  16460. setSpecies(CONSTRUCTOR_NAME);
  16461. }
  16462. };
  16463. },{"../internals/an-instance":177,"../internals/create-iter-result-object":203,"../internals/define-built-in-accessor":207,"../internals/define-built-ins":209,"../internals/descriptors":212,"../internals/function-bind-context":238,"../internals/internal-metadata":260,"../internals/internal-state":261,"../internals/is-null-or-undefined":268,"../internals/iterate":273,"../internals/iterator-define":276,"../internals/object-create":287,"../internals/set-species":314}],198:[function(_dereq_,module,exports){
  16464. 'use strict';
  16465. var uncurryThis = _dereq_('../internals/function-uncurry-this');
  16466. var defineBuiltIns = _dereq_('../internals/define-built-ins');
  16467. var getWeakData = _dereq_('../internals/internal-metadata').getWeakData;
  16468. var anInstance = _dereq_('../internals/an-instance');
  16469. var anObject = _dereq_('../internals/an-object');
  16470. var isNullOrUndefined = _dereq_('../internals/is-null-or-undefined');
  16471. var isObject = _dereq_('../internals/is-object');
  16472. var iterate = _dereq_('../internals/iterate');
  16473. var ArrayIterationModule = _dereq_('../internals/array-iteration');
  16474. var hasOwn = _dereq_('../internals/has-own-property');
  16475. var InternalStateModule = _dereq_('../internals/internal-state');
  16476. var setInternalState = InternalStateModule.set;
  16477. var internalStateGetterFor = InternalStateModule.getterFor;
  16478. var find = ArrayIterationModule.find;
  16479. var findIndex = ArrayIterationModule.findIndex;
  16480. var splice = uncurryThis([].splice);
  16481. var id = 0;
  16482. // fallback for uncaught frozen keys
  16483. var uncaughtFrozenStore = function (state) {
  16484. return state.frozen || (state.frozen = new UncaughtFrozenStore());
  16485. };
  16486. var UncaughtFrozenStore = function () {
  16487. this.entries = [];
  16488. };
  16489. var findUncaughtFrozen = function (store, key) {
  16490. return find(store.entries, function (it) {
  16491. return it[0] === key;
  16492. });
  16493. };
  16494. UncaughtFrozenStore.prototype = {
  16495. get: function (key) {
  16496. var entry = findUncaughtFrozen(this, key);
  16497. if (entry) return entry[1];
  16498. },
  16499. has: function (key) {
  16500. return !!findUncaughtFrozen(this, key);
  16501. },
  16502. set: function (key, value) {
  16503. var entry = findUncaughtFrozen(this, key);
  16504. if (entry) entry[1] = value;
  16505. else this.entries.push([key, value]);
  16506. },
  16507. 'delete': function (key) {
  16508. var index = findIndex(this.entries, function (it) {
  16509. return it[0] === key;
  16510. });
  16511. if (~index) splice(this.entries, index, 1);
  16512. return !!~index;
  16513. }
  16514. };
  16515. module.exports = {
  16516. getConstructor: function (wrapper, CONSTRUCTOR_NAME, IS_MAP, ADDER) {
  16517. var Constructor = wrapper(function (that, iterable) {
  16518. anInstance(that, Prototype);
  16519. setInternalState(that, {
  16520. type: CONSTRUCTOR_NAME,
  16521. id: id++,
  16522. frozen: undefined
  16523. });
  16524. if (!isNullOrUndefined(iterable)) iterate(iterable, that[ADDER], { that: that, AS_ENTRIES: IS_MAP });
  16525. });
  16526. var Prototype = Constructor.prototype;
  16527. var getInternalState = internalStateGetterFor(CONSTRUCTOR_NAME);
  16528. var define = function (that, key, value) {
  16529. var state = getInternalState(that);
  16530. var data = getWeakData(anObject(key), true);
  16531. if (data === true) uncaughtFrozenStore(state).set(key, value);
  16532. else data[state.id] = value;
  16533. return that;
  16534. };
  16535. defineBuiltIns(Prototype, {
  16536. // `{ WeakMap, WeakSet }.prototype.delete(key)` methods
  16537. // https://tc39.es/ecma262/#sec-weakmap.prototype.delete
  16538. // https://tc39.es/ecma262/#sec-weakset.prototype.delete
  16539. 'delete': function (key) {
  16540. var state = getInternalState(this);
  16541. if (!isObject(key)) return false;
  16542. var data = getWeakData(key);
  16543. if (data === true) return uncaughtFrozenStore(state)['delete'](key);
  16544. return data && hasOwn(data, state.id) && delete data[state.id];
  16545. },
  16546. // `{ WeakMap, WeakSet }.prototype.has(key)` methods
  16547. // https://tc39.es/ecma262/#sec-weakmap.prototype.has
  16548. // https://tc39.es/ecma262/#sec-weakset.prototype.has
  16549. has: function has(key) {
  16550. var state = getInternalState(this);
  16551. if (!isObject(key)) return false;
  16552. var data = getWeakData(key);
  16553. if (data === true) return uncaughtFrozenStore(state).has(key);
  16554. return data && hasOwn(data, state.id);
  16555. }
  16556. });
  16557. defineBuiltIns(Prototype, IS_MAP ? {
  16558. // `WeakMap.prototype.get(key)` method
  16559. // https://tc39.es/ecma262/#sec-weakmap.prototype.get
  16560. get: function get(key) {
  16561. var state = getInternalState(this);
  16562. if (isObject(key)) {
  16563. var data = getWeakData(key);
  16564. if (data === true) return uncaughtFrozenStore(state).get(key);
  16565. return data ? data[state.id] : undefined;
  16566. }
  16567. },
  16568. // `WeakMap.prototype.set(key, value)` method
  16569. // https://tc39.es/ecma262/#sec-weakmap.prototype.set
  16570. set: function set(key, value) {
  16571. return define(this, key, value);
  16572. }
  16573. } : {
  16574. // `WeakSet.prototype.add(value)` method
  16575. // https://tc39.es/ecma262/#sec-weakset.prototype.add
  16576. add: function add(value) {
  16577. return define(this, value, true);
  16578. }
  16579. });
  16580. return Constructor;
  16581. }
  16582. };
  16583. },{"../internals/an-instance":177,"../internals/an-object":178,"../internals/array-iteration":183,"../internals/define-built-ins":209,"../internals/function-uncurry-this":245,"../internals/has-own-property":252,"../internals/internal-metadata":260,"../internals/internal-state":261,"../internals/is-null-or-undefined":268,"../internals/is-object":269,"../internals/iterate":273}],199:[function(_dereq_,module,exports){
  16584. 'use strict';
  16585. var $ = _dereq_('../internals/export');
  16586. var global = _dereq_('../internals/global');
  16587. var InternalMetadataModule = _dereq_('../internals/internal-metadata');
  16588. var fails = _dereq_('../internals/fails');
  16589. var createNonEnumerableProperty = _dereq_('../internals/create-non-enumerable-property');
  16590. var iterate = _dereq_('../internals/iterate');
  16591. var anInstance = _dereq_('../internals/an-instance');
  16592. var isCallable = _dereq_('../internals/is-callable');
  16593. var isObject = _dereq_('../internals/is-object');
  16594. var setToStringTag = _dereq_('../internals/set-to-string-tag');
  16595. var defineProperty = _dereq_('../internals/object-define-property').f;
  16596. var forEach = _dereq_('../internals/array-iteration').forEach;
  16597. var DESCRIPTORS = _dereq_('../internals/descriptors');
  16598. var InternalStateModule = _dereq_('../internals/internal-state');
  16599. var setInternalState = InternalStateModule.set;
  16600. var internalStateGetterFor = InternalStateModule.getterFor;
  16601. module.exports = function (CONSTRUCTOR_NAME, wrapper, common) {
  16602. var IS_MAP = CONSTRUCTOR_NAME.indexOf('Map') !== -1;
  16603. var IS_WEAK = CONSTRUCTOR_NAME.indexOf('Weak') !== -1;
  16604. var ADDER = IS_MAP ? 'set' : 'add';
  16605. var NativeConstructor = global[CONSTRUCTOR_NAME];
  16606. var NativePrototype = NativeConstructor && NativeConstructor.prototype;
  16607. var exported = {};
  16608. var Constructor;
  16609. if (!DESCRIPTORS || !isCallable(NativeConstructor)
  16610. || !(IS_WEAK || NativePrototype.forEach && !fails(function () { new NativeConstructor().entries().next(); }))
  16611. ) {
  16612. // create collection constructor
  16613. Constructor = common.getConstructor(wrapper, CONSTRUCTOR_NAME, IS_MAP, ADDER);
  16614. InternalMetadataModule.enable();
  16615. } else {
  16616. Constructor = wrapper(function (target, iterable) {
  16617. setInternalState(anInstance(target, Prototype), {
  16618. type: CONSTRUCTOR_NAME,
  16619. collection: new NativeConstructor()
  16620. });
  16621. if (iterable != undefined) iterate(iterable, target[ADDER], { that: target, AS_ENTRIES: IS_MAP });
  16622. });
  16623. var Prototype = Constructor.prototype;
  16624. var getInternalState = internalStateGetterFor(CONSTRUCTOR_NAME);
  16625. forEach(['add', 'clear', 'delete', 'forEach', 'get', 'has', 'set', 'keys', 'values', 'entries'], function (KEY) {
  16626. var IS_ADDER = KEY == 'add' || KEY == 'set';
  16627. if (KEY in NativePrototype && !(IS_WEAK && KEY == 'clear')) {
  16628. createNonEnumerableProperty(Prototype, KEY, function (a, b) {
  16629. var collection = getInternalState(this).collection;
  16630. if (!IS_ADDER && IS_WEAK && !isObject(a)) return KEY == 'get' ? undefined : false;
  16631. var result = collection[KEY](a === 0 ? 0 : a, b);
  16632. return IS_ADDER ? this : result;
  16633. });
  16634. }
  16635. });
  16636. IS_WEAK || defineProperty(Prototype, 'size', {
  16637. configurable: true,
  16638. get: function () {
  16639. return getInternalState(this).collection.size;
  16640. }
  16641. });
  16642. }
  16643. setToStringTag(Constructor, CONSTRUCTOR_NAME, false, true);
  16644. exported[CONSTRUCTOR_NAME] = Constructor;
  16645. $({ global: true, forced: true }, exported);
  16646. if (!IS_WEAK) common.setStrong(Constructor, CONSTRUCTOR_NAME, IS_MAP);
  16647. return Constructor;
  16648. };
  16649. },{"../internals/an-instance":177,"../internals/array-iteration":183,"../internals/create-non-enumerable-property":204,"../internals/descriptors":212,"../internals/export":234,"../internals/fails":235,"../internals/global":251,"../internals/internal-metadata":260,"../internals/internal-state":261,"../internals/is-callable":264,"../internals/is-object":269,"../internals/iterate":273,"../internals/object-define-property":289,"../internals/set-to-string-tag":315}],200:[function(_dereq_,module,exports){
  16650. var hasOwn = _dereq_('../internals/has-own-property');
  16651. var ownKeys = _dereq_('../internals/own-keys');
  16652. var getOwnPropertyDescriptorModule = _dereq_('../internals/object-get-own-property-descriptor');
  16653. var definePropertyModule = _dereq_('../internals/object-define-property');
  16654. module.exports = function (target, source, exceptions) {
  16655. var keys = ownKeys(source);
  16656. var defineProperty = definePropertyModule.f;
  16657. var getOwnPropertyDescriptor = getOwnPropertyDescriptorModule.f;
  16658. for (var i = 0; i < keys.length; i++) {
  16659. var key = keys[i];
  16660. if (!hasOwn(target, key) && !(exceptions && hasOwn(exceptions, key))) {
  16661. defineProperty(target, key, getOwnPropertyDescriptor(source, key));
  16662. }
  16663. }
  16664. };
  16665. },{"../internals/has-own-property":252,"../internals/object-define-property":289,"../internals/object-get-own-property-descriptor":290,"../internals/own-keys":304}],201:[function(_dereq_,module,exports){
  16666. var wellKnownSymbol = _dereq_('../internals/well-known-symbol');
  16667. var MATCH = wellKnownSymbol('match');
  16668. module.exports = function (METHOD_NAME) {
  16669. var regexp = /./;
  16670. try {
  16671. '/./'[METHOD_NAME](regexp);
  16672. } catch (error1) {
  16673. try {
  16674. regexp[MATCH] = false;
  16675. return '/./'[METHOD_NAME](regexp);
  16676. } catch (error2) { /* empty */ }
  16677. } return false;
  16678. };
  16679. },{"../internals/well-known-symbol":343}],202:[function(_dereq_,module,exports){
  16680. var fails = _dereq_('../internals/fails');
  16681. module.exports = !fails(function () {
  16682. function F() { /* empty */ }
  16683. F.prototype.constructor = null;
  16684. // eslint-disable-next-line es/no-object-getprototypeof -- required for testing
  16685. return Object.getPrototypeOf(new F()) !== F.prototype;
  16686. });
  16687. },{"../internals/fails":235}],203:[function(_dereq_,module,exports){
  16688. // `CreateIterResultObject` abstract operation
  16689. // https://tc39.es/ecma262/#sec-createiterresultobject
  16690. module.exports = function (value, done) {
  16691. return { value: value, done: done };
  16692. };
  16693. },{}],204:[function(_dereq_,module,exports){
  16694. var DESCRIPTORS = _dereq_('../internals/descriptors');
  16695. var definePropertyModule = _dereq_('../internals/object-define-property');
  16696. var createPropertyDescriptor = _dereq_('../internals/create-property-descriptor');
  16697. module.exports = DESCRIPTORS ? function (object, key, value) {
  16698. return definePropertyModule.f(object, key, createPropertyDescriptor(1, value));
  16699. } : function (object, key, value) {
  16700. object[key] = value;
  16701. return object;
  16702. };
  16703. },{"../internals/create-property-descriptor":205,"../internals/descriptors":212,"../internals/object-define-property":289}],205:[function(_dereq_,module,exports){
  16704. module.exports = function (bitmap, value) {
  16705. return {
  16706. enumerable: !(bitmap & 1),
  16707. configurable: !(bitmap & 2),
  16708. writable: !(bitmap & 4),
  16709. value: value
  16710. };
  16711. };
  16712. },{}],206:[function(_dereq_,module,exports){
  16713. 'use strict';
  16714. var toPropertyKey = _dereq_('../internals/to-property-key');
  16715. var definePropertyModule = _dereq_('../internals/object-define-property');
  16716. var createPropertyDescriptor = _dereq_('../internals/create-property-descriptor');
  16717. module.exports = function (object, key, value) {
  16718. var propertyKey = toPropertyKey(key);
  16719. if (propertyKey in object) definePropertyModule.f(object, propertyKey, createPropertyDescriptor(0, value));
  16720. else object[propertyKey] = value;
  16721. };
  16722. },{"../internals/create-property-descriptor":205,"../internals/object-define-property":289,"../internals/to-property-key":332}],207:[function(_dereq_,module,exports){
  16723. var defineProperty = _dereq_('../internals/object-define-property');
  16724. module.exports = function (target, name, descriptor) {
  16725. return defineProperty.f(target, name, descriptor);
  16726. };
  16727. },{"../internals/object-define-property":289}],208:[function(_dereq_,module,exports){
  16728. var createNonEnumerableProperty = _dereq_('../internals/create-non-enumerable-property');
  16729. module.exports = function (target, key, value, options) {
  16730. if (options && options.enumerable) target[key] = value;
  16731. else createNonEnumerableProperty(target, key, value);
  16732. return target;
  16733. };
  16734. },{"../internals/create-non-enumerable-property":204}],209:[function(_dereq_,module,exports){
  16735. var defineBuiltIn = _dereq_('../internals/define-built-in');
  16736. module.exports = function (target, src, options) {
  16737. for (var key in src) {
  16738. if (options && options.unsafe && target[key]) target[key] = src[key];
  16739. else defineBuiltIn(target, key, src[key], options);
  16740. } return target;
  16741. };
  16742. },{"../internals/define-built-in":208}],210:[function(_dereq_,module,exports){
  16743. var global = _dereq_('../internals/global');
  16744. // eslint-disable-next-line es/no-object-defineproperty -- safe
  16745. var defineProperty = Object.defineProperty;
  16746. module.exports = function (key, value) {
  16747. try {
  16748. defineProperty(global, key, { value: value, configurable: true, writable: true });
  16749. } catch (error) {
  16750. global[key] = value;
  16751. } return value;
  16752. };
  16753. },{"../internals/global":251}],211:[function(_dereq_,module,exports){
  16754. 'use strict';
  16755. var tryToString = _dereq_('../internals/try-to-string');
  16756. var $TypeError = TypeError;
  16757. module.exports = function (O, P) {
  16758. if (!delete O[P]) throw $TypeError('Cannot delete property ' + tryToString(P) + ' of ' + tryToString(O));
  16759. };
  16760. },{"../internals/try-to-string":335}],212:[function(_dereq_,module,exports){
  16761. var fails = _dereq_('../internals/fails');
  16762. // Detect IE8's incomplete defineProperty implementation
  16763. module.exports = !fails(function () {
  16764. // eslint-disable-next-line es/no-object-defineproperty -- required for testing
  16765. return Object.defineProperty({}, 1, { get: function () { return 7; } })[1] != 7;
  16766. });
  16767. },{"../internals/fails":235}],213:[function(_dereq_,module,exports){
  16768. var documentAll = typeof document == 'object' && document.all;
  16769. // https://tc39.es/ecma262/#sec-IsHTMLDDA-internal-slot
  16770. // eslint-disable-next-line unicorn/no-typeof-undefined -- required for testing
  16771. var IS_HTMLDDA = typeof documentAll == 'undefined' && documentAll !== undefined;
  16772. module.exports = {
  16773. all: documentAll,
  16774. IS_HTMLDDA: IS_HTMLDDA
  16775. };
  16776. },{}],214:[function(_dereq_,module,exports){
  16777. var global = _dereq_('../internals/global');
  16778. var isObject = _dereq_('../internals/is-object');
  16779. var document = global.document;
  16780. // typeof document.createElement is 'object' in old IE
  16781. var EXISTS = isObject(document) && isObject(document.createElement);
  16782. module.exports = function (it) {
  16783. return EXISTS ? document.createElement(it) : {};
  16784. };
  16785. },{"../internals/global":251,"../internals/is-object":269}],215:[function(_dereq_,module,exports){
  16786. var $TypeError = TypeError;
  16787. var MAX_SAFE_INTEGER = 0x1FFFFFFFFFFFFF; // 2 ** 53 - 1 == 9007199254740991
  16788. module.exports = function (it) {
  16789. if (it > MAX_SAFE_INTEGER) throw $TypeError('Maximum allowed index exceeded');
  16790. return it;
  16791. };
  16792. },{}],216:[function(_dereq_,module,exports){
  16793. // iterable DOM collections
  16794. // flag - `iterable` interface - 'entries', 'keys', 'values', 'forEach' methods
  16795. module.exports = {
  16796. CSSRuleList: 0,
  16797. CSSStyleDeclaration: 0,
  16798. CSSValueList: 0,
  16799. ClientRectList: 0,
  16800. DOMRectList: 0,
  16801. DOMStringList: 0,
  16802. DOMTokenList: 1,
  16803. DataTransferItemList: 0,
  16804. FileList: 0,
  16805. HTMLAllCollection: 0,
  16806. HTMLCollection: 0,
  16807. HTMLFormElement: 0,
  16808. HTMLSelectElement: 0,
  16809. MediaList: 0,
  16810. MimeTypeArray: 0,
  16811. NamedNodeMap: 0,
  16812. NodeList: 1,
  16813. PaintRequestList: 0,
  16814. Plugin: 0,
  16815. PluginArray: 0,
  16816. SVGLengthList: 0,
  16817. SVGNumberList: 0,
  16818. SVGPathSegList: 0,
  16819. SVGPointList: 0,
  16820. SVGStringList: 0,
  16821. SVGTransformList: 0,
  16822. SourceBufferList: 0,
  16823. StyleSheetList: 0,
  16824. TextTrackCueList: 0,
  16825. TextTrackList: 0,
  16826. TouchList: 0
  16827. };
  16828. },{}],217:[function(_dereq_,module,exports){
  16829. var userAgent = _dereq_('../internals/engine-user-agent');
  16830. var firefox = userAgent.match(/firefox\/(\d+)/i);
  16831. module.exports = !!firefox && +firefox[1];
  16832. },{"../internals/engine-user-agent":226}],218:[function(_dereq_,module,exports){
  16833. var IS_DENO = _dereq_('../internals/engine-is-deno');
  16834. var IS_NODE = _dereq_('../internals/engine-is-node');
  16835. module.exports = !IS_DENO && !IS_NODE
  16836. && typeof window == 'object'
  16837. && typeof document == 'object';
  16838. },{"../internals/engine-is-deno":220,"../internals/engine-is-node":224}],219:[function(_dereq_,module,exports){
  16839. /* global Bun -- Deno case */
  16840. module.exports = typeof Bun == 'function' && Bun && typeof Bun.version == 'string';
  16841. },{}],220:[function(_dereq_,module,exports){
  16842. /* global Deno -- Deno case */
  16843. module.exports = typeof Deno == 'object' && Deno && typeof Deno.version == 'object';
  16844. },{}],221:[function(_dereq_,module,exports){
  16845. var UA = _dereq_('../internals/engine-user-agent');
  16846. module.exports = /MSIE|Trident/.test(UA);
  16847. },{"../internals/engine-user-agent":226}],222:[function(_dereq_,module,exports){
  16848. var userAgent = _dereq_('../internals/engine-user-agent');
  16849. module.exports = /ipad|iphone|ipod/i.test(userAgent) && typeof Pebble != 'undefined';
  16850. },{"../internals/engine-user-agent":226}],223:[function(_dereq_,module,exports){
  16851. var userAgent = _dereq_('../internals/engine-user-agent');
  16852. // eslint-disable-next-line redos/no-vulnerable -- safe
  16853. module.exports = /(?:ipad|iphone|ipod).*applewebkit/i.test(userAgent);
  16854. },{"../internals/engine-user-agent":226}],224:[function(_dereq_,module,exports){
  16855. (function (process){(function (){
  16856. var classof = _dereq_('../internals/classof-raw');
  16857. module.exports = typeof process != 'undefined' && classof(process) == 'process';
  16858. }).call(this)}).call(this,_dereq_('_process'))
  16859. },{"../internals/classof-raw":195,"_process":107}],225:[function(_dereq_,module,exports){
  16860. var userAgent = _dereq_('../internals/engine-user-agent');
  16861. module.exports = /web0s(?!.*chrome)/i.test(userAgent);
  16862. },{"../internals/engine-user-agent":226}],226:[function(_dereq_,module,exports){
  16863. module.exports = typeof navigator != 'undefined' && String(navigator.userAgent) || '';
  16864. },{}],227:[function(_dereq_,module,exports){
  16865. var global = _dereq_('../internals/global');
  16866. var userAgent = _dereq_('../internals/engine-user-agent');
  16867. var process = global.process;
  16868. var Deno = global.Deno;
  16869. var versions = process && process.versions || Deno && Deno.version;
  16870. var v8 = versions && versions.v8;
  16871. var match, version;
  16872. if (v8) {
  16873. match = v8.split('.');
  16874. // in old Chrome, versions of V8 isn't V8 = Chrome / 10
  16875. // but their correct versions are not interesting for us
  16876. version = match[0] > 0 && match[0] < 4 ? 1 : +(match[0] + match[1]);
  16877. }
  16878. // BrowserFS NodeJS `process` polyfill incorrectly set `.v8` to `0.0`
  16879. // so check `userAgent` even if `.v8` exists, but 0
  16880. if (!version && userAgent) {
  16881. match = userAgent.match(/Edge\/(\d+)/);
  16882. if (!match || match[1] >= 74) {
  16883. match = userAgent.match(/Chrome\/(\d+)/);
  16884. if (match) version = +match[1];
  16885. }
  16886. }
  16887. module.exports = version;
  16888. },{"../internals/engine-user-agent":226,"../internals/global":251}],228:[function(_dereq_,module,exports){
  16889. var userAgent = _dereq_('../internals/engine-user-agent');
  16890. var webkit = userAgent.match(/AppleWebKit\/(\d+)\./);
  16891. module.exports = !!webkit && +webkit[1];
  16892. },{"../internals/engine-user-agent":226}],229:[function(_dereq_,module,exports){
  16893. var path = _dereq_('../internals/path');
  16894. module.exports = function (CONSTRUCTOR) {
  16895. return path[CONSTRUCTOR + 'Prototype'];
  16896. };
  16897. },{"../internals/path":305}],230:[function(_dereq_,module,exports){
  16898. // IE8- don't enum bug keys
  16899. module.exports = [
  16900. 'constructor',
  16901. 'hasOwnProperty',
  16902. 'isPrototypeOf',
  16903. 'propertyIsEnumerable',
  16904. 'toLocaleString',
  16905. 'toString',
  16906. 'valueOf'
  16907. ];
  16908. },{}],231:[function(_dereq_,module,exports){
  16909. var uncurryThis = _dereq_('../internals/function-uncurry-this');
  16910. var $Error = Error;
  16911. var replace = uncurryThis(''.replace);
  16912. var TEST = (function (arg) { return String($Error(arg).stack); })('zxcasd');
  16913. // eslint-disable-next-line redos/no-vulnerable -- safe
  16914. var V8_OR_CHAKRA_STACK_ENTRY = /\n\s*at [^:]*:[^\n]*/;
  16915. var IS_V8_OR_CHAKRA_STACK = V8_OR_CHAKRA_STACK_ENTRY.test(TEST);
  16916. module.exports = function (stack, dropEntries) {
  16917. if (IS_V8_OR_CHAKRA_STACK && typeof stack == 'string' && !$Error.prepareStackTrace) {
  16918. while (dropEntries--) stack = replace(stack, V8_OR_CHAKRA_STACK_ENTRY, '');
  16919. } return stack;
  16920. };
  16921. },{"../internals/function-uncurry-this":245}],232:[function(_dereq_,module,exports){
  16922. var createNonEnumerableProperty = _dereq_('../internals/create-non-enumerable-property');
  16923. var clearErrorStack = _dereq_('../internals/error-stack-clear');
  16924. var ERROR_STACK_INSTALLABLE = _dereq_('../internals/error-stack-installable');
  16925. // non-standard V8
  16926. var captureStackTrace = Error.captureStackTrace;
  16927. module.exports = function (error, C, stack, dropEntries) {
  16928. if (ERROR_STACK_INSTALLABLE) {
  16929. if (captureStackTrace) captureStackTrace(error, C);
  16930. else createNonEnumerableProperty(error, 'stack', clearErrorStack(stack, dropEntries));
  16931. }
  16932. };
  16933. },{"../internals/create-non-enumerable-property":204,"../internals/error-stack-clear":231,"../internals/error-stack-installable":233}],233:[function(_dereq_,module,exports){
  16934. var fails = _dereq_('../internals/fails');
  16935. var createPropertyDescriptor = _dereq_('../internals/create-property-descriptor');
  16936. module.exports = !fails(function () {
  16937. var error = Error('a');
  16938. if (!('stack' in error)) return true;
  16939. // eslint-disable-next-line es/no-object-defineproperty -- safe
  16940. Object.defineProperty(error, 'stack', createPropertyDescriptor(1, 7));
  16941. return error.stack !== 7;
  16942. });
  16943. },{"../internals/create-property-descriptor":205,"../internals/fails":235}],234:[function(_dereq_,module,exports){
  16944. 'use strict';
  16945. var global = _dereq_('../internals/global');
  16946. var apply = _dereq_('../internals/function-apply');
  16947. var uncurryThis = _dereq_('../internals/function-uncurry-this-clause');
  16948. var isCallable = _dereq_('../internals/is-callable');
  16949. var getOwnPropertyDescriptor = _dereq_('../internals/object-get-own-property-descriptor').f;
  16950. var isForced = _dereq_('../internals/is-forced');
  16951. var path = _dereq_('../internals/path');
  16952. var bind = _dereq_('../internals/function-bind-context');
  16953. var createNonEnumerableProperty = _dereq_('../internals/create-non-enumerable-property');
  16954. var hasOwn = _dereq_('../internals/has-own-property');
  16955. var wrapConstructor = function (NativeConstructor) {
  16956. var Wrapper = function (a, b, c) {
  16957. if (this instanceof Wrapper) {
  16958. switch (arguments.length) {
  16959. case 0: return new NativeConstructor();
  16960. case 1: return new NativeConstructor(a);
  16961. case 2: return new NativeConstructor(a, b);
  16962. } return new NativeConstructor(a, b, c);
  16963. } return apply(NativeConstructor, this, arguments);
  16964. };
  16965. Wrapper.prototype = NativeConstructor.prototype;
  16966. return Wrapper;
  16967. };
  16968. /*
  16969. options.target - name of the target object
  16970. options.global - target is the global object
  16971. options.stat - export as static methods of target
  16972. options.proto - export as prototype methods of target
  16973. options.real - real prototype method for the `pure` version
  16974. options.forced - export even if the native feature is available
  16975. options.bind - bind methods to the target, required for the `pure` version
  16976. options.wrap - wrap constructors to preventing global pollution, required for the `pure` version
  16977. options.unsafe - use the simple assignment of property instead of delete + defineProperty
  16978. options.sham - add a flag to not completely full polyfills
  16979. options.enumerable - export as enumerable property
  16980. options.dontCallGetSet - prevent calling a getter on target
  16981. options.name - the .name of the function if it does not match the key
  16982. */
  16983. module.exports = function (options, source) {
  16984. var TARGET = options.target;
  16985. var GLOBAL = options.global;
  16986. var STATIC = options.stat;
  16987. var PROTO = options.proto;
  16988. var nativeSource = GLOBAL ? global : STATIC ? global[TARGET] : (global[TARGET] || {}).prototype;
  16989. var target = GLOBAL ? path : path[TARGET] || createNonEnumerableProperty(path, TARGET, {})[TARGET];
  16990. var targetPrototype = target.prototype;
  16991. var FORCED, USE_NATIVE, VIRTUAL_PROTOTYPE;
  16992. var key, sourceProperty, targetProperty, nativeProperty, resultProperty, descriptor;
  16993. for (key in source) {
  16994. FORCED = isForced(GLOBAL ? key : TARGET + (STATIC ? '.' : '#') + key, options.forced);
  16995. // contains in native
  16996. USE_NATIVE = !FORCED && nativeSource && hasOwn(nativeSource, key);
  16997. targetProperty = target[key];
  16998. if (USE_NATIVE) if (options.dontCallGetSet) {
  16999. descriptor = getOwnPropertyDescriptor(nativeSource, key);
  17000. nativeProperty = descriptor && descriptor.value;
  17001. } else nativeProperty = nativeSource[key];
  17002. // export native or implementation
  17003. sourceProperty = (USE_NATIVE && nativeProperty) ? nativeProperty : source[key];
  17004. if (USE_NATIVE && typeof targetProperty == typeof sourceProperty) continue;
  17005. // bind methods to global for calling from export context
  17006. if (options.bind && USE_NATIVE) resultProperty = bind(sourceProperty, global);
  17007. // wrap global constructors for prevent changes in this version
  17008. else if (options.wrap && USE_NATIVE) resultProperty = wrapConstructor(sourceProperty);
  17009. // make static versions for prototype methods
  17010. else if (PROTO && isCallable(sourceProperty)) resultProperty = uncurryThis(sourceProperty);
  17011. // default case
  17012. else resultProperty = sourceProperty;
  17013. // add a flag to not completely full polyfills
  17014. if (options.sham || (sourceProperty && sourceProperty.sham) || (targetProperty && targetProperty.sham)) {
  17015. createNonEnumerableProperty(resultProperty, 'sham', true);
  17016. }
  17017. createNonEnumerableProperty(target, key, resultProperty);
  17018. if (PROTO) {
  17019. VIRTUAL_PROTOTYPE = TARGET + 'Prototype';
  17020. if (!hasOwn(path, VIRTUAL_PROTOTYPE)) {
  17021. createNonEnumerableProperty(path, VIRTUAL_PROTOTYPE, {});
  17022. }
  17023. // export virtual prototype methods
  17024. createNonEnumerableProperty(path[VIRTUAL_PROTOTYPE], key, sourceProperty);
  17025. // export real prototype methods
  17026. if (options.real && targetPrototype && (FORCED || !targetPrototype[key])) {
  17027. createNonEnumerableProperty(targetPrototype, key, sourceProperty);
  17028. }
  17029. }
  17030. }
  17031. };
  17032. },{"../internals/create-non-enumerable-property":204,"../internals/function-apply":237,"../internals/function-bind-context":238,"../internals/function-uncurry-this-clause":244,"../internals/global":251,"../internals/has-own-property":252,"../internals/is-callable":264,"../internals/is-forced":266,"../internals/object-get-own-property-descriptor":290,"../internals/path":305}],235:[function(_dereq_,module,exports){
  17033. module.exports = function (exec) {
  17034. try {
  17035. return !!exec();
  17036. } catch (error) {
  17037. return true;
  17038. }
  17039. };
  17040. },{}],236:[function(_dereq_,module,exports){
  17041. var fails = _dereq_('../internals/fails');
  17042. module.exports = !fails(function () {
  17043. // eslint-disable-next-line es/no-object-isextensible, es/no-object-preventextensions -- required for testing
  17044. return Object.isExtensible(Object.preventExtensions({}));
  17045. });
  17046. },{"../internals/fails":235}],237:[function(_dereq_,module,exports){
  17047. var NATIVE_BIND = _dereq_('../internals/function-bind-native');
  17048. var FunctionPrototype = Function.prototype;
  17049. var apply = FunctionPrototype.apply;
  17050. var call = FunctionPrototype.call;
  17051. // eslint-disable-next-line es/no-reflect -- safe
  17052. module.exports = typeof Reflect == 'object' && Reflect.apply || (NATIVE_BIND ? call.bind(apply) : function () {
  17053. return call.apply(apply, arguments);
  17054. });
  17055. },{"../internals/function-bind-native":239}],238:[function(_dereq_,module,exports){
  17056. var uncurryThis = _dereq_('../internals/function-uncurry-this-clause');
  17057. var aCallable = _dereq_('../internals/a-callable');
  17058. var NATIVE_BIND = _dereq_('../internals/function-bind-native');
  17059. var bind = uncurryThis(uncurryThis.bind);
  17060. // optional / simple context binding
  17061. module.exports = function (fn, that) {
  17062. aCallable(fn);
  17063. return that === undefined ? fn : NATIVE_BIND ? bind(fn, that) : function (/* ...args */) {
  17064. return fn.apply(that, arguments);
  17065. };
  17066. };
  17067. },{"../internals/a-callable":173,"../internals/function-bind-native":239,"../internals/function-uncurry-this-clause":244}],239:[function(_dereq_,module,exports){
  17068. var fails = _dereq_('../internals/fails');
  17069. module.exports = !fails(function () {
  17070. // eslint-disable-next-line es/no-function-prototype-bind -- safe
  17071. var test = (function () { /* empty */ }).bind();
  17072. // eslint-disable-next-line no-prototype-builtins -- safe
  17073. return typeof test != 'function' || test.hasOwnProperty('prototype');
  17074. });
  17075. },{"../internals/fails":235}],240:[function(_dereq_,module,exports){
  17076. 'use strict';
  17077. var uncurryThis = _dereq_('../internals/function-uncurry-this');
  17078. var aCallable = _dereq_('../internals/a-callable');
  17079. var isObject = _dereq_('../internals/is-object');
  17080. var hasOwn = _dereq_('../internals/has-own-property');
  17081. var arraySlice = _dereq_('../internals/array-slice');
  17082. var NATIVE_BIND = _dereq_('../internals/function-bind-native');
  17083. var $Function = Function;
  17084. var concat = uncurryThis([].concat);
  17085. var join = uncurryThis([].join);
  17086. var factories = {};
  17087. var construct = function (C, argsLength, args) {
  17088. if (!hasOwn(factories, argsLength)) {
  17089. for (var list = [], i = 0; i < argsLength; i++) list[i] = 'a[' + i + ']';
  17090. factories[argsLength] = $Function('C,a', 'return new C(' + join(list, ',') + ')');
  17091. } return factories[argsLength](C, args);
  17092. };
  17093. // `Function.prototype.bind` method implementation
  17094. // https://tc39.es/ecma262/#sec-function.prototype.bind
  17095. // eslint-disable-next-line es/no-function-prototype-bind -- detection
  17096. module.exports = NATIVE_BIND ? $Function.bind : function bind(that /* , ...args */) {
  17097. var F = aCallable(this);
  17098. var Prototype = F.prototype;
  17099. var partArgs = arraySlice(arguments, 1);
  17100. var boundFunction = function bound(/* args... */) {
  17101. var args = concat(partArgs, arraySlice(arguments));
  17102. return this instanceof boundFunction ? construct(F, args.length, args) : F.apply(that, args);
  17103. };
  17104. if (isObject(Prototype)) boundFunction.prototype = Prototype;
  17105. return boundFunction;
  17106. };
  17107. },{"../internals/a-callable":173,"../internals/array-slice":189,"../internals/function-bind-native":239,"../internals/function-uncurry-this":245,"../internals/has-own-property":252,"../internals/is-object":269}],241:[function(_dereq_,module,exports){
  17108. var NATIVE_BIND = _dereq_('../internals/function-bind-native');
  17109. var call = Function.prototype.call;
  17110. module.exports = NATIVE_BIND ? call.bind(call) : function () {
  17111. return call.apply(call, arguments);
  17112. };
  17113. },{"../internals/function-bind-native":239}],242:[function(_dereq_,module,exports){
  17114. var DESCRIPTORS = _dereq_('../internals/descriptors');
  17115. var hasOwn = _dereq_('../internals/has-own-property');
  17116. var FunctionPrototype = Function.prototype;
  17117. // eslint-disable-next-line es/no-object-getownpropertydescriptor -- safe
  17118. var getDescriptor = DESCRIPTORS && Object.getOwnPropertyDescriptor;
  17119. var EXISTS = hasOwn(FunctionPrototype, 'name');
  17120. // additional protection from minified / mangled / dropped function names
  17121. var PROPER = EXISTS && (function something() { /* empty */ }).name === 'something';
  17122. var CONFIGURABLE = EXISTS && (!DESCRIPTORS || (DESCRIPTORS && getDescriptor(FunctionPrototype, 'name').configurable));
  17123. module.exports = {
  17124. EXISTS: EXISTS,
  17125. PROPER: PROPER,
  17126. CONFIGURABLE: CONFIGURABLE
  17127. };
  17128. },{"../internals/descriptors":212,"../internals/has-own-property":252}],243:[function(_dereq_,module,exports){
  17129. var uncurryThis = _dereq_('../internals/function-uncurry-this');
  17130. var aCallable = _dereq_('../internals/a-callable');
  17131. module.exports = function (object, key, method) {
  17132. try {
  17133. // eslint-disable-next-line es/no-object-getownpropertydescriptor -- safe
  17134. return uncurryThis(aCallable(Object.getOwnPropertyDescriptor(object, key)[method]));
  17135. } catch (error) { /* empty */ }
  17136. };
  17137. },{"../internals/a-callable":173,"../internals/function-uncurry-this":245}],244:[function(_dereq_,module,exports){
  17138. var classofRaw = _dereq_('../internals/classof-raw');
  17139. var uncurryThis = _dereq_('../internals/function-uncurry-this');
  17140. module.exports = function (fn) {
  17141. // Nashorn bug:
  17142. // https://github.com/zloirock/core-js/issues/1128
  17143. // https://github.com/zloirock/core-js/issues/1130
  17144. if (classofRaw(fn) === 'Function') return uncurryThis(fn);
  17145. };
  17146. },{"../internals/classof-raw":195,"../internals/function-uncurry-this":245}],245:[function(_dereq_,module,exports){
  17147. var NATIVE_BIND = _dereq_('../internals/function-bind-native');
  17148. var FunctionPrototype = Function.prototype;
  17149. var call = FunctionPrototype.call;
  17150. var uncurryThisWithBind = NATIVE_BIND && FunctionPrototype.bind.bind(call, call);
  17151. module.exports = NATIVE_BIND ? uncurryThisWithBind : function (fn) {
  17152. return function () {
  17153. return call.apply(fn, arguments);
  17154. };
  17155. };
  17156. },{"../internals/function-bind-native":239}],246:[function(_dereq_,module,exports){
  17157. var path = _dereq_('../internals/path');
  17158. var global = _dereq_('../internals/global');
  17159. var isCallable = _dereq_('../internals/is-callable');
  17160. var aFunction = function (variable) {
  17161. return isCallable(variable) ? variable : undefined;
  17162. };
  17163. module.exports = function (namespace, method) {
  17164. return arguments.length < 2 ? aFunction(path[namespace]) || aFunction(global[namespace])
  17165. : path[namespace] && path[namespace][method] || global[namespace] && global[namespace][method];
  17166. };
  17167. },{"../internals/global":251,"../internals/is-callable":264,"../internals/path":305}],247:[function(_dereq_,module,exports){
  17168. var classof = _dereq_('../internals/classof');
  17169. var getMethod = _dereq_('../internals/get-method');
  17170. var isNullOrUndefined = _dereq_('../internals/is-null-or-undefined');
  17171. var Iterators = _dereq_('../internals/iterators');
  17172. var wellKnownSymbol = _dereq_('../internals/well-known-symbol');
  17173. var ITERATOR = wellKnownSymbol('iterator');
  17174. module.exports = function (it) {
  17175. if (!isNullOrUndefined(it)) return getMethod(it, ITERATOR)
  17176. || getMethod(it, '@@iterator')
  17177. || Iterators[classof(it)];
  17178. };
  17179. },{"../internals/classof":196,"../internals/get-method":250,"../internals/is-null-or-undefined":268,"../internals/iterators":278,"../internals/well-known-symbol":343}],248:[function(_dereq_,module,exports){
  17180. var call = _dereq_('../internals/function-call');
  17181. var aCallable = _dereq_('../internals/a-callable');
  17182. var anObject = _dereq_('../internals/an-object');
  17183. var tryToString = _dereq_('../internals/try-to-string');
  17184. var getIteratorMethod = _dereq_('../internals/get-iterator-method');
  17185. var $TypeError = TypeError;
  17186. module.exports = function (argument, usingIterator) {
  17187. var iteratorMethod = arguments.length < 2 ? getIteratorMethod(argument) : usingIterator;
  17188. if (aCallable(iteratorMethod)) return anObject(call(iteratorMethod, argument));
  17189. throw $TypeError(tryToString(argument) + ' is not iterable');
  17190. };
  17191. },{"../internals/a-callable":173,"../internals/an-object":178,"../internals/function-call":241,"../internals/get-iterator-method":247,"../internals/try-to-string":335}],249:[function(_dereq_,module,exports){
  17192. var uncurryThis = _dereq_('../internals/function-uncurry-this');
  17193. var isArray = _dereq_('../internals/is-array');
  17194. var isCallable = _dereq_('../internals/is-callable');
  17195. var classof = _dereq_('../internals/classof-raw');
  17196. var toString = _dereq_('../internals/to-string');
  17197. var push = uncurryThis([].push);
  17198. module.exports = function (replacer) {
  17199. if (isCallable(replacer)) return replacer;
  17200. if (!isArray(replacer)) return;
  17201. var rawLength = replacer.length;
  17202. var keys = [];
  17203. for (var i = 0; i < rawLength; i++) {
  17204. var element = replacer[i];
  17205. if (typeof element == 'string') push(keys, element);
  17206. else if (typeof element == 'number' || classof(element) == 'Number' || classof(element) == 'String') push(keys, toString(element));
  17207. }
  17208. var keysLength = keys.length;
  17209. var root = true;
  17210. return function (key, value) {
  17211. if (root) {
  17212. root = false;
  17213. return value;
  17214. }
  17215. if (isArray(this)) return value;
  17216. for (var j = 0; j < keysLength; j++) if (keys[j] === key) return value;
  17217. };
  17218. };
  17219. },{"../internals/classof-raw":195,"../internals/function-uncurry-this":245,"../internals/is-array":263,"../internals/is-callable":264,"../internals/to-string":334}],250:[function(_dereq_,module,exports){
  17220. var aCallable = _dereq_('../internals/a-callable');
  17221. var isNullOrUndefined = _dereq_('../internals/is-null-or-undefined');
  17222. // `GetMethod` abstract operation
  17223. // https://tc39.es/ecma262/#sec-getmethod
  17224. module.exports = function (V, P) {
  17225. var func = V[P];
  17226. return isNullOrUndefined(func) ? undefined : aCallable(func);
  17227. };
  17228. },{"../internals/a-callable":173,"../internals/is-null-or-undefined":268}],251:[function(_dereq_,module,exports){
  17229. (function (global){(function (){
  17230. var check = function (it) {
  17231. return it && it.Math == Math && it;
  17232. };
  17233. // https://github.com/zloirock/core-js/issues/86#issuecomment-115759028
  17234. module.exports =
  17235. // eslint-disable-next-line es/no-global-this -- safe
  17236. check(typeof globalThis == 'object' && globalThis) ||
  17237. check(typeof window == 'object' && window) ||
  17238. // eslint-disable-next-line no-restricted-globals -- safe
  17239. check(typeof self == 'object' && self) ||
  17240. check(typeof global == 'object' && global) ||
  17241. // eslint-disable-next-line no-new-func -- fallback
  17242. (function () { return this; })() || this || Function('return this')();
  17243. }).call(this)}).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {})
  17244. },{}],252:[function(_dereq_,module,exports){
  17245. var uncurryThis = _dereq_('../internals/function-uncurry-this');
  17246. var toObject = _dereq_('../internals/to-object');
  17247. var hasOwnProperty = uncurryThis({}.hasOwnProperty);
  17248. // `HasOwnProperty` abstract operation
  17249. // https://tc39.es/ecma262/#sec-hasownproperty
  17250. // eslint-disable-next-line es/no-object-hasown -- safe
  17251. module.exports = Object.hasOwn || function hasOwn(it, key) {
  17252. return hasOwnProperty(toObject(it), key);
  17253. };
  17254. },{"../internals/function-uncurry-this":245,"../internals/to-object":330}],253:[function(_dereq_,module,exports){
  17255. module.exports = {};
  17256. },{}],254:[function(_dereq_,module,exports){
  17257. module.exports = function (a, b) {
  17258. try {
  17259. // eslint-disable-next-line no-console -- safe
  17260. arguments.length == 1 ? console.error(a) : console.error(a, b);
  17261. } catch (error) { /* empty */ }
  17262. };
  17263. },{}],255:[function(_dereq_,module,exports){
  17264. var getBuiltIn = _dereq_('../internals/get-built-in');
  17265. module.exports = getBuiltIn('document', 'documentElement');
  17266. },{"../internals/get-built-in":246}],256:[function(_dereq_,module,exports){
  17267. var DESCRIPTORS = _dereq_('../internals/descriptors');
  17268. var fails = _dereq_('../internals/fails');
  17269. var createElement = _dereq_('../internals/document-create-element');
  17270. // Thanks to IE8 for its funny defineProperty
  17271. module.exports = !DESCRIPTORS && !fails(function () {
  17272. // eslint-disable-next-line es/no-object-defineproperty -- required for testing
  17273. return Object.defineProperty(createElement('div'), 'a', {
  17274. get: function () { return 7; }
  17275. }).a != 7;
  17276. });
  17277. },{"../internals/descriptors":212,"../internals/document-create-element":214,"../internals/fails":235}],257:[function(_dereq_,module,exports){
  17278. var uncurryThis = _dereq_('../internals/function-uncurry-this');
  17279. var fails = _dereq_('../internals/fails');
  17280. var classof = _dereq_('../internals/classof-raw');
  17281. var $Object = Object;
  17282. var split = uncurryThis(''.split);
  17283. // fallback for non-array-like ES3 and non-enumerable old V8 strings
  17284. module.exports = fails(function () {
  17285. // throws an error in rhino, see https://github.com/mozilla/rhino/issues/346
  17286. // eslint-disable-next-line no-prototype-builtins -- safe
  17287. return !$Object('z').propertyIsEnumerable(0);
  17288. }) ? function (it) {
  17289. return classof(it) == 'String' ? split(it, '') : $Object(it);
  17290. } : $Object;
  17291. },{"../internals/classof-raw":195,"../internals/fails":235,"../internals/function-uncurry-this":245}],258:[function(_dereq_,module,exports){
  17292. var uncurryThis = _dereq_('../internals/function-uncurry-this');
  17293. var isCallable = _dereq_('../internals/is-callable');
  17294. var store = _dereq_('../internals/shared-store');
  17295. var functionToString = uncurryThis(Function.toString);
  17296. // this helper broken in `core-js@3.4.1-3.4.4`, so we can't use `shared` helper
  17297. if (!isCallable(store.inspectSource)) {
  17298. store.inspectSource = function (it) {
  17299. return functionToString(it);
  17300. };
  17301. }
  17302. module.exports = store.inspectSource;
  17303. },{"../internals/function-uncurry-this":245,"../internals/is-callable":264,"../internals/shared-store":317}],259:[function(_dereq_,module,exports){
  17304. var isObject = _dereq_('../internals/is-object');
  17305. var createNonEnumerableProperty = _dereq_('../internals/create-non-enumerable-property');
  17306. // `InstallErrorCause` abstract operation
  17307. // https://tc39.es/proposal-error-cause/#sec-errorobjects-install-error-cause
  17308. module.exports = function (O, options) {
  17309. if (isObject(options) && 'cause' in options) {
  17310. createNonEnumerableProperty(O, 'cause', options.cause);
  17311. }
  17312. };
  17313. },{"../internals/create-non-enumerable-property":204,"../internals/is-object":269}],260:[function(_dereq_,module,exports){
  17314. var $ = _dereq_('../internals/export');
  17315. var uncurryThis = _dereq_('../internals/function-uncurry-this');
  17316. var hiddenKeys = _dereq_('../internals/hidden-keys');
  17317. var isObject = _dereq_('../internals/is-object');
  17318. var hasOwn = _dereq_('../internals/has-own-property');
  17319. var defineProperty = _dereq_('../internals/object-define-property').f;
  17320. var getOwnPropertyNamesModule = _dereq_('../internals/object-get-own-property-names');
  17321. var getOwnPropertyNamesExternalModule = _dereq_('../internals/object-get-own-property-names-external');
  17322. var isExtensible = _dereq_('../internals/object-is-extensible');
  17323. var uid = _dereq_('../internals/uid');
  17324. var FREEZING = _dereq_('../internals/freezing');
  17325. var REQUIRED = false;
  17326. var METADATA = uid('meta');
  17327. var id = 0;
  17328. var setMetadata = function (it) {
  17329. defineProperty(it, METADATA, { value: {
  17330. objectID: 'O' + id++, // object ID
  17331. weakData: {} // weak collections IDs
  17332. } });
  17333. };
  17334. var fastKey = function (it, create) {
  17335. // return a primitive with prefix
  17336. if (!isObject(it)) return typeof it == 'symbol' ? it : (typeof it == 'string' ? 'S' : 'P') + it;
  17337. if (!hasOwn(it, METADATA)) {
  17338. // can't set metadata to uncaught frozen object
  17339. if (!isExtensible(it)) return 'F';
  17340. // not necessary to add metadata
  17341. if (!create) return 'E';
  17342. // add missing metadata
  17343. setMetadata(it);
  17344. // return object ID
  17345. } return it[METADATA].objectID;
  17346. };
  17347. var getWeakData = function (it, create) {
  17348. if (!hasOwn(it, METADATA)) {
  17349. // can't set metadata to uncaught frozen object
  17350. if (!isExtensible(it)) return true;
  17351. // not necessary to add metadata
  17352. if (!create) return false;
  17353. // add missing metadata
  17354. setMetadata(it);
  17355. // return the store of weak collections IDs
  17356. } return it[METADATA].weakData;
  17357. };
  17358. // add metadata on freeze-family methods calling
  17359. var onFreeze = function (it) {
  17360. if (FREEZING && REQUIRED && isExtensible(it) && !hasOwn(it, METADATA)) setMetadata(it);
  17361. return it;
  17362. };
  17363. var enable = function () {
  17364. meta.enable = function () { /* empty */ };
  17365. REQUIRED = true;
  17366. var getOwnPropertyNames = getOwnPropertyNamesModule.f;
  17367. var splice = uncurryThis([].splice);
  17368. var test = {};
  17369. test[METADATA] = 1;
  17370. // prevent exposing of metadata key
  17371. if (getOwnPropertyNames(test).length) {
  17372. getOwnPropertyNamesModule.f = function (it) {
  17373. var result = getOwnPropertyNames(it);
  17374. for (var i = 0, length = result.length; i < length; i++) {
  17375. if (result[i] === METADATA) {
  17376. splice(result, i, 1);
  17377. break;
  17378. }
  17379. } return result;
  17380. };
  17381. $({ target: 'Object', stat: true, forced: true }, {
  17382. getOwnPropertyNames: getOwnPropertyNamesExternalModule.f
  17383. });
  17384. }
  17385. };
  17386. var meta = module.exports = {
  17387. enable: enable,
  17388. fastKey: fastKey,
  17389. getWeakData: getWeakData,
  17390. onFreeze: onFreeze
  17391. };
  17392. hiddenKeys[METADATA] = true;
  17393. },{"../internals/export":234,"../internals/freezing":236,"../internals/function-uncurry-this":245,"../internals/has-own-property":252,"../internals/hidden-keys":253,"../internals/is-object":269,"../internals/object-define-property":289,"../internals/object-get-own-property-names":292,"../internals/object-get-own-property-names-external":291,"../internals/object-is-extensible":295,"../internals/uid":336}],261:[function(_dereq_,module,exports){
  17394. var NATIVE_WEAK_MAP = _dereq_('../internals/weak-map-basic-detection');
  17395. var global = _dereq_('../internals/global');
  17396. var isObject = _dereq_('../internals/is-object');
  17397. var createNonEnumerableProperty = _dereq_('../internals/create-non-enumerable-property');
  17398. var hasOwn = _dereq_('../internals/has-own-property');
  17399. var shared = _dereq_('../internals/shared-store');
  17400. var sharedKey = _dereq_('../internals/shared-key');
  17401. var hiddenKeys = _dereq_('../internals/hidden-keys');
  17402. var OBJECT_ALREADY_INITIALIZED = 'Object already initialized';
  17403. var TypeError = global.TypeError;
  17404. var WeakMap = global.WeakMap;
  17405. var set, get, has;
  17406. var enforce = function (it) {
  17407. return has(it) ? get(it) : set(it, {});
  17408. };
  17409. var getterFor = function (TYPE) {
  17410. return function (it) {
  17411. var state;
  17412. if (!isObject(it) || (state = get(it)).type !== TYPE) {
  17413. throw TypeError('Incompatible receiver, ' + TYPE + ' required');
  17414. } return state;
  17415. };
  17416. };
  17417. if (NATIVE_WEAK_MAP || shared.state) {
  17418. var store = shared.state || (shared.state = new WeakMap());
  17419. /* eslint-disable no-self-assign -- prototype methods protection */
  17420. store.get = store.get;
  17421. store.has = store.has;
  17422. store.set = store.set;
  17423. /* eslint-enable no-self-assign -- prototype methods protection */
  17424. set = function (it, metadata) {
  17425. if (store.has(it)) throw TypeError(OBJECT_ALREADY_INITIALIZED);
  17426. metadata.facade = it;
  17427. store.set(it, metadata);
  17428. return metadata;
  17429. };
  17430. get = function (it) {
  17431. return store.get(it) || {};
  17432. };
  17433. has = function (it) {
  17434. return store.has(it);
  17435. };
  17436. } else {
  17437. var STATE = sharedKey('state');
  17438. hiddenKeys[STATE] = true;
  17439. set = function (it, metadata) {
  17440. if (hasOwn(it, STATE)) throw TypeError(OBJECT_ALREADY_INITIALIZED);
  17441. metadata.facade = it;
  17442. createNonEnumerableProperty(it, STATE, metadata);
  17443. return metadata;
  17444. };
  17445. get = function (it) {
  17446. return hasOwn(it, STATE) ? it[STATE] : {};
  17447. };
  17448. has = function (it) {
  17449. return hasOwn(it, STATE);
  17450. };
  17451. }
  17452. module.exports = {
  17453. set: set,
  17454. get: get,
  17455. has: has,
  17456. enforce: enforce,
  17457. getterFor: getterFor
  17458. };
  17459. },{"../internals/create-non-enumerable-property":204,"../internals/global":251,"../internals/has-own-property":252,"../internals/hidden-keys":253,"../internals/is-object":269,"../internals/shared-key":316,"../internals/shared-store":317,"../internals/weak-map-basic-detection":340}],262:[function(_dereq_,module,exports){
  17460. var wellKnownSymbol = _dereq_('../internals/well-known-symbol');
  17461. var Iterators = _dereq_('../internals/iterators');
  17462. var ITERATOR = wellKnownSymbol('iterator');
  17463. var ArrayPrototype = Array.prototype;
  17464. // check on default Array iterator
  17465. module.exports = function (it) {
  17466. return it !== undefined && (Iterators.Array === it || ArrayPrototype[ITERATOR] === it);
  17467. };
  17468. },{"../internals/iterators":278,"../internals/well-known-symbol":343}],263:[function(_dereq_,module,exports){
  17469. var classof = _dereq_('../internals/classof-raw');
  17470. // `IsArray` abstract operation
  17471. // https://tc39.es/ecma262/#sec-isarray
  17472. // eslint-disable-next-line es/no-array-isarray -- safe
  17473. module.exports = Array.isArray || function isArray(argument) {
  17474. return classof(argument) == 'Array';
  17475. };
  17476. },{"../internals/classof-raw":195}],264:[function(_dereq_,module,exports){
  17477. var $documentAll = _dereq_('../internals/document-all');
  17478. var documentAll = $documentAll.all;
  17479. // `IsCallable` abstract operation
  17480. // https://tc39.es/ecma262/#sec-iscallable
  17481. module.exports = $documentAll.IS_HTMLDDA ? function (argument) {
  17482. return typeof argument == 'function' || argument === documentAll;
  17483. } : function (argument) {
  17484. return typeof argument == 'function';
  17485. };
  17486. },{"../internals/document-all":213}],265:[function(_dereq_,module,exports){
  17487. var uncurryThis = _dereq_('../internals/function-uncurry-this');
  17488. var fails = _dereq_('../internals/fails');
  17489. var isCallable = _dereq_('../internals/is-callable');
  17490. var classof = _dereq_('../internals/classof');
  17491. var getBuiltIn = _dereq_('../internals/get-built-in');
  17492. var inspectSource = _dereq_('../internals/inspect-source');
  17493. var noop = function () { /* empty */ };
  17494. var empty = [];
  17495. var construct = getBuiltIn('Reflect', 'construct');
  17496. var constructorRegExp = /^\s*(?:class|function)\b/;
  17497. var exec = uncurryThis(constructorRegExp.exec);
  17498. var INCORRECT_TO_STRING = !constructorRegExp.exec(noop);
  17499. var isConstructorModern = function isConstructor(argument) {
  17500. if (!isCallable(argument)) return false;
  17501. try {
  17502. construct(noop, empty, argument);
  17503. return true;
  17504. } catch (error) {
  17505. return false;
  17506. }
  17507. };
  17508. var isConstructorLegacy = function isConstructor(argument) {
  17509. if (!isCallable(argument)) return false;
  17510. switch (classof(argument)) {
  17511. case 'AsyncFunction':
  17512. case 'GeneratorFunction':
  17513. case 'AsyncGeneratorFunction': return false;
  17514. }
  17515. try {
  17516. // we can't check .prototype since constructors produced by .bind haven't it
  17517. // `Function#toString` throws on some built-it function in some legacy engines
  17518. // (for example, `DOMQuad` and similar in FF41-)
  17519. return INCORRECT_TO_STRING || !!exec(constructorRegExp, inspectSource(argument));
  17520. } catch (error) {
  17521. return true;
  17522. }
  17523. };
  17524. isConstructorLegacy.sham = true;
  17525. // `IsConstructor` abstract operation
  17526. // https://tc39.es/ecma262/#sec-isconstructor
  17527. module.exports = !construct || fails(function () {
  17528. var called;
  17529. return isConstructorModern(isConstructorModern.call)
  17530. || !isConstructorModern(Object)
  17531. || !isConstructorModern(function () { called = true; })
  17532. || called;
  17533. }) ? isConstructorLegacy : isConstructorModern;
  17534. },{"../internals/classof":196,"../internals/fails":235,"../internals/function-uncurry-this":245,"../internals/get-built-in":246,"../internals/inspect-source":258,"../internals/is-callable":264}],266:[function(_dereq_,module,exports){
  17535. var fails = _dereq_('../internals/fails');
  17536. var isCallable = _dereq_('../internals/is-callable');
  17537. var replacement = /#|\.prototype\./;
  17538. var isForced = function (feature, detection) {
  17539. var value = data[normalize(feature)];
  17540. return value == POLYFILL ? true
  17541. : value == NATIVE ? false
  17542. : isCallable(detection) ? fails(detection)
  17543. : !!detection;
  17544. };
  17545. var normalize = isForced.normalize = function (string) {
  17546. return String(string).replace(replacement, '.').toLowerCase();
  17547. };
  17548. var data = isForced.data = {};
  17549. var NATIVE = isForced.NATIVE = 'N';
  17550. var POLYFILL = isForced.POLYFILL = 'P';
  17551. module.exports = isForced;
  17552. },{"../internals/fails":235,"../internals/is-callable":264}],267:[function(_dereq_,module,exports){
  17553. var isObject = _dereq_('../internals/is-object');
  17554. var floor = Math.floor;
  17555. // `IsIntegralNumber` abstract operation
  17556. // https://tc39.es/ecma262/#sec-isintegralnumber
  17557. // eslint-disable-next-line es/no-number-isinteger -- safe
  17558. module.exports = Number.isInteger || function isInteger(it) {
  17559. return !isObject(it) && isFinite(it) && floor(it) === it;
  17560. };
  17561. },{"../internals/is-object":269}],268:[function(_dereq_,module,exports){
  17562. // we can't use just `it == null` since of `document.all` special case
  17563. // https://tc39.es/ecma262/#sec-IsHTMLDDA-internal-slot-aec
  17564. module.exports = function (it) {
  17565. return it === null || it === undefined;
  17566. };
  17567. },{}],269:[function(_dereq_,module,exports){
  17568. var isCallable = _dereq_('../internals/is-callable');
  17569. var $documentAll = _dereq_('../internals/document-all');
  17570. var documentAll = $documentAll.all;
  17571. module.exports = $documentAll.IS_HTMLDDA ? function (it) {
  17572. return typeof it == 'object' ? it !== null : isCallable(it) || it === documentAll;
  17573. } : function (it) {
  17574. return typeof it == 'object' ? it !== null : isCallable(it);
  17575. };
  17576. },{"../internals/document-all":213,"../internals/is-callable":264}],270:[function(_dereq_,module,exports){
  17577. module.exports = true;
  17578. },{}],271:[function(_dereq_,module,exports){
  17579. var isObject = _dereq_('../internals/is-object');
  17580. var classof = _dereq_('../internals/classof-raw');
  17581. var wellKnownSymbol = _dereq_('../internals/well-known-symbol');
  17582. var MATCH = wellKnownSymbol('match');
  17583. // `IsRegExp` abstract operation
  17584. // https://tc39.es/ecma262/#sec-isregexp
  17585. module.exports = function (it) {
  17586. var isRegExp;
  17587. return isObject(it) && ((isRegExp = it[MATCH]) !== undefined ? !!isRegExp : classof(it) == 'RegExp');
  17588. };
  17589. },{"../internals/classof-raw":195,"../internals/is-object":269,"../internals/well-known-symbol":343}],272:[function(_dereq_,module,exports){
  17590. var getBuiltIn = _dereq_('../internals/get-built-in');
  17591. var isCallable = _dereq_('../internals/is-callable');
  17592. var isPrototypeOf = _dereq_('../internals/object-is-prototype-of');
  17593. var USE_SYMBOL_AS_UID = _dereq_('../internals/use-symbol-as-uid');
  17594. var $Object = Object;
  17595. module.exports = USE_SYMBOL_AS_UID ? function (it) {
  17596. return typeof it == 'symbol';
  17597. } : function (it) {
  17598. var $Symbol = getBuiltIn('Symbol');
  17599. return isCallable($Symbol) && isPrototypeOf($Symbol.prototype, $Object(it));
  17600. };
  17601. },{"../internals/get-built-in":246,"../internals/is-callable":264,"../internals/object-is-prototype-of":296,"../internals/use-symbol-as-uid":337}],273:[function(_dereq_,module,exports){
  17602. var bind = _dereq_('../internals/function-bind-context');
  17603. var call = _dereq_('../internals/function-call');
  17604. var anObject = _dereq_('../internals/an-object');
  17605. var tryToString = _dereq_('../internals/try-to-string');
  17606. var isArrayIteratorMethod = _dereq_('../internals/is-array-iterator-method');
  17607. var lengthOfArrayLike = _dereq_('../internals/length-of-array-like');
  17608. var isPrototypeOf = _dereq_('../internals/object-is-prototype-of');
  17609. var getIterator = _dereq_('../internals/get-iterator');
  17610. var getIteratorMethod = _dereq_('../internals/get-iterator-method');
  17611. var iteratorClose = _dereq_('../internals/iterator-close');
  17612. var $TypeError = TypeError;
  17613. var Result = function (stopped, result) {
  17614. this.stopped = stopped;
  17615. this.result = result;
  17616. };
  17617. var ResultPrototype = Result.prototype;
  17618. module.exports = function (iterable, unboundFunction, options) {
  17619. var that = options && options.that;
  17620. var AS_ENTRIES = !!(options && options.AS_ENTRIES);
  17621. var IS_RECORD = !!(options && options.IS_RECORD);
  17622. var IS_ITERATOR = !!(options && options.IS_ITERATOR);
  17623. var INTERRUPTED = !!(options && options.INTERRUPTED);
  17624. var fn = bind(unboundFunction, that);
  17625. var iterator, iterFn, index, length, result, next, step;
  17626. var stop = function (condition) {
  17627. if (iterator) iteratorClose(iterator, 'normal', condition);
  17628. return new Result(true, condition);
  17629. };
  17630. var callFn = function (value) {
  17631. if (AS_ENTRIES) {
  17632. anObject(value);
  17633. return INTERRUPTED ? fn(value[0], value[1], stop) : fn(value[0], value[1]);
  17634. } return INTERRUPTED ? fn(value, stop) : fn(value);
  17635. };
  17636. if (IS_RECORD) {
  17637. iterator = iterable.iterator;
  17638. } else if (IS_ITERATOR) {
  17639. iterator = iterable;
  17640. } else {
  17641. iterFn = getIteratorMethod(iterable);
  17642. if (!iterFn) throw $TypeError(tryToString(iterable) + ' is not iterable');
  17643. // optimisation for array iterators
  17644. if (isArrayIteratorMethod(iterFn)) {
  17645. for (index = 0, length = lengthOfArrayLike(iterable); length > index; index++) {
  17646. result = callFn(iterable[index]);
  17647. if (result && isPrototypeOf(ResultPrototype, result)) return result;
  17648. } return new Result(false);
  17649. }
  17650. iterator = getIterator(iterable, iterFn);
  17651. }
  17652. next = IS_RECORD ? iterable.next : iterator.next;
  17653. while (!(step = call(next, iterator)).done) {
  17654. try {
  17655. result = callFn(step.value);
  17656. } catch (error) {
  17657. iteratorClose(iterator, 'throw', error);
  17658. }
  17659. if (typeof result == 'object' && result && isPrototypeOf(ResultPrototype, result)) return result;
  17660. } return new Result(false);
  17661. };
  17662. },{"../internals/an-object":178,"../internals/function-bind-context":238,"../internals/function-call":241,"../internals/get-iterator":248,"../internals/get-iterator-method":247,"../internals/is-array-iterator-method":262,"../internals/iterator-close":274,"../internals/length-of-array-like":279,"../internals/object-is-prototype-of":296,"../internals/try-to-string":335}],274:[function(_dereq_,module,exports){
  17663. var call = _dereq_('../internals/function-call');
  17664. var anObject = _dereq_('../internals/an-object');
  17665. var getMethod = _dereq_('../internals/get-method');
  17666. module.exports = function (iterator, kind, value) {
  17667. var innerResult, innerError;
  17668. anObject(iterator);
  17669. try {
  17670. innerResult = getMethod(iterator, 'return');
  17671. if (!innerResult) {
  17672. if (kind === 'throw') throw value;
  17673. return value;
  17674. }
  17675. innerResult = call(innerResult, iterator);
  17676. } catch (error) {
  17677. innerError = true;
  17678. innerResult = error;
  17679. }
  17680. if (kind === 'throw') throw value;
  17681. if (innerError) throw innerResult;
  17682. anObject(innerResult);
  17683. return value;
  17684. };
  17685. },{"../internals/an-object":178,"../internals/function-call":241,"../internals/get-method":250}],275:[function(_dereq_,module,exports){
  17686. 'use strict';
  17687. var IteratorPrototype = _dereq_('../internals/iterators-core').IteratorPrototype;
  17688. var create = _dereq_('../internals/object-create');
  17689. var createPropertyDescriptor = _dereq_('../internals/create-property-descriptor');
  17690. var setToStringTag = _dereq_('../internals/set-to-string-tag');
  17691. var Iterators = _dereq_('../internals/iterators');
  17692. var returnThis = function () { return this; };
  17693. module.exports = function (IteratorConstructor, NAME, next, ENUMERABLE_NEXT) {
  17694. var TO_STRING_TAG = NAME + ' Iterator';
  17695. IteratorConstructor.prototype = create(IteratorPrototype, { next: createPropertyDescriptor(+!ENUMERABLE_NEXT, next) });
  17696. setToStringTag(IteratorConstructor, TO_STRING_TAG, false, true);
  17697. Iterators[TO_STRING_TAG] = returnThis;
  17698. return IteratorConstructor;
  17699. };
  17700. },{"../internals/create-property-descriptor":205,"../internals/iterators":278,"../internals/iterators-core":277,"../internals/object-create":287,"../internals/set-to-string-tag":315}],276:[function(_dereq_,module,exports){
  17701. 'use strict';
  17702. var $ = _dereq_('../internals/export');
  17703. var call = _dereq_('../internals/function-call');
  17704. var IS_PURE = _dereq_('../internals/is-pure');
  17705. var FunctionName = _dereq_('../internals/function-name');
  17706. var isCallable = _dereq_('../internals/is-callable');
  17707. var createIteratorConstructor = _dereq_('../internals/iterator-create-constructor');
  17708. var getPrototypeOf = _dereq_('../internals/object-get-prototype-of');
  17709. var setPrototypeOf = _dereq_('../internals/object-set-prototype-of');
  17710. var setToStringTag = _dereq_('../internals/set-to-string-tag');
  17711. var createNonEnumerableProperty = _dereq_('../internals/create-non-enumerable-property');
  17712. var defineBuiltIn = _dereq_('../internals/define-built-in');
  17713. var wellKnownSymbol = _dereq_('../internals/well-known-symbol');
  17714. var Iterators = _dereq_('../internals/iterators');
  17715. var IteratorsCore = _dereq_('../internals/iterators-core');
  17716. var PROPER_FUNCTION_NAME = FunctionName.PROPER;
  17717. var CONFIGURABLE_FUNCTION_NAME = FunctionName.CONFIGURABLE;
  17718. var IteratorPrototype = IteratorsCore.IteratorPrototype;
  17719. var BUGGY_SAFARI_ITERATORS = IteratorsCore.BUGGY_SAFARI_ITERATORS;
  17720. var ITERATOR = wellKnownSymbol('iterator');
  17721. var KEYS = 'keys';
  17722. var VALUES = 'values';
  17723. var ENTRIES = 'entries';
  17724. var returnThis = function () { return this; };
  17725. module.exports = function (Iterable, NAME, IteratorConstructor, next, DEFAULT, IS_SET, FORCED) {
  17726. createIteratorConstructor(IteratorConstructor, NAME, next);
  17727. var getIterationMethod = function (KIND) {
  17728. if (KIND === DEFAULT && defaultIterator) return defaultIterator;
  17729. if (!BUGGY_SAFARI_ITERATORS && KIND in IterablePrototype) return IterablePrototype[KIND];
  17730. switch (KIND) {
  17731. case KEYS: return function keys() { return new IteratorConstructor(this, KIND); };
  17732. case VALUES: return function values() { return new IteratorConstructor(this, KIND); };
  17733. case ENTRIES: return function entries() { return new IteratorConstructor(this, KIND); };
  17734. } return function () { return new IteratorConstructor(this); };
  17735. };
  17736. var TO_STRING_TAG = NAME + ' Iterator';
  17737. var INCORRECT_VALUES_NAME = false;
  17738. var IterablePrototype = Iterable.prototype;
  17739. var nativeIterator = IterablePrototype[ITERATOR]
  17740. || IterablePrototype['@@iterator']
  17741. || DEFAULT && IterablePrototype[DEFAULT];
  17742. var defaultIterator = !BUGGY_SAFARI_ITERATORS && nativeIterator || getIterationMethod(DEFAULT);
  17743. var anyNativeIterator = NAME == 'Array' ? IterablePrototype.entries || nativeIterator : nativeIterator;
  17744. var CurrentIteratorPrototype, methods, KEY;
  17745. // fix native
  17746. if (anyNativeIterator) {
  17747. CurrentIteratorPrototype = getPrototypeOf(anyNativeIterator.call(new Iterable()));
  17748. if (CurrentIteratorPrototype !== Object.prototype && CurrentIteratorPrototype.next) {
  17749. if (!IS_PURE && getPrototypeOf(CurrentIteratorPrototype) !== IteratorPrototype) {
  17750. if (setPrototypeOf) {
  17751. setPrototypeOf(CurrentIteratorPrototype, IteratorPrototype);
  17752. } else if (!isCallable(CurrentIteratorPrototype[ITERATOR])) {
  17753. defineBuiltIn(CurrentIteratorPrototype, ITERATOR, returnThis);
  17754. }
  17755. }
  17756. // Set @@toStringTag to native iterators
  17757. setToStringTag(CurrentIteratorPrototype, TO_STRING_TAG, true, true);
  17758. if (IS_PURE) Iterators[TO_STRING_TAG] = returnThis;
  17759. }
  17760. }
  17761. // fix Array.prototype.{ values, @@iterator }.name in V8 / FF
  17762. if (PROPER_FUNCTION_NAME && DEFAULT == VALUES && nativeIterator && nativeIterator.name !== VALUES) {
  17763. if (!IS_PURE && CONFIGURABLE_FUNCTION_NAME) {
  17764. createNonEnumerableProperty(IterablePrototype, 'name', VALUES);
  17765. } else {
  17766. INCORRECT_VALUES_NAME = true;
  17767. defaultIterator = function values() { return call(nativeIterator, this); };
  17768. }
  17769. }
  17770. // export additional methods
  17771. if (DEFAULT) {
  17772. methods = {
  17773. values: getIterationMethod(VALUES),
  17774. keys: IS_SET ? defaultIterator : getIterationMethod(KEYS),
  17775. entries: getIterationMethod(ENTRIES)
  17776. };
  17777. if (FORCED) for (KEY in methods) {
  17778. if (BUGGY_SAFARI_ITERATORS || INCORRECT_VALUES_NAME || !(KEY in IterablePrototype)) {
  17779. defineBuiltIn(IterablePrototype, KEY, methods[KEY]);
  17780. }
  17781. } else $({ target: NAME, proto: true, forced: BUGGY_SAFARI_ITERATORS || INCORRECT_VALUES_NAME }, methods);
  17782. }
  17783. // define iterator
  17784. if ((!IS_PURE || FORCED) && IterablePrototype[ITERATOR] !== defaultIterator) {
  17785. defineBuiltIn(IterablePrototype, ITERATOR, defaultIterator, { name: DEFAULT });
  17786. }
  17787. Iterators[NAME] = defaultIterator;
  17788. return methods;
  17789. };
  17790. },{"../internals/create-non-enumerable-property":204,"../internals/define-built-in":208,"../internals/export":234,"../internals/function-call":241,"../internals/function-name":242,"../internals/is-callable":264,"../internals/is-pure":270,"../internals/iterator-create-constructor":275,"../internals/iterators":278,"../internals/iterators-core":277,"../internals/object-get-prototype-of":294,"../internals/object-set-prototype-of":300,"../internals/set-to-string-tag":315,"../internals/well-known-symbol":343}],277:[function(_dereq_,module,exports){
  17791. 'use strict';
  17792. var fails = _dereq_('../internals/fails');
  17793. var isCallable = _dereq_('../internals/is-callable');
  17794. var isObject = _dereq_('../internals/is-object');
  17795. var create = _dereq_('../internals/object-create');
  17796. var getPrototypeOf = _dereq_('../internals/object-get-prototype-of');
  17797. var defineBuiltIn = _dereq_('../internals/define-built-in');
  17798. var wellKnownSymbol = _dereq_('../internals/well-known-symbol');
  17799. var IS_PURE = _dereq_('../internals/is-pure');
  17800. var ITERATOR = wellKnownSymbol('iterator');
  17801. var BUGGY_SAFARI_ITERATORS = false;
  17802. // `%IteratorPrototype%` object
  17803. // https://tc39.es/ecma262/#sec-%iteratorprototype%-object
  17804. var IteratorPrototype, PrototypeOfArrayIteratorPrototype, arrayIterator;
  17805. /* eslint-disable es/no-array-prototype-keys -- safe */
  17806. if ([].keys) {
  17807. arrayIterator = [].keys();
  17808. // Safari 8 has buggy iterators w/o `next`
  17809. if (!('next' in arrayIterator)) BUGGY_SAFARI_ITERATORS = true;
  17810. else {
  17811. PrototypeOfArrayIteratorPrototype = getPrototypeOf(getPrototypeOf(arrayIterator));
  17812. if (PrototypeOfArrayIteratorPrototype !== Object.prototype) IteratorPrototype = PrototypeOfArrayIteratorPrototype;
  17813. }
  17814. }
  17815. var NEW_ITERATOR_PROTOTYPE = !isObject(IteratorPrototype) || fails(function () {
  17816. var test = {};
  17817. // FF44- legacy iterators case
  17818. return IteratorPrototype[ITERATOR].call(test) !== test;
  17819. });
  17820. if (NEW_ITERATOR_PROTOTYPE) IteratorPrototype = {};
  17821. else if (IS_PURE) IteratorPrototype = create(IteratorPrototype);
  17822. // `%IteratorPrototype%[@@iterator]()` method
  17823. // https://tc39.es/ecma262/#sec-%iteratorprototype%-@@iterator
  17824. if (!isCallable(IteratorPrototype[ITERATOR])) {
  17825. defineBuiltIn(IteratorPrototype, ITERATOR, function () {
  17826. return this;
  17827. });
  17828. }
  17829. module.exports = {
  17830. IteratorPrototype: IteratorPrototype,
  17831. BUGGY_SAFARI_ITERATORS: BUGGY_SAFARI_ITERATORS
  17832. };
  17833. },{"../internals/define-built-in":208,"../internals/fails":235,"../internals/is-callable":264,"../internals/is-object":269,"../internals/is-pure":270,"../internals/object-create":287,"../internals/object-get-prototype-of":294,"../internals/well-known-symbol":343}],278:[function(_dereq_,module,exports){
  17834. arguments[4][253][0].apply(exports,arguments)
  17835. },{"dup":253}],279:[function(_dereq_,module,exports){
  17836. var toLength = _dereq_('../internals/to-length');
  17837. // `LengthOfArrayLike` abstract operation
  17838. // https://tc39.es/ecma262/#sec-lengthofarraylike
  17839. module.exports = function (obj) {
  17840. return toLength(obj.length);
  17841. };
  17842. },{"../internals/to-length":329}],280:[function(_dereq_,module,exports){
  17843. var ceil = Math.ceil;
  17844. var floor = Math.floor;
  17845. // `Math.trunc` method
  17846. // https://tc39.es/ecma262/#sec-math.trunc
  17847. // eslint-disable-next-line es/no-math-trunc -- safe
  17848. module.exports = Math.trunc || function trunc(x) {
  17849. var n = +x;
  17850. return (n > 0 ? floor : ceil)(n);
  17851. };
  17852. },{}],281:[function(_dereq_,module,exports){
  17853. var global = _dereq_('../internals/global');
  17854. var bind = _dereq_('../internals/function-bind-context');
  17855. var getOwnPropertyDescriptor = _dereq_('../internals/object-get-own-property-descriptor').f;
  17856. var macrotask = _dereq_('../internals/task').set;
  17857. var Queue = _dereq_('../internals/queue');
  17858. var IS_IOS = _dereq_('../internals/engine-is-ios');
  17859. var IS_IOS_PEBBLE = _dereq_('../internals/engine-is-ios-pebble');
  17860. var IS_WEBOS_WEBKIT = _dereq_('../internals/engine-is-webos-webkit');
  17861. var IS_NODE = _dereq_('../internals/engine-is-node');
  17862. var MutationObserver = global.MutationObserver || global.WebKitMutationObserver;
  17863. var document = global.document;
  17864. var process = global.process;
  17865. var Promise = global.Promise;
  17866. // Node.js 11 shows ExperimentalWarning on getting `queueMicrotask`
  17867. var queueMicrotaskDescriptor = getOwnPropertyDescriptor(global, 'queueMicrotask');
  17868. var microtask = queueMicrotaskDescriptor && queueMicrotaskDescriptor.value;
  17869. var notify, toggle, node, promise, then;
  17870. // modern engines have queueMicrotask method
  17871. if (!microtask) {
  17872. var queue = new Queue();
  17873. var flush = function () {
  17874. var parent, fn;
  17875. if (IS_NODE && (parent = process.domain)) parent.exit();
  17876. while (fn = queue.get()) try {
  17877. fn();
  17878. } catch (error) {
  17879. if (queue.head) notify();
  17880. throw error;
  17881. }
  17882. if (parent) parent.enter();
  17883. };
  17884. // browsers with MutationObserver, except iOS - https://github.com/zloirock/core-js/issues/339
  17885. // also except WebOS Webkit https://github.com/zloirock/core-js/issues/898
  17886. if (!IS_IOS && !IS_NODE && !IS_WEBOS_WEBKIT && MutationObserver && document) {
  17887. toggle = true;
  17888. node = document.createTextNode('');
  17889. new MutationObserver(flush).observe(node, { characterData: true });
  17890. notify = function () {
  17891. node.data = toggle = !toggle;
  17892. };
  17893. // environments with maybe non-completely correct, but existent Promise
  17894. } else if (!IS_IOS_PEBBLE && Promise && Promise.resolve) {
  17895. // Promise.resolve without an argument throws an error in LG WebOS 2
  17896. promise = Promise.resolve(undefined);
  17897. // workaround of WebKit ~ iOS Safari 10.1 bug
  17898. promise.constructor = Promise;
  17899. then = bind(promise.then, promise);
  17900. notify = function () {
  17901. then(flush);
  17902. };
  17903. // Node.js without promises
  17904. } else if (IS_NODE) {
  17905. notify = function () {
  17906. process.nextTick(flush);
  17907. };
  17908. // for other environments - macrotask based on:
  17909. // - setImmediate
  17910. // - MessageChannel
  17911. // - window.postMessage
  17912. // - onreadystatechange
  17913. // - setTimeout
  17914. } else {
  17915. // `webpack` dev server bug on IE global methods - use bind(fn, global)
  17916. macrotask = bind(macrotask, global);
  17917. notify = function () {
  17918. macrotask(flush);
  17919. };
  17920. }
  17921. microtask = function (fn) {
  17922. if (!queue.head) notify();
  17923. queue.add(fn);
  17924. };
  17925. }
  17926. module.exports = microtask;
  17927. },{"../internals/engine-is-ios":223,"../internals/engine-is-ios-pebble":222,"../internals/engine-is-node":224,"../internals/engine-is-webos-webkit":225,"../internals/function-bind-context":238,"../internals/global":251,"../internals/object-get-own-property-descriptor":290,"../internals/queue":311,"../internals/task":325}],282:[function(_dereq_,module,exports){
  17928. 'use strict';
  17929. var aCallable = _dereq_('../internals/a-callable');
  17930. var $TypeError = TypeError;
  17931. var PromiseCapability = function (C) {
  17932. var resolve, reject;
  17933. this.promise = new C(function ($$resolve, $$reject) {
  17934. if (resolve !== undefined || reject !== undefined) throw $TypeError('Bad Promise constructor');
  17935. resolve = $$resolve;
  17936. reject = $$reject;
  17937. });
  17938. this.resolve = aCallable(resolve);
  17939. this.reject = aCallable(reject);
  17940. };
  17941. // `NewPromiseCapability` abstract operation
  17942. // https://tc39.es/ecma262/#sec-newpromisecapability
  17943. module.exports.f = function (C) {
  17944. return new PromiseCapability(C);
  17945. };
  17946. },{"../internals/a-callable":173}],283:[function(_dereq_,module,exports){
  17947. var toString = _dereq_('../internals/to-string');
  17948. module.exports = function (argument, $default) {
  17949. return argument === undefined ? arguments.length < 2 ? '' : $default : toString(argument);
  17950. };
  17951. },{"../internals/to-string":334}],284:[function(_dereq_,module,exports){
  17952. var isRegExp = _dereq_('../internals/is-regexp');
  17953. var $TypeError = TypeError;
  17954. module.exports = function (it) {
  17955. if (isRegExp(it)) {
  17956. throw $TypeError("The method doesn't accept regular expressions");
  17957. } return it;
  17958. };
  17959. },{"../internals/is-regexp":271}],285:[function(_dereq_,module,exports){
  17960. var global = _dereq_('../internals/global');
  17961. var fails = _dereq_('../internals/fails');
  17962. var uncurryThis = _dereq_('../internals/function-uncurry-this');
  17963. var toString = _dereq_('../internals/to-string');
  17964. var trim = _dereq_('../internals/string-trim').trim;
  17965. var whitespaces = _dereq_('../internals/whitespaces');
  17966. var $parseInt = global.parseInt;
  17967. var Symbol = global.Symbol;
  17968. var ITERATOR = Symbol && Symbol.iterator;
  17969. var hex = /^[+-]?0x/i;
  17970. var exec = uncurryThis(hex.exec);
  17971. var FORCED = $parseInt(whitespaces + '08') !== 8 || $parseInt(whitespaces + '0x16') !== 22
  17972. // MS Edge 18- broken with boxed symbols
  17973. || (ITERATOR && !fails(function () { $parseInt(Object(ITERATOR)); }));
  17974. // `parseInt` method
  17975. // https://tc39.es/ecma262/#sec-parseint-string-radix
  17976. module.exports = FORCED ? function parseInt(string, radix) {
  17977. var S = trim(toString(string));
  17978. return $parseInt(S, (radix >>> 0) || (exec(hex, S) ? 16 : 10));
  17979. } : $parseInt;
  17980. },{"../internals/fails":235,"../internals/function-uncurry-this":245,"../internals/global":251,"../internals/string-trim":321,"../internals/to-string":334,"../internals/whitespaces":344}],286:[function(_dereq_,module,exports){
  17981. 'use strict';
  17982. var DESCRIPTORS = _dereq_('../internals/descriptors');
  17983. var uncurryThis = _dereq_('../internals/function-uncurry-this');
  17984. var call = _dereq_('../internals/function-call');
  17985. var fails = _dereq_('../internals/fails');
  17986. var objectKeys = _dereq_('../internals/object-keys');
  17987. var getOwnPropertySymbolsModule = _dereq_('../internals/object-get-own-property-symbols');
  17988. var propertyIsEnumerableModule = _dereq_('../internals/object-property-is-enumerable');
  17989. var toObject = _dereq_('../internals/to-object');
  17990. var IndexedObject = _dereq_('../internals/indexed-object');
  17991. // eslint-disable-next-line es/no-object-assign -- safe
  17992. var $assign = Object.assign;
  17993. // eslint-disable-next-line es/no-object-defineproperty -- required for testing
  17994. var defineProperty = Object.defineProperty;
  17995. var concat = uncurryThis([].concat);
  17996. // `Object.assign` method
  17997. // https://tc39.es/ecma262/#sec-object.assign
  17998. module.exports = !$assign || fails(function () {
  17999. // should have correct order of operations (Edge bug)
  18000. if (DESCRIPTORS && $assign({ b: 1 }, $assign(defineProperty({}, 'a', {
  18001. enumerable: true,
  18002. get: function () {
  18003. defineProperty(this, 'b', {
  18004. value: 3,
  18005. enumerable: false
  18006. });
  18007. }
  18008. }), { b: 2 })).b !== 1) return true;
  18009. // should work with symbols and should have deterministic property order (V8 bug)
  18010. var A = {};
  18011. var B = {};
  18012. // eslint-disable-next-line es/no-symbol -- safe
  18013. var symbol = Symbol();
  18014. var alphabet = 'abcdefghijklmnopqrst';
  18015. A[symbol] = 7;
  18016. alphabet.split('').forEach(function (chr) { B[chr] = chr; });
  18017. return $assign({}, A)[symbol] != 7 || objectKeys($assign({}, B)).join('') != alphabet;
  18018. }) ? function assign(target, source) { // eslint-disable-line no-unused-vars -- required for `.length`
  18019. var T = toObject(target);
  18020. var argumentsLength = arguments.length;
  18021. var index = 1;
  18022. var getOwnPropertySymbols = getOwnPropertySymbolsModule.f;
  18023. var propertyIsEnumerable = propertyIsEnumerableModule.f;
  18024. while (argumentsLength > index) {
  18025. var S = IndexedObject(arguments[index++]);
  18026. var keys = getOwnPropertySymbols ? concat(objectKeys(S), getOwnPropertySymbols(S)) : objectKeys(S);
  18027. var length = keys.length;
  18028. var j = 0;
  18029. var key;
  18030. while (length > j) {
  18031. key = keys[j++];
  18032. if (!DESCRIPTORS || call(propertyIsEnumerable, S, key)) T[key] = S[key];
  18033. }
  18034. } return T;
  18035. } : $assign;
  18036. },{"../internals/descriptors":212,"../internals/fails":235,"../internals/function-call":241,"../internals/function-uncurry-this":245,"../internals/indexed-object":257,"../internals/object-get-own-property-symbols":293,"../internals/object-keys":298,"../internals/object-property-is-enumerable":299,"../internals/to-object":330}],287:[function(_dereq_,module,exports){
  18037. /* global ActiveXObject -- old IE, WSH */
  18038. var anObject = _dereq_('../internals/an-object');
  18039. var definePropertiesModule = _dereq_('../internals/object-define-properties');
  18040. var enumBugKeys = _dereq_('../internals/enum-bug-keys');
  18041. var hiddenKeys = _dereq_('../internals/hidden-keys');
  18042. var html = _dereq_('../internals/html');
  18043. var documentCreateElement = _dereq_('../internals/document-create-element');
  18044. var sharedKey = _dereq_('../internals/shared-key');
  18045. var GT = '>';
  18046. var LT = '<';
  18047. var PROTOTYPE = 'prototype';
  18048. var SCRIPT = 'script';
  18049. var IE_PROTO = sharedKey('IE_PROTO');
  18050. var EmptyConstructor = function () { /* empty */ };
  18051. var scriptTag = function (content) {
  18052. return LT + SCRIPT + GT + content + LT + '/' + SCRIPT + GT;
  18053. };
  18054. // Create object with fake `null` prototype: use ActiveX Object with cleared prototype
  18055. var NullProtoObjectViaActiveX = function (activeXDocument) {
  18056. activeXDocument.write(scriptTag(''));
  18057. activeXDocument.close();
  18058. var temp = activeXDocument.parentWindow.Object;
  18059. activeXDocument = null; // avoid memory leak
  18060. return temp;
  18061. };
  18062. // Create object with fake `null` prototype: use iframe Object with cleared prototype
  18063. var NullProtoObjectViaIFrame = function () {
  18064. // Thrash, waste and sodomy: IE GC bug
  18065. var iframe = documentCreateElement('iframe');
  18066. var JS = 'java' + SCRIPT + ':';
  18067. var iframeDocument;
  18068. iframe.style.display = 'none';
  18069. html.appendChild(iframe);
  18070. // https://github.com/zloirock/core-js/issues/475
  18071. iframe.src = String(JS);
  18072. iframeDocument = iframe.contentWindow.document;
  18073. iframeDocument.open();
  18074. iframeDocument.write(scriptTag('document.F=Object'));
  18075. iframeDocument.close();
  18076. return iframeDocument.F;
  18077. };
  18078. // Check for document.domain and active x support
  18079. // No need to use active x approach when document.domain is not set
  18080. // see https://github.com/es-shims/es5-shim/issues/150
  18081. // variation of https://github.com/kitcambridge/es5-shim/commit/4f738ac066346
  18082. // avoid IE GC bug
  18083. var activeXDocument;
  18084. var NullProtoObject = function () {
  18085. try {
  18086. activeXDocument = new ActiveXObject('htmlfile');
  18087. } catch (error) { /* ignore */ }
  18088. NullProtoObject = typeof document != 'undefined'
  18089. ? document.domain && activeXDocument
  18090. ? NullProtoObjectViaActiveX(activeXDocument) // old IE
  18091. : NullProtoObjectViaIFrame()
  18092. : NullProtoObjectViaActiveX(activeXDocument); // WSH
  18093. var length = enumBugKeys.length;
  18094. while (length--) delete NullProtoObject[PROTOTYPE][enumBugKeys[length]];
  18095. return NullProtoObject();
  18096. };
  18097. hiddenKeys[IE_PROTO] = true;
  18098. // `Object.create` method
  18099. // https://tc39.es/ecma262/#sec-object.create
  18100. // eslint-disable-next-line es/no-object-create -- safe
  18101. module.exports = Object.create || function create(O, Properties) {
  18102. var result;
  18103. if (O !== null) {
  18104. EmptyConstructor[PROTOTYPE] = anObject(O);
  18105. result = new EmptyConstructor();
  18106. EmptyConstructor[PROTOTYPE] = null;
  18107. // add "__proto__" for Object.getPrototypeOf polyfill
  18108. result[IE_PROTO] = O;
  18109. } else result = NullProtoObject();
  18110. return Properties === undefined ? result : definePropertiesModule.f(result, Properties);
  18111. };
  18112. },{"../internals/an-object":178,"../internals/document-create-element":214,"../internals/enum-bug-keys":230,"../internals/hidden-keys":253,"../internals/html":255,"../internals/object-define-properties":288,"../internals/shared-key":316}],288:[function(_dereq_,module,exports){
  18113. var DESCRIPTORS = _dereq_('../internals/descriptors');
  18114. var V8_PROTOTYPE_DEFINE_BUG = _dereq_('../internals/v8-prototype-define-bug');
  18115. var definePropertyModule = _dereq_('../internals/object-define-property');
  18116. var anObject = _dereq_('../internals/an-object');
  18117. var toIndexedObject = _dereq_('../internals/to-indexed-object');
  18118. var objectKeys = _dereq_('../internals/object-keys');
  18119. // `Object.defineProperties` method
  18120. // https://tc39.es/ecma262/#sec-object.defineproperties
  18121. // eslint-disable-next-line es/no-object-defineproperties -- safe
  18122. exports.f = DESCRIPTORS && !V8_PROTOTYPE_DEFINE_BUG ? Object.defineProperties : function defineProperties(O, Properties) {
  18123. anObject(O);
  18124. var props = toIndexedObject(Properties);
  18125. var keys = objectKeys(Properties);
  18126. var length = keys.length;
  18127. var index = 0;
  18128. var key;
  18129. while (length > index) definePropertyModule.f(O, key = keys[index++], props[key]);
  18130. return O;
  18131. };
  18132. },{"../internals/an-object":178,"../internals/descriptors":212,"../internals/object-define-property":289,"../internals/object-keys":298,"../internals/to-indexed-object":327,"../internals/v8-prototype-define-bug":338}],289:[function(_dereq_,module,exports){
  18133. var DESCRIPTORS = _dereq_('../internals/descriptors');
  18134. var IE8_DOM_DEFINE = _dereq_('../internals/ie8-dom-define');
  18135. var V8_PROTOTYPE_DEFINE_BUG = _dereq_('../internals/v8-prototype-define-bug');
  18136. var anObject = _dereq_('../internals/an-object');
  18137. var toPropertyKey = _dereq_('../internals/to-property-key');
  18138. var $TypeError = TypeError;
  18139. // eslint-disable-next-line es/no-object-defineproperty -- safe
  18140. var $defineProperty = Object.defineProperty;
  18141. // eslint-disable-next-line es/no-object-getownpropertydescriptor -- safe
  18142. var $getOwnPropertyDescriptor = Object.getOwnPropertyDescriptor;
  18143. var ENUMERABLE = 'enumerable';
  18144. var CONFIGURABLE = 'configurable';
  18145. var WRITABLE = 'writable';
  18146. // `Object.defineProperty` method
  18147. // https://tc39.es/ecma262/#sec-object.defineproperty
  18148. exports.f = DESCRIPTORS ? V8_PROTOTYPE_DEFINE_BUG ? function defineProperty(O, P, Attributes) {
  18149. anObject(O);
  18150. P = toPropertyKey(P);
  18151. anObject(Attributes);
  18152. if (typeof O === 'function' && P === 'prototype' && 'value' in Attributes && WRITABLE in Attributes && !Attributes[WRITABLE]) {
  18153. var current = $getOwnPropertyDescriptor(O, P);
  18154. if (current && current[WRITABLE]) {
  18155. O[P] = Attributes.value;
  18156. Attributes = {
  18157. configurable: CONFIGURABLE in Attributes ? Attributes[CONFIGURABLE] : current[CONFIGURABLE],
  18158. enumerable: ENUMERABLE in Attributes ? Attributes[ENUMERABLE] : current[ENUMERABLE],
  18159. writable: false
  18160. };
  18161. }
  18162. } return $defineProperty(O, P, Attributes);
  18163. } : $defineProperty : function defineProperty(O, P, Attributes) {
  18164. anObject(O);
  18165. P = toPropertyKey(P);
  18166. anObject(Attributes);
  18167. if (IE8_DOM_DEFINE) try {
  18168. return $defineProperty(O, P, Attributes);
  18169. } catch (error) { /* empty */ }
  18170. if ('get' in Attributes || 'set' in Attributes) throw $TypeError('Accessors not supported');
  18171. if ('value' in Attributes) O[P] = Attributes.value;
  18172. return O;
  18173. };
  18174. },{"../internals/an-object":178,"../internals/descriptors":212,"../internals/ie8-dom-define":256,"../internals/to-property-key":332,"../internals/v8-prototype-define-bug":338}],290:[function(_dereq_,module,exports){
  18175. var DESCRIPTORS = _dereq_('../internals/descriptors');
  18176. var call = _dereq_('../internals/function-call');
  18177. var propertyIsEnumerableModule = _dereq_('../internals/object-property-is-enumerable');
  18178. var createPropertyDescriptor = _dereq_('../internals/create-property-descriptor');
  18179. var toIndexedObject = _dereq_('../internals/to-indexed-object');
  18180. var toPropertyKey = _dereq_('../internals/to-property-key');
  18181. var hasOwn = _dereq_('../internals/has-own-property');
  18182. var IE8_DOM_DEFINE = _dereq_('../internals/ie8-dom-define');
  18183. // eslint-disable-next-line es/no-object-getownpropertydescriptor -- safe
  18184. var $getOwnPropertyDescriptor = Object.getOwnPropertyDescriptor;
  18185. // `Object.getOwnPropertyDescriptor` method
  18186. // https://tc39.es/ecma262/#sec-object.getownpropertydescriptor
  18187. exports.f = DESCRIPTORS ? $getOwnPropertyDescriptor : function getOwnPropertyDescriptor(O, P) {
  18188. O = toIndexedObject(O);
  18189. P = toPropertyKey(P);
  18190. if (IE8_DOM_DEFINE) try {
  18191. return $getOwnPropertyDescriptor(O, P);
  18192. } catch (error) { /* empty */ }
  18193. if (hasOwn(O, P)) return createPropertyDescriptor(!call(propertyIsEnumerableModule.f, O, P), O[P]);
  18194. };
  18195. },{"../internals/create-property-descriptor":205,"../internals/descriptors":212,"../internals/function-call":241,"../internals/has-own-property":252,"../internals/ie8-dom-define":256,"../internals/object-property-is-enumerable":299,"../internals/to-indexed-object":327,"../internals/to-property-key":332}],291:[function(_dereq_,module,exports){
  18196. /* eslint-disable es/no-object-getownpropertynames -- safe */
  18197. var classof = _dereq_('../internals/classof-raw');
  18198. var toIndexedObject = _dereq_('../internals/to-indexed-object');
  18199. var $getOwnPropertyNames = _dereq_('../internals/object-get-own-property-names').f;
  18200. var arraySlice = _dereq_('../internals/array-slice-simple');
  18201. var windowNames = typeof window == 'object' && window && Object.getOwnPropertyNames
  18202. ? Object.getOwnPropertyNames(window) : [];
  18203. var getWindowNames = function (it) {
  18204. try {
  18205. return $getOwnPropertyNames(it);
  18206. } catch (error) {
  18207. return arraySlice(windowNames);
  18208. }
  18209. };
  18210. // fallback for IE11 buggy Object.getOwnPropertyNames with iframe and window
  18211. module.exports.f = function getOwnPropertyNames(it) {
  18212. return windowNames && classof(it) == 'Window'
  18213. ? getWindowNames(it)
  18214. : $getOwnPropertyNames(toIndexedObject(it));
  18215. };
  18216. },{"../internals/array-slice-simple":188,"../internals/classof-raw":195,"../internals/object-get-own-property-names":292,"../internals/to-indexed-object":327}],292:[function(_dereq_,module,exports){
  18217. var internalObjectKeys = _dereq_('../internals/object-keys-internal');
  18218. var enumBugKeys = _dereq_('../internals/enum-bug-keys');
  18219. var hiddenKeys = enumBugKeys.concat('length', 'prototype');
  18220. // `Object.getOwnPropertyNames` method
  18221. // https://tc39.es/ecma262/#sec-object.getownpropertynames
  18222. // eslint-disable-next-line es/no-object-getownpropertynames -- safe
  18223. exports.f = Object.getOwnPropertyNames || function getOwnPropertyNames(O) {
  18224. return internalObjectKeys(O, hiddenKeys);
  18225. };
  18226. },{"../internals/enum-bug-keys":230,"../internals/object-keys-internal":297}],293:[function(_dereq_,module,exports){
  18227. // eslint-disable-next-line es/no-object-getownpropertysymbols -- safe
  18228. exports.f = Object.getOwnPropertySymbols;
  18229. },{}],294:[function(_dereq_,module,exports){
  18230. var hasOwn = _dereq_('../internals/has-own-property');
  18231. var isCallable = _dereq_('../internals/is-callable');
  18232. var toObject = _dereq_('../internals/to-object');
  18233. var sharedKey = _dereq_('../internals/shared-key');
  18234. var CORRECT_PROTOTYPE_GETTER = _dereq_('../internals/correct-prototype-getter');
  18235. var IE_PROTO = sharedKey('IE_PROTO');
  18236. var $Object = Object;
  18237. var ObjectPrototype = $Object.prototype;
  18238. // `Object.getPrototypeOf` method
  18239. // https://tc39.es/ecma262/#sec-object.getprototypeof
  18240. // eslint-disable-next-line es/no-object-getprototypeof -- safe
  18241. module.exports = CORRECT_PROTOTYPE_GETTER ? $Object.getPrototypeOf : function (O) {
  18242. var object = toObject(O);
  18243. if (hasOwn(object, IE_PROTO)) return object[IE_PROTO];
  18244. var constructor = object.constructor;
  18245. if (isCallable(constructor) && object instanceof constructor) {
  18246. return constructor.prototype;
  18247. } return object instanceof $Object ? ObjectPrototype : null;
  18248. };
  18249. },{"../internals/correct-prototype-getter":202,"../internals/has-own-property":252,"../internals/is-callable":264,"../internals/shared-key":316,"../internals/to-object":330}],295:[function(_dereq_,module,exports){
  18250. var fails = _dereq_('../internals/fails');
  18251. var isObject = _dereq_('../internals/is-object');
  18252. var classof = _dereq_('../internals/classof-raw');
  18253. var ARRAY_BUFFER_NON_EXTENSIBLE = _dereq_('../internals/array-buffer-non-extensible');
  18254. // eslint-disable-next-line es/no-object-isextensible -- safe
  18255. var $isExtensible = Object.isExtensible;
  18256. var FAILS_ON_PRIMITIVES = fails(function () { $isExtensible(1); });
  18257. // `Object.isExtensible` method
  18258. // https://tc39.es/ecma262/#sec-object.isextensible
  18259. module.exports = (FAILS_ON_PRIMITIVES || ARRAY_BUFFER_NON_EXTENSIBLE) ? function isExtensible(it) {
  18260. if (!isObject(it)) return false;
  18261. if (ARRAY_BUFFER_NON_EXTENSIBLE && classof(it) == 'ArrayBuffer') return false;
  18262. return $isExtensible ? $isExtensible(it) : true;
  18263. } : $isExtensible;
  18264. },{"../internals/array-buffer-non-extensible":179,"../internals/classof-raw":195,"../internals/fails":235,"../internals/is-object":269}],296:[function(_dereq_,module,exports){
  18265. var uncurryThis = _dereq_('../internals/function-uncurry-this');
  18266. module.exports = uncurryThis({}.isPrototypeOf);
  18267. },{"../internals/function-uncurry-this":245}],297:[function(_dereq_,module,exports){
  18268. var uncurryThis = _dereq_('../internals/function-uncurry-this');
  18269. var hasOwn = _dereq_('../internals/has-own-property');
  18270. var toIndexedObject = _dereq_('../internals/to-indexed-object');
  18271. var indexOf = _dereq_('../internals/array-includes').indexOf;
  18272. var hiddenKeys = _dereq_('../internals/hidden-keys');
  18273. var push = uncurryThis([].push);
  18274. module.exports = function (object, names) {
  18275. var O = toIndexedObject(object);
  18276. var i = 0;
  18277. var result = [];
  18278. var key;
  18279. for (key in O) !hasOwn(hiddenKeys, key) && hasOwn(O, key) && push(result, key);
  18280. // Don't enum bug & hidden keys
  18281. while (names.length > i) if (hasOwn(O, key = names[i++])) {
  18282. ~indexOf(result, key) || push(result, key);
  18283. }
  18284. return result;
  18285. };
  18286. },{"../internals/array-includes":182,"../internals/function-uncurry-this":245,"../internals/has-own-property":252,"../internals/hidden-keys":253,"../internals/to-indexed-object":327}],298:[function(_dereq_,module,exports){
  18287. var internalObjectKeys = _dereq_('../internals/object-keys-internal');
  18288. var enumBugKeys = _dereq_('../internals/enum-bug-keys');
  18289. // `Object.keys` method
  18290. // https://tc39.es/ecma262/#sec-object.keys
  18291. // eslint-disable-next-line es/no-object-keys -- safe
  18292. module.exports = Object.keys || function keys(O) {
  18293. return internalObjectKeys(O, enumBugKeys);
  18294. };
  18295. },{"../internals/enum-bug-keys":230,"../internals/object-keys-internal":297}],299:[function(_dereq_,module,exports){
  18296. 'use strict';
  18297. var $propertyIsEnumerable = {}.propertyIsEnumerable;
  18298. // eslint-disable-next-line es/no-object-getownpropertydescriptor -- safe
  18299. var getOwnPropertyDescriptor = Object.getOwnPropertyDescriptor;
  18300. // Nashorn ~ JDK8 bug
  18301. var NASHORN_BUG = getOwnPropertyDescriptor && !$propertyIsEnumerable.call({ 1: 2 }, 1);
  18302. // `Object.prototype.propertyIsEnumerable` method implementation
  18303. // https://tc39.es/ecma262/#sec-object.prototype.propertyisenumerable
  18304. exports.f = NASHORN_BUG ? function propertyIsEnumerable(V) {
  18305. var descriptor = getOwnPropertyDescriptor(this, V);
  18306. return !!descriptor && descriptor.enumerable;
  18307. } : $propertyIsEnumerable;
  18308. },{}],300:[function(_dereq_,module,exports){
  18309. /* eslint-disable no-proto -- safe */
  18310. var uncurryThisAccessor = _dereq_('../internals/function-uncurry-this-accessor');
  18311. var anObject = _dereq_('../internals/an-object');
  18312. var aPossiblePrototype = _dereq_('../internals/a-possible-prototype');
  18313. // `Object.setPrototypeOf` method
  18314. // https://tc39.es/ecma262/#sec-object.setprototypeof
  18315. // Works with __proto__ only. Old v8 can't work with null proto objects.
  18316. // eslint-disable-next-line es/no-object-setprototypeof -- safe
  18317. module.exports = Object.setPrototypeOf || ('__proto__' in {} ? function () {
  18318. var CORRECT_SETTER = false;
  18319. var test = {};
  18320. var setter;
  18321. try {
  18322. setter = uncurryThisAccessor(Object.prototype, '__proto__', 'set');
  18323. setter(test, []);
  18324. CORRECT_SETTER = test instanceof Array;
  18325. } catch (error) { /* empty */ }
  18326. return function setPrototypeOf(O, proto) {
  18327. anObject(O);
  18328. aPossiblePrototype(proto);
  18329. if (CORRECT_SETTER) setter(O, proto);
  18330. else O.__proto__ = proto;
  18331. return O;
  18332. };
  18333. }() : undefined);
  18334. },{"../internals/a-possible-prototype":175,"../internals/an-object":178,"../internals/function-uncurry-this-accessor":243}],301:[function(_dereq_,module,exports){
  18335. var DESCRIPTORS = _dereq_('../internals/descriptors');
  18336. var uncurryThis = _dereq_('../internals/function-uncurry-this');
  18337. var objectKeys = _dereq_('../internals/object-keys');
  18338. var toIndexedObject = _dereq_('../internals/to-indexed-object');
  18339. var $propertyIsEnumerable = _dereq_('../internals/object-property-is-enumerable').f;
  18340. var propertyIsEnumerable = uncurryThis($propertyIsEnumerable);
  18341. var push = uncurryThis([].push);
  18342. // `Object.{ entries, values }` methods implementation
  18343. var createMethod = function (TO_ENTRIES) {
  18344. return function (it) {
  18345. var O = toIndexedObject(it);
  18346. var keys = objectKeys(O);
  18347. var length = keys.length;
  18348. var i = 0;
  18349. var result = [];
  18350. var key;
  18351. while (length > i) {
  18352. key = keys[i++];
  18353. if (!DESCRIPTORS || propertyIsEnumerable(O, key)) {
  18354. push(result, TO_ENTRIES ? [key, O[key]] : O[key]);
  18355. }
  18356. }
  18357. return result;
  18358. };
  18359. };
  18360. module.exports = {
  18361. // `Object.entries` method
  18362. // https://tc39.es/ecma262/#sec-object.entries
  18363. entries: createMethod(true),
  18364. // `Object.values` method
  18365. // https://tc39.es/ecma262/#sec-object.values
  18366. values: createMethod(false)
  18367. };
  18368. },{"../internals/descriptors":212,"../internals/function-uncurry-this":245,"../internals/object-keys":298,"../internals/object-property-is-enumerable":299,"../internals/to-indexed-object":327}],302:[function(_dereq_,module,exports){
  18369. 'use strict';
  18370. var TO_STRING_TAG_SUPPORT = _dereq_('../internals/to-string-tag-support');
  18371. var classof = _dereq_('../internals/classof');
  18372. // `Object.prototype.toString` method implementation
  18373. // https://tc39.es/ecma262/#sec-object.prototype.tostring
  18374. module.exports = TO_STRING_TAG_SUPPORT ? {}.toString : function toString() {
  18375. return '[object ' + classof(this) + ']';
  18376. };
  18377. },{"../internals/classof":196,"../internals/to-string-tag-support":333}],303:[function(_dereq_,module,exports){
  18378. var call = _dereq_('../internals/function-call');
  18379. var isCallable = _dereq_('../internals/is-callable');
  18380. var isObject = _dereq_('../internals/is-object');
  18381. var $TypeError = TypeError;
  18382. // `OrdinaryToPrimitive` abstract operation
  18383. // https://tc39.es/ecma262/#sec-ordinarytoprimitive
  18384. module.exports = function (input, pref) {
  18385. var fn, val;
  18386. if (pref === 'string' && isCallable(fn = input.toString) && !isObject(val = call(fn, input))) return val;
  18387. if (isCallable(fn = input.valueOf) && !isObject(val = call(fn, input))) return val;
  18388. if (pref !== 'string' && isCallable(fn = input.toString) && !isObject(val = call(fn, input))) return val;
  18389. throw $TypeError("Can't convert object to primitive value");
  18390. };
  18391. },{"../internals/function-call":241,"../internals/is-callable":264,"../internals/is-object":269}],304:[function(_dereq_,module,exports){
  18392. var getBuiltIn = _dereq_('../internals/get-built-in');
  18393. var uncurryThis = _dereq_('../internals/function-uncurry-this');
  18394. var getOwnPropertyNamesModule = _dereq_('../internals/object-get-own-property-names');
  18395. var getOwnPropertySymbolsModule = _dereq_('../internals/object-get-own-property-symbols');
  18396. var anObject = _dereq_('../internals/an-object');
  18397. var concat = uncurryThis([].concat);
  18398. // all object keys, includes non-enumerable and symbols
  18399. module.exports = getBuiltIn('Reflect', 'ownKeys') || function ownKeys(it) {
  18400. var keys = getOwnPropertyNamesModule.f(anObject(it));
  18401. var getOwnPropertySymbols = getOwnPropertySymbolsModule.f;
  18402. return getOwnPropertySymbols ? concat(keys, getOwnPropertySymbols(it)) : keys;
  18403. };
  18404. },{"../internals/an-object":178,"../internals/function-uncurry-this":245,"../internals/get-built-in":246,"../internals/object-get-own-property-names":292,"../internals/object-get-own-property-symbols":293}],305:[function(_dereq_,module,exports){
  18405. arguments[4][253][0].apply(exports,arguments)
  18406. },{"dup":253}],306:[function(_dereq_,module,exports){
  18407. module.exports = function (exec) {
  18408. try {
  18409. return { error: false, value: exec() };
  18410. } catch (error) {
  18411. return { error: true, value: error };
  18412. }
  18413. };
  18414. },{}],307:[function(_dereq_,module,exports){
  18415. var global = _dereq_('../internals/global');
  18416. var NativePromiseConstructor = _dereq_('../internals/promise-native-constructor');
  18417. var isCallable = _dereq_('../internals/is-callable');
  18418. var isForced = _dereq_('../internals/is-forced');
  18419. var inspectSource = _dereq_('../internals/inspect-source');
  18420. var wellKnownSymbol = _dereq_('../internals/well-known-symbol');
  18421. var IS_BROWSER = _dereq_('../internals/engine-is-browser');
  18422. var IS_DENO = _dereq_('../internals/engine-is-deno');
  18423. var IS_PURE = _dereq_('../internals/is-pure');
  18424. var V8_VERSION = _dereq_('../internals/engine-v8-version');
  18425. var NativePromisePrototype = NativePromiseConstructor && NativePromiseConstructor.prototype;
  18426. var SPECIES = wellKnownSymbol('species');
  18427. var SUBCLASSING = false;
  18428. var NATIVE_PROMISE_REJECTION_EVENT = isCallable(global.PromiseRejectionEvent);
  18429. var FORCED_PROMISE_CONSTRUCTOR = isForced('Promise', function () {
  18430. var PROMISE_CONSTRUCTOR_SOURCE = inspectSource(NativePromiseConstructor);
  18431. var GLOBAL_CORE_JS_PROMISE = PROMISE_CONSTRUCTOR_SOURCE !== String(NativePromiseConstructor);
  18432. // V8 6.6 (Node 10 and Chrome 66) have a bug with resolving custom thenables
  18433. // https://bugs.chromium.org/p/chromium/issues/detail?id=830565
  18434. // We can't detect it synchronously, so just check versions
  18435. if (!GLOBAL_CORE_JS_PROMISE && V8_VERSION === 66) return true;
  18436. // We need Promise#{ catch, finally } in the pure version for preventing prototype pollution
  18437. if (IS_PURE && !(NativePromisePrototype['catch'] && NativePromisePrototype['finally'])) return true;
  18438. // We can't use @@species feature detection in V8 since it causes
  18439. // deoptimization and performance degradation
  18440. // https://github.com/zloirock/core-js/issues/679
  18441. if (!V8_VERSION || V8_VERSION < 51 || !/native code/.test(PROMISE_CONSTRUCTOR_SOURCE)) {
  18442. // Detect correctness of subclassing with @@species support
  18443. var promise = new NativePromiseConstructor(function (resolve) { resolve(1); });
  18444. var FakePromise = function (exec) {
  18445. exec(function () { /* empty */ }, function () { /* empty */ });
  18446. };
  18447. var constructor = promise.constructor = {};
  18448. constructor[SPECIES] = FakePromise;
  18449. SUBCLASSING = promise.then(function () { /* empty */ }) instanceof FakePromise;
  18450. if (!SUBCLASSING) return true;
  18451. // Unhandled rejections tracking support, NodeJS Promise without it fails @@species test
  18452. } return !GLOBAL_CORE_JS_PROMISE && (IS_BROWSER || IS_DENO) && !NATIVE_PROMISE_REJECTION_EVENT;
  18453. });
  18454. module.exports = {
  18455. CONSTRUCTOR: FORCED_PROMISE_CONSTRUCTOR,
  18456. REJECTION_EVENT: NATIVE_PROMISE_REJECTION_EVENT,
  18457. SUBCLASSING: SUBCLASSING
  18458. };
  18459. },{"../internals/engine-is-browser":218,"../internals/engine-is-deno":220,"../internals/engine-v8-version":227,"../internals/global":251,"../internals/inspect-source":258,"../internals/is-callable":264,"../internals/is-forced":266,"../internals/is-pure":270,"../internals/promise-native-constructor":308,"../internals/well-known-symbol":343}],308:[function(_dereq_,module,exports){
  18460. var global = _dereq_('../internals/global');
  18461. module.exports = global.Promise;
  18462. },{"../internals/global":251}],309:[function(_dereq_,module,exports){
  18463. var anObject = _dereq_('../internals/an-object');
  18464. var isObject = _dereq_('../internals/is-object');
  18465. var newPromiseCapability = _dereq_('../internals/new-promise-capability');
  18466. module.exports = function (C, x) {
  18467. anObject(C);
  18468. if (isObject(x) && x.constructor === C) return x;
  18469. var promiseCapability = newPromiseCapability.f(C);
  18470. var resolve = promiseCapability.resolve;
  18471. resolve(x);
  18472. return promiseCapability.promise;
  18473. };
  18474. },{"../internals/an-object":178,"../internals/is-object":269,"../internals/new-promise-capability":282}],310:[function(_dereq_,module,exports){
  18475. var NativePromiseConstructor = _dereq_('../internals/promise-native-constructor');
  18476. var checkCorrectnessOfIteration = _dereq_('../internals/check-correctness-of-iteration');
  18477. var FORCED_PROMISE_CONSTRUCTOR = _dereq_('../internals/promise-constructor-detection').CONSTRUCTOR;
  18478. module.exports = FORCED_PROMISE_CONSTRUCTOR || !checkCorrectnessOfIteration(function (iterable) {
  18479. NativePromiseConstructor.all(iterable).then(undefined, function () { /* empty */ });
  18480. });
  18481. },{"../internals/check-correctness-of-iteration":194,"../internals/promise-constructor-detection":307,"../internals/promise-native-constructor":308}],311:[function(_dereq_,module,exports){
  18482. var Queue = function () {
  18483. this.head = null;
  18484. this.tail = null;
  18485. };
  18486. Queue.prototype = {
  18487. add: function (item) {
  18488. var entry = { item: item, next: null };
  18489. var tail = this.tail;
  18490. if (tail) tail.next = entry;
  18491. else this.head = entry;
  18492. this.tail = entry;
  18493. },
  18494. get: function () {
  18495. var entry = this.head;
  18496. if (entry) {
  18497. var next = this.head = entry.next;
  18498. if (next === null) this.tail = null;
  18499. return entry.item;
  18500. }
  18501. }
  18502. };
  18503. module.exports = Queue;
  18504. },{}],312:[function(_dereq_,module,exports){
  18505. var isNullOrUndefined = _dereq_('../internals/is-null-or-undefined');
  18506. var $TypeError = TypeError;
  18507. // `RequireObjectCoercible` abstract operation
  18508. // https://tc39.es/ecma262/#sec-requireobjectcoercible
  18509. module.exports = function (it) {
  18510. if (isNullOrUndefined(it)) throw $TypeError("Can't call method on " + it);
  18511. return it;
  18512. };
  18513. },{"../internals/is-null-or-undefined":268}],313:[function(_dereq_,module,exports){
  18514. 'use strict';
  18515. var global = _dereq_('../internals/global');
  18516. var apply = _dereq_('../internals/function-apply');
  18517. var isCallable = _dereq_('../internals/is-callable');
  18518. var ENGINE_IS_BUN = _dereq_('../internals/engine-is-bun');
  18519. var USER_AGENT = _dereq_('../internals/engine-user-agent');
  18520. var arraySlice = _dereq_('../internals/array-slice');
  18521. var validateArgumentsLength = _dereq_('../internals/validate-arguments-length');
  18522. var Function = global.Function;
  18523. // dirty IE9- and Bun 0.3.0- checks
  18524. var WRAP = /MSIE .\./.test(USER_AGENT) || ENGINE_IS_BUN && (function () {
  18525. var version = global.Bun.version.split('.');
  18526. return version.length < 3 || version[0] == 0 && (version[1] < 3 || version[1] == 3 && version[2] == 0);
  18527. })();
  18528. // IE9- / Bun 0.3.0- setTimeout / setInterval / setImmediate additional parameters fix
  18529. // https://html.spec.whatwg.org/multipage/timers-and-user-prompts.html#timers
  18530. // https://github.com/oven-sh/bun/issues/1633
  18531. module.exports = function (scheduler, hasTimeArg) {
  18532. var firstParamIndex = hasTimeArg ? 2 : 1;
  18533. return WRAP ? function (handler, timeout /* , ...arguments */) {
  18534. var boundArgs = validateArgumentsLength(arguments.length, 1) > firstParamIndex;
  18535. var fn = isCallable(handler) ? handler : Function(handler);
  18536. var params = boundArgs ? arraySlice(arguments, firstParamIndex) : [];
  18537. var callback = boundArgs ? function () {
  18538. apply(fn, this, params);
  18539. } : fn;
  18540. return hasTimeArg ? scheduler(callback, timeout) : scheduler(callback);
  18541. } : scheduler;
  18542. };
  18543. },{"../internals/array-slice":189,"../internals/engine-is-bun":219,"../internals/engine-user-agent":226,"../internals/function-apply":237,"../internals/global":251,"../internals/is-callable":264,"../internals/validate-arguments-length":339}],314:[function(_dereq_,module,exports){
  18544. 'use strict';
  18545. var getBuiltIn = _dereq_('../internals/get-built-in');
  18546. var defineBuiltInAccessor = _dereq_('../internals/define-built-in-accessor');
  18547. var wellKnownSymbol = _dereq_('../internals/well-known-symbol');
  18548. var DESCRIPTORS = _dereq_('../internals/descriptors');
  18549. var SPECIES = wellKnownSymbol('species');
  18550. module.exports = function (CONSTRUCTOR_NAME) {
  18551. var Constructor = getBuiltIn(CONSTRUCTOR_NAME);
  18552. if (DESCRIPTORS && Constructor && !Constructor[SPECIES]) {
  18553. defineBuiltInAccessor(Constructor, SPECIES, {
  18554. configurable: true,
  18555. get: function () { return this; }
  18556. });
  18557. }
  18558. };
  18559. },{"../internals/define-built-in-accessor":207,"../internals/descriptors":212,"../internals/get-built-in":246,"../internals/well-known-symbol":343}],315:[function(_dereq_,module,exports){
  18560. var TO_STRING_TAG_SUPPORT = _dereq_('../internals/to-string-tag-support');
  18561. var defineProperty = _dereq_('../internals/object-define-property').f;
  18562. var createNonEnumerableProperty = _dereq_('../internals/create-non-enumerable-property');
  18563. var hasOwn = _dereq_('../internals/has-own-property');
  18564. var toString = _dereq_('../internals/object-to-string');
  18565. var wellKnownSymbol = _dereq_('../internals/well-known-symbol');
  18566. var TO_STRING_TAG = wellKnownSymbol('toStringTag');
  18567. module.exports = function (it, TAG, STATIC, SET_METHOD) {
  18568. if (it) {
  18569. var target = STATIC ? it : it.prototype;
  18570. if (!hasOwn(target, TO_STRING_TAG)) {
  18571. defineProperty(target, TO_STRING_TAG, { configurable: true, value: TAG });
  18572. }
  18573. if (SET_METHOD && !TO_STRING_TAG_SUPPORT) {
  18574. createNonEnumerableProperty(target, 'toString', toString);
  18575. }
  18576. }
  18577. };
  18578. },{"../internals/create-non-enumerable-property":204,"../internals/has-own-property":252,"../internals/object-define-property":289,"../internals/object-to-string":302,"../internals/to-string-tag-support":333,"../internals/well-known-symbol":343}],316:[function(_dereq_,module,exports){
  18579. var shared = _dereq_('../internals/shared');
  18580. var uid = _dereq_('../internals/uid');
  18581. var keys = shared('keys');
  18582. module.exports = function (key) {
  18583. return keys[key] || (keys[key] = uid(key));
  18584. };
  18585. },{"../internals/shared":318,"../internals/uid":336}],317:[function(_dereq_,module,exports){
  18586. var global = _dereq_('../internals/global');
  18587. var defineGlobalProperty = _dereq_('../internals/define-global-property');
  18588. var SHARED = '__core-js_shared__';
  18589. var store = global[SHARED] || defineGlobalProperty(SHARED, {});
  18590. module.exports = store;
  18591. },{"../internals/define-global-property":210,"../internals/global":251}],318:[function(_dereq_,module,exports){
  18592. var IS_PURE = _dereq_('../internals/is-pure');
  18593. var store = _dereq_('../internals/shared-store');
  18594. (module.exports = function (key, value) {
  18595. return store[key] || (store[key] = value !== undefined ? value : {});
  18596. })('versions', []).push({
  18597. version: '3.30.2',
  18598. mode: IS_PURE ? 'pure' : 'global',
  18599. copyright: '© 2014-2023 Denis Pushkarev (zloirock.ru)',
  18600. license: 'https://github.com/zloirock/core-js/blob/v3.30.2/LICENSE',
  18601. source: 'https://github.com/zloirock/core-js'
  18602. });
  18603. },{"../internals/is-pure":270,"../internals/shared-store":317}],319:[function(_dereq_,module,exports){
  18604. var anObject = _dereq_('../internals/an-object');
  18605. var aConstructor = _dereq_('../internals/a-constructor');
  18606. var isNullOrUndefined = _dereq_('../internals/is-null-or-undefined');
  18607. var wellKnownSymbol = _dereq_('../internals/well-known-symbol');
  18608. var SPECIES = wellKnownSymbol('species');
  18609. // `SpeciesConstructor` abstract operation
  18610. // https://tc39.es/ecma262/#sec-speciesconstructor
  18611. module.exports = function (O, defaultConstructor) {
  18612. var C = anObject(O).constructor;
  18613. var S;
  18614. return C === undefined || isNullOrUndefined(S = anObject(C)[SPECIES]) ? defaultConstructor : aConstructor(S);
  18615. };
  18616. },{"../internals/a-constructor":174,"../internals/an-object":178,"../internals/is-null-or-undefined":268,"../internals/well-known-symbol":343}],320:[function(_dereq_,module,exports){
  18617. var uncurryThis = _dereq_('../internals/function-uncurry-this');
  18618. var toIntegerOrInfinity = _dereq_('../internals/to-integer-or-infinity');
  18619. var toString = _dereq_('../internals/to-string');
  18620. var requireObjectCoercible = _dereq_('../internals/require-object-coercible');
  18621. var charAt = uncurryThis(''.charAt);
  18622. var charCodeAt = uncurryThis(''.charCodeAt);
  18623. var stringSlice = uncurryThis(''.slice);
  18624. var createMethod = function (CONVERT_TO_STRING) {
  18625. return function ($this, pos) {
  18626. var S = toString(requireObjectCoercible($this));
  18627. var position = toIntegerOrInfinity(pos);
  18628. var size = S.length;
  18629. var first, second;
  18630. if (position < 0 || position >= size) return CONVERT_TO_STRING ? '' : undefined;
  18631. first = charCodeAt(S, position);
  18632. return first < 0xD800 || first > 0xDBFF || position + 1 === size
  18633. || (second = charCodeAt(S, position + 1)) < 0xDC00 || second > 0xDFFF
  18634. ? CONVERT_TO_STRING
  18635. ? charAt(S, position)
  18636. : first
  18637. : CONVERT_TO_STRING
  18638. ? stringSlice(S, position, position + 2)
  18639. : (first - 0xD800 << 10) + (second - 0xDC00) + 0x10000;
  18640. };
  18641. };
  18642. module.exports = {
  18643. // `String.prototype.codePointAt` method
  18644. // https://tc39.es/ecma262/#sec-string.prototype.codepointat
  18645. codeAt: createMethod(false),
  18646. // `String.prototype.at` method
  18647. // https://github.com/mathiasbynens/String.prototype.at
  18648. charAt: createMethod(true)
  18649. };
  18650. },{"../internals/function-uncurry-this":245,"../internals/require-object-coercible":312,"../internals/to-integer-or-infinity":328,"../internals/to-string":334}],321:[function(_dereq_,module,exports){
  18651. var uncurryThis = _dereq_('../internals/function-uncurry-this');
  18652. var requireObjectCoercible = _dereq_('../internals/require-object-coercible');
  18653. var toString = _dereq_('../internals/to-string');
  18654. var whitespaces = _dereq_('../internals/whitespaces');
  18655. var replace = uncurryThis(''.replace);
  18656. var ltrim = RegExp('^[' + whitespaces + ']+');
  18657. var rtrim = RegExp('(^|[^' + whitespaces + '])[' + whitespaces + ']+$');
  18658. // `String.prototype.{ trim, trimStart, trimEnd, trimLeft, trimRight }` methods implementation
  18659. var createMethod = function (TYPE) {
  18660. return function ($this) {
  18661. var string = toString(requireObjectCoercible($this));
  18662. if (TYPE & 1) string = replace(string, ltrim, '');
  18663. if (TYPE & 2) string = replace(string, rtrim, '$1');
  18664. return string;
  18665. };
  18666. };
  18667. module.exports = {
  18668. // `String.prototype.{ trimLeft, trimStart }` methods
  18669. // https://tc39.es/ecma262/#sec-string.prototype.trimstart
  18670. start: createMethod(1),
  18671. // `String.prototype.{ trimRight, trimEnd }` methods
  18672. // https://tc39.es/ecma262/#sec-string.prototype.trimend
  18673. end: createMethod(2),
  18674. // `String.prototype.trim` method
  18675. // https://tc39.es/ecma262/#sec-string.prototype.trim
  18676. trim: createMethod(3)
  18677. };
  18678. },{"../internals/function-uncurry-this":245,"../internals/require-object-coercible":312,"../internals/to-string":334,"../internals/whitespaces":344}],322:[function(_dereq_,module,exports){
  18679. /* eslint-disable es/no-symbol -- required for testing */
  18680. var V8_VERSION = _dereq_('../internals/engine-v8-version');
  18681. var fails = _dereq_('../internals/fails');
  18682. var global = _dereq_('../internals/global');
  18683. var $String = global.String;
  18684. // eslint-disable-next-line es/no-object-getownpropertysymbols -- required for testing
  18685. module.exports = !!Object.getOwnPropertySymbols && !fails(function () {
  18686. var symbol = Symbol();
  18687. // Chrome 38 Symbol has incorrect toString conversion
  18688. // `get-own-property-symbols` polyfill symbols converted to object are not Symbol instances
  18689. // nb: Do not call `String` directly to avoid this being optimized out to `symbol+''` which will,
  18690. // of course, fail.
  18691. return !$String(symbol) || !(Object(symbol) instanceof Symbol) ||
  18692. // Chrome 38-40 symbols are not inherited from DOM collections prototypes to instances
  18693. !Symbol.sham && V8_VERSION && V8_VERSION < 41;
  18694. });
  18695. },{"../internals/engine-v8-version":227,"../internals/fails":235,"../internals/global":251}],323:[function(_dereq_,module,exports){
  18696. var call = _dereq_('../internals/function-call');
  18697. var getBuiltIn = _dereq_('../internals/get-built-in');
  18698. var wellKnownSymbol = _dereq_('../internals/well-known-symbol');
  18699. var defineBuiltIn = _dereq_('../internals/define-built-in');
  18700. module.exports = function () {
  18701. var Symbol = getBuiltIn('Symbol');
  18702. var SymbolPrototype = Symbol && Symbol.prototype;
  18703. var valueOf = SymbolPrototype && SymbolPrototype.valueOf;
  18704. var TO_PRIMITIVE = wellKnownSymbol('toPrimitive');
  18705. if (SymbolPrototype && !SymbolPrototype[TO_PRIMITIVE]) {
  18706. // `Symbol.prototype[@@toPrimitive]` method
  18707. // https://tc39.es/ecma262/#sec-symbol.prototype-@@toprimitive
  18708. // eslint-disable-next-line no-unused-vars -- required for .length
  18709. defineBuiltIn(SymbolPrototype, TO_PRIMITIVE, function (hint) {
  18710. return call(valueOf, this);
  18711. }, { arity: 1 });
  18712. }
  18713. };
  18714. },{"../internals/define-built-in":208,"../internals/function-call":241,"../internals/get-built-in":246,"../internals/well-known-symbol":343}],324:[function(_dereq_,module,exports){
  18715. var NATIVE_SYMBOL = _dereq_('../internals/symbol-constructor-detection');
  18716. /* eslint-disable es/no-symbol -- safe */
  18717. module.exports = NATIVE_SYMBOL && !!Symbol['for'] && !!Symbol.keyFor;
  18718. },{"../internals/symbol-constructor-detection":322}],325:[function(_dereq_,module,exports){
  18719. var global = _dereq_('../internals/global');
  18720. var apply = _dereq_('../internals/function-apply');
  18721. var bind = _dereq_('../internals/function-bind-context');
  18722. var isCallable = _dereq_('../internals/is-callable');
  18723. var hasOwn = _dereq_('../internals/has-own-property');
  18724. var fails = _dereq_('../internals/fails');
  18725. var html = _dereq_('../internals/html');
  18726. var arraySlice = _dereq_('../internals/array-slice');
  18727. var createElement = _dereq_('../internals/document-create-element');
  18728. var validateArgumentsLength = _dereq_('../internals/validate-arguments-length');
  18729. var IS_IOS = _dereq_('../internals/engine-is-ios');
  18730. var IS_NODE = _dereq_('../internals/engine-is-node');
  18731. var set = global.setImmediate;
  18732. var clear = global.clearImmediate;
  18733. var process = global.process;
  18734. var Dispatch = global.Dispatch;
  18735. var Function = global.Function;
  18736. var MessageChannel = global.MessageChannel;
  18737. var String = global.String;
  18738. var counter = 0;
  18739. var queue = {};
  18740. var ONREADYSTATECHANGE = 'onreadystatechange';
  18741. var $location, defer, channel, port;
  18742. fails(function () {
  18743. // Deno throws a ReferenceError on `location` access without `--location` flag
  18744. $location = global.location;
  18745. });
  18746. var run = function (id) {
  18747. if (hasOwn(queue, id)) {
  18748. var fn = queue[id];
  18749. delete queue[id];
  18750. fn();
  18751. }
  18752. };
  18753. var runner = function (id) {
  18754. return function () {
  18755. run(id);
  18756. };
  18757. };
  18758. var eventListener = function (event) {
  18759. run(event.data);
  18760. };
  18761. var globalPostMessageDefer = function (id) {
  18762. // old engines have not location.origin
  18763. global.postMessage(String(id), $location.protocol + '//' + $location.host);
  18764. };
  18765. // Node.js 0.9+ & IE10+ has setImmediate, otherwise:
  18766. if (!set || !clear) {
  18767. set = function setImmediate(handler) {
  18768. validateArgumentsLength(arguments.length, 1);
  18769. var fn = isCallable(handler) ? handler : Function(handler);
  18770. var args = arraySlice(arguments, 1);
  18771. queue[++counter] = function () {
  18772. apply(fn, undefined, args);
  18773. };
  18774. defer(counter);
  18775. return counter;
  18776. };
  18777. clear = function clearImmediate(id) {
  18778. delete queue[id];
  18779. };
  18780. // Node.js 0.8-
  18781. if (IS_NODE) {
  18782. defer = function (id) {
  18783. process.nextTick(runner(id));
  18784. };
  18785. // Sphere (JS game engine) Dispatch API
  18786. } else if (Dispatch && Dispatch.now) {
  18787. defer = function (id) {
  18788. Dispatch.now(runner(id));
  18789. };
  18790. // Browsers with MessageChannel, includes WebWorkers
  18791. // except iOS - https://github.com/zloirock/core-js/issues/624
  18792. } else if (MessageChannel && !IS_IOS) {
  18793. channel = new MessageChannel();
  18794. port = channel.port2;
  18795. channel.port1.onmessage = eventListener;
  18796. defer = bind(port.postMessage, port);
  18797. // Browsers with postMessage, skip WebWorkers
  18798. // IE8 has postMessage, but it's sync & typeof its postMessage is 'object'
  18799. } else if (
  18800. global.addEventListener &&
  18801. isCallable(global.postMessage) &&
  18802. !global.importScripts &&
  18803. $location && $location.protocol !== 'file:' &&
  18804. !fails(globalPostMessageDefer)
  18805. ) {
  18806. defer = globalPostMessageDefer;
  18807. global.addEventListener('message', eventListener, false);
  18808. // IE8-
  18809. } else if (ONREADYSTATECHANGE in createElement('script')) {
  18810. defer = function (id) {
  18811. html.appendChild(createElement('script'))[ONREADYSTATECHANGE] = function () {
  18812. html.removeChild(this);
  18813. run(id);
  18814. };
  18815. };
  18816. // Rest old browsers
  18817. } else {
  18818. defer = function (id) {
  18819. setTimeout(runner(id), 0);
  18820. };
  18821. }
  18822. }
  18823. module.exports = {
  18824. set: set,
  18825. clear: clear
  18826. };
  18827. },{"../internals/array-slice":189,"../internals/document-create-element":214,"../internals/engine-is-ios":223,"../internals/engine-is-node":224,"../internals/fails":235,"../internals/function-apply":237,"../internals/function-bind-context":238,"../internals/global":251,"../internals/has-own-property":252,"../internals/html":255,"../internals/is-callable":264,"../internals/validate-arguments-length":339}],326:[function(_dereq_,module,exports){
  18828. var toIntegerOrInfinity = _dereq_('../internals/to-integer-or-infinity');
  18829. var max = Math.max;
  18830. var min = Math.min;
  18831. // Helper for a popular repeating case of the spec:
  18832. // Let integer be ? ToInteger(index).
  18833. // If integer < 0, let result be max((length + integer), 0); else let result be min(integer, length).
  18834. module.exports = function (index, length) {
  18835. var integer = toIntegerOrInfinity(index);
  18836. return integer < 0 ? max(integer + length, 0) : min(integer, length);
  18837. };
  18838. },{"../internals/to-integer-or-infinity":328}],327:[function(_dereq_,module,exports){
  18839. // toObject with fallback for non-array-like ES3 strings
  18840. var IndexedObject = _dereq_('../internals/indexed-object');
  18841. var requireObjectCoercible = _dereq_('../internals/require-object-coercible');
  18842. module.exports = function (it) {
  18843. return IndexedObject(requireObjectCoercible(it));
  18844. };
  18845. },{"../internals/indexed-object":257,"../internals/require-object-coercible":312}],328:[function(_dereq_,module,exports){
  18846. var trunc = _dereq_('../internals/math-trunc');
  18847. // `ToIntegerOrInfinity` abstract operation
  18848. // https://tc39.es/ecma262/#sec-tointegerorinfinity
  18849. module.exports = function (argument) {
  18850. var number = +argument;
  18851. // eslint-disable-next-line no-self-compare -- NaN check
  18852. return number !== number || number === 0 ? 0 : trunc(number);
  18853. };
  18854. },{"../internals/math-trunc":280}],329:[function(_dereq_,module,exports){
  18855. var toIntegerOrInfinity = _dereq_('../internals/to-integer-or-infinity');
  18856. var min = Math.min;
  18857. // `ToLength` abstract operation
  18858. // https://tc39.es/ecma262/#sec-tolength
  18859. module.exports = function (argument) {
  18860. return argument > 0 ? min(toIntegerOrInfinity(argument), 0x1FFFFFFFFFFFFF) : 0; // 2 ** 53 - 1 == 9007199254740991
  18861. };
  18862. },{"../internals/to-integer-or-infinity":328}],330:[function(_dereq_,module,exports){
  18863. var requireObjectCoercible = _dereq_('../internals/require-object-coercible');
  18864. var $Object = Object;
  18865. // `ToObject` abstract operation
  18866. // https://tc39.es/ecma262/#sec-toobject
  18867. module.exports = function (argument) {
  18868. return $Object(requireObjectCoercible(argument));
  18869. };
  18870. },{"../internals/require-object-coercible":312}],331:[function(_dereq_,module,exports){
  18871. var call = _dereq_('../internals/function-call');
  18872. var isObject = _dereq_('../internals/is-object');
  18873. var isSymbol = _dereq_('../internals/is-symbol');
  18874. var getMethod = _dereq_('../internals/get-method');
  18875. var ordinaryToPrimitive = _dereq_('../internals/ordinary-to-primitive');
  18876. var wellKnownSymbol = _dereq_('../internals/well-known-symbol');
  18877. var $TypeError = TypeError;
  18878. var TO_PRIMITIVE = wellKnownSymbol('toPrimitive');
  18879. // `ToPrimitive` abstract operation
  18880. // https://tc39.es/ecma262/#sec-toprimitive
  18881. module.exports = function (input, pref) {
  18882. if (!isObject(input) || isSymbol(input)) return input;
  18883. var exoticToPrim = getMethod(input, TO_PRIMITIVE);
  18884. var result;
  18885. if (exoticToPrim) {
  18886. if (pref === undefined) pref = 'default';
  18887. result = call(exoticToPrim, input, pref);
  18888. if (!isObject(result) || isSymbol(result)) return result;
  18889. throw $TypeError("Can't convert object to primitive value");
  18890. }
  18891. if (pref === undefined) pref = 'number';
  18892. return ordinaryToPrimitive(input, pref);
  18893. };
  18894. },{"../internals/function-call":241,"../internals/get-method":250,"../internals/is-object":269,"../internals/is-symbol":272,"../internals/ordinary-to-primitive":303,"../internals/well-known-symbol":343}],332:[function(_dereq_,module,exports){
  18895. var toPrimitive = _dereq_('../internals/to-primitive');
  18896. var isSymbol = _dereq_('../internals/is-symbol');
  18897. // `ToPropertyKey` abstract operation
  18898. // https://tc39.es/ecma262/#sec-topropertykey
  18899. module.exports = function (argument) {
  18900. var key = toPrimitive(argument, 'string');
  18901. return isSymbol(key) ? key : key + '';
  18902. };
  18903. },{"../internals/is-symbol":272,"../internals/to-primitive":331}],333:[function(_dereq_,module,exports){
  18904. var wellKnownSymbol = _dereq_('../internals/well-known-symbol');
  18905. var TO_STRING_TAG = wellKnownSymbol('toStringTag');
  18906. var test = {};
  18907. test[TO_STRING_TAG] = 'z';
  18908. module.exports = String(test) === '[object z]';
  18909. },{"../internals/well-known-symbol":343}],334:[function(_dereq_,module,exports){
  18910. var classof = _dereq_('../internals/classof');
  18911. var $String = String;
  18912. module.exports = function (argument) {
  18913. if (classof(argument) === 'Symbol') throw TypeError('Cannot convert a Symbol value to a string');
  18914. return $String(argument);
  18915. };
  18916. },{"../internals/classof":196}],335:[function(_dereq_,module,exports){
  18917. var $String = String;
  18918. module.exports = function (argument) {
  18919. try {
  18920. return $String(argument);
  18921. } catch (error) {
  18922. return 'Object';
  18923. }
  18924. };
  18925. },{}],336:[function(_dereq_,module,exports){
  18926. var uncurryThis = _dereq_('../internals/function-uncurry-this');
  18927. var id = 0;
  18928. var postfix = Math.random();
  18929. var toString = uncurryThis(1.0.toString);
  18930. module.exports = function (key) {
  18931. return 'Symbol(' + (key === undefined ? '' : key) + ')_' + toString(++id + postfix, 36);
  18932. };
  18933. },{"../internals/function-uncurry-this":245}],337:[function(_dereq_,module,exports){
  18934. /* eslint-disable es/no-symbol -- required for testing */
  18935. var NATIVE_SYMBOL = _dereq_('../internals/symbol-constructor-detection');
  18936. module.exports = NATIVE_SYMBOL
  18937. && !Symbol.sham
  18938. && typeof Symbol.iterator == 'symbol';
  18939. },{"../internals/symbol-constructor-detection":322}],338:[function(_dereq_,module,exports){
  18940. var DESCRIPTORS = _dereq_('../internals/descriptors');
  18941. var fails = _dereq_('../internals/fails');
  18942. // V8 ~ Chrome 36-
  18943. // https://bugs.chromium.org/p/v8/issues/detail?id=3334
  18944. module.exports = DESCRIPTORS && fails(function () {
  18945. // eslint-disable-next-line es/no-object-defineproperty -- required for testing
  18946. return Object.defineProperty(function () { /* empty */ }, 'prototype', {
  18947. value: 42,
  18948. writable: false
  18949. }).prototype != 42;
  18950. });
  18951. },{"../internals/descriptors":212,"../internals/fails":235}],339:[function(_dereq_,module,exports){
  18952. var $TypeError = TypeError;
  18953. module.exports = function (passed, required) {
  18954. if (passed < required) throw $TypeError('Not enough arguments');
  18955. return passed;
  18956. };
  18957. },{}],340:[function(_dereq_,module,exports){
  18958. var global = _dereq_('../internals/global');
  18959. var isCallable = _dereq_('../internals/is-callable');
  18960. var WeakMap = global.WeakMap;
  18961. module.exports = isCallable(WeakMap) && /native code/.test(String(WeakMap));
  18962. },{"../internals/global":251,"../internals/is-callable":264}],341:[function(_dereq_,module,exports){
  18963. var path = _dereq_('../internals/path');
  18964. var hasOwn = _dereq_('../internals/has-own-property');
  18965. var wrappedWellKnownSymbolModule = _dereq_('../internals/well-known-symbol-wrapped');
  18966. var defineProperty = _dereq_('../internals/object-define-property').f;
  18967. module.exports = function (NAME) {
  18968. var Symbol = path.Symbol || (path.Symbol = {});
  18969. if (!hasOwn(Symbol, NAME)) defineProperty(Symbol, NAME, {
  18970. value: wrappedWellKnownSymbolModule.f(NAME)
  18971. });
  18972. };
  18973. },{"../internals/has-own-property":252,"../internals/object-define-property":289,"../internals/path":305,"../internals/well-known-symbol-wrapped":342}],342:[function(_dereq_,module,exports){
  18974. var wellKnownSymbol = _dereq_('../internals/well-known-symbol');
  18975. exports.f = wellKnownSymbol;
  18976. },{"../internals/well-known-symbol":343}],343:[function(_dereq_,module,exports){
  18977. var global = _dereq_('../internals/global');
  18978. var shared = _dereq_('../internals/shared');
  18979. var hasOwn = _dereq_('../internals/has-own-property');
  18980. var uid = _dereq_('../internals/uid');
  18981. var NATIVE_SYMBOL = _dereq_('../internals/symbol-constructor-detection');
  18982. var USE_SYMBOL_AS_UID = _dereq_('../internals/use-symbol-as-uid');
  18983. var Symbol = global.Symbol;
  18984. var WellKnownSymbolsStore = shared('wks');
  18985. var createWellKnownSymbol = USE_SYMBOL_AS_UID ? Symbol['for'] || Symbol : Symbol && Symbol.withoutSetter || uid;
  18986. module.exports = function (name) {
  18987. if (!hasOwn(WellKnownSymbolsStore, name)) {
  18988. WellKnownSymbolsStore[name] = NATIVE_SYMBOL && hasOwn(Symbol, name)
  18989. ? Symbol[name]
  18990. : createWellKnownSymbol('Symbol.' + name);
  18991. } return WellKnownSymbolsStore[name];
  18992. };
  18993. },{"../internals/global":251,"../internals/has-own-property":252,"../internals/shared":318,"../internals/symbol-constructor-detection":322,"../internals/uid":336,"../internals/use-symbol-as-uid":337}],344:[function(_dereq_,module,exports){
  18994. // a string of all valid unicode whitespaces
  18995. module.exports = '\u0009\u000A\u000B\u000C\u000D\u0020\u00A0\u1680\u2000\u2001\u2002' +
  18996. '\u2003\u2004\u2005\u2006\u2007\u2008\u2009\u200A\u202F\u205F\u3000\u2028\u2029\uFEFF';
  18997. },{}],345:[function(_dereq_,module,exports){
  18998. 'use strict';
  18999. var $ = _dereq_('../internals/export');
  19000. var isPrototypeOf = _dereq_('../internals/object-is-prototype-of');
  19001. var getPrototypeOf = _dereq_('../internals/object-get-prototype-of');
  19002. var setPrototypeOf = _dereq_('../internals/object-set-prototype-of');
  19003. var copyConstructorProperties = _dereq_('../internals/copy-constructor-properties');
  19004. var create = _dereq_('../internals/object-create');
  19005. var createNonEnumerableProperty = _dereq_('../internals/create-non-enumerable-property');
  19006. var createPropertyDescriptor = _dereq_('../internals/create-property-descriptor');
  19007. var installErrorCause = _dereq_('../internals/install-error-cause');
  19008. var installErrorStack = _dereq_('../internals/error-stack-install');
  19009. var iterate = _dereq_('../internals/iterate');
  19010. var normalizeStringArgument = _dereq_('../internals/normalize-string-argument');
  19011. var wellKnownSymbol = _dereq_('../internals/well-known-symbol');
  19012. var TO_STRING_TAG = wellKnownSymbol('toStringTag');
  19013. var $Error = Error;
  19014. var push = [].push;
  19015. var $AggregateError = function AggregateError(errors, message /* , options */) {
  19016. var isInstance = isPrototypeOf(AggregateErrorPrototype, this);
  19017. var that;
  19018. if (setPrototypeOf) {
  19019. that = setPrototypeOf($Error(), isInstance ? getPrototypeOf(this) : AggregateErrorPrototype);
  19020. } else {
  19021. that = isInstance ? this : create(AggregateErrorPrototype);
  19022. createNonEnumerableProperty(that, TO_STRING_TAG, 'Error');
  19023. }
  19024. if (message !== undefined) createNonEnumerableProperty(that, 'message', normalizeStringArgument(message));
  19025. installErrorStack(that, $AggregateError, that.stack, 1);
  19026. if (arguments.length > 2) installErrorCause(that, arguments[2]);
  19027. var errorsArray = [];
  19028. iterate(errors, push, { that: errorsArray });
  19029. createNonEnumerableProperty(that, 'errors', errorsArray);
  19030. return that;
  19031. };
  19032. if (setPrototypeOf) setPrototypeOf($AggregateError, $Error);
  19033. else copyConstructorProperties($AggregateError, $Error, { name: true });
  19034. var AggregateErrorPrototype = $AggregateError.prototype = create($Error.prototype, {
  19035. constructor: createPropertyDescriptor(1, $AggregateError),
  19036. message: createPropertyDescriptor(1, ''),
  19037. name: createPropertyDescriptor(1, 'AggregateError')
  19038. });
  19039. // `AggregateError` constructor
  19040. // https://tc39.es/ecma262/#sec-aggregate-error-constructor
  19041. $({ global: true, constructor: true, arity: 2 }, {
  19042. AggregateError: $AggregateError
  19043. });
  19044. },{"../internals/copy-constructor-properties":200,"../internals/create-non-enumerable-property":204,"../internals/create-property-descriptor":205,"../internals/error-stack-install":232,"../internals/export":234,"../internals/install-error-cause":259,"../internals/iterate":273,"../internals/normalize-string-argument":283,"../internals/object-create":287,"../internals/object-get-prototype-of":294,"../internals/object-is-prototype-of":296,"../internals/object-set-prototype-of":300,"../internals/well-known-symbol":343}],346:[function(_dereq_,module,exports){
  19045. // TODO: Remove this module from `core-js@4` since it's replaced to module below
  19046. _dereq_('../modules/es.aggregate-error.constructor');
  19047. },{"../modules/es.aggregate-error.constructor":345}],347:[function(_dereq_,module,exports){
  19048. 'use strict';
  19049. var $ = _dereq_('../internals/export');
  19050. var fails = _dereq_('../internals/fails');
  19051. var isArray = _dereq_('../internals/is-array');
  19052. var isObject = _dereq_('../internals/is-object');
  19053. var toObject = _dereq_('../internals/to-object');
  19054. var lengthOfArrayLike = _dereq_('../internals/length-of-array-like');
  19055. var doesNotExceedSafeInteger = _dereq_('../internals/does-not-exceed-safe-integer');
  19056. var createProperty = _dereq_('../internals/create-property');
  19057. var arraySpeciesCreate = _dereq_('../internals/array-species-create');
  19058. var arrayMethodHasSpeciesSupport = _dereq_('../internals/array-method-has-species-support');
  19059. var wellKnownSymbol = _dereq_('../internals/well-known-symbol');
  19060. var V8_VERSION = _dereq_('../internals/engine-v8-version');
  19061. var IS_CONCAT_SPREADABLE = wellKnownSymbol('isConcatSpreadable');
  19062. // We can't use this feature detection in V8 since it causes
  19063. // deoptimization and serious performance degradation
  19064. // https://github.com/zloirock/core-js/issues/679
  19065. var IS_CONCAT_SPREADABLE_SUPPORT = V8_VERSION >= 51 || !fails(function () {
  19066. var array = [];
  19067. array[IS_CONCAT_SPREADABLE] = false;
  19068. return array.concat()[0] !== array;
  19069. });
  19070. var isConcatSpreadable = function (O) {
  19071. if (!isObject(O)) return false;
  19072. var spreadable = O[IS_CONCAT_SPREADABLE];
  19073. return spreadable !== undefined ? !!spreadable : isArray(O);
  19074. };
  19075. var FORCED = !IS_CONCAT_SPREADABLE_SUPPORT || !arrayMethodHasSpeciesSupport('concat');
  19076. // `Array.prototype.concat` method
  19077. // https://tc39.es/ecma262/#sec-array.prototype.concat
  19078. // with adding support of @@isConcatSpreadable and @@species
  19079. $({ target: 'Array', proto: true, arity: 1, forced: FORCED }, {
  19080. // eslint-disable-next-line no-unused-vars -- required for `.length`
  19081. concat: function concat(arg) {
  19082. var O = toObject(this);
  19083. var A = arraySpeciesCreate(O, 0);
  19084. var n = 0;
  19085. var i, k, length, len, E;
  19086. for (i = -1, length = arguments.length; i < length; i++) {
  19087. E = i === -1 ? O : arguments[i];
  19088. if (isConcatSpreadable(E)) {
  19089. len = lengthOfArrayLike(E);
  19090. doesNotExceedSafeInteger(n + len);
  19091. for (k = 0; k < len; k++, n++) if (k in E) createProperty(A, n, E[k]);
  19092. } else {
  19093. doesNotExceedSafeInteger(n + 1);
  19094. createProperty(A, n++, E);
  19095. }
  19096. }
  19097. A.length = n;
  19098. return A;
  19099. }
  19100. });
  19101. },{"../internals/array-method-has-species-support":184,"../internals/array-species-create":192,"../internals/create-property":206,"../internals/does-not-exceed-safe-integer":215,"../internals/engine-v8-version":227,"../internals/export":234,"../internals/fails":235,"../internals/is-array":263,"../internals/is-object":269,"../internals/length-of-array-like":279,"../internals/to-object":330,"../internals/well-known-symbol":343}],348:[function(_dereq_,module,exports){
  19102. 'use strict';
  19103. var $ = _dereq_('../internals/export');
  19104. var $every = _dereq_('../internals/array-iteration').every;
  19105. var arrayMethodIsStrict = _dereq_('../internals/array-method-is-strict');
  19106. var STRICT_METHOD = arrayMethodIsStrict('every');
  19107. // `Array.prototype.every` method
  19108. // https://tc39.es/ecma262/#sec-array.prototype.every
  19109. $({ target: 'Array', proto: true, forced: !STRICT_METHOD }, {
  19110. every: function every(callbackfn /* , thisArg */) {
  19111. return $every(this, callbackfn, arguments.length > 1 ? arguments[1] : undefined);
  19112. }
  19113. });
  19114. },{"../internals/array-iteration":183,"../internals/array-method-is-strict":185,"../internals/export":234}],349:[function(_dereq_,module,exports){
  19115. 'use strict';
  19116. var $ = _dereq_('../internals/export');
  19117. var $filter = _dereq_('../internals/array-iteration').filter;
  19118. var arrayMethodHasSpeciesSupport = _dereq_('../internals/array-method-has-species-support');
  19119. var HAS_SPECIES_SUPPORT = arrayMethodHasSpeciesSupport('filter');
  19120. // `Array.prototype.filter` method
  19121. // https://tc39.es/ecma262/#sec-array.prototype.filter
  19122. // with adding support of @@species
  19123. $({ target: 'Array', proto: true, forced: !HAS_SPECIES_SUPPORT }, {
  19124. filter: function filter(callbackfn /* , thisArg */) {
  19125. return $filter(this, callbackfn, arguments.length > 1 ? arguments[1] : undefined);
  19126. }
  19127. });
  19128. },{"../internals/array-iteration":183,"../internals/array-method-has-species-support":184,"../internals/export":234}],350:[function(_dereq_,module,exports){
  19129. 'use strict';
  19130. var $ = _dereq_('../internals/export');
  19131. var $findIndex = _dereq_('../internals/array-iteration').findIndex;
  19132. var addToUnscopables = _dereq_('../internals/add-to-unscopables');
  19133. var FIND_INDEX = 'findIndex';
  19134. var SKIPS_HOLES = true;
  19135. // Shouldn't skip holes
  19136. // eslint-disable-next-line es/no-array-prototype-findindex -- testing
  19137. if (FIND_INDEX in []) Array(1)[FIND_INDEX](function () { SKIPS_HOLES = false; });
  19138. // `Array.prototype.findIndex` method
  19139. // https://tc39.es/ecma262/#sec-array.prototype.findindex
  19140. $({ target: 'Array', proto: true, forced: SKIPS_HOLES }, {
  19141. findIndex: function findIndex(callbackfn /* , that = undefined */) {
  19142. return $findIndex(this, callbackfn, arguments.length > 1 ? arguments[1] : undefined);
  19143. }
  19144. });
  19145. // https://tc39.es/ecma262/#sec-array.prototype-@@unscopables
  19146. addToUnscopables(FIND_INDEX);
  19147. },{"../internals/add-to-unscopables":176,"../internals/array-iteration":183,"../internals/export":234}],351:[function(_dereq_,module,exports){
  19148. 'use strict';
  19149. var $ = _dereq_('../internals/export');
  19150. var $find = _dereq_('../internals/array-iteration').find;
  19151. var addToUnscopables = _dereq_('../internals/add-to-unscopables');
  19152. var FIND = 'find';
  19153. var SKIPS_HOLES = true;
  19154. // Shouldn't skip holes
  19155. // eslint-disable-next-line es/no-array-prototype-find -- testing
  19156. if (FIND in []) Array(1)[FIND](function () { SKIPS_HOLES = false; });
  19157. // `Array.prototype.find` method
  19158. // https://tc39.es/ecma262/#sec-array.prototype.find
  19159. $({ target: 'Array', proto: true, forced: SKIPS_HOLES }, {
  19160. find: function find(callbackfn /* , that = undefined */) {
  19161. return $find(this, callbackfn, arguments.length > 1 ? arguments[1] : undefined);
  19162. }
  19163. });
  19164. // https://tc39.es/ecma262/#sec-array.prototype-@@unscopables
  19165. addToUnscopables(FIND);
  19166. },{"../internals/add-to-unscopables":176,"../internals/array-iteration":183,"../internals/export":234}],352:[function(_dereq_,module,exports){
  19167. 'use strict';
  19168. var $ = _dereq_('../internals/export');
  19169. var forEach = _dereq_('../internals/array-for-each');
  19170. // `Array.prototype.forEach` method
  19171. // https://tc39.es/ecma262/#sec-array.prototype.foreach
  19172. // eslint-disable-next-line es/no-array-prototype-foreach -- safe
  19173. $({ target: 'Array', proto: true, forced: [].forEach != forEach }, {
  19174. forEach: forEach
  19175. });
  19176. },{"../internals/array-for-each":180,"../internals/export":234}],353:[function(_dereq_,module,exports){
  19177. var $ = _dereq_('../internals/export');
  19178. var from = _dereq_('../internals/array-from');
  19179. var checkCorrectnessOfIteration = _dereq_('../internals/check-correctness-of-iteration');
  19180. var INCORRECT_ITERATION = !checkCorrectnessOfIteration(function (iterable) {
  19181. // eslint-disable-next-line es/no-array-from -- required for testing
  19182. Array.from(iterable);
  19183. });
  19184. // `Array.from` method
  19185. // https://tc39.es/ecma262/#sec-array.from
  19186. $({ target: 'Array', stat: true, forced: INCORRECT_ITERATION }, {
  19187. from: from
  19188. });
  19189. },{"../internals/array-from":181,"../internals/check-correctness-of-iteration":194,"../internals/export":234}],354:[function(_dereq_,module,exports){
  19190. 'use strict';
  19191. var $ = _dereq_('../internals/export');
  19192. var $includes = _dereq_('../internals/array-includes').includes;
  19193. var fails = _dereq_('../internals/fails');
  19194. var addToUnscopables = _dereq_('../internals/add-to-unscopables');
  19195. // FF99+ bug
  19196. var BROKEN_ON_SPARSE = fails(function () {
  19197. // eslint-disable-next-line es/no-array-prototype-includes -- detection
  19198. return !Array(1).includes();
  19199. });
  19200. // `Array.prototype.includes` method
  19201. // https://tc39.es/ecma262/#sec-array.prototype.includes
  19202. $({ target: 'Array', proto: true, forced: BROKEN_ON_SPARSE }, {
  19203. includes: function includes(el /* , fromIndex = 0 */) {
  19204. return $includes(this, el, arguments.length > 1 ? arguments[1] : undefined);
  19205. }
  19206. });
  19207. // https://tc39.es/ecma262/#sec-array.prototype-@@unscopables
  19208. addToUnscopables('includes');
  19209. },{"../internals/add-to-unscopables":176,"../internals/array-includes":182,"../internals/export":234,"../internals/fails":235}],355:[function(_dereq_,module,exports){
  19210. 'use strict';
  19211. /* eslint-disable es/no-array-prototype-indexof -- required for testing */
  19212. var $ = _dereq_('../internals/export');
  19213. var uncurryThis = _dereq_('../internals/function-uncurry-this-clause');
  19214. var $indexOf = _dereq_('../internals/array-includes').indexOf;
  19215. var arrayMethodIsStrict = _dereq_('../internals/array-method-is-strict');
  19216. var nativeIndexOf = uncurryThis([].indexOf);
  19217. var NEGATIVE_ZERO = !!nativeIndexOf && 1 / nativeIndexOf([1], 1, -0) < 0;
  19218. var FORCED = NEGATIVE_ZERO || !arrayMethodIsStrict('indexOf');
  19219. // `Array.prototype.indexOf` method
  19220. // https://tc39.es/ecma262/#sec-array.prototype.indexof
  19221. $({ target: 'Array', proto: true, forced: FORCED }, {
  19222. indexOf: function indexOf(searchElement /* , fromIndex = 0 */) {
  19223. var fromIndex = arguments.length > 1 ? arguments[1] : undefined;
  19224. return NEGATIVE_ZERO
  19225. // convert -0 to +0
  19226. ? nativeIndexOf(this, searchElement, fromIndex) || 0
  19227. : $indexOf(this, searchElement, fromIndex);
  19228. }
  19229. });
  19230. },{"../internals/array-includes":182,"../internals/array-method-is-strict":185,"../internals/export":234,"../internals/function-uncurry-this-clause":244}],356:[function(_dereq_,module,exports){
  19231. var $ = _dereq_('../internals/export');
  19232. var isArray = _dereq_('../internals/is-array');
  19233. // `Array.isArray` method
  19234. // https://tc39.es/ecma262/#sec-array.isarray
  19235. $({ target: 'Array', stat: true }, {
  19236. isArray: isArray
  19237. });
  19238. },{"../internals/export":234,"../internals/is-array":263}],357:[function(_dereq_,module,exports){
  19239. 'use strict';
  19240. var toIndexedObject = _dereq_('../internals/to-indexed-object');
  19241. var addToUnscopables = _dereq_('../internals/add-to-unscopables');
  19242. var Iterators = _dereq_('../internals/iterators');
  19243. var InternalStateModule = _dereq_('../internals/internal-state');
  19244. var defineProperty = _dereq_('../internals/object-define-property').f;
  19245. var defineIterator = _dereq_('../internals/iterator-define');
  19246. var createIterResultObject = _dereq_('../internals/create-iter-result-object');
  19247. var IS_PURE = _dereq_('../internals/is-pure');
  19248. var DESCRIPTORS = _dereq_('../internals/descriptors');
  19249. var ARRAY_ITERATOR = 'Array Iterator';
  19250. var setInternalState = InternalStateModule.set;
  19251. var getInternalState = InternalStateModule.getterFor(ARRAY_ITERATOR);
  19252. // `Array.prototype.entries` method
  19253. // https://tc39.es/ecma262/#sec-array.prototype.entries
  19254. // `Array.prototype.keys` method
  19255. // https://tc39.es/ecma262/#sec-array.prototype.keys
  19256. // `Array.prototype.values` method
  19257. // https://tc39.es/ecma262/#sec-array.prototype.values
  19258. // `Array.prototype[@@iterator]` method
  19259. // https://tc39.es/ecma262/#sec-array.prototype-@@iterator
  19260. // `CreateArrayIterator` internal method
  19261. // https://tc39.es/ecma262/#sec-createarrayiterator
  19262. module.exports = defineIterator(Array, 'Array', function (iterated, kind) {
  19263. setInternalState(this, {
  19264. type: ARRAY_ITERATOR,
  19265. target: toIndexedObject(iterated), // target
  19266. index: 0, // next index
  19267. kind: kind // kind
  19268. });
  19269. // `%ArrayIteratorPrototype%.next` method
  19270. // https://tc39.es/ecma262/#sec-%arrayiteratorprototype%.next
  19271. }, function () {
  19272. var state = getInternalState(this);
  19273. var target = state.target;
  19274. var kind = state.kind;
  19275. var index = state.index++;
  19276. if (!target || index >= target.length) {
  19277. state.target = undefined;
  19278. return createIterResultObject(undefined, true);
  19279. }
  19280. if (kind == 'keys') return createIterResultObject(index, false);
  19281. if (kind == 'values') return createIterResultObject(target[index], false);
  19282. return createIterResultObject([index, target[index]], false);
  19283. }, 'values');
  19284. // argumentsList[@@iterator] is %ArrayProto_values%
  19285. // https://tc39.es/ecma262/#sec-createunmappedargumentsobject
  19286. // https://tc39.es/ecma262/#sec-createmappedargumentsobject
  19287. var values = Iterators.Arguments = Iterators.Array;
  19288. // https://tc39.es/ecma262/#sec-array.prototype-@@unscopables
  19289. addToUnscopables('keys');
  19290. addToUnscopables('values');
  19291. addToUnscopables('entries');
  19292. // V8 ~ Chrome 45- bug
  19293. if (!IS_PURE && DESCRIPTORS && values.name !== 'values') try {
  19294. defineProperty(values, 'name', { value: 'values' });
  19295. } catch (error) { /* empty */ }
  19296. },{"../internals/add-to-unscopables":176,"../internals/create-iter-result-object":203,"../internals/descriptors":212,"../internals/internal-state":261,"../internals/is-pure":270,"../internals/iterator-define":276,"../internals/iterators":278,"../internals/object-define-property":289,"../internals/to-indexed-object":327}],358:[function(_dereq_,module,exports){
  19297. 'use strict';
  19298. var $ = _dereq_('../internals/export');
  19299. var $map = _dereq_('../internals/array-iteration').map;
  19300. var arrayMethodHasSpeciesSupport = _dereq_('../internals/array-method-has-species-support');
  19301. var HAS_SPECIES_SUPPORT = arrayMethodHasSpeciesSupport('map');
  19302. // `Array.prototype.map` method
  19303. // https://tc39.es/ecma262/#sec-array.prototype.map
  19304. // with adding support of @@species
  19305. $({ target: 'Array', proto: true, forced: !HAS_SPECIES_SUPPORT }, {
  19306. map: function map(callbackfn /* , thisArg */) {
  19307. return $map(this, callbackfn, arguments.length > 1 ? arguments[1] : undefined);
  19308. }
  19309. });
  19310. },{"../internals/array-iteration":183,"../internals/array-method-has-species-support":184,"../internals/export":234}],359:[function(_dereq_,module,exports){
  19311. 'use strict';
  19312. var $ = _dereq_('../internals/export');
  19313. var $reduce = _dereq_('../internals/array-reduce').left;
  19314. var arrayMethodIsStrict = _dereq_('../internals/array-method-is-strict');
  19315. var CHROME_VERSION = _dereq_('../internals/engine-v8-version');
  19316. var IS_NODE = _dereq_('../internals/engine-is-node');
  19317. // Chrome 80-82 has a critical bug
  19318. // https://bugs.chromium.org/p/chromium/issues/detail?id=1049982
  19319. var CHROME_BUG = !IS_NODE && CHROME_VERSION > 79 && CHROME_VERSION < 83;
  19320. var FORCED = CHROME_BUG || !arrayMethodIsStrict('reduce');
  19321. // `Array.prototype.reduce` method
  19322. // https://tc39.es/ecma262/#sec-array.prototype.reduce
  19323. $({ target: 'Array', proto: true, forced: FORCED }, {
  19324. reduce: function reduce(callbackfn /* , initialValue */) {
  19325. var length = arguments.length;
  19326. return $reduce(this, callbackfn, length, length > 1 ? arguments[1] : undefined);
  19327. }
  19328. });
  19329. },{"../internals/array-method-is-strict":185,"../internals/array-reduce":186,"../internals/engine-is-node":224,"../internals/engine-v8-version":227,"../internals/export":234}],360:[function(_dereq_,module,exports){
  19330. 'use strict';
  19331. var $ = _dereq_('../internals/export');
  19332. var isArray = _dereq_('../internals/is-array');
  19333. var isConstructor = _dereq_('../internals/is-constructor');
  19334. var isObject = _dereq_('../internals/is-object');
  19335. var toAbsoluteIndex = _dereq_('../internals/to-absolute-index');
  19336. var lengthOfArrayLike = _dereq_('../internals/length-of-array-like');
  19337. var toIndexedObject = _dereq_('../internals/to-indexed-object');
  19338. var createProperty = _dereq_('../internals/create-property');
  19339. var wellKnownSymbol = _dereq_('../internals/well-known-symbol');
  19340. var arrayMethodHasSpeciesSupport = _dereq_('../internals/array-method-has-species-support');
  19341. var nativeSlice = _dereq_('../internals/array-slice');
  19342. var HAS_SPECIES_SUPPORT = arrayMethodHasSpeciesSupport('slice');
  19343. var SPECIES = wellKnownSymbol('species');
  19344. var $Array = Array;
  19345. var max = Math.max;
  19346. // `Array.prototype.slice` method
  19347. // https://tc39.es/ecma262/#sec-array.prototype.slice
  19348. // fallback for not array-like ES3 strings and DOM objects
  19349. $({ target: 'Array', proto: true, forced: !HAS_SPECIES_SUPPORT }, {
  19350. slice: function slice(start, end) {
  19351. var O = toIndexedObject(this);
  19352. var length = lengthOfArrayLike(O);
  19353. var k = toAbsoluteIndex(start, length);
  19354. var fin = toAbsoluteIndex(end === undefined ? length : end, length);
  19355. // inline `ArraySpeciesCreate` for usage native `Array#slice` where it's possible
  19356. var Constructor, result, n;
  19357. if (isArray(O)) {
  19358. Constructor = O.constructor;
  19359. // cross-realm fallback
  19360. if (isConstructor(Constructor) && (Constructor === $Array || isArray(Constructor.prototype))) {
  19361. Constructor = undefined;
  19362. } else if (isObject(Constructor)) {
  19363. Constructor = Constructor[SPECIES];
  19364. if (Constructor === null) Constructor = undefined;
  19365. }
  19366. if (Constructor === $Array || Constructor === undefined) {
  19367. return nativeSlice(O, k, fin);
  19368. }
  19369. }
  19370. result = new (Constructor === undefined ? $Array : Constructor)(max(fin - k, 0));
  19371. for (n = 0; k < fin; k++, n++) if (k in O) createProperty(result, n, O[k]);
  19372. result.length = n;
  19373. return result;
  19374. }
  19375. });
  19376. },{"../internals/array-method-has-species-support":184,"../internals/array-slice":189,"../internals/create-property":206,"../internals/export":234,"../internals/is-array":263,"../internals/is-constructor":265,"../internals/is-object":269,"../internals/length-of-array-like":279,"../internals/to-absolute-index":326,"../internals/to-indexed-object":327,"../internals/well-known-symbol":343}],361:[function(_dereq_,module,exports){
  19377. 'use strict';
  19378. var $ = _dereq_('../internals/export');
  19379. var uncurryThis = _dereq_('../internals/function-uncurry-this');
  19380. var aCallable = _dereq_('../internals/a-callable');
  19381. var toObject = _dereq_('../internals/to-object');
  19382. var lengthOfArrayLike = _dereq_('../internals/length-of-array-like');
  19383. var deletePropertyOrThrow = _dereq_('../internals/delete-property-or-throw');
  19384. var toString = _dereq_('../internals/to-string');
  19385. var fails = _dereq_('../internals/fails');
  19386. var internalSort = _dereq_('../internals/array-sort');
  19387. var arrayMethodIsStrict = _dereq_('../internals/array-method-is-strict');
  19388. var FF = _dereq_('../internals/engine-ff-version');
  19389. var IE_OR_EDGE = _dereq_('../internals/engine-is-ie-or-edge');
  19390. var V8 = _dereq_('../internals/engine-v8-version');
  19391. var WEBKIT = _dereq_('../internals/engine-webkit-version');
  19392. var test = [];
  19393. var nativeSort = uncurryThis(test.sort);
  19394. var push = uncurryThis(test.push);
  19395. // IE8-
  19396. var FAILS_ON_UNDEFINED = fails(function () {
  19397. test.sort(undefined);
  19398. });
  19399. // V8 bug
  19400. var FAILS_ON_NULL = fails(function () {
  19401. test.sort(null);
  19402. });
  19403. // Old WebKit
  19404. var STRICT_METHOD = arrayMethodIsStrict('sort');
  19405. var STABLE_SORT = !fails(function () {
  19406. // feature detection can be too slow, so check engines versions
  19407. if (V8) return V8 < 70;
  19408. if (FF && FF > 3) return;
  19409. if (IE_OR_EDGE) return true;
  19410. if (WEBKIT) return WEBKIT < 603;
  19411. var result = '';
  19412. var code, chr, value, index;
  19413. // generate an array with more 512 elements (Chakra and old V8 fails only in this case)
  19414. for (code = 65; code < 76; code++) {
  19415. chr = String.fromCharCode(code);
  19416. switch (code) {
  19417. case 66: case 69: case 70: case 72: value = 3; break;
  19418. case 68: case 71: value = 4; break;
  19419. default: value = 2;
  19420. }
  19421. for (index = 0; index < 47; index++) {
  19422. test.push({ k: chr + index, v: value });
  19423. }
  19424. }
  19425. test.sort(function (a, b) { return b.v - a.v; });
  19426. for (index = 0; index < test.length; index++) {
  19427. chr = test[index].k.charAt(0);
  19428. if (result.charAt(result.length - 1) !== chr) result += chr;
  19429. }
  19430. return result !== 'DGBEFHACIJK';
  19431. });
  19432. var FORCED = FAILS_ON_UNDEFINED || !FAILS_ON_NULL || !STRICT_METHOD || !STABLE_SORT;
  19433. var getSortCompare = function (comparefn) {
  19434. return function (x, y) {
  19435. if (y === undefined) return -1;
  19436. if (x === undefined) return 1;
  19437. if (comparefn !== undefined) return +comparefn(x, y) || 0;
  19438. return toString(x) > toString(y) ? 1 : -1;
  19439. };
  19440. };
  19441. // `Array.prototype.sort` method
  19442. // https://tc39.es/ecma262/#sec-array.prototype.sort
  19443. $({ target: 'Array', proto: true, forced: FORCED }, {
  19444. sort: function sort(comparefn) {
  19445. if (comparefn !== undefined) aCallable(comparefn);
  19446. var array = toObject(this);
  19447. if (STABLE_SORT) return comparefn === undefined ? nativeSort(array) : nativeSort(array, comparefn);
  19448. var items = [];
  19449. var arrayLength = lengthOfArrayLike(array);
  19450. var itemsLength, index;
  19451. for (index = 0; index < arrayLength; index++) {
  19452. if (index in array) push(items, array[index]);
  19453. }
  19454. internalSort(items, getSortCompare(comparefn));
  19455. itemsLength = lengthOfArrayLike(items);
  19456. index = 0;
  19457. while (index < itemsLength) array[index] = items[index++];
  19458. while (index < arrayLength) deletePropertyOrThrow(array, index++);
  19459. return array;
  19460. }
  19461. });
  19462. },{"../internals/a-callable":173,"../internals/array-method-is-strict":185,"../internals/array-sort":190,"../internals/delete-property-or-throw":211,"../internals/engine-ff-version":217,"../internals/engine-is-ie-or-edge":221,"../internals/engine-v8-version":227,"../internals/engine-webkit-version":228,"../internals/export":234,"../internals/fails":235,"../internals/function-uncurry-this":245,"../internals/length-of-array-like":279,"../internals/to-object":330,"../internals/to-string":334}],362:[function(_dereq_,module,exports){
  19463. 'use strict';
  19464. var $ = _dereq_('../internals/export');
  19465. var toObject = _dereq_('../internals/to-object');
  19466. var toAbsoluteIndex = _dereq_('../internals/to-absolute-index');
  19467. var toIntegerOrInfinity = _dereq_('../internals/to-integer-or-infinity');
  19468. var lengthOfArrayLike = _dereq_('../internals/length-of-array-like');
  19469. var setArrayLength = _dereq_('../internals/array-set-length');
  19470. var doesNotExceedSafeInteger = _dereq_('../internals/does-not-exceed-safe-integer');
  19471. var arraySpeciesCreate = _dereq_('../internals/array-species-create');
  19472. var createProperty = _dereq_('../internals/create-property');
  19473. var deletePropertyOrThrow = _dereq_('../internals/delete-property-or-throw');
  19474. var arrayMethodHasSpeciesSupport = _dereq_('../internals/array-method-has-species-support');
  19475. var HAS_SPECIES_SUPPORT = arrayMethodHasSpeciesSupport('splice');
  19476. var max = Math.max;
  19477. var min = Math.min;
  19478. // `Array.prototype.splice` method
  19479. // https://tc39.es/ecma262/#sec-array.prototype.splice
  19480. // with adding support of @@species
  19481. $({ target: 'Array', proto: true, forced: !HAS_SPECIES_SUPPORT }, {
  19482. splice: function splice(start, deleteCount /* , ...items */) {
  19483. var O = toObject(this);
  19484. var len = lengthOfArrayLike(O);
  19485. var actualStart = toAbsoluteIndex(start, len);
  19486. var argumentsLength = arguments.length;
  19487. var insertCount, actualDeleteCount, A, k, from, to;
  19488. if (argumentsLength === 0) {
  19489. insertCount = actualDeleteCount = 0;
  19490. } else if (argumentsLength === 1) {
  19491. insertCount = 0;
  19492. actualDeleteCount = len - actualStart;
  19493. } else {
  19494. insertCount = argumentsLength - 2;
  19495. actualDeleteCount = min(max(toIntegerOrInfinity(deleteCount), 0), len - actualStart);
  19496. }
  19497. doesNotExceedSafeInteger(len + insertCount - actualDeleteCount);
  19498. A = arraySpeciesCreate(O, actualDeleteCount);
  19499. for (k = 0; k < actualDeleteCount; k++) {
  19500. from = actualStart + k;
  19501. if (from in O) createProperty(A, k, O[from]);
  19502. }
  19503. A.length = actualDeleteCount;
  19504. if (insertCount < actualDeleteCount) {
  19505. for (k = actualStart; k < len - actualDeleteCount; k++) {
  19506. from = k + actualDeleteCount;
  19507. to = k + insertCount;
  19508. if (from in O) O[to] = O[from];
  19509. else deletePropertyOrThrow(O, to);
  19510. }
  19511. for (k = len; k > len - actualDeleteCount + insertCount; k--) deletePropertyOrThrow(O, k - 1);
  19512. } else if (insertCount > actualDeleteCount) {
  19513. for (k = len - actualDeleteCount; k > actualStart; k--) {
  19514. from = k + actualDeleteCount - 1;
  19515. to = k + insertCount - 1;
  19516. if (from in O) O[to] = O[from];
  19517. else deletePropertyOrThrow(O, to);
  19518. }
  19519. }
  19520. for (k = 0; k < insertCount; k++) {
  19521. O[k + actualStart] = arguments[k + 2];
  19522. }
  19523. setArrayLength(O, len - actualDeleteCount + insertCount);
  19524. return A;
  19525. }
  19526. });
  19527. },{"../internals/array-method-has-species-support":184,"../internals/array-set-length":187,"../internals/array-species-create":192,"../internals/create-property":206,"../internals/delete-property-or-throw":211,"../internals/does-not-exceed-safe-integer":215,"../internals/export":234,"../internals/length-of-array-like":279,"../internals/to-absolute-index":326,"../internals/to-integer-or-infinity":328,"../internals/to-object":330}],363:[function(_dereq_,module,exports){
  19528. // empty
  19529. },{}],364:[function(_dereq_,module,exports){
  19530. // TODO: Remove from `core-js@4`
  19531. var $ = _dereq_('../internals/export');
  19532. var bind = _dereq_('../internals/function-bind');
  19533. // `Function.prototype.bind` method
  19534. // https://tc39.es/ecma262/#sec-function.prototype.bind
  19535. // eslint-disable-next-line es/no-function-prototype-bind -- detection
  19536. $({ target: 'Function', proto: true, forced: Function.bind !== bind }, {
  19537. bind: bind
  19538. });
  19539. },{"../internals/export":234,"../internals/function-bind":240}],365:[function(_dereq_,module,exports){
  19540. var $ = _dereq_('../internals/export');
  19541. var getBuiltIn = _dereq_('../internals/get-built-in');
  19542. var apply = _dereq_('../internals/function-apply');
  19543. var call = _dereq_('../internals/function-call');
  19544. var uncurryThis = _dereq_('../internals/function-uncurry-this');
  19545. var fails = _dereq_('../internals/fails');
  19546. var isCallable = _dereq_('../internals/is-callable');
  19547. var isSymbol = _dereq_('../internals/is-symbol');
  19548. var arraySlice = _dereq_('../internals/array-slice');
  19549. var getReplacerFunction = _dereq_('../internals/get-json-replacer-function');
  19550. var NATIVE_SYMBOL = _dereq_('../internals/symbol-constructor-detection');
  19551. var $String = String;
  19552. var $stringify = getBuiltIn('JSON', 'stringify');
  19553. var exec = uncurryThis(/./.exec);
  19554. var charAt = uncurryThis(''.charAt);
  19555. var charCodeAt = uncurryThis(''.charCodeAt);
  19556. var replace = uncurryThis(''.replace);
  19557. var numberToString = uncurryThis(1.0.toString);
  19558. var tester = /[\uD800-\uDFFF]/g;
  19559. var low = /^[\uD800-\uDBFF]$/;
  19560. var hi = /^[\uDC00-\uDFFF]$/;
  19561. var WRONG_SYMBOLS_CONVERSION = !NATIVE_SYMBOL || fails(function () {
  19562. var symbol = getBuiltIn('Symbol')();
  19563. // MS Edge converts symbol values to JSON as {}
  19564. return $stringify([symbol]) != '[null]'
  19565. // WebKit converts symbol values to JSON as null
  19566. || $stringify({ a: symbol }) != '{}'
  19567. // V8 throws on boxed symbols
  19568. || $stringify(Object(symbol)) != '{}';
  19569. });
  19570. // https://github.com/tc39/proposal-well-formed-stringify
  19571. var ILL_FORMED_UNICODE = fails(function () {
  19572. return $stringify('\uDF06\uD834') !== '"\\udf06\\ud834"'
  19573. || $stringify('\uDEAD') !== '"\\udead"';
  19574. });
  19575. var stringifyWithSymbolsFix = function (it, replacer) {
  19576. var args = arraySlice(arguments);
  19577. var $replacer = getReplacerFunction(replacer);
  19578. if (!isCallable($replacer) && (it === undefined || isSymbol(it))) return; // IE8 returns string on undefined
  19579. args[1] = function (key, value) {
  19580. // some old implementations (like WebKit) could pass numbers as keys
  19581. if (isCallable($replacer)) value = call($replacer, this, $String(key), value);
  19582. if (!isSymbol(value)) return value;
  19583. };
  19584. return apply($stringify, null, args);
  19585. };
  19586. var fixIllFormed = function (match, offset, string) {
  19587. var prev = charAt(string, offset - 1);
  19588. var next = charAt(string, offset + 1);
  19589. if ((exec(low, match) && !exec(hi, next)) || (exec(hi, match) && !exec(low, prev))) {
  19590. return '\\u' + numberToString(charCodeAt(match, 0), 16);
  19591. } return match;
  19592. };
  19593. if ($stringify) {
  19594. // `JSON.stringify` method
  19595. // https://tc39.es/ecma262/#sec-json.stringify
  19596. $({ target: 'JSON', stat: true, arity: 3, forced: WRONG_SYMBOLS_CONVERSION || ILL_FORMED_UNICODE }, {
  19597. // eslint-disable-next-line no-unused-vars -- required for `.length`
  19598. stringify: function stringify(it, replacer, space) {
  19599. var args = arraySlice(arguments);
  19600. var result = apply(WRONG_SYMBOLS_CONVERSION ? stringifyWithSymbolsFix : $stringify, null, args);
  19601. return ILL_FORMED_UNICODE && typeof result == 'string' ? replace(result, tester, fixIllFormed) : result;
  19602. }
  19603. });
  19604. }
  19605. },{"../internals/array-slice":189,"../internals/export":234,"../internals/fails":235,"../internals/function-apply":237,"../internals/function-call":241,"../internals/function-uncurry-this":245,"../internals/get-built-in":246,"../internals/get-json-replacer-function":249,"../internals/is-callable":264,"../internals/is-symbol":272,"../internals/symbol-constructor-detection":322}],366:[function(_dereq_,module,exports){
  19606. var global = _dereq_('../internals/global');
  19607. var setToStringTag = _dereq_('../internals/set-to-string-tag');
  19608. // JSON[@@toStringTag] property
  19609. // https://tc39.es/ecma262/#sec-json-@@tostringtag
  19610. setToStringTag(global.JSON, 'JSON', true);
  19611. },{"../internals/global":251,"../internals/set-to-string-tag":315}],367:[function(_dereq_,module,exports){
  19612. 'use strict';
  19613. var collection = _dereq_('../internals/collection');
  19614. var collectionStrong = _dereq_('../internals/collection-strong');
  19615. // `Map` constructor
  19616. // https://tc39.es/ecma262/#sec-map-objects
  19617. collection('Map', function (init) {
  19618. return function Map() { return init(this, arguments.length ? arguments[0] : undefined); };
  19619. }, collectionStrong);
  19620. },{"../internals/collection":199,"../internals/collection-strong":197}],368:[function(_dereq_,module,exports){
  19621. // TODO: Remove this module from `core-js@4` since it's replaced to module below
  19622. _dereq_('../modules/es.map.constructor');
  19623. },{"../modules/es.map.constructor":367}],369:[function(_dereq_,module,exports){
  19624. arguments[4][363][0].apply(exports,arguments)
  19625. },{"dup":363}],370:[function(_dereq_,module,exports){
  19626. var $ = _dereq_('../internals/export');
  19627. var isIntegralNumber = _dereq_('../internals/is-integral-number');
  19628. // `Number.isInteger` method
  19629. // https://tc39.es/ecma262/#sec-number.isinteger
  19630. $({ target: 'Number', stat: true }, {
  19631. isInteger: isIntegralNumber
  19632. });
  19633. },{"../internals/export":234,"../internals/is-integral-number":267}],371:[function(_dereq_,module,exports){
  19634. var $ = _dereq_('../internals/export');
  19635. var assign = _dereq_('../internals/object-assign');
  19636. // `Object.assign` method
  19637. // https://tc39.es/ecma262/#sec-object.assign
  19638. // eslint-disable-next-line es/no-object-assign -- required for testing
  19639. $({ target: 'Object', stat: true, arity: 2, forced: Object.assign !== assign }, {
  19640. assign: assign
  19641. });
  19642. },{"../internals/export":234,"../internals/object-assign":286}],372:[function(_dereq_,module,exports){
  19643. // TODO: Remove from `core-js@4`
  19644. var $ = _dereq_('../internals/export');
  19645. var DESCRIPTORS = _dereq_('../internals/descriptors');
  19646. var create = _dereq_('../internals/object-create');
  19647. // `Object.create` method
  19648. // https://tc39.es/ecma262/#sec-object.create
  19649. $({ target: 'Object', stat: true, sham: !DESCRIPTORS }, {
  19650. create: create
  19651. });
  19652. },{"../internals/descriptors":212,"../internals/export":234,"../internals/object-create":287}],373:[function(_dereq_,module,exports){
  19653. var $ = _dereq_('../internals/export');
  19654. var DESCRIPTORS = _dereq_('../internals/descriptors');
  19655. var defineProperty = _dereq_('../internals/object-define-property').f;
  19656. // `Object.defineProperty` method
  19657. // https://tc39.es/ecma262/#sec-object.defineproperty
  19658. // eslint-disable-next-line es/no-object-defineproperty -- safe
  19659. $({ target: 'Object', stat: true, forced: Object.defineProperty !== defineProperty, sham: !DESCRIPTORS }, {
  19660. defineProperty: defineProperty
  19661. });
  19662. },{"../internals/descriptors":212,"../internals/export":234,"../internals/object-define-property":289}],374:[function(_dereq_,module,exports){
  19663. var $ = _dereq_('../internals/export');
  19664. var $entries = _dereq_('../internals/object-to-array').entries;
  19665. // `Object.entries` method
  19666. // https://tc39.es/ecma262/#sec-object.entries
  19667. $({ target: 'Object', stat: true }, {
  19668. entries: function entries(O) {
  19669. return $entries(O);
  19670. }
  19671. });
  19672. },{"../internals/export":234,"../internals/object-to-array":301}],375:[function(_dereq_,module,exports){
  19673. var $ = _dereq_('../internals/export');
  19674. var FREEZING = _dereq_('../internals/freezing');
  19675. var fails = _dereq_('../internals/fails');
  19676. var isObject = _dereq_('../internals/is-object');
  19677. var onFreeze = _dereq_('../internals/internal-metadata').onFreeze;
  19678. // eslint-disable-next-line es/no-object-freeze -- safe
  19679. var $freeze = Object.freeze;
  19680. var FAILS_ON_PRIMITIVES = fails(function () { $freeze(1); });
  19681. // `Object.freeze` method
  19682. // https://tc39.es/ecma262/#sec-object.freeze
  19683. $({ target: 'Object', stat: true, forced: FAILS_ON_PRIMITIVES, sham: !FREEZING }, {
  19684. freeze: function freeze(it) {
  19685. return $freeze && isObject(it) ? $freeze(onFreeze(it)) : it;
  19686. }
  19687. });
  19688. },{"../internals/export":234,"../internals/fails":235,"../internals/freezing":236,"../internals/internal-metadata":260,"../internals/is-object":269}],376:[function(_dereq_,module,exports){
  19689. var $ = _dereq_('../internals/export');
  19690. var fails = _dereq_('../internals/fails');
  19691. var toIndexedObject = _dereq_('../internals/to-indexed-object');
  19692. var nativeGetOwnPropertyDescriptor = _dereq_('../internals/object-get-own-property-descriptor').f;
  19693. var DESCRIPTORS = _dereq_('../internals/descriptors');
  19694. var FORCED = !DESCRIPTORS || fails(function () { nativeGetOwnPropertyDescriptor(1); });
  19695. // `Object.getOwnPropertyDescriptor` method
  19696. // https://tc39.es/ecma262/#sec-object.getownpropertydescriptor
  19697. $({ target: 'Object', stat: true, forced: FORCED, sham: !DESCRIPTORS }, {
  19698. getOwnPropertyDescriptor: function getOwnPropertyDescriptor(it, key) {
  19699. return nativeGetOwnPropertyDescriptor(toIndexedObject(it), key);
  19700. }
  19701. });
  19702. },{"../internals/descriptors":212,"../internals/export":234,"../internals/fails":235,"../internals/object-get-own-property-descriptor":290,"../internals/to-indexed-object":327}],377:[function(_dereq_,module,exports){
  19703. var $ = _dereq_('../internals/export');
  19704. var NATIVE_SYMBOL = _dereq_('../internals/symbol-constructor-detection');
  19705. var fails = _dereq_('../internals/fails');
  19706. var getOwnPropertySymbolsModule = _dereq_('../internals/object-get-own-property-symbols');
  19707. var toObject = _dereq_('../internals/to-object');
  19708. // V8 ~ Chrome 38 and 39 `Object.getOwnPropertySymbols` fails on primitives
  19709. // https://bugs.chromium.org/p/v8/issues/detail?id=3443
  19710. var FORCED = !NATIVE_SYMBOL || fails(function () { getOwnPropertySymbolsModule.f(1); });
  19711. // `Object.getOwnPropertySymbols` method
  19712. // https://tc39.es/ecma262/#sec-object.getownpropertysymbols
  19713. $({ target: 'Object', stat: true, forced: FORCED }, {
  19714. getOwnPropertySymbols: function getOwnPropertySymbols(it) {
  19715. var $getOwnPropertySymbols = getOwnPropertySymbolsModule.f;
  19716. return $getOwnPropertySymbols ? $getOwnPropertySymbols(toObject(it)) : [];
  19717. }
  19718. });
  19719. },{"../internals/export":234,"../internals/fails":235,"../internals/object-get-own-property-symbols":293,"../internals/symbol-constructor-detection":322,"../internals/to-object":330}],378:[function(_dereq_,module,exports){
  19720. var $ = _dereq_('../internals/export');
  19721. var fails = _dereq_('../internals/fails');
  19722. var toObject = _dereq_('../internals/to-object');
  19723. var nativeGetPrototypeOf = _dereq_('../internals/object-get-prototype-of');
  19724. var CORRECT_PROTOTYPE_GETTER = _dereq_('../internals/correct-prototype-getter');
  19725. var FAILS_ON_PRIMITIVES = fails(function () { nativeGetPrototypeOf(1); });
  19726. // `Object.getPrototypeOf` method
  19727. // https://tc39.es/ecma262/#sec-object.getprototypeof
  19728. $({ target: 'Object', stat: true, forced: FAILS_ON_PRIMITIVES, sham: !CORRECT_PROTOTYPE_GETTER }, {
  19729. getPrototypeOf: function getPrototypeOf(it) {
  19730. return nativeGetPrototypeOf(toObject(it));
  19731. }
  19732. });
  19733. },{"../internals/correct-prototype-getter":202,"../internals/export":234,"../internals/fails":235,"../internals/object-get-prototype-of":294,"../internals/to-object":330}],379:[function(_dereq_,module,exports){
  19734. var $ = _dereq_('../internals/export');
  19735. var toObject = _dereq_('../internals/to-object');
  19736. var nativeKeys = _dereq_('../internals/object-keys');
  19737. var fails = _dereq_('../internals/fails');
  19738. var FAILS_ON_PRIMITIVES = fails(function () { nativeKeys(1); });
  19739. // `Object.keys` method
  19740. // https://tc39.es/ecma262/#sec-object.keys
  19741. $({ target: 'Object', stat: true, forced: FAILS_ON_PRIMITIVES }, {
  19742. keys: function keys(it) {
  19743. return nativeKeys(toObject(it));
  19744. }
  19745. });
  19746. },{"../internals/export":234,"../internals/fails":235,"../internals/object-keys":298,"../internals/to-object":330}],380:[function(_dereq_,module,exports){
  19747. arguments[4][363][0].apply(exports,arguments)
  19748. },{"dup":363}],381:[function(_dereq_,module,exports){
  19749. var $ = _dereq_('../internals/export');
  19750. var $parseInt = _dereq_('../internals/number-parse-int');
  19751. // `parseInt` method
  19752. // https://tc39.es/ecma262/#sec-parseint-string-radix
  19753. $({ global: true, forced: parseInt != $parseInt }, {
  19754. parseInt: $parseInt
  19755. });
  19756. },{"../internals/export":234,"../internals/number-parse-int":285}],382:[function(_dereq_,module,exports){
  19757. 'use strict';
  19758. var $ = _dereq_('../internals/export');
  19759. var call = _dereq_('../internals/function-call');
  19760. var aCallable = _dereq_('../internals/a-callable');
  19761. var newPromiseCapabilityModule = _dereq_('../internals/new-promise-capability');
  19762. var perform = _dereq_('../internals/perform');
  19763. var iterate = _dereq_('../internals/iterate');
  19764. var PROMISE_STATICS_INCORRECT_ITERATION = _dereq_('../internals/promise-statics-incorrect-iteration');
  19765. // `Promise.allSettled` method
  19766. // https://tc39.es/ecma262/#sec-promise.allsettled
  19767. $({ target: 'Promise', stat: true, forced: PROMISE_STATICS_INCORRECT_ITERATION }, {
  19768. allSettled: function allSettled(iterable) {
  19769. var C = this;
  19770. var capability = newPromiseCapabilityModule.f(C);
  19771. var resolve = capability.resolve;
  19772. var reject = capability.reject;
  19773. var result = perform(function () {
  19774. var promiseResolve = aCallable(C.resolve);
  19775. var values = [];
  19776. var counter = 0;
  19777. var remaining = 1;
  19778. iterate(iterable, function (promise) {
  19779. var index = counter++;
  19780. var alreadyCalled = false;
  19781. remaining++;
  19782. call(promiseResolve, C, promise).then(function (value) {
  19783. if (alreadyCalled) return;
  19784. alreadyCalled = true;
  19785. values[index] = { status: 'fulfilled', value: value };
  19786. --remaining || resolve(values);
  19787. }, function (error) {
  19788. if (alreadyCalled) return;
  19789. alreadyCalled = true;
  19790. values[index] = { status: 'rejected', reason: error };
  19791. --remaining || resolve(values);
  19792. });
  19793. });
  19794. --remaining || resolve(values);
  19795. });
  19796. if (result.error) reject(result.value);
  19797. return capability.promise;
  19798. }
  19799. });
  19800. },{"../internals/a-callable":173,"../internals/export":234,"../internals/function-call":241,"../internals/iterate":273,"../internals/new-promise-capability":282,"../internals/perform":306,"../internals/promise-statics-incorrect-iteration":310}],383:[function(_dereq_,module,exports){
  19801. 'use strict';
  19802. var $ = _dereq_('../internals/export');
  19803. var call = _dereq_('../internals/function-call');
  19804. var aCallable = _dereq_('../internals/a-callable');
  19805. var newPromiseCapabilityModule = _dereq_('../internals/new-promise-capability');
  19806. var perform = _dereq_('../internals/perform');
  19807. var iterate = _dereq_('../internals/iterate');
  19808. var PROMISE_STATICS_INCORRECT_ITERATION = _dereq_('../internals/promise-statics-incorrect-iteration');
  19809. // `Promise.all` method
  19810. // https://tc39.es/ecma262/#sec-promise.all
  19811. $({ target: 'Promise', stat: true, forced: PROMISE_STATICS_INCORRECT_ITERATION }, {
  19812. all: function all(iterable) {
  19813. var C = this;
  19814. var capability = newPromiseCapabilityModule.f(C);
  19815. var resolve = capability.resolve;
  19816. var reject = capability.reject;
  19817. var result = perform(function () {
  19818. var $promiseResolve = aCallable(C.resolve);
  19819. var values = [];
  19820. var counter = 0;
  19821. var remaining = 1;
  19822. iterate(iterable, function (promise) {
  19823. var index = counter++;
  19824. var alreadyCalled = false;
  19825. remaining++;
  19826. call($promiseResolve, C, promise).then(function (value) {
  19827. if (alreadyCalled) return;
  19828. alreadyCalled = true;
  19829. values[index] = value;
  19830. --remaining || resolve(values);
  19831. }, reject);
  19832. });
  19833. --remaining || resolve(values);
  19834. });
  19835. if (result.error) reject(result.value);
  19836. return capability.promise;
  19837. }
  19838. });
  19839. },{"../internals/a-callable":173,"../internals/export":234,"../internals/function-call":241,"../internals/iterate":273,"../internals/new-promise-capability":282,"../internals/perform":306,"../internals/promise-statics-incorrect-iteration":310}],384:[function(_dereq_,module,exports){
  19840. 'use strict';
  19841. var $ = _dereq_('../internals/export');
  19842. var call = _dereq_('../internals/function-call');
  19843. var aCallable = _dereq_('../internals/a-callable');
  19844. var getBuiltIn = _dereq_('../internals/get-built-in');
  19845. var newPromiseCapabilityModule = _dereq_('../internals/new-promise-capability');
  19846. var perform = _dereq_('../internals/perform');
  19847. var iterate = _dereq_('../internals/iterate');
  19848. var PROMISE_STATICS_INCORRECT_ITERATION = _dereq_('../internals/promise-statics-incorrect-iteration');
  19849. var PROMISE_ANY_ERROR = 'No one promise resolved';
  19850. // `Promise.any` method
  19851. // https://tc39.es/ecma262/#sec-promise.any
  19852. $({ target: 'Promise', stat: true, forced: PROMISE_STATICS_INCORRECT_ITERATION }, {
  19853. any: function any(iterable) {
  19854. var C = this;
  19855. var AggregateError = getBuiltIn('AggregateError');
  19856. var capability = newPromiseCapabilityModule.f(C);
  19857. var resolve = capability.resolve;
  19858. var reject = capability.reject;
  19859. var result = perform(function () {
  19860. var promiseResolve = aCallable(C.resolve);
  19861. var errors = [];
  19862. var counter = 0;
  19863. var remaining = 1;
  19864. var alreadyResolved = false;
  19865. iterate(iterable, function (promise) {
  19866. var index = counter++;
  19867. var alreadyRejected = false;
  19868. remaining++;
  19869. call(promiseResolve, C, promise).then(function (value) {
  19870. if (alreadyRejected || alreadyResolved) return;
  19871. alreadyResolved = true;
  19872. resolve(value);
  19873. }, function (error) {
  19874. if (alreadyRejected || alreadyResolved) return;
  19875. alreadyRejected = true;
  19876. errors[index] = error;
  19877. --remaining || reject(new AggregateError(errors, PROMISE_ANY_ERROR));
  19878. });
  19879. });
  19880. --remaining || reject(new AggregateError(errors, PROMISE_ANY_ERROR));
  19881. });
  19882. if (result.error) reject(result.value);
  19883. return capability.promise;
  19884. }
  19885. });
  19886. },{"../internals/a-callable":173,"../internals/export":234,"../internals/function-call":241,"../internals/get-built-in":246,"../internals/iterate":273,"../internals/new-promise-capability":282,"../internals/perform":306,"../internals/promise-statics-incorrect-iteration":310}],385:[function(_dereq_,module,exports){
  19887. 'use strict';
  19888. var $ = _dereq_('../internals/export');
  19889. var IS_PURE = _dereq_('../internals/is-pure');
  19890. var FORCED_PROMISE_CONSTRUCTOR = _dereq_('../internals/promise-constructor-detection').CONSTRUCTOR;
  19891. var NativePromiseConstructor = _dereq_('../internals/promise-native-constructor');
  19892. var getBuiltIn = _dereq_('../internals/get-built-in');
  19893. var isCallable = _dereq_('../internals/is-callable');
  19894. var defineBuiltIn = _dereq_('../internals/define-built-in');
  19895. var NativePromisePrototype = NativePromiseConstructor && NativePromiseConstructor.prototype;
  19896. // `Promise.prototype.catch` method
  19897. // https://tc39.es/ecma262/#sec-promise.prototype.catch
  19898. $({ target: 'Promise', proto: true, forced: FORCED_PROMISE_CONSTRUCTOR, real: true }, {
  19899. 'catch': function (onRejected) {
  19900. return this.then(undefined, onRejected);
  19901. }
  19902. });
  19903. // makes sure that native promise-based APIs `Promise#catch` properly works with patched `Promise#then`
  19904. if (!IS_PURE && isCallable(NativePromiseConstructor)) {
  19905. var method = getBuiltIn('Promise').prototype['catch'];
  19906. if (NativePromisePrototype['catch'] !== method) {
  19907. defineBuiltIn(NativePromisePrototype, 'catch', method, { unsafe: true });
  19908. }
  19909. }
  19910. },{"../internals/define-built-in":208,"../internals/export":234,"../internals/get-built-in":246,"../internals/is-callable":264,"../internals/is-pure":270,"../internals/promise-constructor-detection":307,"../internals/promise-native-constructor":308}],386:[function(_dereq_,module,exports){
  19911. 'use strict';
  19912. var $ = _dereq_('../internals/export');
  19913. var IS_PURE = _dereq_('../internals/is-pure');
  19914. var IS_NODE = _dereq_('../internals/engine-is-node');
  19915. var global = _dereq_('../internals/global');
  19916. var call = _dereq_('../internals/function-call');
  19917. var defineBuiltIn = _dereq_('../internals/define-built-in');
  19918. var setPrototypeOf = _dereq_('../internals/object-set-prototype-of');
  19919. var setToStringTag = _dereq_('../internals/set-to-string-tag');
  19920. var setSpecies = _dereq_('../internals/set-species');
  19921. var aCallable = _dereq_('../internals/a-callable');
  19922. var isCallable = _dereq_('../internals/is-callable');
  19923. var isObject = _dereq_('../internals/is-object');
  19924. var anInstance = _dereq_('../internals/an-instance');
  19925. var speciesConstructor = _dereq_('../internals/species-constructor');
  19926. var task = _dereq_('../internals/task').set;
  19927. var microtask = _dereq_('../internals/microtask');
  19928. var hostReportErrors = _dereq_('../internals/host-report-errors');
  19929. var perform = _dereq_('../internals/perform');
  19930. var Queue = _dereq_('../internals/queue');
  19931. var InternalStateModule = _dereq_('../internals/internal-state');
  19932. var NativePromiseConstructor = _dereq_('../internals/promise-native-constructor');
  19933. var PromiseConstructorDetection = _dereq_('../internals/promise-constructor-detection');
  19934. var newPromiseCapabilityModule = _dereq_('../internals/new-promise-capability');
  19935. var PROMISE = 'Promise';
  19936. var FORCED_PROMISE_CONSTRUCTOR = PromiseConstructorDetection.CONSTRUCTOR;
  19937. var NATIVE_PROMISE_REJECTION_EVENT = PromiseConstructorDetection.REJECTION_EVENT;
  19938. var NATIVE_PROMISE_SUBCLASSING = PromiseConstructorDetection.SUBCLASSING;
  19939. var getInternalPromiseState = InternalStateModule.getterFor(PROMISE);
  19940. var setInternalState = InternalStateModule.set;
  19941. var NativePromisePrototype = NativePromiseConstructor && NativePromiseConstructor.prototype;
  19942. var PromiseConstructor = NativePromiseConstructor;
  19943. var PromisePrototype = NativePromisePrototype;
  19944. var TypeError = global.TypeError;
  19945. var document = global.document;
  19946. var process = global.process;
  19947. var newPromiseCapability = newPromiseCapabilityModule.f;
  19948. var newGenericPromiseCapability = newPromiseCapability;
  19949. var DISPATCH_EVENT = !!(document && document.createEvent && global.dispatchEvent);
  19950. var UNHANDLED_REJECTION = 'unhandledrejection';
  19951. var REJECTION_HANDLED = 'rejectionhandled';
  19952. var PENDING = 0;
  19953. var FULFILLED = 1;
  19954. var REJECTED = 2;
  19955. var HANDLED = 1;
  19956. var UNHANDLED = 2;
  19957. var Internal, OwnPromiseCapability, PromiseWrapper, nativeThen;
  19958. // helpers
  19959. var isThenable = function (it) {
  19960. var then;
  19961. return isObject(it) && isCallable(then = it.then) ? then : false;
  19962. };
  19963. var callReaction = function (reaction, state) {
  19964. var value = state.value;
  19965. var ok = state.state == FULFILLED;
  19966. var handler = ok ? reaction.ok : reaction.fail;
  19967. var resolve = reaction.resolve;
  19968. var reject = reaction.reject;
  19969. var domain = reaction.domain;
  19970. var result, then, exited;
  19971. try {
  19972. if (handler) {
  19973. if (!ok) {
  19974. if (state.rejection === UNHANDLED) onHandleUnhandled(state);
  19975. state.rejection = HANDLED;
  19976. }
  19977. if (handler === true) result = value;
  19978. else {
  19979. if (domain) domain.enter();
  19980. result = handler(value); // can throw
  19981. if (domain) {
  19982. domain.exit();
  19983. exited = true;
  19984. }
  19985. }
  19986. if (result === reaction.promise) {
  19987. reject(TypeError('Promise-chain cycle'));
  19988. } else if (then = isThenable(result)) {
  19989. call(then, result, resolve, reject);
  19990. } else resolve(result);
  19991. } else reject(value);
  19992. } catch (error) {
  19993. if (domain && !exited) domain.exit();
  19994. reject(error);
  19995. }
  19996. };
  19997. var notify = function (state, isReject) {
  19998. if (state.notified) return;
  19999. state.notified = true;
  20000. microtask(function () {
  20001. var reactions = state.reactions;
  20002. var reaction;
  20003. while (reaction = reactions.get()) {
  20004. callReaction(reaction, state);
  20005. }
  20006. state.notified = false;
  20007. if (isReject && !state.rejection) onUnhandled(state);
  20008. });
  20009. };
  20010. var dispatchEvent = function (name, promise, reason) {
  20011. var event, handler;
  20012. if (DISPATCH_EVENT) {
  20013. event = document.createEvent('Event');
  20014. event.promise = promise;
  20015. event.reason = reason;
  20016. event.initEvent(name, false, true);
  20017. global.dispatchEvent(event);
  20018. } else event = { promise: promise, reason: reason };
  20019. if (!NATIVE_PROMISE_REJECTION_EVENT && (handler = global['on' + name])) handler(event);
  20020. else if (name === UNHANDLED_REJECTION) hostReportErrors('Unhandled promise rejection', reason);
  20021. };
  20022. var onUnhandled = function (state) {
  20023. call(task, global, function () {
  20024. var promise = state.facade;
  20025. var value = state.value;
  20026. var IS_UNHANDLED = isUnhandled(state);
  20027. var result;
  20028. if (IS_UNHANDLED) {
  20029. result = perform(function () {
  20030. if (IS_NODE) {
  20031. process.emit('unhandledRejection', value, promise);
  20032. } else dispatchEvent(UNHANDLED_REJECTION, promise, value);
  20033. });
  20034. // Browsers should not trigger `rejectionHandled` event if it was handled here, NodeJS - should
  20035. state.rejection = IS_NODE || isUnhandled(state) ? UNHANDLED : HANDLED;
  20036. if (result.error) throw result.value;
  20037. }
  20038. });
  20039. };
  20040. var isUnhandled = function (state) {
  20041. return state.rejection !== HANDLED && !state.parent;
  20042. };
  20043. var onHandleUnhandled = function (state) {
  20044. call(task, global, function () {
  20045. var promise = state.facade;
  20046. if (IS_NODE) {
  20047. process.emit('rejectionHandled', promise);
  20048. } else dispatchEvent(REJECTION_HANDLED, promise, state.value);
  20049. });
  20050. };
  20051. var bind = function (fn, state, unwrap) {
  20052. return function (value) {
  20053. fn(state, value, unwrap);
  20054. };
  20055. };
  20056. var internalReject = function (state, value, unwrap) {
  20057. if (state.done) return;
  20058. state.done = true;
  20059. if (unwrap) state = unwrap;
  20060. state.value = value;
  20061. state.state = REJECTED;
  20062. notify(state, true);
  20063. };
  20064. var internalResolve = function (state, value, unwrap) {
  20065. if (state.done) return;
  20066. state.done = true;
  20067. if (unwrap) state = unwrap;
  20068. try {
  20069. if (state.facade === value) throw TypeError("Promise can't be resolved itself");
  20070. var then = isThenable(value);
  20071. if (then) {
  20072. microtask(function () {
  20073. var wrapper = { done: false };
  20074. try {
  20075. call(then, value,
  20076. bind(internalResolve, wrapper, state),
  20077. bind(internalReject, wrapper, state)
  20078. );
  20079. } catch (error) {
  20080. internalReject(wrapper, error, state);
  20081. }
  20082. });
  20083. } else {
  20084. state.value = value;
  20085. state.state = FULFILLED;
  20086. notify(state, false);
  20087. }
  20088. } catch (error) {
  20089. internalReject({ done: false }, error, state);
  20090. }
  20091. };
  20092. // constructor polyfill
  20093. if (FORCED_PROMISE_CONSTRUCTOR) {
  20094. // 25.4.3.1 Promise(executor)
  20095. PromiseConstructor = function Promise(executor) {
  20096. anInstance(this, PromisePrototype);
  20097. aCallable(executor);
  20098. call(Internal, this);
  20099. var state = getInternalPromiseState(this);
  20100. try {
  20101. executor(bind(internalResolve, state), bind(internalReject, state));
  20102. } catch (error) {
  20103. internalReject(state, error);
  20104. }
  20105. };
  20106. PromisePrototype = PromiseConstructor.prototype;
  20107. // eslint-disable-next-line no-unused-vars -- required for `.length`
  20108. Internal = function Promise(executor) {
  20109. setInternalState(this, {
  20110. type: PROMISE,
  20111. done: false,
  20112. notified: false,
  20113. parent: false,
  20114. reactions: new Queue(),
  20115. rejection: false,
  20116. state: PENDING,
  20117. value: undefined
  20118. });
  20119. };
  20120. // `Promise.prototype.then` method
  20121. // https://tc39.es/ecma262/#sec-promise.prototype.then
  20122. Internal.prototype = defineBuiltIn(PromisePrototype, 'then', function then(onFulfilled, onRejected) {
  20123. var state = getInternalPromiseState(this);
  20124. var reaction = newPromiseCapability(speciesConstructor(this, PromiseConstructor));
  20125. state.parent = true;
  20126. reaction.ok = isCallable(onFulfilled) ? onFulfilled : true;
  20127. reaction.fail = isCallable(onRejected) && onRejected;
  20128. reaction.domain = IS_NODE ? process.domain : undefined;
  20129. if (state.state == PENDING) state.reactions.add(reaction);
  20130. else microtask(function () {
  20131. callReaction(reaction, state);
  20132. });
  20133. return reaction.promise;
  20134. });
  20135. OwnPromiseCapability = function () {
  20136. var promise = new Internal();
  20137. var state = getInternalPromiseState(promise);
  20138. this.promise = promise;
  20139. this.resolve = bind(internalResolve, state);
  20140. this.reject = bind(internalReject, state);
  20141. };
  20142. newPromiseCapabilityModule.f = newPromiseCapability = function (C) {
  20143. return C === PromiseConstructor || C === PromiseWrapper
  20144. ? new OwnPromiseCapability(C)
  20145. : newGenericPromiseCapability(C);
  20146. };
  20147. if (!IS_PURE && isCallable(NativePromiseConstructor) && NativePromisePrototype !== Object.prototype) {
  20148. nativeThen = NativePromisePrototype.then;
  20149. if (!NATIVE_PROMISE_SUBCLASSING) {
  20150. // make `Promise#then` return a polyfilled `Promise` for native promise-based APIs
  20151. defineBuiltIn(NativePromisePrototype, 'then', function then(onFulfilled, onRejected) {
  20152. var that = this;
  20153. return new PromiseConstructor(function (resolve, reject) {
  20154. call(nativeThen, that, resolve, reject);
  20155. }).then(onFulfilled, onRejected);
  20156. // https://github.com/zloirock/core-js/issues/640
  20157. }, { unsafe: true });
  20158. }
  20159. // make `.constructor === Promise` work for native promise-based APIs
  20160. try {
  20161. delete NativePromisePrototype.constructor;
  20162. } catch (error) { /* empty */ }
  20163. // make `instanceof Promise` work for native promise-based APIs
  20164. if (setPrototypeOf) {
  20165. setPrototypeOf(NativePromisePrototype, PromisePrototype);
  20166. }
  20167. }
  20168. }
  20169. $({ global: true, constructor: true, wrap: true, forced: FORCED_PROMISE_CONSTRUCTOR }, {
  20170. Promise: PromiseConstructor
  20171. });
  20172. setToStringTag(PromiseConstructor, PROMISE, false, true);
  20173. setSpecies(PROMISE);
  20174. },{"../internals/a-callable":173,"../internals/an-instance":177,"../internals/define-built-in":208,"../internals/engine-is-node":224,"../internals/export":234,"../internals/function-call":241,"../internals/global":251,"../internals/host-report-errors":254,"../internals/internal-state":261,"../internals/is-callable":264,"../internals/is-object":269,"../internals/is-pure":270,"../internals/microtask":281,"../internals/new-promise-capability":282,"../internals/object-set-prototype-of":300,"../internals/perform":306,"../internals/promise-constructor-detection":307,"../internals/promise-native-constructor":308,"../internals/queue":311,"../internals/set-species":314,"../internals/set-to-string-tag":315,"../internals/species-constructor":319,"../internals/task":325}],387:[function(_dereq_,module,exports){
  20175. 'use strict';
  20176. var $ = _dereq_('../internals/export');
  20177. var IS_PURE = _dereq_('../internals/is-pure');
  20178. var NativePromiseConstructor = _dereq_('../internals/promise-native-constructor');
  20179. var fails = _dereq_('../internals/fails');
  20180. var getBuiltIn = _dereq_('../internals/get-built-in');
  20181. var isCallable = _dereq_('../internals/is-callable');
  20182. var speciesConstructor = _dereq_('../internals/species-constructor');
  20183. var promiseResolve = _dereq_('../internals/promise-resolve');
  20184. var defineBuiltIn = _dereq_('../internals/define-built-in');
  20185. var NativePromisePrototype = NativePromiseConstructor && NativePromiseConstructor.prototype;
  20186. // Safari bug https://bugs.webkit.org/show_bug.cgi?id=200829
  20187. var NON_GENERIC = !!NativePromiseConstructor && fails(function () {
  20188. // eslint-disable-next-line unicorn/no-thenable -- required for testing
  20189. NativePromisePrototype['finally'].call({ then: function () { /* empty */ } }, function () { /* empty */ });
  20190. });
  20191. // `Promise.prototype.finally` method
  20192. // https://tc39.es/ecma262/#sec-promise.prototype.finally
  20193. $({ target: 'Promise', proto: true, real: true, forced: NON_GENERIC }, {
  20194. 'finally': function (onFinally) {
  20195. var C = speciesConstructor(this, getBuiltIn('Promise'));
  20196. var isFunction = isCallable(onFinally);
  20197. return this.then(
  20198. isFunction ? function (x) {
  20199. return promiseResolve(C, onFinally()).then(function () { return x; });
  20200. } : onFinally,
  20201. isFunction ? function (e) {
  20202. return promiseResolve(C, onFinally()).then(function () { throw e; });
  20203. } : onFinally
  20204. );
  20205. }
  20206. });
  20207. // makes sure that native promise-based APIs `Promise#finally` properly works with patched `Promise#then`
  20208. if (!IS_PURE && isCallable(NativePromiseConstructor)) {
  20209. var method = getBuiltIn('Promise').prototype['finally'];
  20210. if (NativePromisePrototype['finally'] !== method) {
  20211. defineBuiltIn(NativePromisePrototype, 'finally', method, { unsafe: true });
  20212. }
  20213. }
  20214. },{"../internals/define-built-in":208,"../internals/export":234,"../internals/fails":235,"../internals/get-built-in":246,"../internals/is-callable":264,"../internals/is-pure":270,"../internals/promise-native-constructor":308,"../internals/promise-resolve":309,"../internals/species-constructor":319}],388:[function(_dereq_,module,exports){
  20215. // TODO: Remove this module from `core-js@4` since it's split to modules listed below
  20216. _dereq_('../modules/es.promise.constructor');
  20217. _dereq_('../modules/es.promise.all');
  20218. _dereq_('../modules/es.promise.catch');
  20219. _dereq_('../modules/es.promise.race');
  20220. _dereq_('../modules/es.promise.reject');
  20221. _dereq_('../modules/es.promise.resolve');
  20222. },{"../modules/es.promise.all":383,"../modules/es.promise.catch":385,"../modules/es.promise.constructor":386,"../modules/es.promise.race":389,"../modules/es.promise.reject":390,"../modules/es.promise.resolve":391}],389:[function(_dereq_,module,exports){
  20223. 'use strict';
  20224. var $ = _dereq_('../internals/export');
  20225. var call = _dereq_('../internals/function-call');
  20226. var aCallable = _dereq_('../internals/a-callable');
  20227. var newPromiseCapabilityModule = _dereq_('../internals/new-promise-capability');
  20228. var perform = _dereq_('../internals/perform');
  20229. var iterate = _dereq_('../internals/iterate');
  20230. var PROMISE_STATICS_INCORRECT_ITERATION = _dereq_('../internals/promise-statics-incorrect-iteration');
  20231. // `Promise.race` method
  20232. // https://tc39.es/ecma262/#sec-promise.race
  20233. $({ target: 'Promise', stat: true, forced: PROMISE_STATICS_INCORRECT_ITERATION }, {
  20234. race: function race(iterable) {
  20235. var C = this;
  20236. var capability = newPromiseCapabilityModule.f(C);
  20237. var reject = capability.reject;
  20238. var result = perform(function () {
  20239. var $promiseResolve = aCallable(C.resolve);
  20240. iterate(iterable, function (promise) {
  20241. call($promiseResolve, C, promise).then(capability.resolve, reject);
  20242. });
  20243. });
  20244. if (result.error) reject(result.value);
  20245. return capability.promise;
  20246. }
  20247. });
  20248. },{"../internals/a-callable":173,"../internals/export":234,"../internals/function-call":241,"../internals/iterate":273,"../internals/new-promise-capability":282,"../internals/perform":306,"../internals/promise-statics-incorrect-iteration":310}],390:[function(_dereq_,module,exports){
  20249. 'use strict';
  20250. var $ = _dereq_('../internals/export');
  20251. var call = _dereq_('../internals/function-call');
  20252. var newPromiseCapabilityModule = _dereq_('../internals/new-promise-capability');
  20253. var FORCED_PROMISE_CONSTRUCTOR = _dereq_('../internals/promise-constructor-detection').CONSTRUCTOR;
  20254. // `Promise.reject` method
  20255. // https://tc39.es/ecma262/#sec-promise.reject
  20256. $({ target: 'Promise', stat: true, forced: FORCED_PROMISE_CONSTRUCTOR }, {
  20257. reject: function reject(r) {
  20258. var capability = newPromiseCapabilityModule.f(this);
  20259. call(capability.reject, undefined, r);
  20260. return capability.promise;
  20261. }
  20262. });
  20263. },{"../internals/export":234,"../internals/function-call":241,"../internals/new-promise-capability":282,"../internals/promise-constructor-detection":307}],391:[function(_dereq_,module,exports){
  20264. 'use strict';
  20265. var $ = _dereq_('../internals/export');
  20266. var getBuiltIn = _dereq_('../internals/get-built-in');
  20267. var IS_PURE = _dereq_('../internals/is-pure');
  20268. var NativePromiseConstructor = _dereq_('../internals/promise-native-constructor');
  20269. var FORCED_PROMISE_CONSTRUCTOR = _dereq_('../internals/promise-constructor-detection').CONSTRUCTOR;
  20270. var promiseResolve = _dereq_('../internals/promise-resolve');
  20271. var PromiseConstructorWrapper = getBuiltIn('Promise');
  20272. var CHECK_WRAPPER = IS_PURE && !FORCED_PROMISE_CONSTRUCTOR;
  20273. // `Promise.resolve` method
  20274. // https://tc39.es/ecma262/#sec-promise.resolve
  20275. $({ target: 'Promise', stat: true, forced: IS_PURE || FORCED_PROMISE_CONSTRUCTOR }, {
  20276. resolve: function resolve(x) {
  20277. return promiseResolve(CHECK_WRAPPER && this === PromiseConstructorWrapper ? NativePromiseConstructor : this, x);
  20278. }
  20279. });
  20280. },{"../internals/export":234,"../internals/get-built-in":246,"../internals/is-pure":270,"../internals/promise-constructor-detection":307,"../internals/promise-native-constructor":308,"../internals/promise-resolve":309}],392:[function(_dereq_,module,exports){
  20281. arguments[4][363][0].apply(exports,arguments)
  20282. },{"dup":363}],393:[function(_dereq_,module,exports){
  20283. 'use strict';
  20284. var collection = _dereq_('../internals/collection');
  20285. var collectionStrong = _dereq_('../internals/collection-strong');
  20286. // `Set` constructor
  20287. // https://tc39.es/ecma262/#sec-set-objects
  20288. collection('Set', function (init) {
  20289. return function Set() { return init(this, arguments.length ? arguments[0] : undefined); };
  20290. }, collectionStrong);
  20291. },{"../internals/collection":199,"../internals/collection-strong":197}],394:[function(_dereq_,module,exports){
  20292. // TODO: Remove this module from `core-js@4` since it's replaced to module below
  20293. _dereq_('../modules/es.set.constructor');
  20294. },{"../modules/es.set.constructor":393}],395:[function(_dereq_,module,exports){
  20295. 'use strict';
  20296. var $ = _dereq_('../internals/export');
  20297. var uncurryThis = _dereq_('../internals/function-uncurry-this');
  20298. var notARegExp = _dereq_('../internals/not-a-regexp');
  20299. var requireObjectCoercible = _dereq_('../internals/require-object-coercible');
  20300. var toString = _dereq_('../internals/to-string');
  20301. var correctIsRegExpLogic = _dereq_('../internals/correct-is-regexp-logic');
  20302. var stringIndexOf = uncurryThis(''.indexOf);
  20303. // `String.prototype.includes` method
  20304. // https://tc39.es/ecma262/#sec-string.prototype.includes
  20305. $({ target: 'String', proto: true, forced: !correctIsRegExpLogic('includes') }, {
  20306. includes: function includes(searchString /* , position = 0 */) {
  20307. return !!~stringIndexOf(
  20308. toString(requireObjectCoercible(this)),
  20309. toString(notARegExp(searchString)),
  20310. arguments.length > 1 ? arguments[1] : undefined
  20311. );
  20312. }
  20313. });
  20314. },{"../internals/correct-is-regexp-logic":201,"../internals/export":234,"../internals/function-uncurry-this":245,"../internals/not-a-regexp":284,"../internals/require-object-coercible":312,"../internals/to-string":334}],396:[function(_dereq_,module,exports){
  20315. 'use strict';
  20316. var charAt = _dereq_('../internals/string-multibyte').charAt;
  20317. var toString = _dereq_('../internals/to-string');
  20318. var InternalStateModule = _dereq_('../internals/internal-state');
  20319. var defineIterator = _dereq_('../internals/iterator-define');
  20320. var createIterResultObject = _dereq_('../internals/create-iter-result-object');
  20321. var STRING_ITERATOR = 'String Iterator';
  20322. var setInternalState = InternalStateModule.set;
  20323. var getInternalState = InternalStateModule.getterFor(STRING_ITERATOR);
  20324. // `String.prototype[@@iterator]` method
  20325. // https://tc39.es/ecma262/#sec-string.prototype-@@iterator
  20326. defineIterator(String, 'String', function (iterated) {
  20327. setInternalState(this, {
  20328. type: STRING_ITERATOR,
  20329. string: toString(iterated),
  20330. index: 0
  20331. });
  20332. // `%StringIteratorPrototype%.next` method
  20333. // https://tc39.es/ecma262/#sec-%stringiteratorprototype%.next
  20334. }, function next() {
  20335. var state = getInternalState(this);
  20336. var string = state.string;
  20337. var index = state.index;
  20338. var point;
  20339. if (index >= string.length) return createIterResultObject(undefined, true);
  20340. point = charAt(string, index);
  20341. state.index += point.length;
  20342. return createIterResultObject(point, false);
  20343. });
  20344. },{"../internals/create-iter-result-object":203,"../internals/internal-state":261,"../internals/iterator-define":276,"../internals/string-multibyte":320,"../internals/to-string":334}],397:[function(_dereq_,module,exports){
  20345. 'use strict';
  20346. var $ = _dereq_('../internals/export');
  20347. var uncurryThis = _dereq_('../internals/function-uncurry-this-clause');
  20348. var getOwnPropertyDescriptor = _dereq_('../internals/object-get-own-property-descriptor').f;
  20349. var toLength = _dereq_('../internals/to-length');
  20350. var toString = _dereq_('../internals/to-string');
  20351. var notARegExp = _dereq_('../internals/not-a-regexp');
  20352. var requireObjectCoercible = _dereq_('../internals/require-object-coercible');
  20353. var correctIsRegExpLogic = _dereq_('../internals/correct-is-regexp-logic');
  20354. var IS_PURE = _dereq_('../internals/is-pure');
  20355. // eslint-disable-next-line es/no-string-prototype-startswith -- safe
  20356. var nativeStartsWith = uncurryThis(''.startsWith);
  20357. var stringSlice = uncurryThis(''.slice);
  20358. var min = Math.min;
  20359. var CORRECT_IS_REGEXP_LOGIC = correctIsRegExpLogic('startsWith');
  20360. // https://github.com/zloirock/core-js/pull/702
  20361. var MDN_POLYFILL_BUG = !IS_PURE && !CORRECT_IS_REGEXP_LOGIC && !!function () {
  20362. var descriptor = getOwnPropertyDescriptor(String.prototype, 'startsWith');
  20363. return descriptor && !descriptor.writable;
  20364. }();
  20365. // `String.prototype.startsWith` method
  20366. // https://tc39.es/ecma262/#sec-string.prototype.startswith
  20367. $({ target: 'String', proto: true, forced: !MDN_POLYFILL_BUG && !CORRECT_IS_REGEXP_LOGIC }, {
  20368. startsWith: function startsWith(searchString /* , position = 0 */) {
  20369. var that = toString(requireObjectCoercible(this));
  20370. notARegExp(searchString);
  20371. var index = toLength(min(arguments.length > 1 ? arguments[1] : undefined, that.length));
  20372. var search = toString(searchString);
  20373. return nativeStartsWith
  20374. ? nativeStartsWith(that, search, index)
  20375. : stringSlice(that, index, index + search.length) === search;
  20376. }
  20377. });
  20378. },{"../internals/correct-is-regexp-logic":201,"../internals/export":234,"../internals/function-uncurry-this-clause":244,"../internals/is-pure":270,"../internals/not-a-regexp":284,"../internals/object-get-own-property-descriptor":290,"../internals/require-object-coercible":312,"../internals/to-length":329,"../internals/to-string":334}],398:[function(_dereq_,module,exports){
  20379. var defineWellKnownSymbol = _dereq_('../internals/well-known-symbol-define');
  20380. // `Symbol.asyncIterator` well-known symbol
  20381. // https://tc39.es/ecma262/#sec-symbol.asynciterator
  20382. defineWellKnownSymbol('asyncIterator');
  20383. },{"../internals/well-known-symbol-define":341}],399:[function(_dereq_,module,exports){
  20384. 'use strict';
  20385. var $ = _dereq_('../internals/export');
  20386. var global = _dereq_('../internals/global');
  20387. var call = _dereq_('../internals/function-call');
  20388. var uncurryThis = _dereq_('../internals/function-uncurry-this');
  20389. var IS_PURE = _dereq_('../internals/is-pure');
  20390. var DESCRIPTORS = _dereq_('../internals/descriptors');
  20391. var NATIVE_SYMBOL = _dereq_('../internals/symbol-constructor-detection');
  20392. var fails = _dereq_('../internals/fails');
  20393. var hasOwn = _dereq_('../internals/has-own-property');
  20394. var isPrototypeOf = _dereq_('../internals/object-is-prototype-of');
  20395. var anObject = _dereq_('../internals/an-object');
  20396. var toIndexedObject = _dereq_('../internals/to-indexed-object');
  20397. var toPropertyKey = _dereq_('../internals/to-property-key');
  20398. var $toString = _dereq_('../internals/to-string');
  20399. var createPropertyDescriptor = _dereq_('../internals/create-property-descriptor');
  20400. var nativeObjectCreate = _dereq_('../internals/object-create');
  20401. var objectKeys = _dereq_('../internals/object-keys');
  20402. var getOwnPropertyNamesModule = _dereq_('../internals/object-get-own-property-names');
  20403. var getOwnPropertyNamesExternal = _dereq_('../internals/object-get-own-property-names-external');
  20404. var getOwnPropertySymbolsModule = _dereq_('../internals/object-get-own-property-symbols');
  20405. var getOwnPropertyDescriptorModule = _dereq_('../internals/object-get-own-property-descriptor');
  20406. var definePropertyModule = _dereq_('../internals/object-define-property');
  20407. var definePropertiesModule = _dereq_('../internals/object-define-properties');
  20408. var propertyIsEnumerableModule = _dereq_('../internals/object-property-is-enumerable');
  20409. var defineBuiltIn = _dereq_('../internals/define-built-in');
  20410. var defineBuiltInAccessor = _dereq_('../internals/define-built-in-accessor');
  20411. var shared = _dereq_('../internals/shared');
  20412. var sharedKey = _dereq_('../internals/shared-key');
  20413. var hiddenKeys = _dereq_('../internals/hidden-keys');
  20414. var uid = _dereq_('../internals/uid');
  20415. var wellKnownSymbol = _dereq_('../internals/well-known-symbol');
  20416. var wrappedWellKnownSymbolModule = _dereq_('../internals/well-known-symbol-wrapped');
  20417. var defineWellKnownSymbol = _dereq_('../internals/well-known-symbol-define');
  20418. var defineSymbolToPrimitive = _dereq_('../internals/symbol-define-to-primitive');
  20419. var setToStringTag = _dereq_('../internals/set-to-string-tag');
  20420. var InternalStateModule = _dereq_('../internals/internal-state');
  20421. var $forEach = _dereq_('../internals/array-iteration').forEach;
  20422. var HIDDEN = sharedKey('hidden');
  20423. var SYMBOL = 'Symbol';
  20424. var PROTOTYPE = 'prototype';
  20425. var setInternalState = InternalStateModule.set;
  20426. var getInternalState = InternalStateModule.getterFor(SYMBOL);
  20427. var ObjectPrototype = Object[PROTOTYPE];
  20428. var $Symbol = global.Symbol;
  20429. var SymbolPrototype = $Symbol && $Symbol[PROTOTYPE];
  20430. var TypeError = global.TypeError;
  20431. var QObject = global.QObject;
  20432. var nativeGetOwnPropertyDescriptor = getOwnPropertyDescriptorModule.f;
  20433. var nativeDefineProperty = definePropertyModule.f;
  20434. var nativeGetOwnPropertyNames = getOwnPropertyNamesExternal.f;
  20435. var nativePropertyIsEnumerable = propertyIsEnumerableModule.f;
  20436. var push = uncurryThis([].push);
  20437. var AllSymbols = shared('symbols');
  20438. var ObjectPrototypeSymbols = shared('op-symbols');
  20439. var WellKnownSymbolsStore = shared('wks');
  20440. // Don't use setters in Qt Script, https://github.com/zloirock/core-js/issues/173
  20441. var USE_SETTER = !QObject || !QObject[PROTOTYPE] || !QObject[PROTOTYPE].findChild;
  20442. // fallback for old Android, https://code.google.com/p/v8/issues/detail?id=687
  20443. var setSymbolDescriptor = DESCRIPTORS && fails(function () {
  20444. return nativeObjectCreate(nativeDefineProperty({}, 'a', {
  20445. get: function () { return nativeDefineProperty(this, 'a', { value: 7 }).a; }
  20446. })).a != 7;
  20447. }) ? function (O, P, Attributes) {
  20448. var ObjectPrototypeDescriptor = nativeGetOwnPropertyDescriptor(ObjectPrototype, P);
  20449. if (ObjectPrototypeDescriptor) delete ObjectPrototype[P];
  20450. nativeDefineProperty(O, P, Attributes);
  20451. if (ObjectPrototypeDescriptor && O !== ObjectPrototype) {
  20452. nativeDefineProperty(ObjectPrototype, P, ObjectPrototypeDescriptor);
  20453. }
  20454. } : nativeDefineProperty;
  20455. var wrap = function (tag, description) {
  20456. var symbol = AllSymbols[tag] = nativeObjectCreate(SymbolPrototype);
  20457. setInternalState(symbol, {
  20458. type: SYMBOL,
  20459. tag: tag,
  20460. description: description
  20461. });
  20462. if (!DESCRIPTORS) symbol.description = description;
  20463. return symbol;
  20464. };
  20465. var $defineProperty = function defineProperty(O, P, Attributes) {
  20466. if (O === ObjectPrototype) $defineProperty(ObjectPrototypeSymbols, P, Attributes);
  20467. anObject(O);
  20468. var key = toPropertyKey(P);
  20469. anObject(Attributes);
  20470. if (hasOwn(AllSymbols, key)) {
  20471. if (!Attributes.enumerable) {
  20472. if (!hasOwn(O, HIDDEN)) nativeDefineProperty(O, HIDDEN, createPropertyDescriptor(1, {}));
  20473. O[HIDDEN][key] = true;
  20474. } else {
  20475. if (hasOwn(O, HIDDEN) && O[HIDDEN][key]) O[HIDDEN][key] = false;
  20476. Attributes = nativeObjectCreate(Attributes, { enumerable: createPropertyDescriptor(0, false) });
  20477. } return setSymbolDescriptor(O, key, Attributes);
  20478. } return nativeDefineProperty(O, key, Attributes);
  20479. };
  20480. var $defineProperties = function defineProperties(O, Properties) {
  20481. anObject(O);
  20482. var properties = toIndexedObject(Properties);
  20483. var keys = objectKeys(properties).concat($getOwnPropertySymbols(properties));
  20484. $forEach(keys, function (key) {
  20485. if (!DESCRIPTORS || call($propertyIsEnumerable, properties, key)) $defineProperty(O, key, properties[key]);
  20486. });
  20487. return O;
  20488. };
  20489. var $create = function create(O, Properties) {
  20490. return Properties === undefined ? nativeObjectCreate(O) : $defineProperties(nativeObjectCreate(O), Properties);
  20491. };
  20492. var $propertyIsEnumerable = function propertyIsEnumerable(V) {
  20493. var P = toPropertyKey(V);
  20494. var enumerable = call(nativePropertyIsEnumerable, this, P);
  20495. if (this === ObjectPrototype && hasOwn(AllSymbols, P) && !hasOwn(ObjectPrototypeSymbols, P)) return false;
  20496. return enumerable || !hasOwn(this, P) || !hasOwn(AllSymbols, P) || hasOwn(this, HIDDEN) && this[HIDDEN][P]
  20497. ? enumerable : true;
  20498. };
  20499. var $getOwnPropertyDescriptor = function getOwnPropertyDescriptor(O, P) {
  20500. var it = toIndexedObject(O);
  20501. var key = toPropertyKey(P);
  20502. if (it === ObjectPrototype && hasOwn(AllSymbols, key) && !hasOwn(ObjectPrototypeSymbols, key)) return;
  20503. var descriptor = nativeGetOwnPropertyDescriptor(it, key);
  20504. if (descriptor && hasOwn(AllSymbols, key) && !(hasOwn(it, HIDDEN) && it[HIDDEN][key])) {
  20505. descriptor.enumerable = true;
  20506. }
  20507. return descriptor;
  20508. };
  20509. var $getOwnPropertyNames = function getOwnPropertyNames(O) {
  20510. var names = nativeGetOwnPropertyNames(toIndexedObject(O));
  20511. var result = [];
  20512. $forEach(names, function (key) {
  20513. if (!hasOwn(AllSymbols, key) && !hasOwn(hiddenKeys, key)) push(result, key);
  20514. });
  20515. return result;
  20516. };
  20517. var $getOwnPropertySymbols = function (O) {
  20518. var IS_OBJECT_PROTOTYPE = O === ObjectPrototype;
  20519. var names = nativeGetOwnPropertyNames(IS_OBJECT_PROTOTYPE ? ObjectPrototypeSymbols : toIndexedObject(O));
  20520. var result = [];
  20521. $forEach(names, function (key) {
  20522. if (hasOwn(AllSymbols, key) && (!IS_OBJECT_PROTOTYPE || hasOwn(ObjectPrototype, key))) {
  20523. push(result, AllSymbols[key]);
  20524. }
  20525. });
  20526. return result;
  20527. };
  20528. // `Symbol` constructor
  20529. // https://tc39.es/ecma262/#sec-symbol-constructor
  20530. if (!NATIVE_SYMBOL) {
  20531. $Symbol = function Symbol() {
  20532. if (isPrototypeOf(SymbolPrototype, this)) throw TypeError('Symbol is not a constructor');
  20533. var description = !arguments.length || arguments[0] === undefined ? undefined : $toString(arguments[0]);
  20534. var tag = uid(description);
  20535. var setter = function (value) {
  20536. if (this === ObjectPrototype) call(setter, ObjectPrototypeSymbols, value);
  20537. if (hasOwn(this, HIDDEN) && hasOwn(this[HIDDEN], tag)) this[HIDDEN][tag] = false;
  20538. setSymbolDescriptor(this, tag, createPropertyDescriptor(1, value));
  20539. };
  20540. if (DESCRIPTORS && USE_SETTER) setSymbolDescriptor(ObjectPrototype, tag, { configurable: true, set: setter });
  20541. return wrap(tag, description);
  20542. };
  20543. SymbolPrototype = $Symbol[PROTOTYPE];
  20544. defineBuiltIn(SymbolPrototype, 'toString', function toString() {
  20545. return getInternalState(this).tag;
  20546. });
  20547. defineBuiltIn($Symbol, 'withoutSetter', function (description) {
  20548. return wrap(uid(description), description);
  20549. });
  20550. propertyIsEnumerableModule.f = $propertyIsEnumerable;
  20551. definePropertyModule.f = $defineProperty;
  20552. definePropertiesModule.f = $defineProperties;
  20553. getOwnPropertyDescriptorModule.f = $getOwnPropertyDescriptor;
  20554. getOwnPropertyNamesModule.f = getOwnPropertyNamesExternal.f = $getOwnPropertyNames;
  20555. getOwnPropertySymbolsModule.f = $getOwnPropertySymbols;
  20556. wrappedWellKnownSymbolModule.f = function (name) {
  20557. return wrap(wellKnownSymbol(name), name);
  20558. };
  20559. if (DESCRIPTORS) {
  20560. // https://github.com/tc39/proposal-Symbol-description
  20561. defineBuiltInAccessor(SymbolPrototype, 'description', {
  20562. configurable: true,
  20563. get: function description() {
  20564. return getInternalState(this).description;
  20565. }
  20566. });
  20567. if (!IS_PURE) {
  20568. defineBuiltIn(ObjectPrototype, 'propertyIsEnumerable', $propertyIsEnumerable, { unsafe: true });
  20569. }
  20570. }
  20571. }
  20572. $({ global: true, constructor: true, wrap: true, forced: !NATIVE_SYMBOL, sham: !NATIVE_SYMBOL }, {
  20573. Symbol: $Symbol
  20574. });
  20575. $forEach(objectKeys(WellKnownSymbolsStore), function (name) {
  20576. defineWellKnownSymbol(name);
  20577. });
  20578. $({ target: SYMBOL, stat: true, forced: !NATIVE_SYMBOL }, {
  20579. useSetter: function () { USE_SETTER = true; },
  20580. useSimple: function () { USE_SETTER = false; }
  20581. });
  20582. $({ target: 'Object', stat: true, forced: !NATIVE_SYMBOL, sham: !DESCRIPTORS }, {
  20583. // `Object.create` method
  20584. // https://tc39.es/ecma262/#sec-object.create
  20585. create: $create,
  20586. // `Object.defineProperty` method
  20587. // https://tc39.es/ecma262/#sec-object.defineproperty
  20588. defineProperty: $defineProperty,
  20589. // `Object.defineProperties` method
  20590. // https://tc39.es/ecma262/#sec-object.defineproperties
  20591. defineProperties: $defineProperties,
  20592. // `Object.getOwnPropertyDescriptor` method
  20593. // https://tc39.es/ecma262/#sec-object.getownpropertydescriptors
  20594. getOwnPropertyDescriptor: $getOwnPropertyDescriptor
  20595. });
  20596. $({ target: 'Object', stat: true, forced: !NATIVE_SYMBOL }, {
  20597. // `Object.getOwnPropertyNames` method
  20598. // https://tc39.es/ecma262/#sec-object.getownpropertynames
  20599. getOwnPropertyNames: $getOwnPropertyNames
  20600. });
  20601. // `Symbol.prototype[@@toPrimitive]` method
  20602. // https://tc39.es/ecma262/#sec-symbol.prototype-@@toprimitive
  20603. defineSymbolToPrimitive();
  20604. // `Symbol.prototype[@@toStringTag]` property
  20605. // https://tc39.es/ecma262/#sec-symbol.prototype-@@tostringtag
  20606. setToStringTag($Symbol, SYMBOL);
  20607. hiddenKeys[HIDDEN] = true;
  20608. },{"../internals/an-object":178,"../internals/array-iteration":183,"../internals/create-property-descriptor":205,"../internals/define-built-in":208,"../internals/define-built-in-accessor":207,"../internals/descriptors":212,"../internals/export":234,"../internals/fails":235,"../internals/function-call":241,"../internals/function-uncurry-this":245,"../internals/global":251,"../internals/has-own-property":252,"../internals/hidden-keys":253,"../internals/internal-state":261,"../internals/is-pure":270,"../internals/object-create":287,"../internals/object-define-properties":288,"../internals/object-define-property":289,"../internals/object-get-own-property-descriptor":290,"../internals/object-get-own-property-names":292,"../internals/object-get-own-property-names-external":291,"../internals/object-get-own-property-symbols":293,"../internals/object-is-prototype-of":296,"../internals/object-keys":298,"../internals/object-property-is-enumerable":299,"../internals/set-to-string-tag":315,"../internals/shared":318,"../internals/shared-key":316,"../internals/symbol-constructor-detection":322,"../internals/symbol-define-to-primitive":323,"../internals/to-indexed-object":327,"../internals/to-property-key":332,"../internals/to-string":334,"../internals/uid":336,"../internals/well-known-symbol":343,"../internals/well-known-symbol-define":341,"../internals/well-known-symbol-wrapped":342}],400:[function(_dereq_,module,exports){
  20609. arguments[4][363][0].apply(exports,arguments)
  20610. },{"dup":363}],401:[function(_dereq_,module,exports){
  20611. var $ = _dereq_('../internals/export');
  20612. var getBuiltIn = _dereq_('../internals/get-built-in');
  20613. var hasOwn = _dereq_('../internals/has-own-property');
  20614. var toString = _dereq_('../internals/to-string');
  20615. var shared = _dereq_('../internals/shared');
  20616. var NATIVE_SYMBOL_REGISTRY = _dereq_('../internals/symbol-registry-detection');
  20617. var StringToSymbolRegistry = shared('string-to-symbol-registry');
  20618. var SymbolToStringRegistry = shared('symbol-to-string-registry');
  20619. // `Symbol.for` method
  20620. // https://tc39.es/ecma262/#sec-symbol.for
  20621. $({ target: 'Symbol', stat: true, forced: !NATIVE_SYMBOL_REGISTRY }, {
  20622. 'for': function (key) {
  20623. var string = toString(key);
  20624. if (hasOwn(StringToSymbolRegistry, string)) return StringToSymbolRegistry[string];
  20625. var symbol = getBuiltIn('Symbol')(string);
  20626. StringToSymbolRegistry[string] = symbol;
  20627. SymbolToStringRegistry[symbol] = string;
  20628. return symbol;
  20629. }
  20630. });
  20631. },{"../internals/export":234,"../internals/get-built-in":246,"../internals/has-own-property":252,"../internals/shared":318,"../internals/symbol-registry-detection":324,"../internals/to-string":334}],402:[function(_dereq_,module,exports){
  20632. var defineWellKnownSymbol = _dereq_('../internals/well-known-symbol-define');
  20633. // `Symbol.hasInstance` well-known symbol
  20634. // https://tc39.es/ecma262/#sec-symbol.hasinstance
  20635. defineWellKnownSymbol('hasInstance');
  20636. },{"../internals/well-known-symbol-define":341}],403:[function(_dereq_,module,exports){
  20637. var defineWellKnownSymbol = _dereq_('../internals/well-known-symbol-define');
  20638. // `Symbol.isConcatSpreadable` well-known symbol
  20639. // https://tc39.es/ecma262/#sec-symbol.isconcatspreadable
  20640. defineWellKnownSymbol('isConcatSpreadable');
  20641. },{"../internals/well-known-symbol-define":341}],404:[function(_dereq_,module,exports){
  20642. var defineWellKnownSymbol = _dereq_('../internals/well-known-symbol-define');
  20643. // `Symbol.iterator` well-known symbol
  20644. // https://tc39.es/ecma262/#sec-symbol.iterator
  20645. defineWellKnownSymbol('iterator');
  20646. },{"../internals/well-known-symbol-define":341}],405:[function(_dereq_,module,exports){
  20647. // TODO: Remove this module from `core-js@4` since it's split to modules listed below
  20648. _dereq_('../modules/es.symbol.constructor');
  20649. _dereq_('../modules/es.symbol.for');
  20650. _dereq_('../modules/es.symbol.key-for');
  20651. _dereq_('../modules/es.json.stringify');
  20652. _dereq_('../modules/es.object.get-own-property-symbols');
  20653. },{"../modules/es.json.stringify":365,"../modules/es.object.get-own-property-symbols":377,"../modules/es.symbol.constructor":399,"../modules/es.symbol.for":401,"../modules/es.symbol.key-for":406}],406:[function(_dereq_,module,exports){
  20654. var $ = _dereq_('../internals/export');
  20655. var hasOwn = _dereq_('../internals/has-own-property');
  20656. var isSymbol = _dereq_('../internals/is-symbol');
  20657. var tryToString = _dereq_('../internals/try-to-string');
  20658. var shared = _dereq_('../internals/shared');
  20659. var NATIVE_SYMBOL_REGISTRY = _dereq_('../internals/symbol-registry-detection');
  20660. var SymbolToStringRegistry = shared('symbol-to-string-registry');
  20661. // `Symbol.keyFor` method
  20662. // https://tc39.es/ecma262/#sec-symbol.keyfor
  20663. $({ target: 'Symbol', stat: true, forced: !NATIVE_SYMBOL_REGISTRY }, {
  20664. keyFor: function keyFor(sym) {
  20665. if (!isSymbol(sym)) throw TypeError(tryToString(sym) + ' is not a symbol');
  20666. if (hasOwn(SymbolToStringRegistry, sym)) return SymbolToStringRegistry[sym];
  20667. }
  20668. });
  20669. },{"../internals/export":234,"../internals/has-own-property":252,"../internals/is-symbol":272,"../internals/shared":318,"../internals/symbol-registry-detection":324,"../internals/try-to-string":335}],407:[function(_dereq_,module,exports){
  20670. var defineWellKnownSymbol = _dereq_('../internals/well-known-symbol-define');
  20671. // `Symbol.matchAll` well-known symbol
  20672. // https://tc39.es/ecma262/#sec-symbol.matchall
  20673. defineWellKnownSymbol('matchAll');
  20674. },{"../internals/well-known-symbol-define":341}],408:[function(_dereq_,module,exports){
  20675. var defineWellKnownSymbol = _dereq_('../internals/well-known-symbol-define');
  20676. // `Symbol.match` well-known symbol
  20677. // https://tc39.es/ecma262/#sec-symbol.match
  20678. defineWellKnownSymbol('match');
  20679. },{"../internals/well-known-symbol-define":341}],409:[function(_dereq_,module,exports){
  20680. var defineWellKnownSymbol = _dereq_('../internals/well-known-symbol-define');
  20681. // `Symbol.replace` well-known symbol
  20682. // https://tc39.es/ecma262/#sec-symbol.replace
  20683. defineWellKnownSymbol('replace');
  20684. },{"../internals/well-known-symbol-define":341}],410:[function(_dereq_,module,exports){
  20685. var defineWellKnownSymbol = _dereq_('../internals/well-known-symbol-define');
  20686. // `Symbol.search` well-known symbol
  20687. // https://tc39.es/ecma262/#sec-symbol.search
  20688. defineWellKnownSymbol('search');
  20689. },{"../internals/well-known-symbol-define":341}],411:[function(_dereq_,module,exports){
  20690. var defineWellKnownSymbol = _dereq_('../internals/well-known-symbol-define');
  20691. // `Symbol.species` well-known symbol
  20692. // https://tc39.es/ecma262/#sec-symbol.species
  20693. defineWellKnownSymbol('species');
  20694. },{"../internals/well-known-symbol-define":341}],412:[function(_dereq_,module,exports){
  20695. var defineWellKnownSymbol = _dereq_('../internals/well-known-symbol-define');
  20696. // `Symbol.split` well-known symbol
  20697. // https://tc39.es/ecma262/#sec-symbol.split
  20698. defineWellKnownSymbol('split');
  20699. },{"../internals/well-known-symbol-define":341}],413:[function(_dereq_,module,exports){
  20700. var defineWellKnownSymbol = _dereq_('../internals/well-known-symbol-define');
  20701. var defineSymbolToPrimitive = _dereq_('../internals/symbol-define-to-primitive');
  20702. // `Symbol.toPrimitive` well-known symbol
  20703. // https://tc39.es/ecma262/#sec-symbol.toprimitive
  20704. defineWellKnownSymbol('toPrimitive');
  20705. // `Symbol.prototype[@@toPrimitive]` method
  20706. // https://tc39.es/ecma262/#sec-symbol.prototype-@@toprimitive
  20707. defineSymbolToPrimitive();
  20708. },{"../internals/symbol-define-to-primitive":323,"../internals/well-known-symbol-define":341}],414:[function(_dereq_,module,exports){
  20709. var getBuiltIn = _dereq_('../internals/get-built-in');
  20710. var defineWellKnownSymbol = _dereq_('../internals/well-known-symbol-define');
  20711. var setToStringTag = _dereq_('../internals/set-to-string-tag');
  20712. // `Symbol.toStringTag` well-known symbol
  20713. // https://tc39.es/ecma262/#sec-symbol.tostringtag
  20714. defineWellKnownSymbol('toStringTag');
  20715. // `Symbol.prototype[@@toStringTag]` property
  20716. // https://tc39.es/ecma262/#sec-symbol.prototype-@@tostringtag
  20717. setToStringTag(getBuiltIn('Symbol'), 'Symbol');
  20718. },{"../internals/get-built-in":246,"../internals/set-to-string-tag":315,"../internals/well-known-symbol-define":341}],415:[function(_dereq_,module,exports){
  20719. var defineWellKnownSymbol = _dereq_('../internals/well-known-symbol-define');
  20720. // `Symbol.unscopables` well-known symbol
  20721. // https://tc39.es/ecma262/#sec-symbol.unscopables
  20722. defineWellKnownSymbol('unscopables');
  20723. },{"../internals/well-known-symbol-define":341}],416:[function(_dereq_,module,exports){
  20724. 'use strict';
  20725. var FREEZING = _dereq_('../internals/freezing');
  20726. var global = _dereq_('../internals/global');
  20727. var uncurryThis = _dereq_('../internals/function-uncurry-this');
  20728. var defineBuiltIns = _dereq_('../internals/define-built-ins');
  20729. var InternalMetadataModule = _dereq_('../internals/internal-metadata');
  20730. var collection = _dereq_('../internals/collection');
  20731. var collectionWeak = _dereq_('../internals/collection-weak');
  20732. var isObject = _dereq_('../internals/is-object');
  20733. var enforceInternalState = _dereq_('../internals/internal-state').enforce;
  20734. var fails = _dereq_('../internals/fails');
  20735. var NATIVE_WEAK_MAP = _dereq_('../internals/weak-map-basic-detection');
  20736. var $Object = Object;
  20737. // eslint-disable-next-line es/no-array-isarray -- safe
  20738. var isArray = Array.isArray;
  20739. // eslint-disable-next-line es/no-object-isextensible -- safe
  20740. var isExtensible = $Object.isExtensible;
  20741. // eslint-disable-next-line es/no-object-isfrozen -- safe
  20742. var isFrozen = $Object.isFrozen;
  20743. // eslint-disable-next-line es/no-object-issealed -- safe
  20744. var isSealed = $Object.isSealed;
  20745. // eslint-disable-next-line es/no-object-freeze -- safe
  20746. var freeze = $Object.freeze;
  20747. // eslint-disable-next-line es/no-object-seal -- safe
  20748. var seal = $Object.seal;
  20749. var FROZEN = {};
  20750. var SEALED = {};
  20751. var IS_IE11 = !global.ActiveXObject && 'ActiveXObject' in global;
  20752. var InternalWeakMap;
  20753. var wrapper = function (init) {
  20754. return function WeakMap() {
  20755. return init(this, arguments.length ? arguments[0] : undefined);
  20756. };
  20757. };
  20758. // `WeakMap` constructor
  20759. // https://tc39.es/ecma262/#sec-weakmap-constructor
  20760. var $WeakMap = collection('WeakMap', wrapper, collectionWeak);
  20761. var WeakMapPrototype = $WeakMap.prototype;
  20762. var nativeSet = uncurryThis(WeakMapPrototype.set);
  20763. // Chakra Edge bug: adding frozen arrays to WeakMap unfreeze them
  20764. var hasMSEdgeFreezingBug = function () {
  20765. return FREEZING && fails(function () {
  20766. var frozenArray = freeze([]);
  20767. nativeSet(new $WeakMap(), frozenArray, 1);
  20768. return !isFrozen(frozenArray);
  20769. });
  20770. };
  20771. // IE11 WeakMap frozen keys fix
  20772. // We can't use feature detection because it crash some old IE builds
  20773. // https://github.com/zloirock/core-js/issues/485
  20774. if (NATIVE_WEAK_MAP) if (IS_IE11) {
  20775. InternalWeakMap = collectionWeak.getConstructor(wrapper, 'WeakMap', true);
  20776. InternalMetadataModule.enable();
  20777. var nativeDelete = uncurryThis(WeakMapPrototype['delete']);
  20778. var nativeHas = uncurryThis(WeakMapPrototype.has);
  20779. var nativeGet = uncurryThis(WeakMapPrototype.get);
  20780. defineBuiltIns(WeakMapPrototype, {
  20781. 'delete': function (key) {
  20782. if (isObject(key) && !isExtensible(key)) {
  20783. var state = enforceInternalState(this);
  20784. if (!state.frozen) state.frozen = new InternalWeakMap();
  20785. return nativeDelete(this, key) || state.frozen['delete'](key);
  20786. } return nativeDelete(this, key);
  20787. },
  20788. has: function has(key) {
  20789. if (isObject(key) && !isExtensible(key)) {
  20790. var state = enforceInternalState(this);
  20791. if (!state.frozen) state.frozen = new InternalWeakMap();
  20792. return nativeHas(this, key) || state.frozen.has(key);
  20793. } return nativeHas(this, key);
  20794. },
  20795. get: function get(key) {
  20796. if (isObject(key) && !isExtensible(key)) {
  20797. var state = enforceInternalState(this);
  20798. if (!state.frozen) state.frozen = new InternalWeakMap();
  20799. return nativeHas(this, key) ? nativeGet(this, key) : state.frozen.get(key);
  20800. } return nativeGet(this, key);
  20801. },
  20802. set: function set(key, value) {
  20803. if (isObject(key) && !isExtensible(key)) {
  20804. var state = enforceInternalState(this);
  20805. if (!state.frozen) state.frozen = new InternalWeakMap();
  20806. nativeHas(this, key) ? nativeSet(this, key, value) : state.frozen.set(key, value);
  20807. } else nativeSet(this, key, value);
  20808. return this;
  20809. }
  20810. });
  20811. // Chakra Edge frozen keys fix
  20812. } else if (hasMSEdgeFreezingBug()) {
  20813. defineBuiltIns(WeakMapPrototype, {
  20814. set: function set(key, value) {
  20815. var arrayIntegrityLevel;
  20816. if (isArray(key)) {
  20817. if (isFrozen(key)) arrayIntegrityLevel = FROZEN;
  20818. else if (isSealed(key)) arrayIntegrityLevel = SEALED;
  20819. }
  20820. nativeSet(this, key, value);
  20821. if (arrayIntegrityLevel == FROZEN) freeze(key);
  20822. if (arrayIntegrityLevel == SEALED) seal(key);
  20823. return this;
  20824. }
  20825. });
  20826. }
  20827. },{"../internals/collection":199,"../internals/collection-weak":198,"../internals/define-built-ins":209,"../internals/fails":235,"../internals/freezing":236,"../internals/function-uncurry-this":245,"../internals/global":251,"../internals/internal-metadata":260,"../internals/internal-state":261,"../internals/is-object":269,"../internals/weak-map-basic-detection":340}],417:[function(_dereq_,module,exports){
  20828. // TODO: Remove this module from `core-js@4` since it's replaced to module below
  20829. _dereq_('../modules/es.weak-map.constructor');
  20830. },{"../modules/es.weak-map.constructor":416}],418:[function(_dereq_,module,exports){
  20831. var defineWellKnownSymbol = _dereq_('../internals/well-known-symbol-define');
  20832. // `Symbol.asyncDispose` well-known symbol
  20833. // https://github.com/tc39/proposal-async-explicit-resource-management
  20834. defineWellKnownSymbol('asyncDispose');
  20835. },{"../internals/well-known-symbol-define":341}],419:[function(_dereq_,module,exports){
  20836. var defineWellKnownSymbol = _dereq_('../internals/well-known-symbol-define');
  20837. // `Symbol.dispose` well-known symbol
  20838. // https://github.com/tc39/proposal-explicit-resource-management
  20839. defineWellKnownSymbol('dispose');
  20840. },{"../internals/well-known-symbol-define":341}],420:[function(_dereq_,module,exports){
  20841. var $ = _dereq_('../internals/export');
  20842. var getBuiltIn = _dereq_('../internals/get-built-in');
  20843. var uncurryThis = _dereq_('../internals/function-uncurry-this');
  20844. var Symbol = getBuiltIn('Symbol');
  20845. var keyFor = Symbol.keyFor;
  20846. var thisSymbolValue = uncurryThis(Symbol.prototype.valueOf);
  20847. // `Symbol.isRegistered` method
  20848. // https://tc39.es/proposal-symbol-predicates/#sec-symbol-isregistered
  20849. $({ target: 'Symbol', stat: true }, {
  20850. isRegistered: function isRegistered(value) {
  20851. try {
  20852. return keyFor(thisSymbolValue(value)) !== undefined;
  20853. } catch (error) {
  20854. return false;
  20855. }
  20856. }
  20857. });
  20858. },{"../internals/export":234,"../internals/function-uncurry-this":245,"../internals/get-built-in":246}],421:[function(_dereq_,module,exports){
  20859. var $ = _dereq_('../internals/export');
  20860. var shared = _dereq_('../internals/shared');
  20861. var getBuiltIn = _dereq_('../internals/get-built-in');
  20862. var uncurryThis = _dereq_('../internals/function-uncurry-this');
  20863. var isSymbol = _dereq_('../internals/is-symbol');
  20864. var wellKnownSymbol = _dereq_('../internals/well-known-symbol');
  20865. var Symbol = getBuiltIn('Symbol');
  20866. var $isWellKnown = Symbol.isWellKnown;
  20867. var getOwnPropertyNames = getBuiltIn('Object', 'getOwnPropertyNames');
  20868. var thisSymbolValue = uncurryThis(Symbol.prototype.valueOf);
  20869. var WellKnownSymbolsStore = shared('wks');
  20870. for (var i = 0, symbolKeys = getOwnPropertyNames(Symbol), symbolKeysLength = symbolKeys.length; i < symbolKeysLength; i++) {
  20871. // some old engines throws on access to some keys like `arguments` or `caller`
  20872. try {
  20873. var symbolKey = symbolKeys[i];
  20874. if (isSymbol(Symbol[symbolKey])) wellKnownSymbol(symbolKey);
  20875. } catch (error) { /* empty */ }
  20876. }
  20877. // `Symbol.isWellKnown` method
  20878. // https://tc39.es/proposal-symbol-predicates/#sec-symbol-iswellknown
  20879. // We should patch it for newly added well-known symbols. If it's not required, this module just will not be injected
  20880. $({ target: 'Symbol', stat: true, forced: true }, {
  20881. isWellKnown: function isWellKnown(value) {
  20882. if ($isWellKnown && $isWellKnown(value)) return true;
  20883. try {
  20884. var symbol = thisSymbolValue(value);
  20885. for (var j = 0, keys = getOwnPropertyNames(WellKnownSymbolsStore), keysLength = keys.length; j < keysLength; j++) {
  20886. if (WellKnownSymbolsStore[keys[j]] == symbol) return true;
  20887. }
  20888. } catch (error) { /* empty */ }
  20889. return false;
  20890. }
  20891. });
  20892. },{"../internals/export":234,"../internals/function-uncurry-this":245,"../internals/get-built-in":246,"../internals/is-symbol":272,"../internals/shared":318,"../internals/well-known-symbol":343}],422:[function(_dereq_,module,exports){
  20893. var defineWellKnownSymbol = _dereq_('../internals/well-known-symbol-define');
  20894. // `Symbol.matcher` well-known symbol
  20895. // https://github.com/tc39/proposal-pattern-matching
  20896. defineWellKnownSymbol('matcher');
  20897. },{"../internals/well-known-symbol-define":341}],423:[function(_dereq_,module,exports){
  20898. var defineWellKnownSymbol = _dereq_('../internals/well-known-symbol-define');
  20899. // `Symbol.metadataKey` well-known symbol
  20900. // https://github.com/tc39/proposal-decorator-metadata
  20901. defineWellKnownSymbol('metadataKey');
  20902. },{"../internals/well-known-symbol-define":341}],424:[function(_dereq_,module,exports){
  20903. // TODO: Remove from `core-js@4`
  20904. var defineWellKnownSymbol = _dereq_('../internals/well-known-symbol-define');
  20905. // `Symbol.metadata` well-known symbol
  20906. // https://github.com/tc39/proposal-decorators
  20907. defineWellKnownSymbol('metadata');
  20908. },{"../internals/well-known-symbol-define":341}],425:[function(_dereq_,module,exports){
  20909. var defineWellKnownSymbol = _dereq_('../internals/well-known-symbol-define');
  20910. // `Symbol.observable` well-known symbol
  20911. // https://github.com/tc39/proposal-observable
  20912. defineWellKnownSymbol('observable');
  20913. },{"../internals/well-known-symbol-define":341}],426:[function(_dereq_,module,exports){
  20914. // TODO: remove from `core-js@4`
  20915. var defineWellKnownSymbol = _dereq_('../internals/well-known-symbol-define');
  20916. // `Symbol.patternMatch` well-known symbol
  20917. // https://github.com/tc39/proposal-pattern-matching
  20918. defineWellKnownSymbol('patternMatch');
  20919. },{"../internals/well-known-symbol-define":341}],427:[function(_dereq_,module,exports){
  20920. // TODO: remove from `core-js@4`
  20921. var defineWellKnownSymbol = _dereq_('../internals/well-known-symbol-define');
  20922. defineWellKnownSymbol('replaceAll');
  20923. },{"../internals/well-known-symbol-define":341}],428:[function(_dereq_,module,exports){
  20924. _dereq_('../modules/es.array.iterator');
  20925. var DOMIterables = _dereq_('../internals/dom-iterables');
  20926. var global = _dereq_('../internals/global');
  20927. var classof = _dereq_('../internals/classof');
  20928. var createNonEnumerableProperty = _dereq_('../internals/create-non-enumerable-property');
  20929. var Iterators = _dereq_('../internals/iterators');
  20930. var wellKnownSymbol = _dereq_('../internals/well-known-symbol');
  20931. var TO_STRING_TAG = wellKnownSymbol('toStringTag');
  20932. for (var COLLECTION_NAME in DOMIterables) {
  20933. var Collection = global[COLLECTION_NAME];
  20934. var CollectionPrototype = Collection && Collection.prototype;
  20935. if (CollectionPrototype && classof(CollectionPrototype) !== TO_STRING_TAG) {
  20936. createNonEnumerableProperty(CollectionPrototype, TO_STRING_TAG, COLLECTION_NAME);
  20937. }
  20938. Iterators[COLLECTION_NAME] = Iterators.Array;
  20939. }
  20940. },{"../internals/classof":196,"../internals/create-non-enumerable-property":204,"../internals/dom-iterables":216,"../internals/global":251,"../internals/iterators":278,"../internals/well-known-symbol":343,"../modules/es.array.iterator":357}],429:[function(_dereq_,module,exports){
  20941. var $ = _dereq_('../internals/export');
  20942. var global = _dereq_('../internals/global');
  20943. var schedulersFix = _dereq_('../internals/schedulers-fix');
  20944. var setInterval = schedulersFix(global.setInterval, true);
  20945. // Bun / IE9- setInterval additional parameters fix
  20946. // https://html.spec.whatwg.org/multipage/timers-and-user-prompts.html#dom-setinterval
  20947. $({ global: true, bind: true, forced: global.setInterval !== setInterval }, {
  20948. setInterval: setInterval
  20949. });
  20950. },{"../internals/export":234,"../internals/global":251,"../internals/schedulers-fix":313}],430:[function(_dereq_,module,exports){
  20951. var $ = _dereq_('../internals/export');
  20952. var global = _dereq_('../internals/global');
  20953. var schedulersFix = _dereq_('../internals/schedulers-fix');
  20954. var setTimeout = schedulersFix(global.setTimeout, true);
  20955. // Bun / IE9- setTimeout additional parameters fix
  20956. // https://html.spec.whatwg.org/multipage/timers-and-user-prompts.html#dom-settimeout
  20957. $({ global: true, bind: true, forced: global.setTimeout !== setTimeout }, {
  20958. setTimeout: setTimeout
  20959. });
  20960. },{"../internals/export":234,"../internals/global":251,"../internals/schedulers-fix":313}],431:[function(_dereq_,module,exports){
  20961. // TODO: Remove this module from `core-js@4` since it's split to modules listed below
  20962. _dereq_('../modules/web.set-interval');
  20963. _dereq_('../modules/web.set-timeout');
  20964. },{"../modules/web.set-interval":429,"../modules/web.set-timeout":430}],432:[function(_dereq_,module,exports){
  20965. var parent = _dereq_('../../es/array/from');
  20966. module.exports = parent;
  20967. },{"../../es/array/from":112}],433:[function(_dereq_,module,exports){
  20968. var parent = _dereq_('../../es/array/is-array');
  20969. module.exports = parent;
  20970. },{"../../es/array/is-array":113}],434:[function(_dereq_,module,exports){
  20971. var parent = _dereq_('../../../es/array/virtual/entries');
  20972. module.exports = parent;
  20973. },{"../../../es/array/virtual/entries":115}],435:[function(_dereq_,module,exports){
  20974. var parent = _dereq_('../../../es/array/virtual/for-each');
  20975. module.exports = parent;
  20976. },{"../../../es/array/virtual/for-each":120}],436:[function(_dereq_,module,exports){
  20977. var parent = _dereq_('../../../es/array/virtual/keys');
  20978. module.exports = parent;
  20979. },{"../../../es/array/virtual/keys":123}],437:[function(_dereq_,module,exports){
  20980. var parent = _dereq_('../../../es/array/virtual/values');
  20981. module.exports = parent;
  20982. },{"../../../es/array/virtual/values":129}],438:[function(_dereq_,module,exports){
  20983. var parent = _dereq_('../../es/instance/bind');
  20984. module.exports = parent;
  20985. },{"../../es/instance/bind":131}],439:[function(_dereq_,module,exports){
  20986. var parent = _dereq_('../../es/instance/concat');
  20987. module.exports = parent;
  20988. },{"../../es/instance/concat":132}],440:[function(_dereq_,module,exports){
  20989. _dereq_('../../modules/web.dom-collections.iterator');
  20990. var classof = _dereq_('../../internals/classof');
  20991. var hasOwn = _dereq_('../../internals/has-own-property');
  20992. var isPrototypeOf = _dereq_('../../internals/object-is-prototype-of');
  20993. var method = _dereq_('../array/virtual/entries');
  20994. var ArrayPrototype = Array.prototype;
  20995. var DOMIterables = {
  20996. DOMTokenList: true,
  20997. NodeList: true
  20998. };
  20999. module.exports = function (it) {
  21000. var own = it.entries;
  21001. return it === ArrayPrototype || (isPrototypeOf(ArrayPrototype, it) && own === ArrayPrototype.entries)
  21002. || hasOwn(DOMIterables, classof(it)) ? method : own;
  21003. };
  21004. },{"../../internals/classof":196,"../../internals/has-own-property":252,"../../internals/object-is-prototype-of":296,"../../modules/web.dom-collections.iterator":428,"../array/virtual/entries":434}],441:[function(_dereq_,module,exports){
  21005. var parent = _dereq_('../../es/instance/every');
  21006. module.exports = parent;
  21007. },{"../../es/instance/every":133}],442:[function(_dereq_,module,exports){
  21008. var parent = _dereq_('../../es/instance/filter');
  21009. module.exports = parent;
  21010. },{"../../es/instance/filter":134}],443:[function(_dereq_,module,exports){
  21011. var parent = _dereq_('../../es/instance/find-index');
  21012. module.exports = parent;
  21013. },{"../../es/instance/find-index":135}],444:[function(_dereq_,module,exports){
  21014. var parent = _dereq_('../../es/instance/find');
  21015. module.exports = parent;
  21016. },{"../../es/instance/find":136}],445:[function(_dereq_,module,exports){
  21017. _dereq_('../../modules/web.dom-collections.iterator');
  21018. var classof = _dereq_('../../internals/classof');
  21019. var hasOwn = _dereq_('../../internals/has-own-property');
  21020. var isPrototypeOf = _dereq_('../../internals/object-is-prototype-of');
  21021. var method = _dereq_('../array/virtual/for-each');
  21022. var ArrayPrototype = Array.prototype;
  21023. var DOMIterables = {
  21024. DOMTokenList: true,
  21025. NodeList: true
  21026. };
  21027. module.exports = function (it) {
  21028. var own = it.forEach;
  21029. return it === ArrayPrototype || (isPrototypeOf(ArrayPrototype, it) && own === ArrayPrototype.forEach)
  21030. || hasOwn(DOMIterables, classof(it)) ? method : own;
  21031. };
  21032. },{"../../internals/classof":196,"../../internals/has-own-property":252,"../../internals/object-is-prototype-of":296,"../../modules/web.dom-collections.iterator":428,"../array/virtual/for-each":435}],446:[function(_dereq_,module,exports){
  21033. var parent = _dereq_('../../es/instance/includes');
  21034. module.exports = parent;
  21035. },{"../../es/instance/includes":137}],447:[function(_dereq_,module,exports){
  21036. var parent = _dereq_('../../es/instance/index-of');
  21037. module.exports = parent;
  21038. },{"../../es/instance/index-of":138}],448:[function(_dereq_,module,exports){
  21039. _dereq_('../../modules/web.dom-collections.iterator');
  21040. var classof = _dereq_('../../internals/classof');
  21041. var hasOwn = _dereq_('../../internals/has-own-property');
  21042. var isPrototypeOf = _dereq_('../../internals/object-is-prototype-of');
  21043. var method = _dereq_('../array/virtual/keys');
  21044. var ArrayPrototype = Array.prototype;
  21045. var DOMIterables = {
  21046. DOMTokenList: true,
  21047. NodeList: true
  21048. };
  21049. module.exports = function (it) {
  21050. var own = it.keys;
  21051. return it === ArrayPrototype || (isPrototypeOf(ArrayPrototype, it) && own === ArrayPrototype.keys)
  21052. || hasOwn(DOMIterables, classof(it)) ? method : own;
  21053. };
  21054. },{"../../internals/classof":196,"../../internals/has-own-property":252,"../../internals/object-is-prototype-of":296,"../../modules/web.dom-collections.iterator":428,"../array/virtual/keys":436}],449:[function(_dereq_,module,exports){
  21055. var parent = _dereq_('../../es/instance/map');
  21056. module.exports = parent;
  21057. },{"../../es/instance/map":139}],450:[function(_dereq_,module,exports){
  21058. var parent = _dereq_('../../es/instance/reduce');
  21059. module.exports = parent;
  21060. },{"../../es/instance/reduce":140}],451:[function(_dereq_,module,exports){
  21061. var parent = _dereq_('../../es/instance/slice');
  21062. module.exports = parent;
  21063. },{"../../es/instance/slice":141}],452:[function(_dereq_,module,exports){
  21064. var parent = _dereq_('../../es/instance/sort');
  21065. module.exports = parent;
  21066. },{"../../es/instance/sort":142}],453:[function(_dereq_,module,exports){
  21067. var parent = _dereq_('../../es/instance/splice');
  21068. module.exports = parent;
  21069. },{"../../es/instance/splice":143}],454:[function(_dereq_,module,exports){
  21070. var parent = _dereq_('../../es/instance/starts-with');
  21071. module.exports = parent;
  21072. },{"../../es/instance/starts-with":144}],455:[function(_dereq_,module,exports){
  21073. _dereq_('../../modules/web.dom-collections.iterator');
  21074. var classof = _dereq_('../../internals/classof');
  21075. var hasOwn = _dereq_('../../internals/has-own-property');
  21076. var isPrototypeOf = _dereq_('../../internals/object-is-prototype-of');
  21077. var method = _dereq_('../array/virtual/values');
  21078. var ArrayPrototype = Array.prototype;
  21079. var DOMIterables = {
  21080. DOMTokenList: true,
  21081. NodeList: true
  21082. };
  21083. module.exports = function (it) {
  21084. var own = it.values;
  21085. return it === ArrayPrototype || (isPrototypeOf(ArrayPrototype, it) && own === ArrayPrototype.values)
  21086. || hasOwn(DOMIterables, classof(it)) ? method : own;
  21087. };
  21088. },{"../../internals/classof":196,"../../internals/has-own-property":252,"../../internals/object-is-prototype-of":296,"../../modules/web.dom-collections.iterator":428,"../array/virtual/values":437}],456:[function(_dereq_,module,exports){
  21089. var parent = _dereq_('../../es/json/stringify');
  21090. module.exports = parent;
  21091. },{"../../es/json/stringify":145}],457:[function(_dereq_,module,exports){
  21092. var parent = _dereq_('../../es/map');
  21093. _dereq_('../../modules/web.dom-collections.iterator');
  21094. module.exports = parent;
  21095. },{"../../es/map":146,"../../modules/web.dom-collections.iterator":428}],458:[function(_dereq_,module,exports){
  21096. var parent = _dereq_('../../es/number/is-integer');
  21097. module.exports = parent;
  21098. },{"../../es/number/is-integer":147}],459:[function(_dereq_,module,exports){
  21099. var parent = _dereq_('../../es/object/assign');
  21100. module.exports = parent;
  21101. },{"../../es/object/assign":148}],460:[function(_dereq_,module,exports){
  21102. var parent = _dereq_('../../es/object/create');
  21103. module.exports = parent;
  21104. },{"../../es/object/create":149}],461:[function(_dereq_,module,exports){
  21105. var parent = _dereq_('../../es/object/define-property');
  21106. module.exports = parent;
  21107. },{"../../es/object/define-property":150}],462:[function(_dereq_,module,exports){
  21108. var parent = _dereq_('../../es/object/entries');
  21109. module.exports = parent;
  21110. },{"../../es/object/entries":151}],463:[function(_dereq_,module,exports){
  21111. var parent = _dereq_('../../es/object/freeze');
  21112. module.exports = parent;
  21113. },{"../../es/object/freeze":152}],464:[function(_dereq_,module,exports){
  21114. var parent = _dereq_('../../es/object/get-own-property-descriptor');
  21115. module.exports = parent;
  21116. },{"../../es/object/get-own-property-descriptor":153}],465:[function(_dereq_,module,exports){
  21117. var parent = _dereq_('../../es/object/get-prototype-of');
  21118. module.exports = parent;
  21119. },{"../../es/object/get-prototype-of":154}],466:[function(_dereq_,module,exports){
  21120. var parent = _dereq_('../../es/object/keys');
  21121. module.exports = parent;
  21122. },{"../../es/object/keys":155}],467:[function(_dereq_,module,exports){
  21123. var parent = _dereq_('../es/parse-int');
  21124. module.exports = parent;
  21125. },{"../es/parse-int":156}],468:[function(_dereq_,module,exports){
  21126. var parent = _dereq_('../../es/promise');
  21127. _dereq_('../../modules/web.dom-collections.iterator');
  21128. module.exports = parent;
  21129. },{"../../es/promise":157,"../../modules/web.dom-collections.iterator":428}],469:[function(_dereq_,module,exports){
  21130. _dereq_('../modules/web.timers');
  21131. var path = _dereq_('../internals/path');
  21132. module.exports = path.setInterval;
  21133. },{"../internals/path":305,"../modules/web.timers":431}],470:[function(_dereq_,module,exports){
  21134. _dereq_('../modules/web.timers');
  21135. var path = _dereq_('../internals/path');
  21136. module.exports = path.setTimeout;
  21137. },{"../internals/path":305,"../modules/web.timers":431}],471:[function(_dereq_,module,exports){
  21138. var parent = _dereq_('../../es/set');
  21139. _dereq_('../../modules/web.dom-collections.iterator');
  21140. module.exports = parent;
  21141. },{"../../es/set":158,"../../modules/web.dom-collections.iterator":428}],472:[function(_dereq_,module,exports){
  21142. var parent = _dereq_('../../es/symbol');
  21143. _dereq_('../../modules/web.dom-collections.iterator');
  21144. module.exports = parent;
  21145. },{"../../es/symbol":161,"../../modules/web.dom-collections.iterator":428}],473:[function(_dereq_,module,exports){
  21146. var parent = _dereq_('../../es/symbol/iterator');
  21147. _dereq_('../../modules/web.dom-collections.iterator');
  21148. module.exports = parent;
  21149. },{"../../es/symbol/iterator":162,"../../modules/web.dom-collections.iterator":428}],474:[function(_dereq_,module,exports){
  21150. var parent = _dereq_('../../es/symbol/to-primitive');
  21151. module.exports = parent;
  21152. },{"../../es/symbol/to-primitive":163}],475:[function(_dereq_,module,exports){
  21153. var parent = _dereq_('../../es/weak-map');
  21154. _dereq_('../../modules/web.dom-collections.iterator');
  21155. module.exports = parent;
  21156. },{"../../es/weak-map":164,"../../modules/web.dom-collections.iterator":428}],476:[function(_dereq_,module,exports){
  21157. ;(function (root, factory, undef) {
  21158. if (typeof exports === "object") {
  21159. // CommonJS
  21160. module.exports = exports = factory(_dereq_("./core"), _dereq_("./enc-base64"), _dereq_("./md5"), _dereq_("./evpkdf"), _dereq_("./cipher-core"));
  21161. }
  21162. else if (typeof define === "function" && define.amd) {
  21163. // AMD
  21164. define(["./core", "./enc-base64", "./md5", "./evpkdf", "./cipher-core"], factory);
  21165. }
  21166. else {
  21167. // Global (browser)
  21168. factory(root.CryptoJS);
  21169. }
  21170. }(this, function (CryptoJS) {
  21171. (function () {
  21172. // Shortcuts
  21173. var C = CryptoJS;
  21174. var C_lib = C.lib;
  21175. var BlockCipher = C_lib.BlockCipher;
  21176. var C_algo = C.algo;
  21177. // Lookup tables
  21178. var SBOX = [];
  21179. var INV_SBOX = [];
  21180. var SUB_MIX_0 = [];
  21181. var SUB_MIX_1 = [];
  21182. var SUB_MIX_2 = [];
  21183. var SUB_MIX_3 = [];
  21184. var INV_SUB_MIX_0 = [];
  21185. var INV_SUB_MIX_1 = [];
  21186. var INV_SUB_MIX_2 = [];
  21187. var INV_SUB_MIX_3 = [];
  21188. // Compute lookup tables
  21189. (function () {
  21190. // Compute double table
  21191. var d = [];
  21192. for (var i = 0; i < 256; i++) {
  21193. if (i < 128) {
  21194. d[i] = i << 1;
  21195. } else {
  21196. d[i] = (i << 1) ^ 0x11b;
  21197. }
  21198. }
  21199. // Walk GF(2^8)
  21200. var x = 0;
  21201. var xi = 0;
  21202. for (var i = 0; i < 256; i++) {
  21203. // Compute sbox
  21204. var sx = xi ^ (xi << 1) ^ (xi << 2) ^ (xi << 3) ^ (xi << 4);
  21205. sx = (sx >>> 8) ^ (sx & 0xff) ^ 0x63;
  21206. SBOX[x] = sx;
  21207. INV_SBOX[sx] = x;
  21208. // Compute multiplication
  21209. var x2 = d[x];
  21210. var x4 = d[x2];
  21211. var x8 = d[x4];
  21212. // Compute sub bytes, mix columns tables
  21213. var t = (d[sx] * 0x101) ^ (sx * 0x1010100);
  21214. SUB_MIX_0[x] = (t << 24) | (t >>> 8);
  21215. SUB_MIX_1[x] = (t << 16) | (t >>> 16);
  21216. SUB_MIX_2[x] = (t << 8) | (t >>> 24);
  21217. SUB_MIX_3[x] = t;
  21218. // Compute inv sub bytes, inv mix columns tables
  21219. var t = (x8 * 0x1010101) ^ (x4 * 0x10001) ^ (x2 * 0x101) ^ (x * 0x1010100);
  21220. INV_SUB_MIX_0[sx] = (t << 24) | (t >>> 8);
  21221. INV_SUB_MIX_1[sx] = (t << 16) | (t >>> 16);
  21222. INV_SUB_MIX_2[sx] = (t << 8) | (t >>> 24);
  21223. INV_SUB_MIX_3[sx] = t;
  21224. // Compute next counter
  21225. if (!x) {
  21226. x = xi = 1;
  21227. } else {
  21228. x = x2 ^ d[d[d[x8 ^ x2]]];
  21229. xi ^= d[d[xi]];
  21230. }
  21231. }
  21232. }());
  21233. // Precomputed Rcon lookup
  21234. var RCON = [0x00, 0x01, 0x02, 0x04, 0x08, 0x10, 0x20, 0x40, 0x80, 0x1b, 0x36];
  21235. /**
  21236. * AES block cipher algorithm.
  21237. */
  21238. var AES = C_algo.AES = BlockCipher.extend({
  21239. _doReset: function () {
  21240. var t;
  21241. // Skip reset of nRounds has been set before and key did not change
  21242. if (this._nRounds && this._keyPriorReset === this._key) {
  21243. return;
  21244. }
  21245. // Shortcuts
  21246. var key = this._keyPriorReset = this._key;
  21247. var keyWords = key.words;
  21248. var keySize = key.sigBytes / 4;
  21249. // Compute number of rounds
  21250. var nRounds = this._nRounds = keySize + 6;
  21251. // Compute number of key schedule rows
  21252. var ksRows = (nRounds + 1) * 4;
  21253. // Compute key schedule
  21254. var keySchedule = this._keySchedule = [];
  21255. for (var ksRow = 0; ksRow < ksRows; ksRow++) {
  21256. if (ksRow < keySize) {
  21257. keySchedule[ksRow] = keyWords[ksRow];
  21258. } else {
  21259. t = keySchedule[ksRow - 1];
  21260. if (!(ksRow % keySize)) {
  21261. // Rot word
  21262. t = (t << 8) | (t >>> 24);
  21263. // Sub word
  21264. t = (SBOX[t >>> 24] << 24) | (SBOX[(t >>> 16) & 0xff] << 16) | (SBOX[(t >>> 8) & 0xff] << 8) | SBOX[t & 0xff];
  21265. // Mix Rcon
  21266. t ^= RCON[(ksRow / keySize) | 0] << 24;
  21267. } else if (keySize > 6 && ksRow % keySize == 4) {
  21268. // Sub word
  21269. t = (SBOX[t >>> 24] << 24) | (SBOX[(t >>> 16) & 0xff] << 16) | (SBOX[(t >>> 8) & 0xff] << 8) | SBOX[t & 0xff];
  21270. }
  21271. keySchedule[ksRow] = keySchedule[ksRow - keySize] ^ t;
  21272. }
  21273. }
  21274. // Compute inv key schedule
  21275. var invKeySchedule = this._invKeySchedule = [];
  21276. for (var invKsRow = 0; invKsRow < ksRows; invKsRow++) {
  21277. var ksRow = ksRows - invKsRow;
  21278. if (invKsRow % 4) {
  21279. var t = keySchedule[ksRow];
  21280. } else {
  21281. var t = keySchedule[ksRow - 4];
  21282. }
  21283. if (invKsRow < 4 || ksRow <= 4) {
  21284. invKeySchedule[invKsRow] = t;
  21285. } else {
  21286. invKeySchedule[invKsRow] = INV_SUB_MIX_0[SBOX[t >>> 24]] ^ INV_SUB_MIX_1[SBOX[(t >>> 16) & 0xff]] ^
  21287. INV_SUB_MIX_2[SBOX[(t >>> 8) & 0xff]] ^ INV_SUB_MIX_3[SBOX[t & 0xff]];
  21288. }
  21289. }
  21290. },
  21291. encryptBlock: function (M, offset) {
  21292. this._doCryptBlock(M, offset, this._keySchedule, SUB_MIX_0, SUB_MIX_1, SUB_MIX_2, SUB_MIX_3, SBOX);
  21293. },
  21294. decryptBlock: function (M, offset) {
  21295. // Swap 2nd and 4th rows
  21296. var t = M[offset + 1];
  21297. M[offset + 1] = M[offset + 3];
  21298. M[offset + 3] = t;
  21299. this._doCryptBlock(M, offset, this._invKeySchedule, INV_SUB_MIX_0, INV_SUB_MIX_1, INV_SUB_MIX_2, INV_SUB_MIX_3, INV_SBOX);
  21300. // Inv swap 2nd and 4th rows
  21301. var t = M[offset + 1];
  21302. M[offset + 1] = M[offset + 3];
  21303. M[offset + 3] = t;
  21304. },
  21305. _doCryptBlock: function (M, offset, keySchedule, SUB_MIX_0, SUB_MIX_1, SUB_MIX_2, SUB_MIX_3, SBOX) {
  21306. // Shortcut
  21307. var nRounds = this._nRounds;
  21308. // Get input, add round key
  21309. var s0 = M[offset] ^ keySchedule[0];
  21310. var s1 = M[offset + 1] ^ keySchedule[1];
  21311. var s2 = M[offset + 2] ^ keySchedule[2];
  21312. var s3 = M[offset + 3] ^ keySchedule[3];
  21313. // Key schedule row counter
  21314. var ksRow = 4;
  21315. // Rounds
  21316. for (var round = 1; round < nRounds; round++) {
  21317. // Shift rows, sub bytes, mix columns, add round key
  21318. 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++];
  21319. 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++];
  21320. 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++];
  21321. 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++];
  21322. // Update state
  21323. s0 = t0;
  21324. s1 = t1;
  21325. s2 = t2;
  21326. s3 = t3;
  21327. }
  21328. // Shift rows, sub bytes, add round key
  21329. var t0 = ((SBOX[s0 >>> 24] << 24) | (SBOX[(s1 >>> 16) & 0xff] << 16) | (SBOX[(s2 >>> 8) & 0xff] << 8) | SBOX[s3 & 0xff]) ^ keySchedule[ksRow++];
  21330. var t1 = ((SBOX[s1 >>> 24] << 24) | (SBOX[(s2 >>> 16) & 0xff] << 16) | (SBOX[(s3 >>> 8) & 0xff] << 8) | SBOX[s0 & 0xff]) ^ keySchedule[ksRow++];
  21331. var t2 = ((SBOX[s2 >>> 24] << 24) | (SBOX[(s3 >>> 16) & 0xff] << 16) | (SBOX[(s0 >>> 8) & 0xff] << 8) | SBOX[s1 & 0xff]) ^ keySchedule[ksRow++];
  21332. var t3 = ((SBOX[s3 >>> 24] << 24) | (SBOX[(s0 >>> 16) & 0xff] << 16) | (SBOX[(s1 >>> 8) & 0xff] << 8) | SBOX[s2 & 0xff]) ^ keySchedule[ksRow++];
  21333. // Set output
  21334. M[offset] = t0;
  21335. M[offset + 1] = t1;
  21336. M[offset + 2] = t2;
  21337. M[offset + 3] = t3;
  21338. },
  21339. keySize: 256/32
  21340. });
  21341. /**
  21342. * Shortcut functions to the cipher's object interface.
  21343. *
  21344. * @example
  21345. *
  21346. * var ciphertext = CryptoJS.AES.encrypt(message, key, cfg);
  21347. * var plaintext = CryptoJS.AES.decrypt(ciphertext, key, cfg);
  21348. */
  21349. C.AES = BlockCipher._createHelper(AES);
  21350. }());
  21351. return CryptoJS.AES;
  21352. }));
  21353. },{"./cipher-core":477,"./core":478,"./enc-base64":479,"./evpkdf":481,"./md5":483}],477:[function(_dereq_,module,exports){
  21354. ;(function (root, factory, undef) {
  21355. if (typeof exports === "object") {
  21356. // CommonJS
  21357. module.exports = exports = factory(_dereq_("./core"), _dereq_("./evpkdf"));
  21358. }
  21359. else if (typeof define === "function" && define.amd) {
  21360. // AMD
  21361. define(["./core", "./evpkdf"], factory);
  21362. }
  21363. else {
  21364. // Global (browser)
  21365. factory(root.CryptoJS);
  21366. }
  21367. }(this, function (CryptoJS) {
  21368. /**
  21369. * Cipher core components.
  21370. */
  21371. CryptoJS.lib.Cipher || (function (undefined) {
  21372. // Shortcuts
  21373. var C = CryptoJS;
  21374. var C_lib = C.lib;
  21375. var Base = C_lib.Base;
  21376. var WordArray = C_lib.WordArray;
  21377. var BufferedBlockAlgorithm = C_lib.BufferedBlockAlgorithm;
  21378. var C_enc = C.enc;
  21379. var Utf8 = C_enc.Utf8;
  21380. var Base64 = C_enc.Base64;
  21381. var C_algo = C.algo;
  21382. var EvpKDF = C_algo.EvpKDF;
  21383. /**
  21384. * Abstract base cipher template.
  21385. *
  21386. * @property {number} keySize This cipher's key size. Default: 4 (128 bits)
  21387. * @property {number} ivSize This cipher's IV size. Default: 4 (128 bits)
  21388. * @property {number} _ENC_XFORM_MODE A constant representing encryption mode.
  21389. * @property {number} _DEC_XFORM_MODE A constant representing decryption mode.
  21390. */
  21391. var Cipher = C_lib.Cipher = BufferedBlockAlgorithm.extend({
  21392. /**
  21393. * Configuration options.
  21394. *
  21395. * @property {WordArray} iv The IV to use for this operation.
  21396. */
  21397. cfg: Base.extend(),
  21398. /**
  21399. * Creates this cipher in encryption mode.
  21400. *
  21401. * @param {WordArray} key The key.
  21402. * @param {Object} cfg (Optional) The configuration options to use for this operation.
  21403. *
  21404. * @return {Cipher} A cipher instance.
  21405. *
  21406. * @static
  21407. *
  21408. * @example
  21409. *
  21410. * var cipher = CryptoJS.algo.AES.createEncryptor(keyWordArray, { iv: ivWordArray });
  21411. */
  21412. createEncryptor: function (key, cfg) {
  21413. return this.create(this._ENC_XFORM_MODE, key, cfg);
  21414. },
  21415. /**
  21416. * Creates this cipher in decryption mode.
  21417. *
  21418. * @param {WordArray} key The key.
  21419. * @param {Object} cfg (Optional) The configuration options to use for this operation.
  21420. *
  21421. * @return {Cipher} A cipher instance.
  21422. *
  21423. * @static
  21424. *
  21425. * @example
  21426. *
  21427. * var cipher = CryptoJS.algo.AES.createDecryptor(keyWordArray, { iv: ivWordArray });
  21428. */
  21429. createDecryptor: function (key, cfg) {
  21430. return this.create(this._DEC_XFORM_MODE, key, cfg);
  21431. },
  21432. /**
  21433. * Initializes a newly created cipher.
  21434. *
  21435. * @param {number} xformMode Either the encryption or decryption transormation mode constant.
  21436. * @param {WordArray} key The key.
  21437. * @param {Object} cfg (Optional) The configuration options to use for this operation.
  21438. *
  21439. * @example
  21440. *
  21441. * var cipher = CryptoJS.algo.AES.create(CryptoJS.algo.AES._ENC_XFORM_MODE, keyWordArray, { iv: ivWordArray });
  21442. */
  21443. init: function (xformMode, key, cfg) {
  21444. // Apply config defaults
  21445. this.cfg = this.cfg.extend(cfg);
  21446. // Store transform mode and key
  21447. this._xformMode = xformMode;
  21448. this._key = key;
  21449. // Set initial values
  21450. this.reset();
  21451. },
  21452. /**
  21453. * Resets this cipher to its initial state.
  21454. *
  21455. * @example
  21456. *
  21457. * cipher.reset();
  21458. */
  21459. reset: function () {
  21460. // Reset data buffer
  21461. BufferedBlockAlgorithm.reset.call(this);
  21462. // Perform concrete-cipher logic
  21463. this._doReset();
  21464. },
  21465. /**
  21466. * Adds data to be encrypted or decrypted.
  21467. *
  21468. * @param {WordArray|string} dataUpdate The data to encrypt or decrypt.
  21469. *
  21470. * @return {WordArray} The data after processing.
  21471. *
  21472. * @example
  21473. *
  21474. * var encrypted = cipher.process('data');
  21475. * var encrypted = cipher.process(wordArray);
  21476. */
  21477. process: function (dataUpdate) {
  21478. // Append
  21479. this._append(dataUpdate);
  21480. // Process available blocks
  21481. return this._process();
  21482. },
  21483. /**
  21484. * Finalizes the encryption or decryption process.
  21485. * Note that the finalize operation is effectively a destructive, read-once operation.
  21486. *
  21487. * @param {WordArray|string} dataUpdate The final data to encrypt or decrypt.
  21488. *
  21489. * @return {WordArray} The data after final processing.
  21490. *
  21491. * @example
  21492. *
  21493. * var encrypted = cipher.finalize();
  21494. * var encrypted = cipher.finalize('data');
  21495. * var encrypted = cipher.finalize(wordArray);
  21496. */
  21497. finalize: function (dataUpdate) {
  21498. // Final data update
  21499. if (dataUpdate) {
  21500. this._append(dataUpdate);
  21501. }
  21502. // Perform concrete-cipher logic
  21503. var finalProcessedData = this._doFinalize();
  21504. return finalProcessedData;
  21505. },
  21506. keySize: 128/32,
  21507. ivSize: 128/32,
  21508. _ENC_XFORM_MODE: 1,
  21509. _DEC_XFORM_MODE: 2,
  21510. /**
  21511. * Creates shortcut functions to a cipher's object interface.
  21512. *
  21513. * @param {Cipher} cipher The cipher to create a helper for.
  21514. *
  21515. * @return {Object} An object with encrypt and decrypt shortcut functions.
  21516. *
  21517. * @static
  21518. *
  21519. * @example
  21520. *
  21521. * var AES = CryptoJS.lib.Cipher._createHelper(CryptoJS.algo.AES);
  21522. */
  21523. _createHelper: (function () {
  21524. function selectCipherStrategy(key) {
  21525. if (typeof key == 'string') {
  21526. return PasswordBasedCipher;
  21527. } else {
  21528. return SerializableCipher;
  21529. }
  21530. }
  21531. return function (cipher) {
  21532. return {
  21533. encrypt: function (message, key, cfg) {
  21534. return selectCipherStrategy(key).encrypt(cipher, message, key, cfg);
  21535. },
  21536. decrypt: function (ciphertext, key, cfg) {
  21537. return selectCipherStrategy(key).decrypt(cipher, ciphertext, key, cfg);
  21538. }
  21539. };
  21540. };
  21541. }())
  21542. });
  21543. /**
  21544. * Abstract base stream cipher template.
  21545. *
  21546. * @property {number} blockSize The number of 32-bit words this cipher operates on. Default: 1 (32 bits)
  21547. */
  21548. var StreamCipher = C_lib.StreamCipher = Cipher.extend({
  21549. _doFinalize: function () {
  21550. // Process partial blocks
  21551. var finalProcessedBlocks = this._process(!!'flush');
  21552. return finalProcessedBlocks;
  21553. },
  21554. blockSize: 1
  21555. });
  21556. /**
  21557. * Mode namespace.
  21558. */
  21559. var C_mode = C.mode = {};
  21560. /**
  21561. * Abstract base block cipher mode template.
  21562. */
  21563. var BlockCipherMode = C_lib.BlockCipherMode = Base.extend({
  21564. /**
  21565. * Creates this mode for encryption.
  21566. *
  21567. * @param {Cipher} cipher A block cipher instance.
  21568. * @param {Array} iv The IV words.
  21569. *
  21570. * @static
  21571. *
  21572. * @example
  21573. *
  21574. * var mode = CryptoJS.mode.CBC.createEncryptor(cipher, iv.words);
  21575. */
  21576. createEncryptor: function (cipher, iv) {
  21577. return this.Encryptor.create(cipher, iv);
  21578. },
  21579. /**
  21580. * Creates this mode for decryption.
  21581. *
  21582. * @param {Cipher} cipher A block cipher instance.
  21583. * @param {Array} iv The IV words.
  21584. *
  21585. * @static
  21586. *
  21587. * @example
  21588. *
  21589. * var mode = CryptoJS.mode.CBC.createDecryptor(cipher, iv.words);
  21590. */
  21591. createDecryptor: function (cipher, iv) {
  21592. return this.Decryptor.create(cipher, iv);
  21593. },
  21594. /**
  21595. * Initializes a newly created mode.
  21596. *
  21597. * @param {Cipher} cipher A block cipher instance.
  21598. * @param {Array} iv The IV words.
  21599. *
  21600. * @example
  21601. *
  21602. * var mode = CryptoJS.mode.CBC.Encryptor.create(cipher, iv.words);
  21603. */
  21604. init: function (cipher, iv) {
  21605. this._cipher = cipher;
  21606. this._iv = iv;
  21607. }
  21608. });
  21609. /**
  21610. * Cipher Block Chaining mode.
  21611. */
  21612. var CBC = C_mode.CBC = (function () {
  21613. /**
  21614. * Abstract base CBC mode.
  21615. */
  21616. var CBC = BlockCipherMode.extend();
  21617. /**
  21618. * CBC encryptor.
  21619. */
  21620. CBC.Encryptor = CBC.extend({
  21621. /**
  21622. * Processes the data block at offset.
  21623. *
  21624. * @param {Array} words The data words to operate on.
  21625. * @param {number} offset The offset where the block starts.
  21626. *
  21627. * @example
  21628. *
  21629. * mode.processBlock(data.words, offset);
  21630. */
  21631. processBlock: function (words, offset) {
  21632. // Shortcuts
  21633. var cipher = this._cipher;
  21634. var blockSize = cipher.blockSize;
  21635. // XOR and encrypt
  21636. xorBlock.call(this, words, offset, blockSize);
  21637. cipher.encryptBlock(words, offset);
  21638. // Remember this block to use with next block
  21639. this._prevBlock = words.slice(offset, offset + blockSize);
  21640. }
  21641. });
  21642. /**
  21643. * CBC decryptor.
  21644. */
  21645. CBC.Decryptor = CBC.extend({
  21646. /**
  21647. * Processes the data block at offset.
  21648. *
  21649. * @param {Array} words The data words to operate on.
  21650. * @param {number} offset The offset where the block starts.
  21651. *
  21652. * @example
  21653. *
  21654. * mode.processBlock(data.words, offset);
  21655. */
  21656. processBlock: function (words, offset) {
  21657. // Shortcuts
  21658. var cipher = this._cipher;
  21659. var blockSize = cipher.blockSize;
  21660. // Remember this block to use with next block
  21661. var thisBlock = words.slice(offset, offset + blockSize);
  21662. // Decrypt and XOR
  21663. cipher.decryptBlock(words, offset);
  21664. xorBlock.call(this, words, offset, blockSize);
  21665. // This block becomes the previous block
  21666. this._prevBlock = thisBlock;
  21667. }
  21668. });
  21669. function xorBlock(words, offset, blockSize) {
  21670. var block;
  21671. // Shortcut
  21672. var iv = this._iv;
  21673. // Choose mixing block
  21674. if (iv) {
  21675. block = iv;
  21676. // Remove IV for subsequent blocks
  21677. this._iv = undefined;
  21678. } else {
  21679. block = this._prevBlock;
  21680. }
  21681. // XOR blocks
  21682. for (var i = 0; i < blockSize; i++) {
  21683. words[offset + i] ^= block[i];
  21684. }
  21685. }
  21686. return CBC;
  21687. }());
  21688. /**
  21689. * Padding namespace.
  21690. */
  21691. var C_pad = C.pad = {};
  21692. /**
  21693. * PKCS #5/7 padding strategy.
  21694. */
  21695. var Pkcs7 = C_pad.Pkcs7 = {
  21696. /**
  21697. * Pads data using the algorithm defined in PKCS #5/7.
  21698. *
  21699. * @param {WordArray} data The data to pad.
  21700. * @param {number} blockSize The multiple that the data should be padded to.
  21701. *
  21702. * @static
  21703. *
  21704. * @example
  21705. *
  21706. * CryptoJS.pad.Pkcs7.pad(wordArray, 4);
  21707. */
  21708. pad: function (data, blockSize) {
  21709. // Shortcut
  21710. var blockSizeBytes = blockSize * 4;
  21711. // Count padding bytes
  21712. var nPaddingBytes = blockSizeBytes - data.sigBytes % blockSizeBytes;
  21713. // Create padding word
  21714. var paddingWord = (nPaddingBytes << 24) | (nPaddingBytes << 16) | (nPaddingBytes << 8) | nPaddingBytes;
  21715. // Create padding
  21716. var paddingWords = [];
  21717. for (var i = 0; i < nPaddingBytes; i += 4) {
  21718. paddingWords.push(paddingWord);
  21719. }
  21720. var padding = WordArray.create(paddingWords, nPaddingBytes);
  21721. // Add padding
  21722. data.concat(padding);
  21723. },
  21724. /**
  21725. * Unpads data that had been padded using the algorithm defined in PKCS #5/7.
  21726. *
  21727. * @param {WordArray} data The data to unpad.
  21728. *
  21729. * @static
  21730. *
  21731. * @example
  21732. *
  21733. * CryptoJS.pad.Pkcs7.unpad(wordArray);
  21734. */
  21735. unpad: function (data) {
  21736. // Get number of padding bytes from last byte
  21737. var nPaddingBytes = data.words[(data.sigBytes - 1) >>> 2] & 0xff;
  21738. // Remove padding
  21739. data.sigBytes -= nPaddingBytes;
  21740. }
  21741. };
  21742. /**
  21743. * Abstract base block cipher template.
  21744. *
  21745. * @property {number} blockSize The number of 32-bit words this cipher operates on. Default: 4 (128 bits)
  21746. */
  21747. var BlockCipher = C_lib.BlockCipher = Cipher.extend({
  21748. /**
  21749. * Configuration options.
  21750. *
  21751. * @property {Mode} mode The block mode to use. Default: CBC
  21752. * @property {Padding} padding The padding strategy to use. Default: Pkcs7
  21753. */
  21754. cfg: Cipher.cfg.extend({
  21755. mode: CBC,
  21756. padding: Pkcs7
  21757. }),
  21758. reset: function () {
  21759. var modeCreator;
  21760. // Reset cipher
  21761. Cipher.reset.call(this);
  21762. // Shortcuts
  21763. var cfg = this.cfg;
  21764. var iv = cfg.iv;
  21765. var mode = cfg.mode;
  21766. // Reset block mode
  21767. if (this._xformMode == this._ENC_XFORM_MODE) {
  21768. modeCreator = mode.createEncryptor;
  21769. } else /* if (this._xformMode == this._DEC_XFORM_MODE) */ {
  21770. modeCreator = mode.createDecryptor;
  21771. // Keep at least one block in the buffer for unpadding
  21772. this._minBufferSize = 1;
  21773. }
  21774. if (this._mode && this._mode.__creator == modeCreator) {
  21775. this._mode.init(this, iv && iv.words);
  21776. } else {
  21777. this._mode = modeCreator.call(mode, this, iv && iv.words);
  21778. this._mode.__creator = modeCreator;
  21779. }
  21780. },
  21781. _doProcessBlock: function (words, offset) {
  21782. this._mode.processBlock(words, offset);
  21783. },
  21784. _doFinalize: function () {
  21785. var finalProcessedBlocks;
  21786. // Shortcut
  21787. var padding = this.cfg.padding;
  21788. // Finalize
  21789. if (this._xformMode == this._ENC_XFORM_MODE) {
  21790. // Pad data
  21791. padding.pad(this._data, this.blockSize);
  21792. // Process final blocks
  21793. finalProcessedBlocks = this._process(!!'flush');
  21794. } else /* if (this._xformMode == this._DEC_XFORM_MODE) */ {
  21795. // Process final blocks
  21796. finalProcessedBlocks = this._process(!!'flush');
  21797. // Unpad data
  21798. padding.unpad(finalProcessedBlocks);
  21799. }
  21800. return finalProcessedBlocks;
  21801. },
  21802. blockSize: 128/32
  21803. });
  21804. /**
  21805. * A collection of cipher parameters.
  21806. *
  21807. * @property {WordArray} ciphertext The raw ciphertext.
  21808. * @property {WordArray} key The key to this ciphertext.
  21809. * @property {WordArray} iv The IV used in the ciphering operation.
  21810. * @property {WordArray} salt The salt used with a key derivation function.
  21811. * @property {Cipher} algorithm The cipher algorithm.
  21812. * @property {Mode} mode The block mode used in the ciphering operation.
  21813. * @property {Padding} padding The padding scheme used in the ciphering operation.
  21814. * @property {number} blockSize The block size of the cipher.
  21815. * @property {Format} formatter The default formatting strategy to convert this cipher params object to a string.
  21816. */
  21817. var CipherParams = C_lib.CipherParams = Base.extend({
  21818. /**
  21819. * Initializes a newly created cipher params object.
  21820. *
  21821. * @param {Object} cipherParams An object with any of the possible cipher parameters.
  21822. *
  21823. * @example
  21824. *
  21825. * var cipherParams = CryptoJS.lib.CipherParams.create({
  21826. * ciphertext: ciphertextWordArray,
  21827. * key: keyWordArray,
  21828. * iv: ivWordArray,
  21829. * salt: saltWordArray,
  21830. * algorithm: CryptoJS.algo.AES,
  21831. * mode: CryptoJS.mode.CBC,
  21832. * padding: CryptoJS.pad.PKCS7,
  21833. * blockSize: 4,
  21834. * formatter: CryptoJS.format.OpenSSL
  21835. * });
  21836. */
  21837. init: function (cipherParams) {
  21838. this.mixIn(cipherParams);
  21839. },
  21840. /**
  21841. * Converts this cipher params object to a string.
  21842. *
  21843. * @param {Format} formatter (Optional) The formatting strategy to use.
  21844. *
  21845. * @return {string} The stringified cipher params.
  21846. *
  21847. * @throws Error If neither the formatter nor the default formatter is set.
  21848. *
  21849. * @example
  21850. *
  21851. * var string = cipherParams + '';
  21852. * var string = cipherParams.toString();
  21853. * var string = cipherParams.toString(CryptoJS.format.OpenSSL);
  21854. */
  21855. toString: function (formatter) {
  21856. return (formatter || this.formatter).stringify(this);
  21857. }
  21858. });
  21859. /**
  21860. * Format namespace.
  21861. */
  21862. var C_format = C.format = {};
  21863. /**
  21864. * OpenSSL formatting strategy.
  21865. */
  21866. var OpenSSLFormatter = C_format.OpenSSL = {
  21867. /**
  21868. * Converts a cipher params object to an OpenSSL-compatible string.
  21869. *
  21870. * @param {CipherParams} cipherParams The cipher params object.
  21871. *
  21872. * @return {string} The OpenSSL-compatible string.
  21873. *
  21874. * @static
  21875. *
  21876. * @example
  21877. *
  21878. * var openSSLString = CryptoJS.format.OpenSSL.stringify(cipherParams);
  21879. */
  21880. stringify: function (cipherParams) {
  21881. var wordArray;
  21882. // Shortcuts
  21883. var ciphertext = cipherParams.ciphertext;
  21884. var salt = cipherParams.salt;
  21885. // Format
  21886. if (salt) {
  21887. wordArray = WordArray.create([0x53616c74, 0x65645f5f]).concat(salt).concat(ciphertext);
  21888. } else {
  21889. wordArray = ciphertext;
  21890. }
  21891. return wordArray.toString(Base64);
  21892. },
  21893. /**
  21894. * Converts an OpenSSL-compatible string to a cipher params object.
  21895. *
  21896. * @param {string} openSSLStr The OpenSSL-compatible string.
  21897. *
  21898. * @return {CipherParams} The cipher params object.
  21899. *
  21900. * @static
  21901. *
  21902. * @example
  21903. *
  21904. * var cipherParams = CryptoJS.format.OpenSSL.parse(openSSLString);
  21905. */
  21906. parse: function (openSSLStr) {
  21907. var salt;
  21908. // Parse base64
  21909. var ciphertext = Base64.parse(openSSLStr);
  21910. // Shortcut
  21911. var ciphertextWords = ciphertext.words;
  21912. // Test for salt
  21913. if (ciphertextWords[0] == 0x53616c74 && ciphertextWords[1] == 0x65645f5f) {
  21914. // Extract salt
  21915. salt = WordArray.create(ciphertextWords.slice(2, 4));
  21916. // Remove salt from ciphertext
  21917. ciphertextWords.splice(0, 4);
  21918. ciphertext.sigBytes -= 16;
  21919. }
  21920. return CipherParams.create({ ciphertext: ciphertext, salt: salt });
  21921. }
  21922. };
  21923. /**
  21924. * A cipher wrapper that returns ciphertext as a serializable cipher params object.
  21925. */
  21926. var SerializableCipher = C_lib.SerializableCipher = Base.extend({
  21927. /**
  21928. * Configuration options.
  21929. *
  21930. * @property {Formatter} format The formatting strategy to convert cipher param objects to and from a string. Default: OpenSSL
  21931. */
  21932. cfg: Base.extend({
  21933. format: OpenSSLFormatter
  21934. }),
  21935. /**
  21936. * Encrypts a message.
  21937. *
  21938. * @param {Cipher} cipher The cipher algorithm to use.
  21939. * @param {WordArray|string} message The message to encrypt.
  21940. * @param {WordArray} key The key.
  21941. * @param {Object} cfg (Optional) The configuration options to use for this operation.
  21942. *
  21943. * @return {CipherParams} A cipher params object.
  21944. *
  21945. * @static
  21946. *
  21947. * @example
  21948. *
  21949. * var ciphertextParams = CryptoJS.lib.SerializableCipher.encrypt(CryptoJS.algo.AES, message, key);
  21950. * var ciphertextParams = CryptoJS.lib.SerializableCipher.encrypt(CryptoJS.algo.AES, message, key, { iv: iv });
  21951. * var ciphertextParams = CryptoJS.lib.SerializableCipher.encrypt(CryptoJS.algo.AES, message, key, { iv: iv, format: CryptoJS.format.OpenSSL });
  21952. */
  21953. encrypt: function (cipher, message, key, cfg) {
  21954. // Apply config defaults
  21955. cfg = this.cfg.extend(cfg);
  21956. // Encrypt
  21957. var encryptor = cipher.createEncryptor(key, cfg);
  21958. var ciphertext = encryptor.finalize(message);
  21959. // Shortcut
  21960. var cipherCfg = encryptor.cfg;
  21961. // Create and return serializable cipher params
  21962. return CipherParams.create({
  21963. ciphertext: ciphertext,
  21964. key: key,
  21965. iv: cipherCfg.iv,
  21966. algorithm: cipher,
  21967. mode: cipherCfg.mode,
  21968. padding: cipherCfg.padding,
  21969. blockSize: cipher.blockSize,
  21970. formatter: cfg.format
  21971. });
  21972. },
  21973. /**
  21974. * Decrypts serialized ciphertext.
  21975. *
  21976. * @param {Cipher} cipher The cipher algorithm to use.
  21977. * @param {CipherParams|string} ciphertext The ciphertext to decrypt.
  21978. * @param {WordArray} key The key.
  21979. * @param {Object} cfg (Optional) The configuration options to use for this operation.
  21980. *
  21981. * @return {WordArray} The plaintext.
  21982. *
  21983. * @static
  21984. *
  21985. * @example
  21986. *
  21987. * var plaintext = CryptoJS.lib.SerializableCipher.decrypt(CryptoJS.algo.AES, formattedCiphertext, key, { iv: iv, format: CryptoJS.format.OpenSSL });
  21988. * var plaintext = CryptoJS.lib.SerializableCipher.decrypt(CryptoJS.algo.AES, ciphertextParams, key, { iv: iv, format: CryptoJS.format.OpenSSL });
  21989. */
  21990. decrypt: function (cipher, ciphertext, key, cfg) {
  21991. // Apply config defaults
  21992. cfg = this.cfg.extend(cfg);
  21993. // Convert string to CipherParams
  21994. ciphertext = this._parse(ciphertext, cfg.format);
  21995. // Decrypt
  21996. var plaintext = cipher.createDecryptor(key, cfg).finalize(ciphertext.ciphertext);
  21997. return plaintext;
  21998. },
  21999. /**
  22000. * Converts serialized ciphertext to CipherParams,
  22001. * else assumed CipherParams already and returns ciphertext unchanged.
  22002. *
  22003. * @param {CipherParams|string} ciphertext The ciphertext.
  22004. * @param {Formatter} format The formatting strategy to use to parse serialized ciphertext.
  22005. *
  22006. * @return {CipherParams} The unserialized ciphertext.
  22007. *
  22008. * @static
  22009. *
  22010. * @example
  22011. *
  22012. * var ciphertextParams = CryptoJS.lib.SerializableCipher._parse(ciphertextStringOrParams, format);
  22013. */
  22014. _parse: function (ciphertext, format) {
  22015. if (typeof ciphertext == 'string') {
  22016. return format.parse(ciphertext, this);
  22017. } else {
  22018. return ciphertext;
  22019. }
  22020. }
  22021. });
  22022. /**
  22023. * Key derivation function namespace.
  22024. */
  22025. var C_kdf = C.kdf = {};
  22026. /**
  22027. * OpenSSL key derivation function.
  22028. */
  22029. var OpenSSLKdf = C_kdf.OpenSSL = {
  22030. /**
  22031. * Derives a key and IV from a password.
  22032. *
  22033. * @param {string} password The password to derive from.
  22034. * @param {number} keySize The size in words of the key to generate.
  22035. * @param {number} ivSize The size in words of the IV to generate.
  22036. * @param {WordArray|string} salt (Optional) A 64-bit salt to use. If omitted, a salt will be generated randomly.
  22037. *
  22038. * @return {CipherParams} A cipher params object with the key, IV, and salt.
  22039. *
  22040. * @static
  22041. *
  22042. * @example
  22043. *
  22044. * var derivedParams = CryptoJS.kdf.OpenSSL.execute('Password', 256/32, 128/32);
  22045. * var derivedParams = CryptoJS.kdf.OpenSSL.execute('Password', 256/32, 128/32, 'saltsalt');
  22046. */
  22047. execute: function (password, keySize, ivSize, salt, hasher) {
  22048. // Generate random salt
  22049. if (!salt) {
  22050. salt = WordArray.random(64/8);
  22051. }
  22052. // Derive key and IV
  22053. if (!hasher) {
  22054. var key = EvpKDF.create({ keySize: keySize + ivSize }).compute(password, salt);
  22055. } else {
  22056. var key = EvpKDF.create({ keySize: keySize + ivSize, hasher: hasher }).compute(password, salt);
  22057. }
  22058. // Separate key and IV
  22059. var iv = WordArray.create(key.words.slice(keySize), ivSize * 4);
  22060. key.sigBytes = keySize * 4;
  22061. // Return params
  22062. return CipherParams.create({ key: key, iv: iv, salt: salt });
  22063. }
  22064. };
  22065. /**
  22066. * A serializable cipher wrapper that derives the key from a password,
  22067. * and returns ciphertext as a serializable cipher params object.
  22068. */
  22069. var PasswordBasedCipher = C_lib.PasswordBasedCipher = SerializableCipher.extend({
  22070. /**
  22071. * Configuration options.
  22072. *
  22073. * @property {KDF} kdf The key derivation function to use to generate a key and IV from a password. Default: OpenSSL
  22074. */
  22075. cfg: SerializableCipher.cfg.extend({
  22076. kdf: OpenSSLKdf
  22077. }),
  22078. /**
  22079. * Encrypts a message using a password.
  22080. *
  22081. * @param {Cipher} cipher The cipher algorithm to use.
  22082. * @param {WordArray|string} message The message to encrypt.
  22083. * @param {string} password The password.
  22084. * @param {Object} cfg (Optional) The configuration options to use for this operation.
  22085. *
  22086. * @return {CipherParams} A cipher params object.
  22087. *
  22088. * @static
  22089. *
  22090. * @example
  22091. *
  22092. * var ciphertextParams = CryptoJS.lib.PasswordBasedCipher.encrypt(CryptoJS.algo.AES, message, 'password');
  22093. * var ciphertextParams = CryptoJS.lib.PasswordBasedCipher.encrypt(CryptoJS.algo.AES, message, 'password', { format: CryptoJS.format.OpenSSL });
  22094. */
  22095. encrypt: function (cipher, message, password, cfg) {
  22096. // Apply config defaults
  22097. cfg = this.cfg.extend(cfg);
  22098. // Derive key and other params
  22099. var derivedParams = cfg.kdf.execute(password, cipher.keySize, cipher.ivSize, cfg.salt, cfg.hasher);
  22100. // Add IV to config
  22101. cfg.iv = derivedParams.iv;
  22102. // Encrypt
  22103. var ciphertext = SerializableCipher.encrypt.call(this, cipher, message, derivedParams.key, cfg);
  22104. // Mix in derived params
  22105. ciphertext.mixIn(derivedParams);
  22106. return ciphertext;
  22107. },
  22108. /**
  22109. * Decrypts serialized ciphertext using a password.
  22110. *
  22111. * @param {Cipher} cipher The cipher algorithm to use.
  22112. * @param {CipherParams|string} ciphertext The ciphertext to decrypt.
  22113. * @param {string} password The password.
  22114. * @param {Object} cfg (Optional) The configuration options to use for this operation.
  22115. *
  22116. * @return {WordArray} The plaintext.
  22117. *
  22118. * @static
  22119. *
  22120. * @example
  22121. *
  22122. * var plaintext = CryptoJS.lib.PasswordBasedCipher.decrypt(CryptoJS.algo.AES, formattedCiphertext, 'password', { format: CryptoJS.format.OpenSSL });
  22123. * var plaintext = CryptoJS.lib.PasswordBasedCipher.decrypt(CryptoJS.algo.AES, ciphertextParams, 'password', { format: CryptoJS.format.OpenSSL });
  22124. */
  22125. decrypt: function (cipher, ciphertext, password, cfg) {
  22126. // Apply config defaults
  22127. cfg = this.cfg.extend(cfg);
  22128. // Convert string to CipherParams
  22129. ciphertext = this._parse(ciphertext, cfg.format);
  22130. // Derive key and other params
  22131. var derivedParams = cfg.kdf.execute(password, cipher.keySize, cipher.ivSize, ciphertext.salt, cfg.hasher);
  22132. // Add IV to config
  22133. cfg.iv = derivedParams.iv;
  22134. // Decrypt
  22135. var plaintext = SerializableCipher.decrypt.call(this, cipher, ciphertext, derivedParams.key, cfg);
  22136. return plaintext;
  22137. }
  22138. });
  22139. }());
  22140. }));
  22141. },{"./core":478,"./evpkdf":481}],478:[function(_dereq_,module,exports){
  22142. (function (global){(function (){
  22143. ;(function (root, factory) {
  22144. if (typeof exports === "object") {
  22145. // CommonJS
  22146. module.exports = exports = factory();
  22147. }
  22148. else if (typeof define === "function" && define.amd) {
  22149. // AMD
  22150. define([], factory);
  22151. }
  22152. else {
  22153. // Global (browser)
  22154. root.CryptoJS = factory();
  22155. }
  22156. }(this, function () {
  22157. /*globals window, global, require*/
  22158. /**
  22159. * CryptoJS core components.
  22160. */
  22161. var CryptoJS = CryptoJS || (function (Math, undefined) {
  22162. var crypto;
  22163. // Native crypto from window (Browser)
  22164. if (typeof window !== 'undefined' && window.crypto) {
  22165. crypto = window.crypto;
  22166. }
  22167. // Native crypto in web worker (Browser)
  22168. if (typeof self !== 'undefined' && self.crypto) {
  22169. crypto = self.crypto;
  22170. }
  22171. // Native crypto from worker
  22172. if (typeof globalThis !== 'undefined' && globalThis.crypto) {
  22173. crypto = globalThis.crypto;
  22174. }
  22175. // Native (experimental IE 11) crypto from window (Browser)
  22176. if (!crypto && typeof window !== 'undefined' && window.msCrypto) {
  22177. crypto = window.msCrypto;
  22178. }
  22179. // Native crypto from global (NodeJS)
  22180. if (!crypto && typeof global !== 'undefined' && global.crypto) {
  22181. crypto = global.crypto;
  22182. }
  22183. // Native crypto import via require (NodeJS)
  22184. if (!crypto && typeof _dereq_ === 'function') {
  22185. try {
  22186. crypto = _dereq_('crypto');
  22187. } catch (err) {}
  22188. }
  22189. /*
  22190. * Cryptographically secure pseudorandom number generator
  22191. *
  22192. * As Math.random() is cryptographically not safe to use
  22193. */
  22194. var cryptoSecureRandomInt = function () {
  22195. if (crypto) {
  22196. // Use getRandomValues method (Browser)
  22197. if (typeof crypto.getRandomValues === 'function') {
  22198. try {
  22199. return crypto.getRandomValues(new Uint32Array(1))[0];
  22200. } catch (err) {}
  22201. }
  22202. // Use randomBytes method (NodeJS)
  22203. if (typeof crypto.randomBytes === 'function') {
  22204. try {
  22205. return crypto.randomBytes(4).readInt32LE();
  22206. } catch (err) {}
  22207. }
  22208. }
  22209. throw new Error('Native crypto module could not be used to get secure random number.');
  22210. };
  22211. /*
  22212. * Local polyfill of Object.create
  22213. */
  22214. var create = Object.create || (function () {
  22215. function F() {}
  22216. return function (obj) {
  22217. var subtype;
  22218. F.prototype = obj;
  22219. subtype = new F();
  22220. F.prototype = null;
  22221. return subtype;
  22222. };
  22223. }());
  22224. /**
  22225. * CryptoJS namespace.
  22226. */
  22227. var C = {};
  22228. /**
  22229. * Library namespace.
  22230. */
  22231. var C_lib = C.lib = {};
  22232. /**
  22233. * Base object for prototypal inheritance.
  22234. */
  22235. var Base = C_lib.Base = (function () {
  22236. return {
  22237. /**
  22238. * Creates a new object that inherits from this object.
  22239. *
  22240. * @param {Object} overrides Properties to copy into the new object.
  22241. *
  22242. * @return {Object} The new object.
  22243. *
  22244. * @static
  22245. *
  22246. * @example
  22247. *
  22248. * var MyType = CryptoJS.lib.Base.extend({
  22249. * field: 'value',
  22250. *
  22251. * method: function () {
  22252. * }
  22253. * });
  22254. */
  22255. extend: function (overrides) {
  22256. // Spawn
  22257. var subtype = create(this);
  22258. // Augment
  22259. if (overrides) {
  22260. subtype.mixIn(overrides);
  22261. }
  22262. // Create default initializer
  22263. if (!subtype.hasOwnProperty('init') || this.init === subtype.init) {
  22264. subtype.init = function () {
  22265. subtype.$super.init.apply(this, arguments);
  22266. };
  22267. }
  22268. // Initializer's prototype is the subtype object
  22269. subtype.init.prototype = subtype;
  22270. // Reference supertype
  22271. subtype.$super = this;
  22272. return subtype;
  22273. },
  22274. /**
  22275. * Extends this object and runs the init method.
  22276. * Arguments to create() will be passed to init().
  22277. *
  22278. * @return {Object} The new object.
  22279. *
  22280. * @static
  22281. *
  22282. * @example
  22283. *
  22284. * var instance = MyType.create();
  22285. */
  22286. create: function () {
  22287. var instance = this.extend();
  22288. instance.init.apply(instance, arguments);
  22289. return instance;
  22290. },
  22291. /**
  22292. * Initializes a newly created object.
  22293. * Override this method to add some logic when your objects are created.
  22294. *
  22295. * @example
  22296. *
  22297. * var MyType = CryptoJS.lib.Base.extend({
  22298. * init: function () {
  22299. * // ...
  22300. * }
  22301. * });
  22302. */
  22303. init: function () {
  22304. },
  22305. /**
  22306. * Copies properties into this object.
  22307. *
  22308. * @param {Object} properties The properties to mix in.
  22309. *
  22310. * @example
  22311. *
  22312. * MyType.mixIn({
  22313. * field: 'value'
  22314. * });
  22315. */
  22316. mixIn: function (properties) {
  22317. for (var propertyName in properties) {
  22318. if (properties.hasOwnProperty(propertyName)) {
  22319. this[propertyName] = properties[propertyName];
  22320. }
  22321. }
  22322. // IE won't copy toString using the loop above
  22323. if (properties.hasOwnProperty('toString')) {
  22324. this.toString = properties.toString;
  22325. }
  22326. },
  22327. /**
  22328. * Creates a copy of this object.
  22329. *
  22330. * @return {Object} The clone.
  22331. *
  22332. * @example
  22333. *
  22334. * var clone = instance.clone();
  22335. */
  22336. clone: function () {
  22337. return this.init.prototype.extend(this);
  22338. }
  22339. };
  22340. }());
  22341. /**
  22342. * An array of 32-bit words.
  22343. *
  22344. * @property {Array} words The array of 32-bit words.
  22345. * @property {number} sigBytes The number of significant bytes in this word array.
  22346. */
  22347. var WordArray = C_lib.WordArray = Base.extend({
  22348. /**
  22349. * Initializes a newly created word array.
  22350. *
  22351. * @param {Array} words (Optional) An array of 32-bit words.
  22352. * @param {number} sigBytes (Optional) The number of significant bytes in the words.
  22353. *
  22354. * @example
  22355. *
  22356. * var wordArray = CryptoJS.lib.WordArray.create();
  22357. * var wordArray = CryptoJS.lib.WordArray.create([0x00010203, 0x04050607]);
  22358. * var wordArray = CryptoJS.lib.WordArray.create([0x00010203, 0x04050607], 6);
  22359. */
  22360. init: function (words, sigBytes) {
  22361. words = this.words = words || [];
  22362. if (sigBytes != undefined) {
  22363. this.sigBytes = sigBytes;
  22364. } else {
  22365. this.sigBytes = words.length * 4;
  22366. }
  22367. },
  22368. /**
  22369. * Converts this word array to a string.
  22370. *
  22371. * @param {Encoder} encoder (Optional) The encoding strategy to use. Default: CryptoJS.enc.Hex
  22372. *
  22373. * @return {string} The stringified word array.
  22374. *
  22375. * @example
  22376. *
  22377. * var string = wordArray + '';
  22378. * var string = wordArray.toString();
  22379. * var string = wordArray.toString(CryptoJS.enc.Utf8);
  22380. */
  22381. toString: function (encoder) {
  22382. return (encoder || Hex).stringify(this);
  22383. },
  22384. /**
  22385. * Concatenates a word array to this word array.
  22386. *
  22387. * @param {WordArray} wordArray The word array to append.
  22388. *
  22389. * @return {WordArray} This word array.
  22390. *
  22391. * @example
  22392. *
  22393. * wordArray1.concat(wordArray2);
  22394. */
  22395. concat: function (wordArray) {
  22396. // Shortcuts
  22397. var thisWords = this.words;
  22398. var thatWords = wordArray.words;
  22399. var thisSigBytes = this.sigBytes;
  22400. var thatSigBytes = wordArray.sigBytes;
  22401. // Clamp excess bits
  22402. this.clamp();
  22403. // Concat
  22404. if (thisSigBytes % 4) {
  22405. // Copy one byte at a time
  22406. for (var i = 0; i < thatSigBytes; i++) {
  22407. var thatByte = (thatWords[i >>> 2] >>> (24 - (i % 4) * 8)) & 0xff;
  22408. thisWords[(thisSigBytes + i) >>> 2] |= thatByte << (24 - ((thisSigBytes + i) % 4) * 8);
  22409. }
  22410. } else {
  22411. // Copy one word at a time
  22412. for (var j = 0; j < thatSigBytes; j += 4) {
  22413. thisWords[(thisSigBytes + j) >>> 2] = thatWords[j >>> 2];
  22414. }
  22415. }
  22416. this.sigBytes += thatSigBytes;
  22417. // Chainable
  22418. return this;
  22419. },
  22420. /**
  22421. * Removes insignificant bits.
  22422. *
  22423. * @example
  22424. *
  22425. * wordArray.clamp();
  22426. */
  22427. clamp: function () {
  22428. // Shortcuts
  22429. var words = this.words;
  22430. var sigBytes = this.sigBytes;
  22431. // Clamp
  22432. words[sigBytes >>> 2] &= 0xffffffff << (32 - (sigBytes % 4) * 8);
  22433. words.length = Math.ceil(sigBytes / 4);
  22434. },
  22435. /**
  22436. * Creates a copy of this word array.
  22437. *
  22438. * @return {WordArray} The clone.
  22439. *
  22440. * @example
  22441. *
  22442. * var clone = wordArray.clone();
  22443. */
  22444. clone: function () {
  22445. var clone = Base.clone.call(this);
  22446. clone.words = this.words.slice(0);
  22447. return clone;
  22448. },
  22449. /**
  22450. * Creates a word array filled with random bytes.
  22451. *
  22452. * @param {number} nBytes The number of random bytes to generate.
  22453. *
  22454. * @return {WordArray} The random word array.
  22455. *
  22456. * @static
  22457. *
  22458. * @example
  22459. *
  22460. * var wordArray = CryptoJS.lib.WordArray.random(16);
  22461. */
  22462. random: function (nBytes) {
  22463. var words = [];
  22464. for (var i = 0; i < nBytes; i += 4) {
  22465. words.push(cryptoSecureRandomInt());
  22466. }
  22467. return new WordArray.init(words, nBytes);
  22468. }
  22469. });
  22470. /**
  22471. * Encoder namespace.
  22472. */
  22473. var C_enc = C.enc = {};
  22474. /**
  22475. * Hex encoding strategy.
  22476. */
  22477. var Hex = C_enc.Hex = {
  22478. /**
  22479. * Converts a word array to a hex string.
  22480. *
  22481. * @param {WordArray} wordArray The word array.
  22482. *
  22483. * @return {string} The hex string.
  22484. *
  22485. * @static
  22486. *
  22487. * @example
  22488. *
  22489. * var hexString = CryptoJS.enc.Hex.stringify(wordArray);
  22490. */
  22491. stringify: function (wordArray) {
  22492. // Shortcuts
  22493. var words = wordArray.words;
  22494. var sigBytes = wordArray.sigBytes;
  22495. // Convert
  22496. var hexChars = [];
  22497. for (var i = 0; i < sigBytes; i++) {
  22498. var bite = (words[i >>> 2] >>> (24 - (i % 4) * 8)) & 0xff;
  22499. hexChars.push((bite >>> 4).toString(16));
  22500. hexChars.push((bite & 0x0f).toString(16));
  22501. }
  22502. return hexChars.join('');
  22503. },
  22504. /**
  22505. * Converts a hex string to a word array.
  22506. *
  22507. * @param {string} hexStr The hex string.
  22508. *
  22509. * @return {WordArray} The word array.
  22510. *
  22511. * @static
  22512. *
  22513. * @example
  22514. *
  22515. * var wordArray = CryptoJS.enc.Hex.parse(hexString);
  22516. */
  22517. parse: function (hexStr) {
  22518. // Shortcut
  22519. var hexStrLength = hexStr.length;
  22520. // Convert
  22521. var words = [];
  22522. for (var i = 0; i < hexStrLength; i += 2) {
  22523. words[i >>> 3] |= parseInt(hexStr.substr(i, 2), 16) << (24 - (i % 8) * 4);
  22524. }
  22525. return new WordArray.init(words, hexStrLength / 2);
  22526. }
  22527. };
  22528. /**
  22529. * Latin1 encoding strategy.
  22530. */
  22531. var Latin1 = C_enc.Latin1 = {
  22532. /**
  22533. * Converts a word array to a Latin1 string.
  22534. *
  22535. * @param {WordArray} wordArray The word array.
  22536. *
  22537. * @return {string} The Latin1 string.
  22538. *
  22539. * @static
  22540. *
  22541. * @example
  22542. *
  22543. * var latin1String = CryptoJS.enc.Latin1.stringify(wordArray);
  22544. */
  22545. stringify: function (wordArray) {
  22546. // Shortcuts
  22547. var words = wordArray.words;
  22548. var sigBytes = wordArray.sigBytes;
  22549. // Convert
  22550. var latin1Chars = [];
  22551. for (var i = 0; i < sigBytes; i++) {
  22552. var bite = (words[i >>> 2] >>> (24 - (i % 4) * 8)) & 0xff;
  22553. latin1Chars.push(String.fromCharCode(bite));
  22554. }
  22555. return latin1Chars.join('');
  22556. },
  22557. /**
  22558. * Converts a Latin1 string to a word array.
  22559. *
  22560. * @param {string} latin1Str The Latin1 string.
  22561. *
  22562. * @return {WordArray} The word array.
  22563. *
  22564. * @static
  22565. *
  22566. * @example
  22567. *
  22568. * var wordArray = CryptoJS.enc.Latin1.parse(latin1String);
  22569. */
  22570. parse: function (latin1Str) {
  22571. // Shortcut
  22572. var latin1StrLength = latin1Str.length;
  22573. // Convert
  22574. var words = [];
  22575. for (var i = 0; i < latin1StrLength; i++) {
  22576. words[i >>> 2] |= (latin1Str.charCodeAt(i) & 0xff) << (24 - (i % 4) * 8);
  22577. }
  22578. return new WordArray.init(words, latin1StrLength);
  22579. }
  22580. };
  22581. /**
  22582. * UTF-8 encoding strategy.
  22583. */
  22584. var Utf8 = C_enc.Utf8 = {
  22585. /**
  22586. * Converts a word array to a UTF-8 string.
  22587. *
  22588. * @param {WordArray} wordArray The word array.
  22589. *
  22590. * @return {string} The UTF-8 string.
  22591. *
  22592. * @static
  22593. *
  22594. * @example
  22595. *
  22596. * var utf8String = CryptoJS.enc.Utf8.stringify(wordArray);
  22597. */
  22598. stringify: function (wordArray) {
  22599. try {
  22600. return decodeURIComponent(escape(Latin1.stringify(wordArray)));
  22601. } catch (e) {
  22602. throw new Error('Malformed UTF-8 data');
  22603. }
  22604. },
  22605. /**
  22606. * Converts a UTF-8 string to a word array.
  22607. *
  22608. * @param {string} utf8Str The UTF-8 string.
  22609. *
  22610. * @return {WordArray} The word array.
  22611. *
  22612. * @static
  22613. *
  22614. * @example
  22615. *
  22616. * var wordArray = CryptoJS.enc.Utf8.parse(utf8String);
  22617. */
  22618. parse: function (utf8Str) {
  22619. return Latin1.parse(unescape(encodeURIComponent(utf8Str)));
  22620. }
  22621. };
  22622. /**
  22623. * Abstract buffered block algorithm template.
  22624. *
  22625. * The property blockSize must be implemented in a concrete subtype.
  22626. *
  22627. * @property {number} _minBufferSize The number of blocks that should be kept unprocessed in the buffer. Default: 0
  22628. */
  22629. var BufferedBlockAlgorithm = C_lib.BufferedBlockAlgorithm = Base.extend({
  22630. /**
  22631. * Resets this block algorithm's data buffer to its initial state.
  22632. *
  22633. * @example
  22634. *
  22635. * bufferedBlockAlgorithm.reset();
  22636. */
  22637. reset: function () {
  22638. // Initial values
  22639. this._data = new WordArray.init();
  22640. this._nDataBytes = 0;
  22641. },
  22642. /**
  22643. * Adds new data to this block algorithm's buffer.
  22644. *
  22645. * @param {WordArray|string} data The data to append. Strings are converted to a WordArray using UTF-8.
  22646. *
  22647. * @example
  22648. *
  22649. * bufferedBlockAlgorithm._append('data');
  22650. * bufferedBlockAlgorithm._append(wordArray);
  22651. */
  22652. _append: function (data) {
  22653. // Convert string to WordArray, else assume WordArray already
  22654. if (typeof data == 'string') {
  22655. data = Utf8.parse(data);
  22656. }
  22657. // Append
  22658. this._data.concat(data);
  22659. this._nDataBytes += data.sigBytes;
  22660. },
  22661. /**
  22662. * Processes available data blocks.
  22663. *
  22664. * This method invokes _doProcessBlock(offset), which must be implemented by a concrete subtype.
  22665. *
  22666. * @param {boolean} doFlush Whether all blocks and partial blocks should be processed.
  22667. *
  22668. * @return {WordArray} The processed data.
  22669. *
  22670. * @example
  22671. *
  22672. * var processedData = bufferedBlockAlgorithm._process();
  22673. * var processedData = bufferedBlockAlgorithm._process(!!'flush');
  22674. */
  22675. _process: function (doFlush) {
  22676. var processedWords;
  22677. // Shortcuts
  22678. var data = this._data;
  22679. var dataWords = data.words;
  22680. var dataSigBytes = data.sigBytes;
  22681. var blockSize = this.blockSize;
  22682. var blockSizeBytes = blockSize * 4;
  22683. // Count blocks ready
  22684. var nBlocksReady = dataSigBytes / blockSizeBytes;
  22685. if (doFlush) {
  22686. // Round up to include partial blocks
  22687. nBlocksReady = Math.ceil(nBlocksReady);
  22688. } else {
  22689. // Round down to include only full blocks,
  22690. // less the number of blocks that must remain in the buffer
  22691. nBlocksReady = Math.max((nBlocksReady | 0) - this._minBufferSize, 0);
  22692. }
  22693. // Count words ready
  22694. var nWordsReady = nBlocksReady * blockSize;
  22695. // Count bytes ready
  22696. var nBytesReady = Math.min(nWordsReady * 4, dataSigBytes);
  22697. // Process blocks
  22698. if (nWordsReady) {
  22699. for (var offset = 0; offset < nWordsReady; offset += blockSize) {
  22700. // Perform concrete-algorithm logic
  22701. this._doProcessBlock(dataWords, offset);
  22702. }
  22703. // Remove processed words
  22704. processedWords = dataWords.splice(0, nWordsReady);
  22705. data.sigBytes -= nBytesReady;
  22706. }
  22707. // Return processed words
  22708. return new WordArray.init(processedWords, nBytesReady);
  22709. },
  22710. /**
  22711. * Creates a copy of this object.
  22712. *
  22713. * @return {Object} The clone.
  22714. *
  22715. * @example
  22716. *
  22717. * var clone = bufferedBlockAlgorithm.clone();
  22718. */
  22719. clone: function () {
  22720. var clone = Base.clone.call(this);
  22721. clone._data = this._data.clone();
  22722. return clone;
  22723. },
  22724. _minBufferSize: 0
  22725. });
  22726. /**
  22727. * Abstract hasher template.
  22728. *
  22729. * @property {number} blockSize The number of 32-bit words this hasher operates on. Default: 16 (512 bits)
  22730. */
  22731. var Hasher = C_lib.Hasher = BufferedBlockAlgorithm.extend({
  22732. /**
  22733. * Configuration options.
  22734. */
  22735. cfg: Base.extend(),
  22736. /**
  22737. * Initializes a newly created hasher.
  22738. *
  22739. * @param {Object} cfg (Optional) The configuration options to use for this hash computation.
  22740. *
  22741. * @example
  22742. *
  22743. * var hasher = CryptoJS.algo.SHA256.create();
  22744. */
  22745. init: function (cfg) {
  22746. // Apply config defaults
  22747. this.cfg = this.cfg.extend(cfg);
  22748. // Set initial values
  22749. this.reset();
  22750. },
  22751. /**
  22752. * Resets this hasher to its initial state.
  22753. *
  22754. * @example
  22755. *
  22756. * hasher.reset();
  22757. */
  22758. reset: function () {
  22759. // Reset data buffer
  22760. BufferedBlockAlgorithm.reset.call(this);
  22761. // Perform concrete-hasher logic
  22762. this._doReset();
  22763. },
  22764. /**
  22765. * Updates this hasher with a message.
  22766. *
  22767. * @param {WordArray|string} messageUpdate The message to append.
  22768. *
  22769. * @return {Hasher} This hasher.
  22770. *
  22771. * @example
  22772. *
  22773. * hasher.update('message');
  22774. * hasher.update(wordArray);
  22775. */
  22776. update: function (messageUpdate) {
  22777. // Append
  22778. this._append(messageUpdate);
  22779. // Update the hash
  22780. this._process();
  22781. // Chainable
  22782. return this;
  22783. },
  22784. /**
  22785. * Finalizes the hash computation.
  22786. * Note that the finalize operation is effectively a destructive, read-once operation.
  22787. *
  22788. * @param {WordArray|string} messageUpdate (Optional) A final message update.
  22789. *
  22790. * @return {WordArray} The hash.
  22791. *
  22792. * @example
  22793. *
  22794. * var hash = hasher.finalize();
  22795. * var hash = hasher.finalize('message');
  22796. * var hash = hasher.finalize(wordArray);
  22797. */
  22798. finalize: function (messageUpdate) {
  22799. // Final message update
  22800. if (messageUpdate) {
  22801. this._append(messageUpdate);
  22802. }
  22803. // Perform concrete-hasher logic
  22804. var hash = this._doFinalize();
  22805. return hash;
  22806. },
  22807. blockSize: 512/32,
  22808. /**
  22809. * Creates a shortcut function to a hasher's object interface.
  22810. *
  22811. * @param {Hasher} hasher The hasher to create a helper for.
  22812. *
  22813. * @return {Function} The shortcut function.
  22814. *
  22815. * @static
  22816. *
  22817. * @example
  22818. *
  22819. * var SHA256 = CryptoJS.lib.Hasher._createHelper(CryptoJS.algo.SHA256);
  22820. */
  22821. _createHelper: function (hasher) {
  22822. return function (message, cfg) {
  22823. return new hasher.init(cfg).finalize(message);
  22824. };
  22825. },
  22826. /**
  22827. * Creates a shortcut function to the HMAC's object interface.
  22828. *
  22829. * @param {Hasher} hasher The hasher to use in this HMAC helper.
  22830. *
  22831. * @return {Function} The shortcut function.
  22832. *
  22833. * @static
  22834. *
  22835. * @example
  22836. *
  22837. * var HmacSHA256 = CryptoJS.lib.Hasher._createHmacHelper(CryptoJS.algo.SHA256);
  22838. */
  22839. _createHmacHelper: function (hasher) {
  22840. return function (message, key) {
  22841. return new C_algo.HMAC.init(hasher, key).finalize(message);
  22842. };
  22843. }
  22844. });
  22845. /**
  22846. * Algorithm namespace.
  22847. */
  22848. var C_algo = C.algo = {};
  22849. return C;
  22850. }(Math));
  22851. return CryptoJS;
  22852. }));
  22853. }).call(this)}).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {})
  22854. },{"crypto":undefined}],479:[function(_dereq_,module,exports){
  22855. ;(function (root, factory) {
  22856. if (typeof exports === "object") {
  22857. // CommonJS
  22858. module.exports = exports = factory(_dereq_("./core"));
  22859. }
  22860. else if (typeof define === "function" && define.amd) {
  22861. // AMD
  22862. define(["./core"], factory);
  22863. }
  22864. else {
  22865. // Global (browser)
  22866. factory(root.CryptoJS);
  22867. }
  22868. }(this, function (CryptoJS) {
  22869. (function () {
  22870. // Shortcuts
  22871. var C = CryptoJS;
  22872. var C_lib = C.lib;
  22873. var WordArray = C_lib.WordArray;
  22874. var C_enc = C.enc;
  22875. /**
  22876. * Base64 encoding strategy.
  22877. */
  22878. var Base64 = C_enc.Base64 = {
  22879. /**
  22880. * Converts a word array to a Base64 string.
  22881. *
  22882. * @param {WordArray} wordArray The word array.
  22883. *
  22884. * @return {string} The Base64 string.
  22885. *
  22886. * @static
  22887. *
  22888. * @example
  22889. *
  22890. * var base64String = CryptoJS.enc.Base64.stringify(wordArray);
  22891. */
  22892. stringify: function (wordArray) {
  22893. // Shortcuts
  22894. var words = wordArray.words;
  22895. var sigBytes = wordArray.sigBytes;
  22896. var map = this._map;
  22897. // Clamp excess bits
  22898. wordArray.clamp();
  22899. // Convert
  22900. var base64Chars = [];
  22901. for (var i = 0; i < sigBytes; i += 3) {
  22902. var byte1 = (words[i >>> 2] >>> (24 - (i % 4) * 8)) & 0xff;
  22903. var byte2 = (words[(i + 1) >>> 2] >>> (24 - ((i + 1) % 4) * 8)) & 0xff;
  22904. var byte3 = (words[(i + 2) >>> 2] >>> (24 - ((i + 2) % 4) * 8)) & 0xff;
  22905. var triplet = (byte1 << 16) | (byte2 << 8) | byte3;
  22906. for (var j = 0; (j < 4) && (i + j * 0.75 < sigBytes); j++) {
  22907. base64Chars.push(map.charAt((triplet >>> (6 * (3 - j))) & 0x3f));
  22908. }
  22909. }
  22910. // Add padding
  22911. var paddingChar = map.charAt(64);
  22912. if (paddingChar) {
  22913. while (base64Chars.length % 4) {
  22914. base64Chars.push(paddingChar);
  22915. }
  22916. }
  22917. return base64Chars.join('');
  22918. },
  22919. /**
  22920. * Converts a Base64 string to a word array.
  22921. *
  22922. * @param {string} base64Str The Base64 string.
  22923. *
  22924. * @return {WordArray} The word array.
  22925. *
  22926. * @static
  22927. *
  22928. * @example
  22929. *
  22930. * var wordArray = CryptoJS.enc.Base64.parse(base64String);
  22931. */
  22932. parse: function (base64Str) {
  22933. // Shortcuts
  22934. var base64StrLength = base64Str.length;
  22935. var map = this._map;
  22936. var reverseMap = this._reverseMap;
  22937. if (!reverseMap) {
  22938. reverseMap = this._reverseMap = [];
  22939. for (var j = 0; j < map.length; j++) {
  22940. reverseMap[map.charCodeAt(j)] = j;
  22941. }
  22942. }
  22943. // Ignore padding
  22944. var paddingChar = map.charAt(64);
  22945. if (paddingChar) {
  22946. var paddingIndex = base64Str.indexOf(paddingChar);
  22947. if (paddingIndex !== -1) {
  22948. base64StrLength = paddingIndex;
  22949. }
  22950. }
  22951. // Convert
  22952. return parseLoop(base64Str, base64StrLength, reverseMap);
  22953. },
  22954. _map: 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/='
  22955. };
  22956. function parseLoop(base64Str, base64StrLength, reverseMap) {
  22957. var words = [];
  22958. var nBytes = 0;
  22959. for (var i = 0; i < base64StrLength; i++) {
  22960. if (i % 4) {
  22961. var bits1 = reverseMap[base64Str.charCodeAt(i - 1)] << ((i % 4) * 2);
  22962. var bits2 = reverseMap[base64Str.charCodeAt(i)] >>> (6 - (i % 4) * 2);
  22963. var bitsCombined = bits1 | bits2;
  22964. words[nBytes >>> 2] |= bitsCombined << (24 - (nBytes % 4) * 8);
  22965. nBytes++;
  22966. }
  22967. }
  22968. return WordArray.create(words, nBytes);
  22969. }
  22970. }());
  22971. return CryptoJS.enc.Base64;
  22972. }));
  22973. },{"./core":478}],480:[function(_dereq_,module,exports){
  22974. ;(function (root, factory) {
  22975. if (typeof exports === "object") {
  22976. // CommonJS
  22977. module.exports = exports = factory(_dereq_("./core"));
  22978. }
  22979. else if (typeof define === "function" && define.amd) {
  22980. // AMD
  22981. define(["./core"], factory);
  22982. }
  22983. else {
  22984. // Global (browser)
  22985. factory(root.CryptoJS);
  22986. }
  22987. }(this, function (CryptoJS) {
  22988. return CryptoJS.enc.Utf8;
  22989. }));
  22990. },{"./core":478}],481:[function(_dereq_,module,exports){
  22991. ;(function (root, factory, undef) {
  22992. if (typeof exports === "object") {
  22993. // CommonJS
  22994. module.exports = exports = factory(_dereq_("./core"), _dereq_("./sha1"), _dereq_("./hmac"));
  22995. }
  22996. else if (typeof define === "function" && define.amd) {
  22997. // AMD
  22998. define(["./core", "./sha1", "./hmac"], factory);
  22999. }
  23000. else {
  23001. // Global (browser)
  23002. factory(root.CryptoJS);
  23003. }
  23004. }(this, function (CryptoJS) {
  23005. (function () {
  23006. // Shortcuts
  23007. var C = CryptoJS;
  23008. var C_lib = C.lib;
  23009. var Base = C_lib.Base;
  23010. var WordArray = C_lib.WordArray;
  23011. var C_algo = C.algo;
  23012. var MD5 = C_algo.MD5;
  23013. /**
  23014. * This key derivation function is meant to conform with EVP_BytesToKey.
  23015. * www.openssl.org/docs/crypto/EVP_BytesToKey.html
  23016. */
  23017. var EvpKDF = C_algo.EvpKDF = Base.extend({
  23018. /**
  23019. * Configuration options.
  23020. *
  23021. * @property {number} keySize The key size in words to generate. Default: 4 (128 bits)
  23022. * @property {Hasher} hasher The hash algorithm to use. Default: MD5
  23023. * @property {number} iterations The number of iterations to perform. Default: 1
  23024. */
  23025. cfg: Base.extend({
  23026. keySize: 128/32,
  23027. hasher: MD5,
  23028. iterations: 1
  23029. }),
  23030. /**
  23031. * Initializes a newly created key derivation function.
  23032. *
  23033. * @param {Object} cfg (Optional) The configuration options to use for the derivation.
  23034. *
  23035. * @example
  23036. *
  23037. * var kdf = CryptoJS.algo.EvpKDF.create();
  23038. * var kdf = CryptoJS.algo.EvpKDF.create({ keySize: 8 });
  23039. * var kdf = CryptoJS.algo.EvpKDF.create({ keySize: 8, iterations: 1000 });
  23040. */
  23041. init: function (cfg) {
  23042. this.cfg = this.cfg.extend(cfg);
  23043. },
  23044. /**
  23045. * Derives a key from a password.
  23046. *
  23047. * @param {WordArray|string} password The password.
  23048. * @param {WordArray|string} salt A salt.
  23049. *
  23050. * @return {WordArray} The derived key.
  23051. *
  23052. * @example
  23053. *
  23054. * var key = kdf.compute(password, salt);
  23055. */
  23056. compute: function (password, salt) {
  23057. var block;
  23058. // Shortcut
  23059. var cfg = this.cfg;
  23060. // Init hasher
  23061. var hasher = cfg.hasher.create();
  23062. // Initial values
  23063. var derivedKey = WordArray.create();
  23064. // Shortcuts
  23065. var derivedKeyWords = derivedKey.words;
  23066. var keySize = cfg.keySize;
  23067. var iterations = cfg.iterations;
  23068. // Generate key
  23069. while (derivedKeyWords.length < keySize) {
  23070. if (block) {
  23071. hasher.update(block);
  23072. }
  23073. block = hasher.update(password).finalize(salt);
  23074. hasher.reset();
  23075. // Iterations
  23076. for (var i = 1; i < iterations; i++) {
  23077. block = hasher.finalize(block);
  23078. hasher.reset();
  23079. }
  23080. derivedKey.concat(block);
  23081. }
  23082. derivedKey.sigBytes = keySize * 4;
  23083. return derivedKey;
  23084. }
  23085. });
  23086. /**
  23087. * Derives a key from a password.
  23088. *
  23089. * @param {WordArray|string} password The password.
  23090. * @param {WordArray|string} salt A salt.
  23091. * @param {Object} cfg (Optional) The configuration options to use for this computation.
  23092. *
  23093. * @return {WordArray} The derived key.
  23094. *
  23095. * @static
  23096. *
  23097. * @example
  23098. *
  23099. * var key = CryptoJS.EvpKDF(password, salt);
  23100. * var key = CryptoJS.EvpKDF(password, salt, { keySize: 8 });
  23101. * var key = CryptoJS.EvpKDF(password, salt, { keySize: 8, iterations: 1000 });
  23102. */
  23103. C.EvpKDF = function (password, salt, cfg) {
  23104. return EvpKDF.create(cfg).compute(password, salt);
  23105. };
  23106. }());
  23107. return CryptoJS.EvpKDF;
  23108. }));
  23109. },{"./core":478,"./hmac":482,"./sha1":484}],482:[function(_dereq_,module,exports){
  23110. ;(function (root, factory) {
  23111. if (typeof exports === "object") {
  23112. // CommonJS
  23113. module.exports = exports = factory(_dereq_("./core"));
  23114. }
  23115. else if (typeof define === "function" && define.amd) {
  23116. // AMD
  23117. define(["./core"], factory);
  23118. }
  23119. else {
  23120. // Global (browser)
  23121. factory(root.CryptoJS);
  23122. }
  23123. }(this, function (CryptoJS) {
  23124. (function () {
  23125. // Shortcuts
  23126. var C = CryptoJS;
  23127. var C_lib = C.lib;
  23128. var Base = C_lib.Base;
  23129. var C_enc = C.enc;
  23130. var Utf8 = C_enc.Utf8;
  23131. var C_algo = C.algo;
  23132. /**
  23133. * HMAC algorithm.
  23134. */
  23135. var HMAC = C_algo.HMAC = Base.extend({
  23136. /**
  23137. * Initializes a newly created HMAC.
  23138. *
  23139. * @param {Hasher} hasher The hash algorithm to use.
  23140. * @param {WordArray|string} key The secret key.
  23141. *
  23142. * @example
  23143. *
  23144. * var hmacHasher = CryptoJS.algo.HMAC.create(CryptoJS.algo.SHA256, key);
  23145. */
  23146. init: function (hasher, key) {
  23147. // Init hasher
  23148. hasher = this._hasher = new hasher.init();
  23149. // Convert string to WordArray, else assume WordArray already
  23150. if (typeof key == 'string') {
  23151. key = Utf8.parse(key);
  23152. }
  23153. // Shortcuts
  23154. var hasherBlockSize = hasher.blockSize;
  23155. var hasherBlockSizeBytes = hasherBlockSize * 4;
  23156. // Allow arbitrary length keys
  23157. if (key.sigBytes > hasherBlockSizeBytes) {
  23158. key = hasher.finalize(key);
  23159. }
  23160. // Clamp excess bits
  23161. key.clamp();
  23162. // Clone key for inner and outer pads
  23163. var oKey = this._oKey = key.clone();
  23164. var iKey = this._iKey = key.clone();
  23165. // Shortcuts
  23166. var oKeyWords = oKey.words;
  23167. var iKeyWords = iKey.words;
  23168. // XOR keys with pad constants
  23169. for (var i = 0; i < hasherBlockSize; i++) {
  23170. oKeyWords[i] ^= 0x5c5c5c5c;
  23171. iKeyWords[i] ^= 0x36363636;
  23172. }
  23173. oKey.sigBytes = iKey.sigBytes = hasherBlockSizeBytes;
  23174. // Set initial values
  23175. this.reset();
  23176. },
  23177. /**
  23178. * Resets this HMAC to its initial state.
  23179. *
  23180. * @example
  23181. *
  23182. * hmacHasher.reset();
  23183. */
  23184. reset: function () {
  23185. // Shortcut
  23186. var hasher = this._hasher;
  23187. // Reset
  23188. hasher.reset();
  23189. hasher.update(this._iKey);
  23190. },
  23191. /**
  23192. * Updates this HMAC with a message.
  23193. *
  23194. * @param {WordArray|string} messageUpdate The message to append.
  23195. *
  23196. * @return {HMAC} This HMAC instance.
  23197. *
  23198. * @example
  23199. *
  23200. * hmacHasher.update('message');
  23201. * hmacHasher.update(wordArray);
  23202. */
  23203. update: function (messageUpdate) {
  23204. this._hasher.update(messageUpdate);
  23205. // Chainable
  23206. return this;
  23207. },
  23208. /**
  23209. * Finalizes the HMAC computation.
  23210. * Note that the finalize operation is effectively a destructive, read-once operation.
  23211. *
  23212. * @param {WordArray|string} messageUpdate (Optional) A final message update.
  23213. *
  23214. * @return {WordArray} The HMAC.
  23215. *
  23216. * @example
  23217. *
  23218. * var hmac = hmacHasher.finalize();
  23219. * var hmac = hmacHasher.finalize('message');
  23220. * var hmac = hmacHasher.finalize(wordArray);
  23221. */
  23222. finalize: function (messageUpdate) {
  23223. // Shortcut
  23224. var hasher = this._hasher;
  23225. // Compute HMAC
  23226. var innerHash = hasher.finalize(messageUpdate);
  23227. hasher.reset();
  23228. var hmac = hasher.finalize(this._oKey.clone().concat(innerHash));
  23229. return hmac;
  23230. }
  23231. });
  23232. }());
  23233. }));
  23234. },{"./core":478}],483:[function(_dereq_,module,exports){
  23235. ;(function (root, factory) {
  23236. if (typeof exports === "object") {
  23237. // CommonJS
  23238. module.exports = exports = factory(_dereq_("./core"));
  23239. }
  23240. else if (typeof define === "function" && define.amd) {
  23241. // AMD
  23242. define(["./core"], factory);
  23243. }
  23244. else {
  23245. // Global (browser)
  23246. factory(root.CryptoJS);
  23247. }
  23248. }(this, function (CryptoJS) {
  23249. (function (Math) {
  23250. // Shortcuts
  23251. var C = CryptoJS;
  23252. var C_lib = C.lib;
  23253. var WordArray = C_lib.WordArray;
  23254. var Hasher = C_lib.Hasher;
  23255. var C_algo = C.algo;
  23256. // Constants table
  23257. var T = [];
  23258. // Compute constants
  23259. (function () {
  23260. for (var i = 0; i < 64; i++) {
  23261. T[i] = (Math.abs(Math.sin(i + 1)) * 0x100000000) | 0;
  23262. }
  23263. }());
  23264. /**
  23265. * MD5 hash algorithm.
  23266. */
  23267. var MD5 = C_algo.MD5 = Hasher.extend({
  23268. _doReset: function () {
  23269. this._hash = new WordArray.init([
  23270. 0x67452301, 0xefcdab89,
  23271. 0x98badcfe, 0x10325476
  23272. ]);
  23273. },
  23274. _doProcessBlock: function (M, offset) {
  23275. // Swap endian
  23276. for (var i = 0; i < 16; i++) {
  23277. // Shortcuts
  23278. var offset_i = offset + i;
  23279. var M_offset_i = M[offset_i];
  23280. M[offset_i] = (
  23281. (((M_offset_i << 8) | (M_offset_i >>> 24)) & 0x00ff00ff) |
  23282. (((M_offset_i << 24) | (M_offset_i >>> 8)) & 0xff00ff00)
  23283. );
  23284. }
  23285. // Shortcuts
  23286. var H = this._hash.words;
  23287. var M_offset_0 = M[offset + 0];
  23288. var M_offset_1 = M[offset + 1];
  23289. var M_offset_2 = M[offset + 2];
  23290. var M_offset_3 = M[offset + 3];
  23291. var M_offset_4 = M[offset + 4];
  23292. var M_offset_5 = M[offset + 5];
  23293. var M_offset_6 = M[offset + 6];
  23294. var M_offset_7 = M[offset + 7];
  23295. var M_offset_8 = M[offset + 8];
  23296. var M_offset_9 = M[offset + 9];
  23297. var M_offset_10 = M[offset + 10];
  23298. var M_offset_11 = M[offset + 11];
  23299. var M_offset_12 = M[offset + 12];
  23300. var M_offset_13 = M[offset + 13];
  23301. var M_offset_14 = M[offset + 14];
  23302. var M_offset_15 = M[offset + 15];
  23303. // Working variables
  23304. var a = H[0];
  23305. var b = H[1];
  23306. var c = H[2];
  23307. var d = H[3];
  23308. // Computation
  23309. a = FF(a, b, c, d, M_offset_0, 7, T[0]);
  23310. d = FF(d, a, b, c, M_offset_1, 12, T[1]);
  23311. c = FF(c, d, a, b, M_offset_2, 17, T[2]);
  23312. b = FF(b, c, d, a, M_offset_3, 22, T[3]);
  23313. a = FF(a, b, c, d, M_offset_4, 7, T[4]);
  23314. d = FF(d, a, b, c, M_offset_5, 12, T[5]);
  23315. c = FF(c, d, a, b, M_offset_6, 17, T[6]);
  23316. b = FF(b, c, d, a, M_offset_7, 22, T[7]);
  23317. a = FF(a, b, c, d, M_offset_8, 7, T[8]);
  23318. d = FF(d, a, b, c, M_offset_9, 12, T[9]);
  23319. c = FF(c, d, a, b, M_offset_10, 17, T[10]);
  23320. b = FF(b, c, d, a, M_offset_11, 22, T[11]);
  23321. a = FF(a, b, c, d, M_offset_12, 7, T[12]);
  23322. d = FF(d, a, b, c, M_offset_13, 12, T[13]);
  23323. c = FF(c, d, a, b, M_offset_14, 17, T[14]);
  23324. b = FF(b, c, d, a, M_offset_15, 22, T[15]);
  23325. a = GG(a, b, c, d, M_offset_1, 5, T[16]);
  23326. d = GG(d, a, b, c, M_offset_6, 9, T[17]);
  23327. c = GG(c, d, a, b, M_offset_11, 14, T[18]);
  23328. b = GG(b, c, d, a, M_offset_0, 20, T[19]);
  23329. a = GG(a, b, c, d, M_offset_5, 5, T[20]);
  23330. d = GG(d, a, b, c, M_offset_10, 9, T[21]);
  23331. c = GG(c, d, a, b, M_offset_15, 14, T[22]);
  23332. b = GG(b, c, d, a, M_offset_4, 20, T[23]);
  23333. a = GG(a, b, c, d, M_offset_9, 5, T[24]);
  23334. d = GG(d, a, b, c, M_offset_14, 9, T[25]);
  23335. c = GG(c, d, a, b, M_offset_3, 14, T[26]);
  23336. b = GG(b, c, d, a, M_offset_8, 20, T[27]);
  23337. a = GG(a, b, c, d, M_offset_13, 5, T[28]);
  23338. d = GG(d, a, b, c, M_offset_2, 9, T[29]);
  23339. c = GG(c, d, a, b, M_offset_7, 14, T[30]);
  23340. b = GG(b, c, d, a, M_offset_12, 20, T[31]);
  23341. a = HH(a, b, c, d, M_offset_5, 4, T[32]);
  23342. d = HH(d, a, b, c, M_offset_8, 11, T[33]);
  23343. c = HH(c, d, a, b, M_offset_11, 16, T[34]);
  23344. b = HH(b, c, d, a, M_offset_14, 23, T[35]);
  23345. a = HH(a, b, c, d, M_offset_1, 4, T[36]);
  23346. d = HH(d, a, b, c, M_offset_4, 11, T[37]);
  23347. c = HH(c, d, a, b, M_offset_7, 16, T[38]);
  23348. b = HH(b, c, d, a, M_offset_10, 23, T[39]);
  23349. a = HH(a, b, c, d, M_offset_13, 4, T[40]);
  23350. d = HH(d, a, b, c, M_offset_0, 11, T[41]);
  23351. c = HH(c, d, a, b, M_offset_3, 16, T[42]);
  23352. b = HH(b, c, d, a, M_offset_6, 23, T[43]);
  23353. a = HH(a, b, c, d, M_offset_9, 4, T[44]);
  23354. d = HH(d, a, b, c, M_offset_12, 11, T[45]);
  23355. c = HH(c, d, a, b, M_offset_15, 16, T[46]);
  23356. b = HH(b, c, d, a, M_offset_2, 23, T[47]);
  23357. a = II(a, b, c, d, M_offset_0, 6, T[48]);
  23358. d = II(d, a, b, c, M_offset_7, 10, T[49]);
  23359. c = II(c, d, a, b, M_offset_14, 15, T[50]);
  23360. b = II(b, c, d, a, M_offset_5, 21, T[51]);
  23361. a = II(a, b, c, d, M_offset_12, 6, T[52]);
  23362. d = II(d, a, b, c, M_offset_3, 10, T[53]);
  23363. c = II(c, d, a, b, M_offset_10, 15, T[54]);
  23364. b = II(b, c, d, a, M_offset_1, 21, T[55]);
  23365. a = II(a, b, c, d, M_offset_8, 6, T[56]);
  23366. d = II(d, a, b, c, M_offset_15, 10, T[57]);
  23367. c = II(c, d, a, b, M_offset_6, 15, T[58]);
  23368. b = II(b, c, d, a, M_offset_13, 21, T[59]);
  23369. a = II(a, b, c, d, M_offset_4, 6, T[60]);
  23370. d = II(d, a, b, c, M_offset_11, 10, T[61]);
  23371. c = II(c, d, a, b, M_offset_2, 15, T[62]);
  23372. b = II(b, c, d, a, M_offset_9, 21, T[63]);
  23373. // Intermediate hash value
  23374. H[0] = (H[0] + a) | 0;
  23375. H[1] = (H[1] + b) | 0;
  23376. H[2] = (H[2] + c) | 0;
  23377. H[3] = (H[3] + d) | 0;
  23378. },
  23379. _doFinalize: function () {
  23380. // Shortcuts
  23381. var data = this._data;
  23382. var dataWords = data.words;
  23383. var nBitsTotal = this._nDataBytes * 8;
  23384. var nBitsLeft = data.sigBytes * 8;
  23385. // Add padding
  23386. dataWords[nBitsLeft >>> 5] |= 0x80 << (24 - nBitsLeft % 32);
  23387. var nBitsTotalH = Math.floor(nBitsTotal / 0x100000000);
  23388. var nBitsTotalL = nBitsTotal;
  23389. dataWords[(((nBitsLeft + 64) >>> 9) << 4) + 15] = (
  23390. (((nBitsTotalH << 8) | (nBitsTotalH >>> 24)) & 0x00ff00ff) |
  23391. (((nBitsTotalH << 24) | (nBitsTotalH >>> 8)) & 0xff00ff00)
  23392. );
  23393. dataWords[(((nBitsLeft + 64) >>> 9) << 4) + 14] = (
  23394. (((nBitsTotalL << 8) | (nBitsTotalL >>> 24)) & 0x00ff00ff) |
  23395. (((nBitsTotalL << 24) | (nBitsTotalL >>> 8)) & 0xff00ff00)
  23396. );
  23397. data.sigBytes = (dataWords.length + 1) * 4;
  23398. // Hash final blocks
  23399. this._process();
  23400. // Shortcuts
  23401. var hash = this._hash;
  23402. var H = hash.words;
  23403. // Swap endian
  23404. for (var i = 0; i < 4; i++) {
  23405. // Shortcut
  23406. var H_i = H[i];
  23407. H[i] = (((H_i << 8) | (H_i >>> 24)) & 0x00ff00ff) |
  23408. (((H_i << 24) | (H_i >>> 8)) & 0xff00ff00);
  23409. }
  23410. // Return final computed hash
  23411. return hash;
  23412. },
  23413. clone: function () {
  23414. var clone = Hasher.clone.call(this);
  23415. clone._hash = this._hash.clone();
  23416. return clone;
  23417. }
  23418. });
  23419. function FF(a, b, c, d, x, s, t) {
  23420. var n = a + ((b & c) | (~b & d)) + x + t;
  23421. return ((n << s) | (n >>> (32 - s))) + b;
  23422. }
  23423. function GG(a, b, c, d, x, s, t) {
  23424. var n = a + ((b & d) | (c & ~d)) + x + t;
  23425. return ((n << s) | (n >>> (32 - s))) + b;
  23426. }
  23427. function HH(a, b, c, d, x, s, t) {
  23428. var n = a + (b ^ c ^ d) + x + t;
  23429. return ((n << s) | (n >>> (32 - s))) + b;
  23430. }
  23431. function II(a, b, c, d, x, s, t) {
  23432. var n = a + (c ^ (b | ~d)) + x + t;
  23433. return ((n << s) | (n >>> (32 - s))) + b;
  23434. }
  23435. /**
  23436. * Shortcut function to the hasher's object interface.
  23437. *
  23438. * @param {WordArray|string} message The message to hash.
  23439. *
  23440. * @return {WordArray} The hash.
  23441. *
  23442. * @static
  23443. *
  23444. * @example
  23445. *
  23446. * var hash = CryptoJS.MD5('message');
  23447. * var hash = CryptoJS.MD5(wordArray);
  23448. */
  23449. C.MD5 = Hasher._createHelper(MD5);
  23450. /**
  23451. * Shortcut function to the HMAC's object interface.
  23452. *
  23453. * @param {WordArray|string} message The message to hash.
  23454. * @param {WordArray|string} key The secret key.
  23455. *
  23456. * @return {WordArray} The HMAC.
  23457. *
  23458. * @static
  23459. *
  23460. * @example
  23461. *
  23462. * var hmac = CryptoJS.HmacMD5(message, key);
  23463. */
  23464. C.HmacMD5 = Hasher._createHmacHelper(MD5);
  23465. }(Math));
  23466. return CryptoJS.MD5;
  23467. }));
  23468. },{"./core":478}],484:[function(_dereq_,module,exports){
  23469. ;(function (root, factory) {
  23470. if (typeof exports === "object") {
  23471. // CommonJS
  23472. module.exports = exports = factory(_dereq_("./core"));
  23473. }
  23474. else if (typeof define === "function" && define.amd) {
  23475. // AMD
  23476. define(["./core"], factory);
  23477. }
  23478. else {
  23479. // Global (browser)
  23480. factory(root.CryptoJS);
  23481. }
  23482. }(this, function (CryptoJS) {
  23483. (function () {
  23484. // Shortcuts
  23485. var C = CryptoJS;
  23486. var C_lib = C.lib;
  23487. var WordArray = C_lib.WordArray;
  23488. var Hasher = C_lib.Hasher;
  23489. var C_algo = C.algo;
  23490. // Reusable object
  23491. var W = [];
  23492. /**
  23493. * SHA-1 hash algorithm.
  23494. */
  23495. var SHA1 = C_algo.SHA1 = Hasher.extend({
  23496. _doReset: function () {
  23497. this._hash = new WordArray.init([
  23498. 0x67452301, 0xefcdab89,
  23499. 0x98badcfe, 0x10325476,
  23500. 0xc3d2e1f0
  23501. ]);
  23502. },
  23503. _doProcessBlock: function (M, offset) {
  23504. // Shortcut
  23505. var H = this._hash.words;
  23506. // Working variables
  23507. var a = H[0];
  23508. var b = H[1];
  23509. var c = H[2];
  23510. var d = H[3];
  23511. var e = H[4];
  23512. // Computation
  23513. for (var i = 0; i < 80; i++) {
  23514. if (i < 16) {
  23515. W[i] = M[offset + i] | 0;
  23516. } else {
  23517. var n = W[i - 3] ^ W[i - 8] ^ W[i - 14] ^ W[i - 16];
  23518. W[i] = (n << 1) | (n >>> 31);
  23519. }
  23520. var t = ((a << 5) | (a >>> 27)) + e + W[i];
  23521. if (i < 20) {
  23522. t += ((b & c) | (~b & d)) + 0x5a827999;
  23523. } else if (i < 40) {
  23524. t += (b ^ c ^ d) + 0x6ed9eba1;
  23525. } else if (i < 60) {
  23526. t += ((b & c) | (b & d) | (c & d)) - 0x70e44324;
  23527. } else /* if (i < 80) */ {
  23528. t += (b ^ c ^ d) - 0x359d3e2a;
  23529. }
  23530. e = d;
  23531. d = c;
  23532. c = (b << 30) | (b >>> 2);
  23533. b = a;
  23534. a = t;
  23535. }
  23536. // Intermediate hash value
  23537. H[0] = (H[0] + a) | 0;
  23538. H[1] = (H[1] + b) | 0;
  23539. H[2] = (H[2] + c) | 0;
  23540. H[3] = (H[3] + d) | 0;
  23541. H[4] = (H[4] + e) | 0;
  23542. },
  23543. _doFinalize: function () {
  23544. // Shortcuts
  23545. var data = this._data;
  23546. var dataWords = data.words;
  23547. var nBitsTotal = this._nDataBytes * 8;
  23548. var nBitsLeft = data.sigBytes * 8;
  23549. // Add padding
  23550. dataWords[nBitsLeft >>> 5] |= 0x80 << (24 - nBitsLeft % 32);
  23551. dataWords[(((nBitsLeft + 64) >>> 9) << 4) + 14] = Math.floor(nBitsTotal / 0x100000000);
  23552. dataWords[(((nBitsLeft + 64) >>> 9) << 4) + 15] = nBitsTotal;
  23553. data.sigBytes = dataWords.length * 4;
  23554. // Hash final blocks
  23555. this._process();
  23556. // Return final computed hash
  23557. return this._hash;
  23558. },
  23559. clone: function () {
  23560. var clone = Hasher.clone.call(this);
  23561. clone._hash = this._hash.clone();
  23562. return clone;
  23563. }
  23564. });
  23565. /**
  23566. * Shortcut function to the hasher's object interface.
  23567. *
  23568. * @param {WordArray|string} message The message to hash.
  23569. *
  23570. * @return {WordArray} The hash.
  23571. *
  23572. * @static
  23573. *
  23574. * @example
  23575. *
  23576. * var hash = CryptoJS.SHA1('message');
  23577. * var hash = CryptoJS.SHA1(wordArray);
  23578. */
  23579. C.SHA1 = Hasher._createHelper(SHA1);
  23580. /**
  23581. * Shortcut function to the HMAC's object interface.
  23582. *
  23583. * @param {WordArray|string} message The message to hash.
  23584. * @param {WordArray|string} key The secret key.
  23585. *
  23586. * @return {WordArray} The HMAC.
  23587. *
  23588. * @static
  23589. *
  23590. * @example
  23591. *
  23592. * var hmac = CryptoJS.HmacSHA1(message, key);
  23593. */
  23594. C.HmacSHA1 = Hasher._createHmacHelper(SHA1);
  23595. }());
  23596. return CryptoJS.SHA1;
  23597. }));
  23598. },{"./core":478}],485:[function(_dereq_,module,exports){
  23599. // Copyright Joyent, Inc. and other Node contributors.
  23600. //
  23601. // Permission is hereby granted, free of charge, to any person obtaining a
  23602. // copy of this software and associated documentation files (the
  23603. // "Software"), to deal in the Software without restriction, including
  23604. // without limitation the rights to use, copy, modify, merge, publish,
  23605. // distribute, sublicense, and/or sell copies of the Software, and to permit
  23606. // persons to whom the Software is furnished to do so, subject to the
  23607. // following conditions:
  23608. //
  23609. // The above copyright notice and this permission notice shall be included
  23610. // in all copies or substantial portions of the Software.
  23611. //
  23612. // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
  23613. // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
  23614. // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
  23615. // NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
  23616. // DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
  23617. // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
  23618. // USE OR OTHER DEALINGS IN THE SOFTWARE.
  23619. 'use strict';
  23620. var R = typeof Reflect === 'object' ? Reflect : null
  23621. var ReflectApply = R && typeof R.apply === 'function'
  23622. ? R.apply
  23623. : function ReflectApply(target, receiver, args) {
  23624. return Function.prototype.apply.call(target, receiver, args);
  23625. }
  23626. var ReflectOwnKeys
  23627. if (R && typeof R.ownKeys === 'function') {
  23628. ReflectOwnKeys = R.ownKeys
  23629. } else if (Object.getOwnPropertySymbols) {
  23630. ReflectOwnKeys = function ReflectOwnKeys(target) {
  23631. return Object.getOwnPropertyNames(target)
  23632. .concat(Object.getOwnPropertySymbols(target));
  23633. };
  23634. } else {
  23635. ReflectOwnKeys = function ReflectOwnKeys(target) {
  23636. return Object.getOwnPropertyNames(target);
  23637. };
  23638. }
  23639. function ProcessEmitWarning(warning) {
  23640. if (console && console.warn) console.warn(warning);
  23641. }
  23642. var NumberIsNaN = Number.isNaN || function NumberIsNaN(value) {
  23643. return value !== value;
  23644. }
  23645. function EventEmitter() {
  23646. EventEmitter.init.call(this);
  23647. }
  23648. module.exports = EventEmitter;
  23649. module.exports.once = once;
  23650. // Backwards-compat with node 0.10.x
  23651. EventEmitter.EventEmitter = EventEmitter;
  23652. EventEmitter.prototype._events = undefined;
  23653. EventEmitter.prototype._eventsCount = 0;
  23654. EventEmitter.prototype._maxListeners = undefined;
  23655. // By default EventEmitters will print a warning if more than 10 listeners are
  23656. // added to it. This is a useful default which helps finding memory leaks.
  23657. var defaultMaxListeners = 10;
  23658. function checkListener(listener) {
  23659. if (typeof listener !== 'function') {
  23660. throw new TypeError('The "listener" argument must be of type Function. Received type ' + typeof listener);
  23661. }
  23662. }
  23663. Object.defineProperty(EventEmitter, 'defaultMaxListeners', {
  23664. enumerable: true,
  23665. get: function() {
  23666. return defaultMaxListeners;
  23667. },
  23668. set: function(arg) {
  23669. if (typeof arg !== 'number' || arg < 0 || NumberIsNaN(arg)) {
  23670. throw new RangeError('The value of "defaultMaxListeners" is out of range. It must be a non-negative number. Received ' + arg + '.');
  23671. }
  23672. defaultMaxListeners = arg;
  23673. }
  23674. });
  23675. EventEmitter.init = function() {
  23676. if (this._events === undefined ||
  23677. this._events === Object.getPrototypeOf(this)._events) {
  23678. this._events = Object.create(null);
  23679. this._eventsCount = 0;
  23680. }
  23681. this._maxListeners = this._maxListeners || undefined;
  23682. };
  23683. // Obviously not all Emitters should be limited to 10. This function allows
  23684. // that to be increased. Set to zero for unlimited.
  23685. EventEmitter.prototype.setMaxListeners = function setMaxListeners(n) {
  23686. if (typeof n !== 'number' || n < 0 || NumberIsNaN(n)) {
  23687. throw new RangeError('The value of "n" is out of range. It must be a non-negative number. Received ' + n + '.');
  23688. }
  23689. this._maxListeners = n;
  23690. return this;
  23691. };
  23692. function _getMaxListeners(that) {
  23693. if (that._maxListeners === undefined)
  23694. return EventEmitter.defaultMaxListeners;
  23695. return that._maxListeners;
  23696. }
  23697. EventEmitter.prototype.getMaxListeners = function getMaxListeners() {
  23698. return _getMaxListeners(this);
  23699. };
  23700. EventEmitter.prototype.emit = function emit(type) {
  23701. var args = [];
  23702. for (var i = 1; i < arguments.length; i++) args.push(arguments[i]);
  23703. var doError = (type === 'error');
  23704. var events = this._events;
  23705. if (events !== undefined)
  23706. doError = (doError && events.error === undefined);
  23707. else if (!doError)
  23708. return false;
  23709. // If there is no 'error' event listener then throw.
  23710. if (doError) {
  23711. var er;
  23712. if (args.length > 0)
  23713. er = args[0];
  23714. if (er instanceof Error) {
  23715. // Note: The comments on the `throw` lines are intentional, they show
  23716. // up in Node's output if this results in an unhandled exception.
  23717. throw er; // Unhandled 'error' event
  23718. }
  23719. // At least give some kind of context to the user
  23720. var err = new Error('Unhandled error.' + (er ? ' (' + er.message + ')' : ''));
  23721. err.context = er;
  23722. throw err; // Unhandled 'error' event
  23723. }
  23724. var handler = events[type];
  23725. if (handler === undefined)
  23726. return false;
  23727. if (typeof handler === 'function') {
  23728. ReflectApply(handler, this, args);
  23729. } else {
  23730. var len = handler.length;
  23731. var listeners = arrayClone(handler, len);
  23732. for (var i = 0; i < len; ++i)
  23733. ReflectApply(listeners[i], this, args);
  23734. }
  23735. return true;
  23736. };
  23737. function _addListener(target, type, listener, prepend) {
  23738. var m;
  23739. var events;
  23740. var existing;
  23741. checkListener(listener);
  23742. events = target._events;
  23743. if (events === undefined) {
  23744. events = target._events = Object.create(null);
  23745. target._eventsCount = 0;
  23746. } else {
  23747. // To avoid recursion in the case that type === "newListener"! Before
  23748. // adding it to the listeners, first emit "newListener".
  23749. if (events.newListener !== undefined) {
  23750. target.emit('newListener', type,
  23751. listener.listener ? listener.listener : listener);
  23752. // Re-assign `events` because a newListener handler could have caused the
  23753. // this._events to be assigned to a new object
  23754. events = target._events;
  23755. }
  23756. existing = events[type];
  23757. }
  23758. if (existing === undefined) {
  23759. // Optimize the case of one listener. Don't need the extra array object.
  23760. existing = events[type] = listener;
  23761. ++target._eventsCount;
  23762. } else {
  23763. if (typeof existing === 'function') {
  23764. // Adding the second element, need to change to array.
  23765. existing = events[type] =
  23766. prepend ? [listener, existing] : [existing, listener];
  23767. // If we've already got an array, just append.
  23768. } else if (prepend) {
  23769. existing.unshift(listener);
  23770. } else {
  23771. existing.push(listener);
  23772. }
  23773. // Check for listener leak
  23774. m = _getMaxListeners(target);
  23775. if (m > 0 && existing.length > m && !existing.warned) {
  23776. existing.warned = true;
  23777. // No error code for this since it is a Warning
  23778. // eslint-disable-next-line no-restricted-syntax
  23779. var w = new Error('Possible EventEmitter memory leak detected. ' +
  23780. existing.length + ' ' + String(type) + ' listeners ' +
  23781. 'added. Use emitter.setMaxListeners() to ' +
  23782. 'increase limit');
  23783. w.name = 'MaxListenersExceededWarning';
  23784. w.emitter = target;
  23785. w.type = type;
  23786. w.count = existing.length;
  23787. ProcessEmitWarning(w);
  23788. }
  23789. }
  23790. return target;
  23791. }
  23792. EventEmitter.prototype.addListener = function addListener(type, listener) {
  23793. return _addListener(this, type, listener, false);
  23794. };
  23795. EventEmitter.prototype.on = EventEmitter.prototype.addListener;
  23796. EventEmitter.prototype.prependListener =
  23797. function prependListener(type, listener) {
  23798. return _addListener(this, type, listener, true);
  23799. };
  23800. function onceWrapper() {
  23801. if (!this.fired) {
  23802. this.target.removeListener(this.type, this.wrapFn);
  23803. this.fired = true;
  23804. if (arguments.length === 0)
  23805. return this.listener.call(this.target);
  23806. return this.listener.apply(this.target, arguments);
  23807. }
  23808. }
  23809. function _onceWrap(target, type, listener) {
  23810. var state = { fired: false, wrapFn: undefined, target: target, type: type, listener: listener };
  23811. var wrapped = onceWrapper.bind(state);
  23812. wrapped.listener = listener;
  23813. state.wrapFn = wrapped;
  23814. return wrapped;
  23815. }
  23816. EventEmitter.prototype.once = function once(type, listener) {
  23817. checkListener(listener);
  23818. this.on(type, _onceWrap(this, type, listener));
  23819. return this;
  23820. };
  23821. EventEmitter.prototype.prependOnceListener =
  23822. function prependOnceListener(type, listener) {
  23823. checkListener(listener);
  23824. this.prependListener(type, _onceWrap(this, type, listener));
  23825. return this;
  23826. };
  23827. // Emits a 'removeListener' event if and only if the listener was removed.
  23828. EventEmitter.prototype.removeListener =
  23829. function removeListener(type, listener) {
  23830. var list, events, position, i, originalListener;
  23831. checkListener(listener);
  23832. events = this._events;
  23833. if (events === undefined)
  23834. return this;
  23835. list = events[type];
  23836. if (list === undefined)
  23837. return this;
  23838. if (list === listener || list.listener === listener) {
  23839. if (--this._eventsCount === 0)
  23840. this._events = Object.create(null);
  23841. else {
  23842. delete events[type];
  23843. if (events.removeListener)
  23844. this.emit('removeListener', type, list.listener || listener);
  23845. }
  23846. } else if (typeof list !== 'function') {
  23847. position = -1;
  23848. for (i = list.length - 1; i >= 0; i--) {
  23849. if (list[i] === listener || list[i].listener === listener) {
  23850. originalListener = list[i].listener;
  23851. position = i;
  23852. break;
  23853. }
  23854. }
  23855. if (position < 0)
  23856. return this;
  23857. if (position === 0)
  23858. list.shift();
  23859. else {
  23860. spliceOne(list, position);
  23861. }
  23862. if (list.length === 1)
  23863. events[type] = list[0];
  23864. if (events.removeListener !== undefined)
  23865. this.emit('removeListener', type, originalListener || listener);
  23866. }
  23867. return this;
  23868. };
  23869. EventEmitter.prototype.off = EventEmitter.prototype.removeListener;
  23870. EventEmitter.prototype.removeAllListeners =
  23871. function removeAllListeners(type) {
  23872. var listeners, events, i;
  23873. events = this._events;
  23874. if (events === undefined)
  23875. return this;
  23876. // not listening for removeListener, no need to emit
  23877. if (events.removeListener === undefined) {
  23878. if (arguments.length === 0) {
  23879. this._events = Object.create(null);
  23880. this._eventsCount = 0;
  23881. } else if (events[type] !== undefined) {
  23882. if (--this._eventsCount === 0)
  23883. this._events = Object.create(null);
  23884. else
  23885. delete events[type];
  23886. }
  23887. return this;
  23888. }
  23889. // emit removeListener for all listeners on all events
  23890. if (arguments.length === 0) {
  23891. var keys = Object.keys(events);
  23892. var key;
  23893. for (i = 0; i < keys.length; ++i) {
  23894. key = keys[i];
  23895. if (key === 'removeListener') continue;
  23896. this.removeAllListeners(key);
  23897. }
  23898. this.removeAllListeners('removeListener');
  23899. this._events = Object.create(null);
  23900. this._eventsCount = 0;
  23901. return this;
  23902. }
  23903. listeners = events[type];
  23904. if (typeof listeners === 'function') {
  23905. this.removeListener(type, listeners);
  23906. } else if (listeners !== undefined) {
  23907. // LIFO order
  23908. for (i = listeners.length - 1; i >= 0; i--) {
  23909. this.removeListener(type, listeners[i]);
  23910. }
  23911. }
  23912. return this;
  23913. };
  23914. function _listeners(target, type, unwrap) {
  23915. var events = target._events;
  23916. if (events === undefined)
  23917. return [];
  23918. var evlistener = events[type];
  23919. if (evlistener === undefined)
  23920. return [];
  23921. if (typeof evlistener === 'function')
  23922. return unwrap ? [evlistener.listener || evlistener] : [evlistener];
  23923. return unwrap ?
  23924. unwrapListeners(evlistener) : arrayClone(evlistener, evlistener.length);
  23925. }
  23926. EventEmitter.prototype.listeners = function listeners(type) {
  23927. return _listeners(this, type, true);
  23928. };
  23929. EventEmitter.prototype.rawListeners = function rawListeners(type) {
  23930. return _listeners(this, type, false);
  23931. };
  23932. EventEmitter.listenerCount = function(emitter, type) {
  23933. if (typeof emitter.listenerCount === 'function') {
  23934. return emitter.listenerCount(type);
  23935. } else {
  23936. return listenerCount.call(emitter, type);
  23937. }
  23938. };
  23939. EventEmitter.prototype.listenerCount = listenerCount;
  23940. function listenerCount(type) {
  23941. var events = this._events;
  23942. if (events !== undefined) {
  23943. var evlistener = events[type];
  23944. if (typeof evlistener === 'function') {
  23945. return 1;
  23946. } else if (evlistener !== undefined) {
  23947. return evlistener.length;
  23948. }
  23949. }
  23950. return 0;
  23951. }
  23952. EventEmitter.prototype.eventNames = function eventNames() {
  23953. return this._eventsCount > 0 ? ReflectOwnKeys(this._events) : [];
  23954. };
  23955. function arrayClone(arr, n) {
  23956. var copy = new Array(n);
  23957. for (var i = 0; i < n; ++i)
  23958. copy[i] = arr[i];
  23959. return copy;
  23960. }
  23961. function spliceOne(list, index) {
  23962. for (; index + 1 < list.length; index++)
  23963. list[index] = list[index + 1];
  23964. list.pop();
  23965. }
  23966. function unwrapListeners(arr) {
  23967. var ret = new Array(arr.length);
  23968. for (var i = 0; i < ret.length; ++i) {
  23969. ret[i] = arr[i].listener || arr[i];
  23970. }
  23971. return ret;
  23972. }
  23973. function once(emitter, name) {
  23974. return new Promise(function (resolve, reject) {
  23975. function errorListener(err) {
  23976. emitter.removeListener(name, resolver);
  23977. reject(err);
  23978. }
  23979. function resolver() {
  23980. if (typeof emitter.removeListener === 'function') {
  23981. emitter.removeListener('error', errorListener);
  23982. }
  23983. resolve([].slice.call(arguments));
  23984. };
  23985. eventTargetAgnosticAddListener(emitter, name, resolver, { once: true });
  23986. if (name !== 'error') {
  23987. addErrorHandlerIfEventEmitter(emitter, errorListener, { once: true });
  23988. }
  23989. });
  23990. }
  23991. function addErrorHandlerIfEventEmitter(emitter, handler, flags) {
  23992. if (typeof emitter.on === 'function') {
  23993. eventTargetAgnosticAddListener(emitter, 'error', handler, flags);
  23994. }
  23995. }
  23996. function eventTargetAgnosticAddListener(emitter, name, listener, flags) {
  23997. if (typeof emitter.on === 'function') {
  23998. if (flags.once) {
  23999. emitter.once(name, listener);
  24000. } else {
  24001. emitter.on(name, listener);
  24002. }
  24003. } else if (typeof emitter.addEventListener === 'function') {
  24004. // EventTarget does not have `error` event semantics like Node
  24005. // EventEmitters, we do not listen for `error` events here.
  24006. emitter.addEventListener(name, function wrapListener(arg) {
  24007. // IE does not have builtin `{ once: true }` support so we
  24008. // have to do it manually.
  24009. if (flags.once) {
  24010. emitter.removeEventListener(name, wrapListener);
  24011. }
  24012. listener(arg);
  24013. });
  24014. } else {
  24015. throw new TypeError('The "emitter" argument must be of type EventEmitter. Received type ' + typeof emitter);
  24016. }
  24017. }
  24018. },{}],486:[function(_dereq_,module,exports){
  24019. 'use strict';
  24020. function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
  24021. function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
  24022. function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
  24023. function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
  24024. function _iterableToArrayLimit(arr, i) { var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"]; if (_i == null) return; var _arr = []; var _n = true; var _d = false; var _s, _e; try { for (_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"] != null) _i["return"](); } finally { if (_d) throw _e; } } return _arr; }
  24025. function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
  24026. Object.defineProperty(exports, '__esModule', {
  24027. value: true
  24028. });
  24029. function promisifyRequest(request) {
  24030. return new Promise(function (resolve, reject) {
  24031. // @ts-ignore - file size hacks
  24032. request.oncomplete = request.onsuccess = function () {
  24033. return resolve(request.result);
  24034. }; // @ts-ignore - file size hacks
  24035. request.onabort = request.onerror = function () {
  24036. return reject(request.error);
  24037. };
  24038. });
  24039. }
  24040. function createStore(dbName, storeName) {
  24041. var request = indexedDB.open(dbName);
  24042. request.onupgradeneeded = function () {
  24043. return request.result.createObjectStore(storeName);
  24044. };
  24045. var dbp = promisifyRequest(request);
  24046. return function (txMode, callback) {
  24047. return dbp.then(function (db) {
  24048. return callback(db.transaction(storeName, txMode).objectStore(storeName));
  24049. });
  24050. };
  24051. }
  24052. var defaultGetStoreFunc;
  24053. function defaultGetStore() {
  24054. if (!defaultGetStoreFunc) {
  24055. defaultGetStoreFunc = createStore('keyval-store', 'keyval');
  24056. }
  24057. return defaultGetStoreFunc;
  24058. }
  24059. /**
  24060. * Get a value by its key.
  24061. *
  24062. * @param key
  24063. * @param customStore Method to get a custom store. Use with caution (see the docs).
  24064. */
  24065. function get(key) {
  24066. var customStore = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : defaultGetStore();
  24067. return customStore('readonly', function (store) {
  24068. return promisifyRequest(store.get(key));
  24069. });
  24070. }
  24071. /**
  24072. * Set a value with a key.
  24073. *
  24074. * @param key
  24075. * @param value
  24076. * @param customStore Method to get a custom store. Use with caution (see the docs).
  24077. */
  24078. function set(key, value) {
  24079. var customStore = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : defaultGetStore();
  24080. return customStore('readwrite', function (store) {
  24081. store.put(value, key);
  24082. return promisifyRequest(store.transaction);
  24083. });
  24084. }
  24085. /**
  24086. * Set multiple values at once. This is faster than calling set() multiple times.
  24087. * It's also atomic – if one of the pairs can't be added, none will be added.
  24088. *
  24089. * @param entries Array of entries, where each entry is an array of `[key, value]`.
  24090. * @param customStore Method to get a custom store. Use with caution (see the docs).
  24091. */
  24092. function setMany(entries) {
  24093. var customStore = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : defaultGetStore();
  24094. return customStore('readwrite', function (store) {
  24095. entries.forEach(function (entry) {
  24096. return store.put(entry[1], entry[0]);
  24097. });
  24098. return promisifyRequest(store.transaction);
  24099. });
  24100. }
  24101. /**
  24102. * Get multiple values by their keys
  24103. *
  24104. * @param keys
  24105. * @param customStore Method to get a custom store. Use with caution (see the docs).
  24106. */
  24107. function getMany(keys) {
  24108. var customStore = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : defaultGetStore();
  24109. return customStore('readonly', function (store) {
  24110. return Promise.all(keys.map(function (key) {
  24111. return promisifyRequest(store.get(key));
  24112. }));
  24113. });
  24114. }
  24115. /**
  24116. * Update a value. This lets you see the old value and update it as an atomic operation.
  24117. *
  24118. * @param key
  24119. * @param updater A callback that takes the old value and returns a new value.
  24120. * @param customStore Method to get a custom store. Use with caution (see the docs).
  24121. */
  24122. function update(key, updater) {
  24123. var customStore = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : defaultGetStore();
  24124. return customStore('readwrite', function (store) {
  24125. return (// Need to create the promise manually.
  24126. // If I try to chain promises, the transaction closes in browsers
  24127. // that use a promise polyfill (IE10/11).
  24128. new Promise(function (resolve, reject) {
  24129. store.get(key).onsuccess = function () {
  24130. try {
  24131. store.put(updater(this.result), key);
  24132. resolve(promisifyRequest(store.transaction));
  24133. } catch (err) {
  24134. reject(err);
  24135. }
  24136. };
  24137. })
  24138. );
  24139. });
  24140. }
  24141. /**
  24142. * Delete a particular key from the store.
  24143. *
  24144. * @param key
  24145. * @param customStore Method to get a custom store. Use with caution (see the docs).
  24146. */
  24147. function del(key) {
  24148. var customStore = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : defaultGetStore();
  24149. return customStore('readwrite', function (store) {
  24150. store.delete(key);
  24151. return promisifyRequest(store.transaction);
  24152. });
  24153. }
  24154. /**
  24155. * Delete multiple keys at once.
  24156. *
  24157. * @param keys List of keys to delete.
  24158. * @param customStore Method to get a custom store. Use with caution (see the docs).
  24159. */
  24160. function delMany(keys) {
  24161. var customStore = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : defaultGetStore();
  24162. return customStore('readwrite', function (store) {
  24163. keys.forEach(function (key) {
  24164. return store.delete(key);
  24165. });
  24166. return promisifyRequest(store.transaction);
  24167. });
  24168. }
  24169. /**
  24170. * Clear all values in the store.
  24171. *
  24172. * @param customStore Method to get a custom store. Use with caution (see the docs).
  24173. */
  24174. function clear() {
  24175. var customStore = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : defaultGetStore();
  24176. return customStore('readwrite', function (store) {
  24177. store.clear();
  24178. return promisifyRequest(store.transaction);
  24179. });
  24180. }
  24181. function eachCursor(store, callback) {
  24182. store.openCursor().onsuccess = function () {
  24183. if (!this.result) return;
  24184. callback(this.result);
  24185. this.result.continue();
  24186. };
  24187. return promisifyRequest(store.transaction);
  24188. }
  24189. /**
  24190. * Get all keys in the store.
  24191. *
  24192. * @param customStore Method to get a custom store. Use with caution (see the docs).
  24193. */
  24194. function keys() {
  24195. var customStore = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : defaultGetStore();
  24196. return customStore('readonly', function (store) {
  24197. // Fast path for modern browsers
  24198. if (store.getAllKeys) {
  24199. return promisifyRequest(store.getAllKeys());
  24200. }
  24201. var items = [];
  24202. return eachCursor(store, function (cursor) {
  24203. return items.push(cursor.key);
  24204. }).then(function () {
  24205. return items;
  24206. });
  24207. });
  24208. }
  24209. /**
  24210. * Get all values in the store.
  24211. *
  24212. * @param customStore Method to get a custom store. Use with caution (see the docs).
  24213. */
  24214. function values() {
  24215. var customStore = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : defaultGetStore();
  24216. return customStore('readonly', function (store) {
  24217. // Fast path for modern browsers
  24218. if (store.getAll) {
  24219. return promisifyRequest(store.getAll());
  24220. }
  24221. var items = [];
  24222. return eachCursor(store, function (cursor) {
  24223. return items.push(cursor.value);
  24224. }).then(function () {
  24225. return items;
  24226. });
  24227. });
  24228. }
  24229. /**
  24230. * Get all entries in the store. Each entry is an array of `[key, value]`.
  24231. *
  24232. * @param customStore Method to get a custom store. Use with caution (see the docs).
  24233. */
  24234. function entries() {
  24235. var customStore = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : defaultGetStore();
  24236. return customStore('readonly', function (store) {
  24237. // Fast path for modern browsers
  24238. // (although, hopefully we'll get a simpler path some day)
  24239. if (store.getAll && store.getAllKeys) {
  24240. return Promise.all([promisifyRequest(store.getAllKeys()), promisifyRequest(store.getAll())]).then(function (_ref) {
  24241. var _ref2 = _slicedToArray(_ref, 2),
  24242. keys = _ref2[0],
  24243. values = _ref2[1];
  24244. return keys.map(function (key, i) {
  24245. return [key, values[i]];
  24246. });
  24247. });
  24248. }
  24249. var items = [];
  24250. return customStore('readonly', function (store) {
  24251. return eachCursor(store, function (cursor) {
  24252. return items.push([cursor.key, cursor.value]);
  24253. }).then(function () {
  24254. return items;
  24255. });
  24256. });
  24257. });
  24258. }
  24259. exports.clear = clear;
  24260. exports.createStore = createStore;
  24261. exports.del = del;
  24262. exports.delMany = delMany;
  24263. exports.entries = entries;
  24264. exports.get = get;
  24265. exports.getMany = getMany;
  24266. exports.keys = keys;
  24267. exports.promisifyRequest = promisifyRequest;
  24268. exports.set = set;
  24269. exports.setMany = setMany;
  24270. exports.update = update;
  24271. exports.values = values;
  24272. },{}],487:[function(_dereq_,module,exports){
  24273. "use strict";
  24274. Object.defineProperty(exports, "__esModule", {
  24275. value: true
  24276. });
  24277. Object.defineProperty(exports, "MAX", {
  24278. enumerable: true,
  24279. get: function () {
  24280. return _max.default;
  24281. }
  24282. });
  24283. Object.defineProperty(exports, "NIL", {
  24284. enumerable: true,
  24285. get: function () {
  24286. return _nil.default;
  24287. }
  24288. });
  24289. Object.defineProperty(exports, "parse", {
  24290. enumerable: true,
  24291. get: function () {
  24292. return _parse.default;
  24293. }
  24294. });
  24295. Object.defineProperty(exports, "stringify", {
  24296. enumerable: true,
  24297. get: function () {
  24298. return _stringify.default;
  24299. }
  24300. });
  24301. Object.defineProperty(exports, "v1", {
  24302. enumerable: true,
  24303. get: function () {
  24304. return _v.default;
  24305. }
  24306. });
  24307. Object.defineProperty(exports, "v1ToV6", {
  24308. enumerable: true,
  24309. get: function () {
  24310. return _v1ToV.default;
  24311. }
  24312. });
  24313. Object.defineProperty(exports, "v3", {
  24314. enumerable: true,
  24315. get: function () {
  24316. return _v2.default;
  24317. }
  24318. });
  24319. Object.defineProperty(exports, "v4", {
  24320. enumerable: true,
  24321. get: function () {
  24322. return _v3.default;
  24323. }
  24324. });
  24325. Object.defineProperty(exports, "v5", {
  24326. enumerable: true,
  24327. get: function () {
  24328. return _v4.default;
  24329. }
  24330. });
  24331. Object.defineProperty(exports, "v6", {
  24332. enumerable: true,
  24333. get: function () {
  24334. return _v5.default;
  24335. }
  24336. });
  24337. Object.defineProperty(exports, "v6ToV1", {
  24338. enumerable: true,
  24339. get: function () {
  24340. return _v6ToV.default;
  24341. }
  24342. });
  24343. Object.defineProperty(exports, "v7", {
  24344. enumerable: true,
  24345. get: function () {
  24346. return _v6.default;
  24347. }
  24348. });
  24349. Object.defineProperty(exports, "validate", {
  24350. enumerable: true,
  24351. get: function () {
  24352. return _validate.default;
  24353. }
  24354. });
  24355. Object.defineProperty(exports, "version", {
  24356. enumerable: true,
  24357. get: function () {
  24358. return _version.default;
  24359. }
  24360. });
  24361. var _max = _interopRequireDefault(_dereq_("./max.js"));
  24362. var _nil = _interopRequireDefault(_dereq_("./nil.js"));
  24363. var _parse = _interopRequireDefault(_dereq_("./parse.js"));
  24364. var _stringify = _interopRequireDefault(_dereq_("./stringify.js"));
  24365. var _v = _interopRequireDefault(_dereq_("./v1.js"));
  24366. var _v1ToV = _interopRequireDefault(_dereq_("./v1ToV6.js"));
  24367. var _v2 = _interopRequireDefault(_dereq_("./v3.js"));
  24368. var _v3 = _interopRequireDefault(_dereq_("./v4.js"));
  24369. var _v4 = _interopRequireDefault(_dereq_("./v5.js"));
  24370. var _v5 = _interopRequireDefault(_dereq_("./v6.js"));
  24371. var _v6ToV = _interopRequireDefault(_dereq_("./v6ToV1.js"));
  24372. var _v6 = _interopRequireDefault(_dereq_("./v7.js"));
  24373. var _validate = _interopRequireDefault(_dereq_("./validate.js"));
  24374. var _version = _interopRequireDefault(_dereq_("./version.js"));
  24375. function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
  24376. },{"./max.js":488,"./nil.js":491,"./parse.js":492,"./stringify.js":496,"./v1.js":497,"./v1ToV6.js":498,"./v3.js":499,"./v4.js":501,"./v5.js":502,"./v6.js":503,"./v6ToV1.js":504,"./v7.js":505,"./validate.js":506,"./version.js":507}],488:[function(_dereq_,module,exports){
  24377. "use strict";
  24378. Object.defineProperty(exports, "__esModule", {
  24379. value: true
  24380. });
  24381. exports.default = void 0;
  24382. var _default = exports.default = 'ffffffff-ffff-ffff-ffff-ffffffffffff';
  24383. },{}],489:[function(_dereq_,module,exports){
  24384. "use strict";
  24385. Object.defineProperty(exports, "__esModule", {
  24386. value: true
  24387. });
  24388. exports.default = void 0;
  24389. /*
  24390. * Browser-compatible JavaScript MD5
  24391. *
  24392. * Modification of JavaScript MD5
  24393. * https://github.com/blueimp/JavaScript-MD5
  24394. *
  24395. * Copyright 2011, Sebastian Tschan
  24396. * https://blueimp.net
  24397. *
  24398. * Licensed under the MIT license:
  24399. * https://opensource.org/licenses/MIT
  24400. *
  24401. * Based on
  24402. * A JavaScript implementation of the RSA Data Security, Inc. MD5 Message
  24403. * Digest Algorithm, as defined in RFC 1321.
  24404. * Version 2.2 Copyright (C) Paul Johnston 1999 - 2009
  24405. * Other contributors: Greg Holt, Andrew Kepert, Ydnar, Lostinet
  24406. * Distributed under the BSD License
  24407. * See http://pajhome.org.uk/crypt/md5 for more info.
  24408. */
  24409. function md5(bytes) {
  24410. if (typeof bytes === 'string') {
  24411. const msg = unescape(encodeURIComponent(bytes)); // UTF8 escape
  24412. bytes = new Uint8Array(msg.length);
  24413. for (let i = 0; i < msg.length; ++i) {
  24414. bytes[i] = msg.charCodeAt(i);
  24415. }
  24416. }
  24417. return md5ToHexEncodedArray(wordsToMd5(bytesToWords(bytes), bytes.length * 8));
  24418. }
  24419. /*
  24420. * Convert an array of little-endian words to an array of bytes
  24421. */
  24422. function md5ToHexEncodedArray(input) {
  24423. const output = [];
  24424. const length32 = input.length * 32;
  24425. const hexTab = '0123456789abcdef';
  24426. for (let i = 0; i < length32; i += 8) {
  24427. const x = input[i >> 5] >>> i % 32 & 0xff;
  24428. const hex = parseInt(hexTab.charAt(x >>> 4 & 0x0f) + hexTab.charAt(x & 0x0f), 16);
  24429. output.push(hex);
  24430. }
  24431. return output;
  24432. }
  24433. /**
  24434. * Calculate output length with padding and bit length
  24435. */
  24436. function getOutputLength(inputLength8) {
  24437. return (inputLength8 + 64 >>> 9 << 4) + 14 + 1;
  24438. }
  24439. /*
  24440. * Calculate the MD5 of an array of little-endian words, and a bit length.
  24441. */
  24442. function wordsToMd5(x, len) {
  24443. /* append padding */
  24444. x[len >> 5] |= 0x80 << len % 32;
  24445. x[getOutputLength(len) - 1] = len;
  24446. let a = 1732584193;
  24447. let b = -271733879;
  24448. let c = -1732584194;
  24449. let d = 271733878;
  24450. for (let i = 0; i < x.length; i += 16) {
  24451. const olda = a;
  24452. const oldb = b;
  24453. const oldc = c;
  24454. const oldd = d;
  24455. a = md5ff(a, b, c, d, x[i], 7, -680876936);
  24456. d = md5ff(d, a, b, c, x[i + 1], 12, -389564586);
  24457. c = md5ff(c, d, a, b, x[i + 2], 17, 606105819);
  24458. b = md5ff(b, c, d, a, x[i + 3], 22, -1044525330);
  24459. a = md5ff(a, b, c, d, x[i + 4], 7, -176418897);
  24460. d = md5ff(d, a, b, c, x[i + 5], 12, 1200080426);
  24461. c = md5ff(c, d, a, b, x[i + 6], 17, -1473231341);
  24462. b = md5ff(b, c, d, a, x[i + 7], 22, -45705983);
  24463. a = md5ff(a, b, c, d, x[i + 8], 7, 1770035416);
  24464. d = md5ff(d, a, b, c, x[i + 9], 12, -1958414417);
  24465. c = md5ff(c, d, a, b, x[i + 10], 17, -42063);
  24466. b = md5ff(b, c, d, a, x[i + 11], 22, -1990404162);
  24467. a = md5ff(a, b, c, d, x[i + 12], 7, 1804603682);
  24468. d = md5ff(d, a, b, c, x[i + 13], 12, -40341101);
  24469. c = md5ff(c, d, a, b, x[i + 14], 17, -1502002290);
  24470. b = md5ff(b, c, d, a, x[i + 15], 22, 1236535329);
  24471. a = md5gg(a, b, c, d, x[i + 1], 5, -165796510);
  24472. d = md5gg(d, a, b, c, x[i + 6], 9, -1069501632);
  24473. c = md5gg(c, d, a, b, x[i + 11], 14, 643717713);
  24474. b = md5gg(b, c, d, a, x[i], 20, -373897302);
  24475. a = md5gg(a, b, c, d, x[i + 5], 5, -701558691);
  24476. d = md5gg(d, a, b, c, x[i + 10], 9, 38016083);
  24477. c = md5gg(c, d, a, b, x[i + 15], 14, -660478335);
  24478. b = md5gg(b, c, d, a, x[i + 4], 20, -405537848);
  24479. a = md5gg(a, b, c, d, x[i + 9], 5, 568446438);
  24480. d = md5gg(d, a, b, c, x[i + 14], 9, -1019803690);
  24481. c = md5gg(c, d, a, b, x[i + 3], 14, -187363961);
  24482. b = md5gg(b, c, d, a, x[i + 8], 20, 1163531501);
  24483. a = md5gg(a, b, c, d, x[i + 13], 5, -1444681467);
  24484. d = md5gg(d, a, b, c, x[i + 2], 9, -51403784);
  24485. c = md5gg(c, d, a, b, x[i + 7], 14, 1735328473);
  24486. b = md5gg(b, c, d, a, x[i + 12], 20, -1926607734);
  24487. a = md5hh(a, b, c, d, x[i + 5], 4, -378558);
  24488. d = md5hh(d, a, b, c, x[i + 8], 11, -2022574463);
  24489. c = md5hh(c, d, a, b, x[i + 11], 16, 1839030562);
  24490. b = md5hh(b, c, d, a, x[i + 14], 23, -35309556);
  24491. a = md5hh(a, b, c, d, x[i + 1], 4, -1530992060);
  24492. d = md5hh(d, a, b, c, x[i + 4], 11, 1272893353);
  24493. c = md5hh(c, d, a, b, x[i + 7], 16, -155497632);
  24494. b = md5hh(b, c, d, a, x[i + 10], 23, -1094730640);
  24495. a = md5hh(a, b, c, d, x[i + 13], 4, 681279174);
  24496. d = md5hh(d, a, b, c, x[i], 11, -358537222);
  24497. c = md5hh(c, d, a, b, x[i + 3], 16, -722521979);
  24498. b = md5hh(b, c, d, a, x[i + 6], 23, 76029189);
  24499. a = md5hh(a, b, c, d, x[i + 9], 4, -640364487);
  24500. d = md5hh(d, a, b, c, x[i + 12], 11, -421815835);
  24501. c = md5hh(c, d, a, b, x[i + 15], 16, 530742520);
  24502. b = md5hh(b, c, d, a, x[i + 2], 23, -995338651);
  24503. a = md5ii(a, b, c, d, x[i], 6, -198630844);
  24504. d = md5ii(d, a, b, c, x[i + 7], 10, 1126891415);
  24505. c = md5ii(c, d, a, b, x[i + 14], 15, -1416354905);
  24506. b = md5ii(b, c, d, a, x[i + 5], 21, -57434055);
  24507. a = md5ii(a, b, c, d, x[i + 12], 6, 1700485571);
  24508. d = md5ii(d, a, b, c, x[i + 3], 10, -1894986606);
  24509. c = md5ii(c, d, a, b, x[i + 10], 15, -1051523);
  24510. b = md5ii(b, c, d, a, x[i + 1], 21, -2054922799);
  24511. a = md5ii(a, b, c, d, x[i + 8], 6, 1873313359);
  24512. d = md5ii(d, a, b, c, x[i + 15], 10, -30611744);
  24513. c = md5ii(c, d, a, b, x[i + 6], 15, -1560198380);
  24514. b = md5ii(b, c, d, a, x[i + 13], 21, 1309151649);
  24515. a = md5ii(a, b, c, d, x[i + 4], 6, -145523070);
  24516. d = md5ii(d, a, b, c, x[i + 11], 10, -1120210379);
  24517. c = md5ii(c, d, a, b, x[i + 2], 15, 718787259);
  24518. b = md5ii(b, c, d, a, x[i + 9], 21, -343485551);
  24519. a = safeAdd(a, olda);
  24520. b = safeAdd(b, oldb);
  24521. c = safeAdd(c, oldc);
  24522. d = safeAdd(d, oldd);
  24523. }
  24524. return [a, b, c, d];
  24525. }
  24526. /*
  24527. * Convert an array bytes to an array of little-endian words
  24528. * Characters >255 have their high-byte silently ignored.
  24529. */
  24530. function bytesToWords(input) {
  24531. if (input.length === 0) {
  24532. return [];
  24533. }
  24534. const length8 = input.length * 8;
  24535. const output = new Uint32Array(getOutputLength(length8));
  24536. for (let i = 0; i < length8; i += 8) {
  24537. output[i >> 5] |= (input[i / 8] & 0xff) << i % 32;
  24538. }
  24539. return output;
  24540. }
  24541. /*
  24542. * Add integers, wrapping at 2^32. This uses 16-bit operations internally
  24543. * to work around bugs in some JS interpreters.
  24544. */
  24545. function safeAdd(x, y) {
  24546. const lsw = (x & 0xffff) + (y & 0xffff);
  24547. const msw = (x >> 16) + (y >> 16) + (lsw >> 16);
  24548. return msw << 16 | lsw & 0xffff;
  24549. }
  24550. /*
  24551. * Bitwise rotate a 32-bit number to the left.
  24552. */
  24553. function bitRotateLeft(num, cnt) {
  24554. return num << cnt | num >>> 32 - cnt;
  24555. }
  24556. /*
  24557. * These functions implement the four basic operations the algorithm uses.
  24558. */
  24559. function md5cmn(q, a, b, x, s, t) {
  24560. return safeAdd(bitRotateLeft(safeAdd(safeAdd(a, q), safeAdd(x, t)), s), b);
  24561. }
  24562. function md5ff(a, b, c, d, x, s, t) {
  24563. return md5cmn(b & c | ~b & d, a, b, x, s, t);
  24564. }
  24565. function md5gg(a, b, c, d, x, s, t) {
  24566. return md5cmn(b & d | c & ~d, a, b, x, s, t);
  24567. }
  24568. function md5hh(a, b, c, d, x, s, t) {
  24569. return md5cmn(b ^ c ^ d, a, b, x, s, t);
  24570. }
  24571. function md5ii(a, b, c, d, x, s, t) {
  24572. return md5cmn(c ^ (b | ~d), a, b, x, s, t);
  24573. }
  24574. var _default = exports.default = md5;
  24575. },{}],490:[function(_dereq_,module,exports){
  24576. "use strict";
  24577. Object.defineProperty(exports, "__esModule", {
  24578. value: true
  24579. });
  24580. exports.default = void 0;
  24581. const randomUUID = typeof crypto !== 'undefined' && crypto.randomUUID && crypto.randomUUID.bind(crypto);
  24582. var _default = exports.default = {
  24583. randomUUID
  24584. };
  24585. },{}],491:[function(_dereq_,module,exports){
  24586. "use strict";
  24587. Object.defineProperty(exports, "__esModule", {
  24588. value: true
  24589. });
  24590. exports.default = void 0;
  24591. var _default = exports.default = '00000000-0000-0000-0000-000000000000';
  24592. },{}],492:[function(_dereq_,module,exports){
  24593. "use strict";
  24594. Object.defineProperty(exports, "__esModule", {
  24595. value: true
  24596. });
  24597. exports.default = void 0;
  24598. var _validate = _interopRequireDefault(_dereq_("./validate.js"));
  24599. function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
  24600. function parse(uuid) {
  24601. if (!(0, _validate.default)(uuid)) {
  24602. throw TypeError('Invalid UUID');
  24603. }
  24604. let v;
  24605. const arr = new Uint8Array(16);
  24606. // Parse ########-....-....-....-............
  24607. arr[0] = (v = parseInt(uuid.slice(0, 8), 16)) >>> 24;
  24608. arr[1] = v >>> 16 & 0xff;
  24609. arr[2] = v >>> 8 & 0xff;
  24610. arr[3] = v & 0xff;
  24611. // Parse ........-####-....-....-............
  24612. arr[4] = (v = parseInt(uuid.slice(9, 13), 16)) >>> 8;
  24613. arr[5] = v & 0xff;
  24614. // Parse ........-....-####-....-............
  24615. arr[6] = (v = parseInt(uuid.slice(14, 18), 16)) >>> 8;
  24616. arr[7] = v & 0xff;
  24617. // Parse ........-....-....-####-............
  24618. arr[8] = (v = parseInt(uuid.slice(19, 23), 16)) >>> 8;
  24619. arr[9] = v & 0xff;
  24620. // Parse ........-....-....-....-############
  24621. // (Use "/" to avoid 32-bit truncation when bit-shifting high-order bytes)
  24622. arr[10] = (v = parseInt(uuid.slice(24, 36), 16)) / 0x10000000000 & 0xff;
  24623. arr[11] = v / 0x100000000 & 0xff;
  24624. arr[12] = v >>> 24 & 0xff;
  24625. arr[13] = v >>> 16 & 0xff;
  24626. arr[14] = v >>> 8 & 0xff;
  24627. arr[15] = v & 0xff;
  24628. return arr;
  24629. }
  24630. var _default = exports.default = parse;
  24631. },{"./validate.js":506}],493:[function(_dereq_,module,exports){
  24632. "use strict";
  24633. Object.defineProperty(exports, "__esModule", {
  24634. value: true
  24635. });
  24636. exports.default = void 0;
  24637. var _default = exports.default = /^(?:[0-9a-f]{8}-[0-9a-f]{4}-[1-8][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$/i;
  24638. },{}],494:[function(_dereq_,module,exports){
  24639. "use strict";
  24640. Object.defineProperty(exports, "__esModule", {
  24641. value: true
  24642. });
  24643. exports.default = rng;
  24644. // Unique ID creation requires a high quality random # generator. In the browser we therefore
  24645. // require the crypto API and do not support built-in fallback to lower quality random number
  24646. // generators (like Math.random()).
  24647. let getRandomValues;
  24648. const rnds8 = new Uint8Array(16);
  24649. function rng() {
  24650. // lazy load so that environments that need to polyfill have a chance to do so
  24651. if (!getRandomValues) {
  24652. // getRandomValues needs to be invoked in a context where "this" is a Crypto implementation.
  24653. getRandomValues = typeof crypto !== 'undefined' && crypto.getRandomValues && crypto.getRandomValues.bind(crypto);
  24654. if (!getRandomValues) {
  24655. throw new Error('crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported');
  24656. }
  24657. }
  24658. return getRandomValues(rnds8);
  24659. }
  24660. },{}],495:[function(_dereq_,module,exports){
  24661. "use strict";
  24662. Object.defineProperty(exports, "__esModule", {
  24663. value: true
  24664. });
  24665. exports.default = void 0;
  24666. // Adapted from Chris Veness' SHA1 code at
  24667. // http://www.movable-type.co.uk/scripts/sha1.html
  24668. function f(s, x, y, z) {
  24669. switch (s) {
  24670. case 0:
  24671. return x & y ^ ~x & z;
  24672. case 1:
  24673. return x ^ y ^ z;
  24674. case 2:
  24675. return x & y ^ x & z ^ y & z;
  24676. case 3:
  24677. return x ^ y ^ z;
  24678. }
  24679. }
  24680. function ROTL(x, n) {
  24681. return x << n | x >>> 32 - n;
  24682. }
  24683. function sha1(bytes) {
  24684. const K = [0x5a827999, 0x6ed9eba1, 0x8f1bbcdc, 0xca62c1d6];
  24685. const H = [0x67452301, 0xefcdab89, 0x98badcfe, 0x10325476, 0xc3d2e1f0];
  24686. if (typeof bytes === 'string') {
  24687. const msg = unescape(encodeURIComponent(bytes)); // UTF8 escape
  24688. bytes = [];
  24689. for (let i = 0; i < msg.length; ++i) {
  24690. bytes.push(msg.charCodeAt(i));
  24691. }
  24692. } else if (!Array.isArray(bytes)) {
  24693. // Convert Array-like to Array
  24694. bytes = Array.prototype.slice.call(bytes);
  24695. }
  24696. bytes.push(0x80);
  24697. const l = bytes.length / 4 + 2;
  24698. const N = Math.ceil(l / 16);
  24699. const M = new Array(N);
  24700. for (let i = 0; i < N; ++i) {
  24701. const arr = new Uint32Array(16);
  24702. for (let j = 0; j < 16; ++j) {
  24703. arr[j] = bytes[i * 64 + j * 4] << 24 | bytes[i * 64 + j * 4 + 1] << 16 | bytes[i * 64 + j * 4 + 2] << 8 | bytes[i * 64 + j * 4 + 3];
  24704. }
  24705. M[i] = arr;
  24706. }
  24707. M[N - 1][14] = (bytes.length - 1) * 8 / Math.pow(2, 32);
  24708. M[N - 1][14] = Math.floor(M[N - 1][14]);
  24709. M[N - 1][15] = (bytes.length - 1) * 8 & 0xffffffff;
  24710. for (let i = 0; i < N; ++i) {
  24711. const W = new Uint32Array(80);
  24712. for (let t = 0; t < 16; ++t) {
  24713. W[t] = M[i][t];
  24714. }
  24715. for (let t = 16; t < 80; ++t) {
  24716. W[t] = ROTL(W[t - 3] ^ W[t - 8] ^ W[t - 14] ^ W[t - 16], 1);
  24717. }
  24718. let a = H[0];
  24719. let b = H[1];
  24720. let c = H[2];
  24721. let d = H[3];
  24722. let e = H[4];
  24723. for (let t = 0; t < 80; ++t) {
  24724. const s = Math.floor(t / 20);
  24725. const T = ROTL(a, 5) + f(s, b, c, d) + e + K[s] + W[t] >>> 0;
  24726. e = d;
  24727. d = c;
  24728. c = ROTL(b, 30) >>> 0;
  24729. b = a;
  24730. a = T;
  24731. }
  24732. H[0] = H[0] + a >>> 0;
  24733. H[1] = H[1] + b >>> 0;
  24734. H[2] = H[2] + c >>> 0;
  24735. H[3] = H[3] + d >>> 0;
  24736. H[4] = H[4] + e >>> 0;
  24737. }
  24738. return [H[0] >> 24 & 0xff, H[0] >> 16 & 0xff, H[0] >> 8 & 0xff, H[0] & 0xff, H[1] >> 24 & 0xff, H[1] >> 16 & 0xff, H[1] >> 8 & 0xff, H[1] & 0xff, H[2] >> 24 & 0xff, H[2] >> 16 & 0xff, H[2] >> 8 & 0xff, H[2] & 0xff, H[3] >> 24 & 0xff, H[3] >> 16 & 0xff, H[3] >> 8 & 0xff, H[3] & 0xff, H[4] >> 24 & 0xff, H[4] >> 16 & 0xff, H[4] >> 8 & 0xff, H[4] & 0xff];
  24739. }
  24740. var _default = exports.default = sha1;
  24741. },{}],496:[function(_dereq_,module,exports){
  24742. "use strict";
  24743. Object.defineProperty(exports, "__esModule", {
  24744. value: true
  24745. });
  24746. exports.default = void 0;
  24747. exports.unsafeStringify = unsafeStringify;
  24748. var _validate = _interopRequireDefault(_dereq_("./validate.js"));
  24749. function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
  24750. /**
  24751. * Convert array of 16 byte values to UUID string format of the form:
  24752. * XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX
  24753. */
  24754. const byteToHex = [];
  24755. for (let i = 0; i < 256; ++i) {
  24756. byteToHex.push((i + 0x100).toString(16).slice(1));
  24757. }
  24758. function unsafeStringify(arr, offset = 0) {
  24759. // Note: Be careful editing this code! It's been tuned for performance
  24760. // and works in ways you may not expect. See https://github.com/uuidjs/uuid/pull/434
  24761. //
  24762. // Note to future-self: No, you can't remove the `toLowerCase()` call.
  24763. // REF: https://github.com/uuidjs/uuid/pull/677#issuecomment-1757351351
  24764. return (byteToHex[arr[offset + 0]] + byteToHex[arr[offset + 1]] + byteToHex[arr[offset + 2]] + byteToHex[arr[offset + 3]] + '-' + byteToHex[arr[offset + 4]] + byteToHex[arr[offset + 5]] + '-' + byteToHex[arr[offset + 6]] + byteToHex[arr[offset + 7]] + '-' + byteToHex[arr[offset + 8]] + byteToHex[arr[offset + 9]] + '-' + byteToHex[arr[offset + 10]] + byteToHex[arr[offset + 11]] + byteToHex[arr[offset + 12]] + byteToHex[arr[offset + 13]] + byteToHex[arr[offset + 14]] + byteToHex[arr[offset + 15]]).toLowerCase();
  24765. }
  24766. function stringify(arr, offset = 0) {
  24767. const uuid = unsafeStringify(arr, offset);
  24768. // Consistency check for valid UUID. If this throws, it's likely due to one
  24769. // of the following:
  24770. // - One or more input array values don't map to a hex octet (leading to
  24771. // "undefined" in the uuid)
  24772. // - Invalid input values for the RFC `version` or `variant` fields
  24773. if (!(0, _validate.default)(uuid)) {
  24774. throw TypeError('Stringified UUID is invalid');
  24775. }
  24776. return uuid;
  24777. }
  24778. var _default = exports.default = stringify;
  24779. },{"./validate.js":506}],497:[function(_dereq_,module,exports){
  24780. "use strict";
  24781. Object.defineProperty(exports, "__esModule", {
  24782. value: true
  24783. });
  24784. exports.default = void 0;
  24785. var _rng = _interopRequireDefault(_dereq_("./rng.js"));
  24786. var _stringify = _dereq_("./stringify.js");
  24787. function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
  24788. // **`v1()` - Generate time-based UUID**
  24789. //
  24790. // Inspired by https://github.com/LiosK/UUID.js
  24791. // and http://docs.python.org/library/uuid.html
  24792. let _nodeId;
  24793. let _clockseq;
  24794. // Previous uuid creation time
  24795. let _lastMSecs = 0;
  24796. let _lastNSecs = 0;
  24797. // See https://github.com/uuidjs/uuid for API details
  24798. function v1(options, buf, offset) {
  24799. let i = buf && offset || 0;
  24800. const b = buf || new Array(16);
  24801. options = options || {};
  24802. let node = options.node;
  24803. let clockseq = options.clockseq;
  24804. // v1 only: Use cached `node` and `clockseq` values
  24805. if (!options._v6) {
  24806. if (!node) {
  24807. node = _nodeId;
  24808. }
  24809. if (clockseq == null) {
  24810. clockseq = _clockseq;
  24811. }
  24812. }
  24813. // Handle cases where we need entropy. We do this lazily to minimize issues
  24814. // related to insufficient system entropy. See #189
  24815. if (node == null || clockseq == null) {
  24816. const seedBytes = options.random || (options.rng || _rng.default)();
  24817. // Randomize node
  24818. if (node == null) {
  24819. node = [seedBytes[0], seedBytes[1], seedBytes[2], seedBytes[3], seedBytes[4], seedBytes[5]];
  24820. // v1 only: cache node value for reuse
  24821. if (!_nodeId && !options._v6) {
  24822. // per RFC4122 4.5: Set MAC multicast bit (v1 only)
  24823. node[0] |= 0x01; // Set multicast bit
  24824. _nodeId = node;
  24825. }
  24826. }
  24827. // Randomize clockseq
  24828. if (clockseq == null) {
  24829. // Per 4.2.2, randomize (14 bit) clockseq
  24830. clockseq = (seedBytes[6] << 8 | seedBytes[7]) & 0x3fff;
  24831. if (_clockseq === undefined && !options._v6) {
  24832. _clockseq = clockseq;
  24833. }
  24834. }
  24835. }
  24836. // v1 & v6 timestamps are 100 nano-second units since the Gregorian epoch,
  24837. // (1582-10-15 00:00). JSNumbers aren't precise enough for this, so time is
  24838. // handled internally as 'msecs' (integer milliseconds) and 'nsecs'
  24839. // (100-nanoseconds offset from msecs) since unix epoch, 1970-01-01 00:00.
  24840. let msecs = options.msecs !== undefined ? options.msecs : Date.now();
  24841. // Per 4.2.1.2, use count of uuid's generated during the current clock
  24842. // cycle to simulate higher resolution clock
  24843. let nsecs = options.nsecs !== undefined ? options.nsecs : _lastNSecs + 1;
  24844. // Time since last uuid creation (in msecs)
  24845. const dt = msecs - _lastMSecs + (nsecs - _lastNSecs) / 10000;
  24846. // Per 4.2.1.2, Bump clockseq on clock regression
  24847. if (dt < 0 && options.clockseq === undefined) {
  24848. clockseq = clockseq + 1 & 0x3fff;
  24849. }
  24850. // Reset nsecs if clock regresses (new clockseq) or we've moved onto a new
  24851. // time interval
  24852. if ((dt < 0 || msecs > _lastMSecs) && options.nsecs === undefined) {
  24853. nsecs = 0;
  24854. }
  24855. // Per 4.2.1.2 Throw error if too many uuids are requested
  24856. if (nsecs >= 10000) {
  24857. throw new Error("uuid.v1(): Can't create more than 10M uuids/sec");
  24858. }
  24859. _lastMSecs = msecs;
  24860. _lastNSecs = nsecs;
  24861. _clockseq = clockseq;
  24862. // Per 4.1.4 - Convert from unix epoch to Gregorian epoch
  24863. msecs += 12219292800000;
  24864. // `time_low`
  24865. const tl = ((msecs & 0xfffffff) * 10000 + nsecs) % 0x100000000;
  24866. b[i++] = tl >>> 24 & 0xff;
  24867. b[i++] = tl >>> 16 & 0xff;
  24868. b[i++] = tl >>> 8 & 0xff;
  24869. b[i++] = tl & 0xff;
  24870. // `time_mid`
  24871. const tmh = msecs / 0x100000000 * 10000 & 0xfffffff;
  24872. b[i++] = tmh >>> 8 & 0xff;
  24873. b[i++] = tmh & 0xff;
  24874. // `time_high_and_version`
  24875. b[i++] = tmh >>> 24 & 0xf | 0x10; // include version
  24876. b[i++] = tmh >>> 16 & 0xff;
  24877. // `clock_seq_hi_and_reserved` (Per 4.2.2 - include variant)
  24878. b[i++] = clockseq >>> 8 | 0x80;
  24879. // `clock_seq_low`
  24880. b[i++] = clockseq & 0xff;
  24881. // `node`
  24882. for (let n = 0; n < 6; ++n) {
  24883. b[i + n] = node[n];
  24884. }
  24885. return buf || (0, _stringify.unsafeStringify)(b);
  24886. }
  24887. var _default = exports.default = v1;
  24888. },{"./rng.js":494,"./stringify.js":496}],498:[function(_dereq_,module,exports){
  24889. "use strict";
  24890. Object.defineProperty(exports, "__esModule", {
  24891. value: true
  24892. });
  24893. exports.default = v1ToV6;
  24894. var _parse = _interopRequireDefault(_dereq_("./parse.js"));
  24895. var _stringify = _dereq_("./stringify.js");
  24896. function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
  24897. /**
  24898. * Convert a v1 UUID to a v6 UUID
  24899. *
  24900. * @param {string|Uint8Array} uuid - The v1 UUID to convert to v6
  24901. * @returns {string|Uint8Array} The v6 UUID as the same type as the `uuid` arg
  24902. * (string or Uint8Array)
  24903. */
  24904. function v1ToV6(uuid) {
  24905. const v1Bytes = typeof uuid === 'string' ? (0, _parse.default)(uuid) : uuid;
  24906. const v6Bytes = _v1ToV6(v1Bytes);
  24907. return typeof uuid === 'string' ? (0, _stringify.unsafeStringify)(v6Bytes) : v6Bytes;
  24908. }
  24909. // Do the field transformation needed for v1 -> v6
  24910. function _v1ToV6(v1Bytes, randomize = false) {
  24911. return Uint8Array.of((v1Bytes[6] & 0x0f) << 4 | v1Bytes[7] >> 4 & 0x0f, (v1Bytes[7] & 0x0f) << 4 | (v1Bytes[4] & 0xf0) >> 4, (v1Bytes[4] & 0x0f) << 4 | (v1Bytes[5] & 0xf0) >> 4, (v1Bytes[5] & 0x0f) << 4 | (v1Bytes[0] & 0xf0) >> 4, (v1Bytes[0] & 0x0f) << 4 | (v1Bytes[1] & 0xf0) >> 4, (v1Bytes[1] & 0x0f) << 4 | (v1Bytes[2] & 0xf0) >> 4, 0x60 | v1Bytes[2] & 0x0f, v1Bytes[3], v1Bytes[8], v1Bytes[9], v1Bytes[10], v1Bytes[11], v1Bytes[12], v1Bytes[13], v1Bytes[14], v1Bytes[15]);
  24912. }
  24913. },{"./parse.js":492,"./stringify.js":496}],499:[function(_dereq_,module,exports){
  24914. "use strict";
  24915. Object.defineProperty(exports, "__esModule", {
  24916. value: true
  24917. });
  24918. exports.default = void 0;
  24919. var _v = _interopRequireDefault(_dereq_("./v35.js"));
  24920. var _md = _interopRequireDefault(_dereq_("./md5.js"));
  24921. function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
  24922. const v3 = (0, _v.default)('v3', 0x30, _md.default);
  24923. var _default = exports.default = v3;
  24924. },{"./md5.js":489,"./v35.js":500}],500:[function(_dereq_,module,exports){
  24925. "use strict";
  24926. Object.defineProperty(exports, "__esModule", {
  24927. value: true
  24928. });
  24929. exports.URL = exports.DNS = void 0;
  24930. exports.default = v35;
  24931. var _stringify = _dereq_("./stringify.js");
  24932. var _parse = _interopRequireDefault(_dereq_("./parse.js"));
  24933. function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
  24934. function stringToBytes(str) {
  24935. str = unescape(encodeURIComponent(str)); // UTF8 escape
  24936. const bytes = [];
  24937. for (let i = 0; i < str.length; ++i) {
  24938. bytes.push(str.charCodeAt(i));
  24939. }
  24940. return bytes;
  24941. }
  24942. const DNS = exports.DNS = '6ba7b810-9dad-11d1-80b4-00c04fd430c8';
  24943. const URL = exports.URL = '6ba7b811-9dad-11d1-80b4-00c04fd430c8';
  24944. function v35(name, version, hashfunc) {
  24945. function generateUUID(value, namespace, buf, offset) {
  24946. var _namespace;
  24947. if (typeof value === 'string') {
  24948. value = stringToBytes(value);
  24949. }
  24950. if (typeof namespace === 'string') {
  24951. namespace = (0, _parse.default)(namespace);
  24952. }
  24953. if (((_namespace = namespace) === null || _namespace === void 0 ? void 0 : _namespace.length) !== 16) {
  24954. throw TypeError('Namespace must be array-like (16 iterable integer values, 0-255)');
  24955. }
  24956. // Compute hash of namespace and value, Per 4.3
  24957. // Future: Use spread syntax when supported on all platforms, e.g. `bytes =
  24958. // hashfunc([...namespace, ... value])`
  24959. let bytes = new Uint8Array(16 + value.length);
  24960. bytes.set(namespace);
  24961. bytes.set(value, namespace.length);
  24962. bytes = hashfunc(bytes);
  24963. bytes[6] = bytes[6] & 0x0f | version;
  24964. bytes[8] = bytes[8] & 0x3f | 0x80;
  24965. if (buf) {
  24966. offset = offset || 0;
  24967. for (let i = 0; i < 16; ++i) {
  24968. buf[offset + i] = bytes[i];
  24969. }
  24970. return buf;
  24971. }
  24972. return (0, _stringify.unsafeStringify)(bytes);
  24973. }
  24974. // Function#name is not settable on some platforms (#270)
  24975. try {
  24976. generateUUID.name = name;
  24977. } catch (err) {}
  24978. // For CommonJS default export support
  24979. generateUUID.DNS = DNS;
  24980. generateUUID.URL = URL;
  24981. return generateUUID;
  24982. }
  24983. },{"./parse.js":492,"./stringify.js":496}],501:[function(_dereq_,module,exports){
  24984. "use strict";
  24985. Object.defineProperty(exports, "__esModule", {
  24986. value: true
  24987. });
  24988. exports.default = void 0;
  24989. var _native = _interopRequireDefault(_dereq_("./native.js"));
  24990. var _rng = _interopRequireDefault(_dereq_("./rng.js"));
  24991. var _stringify = _dereq_("./stringify.js");
  24992. function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
  24993. function v4(options, buf, offset) {
  24994. if (_native.default.randomUUID && !buf && !options) {
  24995. return _native.default.randomUUID();
  24996. }
  24997. options = options || {};
  24998. const rnds = options.random || (options.rng || _rng.default)();
  24999. // Per 4.4, set bits for version and `clock_seq_hi_and_reserved`
  25000. rnds[6] = rnds[6] & 0x0f | 0x40;
  25001. rnds[8] = rnds[8] & 0x3f | 0x80;
  25002. // Copy bytes to buffer, if provided
  25003. if (buf) {
  25004. offset = offset || 0;
  25005. for (let i = 0; i < 16; ++i) {
  25006. buf[offset + i] = rnds[i];
  25007. }
  25008. return buf;
  25009. }
  25010. return (0, _stringify.unsafeStringify)(rnds);
  25011. }
  25012. var _default = exports.default = v4;
  25013. },{"./native.js":490,"./rng.js":494,"./stringify.js":496}],502:[function(_dereq_,module,exports){
  25014. "use strict";
  25015. Object.defineProperty(exports, "__esModule", {
  25016. value: true
  25017. });
  25018. exports.default = void 0;
  25019. var _v = _interopRequireDefault(_dereq_("./v35.js"));
  25020. var _sha = _interopRequireDefault(_dereq_("./sha1.js"));
  25021. function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
  25022. const v5 = (0, _v.default)('v5', 0x50, _sha.default);
  25023. var _default = exports.default = v5;
  25024. },{"./sha1.js":495,"./v35.js":500}],503:[function(_dereq_,module,exports){
  25025. "use strict";
  25026. Object.defineProperty(exports, "__esModule", {
  25027. value: true
  25028. });
  25029. exports.default = v6;
  25030. var _stringify = _dereq_("./stringify.js");
  25031. var _v = _interopRequireDefault(_dereq_("./v1.js"));
  25032. var _v1ToV = _interopRequireDefault(_dereq_("./v1ToV6.js"));
  25033. function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
  25034. /**
  25035. *
  25036. * @param {object} options
  25037. * @param {Uint8Array=} buf
  25038. * @param {number=} offset
  25039. * @returns
  25040. */
  25041. function v6(options = {}, buf, offset = 0) {
  25042. // v6 is v1 with different field layout, so we start with a v1 UUID, albeit
  25043. // with slightly different behavior around how the clock_seq and node fields
  25044. // are randomized, which is why we call v1 with _v6: true.
  25045. let bytes = (0, _v.default)({
  25046. ...options,
  25047. _v6: true
  25048. }, new Uint8Array(16));
  25049. // Reorder the fields to v6 layout.
  25050. bytes = (0, _v1ToV.default)(bytes);
  25051. // Return as a byte array if requested
  25052. if (buf) {
  25053. for (let i = 0; i < 16; i++) {
  25054. buf[offset + i] = bytes[i];
  25055. }
  25056. return buf;
  25057. }
  25058. return (0, _stringify.unsafeStringify)(bytes);
  25059. }
  25060. },{"./stringify.js":496,"./v1.js":497,"./v1ToV6.js":498}],504:[function(_dereq_,module,exports){
  25061. "use strict";
  25062. Object.defineProperty(exports, "__esModule", {
  25063. value: true
  25064. });
  25065. exports.default = v6ToV1;
  25066. var _parse = _interopRequireDefault(_dereq_("./parse.js"));
  25067. var _stringify = _dereq_("./stringify.js");
  25068. function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
  25069. /**
  25070. * Convert a v6 UUID to a v1 UUID
  25071. *
  25072. * @param {string|Uint8Array} uuid - The v6 UUID to convert to v6
  25073. * @returns {string|Uint8Array} The v1 UUID as the same type as the `uuid` arg
  25074. * (string or Uint8Array)
  25075. */
  25076. function v6ToV1(uuid) {
  25077. const v6Bytes = typeof uuid === 'string' ? (0, _parse.default)(uuid) : uuid;
  25078. const v1Bytes = _v6ToV1(v6Bytes);
  25079. return typeof uuid === 'string' ? (0, _stringify.unsafeStringify)(v1Bytes) : v1Bytes;
  25080. }
  25081. // Do the field transformation needed for v6 -> v1
  25082. function _v6ToV1(v6Bytes) {
  25083. return Uint8Array.of((v6Bytes[3] & 0x0f) << 4 | v6Bytes[4] >> 4 & 0x0f, (v6Bytes[4] & 0x0f) << 4 | (v6Bytes[5] & 0xf0) >> 4, (v6Bytes[5] & 0x0f) << 4 | v6Bytes[6] & 0x0f, v6Bytes[7], (v6Bytes[1] & 0x0f) << 4 | (v6Bytes[2] & 0xf0) >> 4, (v6Bytes[2] & 0x0f) << 4 | (v6Bytes[3] & 0xf0) >> 4, 0x10 | (v6Bytes[0] & 0xf0) >> 4, (v6Bytes[0] & 0x0f) << 4 | (v6Bytes[1] & 0xf0) >> 4, v6Bytes[8], v6Bytes[9], v6Bytes[10], v6Bytes[11], v6Bytes[12], v6Bytes[13], v6Bytes[14], v6Bytes[15]);
  25084. }
  25085. },{"./parse.js":492,"./stringify.js":496}],505:[function(_dereq_,module,exports){
  25086. "use strict";
  25087. Object.defineProperty(exports, "__esModule", {
  25088. value: true
  25089. });
  25090. exports.default = void 0;
  25091. var _rng = _interopRequireDefault(_dereq_("./rng.js"));
  25092. var _stringify = _dereq_("./stringify.js");
  25093. function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
  25094. /**
  25095. * UUID V7 - Unix Epoch time-based UUID
  25096. *
  25097. * The IETF has published RFC9562, introducing 3 new UUID versions (6,7,8). This
  25098. * implementation of V7 is based on the accepted, though not yet approved,
  25099. * revisions.
  25100. *
  25101. * RFC 9562:https://www.rfc-editor.org/rfc/rfc9562.html Universally Unique
  25102. * IDentifiers (UUIDs)
  25103. *
  25104. * Sample V7 value:
  25105. * https://www.rfc-editor.org/rfc/rfc9562.html#name-example-of-a-uuidv7-value
  25106. *
  25107. * Monotonic Bit Layout: RFC rfc9562.6.2 Method 1, Dedicated Counter Bits ref:
  25108. * https://www.rfc-editor.org/rfc/rfc9562.html#section-6.2-5.1
  25109. *
  25110. * 0 1 2 3 0 1 2 3 4 5 6
  25111. * 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
  25112. * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  25113. * | unix_ts_ms |
  25114. * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  25115. * | unix_ts_ms | ver | seq_hi |
  25116. * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  25117. * |var| seq_low | rand |
  25118. * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  25119. * | rand |
  25120. * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  25121. *
  25122. * seq is a 31 bit serialized counter; comprised of 12 bit seq_hi and 19 bit
  25123. * seq_low, and randomly initialized upon timestamp change. 31 bit counter size
  25124. * was selected as any bitwise operations in node are done as _signed_ 32 bit
  25125. * ints. we exclude the sign bit.
  25126. */
  25127. let _seqLow = null;
  25128. let _seqHigh = null;
  25129. let _msecs = 0;
  25130. function v7(options, buf, offset) {
  25131. options = options || {};
  25132. // initialize buffer and pointer
  25133. let i = buf && offset || 0;
  25134. const b = buf || new Uint8Array(16);
  25135. // rnds is Uint8Array(16) filled with random bytes
  25136. const rnds = options.random || (options.rng || _rng.default)();
  25137. // milliseconds since unix epoch, 1970-01-01 00:00
  25138. const msecs = options.msecs !== undefined ? options.msecs : Date.now();
  25139. // seq is user provided 31 bit counter
  25140. let seq = options.seq !== undefined ? options.seq : null;
  25141. // initialize local seq high/low parts
  25142. let seqHigh = _seqHigh;
  25143. let seqLow = _seqLow;
  25144. // check if clock has advanced and user has not provided msecs
  25145. if (msecs > _msecs && options.msecs === undefined) {
  25146. _msecs = msecs;
  25147. // unless user provided seq, reset seq parts
  25148. if (seq !== null) {
  25149. seqHigh = null;
  25150. seqLow = null;
  25151. }
  25152. }
  25153. // if we have a user provided seq
  25154. if (seq !== null) {
  25155. // trim provided seq to 31 bits of value, avoiding overflow
  25156. if (seq > 0x7fffffff) {
  25157. seq = 0x7fffffff;
  25158. }
  25159. // split provided seq into high/low parts
  25160. seqHigh = seq >>> 19 & 0xfff;
  25161. seqLow = seq & 0x7ffff;
  25162. }
  25163. // randomly initialize seq
  25164. if (seqHigh === null || seqLow === null) {
  25165. seqHigh = rnds[6] & 0x7f;
  25166. seqHigh = seqHigh << 8 | rnds[7];
  25167. seqLow = rnds[8] & 0x3f; // pad for var
  25168. seqLow = seqLow << 8 | rnds[9];
  25169. seqLow = seqLow << 5 | rnds[10] >>> 3;
  25170. }
  25171. // increment seq if within msecs window
  25172. if (msecs + 10000 > _msecs && seq === null) {
  25173. if (++seqLow > 0x7ffff) {
  25174. seqLow = 0;
  25175. if (++seqHigh > 0xfff) {
  25176. seqHigh = 0;
  25177. // increment internal _msecs. this allows us to continue incrementing
  25178. // while staying monotonic. Note, once we hit 10k milliseconds beyond system
  25179. // clock, we will reset breaking monotonicity (after (2^31)*10000 generations)
  25180. _msecs++;
  25181. }
  25182. }
  25183. } else {
  25184. // resetting; we have advanced more than
  25185. // 10k milliseconds beyond system clock
  25186. _msecs = msecs;
  25187. }
  25188. _seqHigh = seqHigh;
  25189. _seqLow = seqLow;
  25190. // [bytes 0-5] 48 bits of local timestamp
  25191. b[i++] = _msecs / 0x10000000000 & 0xff;
  25192. b[i++] = _msecs / 0x100000000 & 0xff;
  25193. b[i++] = _msecs / 0x1000000 & 0xff;
  25194. b[i++] = _msecs / 0x10000 & 0xff;
  25195. b[i++] = _msecs / 0x100 & 0xff;
  25196. b[i++] = _msecs & 0xff;
  25197. // [byte 6] - set 4 bits of version (7) with first 4 bits seq_hi
  25198. b[i++] = seqHigh >>> 4 & 0x0f | 0x70;
  25199. // [byte 7] remaining 8 bits of seq_hi
  25200. b[i++] = seqHigh & 0xff;
  25201. // [byte 8] - variant (2 bits), first 6 bits seq_low
  25202. b[i++] = seqLow >>> 13 & 0x3f | 0x80;
  25203. // [byte 9] 8 bits seq_low
  25204. b[i++] = seqLow >>> 5 & 0xff;
  25205. // [byte 10] remaining 5 bits seq_low, 3 bits random
  25206. b[i++] = seqLow << 3 & 0xff | rnds[10] & 0x07;
  25207. // [bytes 11-15] always random
  25208. b[i++] = rnds[11];
  25209. b[i++] = rnds[12];
  25210. b[i++] = rnds[13];
  25211. b[i++] = rnds[14];
  25212. b[i++] = rnds[15];
  25213. return buf || (0, _stringify.unsafeStringify)(b);
  25214. }
  25215. var _default = exports.default = v7;
  25216. },{"./rng.js":494,"./stringify.js":496}],506:[function(_dereq_,module,exports){
  25217. "use strict";
  25218. Object.defineProperty(exports, "__esModule", {
  25219. value: true
  25220. });
  25221. exports.default = void 0;
  25222. var _regex = _interopRequireDefault(_dereq_("./regex.js"));
  25223. function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
  25224. function validate(uuid) {
  25225. return typeof uuid === 'string' && _regex.default.test(uuid);
  25226. }
  25227. var _default = exports.default = validate;
  25228. },{"./regex.js":493}],507:[function(_dereq_,module,exports){
  25229. "use strict";
  25230. Object.defineProperty(exports, "__esModule", {
  25231. value: true
  25232. });
  25233. exports.default = void 0;
  25234. var _validate = _interopRequireDefault(_dereq_("./validate.js"));
  25235. function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
  25236. function version(uuid) {
  25237. if (!(0, _validate.default)(uuid)) {
  25238. throw TypeError('Invalid UUID');
  25239. }
  25240. return parseInt(uuid.slice(14, 15), 16);
  25241. }
  25242. var _default = exports.default = version;
  25243. },{"./validate.js":506}],508:[function(_dereq_,module,exports){
  25244. 'use strict';
  25245. module.exports = function () {
  25246. throw new Error(
  25247. 'ws does not work in the browser. Browser clients must use the native ' +
  25248. 'WebSocket object'
  25249. );
  25250. };
  25251. },{}]},{},[20])(20)
  25252. });