immutable.js 168 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021
  1. /**
  2. * MIT License
  3. *
  4. * Copyright (c) 2014-present, Lee Byron and other contributors.
  5. *
  6. * Permission is hereby granted, free of charge, to any person obtaining a copy
  7. * of this software and associated documentation files (the "Software"), to deal
  8. * in the Software without restriction, including without limitation the rights
  9. * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  10. * copies of the Software, and to permit persons to whom the Software is
  11. * furnished to do so, subject to the following conditions:
  12. *
  13. * The above copyright notice and this permission notice shall be included in all
  14. * copies or substantial portions of the Software.
  15. *
  16. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  17. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  18. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  19. * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  20. * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  21. * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
  22. * SOFTWARE.
  23. */
  24. (function (global, factory) {
  25. typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports) :
  26. typeof define === 'function' && define.amd ? define(['exports'], factory) :
  27. (global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.Immutable = {}));
  28. }(this, (function (exports) { 'use strict';
  29. var DELETE = 'delete';
  30. // Constants describing the size of trie nodes.
  31. var SHIFT = 5; // Resulted in best performance after ______?
  32. var SIZE = 1 << SHIFT;
  33. var MASK = SIZE - 1;
  34. // A consistent shared value representing "not set" which equals nothing other
  35. // than itself, and nothing that could be provided externally.
  36. var NOT_SET = {};
  37. // Boolean references, Rough equivalent of `bool &`.
  38. function MakeRef() {
  39. return { value: false };
  40. }
  41. function SetRef(ref) {
  42. if (ref) {
  43. ref.value = true;
  44. }
  45. }
  46. // A function which returns a value representing an "owner" for transient writes
  47. // to tries. The return value will only ever equal itself, and will not equal
  48. // the return of any subsequent call of this function.
  49. function OwnerID() {}
  50. function ensureSize(iter) {
  51. if (iter.size === undefined) {
  52. iter.size = iter.__iterate(returnTrue);
  53. }
  54. return iter.size;
  55. }
  56. function wrapIndex(iter, index) {
  57. // This implements "is array index" which the ECMAString spec defines as:
  58. //
  59. // A String property name P is an array index if and only if
  60. // ToString(ToUint32(P)) is equal to P and ToUint32(P) is not equal
  61. // to 2^32−1.
  62. //
  63. // http://www.ecma-international.org/ecma-262/6.0/#sec-array-exotic-objects
  64. if (typeof index !== 'number') {
  65. var uint32Index = index >>> 0; // N >>> 0 is shorthand for ToUint32
  66. if ('' + uint32Index !== index || uint32Index === 4294967295) {
  67. return NaN;
  68. }
  69. index = uint32Index;
  70. }
  71. return index < 0 ? ensureSize(iter) + index : index;
  72. }
  73. function returnTrue() {
  74. return true;
  75. }
  76. function wholeSlice(begin, end, size) {
  77. return (
  78. ((begin === 0 && !isNeg(begin)) ||
  79. (size !== undefined && begin <= -size)) &&
  80. (end === undefined || (size !== undefined && end >= size))
  81. );
  82. }
  83. function resolveBegin(begin, size) {
  84. return resolveIndex(begin, size, 0);
  85. }
  86. function resolveEnd(end, size) {
  87. return resolveIndex(end, size, size);
  88. }
  89. function resolveIndex(index, size, defaultIndex) {
  90. // Sanitize indices using this shorthand for ToInt32(argument)
  91. // http://www.ecma-international.org/ecma-262/6.0/#sec-toint32
  92. return index === undefined
  93. ? defaultIndex
  94. : isNeg(index)
  95. ? size === Infinity
  96. ? size
  97. : Math.max(0, size + index) | 0
  98. : size === undefined || size === index
  99. ? index
  100. : Math.min(size, index) | 0;
  101. }
  102. function isNeg(value) {
  103. // Account for -0 which is negative, but not less than 0.
  104. return value < 0 || (value === 0 && 1 / value === -Infinity);
  105. }
  106. var IS_COLLECTION_SYMBOL = '@@__IMMUTABLE_ITERABLE__@@';
  107. function isCollection(maybeCollection) {
  108. return Boolean(maybeCollection && maybeCollection[IS_COLLECTION_SYMBOL]);
  109. }
  110. var IS_KEYED_SYMBOL = '@@__IMMUTABLE_KEYED__@@';
  111. function isKeyed(maybeKeyed) {
  112. return Boolean(maybeKeyed && maybeKeyed[IS_KEYED_SYMBOL]);
  113. }
  114. var IS_INDEXED_SYMBOL = '@@__IMMUTABLE_INDEXED__@@';
  115. function isIndexed(maybeIndexed) {
  116. return Boolean(maybeIndexed && maybeIndexed[IS_INDEXED_SYMBOL]);
  117. }
  118. function isAssociative(maybeAssociative) {
  119. return isKeyed(maybeAssociative) || isIndexed(maybeAssociative);
  120. }
  121. var Collection = function Collection(value) {
  122. return isCollection(value) ? value : Seq(value);
  123. };
  124. var KeyedCollection = /*@__PURE__*/(function (Collection) {
  125. function KeyedCollection(value) {
  126. return isKeyed(value) ? value : KeyedSeq(value);
  127. }
  128. if ( Collection ) KeyedCollection.__proto__ = Collection;
  129. KeyedCollection.prototype = Object.create( Collection && Collection.prototype );
  130. KeyedCollection.prototype.constructor = KeyedCollection;
  131. return KeyedCollection;
  132. }(Collection));
  133. var IndexedCollection = /*@__PURE__*/(function (Collection) {
  134. function IndexedCollection(value) {
  135. return isIndexed(value) ? value : IndexedSeq(value);
  136. }
  137. if ( Collection ) IndexedCollection.__proto__ = Collection;
  138. IndexedCollection.prototype = Object.create( Collection && Collection.prototype );
  139. IndexedCollection.prototype.constructor = IndexedCollection;
  140. return IndexedCollection;
  141. }(Collection));
  142. var SetCollection = /*@__PURE__*/(function (Collection) {
  143. function SetCollection(value) {
  144. return isCollection(value) && !isAssociative(value) ? value : SetSeq(value);
  145. }
  146. if ( Collection ) SetCollection.__proto__ = Collection;
  147. SetCollection.prototype = Object.create( Collection && Collection.prototype );
  148. SetCollection.prototype.constructor = SetCollection;
  149. return SetCollection;
  150. }(Collection));
  151. Collection.Keyed = KeyedCollection;
  152. Collection.Indexed = IndexedCollection;
  153. Collection.Set = SetCollection;
  154. var IS_SEQ_SYMBOL = '@@__IMMUTABLE_SEQ__@@';
  155. function isSeq(maybeSeq) {
  156. return Boolean(maybeSeq && maybeSeq[IS_SEQ_SYMBOL]);
  157. }
  158. var IS_RECORD_SYMBOL = '@@__IMMUTABLE_RECORD__@@';
  159. function isRecord(maybeRecord) {
  160. return Boolean(maybeRecord && maybeRecord[IS_RECORD_SYMBOL]);
  161. }
  162. function isImmutable(maybeImmutable) {
  163. return isCollection(maybeImmutable) || isRecord(maybeImmutable);
  164. }
  165. var IS_ORDERED_SYMBOL = '@@__IMMUTABLE_ORDERED__@@';
  166. function isOrdered(maybeOrdered) {
  167. return Boolean(maybeOrdered && maybeOrdered[IS_ORDERED_SYMBOL]);
  168. }
  169. var ITERATE_KEYS = 0;
  170. var ITERATE_VALUES = 1;
  171. var ITERATE_ENTRIES = 2;
  172. var REAL_ITERATOR_SYMBOL = typeof Symbol === 'function' && Symbol.iterator;
  173. var FAUX_ITERATOR_SYMBOL = '@@iterator';
  174. var ITERATOR_SYMBOL = REAL_ITERATOR_SYMBOL || FAUX_ITERATOR_SYMBOL;
  175. var Iterator = function Iterator(next) {
  176. this.next = next;
  177. };
  178. Iterator.prototype.toString = function toString () {
  179. return '[Iterator]';
  180. };
  181. Iterator.KEYS = ITERATE_KEYS;
  182. Iterator.VALUES = ITERATE_VALUES;
  183. Iterator.ENTRIES = ITERATE_ENTRIES;
  184. Iterator.prototype.inspect = Iterator.prototype.toSource = function () {
  185. return this.toString();
  186. };
  187. Iterator.prototype[ITERATOR_SYMBOL] = function () {
  188. return this;
  189. };
  190. function iteratorValue(type, k, v, iteratorResult) {
  191. var value = type === 0 ? k : type === 1 ? v : [k, v];
  192. iteratorResult
  193. ? (iteratorResult.value = value)
  194. : (iteratorResult = {
  195. value: value,
  196. done: false,
  197. });
  198. return iteratorResult;
  199. }
  200. function iteratorDone() {
  201. return { value: undefined, done: true };
  202. }
  203. function hasIterator(maybeIterable) {
  204. if (Array.isArray(maybeIterable)) {
  205. // IE11 trick as it does not support `Symbol.iterator`
  206. return true;
  207. }
  208. return !!getIteratorFn(maybeIterable);
  209. }
  210. function isIterator(maybeIterator) {
  211. return maybeIterator && typeof maybeIterator.next === 'function';
  212. }
  213. function getIterator(iterable) {
  214. var iteratorFn = getIteratorFn(iterable);
  215. return iteratorFn && iteratorFn.call(iterable);
  216. }
  217. function getIteratorFn(iterable) {
  218. var iteratorFn =
  219. iterable &&
  220. ((REAL_ITERATOR_SYMBOL && iterable[REAL_ITERATOR_SYMBOL]) ||
  221. iterable[FAUX_ITERATOR_SYMBOL]);
  222. if (typeof iteratorFn === 'function') {
  223. return iteratorFn;
  224. }
  225. }
  226. function isEntriesIterable(maybeIterable) {
  227. var iteratorFn = getIteratorFn(maybeIterable);
  228. return iteratorFn && iteratorFn === maybeIterable.entries;
  229. }
  230. function isKeysIterable(maybeIterable) {
  231. var iteratorFn = getIteratorFn(maybeIterable);
  232. return iteratorFn && iteratorFn === maybeIterable.keys;
  233. }
  234. var hasOwnProperty = Object.prototype.hasOwnProperty;
  235. function isArrayLike(value) {
  236. if (Array.isArray(value) || typeof value === 'string') {
  237. return true;
  238. }
  239. return (
  240. value &&
  241. typeof value === 'object' &&
  242. Number.isInteger(value.length) &&
  243. value.length >= 0 &&
  244. (value.length === 0
  245. ? // Only {length: 0} is considered Array-like.
  246. Object.keys(value).length === 1
  247. : // An object is only Array-like if it has a property where the last value
  248. // in the array-like may be found (which could be undefined).
  249. value.hasOwnProperty(value.length - 1))
  250. );
  251. }
  252. var Seq = /*@__PURE__*/(function (Collection) {
  253. function Seq(value) {
  254. return value === undefined || value === null
  255. ? emptySequence()
  256. : isImmutable(value)
  257. ? value.toSeq()
  258. : seqFromValue(value);
  259. }
  260. if ( Collection ) Seq.__proto__ = Collection;
  261. Seq.prototype = Object.create( Collection && Collection.prototype );
  262. Seq.prototype.constructor = Seq;
  263. Seq.prototype.toSeq = function toSeq () {
  264. return this;
  265. };
  266. Seq.prototype.toString = function toString () {
  267. return this.__toString('Seq {', '}');
  268. };
  269. Seq.prototype.cacheResult = function cacheResult () {
  270. if (!this._cache && this.__iterateUncached) {
  271. this._cache = this.entrySeq().toArray();
  272. this.size = this._cache.length;
  273. }
  274. return this;
  275. };
  276. // abstract __iterateUncached(fn, reverse)
  277. Seq.prototype.__iterate = function __iterate (fn, reverse) {
  278. var cache = this._cache;
  279. if (cache) {
  280. var size = cache.length;
  281. var i = 0;
  282. while (i !== size) {
  283. var entry = cache[reverse ? size - ++i : i++];
  284. if (fn(entry[1], entry[0], this) === false) {
  285. break;
  286. }
  287. }
  288. return i;
  289. }
  290. return this.__iterateUncached(fn, reverse);
  291. };
  292. // abstract __iteratorUncached(type, reverse)
  293. Seq.prototype.__iterator = function __iterator (type, reverse) {
  294. var cache = this._cache;
  295. if (cache) {
  296. var size = cache.length;
  297. var i = 0;
  298. return new Iterator(function () {
  299. if (i === size) {
  300. return iteratorDone();
  301. }
  302. var entry = cache[reverse ? size - ++i : i++];
  303. return iteratorValue(type, entry[0], entry[1]);
  304. });
  305. }
  306. return this.__iteratorUncached(type, reverse);
  307. };
  308. return Seq;
  309. }(Collection));
  310. var KeyedSeq = /*@__PURE__*/(function (Seq) {
  311. function KeyedSeq(value) {
  312. return value === undefined || value === null
  313. ? emptySequence().toKeyedSeq()
  314. : isCollection(value)
  315. ? isKeyed(value)
  316. ? value.toSeq()
  317. : value.fromEntrySeq()
  318. : isRecord(value)
  319. ? value.toSeq()
  320. : keyedSeqFromValue(value);
  321. }
  322. if ( Seq ) KeyedSeq.__proto__ = Seq;
  323. KeyedSeq.prototype = Object.create( Seq && Seq.prototype );
  324. KeyedSeq.prototype.constructor = KeyedSeq;
  325. KeyedSeq.prototype.toKeyedSeq = function toKeyedSeq () {
  326. return this;
  327. };
  328. return KeyedSeq;
  329. }(Seq));
  330. var IndexedSeq = /*@__PURE__*/(function (Seq) {
  331. function IndexedSeq(value) {
  332. return value === undefined || value === null
  333. ? emptySequence()
  334. : isCollection(value)
  335. ? isKeyed(value)
  336. ? value.entrySeq()
  337. : value.toIndexedSeq()
  338. : isRecord(value)
  339. ? value.toSeq().entrySeq()
  340. : indexedSeqFromValue(value);
  341. }
  342. if ( Seq ) IndexedSeq.__proto__ = Seq;
  343. IndexedSeq.prototype = Object.create( Seq && Seq.prototype );
  344. IndexedSeq.prototype.constructor = IndexedSeq;
  345. IndexedSeq.of = function of (/*...values*/) {
  346. return IndexedSeq(arguments);
  347. };
  348. IndexedSeq.prototype.toIndexedSeq = function toIndexedSeq () {
  349. return this;
  350. };
  351. IndexedSeq.prototype.toString = function toString () {
  352. return this.__toString('Seq [', ']');
  353. };
  354. return IndexedSeq;
  355. }(Seq));
  356. var SetSeq = /*@__PURE__*/(function (Seq) {
  357. function SetSeq(value) {
  358. return (
  359. isCollection(value) && !isAssociative(value) ? value : IndexedSeq(value)
  360. ).toSetSeq();
  361. }
  362. if ( Seq ) SetSeq.__proto__ = Seq;
  363. SetSeq.prototype = Object.create( Seq && Seq.prototype );
  364. SetSeq.prototype.constructor = SetSeq;
  365. SetSeq.of = function of (/*...values*/) {
  366. return SetSeq(arguments);
  367. };
  368. SetSeq.prototype.toSetSeq = function toSetSeq () {
  369. return this;
  370. };
  371. return SetSeq;
  372. }(Seq));
  373. Seq.isSeq = isSeq;
  374. Seq.Keyed = KeyedSeq;
  375. Seq.Set = SetSeq;
  376. Seq.Indexed = IndexedSeq;
  377. Seq.prototype[IS_SEQ_SYMBOL] = true;
  378. // #pragma Root Sequences
  379. var ArraySeq = /*@__PURE__*/(function (IndexedSeq) {
  380. function ArraySeq(array) {
  381. this._array = array;
  382. this.size = array.length;
  383. }
  384. if ( IndexedSeq ) ArraySeq.__proto__ = IndexedSeq;
  385. ArraySeq.prototype = Object.create( IndexedSeq && IndexedSeq.prototype );
  386. ArraySeq.prototype.constructor = ArraySeq;
  387. ArraySeq.prototype.get = function get (index, notSetValue) {
  388. return this.has(index) ? this._array[wrapIndex(this, index)] : notSetValue;
  389. };
  390. ArraySeq.prototype.__iterate = function __iterate (fn, reverse) {
  391. var array = this._array;
  392. var size = array.length;
  393. var i = 0;
  394. while (i !== size) {
  395. var ii = reverse ? size - ++i : i++;
  396. if (fn(array[ii], ii, this) === false) {
  397. break;
  398. }
  399. }
  400. return i;
  401. };
  402. ArraySeq.prototype.__iterator = function __iterator (type, reverse) {
  403. var array = this._array;
  404. var size = array.length;
  405. var i = 0;
  406. return new Iterator(function () {
  407. if (i === size) {
  408. return iteratorDone();
  409. }
  410. var ii = reverse ? size - ++i : i++;
  411. return iteratorValue(type, ii, array[ii]);
  412. });
  413. };
  414. return ArraySeq;
  415. }(IndexedSeq));
  416. var ObjectSeq = /*@__PURE__*/(function (KeyedSeq) {
  417. function ObjectSeq(object) {
  418. var keys = Object.keys(object).concat(
  419. Object.getOwnPropertySymbols ? Object.getOwnPropertySymbols(object) : []
  420. );
  421. this._object = object;
  422. this._keys = keys;
  423. this.size = keys.length;
  424. }
  425. if ( KeyedSeq ) ObjectSeq.__proto__ = KeyedSeq;
  426. ObjectSeq.prototype = Object.create( KeyedSeq && KeyedSeq.prototype );
  427. ObjectSeq.prototype.constructor = ObjectSeq;
  428. ObjectSeq.prototype.get = function get (key, notSetValue) {
  429. if (notSetValue !== undefined && !this.has(key)) {
  430. return notSetValue;
  431. }
  432. return this._object[key];
  433. };
  434. ObjectSeq.prototype.has = function has (key) {
  435. return hasOwnProperty.call(this._object, key);
  436. };
  437. ObjectSeq.prototype.__iterate = function __iterate (fn, reverse) {
  438. var object = this._object;
  439. var keys = this._keys;
  440. var size = keys.length;
  441. var i = 0;
  442. while (i !== size) {
  443. var key = keys[reverse ? size - ++i : i++];
  444. if (fn(object[key], key, this) === false) {
  445. break;
  446. }
  447. }
  448. return i;
  449. };
  450. ObjectSeq.prototype.__iterator = function __iterator (type, reverse) {
  451. var object = this._object;
  452. var keys = this._keys;
  453. var size = keys.length;
  454. var i = 0;
  455. return new Iterator(function () {
  456. if (i === size) {
  457. return iteratorDone();
  458. }
  459. var key = keys[reverse ? size - ++i : i++];
  460. return iteratorValue(type, key, object[key]);
  461. });
  462. };
  463. return ObjectSeq;
  464. }(KeyedSeq));
  465. ObjectSeq.prototype[IS_ORDERED_SYMBOL] = true;
  466. var CollectionSeq = /*@__PURE__*/(function (IndexedSeq) {
  467. function CollectionSeq(collection) {
  468. this._collection = collection;
  469. this.size = collection.length || collection.size;
  470. }
  471. if ( IndexedSeq ) CollectionSeq.__proto__ = IndexedSeq;
  472. CollectionSeq.prototype = Object.create( IndexedSeq && IndexedSeq.prototype );
  473. CollectionSeq.prototype.constructor = CollectionSeq;
  474. CollectionSeq.prototype.__iterateUncached = function __iterateUncached (fn, reverse) {
  475. if (reverse) {
  476. return this.cacheResult().__iterate(fn, reverse);
  477. }
  478. var collection = this._collection;
  479. var iterator = getIterator(collection);
  480. var iterations = 0;
  481. if (isIterator(iterator)) {
  482. var step;
  483. while (!(step = iterator.next()).done) {
  484. if (fn(step.value, iterations++, this) === false) {
  485. break;
  486. }
  487. }
  488. }
  489. return iterations;
  490. };
  491. CollectionSeq.prototype.__iteratorUncached = function __iteratorUncached (type, reverse) {
  492. if (reverse) {
  493. return this.cacheResult().__iterator(type, reverse);
  494. }
  495. var collection = this._collection;
  496. var iterator = getIterator(collection);
  497. if (!isIterator(iterator)) {
  498. return new Iterator(iteratorDone);
  499. }
  500. var iterations = 0;
  501. return new Iterator(function () {
  502. var step = iterator.next();
  503. return step.done ? step : iteratorValue(type, iterations++, step.value);
  504. });
  505. };
  506. return CollectionSeq;
  507. }(IndexedSeq));
  508. // # pragma Helper functions
  509. var EMPTY_SEQ;
  510. function emptySequence() {
  511. return EMPTY_SEQ || (EMPTY_SEQ = new ArraySeq([]));
  512. }
  513. function keyedSeqFromValue(value) {
  514. var seq = maybeIndexedSeqFromValue(value);
  515. if (seq) {
  516. return seq.fromEntrySeq();
  517. }
  518. if (typeof value === 'object') {
  519. return new ObjectSeq(value);
  520. }
  521. throw new TypeError(
  522. 'Expected Array or collection object of [k, v] entries, or keyed object: ' +
  523. value
  524. );
  525. }
  526. function indexedSeqFromValue(value) {
  527. var seq = maybeIndexedSeqFromValue(value);
  528. if (seq) {
  529. return seq;
  530. }
  531. throw new TypeError(
  532. 'Expected Array or collection object of values: ' + value
  533. );
  534. }
  535. function seqFromValue(value) {
  536. var seq = maybeIndexedSeqFromValue(value);
  537. if (seq) {
  538. return isEntriesIterable(value)
  539. ? seq.fromEntrySeq()
  540. : isKeysIterable(value)
  541. ? seq.toSetSeq()
  542. : seq;
  543. }
  544. if (typeof value === 'object') {
  545. return new ObjectSeq(value);
  546. }
  547. throw new TypeError(
  548. 'Expected Array or collection object of values, or keyed object: ' + value
  549. );
  550. }
  551. function maybeIndexedSeqFromValue(value) {
  552. return isArrayLike(value)
  553. ? new ArraySeq(value)
  554. : hasIterator(value)
  555. ? new CollectionSeq(value)
  556. : undefined;
  557. }
  558. var IS_MAP_SYMBOL = '@@__IMMUTABLE_MAP__@@';
  559. function isMap(maybeMap) {
  560. return Boolean(maybeMap && maybeMap[IS_MAP_SYMBOL]);
  561. }
  562. function isOrderedMap(maybeOrderedMap) {
  563. return isMap(maybeOrderedMap) && isOrdered(maybeOrderedMap);
  564. }
  565. function isValueObject(maybeValue) {
  566. return Boolean(
  567. maybeValue &&
  568. typeof maybeValue.equals === 'function' &&
  569. typeof maybeValue.hashCode === 'function'
  570. );
  571. }
  572. /**
  573. * An extension of the "same-value" algorithm as [described for use by ES6 Map
  574. * and Set](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Map#Key_equality)
  575. *
  576. * NaN is considered the same as NaN, however -0 and 0 are considered the same
  577. * value, which is different from the algorithm described by
  578. * [`Object.is`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/is).
  579. *
  580. * This is extended further to allow Objects to describe the values they
  581. * represent, by way of `valueOf` or `equals` (and `hashCode`).
  582. *
  583. * Note: because of this extension, the key equality of Immutable.Map and the
  584. * value equality of Immutable.Set will differ from ES6 Map and Set.
  585. *
  586. * ### Defining custom values
  587. *
  588. * The easiest way to describe the value an object represents is by implementing
  589. * `valueOf`. For example, `Date` represents a value by returning a unix
  590. * timestamp for `valueOf`:
  591. *
  592. * var date1 = new Date(1234567890000); // Fri Feb 13 2009 ...
  593. * var date2 = new Date(1234567890000);
  594. * date1.valueOf(); // 1234567890000
  595. * assert( date1 !== date2 );
  596. * assert( Immutable.is( date1, date2 ) );
  597. *
  598. * Note: overriding `valueOf` may have other implications if you use this object
  599. * where JavaScript expects a primitive, such as implicit string coercion.
  600. *
  601. * For more complex types, especially collections, implementing `valueOf` may
  602. * not be performant. An alternative is to implement `equals` and `hashCode`.
  603. *
  604. * `equals` takes another object, presumably of similar type, and returns true
  605. * if it is equal. Equality is symmetrical, so the same result should be
  606. * returned if this and the argument are flipped.
  607. *
  608. * assert( a.equals(b) === b.equals(a) );
  609. *
  610. * `hashCode` returns a 32bit integer number representing the object which will
  611. * be used to determine how to store the value object in a Map or Set. You must
  612. * provide both or neither methods, one must not exist without the other.
  613. *
  614. * Also, an important relationship between these methods must be upheld: if two
  615. * values are equal, they *must* return the same hashCode. If the values are not
  616. * equal, they might have the same hashCode; this is called a hash collision,
  617. * and while undesirable for performance reasons, it is acceptable.
  618. *
  619. * if (a.equals(b)) {
  620. * assert( a.hashCode() === b.hashCode() );
  621. * }
  622. *
  623. * All Immutable collections are Value Objects: they implement `equals()`
  624. * and `hashCode()`.
  625. */
  626. function is(valueA, valueB) {
  627. if (valueA === valueB || (valueA !== valueA && valueB !== valueB)) {
  628. return true;
  629. }
  630. if (!valueA || !valueB) {
  631. return false;
  632. }
  633. if (
  634. typeof valueA.valueOf === 'function' &&
  635. typeof valueB.valueOf === 'function'
  636. ) {
  637. valueA = valueA.valueOf();
  638. valueB = valueB.valueOf();
  639. if (valueA === valueB || (valueA !== valueA && valueB !== valueB)) {
  640. return true;
  641. }
  642. if (!valueA || !valueB) {
  643. return false;
  644. }
  645. }
  646. return !!(
  647. isValueObject(valueA) &&
  648. isValueObject(valueB) &&
  649. valueA.equals(valueB)
  650. );
  651. }
  652. var imul =
  653. typeof Math.imul === 'function' && Math.imul(0xffffffff, 2) === -2
  654. ? Math.imul
  655. : function imul(a, b) {
  656. a |= 0; // int
  657. b |= 0; // int
  658. var c = a & 0xffff;
  659. var d = b & 0xffff;
  660. // Shift by 0 fixes the sign on the high part.
  661. return (c * d + ((((a >>> 16) * d + c * (b >>> 16)) << 16) >>> 0)) | 0; // int
  662. };
  663. // v8 has an optimization for storing 31-bit signed numbers.
  664. // Values which have either 00 or 11 as the high order bits qualify.
  665. // This function drops the highest order bit in a signed number, maintaining
  666. // the sign bit.
  667. function smi(i32) {
  668. return ((i32 >>> 1) & 0x40000000) | (i32 & 0xbfffffff);
  669. }
  670. var defaultValueOf = Object.prototype.valueOf;
  671. function hash(o) {
  672. if (o == null) {
  673. return hashNullish(o);
  674. }
  675. if (typeof o.hashCode === 'function') {
  676. // Drop any high bits from accidentally long hash codes.
  677. return smi(o.hashCode(o));
  678. }
  679. var v = valueOf(o);
  680. if (v == null) {
  681. return hashNullish(v);
  682. }
  683. switch (typeof v) {
  684. case 'boolean':
  685. // The hash values for built-in constants are a 1 value for each 5-byte
  686. // shift region expect for the first, which encodes the value. This
  687. // reduces the odds of a hash collision for these common values.
  688. return v ? 0x42108421 : 0x42108420;
  689. case 'number':
  690. return hashNumber(v);
  691. case 'string':
  692. return v.length > STRING_HASH_CACHE_MIN_STRLEN
  693. ? cachedHashString(v)
  694. : hashString(v);
  695. case 'object':
  696. case 'function':
  697. return hashJSObj(v);
  698. case 'symbol':
  699. return hashSymbol(v);
  700. default:
  701. if (typeof v.toString === 'function') {
  702. return hashString(v.toString());
  703. }
  704. throw new Error('Value type ' + typeof v + ' cannot be hashed.');
  705. }
  706. }
  707. function hashNullish(nullish) {
  708. return nullish === null ? 0x42108422 : /* undefined */ 0x42108423;
  709. }
  710. // Compress arbitrarily large numbers into smi hashes.
  711. function hashNumber(n) {
  712. if (n !== n || n === Infinity) {
  713. return 0;
  714. }
  715. var hash = n | 0;
  716. if (hash !== n) {
  717. hash ^= n * 0xffffffff;
  718. }
  719. while (n > 0xffffffff) {
  720. n /= 0xffffffff;
  721. hash ^= n;
  722. }
  723. return smi(hash);
  724. }
  725. function cachedHashString(string) {
  726. var hashed = stringHashCache[string];
  727. if (hashed === undefined) {
  728. hashed = hashString(string);
  729. if (STRING_HASH_CACHE_SIZE === STRING_HASH_CACHE_MAX_SIZE) {
  730. STRING_HASH_CACHE_SIZE = 0;
  731. stringHashCache = {};
  732. }
  733. STRING_HASH_CACHE_SIZE++;
  734. stringHashCache[string] = hashed;
  735. }
  736. return hashed;
  737. }
  738. // http://jsperf.com/hashing-strings
  739. function hashString(string) {
  740. // This is the hash from JVM
  741. // The hash code for a string is computed as
  742. // s[0] * 31 ^ (n - 1) + s[1] * 31 ^ (n - 2) + ... + s[n - 1],
  743. // where s[i] is the ith character of the string and n is the length of
  744. // the string. We "mod" the result to make it between 0 (inclusive) and 2^31
  745. // (exclusive) by dropping high bits.
  746. var hashed = 0;
  747. for (var ii = 0; ii < string.length; ii++) {
  748. hashed = (31 * hashed + string.charCodeAt(ii)) | 0;
  749. }
  750. return smi(hashed);
  751. }
  752. function hashSymbol(sym) {
  753. var hashed = symbolMap[sym];
  754. if (hashed !== undefined) {
  755. return hashed;
  756. }
  757. hashed = nextHash();
  758. symbolMap[sym] = hashed;
  759. return hashed;
  760. }
  761. function hashJSObj(obj) {
  762. var hashed;
  763. if (usingWeakMap) {
  764. hashed = weakMap.get(obj);
  765. if (hashed !== undefined) {
  766. return hashed;
  767. }
  768. }
  769. hashed = obj[UID_HASH_KEY];
  770. if (hashed !== undefined) {
  771. return hashed;
  772. }
  773. if (!canDefineProperty) {
  774. hashed = obj.propertyIsEnumerable && obj.propertyIsEnumerable[UID_HASH_KEY];
  775. if (hashed !== undefined) {
  776. return hashed;
  777. }
  778. hashed = getIENodeHash(obj);
  779. if (hashed !== undefined) {
  780. return hashed;
  781. }
  782. }
  783. hashed = nextHash();
  784. if (usingWeakMap) {
  785. weakMap.set(obj, hashed);
  786. } else if (isExtensible !== undefined && isExtensible(obj) === false) {
  787. throw new Error('Non-extensible objects are not allowed as keys.');
  788. } else if (canDefineProperty) {
  789. Object.defineProperty(obj, UID_HASH_KEY, {
  790. enumerable: false,
  791. configurable: false,
  792. writable: false,
  793. value: hashed,
  794. });
  795. } else if (
  796. obj.propertyIsEnumerable !== undefined &&
  797. obj.propertyIsEnumerable === obj.constructor.prototype.propertyIsEnumerable
  798. ) {
  799. // Since we can't define a non-enumerable property on the object
  800. // we'll hijack one of the less-used non-enumerable properties to
  801. // save our hash on it. Since this is a function it will not show up in
  802. // `JSON.stringify` which is what we want.
  803. obj.propertyIsEnumerable = function () {
  804. return this.constructor.prototype.propertyIsEnumerable.apply(
  805. this,
  806. arguments
  807. );
  808. };
  809. obj.propertyIsEnumerable[UID_HASH_KEY] = hashed;
  810. } else if (obj.nodeType !== undefined) {
  811. // At this point we couldn't get the IE `uniqueID` to use as a hash
  812. // and we couldn't use a non-enumerable property to exploit the
  813. // dontEnum bug so we simply add the `UID_HASH_KEY` on the node
  814. // itself.
  815. obj[UID_HASH_KEY] = hashed;
  816. } else {
  817. throw new Error('Unable to set a non-enumerable property on object.');
  818. }
  819. return hashed;
  820. }
  821. // Get references to ES5 object methods.
  822. var isExtensible = Object.isExtensible;
  823. // True if Object.defineProperty works as expected. IE8 fails this test.
  824. var canDefineProperty = (function () {
  825. try {
  826. Object.defineProperty({}, '@', {});
  827. return true;
  828. } catch (e) {
  829. return false;
  830. }
  831. })();
  832. // IE has a `uniqueID` property on DOM nodes. We can construct the hash from it
  833. // and avoid memory leaks from the IE cloneNode bug.
  834. function getIENodeHash(node) {
  835. if (node && node.nodeType > 0) {
  836. switch (node.nodeType) {
  837. case 1: // Element
  838. return node.uniqueID;
  839. case 9: // Document
  840. return node.documentElement && node.documentElement.uniqueID;
  841. }
  842. }
  843. }
  844. function valueOf(obj) {
  845. return obj.valueOf !== defaultValueOf && typeof obj.valueOf === 'function'
  846. ? obj.valueOf(obj)
  847. : obj;
  848. }
  849. function nextHash() {
  850. var nextHash = ++_objHashUID;
  851. if (_objHashUID & 0x40000000) {
  852. _objHashUID = 0;
  853. }
  854. return nextHash;
  855. }
  856. // If possible, use a WeakMap.
  857. var usingWeakMap = typeof WeakMap === 'function';
  858. var weakMap;
  859. if (usingWeakMap) {
  860. weakMap = new WeakMap();
  861. }
  862. var symbolMap = Object.create(null);
  863. var _objHashUID = 0;
  864. var UID_HASH_KEY = '__immutablehash__';
  865. if (typeof Symbol === 'function') {
  866. UID_HASH_KEY = Symbol(UID_HASH_KEY);
  867. }
  868. var STRING_HASH_CACHE_MIN_STRLEN = 16;
  869. var STRING_HASH_CACHE_MAX_SIZE = 255;
  870. var STRING_HASH_CACHE_SIZE = 0;
  871. var stringHashCache = {};
  872. var ToKeyedSequence = /*@__PURE__*/(function (KeyedSeq) {
  873. function ToKeyedSequence(indexed, useKeys) {
  874. this._iter = indexed;
  875. this._useKeys = useKeys;
  876. this.size = indexed.size;
  877. }
  878. if ( KeyedSeq ) ToKeyedSequence.__proto__ = KeyedSeq;
  879. ToKeyedSequence.prototype = Object.create( KeyedSeq && KeyedSeq.prototype );
  880. ToKeyedSequence.prototype.constructor = ToKeyedSequence;
  881. ToKeyedSequence.prototype.get = function get (key, notSetValue) {
  882. return this._iter.get(key, notSetValue);
  883. };
  884. ToKeyedSequence.prototype.has = function has (key) {
  885. return this._iter.has(key);
  886. };
  887. ToKeyedSequence.prototype.valueSeq = function valueSeq () {
  888. return this._iter.valueSeq();
  889. };
  890. ToKeyedSequence.prototype.reverse = function reverse () {
  891. var this$1$1 = this;
  892. var reversedSequence = reverseFactory(this, true);
  893. if (!this._useKeys) {
  894. reversedSequence.valueSeq = function () { return this$1$1._iter.toSeq().reverse(); };
  895. }
  896. return reversedSequence;
  897. };
  898. ToKeyedSequence.prototype.map = function map (mapper, context) {
  899. var this$1$1 = this;
  900. var mappedSequence = mapFactory(this, mapper, context);
  901. if (!this._useKeys) {
  902. mappedSequence.valueSeq = function () { return this$1$1._iter.toSeq().map(mapper, context); };
  903. }
  904. return mappedSequence;
  905. };
  906. ToKeyedSequence.prototype.__iterate = function __iterate (fn, reverse) {
  907. var this$1$1 = this;
  908. return this._iter.__iterate(function (v, k) { return fn(v, k, this$1$1); }, reverse);
  909. };
  910. ToKeyedSequence.prototype.__iterator = function __iterator (type, reverse) {
  911. return this._iter.__iterator(type, reverse);
  912. };
  913. return ToKeyedSequence;
  914. }(KeyedSeq));
  915. ToKeyedSequence.prototype[IS_ORDERED_SYMBOL] = true;
  916. var ToIndexedSequence = /*@__PURE__*/(function (IndexedSeq) {
  917. function ToIndexedSequence(iter) {
  918. this._iter = iter;
  919. this.size = iter.size;
  920. }
  921. if ( IndexedSeq ) ToIndexedSequence.__proto__ = IndexedSeq;
  922. ToIndexedSequence.prototype = Object.create( IndexedSeq && IndexedSeq.prototype );
  923. ToIndexedSequence.prototype.constructor = ToIndexedSequence;
  924. ToIndexedSequence.prototype.includes = function includes (value) {
  925. return this._iter.includes(value);
  926. };
  927. ToIndexedSequence.prototype.__iterate = function __iterate (fn, reverse) {
  928. var this$1$1 = this;
  929. var i = 0;
  930. reverse && ensureSize(this);
  931. return this._iter.__iterate(
  932. function (v) { return fn(v, reverse ? this$1$1.size - ++i : i++, this$1$1); },
  933. reverse
  934. );
  935. };
  936. ToIndexedSequence.prototype.__iterator = function __iterator (type, reverse) {
  937. var this$1$1 = this;
  938. var iterator = this._iter.__iterator(ITERATE_VALUES, reverse);
  939. var i = 0;
  940. reverse && ensureSize(this);
  941. return new Iterator(function () {
  942. var step = iterator.next();
  943. return step.done
  944. ? step
  945. : iteratorValue(
  946. type,
  947. reverse ? this$1$1.size - ++i : i++,
  948. step.value,
  949. step
  950. );
  951. });
  952. };
  953. return ToIndexedSequence;
  954. }(IndexedSeq));
  955. var ToSetSequence = /*@__PURE__*/(function (SetSeq) {
  956. function ToSetSequence(iter) {
  957. this._iter = iter;
  958. this.size = iter.size;
  959. }
  960. if ( SetSeq ) ToSetSequence.__proto__ = SetSeq;
  961. ToSetSequence.prototype = Object.create( SetSeq && SetSeq.prototype );
  962. ToSetSequence.prototype.constructor = ToSetSequence;
  963. ToSetSequence.prototype.has = function has (key) {
  964. return this._iter.includes(key);
  965. };
  966. ToSetSequence.prototype.__iterate = function __iterate (fn, reverse) {
  967. var this$1$1 = this;
  968. return this._iter.__iterate(function (v) { return fn(v, v, this$1$1); }, reverse);
  969. };
  970. ToSetSequence.prototype.__iterator = function __iterator (type, reverse) {
  971. var iterator = this._iter.__iterator(ITERATE_VALUES, reverse);
  972. return new Iterator(function () {
  973. var step = iterator.next();
  974. return step.done
  975. ? step
  976. : iteratorValue(type, step.value, step.value, step);
  977. });
  978. };
  979. return ToSetSequence;
  980. }(SetSeq));
  981. var FromEntriesSequence = /*@__PURE__*/(function (KeyedSeq) {
  982. function FromEntriesSequence(entries) {
  983. this._iter = entries;
  984. this.size = entries.size;
  985. }
  986. if ( KeyedSeq ) FromEntriesSequence.__proto__ = KeyedSeq;
  987. FromEntriesSequence.prototype = Object.create( KeyedSeq && KeyedSeq.prototype );
  988. FromEntriesSequence.prototype.constructor = FromEntriesSequence;
  989. FromEntriesSequence.prototype.entrySeq = function entrySeq () {
  990. return this._iter.toSeq();
  991. };
  992. FromEntriesSequence.prototype.__iterate = function __iterate (fn, reverse) {
  993. var this$1$1 = this;
  994. return this._iter.__iterate(function (entry) {
  995. // Check if entry exists first so array access doesn't throw for holes
  996. // in the parent iteration.
  997. if (entry) {
  998. validateEntry(entry);
  999. var indexedCollection = isCollection(entry);
  1000. return fn(
  1001. indexedCollection ? entry.get(1) : entry[1],
  1002. indexedCollection ? entry.get(0) : entry[0],
  1003. this$1$1
  1004. );
  1005. }
  1006. }, reverse);
  1007. };
  1008. FromEntriesSequence.prototype.__iterator = function __iterator (type, reverse) {
  1009. var iterator = this._iter.__iterator(ITERATE_VALUES, reverse);
  1010. return new Iterator(function () {
  1011. while (true) {
  1012. var step = iterator.next();
  1013. if (step.done) {
  1014. return step;
  1015. }
  1016. var entry = step.value;
  1017. // Check if entry exists first so array access doesn't throw for holes
  1018. // in the parent iteration.
  1019. if (entry) {
  1020. validateEntry(entry);
  1021. var indexedCollection = isCollection(entry);
  1022. return iteratorValue(
  1023. type,
  1024. indexedCollection ? entry.get(0) : entry[0],
  1025. indexedCollection ? entry.get(1) : entry[1],
  1026. step
  1027. );
  1028. }
  1029. }
  1030. });
  1031. };
  1032. return FromEntriesSequence;
  1033. }(KeyedSeq));
  1034. ToIndexedSequence.prototype.cacheResult =
  1035. ToKeyedSequence.prototype.cacheResult =
  1036. ToSetSequence.prototype.cacheResult =
  1037. FromEntriesSequence.prototype.cacheResult =
  1038. cacheResultThrough;
  1039. function flipFactory(collection) {
  1040. var flipSequence = makeSequence(collection);
  1041. flipSequence._iter = collection;
  1042. flipSequence.size = collection.size;
  1043. flipSequence.flip = function () { return collection; };
  1044. flipSequence.reverse = function () {
  1045. var reversedSequence = collection.reverse.apply(this); // super.reverse()
  1046. reversedSequence.flip = function () { return collection.reverse(); };
  1047. return reversedSequence;
  1048. };
  1049. flipSequence.has = function (key) { return collection.includes(key); };
  1050. flipSequence.includes = function (key) { return collection.has(key); };
  1051. flipSequence.cacheResult = cacheResultThrough;
  1052. flipSequence.__iterateUncached = function (fn, reverse) {
  1053. var this$1$1 = this;
  1054. return collection.__iterate(function (v, k) { return fn(k, v, this$1$1) !== false; }, reverse);
  1055. };
  1056. flipSequence.__iteratorUncached = function (type, reverse) {
  1057. if (type === ITERATE_ENTRIES) {
  1058. var iterator = collection.__iterator(type, reverse);
  1059. return new Iterator(function () {
  1060. var step = iterator.next();
  1061. if (!step.done) {
  1062. var k = step.value[0];
  1063. step.value[0] = step.value[1];
  1064. step.value[1] = k;
  1065. }
  1066. return step;
  1067. });
  1068. }
  1069. return collection.__iterator(
  1070. type === ITERATE_VALUES ? ITERATE_KEYS : ITERATE_VALUES,
  1071. reverse
  1072. );
  1073. };
  1074. return flipSequence;
  1075. }
  1076. function mapFactory(collection, mapper, context) {
  1077. var mappedSequence = makeSequence(collection);
  1078. mappedSequence.size = collection.size;
  1079. mappedSequence.has = function (key) { return collection.has(key); };
  1080. mappedSequence.get = function (key, notSetValue) {
  1081. var v = collection.get(key, NOT_SET);
  1082. return v === NOT_SET
  1083. ? notSetValue
  1084. : mapper.call(context, v, key, collection);
  1085. };
  1086. mappedSequence.__iterateUncached = function (fn, reverse) {
  1087. var this$1$1 = this;
  1088. return collection.__iterate(
  1089. function (v, k, c) { return fn(mapper.call(context, v, k, c), k, this$1$1) !== false; },
  1090. reverse
  1091. );
  1092. };
  1093. mappedSequence.__iteratorUncached = function (type, reverse) {
  1094. var iterator = collection.__iterator(ITERATE_ENTRIES, reverse);
  1095. return new Iterator(function () {
  1096. var step = iterator.next();
  1097. if (step.done) {
  1098. return step;
  1099. }
  1100. var entry = step.value;
  1101. var key = entry[0];
  1102. return iteratorValue(
  1103. type,
  1104. key,
  1105. mapper.call(context, entry[1], key, collection),
  1106. step
  1107. );
  1108. });
  1109. };
  1110. return mappedSequence;
  1111. }
  1112. function reverseFactory(collection, useKeys) {
  1113. var this$1$1 = this;
  1114. var reversedSequence = makeSequence(collection);
  1115. reversedSequence._iter = collection;
  1116. reversedSequence.size = collection.size;
  1117. reversedSequence.reverse = function () { return collection; };
  1118. if (collection.flip) {
  1119. reversedSequence.flip = function () {
  1120. var flipSequence = flipFactory(collection);
  1121. flipSequence.reverse = function () { return collection.flip(); };
  1122. return flipSequence;
  1123. };
  1124. }
  1125. reversedSequence.get = function (key, notSetValue) { return collection.get(useKeys ? key : -1 - key, notSetValue); };
  1126. reversedSequence.has = function (key) { return collection.has(useKeys ? key : -1 - key); };
  1127. reversedSequence.includes = function (value) { return collection.includes(value); };
  1128. reversedSequence.cacheResult = cacheResultThrough;
  1129. reversedSequence.__iterate = function (fn, reverse) {
  1130. var this$1$1 = this;
  1131. var i = 0;
  1132. reverse && ensureSize(collection);
  1133. return collection.__iterate(
  1134. function (v, k) { return fn(v, useKeys ? k : reverse ? this$1$1.size - ++i : i++, this$1$1); },
  1135. !reverse
  1136. );
  1137. };
  1138. reversedSequence.__iterator = function (type, reverse) {
  1139. var i = 0;
  1140. reverse && ensureSize(collection);
  1141. var iterator = collection.__iterator(ITERATE_ENTRIES, !reverse);
  1142. return new Iterator(function () {
  1143. var step = iterator.next();
  1144. if (step.done) {
  1145. return step;
  1146. }
  1147. var entry = step.value;
  1148. return iteratorValue(
  1149. type,
  1150. useKeys ? entry[0] : reverse ? this$1$1.size - ++i : i++,
  1151. entry[1],
  1152. step
  1153. );
  1154. });
  1155. };
  1156. return reversedSequence;
  1157. }
  1158. function filterFactory(collection, predicate, context, useKeys) {
  1159. var filterSequence = makeSequence(collection);
  1160. if (useKeys) {
  1161. filterSequence.has = function (key) {
  1162. var v = collection.get(key, NOT_SET);
  1163. return v !== NOT_SET && !!predicate.call(context, v, key, collection);
  1164. };
  1165. filterSequence.get = function (key, notSetValue) {
  1166. var v = collection.get(key, NOT_SET);
  1167. return v !== NOT_SET && predicate.call(context, v, key, collection)
  1168. ? v
  1169. : notSetValue;
  1170. };
  1171. }
  1172. filterSequence.__iterateUncached = function (fn, reverse) {
  1173. var this$1$1 = this;
  1174. var iterations = 0;
  1175. collection.__iterate(function (v, k, c) {
  1176. if (predicate.call(context, v, k, c)) {
  1177. iterations++;
  1178. return fn(v, useKeys ? k : iterations - 1, this$1$1);
  1179. }
  1180. }, reverse);
  1181. return iterations;
  1182. };
  1183. filterSequence.__iteratorUncached = function (type, reverse) {
  1184. var iterator = collection.__iterator(ITERATE_ENTRIES, reverse);
  1185. var iterations = 0;
  1186. return new Iterator(function () {
  1187. while (true) {
  1188. var step = iterator.next();
  1189. if (step.done) {
  1190. return step;
  1191. }
  1192. var entry = step.value;
  1193. var key = entry[0];
  1194. var value = entry[1];
  1195. if (predicate.call(context, value, key, collection)) {
  1196. return iteratorValue(type, useKeys ? key : iterations++, value, step);
  1197. }
  1198. }
  1199. });
  1200. };
  1201. return filterSequence;
  1202. }
  1203. function countByFactory(collection, grouper, context) {
  1204. var groups = Map().asMutable();
  1205. collection.__iterate(function (v, k) {
  1206. groups.update(grouper.call(context, v, k, collection), 0, function (a) { return a + 1; });
  1207. });
  1208. return groups.asImmutable();
  1209. }
  1210. function groupByFactory(collection, grouper, context) {
  1211. var isKeyedIter = isKeyed(collection);
  1212. var groups = (isOrdered(collection) ? OrderedMap() : Map()).asMutable();
  1213. collection.__iterate(function (v, k) {
  1214. groups.update(
  1215. grouper.call(context, v, k, collection),
  1216. function (a) { return ((a = a || []), a.push(isKeyedIter ? [k, v] : v), a); }
  1217. );
  1218. });
  1219. var coerce = collectionClass(collection);
  1220. return groups.map(function (arr) { return reify(collection, coerce(arr)); }).asImmutable();
  1221. }
  1222. function partitionFactory(collection, predicate, context) {
  1223. var isKeyedIter = isKeyed(collection);
  1224. var groups = [[], []];
  1225. collection.__iterate(function (v, k) {
  1226. groups[predicate.call(context, v, k, collection) ? 1 : 0].push(
  1227. isKeyedIter ? [k, v] : v
  1228. );
  1229. });
  1230. var coerce = collectionClass(collection);
  1231. return groups.map(function (arr) { return reify(collection, coerce(arr)); });
  1232. }
  1233. function sliceFactory(collection, begin, end, useKeys) {
  1234. var originalSize = collection.size;
  1235. if (wholeSlice(begin, end, originalSize)) {
  1236. return collection;
  1237. }
  1238. var resolvedBegin = resolveBegin(begin, originalSize);
  1239. var resolvedEnd = resolveEnd(end, originalSize);
  1240. // begin or end will be NaN if they were provided as negative numbers and
  1241. // this collection's size is unknown. In that case, cache first so there is
  1242. // a known size and these do not resolve to NaN.
  1243. if (resolvedBegin !== resolvedBegin || resolvedEnd !== resolvedEnd) {
  1244. return sliceFactory(collection.toSeq().cacheResult(), begin, end, useKeys);
  1245. }
  1246. // Note: resolvedEnd is undefined when the original sequence's length is
  1247. // unknown and this slice did not supply an end and should contain all
  1248. // elements after resolvedBegin.
  1249. // In that case, resolvedSize will be NaN and sliceSize will remain undefined.
  1250. var resolvedSize = resolvedEnd - resolvedBegin;
  1251. var sliceSize;
  1252. if (resolvedSize === resolvedSize) {
  1253. sliceSize = resolvedSize < 0 ? 0 : resolvedSize;
  1254. }
  1255. var sliceSeq = makeSequence(collection);
  1256. // If collection.size is undefined, the size of the realized sliceSeq is
  1257. // unknown at this point unless the number of items to slice is 0
  1258. sliceSeq.size =
  1259. sliceSize === 0 ? sliceSize : (collection.size && sliceSize) || undefined;
  1260. if (!useKeys && isSeq(collection) && sliceSize >= 0) {
  1261. sliceSeq.get = function (index, notSetValue) {
  1262. index = wrapIndex(this, index);
  1263. return index >= 0 && index < sliceSize
  1264. ? collection.get(index + resolvedBegin, notSetValue)
  1265. : notSetValue;
  1266. };
  1267. }
  1268. sliceSeq.__iterateUncached = function (fn, reverse) {
  1269. var this$1$1 = this;
  1270. if (sliceSize === 0) {
  1271. return 0;
  1272. }
  1273. if (reverse) {
  1274. return this.cacheResult().__iterate(fn, reverse);
  1275. }
  1276. var skipped = 0;
  1277. var isSkipping = true;
  1278. var iterations = 0;
  1279. collection.__iterate(function (v, k) {
  1280. if (!(isSkipping && (isSkipping = skipped++ < resolvedBegin))) {
  1281. iterations++;
  1282. return (
  1283. fn(v, useKeys ? k : iterations - 1, this$1$1) !== false &&
  1284. iterations !== sliceSize
  1285. );
  1286. }
  1287. });
  1288. return iterations;
  1289. };
  1290. sliceSeq.__iteratorUncached = function (type, reverse) {
  1291. if (sliceSize !== 0 && reverse) {
  1292. return this.cacheResult().__iterator(type, reverse);
  1293. }
  1294. // Don't bother instantiating parent iterator if taking 0.
  1295. if (sliceSize === 0) {
  1296. return new Iterator(iteratorDone);
  1297. }
  1298. var iterator = collection.__iterator(type, reverse);
  1299. var skipped = 0;
  1300. var iterations = 0;
  1301. return new Iterator(function () {
  1302. while (skipped++ < resolvedBegin) {
  1303. iterator.next();
  1304. }
  1305. if (++iterations > sliceSize) {
  1306. return iteratorDone();
  1307. }
  1308. var step = iterator.next();
  1309. if (useKeys || type === ITERATE_VALUES || step.done) {
  1310. return step;
  1311. }
  1312. if (type === ITERATE_KEYS) {
  1313. return iteratorValue(type, iterations - 1, undefined, step);
  1314. }
  1315. return iteratorValue(type, iterations - 1, step.value[1], step);
  1316. });
  1317. };
  1318. return sliceSeq;
  1319. }
  1320. function takeWhileFactory(collection, predicate, context) {
  1321. var takeSequence = makeSequence(collection);
  1322. takeSequence.__iterateUncached = function (fn, reverse) {
  1323. var this$1$1 = this;
  1324. if (reverse) {
  1325. return this.cacheResult().__iterate(fn, reverse);
  1326. }
  1327. var iterations = 0;
  1328. collection.__iterate(
  1329. function (v, k, c) { return predicate.call(context, v, k, c) && ++iterations && fn(v, k, this$1$1); }
  1330. );
  1331. return iterations;
  1332. };
  1333. takeSequence.__iteratorUncached = function (type, reverse) {
  1334. var this$1$1 = this;
  1335. if (reverse) {
  1336. return this.cacheResult().__iterator(type, reverse);
  1337. }
  1338. var iterator = collection.__iterator(ITERATE_ENTRIES, reverse);
  1339. var iterating = true;
  1340. return new Iterator(function () {
  1341. if (!iterating) {
  1342. return iteratorDone();
  1343. }
  1344. var step = iterator.next();
  1345. if (step.done) {
  1346. return step;
  1347. }
  1348. var entry = step.value;
  1349. var k = entry[0];
  1350. var v = entry[1];
  1351. if (!predicate.call(context, v, k, this$1$1)) {
  1352. iterating = false;
  1353. return iteratorDone();
  1354. }
  1355. return type === ITERATE_ENTRIES ? step : iteratorValue(type, k, v, step);
  1356. });
  1357. };
  1358. return takeSequence;
  1359. }
  1360. function skipWhileFactory(collection, predicate, context, useKeys) {
  1361. var skipSequence = makeSequence(collection);
  1362. skipSequence.__iterateUncached = function (fn, reverse) {
  1363. var this$1$1 = this;
  1364. if (reverse) {
  1365. return this.cacheResult().__iterate(fn, reverse);
  1366. }
  1367. var isSkipping = true;
  1368. var iterations = 0;
  1369. collection.__iterate(function (v, k, c) {
  1370. if (!(isSkipping && (isSkipping = predicate.call(context, v, k, c)))) {
  1371. iterations++;
  1372. return fn(v, useKeys ? k : iterations - 1, this$1$1);
  1373. }
  1374. });
  1375. return iterations;
  1376. };
  1377. skipSequence.__iteratorUncached = function (type, reverse) {
  1378. var this$1$1 = this;
  1379. if (reverse) {
  1380. return this.cacheResult().__iterator(type, reverse);
  1381. }
  1382. var iterator = collection.__iterator(ITERATE_ENTRIES, reverse);
  1383. var skipping = true;
  1384. var iterations = 0;
  1385. return new Iterator(function () {
  1386. var step;
  1387. var k;
  1388. var v;
  1389. do {
  1390. step = iterator.next();
  1391. if (step.done) {
  1392. if (useKeys || type === ITERATE_VALUES) {
  1393. return step;
  1394. }
  1395. if (type === ITERATE_KEYS) {
  1396. return iteratorValue(type, iterations++, undefined, step);
  1397. }
  1398. return iteratorValue(type, iterations++, step.value[1], step);
  1399. }
  1400. var entry = step.value;
  1401. k = entry[0];
  1402. v = entry[1];
  1403. skipping && (skipping = predicate.call(context, v, k, this$1$1));
  1404. } while (skipping);
  1405. return type === ITERATE_ENTRIES ? step : iteratorValue(type, k, v, step);
  1406. });
  1407. };
  1408. return skipSequence;
  1409. }
  1410. function concatFactory(collection, values) {
  1411. var isKeyedCollection = isKeyed(collection);
  1412. var iters = [collection]
  1413. .concat(values)
  1414. .map(function (v) {
  1415. if (!isCollection(v)) {
  1416. v = isKeyedCollection
  1417. ? keyedSeqFromValue(v)
  1418. : indexedSeqFromValue(Array.isArray(v) ? v : [v]);
  1419. } else if (isKeyedCollection) {
  1420. v = KeyedCollection(v);
  1421. }
  1422. return v;
  1423. })
  1424. .filter(function (v) { return v.size !== 0; });
  1425. if (iters.length === 0) {
  1426. return collection;
  1427. }
  1428. if (iters.length === 1) {
  1429. var singleton = iters[0];
  1430. if (
  1431. singleton === collection ||
  1432. (isKeyedCollection && isKeyed(singleton)) ||
  1433. (isIndexed(collection) && isIndexed(singleton))
  1434. ) {
  1435. return singleton;
  1436. }
  1437. }
  1438. var concatSeq = new ArraySeq(iters);
  1439. if (isKeyedCollection) {
  1440. concatSeq = concatSeq.toKeyedSeq();
  1441. } else if (!isIndexed(collection)) {
  1442. concatSeq = concatSeq.toSetSeq();
  1443. }
  1444. concatSeq = concatSeq.flatten(true);
  1445. concatSeq.size = iters.reduce(function (sum, seq) {
  1446. if (sum !== undefined) {
  1447. var size = seq.size;
  1448. if (size !== undefined) {
  1449. return sum + size;
  1450. }
  1451. }
  1452. }, 0);
  1453. return concatSeq;
  1454. }
  1455. function flattenFactory(collection, depth, useKeys) {
  1456. var flatSequence = makeSequence(collection);
  1457. flatSequence.__iterateUncached = function (fn, reverse) {
  1458. if (reverse) {
  1459. return this.cacheResult().__iterate(fn, reverse);
  1460. }
  1461. var iterations = 0;
  1462. var stopped = false;
  1463. function flatDeep(iter, currentDepth) {
  1464. iter.__iterate(function (v, k) {
  1465. if ((!depth || currentDepth < depth) && isCollection(v)) {
  1466. flatDeep(v, currentDepth + 1);
  1467. } else {
  1468. iterations++;
  1469. if (fn(v, useKeys ? k : iterations - 1, flatSequence) === false) {
  1470. stopped = true;
  1471. }
  1472. }
  1473. return !stopped;
  1474. }, reverse);
  1475. }
  1476. flatDeep(collection, 0);
  1477. return iterations;
  1478. };
  1479. flatSequence.__iteratorUncached = function (type, reverse) {
  1480. if (reverse) {
  1481. return this.cacheResult().__iterator(type, reverse);
  1482. }
  1483. var iterator = collection.__iterator(type, reverse);
  1484. var stack = [];
  1485. var iterations = 0;
  1486. return new Iterator(function () {
  1487. while (iterator) {
  1488. var step = iterator.next();
  1489. if (step.done !== false) {
  1490. iterator = stack.pop();
  1491. continue;
  1492. }
  1493. var v = step.value;
  1494. if (type === ITERATE_ENTRIES) {
  1495. v = v[1];
  1496. }
  1497. if ((!depth || stack.length < depth) && isCollection(v)) {
  1498. stack.push(iterator);
  1499. iterator = v.__iterator(type, reverse);
  1500. } else {
  1501. return useKeys ? step : iteratorValue(type, iterations++, v, step);
  1502. }
  1503. }
  1504. return iteratorDone();
  1505. });
  1506. };
  1507. return flatSequence;
  1508. }
  1509. function flatMapFactory(collection, mapper, context) {
  1510. var coerce = collectionClass(collection);
  1511. return collection
  1512. .toSeq()
  1513. .map(function (v, k) { return coerce(mapper.call(context, v, k, collection)); })
  1514. .flatten(true);
  1515. }
  1516. function interposeFactory(collection, separator) {
  1517. var interposedSequence = makeSequence(collection);
  1518. interposedSequence.size = collection.size && collection.size * 2 - 1;
  1519. interposedSequence.__iterateUncached = function (fn, reverse) {
  1520. var this$1$1 = this;
  1521. var iterations = 0;
  1522. collection.__iterate(
  1523. function (v) { return (!iterations || fn(separator, iterations++, this$1$1) !== false) &&
  1524. fn(v, iterations++, this$1$1) !== false; },
  1525. reverse
  1526. );
  1527. return iterations;
  1528. };
  1529. interposedSequence.__iteratorUncached = function (type, reverse) {
  1530. var iterator = collection.__iterator(ITERATE_VALUES, reverse);
  1531. var iterations = 0;
  1532. var step;
  1533. return new Iterator(function () {
  1534. if (!step || iterations % 2) {
  1535. step = iterator.next();
  1536. if (step.done) {
  1537. return step;
  1538. }
  1539. }
  1540. return iterations % 2
  1541. ? iteratorValue(type, iterations++, separator)
  1542. : iteratorValue(type, iterations++, step.value, step);
  1543. });
  1544. };
  1545. return interposedSequence;
  1546. }
  1547. function sortFactory(collection, comparator, mapper) {
  1548. if (!comparator) {
  1549. comparator = defaultComparator;
  1550. }
  1551. var isKeyedCollection = isKeyed(collection);
  1552. var index = 0;
  1553. var entries = collection
  1554. .toSeq()
  1555. .map(function (v, k) { return [k, v, index++, mapper ? mapper(v, k, collection) : v]; })
  1556. .valueSeq()
  1557. .toArray();
  1558. entries
  1559. .sort(function (a, b) { return comparator(a[3], b[3]) || a[2] - b[2]; })
  1560. .forEach(
  1561. isKeyedCollection
  1562. ? function (v, i) {
  1563. entries[i].length = 2;
  1564. }
  1565. : function (v, i) {
  1566. entries[i] = v[1];
  1567. }
  1568. );
  1569. return isKeyedCollection
  1570. ? KeyedSeq(entries)
  1571. : isIndexed(collection)
  1572. ? IndexedSeq(entries)
  1573. : SetSeq(entries);
  1574. }
  1575. function maxFactory(collection, comparator, mapper) {
  1576. if (!comparator) {
  1577. comparator = defaultComparator;
  1578. }
  1579. if (mapper) {
  1580. var entry = collection
  1581. .toSeq()
  1582. .map(function (v, k) { return [v, mapper(v, k, collection)]; })
  1583. .reduce(function (a, b) { return (maxCompare(comparator, a[1], b[1]) ? b : a); });
  1584. return entry && entry[0];
  1585. }
  1586. return collection.reduce(function (a, b) { return (maxCompare(comparator, a, b) ? b : a); });
  1587. }
  1588. function maxCompare(comparator, a, b) {
  1589. var comp = comparator(b, a);
  1590. // b is considered the new max if the comparator declares them equal, but
  1591. // they are not equal and b is in fact a nullish value.
  1592. return (
  1593. (comp === 0 && b !== a && (b === undefined || b === null || b !== b)) ||
  1594. comp > 0
  1595. );
  1596. }
  1597. function zipWithFactory(keyIter, zipper, iters, zipAll) {
  1598. var zipSequence = makeSequence(keyIter);
  1599. var sizes = new ArraySeq(iters).map(function (i) { return i.size; });
  1600. zipSequence.size = zipAll ? sizes.max() : sizes.min();
  1601. // Note: this a generic base implementation of __iterate in terms of
  1602. // __iterator which may be more generically useful in the future.
  1603. zipSequence.__iterate = function (fn, reverse) {
  1604. /* generic:
  1605. var iterator = this.__iterator(ITERATE_ENTRIES, reverse);
  1606. var step;
  1607. var iterations = 0;
  1608. while (!(step = iterator.next()).done) {
  1609. iterations++;
  1610. if (fn(step.value[1], step.value[0], this) === false) {
  1611. break;
  1612. }
  1613. }
  1614. return iterations;
  1615. */
  1616. // indexed:
  1617. var iterator = this.__iterator(ITERATE_VALUES, reverse);
  1618. var step;
  1619. var iterations = 0;
  1620. while (!(step = iterator.next()).done) {
  1621. if (fn(step.value, iterations++, this) === false) {
  1622. break;
  1623. }
  1624. }
  1625. return iterations;
  1626. };
  1627. zipSequence.__iteratorUncached = function (type, reverse) {
  1628. var iterators = iters.map(
  1629. function (i) { return ((i = Collection(i)), getIterator(reverse ? i.reverse() : i)); }
  1630. );
  1631. var iterations = 0;
  1632. var isDone = false;
  1633. return new Iterator(function () {
  1634. var steps;
  1635. if (!isDone) {
  1636. steps = iterators.map(function (i) { return i.next(); });
  1637. isDone = zipAll ? steps.every(function (s) { return s.done; }) : steps.some(function (s) { return s.done; });
  1638. }
  1639. if (isDone) {
  1640. return iteratorDone();
  1641. }
  1642. return iteratorValue(
  1643. type,
  1644. iterations++,
  1645. zipper.apply(
  1646. null,
  1647. steps.map(function (s) { return s.value; })
  1648. )
  1649. );
  1650. });
  1651. };
  1652. return zipSequence;
  1653. }
  1654. // #pragma Helper Functions
  1655. function reify(iter, seq) {
  1656. return iter === seq ? iter : isSeq(iter) ? seq : iter.constructor(seq);
  1657. }
  1658. function validateEntry(entry) {
  1659. if (entry !== Object(entry)) {
  1660. throw new TypeError('Expected [K, V] tuple: ' + entry);
  1661. }
  1662. }
  1663. function collectionClass(collection) {
  1664. return isKeyed(collection)
  1665. ? KeyedCollection
  1666. : isIndexed(collection)
  1667. ? IndexedCollection
  1668. : SetCollection;
  1669. }
  1670. function makeSequence(collection) {
  1671. return Object.create(
  1672. (isKeyed(collection)
  1673. ? KeyedSeq
  1674. : isIndexed(collection)
  1675. ? IndexedSeq
  1676. : SetSeq
  1677. ).prototype
  1678. );
  1679. }
  1680. function cacheResultThrough() {
  1681. if (this._iter.cacheResult) {
  1682. this._iter.cacheResult();
  1683. this.size = this._iter.size;
  1684. return this;
  1685. }
  1686. return Seq.prototype.cacheResult.call(this);
  1687. }
  1688. function defaultComparator(a, b) {
  1689. if (a === undefined && b === undefined) {
  1690. return 0;
  1691. }
  1692. if (a === undefined) {
  1693. return 1;
  1694. }
  1695. if (b === undefined) {
  1696. return -1;
  1697. }
  1698. return a > b ? 1 : a < b ? -1 : 0;
  1699. }
  1700. function arrCopy(arr, offset) {
  1701. offset = offset || 0;
  1702. var len = Math.max(0, arr.length - offset);
  1703. var newArr = new Array(len);
  1704. for (var ii = 0; ii < len; ii++) {
  1705. newArr[ii] = arr[ii + offset];
  1706. }
  1707. return newArr;
  1708. }
  1709. function invariant(condition, error) {
  1710. if (!condition) { throw new Error(error); }
  1711. }
  1712. function assertNotInfinite(size) {
  1713. invariant(
  1714. size !== Infinity,
  1715. 'Cannot perform this action with an infinite size.'
  1716. );
  1717. }
  1718. function coerceKeyPath(keyPath) {
  1719. if (isArrayLike(keyPath) && typeof keyPath !== 'string') {
  1720. return keyPath;
  1721. }
  1722. if (isOrdered(keyPath)) {
  1723. return keyPath.toArray();
  1724. }
  1725. throw new TypeError(
  1726. 'Invalid keyPath: expected Ordered Collection or Array: ' + keyPath
  1727. );
  1728. }
  1729. var toString = Object.prototype.toString;
  1730. function isPlainObject(value) {
  1731. // The base prototype's toString deals with Argument objects and native namespaces like Math
  1732. if (
  1733. !value ||
  1734. typeof value !== 'object' ||
  1735. toString.call(value) !== '[object Object]'
  1736. ) {
  1737. return false;
  1738. }
  1739. var proto = Object.getPrototypeOf(value);
  1740. if (proto === null) {
  1741. return true;
  1742. }
  1743. // Iteratively going up the prototype chain is needed for cross-realm environments (differing contexts, iframes, etc)
  1744. var parentProto = proto;
  1745. var nextProto = Object.getPrototypeOf(proto);
  1746. while (nextProto !== null) {
  1747. parentProto = nextProto;
  1748. nextProto = Object.getPrototypeOf(parentProto);
  1749. }
  1750. return parentProto === proto;
  1751. }
  1752. /**
  1753. * Returns true if the value is a potentially-persistent data structure, either
  1754. * provided by Immutable.js or a plain Array or Object.
  1755. */
  1756. function isDataStructure(value) {
  1757. return (
  1758. typeof value === 'object' &&
  1759. (isImmutable(value) || Array.isArray(value) || isPlainObject(value))
  1760. );
  1761. }
  1762. function quoteString(value) {
  1763. try {
  1764. return typeof value === 'string' ? JSON.stringify(value) : String(value);
  1765. } catch (_ignoreError) {
  1766. return JSON.stringify(value);
  1767. }
  1768. }
  1769. function has(collection, key) {
  1770. return isImmutable(collection)
  1771. ? collection.has(key)
  1772. : isDataStructure(collection) && hasOwnProperty.call(collection, key);
  1773. }
  1774. function get(collection, key, notSetValue) {
  1775. return isImmutable(collection)
  1776. ? collection.get(key, notSetValue)
  1777. : !has(collection, key)
  1778. ? notSetValue
  1779. : typeof collection.get === 'function'
  1780. ? collection.get(key)
  1781. : collection[key];
  1782. }
  1783. function shallowCopy(from) {
  1784. if (Array.isArray(from)) {
  1785. return arrCopy(from);
  1786. }
  1787. var to = {};
  1788. for (var key in from) {
  1789. if (hasOwnProperty.call(from, key)) {
  1790. to[key] = from[key];
  1791. }
  1792. }
  1793. return to;
  1794. }
  1795. function remove(collection, key) {
  1796. if (!isDataStructure(collection)) {
  1797. throw new TypeError(
  1798. 'Cannot update non-data-structure value: ' + collection
  1799. );
  1800. }
  1801. if (isImmutable(collection)) {
  1802. if (!collection.remove) {
  1803. throw new TypeError(
  1804. 'Cannot update immutable value without .remove() method: ' + collection
  1805. );
  1806. }
  1807. return collection.remove(key);
  1808. }
  1809. if (!hasOwnProperty.call(collection, key)) {
  1810. return collection;
  1811. }
  1812. var collectionCopy = shallowCopy(collection);
  1813. if (Array.isArray(collectionCopy)) {
  1814. collectionCopy.splice(key, 1);
  1815. } else {
  1816. delete collectionCopy[key];
  1817. }
  1818. return collectionCopy;
  1819. }
  1820. function set(collection, key, value) {
  1821. if (!isDataStructure(collection)) {
  1822. throw new TypeError(
  1823. 'Cannot update non-data-structure value: ' + collection
  1824. );
  1825. }
  1826. if (isImmutable(collection)) {
  1827. if (!collection.set) {
  1828. throw new TypeError(
  1829. 'Cannot update immutable value without .set() method: ' + collection
  1830. );
  1831. }
  1832. return collection.set(key, value);
  1833. }
  1834. if (hasOwnProperty.call(collection, key) && value === collection[key]) {
  1835. return collection;
  1836. }
  1837. var collectionCopy = shallowCopy(collection);
  1838. collectionCopy[key] = value;
  1839. return collectionCopy;
  1840. }
  1841. function updateIn$1(collection, keyPath, notSetValue, updater) {
  1842. if (!updater) {
  1843. updater = notSetValue;
  1844. notSetValue = undefined;
  1845. }
  1846. var updatedValue = updateInDeeply(
  1847. isImmutable(collection),
  1848. collection,
  1849. coerceKeyPath(keyPath),
  1850. 0,
  1851. notSetValue,
  1852. updater
  1853. );
  1854. return updatedValue === NOT_SET ? notSetValue : updatedValue;
  1855. }
  1856. function updateInDeeply(
  1857. inImmutable,
  1858. existing,
  1859. keyPath,
  1860. i,
  1861. notSetValue,
  1862. updater
  1863. ) {
  1864. var wasNotSet = existing === NOT_SET;
  1865. if (i === keyPath.length) {
  1866. var existingValue = wasNotSet ? notSetValue : existing;
  1867. var newValue = updater(existingValue);
  1868. return newValue === existingValue ? existing : newValue;
  1869. }
  1870. if (!wasNotSet && !isDataStructure(existing)) {
  1871. throw new TypeError(
  1872. 'Cannot update within non-data-structure value in path [' +
  1873. keyPath.slice(0, i).map(quoteString) +
  1874. ']: ' +
  1875. existing
  1876. );
  1877. }
  1878. var key = keyPath[i];
  1879. var nextExisting = wasNotSet ? NOT_SET : get(existing, key, NOT_SET);
  1880. var nextUpdated = updateInDeeply(
  1881. nextExisting === NOT_SET ? inImmutable : isImmutable(nextExisting),
  1882. nextExisting,
  1883. keyPath,
  1884. i + 1,
  1885. notSetValue,
  1886. updater
  1887. );
  1888. return nextUpdated === nextExisting
  1889. ? existing
  1890. : nextUpdated === NOT_SET
  1891. ? remove(existing, key)
  1892. : set(
  1893. wasNotSet ? (inImmutable ? emptyMap() : {}) : existing,
  1894. key,
  1895. nextUpdated
  1896. );
  1897. }
  1898. function setIn$1(collection, keyPath, value) {
  1899. return updateIn$1(collection, keyPath, NOT_SET, function () { return value; });
  1900. }
  1901. function setIn(keyPath, v) {
  1902. return setIn$1(this, keyPath, v);
  1903. }
  1904. function removeIn(collection, keyPath) {
  1905. return updateIn$1(collection, keyPath, function () { return NOT_SET; });
  1906. }
  1907. function deleteIn(keyPath) {
  1908. return removeIn(this, keyPath);
  1909. }
  1910. function update$1(collection, key, notSetValue, updater) {
  1911. return updateIn$1(collection, [key], notSetValue, updater);
  1912. }
  1913. function update(key, notSetValue, updater) {
  1914. return arguments.length === 1
  1915. ? key(this)
  1916. : update$1(this, key, notSetValue, updater);
  1917. }
  1918. function updateIn(keyPath, notSetValue, updater) {
  1919. return updateIn$1(this, keyPath, notSetValue, updater);
  1920. }
  1921. function merge$1() {
  1922. var iters = [], len = arguments.length;
  1923. while ( len-- ) iters[ len ] = arguments[ len ];
  1924. return mergeIntoKeyedWith(this, iters);
  1925. }
  1926. function mergeWith$1(merger) {
  1927. var iters = [], len = arguments.length - 1;
  1928. while ( len-- > 0 ) iters[ len ] = arguments[ len + 1 ];
  1929. if (typeof merger !== 'function') {
  1930. throw new TypeError('Invalid merger function: ' + merger);
  1931. }
  1932. return mergeIntoKeyedWith(this, iters, merger);
  1933. }
  1934. function mergeIntoKeyedWith(collection, collections, merger) {
  1935. var iters = [];
  1936. for (var ii = 0; ii < collections.length; ii++) {
  1937. var collection$1 = KeyedCollection(collections[ii]);
  1938. if (collection$1.size !== 0) {
  1939. iters.push(collection$1);
  1940. }
  1941. }
  1942. if (iters.length === 0) {
  1943. return collection;
  1944. }
  1945. if (
  1946. collection.toSeq().size === 0 &&
  1947. !collection.__ownerID &&
  1948. iters.length === 1
  1949. ) {
  1950. return collection.constructor(iters[0]);
  1951. }
  1952. return collection.withMutations(function (collection) {
  1953. var mergeIntoCollection = merger
  1954. ? function (value, key) {
  1955. update$1(collection, key, NOT_SET, function (oldVal) { return oldVal === NOT_SET ? value : merger(oldVal, value, key); }
  1956. );
  1957. }
  1958. : function (value, key) {
  1959. collection.set(key, value);
  1960. };
  1961. for (var ii = 0; ii < iters.length; ii++) {
  1962. iters[ii].forEach(mergeIntoCollection);
  1963. }
  1964. });
  1965. }
  1966. function merge(collection) {
  1967. var sources = [], len = arguments.length - 1;
  1968. while ( len-- > 0 ) sources[ len ] = arguments[ len + 1 ];
  1969. return mergeWithSources(collection, sources);
  1970. }
  1971. function mergeWith(merger, collection) {
  1972. var sources = [], len = arguments.length - 2;
  1973. while ( len-- > 0 ) sources[ len ] = arguments[ len + 2 ];
  1974. return mergeWithSources(collection, sources, merger);
  1975. }
  1976. function mergeDeep$1(collection) {
  1977. var sources = [], len = arguments.length - 1;
  1978. while ( len-- > 0 ) sources[ len ] = arguments[ len + 1 ];
  1979. return mergeDeepWithSources(collection, sources);
  1980. }
  1981. function mergeDeepWith$1(merger, collection) {
  1982. var sources = [], len = arguments.length - 2;
  1983. while ( len-- > 0 ) sources[ len ] = arguments[ len + 2 ];
  1984. return mergeDeepWithSources(collection, sources, merger);
  1985. }
  1986. function mergeDeepWithSources(collection, sources, merger) {
  1987. return mergeWithSources(collection, sources, deepMergerWith(merger));
  1988. }
  1989. function mergeWithSources(collection, sources, merger) {
  1990. if (!isDataStructure(collection)) {
  1991. throw new TypeError(
  1992. 'Cannot merge into non-data-structure value: ' + collection
  1993. );
  1994. }
  1995. if (isImmutable(collection)) {
  1996. return typeof merger === 'function' && collection.mergeWith
  1997. ? collection.mergeWith.apply(collection, [ merger ].concat( sources ))
  1998. : collection.merge
  1999. ? collection.merge.apply(collection, sources)
  2000. : collection.concat.apply(collection, sources);
  2001. }
  2002. var isArray = Array.isArray(collection);
  2003. var merged = collection;
  2004. var Collection = isArray ? IndexedCollection : KeyedCollection;
  2005. var mergeItem = isArray
  2006. ? function (value) {
  2007. // Copy on write
  2008. if (merged === collection) {
  2009. merged = shallowCopy(merged);
  2010. }
  2011. merged.push(value);
  2012. }
  2013. : function (value, key) {
  2014. var hasVal = hasOwnProperty.call(merged, key);
  2015. var nextVal =
  2016. hasVal && merger ? merger(merged[key], value, key) : value;
  2017. if (!hasVal || nextVal !== merged[key]) {
  2018. // Copy on write
  2019. if (merged === collection) {
  2020. merged = shallowCopy(merged);
  2021. }
  2022. merged[key] = nextVal;
  2023. }
  2024. };
  2025. for (var i = 0; i < sources.length; i++) {
  2026. Collection(sources[i]).forEach(mergeItem);
  2027. }
  2028. return merged;
  2029. }
  2030. function deepMergerWith(merger) {
  2031. function deepMerger(oldValue, newValue, key) {
  2032. return isDataStructure(oldValue) &&
  2033. isDataStructure(newValue) &&
  2034. areMergeable(oldValue, newValue)
  2035. ? mergeWithSources(oldValue, [newValue], deepMerger)
  2036. : merger
  2037. ? merger(oldValue, newValue, key)
  2038. : newValue;
  2039. }
  2040. return deepMerger;
  2041. }
  2042. /**
  2043. * It's unclear what the desired behavior is for merging two collections that
  2044. * fall into separate categories between keyed, indexed, or set-like, so we only
  2045. * consider them mergeable if they fall into the same category.
  2046. */
  2047. function areMergeable(oldDataStructure, newDataStructure) {
  2048. var oldSeq = Seq(oldDataStructure);
  2049. var newSeq = Seq(newDataStructure);
  2050. // This logic assumes that a sequence can only fall into one of the three
  2051. // categories mentioned above (since there's no `isSetLike()` method).
  2052. return (
  2053. isIndexed(oldSeq) === isIndexed(newSeq) &&
  2054. isKeyed(oldSeq) === isKeyed(newSeq)
  2055. );
  2056. }
  2057. function mergeDeep() {
  2058. var iters = [], len = arguments.length;
  2059. while ( len-- ) iters[ len ] = arguments[ len ];
  2060. return mergeDeepWithSources(this, iters);
  2061. }
  2062. function mergeDeepWith(merger) {
  2063. var iters = [], len = arguments.length - 1;
  2064. while ( len-- > 0 ) iters[ len ] = arguments[ len + 1 ];
  2065. return mergeDeepWithSources(this, iters, merger);
  2066. }
  2067. function mergeIn(keyPath) {
  2068. var iters = [], len = arguments.length - 1;
  2069. while ( len-- > 0 ) iters[ len ] = arguments[ len + 1 ];
  2070. return updateIn$1(this, keyPath, emptyMap(), function (m) { return mergeWithSources(m, iters); });
  2071. }
  2072. function mergeDeepIn(keyPath) {
  2073. var iters = [], len = arguments.length - 1;
  2074. while ( len-- > 0 ) iters[ len ] = arguments[ len + 1 ];
  2075. return updateIn$1(this, keyPath, emptyMap(), function (m) { return mergeDeepWithSources(m, iters); }
  2076. );
  2077. }
  2078. function withMutations(fn) {
  2079. var mutable = this.asMutable();
  2080. fn(mutable);
  2081. return mutable.wasAltered() ? mutable.__ensureOwner(this.__ownerID) : this;
  2082. }
  2083. function asMutable() {
  2084. return this.__ownerID ? this : this.__ensureOwner(new OwnerID());
  2085. }
  2086. function asImmutable() {
  2087. return this.__ensureOwner();
  2088. }
  2089. function wasAltered() {
  2090. return this.__altered;
  2091. }
  2092. var Map = /*@__PURE__*/(function (KeyedCollection) {
  2093. function Map(value) {
  2094. return value === undefined || value === null
  2095. ? emptyMap()
  2096. : isMap(value) && !isOrdered(value)
  2097. ? value
  2098. : emptyMap().withMutations(function (map) {
  2099. var iter = KeyedCollection(value);
  2100. assertNotInfinite(iter.size);
  2101. iter.forEach(function (v, k) { return map.set(k, v); });
  2102. });
  2103. }
  2104. if ( KeyedCollection ) Map.__proto__ = KeyedCollection;
  2105. Map.prototype = Object.create( KeyedCollection && KeyedCollection.prototype );
  2106. Map.prototype.constructor = Map;
  2107. Map.of = function of () {
  2108. var keyValues = [], len = arguments.length;
  2109. while ( len-- ) keyValues[ len ] = arguments[ len ];
  2110. return emptyMap().withMutations(function (map) {
  2111. for (var i = 0; i < keyValues.length; i += 2) {
  2112. if (i + 1 >= keyValues.length) {
  2113. throw new Error('Missing value for key: ' + keyValues[i]);
  2114. }
  2115. map.set(keyValues[i], keyValues[i + 1]);
  2116. }
  2117. });
  2118. };
  2119. Map.prototype.toString = function toString () {
  2120. return this.__toString('Map {', '}');
  2121. };
  2122. // @pragma Access
  2123. Map.prototype.get = function get (k, notSetValue) {
  2124. return this._root
  2125. ? this._root.get(0, undefined, k, notSetValue)
  2126. : notSetValue;
  2127. };
  2128. // @pragma Modification
  2129. Map.prototype.set = function set (k, v) {
  2130. return updateMap(this, k, v);
  2131. };
  2132. Map.prototype.remove = function remove (k) {
  2133. return updateMap(this, k, NOT_SET);
  2134. };
  2135. Map.prototype.deleteAll = function deleteAll (keys) {
  2136. var collection = Collection(keys);
  2137. if (collection.size === 0) {
  2138. return this;
  2139. }
  2140. return this.withMutations(function (map) {
  2141. collection.forEach(function (key) { return map.remove(key); });
  2142. });
  2143. };
  2144. Map.prototype.clear = function clear () {
  2145. if (this.size === 0) {
  2146. return this;
  2147. }
  2148. if (this.__ownerID) {
  2149. this.size = 0;
  2150. this._root = null;
  2151. this.__hash = undefined;
  2152. this.__altered = true;
  2153. return this;
  2154. }
  2155. return emptyMap();
  2156. };
  2157. // @pragma Composition
  2158. Map.prototype.sort = function sort (comparator) {
  2159. // Late binding
  2160. return OrderedMap(sortFactory(this, comparator));
  2161. };
  2162. Map.prototype.sortBy = function sortBy (mapper, comparator) {
  2163. // Late binding
  2164. return OrderedMap(sortFactory(this, comparator, mapper));
  2165. };
  2166. Map.prototype.map = function map (mapper, context) {
  2167. var this$1$1 = this;
  2168. return this.withMutations(function (map) {
  2169. map.forEach(function (value, key) {
  2170. map.set(key, mapper.call(context, value, key, this$1$1));
  2171. });
  2172. });
  2173. };
  2174. // @pragma Mutability
  2175. Map.prototype.__iterator = function __iterator (type, reverse) {
  2176. return new MapIterator(this, type, reverse);
  2177. };
  2178. Map.prototype.__iterate = function __iterate (fn, reverse) {
  2179. var this$1$1 = this;
  2180. var iterations = 0;
  2181. this._root &&
  2182. this._root.iterate(function (entry) {
  2183. iterations++;
  2184. return fn(entry[1], entry[0], this$1$1);
  2185. }, reverse);
  2186. return iterations;
  2187. };
  2188. Map.prototype.__ensureOwner = function __ensureOwner (ownerID) {
  2189. if (ownerID === this.__ownerID) {
  2190. return this;
  2191. }
  2192. if (!ownerID) {
  2193. if (this.size === 0) {
  2194. return emptyMap();
  2195. }
  2196. this.__ownerID = ownerID;
  2197. this.__altered = false;
  2198. return this;
  2199. }
  2200. return makeMap(this.size, this._root, ownerID, this.__hash);
  2201. };
  2202. return Map;
  2203. }(KeyedCollection));
  2204. Map.isMap = isMap;
  2205. var MapPrototype = Map.prototype;
  2206. MapPrototype[IS_MAP_SYMBOL] = true;
  2207. MapPrototype[DELETE] = MapPrototype.remove;
  2208. MapPrototype.removeAll = MapPrototype.deleteAll;
  2209. MapPrototype.setIn = setIn;
  2210. MapPrototype.removeIn = MapPrototype.deleteIn = deleteIn;
  2211. MapPrototype.update = update;
  2212. MapPrototype.updateIn = updateIn;
  2213. MapPrototype.merge = MapPrototype.concat = merge$1;
  2214. MapPrototype.mergeWith = mergeWith$1;
  2215. MapPrototype.mergeDeep = mergeDeep;
  2216. MapPrototype.mergeDeepWith = mergeDeepWith;
  2217. MapPrototype.mergeIn = mergeIn;
  2218. MapPrototype.mergeDeepIn = mergeDeepIn;
  2219. MapPrototype.withMutations = withMutations;
  2220. MapPrototype.wasAltered = wasAltered;
  2221. MapPrototype.asImmutable = asImmutable;
  2222. MapPrototype['@@transducer/init'] = MapPrototype.asMutable = asMutable;
  2223. MapPrototype['@@transducer/step'] = function (result, arr) {
  2224. return result.set(arr[0], arr[1]);
  2225. };
  2226. MapPrototype['@@transducer/result'] = function (obj) {
  2227. return obj.asImmutable();
  2228. };
  2229. // #pragma Trie Nodes
  2230. var ArrayMapNode = function ArrayMapNode(ownerID, entries) {
  2231. this.ownerID = ownerID;
  2232. this.entries = entries;
  2233. };
  2234. ArrayMapNode.prototype.get = function get (shift, keyHash, key, notSetValue) {
  2235. var entries = this.entries;
  2236. for (var ii = 0, len = entries.length; ii < len; ii++) {
  2237. if (is(key, entries[ii][0])) {
  2238. return entries[ii][1];
  2239. }
  2240. }
  2241. return notSetValue;
  2242. };
  2243. ArrayMapNode.prototype.update = function update (ownerID, shift, keyHash, key, value, didChangeSize, didAlter) {
  2244. var removed = value === NOT_SET;
  2245. var entries = this.entries;
  2246. var idx = 0;
  2247. var len = entries.length;
  2248. for (; idx < len; idx++) {
  2249. if (is(key, entries[idx][0])) {
  2250. break;
  2251. }
  2252. }
  2253. var exists = idx < len;
  2254. if (exists ? entries[idx][1] === value : removed) {
  2255. return this;
  2256. }
  2257. SetRef(didAlter);
  2258. (removed || !exists) && SetRef(didChangeSize);
  2259. if (removed && entries.length === 1) {
  2260. return; // undefined
  2261. }
  2262. if (!exists && !removed && entries.length >= MAX_ARRAY_MAP_SIZE) {
  2263. return createNodes(ownerID, entries, key, value);
  2264. }
  2265. var isEditable = ownerID && ownerID === this.ownerID;
  2266. var newEntries = isEditable ? entries : arrCopy(entries);
  2267. if (exists) {
  2268. if (removed) {
  2269. idx === len - 1
  2270. ? newEntries.pop()
  2271. : (newEntries[idx] = newEntries.pop());
  2272. } else {
  2273. newEntries[idx] = [key, value];
  2274. }
  2275. } else {
  2276. newEntries.push([key, value]);
  2277. }
  2278. if (isEditable) {
  2279. this.entries = newEntries;
  2280. return this;
  2281. }
  2282. return new ArrayMapNode(ownerID, newEntries);
  2283. };
  2284. var BitmapIndexedNode = function BitmapIndexedNode(ownerID, bitmap, nodes) {
  2285. this.ownerID = ownerID;
  2286. this.bitmap = bitmap;
  2287. this.nodes = nodes;
  2288. };
  2289. BitmapIndexedNode.prototype.get = function get (shift, keyHash, key, notSetValue) {
  2290. if (keyHash === undefined) {
  2291. keyHash = hash(key);
  2292. }
  2293. var bit = 1 << ((shift === 0 ? keyHash : keyHash >>> shift) & MASK);
  2294. var bitmap = this.bitmap;
  2295. return (bitmap & bit) === 0
  2296. ? notSetValue
  2297. : this.nodes[popCount(bitmap & (bit - 1))].get(
  2298. shift + SHIFT,
  2299. keyHash,
  2300. key,
  2301. notSetValue
  2302. );
  2303. };
  2304. BitmapIndexedNode.prototype.update = function update (ownerID, shift, keyHash, key, value, didChangeSize, didAlter) {
  2305. if (keyHash === undefined) {
  2306. keyHash = hash(key);
  2307. }
  2308. var keyHashFrag = (shift === 0 ? keyHash : keyHash >>> shift) & MASK;
  2309. var bit = 1 << keyHashFrag;
  2310. var bitmap = this.bitmap;
  2311. var exists = (bitmap & bit) !== 0;
  2312. if (!exists && value === NOT_SET) {
  2313. return this;
  2314. }
  2315. var idx = popCount(bitmap & (bit - 1));
  2316. var nodes = this.nodes;
  2317. var node = exists ? nodes[idx] : undefined;
  2318. var newNode = updateNode(
  2319. node,
  2320. ownerID,
  2321. shift + SHIFT,
  2322. keyHash,
  2323. key,
  2324. value,
  2325. didChangeSize,
  2326. didAlter
  2327. );
  2328. if (newNode === node) {
  2329. return this;
  2330. }
  2331. if (!exists && newNode && nodes.length >= MAX_BITMAP_INDEXED_SIZE) {
  2332. return expandNodes(ownerID, nodes, bitmap, keyHashFrag, newNode);
  2333. }
  2334. if (
  2335. exists &&
  2336. !newNode &&
  2337. nodes.length === 2 &&
  2338. isLeafNode(nodes[idx ^ 1])
  2339. ) {
  2340. return nodes[idx ^ 1];
  2341. }
  2342. if (exists && newNode && nodes.length === 1 && isLeafNode(newNode)) {
  2343. return newNode;
  2344. }
  2345. var isEditable = ownerID && ownerID === this.ownerID;
  2346. var newBitmap = exists ? (newNode ? bitmap : bitmap ^ bit) : bitmap | bit;
  2347. var newNodes = exists
  2348. ? newNode
  2349. ? setAt(nodes, idx, newNode, isEditable)
  2350. : spliceOut(nodes, idx, isEditable)
  2351. : spliceIn(nodes, idx, newNode, isEditable);
  2352. if (isEditable) {
  2353. this.bitmap = newBitmap;
  2354. this.nodes = newNodes;
  2355. return this;
  2356. }
  2357. return new BitmapIndexedNode(ownerID, newBitmap, newNodes);
  2358. };
  2359. var HashArrayMapNode = function HashArrayMapNode(ownerID, count, nodes) {
  2360. this.ownerID = ownerID;
  2361. this.count = count;
  2362. this.nodes = nodes;
  2363. };
  2364. HashArrayMapNode.prototype.get = function get (shift, keyHash, key, notSetValue) {
  2365. if (keyHash === undefined) {
  2366. keyHash = hash(key);
  2367. }
  2368. var idx = (shift === 0 ? keyHash : keyHash >>> shift) & MASK;
  2369. var node = this.nodes[idx];
  2370. return node
  2371. ? node.get(shift + SHIFT, keyHash, key, notSetValue)
  2372. : notSetValue;
  2373. };
  2374. HashArrayMapNode.prototype.update = function update (ownerID, shift, keyHash, key, value, didChangeSize, didAlter) {
  2375. if (keyHash === undefined) {
  2376. keyHash = hash(key);
  2377. }
  2378. var idx = (shift === 0 ? keyHash : keyHash >>> shift) & MASK;
  2379. var removed = value === NOT_SET;
  2380. var nodes = this.nodes;
  2381. var node = nodes[idx];
  2382. if (removed && !node) {
  2383. return this;
  2384. }
  2385. var newNode = updateNode(
  2386. node,
  2387. ownerID,
  2388. shift + SHIFT,
  2389. keyHash,
  2390. key,
  2391. value,
  2392. didChangeSize,
  2393. didAlter
  2394. );
  2395. if (newNode === node) {
  2396. return this;
  2397. }
  2398. var newCount = this.count;
  2399. if (!node) {
  2400. newCount++;
  2401. } else if (!newNode) {
  2402. newCount--;
  2403. if (newCount < MIN_HASH_ARRAY_MAP_SIZE) {
  2404. return packNodes(ownerID, nodes, newCount, idx);
  2405. }
  2406. }
  2407. var isEditable = ownerID && ownerID === this.ownerID;
  2408. var newNodes = setAt(nodes, idx, newNode, isEditable);
  2409. if (isEditable) {
  2410. this.count = newCount;
  2411. this.nodes = newNodes;
  2412. return this;
  2413. }
  2414. return new HashArrayMapNode(ownerID, newCount, newNodes);
  2415. };
  2416. var HashCollisionNode = function HashCollisionNode(ownerID, keyHash, entries) {
  2417. this.ownerID = ownerID;
  2418. this.keyHash = keyHash;
  2419. this.entries = entries;
  2420. };
  2421. HashCollisionNode.prototype.get = function get (shift, keyHash, key, notSetValue) {
  2422. var entries = this.entries;
  2423. for (var ii = 0, len = entries.length; ii < len; ii++) {
  2424. if (is(key, entries[ii][0])) {
  2425. return entries[ii][1];
  2426. }
  2427. }
  2428. return notSetValue;
  2429. };
  2430. HashCollisionNode.prototype.update = function update (ownerID, shift, keyHash, key, value, didChangeSize, didAlter) {
  2431. if (keyHash === undefined) {
  2432. keyHash = hash(key);
  2433. }
  2434. var removed = value === NOT_SET;
  2435. if (keyHash !== this.keyHash) {
  2436. if (removed) {
  2437. return this;
  2438. }
  2439. SetRef(didAlter);
  2440. SetRef(didChangeSize);
  2441. return mergeIntoNode(this, ownerID, shift, keyHash, [key, value]);
  2442. }
  2443. var entries = this.entries;
  2444. var idx = 0;
  2445. var len = entries.length;
  2446. for (; idx < len; idx++) {
  2447. if (is(key, entries[idx][0])) {
  2448. break;
  2449. }
  2450. }
  2451. var exists = idx < len;
  2452. if (exists ? entries[idx][1] === value : removed) {
  2453. return this;
  2454. }
  2455. SetRef(didAlter);
  2456. (removed || !exists) && SetRef(didChangeSize);
  2457. if (removed && len === 2) {
  2458. return new ValueNode(ownerID, this.keyHash, entries[idx ^ 1]);
  2459. }
  2460. var isEditable = ownerID && ownerID === this.ownerID;
  2461. var newEntries = isEditable ? entries : arrCopy(entries);
  2462. if (exists) {
  2463. if (removed) {
  2464. idx === len - 1
  2465. ? newEntries.pop()
  2466. : (newEntries[idx] = newEntries.pop());
  2467. } else {
  2468. newEntries[idx] = [key, value];
  2469. }
  2470. } else {
  2471. newEntries.push([key, value]);
  2472. }
  2473. if (isEditable) {
  2474. this.entries = newEntries;
  2475. return this;
  2476. }
  2477. return new HashCollisionNode(ownerID, this.keyHash, newEntries);
  2478. };
  2479. var ValueNode = function ValueNode(ownerID, keyHash, entry) {
  2480. this.ownerID = ownerID;
  2481. this.keyHash = keyHash;
  2482. this.entry = entry;
  2483. };
  2484. ValueNode.prototype.get = function get (shift, keyHash, key, notSetValue) {
  2485. return is(key, this.entry[0]) ? this.entry[1] : notSetValue;
  2486. };
  2487. ValueNode.prototype.update = function update (ownerID, shift, keyHash, key, value, didChangeSize, didAlter) {
  2488. var removed = value === NOT_SET;
  2489. var keyMatch = is(key, this.entry[0]);
  2490. if (keyMatch ? value === this.entry[1] : removed) {
  2491. return this;
  2492. }
  2493. SetRef(didAlter);
  2494. if (removed) {
  2495. SetRef(didChangeSize);
  2496. return; // undefined
  2497. }
  2498. if (keyMatch) {
  2499. if (ownerID && ownerID === this.ownerID) {
  2500. this.entry[1] = value;
  2501. return this;
  2502. }
  2503. return new ValueNode(ownerID, this.keyHash, [key, value]);
  2504. }
  2505. SetRef(didChangeSize);
  2506. return mergeIntoNode(this, ownerID, shift, hash(key), [key, value]);
  2507. };
  2508. // #pragma Iterators
  2509. ArrayMapNode.prototype.iterate = HashCollisionNode.prototype.iterate =
  2510. function (fn, reverse) {
  2511. var entries = this.entries;
  2512. for (var ii = 0, maxIndex = entries.length - 1; ii <= maxIndex; ii++) {
  2513. if (fn(entries[reverse ? maxIndex - ii : ii]) === false) {
  2514. return false;
  2515. }
  2516. }
  2517. };
  2518. BitmapIndexedNode.prototype.iterate = HashArrayMapNode.prototype.iterate =
  2519. function (fn, reverse) {
  2520. var nodes = this.nodes;
  2521. for (var ii = 0, maxIndex = nodes.length - 1; ii <= maxIndex; ii++) {
  2522. var node = nodes[reverse ? maxIndex - ii : ii];
  2523. if (node && node.iterate(fn, reverse) === false) {
  2524. return false;
  2525. }
  2526. }
  2527. };
  2528. // eslint-disable-next-line no-unused-vars
  2529. ValueNode.prototype.iterate = function (fn, reverse) {
  2530. return fn(this.entry);
  2531. };
  2532. var MapIterator = /*@__PURE__*/(function (Iterator) {
  2533. function MapIterator(map, type, reverse) {
  2534. this._type = type;
  2535. this._reverse = reverse;
  2536. this._stack = map._root && mapIteratorFrame(map._root);
  2537. }
  2538. if ( Iterator ) MapIterator.__proto__ = Iterator;
  2539. MapIterator.prototype = Object.create( Iterator && Iterator.prototype );
  2540. MapIterator.prototype.constructor = MapIterator;
  2541. MapIterator.prototype.next = function next () {
  2542. var type = this._type;
  2543. var stack = this._stack;
  2544. while (stack) {
  2545. var node = stack.node;
  2546. var index = stack.index++;
  2547. var maxIndex = (void 0);
  2548. if (node.entry) {
  2549. if (index === 0) {
  2550. return mapIteratorValue(type, node.entry);
  2551. }
  2552. } else if (node.entries) {
  2553. maxIndex = node.entries.length - 1;
  2554. if (index <= maxIndex) {
  2555. return mapIteratorValue(
  2556. type,
  2557. node.entries[this._reverse ? maxIndex - index : index]
  2558. );
  2559. }
  2560. } else {
  2561. maxIndex = node.nodes.length - 1;
  2562. if (index <= maxIndex) {
  2563. var subNode = node.nodes[this._reverse ? maxIndex - index : index];
  2564. if (subNode) {
  2565. if (subNode.entry) {
  2566. return mapIteratorValue(type, subNode.entry);
  2567. }
  2568. stack = this._stack = mapIteratorFrame(subNode, stack);
  2569. }
  2570. continue;
  2571. }
  2572. }
  2573. stack = this._stack = this._stack.__prev;
  2574. }
  2575. return iteratorDone();
  2576. };
  2577. return MapIterator;
  2578. }(Iterator));
  2579. function mapIteratorValue(type, entry) {
  2580. return iteratorValue(type, entry[0], entry[1]);
  2581. }
  2582. function mapIteratorFrame(node, prev) {
  2583. return {
  2584. node: node,
  2585. index: 0,
  2586. __prev: prev,
  2587. };
  2588. }
  2589. function makeMap(size, root, ownerID, hash) {
  2590. var map = Object.create(MapPrototype);
  2591. map.size = size;
  2592. map._root = root;
  2593. map.__ownerID = ownerID;
  2594. map.__hash = hash;
  2595. map.__altered = false;
  2596. return map;
  2597. }
  2598. var EMPTY_MAP;
  2599. function emptyMap() {
  2600. return EMPTY_MAP || (EMPTY_MAP = makeMap(0));
  2601. }
  2602. function updateMap(map, k, v) {
  2603. var newRoot;
  2604. var newSize;
  2605. if (!map._root) {
  2606. if (v === NOT_SET) {
  2607. return map;
  2608. }
  2609. newSize = 1;
  2610. newRoot = new ArrayMapNode(map.__ownerID, [[k, v]]);
  2611. } else {
  2612. var didChangeSize = MakeRef();
  2613. var didAlter = MakeRef();
  2614. newRoot = updateNode(
  2615. map._root,
  2616. map.__ownerID,
  2617. 0,
  2618. undefined,
  2619. k,
  2620. v,
  2621. didChangeSize,
  2622. didAlter
  2623. );
  2624. if (!didAlter.value) {
  2625. return map;
  2626. }
  2627. newSize = map.size + (didChangeSize.value ? (v === NOT_SET ? -1 : 1) : 0);
  2628. }
  2629. if (map.__ownerID) {
  2630. map.size = newSize;
  2631. map._root = newRoot;
  2632. map.__hash = undefined;
  2633. map.__altered = true;
  2634. return map;
  2635. }
  2636. return newRoot ? makeMap(newSize, newRoot) : emptyMap();
  2637. }
  2638. function updateNode(
  2639. node,
  2640. ownerID,
  2641. shift,
  2642. keyHash,
  2643. key,
  2644. value,
  2645. didChangeSize,
  2646. didAlter
  2647. ) {
  2648. if (!node) {
  2649. if (value === NOT_SET) {
  2650. return node;
  2651. }
  2652. SetRef(didAlter);
  2653. SetRef(didChangeSize);
  2654. return new ValueNode(ownerID, keyHash, [key, value]);
  2655. }
  2656. return node.update(
  2657. ownerID,
  2658. shift,
  2659. keyHash,
  2660. key,
  2661. value,
  2662. didChangeSize,
  2663. didAlter
  2664. );
  2665. }
  2666. function isLeafNode(node) {
  2667. return (
  2668. node.constructor === ValueNode || node.constructor === HashCollisionNode
  2669. );
  2670. }
  2671. function mergeIntoNode(node, ownerID, shift, keyHash, entry) {
  2672. if (node.keyHash === keyHash) {
  2673. return new HashCollisionNode(ownerID, keyHash, [node.entry, entry]);
  2674. }
  2675. var idx1 = (shift === 0 ? node.keyHash : node.keyHash >>> shift) & MASK;
  2676. var idx2 = (shift === 0 ? keyHash : keyHash >>> shift) & MASK;
  2677. var newNode;
  2678. var nodes =
  2679. idx1 === idx2
  2680. ? [mergeIntoNode(node, ownerID, shift + SHIFT, keyHash, entry)]
  2681. : ((newNode = new ValueNode(ownerID, keyHash, entry)),
  2682. idx1 < idx2 ? [node, newNode] : [newNode, node]);
  2683. return new BitmapIndexedNode(ownerID, (1 << idx1) | (1 << idx2), nodes);
  2684. }
  2685. function createNodes(ownerID, entries, key, value) {
  2686. if (!ownerID) {
  2687. ownerID = new OwnerID();
  2688. }
  2689. var node = new ValueNode(ownerID, hash(key), [key, value]);
  2690. for (var ii = 0; ii < entries.length; ii++) {
  2691. var entry = entries[ii];
  2692. node = node.update(ownerID, 0, undefined, entry[0], entry[1]);
  2693. }
  2694. return node;
  2695. }
  2696. function packNodes(ownerID, nodes, count, excluding) {
  2697. var bitmap = 0;
  2698. var packedII = 0;
  2699. var packedNodes = new Array(count);
  2700. for (var ii = 0, bit = 1, len = nodes.length; ii < len; ii++, bit <<= 1) {
  2701. var node = nodes[ii];
  2702. if (node !== undefined && ii !== excluding) {
  2703. bitmap |= bit;
  2704. packedNodes[packedII++] = node;
  2705. }
  2706. }
  2707. return new BitmapIndexedNode(ownerID, bitmap, packedNodes);
  2708. }
  2709. function expandNodes(ownerID, nodes, bitmap, including, node) {
  2710. var count = 0;
  2711. var expandedNodes = new Array(SIZE);
  2712. for (var ii = 0; bitmap !== 0; ii++, bitmap >>>= 1) {
  2713. expandedNodes[ii] = bitmap & 1 ? nodes[count++] : undefined;
  2714. }
  2715. expandedNodes[including] = node;
  2716. return new HashArrayMapNode(ownerID, count + 1, expandedNodes);
  2717. }
  2718. function popCount(x) {
  2719. x -= (x >> 1) & 0x55555555;
  2720. x = (x & 0x33333333) + ((x >> 2) & 0x33333333);
  2721. x = (x + (x >> 4)) & 0x0f0f0f0f;
  2722. x += x >> 8;
  2723. x += x >> 16;
  2724. return x & 0x7f;
  2725. }
  2726. function setAt(array, idx, val, canEdit) {
  2727. var newArray = canEdit ? array : arrCopy(array);
  2728. newArray[idx] = val;
  2729. return newArray;
  2730. }
  2731. function spliceIn(array, idx, val, canEdit) {
  2732. var newLen = array.length + 1;
  2733. if (canEdit && idx + 1 === newLen) {
  2734. array[idx] = val;
  2735. return array;
  2736. }
  2737. var newArray = new Array(newLen);
  2738. var after = 0;
  2739. for (var ii = 0; ii < newLen; ii++) {
  2740. if (ii === idx) {
  2741. newArray[ii] = val;
  2742. after = -1;
  2743. } else {
  2744. newArray[ii] = array[ii + after];
  2745. }
  2746. }
  2747. return newArray;
  2748. }
  2749. function spliceOut(array, idx, canEdit) {
  2750. var newLen = array.length - 1;
  2751. if (canEdit && idx === newLen) {
  2752. array.pop();
  2753. return array;
  2754. }
  2755. var newArray = new Array(newLen);
  2756. var after = 0;
  2757. for (var ii = 0; ii < newLen; ii++) {
  2758. if (ii === idx) {
  2759. after = 1;
  2760. }
  2761. newArray[ii] = array[ii + after];
  2762. }
  2763. return newArray;
  2764. }
  2765. var MAX_ARRAY_MAP_SIZE = SIZE / 4;
  2766. var MAX_BITMAP_INDEXED_SIZE = SIZE / 2;
  2767. var MIN_HASH_ARRAY_MAP_SIZE = SIZE / 4;
  2768. var IS_LIST_SYMBOL = '@@__IMMUTABLE_LIST__@@';
  2769. function isList(maybeList) {
  2770. return Boolean(maybeList && maybeList[IS_LIST_SYMBOL]);
  2771. }
  2772. var List = /*@__PURE__*/(function (IndexedCollection) {
  2773. function List(value) {
  2774. var empty = emptyList();
  2775. if (value === undefined || value === null) {
  2776. return empty;
  2777. }
  2778. if (isList(value)) {
  2779. return value;
  2780. }
  2781. var iter = IndexedCollection(value);
  2782. var size = iter.size;
  2783. if (size === 0) {
  2784. return empty;
  2785. }
  2786. assertNotInfinite(size);
  2787. if (size > 0 && size < SIZE) {
  2788. return makeList(0, size, SHIFT, null, new VNode(iter.toArray()));
  2789. }
  2790. return empty.withMutations(function (list) {
  2791. list.setSize(size);
  2792. iter.forEach(function (v, i) { return list.set(i, v); });
  2793. });
  2794. }
  2795. if ( IndexedCollection ) List.__proto__ = IndexedCollection;
  2796. List.prototype = Object.create( IndexedCollection && IndexedCollection.prototype );
  2797. List.prototype.constructor = List;
  2798. List.of = function of (/*...values*/) {
  2799. return this(arguments);
  2800. };
  2801. List.prototype.toString = function toString () {
  2802. return this.__toString('List [', ']');
  2803. };
  2804. // @pragma Access
  2805. List.prototype.get = function get (index, notSetValue) {
  2806. index = wrapIndex(this, index);
  2807. if (index >= 0 && index < this.size) {
  2808. index += this._origin;
  2809. var node = listNodeFor(this, index);
  2810. return node && node.array[index & MASK];
  2811. }
  2812. return notSetValue;
  2813. };
  2814. // @pragma Modification
  2815. List.prototype.set = function set (index, value) {
  2816. return updateList(this, index, value);
  2817. };
  2818. List.prototype.remove = function remove (index) {
  2819. return !this.has(index)
  2820. ? this
  2821. : index === 0
  2822. ? this.shift()
  2823. : index === this.size - 1
  2824. ? this.pop()
  2825. : this.splice(index, 1);
  2826. };
  2827. List.prototype.insert = function insert (index, value) {
  2828. return this.splice(index, 0, value);
  2829. };
  2830. List.prototype.clear = function clear () {
  2831. if (this.size === 0) {
  2832. return this;
  2833. }
  2834. if (this.__ownerID) {
  2835. this.size = this._origin = this._capacity = 0;
  2836. this._level = SHIFT;
  2837. this._root = this._tail = this.__hash = undefined;
  2838. this.__altered = true;
  2839. return this;
  2840. }
  2841. return emptyList();
  2842. };
  2843. List.prototype.push = function push (/*...values*/) {
  2844. var values = arguments;
  2845. var oldSize = this.size;
  2846. return this.withMutations(function (list) {
  2847. setListBounds(list, 0, oldSize + values.length);
  2848. for (var ii = 0; ii < values.length; ii++) {
  2849. list.set(oldSize + ii, values[ii]);
  2850. }
  2851. });
  2852. };
  2853. List.prototype.pop = function pop () {
  2854. return setListBounds(this, 0, -1);
  2855. };
  2856. List.prototype.unshift = function unshift (/*...values*/) {
  2857. var values = arguments;
  2858. return this.withMutations(function (list) {
  2859. setListBounds(list, -values.length);
  2860. for (var ii = 0; ii < values.length; ii++) {
  2861. list.set(ii, values[ii]);
  2862. }
  2863. });
  2864. };
  2865. List.prototype.shift = function shift () {
  2866. return setListBounds(this, 1);
  2867. };
  2868. // @pragma Composition
  2869. List.prototype.concat = function concat (/*...collections*/) {
  2870. var arguments$1 = arguments;
  2871. var seqs = [];
  2872. for (var i = 0; i < arguments.length; i++) {
  2873. var argument = arguments$1[i];
  2874. var seq = IndexedCollection(
  2875. typeof argument !== 'string' && hasIterator(argument)
  2876. ? argument
  2877. : [argument]
  2878. );
  2879. if (seq.size !== 0) {
  2880. seqs.push(seq);
  2881. }
  2882. }
  2883. if (seqs.length === 0) {
  2884. return this;
  2885. }
  2886. if (this.size === 0 && !this.__ownerID && seqs.length === 1) {
  2887. return this.constructor(seqs[0]);
  2888. }
  2889. return this.withMutations(function (list) {
  2890. seqs.forEach(function (seq) { return seq.forEach(function (value) { return list.push(value); }); });
  2891. });
  2892. };
  2893. List.prototype.setSize = function setSize (size) {
  2894. return setListBounds(this, 0, size);
  2895. };
  2896. List.prototype.map = function map (mapper, context) {
  2897. var this$1$1 = this;
  2898. return this.withMutations(function (list) {
  2899. for (var i = 0; i < this$1$1.size; i++) {
  2900. list.set(i, mapper.call(context, list.get(i), i, this$1$1));
  2901. }
  2902. });
  2903. };
  2904. // @pragma Iteration
  2905. List.prototype.slice = function slice (begin, end) {
  2906. var size = this.size;
  2907. if (wholeSlice(begin, end, size)) {
  2908. return this;
  2909. }
  2910. return setListBounds(
  2911. this,
  2912. resolveBegin(begin, size),
  2913. resolveEnd(end, size)
  2914. );
  2915. };
  2916. List.prototype.__iterator = function __iterator (type, reverse) {
  2917. var index = reverse ? this.size : 0;
  2918. var values = iterateList(this, reverse);
  2919. return new Iterator(function () {
  2920. var value = values();
  2921. return value === DONE
  2922. ? iteratorDone()
  2923. : iteratorValue(type, reverse ? --index : index++, value);
  2924. });
  2925. };
  2926. List.prototype.__iterate = function __iterate (fn, reverse) {
  2927. var index = reverse ? this.size : 0;
  2928. var values = iterateList(this, reverse);
  2929. var value;
  2930. while ((value = values()) !== DONE) {
  2931. if (fn(value, reverse ? --index : index++, this) === false) {
  2932. break;
  2933. }
  2934. }
  2935. return index;
  2936. };
  2937. List.prototype.__ensureOwner = function __ensureOwner (ownerID) {
  2938. if (ownerID === this.__ownerID) {
  2939. return this;
  2940. }
  2941. if (!ownerID) {
  2942. if (this.size === 0) {
  2943. return emptyList();
  2944. }
  2945. this.__ownerID = ownerID;
  2946. this.__altered = false;
  2947. return this;
  2948. }
  2949. return makeList(
  2950. this._origin,
  2951. this._capacity,
  2952. this._level,
  2953. this._root,
  2954. this._tail,
  2955. ownerID,
  2956. this.__hash
  2957. );
  2958. };
  2959. return List;
  2960. }(IndexedCollection));
  2961. List.isList = isList;
  2962. var ListPrototype = List.prototype;
  2963. ListPrototype[IS_LIST_SYMBOL] = true;
  2964. ListPrototype[DELETE] = ListPrototype.remove;
  2965. ListPrototype.merge = ListPrototype.concat;
  2966. ListPrototype.setIn = setIn;
  2967. ListPrototype.deleteIn = ListPrototype.removeIn = deleteIn;
  2968. ListPrototype.update = update;
  2969. ListPrototype.updateIn = updateIn;
  2970. ListPrototype.mergeIn = mergeIn;
  2971. ListPrototype.mergeDeepIn = mergeDeepIn;
  2972. ListPrototype.withMutations = withMutations;
  2973. ListPrototype.wasAltered = wasAltered;
  2974. ListPrototype.asImmutable = asImmutable;
  2975. ListPrototype['@@transducer/init'] = ListPrototype.asMutable = asMutable;
  2976. ListPrototype['@@transducer/step'] = function (result, arr) {
  2977. return result.push(arr);
  2978. };
  2979. ListPrototype['@@transducer/result'] = function (obj) {
  2980. return obj.asImmutable();
  2981. };
  2982. var VNode = function VNode(array, ownerID) {
  2983. this.array = array;
  2984. this.ownerID = ownerID;
  2985. };
  2986. // TODO: seems like these methods are very similar
  2987. VNode.prototype.removeBefore = function removeBefore (ownerID, level, index) {
  2988. if (index === level ? 1 << level : this.array.length === 0) {
  2989. return this;
  2990. }
  2991. var originIndex = (index >>> level) & MASK;
  2992. if (originIndex >= this.array.length) {
  2993. return new VNode([], ownerID);
  2994. }
  2995. var removingFirst = originIndex === 0;
  2996. var newChild;
  2997. if (level > 0) {
  2998. var oldChild = this.array[originIndex];
  2999. newChild =
  3000. oldChild && oldChild.removeBefore(ownerID, level - SHIFT, index);
  3001. if (newChild === oldChild && removingFirst) {
  3002. return this;
  3003. }
  3004. }
  3005. if (removingFirst && !newChild) {
  3006. return this;
  3007. }
  3008. var editable = editableVNode(this, ownerID);
  3009. if (!removingFirst) {
  3010. for (var ii = 0; ii < originIndex; ii++) {
  3011. editable.array[ii] = undefined;
  3012. }
  3013. }
  3014. if (newChild) {
  3015. editable.array[originIndex] = newChild;
  3016. }
  3017. return editable;
  3018. };
  3019. VNode.prototype.removeAfter = function removeAfter (ownerID, level, index) {
  3020. if (index === (level ? 1 << level : 0) || this.array.length === 0) {
  3021. return this;
  3022. }
  3023. var sizeIndex = ((index - 1) >>> level) & MASK;
  3024. if (sizeIndex >= this.array.length) {
  3025. return this;
  3026. }
  3027. var newChild;
  3028. if (level > 0) {
  3029. var oldChild = this.array[sizeIndex];
  3030. newChild =
  3031. oldChild && oldChild.removeAfter(ownerID, level - SHIFT, index);
  3032. if (newChild === oldChild && sizeIndex === this.array.length - 1) {
  3033. return this;
  3034. }
  3035. }
  3036. var editable = editableVNode(this, ownerID);
  3037. editable.array.splice(sizeIndex + 1);
  3038. if (newChild) {
  3039. editable.array[sizeIndex] = newChild;
  3040. }
  3041. return editable;
  3042. };
  3043. var DONE = {};
  3044. function iterateList(list, reverse) {
  3045. var left = list._origin;
  3046. var right = list._capacity;
  3047. var tailPos = getTailOffset(right);
  3048. var tail = list._tail;
  3049. return iterateNodeOrLeaf(list._root, list._level, 0);
  3050. function iterateNodeOrLeaf(node, level, offset) {
  3051. return level === 0
  3052. ? iterateLeaf(node, offset)
  3053. : iterateNode(node, level, offset);
  3054. }
  3055. function iterateLeaf(node, offset) {
  3056. var array = offset === tailPos ? tail && tail.array : node && node.array;
  3057. var from = offset > left ? 0 : left - offset;
  3058. var to = right - offset;
  3059. if (to > SIZE) {
  3060. to = SIZE;
  3061. }
  3062. return function () {
  3063. if (from === to) {
  3064. return DONE;
  3065. }
  3066. var idx = reverse ? --to : from++;
  3067. return array && array[idx];
  3068. };
  3069. }
  3070. function iterateNode(node, level, offset) {
  3071. var values;
  3072. var array = node && node.array;
  3073. var from = offset > left ? 0 : (left - offset) >> level;
  3074. var to = ((right - offset) >> level) + 1;
  3075. if (to > SIZE) {
  3076. to = SIZE;
  3077. }
  3078. return function () {
  3079. while (true) {
  3080. if (values) {
  3081. var value = values();
  3082. if (value !== DONE) {
  3083. return value;
  3084. }
  3085. values = null;
  3086. }
  3087. if (from === to) {
  3088. return DONE;
  3089. }
  3090. var idx = reverse ? --to : from++;
  3091. values = iterateNodeOrLeaf(
  3092. array && array[idx],
  3093. level - SHIFT,
  3094. offset + (idx << level)
  3095. );
  3096. }
  3097. };
  3098. }
  3099. }
  3100. function makeList(origin, capacity, level, root, tail, ownerID, hash) {
  3101. var list = Object.create(ListPrototype);
  3102. list.size = capacity - origin;
  3103. list._origin = origin;
  3104. list._capacity = capacity;
  3105. list._level = level;
  3106. list._root = root;
  3107. list._tail = tail;
  3108. list.__ownerID = ownerID;
  3109. list.__hash = hash;
  3110. list.__altered = false;
  3111. return list;
  3112. }
  3113. var EMPTY_LIST;
  3114. function emptyList() {
  3115. return EMPTY_LIST || (EMPTY_LIST = makeList(0, 0, SHIFT));
  3116. }
  3117. function updateList(list, index, value) {
  3118. index = wrapIndex(list, index);
  3119. if (index !== index) {
  3120. return list;
  3121. }
  3122. if (index >= list.size || index < 0) {
  3123. return list.withMutations(function (list) {
  3124. index < 0
  3125. ? setListBounds(list, index).set(0, value)
  3126. : setListBounds(list, 0, index + 1).set(index, value);
  3127. });
  3128. }
  3129. index += list._origin;
  3130. var newTail = list._tail;
  3131. var newRoot = list._root;
  3132. var didAlter = MakeRef();
  3133. if (index >= getTailOffset(list._capacity)) {
  3134. newTail = updateVNode(newTail, list.__ownerID, 0, index, value, didAlter);
  3135. } else {
  3136. newRoot = updateVNode(
  3137. newRoot,
  3138. list.__ownerID,
  3139. list._level,
  3140. index,
  3141. value,
  3142. didAlter
  3143. );
  3144. }
  3145. if (!didAlter.value) {
  3146. return list;
  3147. }
  3148. if (list.__ownerID) {
  3149. list._root = newRoot;
  3150. list._tail = newTail;
  3151. list.__hash = undefined;
  3152. list.__altered = true;
  3153. return list;
  3154. }
  3155. return makeList(list._origin, list._capacity, list._level, newRoot, newTail);
  3156. }
  3157. function updateVNode(node, ownerID, level, index, value, didAlter) {
  3158. var idx = (index >>> level) & MASK;
  3159. var nodeHas = node && idx < node.array.length;
  3160. if (!nodeHas && value === undefined) {
  3161. return node;
  3162. }
  3163. var newNode;
  3164. if (level > 0) {
  3165. var lowerNode = node && node.array[idx];
  3166. var newLowerNode = updateVNode(
  3167. lowerNode,
  3168. ownerID,
  3169. level - SHIFT,
  3170. index,
  3171. value,
  3172. didAlter
  3173. );
  3174. if (newLowerNode === lowerNode) {
  3175. return node;
  3176. }
  3177. newNode = editableVNode(node, ownerID);
  3178. newNode.array[idx] = newLowerNode;
  3179. return newNode;
  3180. }
  3181. if (nodeHas && node.array[idx] === value) {
  3182. return node;
  3183. }
  3184. if (didAlter) {
  3185. SetRef(didAlter);
  3186. }
  3187. newNode = editableVNode(node, ownerID);
  3188. if (value === undefined && idx === newNode.array.length - 1) {
  3189. newNode.array.pop();
  3190. } else {
  3191. newNode.array[idx] = value;
  3192. }
  3193. return newNode;
  3194. }
  3195. function editableVNode(node, ownerID) {
  3196. if (ownerID && node && ownerID === node.ownerID) {
  3197. return node;
  3198. }
  3199. return new VNode(node ? node.array.slice() : [], ownerID);
  3200. }
  3201. function listNodeFor(list, rawIndex) {
  3202. if (rawIndex >= getTailOffset(list._capacity)) {
  3203. return list._tail;
  3204. }
  3205. if (rawIndex < 1 << (list._level + SHIFT)) {
  3206. var node = list._root;
  3207. var level = list._level;
  3208. while (node && level > 0) {
  3209. node = node.array[(rawIndex >>> level) & MASK];
  3210. level -= SHIFT;
  3211. }
  3212. return node;
  3213. }
  3214. }
  3215. function setListBounds(list, begin, end) {
  3216. // Sanitize begin & end using this shorthand for ToInt32(argument)
  3217. // http://www.ecma-international.org/ecma-262/6.0/#sec-toint32
  3218. if (begin !== undefined) {
  3219. begin |= 0;
  3220. }
  3221. if (end !== undefined) {
  3222. end |= 0;
  3223. }
  3224. var owner = list.__ownerID || new OwnerID();
  3225. var oldOrigin = list._origin;
  3226. var oldCapacity = list._capacity;
  3227. var newOrigin = oldOrigin + begin;
  3228. var newCapacity =
  3229. end === undefined
  3230. ? oldCapacity
  3231. : end < 0
  3232. ? oldCapacity + end
  3233. : oldOrigin + end;
  3234. if (newOrigin === oldOrigin && newCapacity === oldCapacity) {
  3235. return list;
  3236. }
  3237. // If it's going to end after it starts, it's empty.
  3238. if (newOrigin >= newCapacity) {
  3239. return list.clear();
  3240. }
  3241. var newLevel = list._level;
  3242. var newRoot = list._root;
  3243. // New origin might need creating a higher root.
  3244. var offsetShift = 0;
  3245. while (newOrigin + offsetShift < 0) {
  3246. newRoot = new VNode(
  3247. newRoot && newRoot.array.length ? [undefined, newRoot] : [],
  3248. owner
  3249. );
  3250. newLevel += SHIFT;
  3251. offsetShift += 1 << newLevel;
  3252. }
  3253. if (offsetShift) {
  3254. newOrigin += offsetShift;
  3255. oldOrigin += offsetShift;
  3256. newCapacity += offsetShift;
  3257. oldCapacity += offsetShift;
  3258. }
  3259. var oldTailOffset = getTailOffset(oldCapacity);
  3260. var newTailOffset = getTailOffset(newCapacity);
  3261. // New size might need creating a higher root.
  3262. while (newTailOffset >= 1 << (newLevel + SHIFT)) {
  3263. newRoot = new VNode(
  3264. newRoot && newRoot.array.length ? [newRoot] : [],
  3265. owner
  3266. );
  3267. newLevel += SHIFT;
  3268. }
  3269. // Locate or create the new tail.
  3270. var oldTail = list._tail;
  3271. var newTail =
  3272. newTailOffset < oldTailOffset
  3273. ? listNodeFor(list, newCapacity - 1)
  3274. : newTailOffset > oldTailOffset
  3275. ? new VNode([], owner)
  3276. : oldTail;
  3277. // Merge Tail into tree.
  3278. if (
  3279. oldTail &&
  3280. newTailOffset > oldTailOffset &&
  3281. newOrigin < oldCapacity &&
  3282. oldTail.array.length
  3283. ) {
  3284. newRoot = editableVNode(newRoot, owner);
  3285. var node = newRoot;
  3286. for (var level = newLevel; level > SHIFT; level -= SHIFT) {
  3287. var idx = (oldTailOffset >>> level) & MASK;
  3288. node = node.array[idx] = editableVNode(node.array[idx], owner);
  3289. }
  3290. node.array[(oldTailOffset >>> SHIFT) & MASK] = oldTail;
  3291. }
  3292. // If the size has been reduced, there's a chance the tail needs to be trimmed.
  3293. if (newCapacity < oldCapacity) {
  3294. newTail = newTail && newTail.removeAfter(owner, 0, newCapacity);
  3295. }
  3296. // If the new origin is within the tail, then we do not need a root.
  3297. if (newOrigin >= newTailOffset) {
  3298. newOrigin -= newTailOffset;
  3299. newCapacity -= newTailOffset;
  3300. newLevel = SHIFT;
  3301. newRoot = null;
  3302. newTail = newTail && newTail.removeBefore(owner, 0, newOrigin);
  3303. // Otherwise, if the root has been trimmed, garbage collect.
  3304. } else if (newOrigin > oldOrigin || newTailOffset < oldTailOffset) {
  3305. offsetShift = 0;
  3306. // Identify the new top root node of the subtree of the old root.
  3307. while (newRoot) {
  3308. var beginIndex = (newOrigin >>> newLevel) & MASK;
  3309. if ((beginIndex !== newTailOffset >>> newLevel) & MASK) {
  3310. break;
  3311. }
  3312. if (beginIndex) {
  3313. offsetShift += (1 << newLevel) * beginIndex;
  3314. }
  3315. newLevel -= SHIFT;
  3316. newRoot = newRoot.array[beginIndex];
  3317. }
  3318. // Trim the new sides of the new root.
  3319. if (newRoot && newOrigin > oldOrigin) {
  3320. newRoot = newRoot.removeBefore(owner, newLevel, newOrigin - offsetShift);
  3321. }
  3322. if (newRoot && newTailOffset < oldTailOffset) {
  3323. newRoot = newRoot.removeAfter(
  3324. owner,
  3325. newLevel,
  3326. newTailOffset - offsetShift
  3327. );
  3328. }
  3329. if (offsetShift) {
  3330. newOrigin -= offsetShift;
  3331. newCapacity -= offsetShift;
  3332. }
  3333. }
  3334. if (list.__ownerID) {
  3335. list.size = newCapacity - newOrigin;
  3336. list._origin = newOrigin;
  3337. list._capacity = newCapacity;
  3338. list._level = newLevel;
  3339. list._root = newRoot;
  3340. list._tail = newTail;
  3341. list.__hash = undefined;
  3342. list.__altered = true;
  3343. return list;
  3344. }
  3345. return makeList(newOrigin, newCapacity, newLevel, newRoot, newTail);
  3346. }
  3347. function getTailOffset(size) {
  3348. return size < SIZE ? 0 : ((size - 1) >>> SHIFT) << SHIFT;
  3349. }
  3350. var OrderedMap = /*@__PURE__*/(function (Map) {
  3351. function OrderedMap(value) {
  3352. return value === undefined || value === null
  3353. ? emptyOrderedMap()
  3354. : isOrderedMap(value)
  3355. ? value
  3356. : emptyOrderedMap().withMutations(function (map) {
  3357. var iter = KeyedCollection(value);
  3358. assertNotInfinite(iter.size);
  3359. iter.forEach(function (v, k) { return map.set(k, v); });
  3360. });
  3361. }
  3362. if ( Map ) OrderedMap.__proto__ = Map;
  3363. OrderedMap.prototype = Object.create( Map && Map.prototype );
  3364. OrderedMap.prototype.constructor = OrderedMap;
  3365. OrderedMap.of = function of (/*...values*/) {
  3366. return this(arguments);
  3367. };
  3368. OrderedMap.prototype.toString = function toString () {
  3369. return this.__toString('OrderedMap {', '}');
  3370. };
  3371. // @pragma Access
  3372. OrderedMap.prototype.get = function get (k, notSetValue) {
  3373. var index = this._map.get(k);
  3374. return index !== undefined ? this._list.get(index)[1] : notSetValue;
  3375. };
  3376. // @pragma Modification
  3377. OrderedMap.prototype.clear = function clear () {
  3378. if (this.size === 0) {
  3379. return this;
  3380. }
  3381. if (this.__ownerID) {
  3382. this.size = 0;
  3383. this._map.clear();
  3384. this._list.clear();
  3385. this.__altered = true;
  3386. return this;
  3387. }
  3388. return emptyOrderedMap();
  3389. };
  3390. OrderedMap.prototype.set = function set (k, v) {
  3391. return updateOrderedMap(this, k, v);
  3392. };
  3393. OrderedMap.prototype.remove = function remove (k) {
  3394. return updateOrderedMap(this, k, NOT_SET);
  3395. };
  3396. OrderedMap.prototype.__iterate = function __iterate (fn, reverse) {
  3397. var this$1$1 = this;
  3398. return this._list.__iterate(
  3399. function (entry) { return entry && fn(entry[1], entry[0], this$1$1); },
  3400. reverse
  3401. );
  3402. };
  3403. OrderedMap.prototype.__iterator = function __iterator (type, reverse) {
  3404. return this._list.fromEntrySeq().__iterator(type, reverse);
  3405. };
  3406. OrderedMap.prototype.__ensureOwner = function __ensureOwner (ownerID) {
  3407. if (ownerID === this.__ownerID) {
  3408. return this;
  3409. }
  3410. var newMap = this._map.__ensureOwner(ownerID);
  3411. var newList = this._list.__ensureOwner(ownerID);
  3412. if (!ownerID) {
  3413. if (this.size === 0) {
  3414. return emptyOrderedMap();
  3415. }
  3416. this.__ownerID = ownerID;
  3417. this.__altered = false;
  3418. this._map = newMap;
  3419. this._list = newList;
  3420. return this;
  3421. }
  3422. return makeOrderedMap(newMap, newList, ownerID, this.__hash);
  3423. };
  3424. return OrderedMap;
  3425. }(Map));
  3426. OrderedMap.isOrderedMap = isOrderedMap;
  3427. OrderedMap.prototype[IS_ORDERED_SYMBOL] = true;
  3428. OrderedMap.prototype[DELETE] = OrderedMap.prototype.remove;
  3429. function makeOrderedMap(map, list, ownerID, hash) {
  3430. var omap = Object.create(OrderedMap.prototype);
  3431. omap.size = map ? map.size : 0;
  3432. omap._map = map;
  3433. omap._list = list;
  3434. omap.__ownerID = ownerID;
  3435. omap.__hash = hash;
  3436. omap.__altered = false;
  3437. return omap;
  3438. }
  3439. var EMPTY_ORDERED_MAP;
  3440. function emptyOrderedMap() {
  3441. return (
  3442. EMPTY_ORDERED_MAP ||
  3443. (EMPTY_ORDERED_MAP = makeOrderedMap(emptyMap(), emptyList()))
  3444. );
  3445. }
  3446. function updateOrderedMap(omap, k, v) {
  3447. var map = omap._map;
  3448. var list = omap._list;
  3449. var i = map.get(k);
  3450. var has = i !== undefined;
  3451. var newMap;
  3452. var newList;
  3453. if (v === NOT_SET) {
  3454. // removed
  3455. if (!has) {
  3456. return omap;
  3457. }
  3458. if (list.size >= SIZE && list.size >= map.size * 2) {
  3459. newList = list.filter(function (entry, idx) { return entry !== undefined && i !== idx; });
  3460. newMap = newList
  3461. .toKeyedSeq()
  3462. .map(function (entry) { return entry[0]; })
  3463. .flip()
  3464. .toMap();
  3465. if (omap.__ownerID) {
  3466. newMap.__ownerID = newList.__ownerID = omap.__ownerID;
  3467. }
  3468. } else {
  3469. newMap = map.remove(k);
  3470. newList = i === list.size - 1 ? list.pop() : list.set(i, undefined);
  3471. }
  3472. } else if (has) {
  3473. if (v === list.get(i)[1]) {
  3474. return omap;
  3475. }
  3476. newMap = map;
  3477. newList = list.set(i, [k, v]);
  3478. } else {
  3479. newMap = map.set(k, list.size);
  3480. newList = list.set(list.size, [k, v]);
  3481. }
  3482. if (omap.__ownerID) {
  3483. omap.size = newMap.size;
  3484. omap._map = newMap;
  3485. omap._list = newList;
  3486. omap.__hash = undefined;
  3487. omap.__altered = true;
  3488. return omap;
  3489. }
  3490. return makeOrderedMap(newMap, newList);
  3491. }
  3492. var IS_STACK_SYMBOL = '@@__IMMUTABLE_STACK__@@';
  3493. function isStack(maybeStack) {
  3494. return Boolean(maybeStack && maybeStack[IS_STACK_SYMBOL]);
  3495. }
  3496. var Stack = /*@__PURE__*/(function (IndexedCollection) {
  3497. function Stack(value) {
  3498. return value === undefined || value === null
  3499. ? emptyStack()
  3500. : isStack(value)
  3501. ? value
  3502. : emptyStack().pushAll(value);
  3503. }
  3504. if ( IndexedCollection ) Stack.__proto__ = IndexedCollection;
  3505. Stack.prototype = Object.create( IndexedCollection && IndexedCollection.prototype );
  3506. Stack.prototype.constructor = Stack;
  3507. Stack.of = function of (/*...values*/) {
  3508. return this(arguments);
  3509. };
  3510. Stack.prototype.toString = function toString () {
  3511. return this.__toString('Stack [', ']');
  3512. };
  3513. // @pragma Access
  3514. Stack.prototype.get = function get (index, notSetValue) {
  3515. var head = this._head;
  3516. index = wrapIndex(this, index);
  3517. while (head && index--) {
  3518. head = head.next;
  3519. }
  3520. return head ? head.value : notSetValue;
  3521. };
  3522. Stack.prototype.peek = function peek () {
  3523. return this._head && this._head.value;
  3524. };
  3525. // @pragma Modification
  3526. Stack.prototype.push = function push (/*...values*/) {
  3527. var arguments$1 = arguments;
  3528. if (arguments.length === 0) {
  3529. return this;
  3530. }
  3531. var newSize = this.size + arguments.length;
  3532. var head = this._head;
  3533. for (var ii = arguments.length - 1; ii >= 0; ii--) {
  3534. head = {
  3535. value: arguments$1[ii],
  3536. next: head,
  3537. };
  3538. }
  3539. if (this.__ownerID) {
  3540. this.size = newSize;
  3541. this._head = head;
  3542. this.__hash = undefined;
  3543. this.__altered = true;
  3544. return this;
  3545. }
  3546. return makeStack(newSize, head);
  3547. };
  3548. Stack.prototype.pushAll = function pushAll (iter) {
  3549. iter = IndexedCollection(iter);
  3550. if (iter.size === 0) {
  3551. return this;
  3552. }
  3553. if (this.size === 0 && isStack(iter)) {
  3554. return iter;
  3555. }
  3556. assertNotInfinite(iter.size);
  3557. var newSize = this.size;
  3558. var head = this._head;
  3559. iter.__iterate(function (value) {
  3560. newSize++;
  3561. head = {
  3562. value: value,
  3563. next: head,
  3564. };
  3565. }, /* reverse */ true);
  3566. if (this.__ownerID) {
  3567. this.size = newSize;
  3568. this._head = head;
  3569. this.__hash = undefined;
  3570. this.__altered = true;
  3571. return this;
  3572. }
  3573. return makeStack(newSize, head);
  3574. };
  3575. Stack.prototype.pop = function pop () {
  3576. return this.slice(1);
  3577. };
  3578. Stack.prototype.clear = function clear () {
  3579. if (this.size === 0) {
  3580. return this;
  3581. }
  3582. if (this.__ownerID) {
  3583. this.size = 0;
  3584. this._head = undefined;
  3585. this.__hash = undefined;
  3586. this.__altered = true;
  3587. return this;
  3588. }
  3589. return emptyStack();
  3590. };
  3591. Stack.prototype.slice = function slice (begin, end) {
  3592. if (wholeSlice(begin, end, this.size)) {
  3593. return this;
  3594. }
  3595. var resolvedBegin = resolveBegin(begin, this.size);
  3596. var resolvedEnd = resolveEnd(end, this.size);
  3597. if (resolvedEnd !== this.size) {
  3598. // super.slice(begin, end);
  3599. return IndexedCollection.prototype.slice.call(this, begin, end);
  3600. }
  3601. var newSize = this.size - resolvedBegin;
  3602. var head = this._head;
  3603. while (resolvedBegin--) {
  3604. head = head.next;
  3605. }
  3606. if (this.__ownerID) {
  3607. this.size = newSize;
  3608. this._head = head;
  3609. this.__hash = undefined;
  3610. this.__altered = true;
  3611. return this;
  3612. }
  3613. return makeStack(newSize, head);
  3614. };
  3615. // @pragma Mutability
  3616. Stack.prototype.__ensureOwner = function __ensureOwner (ownerID) {
  3617. if (ownerID === this.__ownerID) {
  3618. return this;
  3619. }
  3620. if (!ownerID) {
  3621. if (this.size === 0) {
  3622. return emptyStack();
  3623. }
  3624. this.__ownerID = ownerID;
  3625. this.__altered = false;
  3626. return this;
  3627. }
  3628. return makeStack(this.size, this._head, ownerID, this.__hash);
  3629. };
  3630. // @pragma Iteration
  3631. Stack.prototype.__iterate = function __iterate (fn, reverse) {
  3632. var this$1$1 = this;
  3633. if (reverse) {
  3634. return new ArraySeq(this.toArray()).__iterate(
  3635. function (v, k) { return fn(v, k, this$1$1); },
  3636. reverse
  3637. );
  3638. }
  3639. var iterations = 0;
  3640. var node = this._head;
  3641. while (node) {
  3642. if (fn(node.value, iterations++, this) === false) {
  3643. break;
  3644. }
  3645. node = node.next;
  3646. }
  3647. return iterations;
  3648. };
  3649. Stack.prototype.__iterator = function __iterator (type, reverse) {
  3650. if (reverse) {
  3651. return new ArraySeq(this.toArray()).__iterator(type, reverse);
  3652. }
  3653. var iterations = 0;
  3654. var node = this._head;
  3655. return new Iterator(function () {
  3656. if (node) {
  3657. var value = node.value;
  3658. node = node.next;
  3659. return iteratorValue(type, iterations++, value);
  3660. }
  3661. return iteratorDone();
  3662. });
  3663. };
  3664. return Stack;
  3665. }(IndexedCollection));
  3666. Stack.isStack = isStack;
  3667. var StackPrototype = Stack.prototype;
  3668. StackPrototype[IS_STACK_SYMBOL] = true;
  3669. StackPrototype.shift = StackPrototype.pop;
  3670. StackPrototype.unshift = StackPrototype.push;
  3671. StackPrototype.unshiftAll = StackPrototype.pushAll;
  3672. StackPrototype.withMutations = withMutations;
  3673. StackPrototype.wasAltered = wasAltered;
  3674. StackPrototype.asImmutable = asImmutable;
  3675. StackPrototype['@@transducer/init'] = StackPrototype.asMutable = asMutable;
  3676. StackPrototype['@@transducer/step'] = function (result, arr) {
  3677. return result.unshift(arr);
  3678. };
  3679. StackPrototype['@@transducer/result'] = function (obj) {
  3680. return obj.asImmutable();
  3681. };
  3682. function makeStack(size, head, ownerID, hash) {
  3683. var map = Object.create(StackPrototype);
  3684. map.size = size;
  3685. map._head = head;
  3686. map.__ownerID = ownerID;
  3687. map.__hash = hash;
  3688. map.__altered = false;
  3689. return map;
  3690. }
  3691. var EMPTY_STACK;
  3692. function emptyStack() {
  3693. return EMPTY_STACK || (EMPTY_STACK = makeStack(0));
  3694. }
  3695. var IS_SET_SYMBOL = '@@__IMMUTABLE_SET__@@';
  3696. function isSet(maybeSet) {
  3697. return Boolean(maybeSet && maybeSet[IS_SET_SYMBOL]);
  3698. }
  3699. function isOrderedSet(maybeOrderedSet) {
  3700. return isSet(maybeOrderedSet) && isOrdered(maybeOrderedSet);
  3701. }
  3702. function deepEqual(a, b) {
  3703. if (a === b) {
  3704. return true;
  3705. }
  3706. if (
  3707. !isCollection(b) ||
  3708. (a.size !== undefined && b.size !== undefined && a.size !== b.size) ||
  3709. (a.__hash !== undefined &&
  3710. b.__hash !== undefined &&
  3711. a.__hash !== b.__hash) ||
  3712. isKeyed(a) !== isKeyed(b) ||
  3713. isIndexed(a) !== isIndexed(b) ||
  3714. isOrdered(a) !== isOrdered(b)
  3715. ) {
  3716. return false;
  3717. }
  3718. if (a.size === 0 && b.size === 0) {
  3719. return true;
  3720. }
  3721. var notAssociative = !isAssociative(a);
  3722. if (isOrdered(a)) {
  3723. var entries = a.entries();
  3724. return (
  3725. b.every(function (v, k) {
  3726. var entry = entries.next().value;
  3727. return entry && is(entry[1], v) && (notAssociative || is(entry[0], k));
  3728. }) && entries.next().done
  3729. );
  3730. }
  3731. var flipped = false;
  3732. if (a.size === undefined) {
  3733. if (b.size === undefined) {
  3734. if (typeof a.cacheResult === 'function') {
  3735. a.cacheResult();
  3736. }
  3737. } else {
  3738. flipped = true;
  3739. var _ = a;
  3740. a = b;
  3741. b = _;
  3742. }
  3743. }
  3744. var allEqual = true;
  3745. var bSize = b.__iterate(function (v, k) {
  3746. if (
  3747. notAssociative
  3748. ? !a.has(v)
  3749. : flipped
  3750. ? !is(v, a.get(k, NOT_SET))
  3751. : !is(a.get(k, NOT_SET), v)
  3752. ) {
  3753. allEqual = false;
  3754. return false;
  3755. }
  3756. });
  3757. return allEqual && a.size === bSize;
  3758. }
  3759. function mixin(ctor, methods) {
  3760. var keyCopier = function (key) {
  3761. ctor.prototype[key] = methods[key];
  3762. };
  3763. Object.keys(methods).forEach(keyCopier);
  3764. Object.getOwnPropertySymbols &&
  3765. Object.getOwnPropertySymbols(methods).forEach(keyCopier);
  3766. return ctor;
  3767. }
  3768. function toJS(value) {
  3769. if (!value || typeof value !== 'object') {
  3770. return value;
  3771. }
  3772. if (!isCollection(value)) {
  3773. if (!isDataStructure(value)) {
  3774. return value;
  3775. }
  3776. value = Seq(value);
  3777. }
  3778. if (isKeyed(value)) {
  3779. var result$1 = {};
  3780. value.__iterate(function (v, k) {
  3781. result$1[k] = toJS(v);
  3782. });
  3783. return result$1;
  3784. }
  3785. var result = [];
  3786. value.__iterate(function (v) {
  3787. result.push(toJS(v));
  3788. });
  3789. return result;
  3790. }
  3791. var Set = /*@__PURE__*/(function (SetCollection) {
  3792. function Set(value) {
  3793. return value === undefined || value === null
  3794. ? emptySet()
  3795. : isSet(value) && !isOrdered(value)
  3796. ? value
  3797. : emptySet().withMutations(function (set) {
  3798. var iter = SetCollection(value);
  3799. assertNotInfinite(iter.size);
  3800. iter.forEach(function (v) { return set.add(v); });
  3801. });
  3802. }
  3803. if ( SetCollection ) Set.__proto__ = SetCollection;
  3804. Set.prototype = Object.create( SetCollection && SetCollection.prototype );
  3805. Set.prototype.constructor = Set;
  3806. Set.of = function of (/*...values*/) {
  3807. return this(arguments);
  3808. };
  3809. Set.fromKeys = function fromKeys (value) {
  3810. return this(KeyedCollection(value).keySeq());
  3811. };
  3812. Set.intersect = function intersect (sets) {
  3813. sets = Collection(sets).toArray();
  3814. return sets.length
  3815. ? SetPrototype.intersect.apply(Set(sets.pop()), sets)
  3816. : emptySet();
  3817. };
  3818. Set.union = function union (sets) {
  3819. sets = Collection(sets).toArray();
  3820. return sets.length
  3821. ? SetPrototype.union.apply(Set(sets.pop()), sets)
  3822. : emptySet();
  3823. };
  3824. Set.prototype.toString = function toString () {
  3825. return this.__toString('Set {', '}');
  3826. };
  3827. // @pragma Access
  3828. Set.prototype.has = function has (value) {
  3829. return this._map.has(value);
  3830. };
  3831. // @pragma Modification
  3832. Set.prototype.add = function add (value) {
  3833. return updateSet(this, this._map.set(value, value));
  3834. };
  3835. Set.prototype.remove = function remove (value) {
  3836. return updateSet(this, this._map.remove(value));
  3837. };
  3838. Set.prototype.clear = function clear () {
  3839. return updateSet(this, this._map.clear());
  3840. };
  3841. // @pragma Composition
  3842. Set.prototype.map = function map (mapper, context) {
  3843. var this$1$1 = this;
  3844. // keep track if the set is altered by the map function
  3845. var didChanges = false;
  3846. var newMap = updateSet(
  3847. this,
  3848. this._map.mapEntries(function (ref) {
  3849. var v = ref[1];
  3850. var mapped = mapper.call(context, v, v, this$1$1);
  3851. if (mapped !== v) {
  3852. didChanges = true;
  3853. }
  3854. return [mapped, mapped];
  3855. }, context)
  3856. );
  3857. return didChanges ? newMap : this;
  3858. };
  3859. Set.prototype.union = function union () {
  3860. var iters = [], len = arguments.length;
  3861. while ( len-- ) iters[ len ] = arguments[ len ];
  3862. iters = iters.filter(function (x) { return x.size !== 0; });
  3863. if (iters.length === 0) {
  3864. return this;
  3865. }
  3866. if (this.size === 0 && !this.__ownerID && iters.length === 1) {
  3867. return this.constructor(iters[0]);
  3868. }
  3869. return this.withMutations(function (set) {
  3870. for (var ii = 0; ii < iters.length; ii++) {
  3871. if (typeof iters[ii] === 'string') {
  3872. set.add(iters[ii]);
  3873. } else {
  3874. SetCollection(iters[ii]).forEach(function (value) { return set.add(value); });
  3875. }
  3876. }
  3877. });
  3878. };
  3879. Set.prototype.intersect = function intersect () {
  3880. var iters = [], len = arguments.length;
  3881. while ( len-- ) iters[ len ] = arguments[ len ];
  3882. if (iters.length === 0) {
  3883. return this;
  3884. }
  3885. iters = iters.map(function (iter) { return SetCollection(iter); });
  3886. var toRemove = [];
  3887. this.forEach(function (value) {
  3888. if (!iters.every(function (iter) { return iter.includes(value); })) {
  3889. toRemove.push(value);
  3890. }
  3891. });
  3892. return this.withMutations(function (set) {
  3893. toRemove.forEach(function (value) {
  3894. set.remove(value);
  3895. });
  3896. });
  3897. };
  3898. Set.prototype.subtract = function subtract () {
  3899. var iters = [], len = arguments.length;
  3900. while ( len-- ) iters[ len ] = arguments[ len ];
  3901. if (iters.length === 0) {
  3902. return this;
  3903. }
  3904. iters = iters.map(function (iter) { return SetCollection(iter); });
  3905. var toRemove = [];
  3906. this.forEach(function (value) {
  3907. if (iters.some(function (iter) { return iter.includes(value); })) {
  3908. toRemove.push(value);
  3909. }
  3910. });
  3911. return this.withMutations(function (set) {
  3912. toRemove.forEach(function (value) {
  3913. set.remove(value);
  3914. });
  3915. });
  3916. };
  3917. Set.prototype.sort = function sort (comparator) {
  3918. // Late binding
  3919. return OrderedSet(sortFactory(this, comparator));
  3920. };
  3921. Set.prototype.sortBy = function sortBy (mapper, comparator) {
  3922. // Late binding
  3923. return OrderedSet(sortFactory(this, comparator, mapper));
  3924. };
  3925. Set.prototype.wasAltered = function wasAltered () {
  3926. return this._map.wasAltered();
  3927. };
  3928. Set.prototype.__iterate = function __iterate (fn, reverse) {
  3929. var this$1$1 = this;
  3930. return this._map.__iterate(function (k) { return fn(k, k, this$1$1); }, reverse);
  3931. };
  3932. Set.prototype.__iterator = function __iterator (type, reverse) {
  3933. return this._map.__iterator(type, reverse);
  3934. };
  3935. Set.prototype.__ensureOwner = function __ensureOwner (ownerID) {
  3936. if (ownerID === this.__ownerID) {
  3937. return this;
  3938. }
  3939. var newMap = this._map.__ensureOwner(ownerID);
  3940. if (!ownerID) {
  3941. if (this.size === 0) {
  3942. return this.__empty();
  3943. }
  3944. this.__ownerID = ownerID;
  3945. this._map = newMap;
  3946. return this;
  3947. }
  3948. return this.__make(newMap, ownerID);
  3949. };
  3950. return Set;
  3951. }(SetCollection));
  3952. Set.isSet = isSet;
  3953. var SetPrototype = Set.prototype;
  3954. SetPrototype[IS_SET_SYMBOL] = true;
  3955. SetPrototype[DELETE] = SetPrototype.remove;
  3956. SetPrototype.merge = SetPrototype.concat = SetPrototype.union;
  3957. SetPrototype.withMutations = withMutations;
  3958. SetPrototype.asImmutable = asImmutable;
  3959. SetPrototype['@@transducer/init'] = SetPrototype.asMutable = asMutable;
  3960. SetPrototype['@@transducer/step'] = function (result, arr) {
  3961. return result.add(arr);
  3962. };
  3963. SetPrototype['@@transducer/result'] = function (obj) {
  3964. return obj.asImmutable();
  3965. };
  3966. SetPrototype.__empty = emptySet;
  3967. SetPrototype.__make = makeSet;
  3968. function updateSet(set, newMap) {
  3969. if (set.__ownerID) {
  3970. set.size = newMap.size;
  3971. set._map = newMap;
  3972. return set;
  3973. }
  3974. return newMap === set._map
  3975. ? set
  3976. : newMap.size === 0
  3977. ? set.__empty()
  3978. : set.__make(newMap);
  3979. }
  3980. function makeSet(map, ownerID) {
  3981. var set = Object.create(SetPrototype);
  3982. set.size = map ? map.size : 0;
  3983. set._map = map;
  3984. set.__ownerID = ownerID;
  3985. return set;
  3986. }
  3987. var EMPTY_SET;
  3988. function emptySet() {
  3989. return EMPTY_SET || (EMPTY_SET = makeSet(emptyMap()));
  3990. }
  3991. /**
  3992. * Returns a lazy seq of nums from start (inclusive) to end
  3993. * (exclusive), by step, where start defaults to 0, step to 1, and end to
  3994. * infinity. When start is equal to end, returns empty list.
  3995. */
  3996. var Range = /*@__PURE__*/(function (IndexedSeq) {
  3997. function Range(start, end, step) {
  3998. if (!(this instanceof Range)) {
  3999. return new Range(start, end, step);
  4000. }
  4001. invariant(step !== 0, 'Cannot step a Range by 0');
  4002. start = start || 0;
  4003. if (end === undefined) {
  4004. end = Infinity;
  4005. }
  4006. step = step === undefined ? 1 : Math.abs(step);
  4007. if (end < start) {
  4008. step = -step;
  4009. }
  4010. this._start = start;
  4011. this._end = end;
  4012. this._step = step;
  4013. this.size = Math.max(0, Math.ceil((end - start) / step - 1) + 1);
  4014. if (this.size === 0) {
  4015. if (EMPTY_RANGE) {
  4016. return EMPTY_RANGE;
  4017. }
  4018. EMPTY_RANGE = this;
  4019. }
  4020. }
  4021. if ( IndexedSeq ) Range.__proto__ = IndexedSeq;
  4022. Range.prototype = Object.create( IndexedSeq && IndexedSeq.prototype );
  4023. Range.prototype.constructor = Range;
  4024. Range.prototype.toString = function toString () {
  4025. if (this.size === 0) {
  4026. return 'Range []';
  4027. }
  4028. return (
  4029. 'Range [ ' +
  4030. this._start +
  4031. '...' +
  4032. this._end +
  4033. (this._step !== 1 ? ' by ' + this._step : '') +
  4034. ' ]'
  4035. );
  4036. };
  4037. Range.prototype.get = function get (index, notSetValue) {
  4038. return this.has(index)
  4039. ? this._start + wrapIndex(this, index) * this._step
  4040. : notSetValue;
  4041. };
  4042. Range.prototype.includes = function includes (searchValue) {
  4043. var possibleIndex = (searchValue - this._start) / this._step;
  4044. return (
  4045. possibleIndex >= 0 &&
  4046. possibleIndex < this.size &&
  4047. possibleIndex === Math.floor(possibleIndex)
  4048. );
  4049. };
  4050. Range.prototype.slice = function slice (begin, end) {
  4051. if (wholeSlice(begin, end, this.size)) {
  4052. return this;
  4053. }
  4054. begin = resolveBegin(begin, this.size);
  4055. end = resolveEnd(end, this.size);
  4056. if (end <= begin) {
  4057. return new Range(0, 0);
  4058. }
  4059. return new Range(
  4060. this.get(begin, this._end),
  4061. this.get(end, this._end),
  4062. this._step
  4063. );
  4064. };
  4065. Range.prototype.indexOf = function indexOf (searchValue) {
  4066. var offsetValue = searchValue - this._start;
  4067. if (offsetValue % this._step === 0) {
  4068. var index = offsetValue / this._step;
  4069. if (index >= 0 && index < this.size) {
  4070. return index;
  4071. }
  4072. }
  4073. return -1;
  4074. };
  4075. Range.prototype.lastIndexOf = function lastIndexOf (searchValue) {
  4076. return this.indexOf(searchValue);
  4077. };
  4078. Range.prototype.__iterate = function __iterate (fn, reverse) {
  4079. var size = this.size;
  4080. var step = this._step;
  4081. var value = reverse ? this._start + (size - 1) * step : this._start;
  4082. var i = 0;
  4083. while (i !== size) {
  4084. if (fn(value, reverse ? size - ++i : i++, this) === false) {
  4085. break;
  4086. }
  4087. value += reverse ? -step : step;
  4088. }
  4089. return i;
  4090. };
  4091. Range.prototype.__iterator = function __iterator (type, reverse) {
  4092. var size = this.size;
  4093. var step = this._step;
  4094. var value = reverse ? this._start + (size - 1) * step : this._start;
  4095. var i = 0;
  4096. return new Iterator(function () {
  4097. if (i === size) {
  4098. return iteratorDone();
  4099. }
  4100. var v = value;
  4101. value += reverse ? -step : step;
  4102. return iteratorValue(type, reverse ? size - ++i : i++, v);
  4103. });
  4104. };
  4105. Range.prototype.equals = function equals (other) {
  4106. return other instanceof Range
  4107. ? this._start === other._start &&
  4108. this._end === other._end &&
  4109. this._step === other._step
  4110. : deepEqual(this, other);
  4111. };
  4112. return Range;
  4113. }(IndexedSeq));
  4114. var EMPTY_RANGE;
  4115. function getIn$1(collection, searchKeyPath, notSetValue) {
  4116. var keyPath = coerceKeyPath(searchKeyPath);
  4117. var i = 0;
  4118. while (i !== keyPath.length) {
  4119. collection = get(collection, keyPath[i++], NOT_SET);
  4120. if (collection === NOT_SET) {
  4121. return notSetValue;
  4122. }
  4123. }
  4124. return collection;
  4125. }
  4126. function getIn(searchKeyPath, notSetValue) {
  4127. return getIn$1(this, searchKeyPath, notSetValue);
  4128. }
  4129. function hasIn$1(collection, keyPath) {
  4130. return getIn$1(collection, keyPath, NOT_SET) !== NOT_SET;
  4131. }
  4132. function hasIn(searchKeyPath) {
  4133. return hasIn$1(this, searchKeyPath);
  4134. }
  4135. function toObject() {
  4136. assertNotInfinite(this.size);
  4137. var object = {};
  4138. this.__iterate(function (v, k) {
  4139. object[k] = v;
  4140. });
  4141. return object;
  4142. }
  4143. // Note: all of these methods are deprecated.
  4144. Collection.isIterable = isCollection;
  4145. Collection.isKeyed = isKeyed;
  4146. Collection.isIndexed = isIndexed;
  4147. Collection.isAssociative = isAssociative;
  4148. Collection.isOrdered = isOrdered;
  4149. Collection.Iterator = Iterator;
  4150. mixin(Collection, {
  4151. // ### Conversion to other types
  4152. toArray: function toArray() {
  4153. assertNotInfinite(this.size);
  4154. var array = new Array(this.size || 0);
  4155. var useTuples = isKeyed(this);
  4156. var i = 0;
  4157. this.__iterate(function (v, k) {
  4158. // Keyed collections produce an array of tuples.
  4159. array[i++] = useTuples ? [k, v] : v;
  4160. });
  4161. return array;
  4162. },
  4163. toIndexedSeq: function toIndexedSeq() {
  4164. return new ToIndexedSequence(this);
  4165. },
  4166. toJS: function toJS$1() {
  4167. return toJS(this);
  4168. },
  4169. toKeyedSeq: function toKeyedSeq() {
  4170. return new ToKeyedSequence(this, true);
  4171. },
  4172. toMap: function toMap() {
  4173. // Use Late Binding here to solve the circular dependency.
  4174. return Map(this.toKeyedSeq());
  4175. },
  4176. toObject: toObject,
  4177. toOrderedMap: function toOrderedMap() {
  4178. // Use Late Binding here to solve the circular dependency.
  4179. return OrderedMap(this.toKeyedSeq());
  4180. },
  4181. toOrderedSet: function toOrderedSet() {
  4182. // Use Late Binding here to solve the circular dependency.
  4183. return OrderedSet(isKeyed(this) ? this.valueSeq() : this);
  4184. },
  4185. toSet: function toSet() {
  4186. // Use Late Binding here to solve the circular dependency.
  4187. return Set(isKeyed(this) ? this.valueSeq() : this);
  4188. },
  4189. toSetSeq: function toSetSeq() {
  4190. return new ToSetSequence(this);
  4191. },
  4192. toSeq: function toSeq() {
  4193. return isIndexed(this)
  4194. ? this.toIndexedSeq()
  4195. : isKeyed(this)
  4196. ? this.toKeyedSeq()
  4197. : this.toSetSeq();
  4198. },
  4199. toStack: function toStack() {
  4200. // Use Late Binding here to solve the circular dependency.
  4201. return Stack(isKeyed(this) ? this.valueSeq() : this);
  4202. },
  4203. toList: function toList() {
  4204. // Use Late Binding here to solve the circular dependency.
  4205. return List(isKeyed(this) ? this.valueSeq() : this);
  4206. },
  4207. // ### Common JavaScript methods and properties
  4208. toString: function toString() {
  4209. return '[Collection]';
  4210. },
  4211. __toString: function __toString(head, tail) {
  4212. if (this.size === 0) {
  4213. return head + tail;
  4214. }
  4215. return (
  4216. head +
  4217. ' ' +
  4218. this.toSeq().map(this.__toStringMapper).join(', ') +
  4219. ' ' +
  4220. tail
  4221. );
  4222. },
  4223. // ### ES6 Collection methods (ES6 Array and Map)
  4224. concat: function concat() {
  4225. var values = [], len = arguments.length;
  4226. while ( len-- ) values[ len ] = arguments[ len ];
  4227. return reify(this, concatFactory(this, values));
  4228. },
  4229. includes: function includes(searchValue) {
  4230. return this.some(function (value) { return is(value, searchValue); });
  4231. },
  4232. entries: function entries() {
  4233. return this.__iterator(ITERATE_ENTRIES);
  4234. },
  4235. every: function every(predicate, context) {
  4236. assertNotInfinite(this.size);
  4237. var returnValue = true;
  4238. this.__iterate(function (v, k, c) {
  4239. if (!predicate.call(context, v, k, c)) {
  4240. returnValue = false;
  4241. return false;
  4242. }
  4243. });
  4244. return returnValue;
  4245. },
  4246. filter: function filter(predicate, context) {
  4247. return reify(this, filterFactory(this, predicate, context, true));
  4248. },
  4249. partition: function partition(predicate, context) {
  4250. return partitionFactory(this, predicate, context);
  4251. },
  4252. find: function find(predicate, context, notSetValue) {
  4253. var entry = this.findEntry(predicate, context);
  4254. return entry ? entry[1] : notSetValue;
  4255. },
  4256. forEach: function forEach(sideEffect, context) {
  4257. assertNotInfinite(this.size);
  4258. return this.__iterate(context ? sideEffect.bind(context) : sideEffect);
  4259. },
  4260. join: function join(separator) {
  4261. assertNotInfinite(this.size);
  4262. separator = separator !== undefined ? '' + separator : ',';
  4263. var joined = '';
  4264. var isFirst = true;
  4265. this.__iterate(function (v) {
  4266. isFirst ? (isFirst = false) : (joined += separator);
  4267. joined += v !== null && v !== undefined ? v.toString() : '';
  4268. });
  4269. return joined;
  4270. },
  4271. keys: function keys() {
  4272. return this.__iterator(ITERATE_KEYS);
  4273. },
  4274. map: function map(mapper, context) {
  4275. return reify(this, mapFactory(this, mapper, context));
  4276. },
  4277. reduce: function reduce$1(reducer, initialReduction, context) {
  4278. return reduce(
  4279. this,
  4280. reducer,
  4281. initialReduction,
  4282. context,
  4283. arguments.length < 2,
  4284. false
  4285. );
  4286. },
  4287. reduceRight: function reduceRight(reducer, initialReduction, context) {
  4288. return reduce(
  4289. this,
  4290. reducer,
  4291. initialReduction,
  4292. context,
  4293. arguments.length < 2,
  4294. true
  4295. );
  4296. },
  4297. reverse: function reverse() {
  4298. return reify(this, reverseFactory(this, true));
  4299. },
  4300. slice: function slice(begin, end) {
  4301. return reify(this, sliceFactory(this, begin, end, true));
  4302. },
  4303. some: function some(predicate, context) {
  4304. assertNotInfinite(this.size);
  4305. var returnValue = false;
  4306. this.__iterate(function (v, k, c) {
  4307. if (predicate.call(context, v, k, c)) {
  4308. returnValue = true;
  4309. return false;
  4310. }
  4311. });
  4312. return returnValue;
  4313. },
  4314. sort: function sort(comparator) {
  4315. return reify(this, sortFactory(this, comparator));
  4316. },
  4317. values: function values() {
  4318. return this.__iterator(ITERATE_VALUES);
  4319. },
  4320. // ### More sequential methods
  4321. butLast: function butLast() {
  4322. return this.slice(0, -1);
  4323. },
  4324. isEmpty: function isEmpty() {
  4325. return this.size !== undefined ? this.size === 0 : !this.some(function () { return true; });
  4326. },
  4327. count: function count(predicate, context) {
  4328. return ensureSize(
  4329. predicate ? this.toSeq().filter(predicate, context) : this
  4330. );
  4331. },
  4332. countBy: function countBy(grouper, context) {
  4333. return countByFactory(this, grouper, context);
  4334. },
  4335. equals: function equals(other) {
  4336. return deepEqual(this, other);
  4337. },
  4338. entrySeq: function entrySeq() {
  4339. var collection = this;
  4340. if (collection._cache) {
  4341. // We cache as an entries array, so we can just return the cache!
  4342. return new ArraySeq(collection._cache);
  4343. }
  4344. var entriesSequence = collection.toSeq().map(entryMapper).toIndexedSeq();
  4345. entriesSequence.fromEntrySeq = function () { return collection.toSeq(); };
  4346. return entriesSequence;
  4347. },
  4348. filterNot: function filterNot(predicate, context) {
  4349. return this.filter(not(predicate), context);
  4350. },
  4351. findEntry: function findEntry(predicate, context, notSetValue) {
  4352. var found = notSetValue;
  4353. this.__iterate(function (v, k, c) {
  4354. if (predicate.call(context, v, k, c)) {
  4355. found = [k, v];
  4356. return false;
  4357. }
  4358. });
  4359. return found;
  4360. },
  4361. findKey: function findKey(predicate, context) {
  4362. var entry = this.findEntry(predicate, context);
  4363. return entry && entry[0];
  4364. },
  4365. findLast: function findLast(predicate, context, notSetValue) {
  4366. return this.toKeyedSeq().reverse().find(predicate, context, notSetValue);
  4367. },
  4368. findLastEntry: function findLastEntry(predicate, context, notSetValue) {
  4369. return this.toKeyedSeq()
  4370. .reverse()
  4371. .findEntry(predicate, context, notSetValue);
  4372. },
  4373. findLastKey: function findLastKey(predicate, context) {
  4374. return this.toKeyedSeq().reverse().findKey(predicate, context);
  4375. },
  4376. first: function first(notSetValue) {
  4377. return this.find(returnTrue, null, notSetValue);
  4378. },
  4379. flatMap: function flatMap(mapper, context) {
  4380. return reify(this, flatMapFactory(this, mapper, context));
  4381. },
  4382. flatten: function flatten(depth) {
  4383. return reify(this, flattenFactory(this, depth, true));
  4384. },
  4385. fromEntrySeq: function fromEntrySeq() {
  4386. return new FromEntriesSequence(this);
  4387. },
  4388. get: function get(searchKey, notSetValue) {
  4389. return this.find(function (_, key) { return is(key, searchKey); }, undefined, notSetValue);
  4390. },
  4391. getIn: getIn,
  4392. groupBy: function groupBy(grouper, context) {
  4393. return groupByFactory(this, grouper, context);
  4394. },
  4395. has: function has(searchKey) {
  4396. return this.get(searchKey, NOT_SET) !== NOT_SET;
  4397. },
  4398. hasIn: hasIn,
  4399. isSubset: function isSubset(iter) {
  4400. iter = typeof iter.includes === 'function' ? iter : Collection(iter);
  4401. return this.every(function (value) { return iter.includes(value); });
  4402. },
  4403. isSuperset: function isSuperset(iter) {
  4404. iter = typeof iter.isSubset === 'function' ? iter : Collection(iter);
  4405. return iter.isSubset(this);
  4406. },
  4407. keyOf: function keyOf(searchValue) {
  4408. return this.findKey(function (value) { return is(value, searchValue); });
  4409. },
  4410. keySeq: function keySeq() {
  4411. return this.toSeq().map(keyMapper).toIndexedSeq();
  4412. },
  4413. last: function last(notSetValue) {
  4414. return this.toSeq().reverse().first(notSetValue);
  4415. },
  4416. lastKeyOf: function lastKeyOf(searchValue) {
  4417. return this.toKeyedSeq().reverse().keyOf(searchValue);
  4418. },
  4419. max: function max(comparator) {
  4420. return maxFactory(this, comparator);
  4421. },
  4422. maxBy: function maxBy(mapper, comparator) {
  4423. return maxFactory(this, comparator, mapper);
  4424. },
  4425. min: function min(comparator) {
  4426. return maxFactory(
  4427. this,
  4428. comparator ? neg(comparator) : defaultNegComparator
  4429. );
  4430. },
  4431. minBy: function minBy(mapper, comparator) {
  4432. return maxFactory(
  4433. this,
  4434. comparator ? neg(comparator) : defaultNegComparator,
  4435. mapper
  4436. );
  4437. },
  4438. rest: function rest() {
  4439. return this.slice(1);
  4440. },
  4441. skip: function skip(amount) {
  4442. return amount === 0 ? this : this.slice(Math.max(0, amount));
  4443. },
  4444. skipLast: function skipLast(amount) {
  4445. return amount === 0 ? this : this.slice(0, -Math.max(0, amount));
  4446. },
  4447. skipWhile: function skipWhile(predicate, context) {
  4448. return reify(this, skipWhileFactory(this, predicate, context, true));
  4449. },
  4450. skipUntil: function skipUntil(predicate, context) {
  4451. return this.skipWhile(not(predicate), context);
  4452. },
  4453. sortBy: function sortBy(mapper, comparator) {
  4454. return reify(this, sortFactory(this, comparator, mapper));
  4455. },
  4456. take: function take(amount) {
  4457. return this.slice(0, Math.max(0, amount));
  4458. },
  4459. takeLast: function takeLast(amount) {
  4460. return this.slice(-Math.max(0, amount));
  4461. },
  4462. takeWhile: function takeWhile(predicate, context) {
  4463. return reify(this, takeWhileFactory(this, predicate, context));
  4464. },
  4465. takeUntil: function takeUntil(predicate, context) {
  4466. return this.takeWhile(not(predicate), context);
  4467. },
  4468. update: function update(fn) {
  4469. return fn(this);
  4470. },
  4471. valueSeq: function valueSeq() {
  4472. return this.toIndexedSeq();
  4473. },
  4474. // ### Hashable Object
  4475. hashCode: function hashCode() {
  4476. return this.__hash || (this.__hash = hashCollection(this));
  4477. },
  4478. // ### Internal
  4479. // abstract __iterate(fn, reverse)
  4480. // abstract __iterator(type, reverse)
  4481. });
  4482. var CollectionPrototype = Collection.prototype;
  4483. CollectionPrototype[IS_COLLECTION_SYMBOL] = true;
  4484. CollectionPrototype[ITERATOR_SYMBOL] = CollectionPrototype.values;
  4485. CollectionPrototype.toJSON = CollectionPrototype.toArray;
  4486. CollectionPrototype.__toStringMapper = quoteString;
  4487. CollectionPrototype.inspect = CollectionPrototype.toSource = function () {
  4488. return this.toString();
  4489. };
  4490. CollectionPrototype.chain = CollectionPrototype.flatMap;
  4491. CollectionPrototype.contains = CollectionPrototype.includes;
  4492. mixin(KeyedCollection, {
  4493. // ### More sequential methods
  4494. flip: function flip() {
  4495. return reify(this, flipFactory(this));
  4496. },
  4497. mapEntries: function mapEntries(mapper, context) {
  4498. var this$1$1 = this;
  4499. var iterations = 0;
  4500. return reify(
  4501. this,
  4502. this.toSeq()
  4503. .map(function (v, k) { return mapper.call(context, [k, v], iterations++, this$1$1); })
  4504. .fromEntrySeq()
  4505. );
  4506. },
  4507. mapKeys: function mapKeys(mapper, context) {
  4508. var this$1$1 = this;
  4509. return reify(
  4510. this,
  4511. this.toSeq()
  4512. .flip()
  4513. .map(function (k, v) { return mapper.call(context, k, v, this$1$1); })
  4514. .flip()
  4515. );
  4516. },
  4517. });
  4518. var KeyedCollectionPrototype = KeyedCollection.prototype;
  4519. KeyedCollectionPrototype[IS_KEYED_SYMBOL] = true;
  4520. KeyedCollectionPrototype[ITERATOR_SYMBOL] = CollectionPrototype.entries;
  4521. KeyedCollectionPrototype.toJSON = toObject;
  4522. KeyedCollectionPrototype.__toStringMapper = function (v, k) { return quoteString(k) + ': ' + quoteString(v); };
  4523. mixin(IndexedCollection, {
  4524. // ### Conversion to other types
  4525. toKeyedSeq: function toKeyedSeq() {
  4526. return new ToKeyedSequence(this, false);
  4527. },
  4528. // ### ES6 Collection methods (ES6 Array and Map)
  4529. filter: function filter(predicate, context) {
  4530. return reify(this, filterFactory(this, predicate, context, false));
  4531. },
  4532. findIndex: function findIndex(predicate, context) {
  4533. var entry = this.findEntry(predicate, context);
  4534. return entry ? entry[0] : -1;
  4535. },
  4536. indexOf: function indexOf(searchValue) {
  4537. var key = this.keyOf(searchValue);
  4538. return key === undefined ? -1 : key;
  4539. },
  4540. lastIndexOf: function lastIndexOf(searchValue) {
  4541. var key = this.lastKeyOf(searchValue);
  4542. return key === undefined ? -1 : key;
  4543. },
  4544. reverse: function reverse() {
  4545. return reify(this, reverseFactory(this, false));
  4546. },
  4547. slice: function slice(begin, end) {
  4548. return reify(this, sliceFactory(this, begin, end, false));
  4549. },
  4550. splice: function splice(index, removeNum /*, ...values*/) {
  4551. var numArgs = arguments.length;
  4552. removeNum = Math.max(removeNum || 0, 0);
  4553. if (numArgs === 0 || (numArgs === 2 && !removeNum)) {
  4554. return this;
  4555. }
  4556. // If index is negative, it should resolve relative to the size of the
  4557. // collection. However size may be expensive to compute if not cached, so
  4558. // only call count() if the number is in fact negative.
  4559. index = resolveBegin(index, index < 0 ? this.count() : this.size);
  4560. var spliced = this.slice(0, index);
  4561. return reify(
  4562. this,
  4563. numArgs === 1
  4564. ? spliced
  4565. : spliced.concat(arrCopy(arguments, 2), this.slice(index + removeNum))
  4566. );
  4567. },
  4568. // ### More collection methods
  4569. findLastIndex: function findLastIndex(predicate, context) {
  4570. var entry = this.findLastEntry(predicate, context);
  4571. return entry ? entry[0] : -1;
  4572. },
  4573. first: function first(notSetValue) {
  4574. return this.get(0, notSetValue);
  4575. },
  4576. flatten: function flatten(depth) {
  4577. return reify(this, flattenFactory(this, depth, false));
  4578. },
  4579. get: function get(index, notSetValue) {
  4580. index = wrapIndex(this, index);
  4581. return index < 0 ||
  4582. this.size === Infinity ||
  4583. (this.size !== undefined && index > this.size)
  4584. ? notSetValue
  4585. : this.find(function (_, key) { return key === index; }, undefined, notSetValue);
  4586. },
  4587. has: function has(index) {
  4588. index = wrapIndex(this, index);
  4589. return (
  4590. index >= 0 &&
  4591. (this.size !== undefined
  4592. ? this.size === Infinity || index < this.size
  4593. : this.indexOf(index) !== -1)
  4594. );
  4595. },
  4596. interpose: function interpose(separator) {
  4597. return reify(this, interposeFactory(this, separator));
  4598. },
  4599. interleave: function interleave(/*...collections*/) {
  4600. var collections = [this].concat(arrCopy(arguments));
  4601. var zipped = zipWithFactory(this.toSeq(), IndexedSeq.of, collections);
  4602. var interleaved = zipped.flatten(true);
  4603. if (zipped.size) {
  4604. interleaved.size = zipped.size * collections.length;
  4605. }
  4606. return reify(this, interleaved);
  4607. },
  4608. keySeq: function keySeq() {
  4609. return Range(0, this.size);
  4610. },
  4611. last: function last(notSetValue) {
  4612. return this.get(-1, notSetValue);
  4613. },
  4614. skipWhile: function skipWhile(predicate, context) {
  4615. return reify(this, skipWhileFactory(this, predicate, context, false));
  4616. },
  4617. zip: function zip(/*, ...collections */) {
  4618. var collections = [this].concat(arrCopy(arguments));
  4619. return reify(this, zipWithFactory(this, defaultZipper, collections));
  4620. },
  4621. zipAll: function zipAll(/*, ...collections */) {
  4622. var collections = [this].concat(arrCopy(arguments));
  4623. return reify(this, zipWithFactory(this, defaultZipper, collections, true));
  4624. },
  4625. zipWith: function zipWith(zipper /*, ...collections */) {
  4626. var collections = arrCopy(arguments);
  4627. collections[0] = this;
  4628. return reify(this, zipWithFactory(this, zipper, collections));
  4629. },
  4630. });
  4631. var IndexedCollectionPrototype = IndexedCollection.prototype;
  4632. IndexedCollectionPrototype[IS_INDEXED_SYMBOL] = true;
  4633. IndexedCollectionPrototype[IS_ORDERED_SYMBOL] = true;
  4634. mixin(SetCollection, {
  4635. // ### ES6 Collection methods (ES6 Array and Map)
  4636. get: function get(value, notSetValue) {
  4637. return this.has(value) ? value : notSetValue;
  4638. },
  4639. includes: function includes(value) {
  4640. return this.has(value);
  4641. },
  4642. // ### More sequential methods
  4643. keySeq: function keySeq() {
  4644. return this.valueSeq();
  4645. },
  4646. });
  4647. var SetCollectionPrototype = SetCollection.prototype;
  4648. SetCollectionPrototype.has = CollectionPrototype.includes;
  4649. SetCollectionPrototype.contains = SetCollectionPrototype.includes;
  4650. SetCollectionPrototype.keys = SetCollectionPrototype.values;
  4651. // Mixin subclasses
  4652. mixin(KeyedSeq, KeyedCollectionPrototype);
  4653. mixin(IndexedSeq, IndexedCollectionPrototype);
  4654. mixin(SetSeq, SetCollectionPrototype);
  4655. // #pragma Helper functions
  4656. function reduce(collection, reducer, reduction, context, useFirst, reverse) {
  4657. assertNotInfinite(collection.size);
  4658. collection.__iterate(function (v, k, c) {
  4659. if (useFirst) {
  4660. useFirst = false;
  4661. reduction = v;
  4662. } else {
  4663. reduction = reducer.call(context, reduction, v, k, c);
  4664. }
  4665. }, reverse);
  4666. return reduction;
  4667. }
  4668. function keyMapper(v, k) {
  4669. return k;
  4670. }
  4671. function entryMapper(v, k) {
  4672. return [k, v];
  4673. }
  4674. function not(predicate) {
  4675. return function () {
  4676. return !predicate.apply(this, arguments);
  4677. };
  4678. }
  4679. function neg(predicate) {
  4680. return function () {
  4681. return -predicate.apply(this, arguments);
  4682. };
  4683. }
  4684. function defaultZipper() {
  4685. return arrCopy(arguments);
  4686. }
  4687. function defaultNegComparator(a, b) {
  4688. return a < b ? 1 : a > b ? -1 : 0;
  4689. }
  4690. function hashCollection(collection) {
  4691. if (collection.size === Infinity) {
  4692. return 0;
  4693. }
  4694. var ordered = isOrdered(collection);
  4695. var keyed = isKeyed(collection);
  4696. var h = ordered ? 1 : 0;
  4697. var size = collection.__iterate(
  4698. keyed
  4699. ? ordered
  4700. ? function (v, k) {
  4701. h = (31 * h + hashMerge(hash(v), hash(k))) | 0;
  4702. }
  4703. : function (v, k) {
  4704. h = (h + hashMerge(hash(v), hash(k))) | 0;
  4705. }
  4706. : ordered
  4707. ? function (v) {
  4708. h = (31 * h + hash(v)) | 0;
  4709. }
  4710. : function (v) {
  4711. h = (h + hash(v)) | 0;
  4712. }
  4713. );
  4714. return murmurHashOfSize(size, h);
  4715. }
  4716. function murmurHashOfSize(size, h) {
  4717. h = imul(h, 0xcc9e2d51);
  4718. h = imul((h << 15) | (h >>> -15), 0x1b873593);
  4719. h = imul((h << 13) | (h >>> -13), 5);
  4720. h = ((h + 0xe6546b64) | 0) ^ size;
  4721. h = imul(h ^ (h >>> 16), 0x85ebca6b);
  4722. h = imul(h ^ (h >>> 13), 0xc2b2ae35);
  4723. h = smi(h ^ (h >>> 16));
  4724. return h;
  4725. }
  4726. function hashMerge(a, b) {
  4727. return (a ^ (b + 0x9e3779b9 + (a << 6) + (a >> 2))) | 0; // int
  4728. }
  4729. var OrderedSet = /*@__PURE__*/(function (Set) {
  4730. function OrderedSet(value) {
  4731. return value === undefined || value === null
  4732. ? emptyOrderedSet()
  4733. : isOrderedSet(value)
  4734. ? value
  4735. : emptyOrderedSet().withMutations(function (set) {
  4736. var iter = SetCollection(value);
  4737. assertNotInfinite(iter.size);
  4738. iter.forEach(function (v) { return set.add(v); });
  4739. });
  4740. }
  4741. if ( Set ) OrderedSet.__proto__ = Set;
  4742. OrderedSet.prototype = Object.create( Set && Set.prototype );
  4743. OrderedSet.prototype.constructor = OrderedSet;
  4744. OrderedSet.of = function of (/*...values*/) {
  4745. return this(arguments);
  4746. };
  4747. OrderedSet.fromKeys = function fromKeys (value) {
  4748. return this(KeyedCollection(value).keySeq());
  4749. };
  4750. OrderedSet.prototype.toString = function toString () {
  4751. return this.__toString('OrderedSet {', '}');
  4752. };
  4753. return OrderedSet;
  4754. }(Set));
  4755. OrderedSet.isOrderedSet = isOrderedSet;
  4756. var OrderedSetPrototype = OrderedSet.prototype;
  4757. OrderedSetPrototype[IS_ORDERED_SYMBOL] = true;
  4758. OrderedSetPrototype.zip = IndexedCollectionPrototype.zip;
  4759. OrderedSetPrototype.zipWith = IndexedCollectionPrototype.zipWith;
  4760. OrderedSetPrototype.zipAll = IndexedCollectionPrototype.zipAll;
  4761. OrderedSetPrototype.__empty = emptyOrderedSet;
  4762. OrderedSetPrototype.__make = makeOrderedSet;
  4763. function makeOrderedSet(map, ownerID) {
  4764. var set = Object.create(OrderedSetPrototype);
  4765. set.size = map ? map.size : 0;
  4766. set._map = map;
  4767. set.__ownerID = ownerID;
  4768. return set;
  4769. }
  4770. var EMPTY_ORDERED_SET;
  4771. function emptyOrderedSet() {
  4772. return (
  4773. EMPTY_ORDERED_SET || (EMPTY_ORDERED_SET = makeOrderedSet(emptyOrderedMap()))
  4774. );
  4775. }
  4776. var PairSorting = {
  4777. LeftThenRight: -1,
  4778. RightThenLeft: +1,
  4779. };
  4780. function throwOnInvalidDefaultValues(defaultValues) {
  4781. if (isRecord(defaultValues)) {
  4782. throw new Error(
  4783. 'Can not call `Record` with an immutable Record as default values. Use a plain javascript object instead.'
  4784. );
  4785. }
  4786. if (isImmutable(defaultValues)) {
  4787. throw new Error(
  4788. 'Can not call `Record` with an immutable Collection as default values. Use a plain javascript object instead.'
  4789. );
  4790. }
  4791. if (defaultValues === null || typeof defaultValues !== 'object') {
  4792. throw new Error(
  4793. 'Can not call `Record` with a non-object as default values. Use a plain javascript object instead.'
  4794. );
  4795. }
  4796. }
  4797. var Record = function Record(defaultValues, name) {
  4798. var hasInitialized;
  4799. throwOnInvalidDefaultValues(defaultValues);
  4800. var RecordType = function Record(values) {
  4801. var this$1$1 = this;
  4802. if (values instanceof RecordType) {
  4803. return values;
  4804. }
  4805. if (!(this instanceof RecordType)) {
  4806. return new RecordType(values);
  4807. }
  4808. if (!hasInitialized) {
  4809. hasInitialized = true;
  4810. var keys = Object.keys(defaultValues);
  4811. var indices = (RecordTypePrototype._indices = {});
  4812. // Deprecated: left to attempt not to break any external code which
  4813. // relies on a ._name property existing on record instances.
  4814. // Use Record.getDescriptiveName() instead
  4815. RecordTypePrototype._name = name;
  4816. RecordTypePrototype._keys = keys;
  4817. RecordTypePrototype._defaultValues = defaultValues;
  4818. for (var i = 0; i < keys.length; i++) {
  4819. var propName = keys[i];
  4820. indices[propName] = i;
  4821. if (RecordTypePrototype[propName]) {
  4822. /* eslint-disable no-console */
  4823. typeof console === 'object' &&
  4824. console.warn &&
  4825. console.warn(
  4826. 'Cannot define ' +
  4827. recordName(this) +
  4828. ' with property "' +
  4829. propName +
  4830. '" since that property name is part of the Record API.'
  4831. );
  4832. /* eslint-enable no-console */
  4833. } else {
  4834. setProp(RecordTypePrototype, propName);
  4835. }
  4836. }
  4837. }
  4838. this.__ownerID = undefined;
  4839. this._values = List().withMutations(function (l) {
  4840. l.setSize(this$1$1._keys.length);
  4841. KeyedCollection(values).forEach(function (v, k) {
  4842. l.set(this$1$1._indices[k], v === this$1$1._defaultValues[k] ? undefined : v);
  4843. });
  4844. });
  4845. return this;
  4846. };
  4847. var RecordTypePrototype = (RecordType.prototype =
  4848. Object.create(RecordPrototype));
  4849. RecordTypePrototype.constructor = RecordType;
  4850. if (name) {
  4851. RecordType.displayName = name;
  4852. }
  4853. return RecordType;
  4854. };
  4855. Record.prototype.toString = function toString () {
  4856. var str = recordName(this) + ' { ';
  4857. var keys = this._keys;
  4858. var k;
  4859. for (var i = 0, l = keys.length; i !== l; i++) {
  4860. k = keys[i];
  4861. str += (i ? ', ' : '') + k + ': ' + quoteString(this.get(k));
  4862. }
  4863. return str + ' }';
  4864. };
  4865. Record.prototype.equals = function equals (other) {
  4866. return (
  4867. this === other ||
  4868. (isRecord(other) && recordSeq(this).equals(recordSeq(other)))
  4869. );
  4870. };
  4871. Record.prototype.hashCode = function hashCode () {
  4872. return recordSeq(this).hashCode();
  4873. };
  4874. // @pragma Access
  4875. Record.prototype.has = function has (k) {
  4876. return this._indices.hasOwnProperty(k);
  4877. };
  4878. Record.prototype.get = function get (k, notSetValue) {
  4879. if (!this.has(k)) {
  4880. return notSetValue;
  4881. }
  4882. var index = this._indices[k];
  4883. var value = this._values.get(index);
  4884. return value === undefined ? this._defaultValues[k] : value;
  4885. };
  4886. // @pragma Modification
  4887. Record.prototype.set = function set (k, v) {
  4888. if (this.has(k)) {
  4889. var newValues = this._values.set(
  4890. this._indices[k],
  4891. v === this._defaultValues[k] ? undefined : v
  4892. );
  4893. if (newValues !== this._values && !this.__ownerID) {
  4894. return makeRecord(this, newValues);
  4895. }
  4896. }
  4897. return this;
  4898. };
  4899. Record.prototype.remove = function remove (k) {
  4900. return this.set(k);
  4901. };
  4902. Record.prototype.clear = function clear () {
  4903. var newValues = this._values.clear().setSize(this._keys.length);
  4904. return this.__ownerID ? this : makeRecord(this, newValues);
  4905. };
  4906. Record.prototype.wasAltered = function wasAltered () {
  4907. return this._values.wasAltered();
  4908. };
  4909. Record.prototype.toSeq = function toSeq () {
  4910. return recordSeq(this);
  4911. };
  4912. Record.prototype.toJS = function toJS$1 () {
  4913. return toJS(this);
  4914. };
  4915. Record.prototype.entries = function entries () {
  4916. return this.__iterator(ITERATE_ENTRIES);
  4917. };
  4918. Record.prototype.__iterator = function __iterator (type, reverse) {
  4919. return recordSeq(this).__iterator(type, reverse);
  4920. };
  4921. Record.prototype.__iterate = function __iterate (fn, reverse) {
  4922. return recordSeq(this).__iterate(fn, reverse);
  4923. };
  4924. Record.prototype.__ensureOwner = function __ensureOwner (ownerID) {
  4925. if (ownerID === this.__ownerID) {
  4926. return this;
  4927. }
  4928. var newValues = this._values.__ensureOwner(ownerID);
  4929. if (!ownerID) {
  4930. this.__ownerID = ownerID;
  4931. this._values = newValues;
  4932. return this;
  4933. }
  4934. return makeRecord(this, newValues, ownerID);
  4935. };
  4936. Record.isRecord = isRecord;
  4937. Record.getDescriptiveName = recordName;
  4938. var RecordPrototype = Record.prototype;
  4939. RecordPrototype[IS_RECORD_SYMBOL] = true;
  4940. RecordPrototype[DELETE] = RecordPrototype.remove;
  4941. RecordPrototype.deleteIn = RecordPrototype.removeIn = deleteIn;
  4942. RecordPrototype.getIn = getIn;
  4943. RecordPrototype.hasIn = CollectionPrototype.hasIn;
  4944. RecordPrototype.merge = merge$1;
  4945. RecordPrototype.mergeWith = mergeWith$1;
  4946. RecordPrototype.mergeIn = mergeIn;
  4947. RecordPrototype.mergeDeep = mergeDeep;
  4948. RecordPrototype.mergeDeepWith = mergeDeepWith;
  4949. RecordPrototype.mergeDeepIn = mergeDeepIn;
  4950. RecordPrototype.setIn = setIn;
  4951. RecordPrototype.update = update;
  4952. RecordPrototype.updateIn = updateIn;
  4953. RecordPrototype.withMutations = withMutations;
  4954. RecordPrototype.asMutable = asMutable;
  4955. RecordPrototype.asImmutable = asImmutable;
  4956. RecordPrototype[ITERATOR_SYMBOL] = RecordPrototype.entries;
  4957. RecordPrototype.toJSON = RecordPrototype.toObject =
  4958. CollectionPrototype.toObject;
  4959. RecordPrototype.inspect = RecordPrototype.toSource = function () {
  4960. return this.toString();
  4961. };
  4962. function makeRecord(likeRecord, values, ownerID) {
  4963. var record = Object.create(Object.getPrototypeOf(likeRecord));
  4964. record._values = values;
  4965. record.__ownerID = ownerID;
  4966. return record;
  4967. }
  4968. function recordName(record) {
  4969. return record.constructor.displayName || record.constructor.name || 'Record';
  4970. }
  4971. function recordSeq(record) {
  4972. return keyedSeqFromValue(record._keys.map(function (k) { return [k, record.get(k)]; }));
  4973. }
  4974. function setProp(prototype, name) {
  4975. try {
  4976. Object.defineProperty(prototype, name, {
  4977. get: function () {
  4978. return this.get(name);
  4979. },
  4980. set: function (value) {
  4981. invariant(this.__ownerID, 'Cannot set on an immutable record.');
  4982. this.set(name, value);
  4983. },
  4984. });
  4985. } catch (error) {
  4986. // Object.defineProperty failed. Probably IE8.
  4987. }
  4988. }
  4989. /**
  4990. * Returns a lazy Seq of `value` repeated `times` times. When `times` is
  4991. * undefined, returns an infinite sequence of `value`.
  4992. */
  4993. var Repeat = /*@__PURE__*/(function (IndexedSeq) {
  4994. function Repeat(value, times) {
  4995. if (!(this instanceof Repeat)) {
  4996. return new Repeat(value, times);
  4997. }
  4998. this._value = value;
  4999. this.size = times === undefined ? Infinity : Math.max(0, times);
  5000. if (this.size === 0) {
  5001. if (EMPTY_REPEAT) {
  5002. return EMPTY_REPEAT;
  5003. }
  5004. EMPTY_REPEAT = this;
  5005. }
  5006. }
  5007. if ( IndexedSeq ) Repeat.__proto__ = IndexedSeq;
  5008. Repeat.prototype = Object.create( IndexedSeq && IndexedSeq.prototype );
  5009. Repeat.prototype.constructor = Repeat;
  5010. Repeat.prototype.toString = function toString () {
  5011. if (this.size === 0) {
  5012. return 'Repeat []';
  5013. }
  5014. return 'Repeat [ ' + this._value + ' ' + this.size + ' times ]';
  5015. };
  5016. Repeat.prototype.get = function get (index, notSetValue) {
  5017. return this.has(index) ? this._value : notSetValue;
  5018. };
  5019. Repeat.prototype.includes = function includes (searchValue) {
  5020. return is(this._value, searchValue);
  5021. };
  5022. Repeat.prototype.slice = function slice (begin, end) {
  5023. var size = this.size;
  5024. return wholeSlice(begin, end, size)
  5025. ? this
  5026. : new Repeat(
  5027. this._value,
  5028. resolveEnd(end, size) - resolveBegin(begin, size)
  5029. );
  5030. };
  5031. Repeat.prototype.reverse = function reverse () {
  5032. return this;
  5033. };
  5034. Repeat.prototype.indexOf = function indexOf (searchValue) {
  5035. if (is(this._value, searchValue)) {
  5036. return 0;
  5037. }
  5038. return -1;
  5039. };
  5040. Repeat.prototype.lastIndexOf = function lastIndexOf (searchValue) {
  5041. if (is(this._value, searchValue)) {
  5042. return this.size;
  5043. }
  5044. return -1;
  5045. };
  5046. Repeat.prototype.__iterate = function __iterate (fn, reverse) {
  5047. var size = this.size;
  5048. var i = 0;
  5049. while (i !== size) {
  5050. if (fn(this._value, reverse ? size - ++i : i++, this) === false) {
  5051. break;
  5052. }
  5053. }
  5054. return i;
  5055. };
  5056. Repeat.prototype.__iterator = function __iterator (type, reverse) {
  5057. var this$1$1 = this;
  5058. var size = this.size;
  5059. var i = 0;
  5060. return new Iterator(function () { return i === size
  5061. ? iteratorDone()
  5062. : iteratorValue(type, reverse ? size - ++i : i++, this$1$1._value); }
  5063. );
  5064. };
  5065. Repeat.prototype.equals = function equals (other) {
  5066. return other instanceof Repeat
  5067. ? is(this._value, other._value)
  5068. : deepEqual(other);
  5069. };
  5070. return Repeat;
  5071. }(IndexedSeq));
  5072. var EMPTY_REPEAT;
  5073. function fromJS(value, converter) {
  5074. return fromJSWith(
  5075. [],
  5076. converter || defaultConverter,
  5077. value,
  5078. '',
  5079. converter && converter.length > 2 ? [] : undefined,
  5080. { '': value }
  5081. );
  5082. }
  5083. function fromJSWith(stack, converter, value, key, keyPath, parentValue) {
  5084. if (
  5085. typeof value !== 'string' &&
  5086. !isImmutable(value) &&
  5087. (isArrayLike(value) || hasIterator(value) || isPlainObject(value))
  5088. ) {
  5089. if (~stack.indexOf(value)) {
  5090. throw new TypeError('Cannot convert circular structure to Immutable');
  5091. }
  5092. stack.push(value);
  5093. keyPath && key !== '' && keyPath.push(key);
  5094. var converted = converter.call(
  5095. parentValue,
  5096. key,
  5097. Seq(value).map(function (v, k) { return fromJSWith(stack, converter, v, k, keyPath, value); }
  5098. ),
  5099. keyPath && keyPath.slice()
  5100. );
  5101. stack.pop();
  5102. keyPath && keyPath.pop();
  5103. return converted;
  5104. }
  5105. return value;
  5106. }
  5107. function defaultConverter(k, v) {
  5108. // Effectively the opposite of "Collection.toSeq()"
  5109. return isIndexed(v) ? v.toList() : isKeyed(v) ? v.toMap() : v.toSet();
  5110. }
  5111. var version = "4.3.4";
  5112. var Immutable = {
  5113. version: version,
  5114. Collection: Collection,
  5115. // Note: Iterable is deprecated
  5116. Iterable: Collection,
  5117. Seq: Seq,
  5118. Map: Map,
  5119. OrderedMap: OrderedMap,
  5120. List: List,
  5121. Stack: Stack,
  5122. Set: Set,
  5123. OrderedSet: OrderedSet,
  5124. PairSorting: PairSorting,
  5125. Record: Record,
  5126. Range: Range,
  5127. Repeat: Repeat,
  5128. is: is,
  5129. fromJS: fromJS,
  5130. hash: hash,
  5131. isImmutable: isImmutable,
  5132. isCollection: isCollection,
  5133. isKeyed: isKeyed,
  5134. isIndexed: isIndexed,
  5135. isAssociative: isAssociative,
  5136. isOrdered: isOrdered,
  5137. isValueObject: isValueObject,
  5138. isPlainObject: isPlainObject,
  5139. isSeq: isSeq,
  5140. isList: isList,
  5141. isMap: isMap,
  5142. isOrderedMap: isOrderedMap,
  5143. isStack: isStack,
  5144. isSet: isSet,
  5145. isOrderedSet: isOrderedSet,
  5146. isRecord: isRecord,
  5147. get: get,
  5148. getIn: getIn$1,
  5149. has: has,
  5150. hasIn: hasIn$1,
  5151. merge: merge,
  5152. mergeDeep: mergeDeep$1,
  5153. mergeWith: mergeWith,
  5154. mergeDeepWith: mergeDeepWith$1,
  5155. remove: remove,
  5156. removeIn: removeIn,
  5157. set: set,
  5158. setIn: setIn$1,
  5159. update: update$1,
  5160. updateIn: updateIn$1,
  5161. };
  5162. // Note: Iterable is deprecated
  5163. var Iterable = Collection;
  5164. exports.Collection = Collection;
  5165. exports.Iterable = Iterable;
  5166. exports.List = List;
  5167. exports.Map = Map;
  5168. exports.OrderedMap = OrderedMap;
  5169. exports.OrderedSet = OrderedSet;
  5170. exports.PairSorting = PairSorting;
  5171. exports.Range = Range;
  5172. exports.Record = Record;
  5173. exports.Repeat = Repeat;
  5174. exports.Seq = Seq;
  5175. exports.Set = Set;
  5176. exports.Stack = Stack;
  5177. exports.default = Immutable;
  5178. exports.fromJS = fromJS;
  5179. exports.get = get;
  5180. exports.getIn = getIn$1;
  5181. exports.has = has;
  5182. exports.hasIn = hasIn$1;
  5183. exports.hash = hash;
  5184. exports.is = is;
  5185. exports.isAssociative = isAssociative;
  5186. exports.isCollection = isCollection;
  5187. exports.isImmutable = isImmutable;
  5188. exports.isIndexed = isIndexed;
  5189. exports.isKeyed = isKeyed;
  5190. exports.isList = isList;
  5191. exports.isMap = isMap;
  5192. exports.isOrdered = isOrdered;
  5193. exports.isOrderedMap = isOrderedMap;
  5194. exports.isOrderedSet = isOrderedSet;
  5195. exports.isPlainObject = isPlainObject;
  5196. exports.isRecord = isRecord;
  5197. exports.isSeq = isSeq;
  5198. exports.isSet = isSet;
  5199. exports.isStack = isStack;
  5200. exports.isValueObject = isValueObject;
  5201. exports.merge = merge;
  5202. exports.mergeDeep = mergeDeep$1;
  5203. exports.mergeDeepWith = mergeDeepWith$1;
  5204. exports.mergeWith = mergeWith;
  5205. exports.remove = remove;
  5206. exports.removeIn = removeIn;
  5207. exports.set = set;
  5208. exports.setIn = setIn$1;
  5209. exports.update = update$1;
  5210. exports.updateIn = updateIn$1;
  5211. exports.version = version;
  5212. Object.defineProperty(exports, '__esModule', { value: true });
  5213. })));