parse.weapp.js 985 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796479747984799480048014802480348044805480648074808480948104811481248134814481548164817481848194820482148224823482448254826482748284829483048314832483348344835483648374838483948404841484248434844484548464847484848494850485148524853485448554856485748584859486048614862486348644865486648674868486948704871487248734874487548764877487848794880488148824883488448854886488748884889489048914892489348944895489648974898489949004901490249034904490549064907490849094910491149124913491449154916491749184919492049214922492349244925492649274928492949304931493249334934493549364937493849394940494149424943494449454946494749484949495049514952495349544955495649574958495949604961496249634964496549664967496849694970497149724973497449754976497749784979498049814982498349844985498649874988498949904991499249934994499549964997499849995000500150025003500450055006500750085009501050115012501350145015501650175018501950205021502250235024502550265027502850295030503150325033503450355036503750385039504050415042504350445045504650475048504950505051505250535054505550565057505850595060506150625063506450655066506750685069507050715072507350745075507650775078507950805081508250835084508550865087508850895090509150925093509450955096509750985099510051015102510351045105510651075108510951105111511251135114511551165117511851195120512151225123512451255126512751285129513051315132513351345135513651375138513951405141514251435144514551465147514851495150515151525153515451555156515751585159516051615162516351645165516651675168516951705171517251735174517551765177517851795180518151825183518451855186518751885189519051915192519351945195519651975198519952005201520252035204520552065207520852095210521152125213521452155216521752185219522052215222522352245225522652275228522952305231523252335234523552365237523852395240524152425243524452455246524752485249525052515252525352545255525652575258525952605261526252635264526552665267526852695270527152725273527452755276527752785279528052815282528352845285528652875288528952905291529252935294529552965297529852995300530153025303530453055306530753085309531053115312531353145315531653175318531953205321532253235324532553265327532853295330533153325333533453355336533753385339534053415342534353445345534653475348534953505351535253535354535553565357535853595360536153625363536453655366536753685369537053715372537353745375537653775378537953805381538253835384538553865387538853895390539153925393539453955396539753985399540054015402540354045405540654075408540954105411541254135414541554165417541854195420542154225423542454255426542754285429543054315432543354345435543654375438543954405441544254435444544554465447544854495450545154525453545454555456545754585459546054615462546354645465546654675468546954705471547254735474547554765477547854795480548154825483548454855486548754885489549054915492549354945495549654975498549955005501550255035504550555065507550855095510551155125513551455155516551755185519552055215522552355245525552655275528552955305531553255335534553555365537553855395540554155425543554455455546554755485549555055515552555355545555555655575558555955605561556255635564556555665567556855695570557155725573557455755576557755785579558055815582558355845585558655875588558955905591559255935594559555965597559855995600560156025603560456055606560756085609561056115612561356145615561656175618561956205621562256235624562556265627562856295630563156325633563456355636563756385639564056415642564356445645564656475648564956505651565256535654565556565657565856595660566156625663566456655666566756685669567056715672567356745675567656775678567956805681568256835684568556865687568856895690569156925693569456955696569756985699570057015702570357045705570657075708570957105711571257135714571557165717571857195720572157225723572457255726572757285729573057315732573357345735573657375738573957405741574257435744574557465747574857495750575157525753575457555756575757585759576057615762576357645765576657675768576957705771577257735774577557765777577857795780578157825783578457855786578757885789579057915792579357945795579657975798579958005801580258035804580558065807580858095810581158125813581458155816581758185819582058215822582358245825582658275828582958305831583258335834583558365837583858395840584158425843584458455846584758485849585058515852585358545855585658575858585958605861586258635864586558665867586858695870587158725873587458755876587758785879588058815882588358845885588658875888588958905891589258935894589558965897589858995900590159025903590459055906590759085909591059115912591359145915591659175918591959205921592259235924592559265927592859295930593159325933593459355936593759385939594059415942594359445945594659475948594959505951595259535954595559565957595859595960596159625963596459655966596759685969597059715972597359745975597659775978597959805981598259835984598559865987598859895990599159925993599459955996599759985999600060016002600360046005600660076008600960106011601260136014601560166017601860196020602160226023602460256026602760286029603060316032603360346035603660376038603960406041604260436044604560466047604860496050605160526053605460556056605760586059606060616062606360646065606660676068606960706071607260736074607560766077607860796080608160826083608460856086608760886089609060916092609360946095609660976098609961006101610261036104610561066107610861096110611161126113611461156116611761186119612061216122612361246125612661276128612961306131613261336134613561366137613861396140614161426143614461456146614761486149615061516152615361546155615661576158615961606161616261636164616561666167616861696170617161726173617461756176617761786179618061816182618361846185618661876188618961906191619261936194619561966197619861996200620162026203620462056206620762086209621062116212621362146215621662176218621962206221622262236224622562266227622862296230623162326233623462356236623762386239624062416242624362446245624662476248624962506251625262536254625562566257625862596260626162626263626462656266626762686269627062716272627362746275627662776278627962806281628262836284628562866287628862896290629162926293629462956296629762986299630063016302630363046305630663076308630963106311631263136314631563166317631863196320632163226323632463256326632763286329633063316332633363346335633663376338633963406341634263436344634563466347634863496350635163526353635463556356635763586359636063616362636363646365636663676368636963706371637263736374637563766377637863796380638163826383638463856386638763886389639063916392639363946395639663976398639964006401640264036404640564066407640864096410641164126413641464156416641764186419642064216422642364246425642664276428642964306431643264336434643564366437643864396440644164426443644464456446644764486449645064516452645364546455645664576458645964606461646264636464646564666467646864696470647164726473647464756476647764786479648064816482648364846485648664876488648964906491649264936494649564966497649864996500650165026503650465056506650765086509651065116512651365146515651665176518651965206521652265236524652565266527652865296530653165326533653465356536653765386539654065416542654365446545654665476548654965506551655265536554655565566557655865596560656165626563656465656566656765686569657065716572657365746575657665776578657965806581658265836584658565866587658865896590659165926593659465956596659765986599660066016602660366046605660666076608660966106611661266136614661566166617661866196620662166226623662466256626662766286629663066316632663366346635663666376638663966406641664266436644664566466647664866496650665166526653665466556656665766586659666066616662666366646665666666676668666966706671667266736674667566766677667866796680668166826683668466856686668766886689669066916692669366946695669666976698669967006701670267036704670567066707670867096710671167126713671467156716671767186719672067216722672367246725672667276728672967306731673267336734673567366737673867396740674167426743674467456746674767486749675067516752675367546755675667576758675967606761676267636764676567666767676867696770677167726773677467756776677767786779678067816782678367846785678667876788678967906791679267936794679567966797679867996800680168026803680468056806680768086809681068116812681368146815681668176818681968206821682268236824682568266827682868296830683168326833683468356836683768386839684068416842684368446845684668476848684968506851685268536854685568566857685868596860686168626863686468656866686768686869687068716872687368746875687668776878687968806881688268836884688568866887688868896890689168926893689468956896689768986899690069016902690369046905690669076908690969106911691269136914691569166917691869196920692169226923692469256926692769286929693069316932693369346935693669376938693969406941694269436944694569466947694869496950695169526953695469556956695769586959696069616962696369646965696669676968696969706971697269736974697569766977697869796980698169826983698469856986698769886989699069916992699369946995699669976998699970007001700270037004700570067007700870097010701170127013701470157016701770187019702070217022702370247025702670277028702970307031703270337034703570367037703870397040704170427043704470457046704770487049705070517052705370547055705670577058705970607061706270637064706570667067706870697070707170727073707470757076707770787079708070817082708370847085708670877088708970907091709270937094709570967097709870997100710171027103710471057106710771087109711071117112711371147115711671177118711971207121712271237124712571267127712871297130713171327133713471357136713771387139714071417142714371447145714671477148714971507151715271537154715571567157715871597160716171627163716471657166716771687169717071717172717371747175717671777178717971807181718271837184718571867187718871897190719171927193719471957196719771987199720072017202720372047205720672077208720972107211721272137214721572167217721872197220722172227223722472257226722772287229723072317232723372347235723672377238723972407241724272437244724572467247724872497250725172527253725472557256725772587259726072617262726372647265726672677268726972707271727272737274727572767277727872797280728172827283728472857286728772887289729072917292729372947295729672977298729973007301730273037304730573067307730873097310731173127313731473157316731773187319732073217322732373247325732673277328732973307331733273337334733573367337733873397340734173427343734473457346734773487349735073517352735373547355735673577358735973607361736273637364736573667367736873697370737173727373737473757376737773787379738073817382738373847385738673877388738973907391739273937394739573967397739873997400740174027403740474057406740774087409741074117412741374147415741674177418741974207421742274237424742574267427742874297430743174327433743474357436743774387439744074417442744374447445744674477448744974507451745274537454745574567457745874597460746174627463746474657466746774687469747074717472747374747475747674777478747974807481748274837484748574867487748874897490749174927493749474957496749774987499750075017502750375047505750675077508750975107511751275137514751575167517751875197520752175227523752475257526752775287529753075317532753375347535753675377538753975407541754275437544754575467547754875497550755175527553755475557556755775587559756075617562756375647565756675677568756975707571757275737574757575767577757875797580758175827583758475857586758775887589759075917592759375947595759675977598759976007601760276037604760576067607760876097610761176127613761476157616761776187619762076217622762376247625762676277628762976307631763276337634763576367637763876397640764176427643764476457646764776487649765076517652765376547655765676577658765976607661766276637664766576667667766876697670767176727673767476757676767776787679768076817682768376847685768676877688768976907691769276937694769576967697769876997700770177027703770477057706770777087709771077117712771377147715771677177718771977207721772277237724772577267727772877297730773177327733773477357736773777387739774077417742774377447745774677477748774977507751775277537754775577567757775877597760776177627763776477657766776777687769777077717772777377747775777677777778777977807781778277837784778577867787778877897790779177927793779477957796779777987799780078017802780378047805780678077808780978107811781278137814781578167817781878197820782178227823782478257826782778287829783078317832783378347835783678377838783978407841784278437844784578467847784878497850785178527853785478557856785778587859786078617862786378647865786678677868786978707871787278737874787578767877787878797880788178827883788478857886788778887889789078917892789378947895789678977898789979007901790279037904790579067907790879097910791179127913791479157916791779187919792079217922792379247925792679277928792979307931793279337934793579367937793879397940794179427943794479457946794779487949795079517952795379547955795679577958795979607961796279637964796579667967796879697970797179727973797479757976797779787979798079817982798379847985798679877988798979907991799279937994799579967997799879998000800180028003800480058006800780088009801080118012801380148015801680178018801980208021802280238024802580268027802880298030803180328033803480358036803780388039804080418042804380448045804680478048804980508051805280538054805580568057805880598060806180628063806480658066806780688069807080718072807380748075807680778078807980808081808280838084808580868087808880898090809180928093809480958096809780988099810081018102810381048105810681078108810981108111811281138114811581168117811881198120812181228123812481258126812781288129813081318132813381348135813681378138813981408141814281438144814581468147814881498150815181528153815481558156815781588159816081618162816381648165816681678168816981708171817281738174817581768177817881798180818181828183818481858186818781888189819081918192819381948195819681978198819982008201820282038204820582068207820882098210821182128213821482158216821782188219822082218222822382248225822682278228822982308231823282338234823582368237823882398240824182428243824482458246824782488249825082518252825382548255825682578258825982608261826282638264826582668267826882698270827182728273827482758276827782788279828082818282828382848285828682878288828982908291829282938294829582968297829882998300830183028303830483058306830783088309831083118312831383148315831683178318831983208321832283238324832583268327832883298330833183328333833483358336833783388339834083418342834383448345834683478348834983508351835283538354835583568357835883598360836183628363836483658366836783688369837083718372837383748375837683778378837983808381838283838384838583868387838883898390839183928393839483958396839783988399840084018402840384048405840684078408840984108411841284138414841584168417841884198420842184228423842484258426842784288429843084318432843384348435843684378438843984408441844284438444844584468447844884498450845184528453845484558456845784588459846084618462846384648465846684678468846984708471847284738474847584768477847884798480848184828483848484858486848784888489849084918492849384948495849684978498849985008501850285038504850585068507850885098510851185128513851485158516851785188519852085218522852385248525852685278528852985308531853285338534853585368537853885398540854185428543854485458546854785488549855085518552855385548555855685578558855985608561856285638564856585668567856885698570857185728573857485758576857785788579858085818582858385848585858685878588858985908591859285938594859585968597859885998600860186028603860486058606860786088609861086118612861386148615861686178618861986208621862286238624862586268627862886298630863186328633863486358636863786388639864086418642864386448645864686478648864986508651865286538654865586568657865886598660866186628663866486658666866786688669867086718672867386748675867686778678867986808681868286838684868586868687868886898690869186928693869486958696869786988699870087018702870387048705870687078708870987108711871287138714871587168717871887198720872187228723872487258726872787288729873087318732873387348735873687378738873987408741874287438744874587468747874887498750875187528753875487558756875787588759876087618762876387648765876687678768876987708771877287738774877587768777877887798780878187828783878487858786878787888789879087918792879387948795879687978798879988008801880288038804880588068807880888098810881188128813881488158816881788188819882088218822882388248825882688278828882988308831883288338834883588368837883888398840884188428843884488458846884788488849885088518852885388548855885688578858885988608861886288638864886588668867886888698870887188728873887488758876887788788879888088818882888388848885888688878888888988908891889288938894889588968897889888998900890189028903890489058906890789088909891089118912891389148915891689178918891989208921892289238924892589268927892889298930893189328933893489358936893789388939894089418942894389448945894689478948894989508951895289538954895589568957895889598960896189628963896489658966896789688969897089718972897389748975897689778978897989808981898289838984898589868987898889898990899189928993899489958996899789988999900090019002900390049005900690079008900990109011901290139014901590169017901890199020902190229023902490259026902790289029903090319032903390349035903690379038903990409041904290439044904590469047904890499050905190529053905490559056905790589059906090619062906390649065906690679068906990709071907290739074907590769077907890799080908190829083908490859086908790889089909090919092909390949095909690979098909991009101910291039104910591069107910891099110911191129113911491159116911791189119912091219122912391249125912691279128912991309131913291339134913591369137913891399140914191429143914491459146914791489149915091519152915391549155915691579158915991609161916291639164916591669167916891699170917191729173917491759176917791789179918091819182918391849185918691879188918991909191919291939194919591969197919891999200920192029203920492059206920792089209921092119212921392149215921692179218921992209221922292239224922592269227922892299230923192329233923492359236923792389239924092419242924392449245924692479248924992509251925292539254925592569257925892599260926192629263926492659266926792689269927092719272927392749275927692779278927992809281928292839284928592869287928892899290929192929293929492959296929792989299930093019302930393049305930693079308930993109311931293139314931593169317931893199320932193229323932493259326932793289329933093319332933393349335933693379338933993409341934293439344934593469347934893499350935193529353935493559356935793589359936093619362936393649365936693679368936993709371937293739374937593769377937893799380938193829383938493859386938793889389939093919392939393949395939693979398939994009401940294039404940594069407940894099410941194129413941494159416941794189419942094219422942394249425942694279428942994309431943294339434943594369437943894399440944194429443944494459446944794489449945094519452945394549455945694579458945994609461946294639464946594669467946894699470947194729473947494759476947794789479948094819482948394849485948694879488948994909491949294939494949594969497949894999500950195029503950495059506950795089509951095119512951395149515951695179518951995209521952295239524952595269527952895299530953195329533953495359536953795389539954095419542954395449545954695479548954995509551955295539554955595569557955895599560956195629563956495659566956795689569957095719572957395749575957695779578957995809581958295839584958595869587958895899590959195929593959495959596959795989599960096019602960396049605960696079608960996109611961296139614961596169617961896199620962196229623962496259626962796289629963096319632963396349635963696379638963996409641964296439644964596469647964896499650965196529653965496559656965796589659966096619662966396649665966696679668966996709671967296739674967596769677967896799680968196829683968496859686968796889689969096919692969396949695969696979698969997009701970297039704970597069707970897099710971197129713971497159716971797189719972097219722972397249725972697279728972997309731973297339734973597369737973897399740974197429743974497459746974797489749975097519752975397549755975697579758975997609761976297639764976597669767976897699770977197729773977497759776977797789779978097819782978397849785978697879788978997909791979297939794979597969797979897999800980198029803980498059806980798089809981098119812981398149815981698179818981998209821982298239824982598269827982898299830983198329833983498359836983798389839984098419842984398449845984698479848984998509851985298539854985598569857985898599860986198629863986498659866986798689869987098719872987398749875987698779878987998809881988298839884988598869887988898899890989198929893989498959896989798989899990099019902990399049905990699079908990999109911991299139914991599169917991899199920992199229923992499259926992799289929993099319932993399349935993699379938993999409941994299439944994599469947994899499950995199529953995499559956995799589959996099619962996399649965996699679968996999709971997299739974997599769977997899799980998199829983998499859986998799889989999099919992999399949995999699979998999910000100011000210003100041000510006100071000810009100101001110012100131001410015100161001710018100191002010021100221002310024100251002610027100281002910030100311003210033100341003510036100371003810039100401004110042100431004410045100461004710048100491005010051100521005310054100551005610057100581005910060100611006210063100641006510066100671006810069100701007110072100731007410075100761007710078100791008010081100821008310084100851008610087100881008910090100911009210093100941009510096100971009810099101001010110102101031010410105101061010710108101091011010111101121011310114101151011610117101181011910120101211012210123101241012510126101271012810129101301013110132101331013410135101361013710138101391014010141101421014310144101451014610147101481014910150101511015210153101541015510156101571015810159101601016110162101631016410165101661016710168101691017010171101721017310174101751017610177101781017910180101811018210183101841018510186101871018810189101901019110192101931019410195101961019710198101991020010201102021020310204102051020610207102081020910210102111021210213102141021510216102171021810219102201022110222102231022410225102261022710228102291023010231102321023310234102351023610237102381023910240102411024210243102441024510246102471024810249102501025110252102531025410255102561025710258102591026010261102621026310264102651026610267102681026910270102711027210273102741027510276102771027810279102801028110282102831028410285102861028710288102891029010291102921029310294102951029610297102981029910300103011030210303103041030510306103071030810309103101031110312103131031410315103161031710318103191032010321103221032310324103251032610327103281032910330103311033210333103341033510336103371033810339103401034110342103431034410345103461034710348103491035010351103521035310354103551035610357103581035910360103611036210363103641036510366103671036810369103701037110372103731037410375103761037710378103791038010381103821038310384103851038610387103881038910390103911039210393103941039510396103971039810399104001040110402104031040410405104061040710408104091041010411104121041310414104151041610417104181041910420104211042210423104241042510426104271042810429104301043110432104331043410435104361043710438104391044010441104421044310444104451044610447104481044910450104511045210453104541045510456104571045810459104601046110462104631046410465104661046710468104691047010471104721047310474104751047610477104781047910480104811048210483104841048510486104871048810489104901049110492104931049410495104961049710498104991050010501105021050310504105051050610507105081050910510105111051210513105141051510516105171051810519105201052110522105231052410525105261052710528105291053010531105321053310534105351053610537105381053910540105411054210543105441054510546105471054810549105501055110552105531055410555105561055710558105591056010561105621056310564105651056610567105681056910570105711057210573105741057510576105771057810579105801058110582105831058410585105861058710588105891059010591105921059310594105951059610597105981059910600106011060210603106041060510606106071060810609106101061110612106131061410615106161061710618106191062010621106221062310624106251062610627106281062910630106311063210633106341063510636106371063810639106401064110642106431064410645106461064710648106491065010651106521065310654106551065610657106581065910660106611066210663106641066510666106671066810669106701067110672106731067410675106761067710678106791068010681106821068310684106851068610687106881068910690106911069210693106941069510696106971069810699107001070110702107031070410705107061070710708107091071010711107121071310714107151071610717107181071910720107211072210723107241072510726107271072810729107301073110732107331073410735107361073710738107391074010741107421074310744107451074610747107481074910750107511075210753107541075510756107571075810759107601076110762107631076410765107661076710768107691077010771107721077310774107751077610777107781077910780107811078210783107841078510786107871078810789107901079110792107931079410795107961079710798107991080010801108021080310804108051080610807108081080910810108111081210813108141081510816108171081810819108201082110822108231082410825108261082710828108291083010831108321083310834108351083610837108381083910840108411084210843108441084510846108471084810849108501085110852108531085410855108561085710858108591086010861108621086310864108651086610867108681086910870108711087210873108741087510876108771087810879108801088110882108831088410885108861088710888108891089010891108921089310894108951089610897108981089910900109011090210903109041090510906109071090810909109101091110912109131091410915109161091710918109191092010921109221092310924109251092610927109281092910930109311093210933109341093510936109371093810939109401094110942109431094410945109461094710948109491095010951109521095310954109551095610957109581095910960109611096210963109641096510966109671096810969109701097110972109731097410975109761097710978109791098010981109821098310984109851098610987109881098910990109911099210993109941099510996109971099810999110001100111002110031100411005110061100711008110091101011011110121101311014110151101611017110181101911020110211102211023110241102511026110271102811029110301103111032110331103411035110361103711038110391104011041110421104311044110451104611047110481104911050110511105211053110541105511056110571105811059110601106111062110631106411065110661106711068110691107011071110721107311074110751107611077110781107911080110811108211083110841108511086110871108811089110901109111092110931109411095110961109711098110991110011101111021110311104111051110611107111081110911110111111111211113111141111511116111171111811119111201112111122111231112411125111261112711128111291113011131111321113311134111351113611137111381113911140111411114211143111441114511146111471114811149111501115111152111531115411155111561115711158111591116011161111621116311164111651116611167111681116911170111711117211173111741117511176111771117811179111801118111182111831118411185111861118711188111891119011191111921119311194111951119611197111981119911200112011120211203112041120511206112071120811209112101121111212112131121411215112161121711218112191122011221112221122311224112251122611227112281122911230112311123211233112341123511236112371123811239112401124111242112431124411245112461124711248112491125011251112521125311254112551125611257112581125911260112611126211263112641126511266112671126811269112701127111272112731127411275112761127711278112791128011281112821128311284112851128611287112881128911290112911129211293112941129511296112971129811299113001130111302113031130411305113061130711308113091131011311113121131311314113151131611317113181131911320113211132211323113241132511326113271132811329113301133111332113331133411335113361133711338113391134011341113421134311344113451134611347113481134911350113511135211353113541135511356113571135811359113601136111362113631136411365113661136711368113691137011371113721137311374113751137611377113781137911380113811138211383113841138511386113871138811389113901139111392113931139411395113961139711398113991140011401114021140311404114051140611407114081140911410114111141211413114141141511416114171141811419114201142111422114231142411425114261142711428114291143011431114321143311434114351143611437114381143911440114411144211443114441144511446114471144811449114501145111452114531145411455114561145711458114591146011461114621146311464114651146611467114681146911470114711147211473114741147511476114771147811479114801148111482114831148411485114861148711488114891149011491114921149311494114951149611497114981149911500115011150211503115041150511506115071150811509115101151111512115131151411515115161151711518115191152011521115221152311524115251152611527115281152911530115311153211533115341153511536115371153811539115401154111542115431154411545115461154711548115491155011551115521155311554115551155611557115581155911560115611156211563115641156511566115671156811569115701157111572115731157411575115761157711578115791158011581115821158311584115851158611587115881158911590115911159211593115941159511596115971159811599116001160111602116031160411605116061160711608116091161011611116121161311614116151161611617116181161911620116211162211623116241162511626116271162811629116301163111632116331163411635116361163711638116391164011641116421164311644116451164611647116481164911650116511165211653116541165511656116571165811659116601166111662116631166411665116661166711668116691167011671116721167311674116751167611677116781167911680116811168211683116841168511686116871168811689116901169111692116931169411695116961169711698116991170011701117021170311704117051170611707117081170911710117111171211713117141171511716117171171811719117201172111722117231172411725117261172711728117291173011731117321173311734117351173611737117381173911740117411174211743117441174511746117471174811749117501175111752117531175411755117561175711758117591176011761117621176311764117651176611767117681176911770117711177211773117741177511776117771177811779117801178111782117831178411785117861178711788117891179011791117921179311794117951179611797117981179911800118011180211803118041180511806118071180811809118101181111812118131181411815118161181711818118191182011821118221182311824118251182611827118281182911830118311183211833118341183511836118371183811839118401184111842118431184411845118461184711848118491185011851118521185311854118551185611857118581185911860118611186211863118641186511866118671186811869118701187111872118731187411875118761187711878118791188011881118821188311884118851188611887118881188911890118911189211893118941189511896118971189811899119001190111902119031190411905119061190711908119091191011911119121191311914119151191611917119181191911920119211192211923119241192511926119271192811929119301193111932119331193411935119361193711938119391194011941119421194311944119451194611947119481194911950119511195211953119541195511956119571195811959119601196111962119631196411965119661196711968119691197011971119721197311974119751197611977119781197911980119811198211983119841198511986119871198811989119901199111992119931199411995119961199711998119991200012001120021200312004120051200612007120081200912010120111201212013120141201512016120171201812019120201202112022120231202412025120261202712028120291203012031120321203312034120351203612037120381203912040120411204212043120441204512046120471204812049120501205112052120531205412055120561205712058120591206012061120621206312064120651206612067120681206912070120711207212073120741207512076120771207812079120801208112082120831208412085120861208712088120891209012091120921209312094120951209612097120981209912100121011210212103121041210512106121071210812109121101211112112121131211412115121161211712118121191212012121121221212312124121251212612127121281212912130121311213212133121341213512136121371213812139121401214112142121431214412145121461214712148121491215012151121521215312154121551215612157121581215912160121611216212163121641216512166121671216812169121701217112172121731217412175121761217712178121791218012181121821218312184121851218612187121881218912190121911219212193121941219512196121971219812199122001220112202122031220412205122061220712208122091221012211122121221312214122151221612217122181221912220122211222212223122241222512226122271222812229122301223112232122331223412235122361223712238122391224012241122421224312244122451224612247122481224912250122511225212253122541225512256122571225812259122601226112262122631226412265122661226712268122691227012271122721227312274122751227612277122781227912280122811228212283122841228512286122871228812289122901229112292122931229412295122961229712298122991230012301123021230312304123051230612307123081230912310123111231212313123141231512316123171231812319123201232112322123231232412325123261232712328123291233012331123321233312334123351233612337123381233912340123411234212343123441234512346123471234812349123501235112352123531235412355123561235712358123591236012361123621236312364123651236612367123681236912370123711237212373123741237512376123771237812379123801238112382123831238412385123861238712388123891239012391123921239312394123951239612397123981239912400124011240212403124041240512406124071240812409124101241112412124131241412415124161241712418124191242012421124221242312424124251242612427124281242912430124311243212433124341243512436124371243812439124401244112442124431244412445124461244712448124491245012451124521245312454124551245612457124581245912460124611246212463124641246512466124671246812469124701247112472124731247412475124761247712478124791248012481124821248312484124851248612487124881248912490124911249212493124941249512496124971249812499125001250112502125031250412505125061250712508125091251012511125121251312514125151251612517125181251912520125211252212523125241252512526125271252812529125301253112532125331253412535125361253712538125391254012541125421254312544125451254612547125481254912550125511255212553125541255512556125571255812559125601256112562125631256412565125661256712568125691257012571125721257312574125751257612577125781257912580125811258212583125841258512586125871258812589125901259112592125931259412595125961259712598125991260012601126021260312604126051260612607126081260912610126111261212613126141261512616126171261812619126201262112622126231262412625126261262712628126291263012631126321263312634126351263612637126381263912640126411264212643126441264512646126471264812649126501265112652126531265412655126561265712658126591266012661126621266312664126651266612667126681266912670126711267212673126741267512676126771267812679126801268112682126831268412685126861268712688126891269012691126921269312694126951269612697126981269912700127011270212703127041270512706127071270812709127101271112712127131271412715127161271712718127191272012721127221272312724127251272612727127281272912730127311273212733127341273512736127371273812739127401274112742127431274412745127461274712748127491275012751127521275312754127551275612757127581275912760127611276212763127641276512766127671276812769127701277112772127731277412775127761277712778127791278012781127821278312784127851278612787127881278912790127911279212793127941279512796127971279812799128001280112802128031280412805128061280712808128091281012811128121281312814128151281612817128181281912820128211282212823128241282512826128271282812829128301283112832128331283412835128361283712838128391284012841128421284312844128451284612847128481284912850128511285212853128541285512856128571285812859128601286112862128631286412865128661286712868128691287012871128721287312874128751287612877128781287912880128811288212883128841288512886128871288812889128901289112892128931289412895128961289712898128991290012901129021290312904129051290612907129081290912910129111291212913129141291512916129171291812919129201292112922129231292412925129261292712928129291293012931129321293312934129351293612937129381293912940129411294212943129441294512946129471294812949129501295112952129531295412955129561295712958129591296012961129621296312964129651296612967129681296912970129711297212973129741297512976129771297812979129801298112982129831298412985129861298712988129891299012991129921299312994129951299612997129981299913000130011300213003130041300513006130071300813009130101301113012130131301413015130161301713018130191302013021130221302313024130251302613027130281302913030130311303213033130341303513036130371303813039130401304113042130431304413045130461304713048130491305013051130521305313054130551305613057130581305913060130611306213063130641306513066130671306813069130701307113072130731307413075130761307713078130791308013081130821308313084130851308613087130881308913090130911309213093130941309513096130971309813099131001310113102131031310413105131061310713108131091311013111131121311313114131151311613117131181311913120131211312213123131241312513126131271312813129131301313113132131331313413135131361313713138131391314013141131421314313144131451314613147131481314913150131511315213153131541315513156131571315813159131601316113162131631316413165131661316713168131691317013171131721317313174131751317613177131781317913180131811318213183131841318513186131871318813189131901319113192131931319413195131961319713198131991320013201132021320313204132051320613207132081320913210132111321213213132141321513216132171321813219132201322113222132231322413225132261322713228132291323013231132321323313234132351323613237132381323913240132411324213243132441324513246132471324813249132501325113252132531325413255132561325713258132591326013261132621326313264132651326613267132681326913270132711327213273132741327513276132771327813279132801328113282132831328413285132861328713288132891329013291132921329313294132951329613297132981329913300133011330213303133041330513306133071330813309133101331113312133131331413315133161331713318133191332013321133221332313324133251332613327133281332913330133311333213333133341333513336133371333813339133401334113342133431334413345133461334713348133491335013351133521335313354133551335613357133581335913360133611336213363133641336513366133671336813369133701337113372133731337413375133761337713378133791338013381133821338313384133851338613387133881338913390133911339213393133941339513396133971339813399134001340113402134031340413405134061340713408134091341013411134121341313414134151341613417134181341913420134211342213423134241342513426134271342813429134301343113432134331343413435134361343713438134391344013441134421344313444134451344613447134481344913450134511345213453134541345513456134571345813459134601346113462134631346413465134661346713468134691347013471134721347313474134751347613477134781347913480134811348213483134841348513486134871348813489134901349113492134931349413495134961349713498134991350013501135021350313504135051350613507135081350913510135111351213513135141351513516135171351813519135201352113522135231352413525135261352713528135291353013531135321353313534135351353613537135381353913540135411354213543135441354513546135471354813549135501355113552135531355413555135561355713558135591356013561135621356313564135651356613567135681356913570135711357213573135741357513576135771357813579135801358113582135831358413585135861358713588135891359013591135921359313594135951359613597135981359913600136011360213603136041360513606136071360813609136101361113612136131361413615136161361713618136191362013621136221362313624136251362613627136281362913630136311363213633136341363513636136371363813639136401364113642136431364413645136461364713648136491365013651136521365313654136551365613657136581365913660136611366213663136641366513666136671366813669136701367113672136731367413675136761367713678136791368013681136821368313684136851368613687136881368913690136911369213693136941369513696136971369813699137001370113702137031370413705137061370713708137091371013711137121371313714137151371613717137181371913720137211372213723137241372513726137271372813729137301373113732137331373413735137361373713738137391374013741137421374313744137451374613747137481374913750137511375213753137541375513756137571375813759137601376113762137631376413765137661376713768137691377013771137721377313774137751377613777137781377913780137811378213783137841378513786137871378813789137901379113792137931379413795137961379713798137991380013801138021380313804138051380613807138081380913810138111381213813138141381513816138171381813819138201382113822138231382413825138261382713828138291383013831138321383313834138351383613837138381383913840138411384213843138441384513846138471384813849138501385113852138531385413855138561385713858138591386013861138621386313864138651386613867138681386913870138711387213873138741387513876138771387813879138801388113882138831388413885138861388713888138891389013891138921389313894138951389613897138981389913900139011390213903139041390513906139071390813909139101391113912139131391413915139161391713918139191392013921139221392313924139251392613927139281392913930139311393213933139341393513936139371393813939139401394113942139431394413945139461394713948139491395013951139521395313954139551395613957139581395913960139611396213963139641396513966139671396813969139701397113972139731397413975139761397713978139791398013981139821398313984139851398613987139881398913990139911399213993139941399513996139971399813999140001400114002140031400414005140061400714008140091401014011140121401314014140151401614017140181401914020140211402214023140241402514026140271402814029140301403114032140331403414035140361403714038140391404014041140421404314044140451404614047140481404914050140511405214053140541405514056140571405814059140601406114062140631406414065140661406714068140691407014071140721407314074140751407614077140781407914080140811408214083140841408514086140871408814089140901409114092140931409414095140961409714098140991410014101141021410314104141051410614107141081410914110141111411214113141141411514116141171411814119141201412114122141231412414125141261412714128141291413014131141321413314134141351413614137141381413914140141411414214143141441414514146141471414814149141501415114152141531415414155141561415714158141591416014161141621416314164141651416614167141681416914170141711417214173141741417514176141771417814179141801418114182141831418414185141861418714188141891419014191141921419314194141951419614197141981419914200142011420214203142041420514206142071420814209142101421114212142131421414215142161421714218142191422014221142221422314224142251422614227142281422914230142311423214233142341423514236142371423814239142401424114242142431424414245142461424714248142491425014251142521425314254142551425614257142581425914260142611426214263142641426514266142671426814269142701427114272142731427414275142761427714278142791428014281142821428314284142851428614287142881428914290142911429214293142941429514296142971429814299143001430114302143031430414305143061430714308143091431014311143121431314314143151431614317143181431914320143211432214323143241432514326143271432814329143301433114332143331433414335143361433714338143391434014341143421434314344143451434614347143481434914350143511435214353143541435514356143571435814359143601436114362143631436414365143661436714368143691437014371143721437314374143751437614377143781437914380143811438214383143841438514386143871438814389143901439114392143931439414395143961439714398143991440014401144021440314404144051440614407144081440914410144111441214413144141441514416144171441814419144201442114422144231442414425144261442714428144291443014431144321443314434144351443614437144381443914440144411444214443144441444514446144471444814449144501445114452144531445414455144561445714458144591446014461144621446314464144651446614467144681446914470144711447214473144741447514476144771447814479144801448114482144831448414485144861448714488144891449014491144921449314494144951449614497144981449914500145011450214503145041450514506145071450814509145101451114512145131451414515145161451714518145191452014521145221452314524145251452614527145281452914530145311453214533145341453514536145371453814539145401454114542145431454414545145461454714548145491455014551145521455314554145551455614557145581455914560145611456214563145641456514566145671456814569145701457114572145731457414575145761457714578145791458014581145821458314584145851458614587145881458914590145911459214593145941459514596145971459814599146001460114602146031460414605146061460714608146091461014611146121461314614146151461614617146181461914620146211462214623146241462514626146271462814629146301463114632146331463414635146361463714638146391464014641146421464314644146451464614647146481464914650146511465214653146541465514656146571465814659146601466114662146631466414665146661466714668146691467014671146721467314674146751467614677146781467914680146811468214683146841468514686146871468814689146901469114692146931469414695146961469714698146991470014701147021470314704147051470614707147081470914710147111471214713147141471514716147171471814719147201472114722147231472414725147261472714728147291473014731147321473314734147351473614737147381473914740147411474214743147441474514746147471474814749147501475114752147531475414755147561475714758147591476014761147621476314764147651476614767147681476914770147711477214773147741477514776147771477814779147801478114782147831478414785147861478714788147891479014791147921479314794147951479614797147981479914800148011480214803148041480514806148071480814809148101481114812148131481414815148161481714818148191482014821148221482314824148251482614827148281482914830148311483214833148341483514836148371483814839148401484114842148431484414845148461484714848148491485014851148521485314854148551485614857148581485914860148611486214863148641486514866148671486814869148701487114872148731487414875148761487714878148791488014881148821488314884148851488614887148881488914890148911489214893148941489514896148971489814899149001490114902149031490414905149061490714908149091491014911149121491314914149151491614917149181491914920149211492214923149241492514926149271492814929149301493114932149331493414935149361493714938149391494014941149421494314944149451494614947149481494914950149511495214953149541495514956149571495814959149601496114962149631496414965149661496714968149691497014971149721497314974149751497614977149781497914980149811498214983149841498514986149871498814989149901499114992149931499414995149961499714998149991500015001150021500315004150051500615007150081500915010150111501215013150141501515016150171501815019150201502115022150231502415025150261502715028150291503015031150321503315034150351503615037150381503915040150411504215043150441504515046150471504815049150501505115052150531505415055150561505715058150591506015061150621506315064150651506615067150681506915070150711507215073150741507515076150771507815079150801508115082150831508415085150861508715088150891509015091150921509315094150951509615097150981509915100151011510215103151041510515106151071510815109151101511115112151131511415115151161511715118151191512015121151221512315124151251512615127151281512915130151311513215133151341513515136151371513815139151401514115142151431514415145151461514715148151491515015151151521515315154151551515615157151581515915160151611516215163151641516515166151671516815169151701517115172151731517415175151761517715178151791518015181151821518315184151851518615187151881518915190151911519215193151941519515196151971519815199152001520115202152031520415205152061520715208152091521015211152121521315214152151521615217152181521915220152211522215223152241522515226152271522815229152301523115232152331523415235152361523715238152391524015241152421524315244152451524615247152481524915250152511525215253152541525515256152571525815259152601526115262152631526415265152661526715268152691527015271152721527315274152751527615277152781527915280152811528215283152841528515286152871528815289152901529115292152931529415295152961529715298152991530015301153021530315304153051530615307153081530915310153111531215313153141531515316153171531815319153201532115322153231532415325153261532715328153291533015331153321533315334153351533615337153381533915340153411534215343153441534515346153471534815349153501535115352153531535415355153561535715358153591536015361153621536315364153651536615367153681536915370153711537215373153741537515376153771537815379153801538115382153831538415385153861538715388153891539015391153921539315394153951539615397153981539915400154011540215403154041540515406154071540815409154101541115412154131541415415154161541715418154191542015421154221542315424154251542615427154281542915430154311543215433154341543515436154371543815439154401544115442154431544415445154461544715448154491545015451154521545315454154551545615457154581545915460154611546215463154641546515466154671546815469154701547115472154731547415475154761547715478154791548015481154821548315484154851548615487154881548915490154911549215493154941549515496154971549815499155001550115502155031550415505155061550715508155091551015511155121551315514155151551615517155181551915520155211552215523155241552515526155271552815529155301553115532155331553415535155361553715538155391554015541155421554315544155451554615547155481554915550155511555215553155541555515556155571555815559155601556115562155631556415565155661556715568155691557015571155721557315574155751557615577155781557915580155811558215583155841558515586155871558815589155901559115592155931559415595155961559715598155991560015601156021560315604156051560615607156081560915610156111561215613156141561515616156171561815619156201562115622156231562415625156261562715628156291563015631156321563315634156351563615637156381563915640156411564215643156441564515646156471564815649156501565115652156531565415655156561565715658156591566015661156621566315664156651566615667156681566915670156711567215673156741567515676156771567815679156801568115682156831568415685156861568715688156891569015691156921569315694156951569615697156981569915700157011570215703157041570515706157071570815709157101571115712157131571415715157161571715718157191572015721157221572315724157251572615727157281572915730157311573215733157341573515736157371573815739157401574115742157431574415745157461574715748157491575015751157521575315754157551575615757157581575915760157611576215763157641576515766157671576815769157701577115772157731577415775157761577715778157791578015781157821578315784157851578615787157881578915790157911579215793157941579515796157971579815799158001580115802158031580415805158061580715808158091581015811158121581315814158151581615817158181581915820158211582215823158241582515826158271582815829158301583115832158331583415835158361583715838158391584015841158421584315844158451584615847158481584915850158511585215853158541585515856158571585815859158601586115862158631586415865158661586715868158691587015871158721587315874158751587615877158781587915880158811588215883158841588515886158871588815889158901589115892158931589415895158961589715898158991590015901159021590315904159051590615907159081590915910159111591215913159141591515916159171591815919159201592115922159231592415925159261592715928159291593015931159321593315934159351593615937159381593915940159411594215943159441594515946159471594815949159501595115952159531595415955159561595715958159591596015961159621596315964159651596615967159681596915970159711597215973159741597515976159771597815979159801598115982159831598415985159861598715988159891599015991159921599315994159951599615997159981599916000160011600216003160041600516006160071600816009160101601116012160131601416015160161601716018160191602016021160221602316024160251602616027160281602916030160311603216033160341603516036160371603816039160401604116042160431604416045160461604716048160491605016051160521605316054160551605616057160581605916060160611606216063160641606516066160671606816069160701607116072160731607416075160761607716078160791608016081160821608316084160851608616087160881608916090160911609216093160941609516096160971609816099161001610116102161031610416105161061610716108161091611016111161121611316114161151611616117161181611916120161211612216123161241612516126161271612816129161301613116132161331613416135161361613716138161391614016141161421614316144161451614616147161481614916150161511615216153161541615516156161571615816159161601616116162161631616416165161661616716168161691617016171161721617316174161751617616177161781617916180161811618216183161841618516186161871618816189161901619116192161931619416195161961619716198161991620016201162021620316204162051620616207162081620916210162111621216213162141621516216162171621816219162201622116222162231622416225162261622716228162291623016231162321623316234162351623616237162381623916240162411624216243162441624516246162471624816249162501625116252162531625416255162561625716258162591626016261162621626316264162651626616267162681626916270162711627216273162741627516276162771627816279162801628116282162831628416285162861628716288162891629016291162921629316294162951629616297162981629916300163011630216303163041630516306163071630816309163101631116312163131631416315163161631716318163191632016321163221632316324163251632616327163281632916330163311633216333163341633516336163371633816339163401634116342163431634416345163461634716348163491635016351163521635316354163551635616357163581635916360163611636216363163641636516366163671636816369163701637116372163731637416375163761637716378163791638016381163821638316384163851638616387163881638916390163911639216393163941639516396163971639816399164001640116402164031640416405164061640716408164091641016411164121641316414164151641616417164181641916420164211642216423164241642516426164271642816429164301643116432164331643416435164361643716438164391644016441164421644316444164451644616447164481644916450164511645216453164541645516456164571645816459164601646116462164631646416465164661646716468164691647016471164721647316474164751647616477164781647916480164811648216483164841648516486164871648816489164901649116492164931649416495164961649716498164991650016501165021650316504165051650616507165081650916510165111651216513165141651516516165171651816519165201652116522165231652416525165261652716528165291653016531165321653316534165351653616537165381653916540165411654216543165441654516546165471654816549165501655116552165531655416555165561655716558165591656016561165621656316564165651656616567165681656916570165711657216573165741657516576165771657816579165801658116582165831658416585165861658716588165891659016591165921659316594165951659616597165981659916600166011660216603166041660516606166071660816609166101661116612166131661416615166161661716618166191662016621166221662316624166251662616627166281662916630166311663216633166341663516636166371663816639166401664116642166431664416645166461664716648166491665016651166521665316654166551665616657166581665916660166611666216663166641666516666166671666816669166701667116672166731667416675166761667716678166791668016681166821668316684166851668616687166881668916690166911669216693166941669516696166971669816699167001670116702167031670416705167061670716708167091671016711167121671316714167151671616717167181671916720167211672216723167241672516726167271672816729167301673116732167331673416735167361673716738167391674016741167421674316744167451674616747167481674916750167511675216753167541675516756167571675816759167601676116762167631676416765167661676716768167691677016771167721677316774167751677616777167781677916780167811678216783167841678516786167871678816789167901679116792167931679416795167961679716798167991680016801168021680316804168051680616807168081680916810168111681216813168141681516816168171681816819168201682116822168231682416825168261682716828168291683016831168321683316834168351683616837168381683916840168411684216843168441684516846168471684816849168501685116852168531685416855168561685716858168591686016861168621686316864168651686616867168681686916870168711687216873168741687516876168771687816879168801688116882168831688416885168861688716888168891689016891168921689316894168951689616897168981689916900169011690216903169041690516906169071690816909169101691116912169131691416915169161691716918169191692016921169221692316924169251692616927169281692916930169311693216933169341693516936169371693816939169401694116942169431694416945169461694716948169491695016951169521695316954169551695616957169581695916960169611696216963169641696516966169671696816969169701697116972169731697416975169761697716978169791698016981169821698316984169851698616987169881698916990169911699216993169941699516996169971699816999170001700117002170031700417005170061700717008170091701017011170121701317014170151701617017170181701917020170211702217023170241702517026170271702817029170301703117032170331703417035170361703717038170391704017041170421704317044170451704617047170481704917050170511705217053170541705517056170571705817059170601706117062170631706417065170661706717068170691707017071170721707317074170751707617077170781707917080170811708217083170841708517086170871708817089170901709117092170931709417095170961709717098170991710017101171021710317104171051710617107171081710917110171111711217113171141711517116171171711817119171201712117122171231712417125171261712717128171291713017131171321713317134171351713617137171381713917140171411714217143171441714517146171471714817149171501715117152171531715417155171561715717158171591716017161171621716317164171651716617167171681716917170171711717217173171741717517176171771717817179171801718117182171831718417185171861718717188171891719017191171921719317194171951719617197171981719917200172011720217203172041720517206172071720817209172101721117212172131721417215172161721717218172191722017221172221722317224172251722617227172281722917230172311723217233172341723517236172371723817239172401724117242172431724417245172461724717248172491725017251172521725317254172551725617257172581725917260172611726217263172641726517266172671726817269172701727117272172731727417275172761727717278172791728017281172821728317284172851728617287172881728917290172911729217293172941729517296172971729817299173001730117302173031730417305173061730717308173091731017311173121731317314173151731617317173181731917320173211732217323173241732517326173271732817329173301733117332173331733417335173361733717338173391734017341173421734317344173451734617347173481734917350173511735217353173541735517356173571735817359173601736117362173631736417365173661736717368173691737017371173721737317374173751737617377173781737917380173811738217383173841738517386173871738817389173901739117392173931739417395173961739717398173991740017401174021740317404174051740617407174081740917410174111741217413174141741517416174171741817419174201742117422174231742417425174261742717428174291743017431174321743317434174351743617437174381743917440174411744217443174441744517446174471744817449174501745117452174531745417455174561745717458174591746017461174621746317464174651746617467174681746917470174711747217473174741747517476174771747817479174801748117482174831748417485174861748717488174891749017491174921749317494174951749617497174981749917500175011750217503175041750517506175071750817509175101751117512175131751417515175161751717518175191752017521175221752317524175251752617527175281752917530175311753217533175341753517536175371753817539175401754117542175431754417545175461754717548175491755017551175521755317554175551755617557175581755917560175611756217563175641756517566175671756817569175701757117572175731757417575175761757717578175791758017581175821758317584175851758617587175881758917590175911759217593175941759517596175971759817599176001760117602176031760417605176061760717608176091761017611176121761317614176151761617617176181761917620176211762217623176241762517626176271762817629176301763117632176331763417635176361763717638176391764017641176421764317644176451764617647176481764917650176511765217653176541765517656176571765817659176601766117662176631766417665176661766717668176691767017671176721767317674176751767617677176781767917680176811768217683176841768517686176871768817689176901769117692176931769417695176961769717698176991770017701177021770317704177051770617707177081770917710177111771217713177141771517716177171771817719177201772117722177231772417725177261772717728177291773017731177321773317734177351773617737177381773917740177411774217743177441774517746177471774817749177501775117752177531775417755177561775717758177591776017761177621776317764177651776617767177681776917770177711777217773177741777517776177771777817779177801778117782177831778417785177861778717788177891779017791177921779317794177951779617797177981779917800178011780217803178041780517806178071780817809178101781117812178131781417815178161781717818178191782017821178221782317824178251782617827178281782917830178311783217833178341783517836178371783817839178401784117842178431784417845178461784717848178491785017851178521785317854178551785617857178581785917860178611786217863178641786517866178671786817869178701787117872178731787417875178761787717878178791788017881178821788317884178851788617887178881788917890178911789217893178941789517896178971789817899179001790117902179031790417905179061790717908179091791017911179121791317914179151791617917179181791917920179211792217923179241792517926179271792817929179301793117932179331793417935179361793717938179391794017941179421794317944179451794617947179481794917950179511795217953179541795517956179571795817959179601796117962179631796417965179661796717968179691797017971179721797317974179751797617977179781797917980179811798217983179841798517986179871798817989179901799117992179931799417995179961799717998179991800018001180021800318004180051800618007180081800918010180111801218013180141801518016180171801818019180201802118022180231802418025180261802718028180291803018031180321803318034180351803618037180381803918040180411804218043180441804518046180471804818049180501805118052180531805418055180561805718058180591806018061180621806318064180651806618067180681806918070180711807218073180741807518076180771807818079180801808118082180831808418085180861808718088180891809018091180921809318094180951809618097180981809918100181011810218103181041810518106181071810818109181101811118112181131811418115181161811718118181191812018121181221812318124181251812618127181281812918130181311813218133181341813518136181371813818139181401814118142181431814418145181461814718148181491815018151181521815318154181551815618157181581815918160181611816218163181641816518166181671816818169181701817118172181731817418175181761817718178181791818018181181821818318184181851818618187181881818918190181911819218193181941819518196181971819818199182001820118202182031820418205182061820718208182091821018211182121821318214182151821618217182181821918220182211822218223182241822518226182271822818229182301823118232182331823418235182361823718238182391824018241182421824318244182451824618247182481824918250182511825218253182541825518256182571825818259182601826118262182631826418265182661826718268182691827018271182721827318274182751827618277182781827918280182811828218283182841828518286182871828818289182901829118292182931829418295182961829718298182991830018301183021830318304183051830618307183081830918310183111831218313183141831518316183171831818319183201832118322183231832418325183261832718328183291833018331183321833318334183351833618337183381833918340183411834218343183441834518346183471834818349183501835118352183531835418355183561835718358183591836018361183621836318364183651836618367183681836918370183711837218373183741837518376183771837818379183801838118382183831838418385183861838718388183891839018391183921839318394183951839618397183981839918400184011840218403184041840518406184071840818409184101841118412184131841418415184161841718418184191842018421184221842318424184251842618427184281842918430184311843218433184341843518436184371843818439184401844118442184431844418445184461844718448184491845018451184521845318454184551845618457184581845918460184611846218463184641846518466184671846818469184701847118472184731847418475184761847718478184791848018481184821848318484184851848618487184881848918490184911849218493184941849518496184971849818499185001850118502185031850418505185061850718508185091851018511185121851318514185151851618517185181851918520185211852218523185241852518526185271852818529185301853118532185331853418535185361853718538185391854018541185421854318544185451854618547185481854918550185511855218553185541855518556185571855818559185601856118562185631856418565185661856718568185691857018571185721857318574185751857618577185781857918580185811858218583185841858518586185871858818589185901859118592185931859418595185961859718598185991860018601186021860318604186051860618607186081860918610186111861218613186141861518616186171861818619186201862118622186231862418625186261862718628186291863018631186321863318634186351863618637186381863918640186411864218643186441864518646186471864818649186501865118652186531865418655186561865718658186591866018661186621866318664186651866618667186681866918670186711867218673186741867518676186771867818679186801868118682186831868418685186861868718688186891869018691186921869318694186951869618697186981869918700187011870218703187041870518706187071870818709187101871118712187131871418715187161871718718187191872018721187221872318724187251872618727187281872918730187311873218733187341873518736187371873818739187401874118742187431874418745187461874718748187491875018751187521875318754187551875618757187581875918760187611876218763187641876518766187671876818769187701877118772187731877418775187761877718778187791878018781187821878318784187851878618787187881878918790187911879218793187941879518796187971879818799188001880118802188031880418805188061880718808188091881018811188121881318814188151881618817188181881918820188211882218823188241882518826188271882818829188301883118832188331883418835188361883718838188391884018841188421884318844188451884618847188481884918850188511885218853188541885518856188571885818859188601886118862188631886418865188661886718868188691887018871188721887318874188751887618877188781887918880188811888218883188841888518886188871888818889188901889118892188931889418895188961889718898188991890018901189021890318904189051890618907189081890918910189111891218913189141891518916189171891818919189201892118922189231892418925189261892718928189291893018931189321893318934189351893618937189381893918940189411894218943189441894518946189471894818949189501895118952189531895418955189561895718958189591896018961189621896318964189651896618967189681896918970189711897218973189741897518976189771897818979189801898118982189831898418985189861898718988189891899018991189921899318994189951899618997189981899919000190011900219003190041900519006190071900819009190101901119012190131901419015190161901719018190191902019021190221902319024190251902619027190281902919030190311903219033190341903519036190371903819039190401904119042190431904419045190461904719048190491905019051190521905319054190551905619057190581905919060190611906219063190641906519066190671906819069190701907119072190731907419075190761907719078190791908019081190821908319084190851908619087190881908919090190911909219093190941909519096190971909819099191001910119102191031910419105191061910719108191091911019111191121911319114191151911619117191181911919120191211912219123191241912519126191271912819129191301913119132191331913419135191361913719138191391914019141191421914319144191451914619147191481914919150191511915219153191541915519156191571915819159191601916119162191631916419165191661916719168191691917019171191721917319174191751917619177191781917919180191811918219183191841918519186191871918819189191901919119192191931919419195191961919719198191991920019201192021920319204192051920619207192081920919210192111921219213192141921519216192171921819219192201922119222192231922419225192261922719228192291923019231192321923319234192351923619237192381923919240192411924219243192441924519246192471924819249192501925119252192531925419255192561925719258192591926019261192621926319264192651926619267192681926919270192711927219273192741927519276192771927819279192801928119282192831928419285192861928719288192891929019291192921929319294192951929619297192981929919300193011930219303193041930519306193071930819309193101931119312193131931419315193161931719318193191932019321193221932319324193251932619327193281932919330193311933219333193341933519336193371933819339193401934119342193431934419345193461934719348193491935019351193521935319354193551935619357193581935919360193611936219363193641936519366193671936819369193701937119372193731937419375193761937719378193791938019381193821938319384193851938619387193881938919390193911939219393193941939519396193971939819399194001940119402194031940419405194061940719408194091941019411194121941319414194151941619417194181941919420194211942219423194241942519426194271942819429194301943119432194331943419435194361943719438194391944019441194421944319444194451944619447194481944919450194511945219453194541945519456194571945819459194601946119462194631946419465194661946719468194691947019471194721947319474194751947619477194781947919480194811948219483194841948519486194871948819489194901949119492194931949419495194961949719498194991950019501195021950319504195051950619507195081950919510195111951219513195141951519516195171951819519195201952119522195231952419525195261952719528195291953019531195321953319534195351953619537195381953919540195411954219543195441954519546195471954819549195501955119552195531955419555195561955719558195591956019561195621956319564195651956619567195681956919570195711957219573195741957519576195771957819579195801958119582195831958419585195861958719588195891959019591195921959319594195951959619597195981959919600196011960219603196041960519606196071960819609196101961119612196131961419615196161961719618196191962019621196221962319624196251962619627196281962919630196311963219633196341963519636196371963819639196401964119642196431964419645196461964719648196491965019651196521965319654196551965619657196581965919660196611966219663196641966519666196671966819669196701967119672196731967419675196761967719678196791968019681196821968319684196851968619687196881968919690196911969219693196941969519696196971969819699197001970119702197031970419705197061970719708197091971019711197121971319714197151971619717197181971919720197211972219723197241972519726197271972819729197301973119732197331973419735197361973719738197391974019741197421974319744197451974619747197481974919750197511975219753197541975519756197571975819759197601976119762197631976419765197661976719768197691977019771197721977319774197751977619777197781977919780197811978219783197841978519786197871978819789197901979119792197931979419795197961979719798197991980019801198021980319804198051980619807198081980919810198111981219813198141981519816198171981819819198201982119822198231982419825198261982719828198291983019831198321983319834198351983619837198381983919840198411984219843198441984519846198471984819849198501985119852198531985419855198561985719858198591986019861198621986319864198651986619867198681986919870198711987219873198741987519876198771987819879198801988119882198831988419885198861988719888198891989019891198921989319894198951989619897198981989919900199011990219903199041990519906199071990819909199101991119912199131991419915199161991719918199191992019921199221992319924199251992619927199281992919930199311993219933199341993519936199371993819939199401994119942199431994419945199461994719948199491995019951199521995319954199551995619957199581995919960199611996219963199641996519966199671996819969199701997119972199731997419975199761997719978199791998019981199821998319984199851998619987199881998919990199911999219993199941999519996199971999819999200002000120002200032000420005200062000720008200092001020011200122001320014200152001620017200182001920020200212002220023200242002520026200272002820029200302003120032200332003420035200362003720038200392004020041200422004320044200452004620047200482004920050200512005220053200542005520056200572005820059200602006120062200632006420065200662006720068200692007020071200722007320074200752007620077200782007920080200812008220083200842008520086200872008820089200902009120092200932009420095200962009720098200992010020101201022010320104201052010620107201082010920110201112011220113201142011520116201172011820119201202012120122201232012420125201262012720128201292013020131201322013320134201352013620137201382013920140201412014220143201442014520146201472014820149201502015120152201532015420155201562015720158201592016020161201622016320164201652016620167201682016920170201712017220173201742017520176201772017820179201802018120182201832018420185201862018720188201892019020191201922019320194201952019620197201982019920200202012020220203202042020520206202072020820209202102021120212202132021420215202162021720218202192022020221202222022320224202252022620227202282022920230202312023220233202342023520236202372023820239202402024120242202432024420245202462024720248202492025020251202522025320254202552025620257202582025920260202612026220263202642026520266202672026820269202702027120272202732027420275202762027720278202792028020281202822028320284202852028620287202882028920290202912029220293202942029520296202972029820299203002030120302203032030420305203062030720308203092031020311203122031320314203152031620317203182031920320203212032220323203242032520326203272032820329203302033120332203332033420335203362033720338203392034020341203422034320344203452034620347203482034920350203512035220353203542035520356203572035820359203602036120362203632036420365203662036720368203692037020371203722037320374203752037620377203782037920380203812038220383203842038520386203872038820389203902039120392203932039420395203962039720398203992040020401204022040320404204052040620407204082040920410204112041220413204142041520416204172041820419204202042120422204232042420425204262042720428204292043020431204322043320434204352043620437204382043920440204412044220443204442044520446204472044820449204502045120452204532045420455204562045720458204592046020461204622046320464204652046620467204682046920470204712047220473204742047520476204772047820479204802048120482204832048420485204862048720488204892049020491204922049320494204952049620497204982049920500205012050220503205042050520506205072050820509205102051120512205132051420515205162051720518205192052020521205222052320524205252052620527205282052920530205312053220533205342053520536205372053820539205402054120542205432054420545205462054720548205492055020551205522055320554205552055620557205582055920560205612056220563205642056520566205672056820569205702057120572205732057420575205762057720578205792058020581205822058320584205852058620587205882058920590205912059220593205942059520596205972059820599206002060120602206032060420605206062060720608206092061020611206122061320614206152061620617206182061920620206212062220623206242062520626206272062820629206302063120632206332063420635206362063720638206392064020641206422064320644206452064620647206482064920650206512065220653206542065520656206572065820659206602066120662206632066420665206662066720668206692067020671206722067320674206752067620677206782067920680206812068220683206842068520686206872068820689206902069120692206932069420695206962069720698206992070020701207022070320704207052070620707207082070920710207112071220713207142071520716207172071820719207202072120722207232072420725207262072720728207292073020731207322073320734207352073620737207382073920740207412074220743207442074520746207472074820749207502075120752207532075420755207562075720758207592076020761207622076320764207652076620767207682076920770207712077220773207742077520776207772077820779207802078120782207832078420785207862078720788207892079020791207922079320794207952079620797207982079920800208012080220803208042080520806208072080820809208102081120812208132081420815208162081720818208192082020821208222082320824208252082620827208282082920830208312083220833208342083520836208372083820839208402084120842208432084420845208462084720848208492085020851208522085320854208552085620857208582085920860208612086220863208642086520866208672086820869208702087120872208732087420875208762087720878208792088020881208822088320884208852088620887208882088920890208912089220893208942089520896208972089820899209002090120902209032090420905209062090720908209092091020911209122091320914209152091620917209182091920920209212092220923209242092520926209272092820929209302093120932209332093420935209362093720938209392094020941209422094320944209452094620947209482094920950209512095220953209542095520956209572095820959209602096120962209632096420965209662096720968209692097020971209722097320974209752097620977209782097920980209812098220983209842098520986209872098820989209902099120992209932099420995209962099720998209992100021001210022100321004210052100621007210082100921010210112101221013210142101521016210172101821019210202102121022210232102421025210262102721028210292103021031210322103321034210352103621037210382103921040210412104221043210442104521046210472104821049210502105121052210532105421055210562105721058210592106021061210622106321064210652106621067210682106921070210712107221073210742107521076210772107821079210802108121082210832108421085210862108721088210892109021091210922109321094210952109621097210982109921100211012110221103211042110521106211072110821109211102111121112211132111421115211162111721118211192112021121211222112321124211252112621127211282112921130211312113221133211342113521136211372113821139211402114121142211432114421145211462114721148211492115021151211522115321154211552115621157211582115921160211612116221163211642116521166211672116821169211702117121172211732117421175211762117721178211792118021181211822118321184211852118621187211882118921190211912119221193211942119521196211972119821199212002120121202212032120421205212062120721208212092121021211212122121321214212152121621217212182121921220212212122221223212242122521226212272122821229212302123121232212332123421235212362123721238212392124021241212422124321244212452124621247212482124921250212512125221253212542125521256212572125821259212602126121262212632126421265212662126721268212692127021271212722127321274212752127621277212782127921280212812128221283212842128521286212872128821289212902129121292212932129421295212962129721298212992130021301213022130321304213052130621307213082130921310213112131221313213142131521316213172131821319213202132121322213232132421325213262132721328213292133021331213322133321334213352133621337213382133921340213412134221343213442134521346213472134821349213502135121352213532135421355213562135721358213592136021361213622136321364213652136621367213682136921370213712137221373213742137521376213772137821379213802138121382213832138421385213862138721388213892139021391213922139321394213952139621397213982139921400214012140221403214042140521406214072140821409214102141121412214132141421415214162141721418214192142021421214222142321424214252142621427214282142921430214312143221433214342143521436214372143821439214402144121442214432144421445214462144721448214492145021451214522145321454214552145621457214582145921460214612146221463214642146521466214672146821469214702147121472214732147421475214762147721478214792148021481214822148321484214852148621487214882148921490214912149221493214942149521496214972149821499215002150121502215032150421505215062150721508215092151021511215122151321514215152151621517215182151921520215212152221523215242152521526215272152821529215302153121532215332153421535215362153721538215392154021541215422154321544215452154621547215482154921550215512155221553215542155521556215572155821559215602156121562215632156421565215662156721568215692157021571215722157321574215752157621577215782157921580215812158221583215842158521586215872158821589215902159121592215932159421595215962159721598215992160021601216022160321604216052160621607216082160921610216112161221613216142161521616216172161821619216202162121622216232162421625216262162721628216292163021631216322163321634216352163621637216382163921640216412164221643216442164521646216472164821649216502165121652216532165421655216562165721658216592166021661216622166321664216652166621667216682166921670216712167221673216742167521676216772167821679216802168121682216832168421685216862168721688216892169021691216922169321694216952169621697216982169921700217012170221703217042170521706217072170821709217102171121712217132171421715217162171721718217192172021721217222172321724217252172621727217282172921730217312173221733217342173521736217372173821739217402174121742217432174421745217462174721748217492175021751217522175321754217552175621757217582175921760217612176221763217642176521766217672176821769217702177121772217732177421775217762177721778217792178021781217822178321784217852178621787217882178921790217912179221793217942179521796217972179821799218002180121802218032180421805218062180721808218092181021811218122181321814218152181621817218182181921820218212182221823218242182521826218272182821829218302183121832218332183421835218362183721838218392184021841218422184321844218452184621847218482184921850218512185221853218542185521856218572185821859218602186121862218632186421865218662186721868218692187021871218722187321874218752187621877218782187921880218812188221883218842188521886218872188821889218902189121892218932189421895218962189721898218992190021901219022190321904219052190621907219082190921910219112191221913219142191521916219172191821919219202192121922219232192421925219262192721928219292193021931219322193321934219352193621937219382193921940219412194221943219442194521946219472194821949219502195121952219532195421955219562195721958219592196021961219622196321964219652196621967219682196921970219712197221973219742197521976219772197821979219802198121982219832198421985219862198721988219892199021991219922199321994219952199621997219982199922000220012200222003220042200522006220072200822009220102201122012220132201422015220162201722018220192202022021220222202322024220252202622027220282202922030220312203222033220342203522036220372203822039220402204122042220432204422045220462204722048220492205022051220522205322054220552205622057220582205922060220612206222063220642206522066220672206822069220702207122072220732207422075220762207722078220792208022081220822208322084220852208622087220882208922090220912209222093220942209522096220972209822099221002210122102221032210422105221062210722108221092211022111221122211322114221152211622117221182211922120221212212222123221242212522126221272212822129221302213122132221332213422135221362213722138221392214022141221422214322144221452214622147221482214922150221512215222153221542215522156221572215822159221602216122162221632216422165221662216722168221692217022171221722217322174221752217622177221782217922180221812218222183221842218522186221872218822189221902219122192221932219422195221962219722198221992220022201222022220322204222052220622207222082220922210222112221222213222142221522216222172221822219222202222122222222232222422225222262222722228222292223022231222322223322234222352223622237222382223922240222412224222243222442224522246222472224822249222502225122252222532225422255222562225722258222592226022261222622226322264222652226622267222682226922270222712227222273222742227522276222772227822279222802228122282222832228422285222862228722288222892229022291222922229322294222952229622297222982229922300223012230222303223042230522306223072230822309223102231122312223132231422315223162231722318223192232022321223222232322324223252232622327223282232922330223312233222333223342233522336223372233822339223402234122342223432234422345223462234722348223492235022351223522235322354223552235622357223582235922360223612236222363223642236522366223672236822369223702237122372223732237422375223762237722378223792238022381223822238322384223852238622387223882238922390223912239222393223942239522396223972239822399224002240122402224032240422405224062240722408224092241022411224122241322414224152241622417224182241922420224212242222423224242242522426224272242822429224302243122432224332243422435224362243722438224392244022441224422244322444224452244622447224482244922450224512245222453224542245522456224572245822459224602246122462224632246422465224662246722468224692247022471224722247322474224752247622477224782247922480224812248222483224842248522486224872248822489224902249122492224932249422495224962249722498224992250022501225022250322504225052250622507225082250922510225112251222513225142251522516225172251822519225202252122522225232252422525225262252722528225292253022531225322253322534225352253622537225382253922540225412254222543225442254522546225472254822549225502255122552225532255422555225562255722558225592256022561225622256322564225652256622567225682256922570225712257222573225742257522576225772257822579225802258122582225832258422585225862258722588225892259022591225922259322594225952259622597225982259922600226012260222603226042260522606226072260822609226102261122612226132261422615226162261722618226192262022621226222262322624226252262622627226282262922630226312263222633226342263522636226372263822639226402264122642226432264422645226462264722648226492265022651226522265322654226552265622657226582265922660226612266222663226642266522666226672266822669226702267122672226732267422675226762267722678226792268022681226822268322684226852268622687226882268922690226912269222693226942269522696226972269822699227002270122702227032270422705227062270722708227092271022711227122271322714227152271622717227182271922720227212272222723227242272522726227272272822729227302273122732227332273422735227362273722738227392274022741227422274322744227452274622747227482274922750227512275222753227542275522756227572275822759227602276122762227632276422765227662276722768227692277022771227722277322774227752277622777227782277922780227812278222783227842278522786227872278822789227902279122792227932279422795227962279722798227992280022801228022280322804228052280622807228082280922810228112281222813228142281522816228172281822819228202282122822228232282422825228262282722828228292283022831228322283322834228352283622837228382283922840228412284222843228442284522846228472284822849228502285122852228532285422855228562285722858228592286022861228622286322864228652286622867228682286922870228712287222873228742287522876228772287822879228802288122882228832288422885228862288722888228892289022891228922289322894228952289622897228982289922900229012290222903229042290522906229072290822909229102291122912229132291422915229162291722918229192292022921229222292322924229252292622927229282292922930229312293222933229342293522936229372293822939229402294122942229432294422945229462294722948229492295022951229522295322954229552295622957229582295922960229612296222963229642296522966229672296822969229702297122972229732297422975229762297722978229792298022981229822298322984229852298622987229882298922990229912299222993229942299522996229972299822999230002300123002230032300423005230062300723008230092301023011230122301323014230152301623017230182301923020230212302223023230242302523026230272302823029230302303123032230332303423035230362303723038230392304023041230422304323044230452304623047230482304923050230512305223053230542305523056230572305823059230602306123062230632306423065230662306723068230692307023071230722307323074230752307623077230782307923080230812308223083230842308523086230872308823089230902309123092230932309423095230962309723098230992310023101231022310323104231052310623107231082310923110231112311223113231142311523116231172311823119231202312123122231232312423125231262312723128231292313023131231322313323134231352313623137231382313923140231412314223143231442314523146231472314823149231502315123152231532315423155231562315723158231592316023161231622316323164231652316623167231682316923170231712317223173231742317523176231772317823179231802318123182231832318423185231862318723188231892319023191231922319323194231952319623197231982319923200232012320223203232042320523206232072320823209232102321123212232132321423215232162321723218232192322023221232222322323224232252322623227232282322923230232312323223233232342323523236232372323823239232402324123242232432324423245232462324723248232492325023251232522325323254232552325623257232582325923260232612326223263232642326523266232672326823269232702327123272232732327423275232762327723278232792328023281232822328323284232852328623287232882328923290232912329223293232942329523296232972329823299233002330123302233032330423305233062330723308233092331023311233122331323314233152331623317233182331923320233212332223323233242332523326233272332823329233302333123332233332333423335233362333723338233392334023341233422334323344233452334623347233482334923350233512335223353233542335523356233572335823359233602336123362233632336423365233662336723368233692337023371233722337323374233752337623377233782337923380233812338223383233842338523386233872338823389233902339123392233932339423395233962339723398233992340023401234022340323404234052340623407234082340923410234112341223413234142341523416234172341823419234202342123422234232342423425234262342723428234292343023431234322343323434234352343623437234382343923440234412344223443234442344523446234472344823449234502345123452234532345423455234562345723458234592346023461234622346323464234652346623467234682346923470234712347223473234742347523476234772347823479234802348123482234832348423485234862348723488234892349023491234922349323494234952349623497234982349923500235012350223503235042350523506235072350823509235102351123512235132351423515235162351723518235192352023521235222352323524235252352623527235282352923530235312353223533235342353523536235372353823539235402354123542235432354423545235462354723548235492355023551235522355323554235552355623557235582355923560235612356223563235642356523566235672356823569235702357123572235732357423575235762357723578235792358023581235822358323584235852358623587235882358923590235912359223593235942359523596235972359823599236002360123602236032360423605236062360723608236092361023611236122361323614236152361623617236182361923620236212362223623236242362523626236272362823629236302363123632236332363423635236362363723638236392364023641236422364323644236452364623647236482364923650236512365223653236542365523656236572365823659236602366123662236632366423665236662366723668236692367023671236722367323674236752367623677236782367923680236812368223683236842368523686236872368823689236902369123692236932369423695236962369723698236992370023701237022370323704237052370623707237082370923710237112371223713237142371523716237172371823719237202372123722237232372423725237262372723728237292373023731237322373323734237352373623737237382373923740237412374223743237442374523746237472374823749237502375123752237532375423755237562375723758237592376023761237622376323764237652376623767237682376923770237712377223773237742377523776237772377823779237802378123782237832378423785237862378723788237892379023791237922379323794237952379623797237982379923800238012380223803238042380523806238072380823809238102381123812238132381423815238162381723818238192382023821238222382323824238252382623827238282382923830238312383223833238342383523836238372383823839238402384123842238432384423845238462384723848238492385023851238522385323854238552385623857238582385923860238612386223863238642386523866238672386823869238702387123872238732387423875238762387723878238792388023881238822388323884238852388623887238882388923890238912389223893238942389523896238972389823899239002390123902239032390423905239062390723908239092391023911239122391323914239152391623917239182391923920239212392223923239242392523926239272392823929239302393123932239332393423935239362393723938239392394023941239422394323944239452394623947239482394923950239512395223953239542395523956239572395823959239602396123962239632396423965239662396723968239692397023971239722397323974239752397623977239782397923980239812398223983239842398523986239872398823989239902399123992239932399423995239962399723998239992400024001240022400324004240052400624007240082400924010240112401224013240142401524016240172401824019240202402124022240232402424025240262402724028240292403024031240322403324034240352403624037240382403924040240412404224043240442404524046240472404824049240502405124052240532405424055240562405724058240592406024061240622406324064240652406624067240682406924070240712407224073240742407524076240772407824079240802408124082240832408424085240862408724088240892409024091240922409324094240952409624097240982409924100241012410224103241042410524106241072410824109241102411124112241132411424115241162411724118241192412024121241222412324124241252412624127241282412924130241312413224133241342413524136241372413824139241402414124142241432414424145241462414724148241492415024151241522415324154241552415624157241582415924160241612416224163241642416524166241672416824169241702417124172241732417424175241762417724178241792418024181241822418324184241852418624187241882418924190241912419224193241942419524196241972419824199242002420124202242032420424205242062420724208242092421024211242122421324214242152421624217242182421924220242212422224223242242422524226242272422824229242302423124232242332423424235242362423724238242392424024241242422424324244242452424624247242482424924250242512425224253242542425524256242572425824259242602426124262242632426424265242662426724268242692427024271242722427324274242752427624277242782427924280242812428224283242842428524286242872428824289242902429124292242932429424295242962429724298242992430024301243022430324304243052430624307243082430924310243112431224313243142431524316243172431824319243202432124322243232432424325243262432724328243292433024331243322433324334243352433624337243382433924340243412434224343243442434524346243472434824349243502435124352243532435424355243562435724358243592436024361243622436324364243652436624367243682436924370243712437224373243742437524376243772437824379243802438124382243832438424385243862438724388243892439024391243922439324394243952439624397243982439924400244012440224403244042440524406244072440824409244102441124412244132441424415244162441724418244192442024421244222442324424244252442624427244282442924430244312443224433244342443524436244372443824439244402444124442244432444424445244462444724448244492445024451244522445324454244552445624457244582445924460244612446224463244642446524466244672446824469244702447124472244732447424475244762447724478244792448024481244822448324484244852448624487244882448924490244912449224493244942449524496244972449824499245002450124502245032450424505245062450724508245092451024511245122451324514245152451624517245182451924520245212452224523245242452524526245272452824529245302453124532245332453424535245362453724538245392454024541245422454324544245452454624547245482454924550245512455224553245542455524556245572455824559245602456124562245632456424565245662456724568245692457024571245722457324574245752457624577245782457924580245812458224583245842458524586245872458824589245902459124592245932459424595245962459724598245992460024601246022460324604246052460624607246082460924610246112461224613246142461524616246172461824619246202462124622246232462424625246262462724628246292463024631246322463324634246352463624637246382463924640246412464224643246442464524646246472464824649246502465124652246532465424655246562465724658246592466024661246622466324664246652466624667246682466924670246712467224673246742467524676246772467824679246802468124682246832468424685246862468724688246892469024691246922469324694246952469624697246982469924700247012470224703247042470524706247072470824709247102471124712247132471424715247162471724718247192472024721247222472324724247252472624727247282472924730247312473224733247342473524736247372473824739247402474124742247432474424745247462474724748247492475024751247522475324754247552475624757247582475924760247612476224763247642476524766247672476824769247702477124772247732477424775247762477724778247792478024781247822478324784247852478624787247882478924790247912479224793247942479524796247972479824799248002480124802248032480424805248062480724808248092481024811248122481324814248152481624817248182481924820248212482224823248242482524826248272482824829248302483124832248332483424835248362483724838248392484024841248422484324844248452484624847248482484924850248512485224853248542485524856248572485824859248602486124862248632486424865248662486724868248692487024871248722487324874248752487624877248782487924880248812488224883248842488524886248872488824889248902489124892248932489424895248962489724898248992490024901249022490324904249052490624907249082490924910249112491224913249142491524916249172491824919249202492124922249232492424925249262492724928249292493024931249322493324934249352493624937249382493924940249412494224943249442494524946249472494824949249502495124952249532495424955249562495724958249592496024961249622496324964249652496624967249682496924970249712497224973249742497524976249772497824979249802498124982249832498424985249862498724988249892499024991249922499324994249952499624997249982499925000250012500225003250042500525006250072500825009250102501125012250132501425015250162501725018250192502025021250222502325024250252502625027250282502925030250312503225033250342503525036250372503825039250402504125042250432504425045250462504725048250492505025051250522505325054250552505625057250582505925060250612506225063250642506525066250672506825069250702507125072250732507425075250762507725078250792508025081250822508325084250852508625087250882508925090250912509225093250942509525096250972509825099251002510125102251032510425105251062510725108251092511025111251122511325114251152511625117251182511925120251212512225123251242512525126251272512825129251302513125132251332513425135251362513725138251392514025141251422514325144251452514625147251482514925150251512515225153251542515525156251572515825159251602516125162251632516425165251662516725168251692517025171251722517325174251752517625177251782517925180251812518225183251842518525186251872518825189251902519125192251932519425195251962519725198251992520025201252022520325204252052520625207252082520925210252112521225213252142521525216252172521825219252202522125222252232522425225252262522725228252292523025231252322523325234252352523625237252382523925240252412524225243252442524525246252472524825249252502525125252252532525425255252562525725258252592526025261252622526325264252652526625267252682526925270252712527225273252742527525276252772527825279252802528125282252832528425285252862528725288252892529025291252922529325294252952529625297252982529925300253012530225303253042530525306253072530825309253102531125312253132531425315253162531725318253192532025321253222532325324253252532625327253282532925330253312533225333253342533525336253372533825339253402534125342253432534425345253462534725348253492535025351253522535325354253552535625357253582535925360253612536225363253642536525366253672536825369253702537125372253732537425375253762537725378253792538025381253822538325384253852538625387253882538925390253912539225393253942539525396253972539825399254002540125402254032540425405254062540725408254092541025411254122541325414254152541625417254182541925420254212542225423254242542525426254272542825429254302543125432254332543425435254362543725438254392544025441254422544325444254452544625447254482544925450254512545225453254542545525456254572545825459254602546125462254632546425465254662546725468254692547025471254722547325474254752547625477254782547925480254812548225483254842548525486254872548825489254902549125492254932549425495254962549725498254992550025501255022550325504255052550625507255082550925510255112551225513255142551525516255172551825519255202552125522255232552425525255262552725528255292553025531255322553325534255352553625537255382553925540255412554225543255442554525546255472554825549255502555125552255532555425555255562555725558255592556025561255622556325564255652556625567255682556925570255712557225573255742557525576255772557825579255802558125582255832558425585255862558725588255892559025591255922559325594255952559625597255982559925600256012560225603256042560525606256072560825609256102561125612256132561425615256162561725618256192562025621256222562325624256252562625627256282562925630256312563225633256342563525636256372563825639256402564125642256432564425645256462564725648256492565025651256522565325654256552565625657256582565925660256612566225663256642566525666256672566825669256702567125672256732567425675256762567725678256792568025681256822568325684256852568625687256882568925690256912569225693256942569525696256972569825699257002570125702257032570425705257062570725708257092571025711257122571325714257152571625717257182571925720257212572225723257242572525726257272572825729257302573125732257332573425735257362573725738257392574025741257422574325744257452574625747257482574925750257512575225753257542575525756257572575825759257602576125762257632576425765257662576725768257692577025771257722577325774257752577625777257782577925780257812578225783257842578525786257872578825789257902579125792257932579425795257962579725798257992580025801258022580325804258052580625807258082580925810258112581225813258142581525816258172581825819258202582125822258232582425825258262582725828258292583025831258322583325834258352583625837258382583925840258412584225843258442584525846258472584825849258502585125852258532585425855258562585725858258592586025861258622586325864258652586625867258682586925870258712587225873258742587525876258772587825879258802588125882258832588425885258862588725888258892589025891258922589325894258952589625897258982589925900259012590225903259042590525906259072590825909259102591125912259132591425915259162591725918259192592025921259222592325924259252592625927259282592925930259312593225933259342593525936259372593825939259402594125942259432594425945259462594725948259492595025951259522595325954259552595625957259582595925960259612596225963259642596525966259672596825969259702597125972259732597425975259762597725978259792598025981259822598325984259852598625987259882598925990259912599225993259942599525996259972599825999260002600126002260032600426005260062600726008260092601026011260122601326014260152601626017260182601926020260212602226023260242602526026260272602826029260302603126032260332603426035260362603726038260392604026041260422604326044260452604626047260482604926050260512605226053260542605526056260572605826059260602606126062260632606426065260662606726068260692607026071260722607326074260752607626077260782607926080260812608226083260842608526086260872608826089260902609126092260932609426095260962609726098260992610026101261022610326104261052610626107261082610926110261112611226113261142611526116261172611826119261202612126122261232612426125261262612726128261292613026131261322613326134261352613626137261382613926140261412614226143261442614526146261472614826149261502615126152261532615426155261562615726158261592616026161261622616326164261652616626167261682616926170261712617226173261742617526176261772617826179261802618126182261832618426185261862618726188261892619026191261922619326194261952619626197261982619926200262012620226203262042620526206262072620826209262102621126212262132621426215262162621726218262192622026221262222622326224262252622626227262282622926230262312623226233262342623526236262372623826239262402624126242262432624426245262462624726248262492625026251262522625326254262552625626257262582625926260262612626226263262642626526266262672626826269262702627126272262732627426275262762627726278262792628026281262822628326284262852628626287262882628926290262912629226293262942629526296262972629826299263002630126302263032630426305263062630726308263092631026311263122631326314263152631626317263182631926320263212632226323263242632526326263272632826329263302633126332263332633426335263362633726338263392634026341263422634326344263452634626347263482634926350263512635226353263542635526356263572635826359263602636126362263632636426365263662636726368263692637026371263722637326374263752637626377263782637926380263812638226383263842638526386263872638826389263902639126392263932639426395263962639726398263992640026401264022640326404264052640626407264082640926410264112641226413264142641526416264172641826419264202642126422264232642426425264262642726428264292643026431264322643326434264352643626437264382643926440264412644226443264442644526446264472644826449264502645126452264532645426455264562645726458264592646026461264622646326464264652646626467264682646926470264712647226473264742647526476264772647826479264802648126482264832648426485264862648726488264892649026491264922649326494264952649626497264982649926500265012650226503265042650526506265072650826509265102651126512265132651426515265162651726518265192652026521265222652326524265252652626527265282652926530265312653226533265342653526536265372653826539265402654126542265432654426545265462654726548265492655026551265522655326554265552655626557265582655926560265612656226563265642656526566265672656826569265702657126572265732657426575265762657726578265792658026581265822658326584265852658626587265882658926590265912659226593265942659526596265972659826599266002660126602266032660426605266062660726608266092661026611266122661326614266152661626617266182661926620266212662226623266242662526626266272662826629266302663126632266332663426635266362663726638266392664026641266422664326644266452664626647266482664926650266512665226653266542665526656266572665826659266602666126662266632666426665266662666726668266692667026671266722667326674266752667626677266782667926680266812668226683266842668526686266872668826689266902669126692266932669426695266962669726698266992670026701267022670326704267052670626707267082670926710267112671226713267142671526716267172671826719267202672126722267232672426725267262672726728267292673026731267322673326734267352673626737267382673926740267412674226743267442674526746267472674826749267502675126752267532675426755267562675726758267592676026761267622676326764267652676626767267682676926770267712677226773267742677526776267772677826779267802678126782267832678426785267862678726788267892679026791267922679326794267952679626797267982679926800268012680226803268042680526806268072680826809268102681126812268132681426815268162681726818268192682026821268222682326824268252682626827268282682926830268312683226833268342683526836268372683826839268402684126842268432684426845268462684726848268492685026851268522685326854268552685626857268582685926860268612686226863268642686526866268672686826869268702687126872268732687426875268762687726878268792688026881268822688326884268852688626887268882688926890268912689226893268942689526896268972689826899269002690126902269032690426905269062690726908269092691026911269122691326914269152691626917269182691926920269212692226923269242692526926269272692826929269302693126932269332693426935269362693726938269392694026941269422694326944269452694626947269482694926950269512695226953269542695526956269572695826959269602696126962269632696426965269662696726968269692697026971269722697326974269752697626977269782697926980269812698226983269842698526986269872698826989269902699126992269932699426995269962699726998269992700027001270022700327004270052700627007270082700927010270112701227013270142701527016270172701827019270202702127022270232702427025270262702727028270292703027031270322703327034270352703627037270382703927040270412704227043270442704527046270472704827049270502705127052270532705427055270562705727058270592706027061270622706327064270652706627067270682706927070270712707227073270742707527076270772707827079270802708127082270832708427085270862708727088270892709027091270922709327094270952709627097270982709927100271012710227103271042710527106271072710827109271102711127112271132711427115271162711727118271192712027121271222712327124271252712627127271282712927130271312713227133271342713527136271372713827139271402714127142271432714427145271462714727148271492715027151271522715327154271552715627157271582715927160271612716227163271642716527166271672716827169271702717127172271732717427175271762717727178271792718027181271822718327184271852718627187271882718927190271912719227193271942719527196271972719827199272002720127202272032720427205272062720727208272092721027211272122721327214272152721627217272182721927220272212722227223272242722527226272272722827229272302723127232272332723427235272362723727238272392724027241272422724327244272452724627247272482724927250272512725227253272542725527256272572725827259272602726127262272632726427265272662726727268272692727027271272722727327274272752727627277272782727927280272812728227283272842728527286272872728827289272902729127292272932729427295272962729727298272992730027301273022730327304273052730627307273082730927310273112731227313273142731527316273172731827319273202732127322273232732427325273262732727328273292733027331273322733327334273352733627337273382733927340273412734227343273442734527346273472734827349273502735127352273532735427355273562735727358273592736027361273622736327364
  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. "use strict";
  3269. var _WeakMap = _dereq_("@babel/runtime-corejs3/core-js-stable/weak-map");
  3270. var _Object$defineProperty = _dereq_("@babel/runtime-corejs3/core-js-stable/object/define-property");
  3271. var _Object$getOwnPropertyDescriptor = _dereq_("@babel/runtime-corejs3/core-js-stable/object/get-own-property-descriptor");
  3272. var _interopRequireDefault = _dereq_("@babel/runtime-corejs3/helpers/interopRequireDefault");
  3273. _Object$defineProperty(exports, "__esModule", {
  3274. value: true
  3275. });
  3276. exports.default = void 0;
  3277. var _promise = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/promise"));
  3278. var _decode2 = _interopRequireDefault(_dereq_("./decode"));
  3279. var _encode2 = _interopRequireDefault(_dereq_("./encode"));
  3280. var _CryptoController = _interopRequireDefault(_dereq_("./CryptoController"));
  3281. var _EventuallyQueue = _interopRequireDefault(_dereq_("./EventuallyQueue"));
  3282. var _IndexedDBStorageController = _interopRequireDefault(_dereq_("./IndexedDBStorageController"));
  3283. var _InstallationController = _interopRequireDefault(_dereq_("./InstallationController"));
  3284. var ParseOp = _interopRequireWildcard(_dereq_("./ParseOp"));
  3285. var _RESTController = _interopRequireDefault(_dereq_("./RESTController"));
  3286. var _ParseACL = _interopRequireDefault(_dereq_("./ParseACL"));
  3287. var Analytics = _interopRequireWildcard(_dereq_("./Analytics"));
  3288. var _AnonymousUtils = _interopRequireDefault(_dereq_("./AnonymousUtils"));
  3289. var Cloud = _interopRequireWildcard(_dereq_("./Cloud"));
  3290. var _ParseCLP = _interopRequireDefault(_dereq_("./ParseCLP"));
  3291. var _CoreManager = _interopRequireDefault(_dereq_("./CoreManager"));
  3292. var _EventEmitter = _interopRequireDefault(_dereq_("./EventEmitter"));
  3293. var _ParseConfig = _interopRequireDefault(_dereq_("./ParseConfig"));
  3294. var _ParseError = _interopRequireDefault(_dereq_("./ParseError"));
  3295. var _FacebookUtils = _interopRequireDefault(_dereq_("./FacebookUtils"));
  3296. var _ParseFile = _interopRequireDefault(_dereq_("./ParseFile"));
  3297. var Hooks = _interopRequireWildcard(_dereq_("./ParseHooks"));
  3298. var _ParseGeoPoint = _interopRequireDefault(_dereq_("./ParseGeoPoint"));
  3299. var _ParsePolygon = _interopRequireDefault(_dereq_("./ParsePolygon"));
  3300. var _ParseInstallation = _interopRequireDefault(_dereq_("./ParseInstallation"));
  3301. var _LocalDatastore = _interopRequireDefault(_dereq_("./LocalDatastore"));
  3302. var _ParseObject = _interopRequireDefault(_dereq_("./ParseObject"));
  3303. var Push = _interopRequireWildcard(_dereq_("./Push"));
  3304. var _ParseQuery = _interopRequireDefault(_dereq_("./ParseQuery"));
  3305. var _ParseRelation = _interopRequireDefault(_dereq_("./ParseRelation"));
  3306. var _ParseRole = _interopRequireDefault(_dereq_("./ParseRole"));
  3307. var _ParseSchema = _interopRequireDefault(_dereq_("./ParseSchema"));
  3308. var _ParseSession = _interopRequireDefault(_dereq_("./ParseSession"));
  3309. var _Storage = _interopRequireDefault(_dereq_("./Storage"));
  3310. var _ParseUser = _interopRequireDefault(_dereq_("./ParseUser"));
  3311. var _ParseLiveQuery = _interopRequireDefault(_dereq_("./ParseLiveQuery"));
  3312. var _LiveQueryClient = _interopRequireDefault(_dereq_("./LiveQueryClient"));
  3313. var _LocalDatastoreController = _interopRequireDefault(_dereq_("./LocalDatastoreController"));
  3314. var _StorageController = _interopRequireDefault(_dereq_("./StorageController"));
  3315. var _WebSocketController = _interopRequireDefault(_dereq_("./WebSocketController"));
  3316. function _getRequireWildcardCache(e) {
  3317. if ("function" != typeof _WeakMap) return null;
  3318. var r = new _WeakMap(),
  3319. t = new _WeakMap();
  3320. return (_getRequireWildcardCache = function (e) {
  3321. return e ? t : r;
  3322. })(e);
  3323. }
  3324. function _interopRequireWildcard(e, r) {
  3325. if (!r && e && e.__esModule) return e;
  3326. if (null === e || "object" != typeof e && "function" != typeof e) return {
  3327. default: e
  3328. };
  3329. var t = _getRequireWildcardCache(r);
  3330. if (t && t.has(e)) return t.get(e);
  3331. var n = {
  3332. __proto__: null
  3333. };
  3334. for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) {
  3335. var i = _Object$defineProperty && _Object$getOwnPropertyDescriptor ? _Object$getOwnPropertyDescriptor(e, u) : null;
  3336. i && (i.get || i.set) ? _Object$defineProperty(n, u, i) : n[u] = e[u];
  3337. }
  3338. return n.default = e, t && t.set(e, n), n;
  3339. }
  3340. /**
  3341. * Contains all Parse API classes and functions.
  3342. *
  3343. * @static
  3344. * @global
  3345. * @class
  3346. * @hideconstructor
  3347. */
  3348. const Parse = {
  3349. ACL: _ParseACL.default,
  3350. Analytics: Analytics,
  3351. AnonymousUtils: _AnonymousUtils.default,
  3352. Cloud: Cloud,
  3353. CLP: _ParseCLP.default,
  3354. CoreManager: _CoreManager.default,
  3355. Config: _ParseConfig.default,
  3356. Error: _ParseError.default,
  3357. FacebookUtils: _FacebookUtils.default,
  3358. File: _ParseFile.default,
  3359. GeoPoint: _ParseGeoPoint.default,
  3360. Polygon: _ParsePolygon.default,
  3361. Installation: _ParseInstallation.default,
  3362. LocalDatastore: _LocalDatastore.default,
  3363. Object: _ParseObject.default,
  3364. Op: {
  3365. Set: ParseOp.SetOp,
  3366. Unset: ParseOp.UnsetOp,
  3367. Increment: ParseOp.IncrementOp,
  3368. Add: ParseOp.AddOp,
  3369. Remove: ParseOp.RemoveOp,
  3370. AddUnique: ParseOp.AddUniqueOp,
  3371. Relation: ParseOp.RelationOp
  3372. },
  3373. Push: Push,
  3374. Query: _ParseQuery.default,
  3375. Relation: _ParseRelation.default,
  3376. Role: _ParseRole.default,
  3377. Schema: _ParseSchema.default,
  3378. Session: _ParseSession.default,
  3379. Storage: _Storage.default,
  3380. User: _ParseUser.default,
  3381. LiveQueryClient: _LiveQueryClient.default,
  3382. IndexedDB: undefined,
  3383. Hooks: undefined,
  3384. Parse: undefined,
  3385. /**
  3386. * @member {EventuallyQueue} Parse.EventuallyQueue
  3387. * @static
  3388. */
  3389. set EventuallyQueue(queue) {
  3390. _CoreManager.default.setEventuallyQueue(queue);
  3391. },
  3392. get EventuallyQueue() {
  3393. return _CoreManager.default.getEventuallyQueue();
  3394. },
  3395. /**
  3396. * Call this method first to set up your authentication tokens for Parse.
  3397. *
  3398. * @param {string} applicationId Your Parse Application ID.
  3399. * @param {string} [javaScriptKey] Your Parse JavaScript Key (Not needed for parse-server)
  3400. * @param {string} [masterKey] Your Parse Master Key. (Node.js only!)
  3401. * @static
  3402. */
  3403. initialize(applicationId, javaScriptKey) {
  3404. Parse._initialize(applicationId, javaScriptKey);
  3405. },
  3406. _initialize(applicationId, javaScriptKey, masterKey) {
  3407. _CoreManager.default.set('APPLICATION_ID', applicationId);
  3408. _CoreManager.default.set('JAVASCRIPT_KEY', javaScriptKey);
  3409. _CoreManager.default.set('MASTER_KEY', masterKey);
  3410. _CoreManager.default.set('USE_MASTER_KEY', false);
  3411. _CoreManager.default.setIfNeeded('EventEmitter', _EventEmitter.default);
  3412. _CoreManager.default.setIfNeeded('LiveQuery', new _ParseLiveQuery.default());
  3413. _CoreManager.default.setIfNeeded('CryptoController', _CryptoController.default);
  3414. _CoreManager.default.setIfNeeded('EventuallyQueue', _EventuallyQueue.default);
  3415. _CoreManager.default.setIfNeeded('InstallationController', _InstallationController.default);
  3416. _CoreManager.default.setIfNeeded('LocalDatastoreController', _LocalDatastoreController.default);
  3417. _CoreManager.default.setIfNeeded('StorageController', _StorageController.default);
  3418. _CoreManager.default.setIfNeeded('WebSocketController', _WebSocketController.default);
  3419. },
  3420. /**
  3421. * Call this method to set your AsyncStorage engine
  3422. * Starting Parse@1.11, the ParseSDK do not provide a React AsyncStorage as the ReactNative module
  3423. * is not provided at a stable path and changes over versions.
  3424. *
  3425. * @param {AsyncStorage} storage a react native async storage.
  3426. * @static
  3427. */
  3428. setAsyncStorage(storage) {
  3429. _CoreManager.default.setAsyncStorage(storage);
  3430. },
  3431. /**
  3432. * Call this method to set your LocalDatastoreStorage engine
  3433. * If using React-Native use {@link Parse.setAsyncStorage Parse.setAsyncStorage()}
  3434. *
  3435. * @param {LocalDatastoreController} controller a data storage.
  3436. * @static
  3437. */
  3438. setLocalDatastoreController(controller) {
  3439. _CoreManager.default.setLocalDatastoreController(controller);
  3440. },
  3441. /**
  3442. * Returns information regarding the current server's health
  3443. *
  3444. * @returns {Promise}
  3445. * @static
  3446. */
  3447. getServerHealth() {
  3448. return _CoreManager.default.getRESTController().request('GET', 'health');
  3449. },
  3450. /**
  3451. * @member {string} Parse.applicationId
  3452. * @static
  3453. */
  3454. set applicationId(value) {
  3455. _CoreManager.default.set('APPLICATION_ID', value);
  3456. },
  3457. get applicationId() {
  3458. return _CoreManager.default.get('APPLICATION_ID');
  3459. },
  3460. /**
  3461. * @member {string} Parse.javaScriptKey
  3462. * @static
  3463. */
  3464. set javaScriptKey(value) {
  3465. _CoreManager.default.set('JAVASCRIPT_KEY', value);
  3466. },
  3467. get javaScriptKey() {
  3468. return _CoreManager.default.get('JAVASCRIPT_KEY');
  3469. },
  3470. /**
  3471. * @member {string} Parse.masterKey
  3472. * @static
  3473. */
  3474. set masterKey(value) {
  3475. _CoreManager.default.set('MASTER_KEY', value);
  3476. },
  3477. get masterKey() {
  3478. return _CoreManager.default.get('MASTER_KEY');
  3479. },
  3480. /**
  3481. * @member {string} Parse.serverURL
  3482. * @static
  3483. */
  3484. set serverURL(value) {
  3485. _CoreManager.default.set('SERVER_URL', value);
  3486. },
  3487. get serverURL() {
  3488. return _CoreManager.default.get('SERVER_URL');
  3489. },
  3490. /**
  3491. * @member {string} Parse.serverAuthToken
  3492. * @static
  3493. */
  3494. set serverAuthToken(value) {
  3495. _CoreManager.default.set('SERVER_AUTH_TOKEN', value);
  3496. },
  3497. get serverAuthToken() {
  3498. return _CoreManager.default.get('SERVER_AUTH_TOKEN');
  3499. },
  3500. /**
  3501. * @member {string} Parse.serverAuthType
  3502. * @static
  3503. */
  3504. set serverAuthType(value) {
  3505. _CoreManager.default.set('SERVER_AUTH_TYPE', value);
  3506. },
  3507. get serverAuthType() {
  3508. return _CoreManager.default.get('SERVER_AUTH_TYPE');
  3509. },
  3510. /**
  3511. * @member {ParseLiveQuery} Parse.LiveQuery
  3512. * @static
  3513. */
  3514. set LiveQuery(liveQuery) {
  3515. _CoreManager.default.setLiveQuery(liveQuery);
  3516. },
  3517. get LiveQuery() {
  3518. return _CoreManager.default.getLiveQuery();
  3519. },
  3520. /**
  3521. * @member {string} Parse.liveQueryServerURL
  3522. * @static
  3523. */
  3524. set liveQueryServerURL(value) {
  3525. _CoreManager.default.set('LIVEQUERY_SERVER_URL', value);
  3526. },
  3527. get liveQueryServerURL() {
  3528. return _CoreManager.default.get('LIVEQUERY_SERVER_URL');
  3529. },
  3530. /**
  3531. * @member {boolean} Parse.encryptedUser
  3532. * @static
  3533. */
  3534. set encryptedUser(value) {
  3535. _CoreManager.default.set('ENCRYPTED_USER', value);
  3536. },
  3537. get encryptedUser() {
  3538. return _CoreManager.default.get('ENCRYPTED_USER');
  3539. },
  3540. /**
  3541. * @member {string} Parse.secret
  3542. * @static
  3543. */
  3544. set secret(value) {
  3545. _CoreManager.default.set('ENCRYPTED_KEY', value);
  3546. },
  3547. get secret() {
  3548. return _CoreManager.default.get('ENCRYPTED_KEY');
  3549. },
  3550. /**
  3551. * @member {boolean} Parse.idempotency
  3552. * @static
  3553. */
  3554. set idempotency(value) {
  3555. _CoreManager.default.set('IDEMPOTENCY', value);
  3556. },
  3557. get idempotency() {
  3558. return _CoreManager.default.get('IDEMPOTENCY');
  3559. },
  3560. /**
  3561. * @member {boolean} Parse.allowCustomObjectId
  3562. * @static
  3563. */
  3564. set allowCustomObjectId(value) {
  3565. _CoreManager.default.set('ALLOW_CUSTOM_OBJECT_ID', value);
  3566. },
  3567. get allowCustomObjectId() {
  3568. return _CoreManager.default.get('ALLOW_CUSTOM_OBJECT_ID');
  3569. },
  3570. _request() {
  3571. for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
  3572. args[_key] = arguments[_key];
  3573. }
  3574. return _CoreManager.default.getRESTController().request.apply(null, args);
  3575. },
  3576. _ajax() {
  3577. for (var _len2 = arguments.length, args = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
  3578. args[_key2] = arguments[_key2];
  3579. }
  3580. return _CoreManager.default.getRESTController().ajax.apply(null, args);
  3581. },
  3582. // We attempt to match the signatures of the legacy versions of these methods
  3583. _decode(_, value) {
  3584. return (0, _decode2.default)(value);
  3585. },
  3586. _encode(value, _, disallowObjects) {
  3587. return (0, _encode2.default)(value, disallowObjects);
  3588. },
  3589. _getInstallationId() {
  3590. return _CoreManager.default.getInstallationController().currentInstallationId();
  3591. },
  3592. /**
  3593. * Enable pinning in your application.
  3594. * This must be called after `Parse.initialize` in your application.
  3595. *
  3596. * @param [polling] Allow pinging the server /health endpoint. Default true
  3597. * @param [ms] Milliseconds to ping the server. Default 2000ms
  3598. * @static
  3599. */
  3600. enableLocalDatastore() {
  3601. let polling = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : true;
  3602. let ms = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 2000;
  3603. if (!this.applicationId) {
  3604. console.log("'enableLocalDataStore' must be called after 'initialize'");
  3605. return;
  3606. }
  3607. if (!this.LocalDatastore.isEnabled) {
  3608. this.LocalDatastore.isEnabled = true;
  3609. if (polling) {
  3610. _CoreManager.default.getEventuallyQueue().poll(ms);
  3611. }
  3612. }
  3613. },
  3614. /**
  3615. * Flag that indicates whether Local Datastore is enabled.
  3616. *
  3617. * @static
  3618. * @returns {boolean}
  3619. */
  3620. isLocalDatastoreEnabled() {
  3621. return this.LocalDatastore.isEnabled;
  3622. },
  3623. /**
  3624. * Gets all contents from Local Datastore
  3625. *
  3626. * <pre>
  3627. * await Parse.dumpLocalDatastore();
  3628. * </pre>
  3629. *
  3630. * @static
  3631. * @returns {object}
  3632. */
  3633. dumpLocalDatastore() {
  3634. if (!this.LocalDatastore.isEnabled) {
  3635. console.log('Parse.enableLocalDatastore() must be called first'); // eslint-disable-line no-console
  3636. return _promise.default.resolve({});
  3637. } else {
  3638. return Parse.LocalDatastore._getAllContents();
  3639. }
  3640. },
  3641. /**
  3642. * Enable the current user encryption.
  3643. * This must be called before login any user.
  3644. *
  3645. * @static
  3646. */
  3647. enableEncryptedUser() {
  3648. this.encryptedUser = true;
  3649. },
  3650. /**
  3651. * Flag that indicates whether Encrypted User is enabled.
  3652. *
  3653. * @static
  3654. * @returns {boolean}
  3655. */
  3656. isEncryptedUserEnabled() {
  3657. return this.encryptedUser;
  3658. }
  3659. };
  3660. _CoreManager.default.setRESTController(_RESTController.default);
  3661. // For legacy requires, of the form `var Parse = require('parse').Parse`
  3662. Parse.Parse = Parse;
  3663. module.exports = Parse;
  3664. var _default = exports.default = Parse;
  3665. },{"./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}],21:[function(_dereq_,module,exports){
  3666. "use strict";
  3667. var _Object$defineProperty = _dereq_("@babel/runtime-corejs3/core-js-stable/object/define-property");
  3668. var _interopRequireDefault = _dereq_("@babel/runtime-corejs3/helpers/interopRequireDefault");
  3669. _Object$defineProperty(exports, "__esModule", {
  3670. value: true
  3671. });
  3672. exports.default = void 0;
  3673. var _keys = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/object/keys"));
  3674. var _defineProperty2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/helpers/defineProperty"));
  3675. var _CoreManager = _interopRequireDefault(_dereq_("./CoreManager"));
  3676. const PUBLIC_KEY = '*';
  3677. /**
  3678. * Creates a new ACL.
  3679. * If no argument is given, the ACL has no permissions for anyone.
  3680. * If the argument is a Parse.User, the ACL will have read and write
  3681. * permission for only that user.
  3682. * If the argument is any other JSON object, that object will be interpretted
  3683. * as a serialized ACL created with toJSON().
  3684. *
  3685. * <p>An ACL, or Access Control List can be added to any
  3686. * <code>Parse.Object</code> to restrict access to only a subset of users
  3687. * of your application.</p>
  3688. *
  3689. * @alias Parse.ACL
  3690. */
  3691. class ParseACL {
  3692. /**
  3693. * @param {(Parse.User | object)} arg1 The user to initialize the ACL for
  3694. */
  3695. constructor(arg1) {
  3696. (0, _defineProperty2.default)(this, "permissionsById", void 0);
  3697. this.permissionsById = {};
  3698. if (arg1 && typeof arg1 === 'object') {
  3699. const ParseUser = _CoreManager.default.getParseUser();
  3700. if (arg1 instanceof ParseUser) {
  3701. this.setReadAccess(arg1, true);
  3702. this.setWriteAccess(arg1, true);
  3703. } else {
  3704. for (const userId in arg1) {
  3705. const accessList = arg1[userId];
  3706. this.permissionsById[userId] = {};
  3707. for (const permission in accessList) {
  3708. const allowed = accessList[permission];
  3709. if (permission !== 'read' && permission !== 'write') {
  3710. throw new TypeError('Tried to create an ACL with an invalid permission type.');
  3711. }
  3712. if (typeof allowed !== 'boolean') {
  3713. throw new TypeError('Tried to create an ACL with an invalid permission value.');
  3714. }
  3715. this.permissionsById[userId][permission] = allowed;
  3716. }
  3717. }
  3718. }
  3719. } else if (typeof arg1 === 'function') {
  3720. throw new TypeError('ParseACL constructed with a function. Did you forget ()?');
  3721. }
  3722. }
  3723. /**
  3724. * Returns a JSON-encoded version of the ACL.
  3725. *
  3726. * @returns {object}
  3727. */
  3728. toJSON() {
  3729. const permissions = {};
  3730. for (const p in this.permissionsById) {
  3731. permissions[p] = this.permissionsById[p];
  3732. }
  3733. return permissions;
  3734. }
  3735. /**
  3736. * Returns whether this ACL is equal to another object
  3737. *
  3738. * @param {ParseACL} other The other object's ACL to compare to
  3739. * @returns {boolean}
  3740. */
  3741. equals(other) {
  3742. if (!(other instanceof ParseACL)) {
  3743. return false;
  3744. }
  3745. const users = (0, _keys.default)(this.permissionsById);
  3746. const otherUsers = (0, _keys.default)(other.permissionsById);
  3747. if (users.length !== otherUsers.length) {
  3748. return false;
  3749. }
  3750. for (const u in this.permissionsById) {
  3751. if (!other.permissionsById[u]) {
  3752. return false;
  3753. }
  3754. if (this.permissionsById[u].read !== other.permissionsById[u].read) {
  3755. return false;
  3756. }
  3757. if (this.permissionsById[u].write !== other.permissionsById[u].write) {
  3758. return false;
  3759. }
  3760. }
  3761. return true;
  3762. }
  3763. _setAccess(accessType, userId, allowed) {
  3764. const ParseRole = _CoreManager.default.getParseRole();
  3765. const ParseUser = _CoreManager.default.getParseUser();
  3766. if (userId instanceof ParseUser) {
  3767. userId = userId.id;
  3768. } else if (userId instanceof ParseRole) {
  3769. const name = userId.getName();
  3770. if (!name) {
  3771. throw new TypeError('Role must have a name');
  3772. }
  3773. userId = 'role:' + name;
  3774. }
  3775. if (typeof userId !== 'string') {
  3776. throw new TypeError('userId must be a string.');
  3777. }
  3778. if (typeof allowed !== 'boolean') {
  3779. throw new TypeError('allowed must be either true or false.');
  3780. }
  3781. let permissions = this.permissionsById[userId];
  3782. if (!permissions) {
  3783. if (!allowed) {
  3784. // The user already doesn't have this permission, so no action is needed
  3785. return;
  3786. } else {
  3787. permissions = {};
  3788. this.permissionsById[userId] = permissions;
  3789. }
  3790. }
  3791. if (allowed) {
  3792. this.permissionsById[userId][accessType] = true;
  3793. } else {
  3794. delete permissions[accessType];
  3795. if ((0, _keys.default)(permissions).length === 0) {
  3796. delete this.permissionsById[userId];
  3797. }
  3798. }
  3799. }
  3800. _getAccess(accessType, userId) {
  3801. const ParseRole = _CoreManager.default.getParseRole();
  3802. const ParseUser = _CoreManager.default.getParseUser();
  3803. if (userId instanceof ParseUser) {
  3804. userId = userId.id;
  3805. if (!userId) {
  3806. throw new Error('Cannot get access for a ParseUser without an ID');
  3807. }
  3808. } else if (userId instanceof ParseRole) {
  3809. const name = userId.getName();
  3810. if (!name) {
  3811. throw new TypeError('Role must have a name');
  3812. }
  3813. userId = 'role:' + name;
  3814. }
  3815. const permissions = this.permissionsById[userId];
  3816. if (!permissions) {
  3817. return false;
  3818. }
  3819. return !!permissions[accessType];
  3820. }
  3821. /**
  3822. * Sets whether the given user is allowed to read this object.
  3823. *
  3824. * @param userId An instance of Parse.User or its objectId.
  3825. * @param {boolean} allowed Whether that user should have read access.
  3826. */
  3827. setReadAccess(userId, allowed) {
  3828. this._setAccess('read', userId, allowed);
  3829. }
  3830. /**
  3831. * Get whether the given user id is *explicitly* allowed to read this object.
  3832. * Even if this returns false, the user may still be able to access it if
  3833. * getPublicReadAccess returns true or a role that the user belongs to has
  3834. * write access.
  3835. *
  3836. * @param userId An instance of Parse.User or its objectId, or a Parse.Role.
  3837. * @returns {boolean}
  3838. */
  3839. getReadAccess(userId) {
  3840. return this._getAccess('read', userId);
  3841. }
  3842. /**
  3843. * Sets whether the given user id is allowed to write this object.
  3844. *
  3845. * @param userId An instance of Parse.User or its objectId, or a Parse.Role..
  3846. * @param {boolean} allowed Whether that user should have write access.
  3847. */
  3848. setWriteAccess(userId, allowed) {
  3849. this._setAccess('write', userId, allowed);
  3850. }
  3851. /**
  3852. * Gets whether the given user id is *explicitly* allowed to write this object.
  3853. * Even if this returns false, the user may still be able to write it if
  3854. * getPublicWriteAccess returns true or a role that the user belongs to has
  3855. * write access.
  3856. *
  3857. * @param userId An instance of Parse.User or its objectId, or a Parse.Role.
  3858. * @returns {boolean}
  3859. */
  3860. getWriteAccess(userId) {
  3861. return this._getAccess('write', userId);
  3862. }
  3863. /**
  3864. * Sets whether the public is allowed to read this object.
  3865. *
  3866. * @param {boolean} allowed
  3867. */
  3868. setPublicReadAccess(allowed) {
  3869. this.setReadAccess(PUBLIC_KEY, allowed);
  3870. }
  3871. /**
  3872. * Gets whether the public is allowed to read this object.
  3873. *
  3874. * @returns {boolean}
  3875. */
  3876. getPublicReadAccess() {
  3877. return this.getReadAccess(PUBLIC_KEY);
  3878. }
  3879. /**
  3880. * Sets whether the public is allowed to write this object.
  3881. *
  3882. * @param {boolean} allowed
  3883. */
  3884. setPublicWriteAccess(allowed) {
  3885. this.setWriteAccess(PUBLIC_KEY, allowed);
  3886. }
  3887. /**
  3888. * Gets whether the public is allowed to write this object.
  3889. *
  3890. * @returns {boolean}
  3891. */
  3892. getPublicWriteAccess() {
  3893. return this.getWriteAccess(PUBLIC_KEY);
  3894. }
  3895. /**
  3896. * Gets whether users belonging to the given role are allowed
  3897. * to read this object. Even if this returns false, the role may
  3898. * still be able to write it if a parent role has read access.
  3899. *
  3900. * @param role The name of the role, or a Parse.Role object.
  3901. * @returns {boolean} true if the role has read access. false otherwise.
  3902. * @throws {TypeError} If role is neither a Parse.Role nor a String.
  3903. */
  3904. getRoleReadAccess(role) {
  3905. const ParseRole = _CoreManager.default.getParseRole();
  3906. if (role instanceof ParseRole) {
  3907. // Normalize to the String name
  3908. role = role.getName();
  3909. }
  3910. if (typeof role !== 'string') {
  3911. throw new TypeError('role must be a ParseRole or a String');
  3912. }
  3913. return this.getReadAccess('role:' + role);
  3914. }
  3915. /**
  3916. * Gets whether users belonging to the given role are allowed
  3917. * to write this object. Even if this returns false, the role may
  3918. * still be able to write it if a parent role has write access.
  3919. *
  3920. * @param role The name of the role, or a Parse.Role object.
  3921. * @returns {boolean} true if the role has write access. false otherwise.
  3922. * @throws {TypeError} If role is neither a Parse.Role nor a String.
  3923. */
  3924. getRoleWriteAccess(role) {
  3925. const ParseRole = _CoreManager.default.getParseRole();
  3926. if (role instanceof ParseRole) {
  3927. // Normalize to the String name
  3928. role = role.getName();
  3929. }
  3930. if (typeof role !== 'string') {
  3931. throw new TypeError('role must be a ParseRole or a String');
  3932. }
  3933. return this.getWriteAccess('role:' + role);
  3934. }
  3935. /**
  3936. * Sets whether users belonging to the given role are allowed
  3937. * to read this object.
  3938. *
  3939. * @param role The name of the role, or a Parse.Role object.
  3940. * @param {boolean} allowed Whether the given role can read this object.
  3941. * @throws {TypeError} If role is neither a Parse.Role nor a String.
  3942. */
  3943. setRoleReadAccess(role, allowed) {
  3944. const ParseRole = _CoreManager.default.getParseRole();
  3945. if (role instanceof ParseRole) {
  3946. // Normalize to the String name
  3947. role = role.getName();
  3948. }
  3949. if (typeof role !== 'string') {
  3950. throw new TypeError('role must be a ParseRole or a String');
  3951. }
  3952. this.setReadAccess('role:' + role, allowed);
  3953. }
  3954. /**
  3955. * Sets whether users belonging to the given role are allowed
  3956. * to write this object.
  3957. *
  3958. * @param role The name of the role, or a Parse.Role object.
  3959. * @param {boolean} allowed Whether the given role can write this object.
  3960. * @throws {TypeError} If role is neither a Parse.Role nor a String.
  3961. */
  3962. setRoleWriteAccess(role, allowed) {
  3963. const ParseRole = _CoreManager.default.getParseRole();
  3964. if (role instanceof ParseRole) {
  3965. // Normalize to the String name
  3966. role = role.getName();
  3967. }
  3968. if (typeof role !== 'string') {
  3969. throw new TypeError('role must be a ParseRole or a String');
  3970. }
  3971. this.setWriteAccess('role:' + role, allowed);
  3972. }
  3973. }
  3974. var _default = exports.default = ParseACL;
  3975. },{"./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){
  3976. "use strict";
  3977. var _Object$defineProperty = _dereq_("@babel/runtime-corejs3/core-js-stable/object/define-property");
  3978. var _interopRequireDefault = _dereq_("@babel/runtime-corejs3/helpers/interopRequireDefault");
  3979. _Object$defineProperty(exports, "__esModule", {
  3980. value: true
  3981. });
  3982. exports.default = void 0;
  3983. var _defineProperty2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/helpers/defineProperty"));
  3984. var _map = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/map"));
  3985. var _entries = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/instance/entries"));
  3986. var _assign = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/object/assign"));
  3987. var _slice = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/instance/slice"));
  3988. var _includes = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/instance/includes"));
  3989. var _every = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/instance/every"));
  3990. var _keys = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/object/keys"));
  3991. var _isArray = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/array/is-array"));
  3992. var _ParseRole = _interopRequireDefault(_dereq_("./ParseRole"));
  3993. var _ParseUser = _interopRequireDefault(_dereq_("./ParseUser"));
  3994. const PUBLIC_KEY = '*';
  3995. const VALID_PERMISSIONS = new _map.default();
  3996. VALID_PERMISSIONS.set('get', {});
  3997. VALID_PERMISSIONS.set('find', {});
  3998. VALID_PERMISSIONS.set('count', {});
  3999. VALID_PERMISSIONS.set('create', {});
  4000. VALID_PERMISSIONS.set('update', {});
  4001. VALID_PERMISSIONS.set('delete', {});
  4002. VALID_PERMISSIONS.set('addField', {});
  4003. const VALID_PERMISSIONS_EXTENDED = new _map.default();
  4004. VALID_PERMISSIONS_EXTENDED.set('protectedFields', {});
  4005. /**
  4006. * Creates a new CLP.
  4007. * If no argument is given, the CLP has no permissions for anyone.
  4008. * If the argument is a Parse.User or Parse.Role, the CLP will have read and write
  4009. * permission for only that user or role.
  4010. * If the argument is any other JSON object, that object will be interpretted
  4011. * as a serialized CLP created with toJSON().
  4012. *
  4013. * <p>A CLP, or Class Level Permissions can be added to any
  4014. * <code>Parse.Schema</code> to restrict access to only a subset of users
  4015. * of your application.</p>
  4016. *
  4017. * <p>
  4018. * For get/count/find/create/update/delete/addField using the following functions:
  4019. *
  4020. * Entity is type Parse.User or Parse.Role or string
  4021. * Role is type Parse.Role or Name of Parse.Role
  4022. *
  4023. * getGetRequiresAuthentication()
  4024. * setGetRequiresAuthentication(allowed: boolean)
  4025. * getGetPointerFields()
  4026. * setGetPointerFields(pointerFields: string[])
  4027. * getGetAccess(entity: Entity)
  4028. * setGetAccess(entity: Entity, allowed: boolean)
  4029. * getPublicGetAccess()
  4030. * setPublicGetAccess(allowed: boolean)
  4031. * getRoleGetAccess(role: Role)
  4032. * setRoleGetAccess(role: Role, allowed: boolean)
  4033. * getFindRequiresAuthentication()
  4034. * setFindRequiresAuthentication(allowed: boolean)
  4035. * getFindPointerFields()
  4036. * setFindPointerFields(pointerFields: string[])
  4037. * getFindAccess(entity: Entity)
  4038. * setFindAccess(entity: Entity, allowed: boolean)
  4039. * getPublicFindAccess()
  4040. * setPublicFindAccess(allowed: boolean)
  4041. * getRoleFindAccess(role: Role)
  4042. * setRoleFindAccess(role: Role, allowed: boolean)
  4043. * getCountRequiresAuthentication()
  4044. * setCountRequiresAuthentication(allowed: boolean)
  4045. * getCountPointerFields()
  4046. * setCountPointerFields(pointerFields: string[])
  4047. * getCountAccess(entity: Entity)
  4048. * setCountAccess(entity: Entity, allowed: boolean)
  4049. * getPublicCountAccess()
  4050. * setPublicCountAccess(allowed: boolean)
  4051. * getRoleCountAccess(role: Role)
  4052. * setRoleCountAccess(role: Role, allowed: boolean)
  4053. * getCreateRequiresAuthentication()
  4054. * setCreateRequiresAuthentication(allowed: boolean)
  4055. * getCreatePointerFields()
  4056. * setCreatePointerFields(pointerFields: string[])
  4057. * getCreateAccess(entity: Entity)
  4058. * setCreateAccess(entity: Entity, allowed: boolean)
  4059. * getPublicCreateAccess()
  4060. * setPublicCreateAccess(allowed: Boolean)
  4061. * getRoleCreateAccess(role: Role)
  4062. * setRoleCreateAccess(role: Role, allowed: boolean)
  4063. * getUpdateRequiresAuthentication()
  4064. * setUpdateRequiresAuthentication(allowed: boolean)
  4065. * getUpdatePointerFields()
  4066. * setUpdatePointerFields(pointerFields: string[])
  4067. * getUpdateAccess(entity: Entity)
  4068. * setUpdateAccess(entity: Entity, allowed: boolean)
  4069. * getPublicUpdateAccess()
  4070. * setPublicUpdateAccess(allowed: boolean)
  4071. * getRoleUpdateAccess(role: Role)
  4072. * setRoleUpdateAccess(role: Role, allowed: boolean)
  4073. * getDeleteRequiresAuthentication()
  4074. * setDeleteRequiresAuthentication(allowed: boolean)
  4075. * getDeletePointerFields()
  4076. * setDeletePointerFields(pointerFields: string[])
  4077. * getDeleteAccess(entity: Entity)
  4078. * setDeleteAccess(entity: Entity, allowed: boolean)
  4079. * getPublicDeleteAccess()
  4080. * setPublicDeleteAccess(allowed: boolean)
  4081. * getRoleDeleteAccess(role: Role)
  4082. * setRoleDeleteAccess(role: Role, allowed: boolean)
  4083. * getAddFieldRequiresAuthentication()
  4084. * setAddFieldRequiresAuthentication(allowed: boolean)
  4085. * getAddFieldPointerFields()
  4086. * setAddFieldPointerFields(pointerFields: string[])
  4087. * getAddFieldAccess(entity: Entity)
  4088. * setAddFieldAccess(entity: Entity, allowed: boolean)
  4089. * getPublicAddFieldAccess()
  4090. * setPublicAddFieldAccess(allowed: boolean)
  4091. * getRoleAddFieldAccess(role: Role)
  4092. * setRoleAddFieldAccess(role: Role, allowed: boolean)
  4093. * </p>
  4094. *
  4095. * @alias Parse.CLP
  4096. */
  4097. class ParseCLP {
  4098. /**
  4099. * @param {(Parse.User | Parse.Role | object)} userId The user to initialize the CLP for
  4100. */
  4101. constructor(userId) {
  4102. (0, _defineProperty2.default)(this, "permissionsMap", void 0);
  4103. this.permissionsMap = {};
  4104. // Initialize permissions Map with default permissions
  4105. for (const [operation, group] of (0, _entries.default)(VALID_PERMISSIONS).call(VALID_PERMISSIONS)) {
  4106. this.permissionsMap[operation] = (0, _assign.default)({}, group);
  4107. const action = operation.charAt(0).toUpperCase() + (0, _slice.default)(operation).call(operation, 1);
  4108. this[`get${action}RequiresAuthentication`] = function () {
  4109. return this._getAccess(operation, 'requiresAuthentication');
  4110. };
  4111. this[`set${action}RequiresAuthentication`] = function (allowed) {
  4112. this._setAccess(operation, 'requiresAuthentication', allowed);
  4113. };
  4114. this[`get${action}PointerFields`] = function () {
  4115. return this._getAccess(operation, 'pointerFields', false);
  4116. };
  4117. this[`set${action}PointerFields`] = function (pointerFields) {
  4118. this._setArrayAccess(operation, 'pointerFields', pointerFields);
  4119. };
  4120. this[`get${action}Access`] = function (entity) {
  4121. return this._getAccess(operation, entity);
  4122. };
  4123. this[`set${action}Access`] = function (entity, allowed) {
  4124. this._setAccess(operation, entity, allowed);
  4125. };
  4126. this[`getPublic${action}Access`] = function () {
  4127. return this[`get${action}Access`](PUBLIC_KEY);
  4128. };
  4129. this[`setPublic${action}Access`] = function (allowed) {
  4130. this[`set${action}Access`](PUBLIC_KEY, allowed);
  4131. };
  4132. this[`getRole${action}Access`] = function (role) {
  4133. return this[`get${action}Access`](this._getRoleName(role));
  4134. };
  4135. this[`setRole${action}Access`] = function (role, allowed) {
  4136. this[`set${action}Access`](this._getRoleName(role), allowed);
  4137. };
  4138. }
  4139. // Initialize permissions Map with default extended permissions
  4140. for (const [operation, group] of (0, _entries.default)(VALID_PERMISSIONS_EXTENDED).call(VALID_PERMISSIONS_EXTENDED)) {
  4141. this.permissionsMap[operation] = (0, _assign.default)({}, group);
  4142. }
  4143. if (userId && typeof userId === 'object') {
  4144. if (userId instanceof _ParseUser.default) {
  4145. this.setReadAccess(userId, true);
  4146. this.setWriteAccess(userId, true);
  4147. } else if (userId instanceof _ParseRole.default) {
  4148. this.setRoleReadAccess(userId, true);
  4149. this.setRoleWriteAccess(userId, true);
  4150. } else {
  4151. for (const permission in userId) {
  4152. var _context;
  4153. const users = userId[permission];
  4154. const isValidPermission = !!VALID_PERMISSIONS.get(permission);
  4155. const isValidPermissionExtended = !!VALID_PERMISSIONS_EXTENDED.get(permission);
  4156. const isValidGroupPermission = (0, _includes.default)(_context = ['readUserFields', 'writeUserFields']).call(_context, permission);
  4157. if (typeof permission !== 'string' || !(isValidPermission || isValidPermissionExtended || isValidGroupPermission)) {
  4158. throw new TypeError('Tried to create an CLP with an invalid permission type.');
  4159. }
  4160. if (isValidGroupPermission) {
  4161. if ((0, _every.default)(users).call(users, pointer => typeof pointer === 'string')) {
  4162. this.permissionsMap[permission] = users;
  4163. continue;
  4164. } else {
  4165. throw new TypeError('Tried to create an CLP with an invalid permission value.');
  4166. }
  4167. }
  4168. for (const user in users) {
  4169. const allowed = users[user];
  4170. if (typeof allowed !== 'boolean' && !isValidPermissionExtended && user !== 'pointerFields') {
  4171. throw new TypeError('Tried to create an CLP with an invalid permission value.');
  4172. }
  4173. this.permissionsMap[permission][user] = allowed;
  4174. }
  4175. }
  4176. }
  4177. } else if (typeof userId === 'function') {
  4178. throw new TypeError('ParseCLP constructed with a function. Did you forget ()?');
  4179. }
  4180. }
  4181. /**
  4182. * Returns a JSON-encoded version of the CLP.
  4183. *
  4184. * @returns {object}
  4185. */
  4186. toJSON() {
  4187. return {
  4188. ...this.permissionsMap
  4189. };
  4190. }
  4191. /**
  4192. * Returns whether this CLP is equal to another object
  4193. *
  4194. * @param other The other object to compare to
  4195. * @returns {boolean}
  4196. */
  4197. equals(other) {
  4198. if (!(other instanceof ParseCLP)) {
  4199. return false;
  4200. }
  4201. const permissions = (0, _keys.default)(this.permissionsMap);
  4202. const otherPermissions = (0, _keys.default)(other.permissionsMap);
  4203. if (permissions.length !== otherPermissions.length) {
  4204. return false;
  4205. }
  4206. for (const permission in this.permissionsMap) {
  4207. if (!other.permissionsMap[permission]) {
  4208. return false;
  4209. }
  4210. const users = (0, _keys.default)(this.permissionsMap[permission]);
  4211. const otherUsers = (0, _keys.default)(other.permissionsMap[permission]);
  4212. if (users.length !== otherUsers.length) {
  4213. return false;
  4214. }
  4215. for (const user in this.permissionsMap[permission]) {
  4216. if (!other.permissionsMap[permission][user]) {
  4217. return false;
  4218. }
  4219. if (this.permissionsMap[permission][user] !== other.permissionsMap[permission][user]) {
  4220. return false;
  4221. }
  4222. }
  4223. }
  4224. return true;
  4225. }
  4226. _getRoleName(role) {
  4227. let name = role;
  4228. if (role instanceof _ParseRole.default) {
  4229. // Normalize to the String name
  4230. name = role.getName();
  4231. }
  4232. if (typeof name !== 'string') {
  4233. throw new TypeError('role must be a Parse.Role or a String');
  4234. }
  4235. return `role:${name}`;
  4236. }
  4237. _parseEntity(entity) {
  4238. let userId = entity;
  4239. if (userId instanceof _ParseUser.default) {
  4240. userId = userId.id;
  4241. if (!userId) {
  4242. throw new Error('Cannot get access for a Parse.User without an id.');
  4243. }
  4244. } else if (userId instanceof _ParseRole.default) {
  4245. userId = this._getRoleName(userId);
  4246. }
  4247. if (typeof userId !== 'string') {
  4248. throw new TypeError('userId must be a string.');
  4249. }
  4250. return userId;
  4251. }
  4252. _setAccess(permission, userId, allowed) {
  4253. userId = this._parseEntity(userId);
  4254. if (typeof allowed !== 'boolean') {
  4255. throw new TypeError('allowed must be either true or false.');
  4256. }
  4257. const permissions = this.permissionsMap[permission][userId];
  4258. if (!permissions) {
  4259. if (!allowed) {
  4260. // The user already doesn't have this permission, so no action is needed
  4261. return;
  4262. } else {
  4263. this.permissionsMap[permission][userId] = {};
  4264. }
  4265. }
  4266. if (allowed) {
  4267. this.permissionsMap[permission][userId] = true;
  4268. } else {
  4269. delete this.permissionsMap[permission][userId];
  4270. }
  4271. }
  4272. _getAccess(permission, userId) {
  4273. let returnBoolean = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : true;
  4274. userId = this._parseEntity(userId);
  4275. const permissions = this.permissionsMap[permission][userId];
  4276. if (returnBoolean) {
  4277. if (!permissions) {
  4278. return false;
  4279. }
  4280. return !!this.permissionsMap[permission][userId];
  4281. }
  4282. return permissions;
  4283. }
  4284. _setArrayAccess(permission, userId, fields) {
  4285. userId = this._parseEntity(userId);
  4286. const permissions = this.permissionsMap[permission][userId];
  4287. if (!permissions) {
  4288. this.permissionsMap[permission][userId] = [];
  4289. }
  4290. if (!fields || (0, _isArray.default)(fields) && fields.length === 0) {
  4291. delete this.permissionsMap[permission][userId];
  4292. } else if ((0, _isArray.default)(fields) && (0, _every.default)(fields).call(fields, field => typeof field === 'string')) {
  4293. this.permissionsMap[permission][userId] = fields;
  4294. } else {
  4295. throw new TypeError('fields must be an array of strings or undefined.');
  4296. }
  4297. }
  4298. _setGroupPointerPermission(operation, pointerFields) {
  4299. const fields = this.permissionsMap[operation];
  4300. if (!fields) {
  4301. this.permissionsMap[operation] = [];
  4302. }
  4303. if (!pointerFields || (0, _isArray.default)(pointerFields) && pointerFields.length === 0) {
  4304. delete this.permissionsMap[operation];
  4305. } else if ((0, _isArray.default)(pointerFields) && (0, _every.default)(pointerFields).call(pointerFields, field => typeof field === 'string')) {
  4306. this.permissionsMap[operation] = pointerFields;
  4307. } else {
  4308. throw new TypeError(`${operation}.pointerFields must be an array of strings or undefined.`);
  4309. }
  4310. }
  4311. _getGroupPointerPermissions(operation) {
  4312. return this.permissionsMap[operation] || [];
  4313. }
  4314. /**
  4315. * Sets user pointer fields to allow permission for get/count/find operations.
  4316. *
  4317. * @param {string[]} pointerFields User pointer fields
  4318. */
  4319. setReadUserFields(pointerFields) {
  4320. this._setGroupPointerPermission('readUserFields', pointerFields);
  4321. }
  4322. /**
  4323. * @returns {string[]} User pointer fields
  4324. */
  4325. getReadUserFields() {
  4326. return this._getGroupPointerPermissions('readUserFields') || [];
  4327. }
  4328. /**
  4329. * Sets user pointer fields to allow permission for create/delete/update/addField operations
  4330. *
  4331. * @param {string[]} pointerFields User pointer fields
  4332. */
  4333. setWriteUserFields(pointerFields) {
  4334. this._setGroupPointerPermission('writeUserFields', pointerFields);
  4335. }
  4336. /**
  4337. * @returns {string[]} User pointer fields
  4338. */
  4339. getWriteUserFields() {
  4340. return this._getGroupPointerPermissions('writeUserFields') || [];
  4341. }
  4342. /**
  4343. * Sets whether the given user is allowed to retrieve fields from this class.
  4344. *
  4345. * @param userId An instance of Parse.User or its objectId.
  4346. * @param {string[]} fields fields to be protected
  4347. */
  4348. setProtectedFields(userId, fields) {
  4349. this._setArrayAccess('protectedFields', userId, fields);
  4350. }
  4351. /**
  4352. * Returns array of fields are accessable to this user.
  4353. *
  4354. * @param userId An instance of Parse.User or its objectId, or a Parse.Role.
  4355. * @returns {string[]}
  4356. */
  4357. getProtectedFields(userId) {
  4358. return this._getAccess('protectedFields', userId, false);
  4359. }
  4360. /**
  4361. * Sets whether the given user is allowed to read from this class.
  4362. *
  4363. * @param userId An instance of Parse.User or its objectId.
  4364. * @param {boolean} allowed whether that user should have read access.
  4365. */
  4366. setReadAccess(userId, allowed) {
  4367. this._setAccess('find', userId, allowed);
  4368. this._setAccess('get', userId, allowed);
  4369. this._setAccess('count', userId, allowed);
  4370. }
  4371. /**
  4372. * Get whether the given user id is *explicitly* allowed to read from this class.
  4373. * Even if this returns false, the user may still be able to access it if
  4374. * getPublicReadAccess returns true or a role that the user belongs to has
  4375. * write access.
  4376. *
  4377. * @param userId An instance of Parse.User or its objectId, or a Parse.Role.
  4378. * @returns {boolean}
  4379. */
  4380. getReadAccess(userId) {
  4381. return this._getAccess('find', userId) && this._getAccess('get', userId) && this._getAccess('count', userId);
  4382. }
  4383. /**
  4384. * Sets whether the given user id is allowed to write to this class.
  4385. *
  4386. * @param userId An instance of Parse.User or its objectId, or a Parse.Role..
  4387. * @param {boolean} allowed Whether that user should have write access.
  4388. */
  4389. setWriteAccess(userId, allowed) {
  4390. this._setAccess('create', userId, allowed);
  4391. this._setAccess('update', userId, allowed);
  4392. this._setAccess('delete', userId, allowed);
  4393. this._setAccess('addField', userId, allowed);
  4394. }
  4395. /**
  4396. * Gets whether the given user id is *explicitly* allowed to write to this class.
  4397. * Even if this returns false, the user may still be able to write it if
  4398. * getPublicWriteAccess returns true or a role that the user belongs to has
  4399. * write access.
  4400. *
  4401. * @param userId An instance of Parse.User or its objectId, or a Parse.Role.
  4402. * @returns {boolean}
  4403. */
  4404. getWriteAccess(userId) {
  4405. return this._getAccess('create', userId) && this._getAccess('update', userId) && this._getAccess('delete', userId) && this._getAccess('addField', userId);
  4406. }
  4407. /**
  4408. * Sets whether the public is allowed to read from this class.
  4409. *
  4410. * @param {boolean} allowed
  4411. */
  4412. setPublicReadAccess(allowed) {
  4413. this.setReadAccess(PUBLIC_KEY, allowed);
  4414. }
  4415. /**
  4416. * Gets whether the public is allowed to read from this class.
  4417. *
  4418. * @returns {boolean}
  4419. */
  4420. getPublicReadAccess() {
  4421. return this.getReadAccess(PUBLIC_KEY);
  4422. }
  4423. /**
  4424. * Sets whether the public is allowed to write to this class.
  4425. *
  4426. * @param {boolean} allowed
  4427. */
  4428. setPublicWriteAccess(allowed) {
  4429. this.setWriteAccess(PUBLIC_KEY, allowed);
  4430. }
  4431. /**
  4432. * Gets whether the public is allowed to write to this class.
  4433. *
  4434. * @returns {boolean}
  4435. */
  4436. getPublicWriteAccess() {
  4437. return this.getWriteAccess(PUBLIC_KEY);
  4438. }
  4439. /**
  4440. * Sets whether the public is allowed to protect fields in this class.
  4441. *
  4442. * @param {string[]} fields
  4443. */
  4444. setPublicProtectedFields(fields) {
  4445. this.setProtectedFields(PUBLIC_KEY, fields);
  4446. }
  4447. /**
  4448. * Gets whether the public is allowed to read fields from this class.
  4449. *
  4450. * @returns {string[]}
  4451. */
  4452. getPublicProtectedFields() {
  4453. return this.getProtectedFields(PUBLIC_KEY);
  4454. }
  4455. /**
  4456. * Gets whether users belonging to the given role are allowed
  4457. * to read from this class. Even if this returns false, the role may
  4458. * still be able to write it if a parent role has read access.
  4459. *
  4460. * @param role The name of the role, or a Parse.Role object.
  4461. * @returns {boolean} true if the role has read access. false otherwise.
  4462. * @throws {TypeError} If role is neither a Parse.Role nor a String.
  4463. */
  4464. getRoleReadAccess(role) {
  4465. return this.getReadAccess(this._getRoleName(role));
  4466. }
  4467. /**
  4468. * Gets whether users belonging to the given role are allowed
  4469. * to write to this user. Even if this returns false, the role may
  4470. * still be able to write it if a parent role has write access.
  4471. *
  4472. * @param role The name of the role, or a Parse.Role object.
  4473. * @returns {boolean} true if the role has write access. false otherwise.
  4474. * @throws {TypeError} If role is neither a Parse.Role nor a String.
  4475. */
  4476. getRoleWriteAccess(role) {
  4477. return this.getWriteAccess(this._getRoleName(role));
  4478. }
  4479. /**
  4480. * Sets whether users belonging to the given role are allowed
  4481. * to read from this class.
  4482. *
  4483. * @param role The name of the role, or a Parse.Role object.
  4484. * @param {boolean} allowed Whether the given role can read this object.
  4485. * @throws {TypeError} If role is neither a Parse.Role nor a String.
  4486. */
  4487. setRoleReadAccess(role, allowed) {
  4488. this.setReadAccess(this._getRoleName(role), allowed);
  4489. }
  4490. /**
  4491. * Sets whether users belonging to the given role are allowed
  4492. * to write to this class.
  4493. *
  4494. * @param role The name of the role, or a Parse.Role object.
  4495. * @param {boolean} allowed Whether the given role can write this object.
  4496. * @throws {TypeError} If role is neither a Parse.Role nor a String.
  4497. */
  4498. setRoleWriteAccess(role, allowed) {
  4499. this.setWriteAccess(this._getRoleName(role), allowed);
  4500. }
  4501. /**
  4502. * Gets whether users belonging to the given role are allowed
  4503. * to count to this user. Even if this returns false, the role may
  4504. * still be able to count it if a parent role has count access.
  4505. *
  4506. * @param role The name of the role, or a Parse.Role object.
  4507. * @returns {string[]}
  4508. * @throws {TypeError} If role is neither a Parse.Role nor a String.
  4509. */
  4510. getRoleProtectedFields(role) {
  4511. return this.getProtectedFields(this._getRoleName(role));
  4512. }
  4513. /**
  4514. * Sets whether users belonging to the given role are allowed
  4515. * to set access field in this class.
  4516. *
  4517. * @param role The name of the role, or a Parse.Role object.
  4518. * @param {string[]} fields Fields to be protected by Role.
  4519. * @throws {TypeError} If role is neither a Parse.Role nor a String.
  4520. */
  4521. setRoleProtectedFields(role, fields) {
  4522. this.setProtectedFields(this._getRoleName(role), fields);
  4523. }
  4524. }
  4525. var _default = exports.default = ParseCLP;
  4526. },{"./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){
  4527. "use strict";
  4528. var _Object$defineProperty = _dereq_("@babel/runtime-corejs3/core-js-stable/object/define-property");
  4529. var _interopRequireDefault = _dereq_("@babel/runtime-corejs3/helpers/interopRequireDefault");
  4530. _Object$defineProperty(exports, "__esModule", {
  4531. value: true
  4532. });
  4533. exports.default = void 0;
  4534. var _promise = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/promise"));
  4535. var _stringify = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/json/stringify"));
  4536. var _defineProperty2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/helpers/defineProperty"));
  4537. var _CoreManager = _interopRequireDefault(_dereq_("./CoreManager"));
  4538. var _decode = _interopRequireDefault(_dereq_("./decode"));
  4539. var _encode = _interopRequireDefault(_dereq_("./encode"));
  4540. var _escape = _interopRequireDefault(_dereq_("./escape"));
  4541. var _ParseError = _interopRequireDefault(_dereq_("./ParseError"));
  4542. var _Storage = _interopRequireDefault(_dereq_("./Storage"));
  4543. /**
  4544. * Parse.Config is a local representation of configuration data that
  4545. * can be set from the Parse dashboard.
  4546. *
  4547. * @alias Parse.Config
  4548. */
  4549. class ParseConfig {
  4550. constructor() {
  4551. (0, _defineProperty2.default)(this, "attributes", void 0);
  4552. (0, _defineProperty2.default)(this, "_escapedAttributes", void 0);
  4553. this.attributes = {};
  4554. this._escapedAttributes = {};
  4555. }
  4556. /**
  4557. * Gets the value of an attribute.
  4558. *
  4559. * @param {string} attr The name of an attribute.
  4560. * @returns {*}
  4561. */
  4562. get(attr) {
  4563. return this.attributes[attr];
  4564. }
  4565. /**
  4566. * Gets the HTML-escaped value of an attribute.
  4567. *
  4568. * @param {string} attr The name of an attribute.
  4569. * @returns {string}
  4570. */
  4571. escape(attr) {
  4572. const html = this._escapedAttributes[attr];
  4573. if (html) {
  4574. return html;
  4575. }
  4576. const val = this.attributes[attr];
  4577. let escaped = '';
  4578. if (val != null) {
  4579. escaped = (0, _escape.default)(val.toString());
  4580. }
  4581. this._escapedAttributes[attr] = escaped;
  4582. return escaped;
  4583. }
  4584. /**
  4585. * Retrieves the most recently-fetched configuration object, either from
  4586. * memory or from local storage if necessary.
  4587. *
  4588. * @static
  4589. * @returns {Parse.Config} The most recently-fetched Parse.Config if it
  4590. * exists, else an empty Parse.Config.
  4591. */
  4592. static current() {
  4593. const controller = _CoreManager.default.getConfigController();
  4594. return controller.current();
  4595. }
  4596. /**
  4597. * Gets a new configuration object from the server.
  4598. *
  4599. * @static
  4600. * @param {object} options
  4601. * Valid options are:<ul>
  4602. * <li>useMasterKey: In Cloud Code and Node only, causes the Master Key to
  4603. * be used for this request.
  4604. * </ul>
  4605. * @returns {Promise} A promise that is resolved with a newly-created
  4606. * configuration object when the get completes.
  4607. */
  4608. static get() {
  4609. let options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
  4610. const controller = _CoreManager.default.getConfigController();
  4611. return controller.get(options);
  4612. }
  4613. /**
  4614. * Save value keys to the server.
  4615. *
  4616. * @static
  4617. * @param {object} attrs The config parameters and values.
  4618. * @param {object} masterKeyOnlyFlags The flags that define whether config parameters listed
  4619. * in `attrs` should be retrievable only by using the master key.
  4620. * For example: `param1: true` makes `param1` only retrievable by using the master key.
  4621. * If a parameter is not provided or set to `false`, it can be retrieved without
  4622. * using the master key.
  4623. * @returns {Promise} A promise that is resolved with a newly-created
  4624. * configuration object or with the current with the update.
  4625. */
  4626. static save(attrs, masterKeyOnlyFlags) {
  4627. const controller = _CoreManager.default.getConfigController();
  4628. //To avoid a mismatch with the local and the cloud config we get a new version
  4629. return controller.save(attrs, masterKeyOnlyFlags).then(() => {
  4630. return controller.get({
  4631. useMasterKey: true
  4632. });
  4633. }, error => {
  4634. return _promise.default.reject(error);
  4635. });
  4636. }
  4637. /**
  4638. * Used for testing
  4639. *
  4640. * @private
  4641. */
  4642. static _clearCache() {
  4643. currentConfig = null;
  4644. }
  4645. }
  4646. let currentConfig = null;
  4647. const CURRENT_CONFIG_KEY = 'currentConfig';
  4648. function decodePayload(data) {
  4649. try {
  4650. const json = JSON.parse(data);
  4651. if (json && typeof json === 'object') {
  4652. return (0, _decode.default)(json);
  4653. }
  4654. } catch (e) {
  4655. return null;
  4656. }
  4657. }
  4658. const DefaultController = {
  4659. current() {
  4660. if (currentConfig) {
  4661. return currentConfig;
  4662. }
  4663. const config = new ParseConfig();
  4664. const storagePath = _Storage.default.generatePath(CURRENT_CONFIG_KEY);
  4665. if (!_Storage.default.async()) {
  4666. const configData = _Storage.default.getItem(storagePath);
  4667. if (configData) {
  4668. const attributes = decodePayload(configData);
  4669. if (attributes) {
  4670. config.attributes = attributes;
  4671. currentConfig = config;
  4672. }
  4673. }
  4674. return config;
  4675. }
  4676. // Return a promise for async storage controllers
  4677. return _Storage.default.getItemAsync(storagePath).then(configData => {
  4678. if (configData) {
  4679. const attributes = decodePayload(configData);
  4680. if (attributes) {
  4681. config.attributes = attributes;
  4682. currentConfig = config;
  4683. }
  4684. }
  4685. return config;
  4686. });
  4687. },
  4688. get() {
  4689. let options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
  4690. const RESTController = _CoreManager.default.getRESTController();
  4691. return RESTController.request('GET', 'config', {}, options).then(response => {
  4692. if (!response || !response.params) {
  4693. const error = new _ParseError.default(_ParseError.default.INVALID_JSON, 'Config JSON response invalid.');
  4694. return _promise.default.reject(error);
  4695. }
  4696. const config = new ParseConfig();
  4697. config.attributes = {};
  4698. for (const attr in response.params) {
  4699. config.attributes[attr] = (0, _decode.default)(response.params[attr]);
  4700. }
  4701. currentConfig = config;
  4702. return _Storage.default.setItemAsync(_Storage.default.generatePath(CURRENT_CONFIG_KEY), (0, _stringify.default)(response.params)).then(() => {
  4703. return config;
  4704. });
  4705. });
  4706. },
  4707. save(attrs, masterKeyOnlyFlags) {
  4708. const RESTController = _CoreManager.default.getRESTController();
  4709. const encodedAttrs = {};
  4710. for (const key in attrs) {
  4711. encodedAttrs[key] = (0, _encode.default)(attrs[key]);
  4712. }
  4713. return RESTController.request('PUT', 'config', {
  4714. params: encodedAttrs,
  4715. masterKeyOnly: masterKeyOnlyFlags
  4716. }, {
  4717. useMasterKey: true
  4718. }).then(response => {
  4719. if (response && response.result) {
  4720. return _promise.default.resolve();
  4721. } else {
  4722. const error = new _ParseError.default(_ParseError.default.INTERNAL_SERVER_ERROR, 'Error occured updating Config.');
  4723. return _promise.default.reject(error);
  4724. }
  4725. });
  4726. }
  4727. };
  4728. _CoreManager.default.setConfigController(DefaultController);
  4729. var _default = exports.default = ParseConfig;
  4730. },{"./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){
  4731. "use strict";
  4732. var _Object$defineProperty2 = _dereq_("@babel/runtime-corejs3/core-js-stable/object/define-property");
  4733. var _interopRequireDefault = _dereq_("@babel/runtime-corejs3/helpers/interopRequireDefault");
  4734. _Object$defineProperty2(exports, "__esModule", {
  4735. value: true
  4736. });
  4737. exports.default = void 0;
  4738. var _forEach = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/instance/for-each"));
  4739. var _defineProperty2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/object/define-property"));
  4740. var _defineProperty3 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/helpers/defineProperty"));
  4741. var _CoreManager = _interopRequireDefault(_dereq_("./CoreManager"));
  4742. /**
  4743. * Constructs a new Parse.Error object with the given code and message.
  4744. *
  4745. * Parse.CoreManager.set('PARSE_ERRORS', [{ code, message }]) can be use to override error messages.
  4746. *
  4747. * @alias Parse.Error
  4748. */
  4749. class ParseError extends Error {
  4750. /**
  4751. * @param {number} code An error code constant from <code>Parse.Error</code>.
  4752. * @param {string} message A detailed description of the error.
  4753. */
  4754. constructor(code, message) {
  4755. var _context;
  4756. super(message);
  4757. (0, _defineProperty3.default)(this, "code", void 0);
  4758. (0, _defineProperty3.default)(this, "message", void 0);
  4759. (0, _defineProperty3.default)(this, "object", void 0);
  4760. (0, _defineProperty3.default)(this, "errors", void 0);
  4761. this.code = code;
  4762. let customMessage = message;
  4763. (0, _forEach.default)(_context = _CoreManager.default.get('PARSE_ERRORS')).call(_context, error => {
  4764. if (error.code === code && error.code) {
  4765. customMessage = error.message;
  4766. }
  4767. });
  4768. (0, _defineProperty2.default)(this, 'message', {
  4769. enumerable: true,
  4770. value: customMessage
  4771. });
  4772. }
  4773. toString() {
  4774. return 'ParseError: ' + this.code + ' ' + this.message;
  4775. }
  4776. /**
  4777. * Error code indicating some error other than those enumerated here.
  4778. *
  4779. * @property {number} OTHER_CAUSE
  4780. * @static
  4781. */
  4782. }
  4783. (0, _defineProperty3.default)(ParseError, "OTHER_CAUSE", -1);
  4784. /**
  4785. * Error code indicating that something has gone wrong with the server.
  4786. *
  4787. * @property {number} INTERNAL_SERVER_ERROR
  4788. * @static
  4789. */
  4790. (0, _defineProperty3.default)(ParseError, "INTERNAL_SERVER_ERROR", 1);
  4791. /**
  4792. * Error code indicating the connection to the Parse servers failed.
  4793. *
  4794. * @property {number} CONNECTION_FAILED
  4795. * @static
  4796. */
  4797. (0, _defineProperty3.default)(ParseError, "CONNECTION_FAILED", 100);
  4798. /**
  4799. * Error code indicating the specified object doesn't exist.
  4800. *
  4801. * @property {number} OBJECT_NOT_FOUND
  4802. * @static
  4803. */
  4804. (0, _defineProperty3.default)(ParseError, "OBJECT_NOT_FOUND", 101);
  4805. /**
  4806. * Error code indicating you tried to query with a datatype that doesn't
  4807. * support it, like exact matching an array or object.
  4808. *
  4809. * @property {number} INVALID_QUERY
  4810. * @static
  4811. */
  4812. (0, _defineProperty3.default)(ParseError, "INVALID_QUERY", 102);
  4813. /**
  4814. * Error code indicating a missing or invalid classname. Classnames are
  4815. * case-sensitive. They must start with a letter, and a-zA-Z0-9_ are the
  4816. * only valid characters.
  4817. *
  4818. * @property {number} INVALID_CLASS_NAME
  4819. * @static
  4820. */
  4821. (0, _defineProperty3.default)(ParseError, "INVALID_CLASS_NAME", 103);
  4822. /**
  4823. * Error code indicating an unspecified object id.
  4824. *
  4825. * @property {number} MISSING_OBJECT_ID
  4826. * @static
  4827. */
  4828. (0, _defineProperty3.default)(ParseError, "MISSING_OBJECT_ID", 104);
  4829. /**
  4830. * Error code indicating an invalid key name. Keys are case-sensitive. They
  4831. * must start with a letter, and a-zA-Z0-9_ are the only valid characters.
  4832. *
  4833. * @property {number} INVALID_KEY_NAME
  4834. * @static
  4835. */
  4836. (0, _defineProperty3.default)(ParseError, "INVALID_KEY_NAME", 105);
  4837. /**
  4838. * Error code indicating a malformed pointer. You should not see this unless
  4839. * you have been mucking about changing internal Parse code.
  4840. *
  4841. * @property {number} INVALID_POINTER
  4842. * @static
  4843. */
  4844. (0, _defineProperty3.default)(ParseError, "INVALID_POINTER", 106);
  4845. /**
  4846. * Error code indicating that badly formed JSON was received upstream. This
  4847. * either indicates you have done something unusual with modifying how
  4848. * things encode to JSON, or the network is failing badly.
  4849. *
  4850. * @property {number} INVALID_JSON
  4851. * @static
  4852. */
  4853. (0, _defineProperty3.default)(ParseError, "INVALID_JSON", 107);
  4854. /**
  4855. * Error code indicating that the feature you tried to access is only
  4856. * available internally for testing purposes.
  4857. *
  4858. * @property {number} COMMAND_UNAVAILABLE
  4859. * @static
  4860. */
  4861. (0, _defineProperty3.default)(ParseError, "COMMAND_UNAVAILABLE", 108);
  4862. /**
  4863. * You must call Parse.initialize before using the Parse library.
  4864. *
  4865. * @property {number} NOT_INITIALIZED
  4866. * @static
  4867. */
  4868. (0, _defineProperty3.default)(ParseError, "NOT_INITIALIZED", 109);
  4869. /**
  4870. * Error code indicating that a field was set to an inconsistent type.
  4871. *
  4872. * @property {number} INCORRECT_TYPE
  4873. * @static
  4874. */
  4875. (0, _defineProperty3.default)(ParseError, "INCORRECT_TYPE", 111);
  4876. /**
  4877. * Error code indicating an invalid channel name. A channel name is either
  4878. * an empty string (the broadcast channel) or contains only a-zA-Z0-9_
  4879. * characters and starts with a letter.
  4880. *
  4881. * @property {number} INVALID_CHANNEL_NAME
  4882. * @static
  4883. */
  4884. (0, _defineProperty3.default)(ParseError, "INVALID_CHANNEL_NAME", 112);
  4885. /**
  4886. * Error code indicating that push is misconfigured.
  4887. *
  4888. * @property {number} PUSH_MISCONFIGURED
  4889. * @static
  4890. */
  4891. (0, _defineProperty3.default)(ParseError, "PUSH_MISCONFIGURED", 115);
  4892. /**
  4893. * Error code indicating that the object is too large.
  4894. *
  4895. * @property {number} OBJECT_TOO_LARGE
  4896. * @static
  4897. */
  4898. (0, _defineProperty3.default)(ParseError, "OBJECT_TOO_LARGE", 116);
  4899. /**
  4900. * Error code indicating that the operation isn't allowed for clients.
  4901. *
  4902. * @property {number} OPERATION_FORBIDDEN
  4903. * @static
  4904. */
  4905. (0, _defineProperty3.default)(ParseError, "OPERATION_FORBIDDEN", 119);
  4906. /**
  4907. * Error code indicating the result was not found in the cache.
  4908. *
  4909. * @property {number} CACHE_MISS
  4910. * @static
  4911. */
  4912. (0, _defineProperty3.default)(ParseError, "CACHE_MISS", 120);
  4913. /**
  4914. * Error code indicating that an invalid key was used in a nested
  4915. * JSONObject.
  4916. *
  4917. * @property {number} INVALID_NESTED_KEY
  4918. * @static
  4919. */
  4920. (0, _defineProperty3.default)(ParseError, "INVALID_NESTED_KEY", 121);
  4921. /**
  4922. * Error code indicating that an invalid filename was used for ParseFile.
  4923. * A valid file name contains only a-zA-Z0-9_. characters and is between 1
  4924. * and 128 characters.
  4925. *
  4926. * @property {number} INVALID_FILE_NAME
  4927. * @static
  4928. */
  4929. (0, _defineProperty3.default)(ParseError, "INVALID_FILE_NAME", 122);
  4930. /**
  4931. * Error code indicating an invalid ACL was provided.
  4932. *
  4933. * @property {number} INVALID_ACL
  4934. * @static
  4935. */
  4936. (0, _defineProperty3.default)(ParseError, "INVALID_ACL", 123);
  4937. /**
  4938. * Error code indicating that the request timed out on the server. Typically
  4939. * this indicates that the request is too expensive to run.
  4940. *
  4941. * @property {number} TIMEOUT
  4942. * @static
  4943. */
  4944. (0, _defineProperty3.default)(ParseError, "TIMEOUT", 124);
  4945. /**
  4946. * Error code indicating that the email address was invalid.
  4947. *
  4948. * @property {number} INVALID_EMAIL_ADDRESS
  4949. * @static
  4950. */
  4951. (0, _defineProperty3.default)(ParseError, "INVALID_EMAIL_ADDRESS", 125);
  4952. /**
  4953. * Error code indicating a missing content type.
  4954. *
  4955. * @property {number} MISSING_CONTENT_TYPE
  4956. * @static
  4957. */
  4958. (0, _defineProperty3.default)(ParseError, "MISSING_CONTENT_TYPE", 126);
  4959. /**
  4960. * Error code indicating a missing content length.
  4961. *
  4962. * @property {number} MISSING_CONTENT_LENGTH
  4963. * @static
  4964. */
  4965. (0, _defineProperty3.default)(ParseError, "MISSING_CONTENT_LENGTH", 127);
  4966. /**
  4967. * Error code indicating an invalid content length.
  4968. *
  4969. * @property {number} INVALID_CONTENT_LENGTH
  4970. * @static
  4971. */
  4972. (0, _defineProperty3.default)(ParseError, "INVALID_CONTENT_LENGTH", 128);
  4973. /**
  4974. * Error code indicating a file that was too large.
  4975. *
  4976. * @property {number} FILE_TOO_LARGE
  4977. * @static
  4978. */
  4979. (0, _defineProperty3.default)(ParseError, "FILE_TOO_LARGE", 129);
  4980. /**
  4981. * Error code indicating an error saving a file.
  4982. *
  4983. * @property {number} FILE_SAVE_ERROR
  4984. * @static
  4985. */
  4986. (0, _defineProperty3.default)(ParseError, "FILE_SAVE_ERROR", 130);
  4987. /**
  4988. * Error code indicating that a unique field was given a value that is
  4989. * already taken.
  4990. *
  4991. * @property {number} DUPLICATE_VALUE
  4992. * @static
  4993. */
  4994. (0, _defineProperty3.default)(ParseError, "DUPLICATE_VALUE", 137);
  4995. /**
  4996. * Error code indicating that a role's name is invalid.
  4997. *
  4998. * @property {number} INVALID_ROLE_NAME
  4999. * @static
  5000. */
  5001. (0, _defineProperty3.default)(ParseError, "INVALID_ROLE_NAME", 139);
  5002. /**
  5003. * Error code indicating that an application quota was exceeded. Upgrade to
  5004. * resolve.
  5005. *
  5006. * @property {number} EXCEEDED_QUOTA
  5007. * @static
  5008. */
  5009. (0, _defineProperty3.default)(ParseError, "EXCEEDED_QUOTA", 140);
  5010. /**
  5011. * Error code indicating that a Cloud Code script failed.
  5012. *
  5013. * @property {number} SCRIPT_FAILED
  5014. * @static
  5015. */
  5016. (0, _defineProperty3.default)(ParseError, "SCRIPT_FAILED", 141);
  5017. /**
  5018. * Error code indicating that a Cloud Code validation failed.
  5019. *
  5020. * @property {number} VALIDATION_ERROR
  5021. * @static
  5022. */
  5023. (0, _defineProperty3.default)(ParseError, "VALIDATION_ERROR", 142);
  5024. /**
  5025. * Error code indicating that invalid image data was provided.
  5026. *
  5027. * @property {number} INVALID_IMAGE_DATA
  5028. * @static
  5029. */
  5030. (0, _defineProperty3.default)(ParseError, "INVALID_IMAGE_DATA", 143);
  5031. /**
  5032. * Error code indicating an unsaved file.
  5033. *
  5034. * @property {number} UNSAVED_FILE_ERROR
  5035. * @static
  5036. */
  5037. (0, _defineProperty3.default)(ParseError, "UNSAVED_FILE_ERROR", 151);
  5038. /**
  5039. * Error code indicating an invalid push time.
  5040. *
  5041. * @property {number} INVALID_PUSH_TIME_ERROR
  5042. * @static
  5043. */
  5044. (0, _defineProperty3.default)(ParseError, "INVALID_PUSH_TIME_ERROR", 152);
  5045. /**
  5046. * Error code indicating an error deleting a file.
  5047. *
  5048. * @property {number} FILE_DELETE_ERROR
  5049. * @static
  5050. */
  5051. (0, _defineProperty3.default)(ParseError, "FILE_DELETE_ERROR", 153);
  5052. /**
  5053. * Error code indicating an error deleting an unnamed file.
  5054. *
  5055. * @property {number} FILE_DELETE_UNNAMED_ERROR
  5056. * @static
  5057. */
  5058. (0, _defineProperty3.default)(ParseError, "FILE_DELETE_UNNAMED_ERROR", 161);
  5059. /**
  5060. * Error code indicating that the application has exceeded its request
  5061. * limit.
  5062. *
  5063. * @property {number} REQUEST_LIMIT_EXCEEDED
  5064. * @static
  5065. */
  5066. (0, _defineProperty3.default)(ParseError, "REQUEST_LIMIT_EXCEEDED", 155);
  5067. /**
  5068. * Error code indicating that the request was a duplicate and has been discarded due to
  5069. * idempotency rules.
  5070. *
  5071. * @property {number} DUPLICATE_REQUEST
  5072. * @static
  5073. */
  5074. (0, _defineProperty3.default)(ParseError, "DUPLICATE_REQUEST", 159);
  5075. /**
  5076. * Error code indicating an invalid event name.
  5077. *
  5078. * @property {number} INVALID_EVENT_NAME
  5079. * @static
  5080. */
  5081. (0, _defineProperty3.default)(ParseError, "INVALID_EVENT_NAME", 160);
  5082. /**
  5083. * Error code indicating that a field had an invalid value.
  5084. *
  5085. * @property {number} INVALID_VALUE
  5086. * @static
  5087. */
  5088. (0, _defineProperty3.default)(ParseError, "INVALID_VALUE", 162);
  5089. /**
  5090. * Error code indicating that the username is missing or empty.
  5091. *
  5092. * @property {number} USERNAME_MISSING
  5093. * @static
  5094. */
  5095. (0, _defineProperty3.default)(ParseError, "USERNAME_MISSING", 200);
  5096. /**
  5097. * Error code indicating that the password is missing or empty.
  5098. *
  5099. * @property {number} PASSWORD_MISSING
  5100. * @static
  5101. */
  5102. (0, _defineProperty3.default)(ParseError, "PASSWORD_MISSING", 201);
  5103. /**
  5104. * Error code indicating that the username has already been taken.
  5105. *
  5106. * @property {number} USERNAME_TAKEN
  5107. * @static
  5108. */
  5109. (0, _defineProperty3.default)(ParseError, "USERNAME_TAKEN", 202);
  5110. /**
  5111. * Error code indicating that the email has already been taken.
  5112. *
  5113. * @property {number} EMAIL_TAKEN
  5114. * @static
  5115. */
  5116. (0, _defineProperty3.default)(ParseError, "EMAIL_TAKEN", 203);
  5117. /**
  5118. * Error code indicating that the email is missing, but must be specified.
  5119. *
  5120. * @property {number} EMAIL_MISSING
  5121. * @static
  5122. */
  5123. (0, _defineProperty3.default)(ParseError, "EMAIL_MISSING", 204);
  5124. /**
  5125. * Error code indicating that a user with the specified email was not found.
  5126. *
  5127. * @property {number} EMAIL_NOT_FOUND
  5128. * @static
  5129. */
  5130. (0, _defineProperty3.default)(ParseError, "EMAIL_NOT_FOUND", 205);
  5131. /**
  5132. * Error code indicating that a user object without a valid session could
  5133. * not be altered.
  5134. *
  5135. * @property {number} SESSION_MISSING
  5136. * @static
  5137. */
  5138. (0, _defineProperty3.default)(ParseError, "SESSION_MISSING", 206);
  5139. /**
  5140. * Error code indicating that a user can only be created through signup.
  5141. *
  5142. * @property {number} MUST_CREATE_USER_THROUGH_SIGNUP
  5143. * @static
  5144. */
  5145. (0, _defineProperty3.default)(ParseError, "MUST_CREATE_USER_THROUGH_SIGNUP", 207);
  5146. /**
  5147. * Error code indicating that an an account being linked is already linked
  5148. * to another user.
  5149. *
  5150. * @property {number} ACCOUNT_ALREADY_LINKED
  5151. * @static
  5152. */
  5153. (0, _defineProperty3.default)(ParseError, "ACCOUNT_ALREADY_LINKED", 208);
  5154. /**
  5155. * Error code indicating that the current session token is invalid.
  5156. *
  5157. * @property {number} INVALID_SESSION_TOKEN
  5158. * @static
  5159. */
  5160. (0, _defineProperty3.default)(ParseError, "INVALID_SESSION_TOKEN", 209);
  5161. /**
  5162. * Error code indicating an error enabling or verifying MFA
  5163. *
  5164. * @property {number} MFA_ERROR
  5165. * @static
  5166. */
  5167. (0, _defineProperty3.default)(ParseError, "MFA_ERROR", 210);
  5168. /**
  5169. * Error code indicating that a valid MFA token must be provided
  5170. *
  5171. * @property {number} MFA_TOKEN_REQUIRED
  5172. * @static
  5173. */
  5174. (0, _defineProperty3.default)(ParseError, "MFA_TOKEN_REQUIRED", 211);
  5175. /**
  5176. * Error code indicating that a user cannot be linked to an account because
  5177. * that account's id could not be found.
  5178. *
  5179. * @property {number} LINKED_ID_MISSING
  5180. * @static
  5181. */
  5182. (0, _defineProperty3.default)(ParseError, "LINKED_ID_MISSING", 250);
  5183. /**
  5184. * Error code indicating that a user with a linked (e.g. Facebook) account
  5185. * has an invalid session.
  5186. *
  5187. * @property {number} INVALID_LINKED_SESSION
  5188. * @static
  5189. */
  5190. (0, _defineProperty3.default)(ParseError, "INVALID_LINKED_SESSION", 251);
  5191. /**
  5192. * Error code indicating that a service being linked (e.g. Facebook or
  5193. * Twitter) is unsupported.
  5194. *
  5195. * @property {number} UNSUPPORTED_SERVICE
  5196. * @static
  5197. */
  5198. (0, _defineProperty3.default)(ParseError, "UNSUPPORTED_SERVICE", 252);
  5199. /**
  5200. * Error code indicating an invalid operation occured on schema
  5201. *
  5202. * @property {number} INVALID_SCHEMA_OPERATION
  5203. * @static
  5204. */
  5205. (0, _defineProperty3.default)(ParseError, "INVALID_SCHEMA_OPERATION", 255);
  5206. /**
  5207. * Error code indicating that there were multiple errors. Aggregate errors
  5208. * have an "errors" property, which is an array of error objects with more
  5209. * detail about each error that occurred.
  5210. *
  5211. * @property {number} AGGREGATE_ERROR
  5212. * @static
  5213. */
  5214. (0, _defineProperty3.default)(ParseError, "AGGREGATE_ERROR", 600);
  5215. /**
  5216. * Error code indicating the client was unable to read an input file.
  5217. *
  5218. * @property {number} FILE_READ_ERROR
  5219. * @static
  5220. */
  5221. (0, _defineProperty3.default)(ParseError, "FILE_READ_ERROR", 601);
  5222. /**
  5223. * Error code indicating a real error code is unavailable because
  5224. * we had to use an XDomainRequest object to allow CORS requests in
  5225. * Internet Explorer, which strips the body from HTTP responses that have
  5226. * a non-2XX status code.
  5227. *
  5228. * @property {number} X_DOMAIN_REQUEST
  5229. * @static
  5230. */
  5231. (0, _defineProperty3.default)(ParseError, "X_DOMAIN_REQUEST", 602);
  5232. var _default = exports.default = ParseError;
  5233. },{"./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){
  5234. "use strict";
  5235. var _Object$defineProperty = _dereq_("@babel/runtime-corejs3/core-js-stable/object/define-property");
  5236. var _interopRequireDefault = _dereq_("@babel/runtime-corejs3/helpers/interopRequireDefault");
  5237. _Object$defineProperty(exports, "__esModule", {
  5238. value: true
  5239. });
  5240. exports.default = void 0;
  5241. var _isArray = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/array/is-array"));
  5242. var _slice = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/instance/slice"));
  5243. var _forEach = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/instance/for-each"));
  5244. var _keys = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/object/keys"));
  5245. var _promise = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/promise"));
  5246. var _indexOf = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/instance/index-of"));
  5247. var _defineProperty2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/helpers/defineProperty"));
  5248. var _CoreManager = _interopRequireDefault(_dereq_("./CoreManager"));
  5249. var _ParseError = _interopRequireDefault(_dereq_("./ParseError"));
  5250. var _Xhr = _interopRequireDefault(_dereq_("./Xhr.weapp"));
  5251. /* global XMLHttpRequest, Blob */
  5252. let XHR = null;
  5253. if (typeof XMLHttpRequest !== 'undefined') {
  5254. XHR = XMLHttpRequest;
  5255. }
  5256. XHR = _Xhr.default;
  5257. function b64Digit(number) {
  5258. if (number < 26) {
  5259. return String.fromCharCode(65 + number);
  5260. }
  5261. if (number < 52) {
  5262. return String.fromCharCode(97 + (number - 26));
  5263. }
  5264. if (number < 62) {
  5265. return String.fromCharCode(48 + (number - 52));
  5266. }
  5267. if (number === 62) {
  5268. return '+';
  5269. }
  5270. if (number === 63) {
  5271. return '/';
  5272. }
  5273. throw new TypeError('Tried to encode large digit ' + number + ' in base64.');
  5274. }
  5275. /**
  5276. * A Parse.File is a local representation of a file that is saved to the Parse
  5277. * cloud.
  5278. *
  5279. * @alias Parse.File
  5280. */
  5281. class ParseFile {
  5282. /**
  5283. * @param name {String} The file's name. This will be prefixed by a unique
  5284. * value once the file has finished saving. The file name must begin with
  5285. * an alphanumeric character, and consist of alphanumeric characters,
  5286. * periods, spaces, underscores, or dashes.
  5287. * @param data {Array} The data for the file, as either:
  5288. * 1. an Array of byte value Numbers, or
  5289. * 2. an Object like { base64: "..." } with a base64-encoded String.
  5290. * 3. an Object like { uri: "..." } with a uri String.
  5291. * 4. a File object selected with a file upload control. (3) only works
  5292. * in Firefox 3.6+, Safari 6.0.2+, Chrome 7+, and IE 10+.
  5293. * For example:
  5294. * <pre>
  5295. * var fileUploadControl = $("#profilePhotoFileUpload")[0];
  5296. * if (fileUploadControl.files.length > 0) {
  5297. * var file = fileUploadControl.files[0];
  5298. * var name = "photo.jpg";
  5299. * var parseFile = new Parse.File(name, file);
  5300. * parseFile.save().then(function() {
  5301. * // The file has been saved to Parse.
  5302. * }, function(error) {
  5303. * // The file either could not be read, or could not be saved to Parse.
  5304. * });
  5305. * }</pre>
  5306. * @param type {String} Optional Content-Type header to use for the file. If
  5307. * this is omitted, the content type will be inferred from the name's
  5308. * extension.
  5309. * @param metadata {object} Optional key value pairs to be stored with file object
  5310. * @param tags {object} Optional key value pairs to be stored with file object
  5311. */
  5312. constructor(name, data, type, metadata, tags) {
  5313. (0, _defineProperty2.default)(this, "_name", void 0);
  5314. (0, _defineProperty2.default)(this, "_url", void 0);
  5315. (0, _defineProperty2.default)(this, "_source", void 0);
  5316. (0, _defineProperty2.default)(this, "_previousSave", void 0);
  5317. (0, _defineProperty2.default)(this, "_data", void 0);
  5318. (0, _defineProperty2.default)(this, "_requestTask", void 0);
  5319. (0, _defineProperty2.default)(this, "_metadata", void 0);
  5320. (0, _defineProperty2.default)(this, "_tags", void 0);
  5321. const specifiedType = type || '';
  5322. this._name = name;
  5323. this._metadata = metadata || {};
  5324. this._tags = tags || {};
  5325. if (data !== undefined) {
  5326. if ((0, _isArray.default)(data)) {
  5327. this._data = ParseFile.encodeBase64(data);
  5328. this._source = {
  5329. format: 'base64',
  5330. base64: this._data,
  5331. type: specifiedType
  5332. };
  5333. } else if (typeof Blob !== 'undefined' && data instanceof Blob) {
  5334. this._source = {
  5335. format: 'file',
  5336. file: data,
  5337. type: specifiedType
  5338. };
  5339. } else if (data && typeof data.uri === 'string' && data.uri !== undefined) {
  5340. this._source = {
  5341. format: 'uri',
  5342. uri: data.uri,
  5343. type: specifiedType
  5344. };
  5345. } else if (data && typeof data.base64 === 'string') {
  5346. var _context, _context2, _context3;
  5347. const base64 = (0, _slice.default)(_context = data.base64.split(',')).call(_context, -1)[0];
  5348. 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';
  5349. this._data = base64;
  5350. this._source = {
  5351. format: 'base64',
  5352. base64,
  5353. type: dataType
  5354. };
  5355. } else {
  5356. throw new TypeError('Cannot create a Parse.File with that data.');
  5357. }
  5358. }
  5359. }
  5360. /**
  5361. * Return the data for the file, downloading it if not already present.
  5362. * Data is present if initialized with Byte Array, Base64 or Saved with Uri.
  5363. * Data is cleared if saved with File object selected with a file upload control
  5364. *
  5365. * @returns {Promise} Promise that is resolve with base64 data
  5366. */
  5367. async getData() {
  5368. if (this._data) {
  5369. return this._data;
  5370. }
  5371. if (!this._url) {
  5372. throw new Error('Cannot retrieve data for unsaved ParseFile.');
  5373. }
  5374. const controller = _CoreManager.default.getFileController();
  5375. const result = await controller.download(this._url, {
  5376. requestTask: task => this._requestTask = task
  5377. });
  5378. this._data = result.base64;
  5379. return this._data;
  5380. }
  5381. /**
  5382. * Gets the name of the file. Before save is called, this is the filename
  5383. * given by the user. After save is called, that name gets prefixed with a
  5384. * unique identifier.
  5385. *
  5386. * @returns {string}
  5387. */
  5388. name() {
  5389. return this._name;
  5390. }
  5391. /**
  5392. * Gets the url of the file. It is only available after you save the file or
  5393. * after you get the file from a Parse.Object.
  5394. *
  5395. * @param {object} options An object to specify url options
  5396. * @param {boolean} [options.forceSecure] force the url to be secure
  5397. * @returns {string | undefined}
  5398. */
  5399. url(options) {
  5400. options = options || {};
  5401. if (!this._url) {
  5402. return;
  5403. }
  5404. if (options.forceSecure) {
  5405. return this._url.replace(/^http:\/\//i, 'https://');
  5406. } else {
  5407. return this._url;
  5408. }
  5409. }
  5410. /**
  5411. * Gets the metadata of the file.
  5412. *
  5413. * @returns {object}
  5414. */
  5415. metadata() {
  5416. return this._metadata;
  5417. }
  5418. /**
  5419. * Gets the tags of the file.
  5420. *
  5421. * @returns {object}
  5422. */
  5423. tags() {
  5424. return this._tags;
  5425. }
  5426. /**
  5427. * Saves the file to the Parse cloud.
  5428. *
  5429. * @param {object} options
  5430. * Valid options are:<ul>
  5431. * <li>useMasterKey: In Cloud Code and Node only, causes the Master Key to
  5432. * be used for this request.
  5433. * <li>sessionToken: A valid session token, used for making a request on
  5434. * behalf of a specific user.
  5435. * <li>progress: In Browser only, callback for upload progress. For example:
  5436. * <pre>
  5437. * let parseFile = new Parse.File(name, file);
  5438. * parseFile.save({
  5439. * progress: (progressValue, loaded, total, { type }) => {
  5440. * if (type === "upload" && progressValue !== null) {
  5441. * // Update the UI using progressValue
  5442. * }
  5443. * }
  5444. * });
  5445. * </pre>
  5446. * </ul>
  5447. * @returns {Promise | undefined} Promise that is resolved when the save finishes.
  5448. */
  5449. save(options) {
  5450. options = options || {};
  5451. options.requestTask = task => this._requestTask = task;
  5452. options.metadata = this._metadata;
  5453. options.tags = this._tags;
  5454. const controller = _CoreManager.default.getFileController();
  5455. if (!this._previousSave) {
  5456. if (this._source.format === 'file') {
  5457. this._previousSave = controller.saveFile(this._name, this._source, options).then(res => {
  5458. this._name = res.name;
  5459. this._url = res.url;
  5460. this._data = null;
  5461. this._requestTask = null;
  5462. return this;
  5463. });
  5464. } else if (this._source.format === 'uri') {
  5465. this._previousSave = controller.download(this._source.uri, options).then(result => {
  5466. if (!(result && result.base64)) {
  5467. return {};
  5468. }
  5469. const newSource = {
  5470. format: 'base64',
  5471. base64: result.base64,
  5472. type: result.contentType
  5473. };
  5474. this._data = result.base64;
  5475. this._requestTask = null;
  5476. return controller.saveBase64(this._name, newSource, options);
  5477. }).then(res => {
  5478. this._name = res.name;
  5479. this._url = res.url;
  5480. this._requestTask = null;
  5481. return this;
  5482. });
  5483. } else {
  5484. this._previousSave = controller.saveBase64(this._name, this._source, options).then(res => {
  5485. this._name = res.name;
  5486. this._url = res.url;
  5487. this._requestTask = null;
  5488. return this;
  5489. });
  5490. }
  5491. }
  5492. if (this._previousSave) {
  5493. return this._previousSave;
  5494. }
  5495. }
  5496. /**
  5497. * Aborts the request if it has already been sent.
  5498. */
  5499. cancel() {
  5500. if (this._requestTask && typeof this._requestTask.abort === 'function') {
  5501. this._requestTask._aborted = true;
  5502. this._requestTask.abort();
  5503. }
  5504. this._requestTask = null;
  5505. }
  5506. /**
  5507. * Deletes the file from the Parse cloud.
  5508. * In Cloud Code and Node only with Master Key.
  5509. *
  5510. * @param {object} options
  5511. * Valid options are:<ul>
  5512. * <li>useMasterKey: In Cloud Code and Node only, causes the Master Key to
  5513. * be used for this request.
  5514. * <pre>
  5515. * @returns {Promise} Promise that is resolved when the delete finishes.
  5516. */
  5517. destroy() {
  5518. let options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
  5519. if (!this._name) {
  5520. throw new _ParseError.default(_ParseError.default.FILE_DELETE_UNNAMED_ERROR, 'Cannot delete an unnamed file.');
  5521. }
  5522. const destroyOptions = {
  5523. useMasterKey: true
  5524. };
  5525. if (options.hasOwnProperty('useMasterKey')) {
  5526. destroyOptions.useMasterKey = !!options.useMasterKey;
  5527. }
  5528. const controller = _CoreManager.default.getFileController();
  5529. return controller.deleteFile(this._name, destroyOptions).then(() => {
  5530. this._data = undefined;
  5531. this._requestTask = null;
  5532. return this;
  5533. });
  5534. }
  5535. toJSON() {
  5536. return {
  5537. __type: 'File',
  5538. name: this._name,
  5539. url: this._url
  5540. };
  5541. }
  5542. equals(other) {
  5543. if (this === other) {
  5544. return true;
  5545. }
  5546. // Unsaved Files are never equal, since they will be saved to different URLs
  5547. return other instanceof ParseFile && this.name() === other.name() && this.url() === other.url() && typeof this.url() !== 'undefined';
  5548. }
  5549. /**
  5550. * Sets metadata to be saved with file object. Overwrites existing metadata
  5551. *
  5552. * @param {object} metadata Key value pairs to be stored with file object
  5553. */
  5554. setMetadata(metadata) {
  5555. if (metadata && typeof metadata === 'object') {
  5556. var _context4;
  5557. (0, _forEach.default)(_context4 = (0, _keys.default)(metadata)).call(_context4, key => {
  5558. this.addMetadata(key, metadata[key]);
  5559. });
  5560. }
  5561. }
  5562. /**
  5563. * Sets metadata to be saved with file object. Adds to existing metadata.
  5564. *
  5565. * @param {string} key key to store the metadata
  5566. * @param {*} value metadata
  5567. */
  5568. addMetadata(key, value) {
  5569. if (typeof key === 'string') {
  5570. this._metadata[key] = value;
  5571. }
  5572. }
  5573. /**
  5574. * Sets tags to be saved with file object. Overwrites existing tags
  5575. *
  5576. * @param {object} tags Key value pairs to be stored with file object
  5577. */
  5578. setTags(tags) {
  5579. if (tags && typeof tags === 'object') {
  5580. var _context5;
  5581. (0, _forEach.default)(_context5 = (0, _keys.default)(tags)).call(_context5, key => {
  5582. this.addTag(key, tags[key]);
  5583. });
  5584. }
  5585. }
  5586. /**
  5587. * Sets tags to be saved with file object. Adds to existing tags.
  5588. *
  5589. * @param {string} key key to store tags
  5590. * @param {*} value tag
  5591. */
  5592. addTag(key, value) {
  5593. if (typeof key === 'string') {
  5594. this._tags[key] = value;
  5595. }
  5596. }
  5597. static fromJSON(obj) {
  5598. if (obj.__type !== 'File') {
  5599. throw new TypeError('JSON object does not represent a ParseFile');
  5600. }
  5601. const file = new ParseFile(obj.name);
  5602. file._url = obj.url;
  5603. return file;
  5604. }
  5605. static encodeBase64(bytes) {
  5606. const chunks = [];
  5607. chunks.length = Math.ceil(bytes.length / 3);
  5608. for (let i = 0; i < chunks.length; i++) {
  5609. const b1 = bytes[i * 3];
  5610. const b2 = bytes[i * 3 + 1] || 0;
  5611. const b3 = bytes[i * 3 + 2] || 0;
  5612. const has2 = i * 3 + 1 < bytes.length;
  5613. const has3 = i * 3 + 2 < bytes.length;
  5614. 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('');
  5615. }
  5616. return chunks.join('');
  5617. }
  5618. }
  5619. const DefaultController = {
  5620. saveFile: async function (name, source, options) {
  5621. if (source.format !== 'file') {
  5622. throw new Error('saveFile can only be used with File-type sources.');
  5623. }
  5624. const base64Data = await new _promise.default((res, rej) => {
  5625. // eslint-disable-next-line no-undef
  5626. const reader = new FileReader();
  5627. reader.onload = () => res(reader.result);
  5628. reader.onerror = error => rej(error);
  5629. reader.readAsDataURL(source.file);
  5630. });
  5631. // we only want the data after the comma
  5632. // For example: "data:application/pdf;base64,JVBERi0xLjQKJ..." we would only want "JVBERi0xLjQKJ..."
  5633. const [first, second] = base64Data.split(',');
  5634. // in the event there is no 'data:application/pdf;base64,' at the beginning of the base64 string
  5635. // use the entire string instead
  5636. const data = second ? second : first;
  5637. const newSource = {
  5638. format: 'base64',
  5639. base64: data,
  5640. type: source.type || (source.file ? source.file.type : undefined)
  5641. };
  5642. return await DefaultController.saveBase64(name, newSource, options);
  5643. },
  5644. saveBase64: function (name, source) {
  5645. let options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
  5646. if (source.format !== 'base64') {
  5647. throw new Error('saveBase64 can only be used with Base64-type sources.');
  5648. }
  5649. const data = {
  5650. base64: source.base64,
  5651. fileData: {
  5652. metadata: {
  5653. ...options.metadata
  5654. },
  5655. tags: {
  5656. ...options.tags
  5657. }
  5658. }
  5659. };
  5660. delete options.metadata;
  5661. delete options.tags;
  5662. if (source.type) {
  5663. data._ContentType = source.type;
  5664. }
  5665. return _CoreManager.default.getRESTController().request('POST', 'files/' + name, data, options);
  5666. },
  5667. download: function (uri, options) {
  5668. if (XHR) {
  5669. return this.downloadAjax(uri, options);
  5670. } else {
  5671. return _promise.default.reject('Cannot make a request: No definition of XMLHttpRequest was found.');
  5672. }
  5673. },
  5674. downloadAjax: function (uri, options) {
  5675. return new _promise.default((resolve, reject) => {
  5676. const xhr = new XHR();
  5677. xhr.open('GET', uri, true);
  5678. xhr.responseType = 'arraybuffer';
  5679. xhr.onerror = function (e) {
  5680. reject(e);
  5681. };
  5682. xhr.onreadystatechange = function () {
  5683. if (xhr.readyState !== xhr.DONE) {
  5684. return;
  5685. }
  5686. if (!this.response) {
  5687. return resolve({});
  5688. }
  5689. const bytes = new Uint8Array(this.response);
  5690. resolve({
  5691. base64: ParseFile.encodeBase64(bytes),
  5692. contentType: xhr.getResponseHeader('content-type')
  5693. });
  5694. };
  5695. options.requestTask(xhr);
  5696. xhr.send();
  5697. });
  5698. },
  5699. deleteFile: function (name, options) {
  5700. const headers = {
  5701. 'X-Parse-Application-ID': _CoreManager.default.get('APPLICATION_ID')
  5702. };
  5703. if (options.useMasterKey) {
  5704. headers['X-Parse-Master-Key'] = _CoreManager.default.get('MASTER_KEY');
  5705. }
  5706. let url = _CoreManager.default.get('SERVER_URL');
  5707. if (url[url.length - 1] !== '/') {
  5708. url += '/';
  5709. }
  5710. url += 'files/' + name;
  5711. return _CoreManager.default.getRESTController().ajax('DELETE', url, '', headers).catch(response => {
  5712. // TODO: return JSON object in server
  5713. if (!response || response === 'SyntaxError: Unexpected end of JSON input') {
  5714. return _promise.default.resolve();
  5715. } else {
  5716. return _CoreManager.default.getRESTController().handleError(response);
  5717. }
  5718. });
  5719. },
  5720. _setXHR(xhr) {
  5721. XHR = xhr;
  5722. },
  5723. _getXHR() {
  5724. return XHR;
  5725. }
  5726. };
  5727. _CoreManager.default.setFileController(DefaultController);
  5728. var _default = exports.default = ParseFile;
  5729. exports.b64Digit = b64Digit;
  5730. },{"./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){
  5731. "use strict";
  5732. var _Object$defineProperty = _dereq_("@babel/runtime-corejs3/core-js-stable/object/define-property");
  5733. var _interopRequireDefault = _dereq_("@babel/runtime-corejs3/helpers/interopRequireDefault");
  5734. _Object$defineProperty(exports, "__esModule", {
  5735. value: true
  5736. });
  5737. exports.default = void 0;
  5738. var _isArray = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/array/is-array"));
  5739. var _promise = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/promise"));
  5740. var _defineProperty2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/helpers/defineProperty"));
  5741. /**
  5742. * Creates a new GeoPoint with any of the following forms:<br>
  5743. * <pre>
  5744. * new GeoPoint(otherGeoPoint)
  5745. * new GeoPoint(30, 30)
  5746. * new GeoPoint([30, 30])
  5747. * new GeoPoint({latitude: 30, longitude: 30})
  5748. * new GeoPoint() // defaults to (0, 0)
  5749. * </pre>
  5750. * <p>Represents a latitude / longitude point that may be associated
  5751. * with a key in a ParseObject or used as a reference point for geo queries.
  5752. * This allows proximity-based queries on the key.</p>
  5753. *
  5754. * <p>Only one key in a class may contain a GeoPoint.</p>
  5755. *
  5756. * <p>Example:<pre>
  5757. * var point = new Parse.GeoPoint(30.0, -20.0);
  5758. * var object = new Parse.Object("PlaceObject");
  5759. * object.set("location", point);
  5760. * object.save();</pre></p>
  5761. *
  5762. * @alias Parse.GeoPoint
  5763. */
  5764. /* global navigator */
  5765. class ParseGeoPoint {
  5766. /**
  5767. * @param {(number[] | object | number)} arg1 Either a list of coordinate pairs, an object with `latitude`, `longitude`, or the latitude or the point.
  5768. * @param {number} arg2 The longitude of the GeoPoint
  5769. */
  5770. constructor(arg1, arg2) {
  5771. (0, _defineProperty2.default)(this, "_latitude", void 0);
  5772. (0, _defineProperty2.default)(this, "_longitude", void 0);
  5773. if ((0, _isArray.default)(arg1)) {
  5774. ParseGeoPoint._validate(arg1[0], arg1[1]);
  5775. this._latitude = arg1[0];
  5776. this._longitude = arg1[1];
  5777. } else if (typeof arg1 === 'object') {
  5778. ParseGeoPoint._validate(arg1.latitude, arg1.longitude);
  5779. this._latitude = arg1.latitude;
  5780. this._longitude = arg1.longitude;
  5781. } else if (arg1 !== undefined && arg2 !== undefined) {
  5782. ParseGeoPoint._validate(arg1, arg2);
  5783. this._latitude = arg1;
  5784. this._longitude = arg2;
  5785. } else {
  5786. this._latitude = 0;
  5787. this._longitude = 0;
  5788. }
  5789. }
  5790. /**
  5791. * North-south portion of the coordinate, in range [-90, 90].
  5792. * Throws an exception if set out of range in a modern browser.
  5793. *
  5794. * @property {number} latitude
  5795. * @returns {number}
  5796. */
  5797. get latitude() {
  5798. return this._latitude;
  5799. }
  5800. set latitude(val) {
  5801. ParseGeoPoint._validate(val, this.longitude);
  5802. this._latitude = val;
  5803. }
  5804. /**
  5805. * East-west portion of the coordinate, in range [-180, 180].
  5806. * Throws if set out of range in a modern browser.
  5807. *
  5808. * @property {number} longitude
  5809. * @returns {number}
  5810. */
  5811. get longitude() {
  5812. return this._longitude;
  5813. }
  5814. set longitude(val) {
  5815. ParseGeoPoint._validate(this.latitude, val);
  5816. this._longitude = val;
  5817. }
  5818. /**
  5819. * Returns a JSON representation of the GeoPoint, suitable for Parse.
  5820. *
  5821. * @returns {object}
  5822. */
  5823. toJSON() {
  5824. ParseGeoPoint._validate(this._latitude, this._longitude);
  5825. return {
  5826. __type: 'GeoPoint',
  5827. latitude: this._latitude,
  5828. longitude: this._longitude
  5829. };
  5830. }
  5831. equals(other) {
  5832. return other instanceof ParseGeoPoint && this.latitude === other.latitude && this.longitude === other.longitude;
  5833. }
  5834. /**
  5835. * Returns the distance from this GeoPoint to another in radians.
  5836. *
  5837. * @param {Parse.GeoPoint} point the other Parse.GeoPoint.
  5838. * @returns {number}
  5839. */
  5840. radiansTo(point) {
  5841. const d2r = Math.PI / 180.0;
  5842. const lat1rad = this.latitude * d2r;
  5843. const long1rad = this.longitude * d2r;
  5844. const lat2rad = point.latitude * d2r;
  5845. const long2rad = point.longitude * d2r;
  5846. const sinDeltaLatDiv2 = Math.sin((lat1rad - lat2rad) / 2);
  5847. const sinDeltaLongDiv2 = Math.sin((long1rad - long2rad) / 2);
  5848. // Square of half the straight line chord distance between both points.
  5849. let a = sinDeltaLatDiv2 * sinDeltaLatDiv2 + Math.cos(lat1rad) * Math.cos(lat2rad) * sinDeltaLongDiv2 * sinDeltaLongDiv2;
  5850. a = Math.min(1.0, a);
  5851. return 2 * Math.asin(Math.sqrt(a));
  5852. }
  5853. /**
  5854. * Returns the distance from this GeoPoint to another in kilometers.
  5855. *
  5856. * @param {Parse.GeoPoint} point the other Parse.GeoPoint.
  5857. * @returns {number}
  5858. */
  5859. kilometersTo(point) {
  5860. return this.radiansTo(point) * 6371.0;
  5861. }
  5862. /**
  5863. * Returns the distance from this GeoPoint to another in miles.
  5864. *
  5865. * @param {Parse.GeoPoint} point the other Parse.GeoPoint.
  5866. * @returns {number}
  5867. */
  5868. milesTo(point) {
  5869. return this.radiansTo(point) * 3958.8;
  5870. }
  5871. /*
  5872. * Throws an exception if the given lat-long is out of bounds.
  5873. */
  5874. static _validate(latitude, longitude) {
  5875. if (isNaN(latitude) || isNaN(longitude) || typeof latitude !== 'number' || typeof longitude !== 'number') {
  5876. throw new TypeError('GeoPoint latitude and longitude must be valid numbers');
  5877. }
  5878. if (latitude < -90.0) {
  5879. throw new TypeError('GeoPoint latitude out of bounds: ' + latitude + ' < -90.0.');
  5880. }
  5881. if (latitude > 90.0) {
  5882. throw new TypeError('GeoPoint latitude out of bounds: ' + latitude + ' > 90.0.');
  5883. }
  5884. if (longitude < -180.0) {
  5885. throw new TypeError('GeoPoint longitude out of bounds: ' + longitude + ' < -180.0.');
  5886. }
  5887. if (longitude > 180.0) {
  5888. throw new TypeError('GeoPoint longitude out of bounds: ' + longitude + ' > 180.0.');
  5889. }
  5890. }
  5891. /**
  5892. * Creates a GeoPoint with the user's current location, if available.
  5893. *
  5894. * @param {object} options The options.
  5895. * @param {boolean} [options.enableHighAccuracy] A boolean value that indicates the application would like to receive the best possible results.
  5896. * If true and if the device is able to provide a more accurate position, it will do so.
  5897. * Note that this can result in slower response times or increased power consumption (with a GPS chip on a mobile device for example).
  5898. * 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.
  5899. * @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.
  5900. * The default value is Infinity, meaning that getCurrentPosition() won't return until the position is available.
  5901. * @param {number} [options.maximumAge] A positive long value indicating the maximum age in milliseconds of a possible cached position that is acceptable to return.
  5902. * If set to 0, it means that the device cannot use a cached position and must attempt to retrieve the real current position.
  5903. * If set to Infinity the device must return a cached position regardless of its age. Default: 0.
  5904. * @static
  5905. * @returns {Promise<Parse.GeoPoint>} User's current location
  5906. */
  5907. static current(options) {
  5908. return new _promise.default((resolve, reject) => {
  5909. navigator.geolocation.getCurrentPosition(location => {
  5910. resolve(new ParseGeoPoint(location.coords.latitude, location.coords.longitude));
  5911. }, reject, options);
  5912. });
  5913. }
  5914. }
  5915. var _default = exports.default = ParseGeoPoint;
  5916. },{"@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){
  5917. "use strict";
  5918. var _Object$defineProperty = _dereq_("@babel/runtime-corejs3/core-js-stable/object/define-property");
  5919. var _interopRequireDefault = _dereq_("@babel/runtime-corejs3/helpers/interopRequireDefault");
  5920. _Object$defineProperty(exports, "__esModule", {
  5921. value: true
  5922. });
  5923. exports.create = create;
  5924. exports.createFunction = createFunction;
  5925. exports.createTrigger = createTrigger;
  5926. exports.getFunction = getFunction;
  5927. exports.getFunctions = getFunctions;
  5928. exports.getTrigger = getTrigger;
  5929. exports.getTriggers = getTriggers;
  5930. exports.remove = remove;
  5931. exports.removeFunction = removeFunction;
  5932. exports.removeTrigger = removeTrigger;
  5933. exports.update = update;
  5934. exports.updateFunction = updateFunction;
  5935. exports.updateTrigger = updateTrigger;
  5936. var _promise = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/promise"));
  5937. var _CoreManager = _interopRequireDefault(_dereq_("./CoreManager"));
  5938. var _decode = _interopRequireDefault(_dereq_("./decode"));
  5939. var _ParseError = _interopRequireDefault(_dereq_("./ParseError"));
  5940. function getFunctions() {
  5941. return _CoreManager.default.getHooksController().get('functions');
  5942. }
  5943. function getTriggers() {
  5944. return _CoreManager.default.getHooksController().get('triggers');
  5945. }
  5946. function getFunction(name) {
  5947. return _CoreManager.default.getHooksController().get('functions', name);
  5948. }
  5949. function getTrigger(className, triggerName) {
  5950. return _CoreManager.default.getHooksController().get('triggers', className, triggerName);
  5951. }
  5952. function createFunction(functionName, url) {
  5953. return create({
  5954. functionName: functionName,
  5955. url: url
  5956. });
  5957. }
  5958. function createTrigger(className, triggerName, url) {
  5959. return create({
  5960. className: className,
  5961. triggerName: triggerName,
  5962. url: url
  5963. });
  5964. }
  5965. function create(hook) {
  5966. return _CoreManager.default.getHooksController().create(hook);
  5967. }
  5968. function updateFunction(functionName, url) {
  5969. return update({
  5970. functionName: functionName,
  5971. url: url
  5972. });
  5973. }
  5974. function updateTrigger(className, triggerName, url) {
  5975. return update({
  5976. className: className,
  5977. triggerName: triggerName,
  5978. url: url
  5979. });
  5980. }
  5981. function update(hook) {
  5982. return _CoreManager.default.getHooksController().update(hook);
  5983. }
  5984. function removeFunction(functionName) {
  5985. return remove({
  5986. functionName: functionName
  5987. });
  5988. }
  5989. function removeTrigger(className, triggerName) {
  5990. return remove({
  5991. className: className,
  5992. triggerName: triggerName
  5993. });
  5994. }
  5995. function remove(hook) {
  5996. return _CoreManager.default.getHooksController().remove(hook);
  5997. }
  5998. const DefaultController = {
  5999. get(type, functionName, triggerName) {
  6000. let url = '/hooks/' + type;
  6001. if (functionName) {
  6002. url += '/' + functionName;
  6003. if (triggerName) {
  6004. url += '/' + triggerName;
  6005. }
  6006. }
  6007. return this.sendRequest('GET', url);
  6008. },
  6009. create(hook) {
  6010. let url;
  6011. if (hook.functionName && hook.url) {
  6012. url = '/hooks/functions';
  6013. } else if (hook.className && hook.triggerName && hook.url) {
  6014. url = '/hooks/triggers';
  6015. } else {
  6016. return _promise.default.reject({
  6017. error: 'invalid hook declaration',
  6018. code: 143
  6019. });
  6020. }
  6021. return this.sendRequest('POST', url, hook);
  6022. },
  6023. remove(hook) {
  6024. let url;
  6025. if (hook.functionName) {
  6026. url = '/hooks/functions/' + hook.functionName;
  6027. delete hook.functionName;
  6028. } else if (hook.className && hook.triggerName) {
  6029. url = '/hooks/triggers/' + hook.className + '/' + hook.triggerName;
  6030. delete hook.className;
  6031. delete hook.triggerName;
  6032. } else {
  6033. return _promise.default.reject({
  6034. error: 'invalid hook declaration',
  6035. code: 143
  6036. });
  6037. }
  6038. return this.sendRequest('PUT', url, {
  6039. __op: 'Delete'
  6040. });
  6041. },
  6042. update(hook) {
  6043. let url;
  6044. if (hook.functionName && hook.url) {
  6045. url = '/hooks/functions/' + hook.functionName;
  6046. delete hook.functionName;
  6047. } else if (hook.className && hook.triggerName && hook.url) {
  6048. url = '/hooks/triggers/' + hook.className + '/' + hook.triggerName;
  6049. delete hook.className;
  6050. delete hook.triggerName;
  6051. } else {
  6052. return _promise.default.reject({
  6053. error: 'invalid hook declaration',
  6054. code: 143
  6055. });
  6056. }
  6057. return this.sendRequest('PUT', url, hook);
  6058. },
  6059. sendRequest(method, url, body) {
  6060. return _CoreManager.default.getRESTController().request(method, url, body, {
  6061. useMasterKey: true
  6062. }).then(res => {
  6063. const decoded = (0, _decode.default)(res);
  6064. if (decoded) {
  6065. return _promise.default.resolve(decoded);
  6066. }
  6067. return _promise.default.reject(new _ParseError.default(_ParseError.default.INVALID_JSON, 'The server returned an invalid response.'));
  6068. });
  6069. }
  6070. };
  6071. _CoreManager.default.setHooksController(DefaultController);
  6072. },{"./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){
  6073. "use strict";
  6074. var _Object$defineProperty = _dereq_("@babel/runtime-corejs3/core-js-stable/object/define-property");
  6075. var _interopRequireDefault = _dereq_("@babel/runtime-corejs3/helpers/interopRequireDefault");
  6076. _Object$defineProperty(exports, "__esModule", {
  6077. value: true
  6078. });
  6079. exports.default = void 0;
  6080. var _entries = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/object/entries"));
  6081. var _CoreManager = _interopRequireDefault(_dereq_("./CoreManager"));
  6082. var _ParseError = _interopRequireDefault(_dereq_("./ParseError"));
  6083. var _ParseObject = _interopRequireDefault(_dereq_("./ParseObject"));
  6084. const DEVICE_TYPES = {
  6085. IOS: 'ios',
  6086. MACOS: 'macos',
  6087. TVOS: 'tvos',
  6088. FCM: 'fcm',
  6089. ANDROID: 'android',
  6090. WEB: 'web'
  6091. };
  6092. /**
  6093. * Parse.Installation is a local representation of installation data that can be saved and retrieved from the Parse cloud.
  6094. * 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.
  6095. *
  6096. * <p>A valid Parse.Installation can only be instantiated via <code>Parse.Installation.currentInstallation()</code>
  6097. *
  6098. * Parse.Installation objects which have a valid <code>deviceToken</code> and are saved to the Parse cloud can be used to target push notifications.
  6099. * </p>
  6100. *
  6101. * @alias Parse.Installation
  6102. */
  6103. class ParseInstallation extends _ParseObject.default {
  6104. /**
  6105. * @param {object} attributes The initial set of data to store in the object.
  6106. */
  6107. constructor(attributes) {
  6108. super('_Installation');
  6109. if (attributes && typeof attributes === 'object') {
  6110. if (!this.set(attributes)) {
  6111. throw new Error("Can't create an invalid Installation");
  6112. }
  6113. }
  6114. }
  6115. /**
  6116. * A unique identifier for this installation’s client application. In iOS, this is the Bundle Identifier.
  6117. *
  6118. * @property {string} appIdentifier
  6119. * @static
  6120. * @returns {string}
  6121. */
  6122. get appIdentifier() {
  6123. return this.get('appIdentifier');
  6124. }
  6125. /**
  6126. * The version string of the client application to which this installation belongs.
  6127. *
  6128. * @property {string} appVersion
  6129. * @static
  6130. * @returns {string}
  6131. */
  6132. get appVersion() {
  6133. return this.get('appVersion');
  6134. }
  6135. /**
  6136. * The display name of the client application to which this installation belongs.
  6137. *
  6138. * @property {string} appName
  6139. * @static
  6140. * @returns {string}
  6141. */
  6142. get appName() {
  6143. return this.get('appName');
  6144. }
  6145. /**
  6146. * The current value of the icon badge for iOS apps.
  6147. * Changes to this value on the server will be used
  6148. * for future badge-increment push notifications.
  6149. *
  6150. * @property {number} badge
  6151. * @static
  6152. * @returns {number}
  6153. */
  6154. get badge() {
  6155. return this.get('badge');
  6156. }
  6157. /**
  6158. * An array of the channels to which a device is currently subscribed.
  6159. *
  6160. * @property {string[]} channels
  6161. * @static
  6162. * @returns {string[]}
  6163. */
  6164. get channels() {
  6165. return this.get('channels');
  6166. }
  6167. /**
  6168. * Token used to deliver push notifications to the device.
  6169. *
  6170. * @property {string} deviceToken
  6171. * @static
  6172. * @returns {string}
  6173. */
  6174. get deviceToken() {
  6175. return this.get('deviceToken');
  6176. }
  6177. /**
  6178. * The type of device, “ios”, “android”, “web”, etc.
  6179. *
  6180. * @property {string} deviceType
  6181. * @static
  6182. * @returns {string}
  6183. */
  6184. get deviceType() {
  6185. return this.get('deviceType');
  6186. }
  6187. /**
  6188. * Gets the GCM sender identifier for this installation
  6189. *
  6190. * @property {string} GCMSenderId
  6191. * @static
  6192. * @returns {string}
  6193. */
  6194. get GCMSenderId() {
  6195. return this.get('GCMSenderId');
  6196. }
  6197. /**
  6198. * Universally Unique Identifier (UUID) for the device used by Parse. It must be unique across all of an app’s installations.
  6199. *
  6200. * @property {string} installationId
  6201. * @static
  6202. * @returns {string}
  6203. */
  6204. get installationId() {
  6205. return this.get('installationId');
  6206. }
  6207. /**
  6208. * Gets the local identifier for this installation
  6209. *
  6210. * @property {string} localeIdentifier
  6211. * @static
  6212. * @returns {string}
  6213. */
  6214. get localeIdentifier() {
  6215. return this.get('localeIdentifier');
  6216. }
  6217. /**
  6218. * Gets the parse server version for this installation
  6219. *
  6220. * @property {string} parseVersion
  6221. * @static
  6222. * @returns {string}
  6223. */
  6224. get parseVersion() {
  6225. return this.get('parseVersion');
  6226. }
  6227. /**
  6228. * This field is reserved for directing Parse to the push delivery network to be used.
  6229. *
  6230. * @property {string} pushType
  6231. * @static
  6232. * @returns {string}
  6233. */
  6234. get pushType() {
  6235. return this.get('pushType');
  6236. }
  6237. /**
  6238. * Gets the time zone for this installation
  6239. *
  6240. * @property {string} timeZone
  6241. * @static
  6242. * @returns {string}
  6243. */
  6244. get timeZone() {
  6245. return this.get('timeZone');
  6246. }
  6247. /**
  6248. * Returns the device types for used for Push Notifications.
  6249. *
  6250. * <pre>
  6251. * Parse.Installation.DEVICE_TYPES.IOS
  6252. * Parse.Installation.DEVICE_TYPES.MACOS
  6253. * Parse.Installation.DEVICE_TYPES.TVOS
  6254. * Parse.Installation.DEVICE_TYPES.FCM
  6255. * Parse.Installation.DEVICE_TYPES.ANDROID
  6256. * Parse.Installation.DEVICE_TYPES.WEB
  6257. * </pre
  6258. *
  6259. * @property {object} DEVICE_TYPES
  6260. * @static
  6261. * @returns {object}
  6262. */
  6263. static get DEVICE_TYPES() {
  6264. return DEVICE_TYPES;
  6265. }
  6266. /**
  6267. * Wrap the default fetch behavior with functionality to update local storage.
  6268. * If the installation is deleted on the server, retry the fetch as a save operation.
  6269. *
  6270. * @param {...any} args
  6271. * @returns {Promise}
  6272. */
  6273. async fetch() {
  6274. for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
  6275. args[_key] = arguments[_key];
  6276. }
  6277. try {
  6278. await super.fetch.apply(this, args);
  6279. } catch (e) {
  6280. if (e.code !== _ParseError.default.OBJECT_NOT_FOUND) {
  6281. throw e;
  6282. }
  6283. // The installation was deleted from the server.
  6284. // We always want fetch to succeed.
  6285. delete this.id;
  6286. this._getId(); // Generate localId
  6287. this._markAllFieldsDirty();
  6288. await super.save.apply(this, args);
  6289. }
  6290. await _CoreManager.default.getInstallationController().updateInstallationOnDisk(this);
  6291. return this;
  6292. }
  6293. /**
  6294. * Wrap the default save behavior with functionality to update the local storage.
  6295. * If the installation is deleted on the server, retry saving a new installation.
  6296. *
  6297. * @param {...any} args
  6298. * @returns {Promise}
  6299. */
  6300. async save() {
  6301. for (var _len2 = arguments.length, args = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
  6302. args[_key2] = arguments[_key2];
  6303. }
  6304. try {
  6305. await super.save.apply(this, args);
  6306. } catch (e) {
  6307. if (e.code !== _ParseError.default.OBJECT_NOT_FOUND) {
  6308. throw e;
  6309. }
  6310. // The installation was deleted from the server.
  6311. // We always want save to succeed.
  6312. delete this.id;
  6313. this._getId(); // Generate localId
  6314. this._markAllFieldsDirty();
  6315. await super.save.apply(this, args);
  6316. }
  6317. await _CoreManager.default.getInstallationController().updateInstallationOnDisk(this);
  6318. return this;
  6319. }
  6320. _markAllFieldsDirty() {
  6321. for (const [key, value] of (0, _entries.default)(this.attributes)) {
  6322. this.set(key, value);
  6323. }
  6324. }
  6325. /**
  6326. * Get the current Parse.Installation from disk. If doesn't exists, create an new installation.
  6327. *
  6328. * <pre>
  6329. * const installation = await Parse.Installation.currentInstallation();
  6330. * installation.set('deviceToken', '123');
  6331. * await installation.save();
  6332. * </pre>
  6333. *
  6334. * @returns {Promise} A promise that resolves to the local installation object.
  6335. */
  6336. static currentInstallation() {
  6337. return _CoreManager.default.getInstallationController().currentInstallation();
  6338. }
  6339. }
  6340. _ParseObject.default.registerSubclass('_Installation', ParseInstallation);
  6341. module.exports = ParseInstallation;
  6342. var _default = exports.default = ParseInstallation;
  6343. },{"./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){
  6344. "use strict";
  6345. var _Object$defineProperty = _dereq_("@babel/runtime-corejs3/core-js-stable/object/define-property");
  6346. var _interopRequireDefault = _dereq_("@babel/runtime-corejs3/helpers/interopRequireDefault");
  6347. _Object$defineProperty(exports, "__esModule", {
  6348. value: true
  6349. });
  6350. exports.default = void 0;
  6351. var _promise = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/promise"));
  6352. var _indexOf = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/instance/index-of"));
  6353. var _defineProperty2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/helpers/defineProperty"));
  6354. var _LiveQueryClient = _interopRequireDefault(_dereq_("./LiveQueryClient"));
  6355. var _CoreManager = _interopRequireDefault(_dereq_("./CoreManager"));
  6356. function getLiveQueryClient() {
  6357. return _CoreManager.default.getLiveQueryController().getDefaultLiveQueryClient();
  6358. }
  6359. /**
  6360. * We expose three events to help you monitor the status of the WebSocket connection:
  6361. *
  6362. * <p>Open - When we establish the WebSocket connection to the LiveQuery server, you'll get this event.
  6363. *
  6364. * <pre>
  6365. * Parse.LiveQuery.on('open', () => {
  6366. *
  6367. * });</pre></p>
  6368. *
  6369. * <p>Close - When we lose the WebSocket connection to the LiveQuery server, you'll get this event.
  6370. *
  6371. * <pre>
  6372. * Parse.LiveQuery.on('close', () => {
  6373. *
  6374. * });</pre></p>
  6375. *
  6376. * <p>Error - When some network error or LiveQuery server error happens, you'll get this event.
  6377. *
  6378. * <pre>
  6379. * Parse.LiveQuery.on('error', (error) => {
  6380. *
  6381. * });</pre></p>
  6382. *
  6383. * @class Parse.LiveQuery
  6384. * @static
  6385. */
  6386. class LiveQuery {
  6387. constructor() {
  6388. var _this = this;
  6389. (0, _defineProperty2.default)(this, "emitter", void 0);
  6390. (0, _defineProperty2.default)(this, "on", void 0);
  6391. (0, _defineProperty2.default)(this, "emit", void 0);
  6392. const EventEmitter = _CoreManager.default.getEventEmitter();
  6393. this.emitter = new EventEmitter();
  6394. this.on = (eventName, listener) => this.emitter.on(eventName, listener);
  6395. this.emit = function (eventName) {
  6396. for (var _len = arguments.length, args = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
  6397. args[_key - 1] = arguments[_key];
  6398. }
  6399. return _this.emitter.emit(eventName, ...args);
  6400. };
  6401. // adding listener so process does not crash
  6402. // best practice is for developer to register their own listener
  6403. this.on('error', () => {});
  6404. }
  6405. /**
  6406. * After open is called, the LiveQuery will try to send a connect request
  6407. * to the LiveQuery server.
  6408. */
  6409. async open() {
  6410. const liveQueryClient = await getLiveQueryClient();
  6411. liveQueryClient.open();
  6412. }
  6413. /**
  6414. * When you're done using LiveQuery, you can call Parse.LiveQuery.close().
  6415. * This function will close the WebSocket connection to the LiveQuery server,
  6416. * cancel the auto reconnect, and unsubscribe all subscriptions based on it.
  6417. * If you call query.subscribe() after this, we'll create a new WebSocket
  6418. * connection to the LiveQuery server.
  6419. */
  6420. async close() {
  6421. const liveQueryClient = await getLiveQueryClient();
  6422. liveQueryClient.close();
  6423. }
  6424. }
  6425. var _default = exports.default = LiveQuery;
  6426. let defaultLiveQueryClient;
  6427. const DefaultLiveQueryController = {
  6428. setDefaultLiveQueryClient(liveQueryClient) {
  6429. defaultLiveQueryClient = liveQueryClient;
  6430. },
  6431. async getDefaultLiveQueryClient() {
  6432. if (defaultLiveQueryClient) {
  6433. return defaultLiveQueryClient;
  6434. }
  6435. const [currentUser, installationId] = await _promise.default.all([_CoreManager.default.getUserController().currentUserAsync(), _CoreManager.default.getInstallationController().currentInstallationId()]);
  6436. const sessionToken = currentUser ? currentUser.getSessionToken() : undefined;
  6437. let liveQueryServerURL = _CoreManager.default.get('LIVEQUERY_SERVER_URL');
  6438. if (liveQueryServerURL && (0, _indexOf.default)(liveQueryServerURL).call(liveQueryServerURL, 'ws') !== 0) {
  6439. throw new Error('You need to set a proper Parse LiveQuery server url before using LiveQueryClient');
  6440. }
  6441. // If we can not find Parse.liveQueryServerURL, we try to extract it from Parse.serverURL
  6442. if (!liveQueryServerURL) {
  6443. const serverURL = _CoreManager.default.get('SERVER_URL');
  6444. const protocol = (0, _indexOf.default)(serverURL).call(serverURL, 'https') === 0 ? 'wss://' : 'ws://';
  6445. const host = serverURL.replace(/^https?:\/\//, '');
  6446. liveQueryServerURL = protocol + host;
  6447. _CoreManager.default.set('LIVEQUERY_SERVER_URL', liveQueryServerURL);
  6448. }
  6449. const applicationId = _CoreManager.default.get('APPLICATION_ID');
  6450. const javascriptKey = _CoreManager.default.get('JAVASCRIPT_KEY');
  6451. const masterKey = _CoreManager.default.get('MASTER_KEY');
  6452. defaultLiveQueryClient = new _LiveQueryClient.default({
  6453. applicationId,
  6454. serverURL: liveQueryServerURL,
  6455. javascriptKey,
  6456. masterKey,
  6457. sessionToken,
  6458. installationId
  6459. });
  6460. const LiveQuery = _CoreManager.default.getLiveQuery();
  6461. defaultLiveQueryClient.on('error', error => {
  6462. LiveQuery.emit('error', error);
  6463. });
  6464. defaultLiveQueryClient.on('open', () => {
  6465. LiveQuery.emit('open');
  6466. });
  6467. defaultLiveQueryClient.on('close', () => {
  6468. LiveQuery.emit('close');
  6469. });
  6470. return defaultLiveQueryClient;
  6471. },
  6472. _clearCachedDefaultClient() {
  6473. defaultLiveQueryClient = null;
  6474. }
  6475. };
  6476. _CoreManager.default.setLiveQueryController(DefaultLiveQueryController);
  6477. },{"./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){
  6478. "use strict";
  6479. var _WeakMap = _dereq_("@babel/runtime-corejs3/core-js-stable/weak-map");
  6480. var _Object$defineProperty2 = _dereq_("@babel/runtime-corejs3/core-js-stable/object/define-property");
  6481. var _Object$getOwnPropertyDescriptor = _dereq_("@babel/runtime-corejs3/core-js-stable/object/get-own-property-descriptor");
  6482. var _interopRequireDefault = _dereq_("@babel/runtime-corejs3/helpers/interopRequireDefault");
  6483. _Object$defineProperty2(exports, "__esModule", {
  6484. value: true
  6485. });
  6486. exports.default = void 0;
  6487. var _defineProperty2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/helpers/defineProperty"));
  6488. var _indexOf = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/instance/index-of"));
  6489. var _freeze = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/object/freeze"));
  6490. var _keys = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/object/keys"));
  6491. var _forEach = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/instance/for-each"));
  6492. var _stringify = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/json/stringify"));
  6493. var _includes = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/instance/includes"));
  6494. var _getPrototypeOf = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/object/get-prototype-of"));
  6495. var _concat = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/instance/concat"));
  6496. var _isArray = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/array/is-array"));
  6497. var _promise = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/promise"));
  6498. var _create = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/object/create"));
  6499. var _defineProperty3 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/object/define-property"));
  6500. var _find = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/instance/find"));
  6501. var _map = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/instance/map"));
  6502. var _CoreManager = _interopRequireDefault(_dereq_("./CoreManager"));
  6503. var _canBeSerialized = _interopRequireDefault(_dereq_("./canBeSerialized"));
  6504. var _decode = _interopRequireDefault(_dereq_("./decode"));
  6505. var _encode = _interopRequireDefault(_dereq_("./encode"));
  6506. var _escape = _interopRequireDefault(_dereq_("./escape"));
  6507. var _ParseACL = _interopRequireDefault(_dereq_("./ParseACL"));
  6508. var _parseDate = _interopRequireDefault(_dereq_("./parseDate"));
  6509. var _ParseError = _interopRequireDefault(_dereq_("./ParseError"));
  6510. var _ParseFile = _interopRequireDefault(_dereq_("./ParseFile"));
  6511. var _promiseUtils = _dereq_("./promiseUtils");
  6512. var _LocalDatastoreUtils = _dereq_("./LocalDatastoreUtils");
  6513. var _uuid = _interopRequireDefault(_dereq_("./uuid"));
  6514. var _ParseOp = _dereq_("./ParseOp");
  6515. var _ParseRelation = _interopRequireDefault(_dereq_("./ParseRelation"));
  6516. var SingleInstanceStateController = _interopRequireWildcard(_dereq_("./SingleInstanceStateController"));
  6517. var _unique = _interopRequireDefault(_dereq_("./unique"));
  6518. var UniqueInstanceStateController = _interopRequireWildcard(_dereq_("./UniqueInstanceStateController"));
  6519. var _unsavedChildren = _interopRequireDefault(_dereq_("./unsavedChildren"));
  6520. function _getRequireWildcardCache(e) {
  6521. if ("function" != typeof _WeakMap) return null;
  6522. var r = new _WeakMap(),
  6523. t = new _WeakMap();
  6524. return (_getRequireWildcardCache = function (e) {
  6525. return e ? t : r;
  6526. })(e);
  6527. }
  6528. function _interopRequireWildcard(e, r) {
  6529. if (!r && e && e.__esModule) return e;
  6530. if (null === e || "object" != typeof e && "function" != typeof e) return {
  6531. default: e
  6532. };
  6533. var t = _getRequireWildcardCache(r);
  6534. if (t && t.has(e)) return t.get(e);
  6535. var n = {
  6536. __proto__: null
  6537. };
  6538. for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) {
  6539. var i = _Object$defineProperty2 && _Object$getOwnPropertyDescriptor ? _Object$getOwnPropertyDescriptor(e, u) : null;
  6540. i && (i.get || i.set) ? _Object$defineProperty2(n, u, i) : n[u] = e[u];
  6541. }
  6542. return n.default = e, t && t.set(e, n), n;
  6543. }
  6544. // Mapping of class names to constructors, so we can populate objects from the
  6545. // server with appropriate subclasses of ParseObject
  6546. const classMap = {};
  6547. // Global counter for generating unique Ids for non-single-instance objects
  6548. let objectCount = 0;
  6549. // On web clients, objects are single-instance: any two objects with the same Id
  6550. // will have the same attributes. However, this may be dangerous default
  6551. // behavior in a server scenario
  6552. let singleInstance = !_CoreManager.default.get('IS_NODE');
  6553. if (singleInstance) {
  6554. _CoreManager.default.setObjectStateController(SingleInstanceStateController);
  6555. } else {
  6556. _CoreManager.default.setObjectStateController(UniqueInstanceStateController);
  6557. }
  6558. function getServerUrlPath() {
  6559. let serverUrl = _CoreManager.default.get('SERVER_URL');
  6560. if (serverUrl[serverUrl.length - 1] !== '/') {
  6561. serverUrl += '/';
  6562. }
  6563. const url = serverUrl.replace(/https?:\/\//, '');
  6564. return url.substr((0, _indexOf.default)(url).call(url, '/'));
  6565. }
  6566. /**
  6567. * Creates a new model with defined attributes.
  6568. *
  6569. * <p>You won't normally call this method directly. It is recommended that
  6570. * you use a subclass of <code>Parse.Object</code> instead, created by calling
  6571. * <code>extend</code>.</p>
  6572. *
  6573. * <p>However, if you don't want to use a subclass, or aren't sure which
  6574. * subclass is appropriate, you can use this form:<pre>
  6575. * var object = new Parse.Object("ClassName");
  6576. * </pre>
  6577. * That is basically equivalent to:<pre>
  6578. * var MyClass = Parse.Object.extend("ClassName");
  6579. * var object = new MyClass();
  6580. * </pre></p>
  6581. *
  6582. * @alias Parse.Object
  6583. */
  6584. class ParseObject {
  6585. /**
  6586. * @param {string} className The class name for the object
  6587. * @param {object} attributes The initial set of data to store in the object.
  6588. * @param {object} options The options for this object instance.
  6589. * @param {boolean} [options.ignoreValidation] Set to `true` ignore any attribute validation errors.
  6590. */
  6591. constructor(className, attributes, options) {
  6592. /**
  6593. * The ID of this object, unique within its class.
  6594. *
  6595. * @property {string} id
  6596. */
  6597. (0, _defineProperty2.default)(this, "id", void 0);
  6598. (0, _defineProperty2.default)(this, "_localId", void 0);
  6599. (0, _defineProperty2.default)(this, "_objCount", void 0);
  6600. (0, _defineProperty2.default)(this, "className", void 0);
  6601. // Enable legacy initializers
  6602. if (typeof this.initialize === 'function') {
  6603. this.initialize.apply(this, arguments);
  6604. }
  6605. let toSet = null;
  6606. this._objCount = objectCount++;
  6607. if (typeof className === 'string') {
  6608. this.className = className;
  6609. if (attributes && typeof attributes === 'object') {
  6610. toSet = attributes;
  6611. }
  6612. } else if (className && typeof className === 'object') {
  6613. this.className = className.className;
  6614. toSet = {};
  6615. for (const attr in className) {
  6616. if (attr !== 'className') {
  6617. toSet[attr] = className[attr];
  6618. }
  6619. }
  6620. if (attributes && typeof attributes === 'object') {
  6621. options = attributes;
  6622. }
  6623. }
  6624. if (toSet && !this.set(toSet, options)) {
  6625. throw new Error("Can't create an invalid Parse Object");
  6626. }
  6627. }
  6628. /* Prototype getters / setters */
  6629. get attributes() {
  6630. const stateController = _CoreManager.default.getObjectStateController();
  6631. return (0, _freeze.default)(stateController.estimateAttributes(this._getStateIdentifier()));
  6632. }
  6633. /**
  6634. * The first time this object was saved on the server.
  6635. *
  6636. * @property {Date} createdAt
  6637. * @returns {Date}
  6638. */
  6639. get createdAt() {
  6640. return this._getServerData().createdAt;
  6641. }
  6642. /**
  6643. * The last time this object was updated on the server.
  6644. *
  6645. * @property {Date} updatedAt
  6646. * @returns {Date}
  6647. */
  6648. get updatedAt() {
  6649. return this._getServerData().updatedAt;
  6650. }
  6651. /* Private methods */
  6652. /**
  6653. * Returns a local or server Id used uniquely identify this object
  6654. *
  6655. * @returns {string}
  6656. */
  6657. _getId() {
  6658. if (typeof this.id === 'string') {
  6659. return this.id;
  6660. }
  6661. if (typeof this._localId === 'string') {
  6662. return this._localId;
  6663. }
  6664. const localId = 'local' + (0, _uuid.default)();
  6665. this._localId = localId;
  6666. return localId;
  6667. }
  6668. /**
  6669. * Returns a unique identifier used to pull data from the State Controller.
  6670. *
  6671. * @returns {Parse.Object|object}
  6672. */
  6673. _getStateIdentifier() {
  6674. if (singleInstance) {
  6675. let id = this.id;
  6676. if (!id) {
  6677. id = this._getId();
  6678. }
  6679. return {
  6680. id: id,
  6681. className: this.className
  6682. };
  6683. } else {
  6684. return this;
  6685. }
  6686. }
  6687. _getServerData() {
  6688. const stateController = _CoreManager.default.getObjectStateController();
  6689. return stateController.getServerData(this._getStateIdentifier());
  6690. }
  6691. _clearServerData() {
  6692. const serverData = this._getServerData();
  6693. const unset = {};
  6694. for (const attr in serverData) {
  6695. unset[attr] = undefined;
  6696. }
  6697. const stateController = _CoreManager.default.getObjectStateController();
  6698. stateController.setServerData(this._getStateIdentifier(), unset);
  6699. }
  6700. _getPendingOps() {
  6701. const stateController = _CoreManager.default.getObjectStateController();
  6702. return stateController.getPendingOps(this._getStateIdentifier());
  6703. }
  6704. /**
  6705. * @param {Array<string>} [keysToClear] - if specified, only ops matching
  6706. * these fields will be cleared
  6707. */
  6708. _clearPendingOps(keysToClear) {
  6709. const pending = this._getPendingOps();
  6710. const latest = pending[pending.length - 1];
  6711. const keys = keysToClear || (0, _keys.default)(latest);
  6712. (0, _forEach.default)(keys).call(keys, key => {
  6713. delete latest[key];
  6714. });
  6715. }
  6716. _getDirtyObjectAttributes() {
  6717. const attributes = this.attributes;
  6718. const stateController = _CoreManager.default.getObjectStateController();
  6719. const objectCache = stateController.getObjectCache(this._getStateIdentifier());
  6720. const dirty = {};
  6721. for (const attr in attributes) {
  6722. const val = attributes[attr];
  6723. if (val && typeof val === 'object' && !(val instanceof ParseObject) && !(val instanceof _ParseFile.default) && !(val instanceof _ParseRelation.default)) {
  6724. // Due to the way browsers construct maps, the key order will not change
  6725. // unless the object is changed
  6726. try {
  6727. const json = (0, _encode.default)(val, false, true);
  6728. const stringified = (0, _stringify.default)(json);
  6729. if (objectCache[attr] !== stringified) {
  6730. dirty[attr] = val;
  6731. }
  6732. } catch (e) {
  6733. // Error occurred, possibly by a nested unsaved pointer in a mutable container
  6734. // No matter how it happened, it indicates a change in the attribute
  6735. dirty[attr] = val;
  6736. }
  6737. }
  6738. }
  6739. return dirty;
  6740. }
  6741. _toFullJSON(seen, offline) {
  6742. const json = this.toJSON(seen, offline);
  6743. json.__type = 'Object';
  6744. json.className = this.className;
  6745. return json;
  6746. }
  6747. _getSaveJSON() {
  6748. const pending = this._getPendingOps();
  6749. const dirtyObjects = this._getDirtyObjectAttributes();
  6750. const json = {};
  6751. for (var attr in dirtyObjects) {
  6752. let isDotNotation = false;
  6753. for (let i = 0; i < pending.length; i += 1) {
  6754. for (const field in pending[i]) {
  6755. // Dot notation operations are handled later
  6756. if ((0, _includes.default)(field).call(field, '.')) {
  6757. const fieldName = field.split('.')[0];
  6758. if (fieldName === attr) {
  6759. isDotNotation = true;
  6760. break;
  6761. }
  6762. }
  6763. }
  6764. }
  6765. if (!isDotNotation) {
  6766. json[attr] = new _ParseOp.SetOp(dirtyObjects[attr]).toJSON();
  6767. }
  6768. }
  6769. for (attr in pending[0]) {
  6770. json[attr] = pending[0][attr].toJSON();
  6771. }
  6772. return json;
  6773. }
  6774. _getSaveParams() {
  6775. let method = this.id ? 'PUT' : 'POST';
  6776. const body = this._getSaveJSON();
  6777. let path = 'classes/' + this.className;
  6778. if (_CoreManager.default.get('ALLOW_CUSTOM_OBJECT_ID')) {
  6779. if (!this.createdAt) {
  6780. method = 'POST';
  6781. body.objectId = this.id;
  6782. } else {
  6783. method = 'PUT';
  6784. path += '/' + this.id;
  6785. }
  6786. } else if (this.id) {
  6787. path += '/' + this.id;
  6788. } else if (this.className === '_User') {
  6789. path = 'users';
  6790. }
  6791. return {
  6792. method,
  6793. body,
  6794. path
  6795. };
  6796. }
  6797. _finishFetch(serverData) {
  6798. if (!this.id && serverData.objectId) {
  6799. this.id = serverData.objectId;
  6800. }
  6801. const stateController = _CoreManager.default.getObjectStateController();
  6802. stateController.initializeState(this._getStateIdentifier());
  6803. const decoded = {};
  6804. for (const attr in serverData) {
  6805. if (attr === 'ACL') {
  6806. decoded[attr] = new _ParseACL.default(serverData[attr]);
  6807. } else if (attr !== 'objectId') {
  6808. decoded[attr] = (0, _decode.default)(serverData[attr]);
  6809. if (decoded[attr] instanceof _ParseRelation.default) {
  6810. decoded[attr]._ensureParentAndKey(this, attr);
  6811. }
  6812. }
  6813. }
  6814. if (decoded.createdAt && typeof decoded.createdAt === 'string') {
  6815. decoded.createdAt = (0, _parseDate.default)(decoded.createdAt);
  6816. }
  6817. if (decoded.updatedAt && typeof decoded.updatedAt === 'string') {
  6818. decoded.updatedAt = (0, _parseDate.default)(decoded.updatedAt);
  6819. }
  6820. if (!decoded.updatedAt && decoded.createdAt) {
  6821. decoded.updatedAt = decoded.createdAt;
  6822. }
  6823. stateController.commitServerChanges(this._getStateIdentifier(), decoded);
  6824. }
  6825. _setExisted(existed) {
  6826. const stateController = _CoreManager.default.getObjectStateController();
  6827. const state = stateController.getState(this._getStateIdentifier());
  6828. if (state) {
  6829. state.existed = existed;
  6830. }
  6831. }
  6832. _migrateId(serverId) {
  6833. if (this._localId && serverId) {
  6834. if (singleInstance) {
  6835. const stateController = _CoreManager.default.getObjectStateController();
  6836. const oldState = stateController.removeState(this._getStateIdentifier());
  6837. this.id = serverId;
  6838. delete this._localId;
  6839. if (oldState) {
  6840. stateController.initializeState(this._getStateIdentifier(), oldState);
  6841. }
  6842. } else {
  6843. this.id = serverId;
  6844. delete this._localId;
  6845. }
  6846. }
  6847. }
  6848. _handleSaveResponse(response, status) {
  6849. const changes = {};
  6850. const stateController = _CoreManager.default.getObjectStateController();
  6851. const pending = stateController.popPendingState(this._getStateIdentifier());
  6852. for (var attr in pending) {
  6853. if (pending[attr] instanceof _ParseOp.RelationOp) {
  6854. changes[attr] = pending[attr].applyTo(undefined, this, attr);
  6855. } else if (!(attr in response)) {
  6856. // Only SetOps and UnsetOps should not come back with results
  6857. changes[attr] = pending[attr].applyTo(undefined);
  6858. }
  6859. }
  6860. for (attr in response) {
  6861. if ((attr === 'createdAt' || attr === 'updatedAt') && typeof response[attr] === 'string') {
  6862. changes[attr] = (0, _parseDate.default)(response[attr]);
  6863. } else if (attr === 'ACL') {
  6864. changes[attr] = new _ParseACL.default(response[attr]);
  6865. } else if (attr !== 'objectId') {
  6866. const val = (0, _decode.default)(response[attr]);
  6867. if (val && (0, _getPrototypeOf.default)(val) === Object.prototype) {
  6868. changes[attr] = {
  6869. ...this.attributes[attr],
  6870. ...val
  6871. };
  6872. } else {
  6873. changes[attr] = val;
  6874. }
  6875. if (changes[attr] instanceof _ParseOp.UnsetOp) {
  6876. changes[attr] = undefined;
  6877. }
  6878. }
  6879. }
  6880. if (changes.createdAt && !changes.updatedAt) {
  6881. changes.updatedAt = changes.createdAt;
  6882. }
  6883. this._migrateId(response.objectId);
  6884. if (status !== 201) {
  6885. this._setExisted(true);
  6886. }
  6887. stateController.commitServerChanges(this._getStateIdentifier(), changes);
  6888. }
  6889. _handleSaveError() {
  6890. const stateController = _CoreManager.default.getObjectStateController();
  6891. stateController.mergeFirstPendingState(this._getStateIdentifier());
  6892. }
  6893. static _getClassMap() {
  6894. return classMap;
  6895. }
  6896. /* Public methods */
  6897. initialize() {
  6898. // NOOP
  6899. }
  6900. /**
  6901. * Returns a JSON version of the object suitable for saving to Parse.
  6902. *
  6903. * @param seen
  6904. * @param offline
  6905. * @returns {object}
  6906. */
  6907. toJSON(seen, offline) {
  6908. const seenEntry = this.id ? this.className + ':' + this.id : this;
  6909. seen = seen || [seenEntry];
  6910. const json = {};
  6911. const attrs = this.attributes;
  6912. for (const attr in attrs) {
  6913. if ((attr === 'createdAt' || attr === 'updatedAt') && attrs[attr].toJSON) {
  6914. json[attr] = attrs[attr].toJSON();
  6915. } else {
  6916. json[attr] = (0, _encode.default)(attrs[attr], false, false, seen, offline);
  6917. }
  6918. }
  6919. const pending = this._getPendingOps();
  6920. for (const attr in pending[0]) {
  6921. if ((0, _indexOf.default)(attr).call(attr, '.') < 0) {
  6922. json[attr] = pending[0][attr].toJSON(offline);
  6923. }
  6924. }
  6925. if (this.id) {
  6926. json.objectId = this.id;
  6927. }
  6928. return json;
  6929. }
  6930. /**
  6931. * Determines whether this ParseObject is equal to another ParseObject
  6932. *
  6933. * @param {object} other - An other object ot compare
  6934. * @returns {boolean}
  6935. */
  6936. equals(other) {
  6937. if (this === other) {
  6938. return true;
  6939. }
  6940. return other instanceof ParseObject && this.className === other.className && this.id === other.id && typeof this.id !== 'undefined';
  6941. }
  6942. /**
  6943. * Returns true if this object has been modified since its last
  6944. * save/refresh. If an attribute is specified, it returns true only if that
  6945. * particular attribute has been modified since the last save/refresh.
  6946. *
  6947. * @param {string} attr An attribute name (optional).
  6948. * @returns {boolean}
  6949. */
  6950. dirty(attr) {
  6951. if (!this.id) {
  6952. return true;
  6953. }
  6954. const pendingOps = this._getPendingOps();
  6955. const dirtyObjects = this._getDirtyObjectAttributes();
  6956. if (attr) {
  6957. if (dirtyObjects.hasOwnProperty(attr)) {
  6958. return true;
  6959. }
  6960. for (let i = 0; i < pendingOps.length; i++) {
  6961. if (pendingOps[i].hasOwnProperty(attr)) {
  6962. return true;
  6963. }
  6964. }
  6965. return false;
  6966. }
  6967. if ((0, _keys.default)(pendingOps[0]).length !== 0) {
  6968. return true;
  6969. }
  6970. if ((0, _keys.default)(dirtyObjects).length !== 0) {
  6971. return true;
  6972. }
  6973. return false;
  6974. }
  6975. /**
  6976. * Returns an array of keys that have been modified since last save/refresh
  6977. *
  6978. * @returns {string[]}
  6979. */
  6980. dirtyKeys() {
  6981. const pendingOps = this._getPendingOps();
  6982. const keys = {};
  6983. for (let i = 0; i < pendingOps.length; i++) {
  6984. for (const attr in pendingOps[i]) {
  6985. keys[attr] = true;
  6986. }
  6987. }
  6988. const dirtyObjects = this._getDirtyObjectAttributes();
  6989. for (const attr in dirtyObjects) {
  6990. keys[attr] = true;
  6991. }
  6992. return (0, _keys.default)(keys);
  6993. }
  6994. /**
  6995. * Returns true if the object has been fetched.
  6996. *
  6997. * @returns {boolean}
  6998. */
  6999. isDataAvailable() {
  7000. const serverData = this._getServerData();
  7001. return !!(0, _keys.default)(serverData).length;
  7002. }
  7003. /**
  7004. * Gets a Pointer referencing this Object.
  7005. *
  7006. * @returns {Pointer}
  7007. */
  7008. toPointer() {
  7009. if (!this.id) {
  7010. throw new Error('Cannot create a pointer to an unsaved ParseObject');
  7011. }
  7012. return {
  7013. __type: 'Pointer',
  7014. className: this.className,
  7015. objectId: this.id
  7016. };
  7017. }
  7018. /**
  7019. * Gets a Pointer referencing this Object.
  7020. *
  7021. * @returns {Pointer}
  7022. */
  7023. toOfflinePointer() {
  7024. if (!this._localId) {
  7025. throw new Error('Cannot create a offline pointer to a saved ParseObject');
  7026. }
  7027. return {
  7028. __type: 'Object',
  7029. className: this.className,
  7030. _localId: this._localId
  7031. };
  7032. }
  7033. /**
  7034. * Gets the value of an attribute.
  7035. *
  7036. * @param {string} attr The string name of an attribute.
  7037. * @returns {*}
  7038. */
  7039. get(attr) {
  7040. return this.attributes[attr];
  7041. }
  7042. /**
  7043. * Gets a relation on the given class for the attribute.
  7044. *
  7045. * @param {string} attr The attribute to get the relation for.
  7046. * @returns {Parse.Relation}
  7047. */
  7048. relation(attr) {
  7049. const value = this.get(attr);
  7050. if (value) {
  7051. if (!(value instanceof _ParseRelation.default)) {
  7052. throw new Error('Called relation() on non-relation field ' + attr);
  7053. }
  7054. value._ensureParentAndKey(this, attr);
  7055. return value;
  7056. }
  7057. return new _ParseRelation.default(this, attr);
  7058. }
  7059. /**
  7060. * Gets the HTML-escaped value of an attribute.
  7061. *
  7062. * @param {string} attr The string name of an attribute.
  7063. * @returns {string}
  7064. */
  7065. escape(attr) {
  7066. let val = this.attributes[attr];
  7067. if (val == null) {
  7068. return '';
  7069. }
  7070. if (typeof val !== 'string') {
  7071. if (typeof val.toString !== 'function') {
  7072. return '';
  7073. }
  7074. val = val.toString();
  7075. }
  7076. return (0, _escape.default)(val);
  7077. }
  7078. /**
  7079. * Returns <code>true</code> if the attribute contains a value that is not
  7080. * null or undefined.
  7081. *
  7082. * @param {string} attr The string name of the attribute.
  7083. * @returns {boolean}
  7084. */
  7085. has(attr) {
  7086. const attributes = this.attributes;
  7087. if (attributes.hasOwnProperty(attr)) {
  7088. return attributes[attr] != null;
  7089. }
  7090. return false;
  7091. }
  7092. /**
  7093. * Sets a hash of model attributes on the object.
  7094. *
  7095. * <p>You can call it with an object containing keys and values, with one
  7096. * key and value, or dot notation. For example:<pre>
  7097. * gameTurn.set({
  7098. * player: player1,
  7099. * diceRoll: 2
  7100. * }, {
  7101. * error: function(gameTurnAgain, error) {
  7102. * // The set failed validation.
  7103. * }
  7104. * });
  7105. *
  7106. * game.set("currentPlayer", player2, {
  7107. * error: function(gameTurnAgain, error) {
  7108. * // The set failed validation.
  7109. * }
  7110. * });
  7111. *
  7112. * game.set("finished", true);</pre></p>
  7113. *
  7114. * game.set("player.score", 10);</pre></p>
  7115. *
  7116. * @param {(string|object)} key The key to set.
  7117. * @param {(string|object)} value The value to give it.
  7118. * @param {object} options A set of options for the set.
  7119. * The only supported option is <code>error</code>.
  7120. * @returns {(ParseObject|boolean)} true if the set succeeded.
  7121. */
  7122. set(key, value, options) {
  7123. let changes = {};
  7124. const newOps = {};
  7125. if (key && typeof key === 'object') {
  7126. changes = key;
  7127. options = value;
  7128. } else if (typeof key === 'string') {
  7129. changes[key] = value;
  7130. } else {
  7131. return this;
  7132. }
  7133. options = options || {};
  7134. let readonly = [];
  7135. if (typeof this.constructor.readOnlyAttributes === 'function') {
  7136. readonly = (0, _concat.default)(readonly).call(readonly, this.constructor.readOnlyAttributes());
  7137. }
  7138. for (const k in changes) {
  7139. if (k === 'createdAt' || k === 'updatedAt') {
  7140. // This property is read-only, but for legacy reasons we silently
  7141. // ignore it
  7142. continue;
  7143. }
  7144. if ((0, _indexOf.default)(readonly).call(readonly, k) > -1) {
  7145. throw new Error('Cannot modify readonly attribute: ' + k);
  7146. }
  7147. if (options.unset) {
  7148. newOps[k] = new _ParseOp.UnsetOp();
  7149. } else if (changes[k] instanceof _ParseOp.Op) {
  7150. newOps[k] = changes[k];
  7151. } else if (changes[k] && typeof changes[k] === 'object' && typeof changes[k].__op === 'string') {
  7152. newOps[k] = (0, _ParseOp.opFromJSON)(changes[k]);
  7153. } else if (k === 'objectId' || k === 'id') {
  7154. if (typeof changes[k] === 'string') {
  7155. this.id = changes[k];
  7156. }
  7157. } else if (k === 'ACL' && typeof changes[k] === 'object' && !(changes[k] instanceof _ParseACL.default)) {
  7158. newOps[k] = new _ParseOp.SetOp(new _ParseACL.default(changes[k]));
  7159. } else if (changes[k] instanceof _ParseRelation.default) {
  7160. const relation = new _ParseRelation.default(this, k);
  7161. relation.targetClassName = changes[k].targetClassName;
  7162. newOps[k] = new _ParseOp.SetOp(relation);
  7163. } else {
  7164. newOps[k] = new _ParseOp.SetOp(changes[k]);
  7165. }
  7166. }
  7167. const currentAttributes = this.attributes;
  7168. // Calculate new values
  7169. const newValues = {};
  7170. for (const attr in newOps) {
  7171. if (newOps[attr] instanceof _ParseOp.RelationOp) {
  7172. newValues[attr] = newOps[attr].applyTo(currentAttributes[attr], this, attr);
  7173. } else if (!(newOps[attr] instanceof _ParseOp.UnsetOp)) {
  7174. newValues[attr] = newOps[attr].applyTo(currentAttributes[attr]);
  7175. }
  7176. }
  7177. // Validate changes
  7178. if (!options.ignoreValidation) {
  7179. const validation = this.validate(newValues);
  7180. if (validation) {
  7181. if (typeof options.error === 'function') {
  7182. options.error(this, validation);
  7183. }
  7184. return false;
  7185. }
  7186. }
  7187. // Consolidate Ops
  7188. const pendingOps = this._getPendingOps();
  7189. const last = pendingOps.length - 1;
  7190. const stateController = _CoreManager.default.getObjectStateController();
  7191. for (const attr in newOps) {
  7192. const nextOp = newOps[attr].mergeWith(pendingOps[last][attr]);
  7193. stateController.setPendingOp(this._getStateIdentifier(), attr, nextOp);
  7194. }
  7195. return this;
  7196. }
  7197. /**
  7198. * Remove an attribute from the model. This is a noop if the attribute doesn't
  7199. * exist.
  7200. *
  7201. * @param {string} attr The string name of an attribute.
  7202. * @param options
  7203. * @returns {(ParseObject | boolean)}
  7204. */
  7205. unset(attr, options) {
  7206. options = options || {};
  7207. options.unset = true;
  7208. return this.set(attr, null, options);
  7209. }
  7210. /**
  7211. * Atomically increments the value of the given attribute the next time the
  7212. * object is saved. If no amount is specified, 1 is used by default.
  7213. *
  7214. * @param attr {String} The key.
  7215. * @param amount {Number} The amount to increment by (optional).
  7216. * @returns {(ParseObject|boolean)}
  7217. */
  7218. increment(attr, amount) {
  7219. if (typeof amount === 'undefined') {
  7220. amount = 1;
  7221. }
  7222. if (typeof amount !== 'number') {
  7223. throw new Error('Cannot increment by a non-numeric amount.');
  7224. }
  7225. return this.set(attr, new _ParseOp.IncrementOp(amount));
  7226. }
  7227. /**
  7228. * Atomically decrements the value of the given attribute the next time the
  7229. * object is saved. If no amount is specified, 1 is used by default.
  7230. *
  7231. * @param attr {String} The key.
  7232. * @param amount {Number} The amount to decrement by (optional).
  7233. * @returns {(ParseObject | boolean)}
  7234. */
  7235. decrement(attr, amount) {
  7236. if (typeof amount === 'undefined') {
  7237. amount = 1;
  7238. }
  7239. if (typeof amount !== 'number') {
  7240. throw new Error('Cannot decrement by a non-numeric amount.');
  7241. }
  7242. return this.set(attr, new _ParseOp.IncrementOp(amount * -1));
  7243. }
  7244. /**
  7245. * Atomically add an object to the end of the array associated with a given
  7246. * key.
  7247. *
  7248. * @param attr {String} The key.
  7249. * @param item {} The item to add.
  7250. * @returns {(ParseObject | boolean)}
  7251. */
  7252. add(attr, item) {
  7253. return this.set(attr, new _ParseOp.AddOp([item]));
  7254. }
  7255. /**
  7256. * Atomically add the objects to the end of the array associated with a given
  7257. * key.
  7258. *
  7259. * @param attr {String} The key.
  7260. * @param items {Object[]} The items to add.
  7261. * @returns {(ParseObject | boolean)}
  7262. */
  7263. addAll(attr, items) {
  7264. return this.set(attr, new _ParseOp.AddOp(items));
  7265. }
  7266. /**
  7267. * Atomically add an object to the array associated with a given key, only
  7268. * if it is not already present in the array. The position of the insert is
  7269. * not guaranteed.
  7270. *
  7271. * @param attr {String} The key.
  7272. * @param item {} The object to add.
  7273. * @returns {(ParseObject | boolean)}
  7274. */
  7275. addUnique(attr, item) {
  7276. return this.set(attr, new _ParseOp.AddUniqueOp([item]));
  7277. }
  7278. /**
  7279. * Atomically add the objects to the array associated with a given key, only
  7280. * if it is not already present in the array. The position of the insert is
  7281. * not guaranteed.
  7282. *
  7283. * @param attr {String} The key.
  7284. * @param items {Object[]} The objects to add.
  7285. * @returns {(ParseObject | boolean)}
  7286. */
  7287. addAllUnique(attr, items) {
  7288. return this.set(attr, new _ParseOp.AddUniqueOp(items));
  7289. }
  7290. /**
  7291. * Atomically remove all instances of an object from the array associated
  7292. * with a given key.
  7293. *
  7294. * @param attr {String} The key.
  7295. * @param item {} The object to remove.
  7296. * @returns {(ParseObject | boolean)}
  7297. */
  7298. remove(attr, item) {
  7299. return this.set(attr, new _ParseOp.RemoveOp([item]));
  7300. }
  7301. /**
  7302. * Atomically remove all instances of the objects from the array associated
  7303. * with a given key.
  7304. *
  7305. * @param attr {String} The key.
  7306. * @param items {Object[]} The object to remove.
  7307. * @returns {(ParseObject | boolean)}
  7308. */
  7309. removeAll(attr, items) {
  7310. return this.set(attr, new _ParseOp.RemoveOp(items));
  7311. }
  7312. /**
  7313. * Returns an instance of a subclass of Parse.Op describing what kind of
  7314. * modification has been performed on this field since the last time it was
  7315. * saved. For example, after calling object.increment("x"), calling
  7316. * object.op("x") would return an instance of Parse.Op.Increment.
  7317. *
  7318. * @param attr {String} The key.
  7319. * @returns {Parse.Op | undefined} The operation, or undefined if none.
  7320. */
  7321. op(attr) {
  7322. const pending = this._getPendingOps();
  7323. for (let i = pending.length; i--;) {
  7324. if (pending[i][attr]) {
  7325. return pending[i][attr];
  7326. }
  7327. }
  7328. }
  7329. /**
  7330. * Creates a new model with identical attributes to this one.
  7331. *
  7332. * @returns {Parse.Object}
  7333. */
  7334. clone() {
  7335. const clone = new this.constructor(this.className);
  7336. let attributes = this.attributes;
  7337. if (typeof this.constructor.readOnlyAttributes === 'function') {
  7338. const readonly = this.constructor.readOnlyAttributes() || [];
  7339. // Attributes are frozen, so we have to rebuild an object,
  7340. // rather than delete readonly keys
  7341. const copy = {};
  7342. for (const a in attributes) {
  7343. if ((0, _indexOf.default)(readonly).call(readonly, a) < 0) {
  7344. copy[a] = attributes[a];
  7345. }
  7346. }
  7347. attributes = copy;
  7348. }
  7349. if (clone.set) {
  7350. clone.set(attributes);
  7351. }
  7352. return clone;
  7353. }
  7354. /**
  7355. * Creates a new instance of this object. Not to be confused with clone()
  7356. *
  7357. * @returns {Parse.Object}
  7358. */
  7359. newInstance() {
  7360. const clone = new this.constructor(this.className);
  7361. clone.id = this.id;
  7362. if (singleInstance) {
  7363. // Just return an object with the right id
  7364. return clone;
  7365. }
  7366. const stateController = _CoreManager.default.getObjectStateController();
  7367. if (stateController) {
  7368. stateController.duplicateState(this._getStateIdentifier(), clone._getStateIdentifier());
  7369. }
  7370. return clone;
  7371. }
  7372. /**
  7373. * Returns true if this object has never been saved to Parse.
  7374. *
  7375. * @returns {boolean}
  7376. */
  7377. isNew() {
  7378. return !this.id;
  7379. }
  7380. /**
  7381. * Returns true if this object was created by the Parse server when the
  7382. * object might have already been there (e.g. in the case of a Facebook
  7383. * login)
  7384. *
  7385. * @returns {boolean}
  7386. */
  7387. existed() {
  7388. if (!this.id) {
  7389. return false;
  7390. }
  7391. const stateController = _CoreManager.default.getObjectStateController();
  7392. const state = stateController.getState(this._getStateIdentifier());
  7393. if (state) {
  7394. return state.existed;
  7395. }
  7396. return false;
  7397. }
  7398. /**
  7399. * Returns true if this object exists on the Server
  7400. *
  7401. * @param {object} options
  7402. * Valid options are:<ul>
  7403. * <li>useMasterKey: In Cloud Code and Node only, causes the Master Key to
  7404. * be used for this request.
  7405. * <li>sessionToken: A valid session token, used for making a request on
  7406. * behalf of a specific user.
  7407. * </ul>
  7408. * @returns {Promise<boolean>} A boolean promise that is fulfilled if object exists.
  7409. */
  7410. async exists(options) {
  7411. if (!this.id) {
  7412. return false;
  7413. }
  7414. try {
  7415. const ParseQuery = _CoreManager.default.getParseQuery();
  7416. const query = new ParseQuery(this.className);
  7417. await query.get(this.id, options);
  7418. return true;
  7419. } catch (e) {
  7420. if (e.code === _ParseError.default.OBJECT_NOT_FOUND) {
  7421. return false;
  7422. }
  7423. throw e;
  7424. }
  7425. }
  7426. /**
  7427. * Checks if the model is currently in a valid state.
  7428. *
  7429. * @returns {boolean}
  7430. */
  7431. isValid() {
  7432. return !this.validate(this.attributes);
  7433. }
  7434. /**
  7435. * You should not call this function directly unless you subclass
  7436. * <code>Parse.Object</code>, in which case you can override this method
  7437. * to provide additional validation on <code>set</code> and
  7438. * <code>save</code>. Your implementation should return
  7439. *
  7440. * @param {object} attrs The current data to validate.
  7441. * @returns {Parse.Error|boolean} False if the data is valid. An error object otherwise.
  7442. * @see Parse.Object#set
  7443. */
  7444. validate(attrs) {
  7445. if (attrs.hasOwnProperty('ACL') && !(attrs.ACL instanceof _ParseACL.default)) {
  7446. return new _ParseError.default(_ParseError.default.OTHER_CAUSE, 'ACL must be a Parse ACL.');
  7447. }
  7448. for (const key in attrs) {
  7449. if (!/^[A-Za-z][0-9A-Za-z_.]*$/.test(key)) {
  7450. return new _ParseError.default(_ParseError.default.INVALID_KEY_NAME);
  7451. }
  7452. }
  7453. return false;
  7454. }
  7455. /**
  7456. * Returns the ACL for this object.
  7457. *
  7458. * @returns {Parse.ACL|null} An instance of Parse.ACL.
  7459. * @see Parse.Object#get
  7460. */
  7461. getACL() {
  7462. const acl = this.get('ACL');
  7463. if (acl instanceof _ParseACL.default) {
  7464. return acl;
  7465. }
  7466. return null;
  7467. }
  7468. /**
  7469. * Sets the ACL to be used for this object.
  7470. *
  7471. * @param {Parse.ACL} acl An instance of Parse.ACL.
  7472. * @param {object} options
  7473. * @returns {(ParseObject | boolean)} Whether the set passed validation.
  7474. * @see Parse.Object#set
  7475. */
  7476. setACL(acl, options) {
  7477. return this.set('ACL', acl, options);
  7478. }
  7479. /**
  7480. * Clears any (or specific) changes to this object made since the last call to save()
  7481. *
  7482. * @param {string} [keys] - specify which fields to revert
  7483. */
  7484. revert() {
  7485. let keysToRevert;
  7486. for (var _len = arguments.length, keys = new Array(_len), _key = 0; _key < _len; _key++) {
  7487. keys[_key] = arguments[_key];
  7488. }
  7489. if (keys.length) {
  7490. keysToRevert = [];
  7491. for (const key of keys) {
  7492. if (typeof key === 'string') {
  7493. keysToRevert.push(key);
  7494. } else {
  7495. throw new Error('Parse.Object#revert expects either no, or a list of string, arguments.');
  7496. }
  7497. }
  7498. }
  7499. this._clearPendingOps(keysToRevert);
  7500. }
  7501. /**
  7502. * Clears all attributes on a model
  7503. *
  7504. * @returns {(ParseObject | boolean)}
  7505. */
  7506. clear() {
  7507. const attributes = this.attributes;
  7508. const erasable = {};
  7509. let readonly = ['createdAt', 'updatedAt'];
  7510. if (typeof this.constructor.readOnlyAttributes === 'function') {
  7511. readonly = (0, _concat.default)(readonly).call(readonly, this.constructor.readOnlyAttributes());
  7512. }
  7513. for (const attr in attributes) {
  7514. if ((0, _indexOf.default)(readonly).call(readonly, attr) < 0) {
  7515. erasable[attr] = true;
  7516. }
  7517. }
  7518. return this.set(erasable, {
  7519. unset: true
  7520. });
  7521. }
  7522. /**
  7523. * Fetch the model from the server. If the server's representation of the
  7524. * model differs from its current attributes, they will be overriden.
  7525. *
  7526. * @param {object} options
  7527. * Valid options are:<ul>
  7528. * <li>useMasterKey: In Cloud Code and Node only, causes the Master Key to
  7529. * be used for this request.
  7530. * <li>sessionToken: A valid session token, used for making a request on
  7531. * behalf of a specific user.
  7532. * <li>include: The name(s) of the key(s) to include. Can be a string, an array of strings,
  7533. * or an array of array of strings.
  7534. * <li>context: A dictionary that is accessible in Cloud Code `beforeFind` trigger.
  7535. * </ul>
  7536. * @returns {Promise} A promise that is fulfilled when the fetch
  7537. * completes.
  7538. */
  7539. fetch(options) {
  7540. options = options || {};
  7541. const fetchOptions = {};
  7542. if (options.hasOwnProperty('useMasterKey')) {
  7543. fetchOptions.useMasterKey = options.useMasterKey;
  7544. }
  7545. if (options.hasOwnProperty('sessionToken')) {
  7546. fetchOptions.sessionToken = options.sessionToken;
  7547. }
  7548. if (options.hasOwnProperty('context') && typeof options.context === 'object') {
  7549. fetchOptions.context = options.context;
  7550. }
  7551. if (options.hasOwnProperty('include')) {
  7552. fetchOptions.include = [];
  7553. if ((0, _isArray.default)(options.include)) {
  7554. var _context;
  7555. (0, _forEach.default)(_context = options.include).call(_context, key => {
  7556. if ((0, _isArray.default)(key)) {
  7557. var _context2;
  7558. fetchOptions.include = (0, _concat.default)(_context2 = fetchOptions.include).call(_context2, key);
  7559. } else {
  7560. fetchOptions.include.push(key);
  7561. }
  7562. });
  7563. } else {
  7564. fetchOptions.include.push(options.include);
  7565. }
  7566. }
  7567. const controller = _CoreManager.default.getObjectController();
  7568. return controller.fetch(this, true, fetchOptions);
  7569. }
  7570. /**
  7571. * Fetch the model from the server. If the server's representation of the
  7572. * model differs from its current attributes, they will be overriden.
  7573. *
  7574. * Includes nested Parse.Objects for the provided key. You can use dot
  7575. * notation to specify which fields in the included object are also fetched.
  7576. *
  7577. * @param {string | Array<string | Array<string>>} keys The name(s) of the key(s) to include.
  7578. * @param {object} options
  7579. * Valid options are:<ul>
  7580. * <li>useMasterKey: In Cloud Code and Node only, causes the Master Key to
  7581. * be used for this request.
  7582. * <li>sessionToken: A valid session token, used for making a request on
  7583. * behalf of a specific user.
  7584. * </ul>
  7585. * @returns {Promise} A promise that is fulfilled when the fetch
  7586. * completes.
  7587. */
  7588. fetchWithInclude(keys, options) {
  7589. options = options || {};
  7590. options.include = keys;
  7591. return this.fetch(options);
  7592. }
  7593. /**
  7594. * Saves this object to the server at some unspecified time in the future,
  7595. * even if Parse is currently inaccessible.
  7596. *
  7597. * Use this when you may not have a solid network connection, and don't need to know when the save completes.
  7598. * If there is some problem with the object such that it can't be saved, it will be silently discarded.
  7599. *
  7600. * Objects saved with this method will be stored locally in an on-disk cache until they can be delivered to Parse.
  7601. * They will be sent immediately if possible. Otherwise, they will be sent the next time a network connection is
  7602. * available. Objects saved this way will persist even after the app is closed, in which case they will be sent the
  7603. * next time the app is opened.
  7604. *
  7605. * @param {object} [options]
  7606. * Used to pass option parameters to method if arg1 and arg2 were both passed as strings.
  7607. * Valid options are:
  7608. * <ul>
  7609. * <li>sessionToken: A valid session token, used for making a request on
  7610. * behalf of a specific user.
  7611. * <li>cascadeSave: If `false`, nested objects will not be saved (default is `true`).
  7612. * <li>context: A dictionary that is accessible in Cloud Code `beforeSave` and `afterSave` triggers.
  7613. * </ul>
  7614. * @returns {Promise} A promise that is fulfilled when the save
  7615. * completes.
  7616. */
  7617. async saveEventually(options) {
  7618. try {
  7619. await this.save(null, options);
  7620. } catch (e) {
  7621. if (e.code === _ParseError.default.CONNECTION_FAILED) {
  7622. await _CoreManager.default.getEventuallyQueue().save(this, options);
  7623. _CoreManager.default.getEventuallyQueue().poll();
  7624. }
  7625. }
  7626. return this;
  7627. }
  7628. /**
  7629. * Set a hash of model attributes, and save the model to the server.
  7630. * updatedAt will be updated when the request returns.
  7631. * You can either call it as:<pre>
  7632. * object.save();</pre>
  7633. * or<pre>
  7634. * object.save(attrs);</pre>
  7635. * or<pre>
  7636. * object.save(null, options);</pre>
  7637. * or<pre>
  7638. * object.save(attrs, options);</pre>
  7639. * or<pre>
  7640. * object.save(key, value);</pre>
  7641. * or<pre>
  7642. * object.save(key, value, options);</pre>
  7643. *
  7644. * Example 1: <pre>
  7645. * gameTurn.save({
  7646. * player: "Jake Cutter",
  7647. * diceRoll: 2
  7648. * }).then(function(gameTurnAgain) {
  7649. * // The save was successful.
  7650. * }, function(error) {
  7651. * // The save failed. Error is an instance of Parse.Error.
  7652. * });</pre>
  7653. *
  7654. * Example 2: <pre>
  7655. * gameTurn.save("player", "Jake Cutter");</pre>
  7656. *
  7657. * @param {string | object | null} [arg1]
  7658. * Valid options are:<ul>
  7659. * <li>`Object` - Key/value pairs to update on the object.</li>
  7660. * <li>`String` Key - Key of attribute to update (requires arg2 to also be string)</li>
  7661. * <li>`null` - Passing null for arg1 allows you to save the object with options passed in arg2.</li>
  7662. * </ul>
  7663. * @param {string | object} [arg2]
  7664. * <ul>
  7665. * <li>`String` Value - If arg1 was passed as a key, arg2 is the value that should be set on that key.</li>
  7666. * <li>`Object` Options - Valid options are:
  7667. * <ul>
  7668. * <li>useMasterKey: In Cloud Code and Node only, causes the Master Key to
  7669. * be used for this request.
  7670. * <li>sessionToken: A valid session token, used for making a request on
  7671. * behalf of a specific user.
  7672. * <li>cascadeSave: If `false`, nested objects will not be saved (default is `true`).
  7673. * <li>context: A dictionary that is accessible in Cloud Code `beforeSave` and `afterSave` triggers.
  7674. * </ul>
  7675. * </li>
  7676. * </ul>
  7677. * @param {object} [arg3]
  7678. * Used to pass option parameters to method if arg1 and arg2 were both passed as strings.
  7679. * Valid options are:
  7680. * <ul>
  7681. * <li>useMasterKey: In Cloud Code and Node only, causes the Master Key to
  7682. * be used for this request.
  7683. * <li>sessionToken: A valid session token, used for making a request on
  7684. * behalf of a specific user.
  7685. * <li>cascadeSave: If `false`, nested objects will not be saved (default is `true`).
  7686. * <li>context: A dictionary that is accessible in Cloud Code `beforeSave` and `afterSave` triggers.
  7687. * </ul>
  7688. * @returns {Promise} A promise that is fulfilled when the save
  7689. * completes.
  7690. */
  7691. save(arg1, arg2, arg3) {
  7692. let attrs;
  7693. let options;
  7694. if (typeof arg1 === 'object' || typeof arg1 === 'undefined') {
  7695. attrs = arg1;
  7696. if (typeof arg2 === 'object') {
  7697. options = arg2;
  7698. }
  7699. } else {
  7700. attrs = {};
  7701. attrs[arg1] = arg2;
  7702. options = arg3;
  7703. }
  7704. options = options || {};
  7705. if (attrs) {
  7706. let validationError;
  7707. options.error = (_, validation) => {
  7708. validationError = validation;
  7709. };
  7710. const success = this.set(attrs, options);
  7711. if (!success) {
  7712. return _promise.default.reject(validationError);
  7713. }
  7714. }
  7715. const saveOptions = {};
  7716. if (options.hasOwnProperty('useMasterKey')) {
  7717. saveOptions.useMasterKey = !!options.useMasterKey;
  7718. }
  7719. if (options.hasOwnProperty('sessionToken') && typeof options.sessionToken === 'string') {
  7720. saveOptions.sessionToken = options.sessionToken;
  7721. }
  7722. if (options.hasOwnProperty('installationId') && typeof options.installationId === 'string') {
  7723. saveOptions.installationId = options.installationId;
  7724. }
  7725. if (options.hasOwnProperty('context') && typeof options.context === 'object') {
  7726. saveOptions.context = options.context;
  7727. }
  7728. const controller = _CoreManager.default.getObjectController();
  7729. const unsaved = options.cascadeSave !== false ? (0, _unsavedChildren.default)(this) : null;
  7730. return controller.save(unsaved, saveOptions).then(() => {
  7731. return controller.save(this, saveOptions);
  7732. });
  7733. }
  7734. /**
  7735. * Deletes this object from the server at some unspecified time in the future,
  7736. * even if Parse is currently inaccessible.
  7737. *
  7738. * Use this when you may not have a solid network connection,
  7739. * and don't need to know when the delete completes. If there is some problem with the object
  7740. * such that it can't be deleted, the request will be silently discarded.
  7741. *
  7742. * Delete instructions made with this method will be stored locally in an on-disk cache until they can be transmitted
  7743. * to Parse. They will be sent immediately if possible. Otherwise, they will be sent the next time a network connection
  7744. * is available. Delete requests will persist even after the app is closed, in which case they will be sent the
  7745. * next time the app is opened.
  7746. *
  7747. * @param {object} [options]
  7748. * Valid options are:<ul>
  7749. * <li>sessionToken: A valid session token, used for making a request on
  7750. * behalf of a specific user.
  7751. * <li>context: A dictionary that is accessible in Cloud Code `beforeDelete` and `afterDelete` triggers.
  7752. * </ul>
  7753. * @returns {Promise} A promise that is fulfilled when the destroy
  7754. * completes.
  7755. */
  7756. async destroyEventually(options) {
  7757. try {
  7758. await this.destroy(options);
  7759. } catch (e) {
  7760. if (e.code === _ParseError.default.CONNECTION_FAILED) {
  7761. await _CoreManager.default.getEventuallyQueue().destroy(this, options);
  7762. _CoreManager.default.getEventuallyQueue().poll();
  7763. }
  7764. }
  7765. return this;
  7766. }
  7767. /**
  7768. * Destroy this model on the server if it was already persisted.
  7769. *
  7770. * @param {object} options
  7771. * Valid options are:<ul>
  7772. * <li>useMasterKey: In Cloud Code and Node only, causes the Master Key to
  7773. * be used for this request.
  7774. * <li>sessionToken: A valid session token, used for making a request on
  7775. * behalf of a specific user.
  7776. * <li>context: A dictionary that is accessible in Cloud Code `beforeDelete` and `afterDelete` triggers.
  7777. * </ul>
  7778. * @returns {Promise} A promise that is fulfilled when the destroy
  7779. * completes.
  7780. */
  7781. destroy(options) {
  7782. options = options || {};
  7783. const destroyOptions = {};
  7784. if (options.hasOwnProperty('useMasterKey')) {
  7785. destroyOptions.useMasterKey = options.useMasterKey;
  7786. }
  7787. if (options.hasOwnProperty('sessionToken')) {
  7788. destroyOptions.sessionToken = options.sessionToken;
  7789. }
  7790. if (options.hasOwnProperty('context') && typeof options.context === 'object') {
  7791. destroyOptions.context = options.context;
  7792. }
  7793. if (!this.id) {
  7794. return _promise.default.resolve();
  7795. }
  7796. return _CoreManager.default.getObjectController().destroy(this, destroyOptions);
  7797. }
  7798. /**
  7799. * Asynchronously stores the object and every object it points to in the local datastore,
  7800. * recursively, using a default pin name: _default.
  7801. *
  7802. * If those other objects have not been fetched from Parse, they will not be stored.
  7803. * However, if they have changed data, all the changes will be retained.
  7804. *
  7805. * <pre>
  7806. * await object.pin();
  7807. * </pre>
  7808. *
  7809. * To retrieve object:
  7810. * <code>query.fromLocalDatastore()</code> or <code>query.fromPin()</code>
  7811. *
  7812. * @returns {Promise} A promise that is fulfilled when the pin completes.
  7813. */
  7814. pin() {
  7815. return ParseObject.pinAllWithName(_LocalDatastoreUtils.DEFAULT_PIN, [this]);
  7816. }
  7817. /**
  7818. * Asynchronously removes the object and every object it points to in the local datastore,
  7819. * recursively, using a default pin name: _default.
  7820. *
  7821. * <pre>
  7822. * await object.unPin();
  7823. * </pre>
  7824. *
  7825. * @returns {Promise} A promise that is fulfilled when the unPin completes.
  7826. */
  7827. unPin() {
  7828. return ParseObject.unPinAllWithName(_LocalDatastoreUtils.DEFAULT_PIN, [this]);
  7829. }
  7830. /**
  7831. * Asynchronously returns if the object is pinned
  7832. *
  7833. * <pre>
  7834. * const isPinned = await object.isPinned();
  7835. * </pre>
  7836. *
  7837. * @returns {Promise<boolean>} A boolean promise that is fulfilled if object is pinned.
  7838. */
  7839. async isPinned() {
  7840. const localDatastore = _CoreManager.default.getLocalDatastore();
  7841. if (!localDatastore.isEnabled) {
  7842. return _promise.default.reject('Parse.enableLocalDatastore() must be called first');
  7843. }
  7844. const objectKey = localDatastore.getKeyForObject(this);
  7845. const pin = await localDatastore.fromPinWithName(objectKey);
  7846. return pin.length > 0;
  7847. }
  7848. /**
  7849. * Asynchronously stores the objects and every object they point to in the local datastore, recursively.
  7850. *
  7851. * If those other objects have not been fetched from Parse, they will not be stored.
  7852. * However, if they have changed data, all the changes will be retained.
  7853. *
  7854. * <pre>
  7855. * await object.pinWithName(name);
  7856. * </pre>
  7857. *
  7858. * To retrieve object:
  7859. * <code>query.fromLocalDatastore()</code> or <code>query.fromPinWithName(name)</code>
  7860. *
  7861. * @param {string} name Name of Pin.
  7862. * @returns {Promise} A promise that is fulfilled when the pin completes.
  7863. */
  7864. pinWithName(name) {
  7865. return ParseObject.pinAllWithName(name, [this]);
  7866. }
  7867. /**
  7868. * Asynchronously removes the object and every object it points to in the local datastore, recursively.
  7869. *
  7870. * <pre>
  7871. * await object.unPinWithName(name);
  7872. * </pre>
  7873. *
  7874. * @param {string} name Name of Pin.
  7875. * @returns {Promise} A promise that is fulfilled when the unPin completes.
  7876. */
  7877. unPinWithName(name) {
  7878. return ParseObject.unPinAllWithName(name, [this]);
  7879. }
  7880. /**
  7881. * Asynchronously loads data from the local datastore into this object.
  7882. *
  7883. * <pre>
  7884. * await object.fetchFromLocalDatastore();
  7885. * </pre>
  7886. *
  7887. * You can create an unfetched pointer with <code>Parse.Object.createWithoutData()</code>
  7888. * and then call <code>fetchFromLocalDatastore()</code> on it.
  7889. *
  7890. * @returns {Promise} A promise that is fulfilled when the fetch completes.
  7891. */
  7892. async fetchFromLocalDatastore() {
  7893. const localDatastore = _CoreManager.default.getLocalDatastore();
  7894. if (!localDatastore.isEnabled) {
  7895. throw new Error('Parse.enableLocalDatastore() must be called first');
  7896. }
  7897. const objectKey = localDatastore.getKeyForObject(this);
  7898. const pinned = await localDatastore._serializeObject(objectKey);
  7899. if (!pinned) {
  7900. throw new Error('Cannot fetch an unsaved ParseObject');
  7901. }
  7902. const result = ParseObject.fromJSON(pinned);
  7903. this._finishFetch(result.toJSON());
  7904. return this;
  7905. }
  7906. /* Static methods */
  7907. static _clearAllState() {
  7908. const stateController = _CoreManager.default.getObjectStateController();
  7909. stateController.clearAllState();
  7910. }
  7911. /**
  7912. * Fetches the given list of Parse.Object.
  7913. * If any error is encountered, stops and calls the error handler.
  7914. *
  7915. * <pre>
  7916. * Parse.Object.fetchAll([object1, object2, ...])
  7917. * .then((list) => {
  7918. * // All the objects were fetched.
  7919. * }, (error) => {
  7920. * // An error occurred while fetching one of the objects.
  7921. * });
  7922. * </pre>
  7923. *
  7924. * @param {Array} list A list of <code>Parse.Object</code>.
  7925. * @param {object} options
  7926. * Valid options are:<ul>
  7927. * <li>useMasterKey: In Cloud Code and Node only, causes the Master Key to
  7928. * be used for this request.
  7929. * <li>sessionToken: A valid session token, used for making a request on
  7930. * behalf of a specific user.
  7931. * <li>include: The name(s) of the key(s) to include. Can be a string, an array of strings,
  7932. * or an array of array of strings.
  7933. * </ul>
  7934. * @static
  7935. * @returns {Parse.Object[]}
  7936. */
  7937. static fetchAll(list) {
  7938. let options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
  7939. const queryOptions = {};
  7940. if (options.hasOwnProperty('useMasterKey')) {
  7941. queryOptions.useMasterKey = options.useMasterKey;
  7942. }
  7943. if (options.hasOwnProperty('sessionToken')) {
  7944. queryOptions.sessionToken = options.sessionToken;
  7945. }
  7946. if (options.hasOwnProperty('include')) {
  7947. queryOptions.include = ParseObject.handleIncludeOptions(options);
  7948. }
  7949. return _CoreManager.default.getObjectController().fetch(list, true, queryOptions);
  7950. }
  7951. /**
  7952. * Fetches the given list of Parse.Object.
  7953. *
  7954. * Includes nested Parse.Objects for the provided key. You can use dot
  7955. * notation to specify which fields in the included object are also fetched.
  7956. *
  7957. * If any error is encountered, stops and calls the error handler.
  7958. *
  7959. * <pre>
  7960. * Parse.Object.fetchAllWithInclude([object1, object2, ...], [pointer1, pointer2, ...])
  7961. * .then((list) => {
  7962. * // All the objects were fetched.
  7963. * }, (error) => {
  7964. * // An error occurred while fetching one of the objects.
  7965. * });
  7966. * </pre>
  7967. *
  7968. * @param {Array} list A list of <code>Parse.Object</code>.
  7969. * @param {string | Array<string | Array<string>>} keys The name(s) of the key(s) to include.
  7970. * @param {object} options
  7971. * Valid options are:<ul>
  7972. * <li>useMasterKey: In Cloud Code and Node only, causes the Master Key to
  7973. * be used for this request.
  7974. * <li>sessionToken: A valid session token, used for making a request on
  7975. * behalf of a specific user.
  7976. * </ul>
  7977. * @static
  7978. * @returns {Parse.Object[]}
  7979. */
  7980. static fetchAllWithInclude(list, keys, options) {
  7981. options = options || {};
  7982. options.include = keys;
  7983. return ParseObject.fetchAll(list, options);
  7984. }
  7985. /**
  7986. * Fetches the given list of Parse.Object if needed.
  7987. * If any error is encountered, stops and calls the error handler.
  7988. *
  7989. * Includes nested Parse.Objects for the provided key. You can use dot
  7990. * notation to specify which fields in the included object are also fetched.
  7991. *
  7992. * If any error is encountered, stops and calls the error handler.
  7993. *
  7994. * <pre>
  7995. * Parse.Object.fetchAllIfNeededWithInclude([object1, object2, ...], [pointer1, pointer2, ...])
  7996. * .then((list) => {
  7997. * // All the objects were fetched.
  7998. * }, (error) => {
  7999. * // An error occurred while fetching one of the objects.
  8000. * });
  8001. * </pre>
  8002. *
  8003. * @param {Array} list A list of <code>Parse.Object</code>.
  8004. * @param {string | Array<string | Array<string>>} keys The name(s) of the key(s) to include.
  8005. * @param {object} options
  8006. * Valid options are:<ul>
  8007. * <li>useMasterKey: In Cloud Code and Node only, causes the Master Key to
  8008. * be used for this request.
  8009. * <li>sessionToken: A valid session token, used for making a request on
  8010. * behalf of a specific user.
  8011. * </ul>
  8012. * @static
  8013. * @returns {Parse.Object[]}
  8014. */
  8015. static fetchAllIfNeededWithInclude(list, keys, options) {
  8016. options = options || {};
  8017. options.include = keys;
  8018. return ParseObject.fetchAllIfNeeded(list, options);
  8019. }
  8020. /**
  8021. * Fetches the given list of Parse.Object if needed.
  8022. * If any error is encountered, stops and calls the error handler.
  8023. *
  8024. * <pre>
  8025. * Parse.Object.fetchAllIfNeeded([object1, ...])
  8026. * .then((list) => {
  8027. * // Objects were fetched and updated.
  8028. * }, (error) => {
  8029. * // An error occurred while fetching one of the objects.
  8030. * });
  8031. * </pre>
  8032. *
  8033. * @param {Array} list A list of <code>Parse.Object</code>.
  8034. * @param {object} options
  8035. * @static
  8036. * @returns {Parse.Object[]}
  8037. */
  8038. static fetchAllIfNeeded(list, options) {
  8039. options = options || {};
  8040. const queryOptions = {};
  8041. if (options.hasOwnProperty('useMasterKey')) {
  8042. queryOptions.useMasterKey = options.useMasterKey;
  8043. }
  8044. if (options.hasOwnProperty('sessionToken')) {
  8045. queryOptions.sessionToken = options.sessionToken;
  8046. }
  8047. if (options.hasOwnProperty('include')) {
  8048. queryOptions.include = ParseObject.handleIncludeOptions(options);
  8049. }
  8050. return _CoreManager.default.getObjectController().fetch(list, false, queryOptions);
  8051. }
  8052. static handleIncludeOptions(options) {
  8053. let include = [];
  8054. if ((0, _isArray.default)(options.include)) {
  8055. var _context3;
  8056. (0, _forEach.default)(_context3 = options.include).call(_context3, key => {
  8057. if ((0, _isArray.default)(key)) {
  8058. include = (0, _concat.default)(include).call(include, key);
  8059. } else {
  8060. include.push(key);
  8061. }
  8062. });
  8063. } else {
  8064. include.push(options.include);
  8065. }
  8066. return include;
  8067. }
  8068. /**
  8069. * Destroy the given list of models on the server if it was already persisted.
  8070. *
  8071. * <p>Unlike saveAll, if an error occurs while deleting an individual model,
  8072. * this method will continue trying to delete the rest of the models if
  8073. * possible, except in the case of a fatal error like a connection error.
  8074. *
  8075. * <p>In particular, the Parse.Error object returned in the case of error may
  8076. * be one of two types:
  8077. *
  8078. * <ul>
  8079. * <li>A Parse.Error.AGGREGATE_ERROR. This object's "errors" property is an
  8080. * array of other Parse.Error objects. Each error object in this array
  8081. * has an "object" property that references the object that could not be
  8082. * deleted (for instance, because that object could not be found).</li>
  8083. * <li>A non-aggregate Parse.Error. This indicates a serious error that
  8084. * caused the delete operation to be aborted partway through (for
  8085. * instance, a connection failure in the middle of the delete).</li>
  8086. * </ul>
  8087. *
  8088. * <pre>
  8089. * Parse.Object.destroyAll([object1, object2, ...])
  8090. * .then((list) => {
  8091. * // All the objects were deleted.
  8092. * }, (error) => {
  8093. * // An error occurred while deleting one or more of the objects.
  8094. * // If this is an aggregate error, then we can inspect each error
  8095. * // object individually to determine the reason why a particular
  8096. * // object was not deleted.
  8097. * if (error.code === Parse.Error.AGGREGATE_ERROR) {
  8098. * for (var i = 0; i < error.errors.length; i++) {
  8099. * console.log("Couldn't delete " + error.errors[i].object.id +
  8100. * "due to " + error.errors[i].message);
  8101. * }
  8102. * } else {
  8103. * console.log("Delete aborted because of " + error.message);
  8104. * }
  8105. * });
  8106. * </pre>
  8107. *
  8108. * @param {Array} list A list of <code>Parse.Object</code>.
  8109. * @param {object} options
  8110. * @static
  8111. * @returns {Promise} A promise that is fulfilled when the destroyAll
  8112. * completes.
  8113. */
  8114. static destroyAll(list) {
  8115. let options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
  8116. const destroyOptions = {};
  8117. if (options.hasOwnProperty('useMasterKey')) {
  8118. destroyOptions.useMasterKey = options.useMasterKey;
  8119. }
  8120. if (options.hasOwnProperty('sessionToken')) {
  8121. destroyOptions.sessionToken = options.sessionToken;
  8122. }
  8123. if (options.hasOwnProperty('batchSize') && typeof options.batchSize === 'number') {
  8124. destroyOptions.batchSize = options.batchSize;
  8125. }
  8126. if (options.hasOwnProperty('context') && typeof options.context === 'object') {
  8127. destroyOptions.context = options.context;
  8128. }
  8129. return _CoreManager.default.getObjectController().destroy(list, destroyOptions);
  8130. }
  8131. /**
  8132. * Saves the given list of Parse.Object.
  8133. * If any error is encountered, stops and calls the error handler.
  8134. *
  8135. * <pre>
  8136. * Parse.Object.saveAll([object1, object2, ...])
  8137. * .then((list) => {
  8138. * // All the objects were saved.
  8139. * }, (error) => {
  8140. * // An error occurred while saving one of the objects.
  8141. * });
  8142. * </pre>
  8143. *
  8144. * @param {Array} list A list of <code>Parse.Object</code>.
  8145. * @param {object} options
  8146. * @static
  8147. * @returns {Parse.Object[]}
  8148. */
  8149. static saveAll(list) {
  8150. let options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
  8151. const saveOptions = {};
  8152. if (options.hasOwnProperty('useMasterKey')) {
  8153. saveOptions.useMasterKey = options.useMasterKey;
  8154. }
  8155. if (options.hasOwnProperty('sessionToken')) {
  8156. saveOptions.sessionToken = options.sessionToken;
  8157. }
  8158. if (options.hasOwnProperty('batchSize') && typeof options.batchSize === 'number') {
  8159. saveOptions.batchSize = options.batchSize;
  8160. }
  8161. if (options.hasOwnProperty('context') && typeof options.context === 'object') {
  8162. saveOptions.context = options.context;
  8163. }
  8164. return _CoreManager.default.getObjectController().save(list, saveOptions);
  8165. }
  8166. /**
  8167. * Creates a reference to a subclass of Parse.Object with the given id. This
  8168. * does not exist on Parse.Object, only on subclasses.
  8169. *
  8170. * <p>A shortcut for: <pre>
  8171. * var Foo = Parse.Object.extend("Foo");
  8172. * var pointerToFoo = new Foo();
  8173. * pointerToFoo.id = "myObjectId";
  8174. * </pre>
  8175. *
  8176. * @param {string} id The ID of the object to create a reference to.
  8177. * @static
  8178. * @returns {Parse.Object} A Parse.Object reference.
  8179. */
  8180. static createWithoutData(id) {
  8181. const obj = new this();
  8182. obj.id = id;
  8183. return obj;
  8184. }
  8185. /**
  8186. * Creates a new instance of a Parse Object from a JSON representation.
  8187. *
  8188. * @param {object} json The JSON map of the Object's data
  8189. * @param {boolean} override In single instance mode, all old server data
  8190. * is overwritten if this is set to true
  8191. * @param {boolean} dirty Whether the Parse.Object should set JSON keys to dirty
  8192. * @static
  8193. * @returns {Parse.Object} A Parse.Object reference
  8194. */
  8195. static fromJSON(json, override, dirty) {
  8196. if (!json.className) {
  8197. throw new Error('Cannot create an object without a className');
  8198. }
  8199. const constructor = classMap[json.className];
  8200. const o = constructor ? new constructor(json.className) : new ParseObject(json.className);
  8201. const otherAttributes = {};
  8202. for (const attr in json) {
  8203. if (attr !== 'className' && attr !== '__type') {
  8204. otherAttributes[attr] = json[attr];
  8205. if (dirty) {
  8206. o.set(attr, json[attr]);
  8207. }
  8208. }
  8209. }
  8210. if (override) {
  8211. // id needs to be set before clearServerData can work
  8212. if (otherAttributes.objectId) {
  8213. o.id = otherAttributes.objectId;
  8214. }
  8215. let preserved = null;
  8216. if (typeof o._preserveFieldsOnFetch === 'function') {
  8217. preserved = o._preserveFieldsOnFetch();
  8218. }
  8219. o._clearServerData();
  8220. if (preserved) {
  8221. o._finishFetch(preserved);
  8222. }
  8223. }
  8224. o._finishFetch(otherAttributes);
  8225. if (json.objectId) {
  8226. o._setExisted(true);
  8227. }
  8228. return o;
  8229. }
  8230. /**
  8231. * Registers a subclass of Parse.Object with a specific class name.
  8232. * When objects of that class are retrieved from a query, they will be
  8233. * instantiated with this subclass.
  8234. * This is only necessary when using ES6 subclassing.
  8235. *
  8236. * @param {string} className The class name of the subclass
  8237. * @param {Function} constructor The subclass
  8238. */
  8239. static registerSubclass(className, constructor) {
  8240. if (typeof className !== 'string') {
  8241. throw new TypeError('The first argument must be a valid class name.');
  8242. }
  8243. if (typeof constructor === 'undefined') {
  8244. throw new TypeError('You must supply a subclass constructor.');
  8245. }
  8246. if (typeof constructor !== 'function') {
  8247. throw new TypeError('You must register the subclass constructor. ' + 'Did you attempt to register an instance of the subclass?');
  8248. }
  8249. classMap[className] = constructor;
  8250. if (!constructor.className) {
  8251. constructor.className = className;
  8252. }
  8253. }
  8254. /**
  8255. * Unegisters a subclass of Parse.Object with a specific class name.
  8256. *
  8257. * @param {string} className The class name of the subclass
  8258. */
  8259. static unregisterSubclass(className) {
  8260. if (typeof className !== 'string') {
  8261. throw new TypeError('The first argument must be a valid class name.');
  8262. }
  8263. delete classMap[className];
  8264. }
  8265. /**
  8266. * Creates a new subclass of Parse.Object for the given Parse class name.
  8267. *
  8268. * <p>Every extension of a Parse class will inherit from the most recent
  8269. * previous extension of that class. When a Parse.Object is automatically
  8270. * created by parsing JSON, it will use the most recent extension of that
  8271. * class.</p>
  8272. *
  8273. * <p>You should call either:<pre>
  8274. * var MyClass = Parse.Object.extend("MyClass", {
  8275. * <i>Instance methods</i>,
  8276. * initialize: function(attrs, options) {
  8277. * this.someInstanceProperty = [],
  8278. * <i>Other instance properties</i>
  8279. * }
  8280. * }, {
  8281. * <i>Class properties</i>
  8282. * });</pre>
  8283. * or, for Backbone compatibility:<pre>
  8284. * var MyClass = Parse.Object.extend({
  8285. * className: "MyClass",
  8286. * <i>Instance methods</i>,
  8287. * initialize: function(attrs, options) {
  8288. * this.someInstanceProperty = [],
  8289. * <i>Other instance properties</i>
  8290. * }
  8291. * }, {
  8292. * <i>Class properties</i>
  8293. * });</pre></p>
  8294. *
  8295. * @param {string} className The name of the Parse class backing this model.
  8296. * @param {object} [protoProps] Instance properties to add to instances of the
  8297. * class returned from this method.
  8298. * @param {object} [classProps] Class properties to add the class returned from
  8299. * this method.
  8300. * @returns {Parse.Object} A new subclass of Parse.Object.
  8301. */
  8302. static extend(className, protoProps, classProps) {
  8303. if (typeof className !== 'string') {
  8304. if (className && typeof className.className === 'string') {
  8305. return ParseObject.extend(className.className, className, protoProps);
  8306. } else {
  8307. throw new Error("Parse.Object.extend's first argument should be the className.");
  8308. }
  8309. }
  8310. let adjustedClassName = className;
  8311. if (adjustedClassName === 'User' && _CoreManager.default.get('PERFORM_USER_REWRITE')) {
  8312. adjustedClassName = '_User';
  8313. }
  8314. let parentProto = ParseObject.prototype;
  8315. if (this.hasOwnProperty('__super__') && this.__super__) {
  8316. parentProto = this.prototype;
  8317. }
  8318. let ParseObjectSubclass = function (attributes, options) {
  8319. this.className = adjustedClassName;
  8320. this._objCount = objectCount++;
  8321. // Enable legacy initializers
  8322. if (typeof this.initialize === 'function') {
  8323. this.initialize.apply(this, arguments);
  8324. }
  8325. if (this._initializers) {
  8326. for (const initializer of this._initializers) {
  8327. initializer.apply(this, arguments);
  8328. }
  8329. }
  8330. if (attributes && typeof attributes === 'object') {
  8331. if (!this.set(attributes || {}, options)) {
  8332. throw new Error("Can't create an invalid Parse Object");
  8333. }
  8334. }
  8335. };
  8336. if (classMap[adjustedClassName]) {
  8337. ParseObjectSubclass = classMap[adjustedClassName];
  8338. } else {
  8339. ParseObjectSubclass.extend = function (name, protoProps, classProps) {
  8340. if (typeof name === 'string') {
  8341. return ParseObject.extend.call(ParseObjectSubclass, name, protoProps, classProps);
  8342. }
  8343. return ParseObject.extend.call(ParseObjectSubclass, adjustedClassName, name, protoProps);
  8344. };
  8345. ParseObjectSubclass.createWithoutData = ParseObject.createWithoutData;
  8346. ParseObjectSubclass.className = adjustedClassName;
  8347. ParseObjectSubclass.__super__ = parentProto;
  8348. ParseObjectSubclass.prototype = (0, _create.default)(parentProto, {
  8349. constructor: {
  8350. value: ParseObjectSubclass,
  8351. enumerable: false,
  8352. writable: true,
  8353. configurable: true
  8354. }
  8355. });
  8356. }
  8357. if (protoProps) {
  8358. for (const prop in protoProps) {
  8359. if (prop === 'initialize') {
  8360. (0, _defineProperty3.default)(ParseObjectSubclass.prototype, '_initializers', {
  8361. value: [...(ParseObjectSubclass.prototype._initializers || []), protoProps[prop]],
  8362. enumerable: false,
  8363. writable: true,
  8364. configurable: true
  8365. });
  8366. continue;
  8367. }
  8368. if (prop !== 'className') {
  8369. (0, _defineProperty3.default)(ParseObjectSubclass.prototype, prop, {
  8370. value: protoProps[prop],
  8371. enumerable: false,
  8372. writable: true,
  8373. configurable: true
  8374. });
  8375. }
  8376. }
  8377. }
  8378. if (classProps) {
  8379. for (const prop in classProps) {
  8380. if (prop !== 'className') {
  8381. (0, _defineProperty3.default)(ParseObjectSubclass, prop, {
  8382. value: classProps[prop],
  8383. enumerable: false,
  8384. writable: true,
  8385. configurable: true
  8386. });
  8387. }
  8388. }
  8389. }
  8390. classMap[adjustedClassName] = ParseObjectSubclass;
  8391. return ParseObjectSubclass;
  8392. }
  8393. /**
  8394. * Enable single instance objects, where any local objects with the same Id
  8395. * share the same attributes, and stay synchronized with each other.
  8396. * This is disabled by default in server environments, since it can lead to
  8397. * security issues.
  8398. *
  8399. * @static
  8400. */
  8401. static enableSingleInstance() {
  8402. singleInstance = true;
  8403. _CoreManager.default.setObjectStateController(SingleInstanceStateController);
  8404. }
  8405. /**
  8406. * Disable single instance objects, where any local objects with the same Id
  8407. * share the same attributes, and stay synchronized with each other.
  8408. * When disabled, you can have two instances of the same object in memory
  8409. * without them sharing attributes.
  8410. *
  8411. * @static
  8412. */
  8413. static disableSingleInstance() {
  8414. singleInstance = false;
  8415. _CoreManager.default.setObjectStateController(UniqueInstanceStateController);
  8416. }
  8417. /**
  8418. * Asynchronously stores the objects and every object they point to in the local datastore,
  8419. * recursively, using a default pin name: _default.
  8420. *
  8421. * If those other objects have not been fetched from Parse, they will not be stored.
  8422. * However, if they have changed data, all the changes will be retained.
  8423. *
  8424. * <pre>
  8425. * await Parse.Object.pinAll([...]);
  8426. * </pre>
  8427. *
  8428. * To retrieve object:
  8429. * <code>query.fromLocalDatastore()</code> or <code>query.fromPin()</code>
  8430. *
  8431. * @param {Array} objects A list of <code>Parse.Object</code>.
  8432. * @returns {Promise} A promise that is fulfilled when the pin completes.
  8433. * @static
  8434. */
  8435. static pinAll(objects) {
  8436. const localDatastore = _CoreManager.default.getLocalDatastore();
  8437. if (!localDatastore.isEnabled) {
  8438. return _promise.default.reject('Parse.enableLocalDatastore() must be called first');
  8439. }
  8440. return ParseObject.pinAllWithName(_LocalDatastoreUtils.DEFAULT_PIN, objects);
  8441. }
  8442. /**
  8443. * Asynchronously stores the objects and every object they point to in the local datastore, recursively.
  8444. *
  8445. * If those other objects have not been fetched from Parse, they will not be stored.
  8446. * However, if they have changed data, all the changes will be retained.
  8447. *
  8448. * <pre>
  8449. * await Parse.Object.pinAllWithName(name, [obj1, obj2, ...]);
  8450. * </pre>
  8451. *
  8452. * To retrieve object:
  8453. * <code>query.fromLocalDatastore()</code> or <code>query.fromPinWithName(name)</code>
  8454. *
  8455. * @param {string} name Name of Pin.
  8456. * @param {Array} objects A list of <code>Parse.Object</code>.
  8457. * @returns {Promise} A promise that is fulfilled when the pin completes.
  8458. * @static
  8459. */
  8460. static pinAllWithName(name, objects) {
  8461. const localDatastore = _CoreManager.default.getLocalDatastore();
  8462. if (!localDatastore.isEnabled) {
  8463. return _promise.default.reject('Parse.enableLocalDatastore() must be called first');
  8464. }
  8465. return localDatastore._handlePinAllWithName(name, objects);
  8466. }
  8467. /**
  8468. * Asynchronously removes the objects and every object they point to in the local datastore,
  8469. * recursively, using a default pin name: _default.
  8470. *
  8471. * <pre>
  8472. * await Parse.Object.unPinAll([...]);
  8473. * </pre>
  8474. *
  8475. * @param {Array} objects A list of <code>Parse.Object</code>.
  8476. * @returns {Promise} A promise that is fulfilled when the unPin completes.
  8477. * @static
  8478. */
  8479. static unPinAll(objects) {
  8480. const localDatastore = _CoreManager.default.getLocalDatastore();
  8481. if (!localDatastore.isEnabled) {
  8482. return _promise.default.reject('Parse.enableLocalDatastore() must be called first');
  8483. }
  8484. return ParseObject.unPinAllWithName(_LocalDatastoreUtils.DEFAULT_PIN, objects);
  8485. }
  8486. /**
  8487. * Asynchronously removes the objects and every object they point to in the local datastore, recursively.
  8488. *
  8489. * <pre>
  8490. * await Parse.Object.unPinAllWithName(name, [obj1, obj2, ...]);
  8491. * </pre>
  8492. *
  8493. * @param {string} name Name of Pin.
  8494. * @param {Array} objects A list of <code>Parse.Object</code>.
  8495. * @returns {Promise} A promise that is fulfilled when the unPin completes.
  8496. * @static
  8497. */
  8498. static unPinAllWithName(name, objects) {
  8499. const localDatastore = _CoreManager.default.getLocalDatastore();
  8500. if (!localDatastore.isEnabled) {
  8501. return _promise.default.reject('Parse.enableLocalDatastore() must be called first');
  8502. }
  8503. return localDatastore._handleUnPinAllWithName(name, objects);
  8504. }
  8505. /**
  8506. * Asynchronously removes all objects in the local datastore using a default pin name: _default.
  8507. *
  8508. * <pre>
  8509. * await Parse.Object.unPinAllObjects();
  8510. * </pre>
  8511. *
  8512. * @returns {Promise} A promise that is fulfilled when the unPin completes.
  8513. * @static
  8514. */
  8515. static unPinAllObjects() {
  8516. const localDatastore = _CoreManager.default.getLocalDatastore();
  8517. if (!localDatastore.isEnabled) {
  8518. return _promise.default.reject('Parse.enableLocalDatastore() must be called first');
  8519. }
  8520. return localDatastore.unPinWithName(_LocalDatastoreUtils.DEFAULT_PIN);
  8521. }
  8522. /**
  8523. * Asynchronously removes all objects with the specified pin name.
  8524. * Deletes the pin name also.
  8525. *
  8526. * <pre>
  8527. * await Parse.Object.unPinAllObjectsWithName(name);
  8528. * </pre>
  8529. *
  8530. * @param {string} name Name of Pin.
  8531. * @returns {Promise} A promise that is fulfilled when the unPin completes.
  8532. * @static
  8533. */
  8534. static unPinAllObjectsWithName(name) {
  8535. const localDatastore = _CoreManager.default.getLocalDatastore();
  8536. if (!localDatastore.isEnabled) {
  8537. return _promise.default.reject('Parse.enableLocalDatastore() must be called first');
  8538. }
  8539. return localDatastore.unPinWithName(_LocalDatastoreUtils.PIN_PREFIX + name);
  8540. }
  8541. }
  8542. const DefaultController = {
  8543. fetch(target, forceFetch, options) {
  8544. const localDatastore = _CoreManager.default.getLocalDatastore();
  8545. if ((0, _isArray.default)(target)) {
  8546. if (target.length < 1) {
  8547. return _promise.default.resolve([]);
  8548. }
  8549. const objs = [];
  8550. const ids = [];
  8551. let className = null;
  8552. const results = [];
  8553. let error = null;
  8554. (0, _forEach.default)(target).call(target, el => {
  8555. if (error) {
  8556. return;
  8557. }
  8558. if (!className) {
  8559. className = el.className;
  8560. }
  8561. if (className !== el.className) {
  8562. error = new _ParseError.default(_ParseError.default.INVALID_CLASS_NAME, 'All objects should be of the same class');
  8563. }
  8564. if (!el.id) {
  8565. error = new _ParseError.default(_ParseError.default.MISSING_OBJECT_ID, 'All objects must have an ID');
  8566. }
  8567. if (forceFetch || !el.isDataAvailable()) {
  8568. ids.push(el.id);
  8569. objs.push(el);
  8570. }
  8571. results.push(el);
  8572. });
  8573. if (error) {
  8574. return _promise.default.reject(error);
  8575. }
  8576. const ParseQuery = _CoreManager.default.getParseQuery();
  8577. const query = new ParseQuery(className);
  8578. query.containedIn('objectId', ids);
  8579. if (options && options.include) {
  8580. query.include(options.include);
  8581. }
  8582. query._limit = ids.length;
  8583. return (0, _find.default)(query).call(query, options).then(async objects => {
  8584. const idMap = {};
  8585. (0, _forEach.default)(objects).call(objects, o => {
  8586. idMap[o.id] = o;
  8587. });
  8588. for (let i = 0; i < objs.length; i++) {
  8589. const obj = objs[i];
  8590. if (!obj || !obj.id || !idMap[obj.id]) {
  8591. if (forceFetch) {
  8592. return _promise.default.reject(new _ParseError.default(_ParseError.default.OBJECT_NOT_FOUND, 'All objects must exist on the server.'));
  8593. }
  8594. }
  8595. }
  8596. if (!singleInstance) {
  8597. // If single instance objects are disabled, we need to replace the
  8598. for (let i = 0; i < results.length; i++) {
  8599. const obj = results[i];
  8600. if (obj && obj.id && idMap[obj.id]) {
  8601. const id = obj.id;
  8602. obj._finishFetch(idMap[id].toJSON());
  8603. results[i] = idMap[id];
  8604. }
  8605. }
  8606. }
  8607. for (const object of results) {
  8608. await localDatastore._updateObjectIfPinned(object);
  8609. }
  8610. return _promise.default.resolve(results);
  8611. });
  8612. } else if (target instanceof ParseObject) {
  8613. if (!target.id) {
  8614. return _promise.default.reject(new _ParseError.default(_ParseError.default.MISSING_OBJECT_ID, 'Object does not have an ID'));
  8615. }
  8616. const RESTController = _CoreManager.default.getRESTController();
  8617. const params = {};
  8618. if (options && options.include) {
  8619. params.include = options.include.join();
  8620. }
  8621. return RESTController.request('GET', 'classes/' + target.className + '/' + target._getId(), params, options).then(async response => {
  8622. target._clearPendingOps();
  8623. target._clearServerData();
  8624. target._finishFetch(response);
  8625. await localDatastore._updateObjectIfPinned(target);
  8626. return target;
  8627. });
  8628. }
  8629. return _promise.default.resolve(undefined);
  8630. },
  8631. async destroy(target, options) {
  8632. const batchSize = options && options.batchSize ? options.batchSize : _CoreManager.default.get('REQUEST_BATCH_SIZE');
  8633. const localDatastore = _CoreManager.default.getLocalDatastore();
  8634. const RESTController = _CoreManager.default.getRESTController();
  8635. if ((0, _isArray.default)(target)) {
  8636. if (target.length < 1) {
  8637. return _promise.default.resolve([]);
  8638. }
  8639. const batches = [[]];
  8640. (0, _forEach.default)(target).call(target, obj => {
  8641. if (!obj.id) {
  8642. return;
  8643. }
  8644. batches[batches.length - 1].push(obj);
  8645. if (batches[batches.length - 1].length >= batchSize) {
  8646. batches.push([]);
  8647. }
  8648. });
  8649. if (batches[batches.length - 1].length === 0) {
  8650. // If the last batch is empty, remove it
  8651. batches.pop();
  8652. }
  8653. let deleteCompleted = _promise.default.resolve();
  8654. const errors = [];
  8655. (0, _forEach.default)(batches).call(batches, batch => {
  8656. deleteCompleted = deleteCompleted.then(() => {
  8657. return RESTController.request('POST', 'batch', {
  8658. requests: (0, _map.default)(batch).call(batch, obj => {
  8659. return {
  8660. method: 'DELETE',
  8661. path: getServerUrlPath() + 'classes/' + obj.className + '/' + obj._getId(),
  8662. body: {}
  8663. };
  8664. })
  8665. }, options).then(results => {
  8666. for (let i = 0; i < results.length; i++) {
  8667. if (results[i] && results[i].hasOwnProperty('error')) {
  8668. const err = new _ParseError.default(results[i].error.code, results[i].error.error);
  8669. err.object = batch[i];
  8670. errors.push(err);
  8671. }
  8672. }
  8673. });
  8674. });
  8675. });
  8676. return deleteCompleted.then(async () => {
  8677. if (errors.length) {
  8678. const aggregate = new _ParseError.default(_ParseError.default.AGGREGATE_ERROR);
  8679. aggregate.errors = errors;
  8680. return _promise.default.reject(aggregate);
  8681. }
  8682. for (const object of target) {
  8683. await localDatastore._destroyObjectIfPinned(object);
  8684. }
  8685. return _promise.default.resolve(target);
  8686. });
  8687. } else if (target instanceof ParseObject) {
  8688. return RESTController.request('DELETE', 'classes/' + target.className + '/' + target._getId(), {}, options).then(async () => {
  8689. await localDatastore._destroyObjectIfPinned(target);
  8690. return _promise.default.resolve(target);
  8691. });
  8692. }
  8693. return _promise.default.resolve(target);
  8694. },
  8695. save(target, options) {
  8696. const batchSize = options && options.batchSize ? options.batchSize : _CoreManager.default.get('REQUEST_BATCH_SIZE');
  8697. const localDatastore = _CoreManager.default.getLocalDatastore();
  8698. const mapIdForPin = {};
  8699. const RESTController = _CoreManager.default.getRESTController();
  8700. const stateController = _CoreManager.default.getObjectStateController();
  8701. const allowCustomObjectId = _CoreManager.default.get('ALLOW_CUSTOM_OBJECT_ID');
  8702. options = options || {};
  8703. options.returnStatus = options.returnStatus || true;
  8704. if ((0, _isArray.default)(target)) {
  8705. if (target.length < 1) {
  8706. return _promise.default.resolve([]);
  8707. }
  8708. let unsaved = (0, _concat.default)(target).call(target);
  8709. for (let i = 0; i < target.length; i++) {
  8710. const target_i = target[i];
  8711. if (target_i instanceof ParseObject) {
  8712. unsaved = (0, _concat.default)(unsaved).call(unsaved, (0, _unsavedChildren.default)(target_i, true));
  8713. }
  8714. }
  8715. unsaved = (0, _unique.default)(unsaved);
  8716. const filesSaved = [];
  8717. let pending = [];
  8718. (0, _forEach.default)(unsaved).call(unsaved, el => {
  8719. if (el instanceof _ParseFile.default) {
  8720. filesSaved.push(el.save(options));
  8721. } else if (el instanceof ParseObject) {
  8722. pending.push(el);
  8723. }
  8724. });
  8725. return _promise.default.all(filesSaved).then(() => {
  8726. let objectError = null;
  8727. return (0, _promiseUtils.continueWhile)(() => {
  8728. return pending.length > 0;
  8729. }, () => {
  8730. const batch = [];
  8731. const nextPending = [];
  8732. (0, _forEach.default)(pending).call(pending, el => {
  8733. if (allowCustomObjectId && Object.prototype.hasOwnProperty.call(el, 'id') && !el.id) {
  8734. throw new _ParseError.default(_ParseError.default.MISSING_OBJECT_ID, 'objectId must not be empty or null');
  8735. }
  8736. if (batch.length < batchSize && (0, _canBeSerialized.default)(el)) {
  8737. batch.push(el);
  8738. } else {
  8739. nextPending.push(el);
  8740. }
  8741. });
  8742. pending = nextPending;
  8743. if (batch.length < 1) {
  8744. return _promise.default.reject(new _ParseError.default(_ParseError.default.OTHER_CAUSE, 'Tried to save a batch with a cycle.'));
  8745. }
  8746. // Queue up tasks for each object in the batch.
  8747. // When every task is ready, the API request will execute
  8748. const batchReturned = (0, _promiseUtils.resolvingPromise)();
  8749. const batchReady = [];
  8750. const batchTasks = [];
  8751. (0, _forEach.default)(batch).call(batch, (obj, index) => {
  8752. const ready = (0, _promiseUtils.resolvingPromise)();
  8753. batchReady.push(ready);
  8754. stateController.pushPendingState(obj._getStateIdentifier());
  8755. batchTasks.push(stateController.enqueueTask(obj._getStateIdentifier(), function () {
  8756. ready.resolve();
  8757. return batchReturned.then(responses => {
  8758. if (responses[index].hasOwnProperty('success')) {
  8759. const objectId = responses[index].success.objectId;
  8760. const status = responses[index]._status;
  8761. delete responses[index]._status;
  8762. delete responses[index]._headers;
  8763. delete responses[index]._xhr;
  8764. mapIdForPin[objectId] = obj._localId;
  8765. obj._handleSaveResponse(responses[index].success, status);
  8766. } else {
  8767. if (!objectError && responses[index].hasOwnProperty('error')) {
  8768. const serverError = responses[index].error;
  8769. objectError = new _ParseError.default(serverError.code, serverError.error);
  8770. // Cancel the rest of the save
  8771. pending = [];
  8772. }
  8773. obj._handleSaveError();
  8774. }
  8775. });
  8776. }));
  8777. });
  8778. (0, _promiseUtils.when)(batchReady).then(() => {
  8779. // Kick off the batch request
  8780. return RESTController.request('POST', 'batch', {
  8781. requests: (0, _map.default)(batch).call(batch, obj => {
  8782. const params = obj._getSaveParams();
  8783. params.path = getServerUrlPath() + params.path;
  8784. return params;
  8785. })
  8786. }, options);
  8787. }).then(batchReturned.resolve, error => {
  8788. batchReturned.reject(new _ParseError.default(_ParseError.default.INCORRECT_TYPE, error.message));
  8789. });
  8790. return (0, _promiseUtils.when)(batchTasks);
  8791. }).then(async () => {
  8792. if (objectError) {
  8793. return _promise.default.reject(objectError);
  8794. }
  8795. for (const object of target) {
  8796. // Make sure that it is a ParseObject before updating it into the localDataStore
  8797. if (object instanceof ParseObject) {
  8798. await localDatastore._updateLocalIdForObject(mapIdForPin[object.id], object);
  8799. await localDatastore._updateObjectIfPinned(object);
  8800. }
  8801. }
  8802. return _promise.default.resolve(target);
  8803. });
  8804. });
  8805. } else if (target instanceof ParseObject) {
  8806. if (allowCustomObjectId && Object.prototype.hasOwnProperty.call(target, 'id') && !target.id) {
  8807. throw new _ParseError.default(_ParseError.default.MISSING_OBJECT_ID, 'objectId must not be empty or null');
  8808. }
  8809. // generate _localId in case if cascadeSave=false
  8810. target._getId();
  8811. const localId = target._localId;
  8812. // copying target lets guarantee the pointer isn't modified elsewhere
  8813. const targetCopy = target;
  8814. const task = function () {
  8815. const params = targetCopy._getSaveParams();
  8816. return RESTController.request(params.method, params.path, params.body, options).then(response => {
  8817. const status = response._status;
  8818. delete response._status;
  8819. delete response._headers;
  8820. delete response._xhr;
  8821. targetCopy._handleSaveResponse(response, status);
  8822. }, error => {
  8823. targetCopy._handleSaveError();
  8824. return _promise.default.reject(error);
  8825. });
  8826. };
  8827. stateController.pushPendingState(target._getStateIdentifier());
  8828. return stateController.enqueueTask(target._getStateIdentifier(), task).then(async () => {
  8829. await localDatastore._updateLocalIdForObject(localId, target);
  8830. await localDatastore._updateObjectIfPinned(target);
  8831. return target;
  8832. }, error => {
  8833. return _promise.default.reject(error);
  8834. });
  8835. }
  8836. return _promise.default.resolve(undefined);
  8837. }
  8838. };
  8839. _CoreManager.default.setParseObject(ParseObject);
  8840. _CoreManager.default.setObjectController(DefaultController);
  8841. var _default = exports.default = ParseObject;
  8842. },{"./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){
  8843. "use strict";
  8844. var _Object$defineProperty = _dereq_("@babel/runtime-corejs3/core-js-stable/object/define-property");
  8845. var _interopRequireDefault = _dereq_("@babel/runtime-corejs3/helpers/interopRequireDefault");
  8846. _Object$defineProperty(exports, "__esModule", {
  8847. value: true
  8848. });
  8849. exports.UnsetOp = exports.SetOp = exports.RemoveOp = exports.RelationOp = exports.Op = exports.IncrementOp = exports.AddUniqueOp = exports.AddOp = void 0;
  8850. exports.opFromJSON = opFromJSON;
  8851. var _defineProperty2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/helpers/defineProperty"));
  8852. var _isArray = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/array/is-array"));
  8853. var _concat = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/instance/concat"));
  8854. var _forEach = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/instance/for-each"));
  8855. var _indexOf = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/instance/index-of"));
  8856. var _splice = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/instance/splice"));
  8857. var _map = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/instance/map"));
  8858. var _arrayContainsObject = _interopRequireDefault(_dereq_("./arrayContainsObject"));
  8859. var _decode = _interopRequireDefault(_dereq_("./decode"));
  8860. var _encode = _interopRequireDefault(_dereq_("./encode"));
  8861. var _CoreManager = _interopRequireDefault(_dereq_("./CoreManager"));
  8862. var _ParseRelation = _interopRequireDefault(_dereq_("./ParseRelation"));
  8863. var _unique = _interopRequireDefault(_dereq_("./unique"));
  8864. function opFromJSON(json) {
  8865. if (!json || !json.__op) {
  8866. return null;
  8867. }
  8868. switch (json.__op) {
  8869. case 'Delete':
  8870. return new UnsetOp();
  8871. case 'Increment':
  8872. return new IncrementOp(json.amount);
  8873. case 'Add':
  8874. return new AddOp((0, _decode.default)(json.objects));
  8875. case 'AddUnique':
  8876. return new AddUniqueOp((0, _decode.default)(json.objects));
  8877. case 'Remove':
  8878. return new RemoveOp((0, _decode.default)(json.objects));
  8879. case 'AddRelation':
  8880. {
  8881. const toAdd = (0, _decode.default)(json.objects);
  8882. if (!(0, _isArray.default)(toAdd)) {
  8883. return new RelationOp([], []);
  8884. }
  8885. return new RelationOp(toAdd, []);
  8886. }
  8887. case 'RemoveRelation':
  8888. {
  8889. const toRemove = (0, _decode.default)(json.objects);
  8890. if (!(0, _isArray.default)(toRemove)) {
  8891. return new RelationOp([], []);
  8892. }
  8893. return new RelationOp([], toRemove);
  8894. }
  8895. case 'Batch':
  8896. {
  8897. let toAdd = [];
  8898. let toRemove = [];
  8899. for (let i = 0; i < json.ops.length; i++) {
  8900. if (json.ops[i].__op === 'AddRelation') {
  8901. toAdd = (0, _concat.default)(toAdd).call(toAdd, (0, _decode.default)(json.ops[i].objects));
  8902. } else if (json.ops[i].__op === 'RemoveRelation') {
  8903. toRemove = (0, _concat.default)(toRemove).call(toRemove, (0, _decode.default)(json.ops[i].objects));
  8904. }
  8905. }
  8906. return new RelationOp(toAdd, toRemove);
  8907. }
  8908. }
  8909. return null;
  8910. }
  8911. class Op {
  8912. // Empty parent class
  8913. applyTo() {} /* eslint-disable-line @typescript-eslint/no-unused-vars */
  8914. mergeWith() {} /* eslint-disable-line @typescript-eslint/no-unused-vars */
  8915. toJSON() {} /* eslint-disable-line @typescript-eslint/no-unused-vars */
  8916. }
  8917. exports.Op = Op;
  8918. class SetOp extends Op {
  8919. constructor(value) {
  8920. super();
  8921. (0, _defineProperty2.default)(this, "_value", void 0);
  8922. this._value = value;
  8923. }
  8924. applyTo() {
  8925. return this._value;
  8926. }
  8927. mergeWith() {
  8928. return new SetOp(this._value);
  8929. }
  8930. toJSON(offline) {
  8931. return (0, _encode.default)(this._value, false, true, undefined, offline);
  8932. }
  8933. }
  8934. exports.SetOp = SetOp;
  8935. class UnsetOp extends Op {
  8936. applyTo() {
  8937. return undefined;
  8938. }
  8939. mergeWith() {
  8940. return new UnsetOp();
  8941. }
  8942. toJSON() {
  8943. return {
  8944. __op: 'Delete'
  8945. };
  8946. }
  8947. }
  8948. exports.UnsetOp = UnsetOp;
  8949. class IncrementOp extends Op {
  8950. constructor(amount) {
  8951. super();
  8952. (0, _defineProperty2.default)(this, "_amount", void 0);
  8953. if (typeof amount !== 'number') {
  8954. throw new TypeError('Increment Op must be initialized with a numeric amount.');
  8955. }
  8956. this._amount = amount;
  8957. }
  8958. applyTo(value) {
  8959. if (typeof value === 'undefined') {
  8960. return this._amount;
  8961. }
  8962. if (typeof value !== 'number') {
  8963. throw new TypeError('Cannot increment a non-numeric value.');
  8964. }
  8965. return this._amount + value;
  8966. }
  8967. mergeWith(previous) {
  8968. if (!previous) {
  8969. return this;
  8970. }
  8971. if (previous instanceof SetOp) {
  8972. return new SetOp(this.applyTo(previous._value));
  8973. }
  8974. if (previous instanceof UnsetOp) {
  8975. return new SetOp(this._amount);
  8976. }
  8977. if (previous instanceof IncrementOp) {
  8978. return new IncrementOp(this.applyTo(previous._amount));
  8979. }
  8980. throw new Error('Cannot merge Increment Op with the previous Op');
  8981. }
  8982. toJSON() {
  8983. return {
  8984. __op: 'Increment',
  8985. amount: this._amount
  8986. };
  8987. }
  8988. }
  8989. exports.IncrementOp = IncrementOp;
  8990. class AddOp extends Op {
  8991. constructor(value) {
  8992. super();
  8993. (0, _defineProperty2.default)(this, "_value", void 0);
  8994. this._value = (0, _isArray.default)(value) ? value : [value];
  8995. }
  8996. applyTo(value) {
  8997. if (value == null) {
  8998. return this._value;
  8999. }
  9000. if ((0, _isArray.default)(value)) {
  9001. return (0, _concat.default)(value).call(value, this._value);
  9002. }
  9003. throw new Error('Cannot add elements to a non-array value');
  9004. }
  9005. mergeWith(previous) {
  9006. if (!previous) {
  9007. return this;
  9008. }
  9009. if (previous instanceof SetOp) {
  9010. return new SetOp(this.applyTo(previous._value));
  9011. }
  9012. if (previous instanceof UnsetOp) {
  9013. return new SetOp(this._value);
  9014. }
  9015. if (previous instanceof AddOp) {
  9016. return new AddOp(this.applyTo(previous._value));
  9017. }
  9018. throw new Error('Cannot merge Add Op with the previous Op');
  9019. }
  9020. toJSON() {
  9021. return {
  9022. __op: 'Add',
  9023. objects: (0, _encode.default)(this._value, false, true)
  9024. };
  9025. }
  9026. }
  9027. exports.AddOp = AddOp;
  9028. class AddUniqueOp extends Op {
  9029. constructor(value) {
  9030. super();
  9031. (0, _defineProperty2.default)(this, "_value", void 0);
  9032. this._value = (0, _unique.default)((0, _isArray.default)(value) ? value : [value]);
  9033. }
  9034. applyTo(value) {
  9035. if (value == null) {
  9036. return this._value || [];
  9037. }
  9038. if ((0, _isArray.default)(value)) {
  9039. var _context;
  9040. const ParseObject = _CoreManager.default.getParseObject();
  9041. const toAdd = [];
  9042. (0, _forEach.default)(_context = this._value).call(_context, v => {
  9043. if (v instanceof ParseObject) {
  9044. if (!(0, _arrayContainsObject.default)(value, v)) {
  9045. toAdd.push(v);
  9046. }
  9047. } else {
  9048. if ((0, _indexOf.default)(value).call(value, v) < 0) {
  9049. toAdd.push(v);
  9050. }
  9051. }
  9052. });
  9053. return (0, _concat.default)(value).call(value, toAdd);
  9054. }
  9055. throw new Error('Cannot add elements to a non-array value');
  9056. }
  9057. mergeWith(previous) {
  9058. if (!previous) {
  9059. return this;
  9060. }
  9061. if (previous instanceof SetOp) {
  9062. return new SetOp(this.applyTo(previous._value));
  9063. }
  9064. if (previous instanceof UnsetOp) {
  9065. return new SetOp(this._value);
  9066. }
  9067. if (previous instanceof AddUniqueOp) {
  9068. return new AddUniqueOp(this.applyTo(previous._value));
  9069. }
  9070. throw new Error('Cannot merge AddUnique Op with the previous Op');
  9071. }
  9072. toJSON() {
  9073. return {
  9074. __op: 'AddUnique',
  9075. objects: (0, _encode.default)(this._value, false, true)
  9076. };
  9077. }
  9078. }
  9079. exports.AddUniqueOp = AddUniqueOp;
  9080. class RemoveOp extends Op {
  9081. constructor(value) {
  9082. super();
  9083. (0, _defineProperty2.default)(this, "_value", void 0);
  9084. this._value = (0, _unique.default)((0, _isArray.default)(value) ? value : [value]);
  9085. }
  9086. applyTo(value) {
  9087. if (value == null) {
  9088. return [];
  9089. }
  9090. if ((0, _isArray.default)(value)) {
  9091. const ParseObject = _CoreManager.default.getParseObject();
  9092. // var i = value.indexOf(this._value);
  9093. const removed = (0, _concat.default)(value).call(value, []);
  9094. for (let i = 0; i < this._value.length; i++) {
  9095. let index = (0, _indexOf.default)(removed).call(removed, this._value[i]);
  9096. while (index > -1) {
  9097. (0, _splice.default)(removed).call(removed, index, 1);
  9098. index = (0, _indexOf.default)(removed).call(removed, this._value[i]);
  9099. }
  9100. if (this._value[i] instanceof ParseObject && this._value[i].id) {
  9101. for (let j = 0; j < removed.length; j++) {
  9102. if (removed[j] instanceof ParseObject && this._value[i].id === removed[j].id) {
  9103. (0, _splice.default)(removed).call(removed, j, 1);
  9104. j--;
  9105. }
  9106. }
  9107. }
  9108. }
  9109. return removed;
  9110. }
  9111. throw new Error('Cannot remove elements from a non-array value');
  9112. }
  9113. mergeWith(previous) {
  9114. if (!previous) {
  9115. return this;
  9116. }
  9117. if (previous instanceof SetOp) {
  9118. return new SetOp(this.applyTo(previous._value));
  9119. }
  9120. if (previous instanceof UnsetOp) {
  9121. return new UnsetOp();
  9122. }
  9123. if (previous instanceof RemoveOp) {
  9124. var _context2;
  9125. const ParseObject = _CoreManager.default.getParseObject();
  9126. const uniques = (0, _concat.default)(_context2 = previous._value).call(_context2, []);
  9127. for (let i = 0; i < this._value.length; i++) {
  9128. if (this._value[i] instanceof ParseObject) {
  9129. if (!(0, _arrayContainsObject.default)(uniques, this._value[i])) {
  9130. uniques.push(this._value[i]);
  9131. }
  9132. } else {
  9133. if ((0, _indexOf.default)(uniques).call(uniques, this._value[i]) < 0) {
  9134. uniques.push(this._value[i]);
  9135. }
  9136. }
  9137. }
  9138. return new RemoveOp(uniques);
  9139. }
  9140. throw new Error('Cannot merge Remove Op with the previous Op');
  9141. }
  9142. toJSON() {
  9143. return {
  9144. __op: 'Remove',
  9145. objects: (0, _encode.default)(this._value, false, true)
  9146. };
  9147. }
  9148. }
  9149. exports.RemoveOp = RemoveOp;
  9150. class RelationOp extends Op {
  9151. constructor(adds, removes) {
  9152. super();
  9153. (0, _defineProperty2.default)(this, "_targetClassName", void 0);
  9154. (0, _defineProperty2.default)(this, "relationsToAdd", void 0);
  9155. (0, _defineProperty2.default)(this, "relationsToRemove", void 0);
  9156. this._targetClassName = null;
  9157. if ((0, _isArray.default)(adds)) {
  9158. this.relationsToAdd = (0, _unique.default)((0, _map.default)(adds).call(adds, this._extractId, this));
  9159. }
  9160. if ((0, _isArray.default)(removes)) {
  9161. this.relationsToRemove = (0, _unique.default)((0, _map.default)(removes).call(removes, this._extractId, this));
  9162. }
  9163. }
  9164. _extractId(obj) {
  9165. if (typeof obj === 'string') {
  9166. return obj;
  9167. }
  9168. if (!obj.id) {
  9169. throw new Error('You cannot add or remove an unsaved Parse Object from a relation');
  9170. }
  9171. if (!this._targetClassName) {
  9172. this._targetClassName = obj.className;
  9173. }
  9174. if (this._targetClassName !== obj.className) {
  9175. throw new Error('Tried to create a Relation with 2 different object types: ' + this._targetClassName + ' and ' + obj.className + '.');
  9176. }
  9177. return obj.id;
  9178. }
  9179. applyTo(value, parent, key) {
  9180. if (!value) {
  9181. if (!parent || !key) {
  9182. throw new Error('Cannot apply a RelationOp without either a previous value, or an object and a key');
  9183. }
  9184. const relation = new _ParseRelation.default(parent, key);
  9185. relation.targetClassName = this._targetClassName;
  9186. return relation;
  9187. }
  9188. if (value instanceof _ParseRelation.default) {
  9189. if (this._targetClassName) {
  9190. if (value.targetClassName) {
  9191. if (this._targetClassName !== value.targetClassName) {
  9192. throw new Error('Related object must be a ' + value.targetClassName + ', but a ' + this._targetClassName + ' was passed in.');
  9193. }
  9194. } else {
  9195. value.targetClassName = this._targetClassName;
  9196. }
  9197. }
  9198. return value;
  9199. } else {
  9200. throw new Error('Relation cannot be applied to a non-relation field');
  9201. }
  9202. }
  9203. mergeWith(previous) {
  9204. if (!previous) {
  9205. return this;
  9206. } else if (previous instanceof UnsetOp) {
  9207. throw new Error('You cannot modify a relation after deleting it.');
  9208. } else if (previous instanceof SetOp && previous._value instanceof _ParseRelation.default) {
  9209. return this;
  9210. } else if (previous instanceof RelationOp) {
  9211. var _context3, _context4, _context5, _context6, _context7, _context8;
  9212. if (previous._targetClassName && previous._targetClassName !== this._targetClassName) {
  9213. throw new Error('Related object must be of class ' + previous._targetClassName + ', but ' + (this._targetClassName || 'null') + ' was passed in.');
  9214. }
  9215. const newAdd = (0, _concat.default)(_context3 = previous.relationsToAdd).call(_context3, []);
  9216. (0, _forEach.default)(_context4 = this.relationsToRemove).call(_context4, r => {
  9217. const index = (0, _indexOf.default)(newAdd).call(newAdd, r);
  9218. if (index > -1) {
  9219. (0, _splice.default)(newAdd).call(newAdd, index, 1);
  9220. }
  9221. });
  9222. (0, _forEach.default)(_context5 = this.relationsToAdd).call(_context5, r => {
  9223. const index = (0, _indexOf.default)(newAdd).call(newAdd, r);
  9224. if (index < 0) {
  9225. newAdd.push(r);
  9226. }
  9227. });
  9228. const newRemove = (0, _concat.default)(_context6 = previous.relationsToRemove).call(_context6, []);
  9229. (0, _forEach.default)(_context7 = this.relationsToAdd).call(_context7, r => {
  9230. const index = (0, _indexOf.default)(newRemove).call(newRemove, r);
  9231. if (index > -1) {
  9232. (0, _splice.default)(newRemove).call(newRemove, index, 1);
  9233. }
  9234. });
  9235. (0, _forEach.default)(_context8 = this.relationsToRemove).call(_context8, r => {
  9236. const index = (0, _indexOf.default)(newRemove).call(newRemove, r);
  9237. if (index < 0) {
  9238. newRemove.push(r);
  9239. }
  9240. });
  9241. const newRelation = new RelationOp(newAdd, newRemove);
  9242. newRelation._targetClassName = this._targetClassName;
  9243. return newRelation;
  9244. }
  9245. throw new Error('Cannot merge Relation Op with the previous Op');
  9246. }
  9247. toJSON() {
  9248. const idToPointer = id => {
  9249. return {
  9250. __type: 'Pointer',
  9251. className: this._targetClassName,
  9252. objectId: id
  9253. };
  9254. };
  9255. let pointers = null;
  9256. let adds = null;
  9257. let removes = null;
  9258. if (this.relationsToAdd.length > 0) {
  9259. var _context9;
  9260. pointers = (0, _map.default)(_context9 = this.relationsToAdd).call(_context9, idToPointer);
  9261. adds = {
  9262. __op: 'AddRelation',
  9263. objects: pointers
  9264. };
  9265. }
  9266. if (this.relationsToRemove.length > 0) {
  9267. var _context10;
  9268. pointers = (0, _map.default)(_context10 = this.relationsToRemove).call(_context10, idToPointer);
  9269. removes = {
  9270. __op: 'RemoveRelation',
  9271. objects: pointers
  9272. };
  9273. }
  9274. if (adds && removes) {
  9275. return {
  9276. __op: 'Batch',
  9277. ops: [adds, removes]
  9278. };
  9279. }
  9280. return adds || removes || {};
  9281. }
  9282. }
  9283. exports.RelationOp = RelationOp;
  9284. _CoreManager.default.setParseOp({
  9285. Op,
  9286. opFromJSON,
  9287. SetOp,
  9288. UnsetOp,
  9289. IncrementOp,
  9290. AddOp,
  9291. RelationOp,
  9292. RemoveOp,
  9293. AddUniqueOp
  9294. });
  9295. },{"./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){
  9296. "use strict";
  9297. var _Object$defineProperty = _dereq_("@babel/runtime-corejs3/core-js-stable/object/define-property");
  9298. var _interopRequireDefault = _dereq_("@babel/runtime-corejs3/helpers/interopRequireDefault");
  9299. _Object$defineProperty(exports, "__esModule", {
  9300. value: true
  9301. });
  9302. exports.default = void 0;
  9303. var _isArray = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/array/is-array"));
  9304. var _defineProperty2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/helpers/defineProperty"));
  9305. var _ParseGeoPoint = _interopRequireDefault(_dereq_("./ParseGeoPoint"));
  9306. /**
  9307. * Creates a new Polygon with any of the following forms:<br>
  9308. * <pre>
  9309. * new Polygon([[0,0],[0,1],[1,1],[1,0]])
  9310. * new Polygon([GeoPoint, GeoPoint, GeoPoint])
  9311. * </pre>
  9312. *
  9313. * <p>Represents a coordinates that may be associated
  9314. * with a key in a ParseObject or used as a reference point for geo queries.
  9315. * This allows proximity-based queries on the key.</p>
  9316. *
  9317. * <p>Example:<pre>
  9318. * var polygon = new Parse.Polygon([[0,0],[0,1],[1,1],[1,0]]);
  9319. * var object = new Parse.Object("PlaceObject");
  9320. * object.set("area", polygon);
  9321. * object.save();</pre></p>
  9322. *
  9323. * @alias Parse.Polygon
  9324. */
  9325. class ParsePolygon {
  9326. /**
  9327. * @param {(Coordinates | Parse.GeoPoint[])} coordinates An Array of coordinate pairs
  9328. */
  9329. constructor(coordinates) {
  9330. (0, _defineProperty2.default)(this, "_coordinates", void 0);
  9331. this._coordinates = ParsePolygon._validate(coordinates);
  9332. }
  9333. /**
  9334. * Coordinates value for this Polygon.
  9335. * Throws an exception if not valid type.
  9336. *
  9337. * @property {(Coordinates | Parse.GeoPoint[])} coordinates list of coordinates
  9338. * @returns {Coordinates}
  9339. */
  9340. get coordinates() {
  9341. return this._coordinates;
  9342. }
  9343. set coordinates(coords) {
  9344. this._coordinates = ParsePolygon._validate(coords);
  9345. }
  9346. /**
  9347. * Returns a JSON representation of the Polygon, suitable for Parse.
  9348. *
  9349. * @returns {object}
  9350. */
  9351. toJSON() {
  9352. ParsePolygon._validate(this._coordinates);
  9353. return {
  9354. __type: 'Polygon',
  9355. coordinates: this._coordinates
  9356. };
  9357. }
  9358. /**
  9359. * Checks if two polygons are equal
  9360. *
  9361. * @param {(Parse.Polygon | object)} other
  9362. * @returns {boolean}
  9363. */
  9364. equals(other) {
  9365. if (!(other instanceof ParsePolygon) || this.coordinates.length !== other.coordinates.length) {
  9366. return false;
  9367. }
  9368. let isEqual = true;
  9369. for (let i = 1; i < this._coordinates.length; i += 1) {
  9370. if (this._coordinates[i][0] != other.coordinates[i][0] || this._coordinates[i][1] != other.coordinates[i][1]) {
  9371. isEqual = false;
  9372. break;
  9373. }
  9374. }
  9375. return isEqual;
  9376. }
  9377. /**
  9378. *
  9379. * @param {Parse.GeoPoint} point
  9380. * @returns {boolean} Returns if the point is contained in the polygon
  9381. */
  9382. containsPoint(point) {
  9383. let minX = this._coordinates[0][0];
  9384. let maxX = this._coordinates[0][0];
  9385. let minY = this._coordinates[0][1];
  9386. let maxY = this._coordinates[0][1];
  9387. for (let i = 1; i < this._coordinates.length; i += 1) {
  9388. const p = this._coordinates[i];
  9389. minX = Math.min(p[0], minX);
  9390. maxX = Math.max(p[0], maxX);
  9391. minY = Math.min(p[1], minY);
  9392. maxY = Math.max(p[1], maxY);
  9393. }
  9394. const outside = point.latitude < minX || point.latitude > maxX || point.longitude < minY || point.longitude > maxY;
  9395. if (outside) {
  9396. return false;
  9397. }
  9398. let inside = false;
  9399. for (let i = 0, j = this._coordinates.length - 1; i < this._coordinates.length; j = i++) {
  9400. const startX = this._coordinates[i][0];
  9401. const startY = this._coordinates[i][1];
  9402. const endX = this._coordinates[j][0];
  9403. const endY = this._coordinates[j][1];
  9404. const intersect = startY > point.longitude != endY > point.longitude && point.latitude < (endX - startX) * (point.longitude - startY) / (endY - startY) + startX;
  9405. if (intersect) {
  9406. inside = !inside;
  9407. }
  9408. }
  9409. return inside;
  9410. }
  9411. /**
  9412. * Validates that the list of coordinates can form a valid polygon
  9413. *
  9414. * @param {Array} coords the list of coordinates to validate as a polygon
  9415. * @throws {TypeError}
  9416. * @returns {number[][]} Array of coordinates if validated.
  9417. */
  9418. static _validate(coords) {
  9419. if (!(0, _isArray.default)(coords)) {
  9420. throw new TypeError('Coordinates must be an Array');
  9421. }
  9422. if (coords.length < 3) {
  9423. throw new TypeError('Polygon must have at least 3 GeoPoints or Points');
  9424. }
  9425. const points = [];
  9426. for (let i = 0; i < coords.length; i += 1) {
  9427. const coord = coords[i];
  9428. let geoPoint;
  9429. if (coord instanceof _ParseGeoPoint.default) {
  9430. geoPoint = coord;
  9431. } else if ((0, _isArray.default)(coord) && coord.length === 2) {
  9432. geoPoint = new _ParseGeoPoint.default(coord[0], coord[1]);
  9433. } else {
  9434. throw new TypeError('Coordinates must be an Array of GeoPoints or Points');
  9435. }
  9436. points.push([geoPoint.latitude, geoPoint.longitude]);
  9437. }
  9438. return points;
  9439. }
  9440. }
  9441. var _default = exports.default = ParsePolygon;
  9442. },{"./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){
  9443. "use strict";
  9444. var _Object$defineProperty = _dereq_("@babel/runtime-corejs3/core-js-stable/object/define-property");
  9445. var _interopRequireDefault = _dereq_("@babel/runtime-corejs3/helpers/interopRequireDefault");
  9446. _Object$defineProperty(exports, "__esModule", {
  9447. value: true
  9448. });
  9449. exports.default = void 0;
  9450. var _defineProperty2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/helpers/defineProperty"));
  9451. var _forEach = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/instance/for-each"));
  9452. var _indexOf = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/instance/index-of"));
  9453. var _keys = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/object/keys"));
  9454. var _slice = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/instance/slice"));
  9455. var _map = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/instance/map"));
  9456. var _filter = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/instance/filter"));
  9457. var _keys2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/instance/keys"));
  9458. var _concat = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/instance/concat"));
  9459. var _includes = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/instance/includes"));
  9460. var _sort = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/instance/sort"));
  9461. var _splice = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/instance/splice"));
  9462. var _promise = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/promise"));
  9463. var _find = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/instance/find"));
  9464. var _isArray = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/array/is-array"));
  9465. var _entries = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/object/entries"));
  9466. var _CoreManager = _interopRequireDefault(_dereq_("./CoreManager"));
  9467. var _encode = _interopRequireDefault(_dereq_("./encode"));
  9468. var _promiseUtils = _dereq_("./promiseUtils");
  9469. var _ParseError = _interopRequireDefault(_dereq_("./ParseError"));
  9470. var _ParseGeoPoint = _interopRequireDefault(_dereq_("./ParseGeoPoint"));
  9471. var _ParseObject = _interopRequireDefault(_dereq_("./ParseObject"));
  9472. var _OfflineQuery = _interopRequireDefault(_dereq_("./OfflineQuery"));
  9473. var _LocalDatastoreUtils = _dereq_("./LocalDatastoreUtils");
  9474. /**
  9475. * Converts a string into a regex that matches it.
  9476. * Surrounding with \Q .. \E does this, we just need to escape any \E's in
  9477. * the text separately.
  9478. *
  9479. * @param s
  9480. * @private
  9481. * @returns {string}
  9482. */
  9483. function quote(s) {
  9484. return '\\Q' + s.replace('\\E', '\\E\\\\E\\Q') + '\\E';
  9485. }
  9486. /**
  9487. * Extracts the class name from queries. If not all queries have the same
  9488. * class name an error will be thrown.
  9489. *
  9490. * @param queries
  9491. * @private
  9492. * @returns {string}
  9493. */
  9494. function _getClassNameFromQueries(queries) {
  9495. let className = null;
  9496. (0, _forEach.default)(queries).call(queries, q => {
  9497. if (!className) {
  9498. className = q.className;
  9499. }
  9500. if (className !== q.className) {
  9501. throw new Error('All queries must be for the same class.');
  9502. }
  9503. });
  9504. return className;
  9505. }
  9506. /*
  9507. * Handles pre-populating the result data of a query with select fields,
  9508. * making sure that the data object contains keys for all objects that have
  9509. * been requested with a select, so that our cached state updates correctly.
  9510. */
  9511. function handleSelectResult(data, select) {
  9512. const serverDataMask = {};
  9513. (0, _forEach.default)(select).call(select, field => {
  9514. const hasSubObjectSelect = (0, _indexOf.default)(field).call(field, '.') !== -1;
  9515. if (!hasSubObjectSelect && !data.hasOwnProperty(field)) {
  9516. // this field was selected, but is missing from the retrieved data
  9517. data[field] = undefined;
  9518. } else if (hasSubObjectSelect) {
  9519. // this field references a sub-object,
  9520. // so we need to walk down the path components
  9521. const pathComponents = field.split('.');
  9522. let obj = data;
  9523. let serverMask = serverDataMask;
  9524. (0, _forEach.default)(pathComponents).call(pathComponents, (component, index, arr) => {
  9525. // add keys if the expected data is missing
  9526. if (obj && !obj.hasOwnProperty(component)) {
  9527. obj[component] = undefined;
  9528. }
  9529. if (obj && typeof obj === 'object') {
  9530. obj = obj[component];
  9531. }
  9532. //add this path component to the server mask so we can fill it in later if needed
  9533. if (index < arr.length - 1) {
  9534. if (!serverMask[component]) {
  9535. serverMask[component] = {};
  9536. }
  9537. serverMask = serverMask[component];
  9538. }
  9539. });
  9540. }
  9541. });
  9542. if ((0, _keys.default)(serverDataMask).length > 0) {
  9543. // When selecting from sub-objects, we don't want to blow away the missing
  9544. // information that we may have retrieved before. We've already added any
  9545. // missing selected keys to sub-objects, but we still need to add in the
  9546. // data for any previously retrieved sub-objects that were not selected.
  9547. const serverData = _CoreManager.default.getObjectStateController().getServerData({
  9548. id: data.objectId,
  9549. className: data.className
  9550. });
  9551. copyMissingDataWithMask(serverData, data, serverDataMask, false);
  9552. }
  9553. }
  9554. function copyMissingDataWithMask(src, dest, mask, copyThisLevel) {
  9555. //copy missing elements at this level
  9556. if (copyThisLevel) {
  9557. for (const key in src) {
  9558. if (src.hasOwnProperty(key) && !dest.hasOwnProperty(key)) {
  9559. dest[key] = src[key];
  9560. }
  9561. }
  9562. }
  9563. for (const key in mask) {
  9564. if (dest[key] !== undefined && dest[key] !== null && src !== undefined && src !== null) {
  9565. //traverse into objects as needed
  9566. copyMissingDataWithMask(src[key], dest[key], mask[key], true);
  9567. }
  9568. }
  9569. }
  9570. function handleOfflineSort(a, b, sorts) {
  9571. let order = sorts[0];
  9572. const operator = (0, _slice.default)(order).call(order, 0, 1);
  9573. const isDescending = operator === '-';
  9574. if (isDescending) {
  9575. order = order.substring(1);
  9576. }
  9577. if (order === '_created_at') {
  9578. order = 'createdAt';
  9579. }
  9580. if (order === '_updated_at') {
  9581. order = 'updatedAt';
  9582. }
  9583. if (!/^[A-Za-z][0-9A-Za-z_]*$/.test(order) || order === 'password') {
  9584. throw new _ParseError.default(_ParseError.default.INVALID_KEY_NAME, `Invalid Key: ${order}`);
  9585. }
  9586. const field1 = a.get(order);
  9587. const field2 = b.get(order);
  9588. if (field1 < field2) {
  9589. return isDescending ? 1 : -1;
  9590. }
  9591. if (field1 > field2) {
  9592. return isDescending ? -1 : 1;
  9593. }
  9594. if (sorts.length > 1) {
  9595. const remainingSorts = (0, _slice.default)(sorts).call(sorts, 1);
  9596. return handleOfflineSort(a, b, remainingSorts);
  9597. }
  9598. return 0;
  9599. }
  9600. /**
  9601. * Creates a new parse Parse.Query for the given Parse.Object subclass.
  9602. *
  9603. * <p>Parse.Query defines a query that is used to fetch Parse.Objects. The
  9604. * most common use case is finding all objects that match a query through the
  9605. * <code>find</code> method. for example, this sample code fetches all objects
  9606. * of class <code>myclass</code>. it calls a different function depending on
  9607. * whether the fetch succeeded or not.
  9608. *
  9609. * <pre>
  9610. * var query = new Parse.Query(myclass);
  9611. * query.find().then((results) => {
  9612. * // results is an array of parse.object.
  9613. * }).catch((error) => {
  9614. * // error is an instance of parse.error.
  9615. * });</pre></p>
  9616. *
  9617. * <p>a Parse.Query can also be used to retrieve a single object whose id is
  9618. * known, through the get method. for example, this sample code fetches an
  9619. * object of class <code>myclass</code> and id <code>myid</code>. it calls a
  9620. * different function depending on whether the fetch succeeded or not.
  9621. *
  9622. * <pre>
  9623. * var query = new Parse.Query(myclass);
  9624. * query.get(myid).then((object) => {
  9625. * // object is an instance of parse.object.
  9626. * }).catch((error) => {
  9627. * // error is an instance of parse.error.
  9628. * });</pre></p>
  9629. *
  9630. * <p>a Parse.Query can also be used to count the number of objects that match
  9631. * the query without retrieving all of those objects. for example, this
  9632. * sample code counts the number of objects of the class <code>myclass</code>
  9633. * <pre>
  9634. * var query = new Parse.Query(myclass);
  9635. * query.count().then((number) => {
  9636. * // there are number instances of myclass.
  9637. * }).catch((error) => {
  9638. * // error is an instance of Parse.Error.
  9639. * });</pre></p>
  9640. *
  9641. * @alias Parse.Query
  9642. */
  9643. class ParseQuery {
  9644. /**
  9645. * @param {(string | Parse.Object)} objectClass An instance of a subclass of Parse.Object, or a Parse className string.
  9646. */
  9647. constructor(objectClass) {
  9648. /**
  9649. * @property {string} className
  9650. */
  9651. (0, _defineProperty2.default)(this, "className", void 0);
  9652. (0, _defineProperty2.default)(this, "_where", void 0);
  9653. (0, _defineProperty2.default)(this, "_watch", void 0);
  9654. (0, _defineProperty2.default)(this, "_include", void 0);
  9655. (0, _defineProperty2.default)(this, "_exclude", void 0);
  9656. (0, _defineProperty2.default)(this, "_select", void 0);
  9657. (0, _defineProperty2.default)(this, "_limit", void 0);
  9658. (0, _defineProperty2.default)(this, "_skip", void 0);
  9659. (0, _defineProperty2.default)(this, "_count", void 0);
  9660. (0, _defineProperty2.default)(this, "_order", void 0);
  9661. (0, _defineProperty2.default)(this, "_readPreference", void 0);
  9662. (0, _defineProperty2.default)(this, "_includeReadPreference", void 0);
  9663. (0, _defineProperty2.default)(this, "_subqueryReadPreference", void 0);
  9664. (0, _defineProperty2.default)(this, "_queriesLocalDatastore", void 0);
  9665. (0, _defineProperty2.default)(this, "_localDatastorePinName", void 0);
  9666. (0, _defineProperty2.default)(this, "_extraOptions", void 0);
  9667. (0, _defineProperty2.default)(this, "_hint", void 0);
  9668. (0, _defineProperty2.default)(this, "_explain", void 0);
  9669. (0, _defineProperty2.default)(this, "_xhrRequest", void 0);
  9670. (0, _defineProperty2.default)(this, "_comment", void 0);
  9671. if (typeof objectClass === 'string') {
  9672. if (objectClass === 'User' && _CoreManager.default.get('PERFORM_USER_REWRITE')) {
  9673. this.className = '_User';
  9674. } else {
  9675. this.className = objectClass;
  9676. }
  9677. } else if (objectClass instanceof _ParseObject.default) {
  9678. this.className = objectClass.className;
  9679. } else if (typeof objectClass === 'function') {
  9680. const objClass = objectClass;
  9681. if (typeof objClass.className === 'string') {
  9682. this.className = objClass.className;
  9683. } else {
  9684. const obj = new objClass();
  9685. this.className = obj.className;
  9686. }
  9687. } else {
  9688. throw new TypeError('A ParseQuery must be constructed with a ParseObject or class name.');
  9689. }
  9690. this._where = {};
  9691. this._watch = [];
  9692. this._include = [];
  9693. this._exclude = [];
  9694. this._count = false;
  9695. this._limit = -1; // negative limit is not sent in the server request
  9696. this._skip = 0;
  9697. this._readPreference = null;
  9698. this._includeReadPreference = null;
  9699. this._subqueryReadPreference = null;
  9700. this._queriesLocalDatastore = false;
  9701. this._localDatastorePinName = null;
  9702. this._extraOptions = {};
  9703. this._xhrRequest = {
  9704. task: null,
  9705. onchange: () => {}
  9706. };
  9707. this._comment = null;
  9708. }
  9709. /**
  9710. * Adds constraint that at least one of the passed in queries matches.
  9711. *
  9712. * @param {Array} queries
  9713. * @returns {Parse.Query} Returns the query, so you can chain this call.
  9714. */
  9715. _orQuery(queries) {
  9716. const queryJSON = (0, _map.default)(queries).call(queries, q => {
  9717. return q.toJSON().where;
  9718. });
  9719. this._where.$or = queryJSON;
  9720. return this;
  9721. }
  9722. /**
  9723. * Adds constraint that all of the passed in queries match.
  9724. *
  9725. * @param {Array} queries
  9726. * @returns {Parse.Query} Returns the query, so you can chain this call.
  9727. */
  9728. _andQuery(queries) {
  9729. const queryJSON = (0, _map.default)(queries).call(queries, q => {
  9730. return q.toJSON().where;
  9731. });
  9732. this._where.$and = queryJSON;
  9733. return this;
  9734. }
  9735. /**
  9736. * Adds constraint that none of the passed in queries match.
  9737. *
  9738. * @param {Array} queries
  9739. * @returns {Parse.Query} Returns the query, so you can chain this call.
  9740. */
  9741. _norQuery(queries) {
  9742. const queryJSON = (0, _map.default)(queries).call(queries, q => {
  9743. return q.toJSON().where;
  9744. });
  9745. this._where.$nor = queryJSON;
  9746. return this;
  9747. }
  9748. /**
  9749. * Helper for condition queries
  9750. *
  9751. * @param key
  9752. * @param condition
  9753. * @param value
  9754. * @returns {Parse.Query}
  9755. */
  9756. _addCondition(key, condition, value) {
  9757. if (!this._where[key] || typeof this._where[key] === 'string') {
  9758. this._where[key] = {};
  9759. }
  9760. this._where[key][condition] = (0, _encode.default)(value, false, true);
  9761. return this;
  9762. }
  9763. /**
  9764. * Converts string for regular expression at the beginning
  9765. *
  9766. * @param string
  9767. * @returns {string}
  9768. */
  9769. _regexStartWith(string) {
  9770. return '^' + quote(string);
  9771. }
  9772. async _handleOfflineQuery(params) {
  9773. var _context;
  9774. _OfflineQuery.default.validateQuery(this);
  9775. const localDatastore = _CoreManager.default.getLocalDatastore();
  9776. const objects = await localDatastore._serializeObjectsFromPinName(this._localDatastorePinName);
  9777. let results = (0, _filter.default)(_context = (0, _map.default)(objects).call(objects, (json, index, arr) => {
  9778. const object = _ParseObject.default.fromJSON(json, false);
  9779. if (json._localId && !json.objectId) {
  9780. object._localId = json._localId;
  9781. }
  9782. if (!_OfflineQuery.default.matchesQuery(this.className, object, arr, this)) {
  9783. return null;
  9784. }
  9785. return object;
  9786. })).call(_context, object => object !== null);
  9787. if ((0, _keys2.default)(params)) {
  9788. let keys = (0, _keys2.default)(params).split(',');
  9789. keys = (0, _concat.default)(keys).call(keys, ['className', 'objectId', 'createdAt', 'updatedAt', 'ACL']);
  9790. results = (0, _map.default)(results).call(results, object => {
  9791. var _context2;
  9792. const json = object._toFullJSON();
  9793. (0, _forEach.default)(_context2 = (0, _keys.default)(json)).call(_context2, key => {
  9794. if (!(0, _includes.default)(keys).call(keys, key)) {
  9795. delete json[key];
  9796. }
  9797. });
  9798. return _ParseObject.default.fromJSON(json, false);
  9799. });
  9800. }
  9801. if (params.order) {
  9802. const sorts = params.order.split(',');
  9803. (0, _sort.default)(results).call(results, (a, b) => {
  9804. return handleOfflineSort(a, b, sorts);
  9805. });
  9806. }
  9807. let count; // count total before applying limit/skip
  9808. if (params.count) {
  9809. count = results.length; // total count from response
  9810. }
  9811. if (params.skip) {
  9812. if (params.skip >= results.length) {
  9813. results = [];
  9814. } else {
  9815. results = (0, _splice.default)(results).call(results, params.skip, results.length);
  9816. }
  9817. }
  9818. let limit = results.length;
  9819. if (params.limit !== 0 && params.limit < results.length) {
  9820. limit = params.limit;
  9821. }
  9822. results = (0, _splice.default)(results).call(results, 0, limit);
  9823. if (typeof count === 'number') {
  9824. return {
  9825. results,
  9826. count
  9827. };
  9828. }
  9829. return results;
  9830. }
  9831. /**
  9832. * Returns a JSON representation of this query.
  9833. *
  9834. * @returns {object} The JSON representation of the query.
  9835. */
  9836. toJSON() {
  9837. const params = {
  9838. where: this._where
  9839. };
  9840. if (this._watch.length) {
  9841. params.watch = this._watch.join(',');
  9842. }
  9843. if (this._include.length) {
  9844. params.include = this._include.join(',');
  9845. }
  9846. if (this._exclude.length) {
  9847. params.excludeKeys = this._exclude.join(',');
  9848. }
  9849. if (this._select) {
  9850. params.keys = this._select.join(',');
  9851. }
  9852. if (this._count) {
  9853. params.count = 1;
  9854. }
  9855. if (this._limit >= 0) {
  9856. params.limit = this._limit;
  9857. }
  9858. if (this._skip > 0) {
  9859. params.skip = this._skip;
  9860. }
  9861. if (this._order) {
  9862. params.order = this._order.join(',');
  9863. }
  9864. if (this._readPreference) {
  9865. params.readPreference = this._readPreference;
  9866. }
  9867. if (this._includeReadPreference) {
  9868. params.includeReadPreference = this._includeReadPreference;
  9869. }
  9870. if (this._subqueryReadPreference) {
  9871. params.subqueryReadPreference = this._subqueryReadPreference;
  9872. }
  9873. if (this._hint) {
  9874. params.hint = this._hint;
  9875. }
  9876. if (this._explain) {
  9877. params.explain = true;
  9878. }
  9879. if (this._comment) {
  9880. params.comment = this._comment;
  9881. }
  9882. for (const key in this._extraOptions) {
  9883. params[key] = this._extraOptions[key];
  9884. }
  9885. return params;
  9886. }
  9887. /**
  9888. * Return a query with conditions from json, can be useful to send query from server side to client
  9889. * Not static, all query conditions was set before calling this method will be deleted.
  9890. * For example on the server side we have
  9891. * var query = new Parse.Query("className");
  9892. * query.equalTo(key: value);
  9893. * query.limit(100);
  9894. * ... (others queries)
  9895. * Create JSON representation of Query Object
  9896. * var jsonFromServer = query.fromJSON();
  9897. *
  9898. * On client side getting query:
  9899. * var query = new Parse.Query("className");
  9900. * query.fromJSON(jsonFromServer);
  9901. *
  9902. * and continue to query...
  9903. * query.skip(100).find().then(...);
  9904. *
  9905. * @param {QueryJSON} json from Parse.Query.toJSON() method
  9906. * @returns {Parse.Query} Returns the query, so you can chain this call.
  9907. */
  9908. withJSON(json) {
  9909. if (json.where) {
  9910. this._where = json.where;
  9911. }
  9912. if (json.watch) {
  9913. this._watch = json.watch.split(',');
  9914. }
  9915. if (json.include) {
  9916. this._include = json.include.split(',');
  9917. }
  9918. if ((0, _keys2.default)(json)) {
  9919. this._select = (0, _keys2.default)(json).split(',');
  9920. }
  9921. if (json.excludeKeys) {
  9922. this._exclude = json.excludeKeys.split(',');
  9923. }
  9924. if (json.count) {
  9925. this._count = json.count === 1;
  9926. }
  9927. if (json.limit) {
  9928. this._limit = json.limit;
  9929. }
  9930. if (json.skip) {
  9931. this._skip = json.skip;
  9932. }
  9933. if (json.order) {
  9934. this._order = json.order.split(',');
  9935. }
  9936. if (json.readPreference) {
  9937. this._readPreference = json.readPreference;
  9938. }
  9939. if (json.includeReadPreference) {
  9940. this._includeReadPreference = json.includeReadPreference;
  9941. }
  9942. if (json.subqueryReadPreference) {
  9943. this._subqueryReadPreference = json.subqueryReadPreference;
  9944. }
  9945. if (json.hint) {
  9946. this._hint = json.hint;
  9947. }
  9948. if (json.explain) {
  9949. this._explain = !!json.explain;
  9950. }
  9951. if (json.comment) {
  9952. this._comment = json.comment;
  9953. }
  9954. for (const key in json) {
  9955. if (json.hasOwnProperty(key)) {
  9956. var _context3;
  9957. if ((0, _indexOf.default)(_context3 = ['where', 'include', 'keys', 'count', 'limit', 'skip', 'order', 'readPreference', 'includeReadPreference', 'subqueryReadPreference', 'hint', 'explain', 'comment']).call(_context3, key) === -1) {
  9958. this._extraOptions[key] = json[key];
  9959. }
  9960. }
  9961. }
  9962. return this;
  9963. }
  9964. /**
  9965. * Static method to restore Parse.Query by json representation
  9966. * Internally calling Parse.Query.withJSON
  9967. *
  9968. * @param {string} className
  9969. * @param {QueryJSON} json from Parse.Query.toJSON() method
  9970. * @returns {Parse.Query} new created query
  9971. */
  9972. static fromJSON(className, json) {
  9973. const query = new ParseQuery(className);
  9974. return query.withJSON(json);
  9975. }
  9976. /**
  9977. * Constructs a Parse.Object whose id is already known by fetching data from
  9978. * the server. Unlike the <code>first</code> method, it never returns undefined.
  9979. *
  9980. * @param {string} objectId The id of the object to be fetched.
  9981. * @param {object} options
  9982. * Valid options are:<ul>
  9983. * <li>useMasterKey: In Cloud Code and Node only, causes the Master Key to
  9984. * be used for this request.
  9985. * <li>sessionToken: A valid session token, used for making a request on
  9986. * behalf of a specific user.
  9987. * <li>context: A dictionary that is accessible in Cloud Code `beforeFind` trigger.
  9988. * <li>json: Return raw json without converting to Parse.Object
  9989. * </ul>
  9990. * @returns {Promise} A promise that is resolved with the result when
  9991. * the query completes.
  9992. */
  9993. get(objectId, options) {
  9994. this.equalTo('objectId', objectId);
  9995. const firstOptions = {};
  9996. if (options && options.hasOwnProperty('useMasterKey')) {
  9997. firstOptions.useMasterKey = options.useMasterKey;
  9998. }
  9999. if (options && options.hasOwnProperty('sessionToken')) {
  10000. firstOptions.sessionToken = options.sessionToken;
  10001. }
  10002. if (options && options.hasOwnProperty('context') && typeof options.context === 'object') {
  10003. firstOptions.context = options.context;
  10004. }
  10005. if (options && options.hasOwnProperty('json')) {
  10006. firstOptions.json = options.json;
  10007. }
  10008. return this.first(firstOptions).then(response => {
  10009. if (response) {
  10010. return response;
  10011. }
  10012. const errorObject = new _ParseError.default(_ParseError.default.OBJECT_NOT_FOUND, 'Object not found.');
  10013. return _promise.default.reject(errorObject);
  10014. });
  10015. }
  10016. /**
  10017. * Retrieves a list of ParseObjects that satisfy this query.
  10018. *
  10019. * @param {object} options Valid options
  10020. * are:<ul>
  10021. * <li>useMasterKey: In Cloud Code and Node only, causes the Master Key to
  10022. * be used for this request.
  10023. * <li>sessionToken: A valid session token, used for making a request on
  10024. * behalf of a specific user.
  10025. * <li>context: A dictionary that is accessible in Cloud Code `beforeFind` trigger.
  10026. * <li>json: Return raw json without converting to Parse.Object
  10027. * </ul>
  10028. * @returns {Promise} A promise that is resolved with the results when
  10029. * the query completes.
  10030. */
  10031. find(options) {
  10032. options = options || {};
  10033. const findOptions = {};
  10034. if (options.hasOwnProperty('useMasterKey')) {
  10035. findOptions.useMasterKey = options.useMasterKey;
  10036. }
  10037. if (options.hasOwnProperty('sessionToken')) {
  10038. findOptions.sessionToken = options.sessionToken;
  10039. }
  10040. if (options.hasOwnProperty('context') && typeof options.context === 'object') {
  10041. findOptions.context = options.context;
  10042. }
  10043. this._setRequestTask(findOptions);
  10044. const controller = _CoreManager.default.getQueryController();
  10045. const select = this._select;
  10046. if (this._queriesLocalDatastore) {
  10047. return this._handleOfflineQuery(this.toJSON());
  10048. }
  10049. return (0, _find.default)(controller).call(controller, this.className, this.toJSON(), findOptions).then(response => {
  10050. // Return generic object when explain is used
  10051. if (this._explain) {
  10052. return response.results;
  10053. }
  10054. const results = response.results?.map(data => {
  10055. // In cases of relations, the server may send back a className
  10056. // on the top level of the payload
  10057. const override = response.className || this.className;
  10058. if (!data.className) {
  10059. data.className = override;
  10060. }
  10061. // Make sure the data object contains keys for all objects that
  10062. // have been requested with a select, so that our cached state
  10063. // updates correctly.
  10064. if (select) {
  10065. handleSelectResult(data, select);
  10066. }
  10067. if (options.json) {
  10068. return data;
  10069. } else {
  10070. return _ParseObject.default.fromJSON(data, !select);
  10071. }
  10072. });
  10073. const count = response.count;
  10074. if (typeof count === 'number') {
  10075. return {
  10076. results,
  10077. count
  10078. };
  10079. } else {
  10080. return results;
  10081. }
  10082. });
  10083. }
  10084. /**
  10085. * Retrieves a complete list of ParseObjects that satisfy this query.
  10086. * Using `eachBatch` under the hood to fetch all the valid objects.
  10087. *
  10088. * @param {object} options Valid options are:<ul>
  10089. * <li>batchSize: How many objects to yield in each batch (default: 100)
  10090. * <li>useMasterKey: In Cloud Code and Node only, causes the Master Key to
  10091. * be used for this request.
  10092. * <li>sessionToken: A valid session token, used for making a request on
  10093. * behalf of a specific user.
  10094. * </ul>
  10095. * @returns {Promise} A promise that is resolved with the results when
  10096. * the query completes.
  10097. */
  10098. async findAll(options) {
  10099. let result = [];
  10100. await this.eachBatch(objects => {
  10101. result = [...result, ...objects];
  10102. }, options);
  10103. return result;
  10104. }
  10105. /**
  10106. * Counts the number of objects that match this query.
  10107. *
  10108. * @param {object} options
  10109. * @param {boolean} [options.useMasterKey]
  10110. * @param {string} [options.sessionToken]
  10111. * Valid options are:<ul>
  10112. * <li>useMasterKey: In Cloud Code and Node only, causes the Master Key to
  10113. * be used for this request.
  10114. * <li>sessionToken: A valid session token, used for making a request on
  10115. * behalf of a specific user.
  10116. * </ul>
  10117. * @returns {Promise} A promise that is resolved with the count when
  10118. * the query completes.
  10119. */
  10120. count(options) {
  10121. options = options || {};
  10122. const findOptions = {};
  10123. if (options.hasOwnProperty('useMasterKey')) {
  10124. findOptions.useMasterKey = options.useMasterKey;
  10125. }
  10126. if (options.hasOwnProperty('sessionToken')) {
  10127. findOptions.sessionToken = options.sessionToken;
  10128. }
  10129. this._setRequestTask(findOptions);
  10130. const controller = _CoreManager.default.getQueryController();
  10131. const params = this.toJSON();
  10132. params.limit = 0;
  10133. params.count = 1;
  10134. return (0, _find.default)(controller).call(controller, this.className, params, findOptions).then(result => {
  10135. return result.count;
  10136. });
  10137. }
  10138. /**
  10139. * Executes a distinct query and returns unique values
  10140. *
  10141. * @param {string} key A field to find distinct values
  10142. * @param {object} options
  10143. * @param {string} [options.sessionToken] A valid session token, used for making a request on behalf of a specific user.
  10144. * @returns {Promise} A promise that is resolved with the query completes.
  10145. */
  10146. distinct(key, options) {
  10147. options = options || {};
  10148. const distinctOptions = {
  10149. useMasterKey: true
  10150. };
  10151. if (options.hasOwnProperty('sessionToken')) {
  10152. distinctOptions.sessionToken = options.sessionToken;
  10153. }
  10154. this._setRequestTask(distinctOptions);
  10155. const controller = _CoreManager.default.getQueryController();
  10156. const params = {
  10157. distinct: key,
  10158. where: this._where,
  10159. hint: this._hint
  10160. };
  10161. return controller.aggregate(this.className, params, distinctOptions).then(results => {
  10162. return results.results;
  10163. });
  10164. }
  10165. /**
  10166. * Executes an aggregate query and returns aggregate results
  10167. *
  10168. * @param {(Array|object)} pipeline Array or Object of stages to process query
  10169. * @param {object} options
  10170. * @param {string} [options.sessionToken] A valid session token, used for making a request on behalf of a specific user.
  10171. * @returns {Promise} A promise that is resolved with the query completes.
  10172. */
  10173. aggregate(pipeline, options) {
  10174. options = options || {};
  10175. const aggregateOptions = {
  10176. useMasterKey: true
  10177. };
  10178. if (options.hasOwnProperty('sessionToken')) {
  10179. aggregateOptions.sessionToken = options.sessionToken;
  10180. }
  10181. this._setRequestTask(aggregateOptions);
  10182. const controller = _CoreManager.default.getQueryController();
  10183. if (!(0, _isArray.default)(pipeline) && typeof pipeline !== 'object') {
  10184. throw new Error('Invalid pipeline must be Array or Object');
  10185. }
  10186. if ((0, _keys.default)(this._where || {}).length) {
  10187. if (!(0, _isArray.default)(pipeline)) {
  10188. pipeline = [pipeline];
  10189. }
  10190. pipeline.unshift({
  10191. $match: this._where
  10192. });
  10193. }
  10194. const params = {
  10195. pipeline,
  10196. hint: this._hint,
  10197. explain: this._explain,
  10198. readPreference: this._readPreference
  10199. };
  10200. return controller.aggregate(this.className, params, aggregateOptions).then(results => {
  10201. return results.results;
  10202. });
  10203. }
  10204. /**
  10205. * Retrieves at most one Parse.Object that satisfies this query.
  10206. *
  10207. * Returns the object if there is one, otherwise undefined.
  10208. *
  10209. * @param {object} options Valid options are:<ul>
  10210. * <li>useMasterKey: In Cloud Code and Node only, causes the Master Key to
  10211. * be used for this request.
  10212. * <li>sessionToken: A valid session token, used for making a request on
  10213. * behalf of a specific user.
  10214. * <li>context: A dictionary that is accessible in Cloud Code `beforeFind` trigger.
  10215. * <li>json: Return raw json without converting to Parse.Object
  10216. * </ul>
  10217. * @returns {Promise} A promise that is resolved with the object when
  10218. * the query completes.
  10219. */
  10220. first() {
  10221. let options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
  10222. const findOptions = {};
  10223. if (options.hasOwnProperty('useMasterKey')) {
  10224. findOptions.useMasterKey = options.useMasterKey;
  10225. }
  10226. if (options.hasOwnProperty('sessionToken')) {
  10227. findOptions.sessionToken = options.sessionToken;
  10228. }
  10229. if (options.hasOwnProperty('context') && typeof options.context === 'object') {
  10230. findOptions.context = options.context;
  10231. }
  10232. this._setRequestTask(findOptions);
  10233. const controller = _CoreManager.default.getQueryController();
  10234. const params = this.toJSON();
  10235. params.limit = 1;
  10236. const select = this._select;
  10237. if (this._queriesLocalDatastore) {
  10238. return this._handleOfflineQuery(params).then(objects => {
  10239. if (!objects[0]) {
  10240. return undefined;
  10241. }
  10242. return objects[0];
  10243. });
  10244. }
  10245. return (0, _find.default)(controller).call(controller, this.className, params, findOptions).then(response => {
  10246. const objects = response.results;
  10247. if (!objects[0]) {
  10248. return undefined;
  10249. }
  10250. if (!objects[0].className) {
  10251. objects[0].className = this.className;
  10252. }
  10253. // Make sure the data object contains keys for all objects that
  10254. // have been requested with a select, so that our cached state
  10255. // updates correctly.
  10256. if (select) {
  10257. handleSelectResult(objects[0], select);
  10258. }
  10259. if (options.json) {
  10260. return objects[0];
  10261. } else {
  10262. return _ParseObject.default.fromJSON(objects[0], !select);
  10263. }
  10264. });
  10265. }
  10266. /**
  10267. * Iterates over objects matching a query, calling a callback for each batch.
  10268. * If the callback returns a promise, the iteration will not continue until
  10269. * that promise has been fulfilled. If the callback returns a rejected
  10270. * promise, then iteration will stop with that error. The items are processed
  10271. * in an unspecified order. The query may not have any sort order, and may
  10272. * not use limit or skip.
  10273. *
  10274. * @param {Function} callback Callback that will be called with each result
  10275. * of the query.
  10276. * @param {object} options Valid options are:<ul>
  10277. * <li>batchSize: How many objects to yield in each batch (default: 100)
  10278. * <li>useMasterKey: In Cloud Code and Node only, causes the Master Key to
  10279. * be used for this request.
  10280. * <li>sessionToken: A valid session token, used for making a request on
  10281. * behalf of a specific user.
  10282. * <li>context: A dictionary that is accessible in Cloud Code `beforeFind` trigger.
  10283. * </ul>
  10284. * @returns {Promise} A promise that will be fulfilled once the
  10285. * iteration has completed.
  10286. */
  10287. eachBatch(callback, options) {
  10288. options = options || {};
  10289. if (this._order || this._skip || this._limit >= 0) {
  10290. return _promise.default.reject('Cannot iterate on a query with sort, skip, or limit.');
  10291. }
  10292. const query = new ParseQuery(this.className);
  10293. query._limit = options.batchSize || 100;
  10294. query._include = [...this._include];
  10295. query._exclude = [...this._exclude];
  10296. if (this._select) {
  10297. query._select = [...this._select];
  10298. }
  10299. query._hint = this._hint;
  10300. query._where = {};
  10301. for (const attr in this._where) {
  10302. const val = this._where[attr];
  10303. if ((0, _isArray.default)(val)) {
  10304. query._where[attr] = (0, _map.default)(val).call(val, v => {
  10305. return v;
  10306. });
  10307. } else if (val && typeof val === 'object') {
  10308. const conditionMap = {};
  10309. query._where[attr] = conditionMap;
  10310. for (const cond in val) {
  10311. conditionMap[cond] = val[cond];
  10312. }
  10313. } else {
  10314. query._where[attr] = val;
  10315. }
  10316. }
  10317. query.ascending('objectId');
  10318. const findOptions = {};
  10319. if (options.hasOwnProperty('useMasterKey')) {
  10320. findOptions.useMasterKey = options.useMasterKey;
  10321. }
  10322. if (options.hasOwnProperty('sessionToken')) {
  10323. findOptions.sessionToken = options.sessionToken;
  10324. }
  10325. if (options.hasOwnProperty('context') && typeof options.context === 'object') {
  10326. findOptions.context = options.context;
  10327. }
  10328. if (options.hasOwnProperty('json')) {
  10329. findOptions.json = options.json;
  10330. }
  10331. let finished = false;
  10332. let previousResults = [];
  10333. return (0, _promiseUtils.continueWhile)(() => {
  10334. return !finished;
  10335. }, async () => {
  10336. const [results] = await _promise.default.all([(0, _find.default)(query).call(query, findOptions), _promise.default.resolve(previousResults.length > 0 && callback(previousResults))]);
  10337. if (results.length >= query._limit) {
  10338. query.greaterThan('objectId', results[results.length - 1].id);
  10339. previousResults = results;
  10340. } else if (results.length > 0) {
  10341. await _promise.default.resolve(callback(results));
  10342. finished = true;
  10343. } else {
  10344. finished = true;
  10345. }
  10346. });
  10347. }
  10348. /**
  10349. * Iterates over each result of a query, calling a callback for each one. If
  10350. * the callback returns a promise, the iteration will not continue until
  10351. * that promise has been fulfilled. If the callback returns a rejected
  10352. * promise, then iteration will stop with that error. The items are
  10353. * processed in an unspecified order. The query may not have any sort order,
  10354. * and may not use limit or skip.
  10355. *
  10356. * @param {Function} callback Callback that will be called with each result
  10357. * of the query.
  10358. * @param {object} options Valid options are:<ul>
  10359. * <li>useMasterKey: In Cloud Code and Node only, causes the Master Key to
  10360. * be used for this request.
  10361. * <li>sessionToken: A valid session token, used for making a request on
  10362. * behalf of a specific user.
  10363. * <li>json: Return raw json without converting to Parse.Object
  10364. * </ul>
  10365. * @returns {Promise} A promise that will be fulfilled once the
  10366. * iteration has completed.
  10367. */
  10368. each(callback, options) {
  10369. return this.eachBatch(results => {
  10370. let callbacksDone = _promise.default.resolve();
  10371. (0, _forEach.default)(results).call(results, result => {
  10372. callbacksDone = callbacksDone.then(() => {
  10373. return callback(result);
  10374. });
  10375. });
  10376. return callbacksDone;
  10377. }, options);
  10378. }
  10379. /**
  10380. * Adds a hint to force index selection. (https://docs.mongodb.com/manual/reference/operator/meta/hint/)
  10381. *
  10382. * @param {(string|object)} value String or Object of index that should be used when executing query
  10383. * @returns {Parse.Query} Returns the query, so you can chain this call.
  10384. */
  10385. hint(value) {
  10386. if (typeof value === 'undefined') {
  10387. delete this._hint;
  10388. }
  10389. this._hint = value;
  10390. return this;
  10391. }
  10392. /**
  10393. * Investigates the query execution plan. Useful for optimizing queries. (https://docs.mongodb.com/manual/reference/operator/meta/explain/)
  10394. *
  10395. * @param {boolean} explain Used to toggle the information on the query plan.
  10396. * @returns {Parse.Query} Returns the query, so you can chain this call.
  10397. */
  10398. explain() {
  10399. let explain = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : true;
  10400. if (typeof explain !== 'boolean') {
  10401. throw new Error('You can only set explain to a boolean value');
  10402. }
  10403. this._explain = explain;
  10404. return this;
  10405. }
  10406. /**
  10407. * Iterates over each result of a query, calling a callback for each one. If
  10408. * the callback returns a promise, the iteration will not continue until
  10409. * that promise has been fulfilled. If the callback returns a rejected
  10410. * promise, then iteration will stop with that error. The items are
  10411. * processed in an unspecified order. The query may not have any sort order,
  10412. * and may not use limit or skip.
  10413. *
  10414. * @param {Function} callback Callback <ul>
  10415. * <li>currentObject: The current Parse.Object being processed in the array.</li>
  10416. * <li>index: The index of the current Parse.Object being processed in the array.</li>
  10417. * <li>query: The query map was called upon.</li>
  10418. * </ul>
  10419. * @param {object} options Valid options are:<ul>
  10420. * <li>useMasterKey: In Cloud Code and Node only, causes the Master Key to
  10421. * be used for this request.
  10422. * <li>sessionToken: A valid session token, used for making a request on
  10423. * behalf of a specific user.
  10424. * </ul>
  10425. * @returns {Promise} A promise that will be fulfilled once the
  10426. * iteration has completed.
  10427. */
  10428. async map(callback, options) {
  10429. const array = [];
  10430. let index = 0;
  10431. await this.each(object => {
  10432. return _promise.default.resolve(callback(object, index, this)).then(result => {
  10433. array.push(result);
  10434. index += 1;
  10435. });
  10436. }, options);
  10437. return array;
  10438. }
  10439. /**
  10440. * Iterates over each result of a query, calling a callback for each one. If
  10441. * the callback returns a promise, the iteration will not continue until
  10442. * that promise has been fulfilled. If the callback returns a rejected
  10443. * promise, then iteration will stop with that error. The items are
  10444. * processed in an unspecified order. The query may not have any sort order,
  10445. * and may not use limit or skip.
  10446. *
  10447. * @param {Function} callback Callback <ul>
  10448. * <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>
  10449. * <li>currentObject: The current Parse.Object being processed in the array.</li>
  10450. * <li>index: The index of the current Parse.Object being processed in the array.</li>
  10451. * </ul>
  10452. * @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.
  10453. * @param {object} options Valid options are:<ul>
  10454. * <li>useMasterKey: In Cloud Code and Node only, causes the Master Key to
  10455. * be used for this request.
  10456. * <li>sessionToken: A valid session token, used for making a request on
  10457. * behalf of a specific user.
  10458. * </ul>
  10459. * @returns {Promise} A promise that will be fulfilled once the
  10460. * iteration has completed.
  10461. */
  10462. async reduce(callback, initialValue, options) {
  10463. let accumulator = initialValue;
  10464. let index = 0;
  10465. await this.each(object => {
  10466. // If no initial value was given, we take the first object from the query
  10467. // as the initial value and don't call the callback with it.
  10468. if (index === 0 && initialValue === undefined) {
  10469. accumulator = object;
  10470. index += 1;
  10471. return;
  10472. }
  10473. return _promise.default.resolve(callback(accumulator, object, index)).then(result => {
  10474. accumulator = result;
  10475. index += 1;
  10476. });
  10477. }, options);
  10478. if (index === 0 && initialValue === undefined) {
  10479. // Match Array.reduce behavior: "Calling reduce() on an empty array
  10480. // without an initialValue will throw a TypeError".
  10481. throw new TypeError('Reducing empty query result set with no initial value');
  10482. }
  10483. return accumulator;
  10484. }
  10485. /**
  10486. * Iterates over each result of a query, calling a callback for each one. If
  10487. * the callback returns a promise, the iteration will not continue until
  10488. * that promise has been fulfilled. If the callback returns a rejected
  10489. * promise, then iteration will stop with that error. The items are
  10490. * processed in an unspecified order. The query may not have any sort order,
  10491. * and may not use limit or skip.
  10492. *
  10493. * @param {Function} callback Callback <ul>
  10494. * <li>currentObject: The current Parse.Object being processed in the array.</li>
  10495. * <li>index: The index of the current Parse.Object being processed in the array.</li>
  10496. * <li>query: The query filter was called upon.</li>
  10497. * </ul>
  10498. * @param {object} options Valid options are:<ul>
  10499. * <li>useMasterKey: In Cloud Code and Node only, causes the Master Key to
  10500. * be used for this request.
  10501. * <li>sessionToken: A valid session token, used for making a request on
  10502. * behalf of a specific user.
  10503. * </ul>
  10504. * @returns {Promise} A promise that will be fulfilled once the
  10505. * iteration has completed.
  10506. */
  10507. async filter(callback, options) {
  10508. const array = [];
  10509. let index = 0;
  10510. await this.each(object => {
  10511. return _promise.default.resolve(callback(object, index, this)).then(flag => {
  10512. if (flag) {
  10513. array.push(object);
  10514. }
  10515. index += 1;
  10516. });
  10517. }, options);
  10518. return array;
  10519. }
  10520. /* Query Conditions */
  10521. /**
  10522. * Adds a constraint to the query that requires a particular key's value to
  10523. * be equal to the provided value.
  10524. *
  10525. * @param {string} key The key to check.
  10526. * @param value The value that the Parse.Object must contain.
  10527. * @returns {Parse.Query} Returns the query, so you can chain this call.
  10528. */
  10529. equalTo(key, value) {
  10530. if (key && typeof key === 'object') {
  10531. var _context4;
  10532. (0, _forEach.default)(_context4 = (0, _entries.default)(key)).call(_context4, _ref => {
  10533. let [k, val] = _ref;
  10534. return this.equalTo(k, val);
  10535. });
  10536. return this;
  10537. }
  10538. if (typeof value === 'undefined') {
  10539. return this.doesNotExist(key);
  10540. }
  10541. this._where[key] = (0, _encode.default)(value, false, true);
  10542. return this;
  10543. }
  10544. /**
  10545. * Adds a constraint to the query that requires a particular key's value to
  10546. * be not equal to the provided value.
  10547. *
  10548. * @param {string} key The key to check.
  10549. * @param value The value that must not be equalled.
  10550. * @returns {Parse.Query} Returns the query, so you can chain this call.
  10551. */
  10552. notEqualTo(key, value) {
  10553. if (key && typeof key === 'object') {
  10554. var _context5;
  10555. (0, _forEach.default)(_context5 = (0, _entries.default)(key)).call(_context5, _ref2 => {
  10556. let [k, val] = _ref2;
  10557. return this.notEqualTo(k, val);
  10558. });
  10559. return this;
  10560. }
  10561. return this._addCondition(key, '$ne', value);
  10562. }
  10563. /**
  10564. * Adds a constraint to the query that requires a particular key's value to
  10565. * be less than the provided value.
  10566. *
  10567. * @param {string} key The key to check.
  10568. * @param value The value that provides an upper bound.
  10569. * @returns {Parse.Query} Returns the query, so you can chain this call.
  10570. */
  10571. lessThan(key, value) {
  10572. return this._addCondition(key, '$lt', value);
  10573. }
  10574. /**
  10575. * Adds a constraint to the query that requires a particular key's value to
  10576. * be greater than the provided value.
  10577. *
  10578. * @param {string} key The key to check.
  10579. * @param value The value that provides an lower bound.
  10580. * @returns {Parse.Query} Returns the query, so you can chain this call.
  10581. */
  10582. greaterThan(key, value) {
  10583. return this._addCondition(key, '$gt', value);
  10584. }
  10585. /**
  10586. * Adds a constraint to the query that requires a particular key's value to
  10587. * be less than or equal to the provided value.
  10588. *
  10589. * @param {string} key The key to check.
  10590. * @param value The value that provides an upper bound.
  10591. * @returns {Parse.Query} Returns the query, so you can chain this call.
  10592. */
  10593. lessThanOrEqualTo(key, value) {
  10594. return this._addCondition(key, '$lte', value);
  10595. }
  10596. /**
  10597. * Adds a constraint to the query that requires a particular key's value to
  10598. * be greater than or equal to the provided value.
  10599. *
  10600. * @param {string} key The key to check.
  10601. * @param {*} value The value that provides an lower bound.
  10602. * @returns {Parse.Query} Returns the query, so you can chain this call.
  10603. */
  10604. greaterThanOrEqualTo(key, value) {
  10605. return this._addCondition(key, '$gte', value);
  10606. }
  10607. /**
  10608. * Adds a constraint to the query that requires a particular key's value to
  10609. * be contained in the provided list of values.
  10610. *
  10611. * @param {string} key The key to check.
  10612. * @param {Array<*>} value The values that will match.
  10613. * @returns {Parse.Query} Returns the query, so you can chain this call.
  10614. */
  10615. containedIn(key, value) {
  10616. return this._addCondition(key, '$in', value);
  10617. }
  10618. /**
  10619. * Adds a constraint to the query that requires a particular key's value to
  10620. * not be contained in the provided list of values.
  10621. *
  10622. * @param {string} key The key to check.
  10623. * @param {Array<*>} value The values that will not match.
  10624. * @returns {Parse.Query} Returns the query, so you can chain this call.
  10625. */
  10626. notContainedIn(key, value) {
  10627. return this._addCondition(key, '$nin', value);
  10628. }
  10629. /**
  10630. * Adds a constraint to the query that requires a particular key's value to
  10631. * be contained by the provided list of values. Get objects where all array elements match.
  10632. *
  10633. * @param {string} key The key to check.
  10634. * @param {Array} values The values that will match.
  10635. * @returns {Parse.Query} Returns the query, so you can chain this call.
  10636. */
  10637. containedBy(key, values) {
  10638. return this._addCondition(key, '$containedBy', values);
  10639. }
  10640. /**
  10641. * Adds a constraint to the query that requires a particular key's value to
  10642. * contain each one of the provided list of values.
  10643. *
  10644. * @param {string} key The key to check. This key's value must be an array.
  10645. * @param {Array} values The values that will match.
  10646. * @returns {Parse.Query} Returns the query, so you can chain this call.
  10647. */
  10648. containsAll(key, values) {
  10649. return this._addCondition(key, '$all', values);
  10650. }
  10651. /**
  10652. * Adds a constraint to the query that requires a particular key's value to
  10653. * contain each one of the provided list of values starting with given strings.
  10654. *
  10655. * @param {string} key The key to check. This key's value must be an array.
  10656. * @param {Array<string>} values The string values that will match as starting string.
  10657. * @returns {Parse.Query} Returns the query, so you can chain this call.
  10658. */
  10659. containsAllStartingWith(key, values) {
  10660. if (!(0, _isArray.default)(values)) {
  10661. values = [values];
  10662. }
  10663. const regexObject = (0, _map.default)(values).call(values, value => {
  10664. return {
  10665. $regex: this._regexStartWith(value)
  10666. };
  10667. });
  10668. return this.containsAll(key, regexObject);
  10669. }
  10670. /**
  10671. * Adds a constraint for finding objects that contain the given key.
  10672. *
  10673. * @param {string} key The key that should exist.
  10674. * @returns {Parse.Query} Returns the query, so you can chain this call.
  10675. */
  10676. exists(key) {
  10677. return this._addCondition(key, '$exists', true);
  10678. }
  10679. /**
  10680. * Adds a constraint for finding objects that do not contain a given key.
  10681. *
  10682. * @param {string} key The key that should not exist
  10683. * @returns {Parse.Query} Returns the query, so you can chain this call.
  10684. */
  10685. doesNotExist(key) {
  10686. return this._addCondition(key, '$exists', false);
  10687. }
  10688. /**
  10689. * Adds a regular expression constraint for finding string values that match
  10690. * the provided regular expression.
  10691. * This may be slow for large datasets.
  10692. *
  10693. * @param {string} key The key that the string to match is stored in.
  10694. * @param {RegExp | string} regex The regular expression pattern to match.
  10695. * @param {string} modifiers The regular expression mode.
  10696. * @returns {Parse.Query} Returns the query, so you can chain this call.
  10697. */
  10698. matches(key, regex, modifiers) {
  10699. this._addCondition(key, '$regex', regex);
  10700. if (!modifiers) {
  10701. modifiers = '';
  10702. }
  10703. if (typeof regex !== 'string') {
  10704. if (regex.ignoreCase) {
  10705. modifiers += 'i';
  10706. }
  10707. if (regex.multiline) {
  10708. modifiers += 'm';
  10709. }
  10710. }
  10711. if (modifiers.length) {
  10712. this._addCondition(key, '$options', modifiers);
  10713. }
  10714. return this;
  10715. }
  10716. /**
  10717. * Adds a constraint that requires that a key's value matches a Parse.Query
  10718. * constraint.
  10719. *
  10720. * @param {string} key The key that the contains the object to match the
  10721. * query.
  10722. * @param {Parse.Query} query The query that should match.
  10723. * @returns {Parse.Query} Returns the query, so you can chain this call.
  10724. */
  10725. matchesQuery(key, query) {
  10726. const queryJSON = query.toJSON();
  10727. queryJSON.className = query.className;
  10728. return this._addCondition(key, '$inQuery', queryJSON);
  10729. }
  10730. /**
  10731. * Adds a constraint that requires that a key's value not matches a
  10732. * Parse.Query constraint.
  10733. *
  10734. * @param {string} key The key that the contains the object to match the
  10735. * query.
  10736. * @param {Parse.Query} query The query that should not match.
  10737. * @returns {Parse.Query} Returns the query, so you can chain this call.
  10738. */
  10739. doesNotMatchQuery(key, query) {
  10740. const queryJSON = query.toJSON();
  10741. queryJSON.className = query.className;
  10742. return this._addCondition(key, '$notInQuery', queryJSON);
  10743. }
  10744. /**
  10745. * Adds a constraint that requires that a key's value matches a value in
  10746. * an object returned by a different Parse.Query.
  10747. *
  10748. * @param {string} key The key that contains the value that is being
  10749. * matched.
  10750. * @param {string} queryKey The key in the objects returned by the query to
  10751. * match against.
  10752. * @param {Parse.Query} query The query to run.
  10753. * @returns {Parse.Query} Returns the query, so you can chain this call.
  10754. */
  10755. matchesKeyInQuery(key, queryKey, query) {
  10756. const queryJSON = query.toJSON();
  10757. queryJSON.className = query.className;
  10758. return this._addCondition(key, '$select', {
  10759. key: queryKey,
  10760. query: queryJSON
  10761. });
  10762. }
  10763. /**
  10764. * Adds a constraint that requires that a key's value not match a value in
  10765. * an object returned by a different Parse.Query.
  10766. *
  10767. * @param {string} key The key that contains the value that is being
  10768. * excluded.
  10769. * @param {string} queryKey The key in the objects returned by the query to
  10770. * match against.
  10771. * @param {Parse.Query} query The query to run.
  10772. * @returns {Parse.Query} Returns the query, so you can chain this call.
  10773. */
  10774. doesNotMatchKeyInQuery(key, queryKey, query) {
  10775. const queryJSON = query.toJSON();
  10776. queryJSON.className = query.className;
  10777. return this._addCondition(key, '$dontSelect', {
  10778. key: queryKey,
  10779. query: queryJSON
  10780. });
  10781. }
  10782. /**
  10783. * Adds a constraint for finding string values that contain a provided
  10784. * string. This may be slow for large datasets.
  10785. *
  10786. * @param {string} key The key that the string to match is stored in.
  10787. * @param {string} substring The substring that the value must contain.
  10788. * @returns {Parse.Query} Returns the query, so you can chain this call.
  10789. */
  10790. contains(key, substring) {
  10791. if (typeof substring !== 'string') {
  10792. throw new Error('The value being searched for must be a string.');
  10793. }
  10794. return this._addCondition(key, '$regex', quote(substring));
  10795. }
  10796. /**
  10797. * Adds a constraint for finding string values that contain a provided
  10798. * string. This may be slow for large datasets. Requires Parse-Server > 2.5.0
  10799. *
  10800. * In order to sort you must use select and ascending ($score is required)
  10801. * <pre>
  10802. * query.fullText('field', 'term');
  10803. * query.ascending('$score');
  10804. * query.select('$score');
  10805. * </pre>
  10806. *
  10807. * To retrieve the weight / rank
  10808. * <pre>
  10809. * object->get('score');
  10810. * </pre>
  10811. *
  10812. * You can define optionals by providing an object as a third parameter
  10813. * <pre>
  10814. * query.fullText('field', 'term', { language: 'es', diacriticSensitive: true });
  10815. * </pre>
  10816. *
  10817. * @param {string} key The key that the string to match is stored in.
  10818. * @param {string} value The string to search
  10819. * @param {object} options (Optional)
  10820. * @param {string} options.language The language that determines the list of stop words for the search and the rules for the stemmer and tokenizer.
  10821. * @param {boolean} options.caseSensitive A boolean flag to enable or disable case sensitive search.
  10822. * @param {boolean} options.diacriticSensitive A boolean flag to enable or disable diacritic sensitive search.
  10823. * @returns {Parse.Query} Returns the query, so you can chain this call.
  10824. */
  10825. fullText(key, value) {
  10826. let options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
  10827. options = options || {};
  10828. if (!key) {
  10829. throw new Error('A key is required.');
  10830. }
  10831. if (!value) {
  10832. throw new Error('A search term is required');
  10833. }
  10834. if (typeof value !== 'string') {
  10835. throw new Error('The value being searched for must be a string.');
  10836. }
  10837. const fullOptions = {};
  10838. fullOptions.$term = value;
  10839. for (const option in options) {
  10840. switch (option) {
  10841. case 'language':
  10842. fullOptions.$language = options[option];
  10843. break;
  10844. case 'caseSensitive':
  10845. fullOptions.$caseSensitive = options[option];
  10846. break;
  10847. case 'diacriticSensitive':
  10848. fullOptions.$diacriticSensitive = options[option];
  10849. break;
  10850. default:
  10851. throw new Error(`Unknown option: ${option}`);
  10852. }
  10853. }
  10854. return this._addCondition(key, '$text', {
  10855. $search: fullOptions
  10856. });
  10857. }
  10858. /**
  10859. * Method to sort the full text search by text score
  10860. *
  10861. * @returns {Parse.Query} Returns the query, so you can chain this call.
  10862. */
  10863. sortByTextScore() {
  10864. this.ascending('$score');
  10865. this.select(['$score']);
  10866. return this;
  10867. }
  10868. /**
  10869. * Adds a constraint for finding string values that start with a provided
  10870. * string. This query will use the backend index, so it will be fast even
  10871. * for large datasets.
  10872. *
  10873. * @param {string} key The key that the string to match is stored in.
  10874. * @param {string} prefix The substring that the value must start with.
  10875. * @param {string} modifiers The regular expression mode.
  10876. * @returns {Parse.Query} Returns the query, so you can chain this call.
  10877. */
  10878. startsWith(key, prefix, modifiers) {
  10879. if (typeof prefix !== 'string') {
  10880. throw new Error('The value being searched for must be a string.');
  10881. }
  10882. return this.matches(key, this._regexStartWith(prefix), modifiers);
  10883. }
  10884. /**
  10885. * Adds a constraint for finding string values that end with a provided
  10886. * string. This will be slow for large datasets.
  10887. *
  10888. * @param {string} key The key that the string to match is stored in.
  10889. * @param {string} suffix The substring that the value must end with.
  10890. * @param {string} modifiers The regular expression mode.
  10891. * @returns {Parse.Query} Returns the query, so you can chain this call.
  10892. */
  10893. endsWith(key, suffix, modifiers) {
  10894. if (typeof suffix !== 'string') {
  10895. throw new Error('The value being searched for must be a string.');
  10896. }
  10897. return this.matches(key, quote(suffix) + '$', modifiers);
  10898. }
  10899. /**
  10900. * Adds a proximity based constraint for finding objects with key point
  10901. * values near the point given.
  10902. *
  10903. * @param {string} key The key that the Parse.GeoPoint is stored in.
  10904. * @param {Parse.GeoPoint} point The reference Parse.GeoPoint that is used.
  10905. * @returns {Parse.Query} Returns the query, so you can chain this call.
  10906. */
  10907. near(key, point) {
  10908. if (!(point instanceof _ParseGeoPoint.default)) {
  10909. // Try to cast it as a GeoPoint
  10910. point = new _ParseGeoPoint.default(point);
  10911. }
  10912. return this._addCondition(key, '$nearSphere', point);
  10913. }
  10914. /**
  10915. * Adds a proximity based constraint for finding objects with key point
  10916. * values near the point given and within the maximum distance given.
  10917. *
  10918. * @param {string} key The key that the Parse.GeoPoint is stored in.
  10919. * @param {Parse.GeoPoint} point The reference Parse.GeoPoint that is used.
  10920. * @param {number} maxDistance Maximum distance (in radians) of results to return.
  10921. * @param {boolean} sorted A Bool value that is true if results should be
  10922. * sorted by distance ascending, false is no sorting is required,
  10923. * defaults to true.
  10924. * @returns {Parse.Query} Returns the query, so you can chain this call.
  10925. */
  10926. withinRadians(key, point, maxDistance, sorted) {
  10927. if (sorted || sorted === undefined) {
  10928. this.near(key, point);
  10929. return this._addCondition(key, '$maxDistance', maxDistance);
  10930. } else {
  10931. return this._addCondition(key, '$geoWithin', {
  10932. $centerSphere: [[point.longitude, point.latitude], maxDistance]
  10933. });
  10934. }
  10935. }
  10936. /**
  10937. * Adds a proximity based constraint for finding objects with key point
  10938. * values near the point given and within the maximum distance given.
  10939. * Radius of earth used is 3958.8 miles.
  10940. *
  10941. * @param {string} key The key that the Parse.GeoPoint is stored in.
  10942. * @param {Parse.GeoPoint} point The reference Parse.GeoPoint that is used.
  10943. * @param {number} maxDistance Maximum distance (in miles) of results to return.
  10944. * @param {boolean} sorted A Bool value that is true if results should be
  10945. * sorted by distance ascending, false is no sorting is required,
  10946. * defaults to true.
  10947. * @returns {Parse.Query} Returns the query, so you can chain this call.
  10948. */
  10949. withinMiles(key, point, maxDistance, sorted) {
  10950. return this.withinRadians(key, point, maxDistance / 3958.8, sorted);
  10951. }
  10952. /**
  10953. * Adds a proximity based constraint for finding objects with key point
  10954. * values near the point given and within the maximum distance given.
  10955. * Radius of earth used is 6371.0 kilometers.
  10956. *
  10957. * @param {string} key The key that the Parse.GeoPoint is stored in.
  10958. * @param {Parse.GeoPoint} point The reference Parse.GeoPoint that is used.
  10959. * @param {number} maxDistance Maximum distance (in kilometers) of results to return.
  10960. * @param {boolean} sorted A Bool value that is true if results should be
  10961. * sorted by distance ascending, false is no sorting is required,
  10962. * defaults to true.
  10963. * @returns {Parse.Query} Returns the query, so you can chain this call.
  10964. */
  10965. withinKilometers(key, point, maxDistance, sorted) {
  10966. return this.withinRadians(key, point, maxDistance / 6371.0, sorted);
  10967. }
  10968. /**
  10969. * Adds a constraint to the query that requires a particular key's
  10970. * coordinates be contained within a given rectangular geographic bounding
  10971. * box.
  10972. *
  10973. * @param {string} key The key to be constrained.
  10974. * @param {Parse.GeoPoint} southwest
  10975. * The lower-left inclusive corner of the box.
  10976. * @param {Parse.GeoPoint} northeast
  10977. * The upper-right inclusive corner of the box.
  10978. * @returns {Parse.Query} Returns the query, so you can chain this call.
  10979. */
  10980. withinGeoBox(key, southwest, northeast) {
  10981. if (!(southwest instanceof _ParseGeoPoint.default)) {
  10982. southwest = new _ParseGeoPoint.default(southwest);
  10983. }
  10984. if (!(northeast instanceof _ParseGeoPoint.default)) {
  10985. northeast = new _ParseGeoPoint.default(northeast);
  10986. }
  10987. this._addCondition(key, '$within', {
  10988. $box: [southwest, northeast]
  10989. });
  10990. return this;
  10991. }
  10992. /**
  10993. * Adds a constraint to the query that requires a particular key's
  10994. * coordinates be contained within and on the bounds of a given polygon.
  10995. * Supports closed and open (last point is connected to first) paths
  10996. *
  10997. * Polygon must have at least 3 points
  10998. *
  10999. * @param {string} key The key to be constrained.
  11000. * @param {Array} points Array of Coordinates / GeoPoints
  11001. * @returns {Parse.Query} Returns the query, so you can chain this call.
  11002. */
  11003. withinPolygon(key, points) {
  11004. return this._addCondition(key, '$geoWithin', {
  11005. $polygon: points
  11006. });
  11007. }
  11008. /**
  11009. * Add a constraint to the query that requires a particular key's
  11010. * coordinates that contains a ParseGeoPoint
  11011. *
  11012. * @param {string} key The key to be constrained.
  11013. * @param {Parse.GeoPoint} point
  11014. * @returns {Parse.Query} Returns the query, so you can chain this call.
  11015. */
  11016. polygonContains(key, point) {
  11017. return this._addCondition(key, '$geoIntersects', {
  11018. $point: point
  11019. });
  11020. }
  11021. /* Query Orderings */
  11022. /**
  11023. * Sorts the results in ascending order by the given key.
  11024. *
  11025. * @param {(string|string[])} keys The key to order by, which is a
  11026. * string of comma separated values, or an Array of keys, or multiple keys.
  11027. * @returns {Parse.Query} Returns the query, so you can chain this call.
  11028. */
  11029. ascending() {
  11030. this._order = [];
  11031. for (var _len = arguments.length, keys = new Array(_len), _key = 0; _key < _len; _key++) {
  11032. keys[_key] = arguments[_key];
  11033. }
  11034. return this.addAscending.apply(this, keys);
  11035. }
  11036. /**
  11037. * Sorts the results in ascending order by the given key,
  11038. * but can also add secondary sort descriptors without overwriting _order.
  11039. *
  11040. * @param {(string|string[])} keys The key to order by, which is a
  11041. * string of comma separated values, or an Array of keys, or multiple keys.
  11042. * @returns {Parse.Query} Returns the query, so you can chain this call.
  11043. */
  11044. addAscending() {
  11045. if (!this._order) {
  11046. this._order = [];
  11047. }
  11048. for (var _len2 = arguments.length, keys = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
  11049. keys[_key2] = arguments[_key2];
  11050. }
  11051. (0, _forEach.default)(keys).call(keys, key => {
  11052. var _context6;
  11053. if ((0, _isArray.default)(key)) {
  11054. key = key.join();
  11055. }
  11056. this._order = (0, _concat.default)(_context6 = this._order).call(_context6, key.replace(/\s/g, '').split(','));
  11057. });
  11058. return this;
  11059. }
  11060. /**
  11061. * Sorts the results in descending order by the given key.
  11062. *
  11063. * @param {(string|string[])} keys The key to order by, which is a
  11064. * string of comma separated values, or an Array of keys, or multiple keys.
  11065. * @returns {Parse.Query} Returns the query, so you can chain this call.
  11066. */
  11067. descending() {
  11068. this._order = [];
  11069. for (var _len3 = arguments.length, keys = new Array(_len3), _key3 = 0; _key3 < _len3; _key3++) {
  11070. keys[_key3] = arguments[_key3];
  11071. }
  11072. return this.addDescending.apply(this, keys);
  11073. }
  11074. /**
  11075. * Sorts the results in descending order by the given key,
  11076. * but can also add secondary sort descriptors without overwriting _order.
  11077. *
  11078. * @param {(string|string[])} keys The key to order by, which is a
  11079. * string of comma separated values, or an Array of keys, or multiple keys.
  11080. * @returns {Parse.Query} Returns the query, so you can chain this call.
  11081. */
  11082. addDescending() {
  11083. if (!this._order) {
  11084. this._order = [];
  11085. }
  11086. for (var _len4 = arguments.length, keys = new Array(_len4), _key4 = 0; _key4 < _len4; _key4++) {
  11087. keys[_key4] = arguments[_key4];
  11088. }
  11089. (0, _forEach.default)(keys).call(keys, key => {
  11090. var _context7, _context8;
  11091. if ((0, _isArray.default)(key)) {
  11092. key = key.join();
  11093. }
  11094. this._order = (0, _concat.default)(_context7 = this._order).call(_context7, (0, _map.default)(_context8 = key.replace(/\s/g, '').split(',')).call(_context8, k => {
  11095. return '-' + k;
  11096. }));
  11097. });
  11098. return this;
  11099. }
  11100. /* Query Options */
  11101. /**
  11102. * Sets the number of results to skip before returning any results.
  11103. * This is useful for pagination.
  11104. * Default is to skip zero results.
  11105. *
  11106. * @param {number} n the number of results to skip.
  11107. * @returns {Parse.Query} Returns the query, so you can chain this call.
  11108. */
  11109. skip(n) {
  11110. if (typeof n !== 'number' || n < 0) {
  11111. throw new Error('You can only skip by a positive number');
  11112. }
  11113. this._skip = n;
  11114. return this;
  11115. }
  11116. /**
  11117. * Sets the limit of the number of results to return. The default limit is 100.
  11118. *
  11119. * @param {number} n the number of results to limit to.
  11120. * @returns {Parse.Query} Returns the query, so you can chain this call.
  11121. */
  11122. limit(n) {
  11123. if (typeof n !== 'number') {
  11124. throw new Error('You can only set the limit to a numeric value');
  11125. }
  11126. this._limit = n;
  11127. return this;
  11128. }
  11129. /**
  11130. * Sets the flag to include with response the total number of objects satisfying this query,
  11131. * despite limits/skip. Might be useful for pagination.
  11132. * Note that result of this query will be wrapped as an object with
  11133. * `results`: holding {ParseObject} array and `count`: integer holding total number
  11134. *
  11135. * @param {boolean} includeCount false - disable, true - enable.
  11136. * @returns {Parse.Query} Returns the query, so you can chain this call.
  11137. */
  11138. withCount() {
  11139. let includeCount = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : true;
  11140. if (typeof includeCount !== 'boolean') {
  11141. throw new Error('You can only set withCount to a boolean value');
  11142. }
  11143. this._count = includeCount;
  11144. return this;
  11145. }
  11146. /**
  11147. * Includes nested Parse.Objects for the provided key. You can use dot
  11148. * notation to specify which fields in the included object are also fetched.
  11149. *
  11150. * You can include all nested Parse.Objects by passing in '*'.
  11151. * Requires Parse Server 3.0.0+
  11152. * <pre>query.include('*');</pre>
  11153. *
  11154. * @param {...string|Array<string>} keys The name(s) of the key(s) to include.
  11155. * @returns {Parse.Query} Returns the query, so you can chain this call.
  11156. */
  11157. include() {
  11158. for (var _len5 = arguments.length, keys = new Array(_len5), _key5 = 0; _key5 < _len5; _key5++) {
  11159. keys[_key5] = arguments[_key5];
  11160. }
  11161. (0, _forEach.default)(keys).call(keys, key => {
  11162. if ((0, _isArray.default)(key)) {
  11163. var _context9;
  11164. this._include = (0, _concat.default)(_context9 = this._include).call(_context9, key);
  11165. } else {
  11166. this._include.push(key);
  11167. }
  11168. });
  11169. return this;
  11170. }
  11171. /**
  11172. * Includes all nested Parse.Objects one level deep.
  11173. *
  11174. * Requires Parse Server 3.0.0+
  11175. *
  11176. * @returns {Parse.Query} Returns the query, so you can chain this call.
  11177. */
  11178. includeAll() {
  11179. return this.include('*');
  11180. }
  11181. /**
  11182. * Restricts the fields of the returned Parse.Objects to include only the
  11183. * provided keys. If this is called multiple times, then all of the keys
  11184. * specified in each of the calls will be included.
  11185. *
  11186. * @param {...string|Array<string>} keys The name(s) of the key(s) to include.
  11187. * @returns {Parse.Query} Returns the query, so you can chain this call.
  11188. */
  11189. select() {
  11190. if (!this._select) {
  11191. this._select = [];
  11192. }
  11193. for (var _len6 = arguments.length, keys = new Array(_len6), _key6 = 0; _key6 < _len6; _key6++) {
  11194. keys[_key6] = arguments[_key6];
  11195. }
  11196. (0, _forEach.default)(keys).call(keys, key => {
  11197. if ((0, _isArray.default)(key)) {
  11198. var _context10;
  11199. this._select = (0, _concat.default)(_context10 = this._select).call(_context10, key);
  11200. } else {
  11201. this._select.push(key);
  11202. }
  11203. });
  11204. return this;
  11205. }
  11206. /**
  11207. * Restricts the fields of the returned Parse.Objects to all keys except the
  11208. * provided keys. Exclude takes precedence over select and include.
  11209. *
  11210. * Requires Parse Server 3.6.0+
  11211. *
  11212. * @param {...string|Array<string>} keys The name(s) of the key(s) to exclude.
  11213. * @returns {Parse.Query} Returns the query, so you can chain this call.
  11214. */
  11215. exclude() {
  11216. for (var _len7 = arguments.length, keys = new Array(_len7), _key7 = 0; _key7 < _len7; _key7++) {
  11217. keys[_key7] = arguments[_key7];
  11218. }
  11219. (0, _forEach.default)(keys).call(keys, key => {
  11220. if ((0, _isArray.default)(key)) {
  11221. var _context11;
  11222. this._exclude = (0, _concat.default)(_context11 = this._exclude).call(_context11, key);
  11223. } else {
  11224. this._exclude.push(key);
  11225. }
  11226. });
  11227. return this;
  11228. }
  11229. /**
  11230. * Restricts live query to trigger only for watched fields.
  11231. *
  11232. * Requires Parse Server 6.0.0+
  11233. *
  11234. * @param {...string|Array<string>} keys The name(s) of the key(s) to watch.
  11235. * @returns {Parse.Query} Returns the query, so you can chain this call.
  11236. */
  11237. watch() {
  11238. for (var _len8 = arguments.length, keys = new Array(_len8), _key8 = 0; _key8 < _len8; _key8++) {
  11239. keys[_key8] = arguments[_key8];
  11240. }
  11241. (0, _forEach.default)(keys).call(keys, key => {
  11242. if ((0, _isArray.default)(key)) {
  11243. var _context12;
  11244. this._watch = (0, _concat.default)(_context12 = this._watch).call(_context12, key);
  11245. } else {
  11246. this._watch.push(key);
  11247. }
  11248. });
  11249. return this;
  11250. }
  11251. /**
  11252. * Changes the read preference that the backend will use when performing the query to the database.
  11253. *
  11254. * @param {string} readPreference The read preference for the main query.
  11255. * @param {string} includeReadPreference The read preference for the queries to include pointers.
  11256. * @param {string} subqueryReadPreference The read preference for the sub queries.
  11257. * @returns {Parse.Query} Returns the query, so you can chain this call.
  11258. */
  11259. readPreference(readPreference, includeReadPreference, subqueryReadPreference) {
  11260. this._readPreference = readPreference;
  11261. this._includeReadPreference = includeReadPreference || null;
  11262. this._subqueryReadPreference = subqueryReadPreference || null;
  11263. return this;
  11264. }
  11265. /**
  11266. * Subscribe this query to get liveQuery updates
  11267. *
  11268. * @param {string} sessionToken (optional) Defaults to the currentUser
  11269. * @returns {Promise<LiveQuerySubscription>} Returns the liveQuerySubscription, it's an event emitter
  11270. * which can be used to get liveQuery updates.
  11271. */
  11272. async subscribe(sessionToken) {
  11273. const currentUser = await _CoreManager.default.getUserController().currentUserAsync();
  11274. if (!sessionToken) {
  11275. sessionToken = currentUser ? currentUser.getSessionToken() || undefined : undefined;
  11276. }
  11277. const liveQueryClient = await _CoreManager.default.getLiveQueryController().getDefaultLiveQueryClient();
  11278. if (liveQueryClient.shouldOpen()) {
  11279. liveQueryClient.open();
  11280. }
  11281. const subscription = liveQueryClient.subscribe(this, sessionToken);
  11282. return subscription.subscribePromise.then(() => {
  11283. return subscription;
  11284. });
  11285. }
  11286. /**
  11287. * Constructs a Parse.Query that is the OR of the passed in queries. For
  11288. * example:
  11289. * <pre>var compoundQuery = Parse.Query.or(query1, query2, query3);</pre>
  11290. *
  11291. * will create a compoundQuery that is an or of the query1, query2, and
  11292. * query3.
  11293. *
  11294. * @param {...Parse.Query} queries The list of queries to OR.
  11295. * @static
  11296. * @returns {Parse.Query} The query that is the OR of the passed in queries.
  11297. */
  11298. static or() {
  11299. for (var _len9 = arguments.length, queries = new Array(_len9), _key9 = 0; _key9 < _len9; _key9++) {
  11300. queries[_key9] = arguments[_key9];
  11301. }
  11302. const className = _getClassNameFromQueries(queries);
  11303. const query = new ParseQuery(className);
  11304. query._orQuery(queries);
  11305. return query;
  11306. }
  11307. /**
  11308. * Constructs a Parse.Query that is the AND of the passed in queries. For
  11309. * example:
  11310. * <pre>var compoundQuery = Parse.Query.and(query1, query2, query3);</pre>
  11311. *
  11312. * will create a compoundQuery that is an and of the query1, query2, and
  11313. * query3.
  11314. *
  11315. * @param {...Parse.Query} queries The list of queries to AND.
  11316. * @static
  11317. * @returns {Parse.Query} The query that is the AND of the passed in queries.
  11318. */
  11319. static and() {
  11320. for (var _len10 = arguments.length, queries = new Array(_len10), _key10 = 0; _key10 < _len10; _key10++) {
  11321. queries[_key10] = arguments[_key10];
  11322. }
  11323. const className = _getClassNameFromQueries(queries);
  11324. const query = new ParseQuery(className);
  11325. query._andQuery(queries);
  11326. return query;
  11327. }
  11328. /**
  11329. * Constructs a Parse.Query that is the NOR of the passed in queries. For
  11330. * example:
  11331. * <pre>const compoundQuery = Parse.Query.nor(query1, query2, query3);</pre>
  11332. *
  11333. * will create a compoundQuery that is a nor of the query1, query2, and
  11334. * query3.
  11335. *
  11336. * @param {...Parse.Query} queries The list of queries to NOR.
  11337. * @static
  11338. * @returns {Parse.Query} The query that is the NOR of the passed in queries.
  11339. */
  11340. static nor() {
  11341. for (var _len11 = arguments.length, queries = new Array(_len11), _key11 = 0; _key11 < _len11; _key11++) {
  11342. queries[_key11] = arguments[_key11];
  11343. }
  11344. const className = _getClassNameFromQueries(queries);
  11345. const query = new ParseQuery(className);
  11346. query._norQuery(queries);
  11347. return query;
  11348. }
  11349. /**
  11350. * Change the source of this query to the server.
  11351. *
  11352. * @returns {Parse.Query} Returns the query, so you can chain this call.
  11353. */
  11354. fromNetwork() {
  11355. this._queriesLocalDatastore = false;
  11356. this._localDatastorePinName = null;
  11357. return this;
  11358. }
  11359. /**
  11360. * Changes the source of this query to all pinned objects.
  11361. *
  11362. * @returns {Parse.Query} Returns the query, so you can chain this call.
  11363. */
  11364. fromLocalDatastore() {
  11365. return this.fromPinWithName(null);
  11366. }
  11367. /**
  11368. * Changes the source of this query to the default group of pinned objects.
  11369. *
  11370. * @returns {Parse.Query} Returns the query, so you can chain this call.
  11371. */
  11372. fromPin() {
  11373. return this.fromPinWithName(_LocalDatastoreUtils.DEFAULT_PIN);
  11374. }
  11375. /**
  11376. * Changes the source of this query to a specific group of pinned objects.
  11377. *
  11378. * @param {string} name The name of query source.
  11379. * @returns {Parse.Query} Returns the query, so you can chain this call.
  11380. */
  11381. fromPinWithName(name) {
  11382. const localDatastore = _CoreManager.default.getLocalDatastore();
  11383. if (localDatastore.checkIfEnabled()) {
  11384. this._queriesLocalDatastore = true;
  11385. this._localDatastorePinName = name;
  11386. }
  11387. return this;
  11388. }
  11389. /**
  11390. * Cancels the current network request (if any is running).
  11391. *
  11392. * @returns {Parse.Query} Returns the query, so you can chain this call.
  11393. */
  11394. cancel() {
  11395. if (this._xhrRequest.task && typeof this._xhrRequest.task.abort === 'function') {
  11396. this._xhrRequest.task._aborted = true;
  11397. this._xhrRequest.task.abort();
  11398. this._xhrRequest.task = null;
  11399. this._xhrRequest.onchange = () => {};
  11400. return this;
  11401. }
  11402. this._xhrRequest.onchange = () => this.cancel();
  11403. return this;
  11404. }
  11405. _setRequestTask(options) {
  11406. options.requestTask = task => {
  11407. this._xhrRequest.task = task;
  11408. this._xhrRequest.onchange();
  11409. };
  11410. }
  11411. /**
  11412. * Sets a comment to the query so that the query
  11413. * can be identified when using a the profiler for MongoDB.
  11414. *
  11415. * @param {string} value a comment can make your profile data easier to interpret and trace.
  11416. * @returns {Parse.Query} Returns the query, so you can chain this call.
  11417. */
  11418. comment(value) {
  11419. if (value == null) {
  11420. delete this._comment;
  11421. return this;
  11422. }
  11423. if (typeof value !== 'string') {
  11424. throw new Error('The value of a comment to be sent with this query must be a string.');
  11425. }
  11426. this._comment = value;
  11427. return this;
  11428. }
  11429. }
  11430. const DefaultController = {
  11431. find(className, params, options) {
  11432. const RESTController = _CoreManager.default.getRESTController();
  11433. return RESTController.request('GET', 'classes/' + className, params, options);
  11434. },
  11435. aggregate(className, params, options) {
  11436. const RESTController = _CoreManager.default.getRESTController();
  11437. return RESTController.request('GET', 'aggregate/' + className, params, options);
  11438. }
  11439. };
  11440. _CoreManager.default.setParseQuery(ParseQuery);
  11441. _CoreManager.default.setQueryController(DefaultController);
  11442. var _default = exports.default = ParseQuery;
  11443. },{"./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){
  11444. "use strict";
  11445. var _Object$defineProperty = _dereq_("@babel/runtime-corejs3/core-js-stable/object/define-property");
  11446. var _interopRequireDefault = _dereq_("@babel/runtime-corejs3/helpers/interopRequireDefault");
  11447. _Object$defineProperty(exports, "__esModule", {
  11448. value: true
  11449. });
  11450. exports.default = void 0;
  11451. var _isArray = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/array/is-array"));
  11452. var _defineProperty2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/helpers/defineProperty"));
  11453. var _CoreManager = _interopRequireDefault(_dereq_("./CoreManager"));
  11454. /**
  11455. * Creates a new Relation for the given parent object and key. This
  11456. * constructor should rarely be used directly, but rather created by
  11457. * Parse.Object.relation.
  11458. *
  11459. * <p>
  11460. * A class that is used to access all of the children of a many-to-many
  11461. * relationship. Each instance of Parse.Relation is associated with a
  11462. * particular parent object and key.
  11463. * </p>
  11464. *
  11465. * @alias Parse.Relation
  11466. */
  11467. class ParseRelation {
  11468. /**
  11469. * @param {Parse.Object} parent The parent of this relation.
  11470. * @param {string} key The key for this relation on the parent.
  11471. */
  11472. constructor(parent, key) {
  11473. (0, _defineProperty2.default)(this, "parent", void 0);
  11474. (0, _defineProperty2.default)(this, "key", void 0);
  11475. (0, _defineProperty2.default)(this, "targetClassName", void 0);
  11476. this.parent = parent;
  11477. this.key = key;
  11478. this.targetClassName = null;
  11479. }
  11480. /*
  11481. * Makes sure that this relation has the right parent and key.
  11482. */
  11483. _ensureParentAndKey(parent, key) {
  11484. this.key = this.key || key;
  11485. if (this.key !== key) {
  11486. throw new Error('Internal Error. Relation retrieved from two different keys.');
  11487. }
  11488. if (this.parent) {
  11489. if (this.parent.className !== parent.className) {
  11490. throw new Error('Internal Error. Relation retrieved from two different Objects.');
  11491. }
  11492. if (this.parent.id) {
  11493. if (this.parent.id !== parent.id) {
  11494. throw new Error('Internal Error. Relation retrieved from two different Objects.');
  11495. }
  11496. } else if (parent.id) {
  11497. this.parent = parent;
  11498. }
  11499. } else {
  11500. this.parent = parent;
  11501. }
  11502. }
  11503. /**
  11504. * Adds a Parse.Object or an array of Parse.Objects to the relation.
  11505. *
  11506. * @param {(Parse.Object|Array)} objects The item or items to add.
  11507. * @returns {Parse.Object} The parent of the relation.
  11508. */
  11509. add(objects) {
  11510. if (!(0, _isArray.default)(objects)) {
  11511. objects = [objects];
  11512. }
  11513. const {
  11514. RelationOp
  11515. } = _CoreManager.default.getParseOp();
  11516. const change = new RelationOp(objects, []);
  11517. const parent = this.parent;
  11518. if (!parent) {
  11519. throw new Error('Cannot add to a Relation without a parent');
  11520. }
  11521. if (objects.length === 0) {
  11522. return parent;
  11523. }
  11524. parent.set(this.key, change);
  11525. this.targetClassName = change._targetClassName;
  11526. return parent;
  11527. }
  11528. /**
  11529. * Removes a Parse.Object or an array of Parse.Objects from this relation.
  11530. *
  11531. * @param {(Parse.Object|Array)} objects The item or items to remove.
  11532. */
  11533. remove(objects) {
  11534. if (!(0, _isArray.default)(objects)) {
  11535. objects = [objects];
  11536. }
  11537. const {
  11538. RelationOp
  11539. } = _CoreManager.default.getParseOp();
  11540. const change = new RelationOp([], objects);
  11541. if (!this.parent) {
  11542. throw new Error('Cannot remove from a Relation without a parent');
  11543. }
  11544. if (objects.length === 0) {
  11545. return;
  11546. }
  11547. this.parent.set(this.key, change);
  11548. this.targetClassName = change._targetClassName;
  11549. }
  11550. /**
  11551. * Returns a JSON version of the object suitable for saving to disk.
  11552. *
  11553. * @returns {object} JSON representation of Relation
  11554. */
  11555. toJSON() {
  11556. return {
  11557. __type: 'Relation',
  11558. className: this.targetClassName
  11559. };
  11560. }
  11561. /**
  11562. * Returns a Parse.Query that is limited to objects in this
  11563. * relation.
  11564. *
  11565. * @returns {Parse.Query} Relation Query
  11566. */
  11567. query() {
  11568. let query;
  11569. const parent = this.parent;
  11570. if (!parent) {
  11571. throw new Error('Cannot construct a query for a Relation without a parent');
  11572. }
  11573. const ParseQuery = _CoreManager.default.getParseQuery();
  11574. if (!this.targetClassName) {
  11575. query = new ParseQuery(parent.className);
  11576. query._extraOptions.redirectClassNameForKey = this.key;
  11577. } else {
  11578. query = new ParseQuery(this.targetClassName);
  11579. }
  11580. query._addCondition('$relatedTo', 'object', {
  11581. __type: 'Pointer',
  11582. className: parent.className,
  11583. objectId: parent.id
  11584. });
  11585. query._addCondition('$relatedTo', 'key', this.key);
  11586. return query;
  11587. }
  11588. }
  11589. var _default = exports.default = ParseRelation;
  11590. },{"./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){
  11591. "use strict";
  11592. var _Object$defineProperty = _dereq_("@babel/runtime-corejs3/core-js-stable/object/define-property");
  11593. var _interopRequireDefault = _dereq_("@babel/runtime-corejs3/helpers/interopRequireDefault");
  11594. _Object$defineProperty(exports, "__esModule", {
  11595. value: true
  11596. });
  11597. exports.default = void 0;
  11598. var _CoreManager = _interopRequireDefault(_dereq_("./CoreManager"));
  11599. var _ParseACL = _interopRequireDefault(_dereq_("./ParseACL"));
  11600. var _ParseError = _interopRequireDefault(_dereq_("./ParseError"));
  11601. var _ParseObject = _interopRequireDefault(_dereq_("./ParseObject"));
  11602. /**
  11603. * Represents a Role on the Parse server. Roles represent groupings of
  11604. * Users for the purposes of granting permissions (e.g. specifying an ACL
  11605. * for an Object). Roles are specified by their sets of child users and
  11606. * child roles, all of which are granted any permissions that the parent
  11607. * role has.
  11608. *
  11609. * <p>Roles must have a name (which cannot be changed after creation of the
  11610. * role), and must specify an ACL.</p>
  11611. *
  11612. * @alias Parse.Role
  11613. * @augments Parse.Object
  11614. */
  11615. class ParseRole extends _ParseObject.default {
  11616. /**
  11617. * @param {string} name The name of the Role to create.
  11618. * @param {Parse.ACL} acl The ACL for this role. Roles must have an ACL.
  11619. * A Parse.Role is a local representation of a role persisted to the Parse
  11620. * cloud.
  11621. */
  11622. constructor(name, acl) {
  11623. super('_Role');
  11624. if (typeof name === 'string' && acl instanceof _ParseACL.default) {
  11625. this.setName(name);
  11626. this.setACL(acl);
  11627. }
  11628. }
  11629. /**
  11630. * Gets the name of the role. You can alternatively call role.get("name")
  11631. *
  11632. * @returns {string} the name of the role.
  11633. */
  11634. getName() {
  11635. const name = this.get('name');
  11636. if (name == null || typeof name === 'string') {
  11637. return name;
  11638. }
  11639. return '';
  11640. }
  11641. /**
  11642. * Sets the name for a role. This value must be set before the role has
  11643. * been saved to the server, and cannot be set once the role has been
  11644. * saved.
  11645. *
  11646. * <p>
  11647. * A role's name can only contain alphanumeric characters, _, -, and
  11648. * spaces.
  11649. * </p>
  11650. *
  11651. * <p>This is equivalent to calling role.set("name", name)</p>
  11652. *
  11653. * @param {string} name The name of the role.
  11654. * @param {object} options Standard options object with success and error
  11655. * callbacks.
  11656. * @returns {(ParseObject|boolean)} true if the set succeeded.
  11657. */
  11658. setName(name, options) {
  11659. this._validateName(name);
  11660. return this.set('name', name, options);
  11661. }
  11662. /**
  11663. * Gets the Parse.Relation for the Parse.Users that are direct
  11664. * children of this role. These users are granted any privileges that this
  11665. * role has been granted (e.g. read or write access through ACLs). You can
  11666. * add or remove users from the role through this relation.
  11667. *
  11668. * <p>This is equivalent to calling role.relation("users")</p>
  11669. *
  11670. * @returns {Parse.Relation} the relation for the users belonging to this
  11671. * role.
  11672. */
  11673. getUsers() {
  11674. return this.relation('users');
  11675. }
  11676. /**
  11677. * Gets the Parse.Relation for the Parse.Roles that are direct
  11678. * children of this role. These roles' users are granted any privileges that
  11679. * this role has been granted (e.g. read or write access through ACLs). You
  11680. * can add or remove child roles from this role through this relation.
  11681. *
  11682. * <p>This is equivalent to calling role.relation("roles")</p>
  11683. *
  11684. * @returns {Parse.Relation} the relation for the roles belonging to this
  11685. * role.
  11686. */
  11687. getRoles() {
  11688. return this.relation('roles');
  11689. }
  11690. _validateName(newName) {
  11691. if (typeof newName !== 'string') {
  11692. throw new _ParseError.default(_ParseError.default.OTHER_CAUSE, "A role's name must be a String.");
  11693. }
  11694. if (!/^[0-9a-zA-Z\-_ ]+$/.test(newName)) {
  11695. throw new _ParseError.default(_ParseError.default.OTHER_CAUSE, "A role's name can be only contain alphanumeric characters, _, " + '-, and spaces.');
  11696. }
  11697. }
  11698. validate(attrs, options) {
  11699. const isInvalid = super.validate(attrs, options);
  11700. if (isInvalid) {
  11701. return isInvalid;
  11702. }
  11703. if ('name' in attrs && attrs.name !== this.getName()) {
  11704. const newName = attrs.name;
  11705. if (this.id && this.id !== attrs.objectId) {
  11706. // Check to see if the objectId being set matches this.id
  11707. // This happens during a fetch -- the id is set before calling fetch
  11708. // Let the name be set in this case
  11709. return new _ParseError.default(_ParseError.default.OTHER_CAUSE, "A role's name can only be set before it has been saved.");
  11710. }
  11711. try {
  11712. this._validateName(newName);
  11713. } catch (e) {
  11714. return e;
  11715. }
  11716. }
  11717. return false;
  11718. }
  11719. }
  11720. _CoreManager.default.setParseRole(ParseRole);
  11721. _ParseObject.default.registerSubclass('_Role', ParseRole);
  11722. var _default = exports.default = ParseRole;
  11723. },{"./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){
  11724. "use strict";
  11725. var _Object$defineProperty = _dereq_("@babel/runtime-corejs3/core-js-stable/object/define-property");
  11726. var _interopRequireDefault = _dereq_("@babel/runtime-corejs3/helpers/interopRequireDefault");
  11727. _Object$defineProperty(exports, "__esModule", {
  11728. value: true
  11729. });
  11730. exports.default = void 0;
  11731. var _indexOf = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/instance/index-of"));
  11732. var _defineProperty2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/helpers/defineProperty"));
  11733. var _CoreManager = _interopRequireDefault(_dereq_("./CoreManager"));
  11734. var _ParseObject = _interopRequireDefault(_dereq_("./ParseObject"));
  11735. var _ParseCLP = _interopRequireDefault(_dereq_("./ParseCLP"));
  11736. const FIELD_TYPES = ['String', 'Number', 'Boolean', 'Bytes', 'Date', 'File', 'GeoPoint', 'Polygon', 'Array', 'Object', 'Pointer', 'Relation'];
  11737. /**
  11738. * A Parse.Schema object is for handling schema data from Parse.
  11739. * <p>All the schemas methods require MasterKey.
  11740. *
  11741. * When adding fields, you may set required and default values. (Requires Parse Server 3.7.0+)
  11742. *
  11743. * <pre>
  11744. * const options = { required: true, defaultValue: 'hello world' };
  11745. * const schema = new Parse.Schema('MyClass');
  11746. * schema.addString('field', options);
  11747. * schema.addIndex('index_name', { 'field': 1 });
  11748. * schema.save();
  11749. * </pre>
  11750. * </p>
  11751. *
  11752. * @alias Parse.Schema
  11753. */
  11754. class ParseSchema {
  11755. /**
  11756. * @param {string} className Parse Class string.
  11757. */
  11758. constructor(className) {
  11759. (0, _defineProperty2.default)(this, "className", void 0);
  11760. (0, _defineProperty2.default)(this, "_fields", void 0);
  11761. (0, _defineProperty2.default)(this, "_indexes", void 0);
  11762. (0, _defineProperty2.default)(this, "_clp", void 0);
  11763. if (typeof className === 'string') {
  11764. if (className === 'User' && _CoreManager.default.get('PERFORM_USER_REWRITE')) {
  11765. this.className = '_User';
  11766. } else {
  11767. this.className = className;
  11768. }
  11769. }
  11770. this._fields = {};
  11771. this._indexes = {};
  11772. }
  11773. /**
  11774. * Static method to get all schemas
  11775. *
  11776. * @returns {Promise} A promise that is resolved with the result when
  11777. * the query completes.
  11778. */
  11779. static all() {
  11780. const controller = _CoreManager.default.getSchemaController();
  11781. return controller.get('').then(response => {
  11782. if (response.results.length === 0) {
  11783. throw new Error('Schema not found.');
  11784. }
  11785. return response.results;
  11786. });
  11787. }
  11788. /**
  11789. * Get the Schema from Parse
  11790. *
  11791. * @returns {Promise} A promise that is resolved with the result when
  11792. * the query completes.
  11793. */
  11794. get() {
  11795. this.assertClassName();
  11796. const controller = _CoreManager.default.getSchemaController();
  11797. return controller.get(this.className).then(response => {
  11798. if (!response) {
  11799. throw new Error('Schema not found.');
  11800. }
  11801. return response;
  11802. });
  11803. }
  11804. /**
  11805. * Create a new Schema on Parse
  11806. *
  11807. * @returns {Promise} A promise that is resolved with the result when
  11808. * the query completes.
  11809. */
  11810. save() {
  11811. this.assertClassName();
  11812. const controller = _CoreManager.default.getSchemaController();
  11813. const params = {
  11814. className: this.className,
  11815. fields: this._fields,
  11816. indexes: this._indexes,
  11817. classLevelPermissions: this._clp
  11818. };
  11819. return controller.create(this.className, params);
  11820. }
  11821. /**
  11822. * Update a Schema on Parse
  11823. *
  11824. * @returns {Promise} A promise that is resolved with the result when
  11825. * the query completes.
  11826. */
  11827. update() {
  11828. this.assertClassName();
  11829. const controller = _CoreManager.default.getSchemaController();
  11830. const params = {
  11831. className: this.className,
  11832. fields: this._fields,
  11833. indexes: this._indexes,
  11834. classLevelPermissions: this._clp
  11835. };
  11836. this._fields = {};
  11837. this._indexes = {};
  11838. return controller.update(this.className, params);
  11839. }
  11840. /**
  11841. * Removing a Schema from Parse
  11842. * Can only be used on Schema without objects
  11843. *
  11844. * @returns {Promise} A promise that is resolved with the result when
  11845. * the query completes.
  11846. */
  11847. delete() {
  11848. this.assertClassName();
  11849. const controller = _CoreManager.default.getSchemaController();
  11850. return controller.delete(this.className);
  11851. }
  11852. /**
  11853. * Removes all objects from a Schema (class) in Parse.
  11854. * EXERCISE CAUTION, running this will delete all objects for this schema and cannot be reversed
  11855. *
  11856. * @returns {Promise} A promise that is resolved with the result when
  11857. * the query completes.
  11858. */
  11859. purge() {
  11860. this.assertClassName();
  11861. const controller = _CoreManager.default.getSchemaController();
  11862. return controller.purge(this.className);
  11863. }
  11864. /**
  11865. * Assert if ClassName has been filled
  11866. *
  11867. * @private
  11868. */
  11869. assertClassName() {
  11870. if (!this.className) {
  11871. throw new Error('You must set a Class Name before making any request.');
  11872. }
  11873. }
  11874. /**
  11875. * Sets Class Level Permissions when creating / updating a Schema.
  11876. * EXERCISE CAUTION, running this may override CLP for this schema and cannot be reversed
  11877. *
  11878. * @param {object | Parse.CLP} clp Class Level Permissions
  11879. * @returns {Parse.Schema} Returns the schema, so you can chain this call.
  11880. */
  11881. setCLP(clp) {
  11882. if (clp instanceof _ParseCLP.default) {
  11883. this._clp = clp.toJSON();
  11884. } else {
  11885. this._clp = clp;
  11886. }
  11887. return this;
  11888. }
  11889. /**
  11890. * Adding a Field to Create / Update a Schema
  11891. *
  11892. * @param {string} name Name of the field that will be created on Parse
  11893. * @param {string} type Can be a (String|Number|Boolean|Date|Parse.File|Parse.GeoPoint|Array|Object|Pointer|Parse.Relation)
  11894. * @param {object} options
  11895. * Valid options are:<ul>
  11896. * <li>required: If field is not set, save operation fails (Requires Parse Server 3.7.0+)
  11897. * <li>defaultValue: If field is not set, a default value is selected (Requires Parse Server 3.7.0+)
  11898. * <li>targetClass: Required if type is Pointer or Parse.Relation
  11899. * </ul>
  11900. * @returns {Parse.Schema} Returns the schema, so you can chain this call.
  11901. */
  11902. addField(name, type) {
  11903. let options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
  11904. type = type || 'String';
  11905. if (!name) {
  11906. throw new Error('field name may not be null.');
  11907. }
  11908. if ((0, _indexOf.default)(FIELD_TYPES).call(FIELD_TYPES, type) === -1) {
  11909. throw new Error(`${type} is not a valid type.`);
  11910. }
  11911. if (type === 'Pointer') {
  11912. return this.addPointer(name, options.targetClass, options);
  11913. }
  11914. if (type === 'Relation') {
  11915. return this.addRelation(name, options.targetClass);
  11916. }
  11917. const fieldOptions = {
  11918. type
  11919. };
  11920. if (typeof options.required === 'boolean') {
  11921. fieldOptions.required = options.required;
  11922. }
  11923. if (options.defaultValue !== undefined) {
  11924. fieldOptions.defaultValue = options.defaultValue;
  11925. }
  11926. if (type === 'Date') {
  11927. if (options && options.defaultValue) {
  11928. fieldOptions.defaultValue = {
  11929. __type: 'Date',
  11930. iso: new Date(options.defaultValue)
  11931. };
  11932. }
  11933. }
  11934. if (type === 'Bytes') {
  11935. if (options && options.defaultValue) {
  11936. fieldOptions.defaultValue = {
  11937. __type: 'Bytes',
  11938. base64: options.defaultValue
  11939. };
  11940. }
  11941. }
  11942. this._fields[name] = fieldOptions;
  11943. return this;
  11944. }
  11945. /**
  11946. * Adding an Index to Create / Update a Schema
  11947. *
  11948. * @param {string} name Name of the index
  11949. * @param {object} index { field: value }
  11950. * @returns {Parse.Schema} Returns the schema, so you can chain this call.
  11951. *
  11952. * <pre>
  11953. * schema.addIndex('index_name', { 'field': 1 });
  11954. * </pre>
  11955. */
  11956. addIndex(name, index) {
  11957. if (!name) {
  11958. throw new Error('index name may not be null.');
  11959. }
  11960. if (!index) {
  11961. throw new Error('index may not be null.');
  11962. }
  11963. this._indexes[name] = index;
  11964. return this;
  11965. }
  11966. /**
  11967. * Adding String Field
  11968. *
  11969. * @param {string} name Name of the field that will be created on Parse
  11970. * @param {object} options See {@link https://parseplatform.org/Parse-SDK-JS/api/master/Parse.Schema.html#addField addField}
  11971. * @returns {Parse.Schema} Returns the schema, so you can chain this call.
  11972. */
  11973. addString(name, options) {
  11974. return this.addField(name, 'String', options);
  11975. }
  11976. /**
  11977. * Adding Number Field
  11978. *
  11979. * @param {string} name Name of the field that will be created on Parse
  11980. * @param {object} options See {@link https://parseplatform.org/Parse-SDK-JS/api/master/Parse.Schema.html#addField addField}
  11981. * @returns {Parse.Schema} Returns the schema, so you can chain this call.
  11982. */
  11983. addNumber(name, options) {
  11984. return this.addField(name, 'Number', options);
  11985. }
  11986. /**
  11987. * Adding Boolean Field
  11988. *
  11989. * @param {string} name Name of the field that will be created on Parse
  11990. * @param {object} options See {@link https://parseplatform.org/Parse-SDK-JS/api/master/Parse.Schema.html#addField addField}
  11991. * @returns {Parse.Schema} Returns the schema, so you can chain this call.
  11992. */
  11993. addBoolean(name, options) {
  11994. return this.addField(name, 'Boolean', options);
  11995. }
  11996. /**
  11997. * Adding Bytes Field
  11998. *
  11999. * @param {string} name Name of the field that will be created on Parse
  12000. * @param {object} options See {@link https://parseplatform.org/Parse-SDK-JS/api/master/Parse.Schema.html#addField addField}
  12001. * @returns {Parse.Schema} Returns the schema, so you can chain this call.
  12002. */
  12003. addBytes(name, options) {
  12004. return this.addField(name, 'Bytes', options);
  12005. }
  12006. /**
  12007. * Adding Date Field
  12008. *
  12009. * @param {string} name Name of the field that will be created on Parse
  12010. * @param {object} options See {@link https://parseplatform.org/Parse-SDK-JS/api/master/Parse.Schema.html#addField addField}
  12011. * @returns {Parse.Schema} Returns the schema, so you can chain this call.
  12012. */
  12013. addDate(name, options) {
  12014. return this.addField(name, 'Date', options);
  12015. }
  12016. /**
  12017. * Adding File Field
  12018. *
  12019. * @param {string} name Name of the field that will be created on Parse
  12020. * @param {object} options See {@link https://parseplatform.org/Parse-SDK-JS/api/master/Parse.Schema.html#addField addField}
  12021. * @returns {Parse.Schema} Returns the schema, so you can chain this call.
  12022. */
  12023. addFile(name, options) {
  12024. return this.addField(name, 'File', options);
  12025. }
  12026. /**
  12027. * Adding GeoPoint Field
  12028. *
  12029. * @param {string} name Name of the field that will be created on Parse
  12030. * @param {object} options See {@link https://parseplatform.org/Parse-SDK-JS/api/master/Parse.Schema.html#addField addField}
  12031. * @returns {Parse.Schema} Returns the schema, so you can chain this call.
  12032. */
  12033. addGeoPoint(name, options) {
  12034. return this.addField(name, 'GeoPoint', options);
  12035. }
  12036. /**
  12037. * Adding Polygon Field
  12038. *
  12039. * @param {string} name Name of the field that will be created on Parse
  12040. * @param {object} options See {@link https://parseplatform.org/Parse-SDK-JS/api/master/Parse.Schema.html#addField addField}
  12041. * @returns {Parse.Schema} Returns the schema, so you can chain this call.
  12042. */
  12043. addPolygon(name, options) {
  12044. return this.addField(name, 'Polygon', options);
  12045. }
  12046. /**
  12047. * Adding Array Field
  12048. *
  12049. * @param {string} name Name of the field that will be created on Parse
  12050. * @param {object} options See {@link https://parseplatform.org/Parse-SDK-JS/api/master/Parse.Schema.html#addField addField}
  12051. * @returns {Parse.Schema} Returns the schema, so you can chain this call.
  12052. */
  12053. addArray(name, options) {
  12054. return this.addField(name, 'Array', options);
  12055. }
  12056. /**
  12057. * Adding Object Field
  12058. *
  12059. * @param {string} name Name of the field that will be created on Parse
  12060. * @param {object} options See {@link https://parseplatform.org/Parse-SDK-JS/api/master/Parse.Schema.html#addField addField}
  12061. * @returns {Parse.Schema} Returns the schema, so you can chain this call.
  12062. */
  12063. addObject(name, options) {
  12064. return this.addField(name, 'Object', options);
  12065. }
  12066. /**
  12067. * Adding Pointer Field
  12068. *
  12069. * @param {string} name Name of the field that will be created on Parse
  12070. * @param {string} targetClass Name of the target Pointer Class
  12071. * @param {object} options See {@link https://parseplatform.org/Parse-SDK-JS/api/master/Parse.Schema.html#addField addField}
  12072. * @returns {Parse.Schema} Returns the schema, so you can chain this call.
  12073. */
  12074. addPointer(name, targetClass) {
  12075. let options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
  12076. if (!name) {
  12077. throw new Error('field name may not be null.');
  12078. }
  12079. if (!targetClass) {
  12080. throw new Error('You need to set the targetClass of the Pointer.');
  12081. }
  12082. const fieldOptions = {
  12083. type: 'Pointer',
  12084. targetClass
  12085. };
  12086. if (typeof options.required === 'boolean') {
  12087. fieldOptions.required = options.required;
  12088. }
  12089. if (options.defaultValue !== undefined) {
  12090. fieldOptions.defaultValue = options.defaultValue;
  12091. if (options.defaultValue instanceof _ParseObject.default) {
  12092. fieldOptions.defaultValue = options.defaultValue.toPointer();
  12093. }
  12094. }
  12095. this._fields[name] = fieldOptions;
  12096. return this;
  12097. }
  12098. /**
  12099. * Adding Relation Field
  12100. *
  12101. * @param {string} name Name of the field that will be created on Parse
  12102. * @param {string} targetClass Name of the target Pointer Class
  12103. * @returns {Parse.Schema} Returns the schema, so you can chain this call.
  12104. */
  12105. addRelation(name, targetClass) {
  12106. if (!name) {
  12107. throw new Error('field name may not be null.');
  12108. }
  12109. if (!targetClass) {
  12110. throw new Error('You need to set the targetClass of the Relation.');
  12111. }
  12112. this._fields[name] = {
  12113. type: 'Relation',
  12114. targetClass
  12115. };
  12116. return this;
  12117. }
  12118. /**
  12119. * Deleting a Field to Update on a Schema
  12120. *
  12121. * @param {string} name Name of the field
  12122. * @returns {Parse.Schema} Returns the schema, so you can chain this call.
  12123. */
  12124. deleteField(name) {
  12125. this._fields[name] = {
  12126. __op: 'Delete'
  12127. };
  12128. return this;
  12129. }
  12130. /**
  12131. * Deleting an Index to Update on a Schema
  12132. *
  12133. * @param {string} name Name of the field
  12134. * @returns {Parse.Schema} Returns the schema, so you can chain this call.
  12135. */
  12136. deleteIndex(name) {
  12137. this._indexes[name] = {
  12138. __op: 'Delete'
  12139. };
  12140. return this;
  12141. }
  12142. }
  12143. const DefaultController = {
  12144. send(className, method) {
  12145. let params = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
  12146. const RESTController = _CoreManager.default.getRESTController();
  12147. return RESTController.request(method, `schemas/${className}`, params, {
  12148. useMasterKey: true
  12149. });
  12150. },
  12151. get(className) {
  12152. return this.send(className, 'GET');
  12153. },
  12154. create(className, params) {
  12155. return this.send(className, 'POST', params);
  12156. },
  12157. update(className, params) {
  12158. return this.send(className, 'PUT', params);
  12159. },
  12160. delete(className) {
  12161. return this.send(className, 'DELETE');
  12162. },
  12163. purge(className) {
  12164. const RESTController = _CoreManager.default.getRESTController();
  12165. return RESTController.request('DELETE', `purge/${className}`, {}, {
  12166. useMasterKey: true
  12167. });
  12168. }
  12169. };
  12170. _CoreManager.default.setSchemaController(DefaultController);
  12171. var _default = exports.default = ParseSchema;
  12172. },{"./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){
  12173. "use strict";
  12174. var _Object$defineProperty = _dereq_("@babel/runtime-corejs3/core-js-stable/object/define-property");
  12175. var _interopRequireDefault = _dereq_("@babel/runtime-corejs3/helpers/interopRequireDefault");
  12176. _Object$defineProperty(exports, "__esModule", {
  12177. value: true
  12178. });
  12179. exports.default = void 0;
  12180. var _promise = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/promise"));
  12181. var _CoreManager = _interopRequireDefault(_dereq_("./CoreManager"));
  12182. var _isRevocableSession = _interopRequireDefault(_dereq_("./isRevocableSession"));
  12183. var _ParseObject = _interopRequireDefault(_dereq_("./ParseObject"));
  12184. var _ParseUser = _interopRequireDefault(_dereq_("./ParseUser"));
  12185. /**
  12186. * <p>A Parse.Session object is a local representation of a revocable session.
  12187. * This class is a subclass of a Parse.Object, and retains the same
  12188. * functionality of a Parse.Object.</p>
  12189. *
  12190. * @alias Parse.Session
  12191. * @augments Parse.Object
  12192. */
  12193. class ParseSession extends _ParseObject.default {
  12194. /**
  12195. * @param {object} attributes The initial set of data to store in the user.
  12196. */
  12197. constructor(attributes) {
  12198. super('_Session');
  12199. if (attributes && typeof attributes === 'object') {
  12200. if (!this.set(attributes || {})) {
  12201. throw new Error("Can't create an invalid Session");
  12202. }
  12203. }
  12204. }
  12205. /**
  12206. * Returns the session token string.
  12207. *
  12208. * @returns {string}
  12209. */
  12210. getSessionToken() {
  12211. const token = this.get('sessionToken');
  12212. if (typeof token === 'string') {
  12213. return token;
  12214. }
  12215. return '';
  12216. }
  12217. static readOnlyAttributes() {
  12218. return ['createdWith', 'expiresAt', 'installationId', 'restricted', 'sessionToken', 'user'];
  12219. }
  12220. /**
  12221. * Retrieves the Session object for the currently logged in session.
  12222. *
  12223. * @param {object} options useMasterKey
  12224. * @static
  12225. * @returns {Promise} A promise that is resolved with the Parse.Session
  12226. * object after it has been fetched. If there is no current user, the
  12227. * promise will be rejected.
  12228. */
  12229. static current(options) {
  12230. options = options || {};
  12231. const controller = _CoreManager.default.getSessionController();
  12232. const sessionOptions = {};
  12233. if (options.hasOwnProperty('useMasterKey')) {
  12234. sessionOptions.useMasterKey = options.useMasterKey;
  12235. }
  12236. return _ParseUser.default.currentAsync().then(user => {
  12237. if (!user) {
  12238. return _promise.default.reject('There is no current user.');
  12239. }
  12240. sessionOptions.sessionToken = user.getSessionToken();
  12241. return controller.getSession(sessionOptions);
  12242. });
  12243. }
  12244. /**
  12245. * Determines whether the current session token is revocable.
  12246. * This method is useful for migrating Express.js or Node.js web apps to
  12247. * use revocable sessions. If you are migrating an app that uses the Parse
  12248. * SDK in the browser only, please use Parse.User.enableRevocableSession()
  12249. * instead, so that sessions can be automatically upgraded.
  12250. *
  12251. * @static
  12252. * @returns {boolean}
  12253. */
  12254. static isCurrentSessionRevocable() {
  12255. const currentUser = _ParseUser.default.current();
  12256. if (currentUser) {
  12257. return (0, _isRevocableSession.default)(currentUser.getSessionToken() || '');
  12258. }
  12259. return false;
  12260. }
  12261. }
  12262. _ParseObject.default.registerSubclass('_Session', ParseSession);
  12263. const DefaultController = {
  12264. getSession(options) {
  12265. const RESTController = _CoreManager.default.getRESTController();
  12266. const session = new ParseSession();
  12267. return RESTController.request('GET', 'sessions/me', {}, options).then(sessionData => {
  12268. session._finishFetch(sessionData);
  12269. session._setExisted(true);
  12270. return session;
  12271. });
  12272. }
  12273. };
  12274. _CoreManager.default.setSessionController(DefaultController);
  12275. var _default = exports.default = ParseSession;
  12276. },{"./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){
  12277. "use strict";
  12278. var _Object$defineProperty2 = _dereq_("@babel/runtime-corejs3/core-js-stable/object/define-property");
  12279. var _interopRequireDefault = _dereq_("@babel/runtime-corejs3/helpers/interopRequireDefault");
  12280. _Object$defineProperty2(exports, "__esModule", {
  12281. value: true
  12282. });
  12283. exports.default = void 0;
  12284. var _promise = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/promise"));
  12285. var _defineProperty = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/object/define-property"));
  12286. var _stringify = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/json/stringify"));
  12287. var _CoreManager = _interopRequireDefault(_dereq_("./CoreManager"));
  12288. var _isRevocableSession = _interopRequireDefault(_dereq_("./isRevocableSession"));
  12289. var _ParseError = _interopRequireDefault(_dereq_("./ParseError"));
  12290. var _ParseObject = _interopRequireDefault(_dereq_("./ParseObject"));
  12291. var _Storage = _interopRequireDefault(_dereq_("./Storage"));
  12292. const CURRENT_USER_KEY = 'currentUser';
  12293. let canUseCurrentUser = !_CoreManager.default.get('IS_NODE');
  12294. let currentUserCacheMatchesDisk = false;
  12295. let currentUserCache = null;
  12296. const authProviders = {};
  12297. /**
  12298. * <p>A Parse.User object is a local representation of a user persisted to the
  12299. * Parse cloud. This class is a subclass of a Parse.Object, and retains the
  12300. * same functionality of a Parse.Object, but also extends it with various
  12301. * user specific methods, like authentication, signing up, and validation of
  12302. * uniqueness.</p>
  12303. *
  12304. * @alias Parse.User
  12305. * @augments Parse.Object
  12306. */
  12307. class ParseUser extends _ParseObject.default {
  12308. /**
  12309. * @param {object} attributes The initial set of data to store in the user.
  12310. */
  12311. constructor(attributes) {
  12312. super('_User');
  12313. if (attributes && typeof attributes === 'object') {
  12314. if (!this.set(attributes || {})) {
  12315. throw new Error("Can't create an invalid Parse User");
  12316. }
  12317. }
  12318. }
  12319. /**
  12320. * Request a revocable session token to replace the older style of token.
  12321. *
  12322. * @param {object} options
  12323. * @returns {Promise} A promise that is resolved when the replacement
  12324. * token has been fetched.
  12325. */
  12326. _upgradeToRevocableSession(options) {
  12327. options = options || {};
  12328. const upgradeOptions = {};
  12329. if (options.hasOwnProperty('useMasterKey')) {
  12330. upgradeOptions.useMasterKey = options.useMasterKey;
  12331. }
  12332. const controller = _CoreManager.default.getUserController();
  12333. return controller.upgradeToRevocableSession(this, upgradeOptions);
  12334. }
  12335. /**
  12336. * 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
  12337. * your users to sign up or log into your application using their existing identities.
  12338. * Since 2.9.0
  12339. *
  12340. * @see {@link https://docs.parseplatform.org/js/guide/#linking-users Linking Users}
  12341. * @param {string | AuthProvider} provider Name of auth provider or {@link https://parseplatform.org/Parse-SDK-JS/api/master/AuthProvider.html AuthProvider}
  12342. * @param {object} options
  12343. * @param {object} [options.authData] AuthData to link with
  12344. * <ul>
  12345. * <li>If provider is string, options is {@link http://docs.parseplatform.org/parse-server/guide/#supported-3rd-party-authentications authData}
  12346. * <li>If provider is AuthProvider, options is saveOpts
  12347. * </ul>
  12348. * @param {object} saveOpts useMasterKey / sessionToken
  12349. * @returns {Promise} A promise that is fulfilled with the user is linked
  12350. */
  12351. linkWith(provider, options) {
  12352. let saveOpts = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
  12353. saveOpts.sessionToken = saveOpts.sessionToken || this.getSessionToken() || '';
  12354. let authType;
  12355. if (typeof provider === 'string') {
  12356. authType = provider;
  12357. if (authProviders[provider]) {
  12358. provider = authProviders[provider];
  12359. } else {
  12360. const authProvider = {
  12361. restoreAuthentication() {
  12362. return true;
  12363. },
  12364. getAuthType() {
  12365. return authType;
  12366. }
  12367. };
  12368. authProviders[authProvider.getAuthType()] = authProvider;
  12369. provider = authProvider;
  12370. }
  12371. } else {
  12372. authType = provider.getAuthType();
  12373. }
  12374. if (options && options.hasOwnProperty('authData')) {
  12375. const authData = this.get('authData') || {};
  12376. if (typeof authData !== 'object') {
  12377. throw new Error('Invalid type: authData field should be an object');
  12378. }
  12379. authData[authType] = options.authData;
  12380. const oldAnonymousData = authData.anonymous;
  12381. this.stripAnonymity();
  12382. const controller = _CoreManager.default.getUserController();
  12383. return controller.linkWith(this, authData, saveOpts).catch(e => {
  12384. delete authData[authType];
  12385. this.restoreAnonimity(oldAnonymousData);
  12386. throw e;
  12387. });
  12388. } else {
  12389. return new _promise.default((resolve, reject) => {
  12390. provider.authenticate({
  12391. success: (provider, result) => {
  12392. const opts = {};
  12393. opts.authData = result;
  12394. this.linkWith(provider, opts, saveOpts).then(() => {
  12395. resolve(this);
  12396. }, error => {
  12397. reject(error);
  12398. });
  12399. },
  12400. error: (provider, error) => {
  12401. reject(error);
  12402. }
  12403. });
  12404. });
  12405. }
  12406. }
  12407. /**
  12408. * @param provider
  12409. * @param options
  12410. * @param {object} [options.authData]
  12411. * @param saveOpts
  12412. * @deprecated since 2.9.0 see {@link https://parseplatform.org/Parse-SDK-JS/api/master/Parse.User.html#linkWith linkWith}
  12413. * @returns {Promise}
  12414. */
  12415. _linkWith(provider, options) {
  12416. let saveOpts = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
  12417. return this.linkWith(provider, options, saveOpts);
  12418. }
  12419. /**
  12420. * Synchronizes auth data for a provider (e.g. puts the access token in the
  12421. * right place to be used by the Facebook SDK).
  12422. *
  12423. * @param provider
  12424. */
  12425. _synchronizeAuthData(provider) {
  12426. if (!this.isCurrent() || !provider) {
  12427. return;
  12428. }
  12429. let authType;
  12430. if (typeof provider === 'string') {
  12431. authType = provider;
  12432. provider = authProviders[authType];
  12433. } else {
  12434. authType = provider.getAuthType();
  12435. }
  12436. const authData = this.get('authData');
  12437. if (!provider || !authData || typeof authData !== 'object') {
  12438. return;
  12439. }
  12440. const success = provider.restoreAuthentication(authData[authType]);
  12441. if (!success) {
  12442. this._unlinkFrom(provider);
  12443. }
  12444. }
  12445. /**
  12446. * Synchronizes authData for all providers.
  12447. */
  12448. _synchronizeAllAuthData() {
  12449. const authData = this.get('authData');
  12450. if (typeof authData !== 'object') {
  12451. return;
  12452. }
  12453. for (const key in authData) {
  12454. this._synchronizeAuthData(key);
  12455. }
  12456. }
  12457. /**
  12458. * Removes null values from authData (which exist temporarily for unlinking)
  12459. */
  12460. _cleanupAuthData() {
  12461. if (!this.isCurrent()) {
  12462. return;
  12463. }
  12464. const authData = this.get('authData');
  12465. if (typeof authData !== 'object') {
  12466. return;
  12467. }
  12468. for (const key in authData) {
  12469. if (!authData[key]) {
  12470. delete authData[key];
  12471. }
  12472. }
  12473. }
  12474. /**
  12475. * Unlinks a user from a service.
  12476. *
  12477. * @param {string | AuthProvider} provider Name of auth provider or {@link https://parseplatform.org/Parse-SDK-JS/api/master/AuthProvider.html AuthProvider}
  12478. * @param {object} options MasterKey / SessionToken
  12479. * @returns {Promise} A promise that is fulfilled when the unlinking
  12480. * finishes.
  12481. */
  12482. _unlinkFrom(provider, options) {
  12483. return this.linkWith(provider, {
  12484. authData: null
  12485. }, options).then(() => {
  12486. this._synchronizeAuthData(provider);
  12487. return _promise.default.resolve(this);
  12488. });
  12489. }
  12490. /**
  12491. * Checks whether a user is linked to a service.
  12492. *
  12493. * @param {object} provider service to link to
  12494. * @returns {boolean} true if link was successful
  12495. */
  12496. _isLinked(provider) {
  12497. let authType;
  12498. if (typeof provider === 'string') {
  12499. authType = provider;
  12500. } else {
  12501. authType = provider.getAuthType();
  12502. }
  12503. const authData = this.get('authData') || {};
  12504. if (typeof authData !== 'object') {
  12505. return false;
  12506. }
  12507. return !!authData[authType];
  12508. }
  12509. /**
  12510. * Deauthenticates all providers.
  12511. */
  12512. _logOutWithAll() {
  12513. const authData = this.get('authData');
  12514. if (typeof authData !== 'object') {
  12515. return;
  12516. }
  12517. for (const key in authData) {
  12518. this._logOutWith(key);
  12519. }
  12520. }
  12521. /**
  12522. * Deauthenticates a single provider (e.g. removing access tokens from the
  12523. * Facebook SDK).
  12524. *
  12525. * @param {object} provider service to logout of
  12526. */
  12527. _logOutWith(provider) {
  12528. if (!this.isCurrent()) {
  12529. return;
  12530. }
  12531. if (typeof provider === 'string') {
  12532. provider = authProviders[provider];
  12533. }
  12534. if (provider && provider.deauthenticate) {
  12535. provider.deauthenticate();
  12536. }
  12537. }
  12538. /**
  12539. * Class instance method used to maintain specific keys when a fetch occurs.
  12540. * Used to ensure that the session token is not lost.
  12541. *
  12542. * @returns {object} sessionToken
  12543. */
  12544. _preserveFieldsOnFetch() {
  12545. return {
  12546. sessionToken: this.get('sessionToken')
  12547. };
  12548. }
  12549. /**
  12550. * Returns true if <code>current</code> would return this user.
  12551. *
  12552. * @returns {boolean} true if user is cached on disk
  12553. */
  12554. isCurrent() {
  12555. const current = ParseUser.current();
  12556. return !!current && current.id === this.id;
  12557. }
  12558. /**
  12559. * Returns true if <code>current</code> would return this user.
  12560. *
  12561. * @returns {Promise<boolean>} true if user is cached on disk
  12562. */
  12563. async isCurrentAsync() {
  12564. const current = await ParseUser.currentAsync();
  12565. return !!current && current.id === this.id;
  12566. }
  12567. stripAnonymity() {
  12568. const authData = this.get('authData');
  12569. if (authData && typeof authData === 'object' && authData.hasOwnProperty('anonymous')) {
  12570. // We need to set anonymous to null instead of deleting it in order to remove it from Parse.
  12571. authData.anonymous = null;
  12572. }
  12573. }
  12574. restoreAnonimity(anonymousData) {
  12575. if (anonymousData) {
  12576. const authData = this.get('authData');
  12577. authData.anonymous = anonymousData;
  12578. }
  12579. }
  12580. /**
  12581. * Returns get("username").
  12582. *
  12583. * @returns {string}
  12584. */
  12585. getUsername() {
  12586. const username = this.get('username');
  12587. if (username == null || typeof username === 'string') {
  12588. return username;
  12589. }
  12590. return '';
  12591. }
  12592. /**
  12593. * Calls set("username", username, options) and returns the result.
  12594. *
  12595. * @param {string} username
  12596. */
  12597. setUsername(username) {
  12598. this.stripAnonymity();
  12599. this.set('username', username);
  12600. }
  12601. /**
  12602. * Calls set("password", password, options) and returns the result.
  12603. *
  12604. * @param {string} password User's Password
  12605. */
  12606. setPassword(password) {
  12607. this.set('password', password);
  12608. }
  12609. /**
  12610. * Returns get("email").
  12611. *
  12612. * @returns {string} User's Email
  12613. */
  12614. getEmail() {
  12615. const email = this.get('email');
  12616. if (email == null || typeof email === 'string') {
  12617. return email;
  12618. }
  12619. return '';
  12620. }
  12621. /**
  12622. * Calls set("email", email) and returns the result.
  12623. *
  12624. * @param {string} email
  12625. * @returns {boolean}
  12626. */
  12627. setEmail(email) {
  12628. return this.set('email', email);
  12629. }
  12630. /**
  12631. * Returns the session token for this user, if the user has been logged in,
  12632. * or if it is the result of a query with the master key. Otherwise, returns
  12633. * undefined.
  12634. *
  12635. * @returns {string} the session token, or undefined
  12636. */
  12637. getSessionToken() {
  12638. const token = this.get('sessionToken');
  12639. if (token == null || typeof token === 'string') {
  12640. return token;
  12641. }
  12642. return '';
  12643. }
  12644. /**
  12645. * Checks whether this user is the current user and has been authenticated.
  12646. *
  12647. * @returns {boolean} whether this user is the current user and is logged in.
  12648. */
  12649. authenticated() {
  12650. const current = ParseUser.current();
  12651. return !!this.get('sessionToken') && !!current && current.id === this.id;
  12652. }
  12653. /**
  12654. * Signs up a new user. You should call this instead of save for
  12655. * new Parse.Users. This will create a new Parse.User on the server, and
  12656. * also persist the session on disk so that you can access the user using
  12657. * <code>current</code>.
  12658. *
  12659. * <p>A username and password must be set before calling signUp.</p>
  12660. *
  12661. * @param {object} attrs Extra fields to set on the new user, or null.
  12662. * @param {object} options
  12663. * @returns {Promise} A promise that is fulfilled when the signup
  12664. * finishes.
  12665. */
  12666. signUp(attrs, options) {
  12667. options = options || {};
  12668. const signupOptions = {};
  12669. if (options.hasOwnProperty('useMasterKey')) {
  12670. signupOptions.useMasterKey = options.useMasterKey;
  12671. }
  12672. if (options.hasOwnProperty('installationId')) {
  12673. signupOptions.installationId = options.installationId;
  12674. }
  12675. if (options.hasOwnProperty('context') && Object.prototype.toString.call(options.context) === '[object Object]') {
  12676. signupOptions.context = options.context;
  12677. }
  12678. const controller = _CoreManager.default.getUserController();
  12679. return controller.signUp(this, attrs, signupOptions);
  12680. }
  12681. /**
  12682. * Logs in a Parse.User. On success, this saves the session to disk,
  12683. * so you can retrieve the currently logged in user using
  12684. * <code>current</code>.
  12685. *
  12686. * <p>A username and password must be set before calling logIn.</p>
  12687. *
  12688. * @param {object} options
  12689. * @returns {Promise} A promise that is fulfilled with the user when
  12690. * the login is complete.
  12691. */
  12692. logIn() {
  12693. let options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
  12694. options = options || {};
  12695. const loginOptions = {
  12696. usePost: true
  12697. };
  12698. if (options.hasOwnProperty('useMasterKey')) {
  12699. loginOptions.useMasterKey = options.useMasterKey;
  12700. }
  12701. if (options.hasOwnProperty('installationId')) {
  12702. loginOptions.installationId = options.installationId;
  12703. }
  12704. if (options.hasOwnProperty('usePost')) {
  12705. loginOptions.usePost = options.usePost;
  12706. }
  12707. if (options.hasOwnProperty('context') && Object.prototype.toString.call(options.context) === '[object Object]') {
  12708. loginOptions.context = options.context;
  12709. }
  12710. const controller = _CoreManager.default.getUserController();
  12711. return controller.logIn(this, loginOptions);
  12712. }
  12713. /**
  12714. * Wrap the default save behavior with functionality to save to local
  12715. * storage if this is current user.
  12716. *
  12717. * @param {...any} args
  12718. * @returns {Promise}
  12719. */
  12720. async save() {
  12721. for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
  12722. args[_key] = arguments[_key];
  12723. }
  12724. await super.save.apply(this, args);
  12725. const current = await this.isCurrentAsync();
  12726. if (current) {
  12727. return _CoreManager.default.getUserController().updateUserOnDisk(this);
  12728. }
  12729. return this;
  12730. }
  12731. /**
  12732. * Wrap the default destroy behavior with functionality that logs out
  12733. * the current user when it is destroyed
  12734. *
  12735. * @param {...any} args
  12736. * @returns {Parse.User}
  12737. */
  12738. async destroy() {
  12739. for (var _len2 = arguments.length, args = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
  12740. args[_key2] = arguments[_key2];
  12741. }
  12742. await super.destroy.apply(this, args);
  12743. const current = await this.isCurrentAsync();
  12744. if (current) {
  12745. return _CoreManager.default.getUserController().removeUserFromDisk();
  12746. }
  12747. return this;
  12748. }
  12749. /**
  12750. * Wrap the default fetch behavior with functionality to save to local
  12751. * storage if this is current user.
  12752. *
  12753. * @param {...any} args
  12754. * @returns {Parse.User}
  12755. */
  12756. async fetch() {
  12757. for (var _len3 = arguments.length, args = new Array(_len3), _key3 = 0; _key3 < _len3; _key3++) {
  12758. args[_key3] = arguments[_key3];
  12759. }
  12760. await super.fetch.apply(this, args);
  12761. const current = await this.isCurrentAsync();
  12762. if (current) {
  12763. return _CoreManager.default.getUserController().updateUserOnDisk(this);
  12764. }
  12765. return this;
  12766. }
  12767. /**
  12768. * Wrap the default fetchWithInclude behavior with functionality to save to local
  12769. * storage if this is current user.
  12770. *
  12771. * @param {...any} args
  12772. * @returns {Parse.User}
  12773. */
  12774. async fetchWithInclude() {
  12775. for (var _len4 = arguments.length, args = new Array(_len4), _key4 = 0; _key4 < _len4; _key4++) {
  12776. args[_key4] = arguments[_key4];
  12777. }
  12778. await super.fetchWithInclude.apply(this, args);
  12779. const current = await this.isCurrentAsync();
  12780. if (current) {
  12781. return _CoreManager.default.getUserController().updateUserOnDisk(this);
  12782. }
  12783. return this;
  12784. }
  12785. /**
  12786. * Verify whether a given password is the password of the current user.
  12787. *
  12788. * @param {string} password The password to be verified.
  12789. * @param {object} options The options.
  12790. * @param {boolean} [options.ignoreEmailVerification] Set to `true` to bypass email verification and verify
  12791. * the password regardless of whether the email has been verified. This requires the master key.
  12792. * @returns {Promise} A promise that is fulfilled with a user when the password is correct.
  12793. */
  12794. verifyPassword(password, options) {
  12795. const username = this.getUsername() || '';
  12796. return ParseUser.verifyPassword(username, password, options);
  12797. }
  12798. static readOnlyAttributes() {
  12799. return ['sessionToken'];
  12800. }
  12801. /**
  12802. * Adds functionality to the existing Parse.User class.
  12803. *
  12804. * @param {object} protoProps A set of properties to add to the prototype
  12805. * @param {object} classProps A set of static properties to add to the class
  12806. * @static
  12807. * @returns {Parse.User} The newly extended Parse.User class
  12808. */
  12809. static extend(protoProps, classProps) {
  12810. if (protoProps) {
  12811. for (const prop in protoProps) {
  12812. if (prop !== 'className') {
  12813. (0, _defineProperty.default)(ParseUser.prototype, prop, {
  12814. value: protoProps[prop],
  12815. enumerable: false,
  12816. writable: true,
  12817. configurable: true
  12818. });
  12819. }
  12820. }
  12821. }
  12822. if (classProps) {
  12823. for (const prop in classProps) {
  12824. if (prop !== 'className') {
  12825. (0, _defineProperty.default)(ParseUser, prop, {
  12826. value: classProps[prop],
  12827. enumerable: false,
  12828. writable: true,
  12829. configurable: true
  12830. });
  12831. }
  12832. }
  12833. }
  12834. return ParseUser;
  12835. }
  12836. /**
  12837. * Retrieves the currently logged in ParseUser with a valid session,
  12838. * either from memory or localStorage, if necessary.
  12839. *
  12840. * @static
  12841. * @returns {Parse.Object} The currently logged in Parse.User.
  12842. */
  12843. static current() {
  12844. if (!canUseCurrentUser) {
  12845. return null;
  12846. }
  12847. const controller = _CoreManager.default.getUserController();
  12848. return controller.currentUser();
  12849. }
  12850. /**
  12851. * Retrieves the currently logged in ParseUser from asynchronous Storage.
  12852. *
  12853. * @static
  12854. * @returns {Promise} A Promise that is resolved with the currently
  12855. * logged in Parse User
  12856. */
  12857. static currentAsync() {
  12858. if (!canUseCurrentUser) {
  12859. return _promise.default.resolve(null);
  12860. }
  12861. const controller = _CoreManager.default.getUserController();
  12862. return controller.currentUserAsync();
  12863. }
  12864. /**
  12865. * Signs up a new user with a username (or email) and password.
  12866. * This will create a new Parse.User on the server, and also persist the
  12867. * session in localStorage so that you can access the user using
  12868. * {@link #current}.
  12869. *
  12870. * @param {string} username The username (or email) to sign up with.
  12871. * @param {string} password The password to sign up with.
  12872. * @param {object} attrs Extra fields to set on the new user.
  12873. * @param {object} options
  12874. * @static
  12875. * @returns {Promise} A promise that is fulfilled with the user when
  12876. * the signup completes.
  12877. */
  12878. static signUp(username, password, attrs, options) {
  12879. attrs = attrs || {};
  12880. attrs.username = username;
  12881. attrs.password = password;
  12882. const user = new this(attrs);
  12883. return user.signUp({}, options);
  12884. }
  12885. /**
  12886. * Logs in a user with a username (or email) and password. On success, this
  12887. * saves the session to disk, so you can retrieve the currently logged in
  12888. * user using <code>current</code>.
  12889. *
  12890. * @param {string} username The username (or email) to log in with.
  12891. * @param {string} password The password to log in with.
  12892. * @param {object} options
  12893. * @static
  12894. * @returns {Promise} A promise that is fulfilled with the user when
  12895. * the login completes.
  12896. */
  12897. static logIn(username, password, options) {
  12898. if (typeof username !== 'string') {
  12899. return _promise.default.reject(new _ParseError.default(_ParseError.default.OTHER_CAUSE, 'Username must be a string.'));
  12900. } else if (typeof password !== 'string') {
  12901. return _promise.default.reject(new _ParseError.default(_ParseError.default.OTHER_CAUSE, 'Password must be a string.'));
  12902. }
  12903. const user = new this();
  12904. user._finishFetch({
  12905. username: username,
  12906. password: password
  12907. });
  12908. return user.logIn(options);
  12909. }
  12910. /**
  12911. * Logs in a user with a username (or email) and password, and authData. On success, this
  12912. * saves the session to disk, so you can retrieve the currently logged in
  12913. * user using <code>current</code>.
  12914. *
  12915. * @param {string} username The username (or email) to log in with.
  12916. * @param {string} password The password to log in with.
  12917. * @param {object} authData The authData to log in with.
  12918. * @param {object} options
  12919. * @static
  12920. * @returns {Promise} A promise that is fulfilled with the user when
  12921. * the login completes.
  12922. */
  12923. static logInWithAdditionalAuth(username, password, authData, options) {
  12924. if (typeof username !== 'string') {
  12925. return _promise.default.reject(new _ParseError.default(_ParseError.default.OTHER_CAUSE, 'Username must be a string.'));
  12926. }
  12927. if (typeof password !== 'string') {
  12928. return _promise.default.reject(new _ParseError.default(_ParseError.default.OTHER_CAUSE, 'Password must be a string.'));
  12929. }
  12930. if (Object.prototype.toString.call(authData) !== '[object Object]') {
  12931. return _promise.default.reject(new _ParseError.default(_ParseError.default.OTHER_CAUSE, 'Auth must be an object.'));
  12932. }
  12933. const user = new this();
  12934. user._finishFetch({
  12935. username: username,
  12936. password: password,
  12937. authData
  12938. });
  12939. return user.logIn(options);
  12940. }
  12941. /**
  12942. * Logs in a user with an objectId. On success, this saves the session
  12943. * to disk, so you can retrieve the currently logged in user using
  12944. * <code>current</code>.
  12945. *
  12946. * @param {string} userId The objectId for the user.
  12947. * @static
  12948. * @returns {Promise} A promise that is fulfilled with the user when
  12949. * the login completes.
  12950. */
  12951. static loginAs(userId) {
  12952. if (!userId) {
  12953. throw new _ParseError.default(_ParseError.default.USERNAME_MISSING, 'Cannot log in as user with an empty user id');
  12954. }
  12955. const controller = _CoreManager.default.getUserController();
  12956. const user = new this();
  12957. return controller.loginAs(user, userId);
  12958. }
  12959. /**
  12960. * Logs in a user with a session token. On success, this saves the session
  12961. * to disk, so you can retrieve the currently logged in user using
  12962. * <code>current</code>.
  12963. *
  12964. * @param {string} sessionToken The sessionToken to log in with.
  12965. * @param {object} options
  12966. * @static
  12967. * @returns {Promise} A promise that is fulfilled with the user when
  12968. * the login completes.
  12969. */
  12970. static become(sessionToken, options) {
  12971. if (!canUseCurrentUser) {
  12972. throw new Error('It is not memory-safe to become a user in a server environment');
  12973. }
  12974. options = options || {};
  12975. const becomeOptions = {
  12976. sessionToken: sessionToken
  12977. };
  12978. if (options.hasOwnProperty('useMasterKey')) {
  12979. becomeOptions.useMasterKey = options.useMasterKey;
  12980. }
  12981. const controller = _CoreManager.default.getUserController();
  12982. const user = new this();
  12983. return controller.become(user, becomeOptions);
  12984. }
  12985. /**
  12986. * Retrieves a user with a session token.
  12987. *
  12988. * @param {string} sessionToken The sessionToken to get user with.
  12989. * @param {object} options
  12990. * @static
  12991. * @returns {Promise} A promise that is fulfilled with the user is fetched.
  12992. */
  12993. static me(sessionToken) {
  12994. let options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
  12995. const controller = _CoreManager.default.getUserController();
  12996. const meOptions = {
  12997. sessionToken: sessionToken
  12998. };
  12999. if (options.useMasterKey) {
  13000. meOptions.useMasterKey = options.useMasterKey;
  13001. }
  13002. const user = new this();
  13003. return controller.me(user, meOptions);
  13004. }
  13005. /**
  13006. * Logs in a user with a session token. On success, this saves the session
  13007. * to disk, so you can retrieve the currently logged in user using
  13008. * <code>current</code>. If there is no session token the user will not logged in.
  13009. *
  13010. * @param {object} userJSON The JSON map of the User's data
  13011. * @static
  13012. * @returns {Promise} A promise that is fulfilled with the user when
  13013. * the login completes.
  13014. */
  13015. static hydrate(userJSON) {
  13016. const controller = _CoreManager.default.getUserController();
  13017. const user = new this();
  13018. return controller.hydrate(user, userJSON);
  13019. }
  13020. /**
  13021. * Static version of {@link https://parseplatform.org/Parse-SDK-JS/api/master/Parse.User.html#linkWith linkWith}
  13022. *
  13023. * @param provider
  13024. * @param options
  13025. * @param {object} [options.authData]
  13026. * @param saveOpts
  13027. * @static
  13028. * @returns {Promise}
  13029. */
  13030. static logInWith(provider, options, saveOpts) {
  13031. const user = new this();
  13032. return user.linkWith(provider, options, saveOpts);
  13033. }
  13034. /**
  13035. * Logs out the currently logged in user session. This will remove the
  13036. * session from disk, log out of linked services, and future calls to
  13037. * <code>current</code> will return <code>null</code>.
  13038. *
  13039. * @param {object} options
  13040. * @static
  13041. * @returns {Promise} A promise that is resolved when the session is
  13042. * destroyed on the server.
  13043. */
  13044. static logOut() {
  13045. let options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
  13046. const controller = _CoreManager.default.getUserController();
  13047. return controller.logOut(options);
  13048. }
  13049. /**
  13050. * Requests a password reset email to be sent to the specified email address
  13051. * associated with the user account. This email allows the user to securely
  13052. * reset their password on the Parse site.
  13053. *
  13054. * @param {string} email The email address associated with the user that
  13055. * forgot their password.
  13056. * @param {object} options
  13057. * @static
  13058. * @returns {Promise}
  13059. */
  13060. static requestPasswordReset(email, options) {
  13061. options = options || {};
  13062. const requestOptions = {};
  13063. if (options.hasOwnProperty('useMasterKey')) {
  13064. requestOptions.useMasterKey = options.useMasterKey;
  13065. }
  13066. const controller = _CoreManager.default.getUserController();
  13067. return controller.requestPasswordReset(email, requestOptions);
  13068. }
  13069. /**
  13070. * Request an email verification.
  13071. *
  13072. * @param {string} email The email address associated with the user that
  13073. * needs to verify their email.
  13074. * @param {object} options
  13075. * @static
  13076. * @returns {Promise}
  13077. */
  13078. static requestEmailVerification(email, options) {
  13079. options = options || {};
  13080. const requestOptions = {};
  13081. if (options.hasOwnProperty('useMasterKey')) {
  13082. requestOptions.useMasterKey = options.useMasterKey;
  13083. }
  13084. const controller = _CoreManager.default.getUserController();
  13085. return controller.requestEmailVerification(email, requestOptions);
  13086. }
  13087. /**
  13088. * Verify whether a given password is the password of the current user.
  13089. * @static
  13090. *
  13091. * @param {string} username The username of the user whose password should be verified.
  13092. * @param {string} password The password to be verified.
  13093. * @param {object} options The options.
  13094. * @param {boolean} [options.ignoreEmailVerification] Set to `true` to bypass email verification and verify
  13095. * the password regardless of whether the email has been verified. This requires the master key.
  13096. * @returns {Promise} A promise that is fulfilled with a user when the password is correct.
  13097. */
  13098. static verifyPassword(username, password, options) {
  13099. if (typeof username !== 'string') {
  13100. return _promise.default.reject(new _ParseError.default(_ParseError.default.OTHER_CAUSE, 'Username must be a string.'));
  13101. }
  13102. if (typeof password !== 'string') {
  13103. return _promise.default.reject(new _ParseError.default(_ParseError.default.OTHER_CAUSE, 'Password must be a string.'));
  13104. }
  13105. const controller = _CoreManager.default.getUserController();
  13106. return controller.verifyPassword(username, password, options || {});
  13107. }
  13108. /**
  13109. * Allow someone to define a custom User class without className
  13110. * being rewritten to _User. The default behavior is to rewrite
  13111. * User to _User for legacy reasons. This allows developers to
  13112. * override that behavior.
  13113. *
  13114. * @param {boolean} isAllowed Whether or not to allow custom User class
  13115. * @static
  13116. */
  13117. static allowCustomUserClass(isAllowed) {
  13118. _CoreManager.default.set('PERFORM_USER_REWRITE', !isAllowed);
  13119. }
  13120. /**
  13121. * Allows a legacy application to start using revocable sessions. If the
  13122. * current session token is not revocable, a request will be made for a new,
  13123. * revocable session.
  13124. * It is not necessary to call this method from cloud code unless you are
  13125. * handling user signup or login from the server side. In a cloud code call,
  13126. * this function will not attempt to upgrade the current token.
  13127. *
  13128. * @param {object} options
  13129. * @static
  13130. * @returns {Promise} A promise that is resolved when the process has
  13131. * completed. If a replacement session token is requested, the promise
  13132. * will be resolved after a new token has been fetched.
  13133. */
  13134. static enableRevocableSession(options) {
  13135. options = options || {};
  13136. _CoreManager.default.set('FORCE_REVOCABLE_SESSION', true);
  13137. if (canUseCurrentUser) {
  13138. const current = ParseUser.current();
  13139. if (current) {
  13140. return current._upgradeToRevocableSession(options);
  13141. }
  13142. }
  13143. return _promise.default.resolve();
  13144. }
  13145. /**
  13146. * Enables the use of become or the current user in a server
  13147. * environment. These features are disabled by default, since they depend on
  13148. * global objects that are not memory-safe for most servers.
  13149. *
  13150. * @static
  13151. */
  13152. static enableUnsafeCurrentUser() {
  13153. canUseCurrentUser = true;
  13154. }
  13155. /**
  13156. * Disables the use of become or the current user in any environment.
  13157. * These features are disabled on servers by default, since they depend on
  13158. * global objects that are not memory-safe for most servers.
  13159. *
  13160. * @static
  13161. */
  13162. static disableUnsafeCurrentUser() {
  13163. canUseCurrentUser = false;
  13164. }
  13165. /**
  13166. * When registering users with {@link https://parseplatform.org/Parse-SDK-JS/api/master/Parse.User.html#linkWith linkWith} a basic auth provider
  13167. * is automatically created for you.
  13168. *
  13169. * For advanced authentication, you can register an Auth provider to
  13170. * implement custom authentication, deauthentication.
  13171. *
  13172. * @param provider
  13173. * @see {@link https://parseplatform.org/Parse-SDK-JS/api/master/AuthProvider.html AuthProvider}
  13174. * @see {@link https://docs.parseplatform.org/js/guide/#custom-authentication-module Custom Authentication Module}
  13175. * @static
  13176. */
  13177. static _registerAuthenticationProvider(provider) {
  13178. authProviders[provider.getAuthType()] = provider;
  13179. // Synchronize the current user with the auth provider.
  13180. ParseUser.currentAsync().then(current => {
  13181. if (current) {
  13182. current._synchronizeAuthData(provider.getAuthType());
  13183. }
  13184. });
  13185. }
  13186. /**
  13187. * @param provider
  13188. * @param options
  13189. * @param {object} [options.authData]
  13190. * @param saveOpts
  13191. * @deprecated since 2.9.0 see {@link https://parseplatform.org/Parse-SDK-JS/api/master/Parse.User.html#logInWith logInWith}
  13192. * @static
  13193. * @returns {Promise}
  13194. */
  13195. static _logInWith(provider, options, saveOpts) {
  13196. const user = new this();
  13197. return user.linkWith(provider, options, saveOpts);
  13198. }
  13199. static _clearCache() {
  13200. currentUserCache = null;
  13201. currentUserCacheMatchesDisk = false;
  13202. }
  13203. static _setCurrentUserCache(user) {
  13204. currentUserCache = user;
  13205. }
  13206. }
  13207. _ParseObject.default.registerSubclass('_User', ParseUser);
  13208. const DefaultController = {
  13209. updateUserOnDisk(user) {
  13210. const path = _Storage.default.generatePath(CURRENT_USER_KEY);
  13211. const json = user.toJSON();
  13212. delete json.password;
  13213. json.className = '_User';
  13214. let userData = (0, _stringify.default)(json);
  13215. if (_CoreManager.default.get('ENCRYPTED_USER')) {
  13216. const crypto = _CoreManager.default.getCryptoController();
  13217. userData = crypto.encrypt(json, _CoreManager.default.get('ENCRYPTED_KEY'));
  13218. }
  13219. return _Storage.default.setItemAsync(path, userData).then(() => {
  13220. return user;
  13221. });
  13222. },
  13223. removeUserFromDisk() {
  13224. const path = _Storage.default.generatePath(CURRENT_USER_KEY);
  13225. currentUserCacheMatchesDisk = true;
  13226. currentUserCache = null;
  13227. return _Storage.default.removeItemAsync(path);
  13228. },
  13229. setCurrentUser(user) {
  13230. currentUserCache = user;
  13231. user._cleanupAuthData();
  13232. user._synchronizeAllAuthData();
  13233. return DefaultController.updateUserOnDisk(user);
  13234. },
  13235. currentUser() {
  13236. if (currentUserCache) {
  13237. return currentUserCache;
  13238. }
  13239. if (currentUserCacheMatchesDisk) {
  13240. return null;
  13241. }
  13242. if (_Storage.default.async()) {
  13243. throw new Error('Cannot call currentUser() when using a platform with an async ' + 'storage system. Call currentUserAsync() instead.');
  13244. }
  13245. const path = _Storage.default.generatePath(CURRENT_USER_KEY);
  13246. let userData = _Storage.default.getItem(path);
  13247. currentUserCacheMatchesDisk = true;
  13248. if (!userData) {
  13249. currentUserCache = null;
  13250. return null;
  13251. }
  13252. if (_CoreManager.default.get('ENCRYPTED_USER')) {
  13253. const crypto = _CoreManager.default.getCryptoController();
  13254. userData = crypto.decrypt(userData, _CoreManager.default.get('ENCRYPTED_KEY'));
  13255. }
  13256. userData = JSON.parse(userData);
  13257. if (!userData.className) {
  13258. userData.className = '_User';
  13259. }
  13260. if (userData._id) {
  13261. if (userData.objectId !== userData._id) {
  13262. userData.objectId = userData._id;
  13263. }
  13264. delete userData._id;
  13265. }
  13266. if (userData._sessionToken) {
  13267. userData.sessionToken = userData._sessionToken;
  13268. delete userData._sessionToken;
  13269. }
  13270. const current = _ParseObject.default.fromJSON(userData);
  13271. currentUserCache = current;
  13272. current._synchronizeAllAuthData();
  13273. return current;
  13274. },
  13275. currentUserAsync() {
  13276. if (currentUserCache) {
  13277. return _promise.default.resolve(currentUserCache);
  13278. }
  13279. if (currentUserCacheMatchesDisk) {
  13280. return _promise.default.resolve(null);
  13281. }
  13282. const path = _Storage.default.generatePath(CURRENT_USER_KEY);
  13283. return _Storage.default.getItemAsync(path).then(userData => {
  13284. currentUserCacheMatchesDisk = true;
  13285. if (!userData) {
  13286. currentUserCache = null;
  13287. return _promise.default.resolve(null);
  13288. }
  13289. if (_CoreManager.default.get('ENCRYPTED_USER')) {
  13290. const crypto = _CoreManager.default.getCryptoController();
  13291. userData = crypto.decrypt(userData.toString(), _CoreManager.default.get('ENCRYPTED_KEY'));
  13292. }
  13293. userData = JSON.parse(userData);
  13294. if (!userData.className) {
  13295. userData.className = '_User';
  13296. }
  13297. if (userData._id) {
  13298. if (userData.objectId !== userData._id) {
  13299. userData.objectId = userData._id;
  13300. }
  13301. delete userData._id;
  13302. }
  13303. if (userData._sessionToken) {
  13304. userData.sessionToken = userData._sessionToken;
  13305. delete userData._sessionToken;
  13306. }
  13307. const current = _ParseObject.default.fromJSON(userData);
  13308. currentUserCache = current;
  13309. current._synchronizeAllAuthData();
  13310. return _promise.default.resolve(current);
  13311. });
  13312. },
  13313. signUp(user, attrs, options) {
  13314. const username = attrs && attrs.username || user.get('username');
  13315. const password = attrs && attrs.password || user.get('password');
  13316. if (!username || !username.length) {
  13317. return _promise.default.reject(new _ParseError.default(_ParseError.default.OTHER_CAUSE, 'Cannot sign up user with an empty username.'));
  13318. }
  13319. if (!password || !password.length) {
  13320. return _promise.default.reject(new _ParseError.default(_ParseError.default.OTHER_CAUSE, 'Cannot sign up user with an empty password.'));
  13321. }
  13322. return user.save(attrs, options).then(() => {
  13323. // Clear the password field
  13324. user._finishFetch({
  13325. password: undefined
  13326. });
  13327. if (canUseCurrentUser) {
  13328. return DefaultController.setCurrentUser(user);
  13329. }
  13330. return user;
  13331. });
  13332. },
  13333. logIn(user, options) {
  13334. const RESTController = _CoreManager.default.getRESTController();
  13335. const stateController = _CoreManager.default.getObjectStateController();
  13336. const auth = {
  13337. username: user.get('username'),
  13338. password: user.get('password'),
  13339. authData: user.get('authData')
  13340. };
  13341. return RESTController.request(options.usePost ? 'POST' : 'GET', 'login', auth, options).then(response => {
  13342. user._migrateId(response.objectId);
  13343. user._setExisted(true);
  13344. stateController.setPendingOp(user._getStateIdentifier(), 'username', undefined);
  13345. stateController.setPendingOp(user._getStateIdentifier(), 'password', undefined);
  13346. response.password = undefined;
  13347. user._finishFetch(response);
  13348. if (!canUseCurrentUser) {
  13349. // We can't set the current user, so just return the one we logged in
  13350. return _promise.default.resolve(user);
  13351. }
  13352. return DefaultController.setCurrentUser(user);
  13353. });
  13354. },
  13355. loginAs(user, userId) {
  13356. const RESTController = _CoreManager.default.getRESTController();
  13357. return RESTController.request('POST', 'loginAs', {
  13358. userId
  13359. }, {
  13360. useMasterKey: true
  13361. }).then(response => {
  13362. user._finishFetch(response);
  13363. user._setExisted(true);
  13364. if (!canUseCurrentUser) {
  13365. return _promise.default.resolve(user);
  13366. }
  13367. return DefaultController.setCurrentUser(user);
  13368. });
  13369. },
  13370. become(user, options) {
  13371. const RESTController = _CoreManager.default.getRESTController();
  13372. return RESTController.request('GET', 'users/me', {}, options).then(response => {
  13373. user._finishFetch(response);
  13374. user._setExisted(true);
  13375. return DefaultController.setCurrentUser(user);
  13376. });
  13377. },
  13378. hydrate(user, userJSON) {
  13379. user._finishFetch(userJSON);
  13380. user._setExisted(true);
  13381. if (userJSON.sessionToken && canUseCurrentUser) {
  13382. return DefaultController.setCurrentUser(user);
  13383. } else {
  13384. return _promise.default.resolve(user);
  13385. }
  13386. },
  13387. me(user, options) {
  13388. const RESTController = _CoreManager.default.getRESTController();
  13389. return RESTController.request('GET', 'users/me', {}, options).then(response => {
  13390. user._finishFetch(response);
  13391. user._setExisted(true);
  13392. return user;
  13393. });
  13394. },
  13395. logOut(options) {
  13396. const RESTController = _CoreManager.default.getRESTController();
  13397. if (options.sessionToken) {
  13398. return RESTController.request('POST', 'logout', {}, options);
  13399. }
  13400. return DefaultController.currentUserAsync().then(currentUser => {
  13401. const path = _Storage.default.generatePath(CURRENT_USER_KEY);
  13402. let promise = _Storage.default.removeItemAsync(path);
  13403. if (currentUser !== null) {
  13404. const currentSession = currentUser.getSessionToken();
  13405. if (currentSession && (0, _isRevocableSession.default)(currentSession)) {
  13406. promise = promise.then(() => {
  13407. return RESTController.request('POST', 'logout', {}, {
  13408. sessionToken: currentSession
  13409. });
  13410. });
  13411. }
  13412. currentUser._logOutWithAll();
  13413. currentUser._finishFetch({
  13414. sessionToken: undefined
  13415. });
  13416. }
  13417. currentUserCacheMatchesDisk = true;
  13418. currentUserCache = null;
  13419. return promise;
  13420. });
  13421. },
  13422. requestPasswordReset(email, options) {
  13423. const RESTController = _CoreManager.default.getRESTController();
  13424. return RESTController.request('POST', 'requestPasswordReset', {
  13425. email: email
  13426. }, options);
  13427. },
  13428. async upgradeToRevocableSession(user, options) {
  13429. const token = user.getSessionToken();
  13430. if (!token) {
  13431. return _promise.default.reject(new _ParseError.default(_ParseError.default.SESSION_MISSING, 'Cannot upgrade a user with no session token'));
  13432. }
  13433. options.sessionToken = token;
  13434. const RESTController = _CoreManager.default.getRESTController();
  13435. const result = await RESTController.request('POST', 'upgradeToRevocableSession', {}, options);
  13436. user._finishFetch({
  13437. sessionToken: result?.sessionToken || ''
  13438. });
  13439. const current = await user.isCurrentAsync();
  13440. if (current) {
  13441. return DefaultController.setCurrentUser(user);
  13442. }
  13443. return _promise.default.resolve(user);
  13444. },
  13445. linkWith(user, authData, options) {
  13446. return user.save({
  13447. authData
  13448. }, options).then(() => {
  13449. if (canUseCurrentUser) {
  13450. return DefaultController.setCurrentUser(user);
  13451. }
  13452. return user;
  13453. });
  13454. },
  13455. verifyPassword(username, password, options) {
  13456. const RESTController = _CoreManager.default.getRESTController();
  13457. const data = {
  13458. username,
  13459. password,
  13460. ...(options.ignoreEmailVerification !== undefined && {
  13461. ignoreEmailVerification: options.ignoreEmailVerification
  13462. })
  13463. };
  13464. return RESTController.request('GET', 'verifyPassword', data, options);
  13465. },
  13466. requestEmailVerification(email, options) {
  13467. const RESTController = _CoreManager.default.getRESTController();
  13468. return RESTController.request('POST', 'verificationEmailRequest', {
  13469. email: email
  13470. }, options);
  13471. }
  13472. };
  13473. _CoreManager.default.setParseUser(ParseUser);
  13474. _CoreManager.default.setUserController(DefaultController);
  13475. var _default = exports.default = ParseUser;
  13476. },{"./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){
  13477. "use strict";
  13478. var _Object$defineProperty = _dereq_("@babel/runtime-corejs3/core-js-stable/object/define-property");
  13479. var _interopRequireDefault = _dereq_("@babel/runtime-corejs3/helpers/interopRequireDefault");
  13480. _Object$defineProperty(exports, "__esModule", {
  13481. value: true
  13482. });
  13483. exports.getPushStatus = getPushStatus;
  13484. exports.send = send;
  13485. var _CoreManager = _interopRequireDefault(_dereq_("./CoreManager"));
  13486. var _ParseQuery = _interopRequireDefault(_dereq_("./ParseQuery"));
  13487. /**
  13488. * Contains functions to deal with Push in Parse.
  13489. *
  13490. * @class Parse.Push
  13491. * @static
  13492. * @hideconstructor
  13493. */
  13494. /**
  13495. * Sends a push notification.
  13496. * **Available in Cloud Code only.**
  13497. *
  13498. * See {@link https://docs.parseplatform.org/js/guide/#push-notifications Push Notification Guide}
  13499. *
  13500. * @function send
  13501. * @name Parse.Push.send
  13502. * @param {object} data - The data of the push notification. Valid fields
  13503. * are:
  13504. * <ol>
  13505. * <li>channels - An Array of channels to push to.</li>
  13506. * <li>push_time - A Date object for when to send the push.</li>
  13507. * <li>expiration_time - A Date object for when to expire
  13508. * the push.</li>
  13509. * <li>expiration_interval - The seconds from now to expire the push.</li>
  13510. * <li>where - A Parse.Query over Parse.Installation that is used to match
  13511. * a set of installations to push to.</li>
  13512. * <li>data - The data to send as part of the push.</li>
  13513. * <ol>
  13514. * @param {object} options Valid options
  13515. * are:<ul>
  13516. * <li>useMasterKey: In Cloud Code and Node only, causes the Master Key to
  13517. * be used for this request.
  13518. * </ul>
  13519. * @returns {Promise} A promise that is fulfilled when the push request
  13520. * completes and returns `pushStatusId`.
  13521. */
  13522. function send(data) {
  13523. let options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
  13524. if (data.where && data.where instanceof _ParseQuery.default) {
  13525. data.where = data.where.toJSON().where;
  13526. }
  13527. if (data.push_time && typeof data.push_time === 'object') {
  13528. data.push_time = data.push_time.toJSON();
  13529. }
  13530. if (data.expiration_time && typeof data.expiration_time === 'object') {
  13531. data.expiration_time = data.expiration_time.toJSON();
  13532. }
  13533. if (data.expiration_time && data.expiration_interval) {
  13534. throw new Error('expiration_time and expiration_interval cannot both be set.');
  13535. }
  13536. const pushOptions = {
  13537. useMasterKey: true
  13538. };
  13539. if (options.hasOwnProperty('useMasterKey')) {
  13540. pushOptions.useMasterKey = options.useMasterKey;
  13541. }
  13542. return _CoreManager.default.getPushController().send(data, pushOptions);
  13543. }
  13544. /**
  13545. * Gets push status by Id
  13546. *
  13547. * @function getPushStatus
  13548. * @name Parse.Push.getPushStatus
  13549. * @param {string} pushStatusId The Id of Push Status.
  13550. * @param {object} options Valid options
  13551. * are:<ul>
  13552. * <li>useMasterKey: In Cloud Code and Node only, causes the Master Key to
  13553. * be used for this request.
  13554. * </ul>
  13555. * @returns {Parse.Object} Status of Push.
  13556. */
  13557. function getPushStatus(pushStatusId) {
  13558. let options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
  13559. const pushOptions = {
  13560. useMasterKey: true
  13561. };
  13562. if (options.hasOwnProperty('useMasterKey')) {
  13563. pushOptions.useMasterKey = options.useMasterKey;
  13564. }
  13565. const query = new _ParseQuery.default('_PushStatus');
  13566. return query.get(pushStatusId, pushOptions);
  13567. }
  13568. const DefaultController = {
  13569. async send(data, options) {
  13570. options.returnStatus = true;
  13571. const response = await _CoreManager.default.getRESTController().request('POST', 'push', data, options);
  13572. return response._headers?.['X-Parse-Push-Status-Id'];
  13573. }
  13574. };
  13575. _CoreManager.default.setPushController(DefaultController);
  13576. },{"./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){
  13577. (function (process){(function (){
  13578. "use strict";
  13579. var _Object$defineProperty = _dereq_("@babel/runtime-corejs3/core-js-stable/object/define-property");
  13580. var _interopRequireDefault = _dereq_("@babel/runtime-corejs3/helpers/interopRequireDefault");
  13581. _Object$defineProperty(exports, "__esModule", {
  13582. value: true
  13583. });
  13584. exports.default = void 0;
  13585. var _promise = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/promise"));
  13586. var _stringify = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/json/stringify"));
  13587. var _includes = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/instance/includes"));
  13588. var _forEach = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/instance/for-each"));
  13589. var _indexOf = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/instance/index-of"));
  13590. var _setTimeout2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/set-timeout"));
  13591. var _uuid = _interopRequireDefault(_dereq_("./uuid"));
  13592. var _CoreManager = _interopRequireDefault(_dereq_("./CoreManager"));
  13593. var _ParseError = _interopRequireDefault(_dereq_("./ParseError"));
  13594. var _promiseUtils = _dereq_("./promiseUtils");
  13595. var _Xhr = _interopRequireDefault(_dereq_("./Xhr.weapp"));
  13596. /* global XMLHttpRequest, XDomainRequest */
  13597. let XHR = null;
  13598. if (typeof XMLHttpRequest !== 'undefined') {
  13599. XHR = XMLHttpRequest;
  13600. }
  13601. XHR = _Xhr.default;
  13602. let useXDomainRequest = false;
  13603. // @ts-ignore
  13604. if (typeof XDomainRequest !== 'undefined' && !('withCredentials' in new XMLHttpRequest())) {
  13605. useXDomainRequest = true;
  13606. }
  13607. function ajaxIE9(method, url, data, headers, options) {
  13608. return new _promise.default((resolve, reject) => {
  13609. // @ts-ignore
  13610. const xdr = new XDomainRequest();
  13611. xdr.onload = function () {
  13612. let response;
  13613. try {
  13614. response = JSON.parse(xdr.responseText);
  13615. } catch (e) {
  13616. reject(e);
  13617. }
  13618. if (response) {
  13619. resolve({
  13620. response
  13621. });
  13622. }
  13623. };
  13624. xdr.onerror = xdr.ontimeout = function () {
  13625. // Let's fake a real error message.
  13626. const fakeResponse = {
  13627. responseText: (0, _stringify.default)({
  13628. code: _ParseError.default.X_DOMAIN_REQUEST,
  13629. error: "IE's XDomainRequest does not supply error info."
  13630. })
  13631. };
  13632. reject(fakeResponse);
  13633. };
  13634. xdr.onprogress = function () {
  13635. if (options && typeof options.progress === 'function') {
  13636. options.progress(xdr.responseText);
  13637. }
  13638. };
  13639. xdr.open(method, url);
  13640. xdr.send(data);
  13641. // @ts-ignore
  13642. if (options && typeof options.requestTask === 'function') {
  13643. // @ts-ignore
  13644. options.requestTask(xdr);
  13645. }
  13646. });
  13647. }
  13648. const RESTController = {
  13649. ajax(method, url, data, headers, options) {
  13650. var _context;
  13651. if (useXDomainRequest) {
  13652. return ajaxIE9(method, url, data, headers, options);
  13653. }
  13654. const promise = (0, _promiseUtils.resolvingPromise)();
  13655. const isIdempotent = _CoreManager.default.get('IDEMPOTENCY') && (0, _includes.default)(_context = ['POST', 'PUT']).call(_context, method);
  13656. const requestId = isIdempotent ? (0, _uuid.default)() : '';
  13657. let attempts = 0;
  13658. const dispatch = function () {
  13659. if (XHR == null) {
  13660. throw new Error('Cannot make a request: No definition of XMLHttpRequest was found.');
  13661. }
  13662. let handled = false;
  13663. const xhr = new XHR();
  13664. xhr.onreadystatechange = function () {
  13665. if (xhr.readyState !== 4 || handled || xhr._aborted) {
  13666. return;
  13667. }
  13668. handled = true;
  13669. if (xhr.status >= 200 && xhr.status < 300) {
  13670. let response;
  13671. try {
  13672. response = JSON.parse(xhr.responseText);
  13673. const availableHeaders = typeof xhr.getAllResponseHeaders === 'function' ? xhr.getAllResponseHeaders() : '';
  13674. headers = {};
  13675. if (typeof xhr.getResponseHeader === 'function' && availableHeaders?.indexOf('access-control-expose-headers') >= 0) {
  13676. const responseHeaders = xhr.getResponseHeader('access-control-expose-headers').split(', ');
  13677. (0, _forEach.default)(responseHeaders).call(responseHeaders, header => {
  13678. if ((0, _indexOf.default)(availableHeaders).call(availableHeaders, header.toLowerCase()) >= 0) {
  13679. headers[header] = xhr.getResponseHeader(header.toLowerCase());
  13680. }
  13681. });
  13682. }
  13683. } catch (e) {
  13684. promise.reject(e.toString());
  13685. }
  13686. if (response) {
  13687. promise.resolve({
  13688. response,
  13689. headers,
  13690. status: xhr.status,
  13691. xhr
  13692. });
  13693. }
  13694. } else if (xhr.status >= 500 || xhr.status === 0) {
  13695. // retry on 5XX or node-xmlhttprequest error
  13696. if (++attempts < _CoreManager.default.get('REQUEST_ATTEMPT_LIMIT')) {
  13697. // Exponentially-growing random delay
  13698. const delay = Math.round(Math.random() * 125 * Math.pow(2, attempts));
  13699. (0, _setTimeout2.default)(dispatch, delay);
  13700. } else if (xhr.status === 0) {
  13701. promise.reject('Unable to connect to the Parse API');
  13702. } else {
  13703. // After the retry limit is reached, fail
  13704. promise.reject(xhr);
  13705. }
  13706. } else {
  13707. promise.reject(xhr);
  13708. }
  13709. };
  13710. headers = headers || {};
  13711. if (typeof headers['Content-Type'] !== 'string') {
  13712. headers['Content-Type'] = 'text/plain'; // Avoid pre-flight
  13713. }
  13714. if (_CoreManager.default.get('IS_NODE')) {
  13715. headers['User-Agent'] = 'Parse/' + _CoreManager.default.get('VERSION') + ' (NodeJS ' + process.versions.node + ')';
  13716. }
  13717. if (isIdempotent) {
  13718. headers['X-Parse-Request-Id'] = requestId;
  13719. }
  13720. if (_CoreManager.default.get('SERVER_AUTH_TYPE') && _CoreManager.default.get('SERVER_AUTH_TOKEN')) {
  13721. headers['Authorization'] = _CoreManager.default.get('SERVER_AUTH_TYPE') + ' ' + _CoreManager.default.get('SERVER_AUTH_TOKEN');
  13722. }
  13723. const customHeaders = _CoreManager.default.get('REQUEST_HEADERS');
  13724. for (const key in customHeaders) {
  13725. headers[key] = customHeaders[key];
  13726. }
  13727. if (options && typeof options.progress === 'function') {
  13728. const handleProgress = function (type, event) {
  13729. if (event.lengthComputable) {
  13730. options.progress(event.loaded / event.total, event.loaded, event.total, {
  13731. type
  13732. });
  13733. } else {
  13734. options.progress(null, null, null, {
  13735. type
  13736. });
  13737. }
  13738. };
  13739. xhr.onprogress = event => {
  13740. handleProgress('download', event);
  13741. };
  13742. if (xhr.upload) {
  13743. xhr.upload.onprogress = event => {
  13744. handleProgress('upload', event);
  13745. };
  13746. }
  13747. }
  13748. xhr.open(method, url, true);
  13749. for (const h in headers) {
  13750. xhr.setRequestHeader(h, headers[h]);
  13751. }
  13752. xhr.onabort = function () {
  13753. promise.resolve({
  13754. response: {
  13755. results: []
  13756. },
  13757. status: 0,
  13758. xhr
  13759. });
  13760. };
  13761. xhr.send(data);
  13762. // @ts-ignore
  13763. if (options && typeof options.requestTask === 'function') {
  13764. // @ts-ignore
  13765. options.requestTask(xhr);
  13766. }
  13767. };
  13768. dispatch();
  13769. return promise;
  13770. },
  13771. request(method, path, data, options) {
  13772. options = options || {};
  13773. let url = _CoreManager.default.get('SERVER_URL');
  13774. if (url[url.length - 1] !== '/') {
  13775. url += '/';
  13776. }
  13777. url += path;
  13778. const payload = {};
  13779. if (data && typeof data === 'object') {
  13780. for (const k in data) {
  13781. payload[k] = data[k];
  13782. }
  13783. }
  13784. // Add context
  13785. const context = options.context;
  13786. if (context !== undefined) {
  13787. payload._context = context;
  13788. }
  13789. if (method !== 'POST') {
  13790. payload._method = method;
  13791. method = 'POST';
  13792. }
  13793. payload._ApplicationId = _CoreManager.default.get('APPLICATION_ID');
  13794. const jsKey = _CoreManager.default.get('JAVASCRIPT_KEY');
  13795. if (jsKey) {
  13796. payload._JavaScriptKey = jsKey;
  13797. }
  13798. payload._ClientVersion = _CoreManager.default.get('VERSION');
  13799. let useMasterKey = options.useMasterKey;
  13800. if (typeof useMasterKey === 'undefined') {
  13801. useMasterKey = _CoreManager.default.get('USE_MASTER_KEY');
  13802. }
  13803. if (useMasterKey) {
  13804. if (_CoreManager.default.get('MASTER_KEY')) {
  13805. delete payload._JavaScriptKey;
  13806. payload._MasterKey = _CoreManager.default.get('MASTER_KEY');
  13807. } else {
  13808. throw new Error('Cannot use the Master Key, it has not been provided.');
  13809. }
  13810. }
  13811. if (_CoreManager.default.get('FORCE_REVOCABLE_SESSION')) {
  13812. payload._RevocableSession = '1';
  13813. }
  13814. const installationId = options.installationId;
  13815. let installationIdPromise;
  13816. if (installationId && typeof installationId === 'string') {
  13817. installationIdPromise = _promise.default.resolve(installationId);
  13818. } else {
  13819. const installationController = _CoreManager.default.getInstallationController();
  13820. installationIdPromise = installationController.currentInstallationId();
  13821. }
  13822. return installationIdPromise.then(iid => {
  13823. payload._InstallationId = iid;
  13824. const userController = _CoreManager.default.getUserController();
  13825. if (options && typeof options.sessionToken === 'string') {
  13826. return _promise.default.resolve(options.sessionToken);
  13827. } else if (userController) {
  13828. return userController.currentUserAsync().then(user => {
  13829. if (user) {
  13830. return _promise.default.resolve(user.getSessionToken());
  13831. }
  13832. return _promise.default.resolve(null);
  13833. });
  13834. }
  13835. return _promise.default.resolve(null);
  13836. }).then(token => {
  13837. if (token) {
  13838. payload._SessionToken = token;
  13839. }
  13840. const payloadString = (0, _stringify.default)(payload);
  13841. return RESTController.ajax(method, url, payloadString, {}, options).then(_ref => {
  13842. let {
  13843. response,
  13844. status,
  13845. headers,
  13846. xhr
  13847. } = _ref;
  13848. if (options.returnStatus) {
  13849. return {
  13850. ...response,
  13851. _status: status,
  13852. _headers: headers,
  13853. _xhr: xhr
  13854. };
  13855. } else {
  13856. return response;
  13857. }
  13858. });
  13859. }).catch(RESTController.handleError);
  13860. },
  13861. handleError(response) {
  13862. // Transform the error into an instance of ParseError by trying to parse
  13863. // the error string as JSON
  13864. let error;
  13865. if (response && response.responseText) {
  13866. try {
  13867. const errorJSON = JSON.parse(response.responseText);
  13868. error = new _ParseError.default(errorJSON.code, errorJSON.error);
  13869. } catch (e) {
  13870. // If we fail to parse the error text, that's okay.
  13871. error = new _ParseError.default(_ParseError.default.INVALID_JSON, 'Received an error with invalid JSON from Parse: ' + response.responseText);
  13872. }
  13873. } else {
  13874. const message = response.message ? response.message : response;
  13875. error = new _ParseError.default(_ParseError.default.CONNECTION_FAILED, 'XMLHttpRequest failed: ' + (0, _stringify.default)(message));
  13876. }
  13877. return _promise.default.reject(error);
  13878. },
  13879. _setXHR(xhr) {
  13880. XHR = xhr;
  13881. },
  13882. _getXHR() {
  13883. return XHR;
  13884. }
  13885. };
  13886. module.exports = RESTController;
  13887. var _default = exports.default = RESTController;
  13888. }).call(this)}).call(this,_dereq_('_process'))
  13889. },{"./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){
  13890. "use strict";
  13891. var _WeakMap = _dereq_("@babel/runtime-corejs3/core-js-stable/weak-map");
  13892. var _Object$defineProperty = _dereq_("@babel/runtime-corejs3/core-js-stable/object/define-property");
  13893. var _Object$getOwnPropertyDescriptor = _dereq_("@babel/runtime-corejs3/core-js-stable/object/get-own-property-descriptor");
  13894. _Object$defineProperty(exports, "__esModule", {
  13895. value: true
  13896. });
  13897. exports.clearAllState = clearAllState;
  13898. exports.commitServerChanges = commitServerChanges;
  13899. exports.duplicateState = duplicateState;
  13900. exports.enqueueTask = enqueueTask;
  13901. exports.estimateAttribute = estimateAttribute;
  13902. exports.estimateAttributes = estimateAttributes;
  13903. exports.getObjectCache = getObjectCache;
  13904. exports.getPendingOps = getPendingOps;
  13905. exports.getServerData = getServerData;
  13906. exports.getState = getState;
  13907. exports.initializeState = initializeState;
  13908. exports.mergeFirstPendingState = mergeFirstPendingState;
  13909. exports.popPendingState = popPendingState;
  13910. exports.pushPendingState = pushPendingState;
  13911. exports.removeState = removeState;
  13912. exports.setPendingOp = setPendingOp;
  13913. exports.setServerData = setServerData;
  13914. var ObjectStateMutations = _interopRequireWildcard(_dereq_("./ObjectStateMutations"));
  13915. function _getRequireWildcardCache(e) {
  13916. if ("function" != typeof _WeakMap) return null;
  13917. var r = new _WeakMap(),
  13918. t = new _WeakMap();
  13919. return (_getRequireWildcardCache = function (e) {
  13920. return e ? t : r;
  13921. })(e);
  13922. }
  13923. function _interopRequireWildcard(e, r) {
  13924. if (!r && e && e.__esModule) return e;
  13925. if (null === e || "object" != typeof e && "function" != typeof e) return {
  13926. default: e
  13927. };
  13928. var t = _getRequireWildcardCache(r);
  13929. if (t && t.has(e)) return t.get(e);
  13930. var n = {
  13931. __proto__: null
  13932. };
  13933. for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) {
  13934. var i = _Object$defineProperty && _Object$getOwnPropertyDescriptor ? _Object$getOwnPropertyDescriptor(e, u) : null;
  13935. i && (i.get || i.set) ? _Object$defineProperty(n, u, i) : n[u] = e[u];
  13936. }
  13937. return n.default = e, t && t.set(e, n), n;
  13938. }
  13939. let objectState = {};
  13940. function getState(obj) {
  13941. const classData = objectState[obj.className];
  13942. if (classData) {
  13943. return classData[obj.id] || null;
  13944. }
  13945. return null;
  13946. }
  13947. function initializeState(obj, initial) {
  13948. let state = getState(obj);
  13949. if (state) {
  13950. return state;
  13951. }
  13952. if (!objectState[obj.className]) {
  13953. objectState[obj.className] = {};
  13954. }
  13955. if (!initial) {
  13956. initial = ObjectStateMutations.defaultState();
  13957. }
  13958. state = objectState[obj.className][obj.id] = initial;
  13959. return state;
  13960. }
  13961. function removeState(obj) {
  13962. const state = getState(obj);
  13963. if (state === null) {
  13964. return null;
  13965. }
  13966. delete objectState[obj.className][obj.id];
  13967. return state;
  13968. }
  13969. function getServerData(obj) {
  13970. const state = getState(obj);
  13971. if (state) {
  13972. return state.serverData;
  13973. }
  13974. return {};
  13975. }
  13976. function setServerData(obj, attributes) {
  13977. const serverData = initializeState(obj).serverData;
  13978. ObjectStateMutations.setServerData(serverData, attributes);
  13979. }
  13980. function getPendingOps(obj) {
  13981. const state = getState(obj);
  13982. if (state) {
  13983. return state.pendingOps;
  13984. }
  13985. return [{}];
  13986. }
  13987. function setPendingOp(obj, attr, op) {
  13988. const pendingOps = initializeState(obj).pendingOps;
  13989. ObjectStateMutations.setPendingOp(pendingOps, attr, op);
  13990. }
  13991. function pushPendingState(obj) {
  13992. const pendingOps = initializeState(obj).pendingOps;
  13993. ObjectStateMutations.pushPendingState(pendingOps);
  13994. }
  13995. function popPendingState(obj) {
  13996. const pendingOps = initializeState(obj).pendingOps;
  13997. return ObjectStateMutations.popPendingState(pendingOps);
  13998. }
  13999. function mergeFirstPendingState(obj) {
  14000. const pendingOps = getPendingOps(obj);
  14001. ObjectStateMutations.mergeFirstPendingState(pendingOps);
  14002. }
  14003. function getObjectCache(obj) {
  14004. const state = getState(obj);
  14005. if (state) {
  14006. return state.objectCache;
  14007. }
  14008. return {};
  14009. }
  14010. function estimateAttribute(obj, attr) {
  14011. const serverData = getServerData(obj);
  14012. const pendingOps = getPendingOps(obj);
  14013. return ObjectStateMutations.estimateAttribute(serverData, pendingOps, obj, attr);
  14014. }
  14015. function estimateAttributes(obj) {
  14016. const serverData = getServerData(obj);
  14017. const pendingOps = getPendingOps(obj);
  14018. return ObjectStateMutations.estimateAttributes(serverData, pendingOps, obj);
  14019. }
  14020. function commitServerChanges(obj, changes) {
  14021. const state = initializeState(obj);
  14022. ObjectStateMutations.commitServerChanges(state.serverData, state.objectCache, changes);
  14023. }
  14024. function enqueueTask(obj, task) {
  14025. const state = initializeState(obj);
  14026. return state.tasks.enqueue(task);
  14027. }
  14028. function clearAllState() {
  14029. objectState = {};
  14030. }
  14031. function duplicateState(source, dest) {
  14032. dest.id = source.id;
  14033. }
  14034. },{"./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){
  14035. "use strict";
  14036. var _Object$defineProperty = _dereq_("@babel/runtime-corejs3/core-js-stable/object/define-property");
  14037. var _interopRequireDefault = _dereq_("@babel/runtime-corejs3/helpers/interopRequireDefault");
  14038. _Object$defineProperty(exports, "__esModule", {
  14039. value: true
  14040. });
  14041. exports.default = void 0;
  14042. var _defineProperty2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/helpers/defineProperty"));
  14043. class SocketWeapp {
  14044. constructor(serverURL) {
  14045. (0, _defineProperty2.default)(this, "onopen", void 0);
  14046. (0, _defineProperty2.default)(this, "onmessage", void 0);
  14047. (0, _defineProperty2.default)(this, "onclose", void 0);
  14048. (0, _defineProperty2.default)(this, "onerror", void 0);
  14049. this.onopen = () => {};
  14050. this.onmessage = () => {};
  14051. this.onclose = () => {};
  14052. this.onerror = () => {};
  14053. // @ts-ignore
  14054. wx.onSocketOpen(() => {
  14055. this.onopen();
  14056. });
  14057. // @ts-ignore
  14058. wx.onSocketMessage(msg => {
  14059. // @ts-ignore
  14060. this.onmessage(msg);
  14061. });
  14062. // @ts-ignore
  14063. wx.onSocketClose(event => {
  14064. // @ts-ignore
  14065. this.onclose(event);
  14066. });
  14067. // @ts-ignore
  14068. wx.onSocketError(error => {
  14069. // @ts-ignore
  14070. this.onerror(error);
  14071. });
  14072. // @ts-ignore
  14073. wx.connectSocket({
  14074. url: serverURL
  14075. });
  14076. }
  14077. send(data) {
  14078. // @ts-ignore
  14079. wx.sendSocketMessage({
  14080. data
  14081. });
  14082. }
  14083. close() {
  14084. // @ts-ignore
  14085. wx.closeSocket();
  14086. }
  14087. }
  14088. module.exports = SocketWeapp;
  14089. var _default = exports.default = SocketWeapp;
  14090. },{"@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){
  14091. "use strict";
  14092. var _Object$defineProperty = _dereq_("@babel/runtime-corejs3/core-js-stable/object/define-property");
  14093. var _interopRequireDefault = _dereq_("@babel/runtime-corejs3/helpers/interopRequireDefault");
  14094. _Object$defineProperty(exports, "__esModule", {
  14095. value: true
  14096. });
  14097. exports.default = void 0;
  14098. var _promise = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/promise"));
  14099. var _CoreManager = _interopRequireDefault(_dereq_("./CoreManager"));
  14100. const Storage = {
  14101. async() {
  14102. const controller = _CoreManager.default.getStorageController();
  14103. return !!controller.async;
  14104. },
  14105. getItem(path) {
  14106. const controller = _CoreManager.default.getStorageController();
  14107. if (controller.async === 1) {
  14108. throw new Error('Synchronous storage is not supported by the current storage controller');
  14109. }
  14110. return controller.getItem(path);
  14111. },
  14112. getItemAsync(path) {
  14113. const controller = _CoreManager.default.getStorageController();
  14114. if (controller.async === 1) {
  14115. return controller.getItemAsync(path);
  14116. }
  14117. return _promise.default.resolve(controller.getItem(path));
  14118. },
  14119. setItem(path, value) {
  14120. const controller = _CoreManager.default.getStorageController();
  14121. if (controller.async === 1) {
  14122. throw new Error('Synchronous storage is not supported by the current storage controller');
  14123. }
  14124. return controller.setItem(path, value);
  14125. },
  14126. setItemAsync(path, value) {
  14127. const controller = _CoreManager.default.getStorageController();
  14128. if (controller.async === 1) {
  14129. return controller.setItemAsync(path, value);
  14130. }
  14131. return _promise.default.resolve(controller.setItem(path, value));
  14132. },
  14133. removeItem(path) {
  14134. const controller = _CoreManager.default.getStorageController();
  14135. if (controller.async === 1) {
  14136. throw new Error('Synchronous storage is not supported by the current storage controller');
  14137. }
  14138. return controller.removeItem(path);
  14139. },
  14140. removeItemAsync(path) {
  14141. const controller = _CoreManager.default.getStorageController();
  14142. if (controller.async === 1) {
  14143. return controller.removeItemAsync(path);
  14144. }
  14145. return _promise.default.resolve(controller.removeItem(path));
  14146. },
  14147. getAllKeys() {
  14148. const controller = _CoreManager.default.getStorageController();
  14149. if (controller.async === 1) {
  14150. throw new Error('Synchronous storage is not supported by the current storage controller');
  14151. }
  14152. return controller.getAllKeys();
  14153. },
  14154. getAllKeysAsync() {
  14155. const controller = _CoreManager.default.getStorageController();
  14156. if (controller.async === 1) {
  14157. return controller.getAllKeysAsync();
  14158. }
  14159. return _promise.default.resolve(controller.getAllKeys());
  14160. },
  14161. generatePath(path) {
  14162. if (!_CoreManager.default.get('APPLICATION_ID')) {
  14163. throw new Error('You need to call Parse.initialize before using Parse.');
  14164. }
  14165. if (typeof path !== 'string') {
  14166. throw new Error('Tried to get a Storage path that was not a String.');
  14167. }
  14168. if (path[0] === '/') {
  14169. path = path.substr(1);
  14170. }
  14171. return 'Parse/' + _CoreManager.default.get('APPLICATION_ID') + '/' + path;
  14172. },
  14173. _clear() {
  14174. const controller = _CoreManager.default.getStorageController();
  14175. if (controller.hasOwnProperty('clear')) {
  14176. controller.clear();
  14177. }
  14178. }
  14179. };
  14180. module.exports = Storage;
  14181. var _default = exports.default = Storage;
  14182. },{"./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){
  14183. "use strict";
  14184. var _Object$defineProperty = _dereq_("@babel/runtime-corejs3/core-js-stable/object/define-property");
  14185. _Object$defineProperty(exports, "__esModule", {
  14186. value: true
  14187. });
  14188. exports.default = void 0;
  14189. /* global localStorage */
  14190. const StorageController = {
  14191. async: 0,
  14192. getItem(path) {
  14193. return localStorage.getItem(path);
  14194. },
  14195. setItem(path, value) {
  14196. try {
  14197. localStorage.setItem(path, value);
  14198. } catch (e) {
  14199. // Quota exceeded, possibly due to Safari Private Browsing mode
  14200. console.log(e.message);
  14201. }
  14202. },
  14203. removeItem(path) {
  14204. localStorage.removeItem(path);
  14205. },
  14206. getAllKeys() {
  14207. const keys = [];
  14208. for (let i = 0; i < localStorage.length; i += 1) {
  14209. keys.push(localStorage.key(i));
  14210. }
  14211. return keys;
  14212. },
  14213. clear() {
  14214. localStorage.clear();
  14215. }
  14216. };
  14217. module.exports = StorageController;
  14218. var _default = exports.default = StorageController;
  14219. },{"@babel/runtime-corejs3/core-js-stable/object/define-property":90}],45:[function(_dereq_,module,exports){
  14220. "use strict";
  14221. var _Object$defineProperty = _dereq_("@babel/runtime-corejs3/core-js-stable/object/define-property");
  14222. var _interopRequireDefault = _dereq_("@babel/runtime-corejs3/helpers/interopRequireDefault");
  14223. _Object$defineProperty(exports, "__esModule", {
  14224. value: true
  14225. });
  14226. exports.default = void 0;
  14227. var _keys = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/object/keys"));
  14228. // When there is no native storage interface, we default to an in-memory map
  14229. const memMap = {};
  14230. const StorageController = {
  14231. async: 0,
  14232. getItem(path) {
  14233. if (memMap.hasOwnProperty(path)) {
  14234. return memMap[path];
  14235. }
  14236. return null;
  14237. },
  14238. setItem(path, value) {
  14239. memMap[path] = String(value);
  14240. },
  14241. removeItem(path) {
  14242. delete memMap[path];
  14243. },
  14244. getAllKeys() {
  14245. return (0, _keys.default)(memMap);
  14246. },
  14247. clear() {
  14248. for (const key in memMap) {
  14249. if (memMap.hasOwnProperty(key)) {
  14250. delete memMap[key];
  14251. }
  14252. }
  14253. }
  14254. };
  14255. module.exports = StorageController;
  14256. var _default = exports.default = StorageController;
  14257. },{"@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){
  14258. "use strict";
  14259. var _Object$defineProperty = _dereq_("@babel/runtime-corejs3/core-js-stable/object/define-property");
  14260. var _interopRequireDefault = _dereq_("@babel/runtime-corejs3/helpers/interopRequireDefault");
  14261. _Object$defineProperty(exports, "__esModule", {
  14262. value: true
  14263. });
  14264. exports.default = void 0;
  14265. var _StorageController = _interopRequireDefault(_dereq_("./StorageController.react-native"));
  14266. var _StorageController2 = _interopRequireDefault(_dereq_("./StorageController.browser"));
  14267. var _StorageController3 = _interopRequireDefault(_dereq_("./StorageController.weapp"));
  14268. var _StorageController4 = _interopRequireDefault(_dereq_("./StorageController.default"));
  14269. let StorageController = _StorageController4.default;
  14270. StorageController = _StorageController3.default;
  14271. module.exports = StorageController;
  14272. var _default = exports.default = StorageController;
  14273. },{"./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){
  14274. "use strict";
  14275. var _Object$defineProperty = _dereq_("@babel/runtime-corejs3/core-js-stable/object/define-property");
  14276. var _interopRequireDefault = _dereq_("@babel/runtime-corejs3/helpers/interopRequireDefault");
  14277. _Object$defineProperty(exports, "__esModule", {
  14278. value: true
  14279. });
  14280. exports.default = void 0;
  14281. var _promise = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/promise"));
  14282. var _CoreManager = _interopRequireDefault(_dereq_("./CoreManager"));
  14283. const StorageController = {
  14284. async: 1,
  14285. getItemAsync(path) {
  14286. return new _promise.default((resolve, reject) => {
  14287. _CoreManager.default.getAsyncStorage().getItem(path, (err, value) => {
  14288. if (err) {
  14289. reject(err);
  14290. } else {
  14291. resolve(value || null);
  14292. }
  14293. });
  14294. });
  14295. },
  14296. setItemAsync(path, value) {
  14297. return new _promise.default((resolve, reject) => {
  14298. _CoreManager.default.getAsyncStorage().setItem(path, value, err => {
  14299. if (err) {
  14300. reject(err);
  14301. } else {
  14302. resolve();
  14303. }
  14304. });
  14305. });
  14306. },
  14307. removeItemAsync(path) {
  14308. return new _promise.default((resolve, reject) => {
  14309. _CoreManager.default.getAsyncStorage().removeItem(path, err => {
  14310. if (err) {
  14311. reject(err);
  14312. } else {
  14313. resolve();
  14314. }
  14315. });
  14316. });
  14317. },
  14318. getAllKeysAsync() {
  14319. return new _promise.default((resolve, reject) => {
  14320. _CoreManager.default.getAsyncStorage().getAllKeys((err, keys) => {
  14321. if (err) {
  14322. reject(err);
  14323. } else {
  14324. resolve(keys || []);
  14325. }
  14326. });
  14327. });
  14328. },
  14329. multiGet(keys) {
  14330. return new _promise.default((resolve, reject) => {
  14331. _CoreManager.default.getAsyncStorage().multiGet(keys, (err, result) => {
  14332. if (err) {
  14333. reject(err);
  14334. } else {
  14335. resolve(result || null);
  14336. }
  14337. });
  14338. });
  14339. },
  14340. multiRemove(keys) {
  14341. return new _promise.default((resolve, reject) => {
  14342. _CoreManager.default.getAsyncStorage().multiRemove(keys, err => {
  14343. if (err) {
  14344. reject(err);
  14345. } else {
  14346. resolve(keys);
  14347. }
  14348. });
  14349. });
  14350. },
  14351. clear() {
  14352. return _CoreManager.default.getAsyncStorage().clear();
  14353. }
  14354. };
  14355. module.exports = StorageController;
  14356. var _default = exports.default = StorageController;
  14357. },{"./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){
  14358. "use strict";
  14359. var _Object$defineProperty = _dereq_("@babel/runtime-corejs3/core-js-stable/object/define-property");
  14360. var _interopRequireDefault = _dereq_("@babel/runtime-corejs3/helpers/interopRequireDefault");
  14361. _Object$defineProperty(exports, "__esModule", {
  14362. value: true
  14363. });
  14364. exports.default = void 0;
  14365. var _keys = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/instance/keys"));
  14366. const StorageController = {
  14367. async: 0,
  14368. getItem(path) {
  14369. // @ts-ignore
  14370. return wx.getStorageSync(path);
  14371. },
  14372. setItem(path, value) {
  14373. try {
  14374. // @ts-ignore
  14375. wx.setStorageSync(path, value);
  14376. } catch (e) {
  14377. // Quota exceeded
  14378. }
  14379. },
  14380. removeItem(path) {
  14381. // @ts-ignore
  14382. wx.removeStorageSync(path);
  14383. },
  14384. getAllKeys() {
  14385. // @ts-ignore
  14386. const res = wx.getStorageInfoSync();
  14387. return (0, _keys.default)(res);
  14388. },
  14389. clear() {
  14390. // @ts-ignore
  14391. wx.clearStorageSync();
  14392. }
  14393. };
  14394. module.exports = StorageController;
  14395. var _default = exports.default = StorageController;
  14396. },{"@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){
  14397. "use strict";
  14398. var _Object$defineProperty = _dereq_("@babel/runtime-corejs3/core-js-stable/object/define-property");
  14399. var _interopRequireDefault = _dereq_("@babel/runtime-corejs3/helpers/interopRequireDefault");
  14400. _Object$defineProperty(exports, "__esModule", {
  14401. value: true
  14402. });
  14403. exports.default = void 0;
  14404. var _defineProperty2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/helpers/defineProperty"));
  14405. var _promiseUtils = _dereq_("./promiseUtils");
  14406. class TaskQueue {
  14407. constructor() {
  14408. (0, _defineProperty2.default)(this, "queue", void 0);
  14409. this.queue = [];
  14410. }
  14411. enqueue(task) {
  14412. const taskComplete = (0, _promiseUtils.resolvingPromise)();
  14413. this.queue.push({
  14414. task: task,
  14415. _completion: taskComplete
  14416. });
  14417. if (this.queue.length === 1) {
  14418. task().then(() => {
  14419. this._dequeue();
  14420. taskComplete.resolve();
  14421. }, error => {
  14422. this._dequeue();
  14423. taskComplete.reject(error);
  14424. });
  14425. }
  14426. return taskComplete;
  14427. }
  14428. _dequeue() {
  14429. this.queue.shift();
  14430. if (this.queue.length) {
  14431. const next = this.queue[0];
  14432. next.task().then(() => {
  14433. this._dequeue();
  14434. next._completion.resolve();
  14435. }, error => {
  14436. this._dequeue();
  14437. next._completion.reject(error);
  14438. });
  14439. }
  14440. }
  14441. }
  14442. module.exports = TaskQueue;
  14443. var _default = exports.default = TaskQueue;
  14444. },{"./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){
  14445. "use strict";
  14446. var _WeakMap2 = _dereq_("@babel/runtime-corejs3/core-js-stable/weak-map");
  14447. var _Object$defineProperty = _dereq_("@babel/runtime-corejs3/core-js-stable/object/define-property");
  14448. var _Object$getOwnPropertyDescriptor = _dereq_("@babel/runtime-corejs3/core-js-stable/object/get-own-property-descriptor");
  14449. var _interopRequireDefault = _dereq_("@babel/runtime-corejs3/helpers/interopRequireDefault");
  14450. _Object$defineProperty(exports, "__esModule", {
  14451. value: true
  14452. });
  14453. exports.clearAllState = clearAllState;
  14454. exports.commitServerChanges = commitServerChanges;
  14455. exports.duplicateState = duplicateState;
  14456. exports.enqueueTask = enqueueTask;
  14457. exports.estimateAttribute = estimateAttribute;
  14458. exports.estimateAttributes = estimateAttributes;
  14459. exports.getObjectCache = getObjectCache;
  14460. exports.getPendingOps = getPendingOps;
  14461. exports.getServerData = getServerData;
  14462. exports.getState = getState;
  14463. exports.initializeState = initializeState;
  14464. exports.mergeFirstPendingState = mergeFirstPendingState;
  14465. exports.popPendingState = popPendingState;
  14466. exports.pushPendingState = pushPendingState;
  14467. exports.removeState = removeState;
  14468. exports.setPendingOp = setPendingOp;
  14469. exports.setServerData = setServerData;
  14470. var _weakMap = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/weak-map"));
  14471. var ObjectStateMutations = _interopRequireWildcard(_dereq_("./ObjectStateMutations"));
  14472. var _TaskQueue = _interopRequireDefault(_dereq_("./TaskQueue"));
  14473. function _getRequireWildcardCache(e) {
  14474. if ("function" != typeof _WeakMap2) return null;
  14475. var r = new _WeakMap2(),
  14476. t = new _WeakMap2();
  14477. return (_getRequireWildcardCache = function (e) {
  14478. return e ? t : r;
  14479. })(e);
  14480. }
  14481. function _interopRequireWildcard(e, r) {
  14482. if (!r && e && e.__esModule) return e;
  14483. if (null === e || "object" != typeof e && "function" != typeof e) return {
  14484. default: e
  14485. };
  14486. var t = _getRequireWildcardCache(r);
  14487. if (t && t.has(e)) return t.get(e);
  14488. var n = {
  14489. __proto__: null
  14490. };
  14491. for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) {
  14492. var i = _Object$defineProperty && _Object$getOwnPropertyDescriptor ? _Object$getOwnPropertyDescriptor(e, u) : null;
  14493. i && (i.get || i.set) ? _Object$defineProperty(n, u, i) : n[u] = e[u];
  14494. }
  14495. return n.default = e, t && t.set(e, n), n;
  14496. }
  14497. let objectState = new _weakMap.default();
  14498. function getState(obj) {
  14499. const classData = objectState.get(obj);
  14500. return classData || null;
  14501. }
  14502. function initializeState(obj, initial) {
  14503. let state = getState(obj);
  14504. if (state) {
  14505. return state;
  14506. }
  14507. if (!initial) {
  14508. initial = {
  14509. serverData: {},
  14510. pendingOps: [{}],
  14511. objectCache: {},
  14512. tasks: new _TaskQueue.default(),
  14513. existed: false
  14514. };
  14515. }
  14516. state = initial;
  14517. objectState.set(obj, state);
  14518. return state;
  14519. }
  14520. function removeState(obj) {
  14521. const state = getState(obj);
  14522. if (state === null) {
  14523. return null;
  14524. }
  14525. objectState.delete(obj);
  14526. return state;
  14527. }
  14528. function getServerData(obj) {
  14529. const state = getState(obj);
  14530. if (state) {
  14531. return state.serverData;
  14532. }
  14533. return {};
  14534. }
  14535. function setServerData(obj, attributes) {
  14536. const serverData = initializeState(obj).serverData;
  14537. ObjectStateMutations.setServerData(serverData, attributes);
  14538. }
  14539. function getPendingOps(obj) {
  14540. const state = getState(obj);
  14541. if (state) {
  14542. return state.pendingOps;
  14543. }
  14544. return [{}];
  14545. }
  14546. function setPendingOp(obj, attr, op) {
  14547. const pendingOps = initializeState(obj).pendingOps;
  14548. ObjectStateMutations.setPendingOp(pendingOps, attr, op);
  14549. }
  14550. function pushPendingState(obj) {
  14551. const pendingOps = initializeState(obj).pendingOps;
  14552. ObjectStateMutations.pushPendingState(pendingOps);
  14553. }
  14554. function popPendingState(obj) {
  14555. const pendingOps = initializeState(obj).pendingOps;
  14556. return ObjectStateMutations.popPendingState(pendingOps);
  14557. }
  14558. function mergeFirstPendingState(obj) {
  14559. const pendingOps = getPendingOps(obj);
  14560. ObjectStateMutations.mergeFirstPendingState(pendingOps);
  14561. }
  14562. function getObjectCache(obj) {
  14563. const state = getState(obj);
  14564. if (state) {
  14565. return state.objectCache;
  14566. }
  14567. return {};
  14568. }
  14569. function estimateAttribute(obj, attr) {
  14570. const serverData = getServerData(obj);
  14571. const pendingOps = getPendingOps(obj);
  14572. return ObjectStateMutations.estimateAttribute(serverData, pendingOps, obj, attr);
  14573. }
  14574. function estimateAttributes(obj) {
  14575. const serverData = getServerData(obj);
  14576. const pendingOps = getPendingOps(obj);
  14577. return ObjectStateMutations.estimateAttributes(serverData, pendingOps, obj);
  14578. }
  14579. function commitServerChanges(obj, changes) {
  14580. const state = initializeState(obj);
  14581. ObjectStateMutations.commitServerChanges(state.serverData, state.objectCache, changes);
  14582. }
  14583. function enqueueTask(obj, task) {
  14584. const state = initializeState(obj);
  14585. return state.tasks.enqueue(task);
  14586. }
  14587. function duplicateState(source, dest) {
  14588. const oldState = initializeState(source);
  14589. const newState = initializeState(dest);
  14590. for (const key in oldState.serverData) {
  14591. newState.serverData[key] = oldState.serverData[key];
  14592. }
  14593. for (let index = 0; index < oldState.pendingOps.length; index++) {
  14594. for (const key in oldState.pendingOps[index]) {
  14595. newState.pendingOps[index][key] = oldState.pendingOps[index][key];
  14596. }
  14597. }
  14598. for (const key in oldState.objectCache) {
  14599. newState.objectCache[key] = oldState.objectCache[key];
  14600. }
  14601. newState.existed = oldState.existed;
  14602. }
  14603. function clearAllState() {
  14604. objectState = new _weakMap.default();
  14605. }
  14606. },{"./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){
  14607. "use strict";
  14608. var _Object$defineProperty = _dereq_("@babel/runtime-corejs3/core-js-stable/object/define-property");
  14609. var _interopRequireDefault = _dereq_("@babel/runtime-corejs3/helpers/interopRequireDefault");
  14610. _Object$defineProperty(exports, "__esModule", {
  14611. value: true
  14612. });
  14613. exports.default = void 0;
  14614. var _ws = _interopRequireDefault(_dereq_("ws"));
  14615. var _Socket = _interopRequireDefault(_dereq_("./Socket.weapp"));
  14616. /* global WebSocket */
  14617. let WebSocketController;
  14618. try {
  14619. WebSocketController = _Socket.default;
  14620. } catch (_) {
  14621. // WebSocket unavailable
  14622. }
  14623. module.exports = WebSocketController;
  14624. var _default = exports.default = WebSocketController;
  14625. },{"./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){
  14626. "use strict";
  14627. var _Object$defineProperty = _dereq_("@babel/runtime-corejs3/core-js-stable/object/define-property");
  14628. var _interopRequireDefault = _dereq_("@babel/runtime-corejs3/helpers/interopRequireDefault");
  14629. _Object$defineProperty(exports, "__esModule", {
  14630. value: true
  14631. });
  14632. exports.default = void 0;
  14633. var _stringify = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/json/stringify"));
  14634. var _defineProperty2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/helpers/defineProperty"));
  14635. class XhrWeapp {
  14636. constructor() {
  14637. (0, _defineProperty2.default)(this, "UNSENT", void 0);
  14638. (0, _defineProperty2.default)(this, "OPENED", void 0);
  14639. (0, _defineProperty2.default)(this, "HEADERS_RECEIVED", void 0);
  14640. (0, _defineProperty2.default)(this, "LOADING", void 0);
  14641. (0, _defineProperty2.default)(this, "DONE", void 0);
  14642. (0, _defineProperty2.default)(this, "header", void 0);
  14643. (0, _defineProperty2.default)(this, "readyState", void 0);
  14644. (0, _defineProperty2.default)(this, "status", void 0);
  14645. (0, _defineProperty2.default)(this, "response", void 0);
  14646. (0, _defineProperty2.default)(this, "responseType", void 0);
  14647. (0, _defineProperty2.default)(this, "responseText", void 0);
  14648. (0, _defineProperty2.default)(this, "responseHeader", void 0);
  14649. (0, _defineProperty2.default)(this, "method", void 0);
  14650. (0, _defineProperty2.default)(this, "url", void 0);
  14651. (0, _defineProperty2.default)(this, "onabort", void 0);
  14652. (0, _defineProperty2.default)(this, "onprogress", void 0);
  14653. (0, _defineProperty2.default)(this, "onerror", void 0);
  14654. (0, _defineProperty2.default)(this, "onreadystatechange", void 0);
  14655. (0, _defineProperty2.default)(this, "requestTask", void 0);
  14656. this.UNSENT = 0;
  14657. this.OPENED = 1;
  14658. this.HEADERS_RECEIVED = 2;
  14659. this.LOADING = 3;
  14660. this.DONE = 4;
  14661. this.header = {};
  14662. this.readyState = this.DONE;
  14663. this.status = 0;
  14664. this.response = '';
  14665. this.responseType = '';
  14666. this.responseText = '';
  14667. this.responseHeader = {};
  14668. this.method = '';
  14669. this.url = '';
  14670. this.onabort = () => {};
  14671. this.onprogress = () => {};
  14672. this.onerror = () => {};
  14673. this.onreadystatechange = () => {};
  14674. this.requestTask = null;
  14675. }
  14676. getAllResponseHeaders() {
  14677. let header = '';
  14678. for (const key in this.responseHeader) {
  14679. header += key + ':' + this.getResponseHeader(key) + '\r\n';
  14680. }
  14681. return header;
  14682. }
  14683. getResponseHeader(key) {
  14684. return this.responseHeader[key];
  14685. }
  14686. setRequestHeader(key, value) {
  14687. this.header[key] = value;
  14688. }
  14689. open(method, url) {
  14690. this.method = method;
  14691. this.url = url;
  14692. }
  14693. abort() {
  14694. if (!this.requestTask) {
  14695. return;
  14696. }
  14697. this.requestTask.abort();
  14698. this.status = 0;
  14699. this.response = undefined;
  14700. this.onabort();
  14701. this.onreadystatechange();
  14702. }
  14703. send(data) {
  14704. // @ts-ignore
  14705. this.requestTask = wx.request({
  14706. url: this.url,
  14707. method: this.method,
  14708. data: data,
  14709. header: this.header,
  14710. responseType: this.responseType,
  14711. success: res => {
  14712. this.status = res.statusCode;
  14713. this.response = res.data;
  14714. this.responseHeader = res.header;
  14715. this.responseText = (0, _stringify.default)(res.data);
  14716. this.requestTask = null;
  14717. this.onreadystatechange();
  14718. },
  14719. fail: err => {
  14720. this.requestTask = null;
  14721. // @ts-ignore
  14722. this.onerror(err);
  14723. }
  14724. });
  14725. this.requestTask.onProgressUpdate(res => {
  14726. const event = {
  14727. lengthComputable: res.totalBytesExpectedToWrite !== 0,
  14728. loaded: res.totalBytesWritten,
  14729. total: res.totalBytesExpectedToWrite
  14730. };
  14731. // @ts-ignore
  14732. this.onprogress(event);
  14733. });
  14734. }
  14735. }
  14736. module.exports = XhrWeapp;
  14737. var _default = exports.default = XhrWeapp;
  14738. },{"@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){
  14739. "use strict";
  14740. var _Object$defineProperty = _dereq_("@babel/runtime-corejs3/core-js-stable/object/define-property");
  14741. var _interopRequireDefault = _dereq_("@babel/runtime-corejs3/helpers/interopRequireDefault");
  14742. _Object$defineProperty(exports, "__esModule", {
  14743. value: true
  14744. });
  14745. exports.default = arrayContainsObject;
  14746. var _indexOf = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/instance/index-of"));
  14747. var _CoreManager = _interopRequireDefault(_dereq_("./CoreManager"));
  14748. function arrayContainsObject(array, object) {
  14749. if ((0, _indexOf.default)(array).call(array, object) > -1) {
  14750. return true;
  14751. }
  14752. const ParseObject = _CoreManager.default.getParseObject();
  14753. for (let i = 0; i < array.length; i++) {
  14754. if (array[i] instanceof ParseObject && array[i].className === object.className && array[i]._getId() === object._getId()) {
  14755. return true;
  14756. }
  14757. }
  14758. return false;
  14759. }
  14760. },{"./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){
  14761. "use strict";
  14762. var _Object$defineProperty = _dereq_("@babel/runtime-corejs3/core-js-stable/object/define-property");
  14763. var _interopRequireDefault = _dereq_("@babel/runtime-corejs3/helpers/interopRequireDefault");
  14764. _Object$defineProperty(exports, "__esModule", {
  14765. value: true
  14766. });
  14767. exports.default = canBeSerialized;
  14768. var _isArray = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/array/is-array"));
  14769. var _CoreManager = _interopRequireDefault(_dereq_("./CoreManager"));
  14770. var _ParseFile = _interopRequireDefault(_dereq_("./ParseFile"));
  14771. var _ParseRelation = _interopRequireDefault(_dereq_("./ParseRelation"));
  14772. function canBeSerialized(obj) {
  14773. const ParseObject = _CoreManager.default.getParseObject();
  14774. if (!(obj instanceof ParseObject)) {
  14775. return true;
  14776. }
  14777. const attributes = obj.attributes;
  14778. for (const attr in attributes) {
  14779. const val = attributes[attr];
  14780. if (!canBeSerializedHelper(val)) {
  14781. return false;
  14782. }
  14783. }
  14784. return true;
  14785. }
  14786. function canBeSerializedHelper(value) {
  14787. if (typeof value !== 'object') {
  14788. return true;
  14789. }
  14790. if (value instanceof _ParseRelation.default) {
  14791. return true;
  14792. }
  14793. const ParseObject = _CoreManager.default.getParseObject();
  14794. if (value instanceof ParseObject) {
  14795. return !!value.id;
  14796. }
  14797. if (value instanceof _ParseFile.default) {
  14798. if (value.url()) {
  14799. return true;
  14800. }
  14801. return false;
  14802. }
  14803. if ((0, _isArray.default)(value)) {
  14804. for (let i = 0; i < value.length; i++) {
  14805. if (!canBeSerializedHelper(value[i])) {
  14806. return false;
  14807. }
  14808. }
  14809. return true;
  14810. }
  14811. for (const k in value) {
  14812. if (!canBeSerializedHelper(value[k])) {
  14813. return false;
  14814. }
  14815. }
  14816. return true;
  14817. }
  14818. },{"./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){
  14819. "use strict";
  14820. var _Object$defineProperty = _dereq_("@babel/runtime-corejs3/core-js-stable/object/define-property");
  14821. var _interopRequireDefault = _dereq_("@babel/runtime-corejs3/helpers/interopRequireDefault");
  14822. _Object$defineProperty(exports, "__esModule", {
  14823. value: true
  14824. });
  14825. exports.default = decode;
  14826. var _isArray = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/array/is-array"));
  14827. var _forEach = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/instance/for-each"));
  14828. var _CoreManager = _interopRequireDefault(_dereq_("./CoreManager"));
  14829. var _ParseFile = _interopRequireDefault(_dereq_("./ParseFile"));
  14830. var _ParseGeoPoint = _interopRequireDefault(_dereq_("./ParseGeoPoint"));
  14831. var _ParsePolygon = _interopRequireDefault(_dereq_("./ParsePolygon"));
  14832. var _ParseRelation = _interopRequireDefault(_dereq_("./ParseRelation"));
  14833. function decode(value) {
  14834. if (value === null || typeof value !== 'object' || value instanceof Date) {
  14835. return value;
  14836. }
  14837. if ((0, _isArray.default)(value)) {
  14838. const dup = [];
  14839. (0, _forEach.default)(value).call(value, (v, i) => {
  14840. dup[i] = decode(v);
  14841. });
  14842. return dup;
  14843. }
  14844. if (typeof value.__op === 'string') {
  14845. const {
  14846. opFromJSON
  14847. } = _CoreManager.default.getParseOp();
  14848. return opFromJSON(value);
  14849. }
  14850. const ParseObject = _CoreManager.default.getParseObject();
  14851. if (value.__type === 'Pointer' && value.className) {
  14852. return ParseObject.fromJSON(value);
  14853. }
  14854. if (value.__type === 'Object' && value.className) {
  14855. return ParseObject.fromJSON(value);
  14856. }
  14857. if (value.__type === 'Relation') {
  14858. // The parent and key fields will be populated by the parent
  14859. const relation = new _ParseRelation.default(null, null);
  14860. relation.targetClassName = value.className;
  14861. return relation;
  14862. }
  14863. if (value.__type === 'Date') {
  14864. return new Date(value.iso);
  14865. }
  14866. if (value.__type === 'File') {
  14867. return _ParseFile.default.fromJSON(value);
  14868. }
  14869. if (value.__type === 'GeoPoint') {
  14870. return new _ParseGeoPoint.default({
  14871. latitude: value.latitude,
  14872. longitude: value.longitude
  14873. });
  14874. }
  14875. if (value.__type === 'Polygon') {
  14876. return new _ParsePolygon.default(value.coordinates);
  14877. }
  14878. const copy = {};
  14879. for (const k in value) {
  14880. copy[k] = decode(value[k]);
  14881. }
  14882. return copy;
  14883. }
  14884. },{"./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){
  14885. "use strict";
  14886. var _Object$defineProperty = _dereq_("@babel/runtime-corejs3/core-js-stable/object/define-property");
  14887. var _interopRequireDefault = _dereq_("@babel/runtime-corejs3/helpers/interopRequireDefault");
  14888. _Object$defineProperty(exports, "__esModule", {
  14889. value: true
  14890. });
  14891. exports.default = _default;
  14892. var _indexOf = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/instance/index-of"));
  14893. var _keys = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/object/keys"));
  14894. var _startsWith = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/instance/starts-with"));
  14895. var _concat = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/instance/concat"));
  14896. var _isArray = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/array/is-array"));
  14897. var _map = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/instance/map"));
  14898. var _CoreManager = _interopRequireDefault(_dereq_("./CoreManager"));
  14899. var _ParseACL = _interopRequireDefault(_dereq_("./ParseACL"));
  14900. var _ParseFile = _interopRequireDefault(_dereq_("./ParseFile"));
  14901. var _ParseGeoPoint = _interopRequireDefault(_dereq_("./ParseGeoPoint"));
  14902. var _ParsePolygon = _interopRequireDefault(_dereq_("./ParsePolygon"));
  14903. var _ParseRelation = _interopRequireDefault(_dereq_("./ParseRelation"));
  14904. function encode(value, disallowObjects, forcePointers, seen, offline) {
  14905. const ParseObject = _CoreManager.default.getParseObject();
  14906. if (value instanceof ParseObject) {
  14907. if (disallowObjects) {
  14908. throw new Error('Parse Objects not allowed here');
  14909. }
  14910. const seenEntry = value.id ? value.className + ':' + value.id : value;
  14911. if (forcePointers || !seen || (0, _indexOf.default)(seen).call(seen, seenEntry) > -1 || value.dirty() || (0, _keys.default)(value._getServerData()).length < 1) {
  14912. var _context;
  14913. if (offline && (0, _startsWith.default)(_context = value._getId()).call(_context, 'local')) {
  14914. return value.toOfflinePointer();
  14915. }
  14916. return value.toPointer();
  14917. }
  14918. seen = (0, _concat.default)(seen).call(seen, seenEntry);
  14919. return value._toFullJSON(seen, offline);
  14920. }
  14921. const {
  14922. Op
  14923. } = _CoreManager.default.getParseOp();
  14924. if (value instanceof Op || value instanceof _ParseACL.default || value instanceof _ParseGeoPoint.default || value instanceof _ParsePolygon.default || value instanceof _ParseRelation.default) {
  14925. return value.toJSON();
  14926. }
  14927. if (value instanceof _ParseFile.default) {
  14928. if (!value.url()) {
  14929. throw new Error('Tried to encode an unsaved file.');
  14930. }
  14931. return value.toJSON();
  14932. }
  14933. if (Object.prototype.toString.call(value) === '[object Date]') {
  14934. if (isNaN(value)) {
  14935. throw new Error('Tried to encode an invalid date.');
  14936. }
  14937. return {
  14938. __type: 'Date',
  14939. iso: value.toJSON()
  14940. };
  14941. }
  14942. if (Object.prototype.toString.call(value) === '[object RegExp]' && typeof value.source === 'string') {
  14943. return value.source;
  14944. }
  14945. if ((0, _isArray.default)(value)) {
  14946. return (0, _map.default)(value).call(value, v => {
  14947. return encode(v, disallowObjects, forcePointers, seen, offline);
  14948. });
  14949. }
  14950. if (value && typeof value === 'object') {
  14951. const output = {};
  14952. for (const k in value) {
  14953. output[k] = encode(value[k], disallowObjects, forcePointers, seen, offline);
  14954. }
  14955. return output;
  14956. }
  14957. return value;
  14958. }
  14959. function _default(value, disallowObjects, forcePointers, seen, offline) {
  14960. return encode(value, !!disallowObjects, !!forcePointers, seen || [], offline);
  14961. }
  14962. },{"./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){
  14963. "use strict";
  14964. var _Object$defineProperty = _dereq_("@babel/runtime-corejs3/core-js-stable/object/define-property");
  14965. var _interopRequireDefault = _dereq_("@babel/runtime-corejs3/helpers/interopRequireDefault");
  14966. _Object$defineProperty(exports, "__esModule", {
  14967. value: true
  14968. });
  14969. exports.default = equals;
  14970. var _isArray = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/array/is-array"));
  14971. var _keys = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/object/keys"));
  14972. var _CoreManager = _interopRequireDefault(_dereq_("./CoreManager"));
  14973. var _ParseACL = _interopRequireDefault(_dereq_("./ParseACL"));
  14974. var _ParseFile = _interopRequireDefault(_dereq_("./ParseFile"));
  14975. var _ParseGeoPoint = _interopRequireDefault(_dereq_("./ParseGeoPoint"));
  14976. function equals(a, b) {
  14977. const toString = Object.prototype.toString;
  14978. if (toString.call(a) === '[object Date]' || toString.call(b) === '[object Date]') {
  14979. const dateA = new Date(a);
  14980. const dateB = new Date(b);
  14981. return +dateA === +dateB;
  14982. }
  14983. if (typeof a !== typeof b) {
  14984. return false;
  14985. }
  14986. if (!a || typeof a !== 'object') {
  14987. // a is a primitive
  14988. return a === b;
  14989. }
  14990. if ((0, _isArray.default)(a) || (0, _isArray.default)(b)) {
  14991. if (!(0, _isArray.default)(a) || !(0, _isArray.default)(b)) {
  14992. return false;
  14993. }
  14994. if (a.length !== b.length) {
  14995. return false;
  14996. }
  14997. for (let i = a.length; i--;) {
  14998. if (!equals(a[i], b[i])) {
  14999. return false;
  15000. }
  15001. }
  15002. return true;
  15003. }
  15004. const ParseObject = _CoreManager.default.getParseObject();
  15005. if (a instanceof _ParseACL.default || a instanceof _ParseFile.default || a instanceof _ParseGeoPoint.default || a instanceof ParseObject) {
  15006. return a.equals(b);
  15007. }
  15008. if (b instanceof ParseObject) {
  15009. if (a.__type === 'Object' || a.__type === 'Pointer') {
  15010. return a.objectId === b.id && a.className === b.className;
  15011. }
  15012. }
  15013. if ((0, _keys.default)(a).length !== (0, _keys.default)(b).length) {
  15014. return false;
  15015. }
  15016. for (const k in a) {
  15017. if (!equals(a[k], b[k])) {
  15018. return false;
  15019. }
  15020. }
  15021. return true;
  15022. }
  15023. },{"./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){
  15024. "use strict";
  15025. var _Object$defineProperty = _dereq_("@babel/runtime-corejs3/core-js-stable/object/define-property");
  15026. _Object$defineProperty(exports, "__esModule", {
  15027. value: true
  15028. });
  15029. exports.default = escape;
  15030. const encoded = {
  15031. '&': '&amp;',
  15032. '<': '&lt;',
  15033. '>': '&gt;',
  15034. '/': '&#x2F;',
  15035. "'": '&#x27;',
  15036. '"': '&quot;'
  15037. };
  15038. function escape(str) {
  15039. return str.replace(/[&<>\/'"]/g, function (char) {
  15040. return encoded[char];
  15041. });
  15042. }
  15043. },{"@babel/runtime-corejs3/core-js-stable/object/define-property":90}],59:[function(_dereq_,module,exports){
  15044. "use strict";
  15045. var _Object$defineProperty = _dereq_("@babel/runtime-corejs3/core-js-stable/object/define-property");
  15046. var _interopRequireDefault = _dereq_("@babel/runtime-corejs3/helpers/interopRequireDefault");
  15047. _Object$defineProperty(exports, "__esModule", {
  15048. value: true
  15049. });
  15050. exports.default = isRevocableSession;
  15051. var _indexOf = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/instance/index-of"));
  15052. function isRevocableSession(token) {
  15053. return (0, _indexOf.default)(token).call(token, 'r:') > -1;
  15054. }
  15055. },{"@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){
  15056. "use strict";
  15057. var _Object$defineProperty = _dereq_("@babel/runtime-corejs3/core-js-stable/object/define-property");
  15058. var _interopRequireDefault = _dereq_("@babel/runtime-corejs3/helpers/interopRequireDefault");
  15059. _Object$defineProperty(exports, "__esModule", {
  15060. value: true
  15061. });
  15062. exports.default = parseDate;
  15063. var _parseInt2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/parse-int"));
  15064. function parseDate(iso8601) {
  15065. 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$');
  15066. const match = regexp.exec(iso8601);
  15067. if (!match) {
  15068. return null;
  15069. }
  15070. const year = (0, _parseInt2.default)(match[1]) || 0;
  15071. const month = ((0, _parseInt2.default)(match[2]) || 1) - 1;
  15072. const day = (0, _parseInt2.default)(match[3]) || 0;
  15073. const hour = (0, _parseInt2.default)(match[4]) || 0;
  15074. const minute = (0, _parseInt2.default)(match[5]) || 0;
  15075. const second = (0, _parseInt2.default)(match[6]) || 0;
  15076. const milli = (0, _parseInt2.default)(match[8]) || 0;
  15077. return new Date(Date.UTC(year, month, day, hour, minute, second, milli));
  15078. }
  15079. },{"@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){
  15080. "use strict";
  15081. var _Object$defineProperty = _dereq_("@babel/runtime-corejs3/core-js-stable/object/define-property");
  15082. var _interopRequireDefault = _dereq_("@babel/runtime-corejs3/helpers/interopRequireDefault");
  15083. _Object$defineProperty(exports, "__esModule", {
  15084. value: true
  15085. });
  15086. exports.continueWhile = continueWhile;
  15087. exports.resolvingPromise = resolvingPromise;
  15088. exports.when = when;
  15089. var _promise = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/promise"));
  15090. var _isArray = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/array/is-array"));
  15091. // Create Deferred Promise
  15092. function resolvingPromise() {
  15093. let res;
  15094. let rej;
  15095. const promise = new _promise.default((resolve, reject) => {
  15096. res = resolve;
  15097. rej = reject;
  15098. });
  15099. const defer = promise;
  15100. defer.resolve = res;
  15101. defer.reject = rej;
  15102. return defer;
  15103. }
  15104. function when(promises) {
  15105. let objects;
  15106. const arrayArgument = (0, _isArray.default)(promises);
  15107. if (arrayArgument) {
  15108. objects = promises;
  15109. } else {
  15110. objects = arguments;
  15111. }
  15112. let total = objects.length;
  15113. let hadError = false;
  15114. const results = [];
  15115. const returnValue = arrayArgument ? [results] : results;
  15116. const errors = [];
  15117. results.length = objects.length;
  15118. errors.length = objects.length;
  15119. if (total === 0) {
  15120. return _promise.default.resolve(returnValue);
  15121. }
  15122. const promise = resolvingPromise();
  15123. const resolveOne = function () {
  15124. total--;
  15125. if (total <= 0) {
  15126. if (hadError) {
  15127. promise.reject(errors);
  15128. } else {
  15129. promise.resolve(returnValue);
  15130. }
  15131. }
  15132. };
  15133. const chain = function (object, index) {
  15134. if (object && typeof object.then === 'function') {
  15135. object.then(function (result) {
  15136. results[index] = result;
  15137. resolveOne();
  15138. }, function (error) {
  15139. errors[index] = error;
  15140. hadError = true;
  15141. resolveOne();
  15142. });
  15143. } else {
  15144. results[index] = object;
  15145. resolveOne();
  15146. }
  15147. };
  15148. for (let i = 0; i < objects.length; i++) {
  15149. chain(objects[i], i);
  15150. }
  15151. return promise;
  15152. }
  15153. function continueWhile(test, emitter) {
  15154. if (test()) {
  15155. return emitter().then(() => {
  15156. return continueWhile(test, emitter);
  15157. });
  15158. }
  15159. return _promise.default.resolve();
  15160. }
  15161. },{"@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){
  15162. "use strict";
  15163. var _Object$defineProperty = _dereq_("@babel/runtime-corejs3/core-js-stable/object/define-property");
  15164. var _interopRequireDefault = _dereq_("@babel/runtime-corejs3/helpers/interopRequireDefault");
  15165. _Object$defineProperty(exports, "__esModule", {
  15166. value: true
  15167. });
  15168. exports.default = unique;
  15169. var _forEach = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/instance/for-each"));
  15170. var _indexOf = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/instance/index-of"));
  15171. var _arrayContainsObject = _interopRequireDefault(_dereq_("./arrayContainsObject"));
  15172. var _CoreManager = _interopRequireDefault(_dereq_("./CoreManager"));
  15173. function unique(arr) {
  15174. const uniques = [];
  15175. (0, _forEach.default)(arr).call(arr, value => {
  15176. const ParseObject = _CoreManager.default.getParseObject();
  15177. if (value instanceof ParseObject) {
  15178. if (!(0, _arrayContainsObject.default)(uniques, value)) {
  15179. uniques.push(value);
  15180. }
  15181. } else {
  15182. if ((0, _indexOf.default)(uniques).call(uniques, value) < 0) {
  15183. uniques.push(value);
  15184. }
  15185. }
  15186. });
  15187. return uniques;
  15188. }
  15189. },{"./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){
  15190. "use strict";
  15191. var _Object$defineProperty = _dereq_("@babel/runtime-corejs3/core-js-stable/object/define-property");
  15192. var _interopRequireDefault = _dereq_("@babel/runtime-corejs3/helpers/interopRequireDefault");
  15193. _Object$defineProperty(exports, "__esModule", {
  15194. value: true
  15195. });
  15196. exports.default = unsavedChildren;
  15197. var _concat = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/instance/concat"));
  15198. var _indexOf = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/instance/index-of"));
  15199. var _isArray = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/array/is-array"));
  15200. var _forEach = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/instance/for-each"));
  15201. var _CoreManager = _interopRequireDefault(_dereq_("./CoreManager"));
  15202. var _ParseFile = _interopRequireDefault(_dereq_("./ParseFile"));
  15203. var _ParseRelation = _interopRequireDefault(_dereq_("./ParseRelation"));
  15204. /**
  15205. * Return an array of unsaved children, which are either Parse Objects or Files.
  15206. * If it encounters any dirty Objects without Ids, it will throw an exception.
  15207. *
  15208. * @param {Parse.Object} obj
  15209. * @param {boolean} allowDeepUnsaved
  15210. * @returns {Array}
  15211. */
  15212. function unsavedChildren(obj, allowDeepUnsaved) {
  15213. const encountered = {
  15214. objects: {},
  15215. files: []
  15216. };
  15217. const identifier = obj.className + ':' + obj._getId();
  15218. encountered.objects[identifier] = obj.dirty() ? obj : true;
  15219. const attributes = obj.attributes;
  15220. for (const attr in attributes) {
  15221. if (typeof attributes[attr] === 'object') {
  15222. traverse(attributes[attr], encountered, false, !!allowDeepUnsaved);
  15223. }
  15224. }
  15225. const unsaved = [];
  15226. for (const id in encountered.objects) {
  15227. if (id !== identifier && encountered.objects[id] !== true) {
  15228. unsaved.push(encountered.objects[id]);
  15229. }
  15230. }
  15231. return (0, _concat.default)(unsaved).call(unsaved, encountered.files);
  15232. }
  15233. function traverse(obj, encountered, shouldThrow, allowDeepUnsaved) {
  15234. const ParseObject = _CoreManager.default.getParseObject();
  15235. if (obj instanceof ParseObject) {
  15236. if (!obj.id && shouldThrow) {
  15237. throw new Error('Cannot create a pointer to an unsaved Object.');
  15238. }
  15239. const identifier = obj.className + ':' + obj._getId();
  15240. if (!encountered.objects[identifier]) {
  15241. encountered.objects[identifier] = obj.dirty() ? obj : true;
  15242. const attributes = obj.attributes;
  15243. for (const attr in attributes) {
  15244. if (typeof attributes[attr] === 'object') {
  15245. traverse(attributes[attr], encountered, !allowDeepUnsaved, allowDeepUnsaved);
  15246. }
  15247. }
  15248. }
  15249. return;
  15250. }
  15251. if (obj instanceof _ParseFile.default) {
  15252. var _context;
  15253. if (!obj.url() && (0, _indexOf.default)(_context = encountered.files).call(_context, obj) < 0) {
  15254. encountered.files.push(obj);
  15255. }
  15256. return;
  15257. }
  15258. if (obj instanceof _ParseRelation.default) {
  15259. return;
  15260. }
  15261. if ((0, _isArray.default)(obj)) {
  15262. (0, _forEach.default)(obj).call(obj, el => {
  15263. if (typeof el === 'object') {
  15264. traverse(el, encountered, shouldThrow, allowDeepUnsaved);
  15265. }
  15266. });
  15267. }
  15268. for (const k in obj) {
  15269. if (typeof obj[k] === 'object') {
  15270. traverse(obj[k], encountered, shouldThrow, allowDeepUnsaved);
  15271. }
  15272. }
  15273. }
  15274. },{"./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){
  15275. "use strict";
  15276. var _Object$defineProperty = _dereq_("@babel/runtime-corejs3/core-js-stable/object/define-property");
  15277. _Object$defineProperty(exports, "__esModule", {
  15278. value: true
  15279. });
  15280. exports.default = void 0;
  15281. var _uuid = _dereq_("uuid");
  15282. let uuid = function () {
  15283. const s = [];
  15284. const hexDigits = '0123456789abcdef';
  15285. for (let i = 0; i < 36; i++) {
  15286. s[i] = hexDigits.substr(Math.floor(Math.random() * 0x10), 1);
  15287. }
  15288. s[14] = '4'; // bits 12-15 of the time_hi_and_version field to 0010
  15289. s[19] = hexDigits.substr(Number(s[19]) & 0x3 | 0x8, 1); // bits 6-7 of the clock_seq_hi_and_reserved to 01
  15290. s[8] = s[13] = s[18] = s[23] = '-';
  15291. return s.join('');
  15292. };
  15293. module.exports = uuid;
  15294. var _default = exports.default = uuid;
  15295. },{"@babel/runtime-corejs3/core-js-stable/object/define-property":90,"uuid":487}],65:[function(_dereq_,module,exports){
  15296. module.exports = _dereq_("core-js-pure/stable/array/from");
  15297. },{"core-js-pure/stable/array/from":432}],66:[function(_dereq_,module,exports){
  15298. module.exports = _dereq_("core-js-pure/stable/array/is-array");
  15299. },{"core-js-pure/stable/array/is-array":433}],67:[function(_dereq_,module,exports){
  15300. module.exports = _dereq_("core-js-pure/stable/instance/bind");
  15301. },{"core-js-pure/stable/instance/bind":438}],68:[function(_dereq_,module,exports){
  15302. module.exports = _dereq_("core-js-pure/stable/instance/concat");
  15303. },{"core-js-pure/stable/instance/concat":439}],69:[function(_dereq_,module,exports){
  15304. module.exports = _dereq_("core-js-pure/stable/instance/entries");
  15305. },{"core-js-pure/stable/instance/entries":440}],70:[function(_dereq_,module,exports){
  15306. module.exports = _dereq_("core-js-pure/stable/instance/every");
  15307. },{"core-js-pure/stable/instance/every":441}],71:[function(_dereq_,module,exports){
  15308. module.exports = _dereq_("core-js-pure/stable/instance/filter");
  15309. },{"core-js-pure/stable/instance/filter":442}],72:[function(_dereq_,module,exports){
  15310. module.exports = _dereq_("core-js-pure/stable/instance/find-index");
  15311. },{"core-js-pure/stable/instance/find-index":443}],73:[function(_dereq_,module,exports){
  15312. module.exports = _dereq_("core-js-pure/stable/instance/find");
  15313. },{"core-js-pure/stable/instance/find":444}],74:[function(_dereq_,module,exports){
  15314. module.exports = _dereq_("core-js-pure/stable/instance/for-each");
  15315. },{"core-js-pure/stable/instance/for-each":445}],75:[function(_dereq_,module,exports){
  15316. module.exports = _dereq_("core-js-pure/stable/instance/includes");
  15317. },{"core-js-pure/stable/instance/includes":446}],76:[function(_dereq_,module,exports){
  15318. module.exports = _dereq_("core-js-pure/stable/instance/index-of");
  15319. },{"core-js-pure/stable/instance/index-of":447}],77:[function(_dereq_,module,exports){
  15320. module.exports = _dereq_("core-js-pure/stable/instance/keys");
  15321. },{"core-js-pure/stable/instance/keys":448}],78:[function(_dereq_,module,exports){
  15322. module.exports = _dereq_("core-js-pure/stable/instance/map");
  15323. },{"core-js-pure/stable/instance/map":449}],79:[function(_dereq_,module,exports){
  15324. module.exports = _dereq_("core-js-pure/stable/instance/reduce");
  15325. },{"core-js-pure/stable/instance/reduce":450}],80:[function(_dereq_,module,exports){
  15326. module.exports = _dereq_("core-js-pure/stable/instance/slice");
  15327. },{"core-js-pure/stable/instance/slice":451}],81:[function(_dereq_,module,exports){
  15328. module.exports = _dereq_("core-js-pure/stable/instance/sort");
  15329. },{"core-js-pure/stable/instance/sort":452}],82:[function(_dereq_,module,exports){
  15330. module.exports = _dereq_("core-js-pure/stable/instance/splice");
  15331. },{"core-js-pure/stable/instance/splice":453}],83:[function(_dereq_,module,exports){
  15332. module.exports = _dereq_("core-js-pure/stable/instance/starts-with");
  15333. },{"core-js-pure/stable/instance/starts-with":454}],84:[function(_dereq_,module,exports){
  15334. module.exports = _dereq_("core-js-pure/stable/instance/values");
  15335. },{"core-js-pure/stable/instance/values":455}],85:[function(_dereq_,module,exports){
  15336. module.exports = _dereq_("core-js-pure/stable/json/stringify");
  15337. },{"core-js-pure/stable/json/stringify":456}],86:[function(_dereq_,module,exports){
  15338. module.exports = _dereq_("core-js-pure/stable/map");
  15339. },{"core-js-pure/stable/map":457}],87:[function(_dereq_,module,exports){
  15340. module.exports = _dereq_("core-js-pure/stable/number/is-integer");
  15341. },{"core-js-pure/stable/number/is-integer":458}],88:[function(_dereq_,module,exports){
  15342. module.exports = _dereq_("core-js-pure/stable/object/assign");
  15343. },{"core-js-pure/stable/object/assign":459}],89:[function(_dereq_,module,exports){
  15344. module.exports = _dereq_("core-js-pure/stable/object/create");
  15345. },{"core-js-pure/stable/object/create":460}],90:[function(_dereq_,module,exports){
  15346. module.exports = _dereq_("core-js-pure/stable/object/define-property");
  15347. },{"core-js-pure/stable/object/define-property":461}],91:[function(_dereq_,module,exports){
  15348. module.exports = _dereq_("core-js-pure/stable/object/entries");
  15349. },{"core-js-pure/stable/object/entries":462}],92:[function(_dereq_,module,exports){
  15350. module.exports = _dereq_("core-js-pure/stable/object/freeze");
  15351. },{"core-js-pure/stable/object/freeze":463}],93:[function(_dereq_,module,exports){
  15352. module.exports = _dereq_("core-js-pure/stable/object/get-own-property-descriptor");
  15353. },{"core-js-pure/stable/object/get-own-property-descriptor":464}],94:[function(_dereq_,module,exports){
  15354. module.exports = _dereq_("core-js-pure/stable/object/get-prototype-of");
  15355. },{"core-js-pure/stable/object/get-prototype-of":465}],95:[function(_dereq_,module,exports){
  15356. module.exports = _dereq_("core-js-pure/stable/object/keys");
  15357. },{"core-js-pure/stable/object/keys":466}],96:[function(_dereq_,module,exports){
  15358. module.exports = _dereq_("core-js-pure/stable/parse-int");
  15359. },{"core-js-pure/stable/parse-int":467}],97:[function(_dereq_,module,exports){
  15360. module.exports = _dereq_("core-js-pure/stable/promise");
  15361. },{"core-js-pure/stable/promise":468}],98:[function(_dereq_,module,exports){
  15362. module.exports = _dereq_("core-js-pure/stable/set-interval");
  15363. },{"core-js-pure/stable/set-interval":469}],99:[function(_dereq_,module,exports){
  15364. module.exports = _dereq_("core-js-pure/stable/set-timeout");
  15365. },{"core-js-pure/stable/set-timeout":470}],100:[function(_dereq_,module,exports){
  15366. module.exports = _dereq_("core-js-pure/stable/set");
  15367. },{"core-js-pure/stable/set":471}],101:[function(_dereq_,module,exports){
  15368. module.exports = _dereq_("core-js-pure/stable/weak-map");
  15369. },{"core-js-pure/stable/weak-map":475}],102:[function(_dereq_,module,exports){
  15370. var _Object$defineProperty = _dereq_("core-js-pure/features/object/define-property.js");
  15371. var toPropertyKey = _dereq_("./toPropertyKey.js");
  15372. function _defineProperty(e, r, t) {
  15373. return (r = toPropertyKey(r)) in e ? _Object$defineProperty(e, r, {
  15374. value: t,
  15375. enumerable: !0,
  15376. configurable: !0,
  15377. writable: !0
  15378. }) : e[r] = t, e;
  15379. }
  15380. module.exports = _defineProperty, module.exports.__esModule = true, module.exports["default"] = module.exports;
  15381. },{"./toPropertyKey.js":105,"core-js-pure/features/object/define-property.js":165}],103:[function(_dereq_,module,exports){
  15382. function _interopRequireDefault(e) {
  15383. return e && e.__esModule ? e : {
  15384. "default": e
  15385. };
  15386. }
  15387. module.exports = _interopRequireDefault, module.exports.__esModule = true, module.exports["default"] = module.exports;
  15388. },{}],104:[function(_dereq_,module,exports){
  15389. var _Symbol$toPrimitive = _dereq_("core-js-pure/features/symbol/to-primitive.js");
  15390. var _typeof = _dereq_("./typeof.js")["default"];
  15391. function toPrimitive(t, r) {
  15392. if ("object" != _typeof(t) || !t) return t;
  15393. var e = t[_Symbol$toPrimitive];
  15394. if (void 0 !== e) {
  15395. var i = e.call(t, r || "default");
  15396. if ("object" != _typeof(i)) return i;
  15397. throw new TypeError("@@toPrimitive must return a primitive value.");
  15398. }
  15399. return ("string" === r ? String : Number)(t);
  15400. }
  15401. module.exports = toPrimitive, module.exports.__esModule = true, module.exports["default"] = module.exports;
  15402. },{"./typeof.js":106,"core-js-pure/features/symbol/to-primitive.js":168}],105:[function(_dereq_,module,exports){
  15403. var _typeof = _dereq_("./typeof.js")["default"];
  15404. var toPrimitive = _dereq_("./toPrimitive.js");
  15405. function toPropertyKey(t) {
  15406. var i = toPrimitive(t, "string");
  15407. return "symbol" == _typeof(i) ? i : i + "";
  15408. }
  15409. module.exports = toPropertyKey, module.exports.__esModule = true, module.exports["default"] = module.exports;
  15410. },{"./toPrimitive.js":104,"./typeof.js":106}],106:[function(_dereq_,module,exports){
  15411. var _Symbol = _dereq_("core-js-pure/features/symbol/index.js");
  15412. var _Symbol$iterator = _dereq_("core-js-pure/features/symbol/iterator.js");
  15413. function _typeof(o) {
  15414. "@babel/helpers - typeof";
  15415. return (module.exports = _typeof = "function" == typeof _Symbol && "symbol" == typeof _Symbol$iterator ? function (o) {
  15416. return typeof o;
  15417. } : function (o) {
  15418. return o && "function" == typeof _Symbol && o.constructor === _Symbol && o !== _Symbol.prototype ? "symbol" : typeof o;
  15419. }, module.exports.__esModule = true, module.exports["default"] = module.exports), _typeof(o);
  15420. }
  15421. module.exports = _typeof, module.exports.__esModule = true, module.exports["default"] = module.exports;
  15422. },{"core-js-pure/features/symbol/index.js":166,"core-js-pure/features/symbol/iterator.js":167}],107:[function(_dereq_,module,exports){
  15423. },{}],108:[function(_dereq_,module,exports){
  15424. var parent = _dereq_('../../stable/object/define-property');
  15425. module.exports = parent;
  15426. },{"../../stable/object/define-property":461}],109:[function(_dereq_,module,exports){
  15427. var parent = _dereq_('../../stable/symbol');
  15428. _dereq_('../../modules/esnext.symbol.dispose');
  15429. module.exports = parent;
  15430. },{"../../modules/esnext.symbol.dispose":419,"../../stable/symbol":472}],110:[function(_dereq_,module,exports){
  15431. var parent = _dereq_('../../stable/symbol/iterator');
  15432. module.exports = parent;
  15433. },{"../../stable/symbol/iterator":473}],111:[function(_dereq_,module,exports){
  15434. var parent = _dereq_('../../stable/symbol/to-primitive');
  15435. module.exports = parent;
  15436. },{"../../stable/symbol/to-primitive":474}],112:[function(_dereq_,module,exports){
  15437. _dereq_('../../modules/es.string.iterator');
  15438. _dereq_('../../modules/es.array.from');
  15439. var path = _dereq_('../../internals/path');
  15440. module.exports = path.Array.from;
  15441. },{"../../internals/path":305,"../../modules/es.array.from":353,"../../modules/es.string.iterator":396}],113:[function(_dereq_,module,exports){
  15442. _dereq_('../../modules/es.array.is-array');
  15443. var path = _dereq_('../../internals/path');
  15444. module.exports = path.Array.isArray;
  15445. },{"../../internals/path":305,"../../modules/es.array.is-array":356}],114:[function(_dereq_,module,exports){
  15446. _dereq_('../../../modules/es.array.concat');
  15447. var entryVirtual = _dereq_('../../../internals/entry-virtual');
  15448. module.exports = entryVirtual('Array').concat;
  15449. },{"../../../internals/entry-virtual":229,"../../../modules/es.array.concat":347}],115:[function(_dereq_,module,exports){
  15450. _dereq_('../../../modules/es.array.iterator');
  15451. _dereq_('../../../modules/es.object.to-string');
  15452. var entryVirtual = _dereq_('../../../internals/entry-virtual');
  15453. module.exports = entryVirtual('Array').entries;
  15454. },{"../../../internals/entry-virtual":229,"../../../modules/es.array.iterator":357,"../../../modules/es.object.to-string":380}],116:[function(_dereq_,module,exports){
  15455. _dereq_('../../../modules/es.array.every');
  15456. var entryVirtual = _dereq_('../../../internals/entry-virtual');
  15457. module.exports = entryVirtual('Array').every;
  15458. },{"../../../internals/entry-virtual":229,"../../../modules/es.array.every":348}],117:[function(_dereq_,module,exports){
  15459. _dereq_('../../../modules/es.array.filter');
  15460. var entryVirtual = _dereq_('../../../internals/entry-virtual');
  15461. module.exports = entryVirtual('Array').filter;
  15462. },{"../../../internals/entry-virtual":229,"../../../modules/es.array.filter":349}],118:[function(_dereq_,module,exports){
  15463. _dereq_('../../../modules/es.array.find-index');
  15464. var entryVirtual = _dereq_('../../../internals/entry-virtual');
  15465. module.exports = entryVirtual('Array').findIndex;
  15466. },{"../../../internals/entry-virtual":229,"../../../modules/es.array.find-index":350}],119:[function(_dereq_,module,exports){
  15467. _dereq_('../../../modules/es.array.find');
  15468. var entryVirtual = _dereq_('../../../internals/entry-virtual');
  15469. module.exports = entryVirtual('Array').find;
  15470. },{"../../../internals/entry-virtual":229,"../../../modules/es.array.find":351}],120:[function(_dereq_,module,exports){
  15471. _dereq_('../../../modules/es.array.for-each');
  15472. var entryVirtual = _dereq_('../../../internals/entry-virtual');
  15473. module.exports = entryVirtual('Array').forEach;
  15474. },{"../../../internals/entry-virtual":229,"../../../modules/es.array.for-each":352}],121:[function(_dereq_,module,exports){
  15475. _dereq_('../../../modules/es.array.includes');
  15476. var entryVirtual = _dereq_('../../../internals/entry-virtual');
  15477. module.exports = entryVirtual('Array').includes;
  15478. },{"../../../internals/entry-virtual":229,"../../../modules/es.array.includes":354}],122:[function(_dereq_,module,exports){
  15479. _dereq_('../../../modules/es.array.index-of');
  15480. var entryVirtual = _dereq_('../../../internals/entry-virtual');
  15481. module.exports = entryVirtual('Array').indexOf;
  15482. },{"../../../internals/entry-virtual":229,"../../../modules/es.array.index-of":355}],123:[function(_dereq_,module,exports){
  15483. _dereq_('../../../modules/es.array.iterator');
  15484. _dereq_('../../../modules/es.object.to-string');
  15485. var entryVirtual = _dereq_('../../../internals/entry-virtual');
  15486. module.exports = entryVirtual('Array').keys;
  15487. },{"../../../internals/entry-virtual":229,"../../../modules/es.array.iterator":357,"../../../modules/es.object.to-string":380}],124:[function(_dereq_,module,exports){
  15488. _dereq_('../../../modules/es.array.map');
  15489. var entryVirtual = _dereq_('../../../internals/entry-virtual');
  15490. module.exports = entryVirtual('Array').map;
  15491. },{"../../../internals/entry-virtual":229,"../../../modules/es.array.map":358}],125:[function(_dereq_,module,exports){
  15492. _dereq_('../../../modules/es.array.reduce');
  15493. var entryVirtual = _dereq_('../../../internals/entry-virtual');
  15494. module.exports = entryVirtual('Array').reduce;
  15495. },{"../../../internals/entry-virtual":229,"../../../modules/es.array.reduce":359}],126:[function(_dereq_,module,exports){
  15496. _dereq_('../../../modules/es.array.slice');
  15497. var entryVirtual = _dereq_('../../../internals/entry-virtual');
  15498. module.exports = entryVirtual('Array').slice;
  15499. },{"../../../internals/entry-virtual":229,"../../../modules/es.array.slice":360}],127:[function(_dereq_,module,exports){
  15500. _dereq_('../../../modules/es.array.sort');
  15501. var entryVirtual = _dereq_('../../../internals/entry-virtual');
  15502. module.exports = entryVirtual('Array').sort;
  15503. },{"../../../internals/entry-virtual":229,"../../../modules/es.array.sort":361}],128:[function(_dereq_,module,exports){
  15504. _dereq_('../../../modules/es.array.splice');
  15505. var entryVirtual = _dereq_('../../../internals/entry-virtual');
  15506. module.exports = entryVirtual('Array').splice;
  15507. },{"../../../internals/entry-virtual":229,"../../../modules/es.array.splice":362}],129:[function(_dereq_,module,exports){
  15508. _dereq_('../../../modules/es.array.iterator');
  15509. _dereq_('../../../modules/es.object.to-string');
  15510. var entryVirtual = _dereq_('../../../internals/entry-virtual');
  15511. module.exports = entryVirtual('Array').values;
  15512. },{"../../../internals/entry-virtual":229,"../../../modules/es.array.iterator":357,"../../../modules/es.object.to-string":380}],130:[function(_dereq_,module,exports){
  15513. _dereq_('../../../modules/es.function.bind');
  15514. var entryVirtual = _dereq_('../../../internals/entry-virtual');
  15515. module.exports = entryVirtual('Function').bind;
  15516. },{"../../../internals/entry-virtual":229,"../../../modules/es.function.bind":364}],131:[function(_dereq_,module,exports){
  15517. var isPrototypeOf = _dereq_('../../internals/object-is-prototype-of');
  15518. var method = _dereq_('../function/virtual/bind');
  15519. var FunctionPrototype = Function.prototype;
  15520. module.exports = function (it) {
  15521. var own = it.bind;
  15522. return it === FunctionPrototype || (isPrototypeOf(FunctionPrototype, it) && own === FunctionPrototype.bind) ? method : own;
  15523. };
  15524. },{"../../internals/object-is-prototype-of":296,"../function/virtual/bind":130}],132:[function(_dereq_,module,exports){
  15525. var isPrototypeOf = _dereq_('../../internals/object-is-prototype-of');
  15526. var method = _dereq_('../array/virtual/concat');
  15527. var ArrayPrototype = Array.prototype;
  15528. module.exports = function (it) {
  15529. var own = it.concat;
  15530. return it === ArrayPrototype || (isPrototypeOf(ArrayPrototype, it) && own === ArrayPrototype.concat) ? method : own;
  15531. };
  15532. },{"../../internals/object-is-prototype-of":296,"../array/virtual/concat":114}],133:[function(_dereq_,module,exports){
  15533. var isPrototypeOf = _dereq_('../../internals/object-is-prototype-of');
  15534. var method = _dereq_('../array/virtual/every');
  15535. var ArrayPrototype = Array.prototype;
  15536. module.exports = function (it) {
  15537. var own = it.every;
  15538. return it === ArrayPrototype || (isPrototypeOf(ArrayPrototype, it) && own === ArrayPrototype.every) ? method : own;
  15539. };
  15540. },{"../../internals/object-is-prototype-of":296,"../array/virtual/every":116}],134:[function(_dereq_,module,exports){
  15541. var isPrototypeOf = _dereq_('../../internals/object-is-prototype-of');
  15542. var method = _dereq_('../array/virtual/filter');
  15543. var ArrayPrototype = Array.prototype;
  15544. module.exports = function (it) {
  15545. var own = it.filter;
  15546. return it === ArrayPrototype || (isPrototypeOf(ArrayPrototype, it) && own === ArrayPrototype.filter) ? method : own;
  15547. };
  15548. },{"../../internals/object-is-prototype-of":296,"../array/virtual/filter":117}],135:[function(_dereq_,module,exports){
  15549. var isPrototypeOf = _dereq_('../../internals/object-is-prototype-of');
  15550. var method = _dereq_('../array/virtual/find-index');
  15551. var ArrayPrototype = Array.prototype;
  15552. module.exports = function (it) {
  15553. var own = it.findIndex;
  15554. return it === ArrayPrototype || (isPrototypeOf(ArrayPrototype, it) && own === ArrayPrototype.findIndex) ? method : own;
  15555. };
  15556. },{"../../internals/object-is-prototype-of":296,"../array/virtual/find-index":118}],136:[function(_dereq_,module,exports){
  15557. var isPrototypeOf = _dereq_('../../internals/object-is-prototype-of');
  15558. var method = _dereq_('../array/virtual/find');
  15559. var ArrayPrototype = Array.prototype;
  15560. module.exports = function (it) {
  15561. var own = it.find;
  15562. return it === ArrayPrototype || (isPrototypeOf(ArrayPrototype, it) && own === ArrayPrototype.find) ? method : own;
  15563. };
  15564. },{"../../internals/object-is-prototype-of":296,"../array/virtual/find":119}],137:[function(_dereq_,module,exports){
  15565. var isPrototypeOf = _dereq_('../../internals/object-is-prototype-of');
  15566. var arrayMethod = _dereq_('../array/virtual/includes');
  15567. var stringMethod = _dereq_('../string/virtual/includes');
  15568. var ArrayPrototype = Array.prototype;
  15569. var StringPrototype = String.prototype;
  15570. module.exports = function (it) {
  15571. var own = it.includes;
  15572. if (it === ArrayPrototype || (isPrototypeOf(ArrayPrototype, it) && own === ArrayPrototype.includes)) return arrayMethod;
  15573. if (typeof it == 'string' || it === StringPrototype || (isPrototypeOf(StringPrototype, it) && own === StringPrototype.includes)) {
  15574. return stringMethod;
  15575. } return own;
  15576. };
  15577. },{"../../internals/object-is-prototype-of":296,"../array/virtual/includes":121,"../string/virtual/includes":159}],138:[function(_dereq_,module,exports){
  15578. var isPrototypeOf = _dereq_('../../internals/object-is-prototype-of');
  15579. var method = _dereq_('../array/virtual/index-of');
  15580. var ArrayPrototype = Array.prototype;
  15581. module.exports = function (it) {
  15582. var own = it.indexOf;
  15583. return it === ArrayPrototype || (isPrototypeOf(ArrayPrototype, it) && own === ArrayPrototype.indexOf) ? method : own;
  15584. };
  15585. },{"../../internals/object-is-prototype-of":296,"../array/virtual/index-of":122}],139:[function(_dereq_,module,exports){
  15586. var isPrototypeOf = _dereq_('../../internals/object-is-prototype-of');
  15587. var method = _dereq_('../array/virtual/map');
  15588. var ArrayPrototype = Array.prototype;
  15589. module.exports = function (it) {
  15590. var own = it.map;
  15591. return it === ArrayPrototype || (isPrototypeOf(ArrayPrototype, it) && own === ArrayPrototype.map) ? method : own;
  15592. };
  15593. },{"../../internals/object-is-prototype-of":296,"../array/virtual/map":124}],140:[function(_dereq_,module,exports){
  15594. var isPrototypeOf = _dereq_('../../internals/object-is-prototype-of');
  15595. var method = _dereq_('../array/virtual/reduce');
  15596. var ArrayPrototype = Array.prototype;
  15597. module.exports = function (it) {
  15598. var own = it.reduce;
  15599. return it === ArrayPrototype || (isPrototypeOf(ArrayPrototype, it) && own === ArrayPrototype.reduce) ? method : own;
  15600. };
  15601. },{"../../internals/object-is-prototype-of":296,"../array/virtual/reduce":125}],141:[function(_dereq_,module,exports){
  15602. var isPrototypeOf = _dereq_('../../internals/object-is-prototype-of');
  15603. var method = _dereq_('../array/virtual/slice');
  15604. var ArrayPrototype = Array.prototype;
  15605. module.exports = function (it) {
  15606. var own = it.slice;
  15607. return it === ArrayPrototype || (isPrototypeOf(ArrayPrototype, it) && own === ArrayPrototype.slice) ? method : own;
  15608. };
  15609. },{"../../internals/object-is-prototype-of":296,"../array/virtual/slice":126}],142:[function(_dereq_,module,exports){
  15610. var isPrototypeOf = _dereq_('../../internals/object-is-prototype-of');
  15611. var method = _dereq_('../array/virtual/sort');
  15612. var ArrayPrototype = Array.prototype;
  15613. module.exports = function (it) {
  15614. var own = it.sort;
  15615. return it === ArrayPrototype || (isPrototypeOf(ArrayPrototype, it) && own === ArrayPrototype.sort) ? method : own;
  15616. };
  15617. },{"../../internals/object-is-prototype-of":296,"../array/virtual/sort":127}],143:[function(_dereq_,module,exports){
  15618. var isPrototypeOf = _dereq_('../../internals/object-is-prototype-of');
  15619. var method = _dereq_('../array/virtual/splice');
  15620. var ArrayPrototype = Array.prototype;
  15621. module.exports = function (it) {
  15622. var own = it.splice;
  15623. return it === ArrayPrototype || (isPrototypeOf(ArrayPrototype, it) && own === ArrayPrototype.splice) ? method : own;
  15624. };
  15625. },{"../../internals/object-is-prototype-of":296,"../array/virtual/splice":128}],144:[function(_dereq_,module,exports){
  15626. var isPrototypeOf = _dereq_('../../internals/object-is-prototype-of');
  15627. var method = _dereq_('../string/virtual/starts-with');
  15628. var StringPrototype = String.prototype;
  15629. module.exports = function (it) {
  15630. var own = it.startsWith;
  15631. return typeof it == 'string' || it === StringPrototype
  15632. || (isPrototypeOf(StringPrototype, it) && own === StringPrototype.startsWith) ? method : own;
  15633. };
  15634. },{"../../internals/object-is-prototype-of":296,"../string/virtual/starts-with":160}],145:[function(_dereq_,module,exports){
  15635. _dereq_('../../modules/es.json.stringify');
  15636. var path = _dereq_('../../internals/path');
  15637. var apply = _dereq_('../../internals/function-apply');
  15638. // eslint-disable-next-line es/no-json -- safe
  15639. if (!path.JSON) path.JSON = { stringify: JSON.stringify };
  15640. // eslint-disable-next-line no-unused-vars -- required for `.length`
  15641. module.exports = function stringify(it, replacer, space) {
  15642. return apply(path.JSON.stringify, null, arguments);
  15643. };
  15644. },{"../../internals/function-apply":237,"../../internals/path":305,"../../modules/es.json.stringify":365}],146:[function(_dereq_,module,exports){
  15645. _dereq_('../../modules/es.array.iterator');
  15646. _dereq_('../../modules/es.map');
  15647. _dereq_('../../modules/es.object.to-string');
  15648. _dereq_('../../modules/es.string.iterator');
  15649. var path = _dereq_('../../internals/path');
  15650. module.exports = path.Map;
  15651. },{"../../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){
  15652. _dereq_('../../modules/es.number.is-integer');
  15653. var path = _dereq_('../../internals/path');
  15654. module.exports = path.Number.isInteger;
  15655. },{"../../internals/path":305,"../../modules/es.number.is-integer":370}],148:[function(_dereq_,module,exports){
  15656. _dereq_('../../modules/es.object.assign');
  15657. var path = _dereq_('../../internals/path');
  15658. module.exports = path.Object.assign;
  15659. },{"../../internals/path":305,"../../modules/es.object.assign":371}],149:[function(_dereq_,module,exports){
  15660. _dereq_('../../modules/es.object.create');
  15661. var path = _dereq_('../../internals/path');
  15662. var Object = path.Object;
  15663. module.exports = function create(P, D) {
  15664. return Object.create(P, D);
  15665. };
  15666. },{"../../internals/path":305,"../../modules/es.object.create":372}],150:[function(_dereq_,module,exports){
  15667. _dereq_('../../modules/es.object.define-property');
  15668. var path = _dereq_('../../internals/path');
  15669. var Object = path.Object;
  15670. var defineProperty = module.exports = function defineProperty(it, key, desc) {
  15671. return Object.defineProperty(it, key, desc);
  15672. };
  15673. if (Object.defineProperty.sham) defineProperty.sham = true;
  15674. },{"../../internals/path":305,"../../modules/es.object.define-property":373}],151:[function(_dereq_,module,exports){
  15675. _dereq_('../../modules/es.object.entries');
  15676. var path = _dereq_('../../internals/path');
  15677. module.exports = path.Object.entries;
  15678. },{"../../internals/path":305,"../../modules/es.object.entries":374}],152:[function(_dereq_,module,exports){
  15679. _dereq_('../../modules/es.object.freeze');
  15680. var path = _dereq_('../../internals/path');
  15681. module.exports = path.Object.freeze;
  15682. },{"../../internals/path":305,"../../modules/es.object.freeze":375}],153:[function(_dereq_,module,exports){
  15683. _dereq_('../../modules/es.object.get-own-property-descriptor');
  15684. var path = _dereq_('../../internals/path');
  15685. var Object = path.Object;
  15686. var getOwnPropertyDescriptor = module.exports = function getOwnPropertyDescriptor(it, key) {
  15687. return Object.getOwnPropertyDescriptor(it, key);
  15688. };
  15689. if (Object.getOwnPropertyDescriptor.sham) getOwnPropertyDescriptor.sham = true;
  15690. },{"../../internals/path":305,"../../modules/es.object.get-own-property-descriptor":376}],154:[function(_dereq_,module,exports){
  15691. _dereq_('../../modules/es.object.get-prototype-of');
  15692. var path = _dereq_('../../internals/path');
  15693. module.exports = path.Object.getPrototypeOf;
  15694. },{"../../internals/path":305,"../../modules/es.object.get-prototype-of":378}],155:[function(_dereq_,module,exports){
  15695. _dereq_('../../modules/es.object.keys');
  15696. var path = _dereq_('../../internals/path');
  15697. module.exports = path.Object.keys;
  15698. },{"../../internals/path":305,"../../modules/es.object.keys":379}],156:[function(_dereq_,module,exports){
  15699. _dereq_('../modules/es.parse-int');
  15700. var path = _dereq_('../internals/path');
  15701. module.exports = path.parseInt;
  15702. },{"../internals/path":305,"../modules/es.parse-int":381}],157:[function(_dereq_,module,exports){
  15703. _dereq_('../../modules/es.aggregate-error');
  15704. _dereq_('../../modules/es.array.iterator');
  15705. _dereq_('../../modules/es.object.to-string');
  15706. _dereq_('../../modules/es.promise');
  15707. _dereq_('../../modules/es.promise.all-settled');
  15708. _dereq_('../../modules/es.promise.any');
  15709. _dereq_('../../modules/es.promise.finally');
  15710. _dereq_('../../modules/es.string.iterator');
  15711. var path = _dereq_('../../internals/path');
  15712. module.exports = path.Promise;
  15713. },{"../../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){
  15714. _dereq_('../../modules/es.array.iterator');
  15715. _dereq_('../../modules/es.object.to-string');
  15716. _dereq_('../../modules/es.set');
  15717. _dereq_('../../modules/es.string.iterator');
  15718. var path = _dereq_('../../internals/path');
  15719. module.exports = path.Set;
  15720. },{"../../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){
  15721. _dereq_('../../../modules/es.string.includes');
  15722. var entryVirtual = _dereq_('../../../internals/entry-virtual');
  15723. module.exports = entryVirtual('String').includes;
  15724. },{"../../../internals/entry-virtual":229,"../../../modules/es.string.includes":395}],160:[function(_dereq_,module,exports){
  15725. _dereq_('../../../modules/es.string.starts-with');
  15726. var entryVirtual = _dereq_('../../../internals/entry-virtual');
  15727. module.exports = entryVirtual('String').startsWith;
  15728. },{"../../../internals/entry-virtual":229,"../../../modules/es.string.starts-with":397}],161:[function(_dereq_,module,exports){
  15729. _dereq_('../../modules/es.array.concat');
  15730. _dereq_('../../modules/es.object.to-string');
  15731. _dereq_('../../modules/es.symbol');
  15732. _dereq_('../../modules/es.symbol.async-iterator');
  15733. _dereq_('../../modules/es.symbol.description');
  15734. _dereq_('../../modules/es.symbol.has-instance');
  15735. _dereq_('../../modules/es.symbol.is-concat-spreadable');
  15736. _dereq_('../../modules/es.symbol.iterator');
  15737. _dereq_('../../modules/es.symbol.match');
  15738. _dereq_('../../modules/es.symbol.match-all');
  15739. _dereq_('../../modules/es.symbol.replace');
  15740. _dereq_('../../modules/es.symbol.search');
  15741. _dereq_('../../modules/es.symbol.species');
  15742. _dereq_('../../modules/es.symbol.split');
  15743. _dereq_('../../modules/es.symbol.to-primitive');
  15744. _dereq_('../../modules/es.symbol.to-string-tag');
  15745. _dereq_('../../modules/es.symbol.unscopables');
  15746. _dereq_('../../modules/es.json.to-string-tag');
  15747. _dereq_('../../modules/es.math.to-string-tag');
  15748. _dereq_('../../modules/es.reflect.to-string-tag');
  15749. var path = _dereq_('../../internals/path');
  15750. module.exports = path.Symbol;
  15751. },{"../../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){
  15752. _dereq_('../../modules/es.array.iterator');
  15753. _dereq_('../../modules/es.object.to-string');
  15754. _dereq_('../../modules/es.string.iterator');
  15755. _dereq_('../../modules/es.symbol.iterator');
  15756. var WrappedWellKnownSymbolModule = _dereq_('../../internals/well-known-symbol-wrapped');
  15757. module.exports = WrappedWellKnownSymbolModule.f('iterator');
  15758. },{"../../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){
  15759. _dereq_('../../modules/es.date.to-primitive');
  15760. _dereq_('../../modules/es.symbol.to-primitive');
  15761. var WrappedWellKnownSymbolModule = _dereq_('../../internals/well-known-symbol-wrapped');
  15762. module.exports = WrappedWellKnownSymbolModule.f('toPrimitive');
  15763. },{"../../internals/well-known-symbol-wrapped":342,"../../modules/es.date.to-primitive":363,"../../modules/es.symbol.to-primitive":413}],164:[function(_dereq_,module,exports){
  15764. _dereq_('../../modules/es.array.iterator');
  15765. _dereq_('../../modules/es.object.to-string');
  15766. _dereq_('../../modules/es.weak-map');
  15767. var path = _dereq_('../../internals/path');
  15768. module.exports = path.WeakMap;
  15769. },{"../../internals/path":305,"../../modules/es.array.iterator":357,"../../modules/es.object.to-string":380,"../../modules/es.weak-map":417}],165:[function(_dereq_,module,exports){
  15770. module.exports = _dereq_('../../full/object/define-property');
  15771. },{"../../full/object/define-property":169}],166:[function(_dereq_,module,exports){
  15772. module.exports = _dereq_('../../full/symbol');
  15773. },{"../../full/symbol":170}],167:[function(_dereq_,module,exports){
  15774. module.exports = _dereq_('../../full/symbol/iterator');
  15775. },{"../../full/symbol/iterator":171}],168:[function(_dereq_,module,exports){
  15776. module.exports = _dereq_('../../full/symbol/to-primitive');
  15777. },{"../../full/symbol/to-primitive":172}],169:[function(_dereq_,module,exports){
  15778. var parent = _dereq_('../../actual/object/define-property');
  15779. module.exports = parent;
  15780. },{"../../actual/object/define-property":108}],170:[function(_dereq_,module,exports){
  15781. var parent = _dereq_('../../actual/symbol');
  15782. _dereq_('../../modules/esnext.symbol.async-dispose');
  15783. _dereq_('../../modules/esnext.symbol.is-registered');
  15784. _dereq_('../../modules/esnext.symbol.is-well-known');
  15785. _dereq_('../../modules/esnext.symbol.matcher');
  15786. _dereq_('../../modules/esnext.symbol.metadata-key');
  15787. _dereq_('../../modules/esnext.symbol.observable');
  15788. // TODO: Remove from `core-js@4`
  15789. _dereq_('../../modules/esnext.symbol.metadata');
  15790. _dereq_('../../modules/esnext.symbol.pattern-match');
  15791. _dereq_('../../modules/esnext.symbol.replace-all');
  15792. module.exports = parent;
  15793. },{"../../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){
  15794. var parent = _dereq_('../../actual/symbol/iterator');
  15795. module.exports = parent;
  15796. },{"../../actual/symbol/iterator":110}],172:[function(_dereq_,module,exports){
  15797. var parent = _dereq_('../../actual/symbol/to-primitive');
  15798. module.exports = parent;
  15799. },{"../../actual/symbol/to-primitive":111}],173:[function(_dereq_,module,exports){
  15800. var isCallable = _dereq_('../internals/is-callable');
  15801. var tryToString = _dereq_('../internals/try-to-string');
  15802. var $TypeError = TypeError;
  15803. // `Assert: IsCallable(argument) is true`
  15804. module.exports = function (argument) {
  15805. if (isCallable(argument)) return argument;
  15806. throw $TypeError(tryToString(argument) + ' is not a function');
  15807. };
  15808. },{"../internals/is-callable":264,"../internals/try-to-string":335}],174:[function(_dereq_,module,exports){
  15809. var isConstructor = _dereq_('../internals/is-constructor');
  15810. var tryToString = _dereq_('../internals/try-to-string');
  15811. var $TypeError = TypeError;
  15812. // `Assert: IsConstructor(argument) is true`
  15813. module.exports = function (argument) {
  15814. if (isConstructor(argument)) return argument;
  15815. throw $TypeError(tryToString(argument) + ' is not a constructor');
  15816. };
  15817. },{"../internals/is-constructor":265,"../internals/try-to-string":335}],175:[function(_dereq_,module,exports){
  15818. var isCallable = _dereq_('../internals/is-callable');
  15819. var $String = String;
  15820. var $TypeError = TypeError;
  15821. module.exports = function (argument) {
  15822. if (typeof argument == 'object' || isCallable(argument)) return argument;
  15823. throw $TypeError("Can't set " + $String(argument) + ' as a prototype');
  15824. };
  15825. },{"../internals/is-callable":264}],176:[function(_dereq_,module,exports){
  15826. module.exports = function () { /* empty */ };
  15827. },{}],177:[function(_dereq_,module,exports){
  15828. var isPrototypeOf = _dereq_('../internals/object-is-prototype-of');
  15829. var $TypeError = TypeError;
  15830. module.exports = function (it, Prototype) {
  15831. if (isPrototypeOf(Prototype, it)) return it;
  15832. throw $TypeError('Incorrect invocation');
  15833. };
  15834. },{"../internals/object-is-prototype-of":296}],178:[function(_dereq_,module,exports){
  15835. var isObject = _dereq_('../internals/is-object');
  15836. var $String = String;
  15837. var $TypeError = TypeError;
  15838. // `Assert: Type(argument) is Object`
  15839. module.exports = function (argument) {
  15840. if (isObject(argument)) return argument;
  15841. throw $TypeError($String(argument) + ' is not an object');
  15842. };
  15843. },{"../internals/is-object":269}],179:[function(_dereq_,module,exports){
  15844. // FF26- bug: ArrayBuffers are non-extensible, but Object.isExtensible does not report it
  15845. var fails = _dereq_('../internals/fails');
  15846. module.exports = fails(function () {
  15847. if (typeof ArrayBuffer == 'function') {
  15848. var buffer = new ArrayBuffer(8);
  15849. // eslint-disable-next-line es/no-object-isextensible, es/no-object-defineproperty -- safe
  15850. if (Object.isExtensible(buffer)) Object.defineProperty(buffer, 'a', { value: 8 });
  15851. }
  15852. });
  15853. },{"../internals/fails":235}],180:[function(_dereq_,module,exports){
  15854. 'use strict';
  15855. var $forEach = _dereq_('../internals/array-iteration').forEach;
  15856. var arrayMethodIsStrict = _dereq_('../internals/array-method-is-strict');
  15857. var STRICT_METHOD = arrayMethodIsStrict('forEach');
  15858. // `Array.prototype.forEach` method implementation
  15859. // https://tc39.es/ecma262/#sec-array.prototype.foreach
  15860. module.exports = !STRICT_METHOD ? function forEach(callbackfn /* , thisArg */) {
  15861. return $forEach(this, callbackfn, arguments.length > 1 ? arguments[1] : undefined);
  15862. // eslint-disable-next-line es/no-array-prototype-foreach -- safe
  15863. } : [].forEach;
  15864. },{"../internals/array-iteration":183,"../internals/array-method-is-strict":185}],181:[function(_dereq_,module,exports){
  15865. 'use strict';
  15866. var bind = _dereq_('../internals/function-bind-context');
  15867. var call = _dereq_('../internals/function-call');
  15868. var toObject = _dereq_('../internals/to-object');
  15869. var callWithSafeIterationClosing = _dereq_('../internals/call-with-safe-iteration-closing');
  15870. var isArrayIteratorMethod = _dereq_('../internals/is-array-iterator-method');
  15871. var isConstructor = _dereq_('../internals/is-constructor');
  15872. var lengthOfArrayLike = _dereq_('../internals/length-of-array-like');
  15873. var createProperty = _dereq_('../internals/create-property');
  15874. var getIterator = _dereq_('../internals/get-iterator');
  15875. var getIteratorMethod = _dereq_('../internals/get-iterator-method');
  15876. var $Array = Array;
  15877. // `Array.from` method implementation
  15878. // https://tc39.es/ecma262/#sec-array.from
  15879. module.exports = function from(arrayLike /* , mapfn = undefined, thisArg = undefined */) {
  15880. var O = toObject(arrayLike);
  15881. var IS_CONSTRUCTOR = isConstructor(this);
  15882. var argumentsLength = arguments.length;
  15883. var mapfn = argumentsLength > 1 ? arguments[1] : undefined;
  15884. var mapping = mapfn !== undefined;
  15885. if (mapping) mapfn = bind(mapfn, argumentsLength > 2 ? arguments[2] : undefined);
  15886. var iteratorMethod = getIteratorMethod(O);
  15887. var index = 0;
  15888. var length, result, step, iterator, next, value;
  15889. // if the target is not iterable or it's an array with the default iterator - use a simple case
  15890. if (iteratorMethod && !(this === $Array && isArrayIteratorMethod(iteratorMethod))) {
  15891. iterator = getIterator(O, iteratorMethod);
  15892. next = iterator.next;
  15893. result = IS_CONSTRUCTOR ? new this() : [];
  15894. for (;!(step = call(next, iterator)).done; index++) {
  15895. value = mapping ? callWithSafeIterationClosing(iterator, mapfn, [step.value, index], true) : step.value;
  15896. createProperty(result, index, value);
  15897. }
  15898. } else {
  15899. length = lengthOfArrayLike(O);
  15900. result = IS_CONSTRUCTOR ? new this(length) : $Array(length);
  15901. for (;length > index; index++) {
  15902. value = mapping ? mapfn(O[index], index) : O[index];
  15903. createProperty(result, index, value);
  15904. }
  15905. }
  15906. result.length = index;
  15907. return result;
  15908. };
  15909. },{"../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){
  15910. var toIndexedObject = _dereq_('../internals/to-indexed-object');
  15911. var toAbsoluteIndex = _dereq_('../internals/to-absolute-index');
  15912. var lengthOfArrayLike = _dereq_('../internals/length-of-array-like');
  15913. // `Array.prototype.{ indexOf, includes }` methods implementation
  15914. var createMethod = function (IS_INCLUDES) {
  15915. return function ($this, el, fromIndex) {
  15916. var O = toIndexedObject($this);
  15917. var length = lengthOfArrayLike(O);
  15918. var index = toAbsoluteIndex(fromIndex, length);
  15919. var value;
  15920. // Array#includes uses SameValueZero equality algorithm
  15921. // eslint-disable-next-line no-self-compare -- NaN check
  15922. if (IS_INCLUDES && el != el) while (length > index) {
  15923. value = O[index++];
  15924. // eslint-disable-next-line no-self-compare -- NaN check
  15925. if (value != value) return true;
  15926. // Array#indexOf ignores holes, Array#includes - not
  15927. } else for (;length > index; index++) {
  15928. if ((IS_INCLUDES || index in O) && O[index] === el) return IS_INCLUDES || index || 0;
  15929. } return !IS_INCLUDES && -1;
  15930. };
  15931. };
  15932. module.exports = {
  15933. // `Array.prototype.includes` method
  15934. // https://tc39.es/ecma262/#sec-array.prototype.includes
  15935. includes: createMethod(true),
  15936. // `Array.prototype.indexOf` method
  15937. // https://tc39.es/ecma262/#sec-array.prototype.indexof
  15938. indexOf: createMethod(false)
  15939. };
  15940. },{"../internals/length-of-array-like":279,"../internals/to-absolute-index":326,"../internals/to-indexed-object":327}],183:[function(_dereq_,module,exports){
  15941. var bind = _dereq_('../internals/function-bind-context');
  15942. var uncurryThis = _dereq_('../internals/function-uncurry-this');
  15943. var IndexedObject = _dereq_('../internals/indexed-object');
  15944. var toObject = _dereq_('../internals/to-object');
  15945. var lengthOfArrayLike = _dereq_('../internals/length-of-array-like');
  15946. var arraySpeciesCreate = _dereq_('../internals/array-species-create');
  15947. var push = uncurryThis([].push);
  15948. // `Array.prototype.{ forEach, map, filter, some, every, find, findIndex, filterReject }` methods implementation
  15949. var createMethod = function (TYPE) {
  15950. var IS_MAP = TYPE == 1;
  15951. var IS_FILTER = TYPE == 2;
  15952. var IS_SOME = TYPE == 3;
  15953. var IS_EVERY = TYPE == 4;
  15954. var IS_FIND_INDEX = TYPE == 6;
  15955. var IS_FILTER_REJECT = TYPE == 7;
  15956. var NO_HOLES = TYPE == 5 || IS_FIND_INDEX;
  15957. return function ($this, callbackfn, that, specificCreate) {
  15958. var O = toObject($this);
  15959. var self = IndexedObject(O);
  15960. var boundFunction = bind(callbackfn, that);
  15961. var length = lengthOfArrayLike(self);
  15962. var index = 0;
  15963. var create = specificCreate || arraySpeciesCreate;
  15964. var target = IS_MAP ? create($this, length) : IS_FILTER || IS_FILTER_REJECT ? create($this, 0) : undefined;
  15965. var value, result;
  15966. for (;length > index; index++) if (NO_HOLES || index in self) {
  15967. value = self[index];
  15968. result = boundFunction(value, index, O);
  15969. if (TYPE) {
  15970. if (IS_MAP) target[index] = result; // map
  15971. else if (result) switch (TYPE) {
  15972. case 3: return true; // some
  15973. case 5: return value; // find
  15974. case 6: return index; // findIndex
  15975. case 2: push(target, value); // filter
  15976. } else switch (TYPE) {
  15977. case 4: return false; // every
  15978. case 7: push(target, value); // filterReject
  15979. }
  15980. }
  15981. }
  15982. return IS_FIND_INDEX ? -1 : IS_SOME || IS_EVERY ? IS_EVERY : target;
  15983. };
  15984. };
  15985. module.exports = {
  15986. // `Array.prototype.forEach` method
  15987. // https://tc39.es/ecma262/#sec-array.prototype.foreach
  15988. forEach: createMethod(0),
  15989. // `Array.prototype.map` method
  15990. // https://tc39.es/ecma262/#sec-array.prototype.map
  15991. map: createMethod(1),
  15992. // `Array.prototype.filter` method
  15993. // https://tc39.es/ecma262/#sec-array.prototype.filter
  15994. filter: createMethod(2),
  15995. // `Array.prototype.some` method
  15996. // https://tc39.es/ecma262/#sec-array.prototype.some
  15997. some: createMethod(3),
  15998. // `Array.prototype.every` method
  15999. // https://tc39.es/ecma262/#sec-array.prototype.every
  16000. every: createMethod(4),
  16001. // `Array.prototype.find` method
  16002. // https://tc39.es/ecma262/#sec-array.prototype.find
  16003. find: createMethod(5),
  16004. // `Array.prototype.findIndex` method
  16005. // https://tc39.es/ecma262/#sec-array.prototype.findIndex
  16006. findIndex: createMethod(6),
  16007. // `Array.prototype.filterReject` method
  16008. // https://github.com/tc39/proposal-array-filtering
  16009. filterReject: createMethod(7)
  16010. };
  16011. },{"../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){
  16012. var fails = _dereq_('../internals/fails');
  16013. var wellKnownSymbol = _dereq_('../internals/well-known-symbol');
  16014. var V8_VERSION = _dereq_('../internals/engine-v8-version');
  16015. var SPECIES = wellKnownSymbol('species');
  16016. module.exports = function (METHOD_NAME) {
  16017. // We can't use this feature detection in V8 since it causes
  16018. // deoptimization and serious performance degradation
  16019. // https://github.com/zloirock/core-js/issues/677
  16020. return V8_VERSION >= 51 || !fails(function () {
  16021. var array = [];
  16022. var constructor = array.constructor = {};
  16023. constructor[SPECIES] = function () {
  16024. return { foo: 1 };
  16025. };
  16026. return array[METHOD_NAME](Boolean).foo !== 1;
  16027. });
  16028. };
  16029. },{"../internals/engine-v8-version":227,"../internals/fails":235,"../internals/well-known-symbol":343}],185:[function(_dereq_,module,exports){
  16030. 'use strict';
  16031. var fails = _dereq_('../internals/fails');
  16032. module.exports = function (METHOD_NAME, argument) {
  16033. var method = [][METHOD_NAME];
  16034. return !!method && fails(function () {
  16035. // eslint-disable-next-line no-useless-call -- required for testing
  16036. method.call(null, argument || function () { return 1; }, 1);
  16037. });
  16038. };
  16039. },{"../internals/fails":235}],186:[function(_dereq_,module,exports){
  16040. var aCallable = _dereq_('../internals/a-callable');
  16041. var toObject = _dereq_('../internals/to-object');
  16042. var IndexedObject = _dereq_('../internals/indexed-object');
  16043. var lengthOfArrayLike = _dereq_('../internals/length-of-array-like');
  16044. var $TypeError = TypeError;
  16045. // `Array.prototype.{ reduce, reduceRight }` methods implementation
  16046. var createMethod = function (IS_RIGHT) {
  16047. return function (that, callbackfn, argumentsLength, memo) {
  16048. aCallable(callbackfn);
  16049. var O = toObject(that);
  16050. var self = IndexedObject(O);
  16051. var length = lengthOfArrayLike(O);
  16052. var index = IS_RIGHT ? length - 1 : 0;
  16053. var i = IS_RIGHT ? -1 : 1;
  16054. if (argumentsLength < 2) while (true) {
  16055. if (index in self) {
  16056. memo = self[index];
  16057. index += i;
  16058. break;
  16059. }
  16060. index += i;
  16061. if (IS_RIGHT ? index < 0 : length <= index) {
  16062. throw $TypeError('Reduce of empty array with no initial value');
  16063. }
  16064. }
  16065. for (;IS_RIGHT ? index >= 0 : length > index; index += i) if (index in self) {
  16066. memo = callbackfn(memo, self[index], index, O);
  16067. }
  16068. return memo;
  16069. };
  16070. };
  16071. module.exports = {
  16072. // `Array.prototype.reduce` method
  16073. // https://tc39.es/ecma262/#sec-array.prototype.reduce
  16074. left: createMethod(false),
  16075. // `Array.prototype.reduceRight` method
  16076. // https://tc39.es/ecma262/#sec-array.prototype.reduceright
  16077. right: createMethod(true)
  16078. };
  16079. },{"../internals/a-callable":173,"../internals/indexed-object":257,"../internals/length-of-array-like":279,"../internals/to-object":330}],187:[function(_dereq_,module,exports){
  16080. 'use strict';
  16081. var DESCRIPTORS = _dereq_('../internals/descriptors');
  16082. var isArray = _dereq_('../internals/is-array');
  16083. var $TypeError = TypeError;
  16084. // eslint-disable-next-line es/no-object-getownpropertydescriptor -- safe
  16085. var getOwnPropertyDescriptor = Object.getOwnPropertyDescriptor;
  16086. // Safari < 13 does not throw an error in this case
  16087. var SILENT_ON_NON_WRITABLE_LENGTH_SET = DESCRIPTORS && !function () {
  16088. // makes no sense without proper strict mode support
  16089. if (this !== undefined) return true;
  16090. try {
  16091. // eslint-disable-next-line es/no-object-defineproperty -- safe
  16092. Object.defineProperty([], 'length', { writable: false }).length = 1;
  16093. } catch (error) {
  16094. return error instanceof TypeError;
  16095. }
  16096. }();
  16097. module.exports = SILENT_ON_NON_WRITABLE_LENGTH_SET ? function (O, length) {
  16098. if (isArray(O) && !getOwnPropertyDescriptor(O, 'length').writable) {
  16099. throw $TypeError('Cannot set read only .length');
  16100. } return O.length = length;
  16101. } : function (O, length) {
  16102. return O.length = length;
  16103. };
  16104. },{"../internals/descriptors":212,"../internals/is-array":263}],188:[function(_dereq_,module,exports){
  16105. var toAbsoluteIndex = _dereq_('../internals/to-absolute-index');
  16106. var lengthOfArrayLike = _dereq_('../internals/length-of-array-like');
  16107. var createProperty = _dereq_('../internals/create-property');
  16108. var $Array = Array;
  16109. var max = Math.max;
  16110. module.exports = function (O, start, end) {
  16111. var length = lengthOfArrayLike(O);
  16112. var k = toAbsoluteIndex(start, length);
  16113. var fin = toAbsoluteIndex(end === undefined ? length : end, length);
  16114. var result = $Array(max(fin - k, 0));
  16115. for (var n = 0; k < fin; k++, n++) createProperty(result, n, O[k]);
  16116. result.length = n;
  16117. return result;
  16118. };
  16119. },{"../internals/create-property":206,"../internals/length-of-array-like":279,"../internals/to-absolute-index":326}],189:[function(_dereq_,module,exports){
  16120. var uncurryThis = _dereq_('../internals/function-uncurry-this');
  16121. module.exports = uncurryThis([].slice);
  16122. },{"../internals/function-uncurry-this":245}],190:[function(_dereq_,module,exports){
  16123. var arraySlice = _dereq_('../internals/array-slice-simple');
  16124. var floor = Math.floor;
  16125. var mergeSort = function (array, comparefn) {
  16126. var length = array.length;
  16127. var middle = floor(length / 2);
  16128. return length < 8 ? insertionSort(array, comparefn) : merge(
  16129. array,
  16130. mergeSort(arraySlice(array, 0, middle), comparefn),
  16131. mergeSort(arraySlice(array, middle), comparefn),
  16132. comparefn
  16133. );
  16134. };
  16135. var insertionSort = function (array, comparefn) {
  16136. var length = array.length;
  16137. var i = 1;
  16138. var element, j;
  16139. while (i < length) {
  16140. j = i;
  16141. element = array[i];
  16142. while (j && comparefn(array[j - 1], element) > 0) {
  16143. array[j] = array[--j];
  16144. }
  16145. if (j !== i++) array[j] = element;
  16146. } return array;
  16147. };
  16148. var merge = function (array, left, right, comparefn) {
  16149. var llength = left.length;
  16150. var rlength = right.length;
  16151. var lindex = 0;
  16152. var rindex = 0;
  16153. while (lindex < llength || rindex < rlength) {
  16154. array[lindex + rindex] = (lindex < llength && rindex < rlength)
  16155. ? comparefn(left[lindex], right[rindex]) <= 0 ? left[lindex++] : right[rindex++]
  16156. : lindex < llength ? left[lindex++] : right[rindex++];
  16157. } return array;
  16158. };
  16159. module.exports = mergeSort;
  16160. },{"../internals/array-slice-simple":188}],191:[function(_dereq_,module,exports){
  16161. var isArray = _dereq_('../internals/is-array');
  16162. var isConstructor = _dereq_('../internals/is-constructor');
  16163. var isObject = _dereq_('../internals/is-object');
  16164. var wellKnownSymbol = _dereq_('../internals/well-known-symbol');
  16165. var SPECIES = wellKnownSymbol('species');
  16166. var $Array = Array;
  16167. // a part of `ArraySpeciesCreate` abstract operation
  16168. // https://tc39.es/ecma262/#sec-arrayspeciescreate
  16169. module.exports = function (originalArray) {
  16170. var C;
  16171. if (isArray(originalArray)) {
  16172. C = originalArray.constructor;
  16173. // cross-realm fallback
  16174. if (isConstructor(C) && (C === $Array || isArray(C.prototype))) C = undefined;
  16175. else if (isObject(C)) {
  16176. C = C[SPECIES];
  16177. if (C === null) C = undefined;
  16178. }
  16179. } return C === undefined ? $Array : C;
  16180. };
  16181. },{"../internals/is-array":263,"../internals/is-constructor":265,"../internals/is-object":269,"../internals/well-known-symbol":343}],192:[function(_dereq_,module,exports){
  16182. var arraySpeciesConstructor = _dereq_('../internals/array-species-constructor');
  16183. // `ArraySpeciesCreate` abstract operation
  16184. // https://tc39.es/ecma262/#sec-arrayspeciescreate
  16185. module.exports = function (originalArray, length) {
  16186. return new (arraySpeciesConstructor(originalArray))(length === 0 ? 0 : length);
  16187. };
  16188. },{"../internals/array-species-constructor":191}],193:[function(_dereq_,module,exports){
  16189. var anObject = _dereq_('../internals/an-object');
  16190. var iteratorClose = _dereq_('../internals/iterator-close');
  16191. // call something on iterator step with safe closing on error
  16192. module.exports = function (iterator, fn, value, ENTRIES) {
  16193. try {
  16194. return ENTRIES ? fn(anObject(value)[0], value[1]) : fn(value);
  16195. } catch (error) {
  16196. iteratorClose(iterator, 'throw', error);
  16197. }
  16198. };
  16199. },{"../internals/an-object":178,"../internals/iterator-close":274}],194:[function(_dereq_,module,exports){
  16200. var wellKnownSymbol = _dereq_('../internals/well-known-symbol');
  16201. var ITERATOR = wellKnownSymbol('iterator');
  16202. var SAFE_CLOSING = false;
  16203. try {
  16204. var called = 0;
  16205. var iteratorWithReturn = {
  16206. next: function () {
  16207. return { done: !!called++ };
  16208. },
  16209. 'return': function () {
  16210. SAFE_CLOSING = true;
  16211. }
  16212. };
  16213. iteratorWithReturn[ITERATOR] = function () {
  16214. return this;
  16215. };
  16216. // eslint-disable-next-line es/no-array-from, no-throw-literal -- required for testing
  16217. Array.from(iteratorWithReturn, function () { throw 2; });
  16218. } catch (error) { /* empty */ }
  16219. module.exports = function (exec, SKIP_CLOSING) {
  16220. if (!SKIP_CLOSING && !SAFE_CLOSING) return false;
  16221. var ITERATION_SUPPORT = false;
  16222. try {
  16223. var object = {};
  16224. object[ITERATOR] = function () {
  16225. return {
  16226. next: function () {
  16227. return { done: ITERATION_SUPPORT = true };
  16228. }
  16229. };
  16230. };
  16231. exec(object);
  16232. } catch (error) { /* empty */ }
  16233. return ITERATION_SUPPORT;
  16234. };
  16235. },{"../internals/well-known-symbol":343}],195:[function(_dereq_,module,exports){
  16236. var uncurryThis = _dereq_('../internals/function-uncurry-this');
  16237. var toString = uncurryThis({}.toString);
  16238. var stringSlice = uncurryThis(''.slice);
  16239. module.exports = function (it) {
  16240. return stringSlice(toString(it), 8, -1);
  16241. };
  16242. },{"../internals/function-uncurry-this":245}],196:[function(_dereq_,module,exports){
  16243. var TO_STRING_TAG_SUPPORT = _dereq_('../internals/to-string-tag-support');
  16244. var isCallable = _dereq_('../internals/is-callable');
  16245. var classofRaw = _dereq_('../internals/classof-raw');
  16246. var wellKnownSymbol = _dereq_('../internals/well-known-symbol');
  16247. var TO_STRING_TAG = wellKnownSymbol('toStringTag');
  16248. var $Object = Object;
  16249. // ES3 wrong here
  16250. var CORRECT_ARGUMENTS = classofRaw(function () { return arguments; }()) == 'Arguments';
  16251. // fallback for IE11 Script Access Denied error
  16252. var tryGet = function (it, key) {
  16253. try {
  16254. return it[key];
  16255. } catch (error) { /* empty */ }
  16256. };
  16257. // getting tag from ES6+ `Object.prototype.toString`
  16258. module.exports = TO_STRING_TAG_SUPPORT ? classofRaw : function (it) {
  16259. var O, tag, result;
  16260. return it === undefined ? 'Undefined' : it === null ? 'Null'
  16261. // @@toStringTag case
  16262. : typeof (tag = tryGet(O = $Object(it), TO_STRING_TAG)) == 'string' ? tag
  16263. // builtinTag case
  16264. : CORRECT_ARGUMENTS ? classofRaw(O)
  16265. // ES3 arguments fallback
  16266. : (result = classofRaw(O)) == 'Object' && isCallable(O.callee) ? 'Arguments' : result;
  16267. };
  16268. },{"../internals/classof-raw":195,"../internals/is-callable":264,"../internals/to-string-tag-support":333,"../internals/well-known-symbol":343}],197:[function(_dereq_,module,exports){
  16269. 'use strict';
  16270. var create = _dereq_('../internals/object-create');
  16271. var defineBuiltInAccessor = _dereq_('../internals/define-built-in-accessor');
  16272. var defineBuiltIns = _dereq_('../internals/define-built-ins');
  16273. var bind = _dereq_('../internals/function-bind-context');
  16274. var anInstance = _dereq_('../internals/an-instance');
  16275. var isNullOrUndefined = _dereq_('../internals/is-null-or-undefined');
  16276. var iterate = _dereq_('../internals/iterate');
  16277. var defineIterator = _dereq_('../internals/iterator-define');
  16278. var createIterResultObject = _dereq_('../internals/create-iter-result-object');
  16279. var setSpecies = _dereq_('../internals/set-species');
  16280. var DESCRIPTORS = _dereq_('../internals/descriptors');
  16281. var fastKey = _dereq_('../internals/internal-metadata').fastKey;
  16282. var InternalStateModule = _dereq_('../internals/internal-state');
  16283. var setInternalState = InternalStateModule.set;
  16284. var internalStateGetterFor = InternalStateModule.getterFor;
  16285. module.exports = {
  16286. getConstructor: function (wrapper, CONSTRUCTOR_NAME, IS_MAP, ADDER) {
  16287. var Constructor = wrapper(function (that, iterable) {
  16288. anInstance(that, Prototype);
  16289. setInternalState(that, {
  16290. type: CONSTRUCTOR_NAME,
  16291. index: create(null),
  16292. first: undefined,
  16293. last: undefined,
  16294. size: 0
  16295. });
  16296. if (!DESCRIPTORS) that.size = 0;
  16297. if (!isNullOrUndefined(iterable)) iterate(iterable, that[ADDER], { that: that, AS_ENTRIES: IS_MAP });
  16298. });
  16299. var Prototype = Constructor.prototype;
  16300. var getInternalState = internalStateGetterFor(CONSTRUCTOR_NAME);
  16301. var define = function (that, key, value) {
  16302. var state = getInternalState(that);
  16303. var entry = getEntry(that, key);
  16304. var previous, index;
  16305. // change existing entry
  16306. if (entry) {
  16307. entry.value = value;
  16308. // create new entry
  16309. } else {
  16310. state.last = entry = {
  16311. index: index = fastKey(key, true),
  16312. key: key,
  16313. value: value,
  16314. previous: previous = state.last,
  16315. next: undefined,
  16316. removed: false
  16317. };
  16318. if (!state.first) state.first = entry;
  16319. if (previous) previous.next = entry;
  16320. if (DESCRIPTORS) state.size++;
  16321. else that.size++;
  16322. // add to index
  16323. if (index !== 'F') state.index[index] = entry;
  16324. } return that;
  16325. };
  16326. var getEntry = function (that, key) {
  16327. var state = getInternalState(that);
  16328. // fast case
  16329. var index = fastKey(key);
  16330. var entry;
  16331. if (index !== 'F') return state.index[index];
  16332. // frozen object case
  16333. for (entry = state.first; entry; entry = entry.next) {
  16334. if (entry.key == key) return entry;
  16335. }
  16336. };
  16337. defineBuiltIns(Prototype, {
  16338. // `{ Map, Set }.prototype.clear()` methods
  16339. // https://tc39.es/ecma262/#sec-map.prototype.clear
  16340. // https://tc39.es/ecma262/#sec-set.prototype.clear
  16341. clear: function clear() {
  16342. var that = this;
  16343. var state = getInternalState(that);
  16344. var data = state.index;
  16345. var entry = state.first;
  16346. while (entry) {
  16347. entry.removed = true;
  16348. if (entry.previous) entry.previous = entry.previous.next = undefined;
  16349. delete data[entry.index];
  16350. entry = entry.next;
  16351. }
  16352. state.first = state.last = undefined;
  16353. if (DESCRIPTORS) state.size = 0;
  16354. else that.size = 0;
  16355. },
  16356. // `{ Map, Set }.prototype.delete(key)` methods
  16357. // https://tc39.es/ecma262/#sec-map.prototype.delete
  16358. // https://tc39.es/ecma262/#sec-set.prototype.delete
  16359. 'delete': function (key) {
  16360. var that = this;
  16361. var state = getInternalState(that);
  16362. var entry = getEntry(that, key);
  16363. if (entry) {
  16364. var next = entry.next;
  16365. var prev = entry.previous;
  16366. delete state.index[entry.index];
  16367. entry.removed = true;
  16368. if (prev) prev.next = next;
  16369. if (next) next.previous = prev;
  16370. if (state.first == entry) state.first = next;
  16371. if (state.last == entry) state.last = prev;
  16372. if (DESCRIPTORS) state.size--;
  16373. else that.size--;
  16374. } return !!entry;
  16375. },
  16376. // `{ Map, Set }.prototype.forEach(callbackfn, thisArg = undefined)` methods
  16377. // https://tc39.es/ecma262/#sec-map.prototype.foreach
  16378. // https://tc39.es/ecma262/#sec-set.prototype.foreach
  16379. forEach: function forEach(callbackfn /* , that = undefined */) {
  16380. var state = getInternalState(this);
  16381. var boundFunction = bind(callbackfn, arguments.length > 1 ? arguments[1] : undefined);
  16382. var entry;
  16383. while (entry = entry ? entry.next : state.first) {
  16384. boundFunction(entry.value, entry.key, this);
  16385. // revert to the last existing entry
  16386. while (entry && entry.removed) entry = entry.previous;
  16387. }
  16388. },
  16389. // `{ Map, Set}.prototype.has(key)` methods
  16390. // https://tc39.es/ecma262/#sec-map.prototype.has
  16391. // https://tc39.es/ecma262/#sec-set.prototype.has
  16392. has: function has(key) {
  16393. return !!getEntry(this, key);
  16394. }
  16395. });
  16396. defineBuiltIns(Prototype, IS_MAP ? {
  16397. // `Map.prototype.get(key)` method
  16398. // https://tc39.es/ecma262/#sec-map.prototype.get
  16399. get: function get(key) {
  16400. var entry = getEntry(this, key);
  16401. return entry && entry.value;
  16402. },
  16403. // `Map.prototype.set(key, value)` method
  16404. // https://tc39.es/ecma262/#sec-map.prototype.set
  16405. set: function set(key, value) {
  16406. return define(this, key === 0 ? 0 : key, value);
  16407. }
  16408. } : {
  16409. // `Set.prototype.add(value)` method
  16410. // https://tc39.es/ecma262/#sec-set.prototype.add
  16411. add: function add(value) {
  16412. return define(this, value = value === 0 ? 0 : value, value);
  16413. }
  16414. });
  16415. if (DESCRIPTORS) defineBuiltInAccessor(Prototype, 'size', {
  16416. configurable: true,
  16417. get: function () {
  16418. return getInternalState(this).size;
  16419. }
  16420. });
  16421. return Constructor;
  16422. },
  16423. setStrong: function (Constructor, CONSTRUCTOR_NAME, IS_MAP) {
  16424. var ITERATOR_NAME = CONSTRUCTOR_NAME + ' Iterator';
  16425. var getInternalCollectionState = internalStateGetterFor(CONSTRUCTOR_NAME);
  16426. var getInternalIteratorState = internalStateGetterFor(ITERATOR_NAME);
  16427. // `{ Map, Set }.prototype.{ keys, values, entries, @@iterator }()` methods
  16428. // https://tc39.es/ecma262/#sec-map.prototype.entries
  16429. // https://tc39.es/ecma262/#sec-map.prototype.keys
  16430. // https://tc39.es/ecma262/#sec-map.prototype.values
  16431. // https://tc39.es/ecma262/#sec-map.prototype-@@iterator
  16432. // https://tc39.es/ecma262/#sec-set.prototype.entries
  16433. // https://tc39.es/ecma262/#sec-set.prototype.keys
  16434. // https://tc39.es/ecma262/#sec-set.prototype.values
  16435. // https://tc39.es/ecma262/#sec-set.prototype-@@iterator
  16436. defineIterator(Constructor, CONSTRUCTOR_NAME, function (iterated, kind) {
  16437. setInternalState(this, {
  16438. type: ITERATOR_NAME,
  16439. target: iterated,
  16440. state: getInternalCollectionState(iterated),
  16441. kind: kind,
  16442. last: undefined
  16443. });
  16444. }, function () {
  16445. var state = getInternalIteratorState(this);
  16446. var kind = state.kind;
  16447. var entry = state.last;
  16448. // revert to the last existing entry
  16449. while (entry && entry.removed) entry = entry.previous;
  16450. // get next entry
  16451. if (!state.target || !(state.last = entry = entry ? entry.next : state.state.first)) {
  16452. // or finish the iteration
  16453. state.target = undefined;
  16454. return createIterResultObject(undefined, true);
  16455. }
  16456. // return step by kind
  16457. if (kind == 'keys') return createIterResultObject(entry.key, false);
  16458. if (kind == 'values') return createIterResultObject(entry.value, false);
  16459. return createIterResultObject([entry.key, entry.value], false);
  16460. }, IS_MAP ? 'entries' : 'values', !IS_MAP, true);
  16461. // `{ Map, Set }.prototype[@@species]` accessors
  16462. // https://tc39.es/ecma262/#sec-get-map-@@species
  16463. // https://tc39.es/ecma262/#sec-get-set-@@species
  16464. setSpecies(CONSTRUCTOR_NAME);
  16465. }
  16466. };
  16467. },{"../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){
  16468. 'use strict';
  16469. var uncurryThis = _dereq_('../internals/function-uncurry-this');
  16470. var defineBuiltIns = _dereq_('../internals/define-built-ins');
  16471. var getWeakData = _dereq_('../internals/internal-metadata').getWeakData;
  16472. var anInstance = _dereq_('../internals/an-instance');
  16473. var anObject = _dereq_('../internals/an-object');
  16474. var isNullOrUndefined = _dereq_('../internals/is-null-or-undefined');
  16475. var isObject = _dereq_('../internals/is-object');
  16476. var iterate = _dereq_('../internals/iterate');
  16477. var ArrayIterationModule = _dereq_('../internals/array-iteration');
  16478. var hasOwn = _dereq_('../internals/has-own-property');
  16479. var InternalStateModule = _dereq_('../internals/internal-state');
  16480. var setInternalState = InternalStateModule.set;
  16481. var internalStateGetterFor = InternalStateModule.getterFor;
  16482. var find = ArrayIterationModule.find;
  16483. var findIndex = ArrayIterationModule.findIndex;
  16484. var splice = uncurryThis([].splice);
  16485. var id = 0;
  16486. // fallback for uncaught frozen keys
  16487. var uncaughtFrozenStore = function (state) {
  16488. return state.frozen || (state.frozen = new UncaughtFrozenStore());
  16489. };
  16490. var UncaughtFrozenStore = function () {
  16491. this.entries = [];
  16492. };
  16493. var findUncaughtFrozen = function (store, key) {
  16494. return find(store.entries, function (it) {
  16495. return it[0] === key;
  16496. });
  16497. };
  16498. UncaughtFrozenStore.prototype = {
  16499. get: function (key) {
  16500. var entry = findUncaughtFrozen(this, key);
  16501. if (entry) return entry[1];
  16502. },
  16503. has: function (key) {
  16504. return !!findUncaughtFrozen(this, key);
  16505. },
  16506. set: function (key, value) {
  16507. var entry = findUncaughtFrozen(this, key);
  16508. if (entry) entry[1] = value;
  16509. else this.entries.push([key, value]);
  16510. },
  16511. 'delete': function (key) {
  16512. var index = findIndex(this.entries, function (it) {
  16513. return it[0] === key;
  16514. });
  16515. if (~index) splice(this.entries, index, 1);
  16516. return !!~index;
  16517. }
  16518. };
  16519. module.exports = {
  16520. getConstructor: function (wrapper, CONSTRUCTOR_NAME, IS_MAP, ADDER) {
  16521. var Constructor = wrapper(function (that, iterable) {
  16522. anInstance(that, Prototype);
  16523. setInternalState(that, {
  16524. type: CONSTRUCTOR_NAME,
  16525. id: id++,
  16526. frozen: undefined
  16527. });
  16528. if (!isNullOrUndefined(iterable)) iterate(iterable, that[ADDER], { that: that, AS_ENTRIES: IS_MAP });
  16529. });
  16530. var Prototype = Constructor.prototype;
  16531. var getInternalState = internalStateGetterFor(CONSTRUCTOR_NAME);
  16532. var define = function (that, key, value) {
  16533. var state = getInternalState(that);
  16534. var data = getWeakData(anObject(key), true);
  16535. if (data === true) uncaughtFrozenStore(state).set(key, value);
  16536. else data[state.id] = value;
  16537. return that;
  16538. };
  16539. defineBuiltIns(Prototype, {
  16540. // `{ WeakMap, WeakSet }.prototype.delete(key)` methods
  16541. // https://tc39.es/ecma262/#sec-weakmap.prototype.delete
  16542. // https://tc39.es/ecma262/#sec-weakset.prototype.delete
  16543. 'delete': function (key) {
  16544. var state = getInternalState(this);
  16545. if (!isObject(key)) return false;
  16546. var data = getWeakData(key);
  16547. if (data === true) return uncaughtFrozenStore(state)['delete'](key);
  16548. return data && hasOwn(data, state.id) && delete data[state.id];
  16549. },
  16550. // `{ WeakMap, WeakSet }.prototype.has(key)` methods
  16551. // https://tc39.es/ecma262/#sec-weakmap.prototype.has
  16552. // https://tc39.es/ecma262/#sec-weakset.prototype.has
  16553. has: function has(key) {
  16554. var state = getInternalState(this);
  16555. if (!isObject(key)) return false;
  16556. var data = getWeakData(key);
  16557. if (data === true) return uncaughtFrozenStore(state).has(key);
  16558. return data && hasOwn(data, state.id);
  16559. }
  16560. });
  16561. defineBuiltIns(Prototype, IS_MAP ? {
  16562. // `WeakMap.prototype.get(key)` method
  16563. // https://tc39.es/ecma262/#sec-weakmap.prototype.get
  16564. get: function get(key) {
  16565. var state = getInternalState(this);
  16566. if (isObject(key)) {
  16567. var data = getWeakData(key);
  16568. if (data === true) return uncaughtFrozenStore(state).get(key);
  16569. return data ? data[state.id] : undefined;
  16570. }
  16571. },
  16572. // `WeakMap.prototype.set(key, value)` method
  16573. // https://tc39.es/ecma262/#sec-weakmap.prototype.set
  16574. set: function set(key, value) {
  16575. return define(this, key, value);
  16576. }
  16577. } : {
  16578. // `WeakSet.prototype.add(value)` method
  16579. // https://tc39.es/ecma262/#sec-weakset.prototype.add
  16580. add: function add(value) {
  16581. return define(this, value, true);
  16582. }
  16583. });
  16584. return Constructor;
  16585. }
  16586. };
  16587. },{"../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){
  16588. 'use strict';
  16589. var $ = _dereq_('../internals/export');
  16590. var global = _dereq_('../internals/global');
  16591. var InternalMetadataModule = _dereq_('../internals/internal-metadata');
  16592. var fails = _dereq_('../internals/fails');
  16593. var createNonEnumerableProperty = _dereq_('../internals/create-non-enumerable-property');
  16594. var iterate = _dereq_('../internals/iterate');
  16595. var anInstance = _dereq_('../internals/an-instance');
  16596. var isCallable = _dereq_('../internals/is-callable');
  16597. var isObject = _dereq_('../internals/is-object');
  16598. var setToStringTag = _dereq_('../internals/set-to-string-tag');
  16599. var defineProperty = _dereq_('../internals/object-define-property').f;
  16600. var forEach = _dereq_('../internals/array-iteration').forEach;
  16601. var DESCRIPTORS = _dereq_('../internals/descriptors');
  16602. var InternalStateModule = _dereq_('../internals/internal-state');
  16603. var setInternalState = InternalStateModule.set;
  16604. var internalStateGetterFor = InternalStateModule.getterFor;
  16605. module.exports = function (CONSTRUCTOR_NAME, wrapper, common) {
  16606. var IS_MAP = CONSTRUCTOR_NAME.indexOf('Map') !== -1;
  16607. var IS_WEAK = CONSTRUCTOR_NAME.indexOf('Weak') !== -1;
  16608. var ADDER = IS_MAP ? 'set' : 'add';
  16609. var NativeConstructor = global[CONSTRUCTOR_NAME];
  16610. var NativePrototype = NativeConstructor && NativeConstructor.prototype;
  16611. var exported = {};
  16612. var Constructor;
  16613. if (!DESCRIPTORS || !isCallable(NativeConstructor)
  16614. || !(IS_WEAK || NativePrototype.forEach && !fails(function () { new NativeConstructor().entries().next(); }))
  16615. ) {
  16616. // create collection constructor
  16617. Constructor = common.getConstructor(wrapper, CONSTRUCTOR_NAME, IS_MAP, ADDER);
  16618. InternalMetadataModule.enable();
  16619. } else {
  16620. Constructor = wrapper(function (target, iterable) {
  16621. setInternalState(anInstance(target, Prototype), {
  16622. type: CONSTRUCTOR_NAME,
  16623. collection: new NativeConstructor()
  16624. });
  16625. if (iterable != undefined) iterate(iterable, target[ADDER], { that: target, AS_ENTRIES: IS_MAP });
  16626. });
  16627. var Prototype = Constructor.prototype;
  16628. var getInternalState = internalStateGetterFor(CONSTRUCTOR_NAME);
  16629. forEach(['add', 'clear', 'delete', 'forEach', 'get', 'has', 'set', 'keys', 'values', 'entries'], function (KEY) {
  16630. var IS_ADDER = KEY == 'add' || KEY == 'set';
  16631. if (KEY in NativePrototype && !(IS_WEAK && KEY == 'clear')) {
  16632. createNonEnumerableProperty(Prototype, KEY, function (a, b) {
  16633. var collection = getInternalState(this).collection;
  16634. if (!IS_ADDER && IS_WEAK && !isObject(a)) return KEY == 'get' ? undefined : false;
  16635. var result = collection[KEY](a === 0 ? 0 : a, b);
  16636. return IS_ADDER ? this : result;
  16637. });
  16638. }
  16639. });
  16640. IS_WEAK || defineProperty(Prototype, 'size', {
  16641. configurable: true,
  16642. get: function () {
  16643. return getInternalState(this).collection.size;
  16644. }
  16645. });
  16646. }
  16647. setToStringTag(Constructor, CONSTRUCTOR_NAME, false, true);
  16648. exported[CONSTRUCTOR_NAME] = Constructor;
  16649. $({ global: true, forced: true }, exported);
  16650. if (!IS_WEAK) common.setStrong(Constructor, CONSTRUCTOR_NAME, IS_MAP);
  16651. return Constructor;
  16652. };
  16653. },{"../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){
  16654. var hasOwn = _dereq_('../internals/has-own-property');
  16655. var ownKeys = _dereq_('../internals/own-keys');
  16656. var getOwnPropertyDescriptorModule = _dereq_('../internals/object-get-own-property-descriptor');
  16657. var definePropertyModule = _dereq_('../internals/object-define-property');
  16658. module.exports = function (target, source, exceptions) {
  16659. var keys = ownKeys(source);
  16660. var defineProperty = definePropertyModule.f;
  16661. var getOwnPropertyDescriptor = getOwnPropertyDescriptorModule.f;
  16662. for (var i = 0; i < keys.length; i++) {
  16663. var key = keys[i];
  16664. if (!hasOwn(target, key) && !(exceptions && hasOwn(exceptions, key))) {
  16665. defineProperty(target, key, getOwnPropertyDescriptor(source, key));
  16666. }
  16667. }
  16668. };
  16669. },{"../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){
  16670. var wellKnownSymbol = _dereq_('../internals/well-known-symbol');
  16671. var MATCH = wellKnownSymbol('match');
  16672. module.exports = function (METHOD_NAME) {
  16673. var regexp = /./;
  16674. try {
  16675. '/./'[METHOD_NAME](regexp);
  16676. } catch (error1) {
  16677. try {
  16678. regexp[MATCH] = false;
  16679. return '/./'[METHOD_NAME](regexp);
  16680. } catch (error2) { /* empty */ }
  16681. } return false;
  16682. };
  16683. },{"../internals/well-known-symbol":343}],202:[function(_dereq_,module,exports){
  16684. var fails = _dereq_('../internals/fails');
  16685. module.exports = !fails(function () {
  16686. function F() { /* empty */ }
  16687. F.prototype.constructor = null;
  16688. // eslint-disable-next-line es/no-object-getprototypeof -- required for testing
  16689. return Object.getPrototypeOf(new F()) !== F.prototype;
  16690. });
  16691. },{"../internals/fails":235}],203:[function(_dereq_,module,exports){
  16692. // `CreateIterResultObject` abstract operation
  16693. // https://tc39.es/ecma262/#sec-createiterresultobject
  16694. module.exports = function (value, done) {
  16695. return { value: value, done: done };
  16696. };
  16697. },{}],204:[function(_dereq_,module,exports){
  16698. var DESCRIPTORS = _dereq_('../internals/descriptors');
  16699. var definePropertyModule = _dereq_('../internals/object-define-property');
  16700. var createPropertyDescriptor = _dereq_('../internals/create-property-descriptor');
  16701. module.exports = DESCRIPTORS ? function (object, key, value) {
  16702. return definePropertyModule.f(object, key, createPropertyDescriptor(1, value));
  16703. } : function (object, key, value) {
  16704. object[key] = value;
  16705. return object;
  16706. };
  16707. },{"../internals/create-property-descriptor":205,"../internals/descriptors":212,"../internals/object-define-property":289}],205:[function(_dereq_,module,exports){
  16708. module.exports = function (bitmap, value) {
  16709. return {
  16710. enumerable: !(bitmap & 1),
  16711. configurable: !(bitmap & 2),
  16712. writable: !(bitmap & 4),
  16713. value: value
  16714. };
  16715. };
  16716. },{}],206:[function(_dereq_,module,exports){
  16717. 'use strict';
  16718. var toPropertyKey = _dereq_('../internals/to-property-key');
  16719. var definePropertyModule = _dereq_('../internals/object-define-property');
  16720. var createPropertyDescriptor = _dereq_('../internals/create-property-descriptor');
  16721. module.exports = function (object, key, value) {
  16722. var propertyKey = toPropertyKey(key);
  16723. if (propertyKey in object) definePropertyModule.f(object, propertyKey, createPropertyDescriptor(0, value));
  16724. else object[propertyKey] = value;
  16725. };
  16726. },{"../internals/create-property-descriptor":205,"../internals/object-define-property":289,"../internals/to-property-key":332}],207:[function(_dereq_,module,exports){
  16727. var defineProperty = _dereq_('../internals/object-define-property');
  16728. module.exports = function (target, name, descriptor) {
  16729. return defineProperty.f(target, name, descriptor);
  16730. };
  16731. },{"../internals/object-define-property":289}],208:[function(_dereq_,module,exports){
  16732. var createNonEnumerableProperty = _dereq_('../internals/create-non-enumerable-property');
  16733. module.exports = function (target, key, value, options) {
  16734. if (options && options.enumerable) target[key] = value;
  16735. else createNonEnumerableProperty(target, key, value);
  16736. return target;
  16737. };
  16738. },{"../internals/create-non-enumerable-property":204}],209:[function(_dereq_,module,exports){
  16739. var defineBuiltIn = _dereq_('../internals/define-built-in');
  16740. module.exports = function (target, src, options) {
  16741. for (var key in src) {
  16742. if (options && options.unsafe && target[key]) target[key] = src[key];
  16743. else defineBuiltIn(target, key, src[key], options);
  16744. } return target;
  16745. };
  16746. },{"../internals/define-built-in":208}],210:[function(_dereq_,module,exports){
  16747. var global = _dereq_('../internals/global');
  16748. // eslint-disable-next-line es/no-object-defineproperty -- safe
  16749. var defineProperty = Object.defineProperty;
  16750. module.exports = function (key, value) {
  16751. try {
  16752. defineProperty(global, key, { value: value, configurable: true, writable: true });
  16753. } catch (error) {
  16754. global[key] = value;
  16755. } return value;
  16756. };
  16757. },{"../internals/global":251}],211:[function(_dereq_,module,exports){
  16758. 'use strict';
  16759. var tryToString = _dereq_('../internals/try-to-string');
  16760. var $TypeError = TypeError;
  16761. module.exports = function (O, P) {
  16762. if (!delete O[P]) throw $TypeError('Cannot delete property ' + tryToString(P) + ' of ' + tryToString(O));
  16763. };
  16764. },{"../internals/try-to-string":335}],212:[function(_dereq_,module,exports){
  16765. var fails = _dereq_('../internals/fails');
  16766. // Detect IE8's incomplete defineProperty implementation
  16767. module.exports = !fails(function () {
  16768. // eslint-disable-next-line es/no-object-defineproperty -- required for testing
  16769. return Object.defineProperty({}, 1, { get: function () { return 7; } })[1] != 7;
  16770. });
  16771. },{"../internals/fails":235}],213:[function(_dereq_,module,exports){
  16772. var documentAll = typeof document == 'object' && document.all;
  16773. // https://tc39.es/ecma262/#sec-IsHTMLDDA-internal-slot
  16774. // eslint-disable-next-line unicorn/no-typeof-undefined -- required for testing
  16775. var IS_HTMLDDA = typeof documentAll == 'undefined' && documentAll !== undefined;
  16776. module.exports = {
  16777. all: documentAll,
  16778. IS_HTMLDDA: IS_HTMLDDA
  16779. };
  16780. },{}],214:[function(_dereq_,module,exports){
  16781. var global = _dereq_('../internals/global');
  16782. var isObject = _dereq_('../internals/is-object');
  16783. var document = global.document;
  16784. // typeof document.createElement is 'object' in old IE
  16785. var EXISTS = isObject(document) && isObject(document.createElement);
  16786. module.exports = function (it) {
  16787. return EXISTS ? document.createElement(it) : {};
  16788. };
  16789. },{"../internals/global":251,"../internals/is-object":269}],215:[function(_dereq_,module,exports){
  16790. var $TypeError = TypeError;
  16791. var MAX_SAFE_INTEGER = 0x1FFFFFFFFFFFFF; // 2 ** 53 - 1 == 9007199254740991
  16792. module.exports = function (it) {
  16793. if (it > MAX_SAFE_INTEGER) throw $TypeError('Maximum allowed index exceeded');
  16794. return it;
  16795. };
  16796. },{}],216:[function(_dereq_,module,exports){
  16797. // iterable DOM collections
  16798. // flag - `iterable` interface - 'entries', 'keys', 'values', 'forEach' methods
  16799. module.exports = {
  16800. CSSRuleList: 0,
  16801. CSSStyleDeclaration: 0,
  16802. CSSValueList: 0,
  16803. ClientRectList: 0,
  16804. DOMRectList: 0,
  16805. DOMStringList: 0,
  16806. DOMTokenList: 1,
  16807. DataTransferItemList: 0,
  16808. FileList: 0,
  16809. HTMLAllCollection: 0,
  16810. HTMLCollection: 0,
  16811. HTMLFormElement: 0,
  16812. HTMLSelectElement: 0,
  16813. MediaList: 0,
  16814. MimeTypeArray: 0,
  16815. NamedNodeMap: 0,
  16816. NodeList: 1,
  16817. PaintRequestList: 0,
  16818. Plugin: 0,
  16819. PluginArray: 0,
  16820. SVGLengthList: 0,
  16821. SVGNumberList: 0,
  16822. SVGPathSegList: 0,
  16823. SVGPointList: 0,
  16824. SVGStringList: 0,
  16825. SVGTransformList: 0,
  16826. SourceBufferList: 0,
  16827. StyleSheetList: 0,
  16828. TextTrackCueList: 0,
  16829. TextTrackList: 0,
  16830. TouchList: 0
  16831. };
  16832. },{}],217:[function(_dereq_,module,exports){
  16833. var userAgent = _dereq_('../internals/engine-user-agent');
  16834. var firefox = userAgent.match(/firefox\/(\d+)/i);
  16835. module.exports = !!firefox && +firefox[1];
  16836. },{"../internals/engine-user-agent":226}],218:[function(_dereq_,module,exports){
  16837. var IS_DENO = _dereq_('../internals/engine-is-deno');
  16838. var IS_NODE = _dereq_('../internals/engine-is-node');
  16839. module.exports = !IS_DENO && !IS_NODE
  16840. && typeof window == 'object'
  16841. && typeof document == 'object';
  16842. },{"../internals/engine-is-deno":220,"../internals/engine-is-node":224}],219:[function(_dereq_,module,exports){
  16843. /* global Bun -- Deno case */
  16844. module.exports = typeof Bun == 'function' && Bun && typeof Bun.version == 'string';
  16845. },{}],220:[function(_dereq_,module,exports){
  16846. /* global Deno -- Deno case */
  16847. module.exports = typeof Deno == 'object' && Deno && typeof Deno.version == 'object';
  16848. },{}],221:[function(_dereq_,module,exports){
  16849. var UA = _dereq_('../internals/engine-user-agent');
  16850. module.exports = /MSIE|Trident/.test(UA);
  16851. },{"../internals/engine-user-agent":226}],222:[function(_dereq_,module,exports){
  16852. var userAgent = _dereq_('../internals/engine-user-agent');
  16853. module.exports = /ipad|iphone|ipod/i.test(userAgent) && typeof Pebble != 'undefined';
  16854. },{"../internals/engine-user-agent":226}],223:[function(_dereq_,module,exports){
  16855. var userAgent = _dereq_('../internals/engine-user-agent');
  16856. // eslint-disable-next-line redos/no-vulnerable -- safe
  16857. module.exports = /(?:ipad|iphone|ipod).*applewebkit/i.test(userAgent);
  16858. },{"../internals/engine-user-agent":226}],224:[function(_dereq_,module,exports){
  16859. (function (process){(function (){
  16860. var classof = _dereq_('../internals/classof-raw');
  16861. module.exports = typeof process != 'undefined' && classof(process) == 'process';
  16862. }).call(this)}).call(this,_dereq_('_process'))
  16863. },{"../internals/classof-raw":195,"_process":107}],225:[function(_dereq_,module,exports){
  16864. var userAgent = _dereq_('../internals/engine-user-agent');
  16865. module.exports = /web0s(?!.*chrome)/i.test(userAgent);
  16866. },{"../internals/engine-user-agent":226}],226:[function(_dereq_,module,exports){
  16867. module.exports = typeof navigator != 'undefined' && String(navigator.userAgent) || '';
  16868. },{}],227:[function(_dereq_,module,exports){
  16869. var global = _dereq_('../internals/global');
  16870. var userAgent = _dereq_('../internals/engine-user-agent');
  16871. var process = global.process;
  16872. var Deno = global.Deno;
  16873. var versions = process && process.versions || Deno && Deno.version;
  16874. var v8 = versions && versions.v8;
  16875. var match, version;
  16876. if (v8) {
  16877. match = v8.split('.');
  16878. // in old Chrome, versions of V8 isn't V8 = Chrome / 10
  16879. // but their correct versions are not interesting for us
  16880. version = match[0] > 0 && match[0] < 4 ? 1 : +(match[0] + match[1]);
  16881. }
  16882. // BrowserFS NodeJS `process` polyfill incorrectly set `.v8` to `0.0`
  16883. // so check `userAgent` even if `.v8` exists, but 0
  16884. if (!version && userAgent) {
  16885. match = userAgent.match(/Edge\/(\d+)/);
  16886. if (!match || match[1] >= 74) {
  16887. match = userAgent.match(/Chrome\/(\d+)/);
  16888. if (match) version = +match[1];
  16889. }
  16890. }
  16891. module.exports = version;
  16892. },{"../internals/engine-user-agent":226,"../internals/global":251}],228:[function(_dereq_,module,exports){
  16893. var userAgent = _dereq_('../internals/engine-user-agent');
  16894. var webkit = userAgent.match(/AppleWebKit\/(\d+)\./);
  16895. module.exports = !!webkit && +webkit[1];
  16896. },{"../internals/engine-user-agent":226}],229:[function(_dereq_,module,exports){
  16897. var path = _dereq_('../internals/path');
  16898. module.exports = function (CONSTRUCTOR) {
  16899. return path[CONSTRUCTOR + 'Prototype'];
  16900. };
  16901. },{"../internals/path":305}],230:[function(_dereq_,module,exports){
  16902. // IE8- don't enum bug keys
  16903. module.exports = [
  16904. 'constructor',
  16905. 'hasOwnProperty',
  16906. 'isPrototypeOf',
  16907. 'propertyIsEnumerable',
  16908. 'toLocaleString',
  16909. 'toString',
  16910. 'valueOf'
  16911. ];
  16912. },{}],231:[function(_dereq_,module,exports){
  16913. var uncurryThis = _dereq_('../internals/function-uncurry-this');
  16914. var $Error = Error;
  16915. var replace = uncurryThis(''.replace);
  16916. var TEST = (function (arg) { return String($Error(arg).stack); })('zxcasd');
  16917. // eslint-disable-next-line redos/no-vulnerable -- safe
  16918. var V8_OR_CHAKRA_STACK_ENTRY = /\n\s*at [^:]*:[^\n]*/;
  16919. var IS_V8_OR_CHAKRA_STACK = V8_OR_CHAKRA_STACK_ENTRY.test(TEST);
  16920. module.exports = function (stack, dropEntries) {
  16921. if (IS_V8_OR_CHAKRA_STACK && typeof stack == 'string' && !$Error.prepareStackTrace) {
  16922. while (dropEntries--) stack = replace(stack, V8_OR_CHAKRA_STACK_ENTRY, '');
  16923. } return stack;
  16924. };
  16925. },{"../internals/function-uncurry-this":245}],232:[function(_dereq_,module,exports){
  16926. var createNonEnumerableProperty = _dereq_('../internals/create-non-enumerable-property');
  16927. var clearErrorStack = _dereq_('../internals/error-stack-clear');
  16928. var ERROR_STACK_INSTALLABLE = _dereq_('../internals/error-stack-installable');
  16929. // non-standard V8
  16930. var captureStackTrace = Error.captureStackTrace;
  16931. module.exports = function (error, C, stack, dropEntries) {
  16932. if (ERROR_STACK_INSTALLABLE) {
  16933. if (captureStackTrace) captureStackTrace(error, C);
  16934. else createNonEnumerableProperty(error, 'stack', clearErrorStack(stack, dropEntries));
  16935. }
  16936. };
  16937. },{"../internals/create-non-enumerable-property":204,"../internals/error-stack-clear":231,"../internals/error-stack-installable":233}],233:[function(_dereq_,module,exports){
  16938. var fails = _dereq_('../internals/fails');
  16939. var createPropertyDescriptor = _dereq_('../internals/create-property-descriptor');
  16940. module.exports = !fails(function () {
  16941. var error = Error('a');
  16942. if (!('stack' in error)) return true;
  16943. // eslint-disable-next-line es/no-object-defineproperty -- safe
  16944. Object.defineProperty(error, 'stack', createPropertyDescriptor(1, 7));
  16945. return error.stack !== 7;
  16946. });
  16947. },{"../internals/create-property-descriptor":205,"../internals/fails":235}],234:[function(_dereq_,module,exports){
  16948. 'use strict';
  16949. var global = _dereq_('../internals/global');
  16950. var apply = _dereq_('../internals/function-apply');
  16951. var uncurryThis = _dereq_('../internals/function-uncurry-this-clause');
  16952. var isCallable = _dereq_('../internals/is-callable');
  16953. var getOwnPropertyDescriptor = _dereq_('../internals/object-get-own-property-descriptor').f;
  16954. var isForced = _dereq_('../internals/is-forced');
  16955. var path = _dereq_('../internals/path');
  16956. var bind = _dereq_('../internals/function-bind-context');
  16957. var createNonEnumerableProperty = _dereq_('../internals/create-non-enumerable-property');
  16958. var hasOwn = _dereq_('../internals/has-own-property');
  16959. var wrapConstructor = function (NativeConstructor) {
  16960. var Wrapper = function (a, b, c) {
  16961. if (this instanceof Wrapper) {
  16962. switch (arguments.length) {
  16963. case 0: return new NativeConstructor();
  16964. case 1: return new NativeConstructor(a);
  16965. case 2: return new NativeConstructor(a, b);
  16966. } return new NativeConstructor(a, b, c);
  16967. } return apply(NativeConstructor, this, arguments);
  16968. };
  16969. Wrapper.prototype = NativeConstructor.prototype;
  16970. return Wrapper;
  16971. };
  16972. /*
  16973. options.target - name of the target object
  16974. options.global - target is the global object
  16975. options.stat - export as static methods of target
  16976. options.proto - export as prototype methods of target
  16977. options.real - real prototype method for the `pure` version
  16978. options.forced - export even if the native feature is available
  16979. options.bind - bind methods to the target, required for the `pure` version
  16980. options.wrap - wrap constructors to preventing global pollution, required for the `pure` version
  16981. options.unsafe - use the simple assignment of property instead of delete + defineProperty
  16982. options.sham - add a flag to not completely full polyfills
  16983. options.enumerable - export as enumerable property
  16984. options.dontCallGetSet - prevent calling a getter on target
  16985. options.name - the .name of the function if it does not match the key
  16986. */
  16987. module.exports = function (options, source) {
  16988. var TARGET = options.target;
  16989. var GLOBAL = options.global;
  16990. var STATIC = options.stat;
  16991. var PROTO = options.proto;
  16992. var nativeSource = GLOBAL ? global : STATIC ? global[TARGET] : (global[TARGET] || {}).prototype;
  16993. var target = GLOBAL ? path : path[TARGET] || createNonEnumerableProperty(path, TARGET, {})[TARGET];
  16994. var targetPrototype = target.prototype;
  16995. var FORCED, USE_NATIVE, VIRTUAL_PROTOTYPE;
  16996. var key, sourceProperty, targetProperty, nativeProperty, resultProperty, descriptor;
  16997. for (key in source) {
  16998. FORCED = isForced(GLOBAL ? key : TARGET + (STATIC ? '.' : '#') + key, options.forced);
  16999. // contains in native
  17000. USE_NATIVE = !FORCED && nativeSource && hasOwn(nativeSource, key);
  17001. targetProperty = target[key];
  17002. if (USE_NATIVE) if (options.dontCallGetSet) {
  17003. descriptor = getOwnPropertyDescriptor(nativeSource, key);
  17004. nativeProperty = descriptor && descriptor.value;
  17005. } else nativeProperty = nativeSource[key];
  17006. // export native or implementation
  17007. sourceProperty = (USE_NATIVE && nativeProperty) ? nativeProperty : source[key];
  17008. if (USE_NATIVE && typeof targetProperty == typeof sourceProperty) continue;
  17009. // bind methods to global for calling from export context
  17010. if (options.bind && USE_NATIVE) resultProperty = bind(sourceProperty, global);
  17011. // wrap global constructors for prevent changes in this version
  17012. else if (options.wrap && USE_NATIVE) resultProperty = wrapConstructor(sourceProperty);
  17013. // make static versions for prototype methods
  17014. else if (PROTO && isCallable(sourceProperty)) resultProperty = uncurryThis(sourceProperty);
  17015. // default case
  17016. else resultProperty = sourceProperty;
  17017. // add a flag to not completely full polyfills
  17018. if (options.sham || (sourceProperty && sourceProperty.sham) || (targetProperty && targetProperty.sham)) {
  17019. createNonEnumerableProperty(resultProperty, 'sham', true);
  17020. }
  17021. createNonEnumerableProperty(target, key, resultProperty);
  17022. if (PROTO) {
  17023. VIRTUAL_PROTOTYPE = TARGET + 'Prototype';
  17024. if (!hasOwn(path, VIRTUAL_PROTOTYPE)) {
  17025. createNonEnumerableProperty(path, VIRTUAL_PROTOTYPE, {});
  17026. }
  17027. // export virtual prototype methods
  17028. createNonEnumerableProperty(path[VIRTUAL_PROTOTYPE], key, sourceProperty);
  17029. // export real prototype methods
  17030. if (options.real && targetPrototype && (FORCED || !targetPrototype[key])) {
  17031. createNonEnumerableProperty(targetPrototype, key, sourceProperty);
  17032. }
  17033. }
  17034. }
  17035. };
  17036. },{"../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){
  17037. module.exports = function (exec) {
  17038. try {
  17039. return !!exec();
  17040. } catch (error) {
  17041. return true;
  17042. }
  17043. };
  17044. },{}],236:[function(_dereq_,module,exports){
  17045. var fails = _dereq_('../internals/fails');
  17046. module.exports = !fails(function () {
  17047. // eslint-disable-next-line es/no-object-isextensible, es/no-object-preventextensions -- required for testing
  17048. return Object.isExtensible(Object.preventExtensions({}));
  17049. });
  17050. },{"../internals/fails":235}],237:[function(_dereq_,module,exports){
  17051. var NATIVE_BIND = _dereq_('../internals/function-bind-native');
  17052. var FunctionPrototype = Function.prototype;
  17053. var apply = FunctionPrototype.apply;
  17054. var call = FunctionPrototype.call;
  17055. // eslint-disable-next-line es/no-reflect -- safe
  17056. module.exports = typeof Reflect == 'object' && Reflect.apply || (NATIVE_BIND ? call.bind(apply) : function () {
  17057. return call.apply(apply, arguments);
  17058. });
  17059. },{"../internals/function-bind-native":239}],238:[function(_dereq_,module,exports){
  17060. var uncurryThis = _dereq_('../internals/function-uncurry-this-clause');
  17061. var aCallable = _dereq_('../internals/a-callable');
  17062. var NATIVE_BIND = _dereq_('../internals/function-bind-native');
  17063. var bind = uncurryThis(uncurryThis.bind);
  17064. // optional / simple context binding
  17065. module.exports = function (fn, that) {
  17066. aCallable(fn);
  17067. return that === undefined ? fn : NATIVE_BIND ? bind(fn, that) : function (/* ...args */) {
  17068. return fn.apply(that, arguments);
  17069. };
  17070. };
  17071. },{"../internals/a-callable":173,"../internals/function-bind-native":239,"../internals/function-uncurry-this-clause":244}],239:[function(_dereq_,module,exports){
  17072. var fails = _dereq_('../internals/fails');
  17073. module.exports = !fails(function () {
  17074. // eslint-disable-next-line es/no-function-prototype-bind -- safe
  17075. var test = (function () { /* empty */ }).bind();
  17076. // eslint-disable-next-line no-prototype-builtins -- safe
  17077. return typeof test != 'function' || test.hasOwnProperty('prototype');
  17078. });
  17079. },{"../internals/fails":235}],240:[function(_dereq_,module,exports){
  17080. 'use strict';
  17081. var uncurryThis = _dereq_('../internals/function-uncurry-this');
  17082. var aCallable = _dereq_('../internals/a-callable');
  17083. var isObject = _dereq_('../internals/is-object');
  17084. var hasOwn = _dereq_('../internals/has-own-property');
  17085. var arraySlice = _dereq_('../internals/array-slice');
  17086. var NATIVE_BIND = _dereq_('../internals/function-bind-native');
  17087. var $Function = Function;
  17088. var concat = uncurryThis([].concat);
  17089. var join = uncurryThis([].join);
  17090. var factories = {};
  17091. var construct = function (C, argsLength, args) {
  17092. if (!hasOwn(factories, argsLength)) {
  17093. for (var list = [], i = 0; i < argsLength; i++) list[i] = 'a[' + i + ']';
  17094. factories[argsLength] = $Function('C,a', 'return new C(' + join(list, ',') + ')');
  17095. } return factories[argsLength](C, args);
  17096. };
  17097. // `Function.prototype.bind` method implementation
  17098. // https://tc39.es/ecma262/#sec-function.prototype.bind
  17099. // eslint-disable-next-line es/no-function-prototype-bind -- detection
  17100. module.exports = NATIVE_BIND ? $Function.bind : function bind(that /* , ...args */) {
  17101. var F = aCallable(this);
  17102. var Prototype = F.prototype;
  17103. var partArgs = arraySlice(arguments, 1);
  17104. var boundFunction = function bound(/* args... */) {
  17105. var args = concat(partArgs, arraySlice(arguments));
  17106. return this instanceof boundFunction ? construct(F, args.length, args) : F.apply(that, args);
  17107. };
  17108. if (isObject(Prototype)) boundFunction.prototype = Prototype;
  17109. return boundFunction;
  17110. };
  17111. },{"../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){
  17112. var NATIVE_BIND = _dereq_('../internals/function-bind-native');
  17113. var call = Function.prototype.call;
  17114. module.exports = NATIVE_BIND ? call.bind(call) : function () {
  17115. return call.apply(call, arguments);
  17116. };
  17117. },{"../internals/function-bind-native":239}],242:[function(_dereq_,module,exports){
  17118. var DESCRIPTORS = _dereq_('../internals/descriptors');
  17119. var hasOwn = _dereq_('../internals/has-own-property');
  17120. var FunctionPrototype = Function.prototype;
  17121. // eslint-disable-next-line es/no-object-getownpropertydescriptor -- safe
  17122. var getDescriptor = DESCRIPTORS && Object.getOwnPropertyDescriptor;
  17123. var EXISTS = hasOwn(FunctionPrototype, 'name');
  17124. // additional protection from minified / mangled / dropped function names
  17125. var PROPER = EXISTS && (function something() { /* empty */ }).name === 'something';
  17126. var CONFIGURABLE = EXISTS && (!DESCRIPTORS || (DESCRIPTORS && getDescriptor(FunctionPrototype, 'name').configurable));
  17127. module.exports = {
  17128. EXISTS: EXISTS,
  17129. PROPER: PROPER,
  17130. CONFIGURABLE: CONFIGURABLE
  17131. };
  17132. },{"../internals/descriptors":212,"../internals/has-own-property":252}],243:[function(_dereq_,module,exports){
  17133. var uncurryThis = _dereq_('../internals/function-uncurry-this');
  17134. var aCallable = _dereq_('../internals/a-callable');
  17135. module.exports = function (object, key, method) {
  17136. try {
  17137. // eslint-disable-next-line es/no-object-getownpropertydescriptor -- safe
  17138. return uncurryThis(aCallable(Object.getOwnPropertyDescriptor(object, key)[method]));
  17139. } catch (error) { /* empty */ }
  17140. };
  17141. },{"../internals/a-callable":173,"../internals/function-uncurry-this":245}],244:[function(_dereq_,module,exports){
  17142. var classofRaw = _dereq_('../internals/classof-raw');
  17143. var uncurryThis = _dereq_('../internals/function-uncurry-this');
  17144. module.exports = function (fn) {
  17145. // Nashorn bug:
  17146. // https://github.com/zloirock/core-js/issues/1128
  17147. // https://github.com/zloirock/core-js/issues/1130
  17148. if (classofRaw(fn) === 'Function') return uncurryThis(fn);
  17149. };
  17150. },{"../internals/classof-raw":195,"../internals/function-uncurry-this":245}],245:[function(_dereq_,module,exports){
  17151. var NATIVE_BIND = _dereq_('../internals/function-bind-native');
  17152. var FunctionPrototype = Function.prototype;
  17153. var call = FunctionPrototype.call;
  17154. var uncurryThisWithBind = NATIVE_BIND && FunctionPrototype.bind.bind(call, call);
  17155. module.exports = NATIVE_BIND ? uncurryThisWithBind : function (fn) {
  17156. return function () {
  17157. return call.apply(fn, arguments);
  17158. };
  17159. };
  17160. },{"../internals/function-bind-native":239}],246:[function(_dereq_,module,exports){
  17161. var path = _dereq_('../internals/path');
  17162. var global = _dereq_('../internals/global');
  17163. var isCallable = _dereq_('../internals/is-callable');
  17164. var aFunction = function (variable) {
  17165. return isCallable(variable) ? variable : undefined;
  17166. };
  17167. module.exports = function (namespace, method) {
  17168. return arguments.length < 2 ? aFunction(path[namespace]) || aFunction(global[namespace])
  17169. : path[namespace] && path[namespace][method] || global[namespace] && global[namespace][method];
  17170. };
  17171. },{"../internals/global":251,"../internals/is-callable":264,"../internals/path":305}],247:[function(_dereq_,module,exports){
  17172. var classof = _dereq_('../internals/classof');
  17173. var getMethod = _dereq_('../internals/get-method');
  17174. var isNullOrUndefined = _dereq_('../internals/is-null-or-undefined');
  17175. var Iterators = _dereq_('../internals/iterators');
  17176. var wellKnownSymbol = _dereq_('../internals/well-known-symbol');
  17177. var ITERATOR = wellKnownSymbol('iterator');
  17178. module.exports = function (it) {
  17179. if (!isNullOrUndefined(it)) return getMethod(it, ITERATOR)
  17180. || getMethod(it, '@@iterator')
  17181. || Iterators[classof(it)];
  17182. };
  17183. },{"../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){
  17184. var call = _dereq_('../internals/function-call');
  17185. var aCallable = _dereq_('../internals/a-callable');
  17186. var anObject = _dereq_('../internals/an-object');
  17187. var tryToString = _dereq_('../internals/try-to-string');
  17188. var getIteratorMethod = _dereq_('../internals/get-iterator-method');
  17189. var $TypeError = TypeError;
  17190. module.exports = function (argument, usingIterator) {
  17191. var iteratorMethod = arguments.length < 2 ? getIteratorMethod(argument) : usingIterator;
  17192. if (aCallable(iteratorMethod)) return anObject(call(iteratorMethod, argument));
  17193. throw $TypeError(tryToString(argument) + ' is not iterable');
  17194. };
  17195. },{"../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){
  17196. var uncurryThis = _dereq_('../internals/function-uncurry-this');
  17197. var isArray = _dereq_('../internals/is-array');
  17198. var isCallable = _dereq_('../internals/is-callable');
  17199. var classof = _dereq_('../internals/classof-raw');
  17200. var toString = _dereq_('../internals/to-string');
  17201. var push = uncurryThis([].push);
  17202. module.exports = function (replacer) {
  17203. if (isCallable(replacer)) return replacer;
  17204. if (!isArray(replacer)) return;
  17205. var rawLength = replacer.length;
  17206. var keys = [];
  17207. for (var i = 0; i < rawLength; i++) {
  17208. var element = replacer[i];
  17209. if (typeof element == 'string') push(keys, element);
  17210. else if (typeof element == 'number' || classof(element) == 'Number' || classof(element) == 'String') push(keys, toString(element));
  17211. }
  17212. var keysLength = keys.length;
  17213. var root = true;
  17214. return function (key, value) {
  17215. if (root) {
  17216. root = false;
  17217. return value;
  17218. }
  17219. if (isArray(this)) return value;
  17220. for (var j = 0; j < keysLength; j++) if (keys[j] === key) return value;
  17221. };
  17222. };
  17223. },{"../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){
  17224. var aCallable = _dereq_('../internals/a-callable');
  17225. var isNullOrUndefined = _dereq_('../internals/is-null-or-undefined');
  17226. // `GetMethod` abstract operation
  17227. // https://tc39.es/ecma262/#sec-getmethod
  17228. module.exports = function (V, P) {
  17229. var func = V[P];
  17230. return isNullOrUndefined(func) ? undefined : aCallable(func);
  17231. };
  17232. },{"../internals/a-callable":173,"../internals/is-null-or-undefined":268}],251:[function(_dereq_,module,exports){
  17233. (function (global){(function (){
  17234. var check = function (it) {
  17235. return it && it.Math == Math && it;
  17236. };
  17237. // https://github.com/zloirock/core-js/issues/86#issuecomment-115759028
  17238. module.exports =
  17239. // eslint-disable-next-line es/no-global-this -- safe
  17240. check(typeof globalThis == 'object' && globalThis) ||
  17241. check(typeof window == 'object' && window) ||
  17242. // eslint-disable-next-line no-restricted-globals -- safe
  17243. check(typeof self == 'object' && self) ||
  17244. check(typeof global == 'object' && global) ||
  17245. // eslint-disable-next-line no-new-func -- fallback
  17246. (function () { return this; })() || this || Function('return this')();
  17247. }).call(this)}).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {})
  17248. },{}],252:[function(_dereq_,module,exports){
  17249. var uncurryThis = _dereq_('../internals/function-uncurry-this');
  17250. var toObject = _dereq_('../internals/to-object');
  17251. var hasOwnProperty = uncurryThis({}.hasOwnProperty);
  17252. // `HasOwnProperty` abstract operation
  17253. // https://tc39.es/ecma262/#sec-hasownproperty
  17254. // eslint-disable-next-line es/no-object-hasown -- safe
  17255. module.exports = Object.hasOwn || function hasOwn(it, key) {
  17256. return hasOwnProperty(toObject(it), key);
  17257. };
  17258. },{"../internals/function-uncurry-this":245,"../internals/to-object":330}],253:[function(_dereq_,module,exports){
  17259. module.exports = {};
  17260. },{}],254:[function(_dereq_,module,exports){
  17261. module.exports = function (a, b) {
  17262. try {
  17263. // eslint-disable-next-line no-console -- safe
  17264. arguments.length == 1 ? console.error(a) : console.error(a, b);
  17265. } catch (error) { /* empty */ }
  17266. };
  17267. },{}],255:[function(_dereq_,module,exports){
  17268. var getBuiltIn = _dereq_('../internals/get-built-in');
  17269. module.exports = getBuiltIn('document', 'documentElement');
  17270. },{"../internals/get-built-in":246}],256:[function(_dereq_,module,exports){
  17271. var DESCRIPTORS = _dereq_('../internals/descriptors');
  17272. var fails = _dereq_('../internals/fails');
  17273. var createElement = _dereq_('../internals/document-create-element');
  17274. // Thanks to IE8 for its funny defineProperty
  17275. module.exports = !DESCRIPTORS && !fails(function () {
  17276. // eslint-disable-next-line es/no-object-defineproperty -- required for testing
  17277. return Object.defineProperty(createElement('div'), 'a', {
  17278. get: function () { return 7; }
  17279. }).a != 7;
  17280. });
  17281. },{"../internals/descriptors":212,"../internals/document-create-element":214,"../internals/fails":235}],257:[function(_dereq_,module,exports){
  17282. var uncurryThis = _dereq_('../internals/function-uncurry-this');
  17283. var fails = _dereq_('../internals/fails');
  17284. var classof = _dereq_('../internals/classof-raw');
  17285. var $Object = Object;
  17286. var split = uncurryThis(''.split);
  17287. // fallback for non-array-like ES3 and non-enumerable old V8 strings
  17288. module.exports = fails(function () {
  17289. // throws an error in rhino, see https://github.com/mozilla/rhino/issues/346
  17290. // eslint-disable-next-line no-prototype-builtins -- safe
  17291. return !$Object('z').propertyIsEnumerable(0);
  17292. }) ? function (it) {
  17293. return classof(it) == 'String' ? split(it, '') : $Object(it);
  17294. } : $Object;
  17295. },{"../internals/classof-raw":195,"../internals/fails":235,"../internals/function-uncurry-this":245}],258:[function(_dereq_,module,exports){
  17296. var uncurryThis = _dereq_('../internals/function-uncurry-this');
  17297. var isCallable = _dereq_('../internals/is-callable');
  17298. var store = _dereq_('../internals/shared-store');
  17299. var functionToString = uncurryThis(Function.toString);
  17300. // this helper broken in `core-js@3.4.1-3.4.4`, so we can't use `shared` helper
  17301. if (!isCallable(store.inspectSource)) {
  17302. store.inspectSource = function (it) {
  17303. return functionToString(it);
  17304. };
  17305. }
  17306. module.exports = store.inspectSource;
  17307. },{"../internals/function-uncurry-this":245,"../internals/is-callable":264,"../internals/shared-store":317}],259:[function(_dereq_,module,exports){
  17308. var isObject = _dereq_('../internals/is-object');
  17309. var createNonEnumerableProperty = _dereq_('../internals/create-non-enumerable-property');
  17310. // `InstallErrorCause` abstract operation
  17311. // https://tc39.es/proposal-error-cause/#sec-errorobjects-install-error-cause
  17312. module.exports = function (O, options) {
  17313. if (isObject(options) && 'cause' in options) {
  17314. createNonEnumerableProperty(O, 'cause', options.cause);
  17315. }
  17316. };
  17317. },{"../internals/create-non-enumerable-property":204,"../internals/is-object":269}],260:[function(_dereq_,module,exports){
  17318. var $ = _dereq_('../internals/export');
  17319. var uncurryThis = _dereq_('../internals/function-uncurry-this');
  17320. var hiddenKeys = _dereq_('../internals/hidden-keys');
  17321. var isObject = _dereq_('../internals/is-object');
  17322. var hasOwn = _dereq_('../internals/has-own-property');
  17323. var defineProperty = _dereq_('../internals/object-define-property').f;
  17324. var getOwnPropertyNamesModule = _dereq_('../internals/object-get-own-property-names');
  17325. var getOwnPropertyNamesExternalModule = _dereq_('../internals/object-get-own-property-names-external');
  17326. var isExtensible = _dereq_('../internals/object-is-extensible');
  17327. var uid = _dereq_('../internals/uid');
  17328. var FREEZING = _dereq_('../internals/freezing');
  17329. var REQUIRED = false;
  17330. var METADATA = uid('meta');
  17331. var id = 0;
  17332. var setMetadata = function (it) {
  17333. defineProperty(it, METADATA, { value: {
  17334. objectID: 'O' + id++, // object ID
  17335. weakData: {} // weak collections IDs
  17336. } });
  17337. };
  17338. var fastKey = function (it, create) {
  17339. // return a primitive with prefix
  17340. if (!isObject(it)) return typeof it == 'symbol' ? it : (typeof it == 'string' ? 'S' : 'P') + it;
  17341. if (!hasOwn(it, METADATA)) {
  17342. // can't set metadata to uncaught frozen object
  17343. if (!isExtensible(it)) return 'F';
  17344. // not necessary to add metadata
  17345. if (!create) return 'E';
  17346. // add missing metadata
  17347. setMetadata(it);
  17348. // return object ID
  17349. } return it[METADATA].objectID;
  17350. };
  17351. var getWeakData = function (it, create) {
  17352. if (!hasOwn(it, METADATA)) {
  17353. // can't set metadata to uncaught frozen object
  17354. if (!isExtensible(it)) return true;
  17355. // not necessary to add metadata
  17356. if (!create) return false;
  17357. // add missing metadata
  17358. setMetadata(it);
  17359. // return the store of weak collections IDs
  17360. } return it[METADATA].weakData;
  17361. };
  17362. // add metadata on freeze-family methods calling
  17363. var onFreeze = function (it) {
  17364. if (FREEZING && REQUIRED && isExtensible(it) && !hasOwn(it, METADATA)) setMetadata(it);
  17365. return it;
  17366. };
  17367. var enable = function () {
  17368. meta.enable = function () { /* empty */ };
  17369. REQUIRED = true;
  17370. var getOwnPropertyNames = getOwnPropertyNamesModule.f;
  17371. var splice = uncurryThis([].splice);
  17372. var test = {};
  17373. test[METADATA] = 1;
  17374. // prevent exposing of metadata key
  17375. if (getOwnPropertyNames(test).length) {
  17376. getOwnPropertyNamesModule.f = function (it) {
  17377. var result = getOwnPropertyNames(it);
  17378. for (var i = 0, length = result.length; i < length; i++) {
  17379. if (result[i] === METADATA) {
  17380. splice(result, i, 1);
  17381. break;
  17382. }
  17383. } return result;
  17384. };
  17385. $({ target: 'Object', stat: true, forced: true }, {
  17386. getOwnPropertyNames: getOwnPropertyNamesExternalModule.f
  17387. });
  17388. }
  17389. };
  17390. var meta = module.exports = {
  17391. enable: enable,
  17392. fastKey: fastKey,
  17393. getWeakData: getWeakData,
  17394. onFreeze: onFreeze
  17395. };
  17396. hiddenKeys[METADATA] = true;
  17397. },{"../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){
  17398. var NATIVE_WEAK_MAP = _dereq_('../internals/weak-map-basic-detection');
  17399. var global = _dereq_('../internals/global');
  17400. var isObject = _dereq_('../internals/is-object');
  17401. var createNonEnumerableProperty = _dereq_('../internals/create-non-enumerable-property');
  17402. var hasOwn = _dereq_('../internals/has-own-property');
  17403. var shared = _dereq_('../internals/shared-store');
  17404. var sharedKey = _dereq_('../internals/shared-key');
  17405. var hiddenKeys = _dereq_('../internals/hidden-keys');
  17406. var OBJECT_ALREADY_INITIALIZED = 'Object already initialized';
  17407. var TypeError = global.TypeError;
  17408. var WeakMap = global.WeakMap;
  17409. var set, get, has;
  17410. var enforce = function (it) {
  17411. return has(it) ? get(it) : set(it, {});
  17412. };
  17413. var getterFor = function (TYPE) {
  17414. return function (it) {
  17415. var state;
  17416. if (!isObject(it) || (state = get(it)).type !== TYPE) {
  17417. throw TypeError('Incompatible receiver, ' + TYPE + ' required');
  17418. } return state;
  17419. };
  17420. };
  17421. if (NATIVE_WEAK_MAP || shared.state) {
  17422. var store = shared.state || (shared.state = new WeakMap());
  17423. /* eslint-disable no-self-assign -- prototype methods protection */
  17424. store.get = store.get;
  17425. store.has = store.has;
  17426. store.set = store.set;
  17427. /* eslint-enable no-self-assign -- prototype methods protection */
  17428. set = function (it, metadata) {
  17429. if (store.has(it)) throw TypeError(OBJECT_ALREADY_INITIALIZED);
  17430. metadata.facade = it;
  17431. store.set(it, metadata);
  17432. return metadata;
  17433. };
  17434. get = function (it) {
  17435. return store.get(it) || {};
  17436. };
  17437. has = function (it) {
  17438. return store.has(it);
  17439. };
  17440. } else {
  17441. var STATE = sharedKey('state');
  17442. hiddenKeys[STATE] = true;
  17443. set = function (it, metadata) {
  17444. if (hasOwn(it, STATE)) throw TypeError(OBJECT_ALREADY_INITIALIZED);
  17445. metadata.facade = it;
  17446. createNonEnumerableProperty(it, STATE, metadata);
  17447. return metadata;
  17448. };
  17449. get = function (it) {
  17450. return hasOwn(it, STATE) ? it[STATE] : {};
  17451. };
  17452. has = function (it) {
  17453. return hasOwn(it, STATE);
  17454. };
  17455. }
  17456. module.exports = {
  17457. set: set,
  17458. get: get,
  17459. has: has,
  17460. enforce: enforce,
  17461. getterFor: getterFor
  17462. };
  17463. },{"../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){
  17464. var wellKnownSymbol = _dereq_('../internals/well-known-symbol');
  17465. var Iterators = _dereq_('../internals/iterators');
  17466. var ITERATOR = wellKnownSymbol('iterator');
  17467. var ArrayPrototype = Array.prototype;
  17468. // check on default Array iterator
  17469. module.exports = function (it) {
  17470. return it !== undefined && (Iterators.Array === it || ArrayPrototype[ITERATOR] === it);
  17471. };
  17472. },{"../internals/iterators":278,"../internals/well-known-symbol":343}],263:[function(_dereq_,module,exports){
  17473. var classof = _dereq_('../internals/classof-raw');
  17474. // `IsArray` abstract operation
  17475. // https://tc39.es/ecma262/#sec-isarray
  17476. // eslint-disable-next-line es/no-array-isarray -- safe
  17477. module.exports = Array.isArray || function isArray(argument) {
  17478. return classof(argument) == 'Array';
  17479. };
  17480. },{"../internals/classof-raw":195}],264:[function(_dereq_,module,exports){
  17481. var $documentAll = _dereq_('../internals/document-all');
  17482. var documentAll = $documentAll.all;
  17483. // `IsCallable` abstract operation
  17484. // https://tc39.es/ecma262/#sec-iscallable
  17485. module.exports = $documentAll.IS_HTMLDDA ? function (argument) {
  17486. return typeof argument == 'function' || argument === documentAll;
  17487. } : function (argument) {
  17488. return typeof argument == 'function';
  17489. };
  17490. },{"../internals/document-all":213}],265:[function(_dereq_,module,exports){
  17491. var uncurryThis = _dereq_('../internals/function-uncurry-this');
  17492. var fails = _dereq_('../internals/fails');
  17493. var isCallable = _dereq_('../internals/is-callable');
  17494. var classof = _dereq_('../internals/classof');
  17495. var getBuiltIn = _dereq_('../internals/get-built-in');
  17496. var inspectSource = _dereq_('../internals/inspect-source');
  17497. var noop = function () { /* empty */ };
  17498. var empty = [];
  17499. var construct = getBuiltIn('Reflect', 'construct');
  17500. var constructorRegExp = /^\s*(?:class|function)\b/;
  17501. var exec = uncurryThis(constructorRegExp.exec);
  17502. var INCORRECT_TO_STRING = !constructorRegExp.exec(noop);
  17503. var isConstructorModern = function isConstructor(argument) {
  17504. if (!isCallable(argument)) return false;
  17505. try {
  17506. construct(noop, empty, argument);
  17507. return true;
  17508. } catch (error) {
  17509. return false;
  17510. }
  17511. };
  17512. var isConstructorLegacy = function isConstructor(argument) {
  17513. if (!isCallable(argument)) return false;
  17514. switch (classof(argument)) {
  17515. case 'AsyncFunction':
  17516. case 'GeneratorFunction':
  17517. case 'AsyncGeneratorFunction': return false;
  17518. }
  17519. try {
  17520. // we can't check .prototype since constructors produced by .bind haven't it
  17521. // `Function#toString` throws on some built-it function in some legacy engines
  17522. // (for example, `DOMQuad` and similar in FF41-)
  17523. return INCORRECT_TO_STRING || !!exec(constructorRegExp, inspectSource(argument));
  17524. } catch (error) {
  17525. return true;
  17526. }
  17527. };
  17528. isConstructorLegacy.sham = true;
  17529. // `IsConstructor` abstract operation
  17530. // https://tc39.es/ecma262/#sec-isconstructor
  17531. module.exports = !construct || fails(function () {
  17532. var called;
  17533. return isConstructorModern(isConstructorModern.call)
  17534. || !isConstructorModern(Object)
  17535. || !isConstructorModern(function () { called = true; })
  17536. || called;
  17537. }) ? isConstructorLegacy : isConstructorModern;
  17538. },{"../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){
  17539. var fails = _dereq_('../internals/fails');
  17540. var isCallable = _dereq_('../internals/is-callable');
  17541. var replacement = /#|\.prototype\./;
  17542. var isForced = function (feature, detection) {
  17543. var value = data[normalize(feature)];
  17544. return value == POLYFILL ? true
  17545. : value == NATIVE ? false
  17546. : isCallable(detection) ? fails(detection)
  17547. : !!detection;
  17548. };
  17549. var normalize = isForced.normalize = function (string) {
  17550. return String(string).replace(replacement, '.').toLowerCase();
  17551. };
  17552. var data = isForced.data = {};
  17553. var NATIVE = isForced.NATIVE = 'N';
  17554. var POLYFILL = isForced.POLYFILL = 'P';
  17555. module.exports = isForced;
  17556. },{"../internals/fails":235,"../internals/is-callable":264}],267:[function(_dereq_,module,exports){
  17557. var isObject = _dereq_('../internals/is-object');
  17558. var floor = Math.floor;
  17559. // `IsIntegralNumber` abstract operation
  17560. // https://tc39.es/ecma262/#sec-isintegralnumber
  17561. // eslint-disable-next-line es/no-number-isinteger -- safe
  17562. module.exports = Number.isInteger || function isInteger(it) {
  17563. return !isObject(it) && isFinite(it) && floor(it) === it;
  17564. };
  17565. },{"../internals/is-object":269}],268:[function(_dereq_,module,exports){
  17566. // we can't use just `it == null` since of `document.all` special case
  17567. // https://tc39.es/ecma262/#sec-IsHTMLDDA-internal-slot-aec
  17568. module.exports = function (it) {
  17569. return it === null || it === undefined;
  17570. };
  17571. },{}],269:[function(_dereq_,module,exports){
  17572. var isCallable = _dereq_('../internals/is-callable');
  17573. var $documentAll = _dereq_('../internals/document-all');
  17574. var documentAll = $documentAll.all;
  17575. module.exports = $documentAll.IS_HTMLDDA ? function (it) {
  17576. return typeof it == 'object' ? it !== null : isCallable(it) || it === documentAll;
  17577. } : function (it) {
  17578. return typeof it == 'object' ? it !== null : isCallable(it);
  17579. };
  17580. },{"../internals/document-all":213,"../internals/is-callable":264}],270:[function(_dereq_,module,exports){
  17581. module.exports = true;
  17582. },{}],271:[function(_dereq_,module,exports){
  17583. var isObject = _dereq_('../internals/is-object');
  17584. var classof = _dereq_('../internals/classof-raw');
  17585. var wellKnownSymbol = _dereq_('../internals/well-known-symbol');
  17586. var MATCH = wellKnownSymbol('match');
  17587. // `IsRegExp` abstract operation
  17588. // https://tc39.es/ecma262/#sec-isregexp
  17589. module.exports = function (it) {
  17590. var isRegExp;
  17591. return isObject(it) && ((isRegExp = it[MATCH]) !== undefined ? !!isRegExp : classof(it) == 'RegExp');
  17592. };
  17593. },{"../internals/classof-raw":195,"../internals/is-object":269,"../internals/well-known-symbol":343}],272:[function(_dereq_,module,exports){
  17594. var getBuiltIn = _dereq_('../internals/get-built-in');
  17595. var isCallable = _dereq_('../internals/is-callable');
  17596. var isPrototypeOf = _dereq_('../internals/object-is-prototype-of');
  17597. var USE_SYMBOL_AS_UID = _dereq_('../internals/use-symbol-as-uid');
  17598. var $Object = Object;
  17599. module.exports = USE_SYMBOL_AS_UID ? function (it) {
  17600. return typeof it == 'symbol';
  17601. } : function (it) {
  17602. var $Symbol = getBuiltIn('Symbol');
  17603. return isCallable($Symbol) && isPrototypeOf($Symbol.prototype, $Object(it));
  17604. };
  17605. },{"../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){
  17606. var bind = _dereq_('../internals/function-bind-context');
  17607. var call = _dereq_('../internals/function-call');
  17608. var anObject = _dereq_('../internals/an-object');
  17609. var tryToString = _dereq_('../internals/try-to-string');
  17610. var isArrayIteratorMethod = _dereq_('../internals/is-array-iterator-method');
  17611. var lengthOfArrayLike = _dereq_('../internals/length-of-array-like');
  17612. var isPrototypeOf = _dereq_('../internals/object-is-prototype-of');
  17613. var getIterator = _dereq_('../internals/get-iterator');
  17614. var getIteratorMethod = _dereq_('../internals/get-iterator-method');
  17615. var iteratorClose = _dereq_('../internals/iterator-close');
  17616. var $TypeError = TypeError;
  17617. var Result = function (stopped, result) {
  17618. this.stopped = stopped;
  17619. this.result = result;
  17620. };
  17621. var ResultPrototype = Result.prototype;
  17622. module.exports = function (iterable, unboundFunction, options) {
  17623. var that = options && options.that;
  17624. var AS_ENTRIES = !!(options && options.AS_ENTRIES);
  17625. var IS_RECORD = !!(options && options.IS_RECORD);
  17626. var IS_ITERATOR = !!(options && options.IS_ITERATOR);
  17627. var INTERRUPTED = !!(options && options.INTERRUPTED);
  17628. var fn = bind(unboundFunction, that);
  17629. var iterator, iterFn, index, length, result, next, step;
  17630. var stop = function (condition) {
  17631. if (iterator) iteratorClose(iterator, 'normal', condition);
  17632. return new Result(true, condition);
  17633. };
  17634. var callFn = function (value) {
  17635. if (AS_ENTRIES) {
  17636. anObject(value);
  17637. return INTERRUPTED ? fn(value[0], value[1], stop) : fn(value[0], value[1]);
  17638. } return INTERRUPTED ? fn(value, stop) : fn(value);
  17639. };
  17640. if (IS_RECORD) {
  17641. iterator = iterable.iterator;
  17642. } else if (IS_ITERATOR) {
  17643. iterator = iterable;
  17644. } else {
  17645. iterFn = getIteratorMethod(iterable);
  17646. if (!iterFn) throw $TypeError(tryToString(iterable) + ' is not iterable');
  17647. // optimisation for array iterators
  17648. if (isArrayIteratorMethod(iterFn)) {
  17649. for (index = 0, length = lengthOfArrayLike(iterable); length > index; index++) {
  17650. result = callFn(iterable[index]);
  17651. if (result && isPrototypeOf(ResultPrototype, result)) return result;
  17652. } return new Result(false);
  17653. }
  17654. iterator = getIterator(iterable, iterFn);
  17655. }
  17656. next = IS_RECORD ? iterable.next : iterator.next;
  17657. while (!(step = call(next, iterator)).done) {
  17658. try {
  17659. result = callFn(step.value);
  17660. } catch (error) {
  17661. iteratorClose(iterator, 'throw', error);
  17662. }
  17663. if (typeof result == 'object' && result && isPrototypeOf(ResultPrototype, result)) return result;
  17664. } return new Result(false);
  17665. };
  17666. },{"../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){
  17667. var call = _dereq_('../internals/function-call');
  17668. var anObject = _dereq_('../internals/an-object');
  17669. var getMethod = _dereq_('../internals/get-method');
  17670. module.exports = function (iterator, kind, value) {
  17671. var innerResult, innerError;
  17672. anObject(iterator);
  17673. try {
  17674. innerResult = getMethod(iterator, 'return');
  17675. if (!innerResult) {
  17676. if (kind === 'throw') throw value;
  17677. return value;
  17678. }
  17679. innerResult = call(innerResult, iterator);
  17680. } catch (error) {
  17681. innerError = true;
  17682. innerResult = error;
  17683. }
  17684. if (kind === 'throw') throw value;
  17685. if (innerError) throw innerResult;
  17686. anObject(innerResult);
  17687. return value;
  17688. };
  17689. },{"../internals/an-object":178,"../internals/function-call":241,"../internals/get-method":250}],275:[function(_dereq_,module,exports){
  17690. 'use strict';
  17691. var IteratorPrototype = _dereq_('../internals/iterators-core').IteratorPrototype;
  17692. var create = _dereq_('../internals/object-create');
  17693. var createPropertyDescriptor = _dereq_('../internals/create-property-descriptor');
  17694. var setToStringTag = _dereq_('../internals/set-to-string-tag');
  17695. var Iterators = _dereq_('../internals/iterators');
  17696. var returnThis = function () { return this; };
  17697. module.exports = function (IteratorConstructor, NAME, next, ENUMERABLE_NEXT) {
  17698. var TO_STRING_TAG = NAME + ' Iterator';
  17699. IteratorConstructor.prototype = create(IteratorPrototype, { next: createPropertyDescriptor(+!ENUMERABLE_NEXT, next) });
  17700. setToStringTag(IteratorConstructor, TO_STRING_TAG, false, true);
  17701. Iterators[TO_STRING_TAG] = returnThis;
  17702. return IteratorConstructor;
  17703. };
  17704. },{"../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){
  17705. 'use strict';
  17706. var $ = _dereq_('../internals/export');
  17707. var call = _dereq_('../internals/function-call');
  17708. var IS_PURE = _dereq_('../internals/is-pure');
  17709. var FunctionName = _dereq_('../internals/function-name');
  17710. var isCallable = _dereq_('../internals/is-callable');
  17711. var createIteratorConstructor = _dereq_('../internals/iterator-create-constructor');
  17712. var getPrototypeOf = _dereq_('../internals/object-get-prototype-of');
  17713. var setPrototypeOf = _dereq_('../internals/object-set-prototype-of');
  17714. var setToStringTag = _dereq_('../internals/set-to-string-tag');
  17715. var createNonEnumerableProperty = _dereq_('../internals/create-non-enumerable-property');
  17716. var defineBuiltIn = _dereq_('../internals/define-built-in');
  17717. var wellKnownSymbol = _dereq_('../internals/well-known-symbol');
  17718. var Iterators = _dereq_('../internals/iterators');
  17719. var IteratorsCore = _dereq_('../internals/iterators-core');
  17720. var PROPER_FUNCTION_NAME = FunctionName.PROPER;
  17721. var CONFIGURABLE_FUNCTION_NAME = FunctionName.CONFIGURABLE;
  17722. var IteratorPrototype = IteratorsCore.IteratorPrototype;
  17723. var BUGGY_SAFARI_ITERATORS = IteratorsCore.BUGGY_SAFARI_ITERATORS;
  17724. var ITERATOR = wellKnownSymbol('iterator');
  17725. var KEYS = 'keys';
  17726. var VALUES = 'values';
  17727. var ENTRIES = 'entries';
  17728. var returnThis = function () { return this; };
  17729. module.exports = function (Iterable, NAME, IteratorConstructor, next, DEFAULT, IS_SET, FORCED) {
  17730. createIteratorConstructor(IteratorConstructor, NAME, next);
  17731. var getIterationMethod = function (KIND) {
  17732. if (KIND === DEFAULT && defaultIterator) return defaultIterator;
  17733. if (!BUGGY_SAFARI_ITERATORS && KIND in IterablePrototype) return IterablePrototype[KIND];
  17734. switch (KIND) {
  17735. case KEYS: return function keys() { return new IteratorConstructor(this, KIND); };
  17736. case VALUES: return function values() { return new IteratorConstructor(this, KIND); };
  17737. case ENTRIES: return function entries() { return new IteratorConstructor(this, KIND); };
  17738. } return function () { return new IteratorConstructor(this); };
  17739. };
  17740. var TO_STRING_TAG = NAME + ' Iterator';
  17741. var INCORRECT_VALUES_NAME = false;
  17742. var IterablePrototype = Iterable.prototype;
  17743. var nativeIterator = IterablePrototype[ITERATOR]
  17744. || IterablePrototype['@@iterator']
  17745. || DEFAULT && IterablePrototype[DEFAULT];
  17746. var defaultIterator = !BUGGY_SAFARI_ITERATORS && nativeIterator || getIterationMethod(DEFAULT);
  17747. var anyNativeIterator = NAME == 'Array' ? IterablePrototype.entries || nativeIterator : nativeIterator;
  17748. var CurrentIteratorPrototype, methods, KEY;
  17749. // fix native
  17750. if (anyNativeIterator) {
  17751. CurrentIteratorPrototype = getPrototypeOf(anyNativeIterator.call(new Iterable()));
  17752. if (CurrentIteratorPrototype !== Object.prototype && CurrentIteratorPrototype.next) {
  17753. if (!IS_PURE && getPrototypeOf(CurrentIteratorPrototype) !== IteratorPrototype) {
  17754. if (setPrototypeOf) {
  17755. setPrototypeOf(CurrentIteratorPrototype, IteratorPrototype);
  17756. } else if (!isCallable(CurrentIteratorPrototype[ITERATOR])) {
  17757. defineBuiltIn(CurrentIteratorPrototype, ITERATOR, returnThis);
  17758. }
  17759. }
  17760. // Set @@toStringTag to native iterators
  17761. setToStringTag(CurrentIteratorPrototype, TO_STRING_TAG, true, true);
  17762. if (IS_PURE) Iterators[TO_STRING_TAG] = returnThis;
  17763. }
  17764. }
  17765. // fix Array.prototype.{ values, @@iterator }.name in V8 / FF
  17766. if (PROPER_FUNCTION_NAME && DEFAULT == VALUES && nativeIterator && nativeIterator.name !== VALUES) {
  17767. if (!IS_PURE && CONFIGURABLE_FUNCTION_NAME) {
  17768. createNonEnumerableProperty(IterablePrototype, 'name', VALUES);
  17769. } else {
  17770. INCORRECT_VALUES_NAME = true;
  17771. defaultIterator = function values() { return call(nativeIterator, this); };
  17772. }
  17773. }
  17774. // export additional methods
  17775. if (DEFAULT) {
  17776. methods = {
  17777. values: getIterationMethod(VALUES),
  17778. keys: IS_SET ? defaultIterator : getIterationMethod(KEYS),
  17779. entries: getIterationMethod(ENTRIES)
  17780. };
  17781. if (FORCED) for (KEY in methods) {
  17782. if (BUGGY_SAFARI_ITERATORS || INCORRECT_VALUES_NAME || !(KEY in IterablePrototype)) {
  17783. defineBuiltIn(IterablePrototype, KEY, methods[KEY]);
  17784. }
  17785. } else $({ target: NAME, proto: true, forced: BUGGY_SAFARI_ITERATORS || INCORRECT_VALUES_NAME }, methods);
  17786. }
  17787. // define iterator
  17788. if ((!IS_PURE || FORCED) && IterablePrototype[ITERATOR] !== defaultIterator) {
  17789. defineBuiltIn(IterablePrototype, ITERATOR, defaultIterator, { name: DEFAULT });
  17790. }
  17791. Iterators[NAME] = defaultIterator;
  17792. return methods;
  17793. };
  17794. },{"../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){
  17795. 'use strict';
  17796. var fails = _dereq_('../internals/fails');
  17797. var isCallable = _dereq_('../internals/is-callable');
  17798. var isObject = _dereq_('../internals/is-object');
  17799. var create = _dereq_('../internals/object-create');
  17800. var getPrototypeOf = _dereq_('../internals/object-get-prototype-of');
  17801. var defineBuiltIn = _dereq_('../internals/define-built-in');
  17802. var wellKnownSymbol = _dereq_('../internals/well-known-symbol');
  17803. var IS_PURE = _dereq_('../internals/is-pure');
  17804. var ITERATOR = wellKnownSymbol('iterator');
  17805. var BUGGY_SAFARI_ITERATORS = false;
  17806. // `%IteratorPrototype%` object
  17807. // https://tc39.es/ecma262/#sec-%iteratorprototype%-object
  17808. var IteratorPrototype, PrototypeOfArrayIteratorPrototype, arrayIterator;
  17809. /* eslint-disable es/no-array-prototype-keys -- safe */
  17810. if ([].keys) {
  17811. arrayIterator = [].keys();
  17812. // Safari 8 has buggy iterators w/o `next`
  17813. if (!('next' in arrayIterator)) BUGGY_SAFARI_ITERATORS = true;
  17814. else {
  17815. PrototypeOfArrayIteratorPrototype = getPrototypeOf(getPrototypeOf(arrayIterator));
  17816. if (PrototypeOfArrayIteratorPrototype !== Object.prototype) IteratorPrototype = PrototypeOfArrayIteratorPrototype;
  17817. }
  17818. }
  17819. var NEW_ITERATOR_PROTOTYPE = !isObject(IteratorPrototype) || fails(function () {
  17820. var test = {};
  17821. // FF44- legacy iterators case
  17822. return IteratorPrototype[ITERATOR].call(test) !== test;
  17823. });
  17824. if (NEW_ITERATOR_PROTOTYPE) IteratorPrototype = {};
  17825. else if (IS_PURE) IteratorPrototype = create(IteratorPrototype);
  17826. // `%IteratorPrototype%[@@iterator]()` method
  17827. // https://tc39.es/ecma262/#sec-%iteratorprototype%-@@iterator
  17828. if (!isCallable(IteratorPrototype[ITERATOR])) {
  17829. defineBuiltIn(IteratorPrototype, ITERATOR, function () {
  17830. return this;
  17831. });
  17832. }
  17833. module.exports = {
  17834. IteratorPrototype: IteratorPrototype,
  17835. BUGGY_SAFARI_ITERATORS: BUGGY_SAFARI_ITERATORS
  17836. };
  17837. },{"../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){
  17838. arguments[4][253][0].apply(exports,arguments)
  17839. },{"dup":253}],279:[function(_dereq_,module,exports){
  17840. var toLength = _dereq_('../internals/to-length');
  17841. // `LengthOfArrayLike` abstract operation
  17842. // https://tc39.es/ecma262/#sec-lengthofarraylike
  17843. module.exports = function (obj) {
  17844. return toLength(obj.length);
  17845. };
  17846. },{"../internals/to-length":329}],280:[function(_dereq_,module,exports){
  17847. var ceil = Math.ceil;
  17848. var floor = Math.floor;
  17849. // `Math.trunc` method
  17850. // https://tc39.es/ecma262/#sec-math.trunc
  17851. // eslint-disable-next-line es/no-math-trunc -- safe
  17852. module.exports = Math.trunc || function trunc(x) {
  17853. var n = +x;
  17854. return (n > 0 ? floor : ceil)(n);
  17855. };
  17856. },{}],281:[function(_dereq_,module,exports){
  17857. var global = _dereq_('../internals/global');
  17858. var bind = _dereq_('../internals/function-bind-context');
  17859. var getOwnPropertyDescriptor = _dereq_('../internals/object-get-own-property-descriptor').f;
  17860. var macrotask = _dereq_('../internals/task').set;
  17861. var Queue = _dereq_('../internals/queue');
  17862. var IS_IOS = _dereq_('../internals/engine-is-ios');
  17863. var IS_IOS_PEBBLE = _dereq_('../internals/engine-is-ios-pebble');
  17864. var IS_WEBOS_WEBKIT = _dereq_('../internals/engine-is-webos-webkit');
  17865. var IS_NODE = _dereq_('../internals/engine-is-node');
  17866. var MutationObserver = global.MutationObserver || global.WebKitMutationObserver;
  17867. var document = global.document;
  17868. var process = global.process;
  17869. var Promise = global.Promise;
  17870. // Node.js 11 shows ExperimentalWarning on getting `queueMicrotask`
  17871. var queueMicrotaskDescriptor = getOwnPropertyDescriptor(global, 'queueMicrotask');
  17872. var microtask = queueMicrotaskDescriptor && queueMicrotaskDescriptor.value;
  17873. var notify, toggle, node, promise, then;
  17874. // modern engines have queueMicrotask method
  17875. if (!microtask) {
  17876. var queue = new Queue();
  17877. var flush = function () {
  17878. var parent, fn;
  17879. if (IS_NODE && (parent = process.domain)) parent.exit();
  17880. while (fn = queue.get()) try {
  17881. fn();
  17882. } catch (error) {
  17883. if (queue.head) notify();
  17884. throw error;
  17885. }
  17886. if (parent) parent.enter();
  17887. };
  17888. // browsers with MutationObserver, except iOS - https://github.com/zloirock/core-js/issues/339
  17889. // also except WebOS Webkit https://github.com/zloirock/core-js/issues/898
  17890. if (!IS_IOS && !IS_NODE && !IS_WEBOS_WEBKIT && MutationObserver && document) {
  17891. toggle = true;
  17892. node = document.createTextNode('');
  17893. new MutationObserver(flush).observe(node, { characterData: true });
  17894. notify = function () {
  17895. node.data = toggle = !toggle;
  17896. };
  17897. // environments with maybe non-completely correct, but existent Promise
  17898. } else if (!IS_IOS_PEBBLE && Promise && Promise.resolve) {
  17899. // Promise.resolve without an argument throws an error in LG WebOS 2
  17900. promise = Promise.resolve(undefined);
  17901. // workaround of WebKit ~ iOS Safari 10.1 bug
  17902. promise.constructor = Promise;
  17903. then = bind(promise.then, promise);
  17904. notify = function () {
  17905. then(flush);
  17906. };
  17907. // Node.js without promises
  17908. } else if (IS_NODE) {
  17909. notify = function () {
  17910. process.nextTick(flush);
  17911. };
  17912. // for other environments - macrotask based on:
  17913. // - setImmediate
  17914. // - MessageChannel
  17915. // - window.postMessage
  17916. // - onreadystatechange
  17917. // - setTimeout
  17918. } else {
  17919. // `webpack` dev server bug on IE global methods - use bind(fn, global)
  17920. macrotask = bind(macrotask, global);
  17921. notify = function () {
  17922. macrotask(flush);
  17923. };
  17924. }
  17925. microtask = function (fn) {
  17926. if (!queue.head) notify();
  17927. queue.add(fn);
  17928. };
  17929. }
  17930. module.exports = microtask;
  17931. },{"../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){
  17932. 'use strict';
  17933. var aCallable = _dereq_('../internals/a-callable');
  17934. var $TypeError = TypeError;
  17935. var PromiseCapability = function (C) {
  17936. var resolve, reject;
  17937. this.promise = new C(function ($$resolve, $$reject) {
  17938. if (resolve !== undefined || reject !== undefined) throw $TypeError('Bad Promise constructor');
  17939. resolve = $$resolve;
  17940. reject = $$reject;
  17941. });
  17942. this.resolve = aCallable(resolve);
  17943. this.reject = aCallable(reject);
  17944. };
  17945. // `NewPromiseCapability` abstract operation
  17946. // https://tc39.es/ecma262/#sec-newpromisecapability
  17947. module.exports.f = function (C) {
  17948. return new PromiseCapability(C);
  17949. };
  17950. },{"../internals/a-callable":173}],283:[function(_dereq_,module,exports){
  17951. var toString = _dereq_('../internals/to-string');
  17952. module.exports = function (argument, $default) {
  17953. return argument === undefined ? arguments.length < 2 ? '' : $default : toString(argument);
  17954. };
  17955. },{"../internals/to-string":334}],284:[function(_dereq_,module,exports){
  17956. var isRegExp = _dereq_('../internals/is-regexp');
  17957. var $TypeError = TypeError;
  17958. module.exports = function (it) {
  17959. if (isRegExp(it)) {
  17960. throw $TypeError("The method doesn't accept regular expressions");
  17961. } return it;
  17962. };
  17963. },{"../internals/is-regexp":271}],285:[function(_dereq_,module,exports){
  17964. var global = _dereq_('../internals/global');
  17965. var fails = _dereq_('../internals/fails');
  17966. var uncurryThis = _dereq_('../internals/function-uncurry-this');
  17967. var toString = _dereq_('../internals/to-string');
  17968. var trim = _dereq_('../internals/string-trim').trim;
  17969. var whitespaces = _dereq_('../internals/whitespaces');
  17970. var $parseInt = global.parseInt;
  17971. var Symbol = global.Symbol;
  17972. var ITERATOR = Symbol && Symbol.iterator;
  17973. var hex = /^[+-]?0x/i;
  17974. var exec = uncurryThis(hex.exec);
  17975. var FORCED = $parseInt(whitespaces + '08') !== 8 || $parseInt(whitespaces + '0x16') !== 22
  17976. // MS Edge 18- broken with boxed symbols
  17977. || (ITERATOR && !fails(function () { $parseInt(Object(ITERATOR)); }));
  17978. // `parseInt` method
  17979. // https://tc39.es/ecma262/#sec-parseint-string-radix
  17980. module.exports = FORCED ? function parseInt(string, radix) {
  17981. var S = trim(toString(string));
  17982. return $parseInt(S, (radix >>> 0) || (exec(hex, S) ? 16 : 10));
  17983. } : $parseInt;
  17984. },{"../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){
  17985. 'use strict';
  17986. var DESCRIPTORS = _dereq_('../internals/descriptors');
  17987. var uncurryThis = _dereq_('../internals/function-uncurry-this');
  17988. var call = _dereq_('../internals/function-call');
  17989. var fails = _dereq_('../internals/fails');
  17990. var objectKeys = _dereq_('../internals/object-keys');
  17991. var getOwnPropertySymbolsModule = _dereq_('../internals/object-get-own-property-symbols');
  17992. var propertyIsEnumerableModule = _dereq_('../internals/object-property-is-enumerable');
  17993. var toObject = _dereq_('../internals/to-object');
  17994. var IndexedObject = _dereq_('../internals/indexed-object');
  17995. // eslint-disable-next-line es/no-object-assign -- safe
  17996. var $assign = Object.assign;
  17997. // eslint-disable-next-line es/no-object-defineproperty -- required for testing
  17998. var defineProperty = Object.defineProperty;
  17999. var concat = uncurryThis([].concat);
  18000. // `Object.assign` method
  18001. // https://tc39.es/ecma262/#sec-object.assign
  18002. module.exports = !$assign || fails(function () {
  18003. // should have correct order of operations (Edge bug)
  18004. if (DESCRIPTORS && $assign({ b: 1 }, $assign(defineProperty({}, 'a', {
  18005. enumerable: true,
  18006. get: function () {
  18007. defineProperty(this, 'b', {
  18008. value: 3,
  18009. enumerable: false
  18010. });
  18011. }
  18012. }), { b: 2 })).b !== 1) return true;
  18013. // should work with symbols and should have deterministic property order (V8 bug)
  18014. var A = {};
  18015. var B = {};
  18016. // eslint-disable-next-line es/no-symbol -- safe
  18017. var symbol = Symbol();
  18018. var alphabet = 'abcdefghijklmnopqrst';
  18019. A[symbol] = 7;
  18020. alphabet.split('').forEach(function (chr) { B[chr] = chr; });
  18021. return $assign({}, A)[symbol] != 7 || objectKeys($assign({}, B)).join('') != alphabet;
  18022. }) ? function assign(target, source) { // eslint-disable-line no-unused-vars -- required for `.length`
  18023. var T = toObject(target);
  18024. var argumentsLength = arguments.length;
  18025. var index = 1;
  18026. var getOwnPropertySymbols = getOwnPropertySymbolsModule.f;
  18027. var propertyIsEnumerable = propertyIsEnumerableModule.f;
  18028. while (argumentsLength > index) {
  18029. var S = IndexedObject(arguments[index++]);
  18030. var keys = getOwnPropertySymbols ? concat(objectKeys(S), getOwnPropertySymbols(S)) : objectKeys(S);
  18031. var length = keys.length;
  18032. var j = 0;
  18033. var key;
  18034. while (length > j) {
  18035. key = keys[j++];
  18036. if (!DESCRIPTORS || call(propertyIsEnumerable, S, key)) T[key] = S[key];
  18037. }
  18038. } return T;
  18039. } : $assign;
  18040. },{"../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){
  18041. /* global ActiveXObject -- old IE, WSH */
  18042. var anObject = _dereq_('../internals/an-object');
  18043. var definePropertiesModule = _dereq_('../internals/object-define-properties');
  18044. var enumBugKeys = _dereq_('../internals/enum-bug-keys');
  18045. var hiddenKeys = _dereq_('../internals/hidden-keys');
  18046. var html = _dereq_('../internals/html');
  18047. var documentCreateElement = _dereq_('../internals/document-create-element');
  18048. var sharedKey = _dereq_('../internals/shared-key');
  18049. var GT = '>';
  18050. var LT = '<';
  18051. var PROTOTYPE = 'prototype';
  18052. var SCRIPT = 'script';
  18053. var IE_PROTO = sharedKey('IE_PROTO');
  18054. var EmptyConstructor = function () { /* empty */ };
  18055. var scriptTag = function (content) {
  18056. return LT + SCRIPT + GT + content + LT + '/' + SCRIPT + GT;
  18057. };
  18058. // Create object with fake `null` prototype: use ActiveX Object with cleared prototype
  18059. var NullProtoObjectViaActiveX = function (activeXDocument) {
  18060. activeXDocument.write(scriptTag(''));
  18061. activeXDocument.close();
  18062. var temp = activeXDocument.parentWindow.Object;
  18063. activeXDocument = null; // avoid memory leak
  18064. return temp;
  18065. };
  18066. // Create object with fake `null` prototype: use iframe Object with cleared prototype
  18067. var NullProtoObjectViaIFrame = function () {
  18068. // Thrash, waste and sodomy: IE GC bug
  18069. var iframe = documentCreateElement('iframe');
  18070. var JS = 'java' + SCRIPT + ':';
  18071. var iframeDocument;
  18072. iframe.style.display = 'none';
  18073. html.appendChild(iframe);
  18074. // https://github.com/zloirock/core-js/issues/475
  18075. iframe.src = String(JS);
  18076. iframeDocument = iframe.contentWindow.document;
  18077. iframeDocument.open();
  18078. iframeDocument.write(scriptTag('document.F=Object'));
  18079. iframeDocument.close();
  18080. return iframeDocument.F;
  18081. };
  18082. // Check for document.domain and active x support
  18083. // No need to use active x approach when document.domain is not set
  18084. // see https://github.com/es-shims/es5-shim/issues/150
  18085. // variation of https://github.com/kitcambridge/es5-shim/commit/4f738ac066346
  18086. // avoid IE GC bug
  18087. var activeXDocument;
  18088. var NullProtoObject = function () {
  18089. try {
  18090. activeXDocument = new ActiveXObject('htmlfile');
  18091. } catch (error) { /* ignore */ }
  18092. NullProtoObject = typeof document != 'undefined'
  18093. ? document.domain && activeXDocument
  18094. ? NullProtoObjectViaActiveX(activeXDocument) // old IE
  18095. : NullProtoObjectViaIFrame()
  18096. : NullProtoObjectViaActiveX(activeXDocument); // WSH
  18097. var length = enumBugKeys.length;
  18098. while (length--) delete NullProtoObject[PROTOTYPE][enumBugKeys[length]];
  18099. return NullProtoObject();
  18100. };
  18101. hiddenKeys[IE_PROTO] = true;
  18102. // `Object.create` method
  18103. // https://tc39.es/ecma262/#sec-object.create
  18104. // eslint-disable-next-line es/no-object-create -- safe
  18105. module.exports = Object.create || function create(O, Properties) {
  18106. var result;
  18107. if (O !== null) {
  18108. EmptyConstructor[PROTOTYPE] = anObject(O);
  18109. result = new EmptyConstructor();
  18110. EmptyConstructor[PROTOTYPE] = null;
  18111. // add "__proto__" for Object.getPrototypeOf polyfill
  18112. result[IE_PROTO] = O;
  18113. } else result = NullProtoObject();
  18114. return Properties === undefined ? result : definePropertiesModule.f(result, Properties);
  18115. };
  18116. },{"../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){
  18117. var DESCRIPTORS = _dereq_('../internals/descriptors');
  18118. var V8_PROTOTYPE_DEFINE_BUG = _dereq_('../internals/v8-prototype-define-bug');
  18119. var definePropertyModule = _dereq_('../internals/object-define-property');
  18120. var anObject = _dereq_('../internals/an-object');
  18121. var toIndexedObject = _dereq_('../internals/to-indexed-object');
  18122. var objectKeys = _dereq_('../internals/object-keys');
  18123. // `Object.defineProperties` method
  18124. // https://tc39.es/ecma262/#sec-object.defineproperties
  18125. // eslint-disable-next-line es/no-object-defineproperties -- safe
  18126. exports.f = DESCRIPTORS && !V8_PROTOTYPE_DEFINE_BUG ? Object.defineProperties : function defineProperties(O, Properties) {
  18127. anObject(O);
  18128. var props = toIndexedObject(Properties);
  18129. var keys = objectKeys(Properties);
  18130. var length = keys.length;
  18131. var index = 0;
  18132. var key;
  18133. while (length > index) definePropertyModule.f(O, key = keys[index++], props[key]);
  18134. return O;
  18135. };
  18136. },{"../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){
  18137. var DESCRIPTORS = _dereq_('../internals/descriptors');
  18138. var IE8_DOM_DEFINE = _dereq_('../internals/ie8-dom-define');
  18139. var V8_PROTOTYPE_DEFINE_BUG = _dereq_('../internals/v8-prototype-define-bug');
  18140. var anObject = _dereq_('../internals/an-object');
  18141. var toPropertyKey = _dereq_('../internals/to-property-key');
  18142. var $TypeError = TypeError;
  18143. // eslint-disable-next-line es/no-object-defineproperty -- safe
  18144. var $defineProperty = Object.defineProperty;
  18145. // eslint-disable-next-line es/no-object-getownpropertydescriptor -- safe
  18146. var $getOwnPropertyDescriptor = Object.getOwnPropertyDescriptor;
  18147. var ENUMERABLE = 'enumerable';
  18148. var CONFIGURABLE = 'configurable';
  18149. var WRITABLE = 'writable';
  18150. // `Object.defineProperty` method
  18151. // https://tc39.es/ecma262/#sec-object.defineproperty
  18152. exports.f = DESCRIPTORS ? V8_PROTOTYPE_DEFINE_BUG ? function defineProperty(O, P, Attributes) {
  18153. anObject(O);
  18154. P = toPropertyKey(P);
  18155. anObject(Attributes);
  18156. if (typeof O === 'function' && P === 'prototype' && 'value' in Attributes && WRITABLE in Attributes && !Attributes[WRITABLE]) {
  18157. var current = $getOwnPropertyDescriptor(O, P);
  18158. if (current && current[WRITABLE]) {
  18159. O[P] = Attributes.value;
  18160. Attributes = {
  18161. configurable: CONFIGURABLE in Attributes ? Attributes[CONFIGURABLE] : current[CONFIGURABLE],
  18162. enumerable: ENUMERABLE in Attributes ? Attributes[ENUMERABLE] : current[ENUMERABLE],
  18163. writable: false
  18164. };
  18165. }
  18166. } return $defineProperty(O, P, Attributes);
  18167. } : $defineProperty : function defineProperty(O, P, Attributes) {
  18168. anObject(O);
  18169. P = toPropertyKey(P);
  18170. anObject(Attributes);
  18171. if (IE8_DOM_DEFINE) try {
  18172. return $defineProperty(O, P, Attributes);
  18173. } catch (error) { /* empty */ }
  18174. if ('get' in Attributes || 'set' in Attributes) throw $TypeError('Accessors not supported');
  18175. if ('value' in Attributes) O[P] = Attributes.value;
  18176. return O;
  18177. };
  18178. },{"../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){
  18179. var DESCRIPTORS = _dereq_('../internals/descriptors');
  18180. var call = _dereq_('../internals/function-call');
  18181. var propertyIsEnumerableModule = _dereq_('../internals/object-property-is-enumerable');
  18182. var createPropertyDescriptor = _dereq_('../internals/create-property-descriptor');
  18183. var toIndexedObject = _dereq_('../internals/to-indexed-object');
  18184. var toPropertyKey = _dereq_('../internals/to-property-key');
  18185. var hasOwn = _dereq_('../internals/has-own-property');
  18186. var IE8_DOM_DEFINE = _dereq_('../internals/ie8-dom-define');
  18187. // eslint-disable-next-line es/no-object-getownpropertydescriptor -- safe
  18188. var $getOwnPropertyDescriptor = Object.getOwnPropertyDescriptor;
  18189. // `Object.getOwnPropertyDescriptor` method
  18190. // https://tc39.es/ecma262/#sec-object.getownpropertydescriptor
  18191. exports.f = DESCRIPTORS ? $getOwnPropertyDescriptor : function getOwnPropertyDescriptor(O, P) {
  18192. O = toIndexedObject(O);
  18193. P = toPropertyKey(P);
  18194. if (IE8_DOM_DEFINE) try {
  18195. return $getOwnPropertyDescriptor(O, P);
  18196. } catch (error) { /* empty */ }
  18197. if (hasOwn(O, P)) return createPropertyDescriptor(!call(propertyIsEnumerableModule.f, O, P), O[P]);
  18198. };
  18199. },{"../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){
  18200. /* eslint-disable es/no-object-getownpropertynames -- safe */
  18201. var classof = _dereq_('../internals/classof-raw');
  18202. var toIndexedObject = _dereq_('../internals/to-indexed-object');
  18203. var $getOwnPropertyNames = _dereq_('../internals/object-get-own-property-names').f;
  18204. var arraySlice = _dereq_('../internals/array-slice-simple');
  18205. var windowNames = typeof window == 'object' && window && Object.getOwnPropertyNames
  18206. ? Object.getOwnPropertyNames(window) : [];
  18207. var getWindowNames = function (it) {
  18208. try {
  18209. return $getOwnPropertyNames(it);
  18210. } catch (error) {
  18211. return arraySlice(windowNames);
  18212. }
  18213. };
  18214. // fallback for IE11 buggy Object.getOwnPropertyNames with iframe and window
  18215. module.exports.f = function getOwnPropertyNames(it) {
  18216. return windowNames && classof(it) == 'Window'
  18217. ? getWindowNames(it)
  18218. : $getOwnPropertyNames(toIndexedObject(it));
  18219. };
  18220. },{"../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){
  18221. var internalObjectKeys = _dereq_('../internals/object-keys-internal');
  18222. var enumBugKeys = _dereq_('../internals/enum-bug-keys');
  18223. var hiddenKeys = enumBugKeys.concat('length', 'prototype');
  18224. // `Object.getOwnPropertyNames` method
  18225. // https://tc39.es/ecma262/#sec-object.getownpropertynames
  18226. // eslint-disable-next-line es/no-object-getownpropertynames -- safe
  18227. exports.f = Object.getOwnPropertyNames || function getOwnPropertyNames(O) {
  18228. return internalObjectKeys(O, hiddenKeys);
  18229. };
  18230. },{"../internals/enum-bug-keys":230,"../internals/object-keys-internal":297}],293:[function(_dereq_,module,exports){
  18231. // eslint-disable-next-line es/no-object-getownpropertysymbols -- safe
  18232. exports.f = Object.getOwnPropertySymbols;
  18233. },{}],294:[function(_dereq_,module,exports){
  18234. var hasOwn = _dereq_('../internals/has-own-property');
  18235. var isCallable = _dereq_('../internals/is-callable');
  18236. var toObject = _dereq_('../internals/to-object');
  18237. var sharedKey = _dereq_('../internals/shared-key');
  18238. var CORRECT_PROTOTYPE_GETTER = _dereq_('../internals/correct-prototype-getter');
  18239. var IE_PROTO = sharedKey('IE_PROTO');
  18240. var $Object = Object;
  18241. var ObjectPrototype = $Object.prototype;
  18242. // `Object.getPrototypeOf` method
  18243. // https://tc39.es/ecma262/#sec-object.getprototypeof
  18244. // eslint-disable-next-line es/no-object-getprototypeof -- safe
  18245. module.exports = CORRECT_PROTOTYPE_GETTER ? $Object.getPrototypeOf : function (O) {
  18246. var object = toObject(O);
  18247. if (hasOwn(object, IE_PROTO)) return object[IE_PROTO];
  18248. var constructor = object.constructor;
  18249. if (isCallable(constructor) && object instanceof constructor) {
  18250. return constructor.prototype;
  18251. } return object instanceof $Object ? ObjectPrototype : null;
  18252. };
  18253. },{"../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){
  18254. var fails = _dereq_('../internals/fails');
  18255. var isObject = _dereq_('../internals/is-object');
  18256. var classof = _dereq_('../internals/classof-raw');
  18257. var ARRAY_BUFFER_NON_EXTENSIBLE = _dereq_('../internals/array-buffer-non-extensible');
  18258. // eslint-disable-next-line es/no-object-isextensible -- safe
  18259. var $isExtensible = Object.isExtensible;
  18260. var FAILS_ON_PRIMITIVES = fails(function () { $isExtensible(1); });
  18261. // `Object.isExtensible` method
  18262. // https://tc39.es/ecma262/#sec-object.isextensible
  18263. module.exports = (FAILS_ON_PRIMITIVES || ARRAY_BUFFER_NON_EXTENSIBLE) ? function isExtensible(it) {
  18264. if (!isObject(it)) return false;
  18265. if (ARRAY_BUFFER_NON_EXTENSIBLE && classof(it) == 'ArrayBuffer') return false;
  18266. return $isExtensible ? $isExtensible(it) : true;
  18267. } : $isExtensible;
  18268. },{"../internals/array-buffer-non-extensible":179,"../internals/classof-raw":195,"../internals/fails":235,"../internals/is-object":269}],296:[function(_dereq_,module,exports){
  18269. var uncurryThis = _dereq_('../internals/function-uncurry-this');
  18270. module.exports = uncurryThis({}.isPrototypeOf);
  18271. },{"../internals/function-uncurry-this":245}],297:[function(_dereq_,module,exports){
  18272. var uncurryThis = _dereq_('../internals/function-uncurry-this');
  18273. var hasOwn = _dereq_('../internals/has-own-property');
  18274. var toIndexedObject = _dereq_('../internals/to-indexed-object');
  18275. var indexOf = _dereq_('../internals/array-includes').indexOf;
  18276. var hiddenKeys = _dereq_('../internals/hidden-keys');
  18277. var push = uncurryThis([].push);
  18278. module.exports = function (object, names) {
  18279. var O = toIndexedObject(object);
  18280. var i = 0;
  18281. var result = [];
  18282. var key;
  18283. for (key in O) !hasOwn(hiddenKeys, key) && hasOwn(O, key) && push(result, key);
  18284. // Don't enum bug & hidden keys
  18285. while (names.length > i) if (hasOwn(O, key = names[i++])) {
  18286. ~indexOf(result, key) || push(result, key);
  18287. }
  18288. return result;
  18289. };
  18290. },{"../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){
  18291. var internalObjectKeys = _dereq_('../internals/object-keys-internal');
  18292. var enumBugKeys = _dereq_('../internals/enum-bug-keys');
  18293. // `Object.keys` method
  18294. // https://tc39.es/ecma262/#sec-object.keys
  18295. // eslint-disable-next-line es/no-object-keys -- safe
  18296. module.exports = Object.keys || function keys(O) {
  18297. return internalObjectKeys(O, enumBugKeys);
  18298. };
  18299. },{"../internals/enum-bug-keys":230,"../internals/object-keys-internal":297}],299:[function(_dereq_,module,exports){
  18300. 'use strict';
  18301. var $propertyIsEnumerable = {}.propertyIsEnumerable;
  18302. // eslint-disable-next-line es/no-object-getownpropertydescriptor -- safe
  18303. var getOwnPropertyDescriptor = Object.getOwnPropertyDescriptor;
  18304. // Nashorn ~ JDK8 bug
  18305. var NASHORN_BUG = getOwnPropertyDescriptor && !$propertyIsEnumerable.call({ 1: 2 }, 1);
  18306. // `Object.prototype.propertyIsEnumerable` method implementation
  18307. // https://tc39.es/ecma262/#sec-object.prototype.propertyisenumerable
  18308. exports.f = NASHORN_BUG ? function propertyIsEnumerable(V) {
  18309. var descriptor = getOwnPropertyDescriptor(this, V);
  18310. return !!descriptor && descriptor.enumerable;
  18311. } : $propertyIsEnumerable;
  18312. },{}],300:[function(_dereq_,module,exports){
  18313. /* eslint-disable no-proto -- safe */
  18314. var uncurryThisAccessor = _dereq_('../internals/function-uncurry-this-accessor');
  18315. var anObject = _dereq_('../internals/an-object');
  18316. var aPossiblePrototype = _dereq_('../internals/a-possible-prototype');
  18317. // `Object.setPrototypeOf` method
  18318. // https://tc39.es/ecma262/#sec-object.setprototypeof
  18319. // Works with __proto__ only. Old v8 can't work with null proto objects.
  18320. // eslint-disable-next-line es/no-object-setprototypeof -- safe
  18321. module.exports = Object.setPrototypeOf || ('__proto__' in {} ? function () {
  18322. var CORRECT_SETTER = false;
  18323. var test = {};
  18324. var setter;
  18325. try {
  18326. setter = uncurryThisAccessor(Object.prototype, '__proto__', 'set');
  18327. setter(test, []);
  18328. CORRECT_SETTER = test instanceof Array;
  18329. } catch (error) { /* empty */ }
  18330. return function setPrototypeOf(O, proto) {
  18331. anObject(O);
  18332. aPossiblePrototype(proto);
  18333. if (CORRECT_SETTER) setter(O, proto);
  18334. else O.__proto__ = proto;
  18335. return O;
  18336. };
  18337. }() : undefined);
  18338. },{"../internals/a-possible-prototype":175,"../internals/an-object":178,"../internals/function-uncurry-this-accessor":243}],301:[function(_dereq_,module,exports){
  18339. var DESCRIPTORS = _dereq_('../internals/descriptors');
  18340. var uncurryThis = _dereq_('../internals/function-uncurry-this');
  18341. var objectKeys = _dereq_('../internals/object-keys');
  18342. var toIndexedObject = _dereq_('../internals/to-indexed-object');
  18343. var $propertyIsEnumerable = _dereq_('../internals/object-property-is-enumerable').f;
  18344. var propertyIsEnumerable = uncurryThis($propertyIsEnumerable);
  18345. var push = uncurryThis([].push);
  18346. // `Object.{ entries, values }` methods implementation
  18347. var createMethod = function (TO_ENTRIES) {
  18348. return function (it) {
  18349. var O = toIndexedObject(it);
  18350. var keys = objectKeys(O);
  18351. var length = keys.length;
  18352. var i = 0;
  18353. var result = [];
  18354. var key;
  18355. while (length > i) {
  18356. key = keys[i++];
  18357. if (!DESCRIPTORS || propertyIsEnumerable(O, key)) {
  18358. push(result, TO_ENTRIES ? [key, O[key]] : O[key]);
  18359. }
  18360. }
  18361. return result;
  18362. };
  18363. };
  18364. module.exports = {
  18365. // `Object.entries` method
  18366. // https://tc39.es/ecma262/#sec-object.entries
  18367. entries: createMethod(true),
  18368. // `Object.values` method
  18369. // https://tc39.es/ecma262/#sec-object.values
  18370. values: createMethod(false)
  18371. };
  18372. },{"../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){
  18373. 'use strict';
  18374. var TO_STRING_TAG_SUPPORT = _dereq_('../internals/to-string-tag-support');
  18375. var classof = _dereq_('../internals/classof');
  18376. // `Object.prototype.toString` method implementation
  18377. // https://tc39.es/ecma262/#sec-object.prototype.tostring
  18378. module.exports = TO_STRING_TAG_SUPPORT ? {}.toString : function toString() {
  18379. return '[object ' + classof(this) + ']';
  18380. };
  18381. },{"../internals/classof":196,"../internals/to-string-tag-support":333}],303:[function(_dereq_,module,exports){
  18382. var call = _dereq_('../internals/function-call');
  18383. var isCallable = _dereq_('../internals/is-callable');
  18384. var isObject = _dereq_('../internals/is-object');
  18385. var $TypeError = TypeError;
  18386. // `OrdinaryToPrimitive` abstract operation
  18387. // https://tc39.es/ecma262/#sec-ordinarytoprimitive
  18388. module.exports = function (input, pref) {
  18389. var fn, val;
  18390. if (pref === 'string' && isCallable(fn = input.toString) && !isObject(val = call(fn, input))) return val;
  18391. if (isCallable(fn = input.valueOf) && !isObject(val = call(fn, input))) return val;
  18392. if (pref !== 'string' && isCallable(fn = input.toString) && !isObject(val = call(fn, input))) return val;
  18393. throw $TypeError("Can't convert object to primitive value");
  18394. };
  18395. },{"../internals/function-call":241,"../internals/is-callable":264,"../internals/is-object":269}],304:[function(_dereq_,module,exports){
  18396. var getBuiltIn = _dereq_('../internals/get-built-in');
  18397. var uncurryThis = _dereq_('../internals/function-uncurry-this');
  18398. var getOwnPropertyNamesModule = _dereq_('../internals/object-get-own-property-names');
  18399. var getOwnPropertySymbolsModule = _dereq_('../internals/object-get-own-property-symbols');
  18400. var anObject = _dereq_('../internals/an-object');
  18401. var concat = uncurryThis([].concat);
  18402. // all object keys, includes non-enumerable and symbols
  18403. module.exports = getBuiltIn('Reflect', 'ownKeys') || function ownKeys(it) {
  18404. var keys = getOwnPropertyNamesModule.f(anObject(it));
  18405. var getOwnPropertySymbols = getOwnPropertySymbolsModule.f;
  18406. return getOwnPropertySymbols ? concat(keys, getOwnPropertySymbols(it)) : keys;
  18407. };
  18408. },{"../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){
  18409. arguments[4][253][0].apply(exports,arguments)
  18410. },{"dup":253}],306:[function(_dereq_,module,exports){
  18411. module.exports = function (exec) {
  18412. try {
  18413. return { error: false, value: exec() };
  18414. } catch (error) {
  18415. return { error: true, value: error };
  18416. }
  18417. };
  18418. },{}],307:[function(_dereq_,module,exports){
  18419. var global = _dereq_('../internals/global');
  18420. var NativePromiseConstructor = _dereq_('../internals/promise-native-constructor');
  18421. var isCallable = _dereq_('../internals/is-callable');
  18422. var isForced = _dereq_('../internals/is-forced');
  18423. var inspectSource = _dereq_('../internals/inspect-source');
  18424. var wellKnownSymbol = _dereq_('../internals/well-known-symbol');
  18425. var IS_BROWSER = _dereq_('../internals/engine-is-browser');
  18426. var IS_DENO = _dereq_('../internals/engine-is-deno');
  18427. var IS_PURE = _dereq_('../internals/is-pure');
  18428. var V8_VERSION = _dereq_('../internals/engine-v8-version');
  18429. var NativePromisePrototype = NativePromiseConstructor && NativePromiseConstructor.prototype;
  18430. var SPECIES = wellKnownSymbol('species');
  18431. var SUBCLASSING = false;
  18432. var NATIVE_PROMISE_REJECTION_EVENT = isCallable(global.PromiseRejectionEvent);
  18433. var FORCED_PROMISE_CONSTRUCTOR = isForced('Promise', function () {
  18434. var PROMISE_CONSTRUCTOR_SOURCE = inspectSource(NativePromiseConstructor);
  18435. var GLOBAL_CORE_JS_PROMISE = PROMISE_CONSTRUCTOR_SOURCE !== String(NativePromiseConstructor);
  18436. // V8 6.6 (Node 10 and Chrome 66) have a bug with resolving custom thenables
  18437. // https://bugs.chromium.org/p/chromium/issues/detail?id=830565
  18438. // We can't detect it synchronously, so just check versions
  18439. if (!GLOBAL_CORE_JS_PROMISE && V8_VERSION === 66) return true;
  18440. // We need Promise#{ catch, finally } in the pure version for preventing prototype pollution
  18441. if (IS_PURE && !(NativePromisePrototype['catch'] && NativePromisePrototype['finally'])) return true;
  18442. // We can't use @@species feature detection in V8 since it causes
  18443. // deoptimization and performance degradation
  18444. // https://github.com/zloirock/core-js/issues/679
  18445. if (!V8_VERSION || V8_VERSION < 51 || !/native code/.test(PROMISE_CONSTRUCTOR_SOURCE)) {
  18446. // Detect correctness of subclassing with @@species support
  18447. var promise = new NativePromiseConstructor(function (resolve) { resolve(1); });
  18448. var FakePromise = function (exec) {
  18449. exec(function () { /* empty */ }, function () { /* empty */ });
  18450. };
  18451. var constructor = promise.constructor = {};
  18452. constructor[SPECIES] = FakePromise;
  18453. SUBCLASSING = promise.then(function () { /* empty */ }) instanceof FakePromise;
  18454. if (!SUBCLASSING) return true;
  18455. // Unhandled rejections tracking support, NodeJS Promise without it fails @@species test
  18456. } return !GLOBAL_CORE_JS_PROMISE && (IS_BROWSER || IS_DENO) && !NATIVE_PROMISE_REJECTION_EVENT;
  18457. });
  18458. module.exports = {
  18459. CONSTRUCTOR: FORCED_PROMISE_CONSTRUCTOR,
  18460. REJECTION_EVENT: NATIVE_PROMISE_REJECTION_EVENT,
  18461. SUBCLASSING: SUBCLASSING
  18462. };
  18463. },{"../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){
  18464. var global = _dereq_('../internals/global');
  18465. module.exports = global.Promise;
  18466. },{"../internals/global":251}],309:[function(_dereq_,module,exports){
  18467. var anObject = _dereq_('../internals/an-object');
  18468. var isObject = _dereq_('../internals/is-object');
  18469. var newPromiseCapability = _dereq_('../internals/new-promise-capability');
  18470. module.exports = function (C, x) {
  18471. anObject(C);
  18472. if (isObject(x) && x.constructor === C) return x;
  18473. var promiseCapability = newPromiseCapability.f(C);
  18474. var resolve = promiseCapability.resolve;
  18475. resolve(x);
  18476. return promiseCapability.promise;
  18477. };
  18478. },{"../internals/an-object":178,"../internals/is-object":269,"../internals/new-promise-capability":282}],310:[function(_dereq_,module,exports){
  18479. var NativePromiseConstructor = _dereq_('../internals/promise-native-constructor');
  18480. var checkCorrectnessOfIteration = _dereq_('../internals/check-correctness-of-iteration');
  18481. var FORCED_PROMISE_CONSTRUCTOR = _dereq_('../internals/promise-constructor-detection').CONSTRUCTOR;
  18482. module.exports = FORCED_PROMISE_CONSTRUCTOR || !checkCorrectnessOfIteration(function (iterable) {
  18483. NativePromiseConstructor.all(iterable).then(undefined, function () { /* empty */ });
  18484. });
  18485. },{"../internals/check-correctness-of-iteration":194,"../internals/promise-constructor-detection":307,"../internals/promise-native-constructor":308}],311:[function(_dereq_,module,exports){
  18486. var Queue = function () {
  18487. this.head = null;
  18488. this.tail = null;
  18489. };
  18490. Queue.prototype = {
  18491. add: function (item) {
  18492. var entry = { item: item, next: null };
  18493. var tail = this.tail;
  18494. if (tail) tail.next = entry;
  18495. else this.head = entry;
  18496. this.tail = entry;
  18497. },
  18498. get: function () {
  18499. var entry = this.head;
  18500. if (entry) {
  18501. var next = this.head = entry.next;
  18502. if (next === null) this.tail = null;
  18503. return entry.item;
  18504. }
  18505. }
  18506. };
  18507. module.exports = Queue;
  18508. },{}],312:[function(_dereq_,module,exports){
  18509. var isNullOrUndefined = _dereq_('../internals/is-null-or-undefined');
  18510. var $TypeError = TypeError;
  18511. // `RequireObjectCoercible` abstract operation
  18512. // https://tc39.es/ecma262/#sec-requireobjectcoercible
  18513. module.exports = function (it) {
  18514. if (isNullOrUndefined(it)) throw $TypeError("Can't call method on " + it);
  18515. return it;
  18516. };
  18517. },{"../internals/is-null-or-undefined":268}],313:[function(_dereq_,module,exports){
  18518. 'use strict';
  18519. var global = _dereq_('../internals/global');
  18520. var apply = _dereq_('../internals/function-apply');
  18521. var isCallable = _dereq_('../internals/is-callable');
  18522. var ENGINE_IS_BUN = _dereq_('../internals/engine-is-bun');
  18523. var USER_AGENT = _dereq_('../internals/engine-user-agent');
  18524. var arraySlice = _dereq_('../internals/array-slice');
  18525. var validateArgumentsLength = _dereq_('../internals/validate-arguments-length');
  18526. var Function = global.Function;
  18527. // dirty IE9- and Bun 0.3.0- checks
  18528. var WRAP = /MSIE .\./.test(USER_AGENT) || ENGINE_IS_BUN && (function () {
  18529. var version = global.Bun.version.split('.');
  18530. return version.length < 3 || version[0] == 0 && (version[1] < 3 || version[1] == 3 && version[2] == 0);
  18531. })();
  18532. // IE9- / Bun 0.3.0- setTimeout / setInterval / setImmediate additional parameters fix
  18533. // https://html.spec.whatwg.org/multipage/timers-and-user-prompts.html#timers
  18534. // https://github.com/oven-sh/bun/issues/1633
  18535. module.exports = function (scheduler, hasTimeArg) {
  18536. var firstParamIndex = hasTimeArg ? 2 : 1;
  18537. return WRAP ? function (handler, timeout /* , ...arguments */) {
  18538. var boundArgs = validateArgumentsLength(arguments.length, 1) > firstParamIndex;
  18539. var fn = isCallable(handler) ? handler : Function(handler);
  18540. var params = boundArgs ? arraySlice(arguments, firstParamIndex) : [];
  18541. var callback = boundArgs ? function () {
  18542. apply(fn, this, params);
  18543. } : fn;
  18544. return hasTimeArg ? scheduler(callback, timeout) : scheduler(callback);
  18545. } : scheduler;
  18546. };
  18547. },{"../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){
  18548. 'use strict';
  18549. var getBuiltIn = _dereq_('../internals/get-built-in');
  18550. var defineBuiltInAccessor = _dereq_('../internals/define-built-in-accessor');
  18551. var wellKnownSymbol = _dereq_('../internals/well-known-symbol');
  18552. var DESCRIPTORS = _dereq_('../internals/descriptors');
  18553. var SPECIES = wellKnownSymbol('species');
  18554. module.exports = function (CONSTRUCTOR_NAME) {
  18555. var Constructor = getBuiltIn(CONSTRUCTOR_NAME);
  18556. if (DESCRIPTORS && Constructor && !Constructor[SPECIES]) {
  18557. defineBuiltInAccessor(Constructor, SPECIES, {
  18558. configurable: true,
  18559. get: function () { return this; }
  18560. });
  18561. }
  18562. };
  18563. },{"../internals/define-built-in-accessor":207,"../internals/descriptors":212,"../internals/get-built-in":246,"../internals/well-known-symbol":343}],315:[function(_dereq_,module,exports){
  18564. var TO_STRING_TAG_SUPPORT = _dereq_('../internals/to-string-tag-support');
  18565. var defineProperty = _dereq_('../internals/object-define-property').f;
  18566. var createNonEnumerableProperty = _dereq_('../internals/create-non-enumerable-property');
  18567. var hasOwn = _dereq_('../internals/has-own-property');
  18568. var toString = _dereq_('../internals/object-to-string');
  18569. var wellKnownSymbol = _dereq_('../internals/well-known-symbol');
  18570. var TO_STRING_TAG = wellKnownSymbol('toStringTag');
  18571. module.exports = function (it, TAG, STATIC, SET_METHOD) {
  18572. if (it) {
  18573. var target = STATIC ? it : it.prototype;
  18574. if (!hasOwn(target, TO_STRING_TAG)) {
  18575. defineProperty(target, TO_STRING_TAG, { configurable: true, value: TAG });
  18576. }
  18577. if (SET_METHOD && !TO_STRING_TAG_SUPPORT) {
  18578. createNonEnumerableProperty(target, 'toString', toString);
  18579. }
  18580. }
  18581. };
  18582. },{"../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){
  18583. var shared = _dereq_('../internals/shared');
  18584. var uid = _dereq_('../internals/uid');
  18585. var keys = shared('keys');
  18586. module.exports = function (key) {
  18587. return keys[key] || (keys[key] = uid(key));
  18588. };
  18589. },{"../internals/shared":318,"../internals/uid":336}],317:[function(_dereq_,module,exports){
  18590. var global = _dereq_('../internals/global');
  18591. var defineGlobalProperty = _dereq_('../internals/define-global-property');
  18592. var SHARED = '__core-js_shared__';
  18593. var store = global[SHARED] || defineGlobalProperty(SHARED, {});
  18594. module.exports = store;
  18595. },{"../internals/define-global-property":210,"../internals/global":251}],318:[function(_dereq_,module,exports){
  18596. var IS_PURE = _dereq_('../internals/is-pure');
  18597. var store = _dereq_('../internals/shared-store');
  18598. (module.exports = function (key, value) {
  18599. return store[key] || (store[key] = value !== undefined ? value : {});
  18600. })('versions', []).push({
  18601. version: '3.30.2',
  18602. mode: IS_PURE ? 'pure' : 'global',
  18603. copyright: '© 2014-2023 Denis Pushkarev (zloirock.ru)',
  18604. license: 'https://github.com/zloirock/core-js/blob/v3.30.2/LICENSE',
  18605. source: 'https://github.com/zloirock/core-js'
  18606. });
  18607. },{"../internals/is-pure":270,"../internals/shared-store":317}],319:[function(_dereq_,module,exports){
  18608. var anObject = _dereq_('../internals/an-object');
  18609. var aConstructor = _dereq_('../internals/a-constructor');
  18610. var isNullOrUndefined = _dereq_('../internals/is-null-or-undefined');
  18611. var wellKnownSymbol = _dereq_('../internals/well-known-symbol');
  18612. var SPECIES = wellKnownSymbol('species');
  18613. // `SpeciesConstructor` abstract operation
  18614. // https://tc39.es/ecma262/#sec-speciesconstructor
  18615. module.exports = function (O, defaultConstructor) {
  18616. var C = anObject(O).constructor;
  18617. var S;
  18618. return C === undefined || isNullOrUndefined(S = anObject(C)[SPECIES]) ? defaultConstructor : aConstructor(S);
  18619. };
  18620. },{"../internals/a-constructor":174,"../internals/an-object":178,"../internals/is-null-or-undefined":268,"../internals/well-known-symbol":343}],320:[function(_dereq_,module,exports){
  18621. var uncurryThis = _dereq_('../internals/function-uncurry-this');
  18622. var toIntegerOrInfinity = _dereq_('../internals/to-integer-or-infinity');
  18623. var toString = _dereq_('../internals/to-string');
  18624. var requireObjectCoercible = _dereq_('../internals/require-object-coercible');
  18625. var charAt = uncurryThis(''.charAt);
  18626. var charCodeAt = uncurryThis(''.charCodeAt);
  18627. var stringSlice = uncurryThis(''.slice);
  18628. var createMethod = function (CONVERT_TO_STRING) {
  18629. return function ($this, pos) {
  18630. var S = toString(requireObjectCoercible($this));
  18631. var position = toIntegerOrInfinity(pos);
  18632. var size = S.length;
  18633. var first, second;
  18634. if (position < 0 || position >= size) return CONVERT_TO_STRING ? '' : undefined;
  18635. first = charCodeAt(S, position);
  18636. return first < 0xD800 || first > 0xDBFF || position + 1 === size
  18637. || (second = charCodeAt(S, position + 1)) < 0xDC00 || second > 0xDFFF
  18638. ? CONVERT_TO_STRING
  18639. ? charAt(S, position)
  18640. : first
  18641. : CONVERT_TO_STRING
  18642. ? stringSlice(S, position, position + 2)
  18643. : (first - 0xD800 << 10) + (second - 0xDC00) + 0x10000;
  18644. };
  18645. };
  18646. module.exports = {
  18647. // `String.prototype.codePointAt` method
  18648. // https://tc39.es/ecma262/#sec-string.prototype.codepointat
  18649. codeAt: createMethod(false),
  18650. // `String.prototype.at` method
  18651. // https://github.com/mathiasbynens/String.prototype.at
  18652. charAt: createMethod(true)
  18653. };
  18654. },{"../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){
  18655. var uncurryThis = _dereq_('../internals/function-uncurry-this');
  18656. var requireObjectCoercible = _dereq_('../internals/require-object-coercible');
  18657. var toString = _dereq_('../internals/to-string');
  18658. var whitespaces = _dereq_('../internals/whitespaces');
  18659. var replace = uncurryThis(''.replace);
  18660. var ltrim = RegExp('^[' + whitespaces + ']+');
  18661. var rtrim = RegExp('(^|[^' + whitespaces + '])[' + whitespaces + ']+$');
  18662. // `String.prototype.{ trim, trimStart, trimEnd, trimLeft, trimRight }` methods implementation
  18663. var createMethod = function (TYPE) {
  18664. return function ($this) {
  18665. var string = toString(requireObjectCoercible($this));
  18666. if (TYPE & 1) string = replace(string, ltrim, '');
  18667. if (TYPE & 2) string = replace(string, rtrim, '$1');
  18668. return string;
  18669. };
  18670. };
  18671. module.exports = {
  18672. // `String.prototype.{ trimLeft, trimStart }` methods
  18673. // https://tc39.es/ecma262/#sec-string.prototype.trimstart
  18674. start: createMethod(1),
  18675. // `String.prototype.{ trimRight, trimEnd }` methods
  18676. // https://tc39.es/ecma262/#sec-string.prototype.trimend
  18677. end: createMethod(2),
  18678. // `String.prototype.trim` method
  18679. // https://tc39.es/ecma262/#sec-string.prototype.trim
  18680. trim: createMethod(3)
  18681. };
  18682. },{"../internals/function-uncurry-this":245,"../internals/require-object-coercible":312,"../internals/to-string":334,"../internals/whitespaces":344}],322:[function(_dereq_,module,exports){
  18683. /* eslint-disable es/no-symbol -- required for testing */
  18684. var V8_VERSION = _dereq_('../internals/engine-v8-version');
  18685. var fails = _dereq_('../internals/fails');
  18686. var global = _dereq_('../internals/global');
  18687. var $String = global.String;
  18688. // eslint-disable-next-line es/no-object-getownpropertysymbols -- required for testing
  18689. module.exports = !!Object.getOwnPropertySymbols && !fails(function () {
  18690. var symbol = Symbol();
  18691. // Chrome 38 Symbol has incorrect toString conversion
  18692. // `get-own-property-symbols` polyfill symbols converted to object are not Symbol instances
  18693. // nb: Do not call `String` directly to avoid this being optimized out to `symbol+''` which will,
  18694. // of course, fail.
  18695. return !$String(symbol) || !(Object(symbol) instanceof Symbol) ||
  18696. // Chrome 38-40 symbols are not inherited from DOM collections prototypes to instances
  18697. !Symbol.sham && V8_VERSION && V8_VERSION < 41;
  18698. });
  18699. },{"../internals/engine-v8-version":227,"../internals/fails":235,"../internals/global":251}],323:[function(_dereq_,module,exports){
  18700. var call = _dereq_('../internals/function-call');
  18701. var getBuiltIn = _dereq_('../internals/get-built-in');
  18702. var wellKnownSymbol = _dereq_('../internals/well-known-symbol');
  18703. var defineBuiltIn = _dereq_('../internals/define-built-in');
  18704. module.exports = function () {
  18705. var Symbol = getBuiltIn('Symbol');
  18706. var SymbolPrototype = Symbol && Symbol.prototype;
  18707. var valueOf = SymbolPrototype && SymbolPrototype.valueOf;
  18708. var TO_PRIMITIVE = wellKnownSymbol('toPrimitive');
  18709. if (SymbolPrototype && !SymbolPrototype[TO_PRIMITIVE]) {
  18710. // `Symbol.prototype[@@toPrimitive]` method
  18711. // https://tc39.es/ecma262/#sec-symbol.prototype-@@toprimitive
  18712. // eslint-disable-next-line no-unused-vars -- required for .length
  18713. defineBuiltIn(SymbolPrototype, TO_PRIMITIVE, function (hint) {
  18714. return call(valueOf, this);
  18715. }, { arity: 1 });
  18716. }
  18717. };
  18718. },{"../internals/define-built-in":208,"../internals/function-call":241,"../internals/get-built-in":246,"../internals/well-known-symbol":343}],324:[function(_dereq_,module,exports){
  18719. var NATIVE_SYMBOL = _dereq_('../internals/symbol-constructor-detection');
  18720. /* eslint-disable es/no-symbol -- safe */
  18721. module.exports = NATIVE_SYMBOL && !!Symbol['for'] && !!Symbol.keyFor;
  18722. },{"../internals/symbol-constructor-detection":322}],325:[function(_dereq_,module,exports){
  18723. var global = _dereq_('../internals/global');
  18724. var apply = _dereq_('../internals/function-apply');
  18725. var bind = _dereq_('../internals/function-bind-context');
  18726. var isCallable = _dereq_('../internals/is-callable');
  18727. var hasOwn = _dereq_('../internals/has-own-property');
  18728. var fails = _dereq_('../internals/fails');
  18729. var html = _dereq_('../internals/html');
  18730. var arraySlice = _dereq_('../internals/array-slice');
  18731. var createElement = _dereq_('../internals/document-create-element');
  18732. var validateArgumentsLength = _dereq_('../internals/validate-arguments-length');
  18733. var IS_IOS = _dereq_('../internals/engine-is-ios');
  18734. var IS_NODE = _dereq_('../internals/engine-is-node');
  18735. var set = global.setImmediate;
  18736. var clear = global.clearImmediate;
  18737. var process = global.process;
  18738. var Dispatch = global.Dispatch;
  18739. var Function = global.Function;
  18740. var MessageChannel = global.MessageChannel;
  18741. var String = global.String;
  18742. var counter = 0;
  18743. var queue = {};
  18744. var ONREADYSTATECHANGE = 'onreadystatechange';
  18745. var $location, defer, channel, port;
  18746. fails(function () {
  18747. // Deno throws a ReferenceError on `location` access without `--location` flag
  18748. $location = global.location;
  18749. });
  18750. var run = function (id) {
  18751. if (hasOwn(queue, id)) {
  18752. var fn = queue[id];
  18753. delete queue[id];
  18754. fn();
  18755. }
  18756. };
  18757. var runner = function (id) {
  18758. return function () {
  18759. run(id);
  18760. };
  18761. };
  18762. var eventListener = function (event) {
  18763. run(event.data);
  18764. };
  18765. var globalPostMessageDefer = function (id) {
  18766. // old engines have not location.origin
  18767. global.postMessage(String(id), $location.protocol + '//' + $location.host);
  18768. };
  18769. // Node.js 0.9+ & IE10+ has setImmediate, otherwise:
  18770. if (!set || !clear) {
  18771. set = function setImmediate(handler) {
  18772. validateArgumentsLength(arguments.length, 1);
  18773. var fn = isCallable(handler) ? handler : Function(handler);
  18774. var args = arraySlice(arguments, 1);
  18775. queue[++counter] = function () {
  18776. apply(fn, undefined, args);
  18777. };
  18778. defer(counter);
  18779. return counter;
  18780. };
  18781. clear = function clearImmediate(id) {
  18782. delete queue[id];
  18783. };
  18784. // Node.js 0.8-
  18785. if (IS_NODE) {
  18786. defer = function (id) {
  18787. process.nextTick(runner(id));
  18788. };
  18789. // Sphere (JS game engine) Dispatch API
  18790. } else if (Dispatch && Dispatch.now) {
  18791. defer = function (id) {
  18792. Dispatch.now(runner(id));
  18793. };
  18794. // Browsers with MessageChannel, includes WebWorkers
  18795. // except iOS - https://github.com/zloirock/core-js/issues/624
  18796. } else if (MessageChannel && !IS_IOS) {
  18797. channel = new MessageChannel();
  18798. port = channel.port2;
  18799. channel.port1.onmessage = eventListener;
  18800. defer = bind(port.postMessage, port);
  18801. // Browsers with postMessage, skip WebWorkers
  18802. // IE8 has postMessage, but it's sync & typeof its postMessage is 'object'
  18803. } else if (
  18804. global.addEventListener &&
  18805. isCallable(global.postMessage) &&
  18806. !global.importScripts &&
  18807. $location && $location.protocol !== 'file:' &&
  18808. !fails(globalPostMessageDefer)
  18809. ) {
  18810. defer = globalPostMessageDefer;
  18811. global.addEventListener('message', eventListener, false);
  18812. // IE8-
  18813. } else if (ONREADYSTATECHANGE in createElement('script')) {
  18814. defer = function (id) {
  18815. html.appendChild(createElement('script'))[ONREADYSTATECHANGE] = function () {
  18816. html.removeChild(this);
  18817. run(id);
  18818. };
  18819. };
  18820. // Rest old browsers
  18821. } else {
  18822. defer = function (id) {
  18823. setTimeout(runner(id), 0);
  18824. };
  18825. }
  18826. }
  18827. module.exports = {
  18828. set: set,
  18829. clear: clear
  18830. };
  18831. },{"../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){
  18832. var toIntegerOrInfinity = _dereq_('../internals/to-integer-or-infinity');
  18833. var max = Math.max;
  18834. var min = Math.min;
  18835. // Helper for a popular repeating case of the spec:
  18836. // Let integer be ? ToInteger(index).
  18837. // If integer < 0, let result be max((length + integer), 0); else let result be min(integer, length).
  18838. module.exports = function (index, length) {
  18839. var integer = toIntegerOrInfinity(index);
  18840. return integer < 0 ? max(integer + length, 0) : min(integer, length);
  18841. };
  18842. },{"../internals/to-integer-or-infinity":328}],327:[function(_dereq_,module,exports){
  18843. // toObject with fallback for non-array-like ES3 strings
  18844. var IndexedObject = _dereq_('../internals/indexed-object');
  18845. var requireObjectCoercible = _dereq_('../internals/require-object-coercible');
  18846. module.exports = function (it) {
  18847. return IndexedObject(requireObjectCoercible(it));
  18848. };
  18849. },{"../internals/indexed-object":257,"../internals/require-object-coercible":312}],328:[function(_dereq_,module,exports){
  18850. var trunc = _dereq_('../internals/math-trunc');
  18851. // `ToIntegerOrInfinity` abstract operation
  18852. // https://tc39.es/ecma262/#sec-tointegerorinfinity
  18853. module.exports = function (argument) {
  18854. var number = +argument;
  18855. // eslint-disable-next-line no-self-compare -- NaN check
  18856. return number !== number || number === 0 ? 0 : trunc(number);
  18857. };
  18858. },{"../internals/math-trunc":280}],329:[function(_dereq_,module,exports){
  18859. var toIntegerOrInfinity = _dereq_('../internals/to-integer-or-infinity');
  18860. var min = Math.min;
  18861. // `ToLength` abstract operation
  18862. // https://tc39.es/ecma262/#sec-tolength
  18863. module.exports = function (argument) {
  18864. return argument > 0 ? min(toIntegerOrInfinity(argument), 0x1FFFFFFFFFFFFF) : 0; // 2 ** 53 - 1 == 9007199254740991
  18865. };
  18866. },{"../internals/to-integer-or-infinity":328}],330:[function(_dereq_,module,exports){
  18867. var requireObjectCoercible = _dereq_('../internals/require-object-coercible');
  18868. var $Object = Object;
  18869. // `ToObject` abstract operation
  18870. // https://tc39.es/ecma262/#sec-toobject
  18871. module.exports = function (argument) {
  18872. return $Object(requireObjectCoercible(argument));
  18873. };
  18874. },{"../internals/require-object-coercible":312}],331:[function(_dereq_,module,exports){
  18875. var call = _dereq_('../internals/function-call');
  18876. var isObject = _dereq_('../internals/is-object');
  18877. var isSymbol = _dereq_('../internals/is-symbol');
  18878. var getMethod = _dereq_('../internals/get-method');
  18879. var ordinaryToPrimitive = _dereq_('../internals/ordinary-to-primitive');
  18880. var wellKnownSymbol = _dereq_('../internals/well-known-symbol');
  18881. var $TypeError = TypeError;
  18882. var TO_PRIMITIVE = wellKnownSymbol('toPrimitive');
  18883. // `ToPrimitive` abstract operation
  18884. // https://tc39.es/ecma262/#sec-toprimitive
  18885. module.exports = function (input, pref) {
  18886. if (!isObject(input) || isSymbol(input)) return input;
  18887. var exoticToPrim = getMethod(input, TO_PRIMITIVE);
  18888. var result;
  18889. if (exoticToPrim) {
  18890. if (pref === undefined) pref = 'default';
  18891. result = call(exoticToPrim, input, pref);
  18892. if (!isObject(result) || isSymbol(result)) return result;
  18893. throw $TypeError("Can't convert object to primitive value");
  18894. }
  18895. if (pref === undefined) pref = 'number';
  18896. return ordinaryToPrimitive(input, pref);
  18897. };
  18898. },{"../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){
  18899. var toPrimitive = _dereq_('../internals/to-primitive');
  18900. var isSymbol = _dereq_('../internals/is-symbol');
  18901. // `ToPropertyKey` abstract operation
  18902. // https://tc39.es/ecma262/#sec-topropertykey
  18903. module.exports = function (argument) {
  18904. var key = toPrimitive(argument, 'string');
  18905. return isSymbol(key) ? key : key + '';
  18906. };
  18907. },{"../internals/is-symbol":272,"../internals/to-primitive":331}],333:[function(_dereq_,module,exports){
  18908. var wellKnownSymbol = _dereq_('../internals/well-known-symbol');
  18909. var TO_STRING_TAG = wellKnownSymbol('toStringTag');
  18910. var test = {};
  18911. test[TO_STRING_TAG] = 'z';
  18912. module.exports = String(test) === '[object z]';
  18913. },{"../internals/well-known-symbol":343}],334:[function(_dereq_,module,exports){
  18914. var classof = _dereq_('../internals/classof');
  18915. var $String = String;
  18916. module.exports = function (argument) {
  18917. if (classof(argument) === 'Symbol') throw TypeError('Cannot convert a Symbol value to a string');
  18918. return $String(argument);
  18919. };
  18920. },{"../internals/classof":196}],335:[function(_dereq_,module,exports){
  18921. var $String = String;
  18922. module.exports = function (argument) {
  18923. try {
  18924. return $String(argument);
  18925. } catch (error) {
  18926. return 'Object';
  18927. }
  18928. };
  18929. },{}],336:[function(_dereq_,module,exports){
  18930. var uncurryThis = _dereq_('../internals/function-uncurry-this');
  18931. var id = 0;
  18932. var postfix = Math.random();
  18933. var toString = uncurryThis(1.0.toString);
  18934. module.exports = function (key) {
  18935. return 'Symbol(' + (key === undefined ? '' : key) + ')_' + toString(++id + postfix, 36);
  18936. };
  18937. },{"../internals/function-uncurry-this":245}],337:[function(_dereq_,module,exports){
  18938. /* eslint-disable es/no-symbol -- required for testing */
  18939. var NATIVE_SYMBOL = _dereq_('../internals/symbol-constructor-detection');
  18940. module.exports = NATIVE_SYMBOL
  18941. && !Symbol.sham
  18942. && typeof Symbol.iterator == 'symbol';
  18943. },{"../internals/symbol-constructor-detection":322}],338:[function(_dereq_,module,exports){
  18944. var DESCRIPTORS = _dereq_('../internals/descriptors');
  18945. var fails = _dereq_('../internals/fails');
  18946. // V8 ~ Chrome 36-
  18947. // https://bugs.chromium.org/p/v8/issues/detail?id=3334
  18948. module.exports = DESCRIPTORS && fails(function () {
  18949. // eslint-disable-next-line es/no-object-defineproperty -- required for testing
  18950. return Object.defineProperty(function () { /* empty */ }, 'prototype', {
  18951. value: 42,
  18952. writable: false
  18953. }).prototype != 42;
  18954. });
  18955. },{"../internals/descriptors":212,"../internals/fails":235}],339:[function(_dereq_,module,exports){
  18956. var $TypeError = TypeError;
  18957. module.exports = function (passed, required) {
  18958. if (passed < required) throw $TypeError('Not enough arguments');
  18959. return passed;
  18960. };
  18961. },{}],340:[function(_dereq_,module,exports){
  18962. var global = _dereq_('../internals/global');
  18963. var isCallable = _dereq_('../internals/is-callable');
  18964. var WeakMap = global.WeakMap;
  18965. module.exports = isCallable(WeakMap) && /native code/.test(String(WeakMap));
  18966. },{"../internals/global":251,"../internals/is-callable":264}],341:[function(_dereq_,module,exports){
  18967. var path = _dereq_('../internals/path');
  18968. var hasOwn = _dereq_('../internals/has-own-property');
  18969. var wrappedWellKnownSymbolModule = _dereq_('../internals/well-known-symbol-wrapped');
  18970. var defineProperty = _dereq_('../internals/object-define-property').f;
  18971. module.exports = function (NAME) {
  18972. var Symbol = path.Symbol || (path.Symbol = {});
  18973. if (!hasOwn(Symbol, NAME)) defineProperty(Symbol, NAME, {
  18974. value: wrappedWellKnownSymbolModule.f(NAME)
  18975. });
  18976. };
  18977. },{"../internals/has-own-property":252,"../internals/object-define-property":289,"../internals/path":305,"../internals/well-known-symbol-wrapped":342}],342:[function(_dereq_,module,exports){
  18978. var wellKnownSymbol = _dereq_('../internals/well-known-symbol');
  18979. exports.f = wellKnownSymbol;
  18980. },{"../internals/well-known-symbol":343}],343:[function(_dereq_,module,exports){
  18981. var global = _dereq_('../internals/global');
  18982. var shared = _dereq_('../internals/shared');
  18983. var hasOwn = _dereq_('../internals/has-own-property');
  18984. var uid = _dereq_('../internals/uid');
  18985. var NATIVE_SYMBOL = _dereq_('../internals/symbol-constructor-detection');
  18986. var USE_SYMBOL_AS_UID = _dereq_('../internals/use-symbol-as-uid');
  18987. var Symbol = global.Symbol;
  18988. var WellKnownSymbolsStore = shared('wks');
  18989. var createWellKnownSymbol = USE_SYMBOL_AS_UID ? Symbol['for'] || Symbol : Symbol && Symbol.withoutSetter || uid;
  18990. module.exports = function (name) {
  18991. if (!hasOwn(WellKnownSymbolsStore, name)) {
  18992. WellKnownSymbolsStore[name] = NATIVE_SYMBOL && hasOwn(Symbol, name)
  18993. ? Symbol[name]
  18994. : createWellKnownSymbol('Symbol.' + name);
  18995. } return WellKnownSymbolsStore[name];
  18996. };
  18997. },{"../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){
  18998. // a string of all valid unicode whitespaces
  18999. module.exports = '\u0009\u000A\u000B\u000C\u000D\u0020\u00A0\u1680\u2000\u2001\u2002' +
  19000. '\u2003\u2004\u2005\u2006\u2007\u2008\u2009\u200A\u202F\u205F\u3000\u2028\u2029\uFEFF';
  19001. },{}],345:[function(_dereq_,module,exports){
  19002. 'use strict';
  19003. var $ = _dereq_('../internals/export');
  19004. var isPrototypeOf = _dereq_('../internals/object-is-prototype-of');
  19005. var getPrototypeOf = _dereq_('../internals/object-get-prototype-of');
  19006. var setPrototypeOf = _dereq_('../internals/object-set-prototype-of');
  19007. var copyConstructorProperties = _dereq_('../internals/copy-constructor-properties');
  19008. var create = _dereq_('../internals/object-create');
  19009. var createNonEnumerableProperty = _dereq_('../internals/create-non-enumerable-property');
  19010. var createPropertyDescriptor = _dereq_('../internals/create-property-descriptor');
  19011. var installErrorCause = _dereq_('../internals/install-error-cause');
  19012. var installErrorStack = _dereq_('../internals/error-stack-install');
  19013. var iterate = _dereq_('../internals/iterate');
  19014. var normalizeStringArgument = _dereq_('../internals/normalize-string-argument');
  19015. var wellKnownSymbol = _dereq_('../internals/well-known-symbol');
  19016. var TO_STRING_TAG = wellKnownSymbol('toStringTag');
  19017. var $Error = Error;
  19018. var push = [].push;
  19019. var $AggregateError = function AggregateError(errors, message /* , options */) {
  19020. var isInstance = isPrototypeOf(AggregateErrorPrototype, this);
  19021. var that;
  19022. if (setPrototypeOf) {
  19023. that = setPrototypeOf($Error(), isInstance ? getPrototypeOf(this) : AggregateErrorPrototype);
  19024. } else {
  19025. that = isInstance ? this : create(AggregateErrorPrototype);
  19026. createNonEnumerableProperty(that, TO_STRING_TAG, 'Error');
  19027. }
  19028. if (message !== undefined) createNonEnumerableProperty(that, 'message', normalizeStringArgument(message));
  19029. installErrorStack(that, $AggregateError, that.stack, 1);
  19030. if (arguments.length > 2) installErrorCause(that, arguments[2]);
  19031. var errorsArray = [];
  19032. iterate(errors, push, { that: errorsArray });
  19033. createNonEnumerableProperty(that, 'errors', errorsArray);
  19034. return that;
  19035. };
  19036. if (setPrototypeOf) setPrototypeOf($AggregateError, $Error);
  19037. else copyConstructorProperties($AggregateError, $Error, { name: true });
  19038. var AggregateErrorPrototype = $AggregateError.prototype = create($Error.prototype, {
  19039. constructor: createPropertyDescriptor(1, $AggregateError),
  19040. message: createPropertyDescriptor(1, ''),
  19041. name: createPropertyDescriptor(1, 'AggregateError')
  19042. });
  19043. // `AggregateError` constructor
  19044. // https://tc39.es/ecma262/#sec-aggregate-error-constructor
  19045. $({ global: true, constructor: true, arity: 2 }, {
  19046. AggregateError: $AggregateError
  19047. });
  19048. },{"../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){
  19049. // TODO: Remove this module from `core-js@4` since it's replaced to module below
  19050. _dereq_('../modules/es.aggregate-error.constructor');
  19051. },{"../modules/es.aggregate-error.constructor":345}],347:[function(_dereq_,module,exports){
  19052. 'use strict';
  19053. var $ = _dereq_('../internals/export');
  19054. var fails = _dereq_('../internals/fails');
  19055. var isArray = _dereq_('../internals/is-array');
  19056. var isObject = _dereq_('../internals/is-object');
  19057. var toObject = _dereq_('../internals/to-object');
  19058. var lengthOfArrayLike = _dereq_('../internals/length-of-array-like');
  19059. var doesNotExceedSafeInteger = _dereq_('../internals/does-not-exceed-safe-integer');
  19060. var createProperty = _dereq_('../internals/create-property');
  19061. var arraySpeciesCreate = _dereq_('../internals/array-species-create');
  19062. var arrayMethodHasSpeciesSupport = _dereq_('../internals/array-method-has-species-support');
  19063. var wellKnownSymbol = _dereq_('../internals/well-known-symbol');
  19064. var V8_VERSION = _dereq_('../internals/engine-v8-version');
  19065. var IS_CONCAT_SPREADABLE = wellKnownSymbol('isConcatSpreadable');
  19066. // We can't use this feature detection in V8 since it causes
  19067. // deoptimization and serious performance degradation
  19068. // https://github.com/zloirock/core-js/issues/679
  19069. var IS_CONCAT_SPREADABLE_SUPPORT = V8_VERSION >= 51 || !fails(function () {
  19070. var array = [];
  19071. array[IS_CONCAT_SPREADABLE] = false;
  19072. return array.concat()[0] !== array;
  19073. });
  19074. var isConcatSpreadable = function (O) {
  19075. if (!isObject(O)) return false;
  19076. var spreadable = O[IS_CONCAT_SPREADABLE];
  19077. return spreadable !== undefined ? !!spreadable : isArray(O);
  19078. };
  19079. var FORCED = !IS_CONCAT_SPREADABLE_SUPPORT || !arrayMethodHasSpeciesSupport('concat');
  19080. // `Array.prototype.concat` method
  19081. // https://tc39.es/ecma262/#sec-array.prototype.concat
  19082. // with adding support of @@isConcatSpreadable and @@species
  19083. $({ target: 'Array', proto: true, arity: 1, forced: FORCED }, {
  19084. // eslint-disable-next-line no-unused-vars -- required for `.length`
  19085. concat: function concat(arg) {
  19086. var O = toObject(this);
  19087. var A = arraySpeciesCreate(O, 0);
  19088. var n = 0;
  19089. var i, k, length, len, E;
  19090. for (i = -1, length = arguments.length; i < length; i++) {
  19091. E = i === -1 ? O : arguments[i];
  19092. if (isConcatSpreadable(E)) {
  19093. len = lengthOfArrayLike(E);
  19094. doesNotExceedSafeInteger(n + len);
  19095. for (k = 0; k < len; k++, n++) if (k in E) createProperty(A, n, E[k]);
  19096. } else {
  19097. doesNotExceedSafeInteger(n + 1);
  19098. createProperty(A, n++, E);
  19099. }
  19100. }
  19101. A.length = n;
  19102. return A;
  19103. }
  19104. });
  19105. },{"../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){
  19106. 'use strict';
  19107. var $ = _dereq_('../internals/export');
  19108. var $every = _dereq_('../internals/array-iteration').every;
  19109. var arrayMethodIsStrict = _dereq_('../internals/array-method-is-strict');
  19110. var STRICT_METHOD = arrayMethodIsStrict('every');
  19111. // `Array.prototype.every` method
  19112. // https://tc39.es/ecma262/#sec-array.prototype.every
  19113. $({ target: 'Array', proto: true, forced: !STRICT_METHOD }, {
  19114. every: function every(callbackfn /* , thisArg */) {
  19115. return $every(this, callbackfn, arguments.length > 1 ? arguments[1] : undefined);
  19116. }
  19117. });
  19118. },{"../internals/array-iteration":183,"../internals/array-method-is-strict":185,"../internals/export":234}],349:[function(_dereq_,module,exports){
  19119. 'use strict';
  19120. var $ = _dereq_('../internals/export');
  19121. var $filter = _dereq_('../internals/array-iteration').filter;
  19122. var arrayMethodHasSpeciesSupport = _dereq_('../internals/array-method-has-species-support');
  19123. var HAS_SPECIES_SUPPORT = arrayMethodHasSpeciesSupport('filter');
  19124. // `Array.prototype.filter` method
  19125. // https://tc39.es/ecma262/#sec-array.prototype.filter
  19126. // with adding support of @@species
  19127. $({ target: 'Array', proto: true, forced: !HAS_SPECIES_SUPPORT }, {
  19128. filter: function filter(callbackfn /* , thisArg */) {
  19129. return $filter(this, callbackfn, arguments.length > 1 ? arguments[1] : undefined);
  19130. }
  19131. });
  19132. },{"../internals/array-iteration":183,"../internals/array-method-has-species-support":184,"../internals/export":234}],350:[function(_dereq_,module,exports){
  19133. 'use strict';
  19134. var $ = _dereq_('../internals/export');
  19135. var $findIndex = _dereq_('../internals/array-iteration').findIndex;
  19136. var addToUnscopables = _dereq_('../internals/add-to-unscopables');
  19137. var FIND_INDEX = 'findIndex';
  19138. var SKIPS_HOLES = true;
  19139. // Shouldn't skip holes
  19140. // eslint-disable-next-line es/no-array-prototype-findindex -- testing
  19141. if (FIND_INDEX in []) Array(1)[FIND_INDEX](function () { SKIPS_HOLES = false; });
  19142. // `Array.prototype.findIndex` method
  19143. // https://tc39.es/ecma262/#sec-array.prototype.findindex
  19144. $({ target: 'Array', proto: true, forced: SKIPS_HOLES }, {
  19145. findIndex: function findIndex(callbackfn /* , that = undefined */) {
  19146. return $findIndex(this, callbackfn, arguments.length > 1 ? arguments[1] : undefined);
  19147. }
  19148. });
  19149. // https://tc39.es/ecma262/#sec-array.prototype-@@unscopables
  19150. addToUnscopables(FIND_INDEX);
  19151. },{"../internals/add-to-unscopables":176,"../internals/array-iteration":183,"../internals/export":234}],351:[function(_dereq_,module,exports){
  19152. 'use strict';
  19153. var $ = _dereq_('../internals/export');
  19154. var $find = _dereq_('../internals/array-iteration').find;
  19155. var addToUnscopables = _dereq_('../internals/add-to-unscopables');
  19156. var FIND = 'find';
  19157. var SKIPS_HOLES = true;
  19158. // Shouldn't skip holes
  19159. // eslint-disable-next-line es/no-array-prototype-find -- testing
  19160. if (FIND in []) Array(1)[FIND](function () { SKIPS_HOLES = false; });
  19161. // `Array.prototype.find` method
  19162. // https://tc39.es/ecma262/#sec-array.prototype.find
  19163. $({ target: 'Array', proto: true, forced: SKIPS_HOLES }, {
  19164. find: function find(callbackfn /* , that = undefined */) {
  19165. return $find(this, callbackfn, arguments.length > 1 ? arguments[1] : undefined);
  19166. }
  19167. });
  19168. // https://tc39.es/ecma262/#sec-array.prototype-@@unscopables
  19169. addToUnscopables(FIND);
  19170. },{"../internals/add-to-unscopables":176,"../internals/array-iteration":183,"../internals/export":234}],352:[function(_dereq_,module,exports){
  19171. 'use strict';
  19172. var $ = _dereq_('../internals/export');
  19173. var forEach = _dereq_('../internals/array-for-each');
  19174. // `Array.prototype.forEach` method
  19175. // https://tc39.es/ecma262/#sec-array.prototype.foreach
  19176. // eslint-disable-next-line es/no-array-prototype-foreach -- safe
  19177. $({ target: 'Array', proto: true, forced: [].forEach != forEach }, {
  19178. forEach: forEach
  19179. });
  19180. },{"../internals/array-for-each":180,"../internals/export":234}],353:[function(_dereq_,module,exports){
  19181. var $ = _dereq_('../internals/export');
  19182. var from = _dereq_('../internals/array-from');
  19183. var checkCorrectnessOfIteration = _dereq_('../internals/check-correctness-of-iteration');
  19184. var INCORRECT_ITERATION = !checkCorrectnessOfIteration(function (iterable) {
  19185. // eslint-disable-next-line es/no-array-from -- required for testing
  19186. Array.from(iterable);
  19187. });
  19188. // `Array.from` method
  19189. // https://tc39.es/ecma262/#sec-array.from
  19190. $({ target: 'Array', stat: true, forced: INCORRECT_ITERATION }, {
  19191. from: from
  19192. });
  19193. },{"../internals/array-from":181,"../internals/check-correctness-of-iteration":194,"../internals/export":234}],354:[function(_dereq_,module,exports){
  19194. 'use strict';
  19195. var $ = _dereq_('../internals/export');
  19196. var $includes = _dereq_('../internals/array-includes').includes;
  19197. var fails = _dereq_('../internals/fails');
  19198. var addToUnscopables = _dereq_('../internals/add-to-unscopables');
  19199. // FF99+ bug
  19200. var BROKEN_ON_SPARSE = fails(function () {
  19201. // eslint-disable-next-line es/no-array-prototype-includes -- detection
  19202. return !Array(1).includes();
  19203. });
  19204. // `Array.prototype.includes` method
  19205. // https://tc39.es/ecma262/#sec-array.prototype.includes
  19206. $({ target: 'Array', proto: true, forced: BROKEN_ON_SPARSE }, {
  19207. includes: function includes(el /* , fromIndex = 0 */) {
  19208. return $includes(this, el, arguments.length > 1 ? arguments[1] : undefined);
  19209. }
  19210. });
  19211. // https://tc39.es/ecma262/#sec-array.prototype-@@unscopables
  19212. addToUnscopables('includes');
  19213. },{"../internals/add-to-unscopables":176,"../internals/array-includes":182,"../internals/export":234,"../internals/fails":235}],355:[function(_dereq_,module,exports){
  19214. 'use strict';
  19215. /* eslint-disable es/no-array-prototype-indexof -- required for testing */
  19216. var $ = _dereq_('../internals/export');
  19217. var uncurryThis = _dereq_('../internals/function-uncurry-this-clause');
  19218. var $indexOf = _dereq_('../internals/array-includes').indexOf;
  19219. var arrayMethodIsStrict = _dereq_('../internals/array-method-is-strict');
  19220. var nativeIndexOf = uncurryThis([].indexOf);
  19221. var NEGATIVE_ZERO = !!nativeIndexOf && 1 / nativeIndexOf([1], 1, -0) < 0;
  19222. var FORCED = NEGATIVE_ZERO || !arrayMethodIsStrict('indexOf');
  19223. // `Array.prototype.indexOf` method
  19224. // https://tc39.es/ecma262/#sec-array.prototype.indexof
  19225. $({ target: 'Array', proto: true, forced: FORCED }, {
  19226. indexOf: function indexOf(searchElement /* , fromIndex = 0 */) {
  19227. var fromIndex = arguments.length > 1 ? arguments[1] : undefined;
  19228. return NEGATIVE_ZERO
  19229. // convert -0 to +0
  19230. ? nativeIndexOf(this, searchElement, fromIndex) || 0
  19231. : $indexOf(this, searchElement, fromIndex);
  19232. }
  19233. });
  19234. },{"../internals/array-includes":182,"../internals/array-method-is-strict":185,"../internals/export":234,"../internals/function-uncurry-this-clause":244}],356:[function(_dereq_,module,exports){
  19235. var $ = _dereq_('../internals/export');
  19236. var isArray = _dereq_('../internals/is-array');
  19237. // `Array.isArray` method
  19238. // https://tc39.es/ecma262/#sec-array.isarray
  19239. $({ target: 'Array', stat: true }, {
  19240. isArray: isArray
  19241. });
  19242. },{"../internals/export":234,"../internals/is-array":263}],357:[function(_dereq_,module,exports){
  19243. 'use strict';
  19244. var toIndexedObject = _dereq_('../internals/to-indexed-object');
  19245. var addToUnscopables = _dereq_('../internals/add-to-unscopables');
  19246. var Iterators = _dereq_('../internals/iterators');
  19247. var InternalStateModule = _dereq_('../internals/internal-state');
  19248. var defineProperty = _dereq_('../internals/object-define-property').f;
  19249. var defineIterator = _dereq_('../internals/iterator-define');
  19250. var createIterResultObject = _dereq_('../internals/create-iter-result-object');
  19251. var IS_PURE = _dereq_('../internals/is-pure');
  19252. var DESCRIPTORS = _dereq_('../internals/descriptors');
  19253. var ARRAY_ITERATOR = 'Array Iterator';
  19254. var setInternalState = InternalStateModule.set;
  19255. var getInternalState = InternalStateModule.getterFor(ARRAY_ITERATOR);
  19256. // `Array.prototype.entries` method
  19257. // https://tc39.es/ecma262/#sec-array.prototype.entries
  19258. // `Array.prototype.keys` method
  19259. // https://tc39.es/ecma262/#sec-array.prototype.keys
  19260. // `Array.prototype.values` method
  19261. // https://tc39.es/ecma262/#sec-array.prototype.values
  19262. // `Array.prototype[@@iterator]` method
  19263. // https://tc39.es/ecma262/#sec-array.prototype-@@iterator
  19264. // `CreateArrayIterator` internal method
  19265. // https://tc39.es/ecma262/#sec-createarrayiterator
  19266. module.exports = defineIterator(Array, 'Array', function (iterated, kind) {
  19267. setInternalState(this, {
  19268. type: ARRAY_ITERATOR,
  19269. target: toIndexedObject(iterated), // target
  19270. index: 0, // next index
  19271. kind: kind // kind
  19272. });
  19273. // `%ArrayIteratorPrototype%.next` method
  19274. // https://tc39.es/ecma262/#sec-%arrayiteratorprototype%.next
  19275. }, function () {
  19276. var state = getInternalState(this);
  19277. var target = state.target;
  19278. var kind = state.kind;
  19279. var index = state.index++;
  19280. if (!target || index >= target.length) {
  19281. state.target = undefined;
  19282. return createIterResultObject(undefined, true);
  19283. }
  19284. if (kind == 'keys') return createIterResultObject(index, false);
  19285. if (kind == 'values') return createIterResultObject(target[index], false);
  19286. return createIterResultObject([index, target[index]], false);
  19287. }, 'values');
  19288. // argumentsList[@@iterator] is %ArrayProto_values%
  19289. // https://tc39.es/ecma262/#sec-createunmappedargumentsobject
  19290. // https://tc39.es/ecma262/#sec-createmappedargumentsobject
  19291. var values = Iterators.Arguments = Iterators.Array;
  19292. // https://tc39.es/ecma262/#sec-array.prototype-@@unscopables
  19293. addToUnscopables('keys');
  19294. addToUnscopables('values');
  19295. addToUnscopables('entries');
  19296. // V8 ~ Chrome 45- bug
  19297. if (!IS_PURE && DESCRIPTORS && values.name !== 'values') try {
  19298. defineProperty(values, 'name', { value: 'values' });
  19299. } catch (error) { /* empty */ }
  19300. },{"../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){
  19301. 'use strict';
  19302. var $ = _dereq_('../internals/export');
  19303. var $map = _dereq_('../internals/array-iteration').map;
  19304. var arrayMethodHasSpeciesSupport = _dereq_('../internals/array-method-has-species-support');
  19305. var HAS_SPECIES_SUPPORT = arrayMethodHasSpeciesSupport('map');
  19306. // `Array.prototype.map` method
  19307. // https://tc39.es/ecma262/#sec-array.prototype.map
  19308. // with adding support of @@species
  19309. $({ target: 'Array', proto: true, forced: !HAS_SPECIES_SUPPORT }, {
  19310. map: function map(callbackfn /* , thisArg */) {
  19311. return $map(this, callbackfn, arguments.length > 1 ? arguments[1] : undefined);
  19312. }
  19313. });
  19314. },{"../internals/array-iteration":183,"../internals/array-method-has-species-support":184,"../internals/export":234}],359:[function(_dereq_,module,exports){
  19315. 'use strict';
  19316. var $ = _dereq_('../internals/export');
  19317. var $reduce = _dereq_('../internals/array-reduce').left;
  19318. var arrayMethodIsStrict = _dereq_('../internals/array-method-is-strict');
  19319. var CHROME_VERSION = _dereq_('../internals/engine-v8-version');
  19320. var IS_NODE = _dereq_('../internals/engine-is-node');
  19321. // Chrome 80-82 has a critical bug
  19322. // https://bugs.chromium.org/p/chromium/issues/detail?id=1049982
  19323. var CHROME_BUG = !IS_NODE && CHROME_VERSION > 79 && CHROME_VERSION < 83;
  19324. var FORCED = CHROME_BUG || !arrayMethodIsStrict('reduce');
  19325. // `Array.prototype.reduce` method
  19326. // https://tc39.es/ecma262/#sec-array.prototype.reduce
  19327. $({ target: 'Array', proto: true, forced: FORCED }, {
  19328. reduce: function reduce(callbackfn /* , initialValue */) {
  19329. var length = arguments.length;
  19330. return $reduce(this, callbackfn, length, length > 1 ? arguments[1] : undefined);
  19331. }
  19332. });
  19333. },{"../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){
  19334. 'use strict';
  19335. var $ = _dereq_('../internals/export');
  19336. var isArray = _dereq_('../internals/is-array');
  19337. var isConstructor = _dereq_('../internals/is-constructor');
  19338. var isObject = _dereq_('../internals/is-object');
  19339. var toAbsoluteIndex = _dereq_('../internals/to-absolute-index');
  19340. var lengthOfArrayLike = _dereq_('../internals/length-of-array-like');
  19341. var toIndexedObject = _dereq_('../internals/to-indexed-object');
  19342. var createProperty = _dereq_('../internals/create-property');
  19343. var wellKnownSymbol = _dereq_('../internals/well-known-symbol');
  19344. var arrayMethodHasSpeciesSupport = _dereq_('../internals/array-method-has-species-support');
  19345. var nativeSlice = _dereq_('../internals/array-slice');
  19346. var HAS_SPECIES_SUPPORT = arrayMethodHasSpeciesSupport('slice');
  19347. var SPECIES = wellKnownSymbol('species');
  19348. var $Array = Array;
  19349. var max = Math.max;
  19350. // `Array.prototype.slice` method
  19351. // https://tc39.es/ecma262/#sec-array.prototype.slice
  19352. // fallback for not array-like ES3 strings and DOM objects
  19353. $({ target: 'Array', proto: true, forced: !HAS_SPECIES_SUPPORT }, {
  19354. slice: function slice(start, end) {
  19355. var O = toIndexedObject(this);
  19356. var length = lengthOfArrayLike(O);
  19357. var k = toAbsoluteIndex(start, length);
  19358. var fin = toAbsoluteIndex(end === undefined ? length : end, length);
  19359. // inline `ArraySpeciesCreate` for usage native `Array#slice` where it's possible
  19360. var Constructor, result, n;
  19361. if (isArray(O)) {
  19362. Constructor = O.constructor;
  19363. // cross-realm fallback
  19364. if (isConstructor(Constructor) && (Constructor === $Array || isArray(Constructor.prototype))) {
  19365. Constructor = undefined;
  19366. } else if (isObject(Constructor)) {
  19367. Constructor = Constructor[SPECIES];
  19368. if (Constructor === null) Constructor = undefined;
  19369. }
  19370. if (Constructor === $Array || Constructor === undefined) {
  19371. return nativeSlice(O, k, fin);
  19372. }
  19373. }
  19374. result = new (Constructor === undefined ? $Array : Constructor)(max(fin - k, 0));
  19375. for (n = 0; k < fin; k++, n++) if (k in O) createProperty(result, n, O[k]);
  19376. result.length = n;
  19377. return result;
  19378. }
  19379. });
  19380. },{"../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){
  19381. 'use strict';
  19382. var $ = _dereq_('../internals/export');
  19383. var uncurryThis = _dereq_('../internals/function-uncurry-this');
  19384. var aCallable = _dereq_('../internals/a-callable');
  19385. var toObject = _dereq_('../internals/to-object');
  19386. var lengthOfArrayLike = _dereq_('../internals/length-of-array-like');
  19387. var deletePropertyOrThrow = _dereq_('../internals/delete-property-or-throw');
  19388. var toString = _dereq_('../internals/to-string');
  19389. var fails = _dereq_('../internals/fails');
  19390. var internalSort = _dereq_('../internals/array-sort');
  19391. var arrayMethodIsStrict = _dereq_('../internals/array-method-is-strict');
  19392. var FF = _dereq_('../internals/engine-ff-version');
  19393. var IE_OR_EDGE = _dereq_('../internals/engine-is-ie-or-edge');
  19394. var V8 = _dereq_('../internals/engine-v8-version');
  19395. var WEBKIT = _dereq_('../internals/engine-webkit-version');
  19396. var test = [];
  19397. var nativeSort = uncurryThis(test.sort);
  19398. var push = uncurryThis(test.push);
  19399. // IE8-
  19400. var FAILS_ON_UNDEFINED = fails(function () {
  19401. test.sort(undefined);
  19402. });
  19403. // V8 bug
  19404. var FAILS_ON_NULL = fails(function () {
  19405. test.sort(null);
  19406. });
  19407. // Old WebKit
  19408. var STRICT_METHOD = arrayMethodIsStrict('sort');
  19409. var STABLE_SORT = !fails(function () {
  19410. // feature detection can be too slow, so check engines versions
  19411. if (V8) return V8 < 70;
  19412. if (FF && FF > 3) return;
  19413. if (IE_OR_EDGE) return true;
  19414. if (WEBKIT) return WEBKIT < 603;
  19415. var result = '';
  19416. var code, chr, value, index;
  19417. // generate an array with more 512 elements (Chakra and old V8 fails only in this case)
  19418. for (code = 65; code < 76; code++) {
  19419. chr = String.fromCharCode(code);
  19420. switch (code) {
  19421. case 66: case 69: case 70: case 72: value = 3; break;
  19422. case 68: case 71: value = 4; break;
  19423. default: value = 2;
  19424. }
  19425. for (index = 0; index < 47; index++) {
  19426. test.push({ k: chr + index, v: value });
  19427. }
  19428. }
  19429. test.sort(function (a, b) { return b.v - a.v; });
  19430. for (index = 0; index < test.length; index++) {
  19431. chr = test[index].k.charAt(0);
  19432. if (result.charAt(result.length - 1) !== chr) result += chr;
  19433. }
  19434. return result !== 'DGBEFHACIJK';
  19435. });
  19436. var FORCED = FAILS_ON_UNDEFINED || !FAILS_ON_NULL || !STRICT_METHOD || !STABLE_SORT;
  19437. var getSortCompare = function (comparefn) {
  19438. return function (x, y) {
  19439. if (y === undefined) return -1;
  19440. if (x === undefined) return 1;
  19441. if (comparefn !== undefined) return +comparefn(x, y) || 0;
  19442. return toString(x) > toString(y) ? 1 : -1;
  19443. };
  19444. };
  19445. // `Array.prototype.sort` method
  19446. // https://tc39.es/ecma262/#sec-array.prototype.sort
  19447. $({ target: 'Array', proto: true, forced: FORCED }, {
  19448. sort: function sort(comparefn) {
  19449. if (comparefn !== undefined) aCallable(comparefn);
  19450. var array = toObject(this);
  19451. if (STABLE_SORT) return comparefn === undefined ? nativeSort(array) : nativeSort(array, comparefn);
  19452. var items = [];
  19453. var arrayLength = lengthOfArrayLike(array);
  19454. var itemsLength, index;
  19455. for (index = 0; index < arrayLength; index++) {
  19456. if (index in array) push(items, array[index]);
  19457. }
  19458. internalSort(items, getSortCompare(comparefn));
  19459. itemsLength = lengthOfArrayLike(items);
  19460. index = 0;
  19461. while (index < itemsLength) array[index] = items[index++];
  19462. while (index < arrayLength) deletePropertyOrThrow(array, index++);
  19463. return array;
  19464. }
  19465. });
  19466. },{"../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){
  19467. 'use strict';
  19468. var $ = _dereq_('../internals/export');
  19469. var toObject = _dereq_('../internals/to-object');
  19470. var toAbsoluteIndex = _dereq_('../internals/to-absolute-index');
  19471. var toIntegerOrInfinity = _dereq_('../internals/to-integer-or-infinity');
  19472. var lengthOfArrayLike = _dereq_('../internals/length-of-array-like');
  19473. var setArrayLength = _dereq_('../internals/array-set-length');
  19474. var doesNotExceedSafeInteger = _dereq_('../internals/does-not-exceed-safe-integer');
  19475. var arraySpeciesCreate = _dereq_('../internals/array-species-create');
  19476. var createProperty = _dereq_('../internals/create-property');
  19477. var deletePropertyOrThrow = _dereq_('../internals/delete-property-or-throw');
  19478. var arrayMethodHasSpeciesSupport = _dereq_('../internals/array-method-has-species-support');
  19479. var HAS_SPECIES_SUPPORT = arrayMethodHasSpeciesSupport('splice');
  19480. var max = Math.max;
  19481. var min = Math.min;
  19482. // `Array.prototype.splice` method
  19483. // https://tc39.es/ecma262/#sec-array.prototype.splice
  19484. // with adding support of @@species
  19485. $({ target: 'Array', proto: true, forced: !HAS_SPECIES_SUPPORT }, {
  19486. splice: function splice(start, deleteCount /* , ...items */) {
  19487. var O = toObject(this);
  19488. var len = lengthOfArrayLike(O);
  19489. var actualStart = toAbsoluteIndex(start, len);
  19490. var argumentsLength = arguments.length;
  19491. var insertCount, actualDeleteCount, A, k, from, to;
  19492. if (argumentsLength === 0) {
  19493. insertCount = actualDeleteCount = 0;
  19494. } else if (argumentsLength === 1) {
  19495. insertCount = 0;
  19496. actualDeleteCount = len - actualStart;
  19497. } else {
  19498. insertCount = argumentsLength - 2;
  19499. actualDeleteCount = min(max(toIntegerOrInfinity(deleteCount), 0), len - actualStart);
  19500. }
  19501. doesNotExceedSafeInteger(len + insertCount - actualDeleteCount);
  19502. A = arraySpeciesCreate(O, actualDeleteCount);
  19503. for (k = 0; k < actualDeleteCount; k++) {
  19504. from = actualStart + k;
  19505. if (from in O) createProperty(A, k, O[from]);
  19506. }
  19507. A.length = actualDeleteCount;
  19508. if (insertCount < actualDeleteCount) {
  19509. for (k = actualStart; k < len - actualDeleteCount; k++) {
  19510. from = k + actualDeleteCount;
  19511. to = k + insertCount;
  19512. if (from in O) O[to] = O[from];
  19513. else deletePropertyOrThrow(O, to);
  19514. }
  19515. for (k = len; k > len - actualDeleteCount + insertCount; k--) deletePropertyOrThrow(O, k - 1);
  19516. } else if (insertCount > actualDeleteCount) {
  19517. for (k = len - actualDeleteCount; k > actualStart; k--) {
  19518. from = k + actualDeleteCount - 1;
  19519. to = k + insertCount - 1;
  19520. if (from in O) O[to] = O[from];
  19521. else deletePropertyOrThrow(O, to);
  19522. }
  19523. }
  19524. for (k = 0; k < insertCount; k++) {
  19525. O[k + actualStart] = arguments[k + 2];
  19526. }
  19527. setArrayLength(O, len - actualDeleteCount + insertCount);
  19528. return A;
  19529. }
  19530. });
  19531. },{"../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){
  19532. // empty
  19533. },{}],364:[function(_dereq_,module,exports){
  19534. // TODO: Remove from `core-js@4`
  19535. var $ = _dereq_('../internals/export');
  19536. var bind = _dereq_('../internals/function-bind');
  19537. // `Function.prototype.bind` method
  19538. // https://tc39.es/ecma262/#sec-function.prototype.bind
  19539. // eslint-disable-next-line es/no-function-prototype-bind -- detection
  19540. $({ target: 'Function', proto: true, forced: Function.bind !== bind }, {
  19541. bind: bind
  19542. });
  19543. },{"../internals/export":234,"../internals/function-bind":240}],365:[function(_dereq_,module,exports){
  19544. var $ = _dereq_('../internals/export');
  19545. var getBuiltIn = _dereq_('../internals/get-built-in');
  19546. var apply = _dereq_('../internals/function-apply');
  19547. var call = _dereq_('../internals/function-call');
  19548. var uncurryThis = _dereq_('../internals/function-uncurry-this');
  19549. var fails = _dereq_('../internals/fails');
  19550. var isCallable = _dereq_('../internals/is-callable');
  19551. var isSymbol = _dereq_('../internals/is-symbol');
  19552. var arraySlice = _dereq_('../internals/array-slice');
  19553. var getReplacerFunction = _dereq_('../internals/get-json-replacer-function');
  19554. var NATIVE_SYMBOL = _dereq_('../internals/symbol-constructor-detection');
  19555. var $String = String;
  19556. var $stringify = getBuiltIn('JSON', 'stringify');
  19557. var exec = uncurryThis(/./.exec);
  19558. var charAt = uncurryThis(''.charAt);
  19559. var charCodeAt = uncurryThis(''.charCodeAt);
  19560. var replace = uncurryThis(''.replace);
  19561. var numberToString = uncurryThis(1.0.toString);
  19562. var tester = /[\uD800-\uDFFF]/g;
  19563. var low = /^[\uD800-\uDBFF]$/;
  19564. var hi = /^[\uDC00-\uDFFF]$/;
  19565. var WRONG_SYMBOLS_CONVERSION = !NATIVE_SYMBOL || fails(function () {
  19566. var symbol = getBuiltIn('Symbol')();
  19567. // MS Edge converts symbol values to JSON as {}
  19568. return $stringify([symbol]) != '[null]'
  19569. // WebKit converts symbol values to JSON as null
  19570. || $stringify({ a: symbol }) != '{}'
  19571. // V8 throws on boxed symbols
  19572. || $stringify(Object(symbol)) != '{}';
  19573. });
  19574. // https://github.com/tc39/proposal-well-formed-stringify
  19575. var ILL_FORMED_UNICODE = fails(function () {
  19576. return $stringify('\uDF06\uD834') !== '"\\udf06\\ud834"'
  19577. || $stringify('\uDEAD') !== '"\\udead"';
  19578. });
  19579. var stringifyWithSymbolsFix = function (it, replacer) {
  19580. var args = arraySlice(arguments);
  19581. var $replacer = getReplacerFunction(replacer);
  19582. if (!isCallable($replacer) && (it === undefined || isSymbol(it))) return; // IE8 returns string on undefined
  19583. args[1] = function (key, value) {
  19584. // some old implementations (like WebKit) could pass numbers as keys
  19585. if (isCallable($replacer)) value = call($replacer, this, $String(key), value);
  19586. if (!isSymbol(value)) return value;
  19587. };
  19588. return apply($stringify, null, args);
  19589. };
  19590. var fixIllFormed = function (match, offset, string) {
  19591. var prev = charAt(string, offset - 1);
  19592. var next = charAt(string, offset + 1);
  19593. if ((exec(low, match) && !exec(hi, next)) || (exec(hi, match) && !exec(low, prev))) {
  19594. return '\\u' + numberToString(charCodeAt(match, 0), 16);
  19595. } return match;
  19596. };
  19597. if ($stringify) {
  19598. // `JSON.stringify` method
  19599. // https://tc39.es/ecma262/#sec-json.stringify
  19600. $({ target: 'JSON', stat: true, arity: 3, forced: WRONG_SYMBOLS_CONVERSION || ILL_FORMED_UNICODE }, {
  19601. // eslint-disable-next-line no-unused-vars -- required for `.length`
  19602. stringify: function stringify(it, replacer, space) {
  19603. var args = arraySlice(arguments);
  19604. var result = apply(WRONG_SYMBOLS_CONVERSION ? stringifyWithSymbolsFix : $stringify, null, args);
  19605. return ILL_FORMED_UNICODE && typeof result == 'string' ? replace(result, tester, fixIllFormed) : result;
  19606. }
  19607. });
  19608. }
  19609. },{"../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){
  19610. var global = _dereq_('../internals/global');
  19611. var setToStringTag = _dereq_('../internals/set-to-string-tag');
  19612. // JSON[@@toStringTag] property
  19613. // https://tc39.es/ecma262/#sec-json-@@tostringtag
  19614. setToStringTag(global.JSON, 'JSON', true);
  19615. },{"../internals/global":251,"../internals/set-to-string-tag":315}],367:[function(_dereq_,module,exports){
  19616. 'use strict';
  19617. var collection = _dereq_('../internals/collection');
  19618. var collectionStrong = _dereq_('../internals/collection-strong');
  19619. // `Map` constructor
  19620. // https://tc39.es/ecma262/#sec-map-objects
  19621. collection('Map', function (init) {
  19622. return function Map() { return init(this, arguments.length ? arguments[0] : undefined); };
  19623. }, collectionStrong);
  19624. },{"../internals/collection":199,"../internals/collection-strong":197}],368:[function(_dereq_,module,exports){
  19625. // TODO: Remove this module from `core-js@4` since it's replaced to module below
  19626. _dereq_('../modules/es.map.constructor');
  19627. },{"../modules/es.map.constructor":367}],369:[function(_dereq_,module,exports){
  19628. arguments[4][363][0].apply(exports,arguments)
  19629. },{"dup":363}],370:[function(_dereq_,module,exports){
  19630. var $ = _dereq_('../internals/export');
  19631. var isIntegralNumber = _dereq_('../internals/is-integral-number');
  19632. // `Number.isInteger` method
  19633. // https://tc39.es/ecma262/#sec-number.isinteger
  19634. $({ target: 'Number', stat: true }, {
  19635. isInteger: isIntegralNumber
  19636. });
  19637. },{"../internals/export":234,"../internals/is-integral-number":267}],371:[function(_dereq_,module,exports){
  19638. var $ = _dereq_('../internals/export');
  19639. var assign = _dereq_('../internals/object-assign');
  19640. // `Object.assign` method
  19641. // https://tc39.es/ecma262/#sec-object.assign
  19642. // eslint-disable-next-line es/no-object-assign -- required for testing
  19643. $({ target: 'Object', stat: true, arity: 2, forced: Object.assign !== assign }, {
  19644. assign: assign
  19645. });
  19646. },{"../internals/export":234,"../internals/object-assign":286}],372:[function(_dereq_,module,exports){
  19647. // TODO: Remove from `core-js@4`
  19648. var $ = _dereq_('../internals/export');
  19649. var DESCRIPTORS = _dereq_('../internals/descriptors');
  19650. var create = _dereq_('../internals/object-create');
  19651. // `Object.create` method
  19652. // https://tc39.es/ecma262/#sec-object.create
  19653. $({ target: 'Object', stat: true, sham: !DESCRIPTORS }, {
  19654. create: create
  19655. });
  19656. },{"../internals/descriptors":212,"../internals/export":234,"../internals/object-create":287}],373:[function(_dereq_,module,exports){
  19657. var $ = _dereq_('../internals/export');
  19658. var DESCRIPTORS = _dereq_('../internals/descriptors');
  19659. var defineProperty = _dereq_('../internals/object-define-property').f;
  19660. // `Object.defineProperty` method
  19661. // https://tc39.es/ecma262/#sec-object.defineproperty
  19662. // eslint-disable-next-line es/no-object-defineproperty -- safe
  19663. $({ target: 'Object', stat: true, forced: Object.defineProperty !== defineProperty, sham: !DESCRIPTORS }, {
  19664. defineProperty: defineProperty
  19665. });
  19666. },{"../internals/descriptors":212,"../internals/export":234,"../internals/object-define-property":289}],374:[function(_dereq_,module,exports){
  19667. var $ = _dereq_('../internals/export');
  19668. var $entries = _dereq_('../internals/object-to-array').entries;
  19669. // `Object.entries` method
  19670. // https://tc39.es/ecma262/#sec-object.entries
  19671. $({ target: 'Object', stat: true }, {
  19672. entries: function entries(O) {
  19673. return $entries(O);
  19674. }
  19675. });
  19676. },{"../internals/export":234,"../internals/object-to-array":301}],375:[function(_dereq_,module,exports){
  19677. var $ = _dereq_('../internals/export');
  19678. var FREEZING = _dereq_('../internals/freezing');
  19679. var fails = _dereq_('../internals/fails');
  19680. var isObject = _dereq_('../internals/is-object');
  19681. var onFreeze = _dereq_('../internals/internal-metadata').onFreeze;
  19682. // eslint-disable-next-line es/no-object-freeze -- safe
  19683. var $freeze = Object.freeze;
  19684. var FAILS_ON_PRIMITIVES = fails(function () { $freeze(1); });
  19685. // `Object.freeze` method
  19686. // https://tc39.es/ecma262/#sec-object.freeze
  19687. $({ target: 'Object', stat: true, forced: FAILS_ON_PRIMITIVES, sham: !FREEZING }, {
  19688. freeze: function freeze(it) {
  19689. return $freeze && isObject(it) ? $freeze(onFreeze(it)) : it;
  19690. }
  19691. });
  19692. },{"../internals/export":234,"../internals/fails":235,"../internals/freezing":236,"../internals/internal-metadata":260,"../internals/is-object":269}],376:[function(_dereq_,module,exports){
  19693. var $ = _dereq_('../internals/export');
  19694. var fails = _dereq_('../internals/fails');
  19695. var toIndexedObject = _dereq_('../internals/to-indexed-object');
  19696. var nativeGetOwnPropertyDescriptor = _dereq_('../internals/object-get-own-property-descriptor').f;
  19697. var DESCRIPTORS = _dereq_('../internals/descriptors');
  19698. var FORCED = !DESCRIPTORS || fails(function () { nativeGetOwnPropertyDescriptor(1); });
  19699. // `Object.getOwnPropertyDescriptor` method
  19700. // https://tc39.es/ecma262/#sec-object.getownpropertydescriptor
  19701. $({ target: 'Object', stat: true, forced: FORCED, sham: !DESCRIPTORS }, {
  19702. getOwnPropertyDescriptor: function getOwnPropertyDescriptor(it, key) {
  19703. return nativeGetOwnPropertyDescriptor(toIndexedObject(it), key);
  19704. }
  19705. });
  19706. },{"../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){
  19707. var $ = _dereq_('../internals/export');
  19708. var NATIVE_SYMBOL = _dereq_('../internals/symbol-constructor-detection');
  19709. var fails = _dereq_('../internals/fails');
  19710. var getOwnPropertySymbolsModule = _dereq_('../internals/object-get-own-property-symbols');
  19711. var toObject = _dereq_('../internals/to-object');
  19712. // V8 ~ Chrome 38 and 39 `Object.getOwnPropertySymbols` fails on primitives
  19713. // https://bugs.chromium.org/p/v8/issues/detail?id=3443
  19714. var FORCED = !NATIVE_SYMBOL || fails(function () { getOwnPropertySymbolsModule.f(1); });
  19715. // `Object.getOwnPropertySymbols` method
  19716. // https://tc39.es/ecma262/#sec-object.getownpropertysymbols
  19717. $({ target: 'Object', stat: true, forced: FORCED }, {
  19718. getOwnPropertySymbols: function getOwnPropertySymbols(it) {
  19719. var $getOwnPropertySymbols = getOwnPropertySymbolsModule.f;
  19720. return $getOwnPropertySymbols ? $getOwnPropertySymbols(toObject(it)) : [];
  19721. }
  19722. });
  19723. },{"../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){
  19724. var $ = _dereq_('../internals/export');
  19725. var fails = _dereq_('../internals/fails');
  19726. var toObject = _dereq_('../internals/to-object');
  19727. var nativeGetPrototypeOf = _dereq_('../internals/object-get-prototype-of');
  19728. var CORRECT_PROTOTYPE_GETTER = _dereq_('../internals/correct-prototype-getter');
  19729. var FAILS_ON_PRIMITIVES = fails(function () { nativeGetPrototypeOf(1); });
  19730. // `Object.getPrototypeOf` method
  19731. // https://tc39.es/ecma262/#sec-object.getprototypeof
  19732. $({ target: 'Object', stat: true, forced: FAILS_ON_PRIMITIVES, sham: !CORRECT_PROTOTYPE_GETTER }, {
  19733. getPrototypeOf: function getPrototypeOf(it) {
  19734. return nativeGetPrototypeOf(toObject(it));
  19735. }
  19736. });
  19737. },{"../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){
  19738. var $ = _dereq_('../internals/export');
  19739. var toObject = _dereq_('../internals/to-object');
  19740. var nativeKeys = _dereq_('../internals/object-keys');
  19741. var fails = _dereq_('../internals/fails');
  19742. var FAILS_ON_PRIMITIVES = fails(function () { nativeKeys(1); });
  19743. // `Object.keys` method
  19744. // https://tc39.es/ecma262/#sec-object.keys
  19745. $({ target: 'Object', stat: true, forced: FAILS_ON_PRIMITIVES }, {
  19746. keys: function keys(it) {
  19747. return nativeKeys(toObject(it));
  19748. }
  19749. });
  19750. },{"../internals/export":234,"../internals/fails":235,"../internals/object-keys":298,"../internals/to-object":330}],380:[function(_dereq_,module,exports){
  19751. arguments[4][363][0].apply(exports,arguments)
  19752. },{"dup":363}],381:[function(_dereq_,module,exports){
  19753. var $ = _dereq_('../internals/export');
  19754. var $parseInt = _dereq_('../internals/number-parse-int');
  19755. // `parseInt` method
  19756. // https://tc39.es/ecma262/#sec-parseint-string-radix
  19757. $({ global: true, forced: parseInt != $parseInt }, {
  19758. parseInt: $parseInt
  19759. });
  19760. },{"../internals/export":234,"../internals/number-parse-int":285}],382:[function(_dereq_,module,exports){
  19761. 'use strict';
  19762. var $ = _dereq_('../internals/export');
  19763. var call = _dereq_('../internals/function-call');
  19764. var aCallable = _dereq_('../internals/a-callable');
  19765. var newPromiseCapabilityModule = _dereq_('../internals/new-promise-capability');
  19766. var perform = _dereq_('../internals/perform');
  19767. var iterate = _dereq_('../internals/iterate');
  19768. var PROMISE_STATICS_INCORRECT_ITERATION = _dereq_('../internals/promise-statics-incorrect-iteration');
  19769. // `Promise.allSettled` method
  19770. // https://tc39.es/ecma262/#sec-promise.allsettled
  19771. $({ target: 'Promise', stat: true, forced: PROMISE_STATICS_INCORRECT_ITERATION }, {
  19772. allSettled: function allSettled(iterable) {
  19773. var C = this;
  19774. var capability = newPromiseCapabilityModule.f(C);
  19775. var resolve = capability.resolve;
  19776. var reject = capability.reject;
  19777. var result = perform(function () {
  19778. var promiseResolve = aCallable(C.resolve);
  19779. var values = [];
  19780. var counter = 0;
  19781. var remaining = 1;
  19782. iterate(iterable, function (promise) {
  19783. var index = counter++;
  19784. var alreadyCalled = false;
  19785. remaining++;
  19786. call(promiseResolve, C, promise).then(function (value) {
  19787. if (alreadyCalled) return;
  19788. alreadyCalled = true;
  19789. values[index] = { status: 'fulfilled', value: value };
  19790. --remaining || resolve(values);
  19791. }, function (error) {
  19792. if (alreadyCalled) return;
  19793. alreadyCalled = true;
  19794. values[index] = { status: 'rejected', reason: error };
  19795. --remaining || resolve(values);
  19796. });
  19797. });
  19798. --remaining || resolve(values);
  19799. });
  19800. if (result.error) reject(result.value);
  19801. return capability.promise;
  19802. }
  19803. });
  19804. },{"../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){
  19805. 'use strict';
  19806. var $ = _dereq_('../internals/export');
  19807. var call = _dereq_('../internals/function-call');
  19808. var aCallable = _dereq_('../internals/a-callable');
  19809. var newPromiseCapabilityModule = _dereq_('../internals/new-promise-capability');
  19810. var perform = _dereq_('../internals/perform');
  19811. var iterate = _dereq_('../internals/iterate');
  19812. var PROMISE_STATICS_INCORRECT_ITERATION = _dereq_('../internals/promise-statics-incorrect-iteration');
  19813. // `Promise.all` method
  19814. // https://tc39.es/ecma262/#sec-promise.all
  19815. $({ target: 'Promise', stat: true, forced: PROMISE_STATICS_INCORRECT_ITERATION }, {
  19816. all: function all(iterable) {
  19817. var C = this;
  19818. var capability = newPromiseCapabilityModule.f(C);
  19819. var resolve = capability.resolve;
  19820. var reject = capability.reject;
  19821. var result = perform(function () {
  19822. var $promiseResolve = aCallable(C.resolve);
  19823. var values = [];
  19824. var counter = 0;
  19825. var remaining = 1;
  19826. iterate(iterable, function (promise) {
  19827. var index = counter++;
  19828. var alreadyCalled = false;
  19829. remaining++;
  19830. call($promiseResolve, C, promise).then(function (value) {
  19831. if (alreadyCalled) return;
  19832. alreadyCalled = true;
  19833. values[index] = value;
  19834. --remaining || resolve(values);
  19835. }, reject);
  19836. });
  19837. --remaining || resolve(values);
  19838. });
  19839. if (result.error) reject(result.value);
  19840. return capability.promise;
  19841. }
  19842. });
  19843. },{"../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){
  19844. 'use strict';
  19845. var $ = _dereq_('../internals/export');
  19846. var call = _dereq_('../internals/function-call');
  19847. var aCallable = _dereq_('../internals/a-callable');
  19848. var getBuiltIn = _dereq_('../internals/get-built-in');
  19849. var newPromiseCapabilityModule = _dereq_('../internals/new-promise-capability');
  19850. var perform = _dereq_('../internals/perform');
  19851. var iterate = _dereq_('../internals/iterate');
  19852. var PROMISE_STATICS_INCORRECT_ITERATION = _dereq_('../internals/promise-statics-incorrect-iteration');
  19853. var PROMISE_ANY_ERROR = 'No one promise resolved';
  19854. // `Promise.any` method
  19855. // https://tc39.es/ecma262/#sec-promise.any
  19856. $({ target: 'Promise', stat: true, forced: PROMISE_STATICS_INCORRECT_ITERATION }, {
  19857. any: function any(iterable) {
  19858. var C = this;
  19859. var AggregateError = getBuiltIn('AggregateError');
  19860. var capability = newPromiseCapabilityModule.f(C);
  19861. var resolve = capability.resolve;
  19862. var reject = capability.reject;
  19863. var result = perform(function () {
  19864. var promiseResolve = aCallable(C.resolve);
  19865. var errors = [];
  19866. var counter = 0;
  19867. var remaining = 1;
  19868. var alreadyResolved = false;
  19869. iterate(iterable, function (promise) {
  19870. var index = counter++;
  19871. var alreadyRejected = false;
  19872. remaining++;
  19873. call(promiseResolve, C, promise).then(function (value) {
  19874. if (alreadyRejected || alreadyResolved) return;
  19875. alreadyResolved = true;
  19876. resolve(value);
  19877. }, function (error) {
  19878. if (alreadyRejected || alreadyResolved) return;
  19879. alreadyRejected = true;
  19880. errors[index] = error;
  19881. --remaining || reject(new AggregateError(errors, PROMISE_ANY_ERROR));
  19882. });
  19883. });
  19884. --remaining || reject(new AggregateError(errors, PROMISE_ANY_ERROR));
  19885. });
  19886. if (result.error) reject(result.value);
  19887. return capability.promise;
  19888. }
  19889. });
  19890. },{"../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){
  19891. 'use strict';
  19892. var $ = _dereq_('../internals/export');
  19893. var IS_PURE = _dereq_('../internals/is-pure');
  19894. var FORCED_PROMISE_CONSTRUCTOR = _dereq_('../internals/promise-constructor-detection').CONSTRUCTOR;
  19895. var NativePromiseConstructor = _dereq_('../internals/promise-native-constructor');
  19896. var getBuiltIn = _dereq_('../internals/get-built-in');
  19897. var isCallable = _dereq_('../internals/is-callable');
  19898. var defineBuiltIn = _dereq_('../internals/define-built-in');
  19899. var NativePromisePrototype = NativePromiseConstructor && NativePromiseConstructor.prototype;
  19900. // `Promise.prototype.catch` method
  19901. // https://tc39.es/ecma262/#sec-promise.prototype.catch
  19902. $({ target: 'Promise', proto: true, forced: FORCED_PROMISE_CONSTRUCTOR, real: true }, {
  19903. 'catch': function (onRejected) {
  19904. return this.then(undefined, onRejected);
  19905. }
  19906. });
  19907. // makes sure that native promise-based APIs `Promise#catch` properly works with patched `Promise#then`
  19908. if (!IS_PURE && isCallable(NativePromiseConstructor)) {
  19909. var method = getBuiltIn('Promise').prototype['catch'];
  19910. if (NativePromisePrototype['catch'] !== method) {
  19911. defineBuiltIn(NativePromisePrototype, 'catch', method, { unsafe: true });
  19912. }
  19913. }
  19914. },{"../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){
  19915. 'use strict';
  19916. var $ = _dereq_('../internals/export');
  19917. var IS_PURE = _dereq_('../internals/is-pure');
  19918. var IS_NODE = _dereq_('../internals/engine-is-node');
  19919. var global = _dereq_('../internals/global');
  19920. var call = _dereq_('../internals/function-call');
  19921. var defineBuiltIn = _dereq_('../internals/define-built-in');
  19922. var setPrototypeOf = _dereq_('../internals/object-set-prototype-of');
  19923. var setToStringTag = _dereq_('../internals/set-to-string-tag');
  19924. var setSpecies = _dereq_('../internals/set-species');
  19925. var aCallable = _dereq_('../internals/a-callable');
  19926. var isCallable = _dereq_('../internals/is-callable');
  19927. var isObject = _dereq_('../internals/is-object');
  19928. var anInstance = _dereq_('../internals/an-instance');
  19929. var speciesConstructor = _dereq_('../internals/species-constructor');
  19930. var task = _dereq_('../internals/task').set;
  19931. var microtask = _dereq_('../internals/microtask');
  19932. var hostReportErrors = _dereq_('../internals/host-report-errors');
  19933. var perform = _dereq_('../internals/perform');
  19934. var Queue = _dereq_('../internals/queue');
  19935. var InternalStateModule = _dereq_('../internals/internal-state');
  19936. var NativePromiseConstructor = _dereq_('../internals/promise-native-constructor');
  19937. var PromiseConstructorDetection = _dereq_('../internals/promise-constructor-detection');
  19938. var newPromiseCapabilityModule = _dereq_('../internals/new-promise-capability');
  19939. var PROMISE = 'Promise';
  19940. var FORCED_PROMISE_CONSTRUCTOR = PromiseConstructorDetection.CONSTRUCTOR;
  19941. var NATIVE_PROMISE_REJECTION_EVENT = PromiseConstructorDetection.REJECTION_EVENT;
  19942. var NATIVE_PROMISE_SUBCLASSING = PromiseConstructorDetection.SUBCLASSING;
  19943. var getInternalPromiseState = InternalStateModule.getterFor(PROMISE);
  19944. var setInternalState = InternalStateModule.set;
  19945. var NativePromisePrototype = NativePromiseConstructor && NativePromiseConstructor.prototype;
  19946. var PromiseConstructor = NativePromiseConstructor;
  19947. var PromisePrototype = NativePromisePrototype;
  19948. var TypeError = global.TypeError;
  19949. var document = global.document;
  19950. var process = global.process;
  19951. var newPromiseCapability = newPromiseCapabilityModule.f;
  19952. var newGenericPromiseCapability = newPromiseCapability;
  19953. var DISPATCH_EVENT = !!(document && document.createEvent && global.dispatchEvent);
  19954. var UNHANDLED_REJECTION = 'unhandledrejection';
  19955. var REJECTION_HANDLED = 'rejectionhandled';
  19956. var PENDING = 0;
  19957. var FULFILLED = 1;
  19958. var REJECTED = 2;
  19959. var HANDLED = 1;
  19960. var UNHANDLED = 2;
  19961. var Internal, OwnPromiseCapability, PromiseWrapper, nativeThen;
  19962. // helpers
  19963. var isThenable = function (it) {
  19964. var then;
  19965. return isObject(it) && isCallable(then = it.then) ? then : false;
  19966. };
  19967. var callReaction = function (reaction, state) {
  19968. var value = state.value;
  19969. var ok = state.state == FULFILLED;
  19970. var handler = ok ? reaction.ok : reaction.fail;
  19971. var resolve = reaction.resolve;
  19972. var reject = reaction.reject;
  19973. var domain = reaction.domain;
  19974. var result, then, exited;
  19975. try {
  19976. if (handler) {
  19977. if (!ok) {
  19978. if (state.rejection === UNHANDLED) onHandleUnhandled(state);
  19979. state.rejection = HANDLED;
  19980. }
  19981. if (handler === true) result = value;
  19982. else {
  19983. if (domain) domain.enter();
  19984. result = handler(value); // can throw
  19985. if (domain) {
  19986. domain.exit();
  19987. exited = true;
  19988. }
  19989. }
  19990. if (result === reaction.promise) {
  19991. reject(TypeError('Promise-chain cycle'));
  19992. } else if (then = isThenable(result)) {
  19993. call(then, result, resolve, reject);
  19994. } else resolve(result);
  19995. } else reject(value);
  19996. } catch (error) {
  19997. if (domain && !exited) domain.exit();
  19998. reject(error);
  19999. }
  20000. };
  20001. var notify = function (state, isReject) {
  20002. if (state.notified) return;
  20003. state.notified = true;
  20004. microtask(function () {
  20005. var reactions = state.reactions;
  20006. var reaction;
  20007. while (reaction = reactions.get()) {
  20008. callReaction(reaction, state);
  20009. }
  20010. state.notified = false;
  20011. if (isReject && !state.rejection) onUnhandled(state);
  20012. });
  20013. };
  20014. var dispatchEvent = function (name, promise, reason) {
  20015. var event, handler;
  20016. if (DISPATCH_EVENT) {
  20017. event = document.createEvent('Event');
  20018. event.promise = promise;
  20019. event.reason = reason;
  20020. event.initEvent(name, false, true);
  20021. global.dispatchEvent(event);
  20022. } else event = { promise: promise, reason: reason };
  20023. if (!NATIVE_PROMISE_REJECTION_EVENT && (handler = global['on' + name])) handler(event);
  20024. else if (name === UNHANDLED_REJECTION) hostReportErrors('Unhandled promise rejection', reason);
  20025. };
  20026. var onUnhandled = function (state) {
  20027. call(task, global, function () {
  20028. var promise = state.facade;
  20029. var value = state.value;
  20030. var IS_UNHANDLED = isUnhandled(state);
  20031. var result;
  20032. if (IS_UNHANDLED) {
  20033. result = perform(function () {
  20034. if (IS_NODE) {
  20035. process.emit('unhandledRejection', value, promise);
  20036. } else dispatchEvent(UNHANDLED_REJECTION, promise, value);
  20037. });
  20038. // Browsers should not trigger `rejectionHandled` event if it was handled here, NodeJS - should
  20039. state.rejection = IS_NODE || isUnhandled(state) ? UNHANDLED : HANDLED;
  20040. if (result.error) throw result.value;
  20041. }
  20042. });
  20043. };
  20044. var isUnhandled = function (state) {
  20045. return state.rejection !== HANDLED && !state.parent;
  20046. };
  20047. var onHandleUnhandled = function (state) {
  20048. call(task, global, function () {
  20049. var promise = state.facade;
  20050. if (IS_NODE) {
  20051. process.emit('rejectionHandled', promise);
  20052. } else dispatchEvent(REJECTION_HANDLED, promise, state.value);
  20053. });
  20054. };
  20055. var bind = function (fn, state, unwrap) {
  20056. return function (value) {
  20057. fn(state, value, unwrap);
  20058. };
  20059. };
  20060. var internalReject = function (state, value, unwrap) {
  20061. if (state.done) return;
  20062. state.done = true;
  20063. if (unwrap) state = unwrap;
  20064. state.value = value;
  20065. state.state = REJECTED;
  20066. notify(state, true);
  20067. };
  20068. var internalResolve = function (state, value, unwrap) {
  20069. if (state.done) return;
  20070. state.done = true;
  20071. if (unwrap) state = unwrap;
  20072. try {
  20073. if (state.facade === value) throw TypeError("Promise can't be resolved itself");
  20074. var then = isThenable(value);
  20075. if (then) {
  20076. microtask(function () {
  20077. var wrapper = { done: false };
  20078. try {
  20079. call(then, value,
  20080. bind(internalResolve, wrapper, state),
  20081. bind(internalReject, wrapper, state)
  20082. );
  20083. } catch (error) {
  20084. internalReject(wrapper, error, state);
  20085. }
  20086. });
  20087. } else {
  20088. state.value = value;
  20089. state.state = FULFILLED;
  20090. notify(state, false);
  20091. }
  20092. } catch (error) {
  20093. internalReject({ done: false }, error, state);
  20094. }
  20095. };
  20096. // constructor polyfill
  20097. if (FORCED_PROMISE_CONSTRUCTOR) {
  20098. // 25.4.3.1 Promise(executor)
  20099. PromiseConstructor = function Promise(executor) {
  20100. anInstance(this, PromisePrototype);
  20101. aCallable(executor);
  20102. call(Internal, this);
  20103. var state = getInternalPromiseState(this);
  20104. try {
  20105. executor(bind(internalResolve, state), bind(internalReject, state));
  20106. } catch (error) {
  20107. internalReject(state, error);
  20108. }
  20109. };
  20110. PromisePrototype = PromiseConstructor.prototype;
  20111. // eslint-disable-next-line no-unused-vars -- required for `.length`
  20112. Internal = function Promise(executor) {
  20113. setInternalState(this, {
  20114. type: PROMISE,
  20115. done: false,
  20116. notified: false,
  20117. parent: false,
  20118. reactions: new Queue(),
  20119. rejection: false,
  20120. state: PENDING,
  20121. value: undefined
  20122. });
  20123. };
  20124. // `Promise.prototype.then` method
  20125. // https://tc39.es/ecma262/#sec-promise.prototype.then
  20126. Internal.prototype = defineBuiltIn(PromisePrototype, 'then', function then(onFulfilled, onRejected) {
  20127. var state = getInternalPromiseState(this);
  20128. var reaction = newPromiseCapability(speciesConstructor(this, PromiseConstructor));
  20129. state.parent = true;
  20130. reaction.ok = isCallable(onFulfilled) ? onFulfilled : true;
  20131. reaction.fail = isCallable(onRejected) && onRejected;
  20132. reaction.domain = IS_NODE ? process.domain : undefined;
  20133. if (state.state == PENDING) state.reactions.add(reaction);
  20134. else microtask(function () {
  20135. callReaction(reaction, state);
  20136. });
  20137. return reaction.promise;
  20138. });
  20139. OwnPromiseCapability = function () {
  20140. var promise = new Internal();
  20141. var state = getInternalPromiseState(promise);
  20142. this.promise = promise;
  20143. this.resolve = bind(internalResolve, state);
  20144. this.reject = bind(internalReject, state);
  20145. };
  20146. newPromiseCapabilityModule.f = newPromiseCapability = function (C) {
  20147. return C === PromiseConstructor || C === PromiseWrapper
  20148. ? new OwnPromiseCapability(C)
  20149. : newGenericPromiseCapability(C);
  20150. };
  20151. if (!IS_PURE && isCallable(NativePromiseConstructor) && NativePromisePrototype !== Object.prototype) {
  20152. nativeThen = NativePromisePrototype.then;
  20153. if (!NATIVE_PROMISE_SUBCLASSING) {
  20154. // make `Promise#then` return a polyfilled `Promise` for native promise-based APIs
  20155. defineBuiltIn(NativePromisePrototype, 'then', function then(onFulfilled, onRejected) {
  20156. var that = this;
  20157. return new PromiseConstructor(function (resolve, reject) {
  20158. call(nativeThen, that, resolve, reject);
  20159. }).then(onFulfilled, onRejected);
  20160. // https://github.com/zloirock/core-js/issues/640
  20161. }, { unsafe: true });
  20162. }
  20163. // make `.constructor === Promise` work for native promise-based APIs
  20164. try {
  20165. delete NativePromisePrototype.constructor;
  20166. } catch (error) { /* empty */ }
  20167. // make `instanceof Promise` work for native promise-based APIs
  20168. if (setPrototypeOf) {
  20169. setPrototypeOf(NativePromisePrototype, PromisePrototype);
  20170. }
  20171. }
  20172. }
  20173. $({ global: true, constructor: true, wrap: true, forced: FORCED_PROMISE_CONSTRUCTOR }, {
  20174. Promise: PromiseConstructor
  20175. });
  20176. setToStringTag(PromiseConstructor, PROMISE, false, true);
  20177. setSpecies(PROMISE);
  20178. },{"../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){
  20179. 'use strict';
  20180. var $ = _dereq_('../internals/export');
  20181. var IS_PURE = _dereq_('../internals/is-pure');
  20182. var NativePromiseConstructor = _dereq_('../internals/promise-native-constructor');
  20183. var fails = _dereq_('../internals/fails');
  20184. var getBuiltIn = _dereq_('../internals/get-built-in');
  20185. var isCallable = _dereq_('../internals/is-callable');
  20186. var speciesConstructor = _dereq_('../internals/species-constructor');
  20187. var promiseResolve = _dereq_('../internals/promise-resolve');
  20188. var defineBuiltIn = _dereq_('../internals/define-built-in');
  20189. var NativePromisePrototype = NativePromiseConstructor && NativePromiseConstructor.prototype;
  20190. // Safari bug https://bugs.webkit.org/show_bug.cgi?id=200829
  20191. var NON_GENERIC = !!NativePromiseConstructor && fails(function () {
  20192. // eslint-disable-next-line unicorn/no-thenable -- required for testing
  20193. NativePromisePrototype['finally'].call({ then: function () { /* empty */ } }, function () { /* empty */ });
  20194. });
  20195. // `Promise.prototype.finally` method
  20196. // https://tc39.es/ecma262/#sec-promise.prototype.finally
  20197. $({ target: 'Promise', proto: true, real: true, forced: NON_GENERIC }, {
  20198. 'finally': function (onFinally) {
  20199. var C = speciesConstructor(this, getBuiltIn('Promise'));
  20200. var isFunction = isCallable(onFinally);
  20201. return this.then(
  20202. isFunction ? function (x) {
  20203. return promiseResolve(C, onFinally()).then(function () { return x; });
  20204. } : onFinally,
  20205. isFunction ? function (e) {
  20206. return promiseResolve(C, onFinally()).then(function () { throw e; });
  20207. } : onFinally
  20208. );
  20209. }
  20210. });
  20211. // makes sure that native promise-based APIs `Promise#finally` properly works with patched `Promise#then`
  20212. if (!IS_PURE && isCallable(NativePromiseConstructor)) {
  20213. var method = getBuiltIn('Promise').prototype['finally'];
  20214. if (NativePromisePrototype['finally'] !== method) {
  20215. defineBuiltIn(NativePromisePrototype, 'finally', method, { unsafe: true });
  20216. }
  20217. }
  20218. },{"../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){
  20219. // TODO: Remove this module from `core-js@4` since it's split to modules listed below
  20220. _dereq_('../modules/es.promise.constructor');
  20221. _dereq_('../modules/es.promise.all');
  20222. _dereq_('../modules/es.promise.catch');
  20223. _dereq_('../modules/es.promise.race');
  20224. _dereq_('../modules/es.promise.reject');
  20225. _dereq_('../modules/es.promise.resolve');
  20226. },{"../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){
  20227. 'use strict';
  20228. var $ = _dereq_('../internals/export');
  20229. var call = _dereq_('../internals/function-call');
  20230. var aCallable = _dereq_('../internals/a-callable');
  20231. var newPromiseCapabilityModule = _dereq_('../internals/new-promise-capability');
  20232. var perform = _dereq_('../internals/perform');
  20233. var iterate = _dereq_('../internals/iterate');
  20234. var PROMISE_STATICS_INCORRECT_ITERATION = _dereq_('../internals/promise-statics-incorrect-iteration');
  20235. // `Promise.race` method
  20236. // https://tc39.es/ecma262/#sec-promise.race
  20237. $({ target: 'Promise', stat: true, forced: PROMISE_STATICS_INCORRECT_ITERATION }, {
  20238. race: function race(iterable) {
  20239. var C = this;
  20240. var capability = newPromiseCapabilityModule.f(C);
  20241. var reject = capability.reject;
  20242. var result = perform(function () {
  20243. var $promiseResolve = aCallable(C.resolve);
  20244. iterate(iterable, function (promise) {
  20245. call($promiseResolve, C, promise).then(capability.resolve, reject);
  20246. });
  20247. });
  20248. if (result.error) reject(result.value);
  20249. return capability.promise;
  20250. }
  20251. });
  20252. },{"../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){
  20253. 'use strict';
  20254. var $ = _dereq_('../internals/export');
  20255. var call = _dereq_('../internals/function-call');
  20256. var newPromiseCapabilityModule = _dereq_('../internals/new-promise-capability');
  20257. var FORCED_PROMISE_CONSTRUCTOR = _dereq_('../internals/promise-constructor-detection').CONSTRUCTOR;
  20258. // `Promise.reject` method
  20259. // https://tc39.es/ecma262/#sec-promise.reject
  20260. $({ target: 'Promise', stat: true, forced: FORCED_PROMISE_CONSTRUCTOR }, {
  20261. reject: function reject(r) {
  20262. var capability = newPromiseCapabilityModule.f(this);
  20263. call(capability.reject, undefined, r);
  20264. return capability.promise;
  20265. }
  20266. });
  20267. },{"../internals/export":234,"../internals/function-call":241,"../internals/new-promise-capability":282,"../internals/promise-constructor-detection":307}],391:[function(_dereq_,module,exports){
  20268. 'use strict';
  20269. var $ = _dereq_('../internals/export');
  20270. var getBuiltIn = _dereq_('../internals/get-built-in');
  20271. var IS_PURE = _dereq_('../internals/is-pure');
  20272. var NativePromiseConstructor = _dereq_('../internals/promise-native-constructor');
  20273. var FORCED_PROMISE_CONSTRUCTOR = _dereq_('../internals/promise-constructor-detection').CONSTRUCTOR;
  20274. var promiseResolve = _dereq_('../internals/promise-resolve');
  20275. var PromiseConstructorWrapper = getBuiltIn('Promise');
  20276. var CHECK_WRAPPER = IS_PURE && !FORCED_PROMISE_CONSTRUCTOR;
  20277. // `Promise.resolve` method
  20278. // https://tc39.es/ecma262/#sec-promise.resolve
  20279. $({ target: 'Promise', stat: true, forced: IS_PURE || FORCED_PROMISE_CONSTRUCTOR }, {
  20280. resolve: function resolve(x) {
  20281. return promiseResolve(CHECK_WRAPPER && this === PromiseConstructorWrapper ? NativePromiseConstructor : this, x);
  20282. }
  20283. });
  20284. },{"../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){
  20285. arguments[4][363][0].apply(exports,arguments)
  20286. },{"dup":363}],393:[function(_dereq_,module,exports){
  20287. 'use strict';
  20288. var collection = _dereq_('../internals/collection');
  20289. var collectionStrong = _dereq_('../internals/collection-strong');
  20290. // `Set` constructor
  20291. // https://tc39.es/ecma262/#sec-set-objects
  20292. collection('Set', function (init) {
  20293. return function Set() { return init(this, arguments.length ? arguments[0] : undefined); };
  20294. }, collectionStrong);
  20295. },{"../internals/collection":199,"../internals/collection-strong":197}],394:[function(_dereq_,module,exports){
  20296. // TODO: Remove this module from `core-js@4` since it's replaced to module below
  20297. _dereq_('../modules/es.set.constructor');
  20298. },{"../modules/es.set.constructor":393}],395:[function(_dereq_,module,exports){
  20299. 'use strict';
  20300. var $ = _dereq_('../internals/export');
  20301. var uncurryThis = _dereq_('../internals/function-uncurry-this');
  20302. var notARegExp = _dereq_('../internals/not-a-regexp');
  20303. var requireObjectCoercible = _dereq_('../internals/require-object-coercible');
  20304. var toString = _dereq_('../internals/to-string');
  20305. var correctIsRegExpLogic = _dereq_('../internals/correct-is-regexp-logic');
  20306. var stringIndexOf = uncurryThis(''.indexOf);
  20307. // `String.prototype.includes` method
  20308. // https://tc39.es/ecma262/#sec-string.prototype.includes
  20309. $({ target: 'String', proto: true, forced: !correctIsRegExpLogic('includes') }, {
  20310. includes: function includes(searchString /* , position = 0 */) {
  20311. return !!~stringIndexOf(
  20312. toString(requireObjectCoercible(this)),
  20313. toString(notARegExp(searchString)),
  20314. arguments.length > 1 ? arguments[1] : undefined
  20315. );
  20316. }
  20317. });
  20318. },{"../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){
  20319. 'use strict';
  20320. var charAt = _dereq_('../internals/string-multibyte').charAt;
  20321. var toString = _dereq_('../internals/to-string');
  20322. var InternalStateModule = _dereq_('../internals/internal-state');
  20323. var defineIterator = _dereq_('../internals/iterator-define');
  20324. var createIterResultObject = _dereq_('../internals/create-iter-result-object');
  20325. var STRING_ITERATOR = 'String Iterator';
  20326. var setInternalState = InternalStateModule.set;
  20327. var getInternalState = InternalStateModule.getterFor(STRING_ITERATOR);
  20328. // `String.prototype[@@iterator]` method
  20329. // https://tc39.es/ecma262/#sec-string.prototype-@@iterator
  20330. defineIterator(String, 'String', function (iterated) {
  20331. setInternalState(this, {
  20332. type: STRING_ITERATOR,
  20333. string: toString(iterated),
  20334. index: 0
  20335. });
  20336. // `%StringIteratorPrototype%.next` method
  20337. // https://tc39.es/ecma262/#sec-%stringiteratorprototype%.next
  20338. }, function next() {
  20339. var state = getInternalState(this);
  20340. var string = state.string;
  20341. var index = state.index;
  20342. var point;
  20343. if (index >= string.length) return createIterResultObject(undefined, true);
  20344. point = charAt(string, index);
  20345. state.index += point.length;
  20346. return createIterResultObject(point, false);
  20347. });
  20348. },{"../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){
  20349. 'use strict';
  20350. var $ = _dereq_('../internals/export');
  20351. var uncurryThis = _dereq_('../internals/function-uncurry-this-clause');
  20352. var getOwnPropertyDescriptor = _dereq_('../internals/object-get-own-property-descriptor').f;
  20353. var toLength = _dereq_('../internals/to-length');
  20354. var toString = _dereq_('../internals/to-string');
  20355. var notARegExp = _dereq_('../internals/not-a-regexp');
  20356. var requireObjectCoercible = _dereq_('../internals/require-object-coercible');
  20357. var correctIsRegExpLogic = _dereq_('../internals/correct-is-regexp-logic');
  20358. var IS_PURE = _dereq_('../internals/is-pure');
  20359. // eslint-disable-next-line es/no-string-prototype-startswith -- safe
  20360. var nativeStartsWith = uncurryThis(''.startsWith);
  20361. var stringSlice = uncurryThis(''.slice);
  20362. var min = Math.min;
  20363. var CORRECT_IS_REGEXP_LOGIC = correctIsRegExpLogic('startsWith');
  20364. // https://github.com/zloirock/core-js/pull/702
  20365. var MDN_POLYFILL_BUG = !IS_PURE && !CORRECT_IS_REGEXP_LOGIC && !!function () {
  20366. var descriptor = getOwnPropertyDescriptor(String.prototype, 'startsWith');
  20367. return descriptor && !descriptor.writable;
  20368. }();
  20369. // `String.prototype.startsWith` method
  20370. // https://tc39.es/ecma262/#sec-string.prototype.startswith
  20371. $({ target: 'String', proto: true, forced: !MDN_POLYFILL_BUG && !CORRECT_IS_REGEXP_LOGIC }, {
  20372. startsWith: function startsWith(searchString /* , position = 0 */) {
  20373. var that = toString(requireObjectCoercible(this));
  20374. notARegExp(searchString);
  20375. var index = toLength(min(arguments.length > 1 ? arguments[1] : undefined, that.length));
  20376. var search = toString(searchString);
  20377. return nativeStartsWith
  20378. ? nativeStartsWith(that, search, index)
  20379. : stringSlice(that, index, index + search.length) === search;
  20380. }
  20381. });
  20382. },{"../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){
  20383. var defineWellKnownSymbol = _dereq_('../internals/well-known-symbol-define');
  20384. // `Symbol.asyncIterator` well-known symbol
  20385. // https://tc39.es/ecma262/#sec-symbol.asynciterator
  20386. defineWellKnownSymbol('asyncIterator');
  20387. },{"../internals/well-known-symbol-define":341}],399:[function(_dereq_,module,exports){
  20388. 'use strict';
  20389. var $ = _dereq_('../internals/export');
  20390. var global = _dereq_('../internals/global');
  20391. var call = _dereq_('../internals/function-call');
  20392. var uncurryThis = _dereq_('../internals/function-uncurry-this');
  20393. var IS_PURE = _dereq_('../internals/is-pure');
  20394. var DESCRIPTORS = _dereq_('../internals/descriptors');
  20395. var NATIVE_SYMBOL = _dereq_('../internals/symbol-constructor-detection');
  20396. var fails = _dereq_('../internals/fails');
  20397. var hasOwn = _dereq_('../internals/has-own-property');
  20398. var isPrototypeOf = _dereq_('../internals/object-is-prototype-of');
  20399. var anObject = _dereq_('../internals/an-object');
  20400. var toIndexedObject = _dereq_('../internals/to-indexed-object');
  20401. var toPropertyKey = _dereq_('../internals/to-property-key');
  20402. var $toString = _dereq_('../internals/to-string');
  20403. var createPropertyDescriptor = _dereq_('../internals/create-property-descriptor');
  20404. var nativeObjectCreate = _dereq_('../internals/object-create');
  20405. var objectKeys = _dereq_('../internals/object-keys');
  20406. var getOwnPropertyNamesModule = _dereq_('../internals/object-get-own-property-names');
  20407. var getOwnPropertyNamesExternal = _dereq_('../internals/object-get-own-property-names-external');
  20408. var getOwnPropertySymbolsModule = _dereq_('../internals/object-get-own-property-symbols');
  20409. var getOwnPropertyDescriptorModule = _dereq_('../internals/object-get-own-property-descriptor');
  20410. var definePropertyModule = _dereq_('../internals/object-define-property');
  20411. var definePropertiesModule = _dereq_('../internals/object-define-properties');
  20412. var propertyIsEnumerableModule = _dereq_('../internals/object-property-is-enumerable');
  20413. var defineBuiltIn = _dereq_('../internals/define-built-in');
  20414. var defineBuiltInAccessor = _dereq_('../internals/define-built-in-accessor');
  20415. var shared = _dereq_('../internals/shared');
  20416. var sharedKey = _dereq_('../internals/shared-key');
  20417. var hiddenKeys = _dereq_('../internals/hidden-keys');
  20418. var uid = _dereq_('../internals/uid');
  20419. var wellKnownSymbol = _dereq_('../internals/well-known-symbol');
  20420. var wrappedWellKnownSymbolModule = _dereq_('../internals/well-known-symbol-wrapped');
  20421. var defineWellKnownSymbol = _dereq_('../internals/well-known-symbol-define');
  20422. var defineSymbolToPrimitive = _dereq_('../internals/symbol-define-to-primitive');
  20423. var setToStringTag = _dereq_('../internals/set-to-string-tag');
  20424. var InternalStateModule = _dereq_('../internals/internal-state');
  20425. var $forEach = _dereq_('../internals/array-iteration').forEach;
  20426. var HIDDEN = sharedKey('hidden');
  20427. var SYMBOL = 'Symbol';
  20428. var PROTOTYPE = 'prototype';
  20429. var setInternalState = InternalStateModule.set;
  20430. var getInternalState = InternalStateModule.getterFor(SYMBOL);
  20431. var ObjectPrototype = Object[PROTOTYPE];
  20432. var $Symbol = global.Symbol;
  20433. var SymbolPrototype = $Symbol && $Symbol[PROTOTYPE];
  20434. var TypeError = global.TypeError;
  20435. var QObject = global.QObject;
  20436. var nativeGetOwnPropertyDescriptor = getOwnPropertyDescriptorModule.f;
  20437. var nativeDefineProperty = definePropertyModule.f;
  20438. var nativeGetOwnPropertyNames = getOwnPropertyNamesExternal.f;
  20439. var nativePropertyIsEnumerable = propertyIsEnumerableModule.f;
  20440. var push = uncurryThis([].push);
  20441. var AllSymbols = shared('symbols');
  20442. var ObjectPrototypeSymbols = shared('op-symbols');
  20443. var WellKnownSymbolsStore = shared('wks');
  20444. // Don't use setters in Qt Script, https://github.com/zloirock/core-js/issues/173
  20445. var USE_SETTER = !QObject || !QObject[PROTOTYPE] || !QObject[PROTOTYPE].findChild;
  20446. // fallback for old Android, https://code.google.com/p/v8/issues/detail?id=687
  20447. var setSymbolDescriptor = DESCRIPTORS && fails(function () {
  20448. return nativeObjectCreate(nativeDefineProperty({}, 'a', {
  20449. get: function () { return nativeDefineProperty(this, 'a', { value: 7 }).a; }
  20450. })).a != 7;
  20451. }) ? function (O, P, Attributes) {
  20452. var ObjectPrototypeDescriptor = nativeGetOwnPropertyDescriptor(ObjectPrototype, P);
  20453. if (ObjectPrototypeDescriptor) delete ObjectPrototype[P];
  20454. nativeDefineProperty(O, P, Attributes);
  20455. if (ObjectPrototypeDescriptor && O !== ObjectPrototype) {
  20456. nativeDefineProperty(ObjectPrototype, P, ObjectPrototypeDescriptor);
  20457. }
  20458. } : nativeDefineProperty;
  20459. var wrap = function (tag, description) {
  20460. var symbol = AllSymbols[tag] = nativeObjectCreate(SymbolPrototype);
  20461. setInternalState(symbol, {
  20462. type: SYMBOL,
  20463. tag: tag,
  20464. description: description
  20465. });
  20466. if (!DESCRIPTORS) symbol.description = description;
  20467. return symbol;
  20468. };
  20469. var $defineProperty = function defineProperty(O, P, Attributes) {
  20470. if (O === ObjectPrototype) $defineProperty(ObjectPrototypeSymbols, P, Attributes);
  20471. anObject(O);
  20472. var key = toPropertyKey(P);
  20473. anObject(Attributes);
  20474. if (hasOwn(AllSymbols, key)) {
  20475. if (!Attributes.enumerable) {
  20476. if (!hasOwn(O, HIDDEN)) nativeDefineProperty(O, HIDDEN, createPropertyDescriptor(1, {}));
  20477. O[HIDDEN][key] = true;
  20478. } else {
  20479. if (hasOwn(O, HIDDEN) && O[HIDDEN][key]) O[HIDDEN][key] = false;
  20480. Attributes = nativeObjectCreate(Attributes, { enumerable: createPropertyDescriptor(0, false) });
  20481. } return setSymbolDescriptor(O, key, Attributes);
  20482. } return nativeDefineProperty(O, key, Attributes);
  20483. };
  20484. var $defineProperties = function defineProperties(O, Properties) {
  20485. anObject(O);
  20486. var properties = toIndexedObject(Properties);
  20487. var keys = objectKeys(properties).concat($getOwnPropertySymbols(properties));
  20488. $forEach(keys, function (key) {
  20489. if (!DESCRIPTORS || call($propertyIsEnumerable, properties, key)) $defineProperty(O, key, properties[key]);
  20490. });
  20491. return O;
  20492. };
  20493. var $create = function create(O, Properties) {
  20494. return Properties === undefined ? nativeObjectCreate(O) : $defineProperties(nativeObjectCreate(O), Properties);
  20495. };
  20496. var $propertyIsEnumerable = function propertyIsEnumerable(V) {
  20497. var P = toPropertyKey(V);
  20498. var enumerable = call(nativePropertyIsEnumerable, this, P);
  20499. if (this === ObjectPrototype && hasOwn(AllSymbols, P) && !hasOwn(ObjectPrototypeSymbols, P)) return false;
  20500. return enumerable || !hasOwn(this, P) || !hasOwn(AllSymbols, P) || hasOwn(this, HIDDEN) && this[HIDDEN][P]
  20501. ? enumerable : true;
  20502. };
  20503. var $getOwnPropertyDescriptor = function getOwnPropertyDescriptor(O, P) {
  20504. var it = toIndexedObject(O);
  20505. var key = toPropertyKey(P);
  20506. if (it === ObjectPrototype && hasOwn(AllSymbols, key) && !hasOwn(ObjectPrototypeSymbols, key)) return;
  20507. var descriptor = nativeGetOwnPropertyDescriptor(it, key);
  20508. if (descriptor && hasOwn(AllSymbols, key) && !(hasOwn(it, HIDDEN) && it[HIDDEN][key])) {
  20509. descriptor.enumerable = true;
  20510. }
  20511. return descriptor;
  20512. };
  20513. var $getOwnPropertyNames = function getOwnPropertyNames(O) {
  20514. var names = nativeGetOwnPropertyNames(toIndexedObject(O));
  20515. var result = [];
  20516. $forEach(names, function (key) {
  20517. if (!hasOwn(AllSymbols, key) && !hasOwn(hiddenKeys, key)) push(result, key);
  20518. });
  20519. return result;
  20520. };
  20521. var $getOwnPropertySymbols = function (O) {
  20522. var IS_OBJECT_PROTOTYPE = O === ObjectPrototype;
  20523. var names = nativeGetOwnPropertyNames(IS_OBJECT_PROTOTYPE ? ObjectPrototypeSymbols : toIndexedObject(O));
  20524. var result = [];
  20525. $forEach(names, function (key) {
  20526. if (hasOwn(AllSymbols, key) && (!IS_OBJECT_PROTOTYPE || hasOwn(ObjectPrototype, key))) {
  20527. push(result, AllSymbols[key]);
  20528. }
  20529. });
  20530. return result;
  20531. };
  20532. // `Symbol` constructor
  20533. // https://tc39.es/ecma262/#sec-symbol-constructor
  20534. if (!NATIVE_SYMBOL) {
  20535. $Symbol = function Symbol() {
  20536. if (isPrototypeOf(SymbolPrototype, this)) throw TypeError('Symbol is not a constructor');
  20537. var description = !arguments.length || arguments[0] === undefined ? undefined : $toString(arguments[0]);
  20538. var tag = uid(description);
  20539. var setter = function (value) {
  20540. if (this === ObjectPrototype) call(setter, ObjectPrototypeSymbols, value);
  20541. if (hasOwn(this, HIDDEN) && hasOwn(this[HIDDEN], tag)) this[HIDDEN][tag] = false;
  20542. setSymbolDescriptor(this, tag, createPropertyDescriptor(1, value));
  20543. };
  20544. if (DESCRIPTORS && USE_SETTER) setSymbolDescriptor(ObjectPrototype, tag, { configurable: true, set: setter });
  20545. return wrap(tag, description);
  20546. };
  20547. SymbolPrototype = $Symbol[PROTOTYPE];
  20548. defineBuiltIn(SymbolPrototype, 'toString', function toString() {
  20549. return getInternalState(this).tag;
  20550. });
  20551. defineBuiltIn($Symbol, 'withoutSetter', function (description) {
  20552. return wrap(uid(description), description);
  20553. });
  20554. propertyIsEnumerableModule.f = $propertyIsEnumerable;
  20555. definePropertyModule.f = $defineProperty;
  20556. definePropertiesModule.f = $defineProperties;
  20557. getOwnPropertyDescriptorModule.f = $getOwnPropertyDescriptor;
  20558. getOwnPropertyNamesModule.f = getOwnPropertyNamesExternal.f = $getOwnPropertyNames;
  20559. getOwnPropertySymbolsModule.f = $getOwnPropertySymbols;
  20560. wrappedWellKnownSymbolModule.f = function (name) {
  20561. return wrap(wellKnownSymbol(name), name);
  20562. };
  20563. if (DESCRIPTORS) {
  20564. // https://github.com/tc39/proposal-Symbol-description
  20565. defineBuiltInAccessor(SymbolPrototype, 'description', {
  20566. configurable: true,
  20567. get: function description() {
  20568. return getInternalState(this).description;
  20569. }
  20570. });
  20571. if (!IS_PURE) {
  20572. defineBuiltIn(ObjectPrototype, 'propertyIsEnumerable', $propertyIsEnumerable, { unsafe: true });
  20573. }
  20574. }
  20575. }
  20576. $({ global: true, constructor: true, wrap: true, forced: !NATIVE_SYMBOL, sham: !NATIVE_SYMBOL }, {
  20577. Symbol: $Symbol
  20578. });
  20579. $forEach(objectKeys(WellKnownSymbolsStore), function (name) {
  20580. defineWellKnownSymbol(name);
  20581. });
  20582. $({ target: SYMBOL, stat: true, forced: !NATIVE_SYMBOL }, {
  20583. useSetter: function () { USE_SETTER = true; },
  20584. useSimple: function () { USE_SETTER = false; }
  20585. });
  20586. $({ target: 'Object', stat: true, forced: !NATIVE_SYMBOL, sham: !DESCRIPTORS }, {
  20587. // `Object.create` method
  20588. // https://tc39.es/ecma262/#sec-object.create
  20589. create: $create,
  20590. // `Object.defineProperty` method
  20591. // https://tc39.es/ecma262/#sec-object.defineproperty
  20592. defineProperty: $defineProperty,
  20593. // `Object.defineProperties` method
  20594. // https://tc39.es/ecma262/#sec-object.defineproperties
  20595. defineProperties: $defineProperties,
  20596. // `Object.getOwnPropertyDescriptor` method
  20597. // https://tc39.es/ecma262/#sec-object.getownpropertydescriptors
  20598. getOwnPropertyDescriptor: $getOwnPropertyDescriptor
  20599. });
  20600. $({ target: 'Object', stat: true, forced: !NATIVE_SYMBOL }, {
  20601. // `Object.getOwnPropertyNames` method
  20602. // https://tc39.es/ecma262/#sec-object.getownpropertynames
  20603. getOwnPropertyNames: $getOwnPropertyNames
  20604. });
  20605. // `Symbol.prototype[@@toPrimitive]` method
  20606. // https://tc39.es/ecma262/#sec-symbol.prototype-@@toprimitive
  20607. defineSymbolToPrimitive();
  20608. // `Symbol.prototype[@@toStringTag]` property
  20609. // https://tc39.es/ecma262/#sec-symbol.prototype-@@tostringtag
  20610. setToStringTag($Symbol, SYMBOL);
  20611. hiddenKeys[HIDDEN] = true;
  20612. },{"../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){
  20613. arguments[4][363][0].apply(exports,arguments)
  20614. },{"dup":363}],401:[function(_dereq_,module,exports){
  20615. var $ = _dereq_('../internals/export');
  20616. var getBuiltIn = _dereq_('../internals/get-built-in');
  20617. var hasOwn = _dereq_('../internals/has-own-property');
  20618. var toString = _dereq_('../internals/to-string');
  20619. var shared = _dereq_('../internals/shared');
  20620. var NATIVE_SYMBOL_REGISTRY = _dereq_('../internals/symbol-registry-detection');
  20621. var StringToSymbolRegistry = shared('string-to-symbol-registry');
  20622. var SymbolToStringRegistry = shared('symbol-to-string-registry');
  20623. // `Symbol.for` method
  20624. // https://tc39.es/ecma262/#sec-symbol.for
  20625. $({ target: 'Symbol', stat: true, forced: !NATIVE_SYMBOL_REGISTRY }, {
  20626. 'for': function (key) {
  20627. var string = toString(key);
  20628. if (hasOwn(StringToSymbolRegistry, string)) return StringToSymbolRegistry[string];
  20629. var symbol = getBuiltIn('Symbol')(string);
  20630. StringToSymbolRegistry[string] = symbol;
  20631. SymbolToStringRegistry[symbol] = string;
  20632. return symbol;
  20633. }
  20634. });
  20635. },{"../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){
  20636. var defineWellKnownSymbol = _dereq_('../internals/well-known-symbol-define');
  20637. // `Symbol.hasInstance` well-known symbol
  20638. // https://tc39.es/ecma262/#sec-symbol.hasinstance
  20639. defineWellKnownSymbol('hasInstance');
  20640. },{"../internals/well-known-symbol-define":341}],403:[function(_dereq_,module,exports){
  20641. var defineWellKnownSymbol = _dereq_('../internals/well-known-symbol-define');
  20642. // `Symbol.isConcatSpreadable` well-known symbol
  20643. // https://tc39.es/ecma262/#sec-symbol.isconcatspreadable
  20644. defineWellKnownSymbol('isConcatSpreadable');
  20645. },{"../internals/well-known-symbol-define":341}],404:[function(_dereq_,module,exports){
  20646. var defineWellKnownSymbol = _dereq_('../internals/well-known-symbol-define');
  20647. // `Symbol.iterator` well-known symbol
  20648. // https://tc39.es/ecma262/#sec-symbol.iterator
  20649. defineWellKnownSymbol('iterator');
  20650. },{"../internals/well-known-symbol-define":341}],405:[function(_dereq_,module,exports){
  20651. // TODO: Remove this module from `core-js@4` since it's split to modules listed below
  20652. _dereq_('../modules/es.symbol.constructor');
  20653. _dereq_('../modules/es.symbol.for');
  20654. _dereq_('../modules/es.symbol.key-for');
  20655. _dereq_('../modules/es.json.stringify');
  20656. _dereq_('../modules/es.object.get-own-property-symbols');
  20657. },{"../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){
  20658. var $ = _dereq_('../internals/export');
  20659. var hasOwn = _dereq_('../internals/has-own-property');
  20660. var isSymbol = _dereq_('../internals/is-symbol');
  20661. var tryToString = _dereq_('../internals/try-to-string');
  20662. var shared = _dereq_('../internals/shared');
  20663. var NATIVE_SYMBOL_REGISTRY = _dereq_('../internals/symbol-registry-detection');
  20664. var SymbolToStringRegistry = shared('symbol-to-string-registry');
  20665. // `Symbol.keyFor` method
  20666. // https://tc39.es/ecma262/#sec-symbol.keyfor
  20667. $({ target: 'Symbol', stat: true, forced: !NATIVE_SYMBOL_REGISTRY }, {
  20668. keyFor: function keyFor(sym) {
  20669. if (!isSymbol(sym)) throw TypeError(tryToString(sym) + ' is not a symbol');
  20670. if (hasOwn(SymbolToStringRegistry, sym)) return SymbolToStringRegistry[sym];
  20671. }
  20672. });
  20673. },{"../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){
  20674. var defineWellKnownSymbol = _dereq_('../internals/well-known-symbol-define');
  20675. // `Symbol.matchAll` well-known symbol
  20676. // https://tc39.es/ecma262/#sec-symbol.matchall
  20677. defineWellKnownSymbol('matchAll');
  20678. },{"../internals/well-known-symbol-define":341}],408:[function(_dereq_,module,exports){
  20679. var defineWellKnownSymbol = _dereq_('../internals/well-known-symbol-define');
  20680. // `Symbol.match` well-known symbol
  20681. // https://tc39.es/ecma262/#sec-symbol.match
  20682. defineWellKnownSymbol('match');
  20683. },{"../internals/well-known-symbol-define":341}],409:[function(_dereq_,module,exports){
  20684. var defineWellKnownSymbol = _dereq_('../internals/well-known-symbol-define');
  20685. // `Symbol.replace` well-known symbol
  20686. // https://tc39.es/ecma262/#sec-symbol.replace
  20687. defineWellKnownSymbol('replace');
  20688. },{"../internals/well-known-symbol-define":341}],410:[function(_dereq_,module,exports){
  20689. var defineWellKnownSymbol = _dereq_('../internals/well-known-symbol-define');
  20690. // `Symbol.search` well-known symbol
  20691. // https://tc39.es/ecma262/#sec-symbol.search
  20692. defineWellKnownSymbol('search');
  20693. },{"../internals/well-known-symbol-define":341}],411:[function(_dereq_,module,exports){
  20694. var defineWellKnownSymbol = _dereq_('../internals/well-known-symbol-define');
  20695. // `Symbol.species` well-known symbol
  20696. // https://tc39.es/ecma262/#sec-symbol.species
  20697. defineWellKnownSymbol('species');
  20698. },{"../internals/well-known-symbol-define":341}],412:[function(_dereq_,module,exports){
  20699. var defineWellKnownSymbol = _dereq_('../internals/well-known-symbol-define');
  20700. // `Symbol.split` well-known symbol
  20701. // https://tc39.es/ecma262/#sec-symbol.split
  20702. defineWellKnownSymbol('split');
  20703. },{"../internals/well-known-symbol-define":341}],413:[function(_dereq_,module,exports){
  20704. var defineWellKnownSymbol = _dereq_('../internals/well-known-symbol-define');
  20705. var defineSymbolToPrimitive = _dereq_('../internals/symbol-define-to-primitive');
  20706. // `Symbol.toPrimitive` well-known symbol
  20707. // https://tc39.es/ecma262/#sec-symbol.toprimitive
  20708. defineWellKnownSymbol('toPrimitive');
  20709. // `Symbol.prototype[@@toPrimitive]` method
  20710. // https://tc39.es/ecma262/#sec-symbol.prototype-@@toprimitive
  20711. defineSymbolToPrimitive();
  20712. },{"../internals/symbol-define-to-primitive":323,"../internals/well-known-symbol-define":341}],414:[function(_dereq_,module,exports){
  20713. var getBuiltIn = _dereq_('../internals/get-built-in');
  20714. var defineWellKnownSymbol = _dereq_('../internals/well-known-symbol-define');
  20715. var setToStringTag = _dereq_('../internals/set-to-string-tag');
  20716. // `Symbol.toStringTag` well-known symbol
  20717. // https://tc39.es/ecma262/#sec-symbol.tostringtag
  20718. defineWellKnownSymbol('toStringTag');
  20719. // `Symbol.prototype[@@toStringTag]` property
  20720. // https://tc39.es/ecma262/#sec-symbol.prototype-@@tostringtag
  20721. setToStringTag(getBuiltIn('Symbol'), 'Symbol');
  20722. },{"../internals/get-built-in":246,"../internals/set-to-string-tag":315,"../internals/well-known-symbol-define":341}],415:[function(_dereq_,module,exports){
  20723. var defineWellKnownSymbol = _dereq_('../internals/well-known-symbol-define');
  20724. // `Symbol.unscopables` well-known symbol
  20725. // https://tc39.es/ecma262/#sec-symbol.unscopables
  20726. defineWellKnownSymbol('unscopables');
  20727. },{"../internals/well-known-symbol-define":341}],416:[function(_dereq_,module,exports){
  20728. 'use strict';
  20729. var FREEZING = _dereq_('../internals/freezing');
  20730. var global = _dereq_('../internals/global');
  20731. var uncurryThis = _dereq_('../internals/function-uncurry-this');
  20732. var defineBuiltIns = _dereq_('../internals/define-built-ins');
  20733. var InternalMetadataModule = _dereq_('../internals/internal-metadata');
  20734. var collection = _dereq_('../internals/collection');
  20735. var collectionWeak = _dereq_('../internals/collection-weak');
  20736. var isObject = _dereq_('../internals/is-object');
  20737. var enforceInternalState = _dereq_('../internals/internal-state').enforce;
  20738. var fails = _dereq_('../internals/fails');
  20739. var NATIVE_WEAK_MAP = _dereq_('../internals/weak-map-basic-detection');
  20740. var $Object = Object;
  20741. // eslint-disable-next-line es/no-array-isarray -- safe
  20742. var isArray = Array.isArray;
  20743. // eslint-disable-next-line es/no-object-isextensible -- safe
  20744. var isExtensible = $Object.isExtensible;
  20745. // eslint-disable-next-line es/no-object-isfrozen -- safe
  20746. var isFrozen = $Object.isFrozen;
  20747. // eslint-disable-next-line es/no-object-issealed -- safe
  20748. var isSealed = $Object.isSealed;
  20749. // eslint-disable-next-line es/no-object-freeze -- safe
  20750. var freeze = $Object.freeze;
  20751. // eslint-disable-next-line es/no-object-seal -- safe
  20752. var seal = $Object.seal;
  20753. var FROZEN = {};
  20754. var SEALED = {};
  20755. var IS_IE11 = !global.ActiveXObject && 'ActiveXObject' in global;
  20756. var InternalWeakMap;
  20757. var wrapper = function (init) {
  20758. return function WeakMap() {
  20759. return init(this, arguments.length ? arguments[0] : undefined);
  20760. };
  20761. };
  20762. // `WeakMap` constructor
  20763. // https://tc39.es/ecma262/#sec-weakmap-constructor
  20764. var $WeakMap = collection('WeakMap', wrapper, collectionWeak);
  20765. var WeakMapPrototype = $WeakMap.prototype;
  20766. var nativeSet = uncurryThis(WeakMapPrototype.set);
  20767. // Chakra Edge bug: adding frozen arrays to WeakMap unfreeze them
  20768. var hasMSEdgeFreezingBug = function () {
  20769. return FREEZING && fails(function () {
  20770. var frozenArray = freeze([]);
  20771. nativeSet(new $WeakMap(), frozenArray, 1);
  20772. return !isFrozen(frozenArray);
  20773. });
  20774. };
  20775. // IE11 WeakMap frozen keys fix
  20776. // We can't use feature detection because it crash some old IE builds
  20777. // https://github.com/zloirock/core-js/issues/485
  20778. if (NATIVE_WEAK_MAP) if (IS_IE11) {
  20779. InternalWeakMap = collectionWeak.getConstructor(wrapper, 'WeakMap', true);
  20780. InternalMetadataModule.enable();
  20781. var nativeDelete = uncurryThis(WeakMapPrototype['delete']);
  20782. var nativeHas = uncurryThis(WeakMapPrototype.has);
  20783. var nativeGet = uncurryThis(WeakMapPrototype.get);
  20784. defineBuiltIns(WeakMapPrototype, {
  20785. 'delete': function (key) {
  20786. if (isObject(key) && !isExtensible(key)) {
  20787. var state = enforceInternalState(this);
  20788. if (!state.frozen) state.frozen = new InternalWeakMap();
  20789. return nativeDelete(this, key) || state.frozen['delete'](key);
  20790. } return nativeDelete(this, key);
  20791. },
  20792. has: function has(key) {
  20793. if (isObject(key) && !isExtensible(key)) {
  20794. var state = enforceInternalState(this);
  20795. if (!state.frozen) state.frozen = new InternalWeakMap();
  20796. return nativeHas(this, key) || state.frozen.has(key);
  20797. } return nativeHas(this, key);
  20798. },
  20799. get: function get(key) {
  20800. if (isObject(key) && !isExtensible(key)) {
  20801. var state = enforceInternalState(this);
  20802. if (!state.frozen) state.frozen = new InternalWeakMap();
  20803. return nativeHas(this, key) ? nativeGet(this, key) : state.frozen.get(key);
  20804. } return nativeGet(this, key);
  20805. },
  20806. set: function set(key, value) {
  20807. if (isObject(key) && !isExtensible(key)) {
  20808. var state = enforceInternalState(this);
  20809. if (!state.frozen) state.frozen = new InternalWeakMap();
  20810. nativeHas(this, key) ? nativeSet(this, key, value) : state.frozen.set(key, value);
  20811. } else nativeSet(this, key, value);
  20812. return this;
  20813. }
  20814. });
  20815. // Chakra Edge frozen keys fix
  20816. } else if (hasMSEdgeFreezingBug()) {
  20817. defineBuiltIns(WeakMapPrototype, {
  20818. set: function set(key, value) {
  20819. var arrayIntegrityLevel;
  20820. if (isArray(key)) {
  20821. if (isFrozen(key)) arrayIntegrityLevel = FROZEN;
  20822. else if (isSealed(key)) arrayIntegrityLevel = SEALED;
  20823. }
  20824. nativeSet(this, key, value);
  20825. if (arrayIntegrityLevel == FROZEN) freeze(key);
  20826. if (arrayIntegrityLevel == SEALED) seal(key);
  20827. return this;
  20828. }
  20829. });
  20830. }
  20831. },{"../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){
  20832. // TODO: Remove this module from `core-js@4` since it's replaced to module below
  20833. _dereq_('../modules/es.weak-map.constructor');
  20834. },{"../modules/es.weak-map.constructor":416}],418:[function(_dereq_,module,exports){
  20835. var defineWellKnownSymbol = _dereq_('../internals/well-known-symbol-define');
  20836. // `Symbol.asyncDispose` well-known symbol
  20837. // https://github.com/tc39/proposal-async-explicit-resource-management
  20838. defineWellKnownSymbol('asyncDispose');
  20839. },{"../internals/well-known-symbol-define":341}],419:[function(_dereq_,module,exports){
  20840. var defineWellKnownSymbol = _dereq_('../internals/well-known-symbol-define');
  20841. // `Symbol.dispose` well-known symbol
  20842. // https://github.com/tc39/proposal-explicit-resource-management
  20843. defineWellKnownSymbol('dispose');
  20844. },{"../internals/well-known-symbol-define":341}],420:[function(_dereq_,module,exports){
  20845. var $ = _dereq_('../internals/export');
  20846. var getBuiltIn = _dereq_('../internals/get-built-in');
  20847. var uncurryThis = _dereq_('../internals/function-uncurry-this');
  20848. var Symbol = getBuiltIn('Symbol');
  20849. var keyFor = Symbol.keyFor;
  20850. var thisSymbolValue = uncurryThis(Symbol.prototype.valueOf);
  20851. // `Symbol.isRegistered` method
  20852. // https://tc39.es/proposal-symbol-predicates/#sec-symbol-isregistered
  20853. $({ target: 'Symbol', stat: true }, {
  20854. isRegistered: function isRegistered(value) {
  20855. try {
  20856. return keyFor(thisSymbolValue(value)) !== undefined;
  20857. } catch (error) {
  20858. return false;
  20859. }
  20860. }
  20861. });
  20862. },{"../internals/export":234,"../internals/function-uncurry-this":245,"../internals/get-built-in":246}],421:[function(_dereq_,module,exports){
  20863. var $ = _dereq_('../internals/export');
  20864. var shared = _dereq_('../internals/shared');
  20865. var getBuiltIn = _dereq_('../internals/get-built-in');
  20866. var uncurryThis = _dereq_('../internals/function-uncurry-this');
  20867. var isSymbol = _dereq_('../internals/is-symbol');
  20868. var wellKnownSymbol = _dereq_('../internals/well-known-symbol');
  20869. var Symbol = getBuiltIn('Symbol');
  20870. var $isWellKnown = Symbol.isWellKnown;
  20871. var getOwnPropertyNames = getBuiltIn('Object', 'getOwnPropertyNames');
  20872. var thisSymbolValue = uncurryThis(Symbol.prototype.valueOf);
  20873. var WellKnownSymbolsStore = shared('wks');
  20874. for (var i = 0, symbolKeys = getOwnPropertyNames(Symbol), symbolKeysLength = symbolKeys.length; i < symbolKeysLength; i++) {
  20875. // some old engines throws on access to some keys like `arguments` or `caller`
  20876. try {
  20877. var symbolKey = symbolKeys[i];
  20878. if (isSymbol(Symbol[symbolKey])) wellKnownSymbol(symbolKey);
  20879. } catch (error) { /* empty */ }
  20880. }
  20881. // `Symbol.isWellKnown` method
  20882. // https://tc39.es/proposal-symbol-predicates/#sec-symbol-iswellknown
  20883. // We should patch it for newly added well-known symbols. If it's not required, this module just will not be injected
  20884. $({ target: 'Symbol', stat: true, forced: true }, {
  20885. isWellKnown: function isWellKnown(value) {
  20886. if ($isWellKnown && $isWellKnown(value)) return true;
  20887. try {
  20888. var symbol = thisSymbolValue(value);
  20889. for (var j = 0, keys = getOwnPropertyNames(WellKnownSymbolsStore), keysLength = keys.length; j < keysLength; j++) {
  20890. if (WellKnownSymbolsStore[keys[j]] == symbol) return true;
  20891. }
  20892. } catch (error) { /* empty */ }
  20893. return false;
  20894. }
  20895. });
  20896. },{"../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){
  20897. var defineWellKnownSymbol = _dereq_('../internals/well-known-symbol-define');
  20898. // `Symbol.matcher` well-known symbol
  20899. // https://github.com/tc39/proposal-pattern-matching
  20900. defineWellKnownSymbol('matcher');
  20901. },{"../internals/well-known-symbol-define":341}],423:[function(_dereq_,module,exports){
  20902. var defineWellKnownSymbol = _dereq_('../internals/well-known-symbol-define');
  20903. // `Symbol.metadataKey` well-known symbol
  20904. // https://github.com/tc39/proposal-decorator-metadata
  20905. defineWellKnownSymbol('metadataKey');
  20906. },{"../internals/well-known-symbol-define":341}],424:[function(_dereq_,module,exports){
  20907. // TODO: Remove from `core-js@4`
  20908. var defineWellKnownSymbol = _dereq_('../internals/well-known-symbol-define');
  20909. // `Symbol.metadata` well-known symbol
  20910. // https://github.com/tc39/proposal-decorators
  20911. defineWellKnownSymbol('metadata');
  20912. },{"../internals/well-known-symbol-define":341}],425:[function(_dereq_,module,exports){
  20913. var defineWellKnownSymbol = _dereq_('../internals/well-known-symbol-define');
  20914. // `Symbol.observable` well-known symbol
  20915. // https://github.com/tc39/proposal-observable
  20916. defineWellKnownSymbol('observable');
  20917. },{"../internals/well-known-symbol-define":341}],426:[function(_dereq_,module,exports){
  20918. // TODO: remove from `core-js@4`
  20919. var defineWellKnownSymbol = _dereq_('../internals/well-known-symbol-define');
  20920. // `Symbol.patternMatch` well-known symbol
  20921. // https://github.com/tc39/proposal-pattern-matching
  20922. defineWellKnownSymbol('patternMatch');
  20923. },{"../internals/well-known-symbol-define":341}],427:[function(_dereq_,module,exports){
  20924. // TODO: remove from `core-js@4`
  20925. var defineWellKnownSymbol = _dereq_('../internals/well-known-symbol-define');
  20926. defineWellKnownSymbol('replaceAll');
  20927. },{"../internals/well-known-symbol-define":341}],428:[function(_dereq_,module,exports){
  20928. _dereq_('../modules/es.array.iterator');
  20929. var DOMIterables = _dereq_('../internals/dom-iterables');
  20930. var global = _dereq_('../internals/global');
  20931. var classof = _dereq_('../internals/classof');
  20932. var createNonEnumerableProperty = _dereq_('../internals/create-non-enumerable-property');
  20933. var Iterators = _dereq_('../internals/iterators');
  20934. var wellKnownSymbol = _dereq_('../internals/well-known-symbol');
  20935. var TO_STRING_TAG = wellKnownSymbol('toStringTag');
  20936. for (var COLLECTION_NAME in DOMIterables) {
  20937. var Collection = global[COLLECTION_NAME];
  20938. var CollectionPrototype = Collection && Collection.prototype;
  20939. if (CollectionPrototype && classof(CollectionPrototype) !== TO_STRING_TAG) {
  20940. createNonEnumerableProperty(CollectionPrototype, TO_STRING_TAG, COLLECTION_NAME);
  20941. }
  20942. Iterators[COLLECTION_NAME] = Iterators.Array;
  20943. }
  20944. },{"../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){
  20945. var $ = _dereq_('../internals/export');
  20946. var global = _dereq_('../internals/global');
  20947. var schedulersFix = _dereq_('../internals/schedulers-fix');
  20948. var setInterval = schedulersFix(global.setInterval, true);
  20949. // Bun / IE9- setInterval additional parameters fix
  20950. // https://html.spec.whatwg.org/multipage/timers-and-user-prompts.html#dom-setinterval
  20951. $({ global: true, bind: true, forced: global.setInterval !== setInterval }, {
  20952. setInterval: setInterval
  20953. });
  20954. },{"../internals/export":234,"../internals/global":251,"../internals/schedulers-fix":313}],430:[function(_dereq_,module,exports){
  20955. var $ = _dereq_('../internals/export');
  20956. var global = _dereq_('../internals/global');
  20957. var schedulersFix = _dereq_('../internals/schedulers-fix');
  20958. var setTimeout = schedulersFix(global.setTimeout, true);
  20959. // Bun / IE9- setTimeout additional parameters fix
  20960. // https://html.spec.whatwg.org/multipage/timers-and-user-prompts.html#dom-settimeout
  20961. $({ global: true, bind: true, forced: global.setTimeout !== setTimeout }, {
  20962. setTimeout: setTimeout
  20963. });
  20964. },{"../internals/export":234,"../internals/global":251,"../internals/schedulers-fix":313}],431:[function(_dereq_,module,exports){
  20965. // TODO: Remove this module from `core-js@4` since it's split to modules listed below
  20966. _dereq_('../modules/web.set-interval');
  20967. _dereq_('../modules/web.set-timeout');
  20968. },{"../modules/web.set-interval":429,"../modules/web.set-timeout":430}],432:[function(_dereq_,module,exports){
  20969. var parent = _dereq_('../../es/array/from');
  20970. module.exports = parent;
  20971. },{"../../es/array/from":112}],433:[function(_dereq_,module,exports){
  20972. var parent = _dereq_('../../es/array/is-array');
  20973. module.exports = parent;
  20974. },{"../../es/array/is-array":113}],434:[function(_dereq_,module,exports){
  20975. var parent = _dereq_('../../../es/array/virtual/entries');
  20976. module.exports = parent;
  20977. },{"../../../es/array/virtual/entries":115}],435:[function(_dereq_,module,exports){
  20978. var parent = _dereq_('../../../es/array/virtual/for-each');
  20979. module.exports = parent;
  20980. },{"../../../es/array/virtual/for-each":120}],436:[function(_dereq_,module,exports){
  20981. var parent = _dereq_('../../../es/array/virtual/keys');
  20982. module.exports = parent;
  20983. },{"../../../es/array/virtual/keys":123}],437:[function(_dereq_,module,exports){
  20984. var parent = _dereq_('../../../es/array/virtual/values');
  20985. module.exports = parent;
  20986. },{"../../../es/array/virtual/values":129}],438:[function(_dereq_,module,exports){
  20987. var parent = _dereq_('../../es/instance/bind');
  20988. module.exports = parent;
  20989. },{"../../es/instance/bind":131}],439:[function(_dereq_,module,exports){
  20990. var parent = _dereq_('../../es/instance/concat');
  20991. module.exports = parent;
  20992. },{"../../es/instance/concat":132}],440:[function(_dereq_,module,exports){
  20993. _dereq_('../../modules/web.dom-collections.iterator');
  20994. var classof = _dereq_('../../internals/classof');
  20995. var hasOwn = _dereq_('../../internals/has-own-property');
  20996. var isPrototypeOf = _dereq_('../../internals/object-is-prototype-of');
  20997. var method = _dereq_('../array/virtual/entries');
  20998. var ArrayPrototype = Array.prototype;
  20999. var DOMIterables = {
  21000. DOMTokenList: true,
  21001. NodeList: true
  21002. };
  21003. module.exports = function (it) {
  21004. var own = it.entries;
  21005. return it === ArrayPrototype || (isPrototypeOf(ArrayPrototype, it) && own === ArrayPrototype.entries)
  21006. || hasOwn(DOMIterables, classof(it)) ? method : own;
  21007. };
  21008. },{"../../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){
  21009. var parent = _dereq_('../../es/instance/every');
  21010. module.exports = parent;
  21011. },{"../../es/instance/every":133}],442:[function(_dereq_,module,exports){
  21012. var parent = _dereq_('../../es/instance/filter');
  21013. module.exports = parent;
  21014. },{"../../es/instance/filter":134}],443:[function(_dereq_,module,exports){
  21015. var parent = _dereq_('../../es/instance/find-index');
  21016. module.exports = parent;
  21017. },{"../../es/instance/find-index":135}],444:[function(_dereq_,module,exports){
  21018. var parent = _dereq_('../../es/instance/find');
  21019. module.exports = parent;
  21020. },{"../../es/instance/find":136}],445:[function(_dereq_,module,exports){
  21021. _dereq_('../../modules/web.dom-collections.iterator');
  21022. var classof = _dereq_('../../internals/classof');
  21023. var hasOwn = _dereq_('../../internals/has-own-property');
  21024. var isPrototypeOf = _dereq_('../../internals/object-is-prototype-of');
  21025. var method = _dereq_('../array/virtual/for-each');
  21026. var ArrayPrototype = Array.prototype;
  21027. var DOMIterables = {
  21028. DOMTokenList: true,
  21029. NodeList: true
  21030. };
  21031. module.exports = function (it) {
  21032. var own = it.forEach;
  21033. return it === ArrayPrototype || (isPrototypeOf(ArrayPrototype, it) && own === ArrayPrototype.forEach)
  21034. || hasOwn(DOMIterables, classof(it)) ? method : own;
  21035. };
  21036. },{"../../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){
  21037. var parent = _dereq_('../../es/instance/includes');
  21038. module.exports = parent;
  21039. },{"../../es/instance/includes":137}],447:[function(_dereq_,module,exports){
  21040. var parent = _dereq_('../../es/instance/index-of');
  21041. module.exports = parent;
  21042. },{"../../es/instance/index-of":138}],448:[function(_dereq_,module,exports){
  21043. _dereq_('../../modules/web.dom-collections.iterator');
  21044. var classof = _dereq_('../../internals/classof');
  21045. var hasOwn = _dereq_('../../internals/has-own-property');
  21046. var isPrototypeOf = _dereq_('../../internals/object-is-prototype-of');
  21047. var method = _dereq_('../array/virtual/keys');
  21048. var ArrayPrototype = Array.prototype;
  21049. var DOMIterables = {
  21050. DOMTokenList: true,
  21051. NodeList: true
  21052. };
  21053. module.exports = function (it) {
  21054. var own = it.keys;
  21055. return it === ArrayPrototype || (isPrototypeOf(ArrayPrototype, it) && own === ArrayPrototype.keys)
  21056. || hasOwn(DOMIterables, classof(it)) ? method : own;
  21057. };
  21058. },{"../../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){
  21059. var parent = _dereq_('../../es/instance/map');
  21060. module.exports = parent;
  21061. },{"../../es/instance/map":139}],450:[function(_dereq_,module,exports){
  21062. var parent = _dereq_('../../es/instance/reduce');
  21063. module.exports = parent;
  21064. },{"../../es/instance/reduce":140}],451:[function(_dereq_,module,exports){
  21065. var parent = _dereq_('../../es/instance/slice');
  21066. module.exports = parent;
  21067. },{"../../es/instance/slice":141}],452:[function(_dereq_,module,exports){
  21068. var parent = _dereq_('../../es/instance/sort');
  21069. module.exports = parent;
  21070. },{"../../es/instance/sort":142}],453:[function(_dereq_,module,exports){
  21071. var parent = _dereq_('../../es/instance/splice');
  21072. module.exports = parent;
  21073. },{"../../es/instance/splice":143}],454:[function(_dereq_,module,exports){
  21074. var parent = _dereq_('../../es/instance/starts-with');
  21075. module.exports = parent;
  21076. },{"../../es/instance/starts-with":144}],455:[function(_dereq_,module,exports){
  21077. _dereq_('../../modules/web.dom-collections.iterator');
  21078. var classof = _dereq_('../../internals/classof');
  21079. var hasOwn = _dereq_('../../internals/has-own-property');
  21080. var isPrototypeOf = _dereq_('../../internals/object-is-prototype-of');
  21081. var method = _dereq_('../array/virtual/values');
  21082. var ArrayPrototype = Array.prototype;
  21083. var DOMIterables = {
  21084. DOMTokenList: true,
  21085. NodeList: true
  21086. };
  21087. module.exports = function (it) {
  21088. var own = it.values;
  21089. return it === ArrayPrototype || (isPrototypeOf(ArrayPrototype, it) && own === ArrayPrototype.values)
  21090. || hasOwn(DOMIterables, classof(it)) ? method : own;
  21091. };
  21092. },{"../../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){
  21093. var parent = _dereq_('../../es/json/stringify');
  21094. module.exports = parent;
  21095. },{"../../es/json/stringify":145}],457:[function(_dereq_,module,exports){
  21096. var parent = _dereq_('../../es/map');
  21097. _dereq_('../../modules/web.dom-collections.iterator');
  21098. module.exports = parent;
  21099. },{"../../es/map":146,"../../modules/web.dom-collections.iterator":428}],458:[function(_dereq_,module,exports){
  21100. var parent = _dereq_('../../es/number/is-integer');
  21101. module.exports = parent;
  21102. },{"../../es/number/is-integer":147}],459:[function(_dereq_,module,exports){
  21103. var parent = _dereq_('../../es/object/assign');
  21104. module.exports = parent;
  21105. },{"../../es/object/assign":148}],460:[function(_dereq_,module,exports){
  21106. var parent = _dereq_('../../es/object/create');
  21107. module.exports = parent;
  21108. },{"../../es/object/create":149}],461:[function(_dereq_,module,exports){
  21109. var parent = _dereq_('../../es/object/define-property');
  21110. module.exports = parent;
  21111. },{"../../es/object/define-property":150}],462:[function(_dereq_,module,exports){
  21112. var parent = _dereq_('../../es/object/entries');
  21113. module.exports = parent;
  21114. },{"../../es/object/entries":151}],463:[function(_dereq_,module,exports){
  21115. var parent = _dereq_('../../es/object/freeze');
  21116. module.exports = parent;
  21117. },{"../../es/object/freeze":152}],464:[function(_dereq_,module,exports){
  21118. var parent = _dereq_('../../es/object/get-own-property-descriptor');
  21119. module.exports = parent;
  21120. },{"../../es/object/get-own-property-descriptor":153}],465:[function(_dereq_,module,exports){
  21121. var parent = _dereq_('../../es/object/get-prototype-of');
  21122. module.exports = parent;
  21123. },{"../../es/object/get-prototype-of":154}],466:[function(_dereq_,module,exports){
  21124. var parent = _dereq_('../../es/object/keys');
  21125. module.exports = parent;
  21126. },{"../../es/object/keys":155}],467:[function(_dereq_,module,exports){
  21127. var parent = _dereq_('../es/parse-int');
  21128. module.exports = parent;
  21129. },{"../es/parse-int":156}],468:[function(_dereq_,module,exports){
  21130. var parent = _dereq_('../../es/promise');
  21131. _dereq_('../../modules/web.dom-collections.iterator');
  21132. module.exports = parent;
  21133. },{"../../es/promise":157,"../../modules/web.dom-collections.iterator":428}],469:[function(_dereq_,module,exports){
  21134. _dereq_('../modules/web.timers');
  21135. var path = _dereq_('../internals/path');
  21136. module.exports = path.setInterval;
  21137. },{"../internals/path":305,"../modules/web.timers":431}],470:[function(_dereq_,module,exports){
  21138. _dereq_('../modules/web.timers');
  21139. var path = _dereq_('../internals/path');
  21140. module.exports = path.setTimeout;
  21141. },{"../internals/path":305,"../modules/web.timers":431}],471:[function(_dereq_,module,exports){
  21142. var parent = _dereq_('../../es/set');
  21143. _dereq_('../../modules/web.dom-collections.iterator');
  21144. module.exports = parent;
  21145. },{"../../es/set":158,"../../modules/web.dom-collections.iterator":428}],472:[function(_dereq_,module,exports){
  21146. var parent = _dereq_('../../es/symbol');
  21147. _dereq_('../../modules/web.dom-collections.iterator');
  21148. module.exports = parent;
  21149. },{"../../es/symbol":161,"../../modules/web.dom-collections.iterator":428}],473:[function(_dereq_,module,exports){
  21150. var parent = _dereq_('../../es/symbol/iterator');
  21151. _dereq_('../../modules/web.dom-collections.iterator');
  21152. module.exports = parent;
  21153. },{"../../es/symbol/iterator":162,"../../modules/web.dom-collections.iterator":428}],474:[function(_dereq_,module,exports){
  21154. var parent = _dereq_('../../es/symbol/to-primitive');
  21155. module.exports = parent;
  21156. },{"../../es/symbol/to-primitive":163}],475:[function(_dereq_,module,exports){
  21157. var parent = _dereq_('../../es/weak-map');
  21158. _dereq_('../../modules/web.dom-collections.iterator');
  21159. module.exports = parent;
  21160. },{"../../es/weak-map":164,"../../modules/web.dom-collections.iterator":428}],476:[function(_dereq_,module,exports){
  21161. ;(function (root, factory, undef) {
  21162. if (typeof exports === "object") {
  21163. // CommonJS
  21164. module.exports = exports = factory(_dereq_("./core"), _dereq_("./enc-base64"), _dereq_("./md5"), _dereq_("./evpkdf"), _dereq_("./cipher-core"));
  21165. }
  21166. else if (typeof define === "function" && define.amd) {
  21167. // AMD
  21168. define(["./core", "./enc-base64", "./md5", "./evpkdf", "./cipher-core"], factory);
  21169. }
  21170. else {
  21171. // Global (browser)
  21172. factory(root.CryptoJS);
  21173. }
  21174. }(this, function (CryptoJS) {
  21175. (function () {
  21176. // Shortcuts
  21177. var C = CryptoJS;
  21178. var C_lib = C.lib;
  21179. var BlockCipher = C_lib.BlockCipher;
  21180. var C_algo = C.algo;
  21181. // Lookup tables
  21182. var SBOX = [];
  21183. var INV_SBOX = [];
  21184. var SUB_MIX_0 = [];
  21185. var SUB_MIX_1 = [];
  21186. var SUB_MIX_2 = [];
  21187. var SUB_MIX_3 = [];
  21188. var INV_SUB_MIX_0 = [];
  21189. var INV_SUB_MIX_1 = [];
  21190. var INV_SUB_MIX_2 = [];
  21191. var INV_SUB_MIX_3 = [];
  21192. // Compute lookup tables
  21193. (function () {
  21194. // Compute double table
  21195. var d = [];
  21196. for (var i = 0; i < 256; i++) {
  21197. if (i < 128) {
  21198. d[i] = i << 1;
  21199. } else {
  21200. d[i] = (i << 1) ^ 0x11b;
  21201. }
  21202. }
  21203. // Walk GF(2^8)
  21204. var x = 0;
  21205. var xi = 0;
  21206. for (var i = 0; i < 256; i++) {
  21207. // Compute sbox
  21208. var sx = xi ^ (xi << 1) ^ (xi << 2) ^ (xi << 3) ^ (xi << 4);
  21209. sx = (sx >>> 8) ^ (sx & 0xff) ^ 0x63;
  21210. SBOX[x] = sx;
  21211. INV_SBOX[sx] = x;
  21212. // Compute multiplication
  21213. var x2 = d[x];
  21214. var x4 = d[x2];
  21215. var x8 = d[x4];
  21216. // Compute sub bytes, mix columns tables
  21217. var t = (d[sx] * 0x101) ^ (sx * 0x1010100);
  21218. SUB_MIX_0[x] = (t << 24) | (t >>> 8);
  21219. SUB_MIX_1[x] = (t << 16) | (t >>> 16);
  21220. SUB_MIX_2[x] = (t << 8) | (t >>> 24);
  21221. SUB_MIX_3[x] = t;
  21222. // Compute inv sub bytes, inv mix columns tables
  21223. var t = (x8 * 0x1010101) ^ (x4 * 0x10001) ^ (x2 * 0x101) ^ (x * 0x1010100);
  21224. INV_SUB_MIX_0[sx] = (t << 24) | (t >>> 8);
  21225. INV_SUB_MIX_1[sx] = (t << 16) | (t >>> 16);
  21226. INV_SUB_MIX_2[sx] = (t << 8) | (t >>> 24);
  21227. INV_SUB_MIX_3[sx] = t;
  21228. // Compute next counter
  21229. if (!x) {
  21230. x = xi = 1;
  21231. } else {
  21232. x = x2 ^ d[d[d[x8 ^ x2]]];
  21233. xi ^= d[d[xi]];
  21234. }
  21235. }
  21236. }());
  21237. // Precomputed Rcon lookup
  21238. var RCON = [0x00, 0x01, 0x02, 0x04, 0x08, 0x10, 0x20, 0x40, 0x80, 0x1b, 0x36];
  21239. /**
  21240. * AES block cipher algorithm.
  21241. */
  21242. var AES = C_algo.AES = BlockCipher.extend({
  21243. _doReset: function () {
  21244. var t;
  21245. // Skip reset of nRounds has been set before and key did not change
  21246. if (this._nRounds && this._keyPriorReset === this._key) {
  21247. return;
  21248. }
  21249. // Shortcuts
  21250. var key = this._keyPriorReset = this._key;
  21251. var keyWords = key.words;
  21252. var keySize = key.sigBytes / 4;
  21253. // Compute number of rounds
  21254. var nRounds = this._nRounds = keySize + 6;
  21255. // Compute number of key schedule rows
  21256. var ksRows = (nRounds + 1) * 4;
  21257. // Compute key schedule
  21258. var keySchedule = this._keySchedule = [];
  21259. for (var ksRow = 0; ksRow < ksRows; ksRow++) {
  21260. if (ksRow < keySize) {
  21261. keySchedule[ksRow] = keyWords[ksRow];
  21262. } else {
  21263. t = keySchedule[ksRow - 1];
  21264. if (!(ksRow % keySize)) {
  21265. // Rot word
  21266. t = (t << 8) | (t >>> 24);
  21267. // Sub word
  21268. t = (SBOX[t >>> 24] << 24) | (SBOX[(t >>> 16) & 0xff] << 16) | (SBOX[(t >>> 8) & 0xff] << 8) | SBOX[t & 0xff];
  21269. // Mix Rcon
  21270. t ^= RCON[(ksRow / keySize) | 0] << 24;
  21271. } else if (keySize > 6 && ksRow % keySize == 4) {
  21272. // Sub word
  21273. t = (SBOX[t >>> 24] << 24) | (SBOX[(t >>> 16) & 0xff] << 16) | (SBOX[(t >>> 8) & 0xff] << 8) | SBOX[t & 0xff];
  21274. }
  21275. keySchedule[ksRow] = keySchedule[ksRow - keySize] ^ t;
  21276. }
  21277. }
  21278. // Compute inv key schedule
  21279. var invKeySchedule = this._invKeySchedule = [];
  21280. for (var invKsRow = 0; invKsRow < ksRows; invKsRow++) {
  21281. var ksRow = ksRows - invKsRow;
  21282. if (invKsRow % 4) {
  21283. var t = keySchedule[ksRow];
  21284. } else {
  21285. var t = keySchedule[ksRow - 4];
  21286. }
  21287. if (invKsRow < 4 || ksRow <= 4) {
  21288. invKeySchedule[invKsRow] = t;
  21289. } else {
  21290. invKeySchedule[invKsRow] = INV_SUB_MIX_0[SBOX[t >>> 24]] ^ INV_SUB_MIX_1[SBOX[(t >>> 16) & 0xff]] ^
  21291. INV_SUB_MIX_2[SBOX[(t >>> 8) & 0xff]] ^ INV_SUB_MIX_3[SBOX[t & 0xff]];
  21292. }
  21293. }
  21294. },
  21295. encryptBlock: function (M, offset) {
  21296. this._doCryptBlock(M, offset, this._keySchedule, SUB_MIX_0, SUB_MIX_1, SUB_MIX_2, SUB_MIX_3, SBOX);
  21297. },
  21298. decryptBlock: function (M, offset) {
  21299. // Swap 2nd and 4th rows
  21300. var t = M[offset + 1];
  21301. M[offset + 1] = M[offset + 3];
  21302. M[offset + 3] = t;
  21303. this._doCryptBlock(M, offset, this._invKeySchedule, INV_SUB_MIX_0, INV_SUB_MIX_1, INV_SUB_MIX_2, INV_SUB_MIX_3, INV_SBOX);
  21304. // Inv swap 2nd and 4th rows
  21305. var t = M[offset + 1];
  21306. M[offset + 1] = M[offset + 3];
  21307. M[offset + 3] = t;
  21308. },
  21309. _doCryptBlock: function (M, offset, keySchedule, SUB_MIX_0, SUB_MIX_1, SUB_MIX_2, SUB_MIX_3, SBOX) {
  21310. // Shortcut
  21311. var nRounds = this._nRounds;
  21312. // Get input, add round key
  21313. var s0 = M[offset] ^ keySchedule[0];
  21314. var s1 = M[offset + 1] ^ keySchedule[1];
  21315. var s2 = M[offset + 2] ^ keySchedule[2];
  21316. var s3 = M[offset + 3] ^ keySchedule[3];
  21317. // Key schedule row counter
  21318. var ksRow = 4;
  21319. // Rounds
  21320. for (var round = 1; round < nRounds; round++) {
  21321. // Shift rows, sub bytes, mix columns, add round key
  21322. 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++];
  21323. 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++];
  21324. 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++];
  21325. 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++];
  21326. // Update state
  21327. s0 = t0;
  21328. s1 = t1;
  21329. s2 = t2;
  21330. s3 = t3;
  21331. }
  21332. // Shift rows, sub bytes, add round key
  21333. var t0 = ((SBOX[s0 >>> 24] << 24) | (SBOX[(s1 >>> 16) & 0xff] << 16) | (SBOX[(s2 >>> 8) & 0xff] << 8) | SBOX[s3 & 0xff]) ^ keySchedule[ksRow++];
  21334. var t1 = ((SBOX[s1 >>> 24] << 24) | (SBOX[(s2 >>> 16) & 0xff] << 16) | (SBOX[(s3 >>> 8) & 0xff] << 8) | SBOX[s0 & 0xff]) ^ keySchedule[ksRow++];
  21335. var t2 = ((SBOX[s2 >>> 24] << 24) | (SBOX[(s3 >>> 16) & 0xff] << 16) | (SBOX[(s0 >>> 8) & 0xff] << 8) | SBOX[s1 & 0xff]) ^ keySchedule[ksRow++];
  21336. var t3 = ((SBOX[s3 >>> 24] << 24) | (SBOX[(s0 >>> 16) & 0xff] << 16) | (SBOX[(s1 >>> 8) & 0xff] << 8) | SBOX[s2 & 0xff]) ^ keySchedule[ksRow++];
  21337. // Set output
  21338. M[offset] = t0;
  21339. M[offset + 1] = t1;
  21340. M[offset + 2] = t2;
  21341. M[offset + 3] = t3;
  21342. },
  21343. keySize: 256/32
  21344. });
  21345. /**
  21346. * Shortcut functions to the cipher's object interface.
  21347. *
  21348. * @example
  21349. *
  21350. * var ciphertext = CryptoJS.AES.encrypt(message, key, cfg);
  21351. * var plaintext = CryptoJS.AES.decrypt(ciphertext, key, cfg);
  21352. */
  21353. C.AES = BlockCipher._createHelper(AES);
  21354. }());
  21355. return CryptoJS.AES;
  21356. }));
  21357. },{"./cipher-core":477,"./core":478,"./enc-base64":479,"./evpkdf":481,"./md5":483}],477:[function(_dereq_,module,exports){
  21358. ;(function (root, factory, undef) {
  21359. if (typeof exports === "object") {
  21360. // CommonJS
  21361. module.exports = exports = factory(_dereq_("./core"), _dereq_("./evpkdf"));
  21362. }
  21363. else if (typeof define === "function" && define.amd) {
  21364. // AMD
  21365. define(["./core", "./evpkdf"], factory);
  21366. }
  21367. else {
  21368. // Global (browser)
  21369. factory(root.CryptoJS);
  21370. }
  21371. }(this, function (CryptoJS) {
  21372. /**
  21373. * Cipher core components.
  21374. */
  21375. CryptoJS.lib.Cipher || (function (undefined) {
  21376. // Shortcuts
  21377. var C = CryptoJS;
  21378. var C_lib = C.lib;
  21379. var Base = C_lib.Base;
  21380. var WordArray = C_lib.WordArray;
  21381. var BufferedBlockAlgorithm = C_lib.BufferedBlockAlgorithm;
  21382. var C_enc = C.enc;
  21383. var Utf8 = C_enc.Utf8;
  21384. var Base64 = C_enc.Base64;
  21385. var C_algo = C.algo;
  21386. var EvpKDF = C_algo.EvpKDF;
  21387. /**
  21388. * Abstract base cipher template.
  21389. *
  21390. * @property {number} keySize This cipher's key size. Default: 4 (128 bits)
  21391. * @property {number} ivSize This cipher's IV size. Default: 4 (128 bits)
  21392. * @property {number} _ENC_XFORM_MODE A constant representing encryption mode.
  21393. * @property {number} _DEC_XFORM_MODE A constant representing decryption mode.
  21394. */
  21395. var Cipher = C_lib.Cipher = BufferedBlockAlgorithm.extend({
  21396. /**
  21397. * Configuration options.
  21398. *
  21399. * @property {WordArray} iv The IV to use for this operation.
  21400. */
  21401. cfg: Base.extend(),
  21402. /**
  21403. * Creates this cipher in encryption mode.
  21404. *
  21405. * @param {WordArray} key The key.
  21406. * @param {Object} cfg (Optional) The configuration options to use for this operation.
  21407. *
  21408. * @return {Cipher} A cipher instance.
  21409. *
  21410. * @static
  21411. *
  21412. * @example
  21413. *
  21414. * var cipher = CryptoJS.algo.AES.createEncryptor(keyWordArray, { iv: ivWordArray });
  21415. */
  21416. createEncryptor: function (key, cfg) {
  21417. return this.create(this._ENC_XFORM_MODE, key, cfg);
  21418. },
  21419. /**
  21420. * Creates this cipher in decryption mode.
  21421. *
  21422. * @param {WordArray} key The key.
  21423. * @param {Object} cfg (Optional) The configuration options to use for this operation.
  21424. *
  21425. * @return {Cipher} A cipher instance.
  21426. *
  21427. * @static
  21428. *
  21429. * @example
  21430. *
  21431. * var cipher = CryptoJS.algo.AES.createDecryptor(keyWordArray, { iv: ivWordArray });
  21432. */
  21433. createDecryptor: function (key, cfg) {
  21434. return this.create(this._DEC_XFORM_MODE, key, cfg);
  21435. },
  21436. /**
  21437. * Initializes a newly created cipher.
  21438. *
  21439. * @param {number} xformMode Either the encryption or decryption transormation mode constant.
  21440. * @param {WordArray} key The key.
  21441. * @param {Object} cfg (Optional) The configuration options to use for this operation.
  21442. *
  21443. * @example
  21444. *
  21445. * var cipher = CryptoJS.algo.AES.create(CryptoJS.algo.AES._ENC_XFORM_MODE, keyWordArray, { iv: ivWordArray });
  21446. */
  21447. init: function (xformMode, key, cfg) {
  21448. // Apply config defaults
  21449. this.cfg = this.cfg.extend(cfg);
  21450. // Store transform mode and key
  21451. this._xformMode = xformMode;
  21452. this._key = key;
  21453. // Set initial values
  21454. this.reset();
  21455. },
  21456. /**
  21457. * Resets this cipher to its initial state.
  21458. *
  21459. * @example
  21460. *
  21461. * cipher.reset();
  21462. */
  21463. reset: function () {
  21464. // Reset data buffer
  21465. BufferedBlockAlgorithm.reset.call(this);
  21466. // Perform concrete-cipher logic
  21467. this._doReset();
  21468. },
  21469. /**
  21470. * Adds data to be encrypted or decrypted.
  21471. *
  21472. * @param {WordArray|string} dataUpdate The data to encrypt or decrypt.
  21473. *
  21474. * @return {WordArray} The data after processing.
  21475. *
  21476. * @example
  21477. *
  21478. * var encrypted = cipher.process('data');
  21479. * var encrypted = cipher.process(wordArray);
  21480. */
  21481. process: function (dataUpdate) {
  21482. // Append
  21483. this._append(dataUpdate);
  21484. // Process available blocks
  21485. return this._process();
  21486. },
  21487. /**
  21488. * Finalizes the encryption or decryption process.
  21489. * Note that the finalize operation is effectively a destructive, read-once operation.
  21490. *
  21491. * @param {WordArray|string} dataUpdate The final data to encrypt or decrypt.
  21492. *
  21493. * @return {WordArray} The data after final processing.
  21494. *
  21495. * @example
  21496. *
  21497. * var encrypted = cipher.finalize();
  21498. * var encrypted = cipher.finalize('data');
  21499. * var encrypted = cipher.finalize(wordArray);
  21500. */
  21501. finalize: function (dataUpdate) {
  21502. // Final data update
  21503. if (dataUpdate) {
  21504. this._append(dataUpdate);
  21505. }
  21506. // Perform concrete-cipher logic
  21507. var finalProcessedData = this._doFinalize();
  21508. return finalProcessedData;
  21509. },
  21510. keySize: 128/32,
  21511. ivSize: 128/32,
  21512. _ENC_XFORM_MODE: 1,
  21513. _DEC_XFORM_MODE: 2,
  21514. /**
  21515. * Creates shortcut functions to a cipher's object interface.
  21516. *
  21517. * @param {Cipher} cipher The cipher to create a helper for.
  21518. *
  21519. * @return {Object} An object with encrypt and decrypt shortcut functions.
  21520. *
  21521. * @static
  21522. *
  21523. * @example
  21524. *
  21525. * var AES = CryptoJS.lib.Cipher._createHelper(CryptoJS.algo.AES);
  21526. */
  21527. _createHelper: (function () {
  21528. function selectCipherStrategy(key) {
  21529. if (typeof key == 'string') {
  21530. return PasswordBasedCipher;
  21531. } else {
  21532. return SerializableCipher;
  21533. }
  21534. }
  21535. return function (cipher) {
  21536. return {
  21537. encrypt: function (message, key, cfg) {
  21538. return selectCipherStrategy(key).encrypt(cipher, message, key, cfg);
  21539. },
  21540. decrypt: function (ciphertext, key, cfg) {
  21541. return selectCipherStrategy(key).decrypt(cipher, ciphertext, key, cfg);
  21542. }
  21543. };
  21544. };
  21545. }())
  21546. });
  21547. /**
  21548. * Abstract base stream cipher template.
  21549. *
  21550. * @property {number} blockSize The number of 32-bit words this cipher operates on. Default: 1 (32 bits)
  21551. */
  21552. var StreamCipher = C_lib.StreamCipher = Cipher.extend({
  21553. _doFinalize: function () {
  21554. // Process partial blocks
  21555. var finalProcessedBlocks = this._process(!!'flush');
  21556. return finalProcessedBlocks;
  21557. },
  21558. blockSize: 1
  21559. });
  21560. /**
  21561. * Mode namespace.
  21562. */
  21563. var C_mode = C.mode = {};
  21564. /**
  21565. * Abstract base block cipher mode template.
  21566. */
  21567. var BlockCipherMode = C_lib.BlockCipherMode = Base.extend({
  21568. /**
  21569. * Creates this mode for encryption.
  21570. *
  21571. * @param {Cipher} cipher A block cipher instance.
  21572. * @param {Array} iv The IV words.
  21573. *
  21574. * @static
  21575. *
  21576. * @example
  21577. *
  21578. * var mode = CryptoJS.mode.CBC.createEncryptor(cipher, iv.words);
  21579. */
  21580. createEncryptor: function (cipher, iv) {
  21581. return this.Encryptor.create(cipher, iv);
  21582. },
  21583. /**
  21584. * Creates this mode for decryption.
  21585. *
  21586. * @param {Cipher} cipher A block cipher instance.
  21587. * @param {Array} iv The IV words.
  21588. *
  21589. * @static
  21590. *
  21591. * @example
  21592. *
  21593. * var mode = CryptoJS.mode.CBC.createDecryptor(cipher, iv.words);
  21594. */
  21595. createDecryptor: function (cipher, iv) {
  21596. return this.Decryptor.create(cipher, iv);
  21597. },
  21598. /**
  21599. * Initializes a newly created mode.
  21600. *
  21601. * @param {Cipher} cipher A block cipher instance.
  21602. * @param {Array} iv The IV words.
  21603. *
  21604. * @example
  21605. *
  21606. * var mode = CryptoJS.mode.CBC.Encryptor.create(cipher, iv.words);
  21607. */
  21608. init: function (cipher, iv) {
  21609. this._cipher = cipher;
  21610. this._iv = iv;
  21611. }
  21612. });
  21613. /**
  21614. * Cipher Block Chaining mode.
  21615. */
  21616. var CBC = C_mode.CBC = (function () {
  21617. /**
  21618. * Abstract base CBC mode.
  21619. */
  21620. var CBC = BlockCipherMode.extend();
  21621. /**
  21622. * CBC encryptor.
  21623. */
  21624. CBC.Encryptor = CBC.extend({
  21625. /**
  21626. * Processes the data block at offset.
  21627. *
  21628. * @param {Array} words The data words to operate on.
  21629. * @param {number} offset The offset where the block starts.
  21630. *
  21631. * @example
  21632. *
  21633. * mode.processBlock(data.words, offset);
  21634. */
  21635. processBlock: function (words, offset) {
  21636. // Shortcuts
  21637. var cipher = this._cipher;
  21638. var blockSize = cipher.blockSize;
  21639. // XOR and encrypt
  21640. xorBlock.call(this, words, offset, blockSize);
  21641. cipher.encryptBlock(words, offset);
  21642. // Remember this block to use with next block
  21643. this._prevBlock = words.slice(offset, offset + blockSize);
  21644. }
  21645. });
  21646. /**
  21647. * CBC decryptor.
  21648. */
  21649. CBC.Decryptor = CBC.extend({
  21650. /**
  21651. * Processes the data block at offset.
  21652. *
  21653. * @param {Array} words The data words to operate on.
  21654. * @param {number} offset The offset where the block starts.
  21655. *
  21656. * @example
  21657. *
  21658. * mode.processBlock(data.words, offset);
  21659. */
  21660. processBlock: function (words, offset) {
  21661. // Shortcuts
  21662. var cipher = this._cipher;
  21663. var blockSize = cipher.blockSize;
  21664. // Remember this block to use with next block
  21665. var thisBlock = words.slice(offset, offset + blockSize);
  21666. // Decrypt and XOR
  21667. cipher.decryptBlock(words, offset);
  21668. xorBlock.call(this, words, offset, blockSize);
  21669. // This block becomes the previous block
  21670. this._prevBlock = thisBlock;
  21671. }
  21672. });
  21673. function xorBlock(words, offset, blockSize) {
  21674. var block;
  21675. // Shortcut
  21676. var iv = this._iv;
  21677. // Choose mixing block
  21678. if (iv) {
  21679. block = iv;
  21680. // Remove IV for subsequent blocks
  21681. this._iv = undefined;
  21682. } else {
  21683. block = this._prevBlock;
  21684. }
  21685. // XOR blocks
  21686. for (var i = 0; i < blockSize; i++) {
  21687. words[offset + i] ^= block[i];
  21688. }
  21689. }
  21690. return CBC;
  21691. }());
  21692. /**
  21693. * Padding namespace.
  21694. */
  21695. var C_pad = C.pad = {};
  21696. /**
  21697. * PKCS #5/7 padding strategy.
  21698. */
  21699. var Pkcs7 = C_pad.Pkcs7 = {
  21700. /**
  21701. * Pads data using the algorithm defined in PKCS #5/7.
  21702. *
  21703. * @param {WordArray} data The data to pad.
  21704. * @param {number} blockSize The multiple that the data should be padded to.
  21705. *
  21706. * @static
  21707. *
  21708. * @example
  21709. *
  21710. * CryptoJS.pad.Pkcs7.pad(wordArray, 4);
  21711. */
  21712. pad: function (data, blockSize) {
  21713. // Shortcut
  21714. var blockSizeBytes = blockSize * 4;
  21715. // Count padding bytes
  21716. var nPaddingBytes = blockSizeBytes - data.sigBytes % blockSizeBytes;
  21717. // Create padding word
  21718. var paddingWord = (nPaddingBytes << 24) | (nPaddingBytes << 16) | (nPaddingBytes << 8) | nPaddingBytes;
  21719. // Create padding
  21720. var paddingWords = [];
  21721. for (var i = 0; i < nPaddingBytes; i += 4) {
  21722. paddingWords.push(paddingWord);
  21723. }
  21724. var padding = WordArray.create(paddingWords, nPaddingBytes);
  21725. // Add padding
  21726. data.concat(padding);
  21727. },
  21728. /**
  21729. * Unpads data that had been padded using the algorithm defined in PKCS #5/7.
  21730. *
  21731. * @param {WordArray} data The data to unpad.
  21732. *
  21733. * @static
  21734. *
  21735. * @example
  21736. *
  21737. * CryptoJS.pad.Pkcs7.unpad(wordArray);
  21738. */
  21739. unpad: function (data) {
  21740. // Get number of padding bytes from last byte
  21741. var nPaddingBytes = data.words[(data.sigBytes - 1) >>> 2] & 0xff;
  21742. // Remove padding
  21743. data.sigBytes -= nPaddingBytes;
  21744. }
  21745. };
  21746. /**
  21747. * Abstract base block cipher template.
  21748. *
  21749. * @property {number} blockSize The number of 32-bit words this cipher operates on. Default: 4 (128 bits)
  21750. */
  21751. var BlockCipher = C_lib.BlockCipher = Cipher.extend({
  21752. /**
  21753. * Configuration options.
  21754. *
  21755. * @property {Mode} mode The block mode to use. Default: CBC
  21756. * @property {Padding} padding The padding strategy to use. Default: Pkcs7
  21757. */
  21758. cfg: Cipher.cfg.extend({
  21759. mode: CBC,
  21760. padding: Pkcs7
  21761. }),
  21762. reset: function () {
  21763. var modeCreator;
  21764. // Reset cipher
  21765. Cipher.reset.call(this);
  21766. // Shortcuts
  21767. var cfg = this.cfg;
  21768. var iv = cfg.iv;
  21769. var mode = cfg.mode;
  21770. // Reset block mode
  21771. if (this._xformMode == this._ENC_XFORM_MODE) {
  21772. modeCreator = mode.createEncryptor;
  21773. } else /* if (this._xformMode == this._DEC_XFORM_MODE) */ {
  21774. modeCreator = mode.createDecryptor;
  21775. // Keep at least one block in the buffer for unpadding
  21776. this._minBufferSize = 1;
  21777. }
  21778. if (this._mode && this._mode.__creator == modeCreator) {
  21779. this._mode.init(this, iv && iv.words);
  21780. } else {
  21781. this._mode = modeCreator.call(mode, this, iv && iv.words);
  21782. this._mode.__creator = modeCreator;
  21783. }
  21784. },
  21785. _doProcessBlock: function (words, offset) {
  21786. this._mode.processBlock(words, offset);
  21787. },
  21788. _doFinalize: function () {
  21789. var finalProcessedBlocks;
  21790. // Shortcut
  21791. var padding = this.cfg.padding;
  21792. // Finalize
  21793. if (this._xformMode == this._ENC_XFORM_MODE) {
  21794. // Pad data
  21795. padding.pad(this._data, this.blockSize);
  21796. // Process final blocks
  21797. finalProcessedBlocks = this._process(!!'flush');
  21798. } else /* if (this._xformMode == this._DEC_XFORM_MODE) */ {
  21799. // Process final blocks
  21800. finalProcessedBlocks = this._process(!!'flush');
  21801. // Unpad data
  21802. padding.unpad(finalProcessedBlocks);
  21803. }
  21804. return finalProcessedBlocks;
  21805. },
  21806. blockSize: 128/32
  21807. });
  21808. /**
  21809. * A collection of cipher parameters.
  21810. *
  21811. * @property {WordArray} ciphertext The raw ciphertext.
  21812. * @property {WordArray} key The key to this ciphertext.
  21813. * @property {WordArray} iv The IV used in the ciphering operation.
  21814. * @property {WordArray} salt The salt used with a key derivation function.
  21815. * @property {Cipher} algorithm The cipher algorithm.
  21816. * @property {Mode} mode The block mode used in the ciphering operation.
  21817. * @property {Padding} padding The padding scheme used in the ciphering operation.
  21818. * @property {number} blockSize The block size of the cipher.
  21819. * @property {Format} formatter The default formatting strategy to convert this cipher params object to a string.
  21820. */
  21821. var CipherParams = C_lib.CipherParams = Base.extend({
  21822. /**
  21823. * Initializes a newly created cipher params object.
  21824. *
  21825. * @param {Object} cipherParams An object with any of the possible cipher parameters.
  21826. *
  21827. * @example
  21828. *
  21829. * var cipherParams = CryptoJS.lib.CipherParams.create({
  21830. * ciphertext: ciphertextWordArray,
  21831. * key: keyWordArray,
  21832. * iv: ivWordArray,
  21833. * salt: saltWordArray,
  21834. * algorithm: CryptoJS.algo.AES,
  21835. * mode: CryptoJS.mode.CBC,
  21836. * padding: CryptoJS.pad.PKCS7,
  21837. * blockSize: 4,
  21838. * formatter: CryptoJS.format.OpenSSL
  21839. * });
  21840. */
  21841. init: function (cipherParams) {
  21842. this.mixIn(cipherParams);
  21843. },
  21844. /**
  21845. * Converts this cipher params object to a string.
  21846. *
  21847. * @param {Format} formatter (Optional) The formatting strategy to use.
  21848. *
  21849. * @return {string} The stringified cipher params.
  21850. *
  21851. * @throws Error If neither the formatter nor the default formatter is set.
  21852. *
  21853. * @example
  21854. *
  21855. * var string = cipherParams + '';
  21856. * var string = cipherParams.toString();
  21857. * var string = cipherParams.toString(CryptoJS.format.OpenSSL);
  21858. */
  21859. toString: function (formatter) {
  21860. return (formatter || this.formatter).stringify(this);
  21861. }
  21862. });
  21863. /**
  21864. * Format namespace.
  21865. */
  21866. var C_format = C.format = {};
  21867. /**
  21868. * OpenSSL formatting strategy.
  21869. */
  21870. var OpenSSLFormatter = C_format.OpenSSL = {
  21871. /**
  21872. * Converts a cipher params object to an OpenSSL-compatible string.
  21873. *
  21874. * @param {CipherParams} cipherParams The cipher params object.
  21875. *
  21876. * @return {string} The OpenSSL-compatible string.
  21877. *
  21878. * @static
  21879. *
  21880. * @example
  21881. *
  21882. * var openSSLString = CryptoJS.format.OpenSSL.stringify(cipherParams);
  21883. */
  21884. stringify: function (cipherParams) {
  21885. var wordArray;
  21886. // Shortcuts
  21887. var ciphertext = cipherParams.ciphertext;
  21888. var salt = cipherParams.salt;
  21889. // Format
  21890. if (salt) {
  21891. wordArray = WordArray.create([0x53616c74, 0x65645f5f]).concat(salt).concat(ciphertext);
  21892. } else {
  21893. wordArray = ciphertext;
  21894. }
  21895. return wordArray.toString(Base64);
  21896. },
  21897. /**
  21898. * Converts an OpenSSL-compatible string to a cipher params object.
  21899. *
  21900. * @param {string} openSSLStr The OpenSSL-compatible string.
  21901. *
  21902. * @return {CipherParams} The cipher params object.
  21903. *
  21904. * @static
  21905. *
  21906. * @example
  21907. *
  21908. * var cipherParams = CryptoJS.format.OpenSSL.parse(openSSLString);
  21909. */
  21910. parse: function (openSSLStr) {
  21911. var salt;
  21912. // Parse base64
  21913. var ciphertext = Base64.parse(openSSLStr);
  21914. // Shortcut
  21915. var ciphertextWords = ciphertext.words;
  21916. // Test for salt
  21917. if (ciphertextWords[0] == 0x53616c74 && ciphertextWords[1] == 0x65645f5f) {
  21918. // Extract salt
  21919. salt = WordArray.create(ciphertextWords.slice(2, 4));
  21920. // Remove salt from ciphertext
  21921. ciphertextWords.splice(0, 4);
  21922. ciphertext.sigBytes -= 16;
  21923. }
  21924. return CipherParams.create({ ciphertext: ciphertext, salt: salt });
  21925. }
  21926. };
  21927. /**
  21928. * A cipher wrapper that returns ciphertext as a serializable cipher params object.
  21929. */
  21930. var SerializableCipher = C_lib.SerializableCipher = Base.extend({
  21931. /**
  21932. * Configuration options.
  21933. *
  21934. * @property {Formatter} format The formatting strategy to convert cipher param objects to and from a string. Default: OpenSSL
  21935. */
  21936. cfg: Base.extend({
  21937. format: OpenSSLFormatter
  21938. }),
  21939. /**
  21940. * Encrypts a message.
  21941. *
  21942. * @param {Cipher} cipher The cipher algorithm to use.
  21943. * @param {WordArray|string} message The message to encrypt.
  21944. * @param {WordArray} key The key.
  21945. * @param {Object} cfg (Optional) The configuration options to use for this operation.
  21946. *
  21947. * @return {CipherParams} A cipher params object.
  21948. *
  21949. * @static
  21950. *
  21951. * @example
  21952. *
  21953. * var ciphertextParams = CryptoJS.lib.SerializableCipher.encrypt(CryptoJS.algo.AES, message, key);
  21954. * var ciphertextParams = CryptoJS.lib.SerializableCipher.encrypt(CryptoJS.algo.AES, message, key, { iv: iv });
  21955. * var ciphertextParams = CryptoJS.lib.SerializableCipher.encrypt(CryptoJS.algo.AES, message, key, { iv: iv, format: CryptoJS.format.OpenSSL });
  21956. */
  21957. encrypt: function (cipher, message, key, cfg) {
  21958. // Apply config defaults
  21959. cfg = this.cfg.extend(cfg);
  21960. // Encrypt
  21961. var encryptor = cipher.createEncryptor(key, cfg);
  21962. var ciphertext = encryptor.finalize(message);
  21963. // Shortcut
  21964. var cipherCfg = encryptor.cfg;
  21965. // Create and return serializable cipher params
  21966. return CipherParams.create({
  21967. ciphertext: ciphertext,
  21968. key: key,
  21969. iv: cipherCfg.iv,
  21970. algorithm: cipher,
  21971. mode: cipherCfg.mode,
  21972. padding: cipherCfg.padding,
  21973. blockSize: cipher.blockSize,
  21974. formatter: cfg.format
  21975. });
  21976. },
  21977. /**
  21978. * Decrypts serialized ciphertext.
  21979. *
  21980. * @param {Cipher} cipher The cipher algorithm to use.
  21981. * @param {CipherParams|string} ciphertext The ciphertext to decrypt.
  21982. * @param {WordArray} key The key.
  21983. * @param {Object} cfg (Optional) The configuration options to use for this operation.
  21984. *
  21985. * @return {WordArray} The plaintext.
  21986. *
  21987. * @static
  21988. *
  21989. * @example
  21990. *
  21991. * var plaintext = CryptoJS.lib.SerializableCipher.decrypt(CryptoJS.algo.AES, formattedCiphertext, key, { iv: iv, format: CryptoJS.format.OpenSSL });
  21992. * var plaintext = CryptoJS.lib.SerializableCipher.decrypt(CryptoJS.algo.AES, ciphertextParams, key, { iv: iv, format: CryptoJS.format.OpenSSL });
  21993. */
  21994. decrypt: function (cipher, ciphertext, key, cfg) {
  21995. // Apply config defaults
  21996. cfg = this.cfg.extend(cfg);
  21997. // Convert string to CipherParams
  21998. ciphertext = this._parse(ciphertext, cfg.format);
  21999. // Decrypt
  22000. var plaintext = cipher.createDecryptor(key, cfg).finalize(ciphertext.ciphertext);
  22001. return plaintext;
  22002. },
  22003. /**
  22004. * Converts serialized ciphertext to CipherParams,
  22005. * else assumed CipherParams already and returns ciphertext unchanged.
  22006. *
  22007. * @param {CipherParams|string} ciphertext The ciphertext.
  22008. * @param {Formatter} format The formatting strategy to use to parse serialized ciphertext.
  22009. *
  22010. * @return {CipherParams} The unserialized ciphertext.
  22011. *
  22012. * @static
  22013. *
  22014. * @example
  22015. *
  22016. * var ciphertextParams = CryptoJS.lib.SerializableCipher._parse(ciphertextStringOrParams, format);
  22017. */
  22018. _parse: function (ciphertext, format) {
  22019. if (typeof ciphertext == 'string') {
  22020. return format.parse(ciphertext, this);
  22021. } else {
  22022. return ciphertext;
  22023. }
  22024. }
  22025. });
  22026. /**
  22027. * Key derivation function namespace.
  22028. */
  22029. var C_kdf = C.kdf = {};
  22030. /**
  22031. * OpenSSL key derivation function.
  22032. */
  22033. var OpenSSLKdf = C_kdf.OpenSSL = {
  22034. /**
  22035. * Derives a key and IV from a password.
  22036. *
  22037. * @param {string} password The password to derive from.
  22038. * @param {number} keySize The size in words of the key to generate.
  22039. * @param {number} ivSize The size in words of the IV to generate.
  22040. * @param {WordArray|string} salt (Optional) A 64-bit salt to use. If omitted, a salt will be generated randomly.
  22041. *
  22042. * @return {CipherParams} A cipher params object with the key, IV, and salt.
  22043. *
  22044. * @static
  22045. *
  22046. * @example
  22047. *
  22048. * var derivedParams = CryptoJS.kdf.OpenSSL.execute('Password', 256/32, 128/32);
  22049. * var derivedParams = CryptoJS.kdf.OpenSSL.execute('Password', 256/32, 128/32, 'saltsalt');
  22050. */
  22051. execute: function (password, keySize, ivSize, salt, hasher) {
  22052. // Generate random salt
  22053. if (!salt) {
  22054. salt = WordArray.random(64/8);
  22055. }
  22056. // Derive key and IV
  22057. if (!hasher) {
  22058. var key = EvpKDF.create({ keySize: keySize + ivSize }).compute(password, salt);
  22059. } else {
  22060. var key = EvpKDF.create({ keySize: keySize + ivSize, hasher: hasher }).compute(password, salt);
  22061. }
  22062. // Separate key and IV
  22063. var iv = WordArray.create(key.words.slice(keySize), ivSize * 4);
  22064. key.sigBytes = keySize * 4;
  22065. // Return params
  22066. return CipherParams.create({ key: key, iv: iv, salt: salt });
  22067. }
  22068. };
  22069. /**
  22070. * A serializable cipher wrapper that derives the key from a password,
  22071. * and returns ciphertext as a serializable cipher params object.
  22072. */
  22073. var PasswordBasedCipher = C_lib.PasswordBasedCipher = SerializableCipher.extend({
  22074. /**
  22075. * Configuration options.
  22076. *
  22077. * @property {KDF} kdf The key derivation function to use to generate a key and IV from a password. Default: OpenSSL
  22078. */
  22079. cfg: SerializableCipher.cfg.extend({
  22080. kdf: OpenSSLKdf
  22081. }),
  22082. /**
  22083. * Encrypts a message using a password.
  22084. *
  22085. * @param {Cipher} cipher The cipher algorithm to use.
  22086. * @param {WordArray|string} message The message to encrypt.
  22087. * @param {string} password The password.
  22088. * @param {Object} cfg (Optional) The configuration options to use for this operation.
  22089. *
  22090. * @return {CipherParams} A cipher params object.
  22091. *
  22092. * @static
  22093. *
  22094. * @example
  22095. *
  22096. * var ciphertextParams = CryptoJS.lib.PasswordBasedCipher.encrypt(CryptoJS.algo.AES, message, 'password');
  22097. * var ciphertextParams = CryptoJS.lib.PasswordBasedCipher.encrypt(CryptoJS.algo.AES, message, 'password', { format: CryptoJS.format.OpenSSL });
  22098. */
  22099. encrypt: function (cipher, message, password, cfg) {
  22100. // Apply config defaults
  22101. cfg = this.cfg.extend(cfg);
  22102. // Derive key and other params
  22103. var derivedParams = cfg.kdf.execute(password, cipher.keySize, cipher.ivSize, cfg.salt, cfg.hasher);
  22104. // Add IV to config
  22105. cfg.iv = derivedParams.iv;
  22106. // Encrypt
  22107. var ciphertext = SerializableCipher.encrypt.call(this, cipher, message, derivedParams.key, cfg);
  22108. // Mix in derived params
  22109. ciphertext.mixIn(derivedParams);
  22110. return ciphertext;
  22111. },
  22112. /**
  22113. * Decrypts serialized ciphertext using a password.
  22114. *
  22115. * @param {Cipher} cipher The cipher algorithm to use.
  22116. * @param {CipherParams|string} ciphertext The ciphertext to decrypt.
  22117. * @param {string} password The password.
  22118. * @param {Object} cfg (Optional) The configuration options to use for this operation.
  22119. *
  22120. * @return {WordArray} The plaintext.
  22121. *
  22122. * @static
  22123. *
  22124. * @example
  22125. *
  22126. * var plaintext = CryptoJS.lib.PasswordBasedCipher.decrypt(CryptoJS.algo.AES, formattedCiphertext, 'password', { format: CryptoJS.format.OpenSSL });
  22127. * var plaintext = CryptoJS.lib.PasswordBasedCipher.decrypt(CryptoJS.algo.AES, ciphertextParams, 'password', { format: CryptoJS.format.OpenSSL });
  22128. */
  22129. decrypt: function (cipher, ciphertext, password, cfg) {
  22130. // Apply config defaults
  22131. cfg = this.cfg.extend(cfg);
  22132. // Convert string to CipherParams
  22133. ciphertext = this._parse(ciphertext, cfg.format);
  22134. // Derive key and other params
  22135. var derivedParams = cfg.kdf.execute(password, cipher.keySize, cipher.ivSize, ciphertext.salt, cfg.hasher);
  22136. // Add IV to config
  22137. cfg.iv = derivedParams.iv;
  22138. // Decrypt
  22139. var plaintext = SerializableCipher.decrypt.call(this, cipher, ciphertext, derivedParams.key, cfg);
  22140. return plaintext;
  22141. }
  22142. });
  22143. }());
  22144. }));
  22145. },{"./core":478,"./evpkdf":481}],478:[function(_dereq_,module,exports){
  22146. (function (global){(function (){
  22147. ;(function (root, factory) {
  22148. if (typeof exports === "object") {
  22149. // CommonJS
  22150. module.exports = exports = factory();
  22151. }
  22152. else if (typeof define === "function" && define.amd) {
  22153. // AMD
  22154. define([], factory);
  22155. }
  22156. else {
  22157. // Global (browser)
  22158. root.CryptoJS = factory();
  22159. }
  22160. }(this, function () {
  22161. /*globals window, global, require*/
  22162. /**
  22163. * CryptoJS core components.
  22164. */
  22165. var CryptoJS = CryptoJS || (function (Math, undefined) {
  22166. var crypto;
  22167. // Native crypto from window (Browser)
  22168. if (typeof window !== 'undefined' && window.crypto) {
  22169. crypto = window.crypto;
  22170. }
  22171. // Native crypto in web worker (Browser)
  22172. if (typeof self !== 'undefined' && self.crypto) {
  22173. crypto = self.crypto;
  22174. }
  22175. // Native crypto from worker
  22176. if (typeof globalThis !== 'undefined' && globalThis.crypto) {
  22177. crypto = globalThis.crypto;
  22178. }
  22179. // Native (experimental IE 11) crypto from window (Browser)
  22180. if (!crypto && typeof window !== 'undefined' && window.msCrypto) {
  22181. crypto = window.msCrypto;
  22182. }
  22183. // Native crypto from global (NodeJS)
  22184. if (!crypto && typeof global !== 'undefined' && global.crypto) {
  22185. crypto = global.crypto;
  22186. }
  22187. // Native crypto import via require (NodeJS)
  22188. if (!crypto && typeof _dereq_ === 'function') {
  22189. try {
  22190. crypto = _dereq_('crypto');
  22191. } catch (err) {}
  22192. }
  22193. /*
  22194. * Cryptographically secure pseudorandom number generator
  22195. *
  22196. * As Math.random() is cryptographically not safe to use
  22197. */
  22198. var cryptoSecureRandomInt = function () {
  22199. if (crypto) {
  22200. // Use getRandomValues method (Browser)
  22201. if (typeof crypto.getRandomValues === 'function') {
  22202. try {
  22203. return crypto.getRandomValues(new Uint32Array(1))[0];
  22204. } catch (err) {}
  22205. }
  22206. // Use randomBytes method (NodeJS)
  22207. if (typeof crypto.randomBytes === 'function') {
  22208. try {
  22209. return crypto.randomBytes(4).readInt32LE();
  22210. } catch (err) {}
  22211. }
  22212. }
  22213. throw new Error('Native crypto module could not be used to get secure random number.');
  22214. };
  22215. /*
  22216. * Local polyfill of Object.create
  22217. */
  22218. var create = Object.create || (function () {
  22219. function F() {}
  22220. return function (obj) {
  22221. var subtype;
  22222. F.prototype = obj;
  22223. subtype = new F();
  22224. F.prototype = null;
  22225. return subtype;
  22226. };
  22227. }());
  22228. /**
  22229. * CryptoJS namespace.
  22230. */
  22231. var C = {};
  22232. /**
  22233. * Library namespace.
  22234. */
  22235. var C_lib = C.lib = {};
  22236. /**
  22237. * Base object for prototypal inheritance.
  22238. */
  22239. var Base = C_lib.Base = (function () {
  22240. return {
  22241. /**
  22242. * Creates a new object that inherits from this object.
  22243. *
  22244. * @param {Object} overrides Properties to copy into the new object.
  22245. *
  22246. * @return {Object} The new object.
  22247. *
  22248. * @static
  22249. *
  22250. * @example
  22251. *
  22252. * var MyType = CryptoJS.lib.Base.extend({
  22253. * field: 'value',
  22254. *
  22255. * method: function () {
  22256. * }
  22257. * });
  22258. */
  22259. extend: function (overrides) {
  22260. // Spawn
  22261. var subtype = create(this);
  22262. // Augment
  22263. if (overrides) {
  22264. subtype.mixIn(overrides);
  22265. }
  22266. // Create default initializer
  22267. if (!subtype.hasOwnProperty('init') || this.init === subtype.init) {
  22268. subtype.init = function () {
  22269. subtype.$super.init.apply(this, arguments);
  22270. };
  22271. }
  22272. // Initializer's prototype is the subtype object
  22273. subtype.init.prototype = subtype;
  22274. // Reference supertype
  22275. subtype.$super = this;
  22276. return subtype;
  22277. },
  22278. /**
  22279. * Extends this object and runs the init method.
  22280. * Arguments to create() will be passed to init().
  22281. *
  22282. * @return {Object} The new object.
  22283. *
  22284. * @static
  22285. *
  22286. * @example
  22287. *
  22288. * var instance = MyType.create();
  22289. */
  22290. create: function () {
  22291. var instance = this.extend();
  22292. instance.init.apply(instance, arguments);
  22293. return instance;
  22294. },
  22295. /**
  22296. * Initializes a newly created object.
  22297. * Override this method to add some logic when your objects are created.
  22298. *
  22299. * @example
  22300. *
  22301. * var MyType = CryptoJS.lib.Base.extend({
  22302. * init: function () {
  22303. * // ...
  22304. * }
  22305. * });
  22306. */
  22307. init: function () {
  22308. },
  22309. /**
  22310. * Copies properties into this object.
  22311. *
  22312. * @param {Object} properties The properties to mix in.
  22313. *
  22314. * @example
  22315. *
  22316. * MyType.mixIn({
  22317. * field: 'value'
  22318. * });
  22319. */
  22320. mixIn: function (properties) {
  22321. for (var propertyName in properties) {
  22322. if (properties.hasOwnProperty(propertyName)) {
  22323. this[propertyName] = properties[propertyName];
  22324. }
  22325. }
  22326. // IE won't copy toString using the loop above
  22327. if (properties.hasOwnProperty('toString')) {
  22328. this.toString = properties.toString;
  22329. }
  22330. },
  22331. /**
  22332. * Creates a copy of this object.
  22333. *
  22334. * @return {Object} The clone.
  22335. *
  22336. * @example
  22337. *
  22338. * var clone = instance.clone();
  22339. */
  22340. clone: function () {
  22341. return this.init.prototype.extend(this);
  22342. }
  22343. };
  22344. }());
  22345. /**
  22346. * An array of 32-bit words.
  22347. *
  22348. * @property {Array} words The array of 32-bit words.
  22349. * @property {number} sigBytes The number of significant bytes in this word array.
  22350. */
  22351. var WordArray = C_lib.WordArray = Base.extend({
  22352. /**
  22353. * Initializes a newly created word array.
  22354. *
  22355. * @param {Array} words (Optional) An array of 32-bit words.
  22356. * @param {number} sigBytes (Optional) The number of significant bytes in the words.
  22357. *
  22358. * @example
  22359. *
  22360. * var wordArray = CryptoJS.lib.WordArray.create();
  22361. * var wordArray = CryptoJS.lib.WordArray.create([0x00010203, 0x04050607]);
  22362. * var wordArray = CryptoJS.lib.WordArray.create([0x00010203, 0x04050607], 6);
  22363. */
  22364. init: function (words, sigBytes) {
  22365. words = this.words = words || [];
  22366. if (sigBytes != undefined) {
  22367. this.sigBytes = sigBytes;
  22368. } else {
  22369. this.sigBytes = words.length * 4;
  22370. }
  22371. },
  22372. /**
  22373. * Converts this word array to a string.
  22374. *
  22375. * @param {Encoder} encoder (Optional) The encoding strategy to use. Default: CryptoJS.enc.Hex
  22376. *
  22377. * @return {string} The stringified word array.
  22378. *
  22379. * @example
  22380. *
  22381. * var string = wordArray + '';
  22382. * var string = wordArray.toString();
  22383. * var string = wordArray.toString(CryptoJS.enc.Utf8);
  22384. */
  22385. toString: function (encoder) {
  22386. return (encoder || Hex).stringify(this);
  22387. },
  22388. /**
  22389. * Concatenates a word array to this word array.
  22390. *
  22391. * @param {WordArray} wordArray The word array to append.
  22392. *
  22393. * @return {WordArray} This word array.
  22394. *
  22395. * @example
  22396. *
  22397. * wordArray1.concat(wordArray2);
  22398. */
  22399. concat: function (wordArray) {
  22400. // Shortcuts
  22401. var thisWords = this.words;
  22402. var thatWords = wordArray.words;
  22403. var thisSigBytes = this.sigBytes;
  22404. var thatSigBytes = wordArray.sigBytes;
  22405. // Clamp excess bits
  22406. this.clamp();
  22407. // Concat
  22408. if (thisSigBytes % 4) {
  22409. // Copy one byte at a time
  22410. for (var i = 0; i < thatSigBytes; i++) {
  22411. var thatByte = (thatWords[i >>> 2] >>> (24 - (i % 4) * 8)) & 0xff;
  22412. thisWords[(thisSigBytes + i) >>> 2] |= thatByte << (24 - ((thisSigBytes + i) % 4) * 8);
  22413. }
  22414. } else {
  22415. // Copy one word at a time
  22416. for (var j = 0; j < thatSigBytes; j += 4) {
  22417. thisWords[(thisSigBytes + j) >>> 2] = thatWords[j >>> 2];
  22418. }
  22419. }
  22420. this.sigBytes += thatSigBytes;
  22421. // Chainable
  22422. return this;
  22423. },
  22424. /**
  22425. * Removes insignificant bits.
  22426. *
  22427. * @example
  22428. *
  22429. * wordArray.clamp();
  22430. */
  22431. clamp: function () {
  22432. // Shortcuts
  22433. var words = this.words;
  22434. var sigBytes = this.sigBytes;
  22435. // Clamp
  22436. words[sigBytes >>> 2] &= 0xffffffff << (32 - (sigBytes % 4) * 8);
  22437. words.length = Math.ceil(sigBytes / 4);
  22438. },
  22439. /**
  22440. * Creates a copy of this word array.
  22441. *
  22442. * @return {WordArray} The clone.
  22443. *
  22444. * @example
  22445. *
  22446. * var clone = wordArray.clone();
  22447. */
  22448. clone: function () {
  22449. var clone = Base.clone.call(this);
  22450. clone.words = this.words.slice(0);
  22451. return clone;
  22452. },
  22453. /**
  22454. * Creates a word array filled with random bytes.
  22455. *
  22456. * @param {number} nBytes The number of random bytes to generate.
  22457. *
  22458. * @return {WordArray} The random word array.
  22459. *
  22460. * @static
  22461. *
  22462. * @example
  22463. *
  22464. * var wordArray = CryptoJS.lib.WordArray.random(16);
  22465. */
  22466. random: function (nBytes) {
  22467. var words = [];
  22468. for (var i = 0; i < nBytes; i += 4) {
  22469. words.push(cryptoSecureRandomInt());
  22470. }
  22471. return new WordArray.init(words, nBytes);
  22472. }
  22473. });
  22474. /**
  22475. * Encoder namespace.
  22476. */
  22477. var C_enc = C.enc = {};
  22478. /**
  22479. * Hex encoding strategy.
  22480. */
  22481. var Hex = C_enc.Hex = {
  22482. /**
  22483. * Converts a word array to a hex string.
  22484. *
  22485. * @param {WordArray} wordArray The word array.
  22486. *
  22487. * @return {string} The hex string.
  22488. *
  22489. * @static
  22490. *
  22491. * @example
  22492. *
  22493. * var hexString = CryptoJS.enc.Hex.stringify(wordArray);
  22494. */
  22495. stringify: function (wordArray) {
  22496. // Shortcuts
  22497. var words = wordArray.words;
  22498. var sigBytes = wordArray.sigBytes;
  22499. // Convert
  22500. var hexChars = [];
  22501. for (var i = 0; i < sigBytes; i++) {
  22502. var bite = (words[i >>> 2] >>> (24 - (i % 4) * 8)) & 0xff;
  22503. hexChars.push((bite >>> 4).toString(16));
  22504. hexChars.push((bite & 0x0f).toString(16));
  22505. }
  22506. return hexChars.join('');
  22507. },
  22508. /**
  22509. * Converts a hex string to a word array.
  22510. *
  22511. * @param {string} hexStr The hex string.
  22512. *
  22513. * @return {WordArray} The word array.
  22514. *
  22515. * @static
  22516. *
  22517. * @example
  22518. *
  22519. * var wordArray = CryptoJS.enc.Hex.parse(hexString);
  22520. */
  22521. parse: function (hexStr) {
  22522. // Shortcut
  22523. var hexStrLength = hexStr.length;
  22524. // Convert
  22525. var words = [];
  22526. for (var i = 0; i < hexStrLength; i += 2) {
  22527. words[i >>> 3] |= parseInt(hexStr.substr(i, 2), 16) << (24 - (i % 8) * 4);
  22528. }
  22529. return new WordArray.init(words, hexStrLength / 2);
  22530. }
  22531. };
  22532. /**
  22533. * Latin1 encoding strategy.
  22534. */
  22535. var Latin1 = C_enc.Latin1 = {
  22536. /**
  22537. * Converts a word array to a Latin1 string.
  22538. *
  22539. * @param {WordArray} wordArray The word array.
  22540. *
  22541. * @return {string} The Latin1 string.
  22542. *
  22543. * @static
  22544. *
  22545. * @example
  22546. *
  22547. * var latin1String = CryptoJS.enc.Latin1.stringify(wordArray);
  22548. */
  22549. stringify: function (wordArray) {
  22550. // Shortcuts
  22551. var words = wordArray.words;
  22552. var sigBytes = wordArray.sigBytes;
  22553. // Convert
  22554. var latin1Chars = [];
  22555. for (var i = 0; i < sigBytes; i++) {
  22556. var bite = (words[i >>> 2] >>> (24 - (i % 4) * 8)) & 0xff;
  22557. latin1Chars.push(String.fromCharCode(bite));
  22558. }
  22559. return latin1Chars.join('');
  22560. },
  22561. /**
  22562. * Converts a Latin1 string to a word array.
  22563. *
  22564. * @param {string} latin1Str The Latin1 string.
  22565. *
  22566. * @return {WordArray} The word array.
  22567. *
  22568. * @static
  22569. *
  22570. * @example
  22571. *
  22572. * var wordArray = CryptoJS.enc.Latin1.parse(latin1String);
  22573. */
  22574. parse: function (latin1Str) {
  22575. // Shortcut
  22576. var latin1StrLength = latin1Str.length;
  22577. // Convert
  22578. var words = [];
  22579. for (var i = 0; i < latin1StrLength; i++) {
  22580. words[i >>> 2] |= (latin1Str.charCodeAt(i) & 0xff) << (24 - (i % 4) * 8);
  22581. }
  22582. return new WordArray.init(words, latin1StrLength);
  22583. }
  22584. };
  22585. /**
  22586. * UTF-8 encoding strategy.
  22587. */
  22588. var Utf8 = C_enc.Utf8 = {
  22589. /**
  22590. * Converts a word array to a UTF-8 string.
  22591. *
  22592. * @param {WordArray} wordArray The word array.
  22593. *
  22594. * @return {string} The UTF-8 string.
  22595. *
  22596. * @static
  22597. *
  22598. * @example
  22599. *
  22600. * var utf8String = CryptoJS.enc.Utf8.stringify(wordArray);
  22601. */
  22602. stringify: function (wordArray) {
  22603. try {
  22604. return decodeURIComponent(escape(Latin1.stringify(wordArray)));
  22605. } catch (e) {
  22606. throw new Error('Malformed UTF-8 data');
  22607. }
  22608. },
  22609. /**
  22610. * Converts a UTF-8 string to a word array.
  22611. *
  22612. * @param {string} utf8Str The UTF-8 string.
  22613. *
  22614. * @return {WordArray} The word array.
  22615. *
  22616. * @static
  22617. *
  22618. * @example
  22619. *
  22620. * var wordArray = CryptoJS.enc.Utf8.parse(utf8String);
  22621. */
  22622. parse: function (utf8Str) {
  22623. return Latin1.parse(unescape(encodeURIComponent(utf8Str)));
  22624. }
  22625. };
  22626. /**
  22627. * Abstract buffered block algorithm template.
  22628. *
  22629. * The property blockSize must be implemented in a concrete subtype.
  22630. *
  22631. * @property {number} _minBufferSize The number of blocks that should be kept unprocessed in the buffer. Default: 0
  22632. */
  22633. var BufferedBlockAlgorithm = C_lib.BufferedBlockAlgorithm = Base.extend({
  22634. /**
  22635. * Resets this block algorithm's data buffer to its initial state.
  22636. *
  22637. * @example
  22638. *
  22639. * bufferedBlockAlgorithm.reset();
  22640. */
  22641. reset: function () {
  22642. // Initial values
  22643. this._data = new WordArray.init();
  22644. this._nDataBytes = 0;
  22645. },
  22646. /**
  22647. * Adds new data to this block algorithm's buffer.
  22648. *
  22649. * @param {WordArray|string} data The data to append. Strings are converted to a WordArray using UTF-8.
  22650. *
  22651. * @example
  22652. *
  22653. * bufferedBlockAlgorithm._append('data');
  22654. * bufferedBlockAlgorithm._append(wordArray);
  22655. */
  22656. _append: function (data) {
  22657. // Convert string to WordArray, else assume WordArray already
  22658. if (typeof data == 'string') {
  22659. data = Utf8.parse(data);
  22660. }
  22661. // Append
  22662. this._data.concat(data);
  22663. this._nDataBytes += data.sigBytes;
  22664. },
  22665. /**
  22666. * Processes available data blocks.
  22667. *
  22668. * This method invokes _doProcessBlock(offset), which must be implemented by a concrete subtype.
  22669. *
  22670. * @param {boolean} doFlush Whether all blocks and partial blocks should be processed.
  22671. *
  22672. * @return {WordArray} The processed data.
  22673. *
  22674. * @example
  22675. *
  22676. * var processedData = bufferedBlockAlgorithm._process();
  22677. * var processedData = bufferedBlockAlgorithm._process(!!'flush');
  22678. */
  22679. _process: function (doFlush) {
  22680. var processedWords;
  22681. // Shortcuts
  22682. var data = this._data;
  22683. var dataWords = data.words;
  22684. var dataSigBytes = data.sigBytes;
  22685. var blockSize = this.blockSize;
  22686. var blockSizeBytes = blockSize * 4;
  22687. // Count blocks ready
  22688. var nBlocksReady = dataSigBytes / blockSizeBytes;
  22689. if (doFlush) {
  22690. // Round up to include partial blocks
  22691. nBlocksReady = Math.ceil(nBlocksReady);
  22692. } else {
  22693. // Round down to include only full blocks,
  22694. // less the number of blocks that must remain in the buffer
  22695. nBlocksReady = Math.max((nBlocksReady | 0) - this._minBufferSize, 0);
  22696. }
  22697. // Count words ready
  22698. var nWordsReady = nBlocksReady * blockSize;
  22699. // Count bytes ready
  22700. var nBytesReady = Math.min(nWordsReady * 4, dataSigBytes);
  22701. // Process blocks
  22702. if (nWordsReady) {
  22703. for (var offset = 0; offset < nWordsReady; offset += blockSize) {
  22704. // Perform concrete-algorithm logic
  22705. this._doProcessBlock(dataWords, offset);
  22706. }
  22707. // Remove processed words
  22708. processedWords = dataWords.splice(0, nWordsReady);
  22709. data.sigBytes -= nBytesReady;
  22710. }
  22711. // Return processed words
  22712. return new WordArray.init(processedWords, nBytesReady);
  22713. },
  22714. /**
  22715. * Creates a copy of this object.
  22716. *
  22717. * @return {Object} The clone.
  22718. *
  22719. * @example
  22720. *
  22721. * var clone = bufferedBlockAlgorithm.clone();
  22722. */
  22723. clone: function () {
  22724. var clone = Base.clone.call(this);
  22725. clone._data = this._data.clone();
  22726. return clone;
  22727. },
  22728. _minBufferSize: 0
  22729. });
  22730. /**
  22731. * Abstract hasher template.
  22732. *
  22733. * @property {number} blockSize The number of 32-bit words this hasher operates on. Default: 16 (512 bits)
  22734. */
  22735. var Hasher = C_lib.Hasher = BufferedBlockAlgorithm.extend({
  22736. /**
  22737. * Configuration options.
  22738. */
  22739. cfg: Base.extend(),
  22740. /**
  22741. * Initializes a newly created hasher.
  22742. *
  22743. * @param {Object} cfg (Optional) The configuration options to use for this hash computation.
  22744. *
  22745. * @example
  22746. *
  22747. * var hasher = CryptoJS.algo.SHA256.create();
  22748. */
  22749. init: function (cfg) {
  22750. // Apply config defaults
  22751. this.cfg = this.cfg.extend(cfg);
  22752. // Set initial values
  22753. this.reset();
  22754. },
  22755. /**
  22756. * Resets this hasher to its initial state.
  22757. *
  22758. * @example
  22759. *
  22760. * hasher.reset();
  22761. */
  22762. reset: function () {
  22763. // Reset data buffer
  22764. BufferedBlockAlgorithm.reset.call(this);
  22765. // Perform concrete-hasher logic
  22766. this._doReset();
  22767. },
  22768. /**
  22769. * Updates this hasher with a message.
  22770. *
  22771. * @param {WordArray|string} messageUpdate The message to append.
  22772. *
  22773. * @return {Hasher} This hasher.
  22774. *
  22775. * @example
  22776. *
  22777. * hasher.update('message');
  22778. * hasher.update(wordArray);
  22779. */
  22780. update: function (messageUpdate) {
  22781. // Append
  22782. this._append(messageUpdate);
  22783. // Update the hash
  22784. this._process();
  22785. // Chainable
  22786. return this;
  22787. },
  22788. /**
  22789. * Finalizes the hash computation.
  22790. * Note that the finalize operation is effectively a destructive, read-once operation.
  22791. *
  22792. * @param {WordArray|string} messageUpdate (Optional) A final message update.
  22793. *
  22794. * @return {WordArray} The hash.
  22795. *
  22796. * @example
  22797. *
  22798. * var hash = hasher.finalize();
  22799. * var hash = hasher.finalize('message');
  22800. * var hash = hasher.finalize(wordArray);
  22801. */
  22802. finalize: function (messageUpdate) {
  22803. // Final message update
  22804. if (messageUpdate) {
  22805. this._append(messageUpdate);
  22806. }
  22807. // Perform concrete-hasher logic
  22808. var hash = this._doFinalize();
  22809. return hash;
  22810. },
  22811. blockSize: 512/32,
  22812. /**
  22813. * Creates a shortcut function to a hasher's object interface.
  22814. *
  22815. * @param {Hasher} hasher The hasher to create a helper for.
  22816. *
  22817. * @return {Function} The shortcut function.
  22818. *
  22819. * @static
  22820. *
  22821. * @example
  22822. *
  22823. * var SHA256 = CryptoJS.lib.Hasher._createHelper(CryptoJS.algo.SHA256);
  22824. */
  22825. _createHelper: function (hasher) {
  22826. return function (message, cfg) {
  22827. return new hasher.init(cfg).finalize(message);
  22828. };
  22829. },
  22830. /**
  22831. * Creates a shortcut function to the HMAC's object interface.
  22832. *
  22833. * @param {Hasher} hasher The hasher to use in this HMAC helper.
  22834. *
  22835. * @return {Function} The shortcut function.
  22836. *
  22837. * @static
  22838. *
  22839. * @example
  22840. *
  22841. * var HmacSHA256 = CryptoJS.lib.Hasher._createHmacHelper(CryptoJS.algo.SHA256);
  22842. */
  22843. _createHmacHelper: function (hasher) {
  22844. return function (message, key) {
  22845. return new C_algo.HMAC.init(hasher, key).finalize(message);
  22846. };
  22847. }
  22848. });
  22849. /**
  22850. * Algorithm namespace.
  22851. */
  22852. var C_algo = C.algo = {};
  22853. return C;
  22854. }(Math));
  22855. return CryptoJS;
  22856. }));
  22857. }).call(this)}).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {})
  22858. },{"crypto":undefined}],479:[function(_dereq_,module,exports){
  22859. ;(function (root, factory) {
  22860. if (typeof exports === "object") {
  22861. // CommonJS
  22862. module.exports = exports = factory(_dereq_("./core"));
  22863. }
  22864. else if (typeof define === "function" && define.amd) {
  22865. // AMD
  22866. define(["./core"], factory);
  22867. }
  22868. else {
  22869. // Global (browser)
  22870. factory(root.CryptoJS);
  22871. }
  22872. }(this, function (CryptoJS) {
  22873. (function () {
  22874. // Shortcuts
  22875. var C = CryptoJS;
  22876. var C_lib = C.lib;
  22877. var WordArray = C_lib.WordArray;
  22878. var C_enc = C.enc;
  22879. /**
  22880. * Base64 encoding strategy.
  22881. */
  22882. var Base64 = C_enc.Base64 = {
  22883. /**
  22884. * Converts a word array to a Base64 string.
  22885. *
  22886. * @param {WordArray} wordArray The word array.
  22887. *
  22888. * @return {string} The Base64 string.
  22889. *
  22890. * @static
  22891. *
  22892. * @example
  22893. *
  22894. * var base64String = CryptoJS.enc.Base64.stringify(wordArray);
  22895. */
  22896. stringify: function (wordArray) {
  22897. // Shortcuts
  22898. var words = wordArray.words;
  22899. var sigBytes = wordArray.sigBytes;
  22900. var map = this._map;
  22901. // Clamp excess bits
  22902. wordArray.clamp();
  22903. // Convert
  22904. var base64Chars = [];
  22905. for (var i = 0; i < sigBytes; i += 3) {
  22906. var byte1 = (words[i >>> 2] >>> (24 - (i % 4) * 8)) & 0xff;
  22907. var byte2 = (words[(i + 1) >>> 2] >>> (24 - ((i + 1) % 4) * 8)) & 0xff;
  22908. var byte3 = (words[(i + 2) >>> 2] >>> (24 - ((i + 2) % 4) * 8)) & 0xff;
  22909. var triplet = (byte1 << 16) | (byte2 << 8) | byte3;
  22910. for (var j = 0; (j < 4) && (i + j * 0.75 < sigBytes); j++) {
  22911. base64Chars.push(map.charAt((triplet >>> (6 * (3 - j))) & 0x3f));
  22912. }
  22913. }
  22914. // Add padding
  22915. var paddingChar = map.charAt(64);
  22916. if (paddingChar) {
  22917. while (base64Chars.length % 4) {
  22918. base64Chars.push(paddingChar);
  22919. }
  22920. }
  22921. return base64Chars.join('');
  22922. },
  22923. /**
  22924. * Converts a Base64 string to a word array.
  22925. *
  22926. * @param {string} base64Str The Base64 string.
  22927. *
  22928. * @return {WordArray} The word array.
  22929. *
  22930. * @static
  22931. *
  22932. * @example
  22933. *
  22934. * var wordArray = CryptoJS.enc.Base64.parse(base64String);
  22935. */
  22936. parse: function (base64Str) {
  22937. // Shortcuts
  22938. var base64StrLength = base64Str.length;
  22939. var map = this._map;
  22940. var reverseMap = this._reverseMap;
  22941. if (!reverseMap) {
  22942. reverseMap = this._reverseMap = [];
  22943. for (var j = 0; j < map.length; j++) {
  22944. reverseMap[map.charCodeAt(j)] = j;
  22945. }
  22946. }
  22947. // Ignore padding
  22948. var paddingChar = map.charAt(64);
  22949. if (paddingChar) {
  22950. var paddingIndex = base64Str.indexOf(paddingChar);
  22951. if (paddingIndex !== -1) {
  22952. base64StrLength = paddingIndex;
  22953. }
  22954. }
  22955. // Convert
  22956. return parseLoop(base64Str, base64StrLength, reverseMap);
  22957. },
  22958. _map: 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/='
  22959. };
  22960. function parseLoop(base64Str, base64StrLength, reverseMap) {
  22961. var words = [];
  22962. var nBytes = 0;
  22963. for (var i = 0; i < base64StrLength; i++) {
  22964. if (i % 4) {
  22965. var bits1 = reverseMap[base64Str.charCodeAt(i - 1)] << ((i % 4) * 2);
  22966. var bits2 = reverseMap[base64Str.charCodeAt(i)] >>> (6 - (i % 4) * 2);
  22967. var bitsCombined = bits1 | bits2;
  22968. words[nBytes >>> 2] |= bitsCombined << (24 - (nBytes % 4) * 8);
  22969. nBytes++;
  22970. }
  22971. }
  22972. return WordArray.create(words, nBytes);
  22973. }
  22974. }());
  22975. return CryptoJS.enc.Base64;
  22976. }));
  22977. },{"./core":478}],480:[function(_dereq_,module,exports){
  22978. ;(function (root, factory) {
  22979. if (typeof exports === "object") {
  22980. // CommonJS
  22981. module.exports = exports = factory(_dereq_("./core"));
  22982. }
  22983. else if (typeof define === "function" && define.amd) {
  22984. // AMD
  22985. define(["./core"], factory);
  22986. }
  22987. else {
  22988. // Global (browser)
  22989. factory(root.CryptoJS);
  22990. }
  22991. }(this, function (CryptoJS) {
  22992. return CryptoJS.enc.Utf8;
  22993. }));
  22994. },{"./core":478}],481:[function(_dereq_,module,exports){
  22995. ;(function (root, factory, undef) {
  22996. if (typeof exports === "object") {
  22997. // CommonJS
  22998. module.exports = exports = factory(_dereq_("./core"), _dereq_("./sha1"), _dereq_("./hmac"));
  22999. }
  23000. else if (typeof define === "function" && define.amd) {
  23001. // AMD
  23002. define(["./core", "./sha1", "./hmac"], factory);
  23003. }
  23004. else {
  23005. // Global (browser)
  23006. factory(root.CryptoJS);
  23007. }
  23008. }(this, function (CryptoJS) {
  23009. (function () {
  23010. // Shortcuts
  23011. var C = CryptoJS;
  23012. var C_lib = C.lib;
  23013. var Base = C_lib.Base;
  23014. var WordArray = C_lib.WordArray;
  23015. var C_algo = C.algo;
  23016. var MD5 = C_algo.MD5;
  23017. /**
  23018. * This key derivation function is meant to conform with EVP_BytesToKey.
  23019. * www.openssl.org/docs/crypto/EVP_BytesToKey.html
  23020. */
  23021. var EvpKDF = C_algo.EvpKDF = Base.extend({
  23022. /**
  23023. * Configuration options.
  23024. *
  23025. * @property {number} keySize The key size in words to generate. Default: 4 (128 bits)
  23026. * @property {Hasher} hasher The hash algorithm to use. Default: MD5
  23027. * @property {number} iterations The number of iterations to perform. Default: 1
  23028. */
  23029. cfg: Base.extend({
  23030. keySize: 128/32,
  23031. hasher: MD5,
  23032. iterations: 1
  23033. }),
  23034. /**
  23035. * Initializes a newly created key derivation function.
  23036. *
  23037. * @param {Object} cfg (Optional) The configuration options to use for the derivation.
  23038. *
  23039. * @example
  23040. *
  23041. * var kdf = CryptoJS.algo.EvpKDF.create();
  23042. * var kdf = CryptoJS.algo.EvpKDF.create({ keySize: 8 });
  23043. * var kdf = CryptoJS.algo.EvpKDF.create({ keySize: 8, iterations: 1000 });
  23044. */
  23045. init: function (cfg) {
  23046. this.cfg = this.cfg.extend(cfg);
  23047. },
  23048. /**
  23049. * Derives a key from a password.
  23050. *
  23051. * @param {WordArray|string} password The password.
  23052. * @param {WordArray|string} salt A salt.
  23053. *
  23054. * @return {WordArray} The derived key.
  23055. *
  23056. * @example
  23057. *
  23058. * var key = kdf.compute(password, salt);
  23059. */
  23060. compute: function (password, salt) {
  23061. var block;
  23062. // Shortcut
  23063. var cfg = this.cfg;
  23064. // Init hasher
  23065. var hasher = cfg.hasher.create();
  23066. // Initial values
  23067. var derivedKey = WordArray.create();
  23068. // Shortcuts
  23069. var derivedKeyWords = derivedKey.words;
  23070. var keySize = cfg.keySize;
  23071. var iterations = cfg.iterations;
  23072. // Generate key
  23073. while (derivedKeyWords.length < keySize) {
  23074. if (block) {
  23075. hasher.update(block);
  23076. }
  23077. block = hasher.update(password).finalize(salt);
  23078. hasher.reset();
  23079. // Iterations
  23080. for (var i = 1; i < iterations; i++) {
  23081. block = hasher.finalize(block);
  23082. hasher.reset();
  23083. }
  23084. derivedKey.concat(block);
  23085. }
  23086. derivedKey.sigBytes = keySize * 4;
  23087. return derivedKey;
  23088. }
  23089. });
  23090. /**
  23091. * Derives a key from a password.
  23092. *
  23093. * @param {WordArray|string} password The password.
  23094. * @param {WordArray|string} salt A salt.
  23095. * @param {Object} cfg (Optional) The configuration options to use for this computation.
  23096. *
  23097. * @return {WordArray} The derived key.
  23098. *
  23099. * @static
  23100. *
  23101. * @example
  23102. *
  23103. * var key = CryptoJS.EvpKDF(password, salt);
  23104. * var key = CryptoJS.EvpKDF(password, salt, { keySize: 8 });
  23105. * var key = CryptoJS.EvpKDF(password, salt, { keySize: 8, iterations: 1000 });
  23106. */
  23107. C.EvpKDF = function (password, salt, cfg) {
  23108. return EvpKDF.create(cfg).compute(password, salt);
  23109. };
  23110. }());
  23111. return CryptoJS.EvpKDF;
  23112. }));
  23113. },{"./core":478,"./hmac":482,"./sha1":484}],482:[function(_dereq_,module,exports){
  23114. ;(function (root, factory) {
  23115. if (typeof exports === "object") {
  23116. // CommonJS
  23117. module.exports = exports = factory(_dereq_("./core"));
  23118. }
  23119. else if (typeof define === "function" && define.amd) {
  23120. // AMD
  23121. define(["./core"], factory);
  23122. }
  23123. else {
  23124. // Global (browser)
  23125. factory(root.CryptoJS);
  23126. }
  23127. }(this, function (CryptoJS) {
  23128. (function () {
  23129. // Shortcuts
  23130. var C = CryptoJS;
  23131. var C_lib = C.lib;
  23132. var Base = C_lib.Base;
  23133. var C_enc = C.enc;
  23134. var Utf8 = C_enc.Utf8;
  23135. var C_algo = C.algo;
  23136. /**
  23137. * HMAC algorithm.
  23138. */
  23139. var HMAC = C_algo.HMAC = Base.extend({
  23140. /**
  23141. * Initializes a newly created HMAC.
  23142. *
  23143. * @param {Hasher} hasher The hash algorithm to use.
  23144. * @param {WordArray|string} key The secret key.
  23145. *
  23146. * @example
  23147. *
  23148. * var hmacHasher = CryptoJS.algo.HMAC.create(CryptoJS.algo.SHA256, key);
  23149. */
  23150. init: function (hasher, key) {
  23151. // Init hasher
  23152. hasher = this._hasher = new hasher.init();
  23153. // Convert string to WordArray, else assume WordArray already
  23154. if (typeof key == 'string') {
  23155. key = Utf8.parse(key);
  23156. }
  23157. // Shortcuts
  23158. var hasherBlockSize = hasher.blockSize;
  23159. var hasherBlockSizeBytes = hasherBlockSize * 4;
  23160. // Allow arbitrary length keys
  23161. if (key.sigBytes > hasherBlockSizeBytes) {
  23162. key = hasher.finalize(key);
  23163. }
  23164. // Clamp excess bits
  23165. key.clamp();
  23166. // Clone key for inner and outer pads
  23167. var oKey = this._oKey = key.clone();
  23168. var iKey = this._iKey = key.clone();
  23169. // Shortcuts
  23170. var oKeyWords = oKey.words;
  23171. var iKeyWords = iKey.words;
  23172. // XOR keys with pad constants
  23173. for (var i = 0; i < hasherBlockSize; i++) {
  23174. oKeyWords[i] ^= 0x5c5c5c5c;
  23175. iKeyWords[i] ^= 0x36363636;
  23176. }
  23177. oKey.sigBytes = iKey.sigBytes = hasherBlockSizeBytes;
  23178. // Set initial values
  23179. this.reset();
  23180. },
  23181. /**
  23182. * Resets this HMAC to its initial state.
  23183. *
  23184. * @example
  23185. *
  23186. * hmacHasher.reset();
  23187. */
  23188. reset: function () {
  23189. // Shortcut
  23190. var hasher = this._hasher;
  23191. // Reset
  23192. hasher.reset();
  23193. hasher.update(this._iKey);
  23194. },
  23195. /**
  23196. * Updates this HMAC with a message.
  23197. *
  23198. * @param {WordArray|string} messageUpdate The message to append.
  23199. *
  23200. * @return {HMAC} This HMAC instance.
  23201. *
  23202. * @example
  23203. *
  23204. * hmacHasher.update('message');
  23205. * hmacHasher.update(wordArray);
  23206. */
  23207. update: function (messageUpdate) {
  23208. this._hasher.update(messageUpdate);
  23209. // Chainable
  23210. return this;
  23211. },
  23212. /**
  23213. * Finalizes the HMAC computation.
  23214. * Note that the finalize operation is effectively a destructive, read-once operation.
  23215. *
  23216. * @param {WordArray|string} messageUpdate (Optional) A final message update.
  23217. *
  23218. * @return {WordArray} The HMAC.
  23219. *
  23220. * @example
  23221. *
  23222. * var hmac = hmacHasher.finalize();
  23223. * var hmac = hmacHasher.finalize('message');
  23224. * var hmac = hmacHasher.finalize(wordArray);
  23225. */
  23226. finalize: function (messageUpdate) {
  23227. // Shortcut
  23228. var hasher = this._hasher;
  23229. // Compute HMAC
  23230. var innerHash = hasher.finalize(messageUpdate);
  23231. hasher.reset();
  23232. var hmac = hasher.finalize(this._oKey.clone().concat(innerHash));
  23233. return hmac;
  23234. }
  23235. });
  23236. }());
  23237. }));
  23238. },{"./core":478}],483:[function(_dereq_,module,exports){
  23239. ;(function (root, factory) {
  23240. if (typeof exports === "object") {
  23241. // CommonJS
  23242. module.exports = exports = factory(_dereq_("./core"));
  23243. }
  23244. else if (typeof define === "function" && define.amd) {
  23245. // AMD
  23246. define(["./core"], factory);
  23247. }
  23248. else {
  23249. // Global (browser)
  23250. factory(root.CryptoJS);
  23251. }
  23252. }(this, function (CryptoJS) {
  23253. (function (Math) {
  23254. // Shortcuts
  23255. var C = CryptoJS;
  23256. var C_lib = C.lib;
  23257. var WordArray = C_lib.WordArray;
  23258. var Hasher = C_lib.Hasher;
  23259. var C_algo = C.algo;
  23260. // Constants table
  23261. var T = [];
  23262. // Compute constants
  23263. (function () {
  23264. for (var i = 0; i < 64; i++) {
  23265. T[i] = (Math.abs(Math.sin(i + 1)) * 0x100000000) | 0;
  23266. }
  23267. }());
  23268. /**
  23269. * MD5 hash algorithm.
  23270. */
  23271. var MD5 = C_algo.MD5 = Hasher.extend({
  23272. _doReset: function () {
  23273. this._hash = new WordArray.init([
  23274. 0x67452301, 0xefcdab89,
  23275. 0x98badcfe, 0x10325476
  23276. ]);
  23277. },
  23278. _doProcessBlock: function (M, offset) {
  23279. // Swap endian
  23280. for (var i = 0; i < 16; i++) {
  23281. // Shortcuts
  23282. var offset_i = offset + i;
  23283. var M_offset_i = M[offset_i];
  23284. M[offset_i] = (
  23285. (((M_offset_i << 8) | (M_offset_i >>> 24)) & 0x00ff00ff) |
  23286. (((M_offset_i << 24) | (M_offset_i >>> 8)) & 0xff00ff00)
  23287. );
  23288. }
  23289. // Shortcuts
  23290. var H = this._hash.words;
  23291. var M_offset_0 = M[offset + 0];
  23292. var M_offset_1 = M[offset + 1];
  23293. var M_offset_2 = M[offset + 2];
  23294. var M_offset_3 = M[offset + 3];
  23295. var M_offset_4 = M[offset + 4];
  23296. var M_offset_5 = M[offset + 5];
  23297. var M_offset_6 = M[offset + 6];
  23298. var M_offset_7 = M[offset + 7];
  23299. var M_offset_8 = M[offset + 8];
  23300. var M_offset_9 = M[offset + 9];
  23301. var M_offset_10 = M[offset + 10];
  23302. var M_offset_11 = M[offset + 11];
  23303. var M_offset_12 = M[offset + 12];
  23304. var M_offset_13 = M[offset + 13];
  23305. var M_offset_14 = M[offset + 14];
  23306. var M_offset_15 = M[offset + 15];
  23307. // Working variables
  23308. var a = H[0];
  23309. var b = H[1];
  23310. var c = H[2];
  23311. var d = H[3];
  23312. // Computation
  23313. a = FF(a, b, c, d, M_offset_0, 7, T[0]);
  23314. d = FF(d, a, b, c, M_offset_1, 12, T[1]);
  23315. c = FF(c, d, a, b, M_offset_2, 17, T[2]);
  23316. b = FF(b, c, d, a, M_offset_3, 22, T[3]);
  23317. a = FF(a, b, c, d, M_offset_4, 7, T[4]);
  23318. d = FF(d, a, b, c, M_offset_5, 12, T[5]);
  23319. c = FF(c, d, a, b, M_offset_6, 17, T[6]);
  23320. b = FF(b, c, d, a, M_offset_7, 22, T[7]);
  23321. a = FF(a, b, c, d, M_offset_8, 7, T[8]);
  23322. d = FF(d, a, b, c, M_offset_9, 12, T[9]);
  23323. c = FF(c, d, a, b, M_offset_10, 17, T[10]);
  23324. b = FF(b, c, d, a, M_offset_11, 22, T[11]);
  23325. a = FF(a, b, c, d, M_offset_12, 7, T[12]);
  23326. d = FF(d, a, b, c, M_offset_13, 12, T[13]);
  23327. c = FF(c, d, a, b, M_offset_14, 17, T[14]);
  23328. b = FF(b, c, d, a, M_offset_15, 22, T[15]);
  23329. a = GG(a, b, c, d, M_offset_1, 5, T[16]);
  23330. d = GG(d, a, b, c, M_offset_6, 9, T[17]);
  23331. c = GG(c, d, a, b, M_offset_11, 14, T[18]);
  23332. b = GG(b, c, d, a, M_offset_0, 20, T[19]);
  23333. a = GG(a, b, c, d, M_offset_5, 5, T[20]);
  23334. d = GG(d, a, b, c, M_offset_10, 9, T[21]);
  23335. c = GG(c, d, a, b, M_offset_15, 14, T[22]);
  23336. b = GG(b, c, d, a, M_offset_4, 20, T[23]);
  23337. a = GG(a, b, c, d, M_offset_9, 5, T[24]);
  23338. d = GG(d, a, b, c, M_offset_14, 9, T[25]);
  23339. c = GG(c, d, a, b, M_offset_3, 14, T[26]);
  23340. b = GG(b, c, d, a, M_offset_8, 20, T[27]);
  23341. a = GG(a, b, c, d, M_offset_13, 5, T[28]);
  23342. d = GG(d, a, b, c, M_offset_2, 9, T[29]);
  23343. c = GG(c, d, a, b, M_offset_7, 14, T[30]);
  23344. b = GG(b, c, d, a, M_offset_12, 20, T[31]);
  23345. a = HH(a, b, c, d, M_offset_5, 4, T[32]);
  23346. d = HH(d, a, b, c, M_offset_8, 11, T[33]);
  23347. c = HH(c, d, a, b, M_offset_11, 16, T[34]);
  23348. b = HH(b, c, d, a, M_offset_14, 23, T[35]);
  23349. a = HH(a, b, c, d, M_offset_1, 4, T[36]);
  23350. d = HH(d, a, b, c, M_offset_4, 11, T[37]);
  23351. c = HH(c, d, a, b, M_offset_7, 16, T[38]);
  23352. b = HH(b, c, d, a, M_offset_10, 23, T[39]);
  23353. a = HH(a, b, c, d, M_offset_13, 4, T[40]);
  23354. d = HH(d, a, b, c, M_offset_0, 11, T[41]);
  23355. c = HH(c, d, a, b, M_offset_3, 16, T[42]);
  23356. b = HH(b, c, d, a, M_offset_6, 23, T[43]);
  23357. a = HH(a, b, c, d, M_offset_9, 4, T[44]);
  23358. d = HH(d, a, b, c, M_offset_12, 11, T[45]);
  23359. c = HH(c, d, a, b, M_offset_15, 16, T[46]);
  23360. b = HH(b, c, d, a, M_offset_2, 23, T[47]);
  23361. a = II(a, b, c, d, M_offset_0, 6, T[48]);
  23362. d = II(d, a, b, c, M_offset_7, 10, T[49]);
  23363. c = II(c, d, a, b, M_offset_14, 15, T[50]);
  23364. b = II(b, c, d, a, M_offset_5, 21, T[51]);
  23365. a = II(a, b, c, d, M_offset_12, 6, T[52]);
  23366. d = II(d, a, b, c, M_offset_3, 10, T[53]);
  23367. c = II(c, d, a, b, M_offset_10, 15, T[54]);
  23368. b = II(b, c, d, a, M_offset_1, 21, T[55]);
  23369. a = II(a, b, c, d, M_offset_8, 6, T[56]);
  23370. d = II(d, a, b, c, M_offset_15, 10, T[57]);
  23371. c = II(c, d, a, b, M_offset_6, 15, T[58]);
  23372. b = II(b, c, d, a, M_offset_13, 21, T[59]);
  23373. a = II(a, b, c, d, M_offset_4, 6, T[60]);
  23374. d = II(d, a, b, c, M_offset_11, 10, T[61]);
  23375. c = II(c, d, a, b, M_offset_2, 15, T[62]);
  23376. b = II(b, c, d, a, M_offset_9, 21, T[63]);
  23377. // Intermediate hash value
  23378. H[0] = (H[0] + a) | 0;
  23379. H[1] = (H[1] + b) | 0;
  23380. H[2] = (H[2] + c) | 0;
  23381. H[3] = (H[3] + d) | 0;
  23382. },
  23383. _doFinalize: function () {
  23384. // Shortcuts
  23385. var data = this._data;
  23386. var dataWords = data.words;
  23387. var nBitsTotal = this._nDataBytes * 8;
  23388. var nBitsLeft = data.sigBytes * 8;
  23389. // Add padding
  23390. dataWords[nBitsLeft >>> 5] |= 0x80 << (24 - nBitsLeft % 32);
  23391. var nBitsTotalH = Math.floor(nBitsTotal / 0x100000000);
  23392. var nBitsTotalL = nBitsTotal;
  23393. dataWords[(((nBitsLeft + 64) >>> 9) << 4) + 15] = (
  23394. (((nBitsTotalH << 8) | (nBitsTotalH >>> 24)) & 0x00ff00ff) |
  23395. (((nBitsTotalH << 24) | (nBitsTotalH >>> 8)) & 0xff00ff00)
  23396. );
  23397. dataWords[(((nBitsLeft + 64) >>> 9) << 4) + 14] = (
  23398. (((nBitsTotalL << 8) | (nBitsTotalL >>> 24)) & 0x00ff00ff) |
  23399. (((nBitsTotalL << 24) | (nBitsTotalL >>> 8)) & 0xff00ff00)
  23400. );
  23401. data.sigBytes = (dataWords.length + 1) * 4;
  23402. // Hash final blocks
  23403. this._process();
  23404. // Shortcuts
  23405. var hash = this._hash;
  23406. var H = hash.words;
  23407. // Swap endian
  23408. for (var i = 0; i < 4; i++) {
  23409. // Shortcut
  23410. var H_i = H[i];
  23411. H[i] = (((H_i << 8) | (H_i >>> 24)) & 0x00ff00ff) |
  23412. (((H_i << 24) | (H_i >>> 8)) & 0xff00ff00);
  23413. }
  23414. // Return final computed hash
  23415. return hash;
  23416. },
  23417. clone: function () {
  23418. var clone = Hasher.clone.call(this);
  23419. clone._hash = this._hash.clone();
  23420. return clone;
  23421. }
  23422. });
  23423. function FF(a, b, c, d, x, s, t) {
  23424. var n = a + ((b & c) | (~b & d)) + x + t;
  23425. return ((n << s) | (n >>> (32 - s))) + b;
  23426. }
  23427. function GG(a, b, c, d, x, s, t) {
  23428. var n = a + ((b & d) | (c & ~d)) + x + t;
  23429. return ((n << s) | (n >>> (32 - s))) + b;
  23430. }
  23431. function HH(a, b, c, d, x, s, t) {
  23432. var n = a + (b ^ c ^ d) + x + t;
  23433. return ((n << s) | (n >>> (32 - s))) + b;
  23434. }
  23435. function II(a, b, c, d, x, s, t) {
  23436. var n = a + (c ^ (b | ~d)) + x + t;
  23437. return ((n << s) | (n >>> (32 - s))) + b;
  23438. }
  23439. /**
  23440. * Shortcut function to the hasher's object interface.
  23441. *
  23442. * @param {WordArray|string} message The message to hash.
  23443. *
  23444. * @return {WordArray} The hash.
  23445. *
  23446. * @static
  23447. *
  23448. * @example
  23449. *
  23450. * var hash = CryptoJS.MD5('message');
  23451. * var hash = CryptoJS.MD5(wordArray);
  23452. */
  23453. C.MD5 = Hasher._createHelper(MD5);
  23454. /**
  23455. * Shortcut function to the HMAC's object interface.
  23456. *
  23457. * @param {WordArray|string} message The message to hash.
  23458. * @param {WordArray|string} key The secret key.
  23459. *
  23460. * @return {WordArray} The HMAC.
  23461. *
  23462. * @static
  23463. *
  23464. * @example
  23465. *
  23466. * var hmac = CryptoJS.HmacMD5(message, key);
  23467. */
  23468. C.HmacMD5 = Hasher._createHmacHelper(MD5);
  23469. }(Math));
  23470. return CryptoJS.MD5;
  23471. }));
  23472. },{"./core":478}],484:[function(_dereq_,module,exports){
  23473. ;(function (root, factory) {
  23474. if (typeof exports === "object") {
  23475. // CommonJS
  23476. module.exports = exports = factory(_dereq_("./core"));
  23477. }
  23478. else if (typeof define === "function" && define.amd) {
  23479. // AMD
  23480. define(["./core"], factory);
  23481. }
  23482. else {
  23483. // Global (browser)
  23484. factory(root.CryptoJS);
  23485. }
  23486. }(this, function (CryptoJS) {
  23487. (function () {
  23488. // Shortcuts
  23489. var C = CryptoJS;
  23490. var C_lib = C.lib;
  23491. var WordArray = C_lib.WordArray;
  23492. var Hasher = C_lib.Hasher;
  23493. var C_algo = C.algo;
  23494. // Reusable object
  23495. var W = [];
  23496. /**
  23497. * SHA-1 hash algorithm.
  23498. */
  23499. var SHA1 = C_algo.SHA1 = Hasher.extend({
  23500. _doReset: function () {
  23501. this._hash = new WordArray.init([
  23502. 0x67452301, 0xefcdab89,
  23503. 0x98badcfe, 0x10325476,
  23504. 0xc3d2e1f0
  23505. ]);
  23506. },
  23507. _doProcessBlock: function (M, offset) {
  23508. // Shortcut
  23509. var H = this._hash.words;
  23510. // Working variables
  23511. var a = H[0];
  23512. var b = H[1];
  23513. var c = H[2];
  23514. var d = H[3];
  23515. var e = H[4];
  23516. // Computation
  23517. for (var i = 0; i < 80; i++) {
  23518. if (i < 16) {
  23519. W[i] = M[offset + i] | 0;
  23520. } else {
  23521. var n = W[i - 3] ^ W[i - 8] ^ W[i - 14] ^ W[i - 16];
  23522. W[i] = (n << 1) | (n >>> 31);
  23523. }
  23524. var t = ((a << 5) | (a >>> 27)) + e + W[i];
  23525. if (i < 20) {
  23526. t += ((b & c) | (~b & d)) + 0x5a827999;
  23527. } else if (i < 40) {
  23528. t += (b ^ c ^ d) + 0x6ed9eba1;
  23529. } else if (i < 60) {
  23530. t += ((b & c) | (b & d) | (c & d)) - 0x70e44324;
  23531. } else /* if (i < 80) */ {
  23532. t += (b ^ c ^ d) - 0x359d3e2a;
  23533. }
  23534. e = d;
  23535. d = c;
  23536. c = (b << 30) | (b >>> 2);
  23537. b = a;
  23538. a = t;
  23539. }
  23540. // Intermediate hash value
  23541. H[0] = (H[0] + a) | 0;
  23542. H[1] = (H[1] + b) | 0;
  23543. H[2] = (H[2] + c) | 0;
  23544. H[3] = (H[3] + d) | 0;
  23545. H[4] = (H[4] + e) | 0;
  23546. },
  23547. _doFinalize: function () {
  23548. // Shortcuts
  23549. var data = this._data;
  23550. var dataWords = data.words;
  23551. var nBitsTotal = this._nDataBytes * 8;
  23552. var nBitsLeft = data.sigBytes * 8;
  23553. // Add padding
  23554. dataWords[nBitsLeft >>> 5] |= 0x80 << (24 - nBitsLeft % 32);
  23555. dataWords[(((nBitsLeft + 64) >>> 9) << 4) + 14] = Math.floor(nBitsTotal / 0x100000000);
  23556. dataWords[(((nBitsLeft + 64) >>> 9) << 4) + 15] = nBitsTotal;
  23557. data.sigBytes = dataWords.length * 4;
  23558. // Hash final blocks
  23559. this._process();
  23560. // Return final computed hash
  23561. return this._hash;
  23562. },
  23563. clone: function () {
  23564. var clone = Hasher.clone.call(this);
  23565. clone._hash = this._hash.clone();
  23566. return clone;
  23567. }
  23568. });
  23569. /**
  23570. * Shortcut function to the hasher's object interface.
  23571. *
  23572. * @param {WordArray|string} message The message to hash.
  23573. *
  23574. * @return {WordArray} The hash.
  23575. *
  23576. * @static
  23577. *
  23578. * @example
  23579. *
  23580. * var hash = CryptoJS.SHA1('message');
  23581. * var hash = CryptoJS.SHA1(wordArray);
  23582. */
  23583. C.SHA1 = Hasher._createHelper(SHA1);
  23584. /**
  23585. * Shortcut function to the HMAC's object interface.
  23586. *
  23587. * @param {WordArray|string} message The message to hash.
  23588. * @param {WordArray|string} key The secret key.
  23589. *
  23590. * @return {WordArray} The HMAC.
  23591. *
  23592. * @static
  23593. *
  23594. * @example
  23595. *
  23596. * var hmac = CryptoJS.HmacSHA1(message, key);
  23597. */
  23598. C.HmacSHA1 = Hasher._createHmacHelper(SHA1);
  23599. }());
  23600. return CryptoJS.SHA1;
  23601. }));
  23602. },{"./core":478}],485:[function(_dereq_,module,exports){
  23603. // Copyright Joyent, Inc. and other Node contributors.
  23604. //
  23605. // Permission is hereby granted, free of charge, to any person obtaining a
  23606. // copy of this software and associated documentation files (the
  23607. // "Software"), to deal in the Software without restriction, including
  23608. // without limitation the rights to use, copy, modify, merge, publish,
  23609. // distribute, sublicense, and/or sell copies of the Software, and to permit
  23610. // persons to whom the Software is furnished to do so, subject to the
  23611. // following conditions:
  23612. //
  23613. // The above copyright notice and this permission notice shall be included
  23614. // in all copies or substantial portions of the Software.
  23615. //
  23616. // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
  23617. // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
  23618. // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
  23619. // NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
  23620. // DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
  23621. // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
  23622. // USE OR OTHER DEALINGS IN THE SOFTWARE.
  23623. 'use strict';
  23624. var R = typeof Reflect === 'object' ? Reflect : null
  23625. var ReflectApply = R && typeof R.apply === 'function'
  23626. ? R.apply
  23627. : function ReflectApply(target, receiver, args) {
  23628. return Function.prototype.apply.call(target, receiver, args);
  23629. }
  23630. var ReflectOwnKeys
  23631. if (R && typeof R.ownKeys === 'function') {
  23632. ReflectOwnKeys = R.ownKeys
  23633. } else if (Object.getOwnPropertySymbols) {
  23634. ReflectOwnKeys = function ReflectOwnKeys(target) {
  23635. return Object.getOwnPropertyNames(target)
  23636. .concat(Object.getOwnPropertySymbols(target));
  23637. };
  23638. } else {
  23639. ReflectOwnKeys = function ReflectOwnKeys(target) {
  23640. return Object.getOwnPropertyNames(target);
  23641. };
  23642. }
  23643. function ProcessEmitWarning(warning) {
  23644. if (console && console.warn) console.warn(warning);
  23645. }
  23646. var NumberIsNaN = Number.isNaN || function NumberIsNaN(value) {
  23647. return value !== value;
  23648. }
  23649. function EventEmitter() {
  23650. EventEmitter.init.call(this);
  23651. }
  23652. module.exports = EventEmitter;
  23653. module.exports.once = once;
  23654. // Backwards-compat with node 0.10.x
  23655. EventEmitter.EventEmitter = EventEmitter;
  23656. EventEmitter.prototype._events = undefined;
  23657. EventEmitter.prototype._eventsCount = 0;
  23658. EventEmitter.prototype._maxListeners = undefined;
  23659. // By default EventEmitters will print a warning if more than 10 listeners are
  23660. // added to it. This is a useful default which helps finding memory leaks.
  23661. var defaultMaxListeners = 10;
  23662. function checkListener(listener) {
  23663. if (typeof listener !== 'function') {
  23664. throw new TypeError('The "listener" argument must be of type Function. Received type ' + typeof listener);
  23665. }
  23666. }
  23667. Object.defineProperty(EventEmitter, 'defaultMaxListeners', {
  23668. enumerable: true,
  23669. get: function() {
  23670. return defaultMaxListeners;
  23671. },
  23672. set: function(arg) {
  23673. if (typeof arg !== 'number' || arg < 0 || NumberIsNaN(arg)) {
  23674. throw new RangeError('The value of "defaultMaxListeners" is out of range. It must be a non-negative number. Received ' + arg + '.');
  23675. }
  23676. defaultMaxListeners = arg;
  23677. }
  23678. });
  23679. EventEmitter.init = function() {
  23680. if (this._events === undefined ||
  23681. this._events === Object.getPrototypeOf(this)._events) {
  23682. this._events = Object.create(null);
  23683. this._eventsCount = 0;
  23684. }
  23685. this._maxListeners = this._maxListeners || undefined;
  23686. };
  23687. // Obviously not all Emitters should be limited to 10. This function allows
  23688. // that to be increased. Set to zero for unlimited.
  23689. EventEmitter.prototype.setMaxListeners = function setMaxListeners(n) {
  23690. if (typeof n !== 'number' || n < 0 || NumberIsNaN(n)) {
  23691. throw new RangeError('The value of "n" is out of range. It must be a non-negative number. Received ' + n + '.');
  23692. }
  23693. this._maxListeners = n;
  23694. return this;
  23695. };
  23696. function _getMaxListeners(that) {
  23697. if (that._maxListeners === undefined)
  23698. return EventEmitter.defaultMaxListeners;
  23699. return that._maxListeners;
  23700. }
  23701. EventEmitter.prototype.getMaxListeners = function getMaxListeners() {
  23702. return _getMaxListeners(this);
  23703. };
  23704. EventEmitter.prototype.emit = function emit(type) {
  23705. var args = [];
  23706. for (var i = 1; i < arguments.length; i++) args.push(arguments[i]);
  23707. var doError = (type === 'error');
  23708. var events = this._events;
  23709. if (events !== undefined)
  23710. doError = (doError && events.error === undefined);
  23711. else if (!doError)
  23712. return false;
  23713. // If there is no 'error' event listener then throw.
  23714. if (doError) {
  23715. var er;
  23716. if (args.length > 0)
  23717. er = args[0];
  23718. if (er instanceof Error) {
  23719. // Note: The comments on the `throw` lines are intentional, they show
  23720. // up in Node's output if this results in an unhandled exception.
  23721. throw er; // Unhandled 'error' event
  23722. }
  23723. // At least give some kind of context to the user
  23724. var err = new Error('Unhandled error.' + (er ? ' (' + er.message + ')' : ''));
  23725. err.context = er;
  23726. throw err; // Unhandled 'error' event
  23727. }
  23728. var handler = events[type];
  23729. if (handler === undefined)
  23730. return false;
  23731. if (typeof handler === 'function') {
  23732. ReflectApply(handler, this, args);
  23733. } else {
  23734. var len = handler.length;
  23735. var listeners = arrayClone(handler, len);
  23736. for (var i = 0; i < len; ++i)
  23737. ReflectApply(listeners[i], this, args);
  23738. }
  23739. return true;
  23740. };
  23741. function _addListener(target, type, listener, prepend) {
  23742. var m;
  23743. var events;
  23744. var existing;
  23745. checkListener(listener);
  23746. events = target._events;
  23747. if (events === undefined) {
  23748. events = target._events = Object.create(null);
  23749. target._eventsCount = 0;
  23750. } else {
  23751. // To avoid recursion in the case that type === "newListener"! Before
  23752. // adding it to the listeners, first emit "newListener".
  23753. if (events.newListener !== undefined) {
  23754. target.emit('newListener', type,
  23755. listener.listener ? listener.listener : listener);
  23756. // Re-assign `events` because a newListener handler could have caused the
  23757. // this._events to be assigned to a new object
  23758. events = target._events;
  23759. }
  23760. existing = events[type];
  23761. }
  23762. if (existing === undefined) {
  23763. // Optimize the case of one listener. Don't need the extra array object.
  23764. existing = events[type] = listener;
  23765. ++target._eventsCount;
  23766. } else {
  23767. if (typeof existing === 'function') {
  23768. // Adding the second element, need to change to array.
  23769. existing = events[type] =
  23770. prepend ? [listener, existing] : [existing, listener];
  23771. // If we've already got an array, just append.
  23772. } else if (prepend) {
  23773. existing.unshift(listener);
  23774. } else {
  23775. existing.push(listener);
  23776. }
  23777. // Check for listener leak
  23778. m = _getMaxListeners(target);
  23779. if (m > 0 && existing.length > m && !existing.warned) {
  23780. existing.warned = true;
  23781. // No error code for this since it is a Warning
  23782. // eslint-disable-next-line no-restricted-syntax
  23783. var w = new Error('Possible EventEmitter memory leak detected. ' +
  23784. existing.length + ' ' + String(type) + ' listeners ' +
  23785. 'added. Use emitter.setMaxListeners() to ' +
  23786. 'increase limit');
  23787. w.name = 'MaxListenersExceededWarning';
  23788. w.emitter = target;
  23789. w.type = type;
  23790. w.count = existing.length;
  23791. ProcessEmitWarning(w);
  23792. }
  23793. }
  23794. return target;
  23795. }
  23796. EventEmitter.prototype.addListener = function addListener(type, listener) {
  23797. return _addListener(this, type, listener, false);
  23798. };
  23799. EventEmitter.prototype.on = EventEmitter.prototype.addListener;
  23800. EventEmitter.prototype.prependListener =
  23801. function prependListener(type, listener) {
  23802. return _addListener(this, type, listener, true);
  23803. };
  23804. function onceWrapper() {
  23805. if (!this.fired) {
  23806. this.target.removeListener(this.type, this.wrapFn);
  23807. this.fired = true;
  23808. if (arguments.length === 0)
  23809. return this.listener.call(this.target);
  23810. return this.listener.apply(this.target, arguments);
  23811. }
  23812. }
  23813. function _onceWrap(target, type, listener) {
  23814. var state = { fired: false, wrapFn: undefined, target: target, type: type, listener: listener };
  23815. var wrapped = onceWrapper.bind(state);
  23816. wrapped.listener = listener;
  23817. state.wrapFn = wrapped;
  23818. return wrapped;
  23819. }
  23820. EventEmitter.prototype.once = function once(type, listener) {
  23821. checkListener(listener);
  23822. this.on(type, _onceWrap(this, type, listener));
  23823. return this;
  23824. };
  23825. EventEmitter.prototype.prependOnceListener =
  23826. function prependOnceListener(type, listener) {
  23827. checkListener(listener);
  23828. this.prependListener(type, _onceWrap(this, type, listener));
  23829. return this;
  23830. };
  23831. // Emits a 'removeListener' event if and only if the listener was removed.
  23832. EventEmitter.prototype.removeListener =
  23833. function removeListener(type, listener) {
  23834. var list, events, position, i, originalListener;
  23835. checkListener(listener);
  23836. events = this._events;
  23837. if (events === undefined)
  23838. return this;
  23839. list = events[type];
  23840. if (list === undefined)
  23841. return this;
  23842. if (list === listener || list.listener === listener) {
  23843. if (--this._eventsCount === 0)
  23844. this._events = Object.create(null);
  23845. else {
  23846. delete events[type];
  23847. if (events.removeListener)
  23848. this.emit('removeListener', type, list.listener || listener);
  23849. }
  23850. } else if (typeof list !== 'function') {
  23851. position = -1;
  23852. for (i = list.length - 1; i >= 0; i--) {
  23853. if (list[i] === listener || list[i].listener === listener) {
  23854. originalListener = list[i].listener;
  23855. position = i;
  23856. break;
  23857. }
  23858. }
  23859. if (position < 0)
  23860. return this;
  23861. if (position === 0)
  23862. list.shift();
  23863. else {
  23864. spliceOne(list, position);
  23865. }
  23866. if (list.length === 1)
  23867. events[type] = list[0];
  23868. if (events.removeListener !== undefined)
  23869. this.emit('removeListener', type, originalListener || listener);
  23870. }
  23871. return this;
  23872. };
  23873. EventEmitter.prototype.off = EventEmitter.prototype.removeListener;
  23874. EventEmitter.prototype.removeAllListeners =
  23875. function removeAllListeners(type) {
  23876. var listeners, events, i;
  23877. events = this._events;
  23878. if (events === undefined)
  23879. return this;
  23880. // not listening for removeListener, no need to emit
  23881. if (events.removeListener === undefined) {
  23882. if (arguments.length === 0) {
  23883. this._events = Object.create(null);
  23884. this._eventsCount = 0;
  23885. } else if (events[type] !== undefined) {
  23886. if (--this._eventsCount === 0)
  23887. this._events = Object.create(null);
  23888. else
  23889. delete events[type];
  23890. }
  23891. return this;
  23892. }
  23893. // emit removeListener for all listeners on all events
  23894. if (arguments.length === 0) {
  23895. var keys = Object.keys(events);
  23896. var key;
  23897. for (i = 0; i < keys.length; ++i) {
  23898. key = keys[i];
  23899. if (key === 'removeListener') continue;
  23900. this.removeAllListeners(key);
  23901. }
  23902. this.removeAllListeners('removeListener');
  23903. this._events = Object.create(null);
  23904. this._eventsCount = 0;
  23905. return this;
  23906. }
  23907. listeners = events[type];
  23908. if (typeof listeners === 'function') {
  23909. this.removeListener(type, listeners);
  23910. } else if (listeners !== undefined) {
  23911. // LIFO order
  23912. for (i = listeners.length - 1; i >= 0; i--) {
  23913. this.removeListener(type, listeners[i]);
  23914. }
  23915. }
  23916. return this;
  23917. };
  23918. function _listeners(target, type, unwrap) {
  23919. var events = target._events;
  23920. if (events === undefined)
  23921. return [];
  23922. var evlistener = events[type];
  23923. if (evlistener === undefined)
  23924. return [];
  23925. if (typeof evlistener === 'function')
  23926. return unwrap ? [evlistener.listener || evlistener] : [evlistener];
  23927. return unwrap ?
  23928. unwrapListeners(evlistener) : arrayClone(evlistener, evlistener.length);
  23929. }
  23930. EventEmitter.prototype.listeners = function listeners(type) {
  23931. return _listeners(this, type, true);
  23932. };
  23933. EventEmitter.prototype.rawListeners = function rawListeners(type) {
  23934. return _listeners(this, type, false);
  23935. };
  23936. EventEmitter.listenerCount = function(emitter, type) {
  23937. if (typeof emitter.listenerCount === 'function') {
  23938. return emitter.listenerCount(type);
  23939. } else {
  23940. return listenerCount.call(emitter, type);
  23941. }
  23942. };
  23943. EventEmitter.prototype.listenerCount = listenerCount;
  23944. function listenerCount(type) {
  23945. var events = this._events;
  23946. if (events !== undefined) {
  23947. var evlistener = events[type];
  23948. if (typeof evlistener === 'function') {
  23949. return 1;
  23950. } else if (evlistener !== undefined) {
  23951. return evlistener.length;
  23952. }
  23953. }
  23954. return 0;
  23955. }
  23956. EventEmitter.prototype.eventNames = function eventNames() {
  23957. return this._eventsCount > 0 ? ReflectOwnKeys(this._events) : [];
  23958. };
  23959. function arrayClone(arr, n) {
  23960. var copy = new Array(n);
  23961. for (var i = 0; i < n; ++i)
  23962. copy[i] = arr[i];
  23963. return copy;
  23964. }
  23965. function spliceOne(list, index) {
  23966. for (; index + 1 < list.length; index++)
  23967. list[index] = list[index + 1];
  23968. list.pop();
  23969. }
  23970. function unwrapListeners(arr) {
  23971. var ret = new Array(arr.length);
  23972. for (var i = 0; i < ret.length; ++i) {
  23973. ret[i] = arr[i].listener || arr[i];
  23974. }
  23975. return ret;
  23976. }
  23977. function once(emitter, name) {
  23978. return new Promise(function (resolve, reject) {
  23979. function errorListener(err) {
  23980. emitter.removeListener(name, resolver);
  23981. reject(err);
  23982. }
  23983. function resolver() {
  23984. if (typeof emitter.removeListener === 'function') {
  23985. emitter.removeListener('error', errorListener);
  23986. }
  23987. resolve([].slice.call(arguments));
  23988. };
  23989. eventTargetAgnosticAddListener(emitter, name, resolver, { once: true });
  23990. if (name !== 'error') {
  23991. addErrorHandlerIfEventEmitter(emitter, errorListener, { once: true });
  23992. }
  23993. });
  23994. }
  23995. function addErrorHandlerIfEventEmitter(emitter, handler, flags) {
  23996. if (typeof emitter.on === 'function') {
  23997. eventTargetAgnosticAddListener(emitter, 'error', handler, flags);
  23998. }
  23999. }
  24000. function eventTargetAgnosticAddListener(emitter, name, listener, flags) {
  24001. if (typeof emitter.on === 'function') {
  24002. if (flags.once) {
  24003. emitter.once(name, listener);
  24004. } else {
  24005. emitter.on(name, listener);
  24006. }
  24007. } else if (typeof emitter.addEventListener === 'function') {
  24008. // EventTarget does not have `error` event semantics like Node
  24009. // EventEmitters, we do not listen for `error` events here.
  24010. emitter.addEventListener(name, function wrapListener(arg) {
  24011. // IE does not have builtin `{ once: true }` support so we
  24012. // have to do it manually.
  24013. if (flags.once) {
  24014. emitter.removeEventListener(name, wrapListener);
  24015. }
  24016. listener(arg);
  24017. });
  24018. } else {
  24019. throw new TypeError('The "emitter" argument must be of type EventEmitter. Received type ' + typeof emitter);
  24020. }
  24021. }
  24022. },{}],486:[function(_dereq_,module,exports){
  24023. 'use strict';
  24024. function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
  24025. 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."); }
  24026. 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); }
  24027. 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; }
  24028. 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; }
  24029. function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
  24030. Object.defineProperty(exports, '__esModule', {
  24031. value: true
  24032. });
  24033. function promisifyRequest(request) {
  24034. return new Promise(function (resolve, reject) {
  24035. // @ts-ignore - file size hacks
  24036. request.oncomplete = request.onsuccess = function () {
  24037. return resolve(request.result);
  24038. }; // @ts-ignore - file size hacks
  24039. request.onabort = request.onerror = function () {
  24040. return reject(request.error);
  24041. };
  24042. });
  24043. }
  24044. function createStore(dbName, storeName) {
  24045. var request = indexedDB.open(dbName);
  24046. request.onupgradeneeded = function () {
  24047. return request.result.createObjectStore(storeName);
  24048. };
  24049. var dbp = promisifyRequest(request);
  24050. return function (txMode, callback) {
  24051. return dbp.then(function (db) {
  24052. return callback(db.transaction(storeName, txMode).objectStore(storeName));
  24053. });
  24054. };
  24055. }
  24056. var defaultGetStoreFunc;
  24057. function defaultGetStore() {
  24058. if (!defaultGetStoreFunc) {
  24059. defaultGetStoreFunc = createStore('keyval-store', 'keyval');
  24060. }
  24061. return defaultGetStoreFunc;
  24062. }
  24063. /**
  24064. * Get a value by its key.
  24065. *
  24066. * @param key
  24067. * @param customStore Method to get a custom store. Use with caution (see the docs).
  24068. */
  24069. function get(key) {
  24070. var customStore = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : defaultGetStore();
  24071. return customStore('readonly', function (store) {
  24072. return promisifyRequest(store.get(key));
  24073. });
  24074. }
  24075. /**
  24076. * Set a value with a key.
  24077. *
  24078. * @param key
  24079. * @param value
  24080. * @param customStore Method to get a custom store. Use with caution (see the docs).
  24081. */
  24082. function set(key, value) {
  24083. var customStore = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : defaultGetStore();
  24084. return customStore('readwrite', function (store) {
  24085. store.put(value, key);
  24086. return promisifyRequest(store.transaction);
  24087. });
  24088. }
  24089. /**
  24090. * Set multiple values at once. This is faster than calling set() multiple times.
  24091. * It's also atomic – if one of the pairs can't be added, none will be added.
  24092. *
  24093. * @param entries Array of entries, where each entry is an array of `[key, value]`.
  24094. * @param customStore Method to get a custom store. Use with caution (see the docs).
  24095. */
  24096. function setMany(entries) {
  24097. var customStore = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : defaultGetStore();
  24098. return customStore('readwrite', function (store) {
  24099. entries.forEach(function (entry) {
  24100. return store.put(entry[1], entry[0]);
  24101. });
  24102. return promisifyRequest(store.transaction);
  24103. });
  24104. }
  24105. /**
  24106. * Get multiple values by their keys
  24107. *
  24108. * @param keys
  24109. * @param customStore Method to get a custom store. Use with caution (see the docs).
  24110. */
  24111. function getMany(keys) {
  24112. var customStore = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : defaultGetStore();
  24113. return customStore('readonly', function (store) {
  24114. return Promise.all(keys.map(function (key) {
  24115. return promisifyRequest(store.get(key));
  24116. }));
  24117. });
  24118. }
  24119. /**
  24120. * Update a value. This lets you see the old value and update it as an atomic operation.
  24121. *
  24122. * @param key
  24123. * @param updater A callback that takes the old value and returns a new value.
  24124. * @param customStore Method to get a custom store. Use with caution (see the docs).
  24125. */
  24126. function update(key, updater) {
  24127. var customStore = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : defaultGetStore();
  24128. return customStore('readwrite', function (store) {
  24129. return (// Need to create the promise manually.
  24130. // If I try to chain promises, the transaction closes in browsers
  24131. // that use a promise polyfill (IE10/11).
  24132. new Promise(function (resolve, reject) {
  24133. store.get(key).onsuccess = function () {
  24134. try {
  24135. store.put(updater(this.result), key);
  24136. resolve(promisifyRequest(store.transaction));
  24137. } catch (err) {
  24138. reject(err);
  24139. }
  24140. };
  24141. })
  24142. );
  24143. });
  24144. }
  24145. /**
  24146. * Delete a particular key from the store.
  24147. *
  24148. * @param key
  24149. * @param customStore Method to get a custom store. Use with caution (see the docs).
  24150. */
  24151. function del(key) {
  24152. var customStore = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : defaultGetStore();
  24153. return customStore('readwrite', function (store) {
  24154. store.delete(key);
  24155. return promisifyRequest(store.transaction);
  24156. });
  24157. }
  24158. /**
  24159. * Delete multiple keys at once.
  24160. *
  24161. * @param keys List of keys to delete.
  24162. * @param customStore Method to get a custom store. Use with caution (see the docs).
  24163. */
  24164. function delMany(keys) {
  24165. var customStore = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : defaultGetStore();
  24166. return customStore('readwrite', function (store) {
  24167. keys.forEach(function (key) {
  24168. return store.delete(key);
  24169. });
  24170. return promisifyRequest(store.transaction);
  24171. });
  24172. }
  24173. /**
  24174. * Clear all values in the store.
  24175. *
  24176. * @param customStore Method to get a custom store. Use with caution (see the docs).
  24177. */
  24178. function clear() {
  24179. var customStore = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : defaultGetStore();
  24180. return customStore('readwrite', function (store) {
  24181. store.clear();
  24182. return promisifyRequest(store.transaction);
  24183. });
  24184. }
  24185. function eachCursor(store, callback) {
  24186. store.openCursor().onsuccess = function () {
  24187. if (!this.result) return;
  24188. callback(this.result);
  24189. this.result.continue();
  24190. };
  24191. return promisifyRequest(store.transaction);
  24192. }
  24193. /**
  24194. * Get all keys in the store.
  24195. *
  24196. * @param customStore Method to get a custom store. Use with caution (see the docs).
  24197. */
  24198. function keys() {
  24199. var customStore = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : defaultGetStore();
  24200. return customStore('readonly', function (store) {
  24201. // Fast path for modern browsers
  24202. if (store.getAllKeys) {
  24203. return promisifyRequest(store.getAllKeys());
  24204. }
  24205. var items = [];
  24206. return eachCursor(store, function (cursor) {
  24207. return items.push(cursor.key);
  24208. }).then(function () {
  24209. return items;
  24210. });
  24211. });
  24212. }
  24213. /**
  24214. * Get all values in the store.
  24215. *
  24216. * @param customStore Method to get a custom store. Use with caution (see the docs).
  24217. */
  24218. function values() {
  24219. var customStore = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : defaultGetStore();
  24220. return customStore('readonly', function (store) {
  24221. // Fast path for modern browsers
  24222. if (store.getAll) {
  24223. return promisifyRequest(store.getAll());
  24224. }
  24225. var items = [];
  24226. return eachCursor(store, function (cursor) {
  24227. return items.push(cursor.value);
  24228. }).then(function () {
  24229. return items;
  24230. });
  24231. });
  24232. }
  24233. /**
  24234. * Get all entries in the store. Each entry is an array of `[key, value]`.
  24235. *
  24236. * @param customStore Method to get a custom store. Use with caution (see the docs).
  24237. */
  24238. function entries() {
  24239. var customStore = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : defaultGetStore();
  24240. return customStore('readonly', function (store) {
  24241. // Fast path for modern browsers
  24242. // (although, hopefully we'll get a simpler path some day)
  24243. if (store.getAll && store.getAllKeys) {
  24244. return Promise.all([promisifyRequest(store.getAllKeys()), promisifyRequest(store.getAll())]).then(function (_ref) {
  24245. var _ref2 = _slicedToArray(_ref, 2),
  24246. keys = _ref2[0],
  24247. values = _ref2[1];
  24248. return keys.map(function (key, i) {
  24249. return [key, values[i]];
  24250. });
  24251. });
  24252. }
  24253. var items = [];
  24254. return customStore('readonly', function (store) {
  24255. return eachCursor(store, function (cursor) {
  24256. return items.push([cursor.key, cursor.value]);
  24257. }).then(function () {
  24258. return items;
  24259. });
  24260. });
  24261. });
  24262. }
  24263. exports.clear = clear;
  24264. exports.createStore = createStore;
  24265. exports.del = del;
  24266. exports.delMany = delMany;
  24267. exports.entries = entries;
  24268. exports.get = get;
  24269. exports.getMany = getMany;
  24270. exports.keys = keys;
  24271. exports.promisifyRequest = promisifyRequest;
  24272. exports.set = set;
  24273. exports.setMany = setMany;
  24274. exports.update = update;
  24275. exports.values = values;
  24276. },{}],487:[function(_dereq_,module,exports){
  24277. "use strict";
  24278. Object.defineProperty(exports, "__esModule", {
  24279. value: true
  24280. });
  24281. Object.defineProperty(exports, "MAX", {
  24282. enumerable: true,
  24283. get: function () {
  24284. return _max.default;
  24285. }
  24286. });
  24287. Object.defineProperty(exports, "NIL", {
  24288. enumerable: true,
  24289. get: function () {
  24290. return _nil.default;
  24291. }
  24292. });
  24293. Object.defineProperty(exports, "parse", {
  24294. enumerable: true,
  24295. get: function () {
  24296. return _parse.default;
  24297. }
  24298. });
  24299. Object.defineProperty(exports, "stringify", {
  24300. enumerable: true,
  24301. get: function () {
  24302. return _stringify.default;
  24303. }
  24304. });
  24305. Object.defineProperty(exports, "v1", {
  24306. enumerable: true,
  24307. get: function () {
  24308. return _v.default;
  24309. }
  24310. });
  24311. Object.defineProperty(exports, "v1ToV6", {
  24312. enumerable: true,
  24313. get: function () {
  24314. return _v1ToV.default;
  24315. }
  24316. });
  24317. Object.defineProperty(exports, "v3", {
  24318. enumerable: true,
  24319. get: function () {
  24320. return _v2.default;
  24321. }
  24322. });
  24323. Object.defineProperty(exports, "v4", {
  24324. enumerable: true,
  24325. get: function () {
  24326. return _v3.default;
  24327. }
  24328. });
  24329. Object.defineProperty(exports, "v5", {
  24330. enumerable: true,
  24331. get: function () {
  24332. return _v4.default;
  24333. }
  24334. });
  24335. Object.defineProperty(exports, "v6", {
  24336. enumerable: true,
  24337. get: function () {
  24338. return _v5.default;
  24339. }
  24340. });
  24341. Object.defineProperty(exports, "v6ToV1", {
  24342. enumerable: true,
  24343. get: function () {
  24344. return _v6ToV.default;
  24345. }
  24346. });
  24347. Object.defineProperty(exports, "v7", {
  24348. enumerable: true,
  24349. get: function () {
  24350. return _v6.default;
  24351. }
  24352. });
  24353. Object.defineProperty(exports, "validate", {
  24354. enumerable: true,
  24355. get: function () {
  24356. return _validate.default;
  24357. }
  24358. });
  24359. Object.defineProperty(exports, "version", {
  24360. enumerable: true,
  24361. get: function () {
  24362. return _version.default;
  24363. }
  24364. });
  24365. var _max = _interopRequireDefault(_dereq_("./max.js"));
  24366. var _nil = _interopRequireDefault(_dereq_("./nil.js"));
  24367. var _parse = _interopRequireDefault(_dereq_("./parse.js"));
  24368. var _stringify = _interopRequireDefault(_dereq_("./stringify.js"));
  24369. var _v = _interopRequireDefault(_dereq_("./v1.js"));
  24370. var _v1ToV = _interopRequireDefault(_dereq_("./v1ToV6.js"));
  24371. var _v2 = _interopRequireDefault(_dereq_("./v3.js"));
  24372. var _v3 = _interopRequireDefault(_dereq_("./v4.js"));
  24373. var _v4 = _interopRequireDefault(_dereq_("./v5.js"));
  24374. var _v5 = _interopRequireDefault(_dereq_("./v6.js"));
  24375. var _v6ToV = _interopRequireDefault(_dereq_("./v6ToV1.js"));
  24376. var _v6 = _interopRequireDefault(_dereq_("./v7.js"));
  24377. var _validate = _interopRequireDefault(_dereq_("./validate.js"));
  24378. var _version = _interopRequireDefault(_dereq_("./version.js"));
  24379. function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
  24380. },{"./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){
  24381. "use strict";
  24382. Object.defineProperty(exports, "__esModule", {
  24383. value: true
  24384. });
  24385. exports.default = void 0;
  24386. var _default = exports.default = 'ffffffff-ffff-ffff-ffff-ffffffffffff';
  24387. },{}],489:[function(_dereq_,module,exports){
  24388. "use strict";
  24389. Object.defineProperty(exports, "__esModule", {
  24390. value: true
  24391. });
  24392. exports.default = void 0;
  24393. /*
  24394. * Browser-compatible JavaScript MD5
  24395. *
  24396. * Modification of JavaScript MD5
  24397. * https://github.com/blueimp/JavaScript-MD5
  24398. *
  24399. * Copyright 2011, Sebastian Tschan
  24400. * https://blueimp.net
  24401. *
  24402. * Licensed under the MIT license:
  24403. * https://opensource.org/licenses/MIT
  24404. *
  24405. * Based on
  24406. * A JavaScript implementation of the RSA Data Security, Inc. MD5 Message
  24407. * Digest Algorithm, as defined in RFC 1321.
  24408. * Version 2.2 Copyright (C) Paul Johnston 1999 - 2009
  24409. * Other contributors: Greg Holt, Andrew Kepert, Ydnar, Lostinet
  24410. * Distributed under the BSD License
  24411. * See http://pajhome.org.uk/crypt/md5 for more info.
  24412. */
  24413. function md5(bytes) {
  24414. if (typeof bytes === 'string') {
  24415. const msg = unescape(encodeURIComponent(bytes)); // UTF8 escape
  24416. bytes = new Uint8Array(msg.length);
  24417. for (let i = 0; i < msg.length; ++i) {
  24418. bytes[i] = msg.charCodeAt(i);
  24419. }
  24420. }
  24421. return md5ToHexEncodedArray(wordsToMd5(bytesToWords(bytes), bytes.length * 8));
  24422. }
  24423. /*
  24424. * Convert an array of little-endian words to an array of bytes
  24425. */
  24426. function md5ToHexEncodedArray(input) {
  24427. const output = [];
  24428. const length32 = input.length * 32;
  24429. const hexTab = '0123456789abcdef';
  24430. for (let i = 0; i < length32; i += 8) {
  24431. const x = input[i >> 5] >>> i % 32 & 0xff;
  24432. const hex = parseInt(hexTab.charAt(x >>> 4 & 0x0f) + hexTab.charAt(x & 0x0f), 16);
  24433. output.push(hex);
  24434. }
  24435. return output;
  24436. }
  24437. /**
  24438. * Calculate output length with padding and bit length
  24439. */
  24440. function getOutputLength(inputLength8) {
  24441. return (inputLength8 + 64 >>> 9 << 4) + 14 + 1;
  24442. }
  24443. /*
  24444. * Calculate the MD5 of an array of little-endian words, and a bit length.
  24445. */
  24446. function wordsToMd5(x, len) {
  24447. /* append padding */
  24448. x[len >> 5] |= 0x80 << len % 32;
  24449. x[getOutputLength(len) - 1] = len;
  24450. let a = 1732584193;
  24451. let b = -271733879;
  24452. let c = -1732584194;
  24453. let d = 271733878;
  24454. for (let i = 0; i < x.length; i += 16) {
  24455. const olda = a;
  24456. const oldb = b;
  24457. const oldc = c;
  24458. const oldd = d;
  24459. a = md5ff(a, b, c, d, x[i], 7, -680876936);
  24460. d = md5ff(d, a, b, c, x[i + 1], 12, -389564586);
  24461. c = md5ff(c, d, a, b, x[i + 2], 17, 606105819);
  24462. b = md5ff(b, c, d, a, x[i + 3], 22, -1044525330);
  24463. a = md5ff(a, b, c, d, x[i + 4], 7, -176418897);
  24464. d = md5ff(d, a, b, c, x[i + 5], 12, 1200080426);
  24465. c = md5ff(c, d, a, b, x[i + 6], 17, -1473231341);
  24466. b = md5ff(b, c, d, a, x[i + 7], 22, -45705983);
  24467. a = md5ff(a, b, c, d, x[i + 8], 7, 1770035416);
  24468. d = md5ff(d, a, b, c, x[i + 9], 12, -1958414417);
  24469. c = md5ff(c, d, a, b, x[i + 10], 17, -42063);
  24470. b = md5ff(b, c, d, a, x[i + 11], 22, -1990404162);
  24471. a = md5ff(a, b, c, d, x[i + 12], 7, 1804603682);
  24472. d = md5ff(d, a, b, c, x[i + 13], 12, -40341101);
  24473. c = md5ff(c, d, a, b, x[i + 14], 17, -1502002290);
  24474. b = md5ff(b, c, d, a, x[i + 15], 22, 1236535329);
  24475. a = md5gg(a, b, c, d, x[i + 1], 5, -165796510);
  24476. d = md5gg(d, a, b, c, x[i + 6], 9, -1069501632);
  24477. c = md5gg(c, d, a, b, x[i + 11], 14, 643717713);
  24478. b = md5gg(b, c, d, a, x[i], 20, -373897302);
  24479. a = md5gg(a, b, c, d, x[i + 5], 5, -701558691);
  24480. d = md5gg(d, a, b, c, x[i + 10], 9, 38016083);
  24481. c = md5gg(c, d, a, b, x[i + 15], 14, -660478335);
  24482. b = md5gg(b, c, d, a, x[i + 4], 20, -405537848);
  24483. a = md5gg(a, b, c, d, x[i + 9], 5, 568446438);
  24484. d = md5gg(d, a, b, c, x[i + 14], 9, -1019803690);
  24485. c = md5gg(c, d, a, b, x[i + 3], 14, -187363961);
  24486. b = md5gg(b, c, d, a, x[i + 8], 20, 1163531501);
  24487. a = md5gg(a, b, c, d, x[i + 13], 5, -1444681467);
  24488. d = md5gg(d, a, b, c, x[i + 2], 9, -51403784);
  24489. c = md5gg(c, d, a, b, x[i + 7], 14, 1735328473);
  24490. b = md5gg(b, c, d, a, x[i + 12], 20, -1926607734);
  24491. a = md5hh(a, b, c, d, x[i + 5], 4, -378558);
  24492. d = md5hh(d, a, b, c, x[i + 8], 11, -2022574463);
  24493. c = md5hh(c, d, a, b, x[i + 11], 16, 1839030562);
  24494. b = md5hh(b, c, d, a, x[i + 14], 23, -35309556);
  24495. a = md5hh(a, b, c, d, x[i + 1], 4, -1530992060);
  24496. d = md5hh(d, a, b, c, x[i + 4], 11, 1272893353);
  24497. c = md5hh(c, d, a, b, x[i + 7], 16, -155497632);
  24498. b = md5hh(b, c, d, a, x[i + 10], 23, -1094730640);
  24499. a = md5hh(a, b, c, d, x[i + 13], 4, 681279174);
  24500. d = md5hh(d, a, b, c, x[i], 11, -358537222);
  24501. c = md5hh(c, d, a, b, x[i + 3], 16, -722521979);
  24502. b = md5hh(b, c, d, a, x[i + 6], 23, 76029189);
  24503. a = md5hh(a, b, c, d, x[i + 9], 4, -640364487);
  24504. d = md5hh(d, a, b, c, x[i + 12], 11, -421815835);
  24505. c = md5hh(c, d, a, b, x[i + 15], 16, 530742520);
  24506. b = md5hh(b, c, d, a, x[i + 2], 23, -995338651);
  24507. a = md5ii(a, b, c, d, x[i], 6, -198630844);
  24508. d = md5ii(d, a, b, c, x[i + 7], 10, 1126891415);
  24509. c = md5ii(c, d, a, b, x[i + 14], 15, -1416354905);
  24510. b = md5ii(b, c, d, a, x[i + 5], 21, -57434055);
  24511. a = md5ii(a, b, c, d, x[i + 12], 6, 1700485571);
  24512. d = md5ii(d, a, b, c, x[i + 3], 10, -1894986606);
  24513. c = md5ii(c, d, a, b, x[i + 10], 15, -1051523);
  24514. b = md5ii(b, c, d, a, x[i + 1], 21, -2054922799);
  24515. a = md5ii(a, b, c, d, x[i + 8], 6, 1873313359);
  24516. d = md5ii(d, a, b, c, x[i + 15], 10, -30611744);
  24517. c = md5ii(c, d, a, b, x[i + 6], 15, -1560198380);
  24518. b = md5ii(b, c, d, a, x[i + 13], 21, 1309151649);
  24519. a = md5ii(a, b, c, d, x[i + 4], 6, -145523070);
  24520. d = md5ii(d, a, b, c, x[i + 11], 10, -1120210379);
  24521. c = md5ii(c, d, a, b, x[i + 2], 15, 718787259);
  24522. b = md5ii(b, c, d, a, x[i + 9], 21, -343485551);
  24523. a = safeAdd(a, olda);
  24524. b = safeAdd(b, oldb);
  24525. c = safeAdd(c, oldc);
  24526. d = safeAdd(d, oldd);
  24527. }
  24528. return [a, b, c, d];
  24529. }
  24530. /*
  24531. * Convert an array bytes to an array of little-endian words
  24532. * Characters >255 have their high-byte silently ignored.
  24533. */
  24534. function bytesToWords(input) {
  24535. if (input.length === 0) {
  24536. return [];
  24537. }
  24538. const length8 = input.length * 8;
  24539. const output = new Uint32Array(getOutputLength(length8));
  24540. for (let i = 0; i < length8; i += 8) {
  24541. output[i >> 5] |= (input[i / 8] & 0xff) << i % 32;
  24542. }
  24543. return output;
  24544. }
  24545. /*
  24546. * Add integers, wrapping at 2^32. This uses 16-bit operations internally
  24547. * to work around bugs in some JS interpreters.
  24548. */
  24549. function safeAdd(x, y) {
  24550. const lsw = (x & 0xffff) + (y & 0xffff);
  24551. const msw = (x >> 16) + (y >> 16) + (lsw >> 16);
  24552. return msw << 16 | lsw & 0xffff;
  24553. }
  24554. /*
  24555. * Bitwise rotate a 32-bit number to the left.
  24556. */
  24557. function bitRotateLeft(num, cnt) {
  24558. return num << cnt | num >>> 32 - cnt;
  24559. }
  24560. /*
  24561. * These functions implement the four basic operations the algorithm uses.
  24562. */
  24563. function md5cmn(q, a, b, x, s, t) {
  24564. return safeAdd(bitRotateLeft(safeAdd(safeAdd(a, q), safeAdd(x, t)), s), b);
  24565. }
  24566. function md5ff(a, b, c, d, x, s, t) {
  24567. return md5cmn(b & c | ~b & d, a, b, x, s, t);
  24568. }
  24569. function md5gg(a, b, c, d, x, s, t) {
  24570. return md5cmn(b & d | c & ~d, a, b, x, s, t);
  24571. }
  24572. function md5hh(a, b, c, d, x, s, t) {
  24573. return md5cmn(b ^ c ^ d, a, b, x, s, t);
  24574. }
  24575. function md5ii(a, b, c, d, x, s, t) {
  24576. return md5cmn(c ^ (b | ~d), a, b, x, s, t);
  24577. }
  24578. var _default = exports.default = md5;
  24579. },{}],490:[function(_dereq_,module,exports){
  24580. "use strict";
  24581. Object.defineProperty(exports, "__esModule", {
  24582. value: true
  24583. });
  24584. exports.default = void 0;
  24585. const randomUUID = typeof crypto !== 'undefined' && crypto.randomUUID && crypto.randomUUID.bind(crypto);
  24586. var _default = exports.default = {
  24587. randomUUID
  24588. };
  24589. },{}],491:[function(_dereq_,module,exports){
  24590. "use strict";
  24591. Object.defineProperty(exports, "__esModule", {
  24592. value: true
  24593. });
  24594. exports.default = void 0;
  24595. var _default = exports.default = '00000000-0000-0000-0000-000000000000';
  24596. },{}],492:[function(_dereq_,module,exports){
  24597. "use strict";
  24598. Object.defineProperty(exports, "__esModule", {
  24599. value: true
  24600. });
  24601. exports.default = void 0;
  24602. var _validate = _interopRequireDefault(_dereq_("./validate.js"));
  24603. function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
  24604. function parse(uuid) {
  24605. if (!(0, _validate.default)(uuid)) {
  24606. throw TypeError('Invalid UUID');
  24607. }
  24608. let v;
  24609. const arr = new Uint8Array(16);
  24610. // Parse ########-....-....-....-............
  24611. arr[0] = (v = parseInt(uuid.slice(0, 8), 16)) >>> 24;
  24612. arr[1] = v >>> 16 & 0xff;
  24613. arr[2] = v >>> 8 & 0xff;
  24614. arr[3] = v & 0xff;
  24615. // Parse ........-####-....-....-............
  24616. arr[4] = (v = parseInt(uuid.slice(9, 13), 16)) >>> 8;
  24617. arr[5] = v & 0xff;
  24618. // Parse ........-....-####-....-............
  24619. arr[6] = (v = parseInt(uuid.slice(14, 18), 16)) >>> 8;
  24620. arr[7] = v & 0xff;
  24621. // Parse ........-....-....-####-............
  24622. arr[8] = (v = parseInt(uuid.slice(19, 23), 16)) >>> 8;
  24623. arr[9] = v & 0xff;
  24624. // Parse ........-....-....-....-############
  24625. // (Use "/" to avoid 32-bit truncation when bit-shifting high-order bytes)
  24626. arr[10] = (v = parseInt(uuid.slice(24, 36), 16)) / 0x10000000000 & 0xff;
  24627. arr[11] = v / 0x100000000 & 0xff;
  24628. arr[12] = v >>> 24 & 0xff;
  24629. arr[13] = v >>> 16 & 0xff;
  24630. arr[14] = v >>> 8 & 0xff;
  24631. arr[15] = v & 0xff;
  24632. return arr;
  24633. }
  24634. var _default = exports.default = parse;
  24635. },{"./validate.js":506}],493:[function(_dereq_,module,exports){
  24636. "use strict";
  24637. Object.defineProperty(exports, "__esModule", {
  24638. value: true
  24639. });
  24640. exports.default = void 0;
  24641. 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;
  24642. },{}],494:[function(_dereq_,module,exports){
  24643. "use strict";
  24644. Object.defineProperty(exports, "__esModule", {
  24645. value: true
  24646. });
  24647. exports.default = rng;
  24648. // Unique ID creation requires a high quality random # generator. In the browser we therefore
  24649. // require the crypto API and do not support built-in fallback to lower quality random number
  24650. // generators (like Math.random()).
  24651. let getRandomValues;
  24652. const rnds8 = new Uint8Array(16);
  24653. function rng() {
  24654. // lazy load so that environments that need to polyfill have a chance to do so
  24655. if (!getRandomValues) {
  24656. // getRandomValues needs to be invoked in a context where "this" is a Crypto implementation.
  24657. getRandomValues = typeof crypto !== 'undefined' && crypto.getRandomValues && crypto.getRandomValues.bind(crypto);
  24658. if (!getRandomValues) {
  24659. throw new Error('crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported');
  24660. }
  24661. }
  24662. return getRandomValues(rnds8);
  24663. }
  24664. },{}],495:[function(_dereq_,module,exports){
  24665. "use strict";
  24666. Object.defineProperty(exports, "__esModule", {
  24667. value: true
  24668. });
  24669. exports.default = void 0;
  24670. // Adapted from Chris Veness' SHA1 code at
  24671. // http://www.movable-type.co.uk/scripts/sha1.html
  24672. function f(s, x, y, z) {
  24673. switch (s) {
  24674. case 0:
  24675. return x & y ^ ~x & z;
  24676. case 1:
  24677. return x ^ y ^ z;
  24678. case 2:
  24679. return x & y ^ x & z ^ y & z;
  24680. case 3:
  24681. return x ^ y ^ z;
  24682. }
  24683. }
  24684. function ROTL(x, n) {
  24685. return x << n | x >>> 32 - n;
  24686. }
  24687. function sha1(bytes) {
  24688. const K = [0x5a827999, 0x6ed9eba1, 0x8f1bbcdc, 0xca62c1d6];
  24689. const H = [0x67452301, 0xefcdab89, 0x98badcfe, 0x10325476, 0xc3d2e1f0];
  24690. if (typeof bytes === 'string') {
  24691. const msg = unescape(encodeURIComponent(bytes)); // UTF8 escape
  24692. bytes = [];
  24693. for (let i = 0; i < msg.length; ++i) {
  24694. bytes.push(msg.charCodeAt(i));
  24695. }
  24696. } else if (!Array.isArray(bytes)) {
  24697. // Convert Array-like to Array
  24698. bytes = Array.prototype.slice.call(bytes);
  24699. }
  24700. bytes.push(0x80);
  24701. const l = bytes.length / 4 + 2;
  24702. const N = Math.ceil(l / 16);
  24703. const M = new Array(N);
  24704. for (let i = 0; i < N; ++i) {
  24705. const arr = new Uint32Array(16);
  24706. for (let j = 0; j < 16; ++j) {
  24707. 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];
  24708. }
  24709. M[i] = arr;
  24710. }
  24711. M[N - 1][14] = (bytes.length - 1) * 8 / Math.pow(2, 32);
  24712. M[N - 1][14] = Math.floor(M[N - 1][14]);
  24713. M[N - 1][15] = (bytes.length - 1) * 8 & 0xffffffff;
  24714. for (let i = 0; i < N; ++i) {
  24715. const W = new Uint32Array(80);
  24716. for (let t = 0; t < 16; ++t) {
  24717. W[t] = M[i][t];
  24718. }
  24719. for (let t = 16; t < 80; ++t) {
  24720. W[t] = ROTL(W[t - 3] ^ W[t - 8] ^ W[t - 14] ^ W[t - 16], 1);
  24721. }
  24722. let a = H[0];
  24723. let b = H[1];
  24724. let c = H[2];
  24725. let d = H[3];
  24726. let e = H[4];
  24727. for (let t = 0; t < 80; ++t) {
  24728. const s = Math.floor(t / 20);
  24729. const T = ROTL(a, 5) + f(s, b, c, d) + e + K[s] + W[t] >>> 0;
  24730. e = d;
  24731. d = c;
  24732. c = ROTL(b, 30) >>> 0;
  24733. b = a;
  24734. a = T;
  24735. }
  24736. H[0] = H[0] + a >>> 0;
  24737. H[1] = H[1] + b >>> 0;
  24738. H[2] = H[2] + c >>> 0;
  24739. H[3] = H[3] + d >>> 0;
  24740. H[4] = H[4] + e >>> 0;
  24741. }
  24742. 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];
  24743. }
  24744. var _default = exports.default = sha1;
  24745. },{}],496:[function(_dereq_,module,exports){
  24746. "use strict";
  24747. Object.defineProperty(exports, "__esModule", {
  24748. value: true
  24749. });
  24750. exports.default = void 0;
  24751. exports.unsafeStringify = unsafeStringify;
  24752. var _validate = _interopRequireDefault(_dereq_("./validate.js"));
  24753. function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
  24754. /**
  24755. * Convert array of 16 byte values to UUID string format of the form:
  24756. * XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX
  24757. */
  24758. const byteToHex = [];
  24759. for (let i = 0; i < 256; ++i) {
  24760. byteToHex.push((i + 0x100).toString(16).slice(1));
  24761. }
  24762. function unsafeStringify(arr, offset = 0) {
  24763. // Note: Be careful editing this code! It's been tuned for performance
  24764. // and works in ways you may not expect. See https://github.com/uuidjs/uuid/pull/434
  24765. //
  24766. // Note to future-self: No, you can't remove the `toLowerCase()` call.
  24767. // REF: https://github.com/uuidjs/uuid/pull/677#issuecomment-1757351351
  24768. 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();
  24769. }
  24770. function stringify(arr, offset = 0) {
  24771. const uuid = unsafeStringify(arr, offset);
  24772. // Consistency check for valid UUID. If this throws, it's likely due to one
  24773. // of the following:
  24774. // - One or more input array values don't map to a hex octet (leading to
  24775. // "undefined" in the uuid)
  24776. // - Invalid input values for the RFC `version` or `variant` fields
  24777. if (!(0, _validate.default)(uuid)) {
  24778. throw TypeError('Stringified UUID is invalid');
  24779. }
  24780. return uuid;
  24781. }
  24782. var _default = exports.default = stringify;
  24783. },{"./validate.js":506}],497:[function(_dereq_,module,exports){
  24784. "use strict";
  24785. Object.defineProperty(exports, "__esModule", {
  24786. value: true
  24787. });
  24788. exports.default = void 0;
  24789. var _rng = _interopRequireDefault(_dereq_("./rng.js"));
  24790. var _stringify = _dereq_("./stringify.js");
  24791. function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
  24792. // **`v1()` - Generate time-based UUID**
  24793. //
  24794. // Inspired by https://github.com/LiosK/UUID.js
  24795. // and http://docs.python.org/library/uuid.html
  24796. let _nodeId;
  24797. let _clockseq;
  24798. // Previous uuid creation time
  24799. let _lastMSecs = 0;
  24800. let _lastNSecs = 0;
  24801. // See https://github.com/uuidjs/uuid for API details
  24802. function v1(options, buf, offset) {
  24803. let i = buf && offset || 0;
  24804. const b = buf || new Array(16);
  24805. options = options || {};
  24806. let node = options.node;
  24807. let clockseq = options.clockseq;
  24808. // v1 only: Use cached `node` and `clockseq` values
  24809. if (!options._v6) {
  24810. if (!node) {
  24811. node = _nodeId;
  24812. }
  24813. if (clockseq == null) {
  24814. clockseq = _clockseq;
  24815. }
  24816. }
  24817. // Handle cases where we need entropy. We do this lazily to minimize issues
  24818. // related to insufficient system entropy. See #189
  24819. if (node == null || clockseq == null) {
  24820. const seedBytes = options.random || (options.rng || _rng.default)();
  24821. // Randomize node
  24822. if (node == null) {
  24823. node = [seedBytes[0], seedBytes[1], seedBytes[2], seedBytes[3], seedBytes[4], seedBytes[5]];
  24824. // v1 only: cache node value for reuse
  24825. if (!_nodeId && !options._v6) {
  24826. // per RFC4122 4.5: Set MAC multicast bit (v1 only)
  24827. node[0] |= 0x01; // Set multicast bit
  24828. _nodeId = node;
  24829. }
  24830. }
  24831. // Randomize clockseq
  24832. if (clockseq == null) {
  24833. // Per 4.2.2, randomize (14 bit) clockseq
  24834. clockseq = (seedBytes[6] << 8 | seedBytes[7]) & 0x3fff;
  24835. if (_clockseq === undefined && !options._v6) {
  24836. _clockseq = clockseq;
  24837. }
  24838. }
  24839. }
  24840. // v1 & v6 timestamps are 100 nano-second units since the Gregorian epoch,
  24841. // (1582-10-15 00:00). JSNumbers aren't precise enough for this, so time is
  24842. // handled internally as 'msecs' (integer milliseconds) and 'nsecs'
  24843. // (100-nanoseconds offset from msecs) since unix epoch, 1970-01-01 00:00.
  24844. let msecs = options.msecs !== undefined ? options.msecs : Date.now();
  24845. // Per 4.2.1.2, use count of uuid's generated during the current clock
  24846. // cycle to simulate higher resolution clock
  24847. let nsecs = options.nsecs !== undefined ? options.nsecs : _lastNSecs + 1;
  24848. // Time since last uuid creation (in msecs)
  24849. const dt = msecs - _lastMSecs + (nsecs - _lastNSecs) / 10000;
  24850. // Per 4.2.1.2, Bump clockseq on clock regression
  24851. if (dt < 0 && options.clockseq === undefined) {
  24852. clockseq = clockseq + 1 & 0x3fff;
  24853. }
  24854. // Reset nsecs if clock regresses (new clockseq) or we've moved onto a new
  24855. // time interval
  24856. if ((dt < 0 || msecs > _lastMSecs) && options.nsecs === undefined) {
  24857. nsecs = 0;
  24858. }
  24859. // Per 4.2.1.2 Throw error if too many uuids are requested
  24860. if (nsecs >= 10000) {
  24861. throw new Error("uuid.v1(): Can't create more than 10M uuids/sec");
  24862. }
  24863. _lastMSecs = msecs;
  24864. _lastNSecs = nsecs;
  24865. _clockseq = clockseq;
  24866. // Per 4.1.4 - Convert from unix epoch to Gregorian epoch
  24867. msecs += 12219292800000;
  24868. // `time_low`
  24869. const tl = ((msecs & 0xfffffff) * 10000 + nsecs) % 0x100000000;
  24870. b[i++] = tl >>> 24 & 0xff;
  24871. b[i++] = tl >>> 16 & 0xff;
  24872. b[i++] = tl >>> 8 & 0xff;
  24873. b[i++] = tl & 0xff;
  24874. // `time_mid`
  24875. const tmh = msecs / 0x100000000 * 10000 & 0xfffffff;
  24876. b[i++] = tmh >>> 8 & 0xff;
  24877. b[i++] = tmh & 0xff;
  24878. // `time_high_and_version`
  24879. b[i++] = tmh >>> 24 & 0xf | 0x10; // include version
  24880. b[i++] = tmh >>> 16 & 0xff;
  24881. // `clock_seq_hi_and_reserved` (Per 4.2.2 - include variant)
  24882. b[i++] = clockseq >>> 8 | 0x80;
  24883. // `clock_seq_low`
  24884. b[i++] = clockseq & 0xff;
  24885. // `node`
  24886. for (let n = 0; n < 6; ++n) {
  24887. b[i + n] = node[n];
  24888. }
  24889. return buf || (0, _stringify.unsafeStringify)(b);
  24890. }
  24891. var _default = exports.default = v1;
  24892. },{"./rng.js":494,"./stringify.js":496}],498:[function(_dereq_,module,exports){
  24893. "use strict";
  24894. Object.defineProperty(exports, "__esModule", {
  24895. value: true
  24896. });
  24897. exports.default = v1ToV6;
  24898. var _parse = _interopRequireDefault(_dereq_("./parse.js"));
  24899. var _stringify = _dereq_("./stringify.js");
  24900. function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
  24901. /**
  24902. * Convert a v1 UUID to a v6 UUID
  24903. *
  24904. * @param {string|Uint8Array} uuid - The v1 UUID to convert to v6
  24905. * @returns {string|Uint8Array} The v6 UUID as the same type as the `uuid` arg
  24906. * (string or Uint8Array)
  24907. */
  24908. function v1ToV6(uuid) {
  24909. const v1Bytes = typeof uuid === 'string' ? (0, _parse.default)(uuid) : uuid;
  24910. const v6Bytes = _v1ToV6(v1Bytes);
  24911. return typeof uuid === 'string' ? (0, _stringify.unsafeStringify)(v6Bytes) : v6Bytes;
  24912. }
  24913. // Do the field transformation needed for v1 -> v6
  24914. function _v1ToV6(v1Bytes, randomize = false) {
  24915. 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]);
  24916. }
  24917. },{"./parse.js":492,"./stringify.js":496}],499:[function(_dereq_,module,exports){
  24918. "use strict";
  24919. Object.defineProperty(exports, "__esModule", {
  24920. value: true
  24921. });
  24922. exports.default = void 0;
  24923. var _v = _interopRequireDefault(_dereq_("./v35.js"));
  24924. var _md = _interopRequireDefault(_dereq_("./md5.js"));
  24925. function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
  24926. const v3 = (0, _v.default)('v3', 0x30, _md.default);
  24927. var _default = exports.default = v3;
  24928. },{"./md5.js":489,"./v35.js":500}],500:[function(_dereq_,module,exports){
  24929. "use strict";
  24930. Object.defineProperty(exports, "__esModule", {
  24931. value: true
  24932. });
  24933. exports.URL = exports.DNS = void 0;
  24934. exports.default = v35;
  24935. var _stringify = _dereq_("./stringify.js");
  24936. var _parse = _interopRequireDefault(_dereq_("./parse.js"));
  24937. function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
  24938. function stringToBytes(str) {
  24939. str = unescape(encodeURIComponent(str)); // UTF8 escape
  24940. const bytes = [];
  24941. for (let i = 0; i < str.length; ++i) {
  24942. bytes.push(str.charCodeAt(i));
  24943. }
  24944. return bytes;
  24945. }
  24946. const DNS = exports.DNS = '6ba7b810-9dad-11d1-80b4-00c04fd430c8';
  24947. const URL = exports.URL = '6ba7b811-9dad-11d1-80b4-00c04fd430c8';
  24948. function v35(name, version, hashfunc) {
  24949. function generateUUID(value, namespace, buf, offset) {
  24950. var _namespace;
  24951. if (typeof value === 'string') {
  24952. value = stringToBytes(value);
  24953. }
  24954. if (typeof namespace === 'string') {
  24955. namespace = (0, _parse.default)(namespace);
  24956. }
  24957. if (((_namespace = namespace) === null || _namespace === void 0 ? void 0 : _namespace.length) !== 16) {
  24958. throw TypeError('Namespace must be array-like (16 iterable integer values, 0-255)');
  24959. }
  24960. // Compute hash of namespace and value, Per 4.3
  24961. // Future: Use spread syntax when supported on all platforms, e.g. `bytes =
  24962. // hashfunc([...namespace, ... value])`
  24963. let bytes = new Uint8Array(16 + value.length);
  24964. bytes.set(namespace);
  24965. bytes.set(value, namespace.length);
  24966. bytes = hashfunc(bytes);
  24967. bytes[6] = bytes[6] & 0x0f | version;
  24968. bytes[8] = bytes[8] & 0x3f | 0x80;
  24969. if (buf) {
  24970. offset = offset || 0;
  24971. for (let i = 0; i < 16; ++i) {
  24972. buf[offset + i] = bytes[i];
  24973. }
  24974. return buf;
  24975. }
  24976. return (0, _stringify.unsafeStringify)(bytes);
  24977. }
  24978. // Function#name is not settable on some platforms (#270)
  24979. try {
  24980. generateUUID.name = name;
  24981. } catch (err) {}
  24982. // For CommonJS default export support
  24983. generateUUID.DNS = DNS;
  24984. generateUUID.URL = URL;
  24985. return generateUUID;
  24986. }
  24987. },{"./parse.js":492,"./stringify.js":496}],501:[function(_dereq_,module,exports){
  24988. "use strict";
  24989. Object.defineProperty(exports, "__esModule", {
  24990. value: true
  24991. });
  24992. exports.default = void 0;
  24993. var _native = _interopRequireDefault(_dereq_("./native.js"));
  24994. var _rng = _interopRequireDefault(_dereq_("./rng.js"));
  24995. var _stringify = _dereq_("./stringify.js");
  24996. function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
  24997. function v4(options, buf, offset) {
  24998. if (_native.default.randomUUID && !buf && !options) {
  24999. return _native.default.randomUUID();
  25000. }
  25001. options = options || {};
  25002. const rnds = options.random || (options.rng || _rng.default)();
  25003. // Per 4.4, set bits for version and `clock_seq_hi_and_reserved`
  25004. rnds[6] = rnds[6] & 0x0f | 0x40;
  25005. rnds[8] = rnds[8] & 0x3f | 0x80;
  25006. // Copy bytes to buffer, if provided
  25007. if (buf) {
  25008. offset = offset || 0;
  25009. for (let i = 0; i < 16; ++i) {
  25010. buf[offset + i] = rnds[i];
  25011. }
  25012. return buf;
  25013. }
  25014. return (0, _stringify.unsafeStringify)(rnds);
  25015. }
  25016. var _default = exports.default = v4;
  25017. },{"./native.js":490,"./rng.js":494,"./stringify.js":496}],502:[function(_dereq_,module,exports){
  25018. "use strict";
  25019. Object.defineProperty(exports, "__esModule", {
  25020. value: true
  25021. });
  25022. exports.default = void 0;
  25023. var _v = _interopRequireDefault(_dereq_("./v35.js"));
  25024. var _sha = _interopRequireDefault(_dereq_("./sha1.js"));
  25025. function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
  25026. const v5 = (0, _v.default)('v5', 0x50, _sha.default);
  25027. var _default = exports.default = v5;
  25028. },{"./sha1.js":495,"./v35.js":500}],503:[function(_dereq_,module,exports){
  25029. "use strict";
  25030. Object.defineProperty(exports, "__esModule", {
  25031. value: true
  25032. });
  25033. exports.default = v6;
  25034. var _stringify = _dereq_("./stringify.js");
  25035. var _v = _interopRequireDefault(_dereq_("./v1.js"));
  25036. var _v1ToV = _interopRequireDefault(_dereq_("./v1ToV6.js"));
  25037. function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
  25038. /**
  25039. *
  25040. * @param {object} options
  25041. * @param {Uint8Array=} buf
  25042. * @param {number=} offset
  25043. * @returns
  25044. */
  25045. function v6(options = {}, buf, offset = 0) {
  25046. // v6 is v1 with different field layout, so we start with a v1 UUID, albeit
  25047. // with slightly different behavior around how the clock_seq and node fields
  25048. // are randomized, which is why we call v1 with _v6: true.
  25049. let bytes = (0, _v.default)({
  25050. ...options,
  25051. _v6: true
  25052. }, new Uint8Array(16));
  25053. // Reorder the fields to v6 layout.
  25054. bytes = (0, _v1ToV.default)(bytes);
  25055. // Return as a byte array if requested
  25056. if (buf) {
  25057. for (let i = 0; i < 16; i++) {
  25058. buf[offset + i] = bytes[i];
  25059. }
  25060. return buf;
  25061. }
  25062. return (0, _stringify.unsafeStringify)(bytes);
  25063. }
  25064. },{"./stringify.js":496,"./v1.js":497,"./v1ToV6.js":498}],504:[function(_dereq_,module,exports){
  25065. "use strict";
  25066. Object.defineProperty(exports, "__esModule", {
  25067. value: true
  25068. });
  25069. exports.default = v6ToV1;
  25070. var _parse = _interopRequireDefault(_dereq_("./parse.js"));
  25071. var _stringify = _dereq_("./stringify.js");
  25072. function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
  25073. /**
  25074. * Convert a v6 UUID to a v1 UUID
  25075. *
  25076. * @param {string|Uint8Array} uuid - The v6 UUID to convert to v6
  25077. * @returns {string|Uint8Array} The v1 UUID as the same type as the `uuid` arg
  25078. * (string or Uint8Array)
  25079. */
  25080. function v6ToV1(uuid) {
  25081. const v6Bytes = typeof uuid === 'string' ? (0, _parse.default)(uuid) : uuid;
  25082. const v1Bytes = _v6ToV1(v6Bytes);
  25083. return typeof uuid === 'string' ? (0, _stringify.unsafeStringify)(v1Bytes) : v1Bytes;
  25084. }
  25085. // Do the field transformation needed for v6 -> v1
  25086. function _v6ToV1(v6Bytes) {
  25087. 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]);
  25088. }
  25089. },{"./parse.js":492,"./stringify.js":496}],505:[function(_dereq_,module,exports){
  25090. "use strict";
  25091. Object.defineProperty(exports, "__esModule", {
  25092. value: true
  25093. });
  25094. exports.default = void 0;
  25095. var _rng = _interopRequireDefault(_dereq_("./rng.js"));
  25096. var _stringify = _dereq_("./stringify.js");
  25097. function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
  25098. /**
  25099. * UUID V7 - Unix Epoch time-based UUID
  25100. *
  25101. * The IETF has published RFC9562, introducing 3 new UUID versions (6,7,8). This
  25102. * implementation of V7 is based on the accepted, though not yet approved,
  25103. * revisions.
  25104. *
  25105. * RFC 9562:https://www.rfc-editor.org/rfc/rfc9562.html Universally Unique
  25106. * IDentifiers (UUIDs)
  25107. *
  25108. * Sample V7 value:
  25109. * https://www.rfc-editor.org/rfc/rfc9562.html#name-example-of-a-uuidv7-value
  25110. *
  25111. * Monotonic Bit Layout: RFC rfc9562.6.2 Method 1, Dedicated Counter Bits ref:
  25112. * https://www.rfc-editor.org/rfc/rfc9562.html#section-6.2-5.1
  25113. *
  25114. * 0 1 2 3 0 1 2 3 4 5 6
  25115. * 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
  25116. * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  25117. * | unix_ts_ms |
  25118. * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  25119. * | unix_ts_ms | ver | seq_hi |
  25120. * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  25121. * |var| seq_low | rand |
  25122. * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  25123. * | rand |
  25124. * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  25125. *
  25126. * seq is a 31 bit serialized counter; comprised of 12 bit seq_hi and 19 bit
  25127. * seq_low, and randomly initialized upon timestamp change. 31 bit counter size
  25128. * was selected as any bitwise operations in node are done as _signed_ 32 bit
  25129. * ints. we exclude the sign bit.
  25130. */
  25131. let _seqLow = null;
  25132. let _seqHigh = null;
  25133. let _msecs = 0;
  25134. function v7(options, buf, offset) {
  25135. options = options || {};
  25136. // initialize buffer and pointer
  25137. let i = buf && offset || 0;
  25138. const b = buf || new Uint8Array(16);
  25139. // rnds is Uint8Array(16) filled with random bytes
  25140. const rnds = options.random || (options.rng || _rng.default)();
  25141. // milliseconds since unix epoch, 1970-01-01 00:00
  25142. const msecs = options.msecs !== undefined ? options.msecs : Date.now();
  25143. // seq is user provided 31 bit counter
  25144. let seq = options.seq !== undefined ? options.seq : null;
  25145. // initialize local seq high/low parts
  25146. let seqHigh = _seqHigh;
  25147. let seqLow = _seqLow;
  25148. // check if clock has advanced and user has not provided msecs
  25149. if (msecs > _msecs && options.msecs === undefined) {
  25150. _msecs = msecs;
  25151. // unless user provided seq, reset seq parts
  25152. if (seq !== null) {
  25153. seqHigh = null;
  25154. seqLow = null;
  25155. }
  25156. }
  25157. // if we have a user provided seq
  25158. if (seq !== null) {
  25159. // trim provided seq to 31 bits of value, avoiding overflow
  25160. if (seq > 0x7fffffff) {
  25161. seq = 0x7fffffff;
  25162. }
  25163. // split provided seq into high/low parts
  25164. seqHigh = seq >>> 19 & 0xfff;
  25165. seqLow = seq & 0x7ffff;
  25166. }
  25167. // randomly initialize seq
  25168. if (seqHigh === null || seqLow === null) {
  25169. seqHigh = rnds[6] & 0x7f;
  25170. seqHigh = seqHigh << 8 | rnds[7];
  25171. seqLow = rnds[8] & 0x3f; // pad for var
  25172. seqLow = seqLow << 8 | rnds[9];
  25173. seqLow = seqLow << 5 | rnds[10] >>> 3;
  25174. }
  25175. // increment seq if within msecs window
  25176. if (msecs + 10000 > _msecs && seq === null) {
  25177. if (++seqLow > 0x7ffff) {
  25178. seqLow = 0;
  25179. if (++seqHigh > 0xfff) {
  25180. seqHigh = 0;
  25181. // increment internal _msecs. this allows us to continue incrementing
  25182. // while staying monotonic. Note, once we hit 10k milliseconds beyond system
  25183. // clock, we will reset breaking monotonicity (after (2^31)*10000 generations)
  25184. _msecs++;
  25185. }
  25186. }
  25187. } else {
  25188. // resetting; we have advanced more than
  25189. // 10k milliseconds beyond system clock
  25190. _msecs = msecs;
  25191. }
  25192. _seqHigh = seqHigh;
  25193. _seqLow = seqLow;
  25194. // [bytes 0-5] 48 bits of local timestamp
  25195. b[i++] = _msecs / 0x10000000000 & 0xff;
  25196. b[i++] = _msecs / 0x100000000 & 0xff;
  25197. b[i++] = _msecs / 0x1000000 & 0xff;
  25198. b[i++] = _msecs / 0x10000 & 0xff;
  25199. b[i++] = _msecs / 0x100 & 0xff;
  25200. b[i++] = _msecs & 0xff;
  25201. // [byte 6] - set 4 bits of version (7) with first 4 bits seq_hi
  25202. b[i++] = seqHigh >>> 4 & 0x0f | 0x70;
  25203. // [byte 7] remaining 8 bits of seq_hi
  25204. b[i++] = seqHigh & 0xff;
  25205. // [byte 8] - variant (2 bits), first 6 bits seq_low
  25206. b[i++] = seqLow >>> 13 & 0x3f | 0x80;
  25207. // [byte 9] 8 bits seq_low
  25208. b[i++] = seqLow >>> 5 & 0xff;
  25209. // [byte 10] remaining 5 bits seq_low, 3 bits random
  25210. b[i++] = seqLow << 3 & 0xff | rnds[10] & 0x07;
  25211. // [bytes 11-15] always random
  25212. b[i++] = rnds[11];
  25213. b[i++] = rnds[12];
  25214. b[i++] = rnds[13];
  25215. b[i++] = rnds[14];
  25216. b[i++] = rnds[15];
  25217. return buf || (0, _stringify.unsafeStringify)(b);
  25218. }
  25219. var _default = exports.default = v7;
  25220. },{"./rng.js":494,"./stringify.js":496}],506:[function(_dereq_,module,exports){
  25221. "use strict";
  25222. Object.defineProperty(exports, "__esModule", {
  25223. value: true
  25224. });
  25225. exports.default = void 0;
  25226. var _regex = _interopRequireDefault(_dereq_("./regex.js"));
  25227. function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
  25228. function validate(uuid) {
  25229. return typeof uuid === 'string' && _regex.default.test(uuid);
  25230. }
  25231. var _default = exports.default = validate;
  25232. },{"./regex.js":493}],507:[function(_dereq_,module,exports){
  25233. "use strict";
  25234. Object.defineProperty(exports, "__esModule", {
  25235. value: true
  25236. });
  25237. exports.default = void 0;
  25238. var _validate = _interopRequireDefault(_dereq_("./validate.js"));
  25239. function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
  25240. function version(uuid) {
  25241. if (!(0, _validate.default)(uuid)) {
  25242. throw TypeError('Invalid UUID');
  25243. }
  25244. return parseInt(uuid.slice(14, 15), 16);
  25245. }
  25246. var _default = exports.default = version;
  25247. },{"./validate.js":506}],508:[function(_dereq_,module,exports){
  25248. 'use strict';
  25249. module.exports = function () {
  25250. throw new Error(
  25251. 'ws does not work in the browser. Browser clients must use the native ' +
  25252. 'WebSocket object'
  25253. );
  25254. };
  25255. },{}]},{},[20])(20)
  25256. });