Ohm-Management - Projektarbeit B-ME
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

rxjs.umd.js 324KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796479747984799480048014802480348044805480648074808480948104811481248134814481548164817481848194820482148224823482448254826482748284829483048314832483348344835483648374838483948404841484248434844484548464847484848494850485148524853485448554856485748584859486048614862486348644865486648674868486948704871487248734874487548764877487848794880488148824883488448854886488748884889489048914892489348944895489648974898489949004901490249034904490549064907490849094910491149124913491449154916491749184919492049214922492349244925492649274928492949304931493249334934493549364937493849394940494149424943494449454946494749484949495049514952495349544955495649574958495949604961496249634964496549664967496849694970497149724973497449754976497749784979498049814982498349844985498649874988498949904991499249934994499549964997499849995000500150025003500450055006500750085009501050115012501350145015501650175018501950205021502250235024502550265027502850295030503150325033503450355036503750385039504050415042504350445045504650475048504950505051505250535054505550565057505850595060506150625063506450655066506750685069507050715072507350745075507650775078507950805081508250835084508550865087508850895090509150925093509450955096509750985099510051015102510351045105510651075108510951105111511251135114511551165117511851195120512151225123512451255126512751285129513051315132513351345135513651375138513951405141514251435144514551465147514851495150515151525153515451555156515751585159516051615162516351645165516651675168516951705171517251735174517551765177517851795180518151825183518451855186518751885189519051915192519351945195519651975198519952005201520252035204520552065207520852095210521152125213521452155216521752185219522052215222522352245225522652275228522952305231523252335234523552365237523852395240524152425243524452455246524752485249525052515252525352545255525652575258525952605261526252635264526552665267526852695270527152725273527452755276527752785279528052815282528352845285528652875288528952905291529252935294529552965297529852995300530153025303530453055306530753085309531053115312531353145315531653175318531953205321532253235324532553265327532853295330533153325333533453355336533753385339534053415342534353445345534653475348534953505351535253535354535553565357535853595360536153625363536453655366536753685369537053715372537353745375537653775378537953805381538253835384538553865387538853895390539153925393539453955396539753985399540054015402540354045405540654075408540954105411541254135414541554165417541854195420542154225423542454255426542754285429543054315432543354345435543654375438543954405441544254435444544554465447544854495450545154525453545454555456545754585459546054615462546354645465546654675468546954705471547254735474547554765477547854795480548154825483548454855486548754885489549054915492549354945495549654975498549955005501550255035504550555065507550855095510551155125513551455155516551755185519552055215522552355245525552655275528552955305531553255335534553555365537553855395540554155425543554455455546554755485549555055515552555355545555555655575558555955605561556255635564556555665567556855695570557155725573557455755576557755785579558055815582558355845585558655875588558955905591559255935594559555965597559855995600560156025603560456055606560756085609561056115612561356145615561656175618561956205621562256235624562556265627562856295630563156325633563456355636563756385639564056415642564356445645564656475648564956505651565256535654565556565657565856595660566156625663566456655666566756685669567056715672567356745675567656775678567956805681568256835684568556865687568856895690569156925693569456955696569756985699570057015702570357045705570657075708570957105711571257135714571557165717571857195720572157225723572457255726572757285729573057315732573357345735573657375738573957405741574257435744574557465747574857495750575157525753575457555756575757585759576057615762576357645765576657675768576957705771577257735774577557765777577857795780578157825783578457855786578757885789579057915792579357945795579657975798579958005801580258035804580558065807580858095810581158125813581458155816581758185819582058215822582358245825582658275828582958305831583258335834583558365837583858395840584158425843584458455846584758485849585058515852585358545855585658575858585958605861586258635864586558665867586858695870587158725873587458755876587758785879588058815882588358845885588658875888588958905891589258935894589558965897589858995900590159025903590459055906590759085909591059115912591359145915591659175918591959205921592259235924592559265927592859295930593159325933593459355936593759385939594059415942594359445945594659475948594959505951595259535954595559565957595859595960596159625963596459655966596759685969597059715972597359745975597659775978597959805981598259835984598559865987598859895990599159925993599459955996599759985999600060016002600360046005600660076008600960106011601260136014601560166017601860196020602160226023602460256026602760286029603060316032603360346035603660376038603960406041604260436044604560466047604860496050605160526053605460556056605760586059606060616062606360646065606660676068606960706071607260736074607560766077607860796080608160826083608460856086608760886089609060916092609360946095609660976098609961006101610261036104610561066107610861096110611161126113611461156116611761186119612061216122612361246125612661276128612961306131613261336134613561366137613861396140614161426143614461456146614761486149615061516152615361546155615661576158615961606161616261636164616561666167616861696170617161726173617461756176617761786179618061816182618361846185618661876188618961906191619261936194619561966197619861996200620162026203620462056206620762086209621062116212621362146215621662176218621962206221622262236224622562266227622862296230623162326233623462356236623762386239624062416242624362446245624662476248624962506251625262536254625562566257625862596260626162626263626462656266626762686269627062716272627362746275627662776278627962806281628262836284628562866287628862896290629162926293629462956296629762986299630063016302630363046305630663076308630963106311631263136314631563166317631863196320632163226323632463256326632763286329633063316332633363346335633663376338633963406341634263436344634563466347634863496350635163526353635463556356635763586359636063616362636363646365636663676368636963706371637263736374637563766377637863796380638163826383638463856386638763886389639063916392639363946395639663976398639964006401640264036404640564066407640864096410641164126413641464156416641764186419642064216422642364246425642664276428642964306431643264336434643564366437643864396440644164426443644464456446644764486449645064516452645364546455645664576458645964606461646264636464646564666467646864696470647164726473647464756476647764786479648064816482648364846485648664876488648964906491649264936494649564966497649864996500650165026503650465056506650765086509651065116512651365146515651665176518651965206521652265236524652565266527652865296530653165326533653465356536653765386539654065416542654365446545654665476548654965506551655265536554655565566557655865596560656165626563656465656566656765686569657065716572657365746575657665776578657965806581658265836584658565866587658865896590659165926593659465956596659765986599660066016602660366046605660666076608660966106611661266136614661566166617661866196620662166226623662466256626662766286629663066316632663366346635663666376638663966406641664266436644664566466647664866496650665166526653665466556656665766586659666066616662666366646665666666676668666966706671667266736674667566766677667866796680668166826683668466856686668766886689669066916692669366946695669666976698669967006701670267036704670567066707670867096710671167126713671467156716671767186719672067216722672367246725672667276728672967306731673267336734673567366737673867396740674167426743674467456746674767486749675067516752675367546755675667576758675967606761676267636764676567666767676867696770677167726773677467756776677767786779678067816782678367846785678667876788678967906791679267936794679567966797679867996800680168026803680468056806680768086809681068116812681368146815681668176818681968206821682268236824682568266827682868296830683168326833683468356836683768386839684068416842684368446845684668476848684968506851685268536854685568566857685868596860686168626863686468656866686768686869687068716872687368746875687668776878687968806881688268836884688568866887688868896890689168926893689468956896689768986899690069016902690369046905690669076908690969106911691269136914691569166917691869196920692169226923692469256926692769286929693069316932693369346935693669376938693969406941694269436944694569466947694869496950695169526953695469556956695769586959696069616962696369646965696669676968696969706971697269736974697569766977697869796980698169826983698469856986698769886989699069916992699369946995699669976998699970007001700270037004700570067007700870097010701170127013701470157016701770187019702070217022702370247025702670277028702970307031703270337034703570367037703870397040704170427043704470457046704770487049705070517052705370547055705670577058705970607061706270637064706570667067706870697070707170727073707470757076707770787079708070817082708370847085708670877088708970907091709270937094709570967097709870997100710171027103710471057106710771087109711071117112711371147115711671177118711971207121712271237124712571267127712871297130713171327133713471357136713771387139714071417142714371447145714671477148714971507151715271537154715571567157715871597160716171627163716471657166716771687169717071717172717371747175717671777178717971807181718271837184718571867187718871897190719171927193719471957196719771987199720072017202720372047205720672077208720972107211721272137214721572167217721872197220722172227223722472257226722772287229723072317232723372347235723672377238723972407241724272437244724572467247724872497250725172527253725472557256725772587259726072617262726372647265726672677268726972707271727272737274727572767277727872797280728172827283728472857286728772887289729072917292729372947295729672977298729973007301730273037304730573067307730873097310731173127313731473157316731773187319732073217322732373247325732673277328732973307331733273337334733573367337733873397340734173427343734473457346734773487349735073517352735373547355735673577358735973607361736273637364736573667367736873697370737173727373737473757376737773787379738073817382738373847385738673877388738973907391739273937394739573967397739873997400740174027403740474057406740774087409741074117412741374147415741674177418741974207421742274237424742574267427742874297430743174327433743474357436743774387439744074417442744374447445744674477448744974507451745274537454745574567457745874597460746174627463746474657466746774687469747074717472747374747475747674777478747974807481748274837484748574867487748874897490749174927493749474957496749774987499750075017502750375047505750675077508750975107511751275137514751575167517751875197520752175227523752475257526752775287529753075317532753375347535753675377538753975407541754275437544754575467547754875497550755175527553755475557556755775587559756075617562756375647565756675677568756975707571757275737574757575767577757875797580758175827583758475857586758775887589759075917592759375947595759675977598759976007601760276037604760576067607760876097610761176127613761476157616761776187619762076217622762376247625762676277628762976307631763276337634763576367637763876397640764176427643764476457646764776487649765076517652765376547655765676577658765976607661766276637664766576667667766876697670767176727673767476757676767776787679768076817682768376847685768676877688768976907691769276937694769576967697769876997700770177027703770477057706770777087709771077117712771377147715771677177718771977207721772277237724772577267727772877297730773177327733773477357736773777387739774077417742774377447745774677477748774977507751775277537754775577567757775877597760776177627763776477657766776777687769777077717772777377747775777677777778777977807781778277837784778577867787778877897790779177927793779477957796779777987799780078017802780378047805780678077808780978107811781278137814781578167817781878197820782178227823782478257826782778287829783078317832783378347835783678377838783978407841784278437844784578467847784878497850785178527853785478557856785778587859786078617862786378647865786678677868786978707871787278737874787578767877787878797880788178827883788478857886788778887889789078917892789378947895789678977898789979007901790279037904790579067907790879097910791179127913791479157916791779187919792079217922792379247925792679277928792979307931793279337934793579367937793879397940794179427943794479457946794779487949795079517952795379547955795679577958795979607961796279637964796579667967796879697970797179727973797479757976797779787979798079817982798379847985798679877988798979907991799279937994799579967997799879998000800180028003800480058006800780088009801080118012801380148015801680178018801980208021802280238024802580268027802880298030803180328033803480358036803780388039804080418042804380448045804680478048804980508051805280538054805580568057805880598060806180628063806480658066806780688069807080718072807380748075807680778078807980808081808280838084808580868087808880898090809180928093809480958096809780988099810081018102810381048105810681078108810981108111811281138114811581168117811881198120812181228123812481258126812781288129813081318132813381348135813681378138813981408141814281438144814581468147814881498150815181528153815481558156815781588159816081618162816381648165816681678168816981708171817281738174817581768177817881798180818181828183818481858186818781888189819081918192819381948195819681978198819982008201820282038204820582068207820882098210821182128213821482158216821782188219822082218222822382248225822682278228822982308231823282338234823582368237823882398240824182428243824482458246824782488249825082518252825382548255825682578258825982608261826282638264826582668267826882698270827182728273827482758276827782788279828082818282828382848285828682878288828982908291829282938294829582968297829882998300830183028303830483058306830783088309831083118312831383148315831683178318831983208321832283238324832583268327832883298330833183328333833483358336833783388339834083418342834383448345834683478348834983508351835283538354835583568357835883598360836183628363836483658366836783688369837083718372837383748375837683778378837983808381838283838384838583868387838883898390839183928393839483958396839783988399840084018402840384048405840684078408840984108411841284138414841584168417841884198420842184228423842484258426842784288429843084318432843384348435843684378438843984408441844284438444844584468447844884498450845184528453845484558456845784588459846084618462846384648465846684678468846984708471847284738474847584768477847884798480848184828483848484858486848784888489849084918492849384948495849684978498849985008501850285038504850585068507850885098510851185128513851485158516851785188519852085218522852385248525852685278528852985308531853285338534853585368537853885398540854185428543854485458546854785488549855085518552855385548555855685578558855985608561856285638564856585668567856885698570857185728573857485758576857785788579858085818582858385848585858685878588858985908591859285938594859585968597859885998600860186028603860486058606860786088609861086118612861386148615861686178618861986208621862286238624862586268627862886298630863186328633863486358636863786388639864086418642864386448645864686478648864986508651865286538654865586568657865886598660866186628663866486658666866786688669867086718672867386748675867686778678867986808681868286838684868586868687868886898690869186928693869486958696869786988699870087018702870387048705870687078708870987108711871287138714871587168717871887198720872187228723872487258726872787288729873087318732873387348735873687378738873987408741874287438744874587468747874887498750875187528753875487558756875787588759876087618762876387648765876687678768876987708771877287738774877587768777877887798780878187828783878487858786878787888789879087918792879387948795879687978798879988008801880288038804880588068807880888098810881188128813881488158816881788188819882088218822882388248825882688278828882988308831883288338834883588368837883888398840884188428843884488458846884788488849885088518852885388548855885688578858885988608861886288638864886588668867886888698870887188728873887488758876887788788879888088818882888388848885888688878888888988908891889288938894889588968897889888998900890189028903890489058906890789088909891089118912891389148915891689178918891989208921892289238924892589268927892889298930893189328933893489358936893789388939894089418942894389448945894689478948894989508951895289538954895589568957895889598960896189628963896489658966896789688969897089718972897389748975897689778978897989808981898289838984898589868987898889898990899189928993899489958996899789988999900090019002900390049005900690079008900990109011901290139014901590169017901890199020902190229023902490259026902790289029903090319032903390349035903690379038903990409041904290439044904590469047904890499050905190529053905490559056905790589059906090619062906390649065906690679068906990709071907290739074907590769077907890799080908190829083908490859086908790889089909090919092909390949095909690979098909991009101910291039104910591069107910891099110911191129113911491159116911791189119912091219122912391249125912691279128912991309131913291339134913591369137913891399140914191429143914491459146914791489149915091519152915391549155915691579158915991609161916291639164916591669167916891699170917191729173917491759176917791789179918091819182918391849185918691879188918991909191919291939194919591969197919891999200920192029203920492059206920792089209921092119212921392149215921692179218921992209221
  1. /**
  2. @license
  3. Apache License
  4. Version 2.0, January 2004
  5. http://www.apache.org/licenses/
  6. TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
  7. 1. Definitions.
  8. "License" shall mean the terms and conditions for use, reproduction,
  9. and distribution as defined by Sections 1 through 9 of this document.
  10. "Licensor" shall mean the copyright owner or entity authorized by
  11. the copyright owner that is granting the License.
  12. "Legal Entity" shall mean the union of the acting entity and all
  13. other entities that control, are controlled by, or are under common
  14. control with that entity. For the purposes of this definition,
  15. "control" means (i) the power, direct or indirect, to cause the
  16. direction or management of such entity, whether by contract or
  17. otherwise, or (ii) ownership of fifty percent (50%) or more of the
  18. outstanding shares, or (iii) beneficial ownership of such entity.
  19. "You" (or "Your") shall mean an individual or Legal Entity
  20. exercising permissions granted by this License.
  21. "Source" form shall mean the preferred form for making modifications,
  22. including but not limited to software source code, documentation
  23. source, and configuration files.
  24. "Object" form shall mean any form resulting from mechanical
  25. transformation or translation of a Source form, including but
  26. not limited to compiled object code, generated documentation,
  27. and conversions to other media types.
  28. "Work" shall mean the work of authorship, whether in Source or
  29. Object form, made available under the License, as indicated by a
  30. copyright notice that is included in or attached to the work
  31. (an example is provided in the Appendix below).
  32. "Derivative Works" shall mean any work, whether in Source or Object
  33. form, that is based on (or derived from) the Work and for which the
  34. editorial revisions, annotations, elaborations, or other modifications
  35. represent, as a whole, an original work of authorship. For the purposes
  36. of this License, Derivative Works shall not include works that remain
  37. separable from, or merely link (or bind by name) to the interfaces of,
  38. the Work and Derivative Works thereof.
  39. "Contribution" shall mean any work of authorship, including
  40. the original version of the Work and any modifications or additions
  41. to that Work or Derivative Works thereof, that is intentionally
  42. submitted to Licensor for inclusion in the Work by the copyright owner
  43. or by an individual or Legal Entity authorized to submit on behalf of
  44. the copyright owner. For the purposes of this definition, "submitted"
  45. means any form of electronic, verbal, or written communication sent
  46. to the Licensor or its representatives, including but not limited to
  47. communication on electronic mailing lists, source code control systems,
  48. and issue tracking systems that are managed by, or on behalf of, the
  49. Licensor for the purpose of discussing and improving the Work, but
  50. excluding communication that is conspicuously marked or otherwise
  51. designated in writing by the copyright owner as "Not a Contribution."
  52. "Contributor" shall mean Licensor and any individual or Legal Entity
  53. on behalf of whom a Contribution has been received by Licensor and
  54. subsequently incorporated within the Work.
  55. 2. Grant of Copyright License. Subject to the terms and conditions of
  56. this License, each Contributor hereby grants to You a perpetual,
  57. worldwide, non-exclusive, no-charge, royalty-free, irrevocable
  58. copyright license to reproduce, prepare Derivative Works of,
  59. publicly display, publicly perform, sublicense, and distribute the
  60. Work and such Derivative Works in Source or Object form.
  61. 3. Grant of Patent License. Subject to the terms and conditions of
  62. this License, each Contributor hereby grants to You a perpetual,
  63. worldwide, non-exclusive, no-charge, royalty-free, irrevocable
  64. (except as stated in this section) patent license to make, have made,
  65. use, offer to sell, sell, import, and otherwise transfer the Work,
  66. where such license applies only to those patent claims licensable
  67. by such Contributor that are necessarily infringed by their
  68. Contribution(s) alone or by combination of their Contribution(s)
  69. with the Work to which such Contribution(s) was submitted. If You
  70. institute patent litigation against any entity (including a
  71. cross-claim or counterclaim in a lawsuit) alleging that the Work
  72. or a Contribution incorporated within the Work constitutes direct
  73. or contributory patent infringement, then any patent licenses
  74. granted to You under this License for that Work shall terminate
  75. as of the date such litigation is filed.
  76. 4. Redistribution. You may reproduce and distribute copies of the
  77. Work or Derivative Works thereof in any medium, with or without
  78. modifications, and in Source or Object form, provided that You
  79. meet the following conditions:
  80. (a) You must give any other recipients of the Work or
  81. Derivative Works a copy of this License; and
  82. (b) You must cause any modified files to carry prominent notices
  83. stating that You changed the files; and
  84. (c) You must retain, in the Source form of any Derivative Works
  85. that You distribute, all copyright, patent, trademark, and
  86. attribution notices from the Source form of the Work,
  87. excluding those notices that do not pertain to any part of
  88. the Derivative Works; and
  89. (d) If the Work includes a "NOTICE" text file as part of its
  90. distribution, then any Derivative Works that You distribute must
  91. include a readable copy of the attribution notices contained
  92. within such NOTICE file, excluding those notices that do not
  93. pertain to any part of the Derivative Works, in at least one
  94. of the following places: within a NOTICE text file distributed
  95. as part of the Derivative Works; within the Source form or
  96. documentation, if provided along with the Derivative Works; or,
  97. within a display generated by the Derivative Works, if and
  98. wherever such third-party notices normally appear. The contents
  99. of the NOTICE file are for informational purposes only and
  100. do not modify the License. You may add Your own attribution
  101. notices within Derivative Works that You distribute, alongside
  102. or as an addendum to the NOTICE text from the Work, provided
  103. that such additional attribution notices cannot be construed
  104. as modifying the License.
  105. You may add Your own copyright statement to Your modifications and
  106. may provide additional or different license terms and conditions
  107. for use, reproduction, or distribution of Your modifications, or
  108. for any such Derivative Works as a whole, provided Your use,
  109. reproduction, and distribution of the Work otherwise complies with
  110. the conditions stated in this License.
  111. 5. Submission of Contributions. Unless You explicitly state otherwise,
  112. any Contribution intentionally submitted for inclusion in the Work
  113. by You to the Licensor shall be under the terms and conditions of
  114. this License, without any additional terms or conditions.
  115. Notwithstanding the above, nothing herein shall supersede or modify
  116. the terms of any separate license agreement you may have executed
  117. with Licensor regarding such Contributions.
  118. 6. Trademarks. This License does not grant permission to use the trade
  119. names, trademarks, service marks, or product names of the Licensor,
  120. except as required for reasonable and customary use in describing the
  121. origin of the Work and reproducing the content of the NOTICE file.
  122. 7. Disclaimer of Warranty. Unless required by applicable law or
  123. agreed to in writing, Licensor provides the Work (and each
  124. Contributor provides its Contributions) on an "AS IS" BASIS,
  125. WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
  126. implied, including, without limitation, any warranties or conditions
  127. of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
  128. PARTICULAR PURPOSE. You are solely responsible for determining the
  129. appropriateness of using or redistributing the Work and assume any
  130. risks associated with Your exercise of permissions under this License.
  131. 8. Limitation of Liability. In no event and under no legal theory,
  132. whether in tort (including negligence), contract, or otherwise,
  133. unless required by applicable law (such as deliberate and grossly
  134. negligent acts) or agreed to in writing, shall any Contributor be
  135. liable to You for damages, including any direct, indirect, special,
  136. incidental, or consequential damages of any character arising as a
  137. result of this License or out of the use or inability to use the
  138. Work (including but not limited to damages for loss of goodwill,
  139. work stoppage, computer failure or malfunction, or any and all
  140. other commercial damages or losses), even if such Contributor
  141. has been advised of the possibility of such damages.
  142. 9. Accepting Warranty or Additional Liability. While redistributing
  143. the Work or Derivative Works thereof, You may choose to offer,
  144. and charge a fee for, acceptance of support, warranty, indemnity,
  145. or other liability obligations and/or rights consistent with this
  146. License. However, in accepting such obligations, You may act only
  147. on Your own behalf and on Your sole responsibility, not on behalf
  148. of any other Contributor, and only if You agree to indemnify,
  149. defend, and hold each Contributor harmless for any liability
  150. incurred by, or claims asserted against, such Contributor by reason
  151. of your accepting any such warranty or additional liability.
  152. END OF TERMS AND CONDITIONS
  153. APPENDIX: How to apply the Apache License to your work.
  154. To apply the Apache License to your work, attach the following
  155. boilerplate notice, with the fields enclosed by brackets "[]"
  156. replaced with your own identifying information. (Don't include
  157. the brackets!) The text should be enclosed in the appropriate
  158. comment syntax for the file format. We also recommend that a
  159. file or class name and description of purpose be included on the
  160. same "printed page" as the copyright notice for easier
  161. identification within third-party archives.
  162. Copyright (c) 2015-2018 Google, Inc., Netflix, Inc., Microsoft Corp. and contributors
  163. Licensed under the Apache License, Version 2.0 (the "License");
  164. you may not use this file except in compliance with the License.
  165. You may obtain a copy of the License at
  166. http://www.apache.org/licenses/LICENSE-2.0
  167. Unless required by applicable law or agreed to in writing, software
  168. distributed under the License is distributed on an "AS IS" BASIS,
  169. WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  170. See the License for the specific language governing permissions and
  171. limitations under the License.
  172. **/
  173. /**
  174. @license
  175. Apache License
  176. Version 2.0, January 2004
  177. http://www.apache.org/licenses/
  178. TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
  179. 1. Definitions.
  180. "License" shall mean the terms and conditions for use, reproduction,
  181. and distribution as defined by Sections 1 through 9 of this document.
  182. "Licensor" shall mean the copyright owner or entity authorized by
  183. the copyright owner that is granting the License.
  184. "Legal Entity" shall mean the union of the acting entity and all
  185. other entities that control, are controlled by, or are under common
  186. control with that entity. For the purposes of this definition,
  187. "control" means (i) the power, direct or indirect, to cause the
  188. direction or management of such entity, whether by contract or
  189. otherwise, or (ii) ownership of fifty percent (50%) or more of the
  190. outstanding shares, or (iii) beneficial ownership of such entity.
  191. "You" (or "Your") shall mean an individual or Legal Entity
  192. exercising permissions granted by this License.
  193. "Source" form shall mean the preferred form for making modifications,
  194. including but not limited to software source code, documentation
  195. source, and configuration files.
  196. "Object" form shall mean any form resulting from mechanical
  197. transformation or translation of a Source form, including but
  198. not limited to compiled object code, generated documentation,
  199. and conversions to other media types.
  200. "Work" shall mean the work of authorship, whether in Source or
  201. Object form, made available under the License, as indicated by a
  202. copyright notice that is included in or attached to the work
  203. (an example is provided in the Appendix below).
  204. "Derivative Works" shall mean any work, whether in Source or Object
  205. form, that is based on (or derived from) the Work and for which the
  206. editorial revisions, annotations, elaborations, or other modifications
  207. represent, as a whole, an original work of authorship. For the purposes
  208. of this License, Derivative Works shall not include works that remain
  209. separable from, or merely link (or bind by name) to the interfaces of,
  210. the Work and Derivative Works thereof.
  211. "Contribution" shall mean any work of authorship, including
  212. the original version of the Work and any modifications or additions
  213. to that Work or Derivative Works thereof, that is intentionally
  214. submitted to Licensor for inclusion in the Work by the copyright owner
  215. or by an individual or Legal Entity authorized to submit on behalf of
  216. the copyright owner. For the purposes of this definition, "submitted"
  217. means any form of electronic, verbal, or written communication sent
  218. to the Licensor or its representatives, including but not limited to
  219. communication on electronic mailing lists, source code control systems,
  220. and issue tracking systems that are managed by, or on behalf of, the
  221. Licensor for the purpose of discussing and improving the Work, but
  222. excluding communication that is conspicuously marked or otherwise
  223. designated in writing by the copyright owner as "Not a Contribution."
  224. "Contributor" shall mean Licensor and any individual or Legal Entity
  225. on behalf of whom a Contribution has been received by Licensor and
  226. subsequently incorporated within the Work.
  227. 2. Grant of Copyright License. Subject to the terms and conditions of
  228. this License, each Contributor hereby grants to You a perpetual,
  229. worldwide, non-exclusive, no-charge, royalty-free, irrevocable
  230. copyright license to reproduce, prepare Derivative Works of,
  231. publicly display, publicly perform, sublicense, and distribute the
  232. Work and such Derivative Works in Source or Object form.
  233. 3. Grant of Patent License. Subject to the terms and conditions of
  234. this License, each Contributor hereby grants to You a perpetual,
  235. worldwide, non-exclusive, no-charge, royalty-free, irrevocable
  236. (except as stated in this section) patent license to make, have made,
  237. use, offer to sell, sell, import, and otherwise transfer the Work,
  238. where such license applies only to those patent claims licensable
  239. by such Contributor that are necessarily infringed by their
  240. Contribution(s) alone or by combination of their Contribution(s)
  241. with the Work to which such Contribution(s) was submitted. If You
  242. institute patent litigation against any entity (including a
  243. cross-claim or counterclaim in a lawsuit) alleging that the Work
  244. or a Contribution incorporated within the Work constitutes direct
  245. or contributory patent infringement, then any patent licenses
  246. granted to You under this License for that Work shall terminate
  247. as of the date such litigation is filed.
  248. 4. Redistribution. You may reproduce and distribute copies of the
  249. Work or Derivative Works thereof in any medium, with or without
  250. modifications, and in Source or Object form, provided that You
  251. meet the following conditions:
  252. (a) You must give any other recipients of the Work or
  253. Derivative Works a copy of this License; and
  254. (b) You must cause any modified files to carry prominent notices
  255. stating that You changed the files; and
  256. (c) You must retain, in the Source form of any Derivative Works
  257. that You distribute, all copyright, patent, trademark, and
  258. attribution notices from the Source form of the Work,
  259. excluding those notices that do not pertain to any part of
  260. the Derivative Works; and
  261. (d) If the Work includes a "NOTICE" text file as part of its
  262. distribution, then any Derivative Works that You distribute must
  263. include a readable copy of the attribution notices contained
  264. within such NOTICE file, excluding those notices that do not
  265. pertain to any part of the Derivative Works, in at least one
  266. of the following places: within a NOTICE text file distributed
  267. as part of the Derivative Works; within the Source form or
  268. documentation, if provided along with the Derivative Works; or,
  269. within a display generated by the Derivative Works, if and
  270. wherever such third-party notices normally appear. The contents
  271. of the NOTICE file are for informational purposes only and
  272. do not modify the License. You may add Your own attribution
  273. notices within Derivative Works that You distribute, alongside
  274. or as an addendum to the NOTICE text from the Work, provided
  275. that such additional attribution notices cannot be construed
  276. as modifying the License.
  277. You may add Your own copyright statement to Your modifications and
  278. may provide additional or different license terms and conditions
  279. for use, reproduction, or distribution of Your modifications, or
  280. for any such Derivative Works as a whole, provided Your use,
  281. reproduction, and distribution of the Work otherwise complies with
  282. the conditions stated in this License.
  283. 5. Submission of Contributions. Unless You explicitly state otherwise,
  284. any Contribution intentionally submitted for inclusion in the Work
  285. by You to the Licensor shall be under the terms and conditions of
  286. this License, without any additional terms or conditions.
  287. Notwithstanding the above, nothing herein shall supersede or modify
  288. the terms of any separate license agreement you may have executed
  289. with Licensor regarding such Contributions.
  290. 6. Trademarks. This License does not grant permission to use the trade
  291. names, trademarks, service marks, or product names of the Licensor,
  292. except as required for reasonable and customary use in describing the
  293. origin of the Work and reproducing the content of the NOTICE file.
  294. 7. Disclaimer of Warranty. Unless required by applicable law or
  295. agreed to in writing, Licensor provides the Work (and each
  296. Contributor provides its Contributions) on an "AS IS" BASIS,
  297. WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
  298. implied, including, without limitation, any warranties or conditions
  299. of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
  300. PARTICULAR PURPOSE. You are solely responsible for determining the
  301. appropriateness of using or redistributing the Work and assume any
  302. risks associated with Your exercise of permissions under this License.
  303. 8. Limitation of Liability. In no event and under no legal theory,
  304. whether in tort (including negligence), contract, or otherwise,
  305. unless required by applicable law (such as deliberate and grossly
  306. negligent acts) or agreed to in writing, shall any Contributor be
  307. liable to You for damages, including any direct, indirect, special,
  308. incidental, or consequential damages of any character arising as a
  309. result of this License or out of the use or inability to use the
  310. Work (including but not limited to damages for loss of goodwill,
  311. work stoppage, computer failure or malfunction, or any and all
  312. other commercial damages or losses), even if such Contributor
  313. has been advised of the possibility of such damages.
  314. 9. Accepting Warranty or Additional Liability. While redistributing
  315. the Work or Derivative Works thereof, You may choose to offer,
  316. and charge a fee for, acceptance of support, warranty, indemnity,
  317. or other liability obligations and/or rights consistent with this
  318. License. However, in accepting such obligations, You may act only
  319. on Your own behalf and on Your sole responsibility, not on behalf
  320. of any other Contributor, and only if You agree to indemnify,
  321. defend, and hold each Contributor harmless for any liability
  322. incurred by, or claims asserted against, such Contributor by reason
  323. of your accepting any such warranty or additional liability.
  324. END OF TERMS AND CONDITIONS
  325. APPENDIX: How to apply the Apache License to your work.
  326. To apply the Apache License to your work, attach the following
  327. boilerplate notice, with the fields enclosed by brackets "[]"
  328. replaced with your own identifying information. (Don't include
  329. the brackets!) The text should be enclosed in the appropriate
  330. comment syntax for the file format. We also recommend that a
  331. file or class name and description of purpose be included on the
  332. same "printed page" as the copyright notice for easier
  333. identification within third-party archives.
  334. Copyright (c) 2015-2018 Google, Inc., Netflix, Inc., Microsoft Corp. and contributors
  335. Licensed under the Apache License, Version 2.0 (the "License");
  336. you may not use this file except in compliance with the License.
  337. You may obtain a copy of the License at
  338. http://www.apache.org/licenses/LICENSE-2.0
  339. Unless required by applicable law or agreed to in writing, software
  340. distributed under the License is distributed on an "AS IS" BASIS,
  341. WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  342. See the License for the specific language governing permissions and
  343. limitations under the License.
  344. **/
  345. (function (global, factory) {
  346. typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports) :
  347. typeof define === 'function' && define.amd ? define(['exports'], factory) :
  348. (factory((global.rxjs = global.rxjs || {})));
  349. }(this, (function (exports) { 'use strict';
  350. /*! *****************************************************************************
  351. Copyright (c) Microsoft Corporation. All rights reserved.
  352. Licensed under the Apache License, Version 2.0 (the "License"); you may not use
  353. this file except in compliance with the License. You may obtain a copy of the
  354. License at http://www.apache.org/licenses/LICENSE-2.0
  355. THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  356. KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED
  357. WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE,
  358. MERCHANTABLITY OR NON-INFRINGEMENT.
  359. See the Apache Version 2.0 License for specific language governing permissions
  360. and limitations under the License.
  361. ***************************************************************************** */
  362. /* global Reflect, Promise */
  363. var extendStatics = Object.setPrototypeOf ||
  364. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  365. function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
  366. function __extends(d, b) {
  367. extendStatics(d, b);
  368. function __() { this.constructor = d; }
  369. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  370. }
  371. var __assign = Object.assign || function __assign(t) {
  372. for (var s, i = 1, n = arguments.length; i < n; i++) {
  373. s = arguments[i];
  374. for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
  375. }
  376. return t;
  377. };
  378. function __values(o) {
  379. var m = typeof Symbol === "function" && o[Symbol.iterator], i = 0;
  380. if (m) return m.call(o);
  381. return {
  382. next: function () {
  383. if (o && i >= o.length) o = void 0;
  384. return { value: o && o[i++], done: !o };
  385. }
  386. };
  387. }
  388. function __read(o, n) {
  389. var m = typeof Symbol === "function" && o[Symbol.iterator];
  390. if (!m) return o;
  391. var i = m.call(o), r, ar = [], e;
  392. try {
  393. while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
  394. }
  395. catch (error) { e = { error: error }; }
  396. finally {
  397. try {
  398. if (r && !r.done && (m = i["return"])) m.call(i);
  399. }
  400. finally { if (e) throw e.error; }
  401. }
  402. return ar;
  403. }
  404. function __await(v) {
  405. return this instanceof __await ? (this.v = v, this) : new __await(v);
  406. }
  407. function isFunction(x) {
  408. return typeof x === 'function';
  409. }
  410. var _enable_super_gross_mode_that_will_cause_bad_things = false;
  411. var config = {
  412. Promise: undefined,
  413. set useDeprecatedSynchronousErrorHandling(value) {
  414. if (value) {
  415. var error = new Error();
  416. console.warn('DEPRECATED! RxJS was set to use deprecated synchronous error handling behavior by code at: \n' + error.stack);
  417. }
  418. else if (_enable_super_gross_mode_that_will_cause_bad_things) {
  419. console.log('RxJS: Back to a better error behavior. Thank you. <3');
  420. }
  421. _enable_super_gross_mode_that_will_cause_bad_things = value;
  422. },
  423. get useDeprecatedSynchronousErrorHandling() {
  424. return _enable_super_gross_mode_that_will_cause_bad_things;
  425. },
  426. };
  427. function hostReportError(err) {
  428. setTimeout(function () { throw err; });
  429. }
  430. var empty = {
  431. closed: true,
  432. next: function (value) { },
  433. error: function (err) {
  434. if (config.useDeprecatedSynchronousErrorHandling) {
  435. throw err;
  436. }
  437. else {
  438. hostReportError(err);
  439. }
  440. },
  441. complete: function () { }
  442. };
  443. var isArray = Array.isArray || (function (x) { return x && typeof x.length === 'number'; });
  444. function isObject(x) {
  445. return x != null && typeof x === 'object';
  446. }
  447. var errorObject = { e: {} };
  448. var tryCatchTarget;
  449. function tryCatcher() {
  450. try {
  451. return tryCatchTarget.apply(this, arguments);
  452. }
  453. catch (e) {
  454. errorObject.e = e;
  455. return errorObject;
  456. }
  457. }
  458. function tryCatch(fn) {
  459. tryCatchTarget = fn;
  460. return tryCatcher;
  461. }
  462. function UnsubscriptionErrorImpl(errors) {
  463. Error.call(this);
  464. this.message = errors ?
  465. errors.length + " errors occurred during unsubscription:\n" + errors.map(function (err, i) { return i + 1 + ") " + err.toString(); }).join('\n ') : '';
  466. this.name = 'UnsubscriptionError';
  467. this.errors = errors;
  468. return this;
  469. }
  470. UnsubscriptionErrorImpl.prototype = Object.create(Error.prototype);
  471. var UnsubscriptionError = UnsubscriptionErrorImpl;
  472. var Subscription = (function () {
  473. function Subscription(unsubscribe) {
  474. this.closed = false;
  475. this._parent = null;
  476. this._parents = null;
  477. this._subscriptions = null;
  478. if (unsubscribe) {
  479. this._unsubscribe = unsubscribe;
  480. }
  481. }
  482. Subscription.prototype.unsubscribe = function () {
  483. var hasErrors = false;
  484. var errors;
  485. if (this.closed) {
  486. return;
  487. }
  488. var _a = this, _parent = _a._parent, _parents = _a._parents, _unsubscribe = _a._unsubscribe, _subscriptions = _a._subscriptions;
  489. this.closed = true;
  490. this._parent = null;
  491. this._parents = null;
  492. this._subscriptions = null;
  493. var index = -1;
  494. var len = _parents ? _parents.length : 0;
  495. while (_parent) {
  496. _parent.remove(this);
  497. _parent = ++index < len && _parents[index] || null;
  498. }
  499. if (isFunction(_unsubscribe)) {
  500. var trial = tryCatch(_unsubscribe).call(this);
  501. if (trial === errorObject) {
  502. hasErrors = true;
  503. errors = errors || (errorObject.e instanceof UnsubscriptionError ?
  504. flattenUnsubscriptionErrors(errorObject.e.errors) : [errorObject.e]);
  505. }
  506. }
  507. if (isArray(_subscriptions)) {
  508. index = -1;
  509. len = _subscriptions.length;
  510. while (++index < len) {
  511. var sub = _subscriptions[index];
  512. if (isObject(sub)) {
  513. var trial = tryCatch(sub.unsubscribe).call(sub);
  514. if (trial === errorObject) {
  515. hasErrors = true;
  516. errors = errors || [];
  517. var err = errorObject.e;
  518. if (err instanceof UnsubscriptionError) {
  519. errors = errors.concat(flattenUnsubscriptionErrors(err.errors));
  520. }
  521. else {
  522. errors.push(err);
  523. }
  524. }
  525. }
  526. }
  527. }
  528. if (hasErrors) {
  529. throw new UnsubscriptionError(errors);
  530. }
  531. };
  532. Subscription.prototype.add = function (teardown) {
  533. if (!teardown || (teardown === Subscription.EMPTY)) {
  534. return Subscription.EMPTY;
  535. }
  536. if (teardown === this) {
  537. return this;
  538. }
  539. var subscription = teardown;
  540. switch (typeof teardown) {
  541. case 'function':
  542. subscription = new Subscription(teardown);
  543. case 'object':
  544. if (subscription.closed || typeof subscription.unsubscribe !== 'function') {
  545. return subscription;
  546. }
  547. else if (this.closed) {
  548. subscription.unsubscribe();
  549. return subscription;
  550. }
  551. else if (typeof subscription._addParent !== 'function') {
  552. var tmp = subscription;
  553. subscription = new Subscription();
  554. subscription._subscriptions = [tmp];
  555. }
  556. break;
  557. default:
  558. throw new Error('unrecognized teardown ' + teardown + ' added to Subscription.');
  559. }
  560. var subscriptions = this._subscriptions || (this._subscriptions = []);
  561. subscriptions.push(subscription);
  562. subscription._addParent(this);
  563. return subscription;
  564. };
  565. Subscription.prototype.remove = function (subscription) {
  566. var subscriptions = this._subscriptions;
  567. if (subscriptions) {
  568. var subscriptionIndex = subscriptions.indexOf(subscription);
  569. if (subscriptionIndex !== -1) {
  570. subscriptions.splice(subscriptionIndex, 1);
  571. }
  572. }
  573. };
  574. Subscription.prototype._addParent = function (parent) {
  575. var _a = this, _parent = _a._parent, _parents = _a._parents;
  576. if (!_parent || _parent === parent) {
  577. this._parent = parent;
  578. }
  579. else if (!_parents) {
  580. this._parents = [parent];
  581. }
  582. else if (_parents.indexOf(parent) === -1) {
  583. _parents.push(parent);
  584. }
  585. };
  586. Subscription.EMPTY = (function (empty) {
  587. empty.closed = true;
  588. return empty;
  589. }(new Subscription()));
  590. return Subscription;
  591. }());
  592. function flattenUnsubscriptionErrors(errors) {
  593. return errors.reduce(function (errs, err) { return errs.concat((err instanceof UnsubscriptionError) ? err.errors : err); }, []);
  594. }
  595. var rxSubscriber = typeof Symbol === 'function'
  596. ? Symbol('rxSubscriber')
  597. : '@@rxSubscriber_' + Math.random();
  598. var Subscriber = (function (_super) {
  599. __extends(Subscriber, _super);
  600. function Subscriber(destinationOrNext, error, complete) {
  601. var _this = _super.call(this) || this;
  602. _this.syncErrorValue = null;
  603. _this.syncErrorThrown = false;
  604. _this.syncErrorThrowable = false;
  605. _this.isStopped = false;
  606. _this._parentSubscription = null;
  607. switch (arguments.length) {
  608. case 0:
  609. _this.destination = empty;
  610. break;
  611. case 1:
  612. if (!destinationOrNext) {
  613. _this.destination = empty;
  614. break;
  615. }
  616. if (typeof destinationOrNext === 'object') {
  617. if (destinationOrNext instanceof Subscriber) {
  618. _this.syncErrorThrowable = destinationOrNext.syncErrorThrowable;
  619. _this.destination = destinationOrNext;
  620. destinationOrNext.add(_this);
  621. }
  622. else {
  623. _this.syncErrorThrowable = true;
  624. _this.destination = new SafeSubscriber(_this, destinationOrNext);
  625. }
  626. break;
  627. }
  628. default:
  629. _this.syncErrorThrowable = true;
  630. _this.destination = new SafeSubscriber(_this, destinationOrNext, error, complete);
  631. break;
  632. }
  633. return _this;
  634. }
  635. Subscriber.prototype[rxSubscriber] = function () { return this; };
  636. Subscriber.create = function (next, error, complete) {
  637. var subscriber = new Subscriber(next, error, complete);
  638. subscriber.syncErrorThrowable = false;
  639. return subscriber;
  640. };
  641. Subscriber.prototype.next = function (value) {
  642. if (!this.isStopped) {
  643. this._next(value);
  644. }
  645. };
  646. Subscriber.prototype.error = function (err) {
  647. if (!this.isStopped) {
  648. this.isStopped = true;
  649. this._error(err);
  650. }
  651. };
  652. Subscriber.prototype.complete = function () {
  653. if (!this.isStopped) {
  654. this.isStopped = true;
  655. this._complete();
  656. }
  657. };
  658. Subscriber.prototype.unsubscribe = function () {
  659. if (this.closed) {
  660. return;
  661. }
  662. this.isStopped = true;
  663. _super.prototype.unsubscribe.call(this);
  664. };
  665. Subscriber.prototype._next = function (value) {
  666. this.destination.next(value);
  667. };
  668. Subscriber.prototype._error = function (err) {
  669. this.destination.error(err);
  670. this.unsubscribe();
  671. };
  672. Subscriber.prototype._complete = function () {
  673. this.destination.complete();
  674. this.unsubscribe();
  675. };
  676. Subscriber.prototype._unsubscribeAndRecycle = function () {
  677. var _a = this, _parent = _a._parent, _parents = _a._parents;
  678. this._parent = null;
  679. this._parents = null;
  680. this.unsubscribe();
  681. this.closed = false;
  682. this.isStopped = false;
  683. this._parent = _parent;
  684. this._parents = _parents;
  685. this._parentSubscription = null;
  686. return this;
  687. };
  688. return Subscriber;
  689. }(Subscription));
  690. var SafeSubscriber = (function (_super) {
  691. __extends(SafeSubscriber, _super);
  692. function SafeSubscriber(_parentSubscriber, observerOrNext, error, complete) {
  693. var _this = _super.call(this) || this;
  694. _this._parentSubscriber = _parentSubscriber;
  695. var next;
  696. var context = _this;
  697. if (isFunction(observerOrNext)) {
  698. next = observerOrNext;
  699. }
  700. else if (observerOrNext) {
  701. next = observerOrNext.next;
  702. error = observerOrNext.error;
  703. complete = observerOrNext.complete;
  704. if (observerOrNext !== empty) {
  705. context = Object.create(observerOrNext);
  706. if (isFunction(context.unsubscribe)) {
  707. _this.add(context.unsubscribe.bind(context));
  708. }
  709. context.unsubscribe = _this.unsubscribe.bind(_this);
  710. }
  711. }
  712. _this._context = context;
  713. _this._next = next;
  714. _this._error = error;
  715. _this._complete = complete;
  716. return _this;
  717. }
  718. SafeSubscriber.prototype.next = function (value) {
  719. if (!this.isStopped && this._next) {
  720. var _parentSubscriber = this._parentSubscriber;
  721. if (!config.useDeprecatedSynchronousErrorHandling || !_parentSubscriber.syncErrorThrowable) {
  722. this.__tryOrUnsub(this._next, value);
  723. }
  724. else if (this.__tryOrSetError(_parentSubscriber, this._next, value)) {
  725. this.unsubscribe();
  726. }
  727. }
  728. };
  729. SafeSubscriber.prototype.error = function (err) {
  730. if (!this.isStopped) {
  731. var _parentSubscriber = this._parentSubscriber;
  732. var useDeprecatedSynchronousErrorHandling = config.useDeprecatedSynchronousErrorHandling;
  733. if (this._error) {
  734. if (!useDeprecatedSynchronousErrorHandling || !_parentSubscriber.syncErrorThrowable) {
  735. this.__tryOrUnsub(this._error, err);
  736. this.unsubscribe();
  737. }
  738. else {
  739. this.__tryOrSetError(_parentSubscriber, this._error, err);
  740. this.unsubscribe();
  741. }
  742. }
  743. else if (!_parentSubscriber.syncErrorThrowable) {
  744. this.unsubscribe();
  745. if (useDeprecatedSynchronousErrorHandling) {
  746. throw err;
  747. }
  748. hostReportError(err);
  749. }
  750. else {
  751. if (useDeprecatedSynchronousErrorHandling) {
  752. _parentSubscriber.syncErrorValue = err;
  753. _parentSubscriber.syncErrorThrown = true;
  754. }
  755. else {
  756. hostReportError(err);
  757. }
  758. this.unsubscribe();
  759. }
  760. }
  761. };
  762. SafeSubscriber.prototype.complete = function () {
  763. var _this = this;
  764. if (!this.isStopped) {
  765. var _parentSubscriber = this._parentSubscriber;
  766. if (this._complete) {
  767. var wrappedComplete = function () { return _this._complete.call(_this._context); };
  768. if (!config.useDeprecatedSynchronousErrorHandling || !_parentSubscriber.syncErrorThrowable) {
  769. this.__tryOrUnsub(wrappedComplete);
  770. this.unsubscribe();
  771. }
  772. else {
  773. this.__tryOrSetError(_parentSubscriber, wrappedComplete);
  774. this.unsubscribe();
  775. }
  776. }
  777. else {
  778. this.unsubscribe();
  779. }
  780. }
  781. };
  782. SafeSubscriber.prototype.__tryOrUnsub = function (fn, value) {
  783. try {
  784. fn.call(this._context, value);
  785. }
  786. catch (err) {
  787. this.unsubscribe();
  788. if (config.useDeprecatedSynchronousErrorHandling) {
  789. throw err;
  790. }
  791. else {
  792. hostReportError(err);
  793. }
  794. }
  795. };
  796. SafeSubscriber.prototype.__tryOrSetError = function (parent, fn, value) {
  797. if (!config.useDeprecatedSynchronousErrorHandling) {
  798. throw new Error('bad call');
  799. }
  800. try {
  801. fn.call(this._context, value);
  802. }
  803. catch (err) {
  804. if (config.useDeprecatedSynchronousErrorHandling) {
  805. parent.syncErrorValue = err;
  806. parent.syncErrorThrown = true;
  807. return true;
  808. }
  809. else {
  810. hostReportError(err);
  811. return true;
  812. }
  813. }
  814. return false;
  815. };
  816. SafeSubscriber.prototype._unsubscribe = function () {
  817. var _parentSubscriber = this._parentSubscriber;
  818. this._context = null;
  819. this._parentSubscriber = null;
  820. _parentSubscriber.unsubscribe();
  821. };
  822. return SafeSubscriber;
  823. }(Subscriber));
  824. function canReportError(observer) {
  825. while (observer) {
  826. var _a = observer, closed_1 = _a.closed, destination = _a.destination, isStopped = _a.isStopped;
  827. if (closed_1 || isStopped) {
  828. return false;
  829. }
  830. else if (destination && destination instanceof Subscriber) {
  831. observer = destination;
  832. }
  833. else {
  834. observer = null;
  835. }
  836. }
  837. return true;
  838. }
  839. function toSubscriber(nextOrObserver, error, complete) {
  840. if (nextOrObserver) {
  841. if (nextOrObserver instanceof Subscriber) {
  842. return nextOrObserver;
  843. }
  844. if (nextOrObserver[rxSubscriber]) {
  845. return nextOrObserver[rxSubscriber]();
  846. }
  847. }
  848. if (!nextOrObserver && !error && !complete) {
  849. return new Subscriber(empty);
  850. }
  851. return new Subscriber(nextOrObserver, error, complete);
  852. }
  853. var observable = typeof Symbol === 'function' && Symbol.observable || '@@observable';
  854. function noop() { }
  855. function pipe() {
  856. var fns = [];
  857. for (var _i = 0; _i < arguments.length; _i++) {
  858. fns[_i] = arguments[_i];
  859. }
  860. return pipeFromArray(fns);
  861. }
  862. function pipeFromArray(fns) {
  863. if (!fns) {
  864. return noop;
  865. }
  866. if (fns.length === 1) {
  867. return fns[0];
  868. }
  869. return function piped(input) {
  870. return fns.reduce(function (prev, fn) { return fn(prev); }, input);
  871. };
  872. }
  873. var Observable = (function () {
  874. function Observable(subscribe) {
  875. this._isScalar = false;
  876. if (subscribe) {
  877. this._subscribe = subscribe;
  878. }
  879. }
  880. Observable.prototype.lift = function (operator) {
  881. var observable$$1 = new Observable();
  882. observable$$1.source = this;
  883. observable$$1.operator = operator;
  884. return observable$$1;
  885. };
  886. Observable.prototype.subscribe = function (observerOrNext, error, complete) {
  887. var operator = this.operator;
  888. var sink = toSubscriber(observerOrNext, error, complete);
  889. if (operator) {
  890. operator.call(sink, this.source);
  891. }
  892. else {
  893. sink.add(this.source || (config.useDeprecatedSynchronousErrorHandling && !sink.syncErrorThrowable) ?
  894. this._subscribe(sink) :
  895. this._trySubscribe(sink));
  896. }
  897. if (config.useDeprecatedSynchronousErrorHandling) {
  898. if (sink.syncErrorThrowable) {
  899. sink.syncErrorThrowable = false;
  900. if (sink.syncErrorThrown) {
  901. throw sink.syncErrorValue;
  902. }
  903. }
  904. }
  905. return sink;
  906. };
  907. Observable.prototype._trySubscribe = function (sink) {
  908. try {
  909. return this._subscribe(sink);
  910. }
  911. catch (err) {
  912. if (config.useDeprecatedSynchronousErrorHandling) {
  913. sink.syncErrorThrown = true;
  914. sink.syncErrorValue = err;
  915. }
  916. if (canReportError(sink)) {
  917. sink.error(err);
  918. }
  919. else {
  920. console.warn(err);
  921. }
  922. }
  923. };
  924. Observable.prototype.forEach = function (next, promiseCtor) {
  925. var _this = this;
  926. promiseCtor = getPromiseCtor(promiseCtor);
  927. return new promiseCtor(function (resolve, reject) {
  928. var subscription;
  929. subscription = _this.subscribe(function (value) {
  930. try {
  931. next(value);
  932. }
  933. catch (err) {
  934. reject(err);
  935. if (subscription) {
  936. subscription.unsubscribe();
  937. }
  938. }
  939. }, reject, resolve);
  940. });
  941. };
  942. Observable.prototype._subscribe = function (subscriber) {
  943. var source = this.source;
  944. return source && source.subscribe(subscriber);
  945. };
  946. Observable.prototype[observable] = function () {
  947. return this;
  948. };
  949. Observable.prototype.pipe = function () {
  950. var operations = [];
  951. for (var _i = 0; _i < arguments.length; _i++) {
  952. operations[_i] = arguments[_i];
  953. }
  954. if (operations.length === 0) {
  955. return this;
  956. }
  957. return pipeFromArray(operations)(this);
  958. };
  959. Observable.prototype.toPromise = function (promiseCtor) {
  960. var _this = this;
  961. promiseCtor = getPromiseCtor(promiseCtor);
  962. return new promiseCtor(function (resolve, reject) {
  963. var value;
  964. _this.subscribe(function (x) { return value = x; }, function (err) { return reject(err); }, function () { return resolve(value); });
  965. });
  966. };
  967. Observable.create = function (subscribe) {
  968. return new Observable(subscribe);
  969. };
  970. return Observable;
  971. }());
  972. function getPromiseCtor(promiseCtor) {
  973. if (!promiseCtor) {
  974. promiseCtor = config.Promise || Promise;
  975. }
  976. if (!promiseCtor) {
  977. throw new Error('no Promise impl found');
  978. }
  979. return promiseCtor;
  980. }
  981. function ObjectUnsubscribedErrorImpl() {
  982. Error.call(this);
  983. this.message = 'object unsubscribed';
  984. this.name = 'ObjectUnsubscribedError';
  985. return this;
  986. }
  987. ObjectUnsubscribedErrorImpl.prototype = Object.create(Error.prototype);
  988. var ObjectUnsubscribedError = ObjectUnsubscribedErrorImpl;
  989. var SubjectSubscription = (function (_super) {
  990. __extends(SubjectSubscription, _super);
  991. function SubjectSubscription(subject, subscriber) {
  992. var _this = _super.call(this) || this;
  993. _this.subject = subject;
  994. _this.subscriber = subscriber;
  995. _this.closed = false;
  996. return _this;
  997. }
  998. SubjectSubscription.prototype.unsubscribe = function () {
  999. if (this.closed) {
  1000. return;
  1001. }
  1002. this.closed = true;
  1003. var subject = this.subject;
  1004. var observers = subject.observers;
  1005. this.subject = null;
  1006. if (!observers || observers.length === 0 || subject.isStopped || subject.closed) {
  1007. return;
  1008. }
  1009. var subscriberIndex = observers.indexOf(this.subscriber);
  1010. if (subscriberIndex !== -1) {
  1011. observers.splice(subscriberIndex, 1);
  1012. }
  1013. };
  1014. return SubjectSubscription;
  1015. }(Subscription));
  1016. var SubjectSubscriber = (function (_super) {
  1017. __extends(SubjectSubscriber, _super);
  1018. function SubjectSubscriber(destination) {
  1019. var _this = _super.call(this, destination) || this;
  1020. _this.destination = destination;
  1021. return _this;
  1022. }
  1023. return SubjectSubscriber;
  1024. }(Subscriber));
  1025. var Subject = (function (_super) {
  1026. __extends(Subject, _super);
  1027. function Subject() {
  1028. var _this = _super.call(this) || this;
  1029. _this.observers = [];
  1030. _this.closed = false;
  1031. _this.isStopped = false;
  1032. _this.hasError = false;
  1033. _this.thrownError = null;
  1034. return _this;
  1035. }
  1036. Subject.prototype[rxSubscriber] = function () {
  1037. return new SubjectSubscriber(this);
  1038. };
  1039. Subject.prototype.lift = function (operator) {
  1040. var subject = new AnonymousSubject(this, this);
  1041. subject.operator = operator;
  1042. return subject;
  1043. };
  1044. Subject.prototype.next = function (value) {
  1045. if (this.closed) {
  1046. throw new ObjectUnsubscribedError();
  1047. }
  1048. if (!this.isStopped) {
  1049. var observers = this.observers;
  1050. var len = observers.length;
  1051. var copy = observers.slice();
  1052. for (var i = 0; i < len; i++) {
  1053. copy[i].next(value);
  1054. }
  1055. }
  1056. };
  1057. Subject.prototype.error = function (err) {
  1058. if (this.closed) {
  1059. throw new ObjectUnsubscribedError();
  1060. }
  1061. this.hasError = true;
  1062. this.thrownError = err;
  1063. this.isStopped = true;
  1064. var observers = this.observers;
  1065. var len = observers.length;
  1066. var copy = observers.slice();
  1067. for (var i = 0; i < len; i++) {
  1068. copy[i].error(err);
  1069. }
  1070. this.observers.length = 0;
  1071. };
  1072. Subject.prototype.complete = function () {
  1073. if (this.closed) {
  1074. throw new ObjectUnsubscribedError();
  1075. }
  1076. this.isStopped = true;
  1077. var observers = this.observers;
  1078. var len = observers.length;
  1079. var copy = observers.slice();
  1080. for (var i = 0; i < len; i++) {
  1081. copy[i].complete();
  1082. }
  1083. this.observers.length = 0;
  1084. };
  1085. Subject.prototype.unsubscribe = function () {
  1086. this.isStopped = true;
  1087. this.closed = true;
  1088. this.observers = null;
  1089. };
  1090. Subject.prototype._trySubscribe = function (subscriber) {
  1091. if (this.closed) {
  1092. throw new ObjectUnsubscribedError();
  1093. }
  1094. else {
  1095. return _super.prototype._trySubscribe.call(this, subscriber);
  1096. }
  1097. };
  1098. Subject.prototype._subscribe = function (subscriber) {
  1099. if (this.closed) {
  1100. throw new ObjectUnsubscribedError();
  1101. }
  1102. else if (this.hasError) {
  1103. subscriber.error(this.thrownError);
  1104. return Subscription.EMPTY;
  1105. }
  1106. else if (this.isStopped) {
  1107. subscriber.complete();
  1108. return Subscription.EMPTY;
  1109. }
  1110. else {
  1111. this.observers.push(subscriber);
  1112. return new SubjectSubscription(this, subscriber);
  1113. }
  1114. };
  1115. Subject.prototype.asObservable = function () {
  1116. var observable = new Observable();
  1117. observable.source = this;
  1118. return observable;
  1119. };
  1120. Subject.create = function (destination, source) {
  1121. return new AnonymousSubject(destination, source);
  1122. };
  1123. return Subject;
  1124. }(Observable));
  1125. var AnonymousSubject = (function (_super) {
  1126. __extends(AnonymousSubject, _super);
  1127. function AnonymousSubject(destination, source) {
  1128. var _this = _super.call(this) || this;
  1129. _this.destination = destination;
  1130. _this.source = source;
  1131. return _this;
  1132. }
  1133. AnonymousSubject.prototype.next = function (value) {
  1134. var destination = this.destination;
  1135. if (destination && destination.next) {
  1136. destination.next(value);
  1137. }
  1138. };
  1139. AnonymousSubject.prototype.error = function (err) {
  1140. var destination = this.destination;
  1141. if (destination && destination.error) {
  1142. this.destination.error(err);
  1143. }
  1144. };
  1145. AnonymousSubject.prototype.complete = function () {
  1146. var destination = this.destination;
  1147. if (destination && destination.complete) {
  1148. this.destination.complete();
  1149. }
  1150. };
  1151. AnonymousSubject.prototype._subscribe = function (subscriber) {
  1152. var source = this.source;
  1153. if (source) {
  1154. return this.source.subscribe(subscriber);
  1155. }
  1156. else {
  1157. return Subscription.EMPTY;
  1158. }
  1159. };
  1160. return AnonymousSubject;
  1161. }(Subject));
  1162. function refCount() {
  1163. return function refCountOperatorFunction(source) {
  1164. return source.lift(new RefCountOperator$1(source));
  1165. };
  1166. }
  1167. var RefCountOperator$1 = (function () {
  1168. function RefCountOperator(connectable) {
  1169. this.connectable = connectable;
  1170. }
  1171. RefCountOperator.prototype.call = function (subscriber, source) {
  1172. var connectable = this.connectable;
  1173. connectable._refCount++;
  1174. var refCounter = new RefCountSubscriber$1(subscriber, connectable);
  1175. var subscription = source.subscribe(refCounter);
  1176. if (!refCounter.closed) {
  1177. refCounter.connection = connectable.connect();
  1178. }
  1179. return subscription;
  1180. };
  1181. return RefCountOperator;
  1182. }());
  1183. var RefCountSubscriber$1 = (function (_super) {
  1184. __extends(RefCountSubscriber, _super);
  1185. function RefCountSubscriber(destination, connectable) {
  1186. var _this = _super.call(this, destination) || this;
  1187. _this.connectable = connectable;
  1188. return _this;
  1189. }
  1190. RefCountSubscriber.prototype._unsubscribe = function () {
  1191. var connectable = this.connectable;
  1192. if (!connectable) {
  1193. this.connection = null;
  1194. return;
  1195. }
  1196. this.connectable = null;
  1197. var refCount = connectable._refCount;
  1198. if (refCount <= 0) {
  1199. this.connection = null;
  1200. return;
  1201. }
  1202. connectable._refCount = refCount - 1;
  1203. if (refCount > 1) {
  1204. this.connection = null;
  1205. return;
  1206. }
  1207. var connection = this.connection;
  1208. var sharedConnection = connectable._connection;
  1209. this.connection = null;
  1210. if (sharedConnection && (!connection || sharedConnection === connection)) {
  1211. sharedConnection.unsubscribe();
  1212. }
  1213. };
  1214. return RefCountSubscriber;
  1215. }(Subscriber));
  1216. var ConnectableObservable = (function (_super) {
  1217. __extends(ConnectableObservable, _super);
  1218. function ConnectableObservable(source, subjectFactory) {
  1219. var _this = _super.call(this) || this;
  1220. _this.source = source;
  1221. _this.subjectFactory = subjectFactory;
  1222. _this._refCount = 0;
  1223. _this._isComplete = false;
  1224. return _this;
  1225. }
  1226. ConnectableObservable.prototype._subscribe = function (subscriber) {
  1227. return this.getSubject().subscribe(subscriber);
  1228. };
  1229. ConnectableObservable.prototype.getSubject = function () {
  1230. var subject = this._subject;
  1231. if (!subject || subject.isStopped) {
  1232. this._subject = this.subjectFactory();
  1233. }
  1234. return this._subject;
  1235. };
  1236. ConnectableObservable.prototype.connect = function () {
  1237. var connection = this._connection;
  1238. if (!connection) {
  1239. this._isComplete = false;
  1240. connection = this._connection = new Subscription();
  1241. connection.add(this.source
  1242. .subscribe(new ConnectableSubscriber(this.getSubject(), this)));
  1243. if (connection.closed) {
  1244. this._connection = null;
  1245. connection = Subscription.EMPTY;
  1246. }
  1247. else {
  1248. this._connection = connection;
  1249. }
  1250. }
  1251. return connection;
  1252. };
  1253. ConnectableObservable.prototype.refCount = function () {
  1254. return refCount()(this);
  1255. };
  1256. return ConnectableObservable;
  1257. }(Observable));
  1258. var connectableProto = ConnectableObservable.prototype;
  1259. var connectableObservableDescriptor = {
  1260. operator: { value: null },
  1261. _refCount: { value: 0, writable: true },
  1262. _subject: { value: null, writable: true },
  1263. _connection: { value: null, writable: true },
  1264. _subscribe: { value: connectableProto._subscribe },
  1265. _isComplete: { value: connectableProto._isComplete, writable: true },
  1266. getSubject: { value: connectableProto.getSubject },
  1267. connect: { value: connectableProto.connect },
  1268. refCount: { value: connectableProto.refCount }
  1269. };
  1270. var ConnectableSubscriber = (function (_super) {
  1271. __extends(ConnectableSubscriber, _super);
  1272. function ConnectableSubscriber(destination, connectable) {
  1273. var _this = _super.call(this, destination) || this;
  1274. _this.connectable = connectable;
  1275. return _this;
  1276. }
  1277. ConnectableSubscriber.prototype._error = function (err) {
  1278. this._unsubscribe();
  1279. _super.prototype._error.call(this, err);
  1280. };
  1281. ConnectableSubscriber.prototype._complete = function () {
  1282. this.connectable._isComplete = true;
  1283. this._unsubscribe();
  1284. _super.prototype._complete.call(this);
  1285. };
  1286. ConnectableSubscriber.prototype._unsubscribe = function () {
  1287. var connectable = this.connectable;
  1288. if (connectable) {
  1289. this.connectable = null;
  1290. var connection = connectable._connection;
  1291. connectable._refCount = 0;
  1292. connectable._subject = null;
  1293. connectable._connection = null;
  1294. if (connection) {
  1295. connection.unsubscribe();
  1296. }
  1297. }
  1298. };
  1299. return ConnectableSubscriber;
  1300. }(SubjectSubscriber));
  1301. var RefCountSubscriber = (function (_super) {
  1302. __extends(RefCountSubscriber, _super);
  1303. function RefCountSubscriber(destination, connectable) {
  1304. var _this = _super.call(this, destination) || this;
  1305. _this.connectable = connectable;
  1306. return _this;
  1307. }
  1308. RefCountSubscriber.prototype._unsubscribe = function () {
  1309. var connectable = this.connectable;
  1310. if (!connectable) {
  1311. this.connection = null;
  1312. return;
  1313. }
  1314. this.connectable = null;
  1315. var refCount$$1 = connectable._refCount;
  1316. if (refCount$$1 <= 0) {
  1317. this.connection = null;
  1318. return;
  1319. }
  1320. connectable._refCount = refCount$$1 - 1;
  1321. if (refCount$$1 > 1) {
  1322. this.connection = null;
  1323. return;
  1324. }
  1325. var connection = this.connection;
  1326. var sharedConnection = connectable._connection;
  1327. this.connection = null;
  1328. if (sharedConnection && (!connection || sharedConnection === connection)) {
  1329. sharedConnection.unsubscribe();
  1330. }
  1331. };
  1332. return RefCountSubscriber;
  1333. }(Subscriber));
  1334. function groupBy(keySelector, elementSelector, durationSelector, subjectSelector) {
  1335. return function (source) {
  1336. return source.lift(new GroupByOperator(keySelector, elementSelector, durationSelector, subjectSelector));
  1337. };
  1338. }
  1339. var GroupByOperator = (function () {
  1340. function GroupByOperator(keySelector, elementSelector, durationSelector, subjectSelector) {
  1341. this.keySelector = keySelector;
  1342. this.elementSelector = elementSelector;
  1343. this.durationSelector = durationSelector;
  1344. this.subjectSelector = subjectSelector;
  1345. }
  1346. GroupByOperator.prototype.call = function (subscriber, source) {
  1347. return source.subscribe(new GroupBySubscriber(subscriber, this.keySelector, this.elementSelector, this.durationSelector, this.subjectSelector));
  1348. };
  1349. return GroupByOperator;
  1350. }());
  1351. var GroupBySubscriber = (function (_super) {
  1352. __extends(GroupBySubscriber, _super);
  1353. function GroupBySubscriber(destination, keySelector, elementSelector, durationSelector, subjectSelector) {
  1354. var _this = _super.call(this, destination) || this;
  1355. _this.keySelector = keySelector;
  1356. _this.elementSelector = elementSelector;
  1357. _this.durationSelector = durationSelector;
  1358. _this.subjectSelector = subjectSelector;
  1359. _this.groups = null;
  1360. _this.attemptedToUnsubscribe = false;
  1361. _this.count = 0;
  1362. return _this;
  1363. }
  1364. GroupBySubscriber.prototype._next = function (value) {
  1365. var key;
  1366. try {
  1367. key = this.keySelector(value);
  1368. }
  1369. catch (err) {
  1370. this.error(err);
  1371. return;
  1372. }
  1373. this._group(value, key);
  1374. };
  1375. GroupBySubscriber.prototype._group = function (value, key) {
  1376. var groups = this.groups;
  1377. if (!groups) {
  1378. groups = this.groups = new Map();
  1379. }
  1380. var group = groups.get(key);
  1381. var element;
  1382. if (this.elementSelector) {
  1383. try {
  1384. element = this.elementSelector(value);
  1385. }
  1386. catch (err) {
  1387. this.error(err);
  1388. }
  1389. }
  1390. else {
  1391. element = value;
  1392. }
  1393. if (!group) {
  1394. group = (this.subjectSelector ? this.subjectSelector() : new Subject());
  1395. groups.set(key, group);
  1396. var groupedObservable = new GroupedObservable(key, group, this);
  1397. this.destination.next(groupedObservable);
  1398. if (this.durationSelector) {
  1399. var duration = void 0;
  1400. try {
  1401. duration = this.durationSelector(new GroupedObservable(key, group));
  1402. }
  1403. catch (err) {
  1404. this.error(err);
  1405. return;
  1406. }
  1407. this.add(duration.subscribe(new GroupDurationSubscriber(key, group, this)));
  1408. }
  1409. }
  1410. if (!group.closed) {
  1411. group.next(element);
  1412. }
  1413. };
  1414. GroupBySubscriber.prototype._error = function (err) {
  1415. var groups = this.groups;
  1416. if (groups) {
  1417. groups.forEach(function (group, key) {
  1418. group.error(err);
  1419. });
  1420. groups.clear();
  1421. }
  1422. this.destination.error(err);
  1423. };
  1424. GroupBySubscriber.prototype._complete = function () {
  1425. var groups = this.groups;
  1426. if (groups) {
  1427. groups.forEach(function (group, key) {
  1428. group.complete();
  1429. });
  1430. groups.clear();
  1431. }
  1432. this.destination.complete();
  1433. };
  1434. GroupBySubscriber.prototype.removeGroup = function (key) {
  1435. this.groups.delete(key);
  1436. };
  1437. GroupBySubscriber.prototype.unsubscribe = function () {
  1438. if (!this.closed) {
  1439. this.attemptedToUnsubscribe = true;
  1440. if (this.count === 0) {
  1441. _super.prototype.unsubscribe.call(this);
  1442. }
  1443. }
  1444. };
  1445. return GroupBySubscriber;
  1446. }(Subscriber));
  1447. var GroupDurationSubscriber = (function (_super) {
  1448. __extends(GroupDurationSubscriber, _super);
  1449. function GroupDurationSubscriber(key, group, parent) {
  1450. var _this = _super.call(this, group) || this;
  1451. _this.key = key;
  1452. _this.group = group;
  1453. _this.parent = parent;
  1454. return _this;
  1455. }
  1456. GroupDurationSubscriber.prototype._next = function (value) {
  1457. this.complete();
  1458. };
  1459. GroupDurationSubscriber.prototype._unsubscribe = function () {
  1460. var _a = this, parent = _a.parent, key = _a.key;
  1461. this.key = this.parent = null;
  1462. if (parent) {
  1463. parent.removeGroup(key);
  1464. }
  1465. };
  1466. return GroupDurationSubscriber;
  1467. }(Subscriber));
  1468. var GroupedObservable = (function (_super) {
  1469. __extends(GroupedObservable, _super);
  1470. function GroupedObservable(key, groupSubject, refCountSubscription) {
  1471. var _this = _super.call(this) || this;
  1472. _this.key = key;
  1473. _this.groupSubject = groupSubject;
  1474. _this.refCountSubscription = refCountSubscription;
  1475. return _this;
  1476. }
  1477. GroupedObservable.prototype._subscribe = function (subscriber) {
  1478. var subscription = new Subscription();
  1479. var _a = this, refCountSubscription = _a.refCountSubscription, groupSubject = _a.groupSubject;
  1480. if (refCountSubscription && !refCountSubscription.closed) {
  1481. subscription.add(new InnerRefCountSubscription(refCountSubscription));
  1482. }
  1483. subscription.add(groupSubject.subscribe(subscriber));
  1484. return subscription;
  1485. };
  1486. return GroupedObservable;
  1487. }(Observable));
  1488. var InnerRefCountSubscription = (function (_super) {
  1489. __extends(InnerRefCountSubscription, _super);
  1490. function InnerRefCountSubscription(parent) {
  1491. var _this = _super.call(this) || this;
  1492. _this.parent = parent;
  1493. parent.count++;
  1494. return _this;
  1495. }
  1496. InnerRefCountSubscription.prototype.unsubscribe = function () {
  1497. var parent = this.parent;
  1498. if (!parent.closed && !this.closed) {
  1499. _super.prototype.unsubscribe.call(this);
  1500. parent.count -= 1;
  1501. if (parent.count === 0 && parent.attemptedToUnsubscribe) {
  1502. parent.unsubscribe();
  1503. }
  1504. }
  1505. };
  1506. return InnerRefCountSubscription;
  1507. }(Subscription));
  1508. var BehaviorSubject = (function (_super) {
  1509. __extends(BehaviorSubject, _super);
  1510. function BehaviorSubject(_value) {
  1511. var _this = _super.call(this) || this;
  1512. _this._value = _value;
  1513. return _this;
  1514. }
  1515. Object.defineProperty(BehaviorSubject.prototype, "value", {
  1516. get: function () {
  1517. return this.getValue();
  1518. },
  1519. enumerable: true,
  1520. configurable: true
  1521. });
  1522. BehaviorSubject.prototype._subscribe = function (subscriber) {
  1523. var subscription = _super.prototype._subscribe.call(this, subscriber);
  1524. if (subscription && !subscription.closed) {
  1525. subscriber.next(this._value);
  1526. }
  1527. return subscription;
  1528. };
  1529. BehaviorSubject.prototype.getValue = function () {
  1530. if (this.hasError) {
  1531. throw this.thrownError;
  1532. }
  1533. else if (this.closed) {
  1534. throw new ObjectUnsubscribedError();
  1535. }
  1536. else {
  1537. return this._value;
  1538. }
  1539. };
  1540. BehaviorSubject.prototype.next = function (value) {
  1541. _super.prototype.next.call(this, this._value = value);
  1542. };
  1543. return BehaviorSubject;
  1544. }(Subject));
  1545. var Action = (function (_super) {
  1546. __extends(Action, _super);
  1547. function Action(scheduler, work) {
  1548. return _super.call(this) || this;
  1549. }
  1550. Action.prototype.schedule = function (state, delay) {
  1551. if (delay === void 0) { delay = 0; }
  1552. return this;
  1553. };
  1554. return Action;
  1555. }(Subscription));
  1556. var AsyncAction = (function (_super) {
  1557. __extends(AsyncAction, _super);
  1558. function AsyncAction(scheduler, work) {
  1559. var _this = _super.call(this, scheduler, work) || this;
  1560. _this.scheduler = scheduler;
  1561. _this.work = work;
  1562. _this.pending = false;
  1563. return _this;
  1564. }
  1565. AsyncAction.prototype.schedule = function (state, delay) {
  1566. if (delay === void 0) { delay = 0; }
  1567. if (this.closed) {
  1568. return this;
  1569. }
  1570. this.state = state;
  1571. var id = this.id;
  1572. var scheduler = this.scheduler;
  1573. if (id != null) {
  1574. this.id = this.recycleAsyncId(scheduler, id, delay);
  1575. }
  1576. this.pending = true;
  1577. this.delay = delay;
  1578. this.id = this.id || this.requestAsyncId(scheduler, this.id, delay);
  1579. return this;
  1580. };
  1581. AsyncAction.prototype.requestAsyncId = function (scheduler, id, delay) {
  1582. if (delay === void 0) { delay = 0; }
  1583. return setInterval(scheduler.flush.bind(scheduler, this), delay);
  1584. };
  1585. AsyncAction.prototype.recycleAsyncId = function (scheduler, id, delay) {
  1586. if (delay === void 0) { delay = 0; }
  1587. if (delay !== null && this.delay === delay && this.pending === false) {
  1588. return id;
  1589. }
  1590. clearInterval(id);
  1591. };
  1592. AsyncAction.prototype.execute = function (state, delay) {
  1593. if (this.closed) {
  1594. return new Error('executing a cancelled action');
  1595. }
  1596. this.pending = false;
  1597. var error = this._execute(state, delay);
  1598. if (error) {
  1599. return error;
  1600. }
  1601. else if (this.pending === false && this.id != null) {
  1602. this.id = this.recycleAsyncId(this.scheduler, this.id, null);
  1603. }
  1604. };
  1605. AsyncAction.prototype._execute = function (state, delay) {
  1606. var errored = false;
  1607. var errorValue = undefined;
  1608. try {
  1609. this.work(state);
  1610. }
  1611. catch (e) {
  1612. errored = true;
  1613. errorValue = !!e && e || new Error(e);
  1614. }
  1615. if (errored) {
  1616. this.unsubscribe();
  1617. return errorValue;
  1618. }
  1619. };
  1620. AsyncAction.prototype._unsubscribe = function () {
  1621. var id = this.id;
  1622. var scheduler = this.scheduler;
  1623. var actions = scheduler.actions;
  1624. var index = actions.indexOf(this);
  1625. this.work = null;
  1626. this.state = null;
  1627. this.pending = false;
  1628. this.scheduler = null;
  1629. if (index !== -1) {
  1630. actions.splice(index, 1);
  1631. }
  1632. if (id != null) {
  1633. this.id = this.recycleAsyncId(scheduler, id, null);
  1634. }
  1635. this.delay = null;
  1636. };
  1637. return AsyncAction;
  1638. }(Action));
  1639. var QueueAction = (function (_super) {
  1640. __extends(QueueAction, _super);
  1641. function QueueAction(scheduler, work) {
  1642. var _this = _super.call(this, scheduler, work) || this;
  1643. _this.scheduler = scheduler;
  1644. _this.work = work;
  1645. return _this;
  1646. }
  1647. QueueAction.prototype.schedule = function (state, delay) {
  1648. if (delay === void 0) { delay = 0; }
  1649. if (delay > 0) {
  1650. return _super.prototype.schedule.call(this, state, delay);
  1651. }
  1652. this.delay = delay;
  1653. this.state = state;
  1654. this.scheduler.flush(this);
  1655. return this;
  1656. };
  1657. QueueAction.prototype.execute = function (state, delay) {
  1658. return (delay > 0 || this.closed) ?
  1659. _super.prototype.execute.call(this, state, delay) :
  1660. this._execute(state, delay);
  1661. };
  1662. QueueAction.prototype.requestAsyncId = function (scheduler, id, delay) {
  1663. if (delay === void 0) { delay = 0; }
  1664. if ((delay !== null && delay > 0) || (delay === null && this.delay > 0)) {
  1665. return _super.prototype.requestAsyncId.call(this, scheduler, id, delay);
  1666. }
  1667. return scheduler.flush(this);
  1668. };
  1669. return QueueAction;
  1670. }(AsyncAction));
  1671. var Scheduler = (function () {
  1672. function Scheduler(SchedulerAction, now) {
  1673. if (now === void 0) { now = Scheduler.now; }
  1674. this.SchedulerAction = SchedulerAction;
  1675. this.now = now;
  1676. }
  1677. Scheduler.prototype.schedule = function (work, delay, state) {
  1678. if (delay === void 0) { delay = 0; }
  1679. return new this.SchedulerAction(this, work).schedule(state, delay);
  1680. };
  1681. Scheduler.now = function () { return Date.now(); };
  1682. return Scheduler;
  1683. }());
  1684. var AsyncScheduler = (function (_super) {
  1685. __extends(AsyncScheduler, _super);
  1686. function AsyncScheduler(SchedulerAction, now) {
  1687. if (now === void 0) { now = Scheduler.now; }
  1688. var _this = _super.call(this, SchedulerAction, function () {
  1689. if (AsyncScheduler.delegate && AsyncScheduler.delegate !== _this) {
  1690. return AsyncScheduler.delegate.now();
  1691. }
  1692. else {
  1693. return now();
  1694. }
  1695. }) || this;
  1696. _this.actions = [];
  1697. _this.active = false;
  1698. _this.scheduled = undefined;
  1699. return _this;
  1700. }
  1701. AsyncScheduler.prototype.schedule = function (work, delay, state) {
  1702. if (delay === void 0) { delay = 0; }
  1703. if (AsyncScheduler.delegate && AsyncScheduler.delegate !== this) {
  1704. return AsyncScheduler.delegate.schedule(work, delay, state);
  1705. }
  1706. else {
  1707. return _super.prototype.schedule.call(this, work, delay, state);
  1708. }
  1709. };
  1710. AsyncScheduler.prototype.flush = function (action) {
  1711. var actions = this.actions;
  1712. if (this.active) {
  1713. actions.push(action);
  1714. return;
  1715. }
  1716. var error;
  1717. this.active = true;
  1718. do {
  1719. if (error = action.execute(action.state, action.delay)) {
  1720. break;
  1721. }
  1722. } while (action = actions.shift());
  1723. this.active = false;
  1724. if (error) {
  1725. while (action = actions.shift()) {
  1726. action.unsubscribe();
  1727. }
  1728. throw error;
  1729. }
  1730. };
  1731. return AsyncScheduler;
  1732. }(Scheduler));
  1733. var QueueScheduler = (function (_super) {
  1734. __extends(QueueScheduler, _super);
  1735. function QueueScheduler() {
  1736. return _super !== null && _super.apply(this, arguments) || this;
  1737. }
  1738. return QueueScheduler;
  1739. }(AsyncScheduler));
  1740. var queue = new QueueScheduler(QueueAction);
  1741. var EMPTY = new Observable(function (subscriber) { return subscriber.complete(); });
  1742. function empty$1(scheduler) {
  1743. return scheduler ? emptyScheduled(scheduler) : EMPTY;
  1744. }
  1745. function emptyScheduled(scheduler) {
  1746. return new Observable(function (subscriber) { return scheduler.schedule(function () { return subscriber.complete(); }); });
  1747. }
  1748. function isScheduler(value) {
  1749. return value && typeof value.schedule === 'function';
  1750. }
  1751. var subscribeToArray = function (array) { return function (subscriber) {
  1752. for (var i = 0, len = array.length; i < len && !subscriber.closed; i++) {
  1753. subscriber.next(array[i]);
  1754. }
  1755. if (!subscriber.closed) {
  1756. subscriber.complete();
  1757. }
  1758. }; };
  1759. function fromArray(input, scheduler) {
  1760. if (!scheduler) {
  1761. return new Observable(subscribeToArray(input));
  1762. }
  1763. else {
  1764. return new Observable(function (subscriber) {
  1765. var sub = new Subscription();
  1766. var i = 0;
  1767. sub.add(scheduler.schedule(function () {
  1768. if (i === input.length) {
  1769. subscriber.complete();
  1770. return;
  1771. }
  1772. subscriber.next(input[i++]);
  1773. if (!subscriber.closed) {
  1774. sub.add(this.schedule());
  1775. }
  1776. }));
  1777. return sub;
  1778. });
  1779. }
  1780. }
  1781. function scalar(value) {
  1782. var result = new Observable(function (subscriber) {
  1783. subscriber.next(value);
  1784. subscriber.complete();
  1785. });
  1786. result._isScalar = true;
  1787. result.value = value;
  1788. return result;
  1789. }
  1790. function of() {
  1791. var args = [];
  1792. for (var _i = 0; _i < arguments.length; _i++) {
  1793. args[_i] = arguments[_i];
  1794. }
  1795. var scheduler = args[args.length - 1];
  1796. if (isScheduler(scheduler)) {
  1797. args.pop();
  1798. }
  1799. else {
  1800. scheduler = undefined;
  1801. }
  1802. switch (args.length) {
  1803. case 0:
  1804. return empty$1(scheduler);
  1805. case 1:
  1806. return scheduler ? fromArray(args, scheduler) : scalar(args[0]);
  1807. default:
  1808. return fromArray(args, scheduler);
  1809. }
  1810. }
  1811. function throwError(error, scheduler) {
  1812. if (!scheduler) {
  1813. return new Observable(function (subscriber) { return subscriber.error(error); });
  1814. }
  1815. else {
  1816. return new Observable(function (subscriber) { return scheduler.schedule(dispatch, 0, { error: error, subscriber: subscriber }); });
  1817. }
  1818. }
  1819. function dispatch(_a) {
  1820. var error = _a.error, subscriber = _a.subscriber;
  1821. subscriber.error(error);
  1822. }
  1823. var Notification = (function () {
  1824. function Notification(kind, value, error) {
  1825. this.kind = kind;
  1826. this.value = value;
  1827. this.error = error;
  1828. this.hasValue = kind === 'N';
  1829. }
  1830. Notification.prototype.observe = function (observer) {
  1831. switch (this.kind) {
  1832. case 'N':
  1833. return observer.next && observer.next(this.value);
  1834. case 'E':
  1835. return observer.error && observer.error(this.error);
  1836. case 'C':
  1837. return observer.complete && observer.complete();
  1838. }
  1839. };
  1840. Notification.prototype.do = function (next, error, complete) {
  1841. var kind = this.kind;
  1842. switch (kind) {
  1843. case 'N':
  1844. return next && next(this.value);
  1845. case 'E':
  1846. return error && error(this.error);
  1847. case 'C':
  1848. return complete && complete();
  1849. }
  1850. };
  1851. Notification.prototype.accept = function (nextOrObserver, error, complete) {
  1852. if (nextOrObserver && typeof nextOrObserver.next === 'function') {
  1853. return this.observe(nextOrObserver);
  1854. }
  1855. else {
  1856. return this.do(nextOrObserver, error, complete);
  1857. }
  1858. };
  1859. Notification.prototype.toObservable = function () {
  1860. var kind = this.kind;
  1861. switch (kind) {
  1862. case 'N':
  1863. return of(this.value);
  1864. case 'E':
  1865. return throwError(this.error);
  1866. case 'C':
  1867. return empty$1();
  1868. }
  1869. throw new Error('unexpected notification kind value');
  1870. };
  1871. Notification.createNext = function (value) {
  1872. if (typeof value !== 'undefined') {
  1873. return new Notification('N', value);
  1874. }
  1875. return Notification.undefinedValueNotification;
  1876. };
  1877. Notification.createError = function (err) {
  1878. return new Notification('E', undefined, err);
  1879. };
  1880. Notification.createComplete = function () {
  1881. return Notification.completeNotification;
  1882. };
  1883. Notification.completeNotification = new Notification('C');
  1884. Notification.undefinedValueNotification = new Notification('N', undefined);
  1885. return Notification;
  1886. }());
  1887. function observeOn(scheduler, delay) {
  1888. if (delay === void 0) { delay = 0; }
  1889. return function observeOnOperatorFunction(source) {
  1890. return source.lift(new ObserveOnOperator(scheduler, delay));
  1891. };
  1892. }
  1893. var ObserveOnOperator = (function () {
  1894. function ObserveOnOperator(scheduler, delay) {
  1895. if (delay === void 0) { delay = 0; }
  1896. this.scheduler = scheduler;
  1897. this.delay = delay;
  1898. }
  1899. ObserveOnOperator.prototype.call = function (subscriber, source) {
  1900. return source.subscribe(new ObserveOnSubscriber(subscriber, this.scheduler, this.delay));
  1901. };
  1902. return ObserveOnOperator;
  1903. }());
  1904. var ObserveOnSubscriber = (function (_super) {
  1905. __extends(ObserveOnSubscriber, _super);
  1906. function ObserveOnSubscriber(destination, scheduler, delay) {
  1907. if (delay === void 0) { delay = 0; }
  1908. var _this = _super.call(this, destination) || this;
  1909. _this.scheduler = scheduler;
  1910. _this.delay = delay;
  1911. return _this;
  1912. }
  1913. ObserveOnSubscriber.dispatch = function (arg) {
  1914. var notification = arg.notification, destination = arg.destination;
  1915. notification.observe(destination);
  1916. this.unsubscribe();
  1917. };
  1918. ObserveOnSubscriber.prototype.scheduleMessage = function (notification) {
  1919. var destination = this.destination;
  1920. destination.add(this.scheduler.schedule(ObserveOnSubscriber.dispatch, this.delay, new ObserveOnMessage(notification, this.destination)));
  1921. };
  1922. ObserveOnSubscriber.prototype._next = function (value) {
  1923. this.scheduleMessage(Notification.createNext(value));
  1924. };
  1925. ObserveOnSubscriber.prototype._error = function (err) {
  1926. this.scheduleMessage(Notification.createError(err));
  1927. this.unsubscribe();
  1928. };
  1929. ObserveOnSubscriber.prototype._complete = function () {
  1930. this.scheduleMessage(Notification.createComplete());
  1931. this.unsubscribe();
  1932. };
  1933. return ObserveOnSubscriber;
  1934. }(Subscriber));
  1935. var ObserveOnMessage = (function () {
  1936. function ObserveOnMessage(notification, destination) {
  1937. this.notification = notification;
  1938. this.destination = destination;
  1939. }
  1940. return ObserveOnMessage;
  1941. }());
  1942. var ReplaySubject = (function (_super) {
  1943. __extends(ReplaySubject, _super);
  1944. function ReplaySubject(bufferSize, windowTime, scheduler) {
  1945. if (bufferSize === void 0) { bufferSize = Number.POSITIVE_INFINITY; }
  1946. if (windowTime === void 0) { windowTime = Number.POSITIVE_INFINITY; }
  1947. var _this = _super.call(this) || this;
  1948. _this.scheduler = scheduler;
  1949. _this._events = [];
  1950. _this._infiniteTimeWindow = false;
  1951. _this._bufferSize = bufferSize < 1 ? 1 : bufferSize;
  1952. _this._windowTime = windowTime < 1 ? 1 : windowTime;
  1953. if (windowTime === Number.POSITIVE_INFINITY) {
  1954. _this._infiniteTimeWindow = true;
  1955. _this.next = _this.nextInfiniteTimeWindow;
  1956. }
  1957. else {
  1958. _this.next = _this.nextTimeWindow;
  1959. }
  1960. return _this;
  1961. }
  1962. ReplaySubject.prototype.nextInfiniteTimeWindow = function (value) {
  1963. var _events = this._events;
  1964. _events.push(value);
  1965. if (_events.length > this._bufferSize) {
  1966. _events.shift();
  1967. }
  1968. _super.prototype.next.call(this, value);
  1969. };
  1970. ReplaySubject.prototype.nextTimeWindow = function (value) {
  1971. this._events.push(new ReplayEvent(this._getNow(), value));
  1972. this._trimBufferThenGetEvents();
  1973. _super.prototype.next.call(this, value);
  1974. };
  1975. ReplaySubject.prototype._subscribe = function (subscriber) {
  1976. var _infiniteTimeWindow = this._infiniteTimeWindow;
  1977. var _events = _infiniteTimeWindow ? this._events : this._trimBufferThenGetEvents();
  1978. var scheduler = this.scheduler;
  1979. var len = _events.length;
  1980. var subscription;
  1981. if (this.closed) {
  1982. throw new ObjectUnsubscribedError();
  1983. }
  1984. else if (this.isStopped || this.hasError) {
  1985. subscription = Subscription.EMPTY;
  1986. }
  1987. else {
  1988. this.observers.push(subscriber);
  1989. subscription = new SubjectSubscription(this, subscriber);
  1990. }
  1991. if (scheduler) {
  1992. subscriber.add(subscriber = new ObserveOnSubscriber(subscriber, scheduler));
  1993. }
  1994. if (_infiniteTimeWindow) {
  1995. for (var i = 0; i < len && !subscriber.closed; i++) {
  1996. subscriber.next(_events[i]);
  1997. }
  1998. }
  1999. else {
  2000. for (var i = 0; i < len && !subscriber.closed; i++) {
  2001. subscriber.next(_events[i].value);
  2002. }
  2003. }
  2004. if (this.hasError) {
  2005. subscriber.error(this.thrownError);
  2006. }
  2007. else if (this.isStopped) {
  2008. subscriber.complete();
  2009. }
  2010. return subscription;
  2011. };
  2012. ReplaySubject.prototype._getNow = function () {
  2013. return (this.scheduler || queue).now();
  2014. };
  2015. ReplaySubject.prototype._trimBufferThenGetEvents = function () {
  2016. var now = this._getNow();
  2017. var _bufferSize = this._bufferSize;
  2018. var _windowTime = this._windowTime;
  2019. var _events = this._events;
  2020. var eventsCount = _events.length;
  2021. var spliceCount = 0;
  2022. while (spliceCount < eventsCount) {
  2023. if ((now - _events[spliceCount].time) < _windowTime) {
  2024. break;
  2025. }
  2026. spliceCount++;
  2027. }
  2028. if (eventsCount > _bufferSize) {
  2029. spliceCount = Math.max(spliceCount, eventsCount - _bufferSize);
  2030. }
  2031. if (spliceCount > 0) {
  2032. _events.splice(0, spliceCount);
  2033. }
  2034. return _events;
  2035. };
  2036. return ReplaySubject;
  2037. }(Subject));
  2038. var ReplayEvent = (function () {
  2039. function ReplayEvent(time, value) {
  2040. this.time = time;
  2041. this.value = value;
  2042. }
  2043. return ReplayEvent;
  2044. }());
  2045. var AsyncSubject = (function (_super) {
  2046. __extends(AsyncSubject, _super);
  2047. function AsyncSubject() {
  2048. var _this = _super !== null && _super.apply(this, arguments) || this;
  2049. _this.value = null;
  2050. _this.hasNext = false;
  2051. _this.hasCompleted = false;
  2052. return _this;
  2053. }
  2054. AsyncSubject.prototype._subscribe = function (subscriber) {
  2055. if (this.hasError) {
  2056. subscriber.error(this.thrownError);
  2057. return Subscription.EMPTY;
  2058. }
  2059. else if (this.hasCompleted && this.hasNext) {
  2060. subscriber.next(this.value);
  2061. subscriber.complete();
  2062. return Subscription.EMPTY;
  2063. }
  2064. return _super.prototype._subscribe.call(this, subscriber);
  2065. };
  2066. AsyncSubject.prototype.next = function (value) {
  2067. if (!this.hasCompleted) {
  2068. this.value = value;
  2069. this.hasNext = true;
  2070. }
  2071. };
  2072. AsyncSubject.prototype.error = function (error) {
  2073. if (!this.hasCompleted) {
  2074. _super.prototype.error.call(this, error);
  2075. }
  2076. };
  2077. AsyncSubject.prototype.complete = function () {
  2078. this.hasCompleted = true;
  2079. if (this.hasNext) {
  2080. _super.prototype.next.call(this, this.value);
  2081. }
  2082. _super.prototype.complete.call(this);
  2083. };
  2084. return AsyncSubject;
  2085. }(Subject));
  2086. var nextHandle = 1;
  2087. var tasksByHandle = {};
  2088. function runIfPresent(handle) {
  2089. var cb = tasksByHandle[handle];
  2090. if (cb) {
  2091. cb();
  2092. }
  2093. }
  2094. var Immediate = {
  2095. setImmediate: function (cb) {
  2096. var handle = nextHandle++;
  2097. tasksByHandle[handle] = cb;
  2098. Promise.resolve().then(function () { return runIfPresent(handle); });
  2099. return handle;
  2100. },
  2101. clearImmediate: function (handle) {
  2102. delete tasksByHandle[handle];
  2103. },
  2104. };
  2105. var AsapAction = (function (_super) {
  2106. __extends(AsapAction, _super);
  2107. function AsapAction(scheduler, work) {
  2108. var _this = _super.call(this, scheduler, work) || this;
  2109. _this.scheduler = scheduler;
  2110. _this.work = work;
  2111. return _this;
  2112. }
  2113. AsapAction.prototype.requestAsyncId = function (scheduler, id, delay) {
  2114. if (delay === void 0) { delay = 0; }
  2115. if (delay !== null && delay > 0) {
  2116. return _super.prototype.requestAsyncId.call(this, scheduler, id, delay);
  2117. }
  2118. scheduler.actions.push(this);
  2119. return scheduler.scheduled || (scheduler.scheduled = Immediate.setImmediate(scheduler.flush.bind(scheduler, null)));
  2120. };
  2121. AsapAction.prototype.recycleAsyncId = function (scheduler, id, delay) {
  2122. if (delay === void 0) { delay = 0; }
  2123. if ((delay !== null && delay > 0) || (delay === null && this.delay > 0)) {
  2124. return _super.prototype.recycleAsyncId.call(this, scheduler, id, delay);
  2125. }
  2126. if (scheduler.actions.length === 0) {
  2127. Immediate.clearImmediate(id);
  2128. scheduler.scheduled = undefined;
  2129. }
  2130. return undefined;
  2131. };
  2132. return AsapAction;
  2133. }(AsyncAction));
  2134. var AsapScheduler = (function (_super) {
  2135. __extends(AsapScheduler, _super);
  2136. function AsapScheduler() {
  2137. return _super !== null && _super.apply(this, arguments) || this;
  2138. }
  2139. AsapScheduler.prototype.flush = function (action) {
  2140. this.active = true;
  2141. this.scheduled = undefined;
  2142. var actions = this.actions;
  2143. var error;
  2144. var index = -1;
  2145. var count = actions.length;
  2146. action = action || actions.shift();
  2147. do {
  2148. if (error = action.execute(action.state, action.delay)) {
  2149. break;
  2150. }
  2151. } while (++index < count && (action = actions.shift()));
  2152. this.active = false;
  2153. if (error) {
  2154. while (++index < count && (action = actions.shift())) {
  2155. action.unsubscribe();
  2156. }
  2157. throw error;
  2158. }
  2159. };
  2160. return AsapScheduler;
  2161. }(AsyncScheduler));
  2162. var asap = new AsapScheduler(AsapAction);
  2163. var async = new AsyncScheduler(AsyncAction);
  2164. var AnimationFrameAction = (function (_super) {
  2165. __extends(AnimationFrameAction, _super);
  2166. function AnimationFrameAction(scheduler, work) {
  2167. var _this = _super.call(this, scheduler, work) || this;
  2168. _this.scheduler = scheduler;
  2169. _this.work = work;
  2170. return _this;
  2171. }
  2172. AnimationFrameAction.prototype.requestAsyncId = function (scheduler, id, delay) {
  2173. if (delay === void 0) { delay = 0; }
  2174. if (delay !== null && delay > 0) {
  2175. return _super.prototype.requestAsyncId.call(this, scheduler, id, delay);
  2176. }
  2177. scheduler.actions.push(this);
  2178. return scheduler.scheduled || (scheduler.scheduled = requestAnimationFrame(function () { return scheduler.flush(null); }));
  2179. };
  2180. AnimationFrameAction.prototype.recycleAsyncId = function (scheduler, id, delay) {
  2181. if (delay === void 0) { delay = 0; }
  2182. if ((delay !== null && delay > 0) || (delay === null && this.delay > 0)) {
  2183. return _super.prototype.recycleAsyncId.call(this, scheduler, id, delay);
  2184. }
  2185. if (scheduler.actions.length === 0) {
  2186. cancelAnimationFrame(id);
  2187. scheduler.scheduled = undefined;
  2188. }
  2189. return undefined;
  2190. };
  2191. return AnimationFrameAction;
  2192. }(AsyncAction));
  2193. var AnimationFrameScheduler = (function (_super) {
  2194. __extends(AnimationFrameScheduler, _super);
  2195. function AnimationFrameScheduler() {
  2196. return _super !== null && _super.apply(this, arguments) || this;
  2197. }
  2198. AnimationFrameScheduler.prototype.flush = function (action) {
  2199. this.active = true;
  2200. this.scheduled = undefined;
  2201. var actions = this.actions;
  2202. var error;
  2203. var index = -1;
  2204. var count = actions.length;
  2205. action = action || actions.shift();
  2206. do {
  2207. if (error = action.execute(action.state, action.delay)) {
  2208. break;
  2209. }
  2210. } while (++index < count && (action = actions.shift()));
  2211. this.active = false;
  2212. if (error) {
  2213. while (++index < count && (action = actions.shift())) {
  2214. action.unsubscribe();
  2215. }
  2216. throw error;
  2217. }
  2218. };
  2219. return AnimationFrameScheduler;
  2220. }(AsyncScheduler));
  2221. var animationFrame = new AnimationFrameScheduler(AnimationFrameAction);
  2222. var VirtualTimeScheduler = (function (_super) {
  2223. __extends(VirtualTimeScheduler, _super);
  2224. function VirtualTimeScheduler(SchedulerAction, maxFrames) {
  2225. if (SchedulerAction === void 0) { SchedulerAction = VirtualAction; }
  2226. if (maxFrames === void 0) { maxFrames = Number.POSITIVE_INFINITY; }
  2227. var _this = _super.call(this, SchedulerAction, function () { return _this.frame; }) || this;
  2228. _this.maxFrames = maxFrames;
  2229. _this.frame = 0;
  2230. _this.index = -1;
  2231. return _this;
  2232. }
  2233. VirtualTimeScheduler.prototype.flush = function () {
  2234. var _a = this, actions = _a.actions, maxFrames = _a.maxFrames;
  2235. var error, action;
  2236. while ((action = actions.shift()) && (this.frame = action.delay) <= maxFrames) {
  2237. if (error = action.execute(action.state, action.delay)) {
  2238. break;
  2239. }
  2240. }
  2241. if (error) {
  2242. while (action = actions.shift()) {
  2243. action.unsubscribe();
  2244. }
  2245. throw error;
  2246. }
  2247. };
  2248. VirtualTimeScheduler.frameTimeFactor = 10;
  2249. return VirtualTimeScheduler;
  2250. }(AsyncScheduler));
  2251. var VirtualAction = (function (_super) {
  2252. __extends(VirtualAction, _super);
  2253. function VirtualAction(scheduler, work, index) {
  2254. if (index === void 0) { index = scheduler.index += 1; }
  2255. var _this = _super.call(this, scheduler, work) || this;
  2256. _this.scheduler = scheduler;
  2257. _this.work = work;
  2258. _this.index = index;
  2259. _this.active = true;
  2260. _this.index = scheduler.index = index;
  2261. return _this;
  2262. }
  2263. VirtualAction.prototype.schedule = function (state, delay) {
  2264. if (delay === void 0) { delay = 0; }
  2265. if (!this.id) {
  2266. return _super.prototype.schedule.call(this, state, delay);
  2267. }
  2268. this.active = false;
  2269. var action = new VirtualAction(this.scheduler, this.work);
  2270. this.add(action);
  2271. return action.schedule(state, delay);
  2272. };
  2273. VirtualAction.prototype.requestAsyncId = function (scheduler, id, delay) {
  2274. if (delay === void 0) { delay = 0; }
  2275. this.delay = scheduler.frame + delay;
  2276. var actions = scheduler.actions;
  2277. actions.push(this);
  2278. actions.sort(VirtualAction.sortActions);
  2279. return true;
  2280. };
  2281. VirtualAction.prototype.recycleAsyncId = function (scheduler, id, delay) {
  2282. if (delay === void 0) { delay = 0; }
  2283. return undefined;
  2284. };
  2285. VirtualAction.prototype._execute = function (state, delay) {
  2286. if (this.active === true) {
  2287. return _super.prototype._execute.call(this, state, delay);
  2288. }
  2289. };
  2290. VirtualAction.sortActions = function (a, b) {
  2291. if (a.delay === b.delay) {
  2292. if (a.index === b.index) {
  2293. return 0;
  2294. }
  2295. else if (a.index > b.index) {
  2296. return 1;
  2297. }
  2298. else {
  2299. return -1;
  2300. }
  2301. }
  2302. else if (a.delay > b.delay) {
  2303. return 1;
  2304. }
  2305. else {
  2306. return -1;
  2307. }
  2308. };
  2309. return VirtualAction;
  2310. }(AsyncAction));
  2311. function identity(x) {
  2312. return x;
  2313. }
  2314. function isObservable(obj) {
  2315. return !!obj && (obj instanceof Observable || (typeof obj.lift === 'function' && typeof obj.subscribe === 'function'));
  2316. }
  2317. function ArgumentOutOfRangeErrorImpl() {
  2318. Error.call(this);
  2319. this.message = 'argument out of range';
  2320. this.name = 'ArgumentOutOfRangeError';
  2321. return this;
  2322. }
  2323. ArgumentOutOfRangeErrorImpl.prototype = Object.create(Error.prototype);
  2324. var ArgumentOutOfRangeError = ArgumentOutOfRangeErrorImpl;
  2325. function EmptyErrorImpl() {
  2326. Error.call(this);
  2327. this.message = 'no elements in sequence';
  2328. this.name = 'EmptyError';
  2329. return this;
  2330. }
  2331. EmptyErrorImpl.prototype = Object.create(Error.prototype);
  2332. var EmptyError = EmptyErrorImpl;
  2333. function TimeoutErrorImpl() {
  2334. Error.call(this);
  2335. this.message = 'Timeout has occurred';
  2336. this.name = 'TimeoutError';
  2337. return this;
  2338. }
  2339. TimeoutErrorImpl.prototype = Object.create(Error.prototype);
  2340. var TimeoutError = TimeoutErrorImpl;
  2341. function map(project, thisArg) {
  2342. return function mapOperation(source) {
  2343. if (typeof project !== 'function') {
  2344. throw new TypeError('argument is not a function. Are you looking for `mapTo()`?');
  2345. }
  2346. return source.lift(new MapOperator(project, thisArg));
  2347. };
  2348. }
  2349. var MapOperator = (function () {
  2350. function MapOperator(project, thisArg) {
  2351. this.project = project;
  2352. this.thisArg = thisArg;
  2353. }
  2354. MapOperator.prototype.call = function (subscriber, source) {
  2355. return source.subscribe(new MapSubscriber(subscriber, this.project, this.thisArg));
  2356. };
  2357. return MapOperator;
  2358. }());
  2359. var MapSubscriber = (function (_super) {
  2360. __extends(MapSubscriber, _super);
  2361. function MapSubscriber(destination, project, thisArg) {
  2362. var _this = _super.call(this, destination) || this;
  2363. _this.project = project;
  2364. _this.count = 0;
  2365. _this.thisArg = thisArg || _this;
  2366. return _this;
  2367. }
  2368. MapSubscriber.prototype._next = function (value) {
  2369. var result;
  2370. try {
  2371. result = this.project.call(this.thisArg, value, this.count++);
  2372. }
  2373. catch (err) {
  2374. this.destination.error(err);
  2375. return;
  2376. }
  2377. this.destination.next(result);
  2378. };
  2379. return MapSubscriber;
  2380. }(Subscriber));
  2381. function bindCallback(callbackFunc, resultSelector, scheduler) {
  2382. if (resultSelector) {
  2383. if (isScheduler(resultSelector)) {
  2384. scheduler = resultSelector;
  2385. }
  2386. else {
  2387. return function () {
  2388. var args = [];
  2389. for (var _i = 0; _i < arguments.length; _i++) {
  2390. args[_i] = arguments[_i];
  2391. }
  2392. return bindCallback(callbackFunc, scheduler).apply(void 0, args).pipe(map(function (args) { return isArray(args) ? resultSelector.apply(void 0, args) : resultSelector(args); }));
  2393. };
  2394. }
  2395. }
  2396. return function () {
  2397. var args = [];
  2398. for (var _i = 0; _i < arguments.length; _i++) {
  2399. args[_i] = arguments[_i];
  2400. }
  2401. var context = this;
  2402. var subject;
  2403. var params = {
  2404. context: context,
  2405. subject: subject,
  2406. callbackFunc: callbackFunc,
  2407. scheduler: scheduler,
  2408. };
  2409. return new Observable(function (subscriber) {
  2410. if (!scheduler) {
  2411. if (!subject) {
  2412. subject = new AsyncSubject();
  2413. var handler = function () {
  2414. var innerArgs = [];
  2415. for (var _i = 0; _i < arguments.length; _i++) {
  2416. innerArgs[_i] = arguments[_i];
  2417. }
  2418. subject.next(innerArgs.length <= 1 ? innerArgs[0] : innerArgs);
  2419. subject.complete();
  2420. };
  2421. try {
  2422. callbackFunc.apply(context, args.concat([handler]));
  2423. }
  2424. catch (err) {
  2425. if (canReportError(subject)) {
  2426. subject.error(err);
  2427. }
  2428. else {
  2429. console.warn(err);
  2430. }
  2431. }
  2432. }
  2433. return subject.subscribe(subscriber);
  2434. }
  2435. else {
  2436. var state = {
  2437. args: args, subscriber: subscriber, params: params,
  2438. };
  2439. return scheduler.schedule(dispatch$1, 0, state);
  2440. }
  2441. });
  2442. };
  2443. }
  2444. function dispatch$1(state) {
  2445. var _this = this;
  2446. var self = this;
  2447. var args = state.args, subscriber = state.subscriber, params = state.params;
  2448. var callbackFunc = params.callbackFunc, context = params.context, scheduler = params.scheduler;
  2449. var subject = params.subject;
  2450. if (!subject) {
  2451. subject = params.subject = new AsyncSubject();
  2452. var handler = function () {
  2453. var innerArgs = [];
  2454. for (var _i = 0; _i < arguments.length; _i++) {
  2455. innerArgs[_i] = arguments[_i];
  2456. }
  2457. var value = innerArgs.length <= 1 ? innerArgs[0] : innerArgs;
  2458. _this.add(scheduler.schedule(dispatchNext, 0, { value: value, subject: subject }));
  2459. };
  2460. try {
  2461. callbackFunc.apply(context, args.concat([handler]));
  2462. }
  2463. catch (err) {
  2464. subject.error(err);
  2465. }
  2466. }
  2467. this.add(subject.subscribe(subscriber));
  2468. }
  2469. function dispatchNext(state) {
  2470. var value = state.value, subject = state.subject;
  2471. subject.next(value);
  2472. subject.complete();
  2473. }
  2474. function bindNodeCallback(callbackFunc, resultSelector, scheduler) {
  2475. if (resultSelector) {
  2476. if (isScheduler(resultSelector)) {
  2477. scheduler = resultSelector;
  2478. }
  2479. else {
  2480. return function () {
  2481. var args = [];
  2482. for (var _i = 0; _i < arguments.length; _i++) {
  2483. args[_i] = arguments[_i];
  2484. }
  2485. return bindNodeCallback(callbackFunc, scheduler).apply(void 0, args).pipe(map(function (args) { return isArray(args) ? resultSelector.apply(void 0, args) : resultSelector(args); }));
  2486. };
  2487. }
  2488. }
  2489. return function () {
  2490. var args = [];
  2491. for (var _i = 0; _i < arguments.length; _i++) {
  2492. args[_i] = arguments[_i];
  2493. }
  2494. var params = {
  2495. subject: undefined,
  2496. args: args,
  2497. callbackFunc: callbackFunc,
  2498. scheduler: scheduler,
  2499. context: this,
  2500. };
  2501. return new Observable(function (subscriber) {
  2502. var context = params.context;
  2503. var subject = params.subject;
  2504. if (!scheduler) {
  2505. if (!subject) {
  2506. subject = params.subject = new AsyncSubject();
  2507. var handler = function () {
  2508. var innerArgs = [];
  2509. for (var _i = 0; _i < arguments.length; _i++) {
  2510. innerArgs[_i] = arguments[_i];
  2511. }
  2512. var err = innerArgs.shift();
  2513. if (err) {
  2514. subject.error(err);
  2515. return;
  2516. }
  2517. subject.next(innerArgs.length <= 1 ? innerArgs[0] : innerArgs);
  2518. subject.complete();
  2519. };
  2520. try {
  2521. callbackFunc.apply(context, args.concat([handler]));
  2522. }
  2523. catch (err) {
  2524. if (canReportError(subject)) {
  2525. subject.error(err);
  2526. }
  2527. else {
  2528. console.warn(err);
  2529. }
  2530. }
  2531. }
  2532. return subject.subscribe(subscriber);
  2533. }
  2534. else {
  2535. return scheduler.schedule(dispatch$2, 0, { params: params, subscriber: subscriber, context: context });
  2536. }
  2537. });
  2538. };
  2539. }
  2540. function dispatch$2(state) {
  2541. var _this = this;
  2542. var params = state.params, subscriber = state.subscriber, context = state.context;
  2543. var callbackFunc = params.callbackFunc, args = params.args, scheduler = params.scheduler;
  2544. var subject = params.subject;
  2545. if (!subject) {
  2546. subject = params.subject = new AsyncSubject();
  2547. var handler = function () {
  2548. var innerArgs = [];
  2549. for (var _i = 0; _i < arguments.length; _i++) {
  2550. innerArgs[_i] = arguments[_i];
  2551. }
  2552. var err = innerArgs.shift();
  2553. if (err) {
  2554. _this.add(scheduler.schedule(dispatchError$1, 0, { err: err, subject: subject }));
  2555. }
  2556. else {
  2557. var value = innerArgs.length <= 1 ? innerArgs[0] : innerArgs;
  2558. _this.add(scheduler.schedule(dispatchNext$1, 0, { value: value, subject: subject }));
  2559. }
  2560. };
  2561. try {
  2562. callbackFunc.apply(context, args.concat([handler]));
  2563. }
  2564. catch (err) {
  2565. this.add(scheduler.schedule(dispatchError$1, 0, { err: err, subject: subject }));
  2566. }
  2567. }
  2568. this.add(subject.subscribe(subscriber));
  2569. }
  2570. function dispatchNext$1(arg) {
  2571. var value = arg.value, subject = arg.subject;
  2572. subject.next(value);
  2573. subject.complete();
  2574. }
  2575. function dispatchError$1(arg) {
  2576. var err = arg.err, subject = arg.subject;
  2577. subject.error(err);
  2578. }
  2579. var OuterSubscriber = (function (_super) {
  2580. __extends(OuterSubscriber, _super);
  2581. function OuterSubscriber() {
  2582. return _super !== null && _super.apply(this, arguments) || this;
  2583. }
  2584. OuterSubscriber.prototype.notifyNext = function (outerValue, innerValue, outerIndex, innerIndex, innerSub) {
  2585. this.destination.next(innerValue);
  2586. };
  2587. OuterSubscriber.prototype.notifyError = function (error, innerSub) {
  2588. this.destination.error(error);
  2589. };
  2590. OuterSubscriber.prototype.notifyComplete = function (innerSub) {
  2591. this.destination.complete();
  2592. };
  2593. return OuterSubscriber;
  2594. }(Subscriber));
  2595. var InnerSubscriber = (function (_super) {
  2596. __extends(InnerSubscriber, _super);
  2597. function InnerSubscriber(parent, outerValue, outerIndex) {
  2598. var _this = _super.call(this) || this;
  2599. _this.parent = parent;
  2600. _this.outerValue = outerValue;
  2601. _this.outerIndex = outerIndex;
  2602. _this.index = 0;
  2603. return _this;
  2604. }
  2605. InnerSubscriber.prototype._next = function (value) {
  2606. this.parent.notifyNext(this.outerValue, value, this.outerIndex, this.index++, this);
  2607. };
  2608. InnerSubscriber.prototype._error = function (error) {
  2609. this.parent.notifyError(error, this);
  2610. this.unsubscribe();
  2611. };
  2612. InnerSubscriber.prototype._complete = function () {
  2613. this.parent.notifyComplete(this);
  2614. this.unsubscribe();
  2615. };
  2616. return InnerSubscriber;
  2617. }(Subscriber));
  2618. var subscribeToPromise = function (promise) { return function (subscriber) {
  2619. promise.then(function (value) {
  2620. if (!subscriber.closed) {
  2621. subscriber.next(value);
  2622. subscriber.complete();
  2623. }
  2624. }, function (err) { return subscriber.error(err); })
  2625. .then(null, hostReportError);
  2626. return subscriber;
  2627. }; };
  2628. function getSymbolIterator() {
  2629. if (typeof Symbol !== 'function' || !Symbol.iterator) {
  2630. return '@@iterator';
  2631. }
  2632. return Symbol.iterator;
  2633. }
  2634. var iterator = getSymbolIterator();
  2635. var subscribeToIterable = function (iterable) { return function (subscriber) {
  2636. var iterator$$1 = iterable[iterator]();
  2637. do {
  2638. var item = iterator$$1.next();
  2639. if (item.done) {
  2640. subscriber.complete();
  2641. break;
  2642. }
  2643. subscriber.next(item.value);
  2644. if (subscriber.closed) {
  2645. break;
  2646. }
  2647. } while (true);
  2648. if (typeof iterator$$1.return === 'function') {
  2649. subscriber.add(function () {
  2650. if (iterator$$1.return) {
  2651. iterator$$1.return();
  2652. }
  2653. });
  2654. }
  2655. return subscriber;
  2656. }; };
  2657. var subscribeToObservable = function (obj) { return function (subscriber) {
  2658. var obs = obj[observable]();
  2659. if (typeof obs.subscribe !== 'function') {
  2660. throw new TypeError('Provided object does not correctly implement Symbol.observable');
  2661. }
  2662. else {
  2663. return obs.subscribe(subscriber);
  2664. }
  2665. }; };
  2666. var isArrayLike = (function (x) { return x && typeof x.length === 'number' && typeof x !== 'function'; });
  2667. function isPromise(value) {
  2668. return value && typeof value.subscribe !== 'function' && typeof value.then === 'function';
  2669. }
  2670. var subscribeTo = function (result) {
  2671. if (result instanceof Observable) {
  2672. return function (subscriber) {
  2673. if (result._isScalar) {
  2674. subscriber.next(result.value);
  2675. subscriber.complete();
  2676. return undefined;
  2677. }
  2678. else {
  2679. return result.subscribe(subscriber);
  2680. }
  2681. };
  2682. }
  2683. else if (result && typeof result[observable] === 'function') {
  2684. return subscribeToObservable(result);
  2685. }
  2686. else if (isArrayLike(result)) {
  2687. return subscribeToArray(result);
  2688. }
  2689. else if (isPromise(result)) {
  2690. return subscribeToPromise(result);
  2691. }
  2692. else if (result && typeof result[iterator] === 'function') {
  2693. return subscribeToIterable(result);
  2694. }
  2695. else {
  2696. var value = isObject(result) ? 'an invalid object' : "'" + result + "'";
  2697. var msg = "You provided " + value + " where a stream was expected."
  2698. + ' You can provide an Observable, Promise, Array, or Iterable.';
  2699. throw new TypeError(msg);
  2700. }
  2701. };
  2702. function subscribeToResult(outerSubscriber, result, outerValue, outerIndex, destination) {
  2703. if (destination === void 0) { destination = new InnerSubscriber(outerSubscriber, outerValue, outerIndex); }
  2704. if (destination.closed) {
  2705. return;
  2706. }
  2707. return subscribeTo(result)(destination);
  2708. }
  2709. var NONE = {};
  2710. function combineLatest() {
  2711. var observables = [];
  2712. for (var _i = 0; _i < arguments.length; _i++) {
  2713. observables[_i] = arguments[_i];
  2714. }
  2715. var resultSelector = null;
  2716. var scheduler = null;
  2717. if (isScheduler(observables[observables.length - 1])) {
  2718. scheduler = observables.pop();
  2719. }
  2720. if (typeof observables[observables.length - 1] === 'function') {
  2721. resultSelector = observables.pop();
  2722. }
  2723. if (observables.length === 1 && isArray(observables[0])) {
  2724. observables = observables[0];
  2725. }
  2726. return fromArray(observables, scheduler).lift(new CombineLatestOperator(resultSelector));
  2727. }
  2728. var CombineLatestOperator = (function () {
  2729. function CombineLatestOperator(resultSelector) {
  2730. this.resultSelector = resultSelector;
  2731. }
  2732. CombineLatestOperator.prototype.call = function (subscriber, source) {
  2733. return source.subscribe(new CombineLatestSubscriber(subscriber, this.resultSelector));
  2734. };
  2735. return CombineLatestOperator;
  2736. }());
  2737. var CombineLatestSubscriber = (function (_super) {
  2738. __extends(CombineLatestSubscriber, _super);
  2739. function CombineLatestSubscriber(destination, resultSelector) {
  2740. var _this = _super.call(this, destination) || this;
  2741. _this.resultSelector = resultSelector;
  2742. _this.active = 0;
  2743. _this.values = [];
  2744. _this.observables = [];
  2745. return _this;
  2746. }
  2747. CombineLatestSubscriber.prototype._next = function (observable) {
  2748. this.values.push(NONE);
  2749. this.observables.push(observable);
  2750. };
  2751. CombineLatestSubscriber.prototype._complete = function () {
  2752. var observables = this.observables;
  2753. var len = observables.length;
  2754. if (len === 0) {
  2755. this.destination.complete();
  2756. }
  2757. else {
  2758. this.active = len;
  2759. this.toRespond = len;
  2760. for (var i = 0; i < len; i++) {
  2761. var observable = observables[i];
  2762. this.add(subscribeToResult(this, observable, observable, i));
  2763. }
  2764. }
  2765. };
  2766. CombineLatestSubscriber.prototype.notifyComplete = function (unused) {
  2767. if ((this.active -= 1) === 0) {
  2768. this.destination.complete();
  2769. }
  2770. };
  2771. CombineLatestSubscriber.prototype.notifyNext = function (outerValue, innerValue, outerIndex, innerIndex, innerSub) {
  2772. var values = this.values;
  2773. var oldVal = values[outerIndex];
  2774. var toRespond = !this.toRespond
  2775. ? 0
  2776. : oldVal === NONE ? --this.toRespond : this.toRespond;
  2777. values[outerIndex] = innerValue;
  2778. if (toRespond === 0) {
  2779. if (this.resultSelector) {
  2780. this._tryResultSelector(values);
  2781. }
  2782. else {
  2783. this.destination.next(values.slice());
  2784. }
  2785. }
  2786. };
  2787. CombineLatestSubscriber.prototype._tryResultSelector = function (values) {
  2788. var result;
  2789. try {
  2790. result = this.resultSelector.apply(this, values);
  2791. }
  2792. catch (err) {
  2793. this.destination.error(err);
  2794. return;
  2795. }
  2796. this.destination.next(result);
  2797. };
  2798. return CombineLatestSubscriber;
  2799. }(OuterSubscriber));
  2800. function isInteropObservable(input) {
  2801. return input && typeof input[observable] === 'function';
  2802. }
  2803. function isIterable(input) {
  2804. return input && typeof input[iterator] === 'function';
  2805. }
  2806. function fromPromise(input, scheduler) {
  2807. if (!scheduler) {
  2808. return new Observable(subscribeToPromise(input));
  2809. }
  2810. else {
  2811. return new Observable(function (subscriber) {
  2812. var sub = new Subscription();
  2813. sub.add(scheduler.schedule(function () { return input.then(function (value) {
  2814. sub.add(scheduler.schedule(function () {
  2815. subscriber.next(value);
  2816. sub.add(scheduler.schedule(function () { return subscriber.complete(); }));
  2817. }));
  2818. }, function (err) {
  2819. sub.add(scheduler.schedule(function () { return subscriber.error(err); }));
  2820. }); }));
  2821. return sub;
  2822. });
  2823. }
  2824. }
  2825. function fromIterable(input, scheduler) {
  2826. if (!input) {
  2827. throw new Error('Iterable cannot be null');
  2828. }
  2829. if (!scheduler) {
  2830. return new Observable(subscribeToIterable(input));
  2831. }
  2832. else {
  2833. return new Observable(function (subscriber) {
  2834. var sub = new Subscription();
  2835. var iterator$$1;
  2836. sub.add(function () {
  2837. if (iterator$$1 && typeof iterator$$1.return === 'function') {
  2838. iterator$$1.return();
  2839. }
  2840. });
  2841. sub.add(scheduler.schedule(function () {
  2842. iterator$$1 = input[iterator]();
  2843. sub.add(scheduler.schedule(function () {
  2844. if (subscriber.closed) {
  2845. return;
  2846. }
  2847. var value;
  2848. var done;
  2849. try {
  2850. var result = iterator$$1.next();
  2851. value = result.value;
  2852. done = result.done;
  2853. }
  2854. catch (err) {
  2855. subscriber.error(err);
  2856. return;
  2857. }
  2858. if (done) {
  2859. subscriber.complete();
  2860. }
  2861. else {
  2862. subscriber.next(value);
  2863. this.schedule();
  2864. }
  2865. }));
  2866. }));
  2867. return sub;
  2868. });
  2869. }
  2870. }
  2871. function fromObservable(input, scheduler) {
  2872. if (!scheduler) {
  2873. return new Observable(subscribeToObservable(input));
  2874. }
  2875. else {
  2876. return new Observable(function (subscriber) {
  2877. var sub = new Subscription();
  2878. sub.add(scheduler.schedule(function () {
  2879. var observable$$1 = input[observable]();
  2880. sub.add(observable$$1.subscribe({
  2881. next: function (value) { sub.add(scheduler.schedule(function () { return subscriber.next(value); })); },
  2882. error: function (err) { sub.add(scheduler.schedule(function () { return subscriber.error(err); })); },
  2883. complete: function () { sub.add(scheduler.schedule(function () { return subscriber.complete(); })); },
  2884. }));
  2885. }));
  2886. return sub;
  2887. });
  2888. }
  2889. }
  2890. function from(input, scheduler) {
  2891. if (!scheduler) {
  2892. if (input instanceof Observable) {
  2893. return input;
  2894. }
  2895. return new Observable(subscribeTo(input));
  2896. }
  2897. if (input != null) {
  2898. if (isInteropObservable(input)) {
  2899. return fromObservable(input, scheduler);
  2900. }
  2901. else if (isPromise(input)) {
  2902. return fromPromise(input, scheduler);
  2903. }
  2904. else if (isArrayLike(input)) {
  2905. return fromArray(input, scheduler);
  2906. }
  2907. else if (isIterable(input) || typeof input === 'string') {
  2908. return fromIterable(input, scheduler);
  2909. }
  2910. }
  2911. throw new TypeError((input !== null && typeof input || input) + ' is not observable');
  2912. }
  2913. function mergeMap(project, resultSelector, concurrent) {
  2914. if (concurrent === void 0) { concurrent = Number.POSITIVE_INFINITY; }
  2915. if (typeof resultSelector === 'function') {
  2916. return function (source) { return source.pipe(mergeMap(function (a, i) { return from(project(a, i)).pipe(map(function (b, ii) { return resultSelector(a, b, i, ii); })); }, concurrent)); };
  2917. }
  2918. else if (typeof resultSelector === 'number') {
  2919. concurrent = resultSelector;
  2920. }
  2921. return function (source) { return source.lift(new MergeMapOperator(project, concurrent)); };
  2922. }
  2923. var MergeMapOperator = (function () {
  2924. function MergeMapOperator(project, concurrent) {
  2925. if (concurrent === void 0) { concurrent = Number.POSITIVE_INFINITY; }
  2926. this.project = project;
  2927. this.concurrent = concurrent;
  2928. }
  2929. MergeMapOperator.prototype.call = function (observer, source) {
  2930. return source.subscribe(new MergeMapSubscriber(observer, this.project, this.concurrent));
  2931. };
  2932. return MergeMapOperator;
  2933. }());
  2934. var MergeMapSubscriber = (function (_super) {
  2935. __extends(MergeMapSubscriber, _super);
  2936. function MergeMapSubscriber(destination, project, concurrent) {
  2937. if (concurrent === void 0) { concurrent = Number.POSITIVE_INFINITY; }
  2938. var _this = _super.call(this, destination) || this;
  2939. _this.project = project;
  2940. _this.concurrent = concurrent;
  2941. _this.hasCompleted = false;
  2942. _this.buffer = [];
  2943. _this.active = 0;
  2944. _this.index = 0;
  2945. return _this;
  2946. }
  2947. MergeMapSubscriber.prototype._next = function (value) {
  2948. if (this.active < this.concurrent) {
  2949. this._tryNext(value);
  2950. }
  2951. else {
  2952. this.buffer.push(value);
  2953. }
  2954. };
  2955. MergeMapSubscriber.prototype._tryNext = function (value) {
  2956. var result;
  2957. var index = this.index++;
  2958. try {
  2959. result = this.project(value, index);
  2960. }
  2961. catch (err) {
  2962. this.destination.error(err);
  2963. return;
  2964. }
  2965. this.active++;
  2966. this._innerSub(result, value, index);
  2967. };
  2968. MergeMapSubscriber.prototype._innerSub = function (ish, value, index) {
  2969. var innerSubscriber = new InnerSubscriber(this, undefined, undefined);
  2970. var destination = this.destination;
  2971. destination.add(innerSubscriber);
  2972. subscribeToResult(this, ish, value, index, innerSubscriber);
  2973. };
  2974. MergeMapSubscriber.prototype._complete = function () {
  2975. this.hasCompleted = true;
  2976. if (this.active === 0 && this.buffer.length === 0) {
  2977. this.destination.complete();
  2978. }
  2979. this.unsubscribe();
  2980. };
  2981. MergeMapSubscriber.prototype.notifyNext = function (outerValue, innerValue, outerIndex, innerIndex, innerSub) {
  2982. this.destination.next(innerValue);
  2983. };
  2984. MergeMapSubscriber.prototype.notifyComplete = function (innerSub) {
  2985. var buffer = this.buffer;
  2986. this.remove(innerSub);
  2987. this.active--;
  2988. if (buffer.length > 0) {
  2989. this._next(buffer.shift());
  2990. }
  2991. else if (this.active === 0 && this.hasCompleted) {
  2992. this.destination.complete();
  2993. }
  2994. };
  2995. return MergeMapSubscriber;
  2996. }(OuterSubscriber));
  2997. function mergeAll(concurrent) {
  2998. if (concurrent === void 0) { concurrent = Number.POSITIVE_INFINITY; }
  2999. return mergeMap(identity, concurrent);
  3000. }
  3001. function concatAll() {
  3002. return mergeAll(1);
  3003. }
  3004. function concat() {
  3005. var observables = [];
  3006. for (var _i = 0; _i < arguments.length; _i++) {
  3007. observables[_i] = arguments[_i];
  3008. }
  3009. if (observables.length === 1 || (observables.length === 2 && isScheduler(observables[1]))) {
  3010. return from(observables[0]);
  3011. }
  3012. return concatAll()(of.apply(void 0, observables));
  3013. }
  3014. function defer(observableFactory) {
  3015. return new Observable(function (subscriber) {
  3016. var input;
  3017. try {
  3018. input = observableFactory();
  3019. }
  3020. catch (err) {
  3021. subscriber.error(err);
  3022. return undefined;
  3023. }
  3024. var source = input ? from(input) : empty$1();
  3025. return source.subscribe(subscriber);
  3026. });
  3027. }
  3028. function forkJoin() {
  3029. var sources = [];
  3030. for (var _i = 0; _i < arguments.length; _i++) {
  3031. sources[_i] = arguments[_i];
  3032. }
  3033. var resultSelector;
  3034. if (typeof sources[sources.length - 1] === 'function') {
  3035. resultSelector = sources.pop();
  3036. }
  3037. if (sources.length === 1 && isArray(sources[0])) {
  3038. sources = sources[0];
  3039. }
  3040. if (sources.length === 0) {
  3041. return EMPTY;
  3042. }
  3043. if (resultSelector) {
  3044. return forkJoin(sources).pipe(map(function (args) { return resultSelector.apply(void 0, args); }));
  3045. }
  3046. return new Observable(function (subscriber) {
  3047. return new ForkJoinSubscriber(subscriber, sources);
  3048. });
  3049. }
  3050. var ForkJoinSubscriber = (function (_super) {
  3051. __extends(ForkJoinSubscriber, _super);
  3052. function ForkJoinSubscriber(destination, sources) {
  3053. var _this = _super.call(this, destination) || this;
  3054. _this.sources = sources;
  3055. _this.completed = 0;
  3056. _this.haveValues = 0;
  3057. var len = sources.length;
  3058. _this.values = new Array(len);
  3059. for (var i = 0; i < len; i++) {
  3060. var source = sources[i];
  3061. var innerSubscription = subscribeToResult(_this, source, null, i);
  3062. if (innerSubscription) {
  3063. _this.add(innerSubscription);
  3064. }
  3065. }
  3066. return _this;
  3067. }
  3068. ForkJoinSubscriber.prototype.notifyNext = function (outerValue, innerValue, outerIndex, innerIndex, innerSub) {
  3069. this.values[outerIndex] = innerValue;
  3070. if (!innerSub._hasValue) {
  3071. innerSub._hasValue = true;
  3072. this.haveValues++;
  3073. }
  3074. };
  3075. ForkJoinSubscriber.prototype.notifyComplete = function (innerSub) {
  3076. var _a = this, destination = _a.destination, haveValues = _a.haveValues, values = _a.values;
  3077. var len = values.length;
  3078. if (!innerSub._hasValue) {
  3079. destination.complete();
  3080. return;
  3081. }
  3082. this.completed++;
  3083. if (this.completed !== len) {
  3084. return;
  3085. }
  3086. if (haveValues === len) {
  3087. destination.next(values);
  3088. }
  3089. destination.complete();
  3090. };
  3091. return ForkJoinSubscriber;
  3092. }(OuterSubscriber));
  3093. function fromEvent(target, eventName, options, resultSelector) {
  3094. if (isFunction(options)) {
  3095. resultSelector = options;
  3096. options = undefined;
  3097. }
  3098. if (resultSelector) {
  3099. return fromEvent(target, eventName, options).pipe(map(function (args) { return isArray(args) ? resultSelector.apply(void 0, args) : resultSelector(args); }));
  3100. }
  3101. return new Observable(function (subscriber) {
  3102. function handler(e) {
  3103. if (arguments.length > 1) {
  3104. subscriber.next(Array.prototype.slice.call(arguments));
  3105. }
  3106. else {
  3107. subscriber.next(e);
  3108. }
  3109. }
  3110. setupSubscription(target, eventName, handler, subscriber, options);
  3111. });
  3112. }
  3113. function setupSubscription(sourceObj, eventName, handler, subscriber, options) {
  3114. var unsubscribe;
  3115. if (isEventTarget(sourceObj)) {
  3116. var source_1 = sourceObj;
  3117. sourceObj.addEventListener(eventName, handler, options);
  3118. unsubscribe = function () { return source_1.removeEventListener(eventName, handler, options); };
  3119. }
  3120. else if (isJQueryStyleEventEmitter(sourceObj)) {
  3121. var source_2 = sourceObj;
  3122. sourceObj.on(eventName, handler);
  3123. unsubscribe = function () { return source_2.off(eventName, handler); };
  3124. }
  3125. else if (isNodeStyleEventEmitter(sourceObj)) {
  3126. var source_3 = sourceObj;
  3127. sourceObj.addListener(eventName, handler);
  3128. unsubscribe = function () { return source_3.removeListener(eventName, handler); };
  3129. }
  3130. else if (sourceObj && sourceObj.length) {
  3131. for (var i = 0, len = sourceObj.length; i < len; i++) {
  3132. setupSubscription(sourceObj[i], eventName, handler, subscriber, options);
  3133. }
  3134. }
  3135. else {
  3136. throw new TypeError('Invalid event target');
  3137. }
  3138. subscriber.add(unsubscribe);
  3139. }
  3140. function isNodeStyleEventEmitter(sourceObj) {
  3141. return sourceObj && typeof sourceObj.addListener === 'function' && typeof sourceObj.removeListener === 'function';
  3142. }
  3143. function isJQueryStyleEventEmitter(sourceObj) {
  3144. return sourceObj && typeof sourceObj.on === 'function' && typeof sourceObj.off === 'function';
  3145. }
  3146. function isEventTarget(sourceObj) {
  3147. return sourceObj && typeof sourceObj.addEventListener === 'function' && typeof sourceObj.removeEventListener === 'function';
  3148. }
  3149. function fromEventPattern(addHandler, removeHandler, resultSelector) {
  3150. if (resultSelector) {
  3151. return fromEventPattern(addHandler, removeHandler).pipe(map(function (args) { return isArray(args) ? resultSelector.apply(void 0, args) : resultSelector(args); }));
  3152. }
  3153. return new Observable(function (subscriber) {
  3154. var handler = function () {
  3155. var e = [];
  3156. for (var _i = 0; _i < arguments.length; _i++) {
  3157. e[_i] = arguments[_i];
  3158. }
  3159. return subscriber.next(e.length === 1 ? e[0] : e);
  3160. };
  3161. var retValue;
  3162. try {
  3163. retValue = addHandler(handler);
  3164. }
  3165. catch (err) {
  3166. subscriber.error(err);
  3167. return undefined;
  3168. }
  3169. if (!isFunction(removeHandler)) {
  3170. return undefined;
  3171. }
  3172. return function () { return removeHandler(handler, retValue); };
  3173. });
  3174. }
  3175. function generate(initialStateOrOptions, condition, iterate, resultSelectorOrObservable, scheduler) {
  3176. var resultSelector;
  3177. var initialState;
  3178. if (arguments.length == 1) {
  3179. var options = initialStateOrOptions;
  3180. initialState = options.initialState;
  3181. condition = options.condition;
  3182. iterate = options.iterate;
  3183. resultSelector = options.resultSelector || identity;
  3184. scheduler = options.scheduler;
  3185. }
  3186. else if (resultSelectorOrObservable === undefined || isScheduler(resultSelectorOrObservable)) {
  3187. initialState = initialStateOrOptions;
  3188. resultSelector = identity;
  3189. scheduler = resultSelectorOrObservable;
  3190. }
  3191. else {
  3192. initialState = initialStateOrOptions;
  3193. resultSelector = resultSelectorOrObservable;
  3194. }
  3195. return new Observable(function (subscriber) {
  3196. var state = initialState;
  3197. if (scheduler) {
  3198. return scheduler.schedule(dispatch$3, 0, {
  3199. subscriber: subscriber,
  3200. iterate: iterate,
  3201. condition: condition,
  3202. resultSelector: resultSelector,
  3203. state: state
  3204. });
  3205. }
  3206. do {
  3207. if (condition) {
  3208. var conditionResult = void 0;
  3209. try {
  3210. conditionResult = condition(state);
  3211. }
  3212. catch (err) {
  3213. subscriber.error(err);
  3214. return undefined;
  3215. }
  3216. if (!conditionResult) {
  3217. subscriber.complete();
  3218. break;
  3219. }
  3220. }
  3221. var value = void 0;
  3222. try {
  3223. value = resultSelector(state);
  3224. }
  3225. catch (err) {
  3226. subscriber.error(err);
  3227. return undefined;
  3228. }
  3229. subscriber.next(value);
  3230. if (subscriber.closed) {
  3231. break;
  3232. }
  3233. try {
  3234. state = iterate(state);
  3235. }
  3236. catch (err) {
  3237. subscriber.error(err);
  3238. return undefined;
  3239. }
  3240. } while (true);
  3241. return undefined;
  3242. });
  3243. }
  3244. function dispatch$3(state) {
  3245. var subscriber = state.subscriber, condition = state.condition;
  3246. if (subscriber.closed) {
  3247. return undefined;
  3248. }
  3249. if (state.needIterate) {
  3250. try {
  3251. state.state = state.iterate(state.state);
  3252. }
  3253. catch (err) {
  3254. subscriber.error(err);
  3255. return undefined;
  3256. }
  3257. }
  3258. else {
  3259. state.needIterate = true;
  3260. }
  3261. if (condition) {
  3262. var conditionResult = void 0;
  3263. try {
  3264. conditionResult = condition(state.state);
  3265. }
  3266. catch (err) {
  3267. subscriber.error(err);
  3268. return undefined;
  3269. }
  3270. if (!conditionResult) {
  3271. subscriber.complete();
  3272. return undefined;
  3273. }
  3274. if (subscriber.closed) {
  3275. return undefined;
  3276. }
  3277. }
  3278. var value;
  3279. try {
  3280. value = state.resultSelector(state.state);
  3281. }
  3282. catch (err) {
  3283. subscriber.error(err);
  3284. return undefined;
  3285. }
  3286. if (subscriber.closed) {
  3287. return undefined;
  3288. }
  3289. subscriber.next(value);
  3290. if (subscriber.closed) {
  3291. return undefined;
  3292. }
  3293. return this.schedule(state);
  3294. }
  3295. function iif(condition, trueResult, falseResult) {
  3296. if (trueResult === void 0) { trueResult = EMPTY; }
  3297. if (falseResult === void 0) { falseResult = EMPTY; }
  3298. return defer(function () { return condition() ? trueResult : falseResult; });
  3299. }
  3300. function isNumeric(val) {
  3301. return !isArray(val) && (val - parseFloat(val) + 1) >= 0;
  3302. }
  3303. function interval(period, scheduler) {
  3304. if (period === void 0) { period = 0; }
  3305. if (scheduler === void 0) { scheduler = async; }
  3306. if (!isNumeric(period) || period < 0) {
  3307. period = 0;
  3308. }
  3309. if (!scheduler || typeof scheduler.schedule !== 'function') {
  3310. scheduler = async;
  3311. }
  3312. return new Observable(function (subscriber) {
  3313. subscriber.add(scheduler.schedule(dispatch$4, period, { subscriber: subscriber, counter: 0, period: period }));
  3314. return subscriber;
  3315. });
  3316. }
  3317. function dispatch$4(state) {
  3318. var subscriber = state.subscriber, counter = state.counter, period = state.period;
  3319. subscriber.next(counter);
  3320. this.schedule({ subscriber: subscriber, counter: counter + 1, period: period }, period);
  3321. }
  3322. function merge() {
  3323. var observables = [];
  3324. for (var _i = 0; _i < arguments.length; _i++) {
  3325. observables[_i] = arguments[_i];
  3326. }
  3327. var concurrent = Number.POSITIVE_INFINITY;
  3328. var scheduler = null;
  3329. var last = observables[observables.length - 1];
  3330. if (isScheduler(last)) {
  3331. scheduler = observables.pop();
  3332. if (observables.length > 1 && typeof observables[observables.length - 1] === 'number') {
  3333. concurrent = observables.pop();
  3334. }
  3335. }
  3336. else if (typeof last === 'number') {
  3337. concurrent = observables.pop();
  3338. }
  3339. if (scheduler === null && observables.length === 1 && observables[0] instanceof Observable) {
  3340. return observables[0];
  3341. }
  3342. return mergeAll(concurrent)(fromArray(observables, scheduler));
  3343. }
  3344. var NEVER = new Observable(noop);
  3345. function never() {
  3346. return NEVER;
  3347. }
  3348. function onErrorResumeNext() {
  3349. var sources = [];
  3350. for (var _i = 0; _i < arguments.length; _i++) {
  3351. sources[_i] = arguments[_i];
  3352. }
  3353. if (sources.length === 0) {
  3354. return EMPTY;
  3355. }
  3356. var first = sources[0], remainder = sources.slice(1);
  3357. if (sources.length === 1 && isArray(first)) {
  3358. return onErrorResumeNext.apply(void 0, first);
  3359. }
  3360. return new Observable(function (subscriber) {
  3361. var subNext = function () { return subscriber.add(onErrorResumeNext.apply(void 0, remainder).subscribe(subscriber)); };
  3362. return from(first).subscribe({
  3363. next: function (value) { subscriber.next(value); },
  3364. error: subNext,
  3365. complete: subNext,
  3366. });
  3367. });
  3368. }
  3369. function pairs(obj, scheduler) {
  3370. if (!scheduler) {
  3371. return new Observable(function (subscriber) {
  3372. var keys = Object.keys(obj);
  3373. for (var i = 0; i < keys.length && !subscriber.closed; i++) {
  3374. var key = keys[i];
  3375. if (obj.hasOwnProperty(key)) {
  3376. subscriber.next([key, obj[key]]);
  3377. }
  3378. }
  3379. subscriber.complete();
  3380. });
  3381. }
  3382. else {
  3383. return new Observable(function (subscriber) {
  3384. var keys = Object.keys(obj);
  3385. var subscription = new Subscription();
  3386. subscription.add(scheduler.schedule(dispatch$5, 0, { keys: keys, index: 0, subscriber: subscriber, subscription: subscription, obj: obj }));
  3387. return subscription;
  3388. });
  3389. }
  3390. }
  3391. function dispatch$5(state) {
  3392. var keys = state.keys, index = state.index, subscriber = state.subscriber, subscription = state.subscription, obj = state.obj;
  3393. if (!subscriber.closed) {
  3394. if (index < keys.length) {
  3395. var key = keys[index];
  3396. subscriber.next([key, obj[key]]);
  3397. subscription.add(this.schedule({ keys: keys, index: index + 1, subscriber: subscriber, subscription: subscription, obj: obj }));
  3398. }
  3399. else {
  3400. subscriber.complete();
  3401. }
  3402. }
  3403. }
  3404. function race() {
  3405. var observables = [];
  3406. for (var _i = 0; _i < arguments.length; _i++) {
  3407. observables[_i] = arguments[_i];
  3408. }
  3409. if (observables.length === 1) {
  3410. if (isArray(observables[0])) {
  3411. observables = observables[0];
  3412. }
  3413. else {
  3414. return observables[0];
  3415. }
  3416. }
  3417. return fromArray(observables, undefined).lift(new RaceOperator());
  3418. }
  3419. var RaceOperator = (function () {
  3420. function RaceOperator() {
  3421. }
  3422. RaceOperator.prototype.call = function (subscriber, source) {
  3423. return source.subscribe(new RaceSubscriber(subscriber));
  3424. };
  3425. return RaceOperator;
  3426. }());
  3427. var RaceSubscriber = (function (_super) {
  3428. __extends(RaceSubscriber, _super);
  3429. function RaceSubscriber(destination) {
  3430. var _this = _super.call(this, destination) || this;
  3431. _this.hasFirst = false;
  3432. _this.observables = [];
  3433. _this.subscriptions = [];
  3434. return _this;
  3435. }
  3436. RaceSubscriber.prototype._next = function (observable) {
  3437. this.observables.push(observable);
  3438. };
  3439. RaceSubscriber.prototype._complete = function () {
  3440. var observables = this.observables;
  3441. var len = observables.length;
  3442. if (len === 0) {
  3443. this.destination.complete();
  3444. }
  3445. else {
  3446. for (var i = 0; i < len && !this.hasFirst; i++) {
  3447. var observable = observables[i];
  3448. var subscription = subscribeToResult(this, observable, observable, i);
  3449. if (this.subscriptions) {
  3450. this.subscriptions.push(subscription);
  3451. }
  3452. this.add(subscription);
  3453. }
  3454. this.observables = null;
  3455. }
  3456. };
  3457. RaceSubscriber.prototype.notifyNext = function (outerValue, innerValue, outerIndex, innerIndex, innerSub) {
  3458. if (!this.hasFirst) {
  3459. this.hasFirst = true;
  3460. for (var i = 0; i < this.subscriptions.length; i++) {
  3461. if (i !== outerIndex) {
  3462. var subscription = this.subscriptions[i];
  3463. subscription.unsubscribe();
  3464. this.remove(subscription);
  3465. }
  3466. }
  3467. this.subscriptions = null;
  3468. }
  3469. this.destination.next(innerValue);
  3470. };
  3471. return RaceSubscriber;
  3472. }(OuterSubscriber));
  3473. function range(start, count, scheduler) {
  3474. if (start === void 0) { start = 0; }
  3475. if (count === void 0) { count = 0; }
  3476. return new Observable(function (subscriber) {
  3477. var index = 0;
  3478. var current = start;
  3479. if (scheduler) {
  3480. return scheduler.schedule(dispatch$6, 0, {
  3481. index: index, count: count, start: start, subscriber: subscriber
  3482. });
  3483. }
  3484. else {
  3485. do {
  3486. if (index++ >= count) {
  3487. subscriber.complete();
  3488. break;
  3489. }
  3490. subscriber.next(current++);
  3491. if (subscriber.closed) {
  3492. break;
  3493. }
  3494. } while (true);
  3495. }
  3496. return undefined;
  3497. });
  3498. }
  3499. function dispatch$6(state) {
  3500. var start = state.start, index = state.index, count = state.count, subscriber = state.subscriber;
  3501. if (index >= count) {
  3502. subscriber.complete();
  3503. return;
  3504. }
  3505. subscriber.next(start);
  3506. if (subscriber.closed) {
  3507. return;
  3508. }
  3509. state.index = index + 1;
  3510. state.start = start + 1;
  3511. this.schedule(state);
  3512. }
  3513. function timer(dueTime, periodOrScheduler, scheduler) {
  3514. if (dueTime === void 0) { dueTime = 0; }
  3515. var period = -1;
  3516. if (isNumeric(periodOrScheduler)) {
  3517. period = Number(periodOrScheduler) < 1 && 1 || Number(periodOrScheduler);
  3518. }
  3519. else if (isScheduler(periodOrScheduler)) {
  3520. scheduler = periodOrScheduler;
  3521. }
  3522. if (!isScheduler(scheduler)) {
  3523. scheduler = async;
  3524. }
  3525. return new Observable(function (subscriber) {
  3526. var due = isNumeric(dueTime)
  3527. ? dueTime
  3528. : (+dueTime - scheduler.now());
  3529. return scheduler.schedule(dispatch$7, due, {
  3530. index: 0, period: period, subscriber: subscriber
  3531. });
  3532. });
  3533. }
  3534. function dispatch$7(state) {
  3535. var index = state.index, period = state.period, subscriber = state.subscriber;
  3536. subscriber.next(index);
  3537. if (subscriber.closed) {
  3538. return;
  3539. }
  3540. else if (period === -1) {
  3541. return subscriber.complete();
  3542. }
  3543. state.index = index + 1;
  3544. this.schedule(state, period);
  3545. }
  3546. function using(resourceFactory, observableFactory) {
  3547. return new Observable(function (subscriber) {
  3548. var resource;
  3549. try {
  3550. resource = resourceFactory();
  3551. }
  3552. catch (err) {
  3553. subscriber.error(err);
  3554. return undefined;
  3555. }
  3556. var result;
  3557. try {
  3558. result = observableFactory(resource);
  3559. }
  3560. catch (err) {
  3561. subscriber.error(err);
  3562. return undefined;
  3563. }
  3564. var source = result ? from(result) : EMPTY;
  3565. var subscription = source.subscribe(subscriber);
  3566. return function () {
  3567. subscription.unsubscribe();
  3568. if (resource) {
  3569. resource.unsubscribe();
  3570. }
  3571. };
  3572. });
  3573. }
  3574. function zip() {
  3575. var observables = [];
  3576. for (var _i = 0; _i < arguments.length; _i++) {
  3577. observables[_i] = arguments[_i];
  3578. }
  3579. var resultSelector = observables[observables.length - 1];
  3580. if (typeof resultSelector === 'function') {
  3581. observables.pop();
  3582. }
  3583. return fromArray(observables, undefined).lift(new ZipOperator(resultSelector));
  3584. }
  3585. var ZipOperator = (function () {
  3586. function ZipOperator(resultSelector) {
  3587. this.resultSelector = resultSelector;
  3588. }
  3589. ZipOperator.prototype.call = function (subscriber, source) {
  3590. return source.subscribe(new ZipSubscriber(subscriber, this.resultSelector));
  3591. };
  3592. return ZipOperator;
  3593. }());
  3594. var ZipSubscriber = (function (_super) {
  3595. __extends(ZipSubscriber, _super);
  3596. function ZipSubscriber(destination, resultSelector, values) {
  3597. if (values === void 0) { values = Object.create(null); }
  3598. var _this = _super.call(this, destination) || this;
  3599. _this.iterators = [];
  3600. _this.active = 0;
  3601. _this.resultSelector = (typeof resultSelector === 'function') ? resultSelector : null;
  3602. _this.values = values;
  3603. return _this;
  3604. }
  3605. ZipSubscriber.prototype._next = function (value) {
  3606. var iterators = this.iterators;
  3607. if (isArray(value)) {
  3608. iterators.push(new StaticArrayIterator(value));
  3609. }
  3610. else if (typeof value[iterator] === 'function') {
  3611. iterators.push(new StaticIterator(value[iterator]()));
  3612. }
  3613. else {
  3614. iterators.push(new ZipBufferIterator(this.destination, this, value));
  3615. }
  3616. };
  3617. ZipSubscriber.prototype._complete = function () {
  3618. var iterators = this.iterators;
  3619. var len = iterators.length;
  3620. this.unsubscribe();
  3621. if (len === 0) {
  3622. this.destination.complete();
  3623. return;
  3624. }
  3625. this.active = len;
  3626. for (var i = 0; i < len; i++) {
  3627. var iterator$$1 = iterators[i];
  3628. if (iterator$$1.stillUnsubscribed) {
  3629. var destination = this.destination;
  3630. destination.add(iterator$$1.subscribe(iterator$$1, i));
  3631. }
  3632. else {
  3633. this.active--;
  3634. }
  3635. }
  3636. };
  3637. ZipSubscriber.prototype.notifyInactive = function () {
  3638. this.active--;
  3639. if (this.active === 0) {
  3640. this.destination.complete();
  3641. }
  3642. };
  3643. ZipSubscriber.prototype.checkIterators = function () {
  3644. var iterators = this.iterators;
  3645. var len = iterators.length;
  3646. var destination = this.destination;
  3647. for (var i = 0; i < len; i++) {
  3648. var iterator$$1 = iterators[i];
  3649. if (typeof iterator$$1.hasValue === 'function' && !iterator$$1.hasValue()) {
  3650. return;
  3651. }
  3652. }
  3653. var shouldComplete = false;
  3654. var args = [];
  3655. for (var i = 0; i < len; i++) {
  3656. var iterator$$1 = iterators[i];
  3657. var result = iterator$$1.next();
  3658. if (iterator$$1.hasCompleted()) {
  3659. shouldComplete = true;
  3660. }
  3661. if (result.done) {
  3662. destination.complete();
  3663. return;
  3664. }
  3665. args.push(result.value);
  3666. }
  3667. if (this.resultSelector) {
  3668. this._tryresultSelector(args);
  3669. }
  3670. else {
  3671. destination.next(args);
  3672. }
  3673. if (shouldComplete) {
  3674. destination.complete();
  3675. }
  3676. };
  3677. ZipSubscriber.prototype._tryresultSelector = function (args) {
  3678. var result;
  3679. try {
  3680. result = this.resultSelector.apply(this, args);
  3681. }
  3682. catch (err) {
  3683. this.destination.error(err);
  3684. return;
  3685. }
  3686. this.destination.next(result);
  3687. };
  3688. return ZipSubscriber;
  3689. }(Subscriber));
  3690. var StaticIterator = (function () {
  3691. function StaticIterator(iterator$$1) {
  3692. this.iterator = iterator$$1;
  3693. this.nextResult = iterator$$1.next();
  3694. }
  3695. StaticIterator.prototype.hasValue = function () {
  3696. return true;
  3697. };
  3698. StaticIterator.prototype.next = function () {
  3699. var result = this.nextResult;
  3700. this.nextResult = this.iterator.next();
  3701. return result;
  3702. };
  3703. StaticIterator.prototype.hasCompleted = function () {
  3704. var nextResult = this.nextResult;
  3705. return nextResult && nextResult.done;
  3706. };
  3707. return StaticIterator;
  3708. }());
  3709. var StaticArrayIterator = (function () {
  3710. function StaticArrayIterator(array) {
  3711. this.array = array;
  3712. this.index = 0;
  3713. this.length = 0;
  3714. this.length = array.length;
  3715. }
  3716. StaticArrayIterator.prototype[iterator] = function () {
  3717. return this;
  3718. };
  3719. StaticArrayIterator.prototype.next = function (value) {
  3720. var i = this.index++;
  3721. var array = this.array;
  3722. return i < this.length ? { value: array[i], done: false } : { value: null, done: true };
  3723. };
  3724. StaticArrayIterator.prototype.hasValue = function () {
  3725. return this.array.length > this.index;
  3726. };
  3727. StaticArrayIterator.prototype.hasCompleted = function () {
  3728. return this.array.length === this.index;
  3729. };
  3730. return StaticArrayIterator;
  3731. }());
  3732. var ZipBufferIterator = (function (_super) {
  3733. __extends(ZipBufferIterator, _super);
  3734. function ZipBufferIterator(destination, parent, observable) {
  3735. var _this = _super.call(this, destination) || this;
  3736. _this.parent = parent;
  3737. _this.observable = observable;
  3738. _this.stillUnsubscribed = true;
  3739. _this.buffer = [];
  3740. _this.isComplete = false;
  3741. return _this;
  3742. }
  3743. ZipBufferIterator.prototype[iterator] = function () {
  3744. return this;
  3745. };
  3746. ZipBufferIterator.prototype.next = function () {
  3747. var buffer = this.buffer;
  3748. if (buffer.length === 0 && this.isComplete) {
  3749. return { value: null, done: true };
  3750. }
  3751. else {
  3752. return { value: buffer.shift(), done: false };
  3753. }
  3754. };
  3755. ZipBufferIterator.prototype.hasValue = function () {
  3756. return this.buffer.length > 0;
  3757. };
  3758. ZipBufferIterator.prototype.hasCompleted = function () {
  3759. return this.buffer.length === 0 && this.isComplete;
  3760. };
  3761. ZipBufferIterator.prototype.notifyComplete = function () {
  3762. if (this.buffer.length > 0) {
  3763. this.isComplete = true;
  3764. this.parent.notifyInactive();
  3765. }
  3766. else {
  3767. this.destination.complete();
  3768. }
  3769. };
  3770. ZipBufferIterator.prototype.notifyNext = function (outerValue, innerValue, outerIndex, innerIndex, innerSub) {
  3771. this.buffer.push(innerValue);
  3772. this.parent.checkIterators();
  3773. };
  3774. ZipBufferIterator.prototype.subscribe = function (value, index) {
  3775. return subscribeToResult(this, this.observable, this, index);
  3776. };
  3777. return ZipBufferIterator;
  3778. }(OuterSubscriber));
  3779. function audit(durationSelector) {
  3780. return function auditOperatorFunction(source) {
  3781. return source.lift(new AuditOperator(durationSelector));
  3782. };
  3783. }
  3784. var AuditOperator = (function () {
  3785. function AuditOperator(durationSelector) {
  3786. this.durationSelector = durationSelector;
  3787. }
  3788. AuditOperator.prototype.call = function (subscriber, source) {
  3789. return source.subscribe(new AuditSubscriber(subscriber, this.durationSelector));
  3790. };
  3791. return AuditOperator;
  3792. }());
  3793. var AuditSubscriber = (function (_super) {
  3794. __extends(AuditSubscriber, _super);
  3795. function AuditSubscriber(destination, durationSelector) {
  3796. var _this = _super.call(this, destination) || this;
  3797. _this.durationSelector = durationSelector;
  3798. _this.hasValue = false;
  3799. return _this;
  3800. }
  3801. AuditSubscriber.prototype._next = function (value) {
  3802. this.value = value;
  3803. this.hasValue = true;
  3804. if (!this.throttled) {
  3805. var duration = tryCatch(this.durationSelector)(value);
  3806. if (duration === errorObject) {
  3807. this.destination.error(errorObject.e);
  3808. }
  3809. else {
  3810. var innerSubscription = subscribeToResult(this, duration);
  3811. if (!innerSubscription || innerSubscription.closed) {
  3812. this.clearThrottle();
  3813. }
  3814. else {
  3815. this.add(this.throttled = innerSubscription);
  3816. }
  3817. }
  3818. }
  3819. };
  3820. AuditSubscriber.prototype.clearThrottle = function () {
  3821. var _a = this, value = _a.value, hasValue = _a.hasValue, throttled = _a.throttled;
  3822. if (throttled) {
  3823. this.remove(throttled);
  3824. this.throttled = null;
  3825. throttled.unsubscribe();
  3826. }
  3827. if (hasValue) {
  3828. this.value = null;
  3829. this.hasValue = false;
  3830. this.destination.next(value);
  3831. }
  3832. };
  3833. AuditSubscriber.prototype.notifyNext = function (outerValue, innerValue, outerIndex, innerIndex) {
  3834. this.clearThrottle();
  3835. };
  3836. AuditSubscriber.prototype.notifyComplete = function () {
  3837. this.clearThrottle();
  3838. };
  3839. return AuditSubscriber;
  3840. }(OuterSubscriber));
  3841. function auditTime(duration, scheduler) {
  3842. if (scheduler === void 0) { scheduler = async; }
  3843. return audit(function () { return timer(duration, scheduler); });
  3844. }
  3845. function buffer(closingNotifier) {
  3846. return function bufferOperatorFunction(source) {
  3847. return source.lift(new BufferOperator(closingNotifier));
  3848. };
  3849. }
  3850. var BufferOperator = (function () {
  3851. function BufferOperator(closingNotifier) {
  3852. this.closingNotifier = closingNotifier;
  3853. }
  3854. BufferOperator.prototype.call = function (subscriber, source) {
  3855. return source.subscribe(new BufferSubscriber(subscriber, this.closingNotifier));
  3856. };
  3857. return BufferOperator;
  3858. }());
  3859. var BufferSubscriber = (function (_super) {
  3860. __extends(BufferSubscriber, _super);
  3861. function BufferSubscriber(destination, closingNotifier) {
  3862. var _this = _super.call(this, destination) || this;
  3863. _this.buffer = [];
  3864. _this.add(subscribeToResult(_this, closingNotifier));
  3865. return _this;
  3866. }
  3867. BufferSubscriber.prototype._next = function (value) {
  3868. this.buffer.push(value);
  3869. };
  3870. BufferSubscriber.prototype.notifyNext = function (outerValue, innerValue, outerIndex, innerIndex, innerSub) {
  3871. var buffer = this.buffer;
  3872. this.buffer = [];
  3873. this.destination.next(buffer);
  3874. };
  3875. return BufferSubscriber;
  3876. }(OuterSubscriber));
  3877. function bufferCount(bufferSize, startBufferEvery) {
  3878. if (startBufferEvery === void 0) { startBufferEvery = null; }
  3879. return function bufferCountOperatorFunction(source) {
  3880. return source.lift(new BufferCountOperator(bufferSize, startBufferEvery));
  3881. };
  3882. }
  3883. var BufferCountOperator = (function () {
  3884. function BufferCountOperator(bufferSize, startBufferEvery) {
  3885. this.bufferSize = bufferSize;
  3886. this.startBufferEvery = startBufferEvery;
  3887. if (!startBufferEvery || bufferSize === startBufferEvery) {
  3888. this.subscriberClass = BufferCountSubscriber;
  3889. }
  3890. else {
  3891. this.subscriberClass = BufferSkipCountSubscriber;
  3892. }
  3893. }
  3894. BufferCountOperator.prototype.call = function (subscriber, source) {
  3895. return source.subscribe(new this.subscriberClass(subscriber, this.bufferSize, this.startBufferEvery));
  3896. };
  3897. return BufferCountOperator;
  3898. }());
  3899. var BufferCountSubscriber = (function (_super) {
  3900. __extends(BufferCountSubscriber, _super);
  3901. function BufferCountSubscriber(destination, bufferSize) {
  3902. var _this = _super.call(this, destination) || this;
  3903. _this.bufferSize = bufferSize;
  3904. _this.buffer = [];
  3905. return _this;
  3906. }
  3907. BufferCountSubscriber.prototype._next = function (value) {
  3908. var buffer = this.buffer;
  3909. buffer.push(value);
  3910. if (buffer.length == this.bufferSize) {
  3911. this.destination.next(buffer);
  3912. this.buffer = [];
  3913. }
  3914. };
  3915. BufferCountSubscriber.prototype._complete = function () {
  3916. var buffer = this.buffer;
  3917. if (buffer.length > 0) {
  3918. this.destination.next(buffer);
  3919. }
  3920. _super.prototype._complete.call(this);
  3921. };
  3922. return BufferCountSubscriber;
  3923. }(Subscriber));
  3924. var BufferSkipCountSubscriber = (function (_super) {
  3925. __extends(BufferSkipCountSubscriber, _super);
  3926. function BufferSkipCountSubscriber(destination, bufferSize, startBufferEvery) {
  3927. var _this = _super.call(this, destination) || this;
  3928. _this.bufferSize = bufferSize;
  3929. _this.startBufferEvery = startBufferEvery;
  3930. _this.buffers = [];
  3931. _this.count = 0;
  3932. return _this;
  3933. }
  3934. BufferSkipCountSubscriber.prototype._next = function (value) {
  3935. var _a = this, bufferSize = _a.bufferSize, startBufferEvery = _a.startBufferEvery, buffers = _a.buffers, count = _a.count;
  3936. this.count++;
  3937. if (count % startBufferEvery === 0) {
  3938. buffers.push([]);
  3939. }
  3940. for (var i = buffers.length; i--;) {
  3941. var buffer = buffers[i];
  3942. buffer.push(value);
  3943. if (buffer.length === bufferSize) {
  3944. buffers.splice(i, 1);
  3945. this.destination.next(buffer);
  3946. }
  3947. }
  3948. };
  3949. BufferSkipCountSubscriber.prototype._complete = function () {
  3950. var _a = this, buffers = _a.buffers, destination = _a.destination;
  3951. while (buffers.length > 0) {
  3952. var buffer = buffers.shift();
  3953. if (buffer.length > 0) {
  3954. destination.next(buffer);
  3955. }
  3956. }
  3957. _super.prototype._complete.call(this);
  3958. };
  3959. return BufferSkipCountSubscriber;
  3960. }(Subscriber));
  3961. function bufferTime(bufferTimeSpan) {
  3962. var length = arguments.length;
  3963. var scheduler = async;
  3964. if (isScheduler(arguments[arguments.length - 1])) {
  3965. scheduler = arguments[arguments.length - 1];
  3966. length--;
  3967. }
  3968. var bufferCreationInterval = null;
  3969. if (length >= 2) {
  3970. bufferCreationInterval = arguments[1];
  3971. }
  3972. var maxBufferSize = Number.POSITIVE_INFINITY;
  3973. if (length >= 3) {
  3974. maxBufferSize = arguments[2];
  3975. }
  3976. return function bufferTimeOperatorFunction(source) {
  3977. return source.lift(new BufferTimeOperator(bufferTimeSpan, bufferCreationInterval, maxBufferSize, scheduler));
  3978. };
  3979. }
  3980. var BufferTimeOperator = (function () {
  3981. function BufferTimeOperator(bufferTimeSpan, bufferCreationInterval, maxBufferSize, scheduler) {
  3982. this.bufferTimeSpan = bufferTimeSpan;
  3983. this.bufferCreationInterval = bufferCreationInterval;
  3984. this.maxBufferSize = maxBufferSize;
  3985. this.scheduler = scheduler;
  3986. }
  3987. BufferTimeOperator.prototype.call = function (subscriber, source) {
  3988. return source.subscribe(new BufferTimeSubscriber(subscriber, this.bufferTimeSpan, this.bufferCreationInterval, this.maxBufferSize, this.scheduler));
  3989. };
  3990. return BufferTimeOperator;
  3991. }());
  3992. var Context = (function () {
  3993. function Context() {
  3994. this.buffer = [];
  3995. }
  3996. return Context;
  3997. }());
  3998. var BufferTimeSubscriber = (function (_super) {
  3999. __extends(BufferTimeSubscriber, _super);
  4000. function BufferTimeSubscriber(destination, bufferTimeSpan, bufferCreationInterval, maxBufferSize, scheduler) {
  4001. var _this = _super.call(this, destination) || this;
  4002. _this.bufferTimeSpan = bufferTimeSpan;
  4003. _this.bufferCreationInterval = bufferCreationInterval;
  4004. _this.maxBufferSize = maxBufferSize;
  4005. _this.scheduler = scheduler;
  4006. _this.contexts = [];
  4007. var context = _this.openContext();
  4008. _this.timespanOnly = bufferCreationInterval == null || bufferCreationInterval < 0;
  4009. if (_this.timespanOnly) {
  4010. var timeSpanOnlyState = { subscriber: _this, context: context, bufferTimeSpan: bufferTimeSpan };
  4011. _this.add(context.closeAction = scheduler.schedule(dispatchBufferTimeSpanOnly, bufferTimeSpan, timeSpanOnlyState));
  4012. }
  4013. else {
  4014. var closeState = { subscriber: _this, context: context };
  4015. var creationState = { bufferTimeSpan: bufferTimeSpan, bufferCreationInterval: bufferCreationInterval, subscriber: _this, scheduler: scheduler };
  4016. _this.add(context.closeAction = scheduler.schedule(dispatchBufferClose, bufferTimeSpan, closeState));
  4017. _this.add(scheduler.schedule(dispatchBufferCreation, bufferCreationInterval, creationState));
  4018. }
  4019. return _this;
  4020. }
  4021. BufferTimeSubscriber.prototype._next = function (value) {
  4022. var contexts = this.contexts;
  4023. var len = contexts.length;
  4024. var filledBufferContext;
  4025. for (var i = 0; i < len; i++) {
  4026. var context_1 = contexts[i];
  4027. var buffer = context_1.buffer;
  4028. buffer.push(value);
  4029. if (buffer.length == this.maxBufferSize) {
  4030. filledBufferContext = context_1;
  4031. }
  4032. }
  4033. if (filledBufferContext) {
  4034. this.onBufferFull(filledBufferContext);
  4035. }
  4036. };
  4037. BufferTimeSubscriber.prototype._error = function (err) {
  4038. this.contexts.length = 0;
  4039. _super.prototype._error.call(this, err);
  4040. };
  4041. BufferTimeSubscriber.prototype._complete = function () {
  4042. var _a = this, contexts = _a.contexts, destination = _a.destination;
  4043. while (contexts.length > 0) {
  4044. var context_2 = contexts.shift();
  4045. destination.next(context_2.buffer);
  4046. }
  4047. _super.prototype._complete.call(this);
  4048. };
  4049. BufferTimeSubscriber.prototype._unsubscribe = function () {
  4050. this.contexts = null;
  4051. };
  4052. BufferTimeSubscriber.prototype.onBufferFull = function (context) {
  4053. this.closeContext(context);
  4054. var closeAction = context.closeAction;
  4055. closeAction.unsubscribe();
  4056. this.remove(closeAction);
  4057. if (!this.closed && this.timespanOnly) {
  4058. context = this.openContext();
  4059. var bufferTimeSpan = this.bufferTimeSpan;
  4060. var timeSpanOnlyState = { subscriber: this, context: context, bufferTimeSpan: bufferTimeSpan };
  4061. this.add(context.closeAction = this.scheduler.schedule(dispatchBufferTimeSpanOnly, bufferTimeSpan, timeSpanOnlyState));
  4062. }
  4063. };
  4064. BufferTimeSubscriber.prototype.openContext = function () {
  4065. var context = new Context();
  4066. this.contexts.push(context);
  4067. return context;
  4068. };
  4069. BufferTimeSubscriber.prototype.closeContext = function (context) {
  4070. this.destination.next(context.buffer);
  4071. var contexts = this.contexts;
  4072. var spliceIndex = contexts ? contexts.indexOf(context) : -1;
  4073. if (spliceIndex >= 0) {
  4074. contexts.splice(contexts.indexOf(context), 1);
  4075. }
  4076. };
  4077. return BufferTimeSubscriber;
  4078. }(Subscriber));
  4079. function dispatchBufferTimeSpanOnly(state) {
  4080. var subscriber = state.subscriber;
  4081. var prevContext = state.context;
  4082. if (prevContext) {
  4083. subscriber.closeContext(prevContext);
  4084. }
  4085. if (!subscriber.closed) {
  4086. state.context = subscriber.openContext();
  4087. state.context.closeAction = this.schedule(state, state.bufferTimeSpan);
  4088. }
  4089. }
  4090. function dispatchBufferCreation(state) {
  4091. var bufferCreationInterval = state.bufferCreationInterval, bufferTimeSpan = state.bufferTimeSpan, subscriber = state.subscriber, scheduler = state.scheduler;
  4092. var context = subscriber.openContext();
  4093. var action = this;
  4094. if (!subscriber.closed) {
  4095. subscriber.add(context.closeAction = scheduler.schedule(dispatchBufferClose, bufferTimeSpan, { subscriber: subscriber, context: context }));
  4096. action.schedule(state, bufferCreationInterval);
  4097. }
  4098. }
  4099. function dispatchBufferClose(arg) {
  4100. var subscriber = arg.subscriber, context = arg.context;
  4101. subscriber.closeContext(context);
  4102. }
  4103. function bufferToggle(openings, closingSelector) {
  4104. return function bufferToggleOperatorFunction(source) {
  4105. return source.lift(new BufferToggleOperator(openings, closingSelector));
  4106. };
  4107. }
  4108. var BufferToggleOperator = (function () {
  4109. function BufferToggleOperator(openings, closingSelector) {
  4110. this.openings = openings;
  4111. this.closingSelector = closingSelector;
  4112. }
  4113. BufferToggleOperator.prototype.call = function (subscriber, source) {
  4114. return source.subscribe(new BufferToggleSubscriber(subscriber, this.openings, this.closingSelector));
  4115. };
  4116. return BufferToggleOperator;
  4117. }());
  4118. var BufferToggleSubscriber = (function (_super) {
  4119. __extends(BufferToggleSubscriber, _super);
  4120. function BufferToggleSubscriber(destination, openings, closingSelector) {
  4121. var _this = _super.call(this, destination) || this;
  4122. _this.openings = openings;
  4123. _this.closingSelector = closingSelector;
  4124. _this.contexts = [];
  4125. _this.add(subscribeToResult(_this, openings));
  4126. return _this;
  4127. }
  4128. BufferToggleSubscriber.prototype._next = function (value) {
  4129. var contexts = this.contexts;
  4130. var len = contexts.length;
  4131. for (var i = 0; i < len; i++) {
  4132. contexts[i].buffer.push(value);
  4133. }
  4134. };
  4135. BufferToggleSubscriber.prototype._error = function (err) {
  4136. var contexts = this.contexts;
  4137. while (contexts.length > 0) {
  4138. var context_1 = contexts.shift();
  4139. context_1.subscription.unsubscribe();
  4140. context_1.buffer = null;
  4141. context_1.subscription = null;
  4142. }
  4143. this.contexts = null;
  4144. _super.prototype._error.call(this, err);
  4145. };
  4146. BufferToggleSubscriber.prototype._complete = function () {
  4147. var contexts = this.contexts;
  4148. while (contexts.length > 0) {
  4149. var context_2 = contexts.shift();
  4150. this.destination.next(context_2.buffer);
  4151. context_2.subscription.unsubscribe();
  4152. context_2.buffer = null;
  4153. context_2.subscription = null;
  4154. }
  4155. this.contexts = null;
  4156. _super.prototype._complete.call(this);
  4157. };
  4158. BufferToggleSubscriber.prototype.notifyNext = function (outerValue, innerValue, outerIndex, innerIndex, innerSub) {
  4159. outerValue ? this.closeBuffer(outerValue) : this.openBuffer(innerValue);
  4160. };
  4161. BufferToggleSubscriber.prototype.notifyComplete = function (innerSub) {
  4162. this.closeBuffer(innerSub.context);
  4163. };
  4164. BufferToggleSubscriber.prototype.openBuffer = function (value) {
  4165. try {
  4166. var closingSelector = this.closingSelector;
  4167. var closingNotifier = closingSelector.call(this, value);
  4168. if (closingNotifier) {
  4169. this.trySubscribe(closingNotifier);
  4170. }
  4171. }
  4172. catch (err) {
  4173. this._error(err);
  4174. }
  4175. };
  4176. BufferToggleSubscriber.prototype.closeBuffer = function (context) {
  4177. var contexts = this.contexts;
  4178. if (contexts && context) {
  4179. var buffer = context.buffer, subscription = context.subscription;
  4180. this.destination.next(buffer);
  4181. contexts.splice(contexts.indexOf(context), 1);
  4182. this.remove(subscription);
  4183. subscription.unsubscribe();
  4184. }
  4185. };
  4186. BufferToggleSubscriber.prototype.trySubscribe = function (closingNotifier) {
  4187. var contexts = this.contexts;
  4188. var buffer = [];
  4189. var subscription = new Subscription();
  4190. var context = { buffer: buffer, subscription: subscription };
  4191. contexts.push(context);
  4192. var innerSubscription = subscribeToResult(this, closingNotifier, context);
  4193. if (!innerSubscription || innerSubscription.closed) {
  4194. this.closeBuffer(context);
  4195. }
  4196. else {
  4197. innerSubscription.context = context;
  4198. this.add(innerSubscription);
  4199. subscription.add(innerSubscription);
  4200. }
  4201. };
  4202. return BufferToggleSubscriber;
  4203. }(OuterSubscriber));
  4204. function bufferWhen(closingSelector) {
  4205. return function (source) {
  4206. return source.lift(new BufferWhenOperator(closingSelector));
  4207. };
  4208. }
  4209. var BufferWhenOperator = (function () {
  4210. function BufferWhenOperator(closingSelector) {
  4211. this.closingSelector = closingSelector;
  4212. }
  4213. BufferWhenOperator.prototype.call = function (subscriber, source) {
  4214. return source.subscribe(new BufferWhenSubscriber(subscriber, this.closingSelector));
  4215. };
  4216. return BufferWhenOperator;
  4217. }());
  4218. var BufferWhenSubscriber = (function (_super) {
  4219. __extends(BufferWhenSubscriber, _super);
  4220. function BufferWhenSubscriber(destination, closingSelector) {
  4221. var _this = _super.call(this, destination) || this;
  4222. _this.closingSelector = closingSelector;
  4223. _this.subscribing = false;
  4224. _this.openBuffer();
  4225. return _this;
  4226. }
  4227. BufferWhenSubscriber.prototype._next = function (value) {
  4228. this.buffer.push(value);
  4229. };
  4230. BufferWhenSubscriber.prototype._complete = function () {
  4231. var buffer = this.buffer;
  4232. if (buffer) {
  4233. this.destination.next(buffer);
  4234. }
  4235. _super.prototype._complete.call(this);
  4236. };
  4237. BufferWhenSubscriber.prototype._unsubscribe = function () {
  4238. this.buffer = null;
  4239. this.subscribing = false;
  4240. };
  4241. BufferWhenSubscriber.prototype.notifyNext = function (outerValue, innerValue, outerIndex, innerIndex, innerSub) {
  4242. this.openBuffer();
  4243. };
  4244. BufferWhenSubscriber.prototype.notifyComplete = function () {
  4245. if (this.subscribing) {
  4246. this.complete();
  4247. }
  4248. else {
  4249. this.openBuffer();
  4250. }
  4251. };
  4252. BufferWhenSubscriber.prototype.openBuffer = function () {
  4253. var closingSubscription = this.closingSubscription;
  4254. if (closingSubscription) {
  4255. this.remove(closingSubscription);
  4256. closingSubscription.unsubscribe();
  4257. }
  4258. var buffer = this.buffer;
  4259. if (this.buffer) {
  4260. this.destination.next(buffer);
  4261. }
  4262. this.buffer = [];
  4263. var closingNotifier = tryCatch(this.closingSelector)();
  4264. if (closingNotifier === errorObject) {
  4265. this.error(errorObject.e);
  4266. }
  4267. else {
  4268. closingSubscription = new Subscription();
  4269. this.closingSubscription = closingSubscription;
  4270. this.add(closingSubscription);
  4271. this.subscribing = true;
  4272. closingSubscription.add(subscribeToResult(this, closingNotifier));
  4273. this.subscribing = false;
  4274. }
  4275. };
  4276. return BufferWhenSubscriber;
  4277. }(OuterSubscriber));
  4278. function catchError(selector) {
  4279. return function catchErrorOperatorFunction(source) {
  4280. var operator = new CatchOperator(selector);
  4281. var caught = source.lift(operator);
  4282. return (operator.caught = caught);
  4283. };
  4284. }
  4285. var CatchOperator = (function () {
  4286. function CatchOperator(selector) {
  4287. this.selector = selector;
  4288. }
  4289. CatchOperator.prototype.call = function (subscriber, source) {
  4290. return source.subscribe(new CatchSubscriber(subscriber, this.selector, this.caught));
  4291. };
  4292. return CatchOperator;
  4293. }());
  4294. var CatchSubscriber = (function (_super) {
  4295. __extends(CatchSubscriber, _super);
  4296. function CatchSubscriber(destination, selector, caught) {
  4297. var _this = _super.call(this, destination) || this;
  4298. _this.selector = selector;
  4299. _this.caught = caught;
  4300. return _this;
  4301. }
  4302. CatchSubscriber.prototype.error = function (err) {
  4303. if (!this.isStopped) {
  4304. var result = void 0;
  4305. try {
  4306. result = this.selector(err, this.caught);
  4307. }
  4308. catch (err2) {
  4309. _super.prototype.error.call(this, err2);
  4310. return;
  4311. }
  4312. this._unsubscribeAndRecycle();
  4313. var innerSubscriber = new InnerSubscriber(this, undefined, undefined);
  4314. this.add(innerSubscriber);
  4315. subscribeToResult(this, result, undefined, undefined, innerSubscriber);
  4316. }
  4317. };
  4318. return CatchSubscriber;
  4319. }(OuterSubscriber));
  4320. function combineAll(project) {
  4321. return function (source) { return source.lift(new CombineLatestOperator(project)); };
  4322. }
  4323. function combineLatest$1() {
  4324. var observables = [];
  4325. for (var _i = 0; _i < arguments.length; _i++) {
  4326. observables[_i] = arguments[_i];
  4327. }
  4328. var project = null;
  4329. if (typeof observables[observables.length - 1] === 'function') {
  4330. project = observables.pop();
  4331. }
  4332. if (observables.length === 1 && isArray(observables[0])) {
  4333. observables = observables[0].slice();
  4334. }
  4335. return function (source) { return source.lift.call(from([source].concat(observables)), new CombineLatestOperator(project)); };
  4336. }
  4337. function concat$1() {
  4338. var observables = [];
  4339. for (var _i = 0; _i < arguments.length; _i++) {
  4340. observables[_i] = arguments[_i];
  4341. }
  4342. return function (source) { return source.lift.call(concat.apply(void 0, [source].concat(observables))); };
  4343. }
  4344. function concatMap(project, resultSelector) {
  4345. return mergeMap(project, resultSelector, 1);
  4346. }
  4347. function concatMapTo(innerObservable, resultSelector) {
  4348. return concatMap(function () { return innerObservable; }, resultSelector);
  4349. }
  4350. function count(predicate) {
  4351. return function (source) { return source.lift(new CountOperator(predicate, source)); };
  4352. }
  4353. var CountOperator = (function () {
  4354. function CountOperator(predicate, source) {
  4355. this.predicate = predicate;
  4356. this.source = source;
  4357. }
  4358. CountOperator.prototype.call = function (subscriber, source) {
  4359. return source.subscribe(new CountSubscriber(subscriber, this.predicate, this.source));
  4360. };
  4361. return CountOperator;
  4362. }());
  4363. var CountSubscriber = (function (_super) {
  4364. __extends(CountSubscriber, _super);
  4365. function CountSubscriber(destination, predicate, source) {
  4366. var _this = _super.call(this, destination) || this;
  4367. _this.predicate = predicate;
  4368. _this.source = source;
  4369. _this.count = 0;
  4370. _this.index = 0;
  4371. return _this;
  4372. }
  4373. CountSubscriber.prototype._next = function (value) {
  4374. if (this.predicate) {
  4375. this._tryPredicate(value);
  4376. }
  4377. else {
  4378. this.count++;
  4379. }
  4380. };
  4381. CountSubscriber.prototype._tryPredicate = function (value) {
  4382. var result;
  4383. try {
  4384. result = this.predicate(value, this.index++, this.source);
  4385. }
  4386. catch (err) {
  4387. this.destination.error(err);
  4388. return;
  4389. }
  4390. if (result) {
  4391. this.count++;
  4392. }
  4393. };
  4394. CountSubscriber.prototype._complete = function () {
  4395. this.destination.next(this.count);
  4396. this.destination.complete();
  4397. };
  4398. return CountSubscriber;
  4399. }(Subscriber));
  4400. function debounce(durationSelector) {
  4401. return function (source) { return source.lift(new DebounceOperator(durationSelector)); };
  4402. }
  4403. var DebounceOperator = (function () {
  4404. function DebounceOperator(durationSelector) {
  4405. this.durationSelector = durationSelector;
  4406. }
  4407. DebounceOperator.prototype.call = function (subscriber, source) {
  4408. return source.subscribe(new DebounceSubscriber(subscriber, this.durationSelector));
  4409. };
  4410. return DebounceOperator;
  4411. }());
  4412. var DebounceSubscriber = (function (_super) {
  4413. __extends(DebounceSubscriber, _super);
  4414. function DebounceSubscriber(destination, durationSelector) {
  4415. var _this = _super.call(this, destination) || this;
  4416. _this.durationSelector = durationSelector;
  4417. _this.hasValue = false;
  4418. _this.durationSubscription = null;
  4419. return _this;
  4420. }
  4421. DebounceSubscriber.prototype._next = function (value) {
  4422. try {
  4423. var result = this.durationSelector.call(this, value);
  4424. if (result) {
  4425. this._tryNext(value, result);
  4426. }
  4427. }
  4428. catch (err) {
  4429. this.destination.error(err);
  4430. }
  4431. };
  4432. DebounceSubscriber.prototype._complete = function () {
  4433. this.emitValue();
  4434. this.destination.complete();
  4435. };
  4436. DebounceSubscriber.prototype._tryNext = function (value, duration) {
  4437. var subscription = this.durationSubscription;
  4438. this.value = value;
  4439. this.hasValue = true;
  4440. if (subscription) {
  4441. subscription.unsubscribe();
  4442. this.remove(subscription);
  4443. }
  4444. subscription = subscribeToResult(this, duration);
  4445. if (subscription && !subscription.closed) {
  4446. this.add(this.durationSubscription = subscription);
  4447. }
  4448. };
  4449. DebounceSubscriber.prototype.notifyNext = function (outerValue, innerValue, outerIndex, innerIndex, innerSub) {
  4450. this.emitValue();
  4451. };
  4452. DebounceSubscriber.prototype.notifyComplete = function () {
  4453. this.emitValue();
  4454. };
  4455. DebounceSubscriber.prototype.emitValue = function () {
  4456. if (this.hasValue) {
  4457. var value = this.value;
  4458. var subscription = this.durationSubscription;
  4459. if (subscription) {
  4460. this.durationSubscription = null;
  4461. subscription.unsubscribe();
  4462. this.remove(subscription);
  4463. }
  4464. this.value = null;
  4465. this.hasValue = false;
  4466. _super.prototype._next.call(this, value);
  4467. }
  4468. };
  4469. return DebounceSubscriber;
  4470. }(OuterSubscriber));
  4471. function debounceTime(dueTime, scheduler) {
  4472. if (scheduler === void 0) { scheduler = async; }
  4473. return function (source) { return source.lift(new DebounceTimeOperator(dueTime, scheduler)); };
  4474. }
  4475. var DebounceTimeOperator = (function () {
  4476. function DebounceTimeOperator(dueTime, scheduler) {
  4477. this.dueTime = dueTime;
  4478. this.scheduler = scheduler;
  4479. }
  4480. DebounceTimeOperator.prototype.call = function (subscriber, source) {
  4481. return source.subscribe(new DebounceTimeSubscriber(subscriber, this.dueTime, this.scheduler));
  4482. };
  4483. return DebounceTimeOperator;
  4484. }());
  4485. var DebounceTimeSubscriber = (function (_super) {
  4486. __extends(DebounceTimeSubscriber, _super);
  4487. function DebounceTimeSubscriber(destination, dueTime, scheduler) {
  4488. var _this = _super.call(this, destination) || this;
  4489. _this.dueTime = dueTime;
  4490. _this.scheduler = scheduler;
  4491. _this.debouncedSubscription = null;
  4492. _this.lastValue = null;
  4493. _this.hasValue = false;
  4494. return _this;
  4495. }
  4496. DebounceTimeSubscriber.prototype._next = function (value) {
  4497. this.clearDebounce();
  4498. this.lastValue = value;
  4499. this.hasValue = true;
  4500. this.add(this.debouncedSubscription = this.scheduler.schedule(dispatchNext$2, this.dueTime, this));
  4501. };
  4502. DebounceTimeSubscriber.prototype._complete = function () {
  4503. this.debouncedNext();
  4504. this.destination.complete();
  4505. };
  4506. DebounceTimeSubscriber.prototype.debouncedNext = function () {
  4507. this.clearDebounce();
  4508. if (this.hasValue) {
  4509. var lastValue = this.lastValue;
  4510. this.lastValue = null;
  4511. this.hasValue = false;
  4512. this.destination.next(lastValue);
  4513. }
  4514. };
  4515. DebounceTimeSubscriber.prototype.clearDebounce = function () {
  4516. var debouncedSubscription = this.debouncedSubscription;
  4517. if (debouncedSubscription !== null) {
  4518. this.remove(debouncedSubscription);
  4519. debouncedSubscription.unsubscribe();
  4520. this.debouncedSubscription = null;
  4521. }
  4522. };
  4523. return DebounceTimeSubscriber;
  4524. }(Subscriber));
  4525. function dispatchNext$2(subscriber) {
  4526. subscriber.debouncedNext();
  4527. }
  4528. function defaultIfEmpty(defaultValue) {
  4529. if (defaultValue === void 0) { defaultValue = null; }
  4530. return function (source) { return source.lift(new DefaultIfEmptyOperator(defaultValue)); };
  4531. }
  4532. var DefaultIfEmptyOperator = (function () {
  4533. function DefaultIfEmptyOperator(defaultValue) {
  4534. this.defaultValue = defaultValue;
  4535. }
  4536. DefaultIfEmptyOperator.prototype.call = function (subscriber, source) {
  4537. return source.subscribe(new DefaultIfEmptySubscriber(subscriber, this.defaultValue));
  4538. };
  4539. return DefaultIfEmptyOperator;
  4540. }());
  4541. var DefaultIfEmptySubscriber = (function (_super) {
  4542. __extends(DefaultIfEmptySubscriber, _super);
  4543. function DefaultIfEmptySubscriber(destination, defaultValue) {
  4544. var _this = _super.call(this, destination) || this;
  4545. _this.defaultValue = defaultValue;
  4546. _this.isEmpty = true;
  4547. return _this;
  4548. }
  4549. DefaultIfEmptySubscriber.prototype._next = function (value) {
  4550. this.isEmpty = false;
  4551. this.destination.next(value);
  4552. };
  4553. DefaultIfEmptySubscriber.prototype._complete = function () {
  4554. if (this.isEmpty) {
  4555. this.destination.next(this.defaultValue);
  4556. }
  4557. this.destination.complete();
  4558. };
  4559. return DefaultIfEmptySubscriber;
  4560. }(Subscriber));
  4561. function isDate(value) {
  4562. return value instanceof Date && !isNaN(+value);
  4563. }
  4564. function delay(delay, scheduler) {
  4565. if (scheduler === void 0) { scheduler = async; }
  4566. var absoluteDelay = isDate(delay);
  4567. var delayFor = absoluteDelay ? (+delay - scheduler.now()) : Math.abs(delay);
  4568. return function (source) { return source.lift(new DelayOperator(delayFor, scheduler)); };
  4569. }
  4570. var DelayOperator = (function () {
  4571. function DelayOperator(delay, scheduler) {
  4572. this.delay = delay;
  4573. this.scheduler = scheduler;
  4574. }
  4575. DelayOperator.prototype.call = function (subscriber, source) {
  4576. return source.subscribe(new DelaySubscriber(subscriber, this.delay, this.scheduler));
  4577. };
  4578. return DelayOperator;
  4579. }());
  4580. var DelaySubscriber = (function (_super) {
  4581. __extends(DelaySubscriber, _super);
  4582. function DelaySubscriber(destination, delay, scheduler) {
  4583. var _this = _super.call(this, destination) || this;
  4584. _this.delay = delay;
  4585. _this.scheduler = scheduler;
  4586. _this.queue = [];
  4587. _this.active = false;
  4588. _this.errored = false;
  4589. return _this;
  4590. }
  4591. DelaySubscriber.dispatch = function (state) {
  4592. var source = state.source;
  4593. var queue = source.queue;
  4594. var scheduler = state.scheduler;
  4595. var destination = state.destination;
  4596. while (queue.length > 0 && (queue[0].time - scheduler.now()) <= 0) {
  4597. queue.shift().notification.observe(destination);
  4598. }
  4599. if (queue.length > 0) {
  4600. var delay_1 = Math.max(0, queue[0].time - scheduler.now());
  4601. this.schedule(state, delay_1);
  4602. }
  4603. else {
  4604. this.unsubscribe();
  4605. source.active = false;
  4606. }
  4607. };
  4608. DelaySubscriber.prototype._schedule = function (scheduler) {
  4609. this.active = true;
  4610. var destination = this.destination;
  4611. destination.add(scheduler.schedule(DelaySubscriber.dispatch, this.delay, {
  4612. source: this, destination: this.destination, scheduler: scheduler
  4613. }));
  4614. };
  4615. DelaySubscriber.prototype.scheduleNotification = function (notification) {
  4616. if (this.errored === true) {
  4617. return;
  4618. }
  4619. var scheduler = this.scheduler;
  4620. var message = new DelayMessage(scheduler.now() + this.delay, notification);
  4621. this.queue.push(message);
  4622. if (this.active === false) {
  4623. this._schedule(scheduler);
  4624. }
  4625. };
  4626. DelaySubscriber.prototype._next = function (value) {
  4627. this.scheduleNotification(Notification.createNext(value));
  4628. };
  4629. DelaySubscriber.prototype._error = function (err) {
  4630. this.errored = true;
  4631. this.queue = [];
  4632. this.destination.error(err);
  4633. this.unsubscribe();
  4634. };
  4635. DelaySubscriber.prototype._complete = function () {
  4636. this.scheduleNotification(Notification.createComplete());
  4637. this.unsubscribe();
  4638. };
  4639. return DelaySubscriber;
  4640. }(Subscriber));
  4641. var DelayMessage = (function () {
  4642. function DelayMessage(time, notification) {
  4643. this.time = time;
  4644. this.notification = notification;
  4645. }
  4646. return DelayMessage;
  4647. }());
  4648. function delayWhen(delayDurationSelector, subscriptionDelay) {
  4649. if (subscriptionDelay) {
  4650. return function (source) {
  4651. return new SubscriptionDelayObservable(source, subscriptionDelay)
  4652. .lift(new DelayWhenOperator(delayDurationSelector));
  4653. };
  4654. }
  4655. return function (source) { return source.lift(new DelayWhenOperator(delayDurationSelector)); };
  4656. }
  4657. var DelayWhenOperator = (function () {
  4658. function DelayWhenOperator(delayDurationSelector) {
  4659. this.delayDurationSelector = delayDurationSelector;
  4660. }
  4661. DelayWhenOperator.prototype.call = function (subscriber, source) {
  4662. return source.subscribe(new DelayWhenSubscriber(subscriber, this.delayDurationSelector));
  4663. };
  4664. return DelayWhenOperator;
  4665. }());
  4666. var DelayWhenSubscriber = (function (_super) {
  4667. __extends(DelayWhenSubscriber, _super);
  4668. function DelayWhenSubscriber(destination, delayDurationSelector) {
  4669. var _this = _super.call(this, destination) || this;
  4670. _this.delayDurationSelector = delayDurationSelector;
  4671. _this.completed = false;
  4672. _this.delayNotifierSubscriptions = [];
  4673. _this.index = 0;
  4674. return _this;
  4675. }
  4676. DelayWhenSubscriber.prototype.notifyNext = function (outerValue, innerValue, outerIndex, innerIndex, innerSub) {
  4677. this.destination.next(outerValue);
  4678. this.removeSubscription(innerSub);
  4679. this.tryComplete();
  4680. };
  4681. DelayWhenSubscriber.prototype.notifyError = function (error, innerSub) {
  4682. this._error(error);
  4683. };
  4684. DelayWhenSubscriber.prototype.notifyComplete = function (innerSub) {
  4685. var value = this.removeSubscription(innerSub);
  4686. if (value) {
  4687. this.destination.next(value);
  4688. }
  4689. this.tryComplete();
  4690. };
  4691. DelayWhenSubscriber.prototype._next = function (value) {
  4692. var index = this.index++;
  4693. try {
  4694. var delayNotifier = this.delayDurationSelector(value, index);
  4695. if (delayNotifier) {
  4696. this.tryDelay(delayNotifier, value);
  4697. }
  4698. }
  4699. catch (err) {
  4700. this.destination.error(err);
  4701. }
  4702. };
  4703. DelayWhenSubscriber.prototype._complete = function () {
  4704. this.completed = true;
  4705. this.tryComplete();
  4706. this.unsubscribe();
  4707. };
  4708. DelayWhenSubscriber.prototype.removeSubscription = function (subscription) {
  4709. subscription.unsubscribe();
  4710. var subscriptionIdx = this.delayNotifierSubscriptions.indexOf(subscription);
  4711. if (subscriptionIdx !== -1) {
  4712. this.delayNotifierSubscriptions.splice(subscriptionIdx, 1);
  4713. }
  4714. return subscription.outerValue;
  4715. };
  4716. DelayWhenSubscriber.prototype.tryDelay = function (delayNotifier, value) {
  4717. var notifierSubscription = subscribeToResult(this, delayNotifier, value);
  4718. if (notifierSubscription && !notifierSubscription.closed) {
  4719. var destination = this.destination;
  4720. destination.add(notifierSubscription);
  4721. this.delayNotifierSubscriptions.push(notifierSubscription);
  4722. }
  4723. };
  4724. DelayWhenSubscriber.prototype.tryComplete = function () {
  4725. if (this.completed && this.delayNotifierSubscriptions.length === 0) {
  4726. this.destination.complete();
  4727. }
  4728. };
  4729. return DelayWhenSubscriber;
  4730. }(OuterSubscriber));
  4731. var SubscriptionDelayObservable = (function (_super) {
  4732. __extends(SubscriptionDelayObservable, _super);
  4733. function SubscriptionDelayObservable(source, subscriptionDelay) {
  4734. var _this = _super.call(this) || this;
  4735. _this.source = source;
  4736. _this.subscriptionDelay = subscriptionDelay;
  4737. return _this;
  4738. }
  4739. SubscriptionDelayObservable.prototype._subscribe = function (subscriber) {
  4740. this.subscriptionDelay.subscribe(new SubscriptionDelaySubscriber(subscriber, this.source));
  4741. };
  4742. return SubscriptionDelayObservable;
  4743. }(Observable));
  4744. var SubscriptionDelaySubscriber = (function (_super) {
  4745. __extends(SubscriptionDelaySubscriber, _super);
  4746. function SubscriptionDelaySubscriber(parent, source) {
  4747. var _this = _super.call(this) || this;
  4748. _this.parent = parent;
  4749. _this.source = source;
  4750. _this.sourceSubscribed = false;
  4751. return _this;
  4752. }
  4753. SubscriptionDelaySubscriber.prototype._next = function (unused) {
  4754. this.subscribeToSource();
  4755. };
  4756. SubscriptionDelaySubscriber.prototype._error = function (err) {
  4757. this.unsubscribe();
  4758. this.parent.error(err);
  4759. };
  4760. SubscriptionDelaySubscriber.prototype._complete = function () {
  4761. this.unsubscribe();
  4762. this.subscribeToSource();
  4763. };
  4764. SubscriptionDelaySubscriber.prototype.subscribeToSource = function () {
  4765. if (!this.sourceSubscribed) {
  4766. this.sourceSubscribed = true;
  4767. this.unsubscribe();
  4768. this.source.subscribe(this.parent);
  4769. }
  4770. };
  4771. return SubscriptionDelaySubscriber;
  4772. }(Subscriber));
  4773. function dematerialize() {
  4774. return function dematerializeOperatorFunction(source) {
  4775. return source.lift(new DeMaterializeOperator());
  4776. };
  4777. }
  4778. var DeMaterializeOperator = (function () {
  4779. function DeMaterializeOperator() {
  4780. }
  4781. DeMaterializeOperator.prototype.call = function (subscriber, source) {
  4782. return source.subscribe(new DeMaterializeSubscriber(subscriber));
  4783. };
  4784. return DeMaterializeOperator;
  4785. }());
  4786. var DeMaterializeSubscriber = (function (_super) {
  4787. __extends(DeMaterializeSubscriber, _super);
  4788. function DeMaterializeSubscriber(destination) {
  4789. return _super.call(this, destination) || this;
  4790. }
  4791. DeMaterializeSubscriber.prototype._next = function (value) {
  4792. value.observe(this.destination);
  4793. };
  4794. return DeMaterializeSubscriber;
  4795. }(Subscriber));
  4796. function distinct(keySelector, flushes) {
  4797. return function (source) { return source.lift(new DistinctOperator(keySelector, flushes)); };
  4798. }
  4799. var DistinctOperator = (function () {
  4800. function DistinctOperator(keySelector, flushes) {
  4801. this.keySelector = keySelector;
  4802. this.flushes = flushes;
  4803. }
  4804. DistinctOperator.prototype.call = function (subscriber, source) {
  4805. return source.subscribe(new DistinctSubscriber(subscriber, this.keySelector, this.flushes));
  4806. };
  4807. return DistinctOperator;
  4808. }());
  4809. var DistinctSubscriber = (function (_super) {
  4810. __extends(DistinctSubscriber, _super);
  4811. function DistinctSubscriber(destination, keySelector, flushes) {
  4812. var _this = _super.call(this, destination) || this;
  4813. _this.keySelector = keySelector;
  4814. _this.values = new Set();
  4815. if (flushes) {
  4816. _this.add(subscribeToResult(_this, flushes));
  4817. }
  4818. return _this;
  4819. }
  4820. DistinctSubscriber.prototype.notifyNext = function (outerValue, innerValue, outerIndex, innerIndex, innerSub) {
  4821. this.values.clear();
  4822. };
  4823. DistinctSubscriber.prototype.notifyError = function (error, innerSub) {
  4824. this._error(error);
  4825. };
  4826. DistinctSubscriber.prototype._next = function (value) {
  4827. if (this.keySelector) {
  4828. this._useKeySelector(value);
  4829. }
  4830. else {
  4831. this._finalizeNext(value, value);
  4832. }
  4833. };
  4834. DistinctSubscriber.prototype._useKeySelector = function (value) {
  4835. var key;
  4836. var destination = this.destination;
  4837. try {
  4838. key = this.keySelector(value);
  4839. }
  4840. catch (err) {
  4841. destination.error(err);
  4842. return;
  4843. }
  4844. this._finalizeNext(key, value);
  4845. };
  4846. DistinctSubscriber.prototype._finalizeNext = function (key, value) {
  4847. var values = this.values;
  4848. if (!values.has(key)) {
  4849. values.add(key);
  4850. this.destination.next(value);
  4851. }
  4852. };
  4853. return DistinctSubscriber;
  4854. }(OuterSubscriber));
  4855. function distinctUntilChanged(compare, keySelector) {
  4856. return function (source) { return source.lift(new DistinctUntilChangedOperator(compare, keySelector)); };
  4857. }
  4858. var DistinctUntilChangedOperator = (function () {
  4859. function DistinctUntilChangedOperator(compare, keySelector) {
  4860. this.compare = compare;
  4861. this.keySelector = keySelector;
  4862. }
  4863. DistinctUntilChangedOperator.prototype.call = function (subscriber, source) {
  4864. return source.subscribe(new DistinctUntilChangedSubscriber(subscriber, this.compare, this.keySelector));
  4865. };
  4866. return DistinctUntilChangedOperator;
  4867. }());
  4868. var DistinctUntilChangedSubscriber = (function (_super) {
  4869. __extends(DistinctUntilChangedSubscriber, _super);
  4870. function DistinctUntilChangedSubscriber(destination, compare, keySelector) {
  4871. var _this = _super.call(this, destination) || this;
  4872. _this.keySelector = keySelector;
  4873. _this.hasKey = false;
  4874. if (typeof compare === 'function') {
  4875. _this.compare = compare;
  4876. }
  4877. return _this;
  4878. }
  4879. DistinctUntilChangedSubscriber.prototype.compare = function (x, y) {
  4880. return x === y;
  4881. };
  4882. DistinctUntilChangedSubscriber.prototype._next = function (value) {
  4883. var keySelector = this.keySelector;
  4884. var key = value;
  4885. if (keySelector) {
  4886. key = tryCatch(this.keySelector)(value);
  4887. if (key === errorObject) {
  4888. return this.destination.error(errorObject.e);
  4889. }
  4890. }
  4891. var result = false;
  4892. if (this.hasKey) {
  4893. result = tryCatch(this.compare)(this.key, key);
  4894. if (result === errorObject) {
  4895. return this.destination.error(errorObject.e);
  4896. }
  4897. }
  4898. else {
  4899. this.hasKey = true;
  4900. }
  4901. if (Boolean(result) === false) {
  4902. this.key = key;
  4903. this.destination.next(value);
  4904. }
  4905. };
  4906. return DistinctUntilChangedSubscriber;
  4907. }(Subscriber));
  4908. function distinctUntilKeyChanged(key, compare) {
  4909. return distinctUntilChanged(function (x, y) { return compare ? compare(x[key], y[key]) : x[key] === y[key]; });
  4910. }
  4911. function filter(predicate, thisArg) {
  4912. return function filterOperatorFunction(source) {
  4913. return source.lift(new FilterOperator(predicate, thisArg));
  4914. };
  4915. }
  4916. var FilterOperator = (function () {
  4917. function FilterOperator(predicate, thisArg) {
  4918. this.predicate = predicate;
  4919. this.thisArg = thisArg;
  4920. }
  4921. FilterOperator.prototype.call = function (subscriber, source) {
  4922. return source.subscribe(new FilterSubscriber(subscriber, this.predicate, this.thisArg));
  4923. };
  4924. return FilterOperator;
  4925. }());
  4926. var FilterSubscriber = (function (_super) {
  4927. __extends(FilterSubscriber, _super);
  4928. function FilterSubscriber(destination, predicate, thisArg) {
  4929. var _this = _super.call(this, destination) || this;
  4930. _this.predicate = predicate;
  4931. _this.thisArg = thisArg;
  4932. _this.count = 0;
  4933. return _this;
  4934. }
  4935. FilterSubscriber.prototype._next = function (value) {
  4936. var result;
  4937. try {
  4938. result = this.predicate.call(this.thisArg, value, this.count++);
  4939. }
  4940. catch (err) {
  4941. this.destination.error(err);
  4942. return;
  4943. }
  4944. if (result) {
  4945. this.destination.next(value);
  4946. }
  4947. };
  4948. return FilterSubscriber;
  4949. }(Subscriber));
  4950. function tap(nextOrObserver, error, complete) {
  4951. return function tapOperatorFunction(source) {
  4952. return source.lift(new DoOperator(nextOrObserver, error, complete));
  4953. };
  4954. }
  4955. var DoOperator = (function () {
  4956. function DoOperator(nextOrObserver, error, complete) {
  4957. this.nextOrObserver = nextOrObserver;
  4958. this.error = error;
  4959. this.complete = complete;
  4960. }
  4961. DoOperator.prototype.call = function (subscriber, source) {
  4962. return source.subscribe(new TapSubscriber(subscriber, this.nextOrObserver, this.error, this.complete));
  4963. };
  4964. return DoOperator;
  4965. }());
  4966. var TapSubscriber = (function (_super) {
  4967. __extends(TapSubscriber, _super);
  4968. function TapSubscriber(destination, observerOrNext, error, complete) {
  4969. var _this = _super.call(this, destination) || this;
  4970. _this._tapNext = noop;
  4971. _this._tapError = noop;
  4972. _this._tapComplete = noop;
  4973. _this._tapError = error || noop;
  4974. _this._tapComplete = complete || noop;
  4975. if (isFunction(observerOrNext)) {
  4976. _this._context = _this;
  4977. _this._tapNext = observerOrNext;
  4978. }
  4979. else if (observerOrNext) {
  4980. _this._context = observerOrNext;
  4981. _this._tapNext = observerOrNext.next || noop;
  4982. _this._tapError = observerOrNext.error || noop;
  4983. _this._tapComplete = observerOrNext.complete || noop;
  4984. }
  4985. return _this;
  4986. }
  4987. TapSubscriber.prototype._next = function (value) {
  4988. try {
  4989. this._tapNext.call(this._context, value);
  4990. }
  4991. catch (err) {
  4992. this.destination.error(err);
  4993. return;
  4994. }
  4995. this.destination.next(value);
  4996. };
  4997. TapSubscriber.prototype._error = function (err) {
  4998. try {
  4999. this._tapError.call(this._context, err);
  5000. }
  5001. catch (err) {
  5002. this.destination.error(err);
  5003. return;
  5004. }
  5005. this.destination.error(err);
  5006. };
  5007. TapSubscriber.prototype._complete = function () {
  5008. try {
  5009. this._tapComplete.call(this._context);
  5010. }
  5011. catch (err) {
  5012. this.destination.error(err);
  5013. return;
  5014. }
  5015. return this.destination.complete();
  5016. };
  5017. return TapSubscriber;
  5018. }(Subscriber));
  5019. var throwIfEmpty = function (errorFactory) {
  5020. if (errorFactory === void 0) { errorFactory = defaultErrorFactory; }
  5021. return tap({
  5022. hasValue: false,
  5023. next: function () { this.hasValue = true; },
  5024. complete: function () {
  5025. if (!this.hasValue) {
  5026. throw errorFactory();
  5027. }
  5028. }
  5029. });
  5030. };
  5031. function defaultErrorFactory() {
  5032. return new EmptyError();
  5033. }
  5034. function take(count) {
  5035. return function (source) {
  5036. if (count === 0) {
  5037. return empty$1();
  5038. }
  5039. else {
  5040. return source.lift(new TakeOperator(count));
  5041. }
  5042. };
  5043. }
  5044. var TakeOperator = (function () {
  5045. function TakeOperator(total) {
  5046. this.total = total;
  5047. if (this.total < 0) {
  5048. throw new ArgumentOutOfRangeError;
  5049. }
  5050. }
  5051. TakeOperator.prototype.call = function (subscriber, source) {
  5052. return source.subscribe(new TakeSubscriber(subscriber, this.total));
  5053. };
  5054. return TakeOperator;
  5055. }());
  5056. var TakeSubscriber = (function (_super) {
  5057. __extends(TakeSubscriber, _super);
  5058. function TakeSubscriber(destination, total) {
  5059. var _this = _super.call(this, destination) || this;
  5060. _this.total = total;
  5061. _this.count = 0;
  5062. return _this;
  5063. }
  5064. TakeSubscriber.prototype._next = function (value) {
  5065. var total = this.total;
  5066. var count = ++this.count;
  5067. if (count <= total) {
  5068. this.destination.next(value);
  5069. if (count === total) {
  5070. this.destination.complete();
  5071. this.unsubscribe();
  5072. }
  5073. }
  5074. };
  5075. return TakeSubscriber;
  5076. }(Subscriber));
  5077. function elementAt(index, defaultValue) {
  5078. if (index < 0) {
  5079. throw new ArgumentOutOfRangeError();
  5080. }
  5081. var hasDefaultValue = arguments.length >= 2;
  5082. return function (source) { return source.pipe(filter(function (v, i) { return i === index; }), take(1), hasDefaultValue
  5083. ? defaultIfEmpty(defaultValue)
  5084. : throwIfEmpty(function () { return new ArgumentOutOfRangeError(); })); };
  5085. }
  5086. function endWith() {
  5087. var array = [];
  5088. for (var _i = 0; _i < arguments.length; _i++) {
  5089. array[_i] = arguments[_i];
  5090. }
  5091. return function (source) {
  5092. var scheduler = array[array.length - 1];
  5093. if (isScheduler(scheduler)) {
  5094. array.pop();
  5095. }
  5096. else {
  5097. scheduler = null;
  5098. }
  5099. var len = array.length;
  5100. if (len === 1 && !scheduler) {
  5101. return concat(source, scalar(array[0]));
  5102. }
  5103. else if (len > 0) {
  5104. return concat(source, fromArray(array, scheduler));
  5105. }
  5106. else {
  5107. return concat(source, empty$1(scheduler));
  5108. }
  5109. };
  5110. }
  5111. function every(predicate, thisArg) {
  5112. return function (source) { return source.lift(new EveryOperator(predicate, thisArg, source)); };
  5113. }
  5114. var EveryOperator = (function () {
  5115. function EveryOperator(predicate, thisArg, source) {
  5116. this.predicate = predicate;
  5117. this.thisArg = thisArg;
  5118. this.source = source;
  5119. }
  5120. EveryOperator.prototype.call = function (observer, source) {
  5121. return source.subscribe(new EverySubscriber(observer, this.predicate, this.thisArg, this.source));
  5122. };
  5123. return EveryOperator;
  5124. }());
  5125. var EverySubscriber = (function (_super) {
  5126. __extends(EverySubscriber, _super);
  5127. function EverySubscriber(destination, predicate, thisArg, source) {
  5128. var _this = _super.call(this, destination) || this;
  5129. _this.predicate = predicate;
  5130. _this.thisArg = thisArg;
  5131. _this.source = source;
  5132. _this.index = 0;
  5133. _this.thisArg = thisArg || _this;
  5134. return _this;
  5135. }
  5136. EverySubscriber.prototype.notifyComplete = function (everyValueMatch) {
  5137. this.destination.next(everyValueMatch);
  5138. this.destination.complete();
  5139. };
  5140. EverySubscriber.prototype._next = function (value) {
  5141. var result = false;
  5142. try {
  5143. result = this.predicate.call(this.thisArg, value, this.index++, this.source);
  5144. }
  5145. catch (err) {
  5146. this.destination.error(err);
  5147. return;
  5148. }
  5149. if (!result) {
  5150. this.notifyComplete(false);
  5151. }
  5152. };
  5153. EverySubscriber.prototype._complete = function () {
  5154. this.notifyComplete(true);
  5155. };
  5156. return EverySubscriber;
  5157. }(Subscriber));
  5158. function exhaust() {
  5159. return function (source) { return source.lift(new SwitchFirstOperator()); };
  5160. }
  5161. var SwitchFirstOperator = (function () {
  5162. function SwitchFirstOperator() {
  5163. }
  5164. SwitchFirstOperator.prototype.call = function (subscriber, source) {
  5165. return source.subscribe(new SwitchFirstSubscriber(subscriber));
  5166. };
  5167. return SwitchFirstOperator;
  5168. }());
  5169. var SwitchFirstSubscriber = (function (_super) {
  5170. __extends(SwitchFirstSubscriber, _super);
  5171. function SwitchFirstSubscriber(destination) {
  5172. var _this = _super.call(this, destination) || this;
  5173. _this.hasCompleted = false;
  5174. _this.hasSubscription = false;
  5175. return _this;
  5176. }
  5177. SwitchFirstSubscriber.prototype._next = function (value) {
  5178. if (!this.hasSubscription) {
  5179. this.hasSubscription = true;
  5180. this.add(subscribeToResult(this, value));
  5181. }
  5182. };
  5183. SwitchFirstSubscriber.prototype._complete = function () {
  5184. this.hasCompleted = true;
  5185. if (!this.hasSubscription) {
  5186. this.destination.complete();
  5187. }
  5188. };
  5189. SwitchFirstSubscriber.prototype.notifyComplete = function (innerSub) {
  5190. this.remove(innerSub);
  5191. this.hasSubscription = false;
  5192. if (this.hasCompleted) {
  5193. this.destination.complete();
  5194. }
  5195. };
  5196. return SwitchFirstSubscriber;
  5197. }(OuterSubscriber));
  5198. function exhaustMap(project, resultSelector) {
  5199. if (resultSelector) {
  5200. return function (source) { return source.pipe(exhaustMap(function (a, i) { return from(project(a, i)).pipe(map(function (b, ii) { return resultSelector(a, b, i, ii); })); })); };
  5201. }
  5202. return function (source) {
  5203. return source.lift(new ExhauseMapOperator(project));
  5204. };
  5205. }
  5206. var ExhauseMapOperator = (function () {
  5207. function ExhauseMapOperator(project) {
  5208. this.project = project;
  5209. }
  5210. ExhauseMapOperator.prototype.call = function (subscriber, source) {
  5211. return source.subscribe(new ExhaustMapSubscriber(subscriber, this.project));
  5212. };
  5213. return ExhauseMapOperator;
  5214. }());
  5215. var ExhaustMapSubscriber = (function (_super) {
  5216. __extends(ExhaustMapSubscriber, _super);
  5217. function ExhaustMapSubscriber(destination, project) {
  5218. var _this = _super.call(this, destination) || this;
  5219. _this.project = project;
  5220. _this.hasSubscription = false;
  5221. _this.hasCompleted = false;
  5222. _this.index = 0;
  5223. return _this;
  5224. }
  5225. ExhaustMapSubscriber.prototype._next = function (value) {
  5226. if (!this.hasSubscription) {
  5227. this.tryNext(value);
  5228. }
  5229. };
  5230. ExhaustMapSubscriber.prototype.tryNext = function (value) {
  5231. var result;
  5232. var index = this.index++;
  5233. try {
  5234. result = this.project(value, index);
  5235. }
  5236. catch (err) {
  5237. this.destination.error(err);
  5238. return;
  5239. }
  5240. this.hasSubscription = true;
  5241. this._innerSub(result, value, index);
  5242. };
  5243. ExhaustMapSubscriber.prototype._innerSub = function (result, value, index) {
  5244. var innerSubscriber = new InnerSubscriber(this, undefined, undefined);
  5245. var destination = this.destination;
  5246. destination.add(innerSubscriber);
  5247. subscribeToResult(this, result, value, index, innerSubscriber);
  5248. };
  5249. ExhaustMapSubscriber.prototype._complete = function () {
  5250. this.hasCompleted = true;
  5251. if (!this.hasSubscription) {
  5252. this.destination.complete();
  5253. }
  5254. this.unsubscribe();
  5255. };
  5256. ExhaustMapSubscriber.prototype.notifyNext = function (outerValue, innerValue, outerIndex, innerIndex, innerSub) {
  5257. this.destination.next(innerValue);
  5258. };
  5259. ExhaustMapSubscriber.prototype.notifyError = function (err) {
  5260. this.destination.error(err);
  5261. };
  5262. ExhaustMapSubscriber.prototype.notifyComplete = function (innerSub) {
  5263. var destination = this.destination;
  5264. destination.remove(innerSub);
  5265. this.hasSubscription = false;
  5266. if (this.hasCompleted) {
  5267. this.destination.complete();
  5268. }
  5269. };
  5270. return ExhaustMapSubscriber;
  5271. }(OuterSubscriber));
  5272. function expand(project, concurrent, scheduler) {
  5273. if (concurrent === void 0) { concurrent = Number.POSITIVE_INFINITY; }
  5274. if (scheduler === void 0) { scheduler = undefined; }
  5275. concurrent = (concurrent || 0) < 1 ? Number.POSITIVE_INFINITY : concurrent;
  5276. return function (source) { return source.lift(new ExpandOperator(project, concurrent, scheduler)); };
  5277. }
  5278. var ExpandOperator = (function () {
  5279. function ExpandOperator(project, concurrent, scheduler) {
  5280. this.project = project;
  5281. this.concurrent = concurrent;
  5282. this.scheduler = scheduler;
  5283. }
  5284. ExpandOperator.prototype.call = function (subscriber, source) {
  5285. return source.subscribe(new ExpandSubscriber(subscriber, this.project, this.concurrent, this.scheduler));
  5286. };
  5287. return ExpandOperator;
  5288. }());
  5289. var ExpandSubscriber = (function (_super) {
  5290. __extends(ExpandSubscriber, _super);
  5291. function ExpandSubscriber(destination, project, concurrent, scheduler) {
  5292. var _this = _super.call(this, destination) || this;
  5293. _this.project = project;
  5294. _this.concurrent = concurrent;
  5295. _this.scheduler = scheduler;
  5296. _this.index = 0;
  5297. _this.active = 0;
  5298. _this.hasCompleted = false;
  5299. if (concurrent < Number.POSITIVE_INFINITY) {
  5300. _this.buffer = [];
  5301. }
  5302. return _this;
  5303. }
  5304. ExpandSubscriber.dispatch = function (arg) {
  5305. var subscriber = arg.subscriber, result = arg.result, value = arg.value, index = arg.index;
  5306. subscriber.subscribeToProjection(result, value, index);
  5307. };
  5308. ExpandSubscriber.prototype._next = function (value) {
  5309. var destination = this.destination;
  5310. if (destination.closed) {
  5311. this._complete();
  5312. return;
  5313. }
  5314. var index = this.index++;
  5315. if (this.active < this.concurrent) {
  5316. destination.next(value);
  5317. var result = tryCatch(this.project)(value, index);
  5318. if (result === errorObject) {
  5319. destination.error(errorObject.e);
  5320. }
  5321. else if (!this.scheduler) {
  5322. this.subscribeToProjection(result, value, index);
  5323. }
  5324. else {
  5325. var state = { subscriber: this, result: result, value: value, index: index };
  5326. var destination_1 = this.destination;
  5327. destination_1.add(this.scheduler.schedule(ExpandSubscriber.dispatch, 0, state));
  5328. }
  5329. }
  5330. else {
  5331. this.buffer.push(value);
  5332. }
  5333. };
  5334. ExpandSubscriber.prototype.subscribeToProjection = function (result, value, index) {
  5335. this.active++;
  5336. var destination = this.destination;
  5337. destination.add(subscribeToResult(this, result, value, index));
  5338. };
  5339. ExpandSubscriber.prototype._complete = function () {
  5340. this.hasCompleted = true;
  5341. if (this.hasCompleted && this.active === 0) {
  5342. this.destination.complete();
  5343. }
  5344. this.unsubscribe();
  5345. };
  5346. ExpandSubscriber.prototype.notifyNext = function (outerValue, innerValue, outerIndex, innerIndex, innerSub) {
  5347. this._next(innerValue);
  5348. };
  5349. ExpandSubscriber.prototype.notifyComplete = function (innerSub) {
  5350. var buffer = this.buffer;
  5351. var destination = this.destination;
  5352. destination.remove(innerSub);
  5353. this.active--;
  5354. if (buffer && buffer.length > 0) {
  5355. this._next(buffer.shift());
  5356. }
  5357. if (this.hasCompleted && this.active === 0) {
  5358. this.destination.complete();
  5359. }
  5360. };
  5361. return ExpandSubscriber;
  5362. }(OuterSubscriber));
  5363. function finalize(callback) {
  5364. return function (source) { return source.lift(new FinallyOperator(callback)); };
  5365. }
  5366. var FinallyOperator = (function () {
  5367. function FinallyOperator(callback) {
  5368. this.callback = callback;
  5369. }
  5370. FinallyOperator.prototype.call = function (subscriber, source) {
  5371. return source.subscribe(new FinallySubscriber(subscriber, this.callback));
  5372. };
  5373. return FinallyOperator;
  5374. }());
  5375. var FinallySubscriber = (function (_super) {
  5376. __extends(FinallySubscriber, _super);
  5377. function FinallySubscriber(destination, callback) {
  5378. var _this = _super.call(this, destination) || this;
  5379. _this.add(new Subscription(callback));
  5380. return _this;
  5381. }
  5382. return FinallySubscriber;
  5383. }(Subscriber));
  5384. function find(predicate, thisArg) {
  5385. if (typeof predicate !== 'function') {
  5386. throw new TypeError('predicate is not a function');
  5387. }
  5388. return function (source) { return source.lift(new FindValueOperator(predicate, source, false, thisArg)); };
  5389. }
  5390. var FindValueOperator = (function () {
  5391. function FindValueOperator(predicate, source, yieldIndex, thisArg) {
  5392. this.predicate = predicate;
  5393. this.source = source;
  5394. this.yieldIndex = yieldIndex;
  5395. this.thisArg = thisArg;
  5396. }
  5397. FindValueOperator.prototype.call = function (observer, source) {
  5398. return source.subscribe(new FindValueSubscriber(observer, this.predicate, this.source, this.yieldIndex, this.thisArg));
  5399. };
  5400. return FindValueOperator;
  5401. }());
  5402. var FindValueSubscriber = (function (_super) {
  5403. __extends(FindValueSubscriber, _super);
  5404. function FindValueSubscriber(destination, predicate, source, yieldIndex, thisArg) {
  5405. var _this = _super.call(this, destination) || this;
  5406. _this.predicate = predicate;
  5407. _this.source = source;
  5408. _this.yieldIndex = yieldIndex;
  5409. _this.thisArg = thisArg;
  5410. _this.index = 0;
  5411. return _this;
  5412. }
  5413. FindValueSubscriber.prototype.notifyComplete = function (value) {
  5414. var destination = this.destination;
  5415. destination.next(value);
  5416. destination.complete();
  5417. this.unsubscribe();
  5418. };
  5419. FindValueSubscriber.prototype._next = function (value) {
  5420. var _a = this, predicate = _a.predicate, thisArg = _a.thisArg;
  5421. var index = this.index++;
  5422. try {
  5423. var result = predicate.call(thisArg || this, value, index, this.source);
  5424. if (result) {
  5425. this.notifyComplete(this.yieldIndex ? index : value);
  5426. }
  5427. }
  5428. catch (err) {
  5429. this.destination.error(err);
  5430. }
  5431. };
  5432. FindValueSubscriber.prototype._complete = function () {
  5433. this.notifyComplete(this.yieldIndex ? -1 : undefined);
  5434. };
  5435. return FindValueSubscriber;
  5436. }(Subscriber));
  5437. function findIndex(predicate, thisArg) {
  5438. return function (source) { return source.lift(new FindValueOperator(predicate, source, true, thisArg)); };
  5439. }
  5440. function first(predicate, defaultValue) {
  5441. var hasDefaultValue = arguments.length >= 2;
  5442. return function (source) { return source.pipe(predicate ? filter(function (v, i) { return predicate(v, i, source); }) : identity, take(1), hasDefaultValue ? defaultIfEmpty(defaultValue) : throwIfEmpty(function () { return new EmptyError(); })); };
  5443. }
  5444. function ignoreElements() {
  5445. return function ignoreElementsOperatorFunction(source) {
  5446. return source.lift(new IgnoreElementsOperator());
  5447. };
  5448. }
  5449. var IgnoreElementsOperator = (function () {
  5450. function IgnoreElementsOperator() {
  5451. }
  5452. IgnoreElementsOperator.prototype.call = function (subscriber, source) {
  5453. return source.subscribe(new IgnoreElementsSubscriber(subscriber));
  5454. };
  5455. return IgnoreElementsOperator;
  5456. }());
  5457. var IgnoreElementsSubscriber = (function (_super) {
  5458. __extends(IgnoreElementsSubscriber, _super);
  5459. function IgnoreElementsSubscriber() {
  5460. return _super !== null && _super.apply(this, arguments) || this;
  5461. }
  5462. IgnoreElementsSubscriber.prototype._next = function (unused) {
  5463. };
  5464. return IgnoreElementsSubscriber;
  5465. }(Subscriber));
  5466. function isEmpty() {
  5467. return function (source) { return source.lift(new IsEmptyOperator()); };
  5468. }
  5469. var IsEmptyOperator = (function () {
  5470. function IsEmptyOperator() {
  5471. }
  5472. IsEmptyOperator.prototype.call = function (observer, source) {
  5473. return source.subscribe(new IsEmptySubscriber(observer));
  5474. };
  5475. return IsEmptyOperator;
  5476. }());
  5477. var IsEmptySubscriber = (function (_super) {
  5478. __extends(IsEmptySubscriber, _super);
  5479. function IsEmptySubscriber(destination) {
  5480. return _super.call(this, destination) || this;
  5481. }
  5482. IsEmptySubscriber.prototype.notifyComplete = function (isEmpty) {
  5483. var destination = this.destination;
  5484. destination.next(isEmpty);
  5485. destination.complete();
  5486. };
  5487. IsEmptySubscriber.prototype._next = function (value) {
  5488. this.notifyComplete(false);
  5489. };
  5490. IsEmptySubscriber.prototype._complete = function () {
  5491. this.notifyComplete(true);
  5492. };
  5493. return IsEmptySubscriber;
  5494. }(Subscriber));
  5495. function takeLast(count) {
  5496. return function takeLastOperatorFunction(source) {
  5497. if (count === 0) {
  5498. return empty$1();
  5499. }
  5500. else {
  5501. return source.lift(new TakeLastOperator(count));
  5502. }
  5503. };
  5504. }
  5505. var TakeLastOperator = (function () {
  5506. function TakeLastOperator(total) {
  5507. this.total = total;
  5508. if (this.total < 0) {
  5509. throw new ArgumentOutOfRangeError;
  5510. }
  5511. }
  5512. TakeLastOperator.prototype.call = function (subscriber, source) {
  5513. return source.subscribe(new TakeLastSubscriber(subscriber, this.total));
  5514. };
  5515. return TakeLastOperator;
  5516. }());
  5517. var TakeLastSubscriber = (function (_super) {
  5518. __extends(TakeLastSubscriber, _super);
  5519. function TakeLastSubscriber(destination, total) {
  5520. var _this = _super.call(this, destination) || this;
  5521. _this.total = total;
  5522. _this.ring = new Array();
  5523. _this.count = 0;
  5524. return _this;
  5525. }
  5526. TakeLastSubscriber.prototype._next = function (value) {
  5527. var ring = this.ring;
  5528. var total = this.total;
  5529. var count = this.count++;
  5530. if (ring.length < total) {
  5531. ring.push(value);
  5532. }
  5533. else {
  5534. var index = count % total;
  5535. ring[index] = value;
  5536. }
  5537. };
  5538. TakeLastSubscriber.prototype._complete = function () {
  5539. var destination = this.destination;
  5540. var count = this.count;
  5541. if (count > 0) {
  5542. var total = this.count >= this.total ? this.total : this.count;
  5543. var ring = this.ring;
  5544. for (var i = 0; i < total; i++) {
  5545. var idx = (count++) % total;
  5546. destination.next(ring[idx]);
  5547. }
  5548. }
  5549. destination.complete();
  5550. };
  5551. return TakeLastSubscriber;
  5552. }(Subscriber));
  5553. function last(predicate, defaultValue) {
  5554. var hasDefaultValue = arguments.length >= 2;
  5555. return function (source) { return source.pipe(predicate ? filter(function (v, i) { return predicate(v, i, source); }) : identity, takeLast(1), hasDefaultValue ? defaultIfEmpty(defaultValue) : throwIfEmpty(function () { return new EmptyError(); })); };
  5556. }
  5557. function mapTo(value) {
  5558. return function (source) { return source.lift(new MapToOperator(value)); };
  5559. }
  5560. var MapToOperator = (function () {
  5561. function MapToOperator(value) {
  5562. this.value = value;
  5563. }
  5564. MapToOperator.prototype.call = function (subscriber, source) {
  5565. return source.subscribe(new MapToSubscriber(subscriber, this.value));
  5566. };
  5567. return MapToOperator;
  5568. }());
  5569. var MapToSubscriber = (function (_super) {
  5570. __extends(MapToSubscriber, _super);
  5571. function MapToSubscriber(destination, value) {
  5572. var _this = _super.call(this, destination) || this;
  5573. _this.value = value;
  5574. return _this;
  5575. }
  5576. MapToSubscriber.prototype._next = function (x) {
  5577. this.destination.next(this.value);
  5578. };
  5579. return MapToSubscriber;
  5580. }(Subscriber));
  5581. function materialize() {
  5582. return function materializeOperatorFunction(source) {
  5583. return source.lift(new MaterializeOperator());
  5584. };
  5585. }
  5586. var MaterializeOperator = (function () {
  5587. function MaterializeOperator() {
  5588. }
  5589. MaterializeOperator.prototype.call = function (subscriber, source) {
  5590. return source.subscribe(new MaterializeSubscriber(subscriber));
  5591. };
  5592. return MaterializeOperator;
  5593. }());
  5594. var MaterializeSubscriber = (function (_super) {
  5595. __extends(MaterializeSubscriber, _super);
  5596. function MaterializeSubscriber(destination) {
  5597. return _super.call(this, destination) || this;
  5598. }
  5599. MaterializeSubscriber.prototype._next = function (value) {
  5600. this.destination.next(Notification.createNext(value));
  5601. };
  5602. MaterializeSubscriber.prototype._error = function (err) {
  5603. var destination = this.destination;
  5604. destination.next(Notification.createError(err));
  5605. destination.complete();
  5606. };
  5607. MaterializeSubscriber.prototype._complete = function () {
  5608. var destination = this.destination;
  5609. destination.next(Notification.createComplete());
  5610. destination.complete();
  5611. };
  5612. return MaterializeSubscriber;
  5613. }(Subscriber));
  5614. function scan(accumulator, seed) {
  5615. var hasSeed = false;
  5616. if (arguments.length >= 2) {
  5617. hasSeed = true;
  5618. }
  5619. return function scanOperatorFunction(source) {
  5620. return source.lift(new ScanOperator(accumulator, seed, hasSeed));
  5621. };
  5622. }
  5623. var ScanOperator = (function () {
  5624. function ScanOperator(accumulator, seed, hasSeed) {
  5625. if (hasSeed === void 0) { hasSeed = false; }
  5626. this.accumulator = accumulator;
  5627. this.seed = seed;
  5628. this.hasSeed = hasSeed;
  5629. }
  5630. ScanOperator.prototype.call = function (subscriber, source) {
  5631. return source.subscribe(new ScanSubscriber(subscriber, this.accumulator, this.seed, this.hasSeed));
  5632. };
  5633. return ScanOperator;
  5634. }());
  5635. var ScanSubscriber = (function (_super) {
  5636. __extends(ScanSubscriber, _super);
  5637. function ScanSubscriber(destination, accumulator, _seed, hasSeed) {
  5638. var _this = _super.call(this, destination) || this;
  5639. _this.accumulator = accumulator;
  5640. _this._seed = _seed;
  5641. _this.hasSeed = hasSeed;
  5642. _this.index = 0;
  5643. return _this;
  5644. }
  5645. Object.defineProperty(ScanSubscriber.prototype, "seed", {
  5646. get: function () {
  5647. return this._seed;
  5648. },
  5649. set: function (value) {
  5650. this.hasSeed = true;
  5651. this._seed = value;
  5652. },
  5653. enumerable: true,
  5654. configurable: true
  5655. });
  5656. ScanSubscriber.prototype._next = function (value) {
  5657. if (!this.hasSeed) {
  5658. this.seed = value;
  5659. this.destination.next(value);
  5660. }
  5661. else {
  5662. return this._tryNext(value);
  5663. }
  5664. };
  5665. ScanSubscriber.prototype._tryNext = function (value) {
  5666. var index = this.index++;
  5667. var result;
  5668. try {
  5669. result = this.accumulator(this.seed, value, index);
  5670. }
  5671. catch (err) {
  5672. this.destination.error(err);
  5673. }
  5674. this.seed = result;
  5675. this.destination.next(result);
  5676. };
  5677. return ScanSubscriber;
  5678. }(Subscriber));
  5679. function reduce(accumulator, seed) {
  5680. if (arguments.length >= 2) {
  5681. return function reduceOperatorFunctionWithSeed(source) {
  5682. return pipe(scan(accumulator, seed), takeLast(1), defaultIfEmpty(seed))(source);
  5683. };
  5684. }
  5685. return function reduceOperatorFunction(source) {
  5686. return pipe(scan(function (acc, value, index) { return accumulator(acc, value, index + 1); }), takeLast(1))(source);
  5687. };
  5688. }
  5689. function max(comparer) {
  5690. var max = (typeof comparer === 'function')
  5691. ? function (x, y) { return comparer(x, y) > 0 ? x : y; }
  5692. : function (x, y) { return x > y ? x : y; };
  5693. return reduce(max);
  5694. }
  5695. function merge$1() {
  5696. var observables = [];
  5697. for (var _i = 0; _i < arguments.length; _i++) {
  5698. observables[_i] = arguments[_i];
  5699. }
  5700. return function (source) { return source.lift.call(merge.apply(void 0, [source].concat(observables))); };
  5701. }
  5702. function mergeMapTo(innerObservable, resultSelector, concurrent) {
  5703. if (concurrent === void 0) { concurrent = Number.POSITIVE_INFINITY; }
  5704. if (typeof resultSelector === 'function') {
  5705. return mergeMap(function () { return innerObservable; }, resultSelector, concurrent);
  5706. }
  5707. if (typeof resultSelector === 'number') {
  5708. concurrent = resultSelector;
  5709. }
  5710. return mergeMap(function () { return innerObservable; }, concurrent);
  5711. }
  5712. function mergeScan(accumulator, seed, concurrent) {
  5713. if (concurrent === void 0) { concurrent = Number.POSITIVE_INFINITY; }
  5714. return function (source) { return source.lift(new MergeScanOperator(accumulator, seed, concurrent)); };
  5715. }
  5716. var MergeScanOperator = (function () {
  5717. function MergeScanOperator(accumulator, seed, concurrent) {
  5718. this.accumulator = accumulator;
  5719. this.seed = seed;
  5720. this.concurrent = concurrent;
  5721. }
  5722. MergeScanOperator.prototype.call = function (subscriber, source) {
  5723. return source.subscribe(new MergeScanSubscriber(subscriber, this.accumulator, this.seed, this.concurrent));
  5724. };
  5725. return MergeScanOperator;
  5726. }());
  5727. var MergeScanSubscriber = (function (_super) {
  5728. __extends(MergeScanSubscriber, _super);
  5729. function MergeScanSubscriber(destination, accumulator, acc, concurrent) {
  5730. var _this = _super.call(this, destination) || this;
  5731. _this.accumulator = accumulator;
  5732. _this.acc = acc;
  5733. _this.concurrent = concurrent;
  5734. _this.hasValue = false;
  5735. _this.hasCompleted = false;
  5736. _this.buffer = [];
  5737. _this.active = 0;
  5738. _this.index = 0;
  5739. return _this;
  5740. }
  5741. MergeScanSubscriber.prototype._next = function (value) {
  5742. if (this.active < this.concurrent) {
  5743. var index = this.index++;
  5744. var ish = tryCatch(this.accumulator)(this.acc, value);
  5745. var destination = this.destination;
  5746. if (ish === errorObject) {
  5747. destination.error(errorObject.e);
  5748. }
  5749. else {
  5750. this.active++;
  5751. this._innerSub(ish, value, index);
  5752. }
  5753. }
  5754. else {
  5755. this.buffer.push(value);
  5756. }
  5757. };
  5758. MergeScanSubscriber.prototype._innerSub = function (ish, value, index) {
  5759. var innerSubscriber = new InnerSubscriber(this, undefined, undefined);
  5760. var destination = this.destination;
  5761. destination.add(innerSubscriber);
  5762. subscribeToResult(this, ish, value, index, innerSubscriber);
  5763. };
  5764. MergeScanSubscriber.prototype._complete = function () {
  5765. this.hasCompleted = true;
  5766. if (this.active === 0 && this.buffer.length === 0) {
  5767. if (this.hasValue === false) {
  5768. this.destination.next(this.acc);
  5769. }
  5770. this.destination.complete();
  5771. }
  5772. this.unsubscribe();
  5773. };
  5774. MergeScanSubscriber.prototype.notifyNext = function (outerValue, innerValue, outerIndex, innerIndex, innerSub) {
  5775. var destination = this.destination;
  5776. this.acc = innerValue;
  5777. this.hasValue = true;
  5778. destination.next(innerValue);
  5779. };
  5780. MergeScanSubscriber.prototype.notifyComplete = function (innerSub) {
  5781. var buffer = this.buffer;
  5782. var destination = this.destination;
  5783. destination.remove(innerSub);
  5784. this.active--;
  5785. if (buffer.length > 0) {
  5786. this._next(buffer.shift());
  5787. }
  5788. else if (this.active === 0 && this.hasCompleted) {
  5789. if (this.hasValue === false) {
  5790. this.destination.next(this.acc);
  5791. }
  5792. this.destination.complete();
  5793. }
  5794. };
  5795. return MergeScanSubscriber;
  5796. }(OuterSubscriber));
  5797. function min(comparer) {
  5798. var min = (typeof comparer === 'function')
  5799. ? function (x, y) { return comparer(x, y) < 0 ? x : y; }
  5800. : function (x, y) { return x < y ? x : y; };
  5801. return reduce(min);
  5802. }
  5803. function multicast(subjectOrSubjectFactory, selector) {
  5804. return function multicastOperatorFunction(source) {
  5805. var subjectFactory;
  5806. if (typeof subjectOrSubjectFactory === 'function') {
  5807. subjectFactory = subjectOrSubjectFactory;
  5808. }
  5809. else {
  5810. subjectFactory = function subjectFactory() {
  5811. return subjectOrSubjectFactory;
  5812. };
  5813. }
  5814. if (typeof selector === 'function') {
  5815. return source.lift(new MulticastOperator(subjectFactory, selector));
  5816. }
  5817. var connectable = Object.create(source, connectableObservableDescriptor);
  5818. connectable.source = source;
  5819. connectable.subjectFactory = subjectFactory;
  5820. return connectable;
  5821. };
  5822. }
  5823. var MulticastOperator = (function () {
  5824. function MulticastOperator(subjectFactory, selector) {
  5825. this.subjectFactory = subjectFactory;
  5826. this.selector = selector;
  5827. }
  5828. MulticastOperator.prototype.call = function (subscriber, source) {
  5829. var selector = this.selector;
  5830. var subject = this.subjectFactory();
  5831. var subscription = selector(subject).subscribe(subscriber);
  5832. subscription.add(source.subscribe(subject));
  5833. return subscription;
  5834. };
  5835. return MulticastOperator;
  5836. }());
  5837. function onErrorResumeNext$1() {
  5838. var nextSources = [];
  5839. for (var _i = 0; _i < arguments.length; _i++) {
  5840. nextSources[_i] = arguments[_i];
  5841. }
  5842. if (nextSources.length === 1 && isArray(nextSources[0])) {
  5843. nextSources = nextSources[0];
  5844. }
  5845. return function (source) { return source.lift(new OnErrorResumeNextOperator(nextSources)); };
  5846. }
  5847. var OnErrorResumeNextOperator = (function () {
  5848. function OnErrorResumeNextOperator(nextSources) {
  5849. this.nextSources = nextSources;
  5850. }
  5851. OnErrorResumeNextOperator.prototype.call = function (subscriber, source) {
  5852. return source.subscribe(new OnErrorResumeNextSubscriber(subscriber, this.nextSources));
  5853. };
  5854. return OnErrorResumeNextOperator;
  5855. }());
  5856. var OnErrorResumeNextSubscriber = (function (_super) {
  5857. __extends(OnErrorResumeNextSubscriber, _super);
  5858. function OnErrorResumeNextSubscriber(destination, nextSources) {
  5859. var _this = _super.call(this, destination) || this;
  5860. _this.destination = destination;
  5861. _this.nextSources = nextSources;
  5862. return _this;
  5863. }
  5864. OnErrorResumeNextSubscriber.prototype.notifyError = function (error, innerSub) {
  5865. this.subscribeToNextSource();
  5866. };
  5867. OnErrorResumeNextSubscriber.prototype.notifyComplete = function (innerSub) {
  5868. this.subscribeToNextSource();
  5869. };
  5870. OnErrorResumeNextSubscriber.prototype._error = function (err) {
  5871. this.subscribeToNextSource();
  5872. this.unsubscribe();
  5873. };
  5874. OnErrorResumeNextSubscriber.prototype._complete = function () {
  5875. this.subscribeToNextSource();
  5876. this.unsubscribe();
  5877. };
  5878. OnErrorResumeNextSubscriber.prototype.subscribeToNextSource = function () {
  5879. var next = this.nextSources.shift();
  5880. if (next) {
  5881. var innerSubscriber = new InnerSubscriber(this, undefined, undefined);
  5882. var destination = this.destination;
  5883. destination.add(innerSubscriber);
  5884. subscribeToResult(this, next, undefined, undefined, innerSubscriber);
  5885. }
  5886. else {
  5887. this.destination.complete();
  5888. }
  5889. };
  5890. return OnErrorResumeNextSubscriber;
  5891. }(OuterSubscriber));
  5892. function pairwise() {
  5893. return function (source) { return source.lift(new PairwiseOperator()); };
  5894. }
  5895. var PairwiseOperator = (function () {
  5896. function PairwiseOperator() {
  5897. }
  5898. PairwiseOperator.prototype.call = function (subscriber, source) {
  5899. return source.subscribe(new PairwiseSubscriber(subscriber));
  5900. };
  5901. return PairwiseOperator;
  5902. }());
  5903. var PairwiseSubscriber = (function (_super) {
  5904. __extends(PairwiseSubscriber, _super);
  5905. function PairwiseSubscriber(destination) {
  5906. var _this = _super.call(this, destination) || this;
  5907. _this.hasPrev = false;
  5908. return _this;
  5909. }
  5910. PairwiseSubscriber.prototype._next = function (value) {
  5911. if (this.hasPrev) {
  5912. this.destination.next([this.prev, value]);
  5913. }
  5914. else {
  5915. this.hasPrev = true;
  5916. }
  5917. this.prev = value;
  5918. };
  5919. return PairwiseSubscriber;
  5920. }(Subscriber));
  5921. function not(pred, thisArg) {
  5922. function notPred() {
  5923. return !(notPred.pred.apply(notPred.thisArg, arguments));
  5924. }
  5925. notPred.pred = pred;
  5926. notPred.thisArg = thisArg;
  5927. return notPred;
  5928. }
  5929. function partition(predicate, thisArg) {
  5930. return function (source) { return [
  5931. filter(predicate, thisArg)(source),
  5932. filter(not(predicate, thisArg))(source)
  5933. ]; };
  5934. }
  5935. function pluck() {
  5936. var properties = [];
  5937. for (var _i = 0; _i < arguments.length; _i++) {
  5938. properties[_i] = arguments[_i];
  5939. }
  5940. var length = properties.length;
  5941. if (length === 0) {
  5942. throw new Error('list of properties cannot be empty.');
  5943. }
  5944. return function (source) { return map(plucker(properties, length))(source); };
  5945. }
  5946. function plucker(props, length) {
  5947. var mapper = function (x) {
  5948. var currentProp = x;
  5949. for (var i = 0; i < length; i++) {
  5950. var p = currentProp[props[i]];
  5951. if (typeof p !== 'undefined') {
  5952. currentProp = p;
  5953. }
  5954. else {
  5955. return undefined;
  5956. }
  5957. }
  5958. return currentProp;
  5959. };
  5960. return mapper;
  5961. }
  5962. function publish(selector) {
  5963. return selector ?
  5964. multicast(function () { return new Subject(); }, selector) :
  5965. multicast(new Subject());
  5966. }
  5967. function publishBehavior(value) {
  5968. return function (source) { return multicast(new BehaviorSubject(value))(source); };
  5969. }
  5970. function publishLast() {
  5971. return function (source) { return multicast(new AsyncSubject())(source); };
  5972. }
  5973. function publishReplay(bufferSize, windowTime, selectorOrScheduler, scheduler) {
  5974. if (selectorOrScheduler && typeof selectorOrScheduler !== 'function') {
  5975. scheduler = selectorOrScheduler;
  5976. }
  5977. var selector = typeof selectorOrScheduler === 'function' ? selectorOrScheduler : undefined;
  5978. var subject = new ReplaySubject(bufferSize, windowTime, scheduler);
  5979. return function (source) { return multicast(function () { return subject; }, selector)(source); };
  5980. }
  5981. function race$1() {
  5982. var observables = [];
  5983. for (var _i = 0; _i < arguments.length; _i++) {
  5984. observables[_i] = arguments[_i];
  5985. }
  5986. return function raceOperatorFunction(source) {
  5987. if (observables.length === 1 && isArray(observables[0])) {
  5988. observables = observables[0];
  5989. }
  5990. return source.lift.call(race.apply(void 0, [source].concat(observables)));
  5991. };
  5992. }
  5993. function repeat(count) {
  5994. if (count === void 0) { count = -1; }
  5995. return function (source) {
  5996. if (count === 0) {
  5997. return empty$1();
  5998. }
  5999. else if (count < 0) {
  6000. return source.lift(new RepeatOperator(-1, source));
  6001. }
  6002. else {
  6003. return source.lift(new RepeatOperator(count - 1, source));
  6004. }
  6005. };
  6006. }
  6007. var RepeatOperator = (function () {
  6008. function RepeatOperator(count, source) {
  6009. this.count = count;
  6010. this.source = source;
  6011. }
  6012. RepeatOperator.prototype.call = function (subscriber, source) {
  6013. return source.subscribe(new RepeatSubscriber(subscriber, this.count, this.source));
  6014. };
  6015. return RepeatOperator;
  6016. }());
  6017. var RepeatSubscriber = (function (_super) {
  6018. __extends(RepeatSubscriber, _super);
  6019. function RepeatSubscriber(destination, count, source) {
  6020. var _this = _super.call(this, destination) || this;
  6021. _this.count = count;
  6022. _this.source = source;
  6023. return _this;
  6024. }
  6025. RepeatSubscriber.prototype.complete = function () {
  6026. if (!this.isStopped) {
  6027. var _a = this, source = _a.source, count = _a.count;
  6028. if (count === 0) {
  6029. return _super.prototype.complete.call(this);
  6030. }
  6031. else if (count > -1) {
  6032. this.count = count - 1;
  6033. }
  6034. source.subscribe(this._unsubscribeAndRecycle());
  6035. }
  6036. };
  6037. return RepeatSubscriber;
  6038. }(Subscriber));
  6039. function repeatWhen(notifier) {
  6040. return function (source) { return source.lift(new RepeatWhenOperator(notifier)); };
  6041. }
  6042. var RepeatWhenOperator = (function () {
  6043. function RepeatWhenOperator(notifier) {
  6044. this.notifier = notifier;
  6045. }
  6046. RepeatWhenOperator.prototype.call = function (subscriber, source) {
  6047. return source.subscribe(new RepeatWhenSubscriber(subscriber, this.notifier, source));
  6048. };
  6049. return RepeatWhenOperator;
  6050. }());
  6051. var RepeatWhenSubscriber = (function (_super) {
  6052. __extends(RepeatWhenSubscriber, _super);
  6053. function RepeatWhenSubscriber(destination, notifier, source) {
  6054. var _this = _super.call(this, destination) || this;
  6055. _this.notifier = notifier;
  6056. _this.source = source;
  6057. _this.sourceIsBeingSubscribedTo = true;
  6058. return _this;
  6059. }
  6060. RepeatWhenSubscriber.prototype.notifyNext = function (outerValue, innerValue, outerIndex, innerIndex, innerSub) {
  6061. this.sourceIsBeingSubscribedTo = true;
  6062. this.source.subscribe(this);
  6063. };
  6064. RepeatWhenSubscriber.prototype.notifyComplete = function (innerSub) {
  6065. if (this.sourceIsBeingSubscribedTo === false) {
  6066. return _super.prototype.complete.call(this);
  6067. }
  6068. };
  6069. RepeatWhenSubscriber.prototype.complete = function () {
  6070. this.sourceIsBeingSubscribedTo = false;
  6071. if (!this.isStopped) {
  6072. if (!this.retries) {
  6073. this.subscribeToRetries();
  6074. }
  6075. if (!this.retriesSubscription || this.retriesSubscription.closed) {
  6076. return _super.prototype.complete.call(this);
  6077. }
  6078. this._unsubscribeAndRecycle();
  6079. this.notifications.next();
  6080. }
  6081. };
  6082. RepeatWhenSubscriber.prototype._unsubscribe = function () {
  6083. var _a = this, notifications = _a.notifications, retriesSubscription = _a.retriesSubscription;
  6084. if (notifications) {
  6085. notifications.unsubscribe();
  6086. this.notifications = null;
  6087. }
  6088. if (retriesSubscription) {
  6089. retriesSubscription.unsubscribe();
  6090. this.retriesSubscription = null;
  6091. }
  6092. this.retries = null;
  6093. };
  6094. RepeatWhenSubscriber.prototype._unsubscribeAndRecycle = function () {
  6095. var _unsubscribe = this._unsubscribe;
  6096. this._unsubscribe = null;
  6097. _super.prototype._unsubscribeAndRecycle.call(this);
  6098. this._unsubscribe = _unsubscribe;
  6099. return this;
  6100. };
  6101. RepeatWhenSubscriber.prototype.subscribeToRetries = function () {
  6102. this.notifications = new Subject();
  6103. var retries = tryCatch(this.notifier)(this.notifications);
  6104. if (retries === errorObject) {
  6105. return _super.prototype.complete.call(this);
  6106. }
  6107. this.retries = retries;
  6108. this.retriesSubscription = subscribeToResult(this, retries);
  6109. };
  6110. return RepeatWhenSubscriber;
  6111. }(OuterSubscriber));
  6112. function retry(count) {
  6113. if (count === void 0) { count = -1; }
  6114. return function (source) { return source.lift(new RetryOperator(count, source)); };
  6115. }
  6116. var RetryOperator = (function () {
  6117. function RetryOperator(count, source) {
  6118. this.count = count;
  6119. this.source = source;
  6120. }
  6121. RetryOperator.prototype.call = function (subscriber, source) {
  6122. return source.subscribe(new RetrySubscriber(subscriber, this.count, this.source));
  6123. };
  6124. return RetryOperator;
  6125. }());
  6126. var RetrySubscriber = (function (_super) {
  6127. __extends(RetrySubscriber, _super);
  6128. function RetrySubscriber(destination, count, source) {
  6129. var _this = _super.call(this, destination) || this;
  6130. _this.count = count;
  6131. _this.source = source;
  6132. return _this;
  6133. }
  6134. RetrySubscriber.prototype.error = function (err) {
  6135. if (!this.isStopped) {
  6136. var _a = this, source = _a.source, count = _a.count;
  6137. if (count === 0) {
  6138. return _super.prototype.error.call(this, err);
  6139. }
  6140. else if (count > -1) {
  6141. this.count = count - 1;
  6142. }
  6143. source.subscribe(this._unsubscribeAndRecycle());
  6144. }
  6145. };
  6146. return RetrySubscriber;
  6147. }(Subscriber));
  6148. function retryWhen(notifier) {
  6149. return function (source) { return source.lift(new RetryWhenOperator(notifier, source)); };
  6150. }
  6151. var RetryWhenOperator = (function () {
  6152. function RetryWhenOperator(notifier, source) {
  6153. this.notifier = notifier;
  6154. this.source = source;
  6155. }
  6156. RetryWhenOperator.prototype.call = function (subscriber, source) {
  6157. return source.subscribe(new RetryWhenSubscriber(subscriber, this.notifier, this.source));
  6158. };
  6159. return RetryWhenOperator;
  6160. }());
  6161. var RetryWhenSubscriber = (function (_super) {
  6162. __extends(RetryWhenSubscriber, _super);
  6163. function RetryWhenSubscriber(destination, notifier, source) {
  6164. var _this = _super.call(this, destination) || this;
  6165. _this.notifier = notifier;
  6166. _this.source = source;
  6167. return _this;
  6168. }
  6169. RetryWhenSubscriber.prototype.error = function (err) {
  6170. if (!this.isStopped) {
  6171. var errors = this.errors;
  6172. var retries = this.retries;
  6173. var retriesSubscription = this.retriesSubscription;
  6174. if (!retries) {
  6175. errors = new Subject();
  6176. retries = tryCatch(this.notifier)(errors);
  6177. if (retries === errorObject) {
  6178. return _super.prototype.error.call(this, errorObject.e);
  6179. }
  6180. retriesSubscription = subscribeToResult(this, retries);
  6181. }
  6182. else {
  6183. this.errors = null;
  6184. this.retriesSubscription = null;
  6185. }
  6186. this._unsubscribeAndRecycle();
  6187. this.errors = errors;
  6188. this.retries = retries;
  6189. this.retriesSubscription = retriesSubscription;
  6190. errors.next(err);
  6191. }
  6192. };
  6193. RetryWhenSubscriber.prototype._unsubscribe = function () {
  6194. var _a = this, errors = _a.errors, retriesSubscription = _a.retriesSubscription;
  6195. if (errors) {
  6196. errors.unsubscribe();
  6197. this.errors = null;
  6198. }
  6199. if (retriesSubscription) {
  6200. retriesSubscription.unsubscribe();
  6201. this.retriesSubscription = null;
  6202. }
  6203. this.retries = null;
  6204. };
  6205. RetryWhenSubscriber.prototype.notifyNext = function (outerValue, innerValue, outerIndex, innerIndex, innerSub) {
  6206. var _unsubscribe = this._unsubscribe;
  6207. this._unsubscribe = null;
  6208. this._unsubscribeAndRecycle();
  6209. this._unsubscribe = _unsubscribe;
  6210. this.source.subscribe(this);
  6211. };
  6212. return RetryWhenSubscriber;
  6213. }(OuterSubscriber));
  6214. function sample(notifier) {
  6215. return function (source) { return source.lift(new SampleOperator(notifier)); };
  6216. }
  6217. var SampleOperator = (function () {
  6218. function SampleOperator(notifier) {
  6219. this.notifier = notifier;
  6220. }
  6221. SampleOperator.prototype.call = function (subscriber, source) {
  6222. var sampleSubscriber = new SampleSubscriber(subscriber);
  6223. var subscription = source.subscribe(sampleSubscriber);
  6224. subscription.add(subscribeToResult(sampleSubscriber, this.notifier));
  6225. return subscription;
  6226. };
  6227. return SampleOperator;
  6228. }());
  6229. var SampleSubscriber = (function (_super) {
  6230. __extends(SampleSubscriber, _super);
  6231. function SampleSubscriber() {
  6232. var _this = _super !== null && _super.apply(this, arguments) || this;
  6233. _this.hasValue = false;
  6234. return _this;
  6235. }
  6236. SampleSubscriber.prototype._next = function (value) {
  6237. this.value = value;
  6238. this.hasValue = true;
  6239. };
  6240. SampleSubscriber.prototype.notifyNext = function (outerValue, innerValue, outerIndex, innerIndex, innerSub) {
  6241. this.emitValue();
  6242. };
  6243. SampleSubscriber.prototype.notifyComplete = function () {
  6244. this.emitValue();
  6245. };
  6246. SampleSubscriber.prototype.emitValue = function () {
  6247. if (this.hasValue) {
  6248. this.hasValue = false;
  6249. this.destination.next(this.value);
  6250. }
  6251. };
  6252. return SampleSubscriber;
  6253. }(OuterSubscriber));
  6254. function sampleTime(period, scheduler) {
  6255. if (scheduler === void 0) { scheduler = async; }
  6256. return function (source) { return source.lift(new SampleTimeOperator(period, scheduler)); };
  6257. }
  6258. var SampleTimeOperator = (function () {
  6259. function SampleTimeOperator(period, scheduler) {
  6260. this.period = period;
  6261. this.scheduler = scheduler;
  6262. }
  6263. SampleTimeOperator.prototype.call = function (subscriber, source) {
  6264. return source.subscribe(new SampleTimeSubscriber(subscriber, this.period, this.scheduler));
  6265. };
  6266. return SampleTimeOperator;
  6267. }());
  6268. var SampleTimeSubscriber = (function (_super) {
  6269. __extends(SampleTimeSubscriber, _super);
  6270. function SampleTimeSubscriber(destination, period, scheduler) {
  6271. var _this = _super.call(this, destination) || this;
  6272. _this.period = period;
  6273. _this.scheduler = scheduler;
  6274. _this.hasValue = false;
  6275. _this.add(scheduler.schedule(dispatchNotification, period, { subscriber: _this, period: period }));
  6276. return _this;
  6277. }
  6278. SampleTimeSubscriber.prototype._next = function (value) {
  6279. this.lastValue = value;
  6280. this.hasValue = true;
  6281. };
  6282. SampleTimeSubscriber.prototype.notifyNext = function () {
  6283. if (this.hasValue) {
  6284. this.hasValue = false;
  6285. this.destination.next(this.lastValue);
  6286. }
  6287. };
  6288. return SampleTimeSubscriber;
  6289. }(Subscriber));
  6290. function dispatchNotification(state) {
  6291. var subscriber = state.subscriber, period = state.period;
  6292. subscriber.notifyNext();
  6293. this.schedule(state, period);
  6294. }
  6295. function sequenceEqual(compareTo, comparor) {
  6296. return function (source) { return source.lift(new SequenceEqualOperator(compareTo, comparor)); };
  6297. }
  6298. var SequenceEqualOperator = (function () {
  6299. function SequenceEqualOperator(compareTo, comparor) {
  6300. this.compareTo = compareTo;
  6301. this.comparor = comparor;
  6302. }
  6303. SequenceEqualOperator.prototype.call = function (subscriber, source) {
  6304. return source.subscribe(new SequenceEqualSubscriber(subscriber, this.compareTo, this.comparor));
  6305. };
  6306. return SequenceEqualOperator;
  6307. }());
  6308. var SequenceEqualSubscriber = (function (_super) {
  6309. __extends(SequenceEqualSubscriber, _super);
  6310. function SequenceEqualSubscriber(destination, compareTo, comparor) {
  6311. var _this = _super.call(this, destination) || this;
  6312. _this.compareTo = compareTo;
  6313. _this.comparor = comparor;
  6314. _this._a = [];
  6315. _this._b = [];
  6316. _this._oneComplete = false;
  6317. _this.destination.add(compareTo.subscribe(new SequenceEqualCompareToSubscriber(destination, _this)));
  6318. return _this;
  6319. }
  6320. SequenceEqualSubscriber.prototype._next = function (value) {
  6321. if (this._oneComplete && this._b.length === 0) {
  6322. this.emit(false);
  6323. }
  6324. else {
  6325. this._a.push(value);
  6326. this.checkValues();
  6327. }
  6328. };
  6329. SequenceEqualSubscriber.prototype._complete = function () {
  6330. if (this._oneComplete) {
  6331. this.emit(this._a.length === 0 && this._b.length === 0);
  6332. }
  6333. else {
  6334. this._oneComplete = true;
  6335. }
  6336. this.unsubscribe();
  6337. };
  6338. SequenceEqualSubscriber.prototype.checkValues = function () {
  6339. var _c = this, _a = _c._a, _b = _c._b, comparor = _c.comparor;
  6340. while (_a.length > 0 && _b.length > 0) {
  6341. var a = _a.shift();
  6342. var b = _b.shift();
  6343. var areEqual = false;
  6344. if (comparor) {
  6345. areEqual = tryCatch(comparor)(a, b);
  6346. if (areEqual === errorObject) {
  6347. this.destination.error(errorObject.e);
  6348. }
  6349. }
  6350. else {
  6351. areEqual = a === b;
  6352. }
  6353. if (!areEqual) {
  6354. this.emit(false);
  6355. }
  6356. }
  6357. };
  6358. SequenceEqualSubscriber.prototype.emit = function (value) {
  6359. var destination = this.destination;
  6360. destination.next(value);
  6361. destination.complete();
  6362. };
  6363. SequenceEqualSubscriber.prototype.nextB = function (value) {
  6364. if (this._oneComplete && this._a.length === 0) {
  6365. this.emit(false);
  6366. }
  6367. else {
  6368. this._b.push(value);
  6369. this.checkValues();
  6370. }
  6371. };
  6372. SequenceEqualSubscriber.prototype.completeB = function () {
  6373. if (this._oneComplete) {
  6374. this.emit(this._a.length === 0 && this._b.length === 0);
  6375. }
  6376. else {
  6377. this._oneComplete = true;
  6378. }
  6379. };
  6380. return SequenceEqualSubscriber;
  6381. }(Subscriber));
  6382. var SequenceEqualCompareToSubscriber = (function (_super) {
  6383. __extends(SequenceEqualCompareToSubscriber, _super);
  6384. function SequenceEqualCompareToSubscriber(destination, parent) {
  6385. var _this = _super.call(this, destination) || this;
  6386. _this.parent = parent;
  6387. return _this;
  6388. }
  6389. SequenceEqualCompareToSubscriber.prototype._next = function (value) {
  6390. this.parent.nextB(value);
  6391. };
  6392. SequenceEqualCompareToSubscriber.prototype._error = function (err) {
  6393. this.parent.error(err);
  6394. this.unsubscribe();
  6395. };
  6396. SequenceEqualCompareToSubscriber.prototype._complete = function () {
  6397. this.parent.completeB();
  6398. this.unsubscribe();
  6399. };
  6400. return SequenceEqualCompareToSubscriber;
  6401. }(Subscriber));
  6402. function shareSubjectFactory() {
  6403. return new Subject();
  6404. }
  6405. function share() {
  6406. return function (source) { return refCount()(multicast(shareSubjectFactory)(source)); };
  6407. }
  6408. function shareReplay(bufferSize, windowTime, scheduler) {
  6409. if (bufferSize === void 0) { bufferSize = Number.POSITIVE_INFINITY; }
  6410. if (windowTime === void 0) { windowTime = Number.POSITIVE_INFINITY; }
  6411. return function (source) { return source.lift(shareReplayOperator(bufferSize, windowTime, scheduler)); };
  6412. }
  6413. function shareReplayOperator(bufferSize, windowTime, scheduler) {
  6414. var subject;
  6415. var refCount = 0;
  6416. var subscription;
  6417. var hasError = false;
  6418. var isComplete = false;
  6419. return function shareReplayOperation(source) {
  6420. refCount++;
  6421. if (!subject || hasError) {
  6422. hasError = false;
  6423. subject = new ReplaySubject(bufferSize, windowTime, scheduler);
  6424. subscription = source.subscribe({
  6425. next: function (value) { subject.next(value); },
  6426. error: function (err) {
  6427. hasError = true;
  6428. subject.error(err);
  6429. },
  6430. complete: function () {
  6431. isComplete = true;
  6432. subject.complete();
  6433. },
  6434. });
  6435. }
  6436. var innerSub = subject.subscribe(this);
  6437. return function () {
  6438. refCount--;
  6439. innerSub.unsubscribe();
  6440. if (subscription && refCount === 0 && isComplete) {
  6441. subscription.unsubscribe();
  6442. }
  6443. };
  6444. };
  6445. }
  6446. function single(predicate) {
  6447. return function (source) { return source.lift(new SingleOperator(predicate, source)); };
  6448. }
  6449. var SingleOperator = (function () {
  6450. function SingleOperator(predicate, source) {
  6451. this.predicate = predicate;
  6452. this.source = source;
  6453. }
  6454. SingleOperator.prototype.call = function (subscriber, source) {
  6455. return source.subscribe(new SingleSubscriber(subscriber, this.predicate, this.source));
  6456. };
  6457. return SingleOperator;
  6458. }());
  6459. var SingleSubscriber = (function (_super) {
  6460. __extends(SingleSubscriber, _super);
  6461. function SingleSubscriber(destination, predicate, source) {
  6462. var _this = _super.call(this, destination) || this;
  6463. _this.predicate = predicate;
  6464. _this.source = source;
  6465. _this.seenValue = false;
  6466. _this.index = 0;
  6467. return _this;
  6468. }
  6469. SingleSubscriber.prototype.applySingleValue = function (value) {
  6470. if (this.seenValue) {
  6471. this.destination.error('Sequence contains more than one element');
  6472. }
  6473. else {
  6474. this.seenValue = true;
  6475. this.singleValue = value;
  6476. }
  6477. };
  6478. SingleSubscriber.prototype._next = function (value) {
  6479. var index = this.index++;
  6480. if (this.predicate) {
  6481. this.tryNext(value, index);
  6482. }
  6483. else {
  6484. this.applySingleValue(value);
  6485. }
  6486. };
  6487. SingleSubscriber.prototype.tryNext = function (value, index) {
  6488. try {
  6489. if (this.predicate(value, index, this.source)) {
  6490. this.applySingleValue(value);
  6491. }
  6492. }
  6493. catch (err) {
  6494. this.destination.error(err);
  6495. }
  6496. };
  6497. SingleSubscriber.prototype._complete = function () {
  6498. var destination = this.destination;
  6499. if (this.index > 0) {
  6500. destination.next(this.seenValue ? this.singleValue : undefined);
  6501. destination.complete();
  6502. }
  6503. else {
  6504. destination.error(new EmptyError);
  6505. }
  6506. };
  6507. return SingleSubscriber;
  6508. }(Subscriber));
  6509. function skip(count) {
  6510. return function (source) { return source.lift(new SkipOperator(count)); };
  6511. }
  6512. var SkipOperator = (function () {
  6513. function SkipOperator(total) {
  6514. this.total = total;
  6515. }
  6516. SkipOperator.prototype.call = function (subscriber, source) {
  6517. return source.subscribe(new SkipSubscriber(subscriber, this.total));
  6518. };
  6519. return SkipOperator;
  6520. }());
  6521. var SkipSubscriber = (function (_super) {
  6522. __extends(SkipSubscriber, _super);
  6523. function SkipSubscriber(destination, total) {
  6524. var _this = _super.call(this, destination) || this;
  6525. _this.total = total;
  6526. _this.count = 0;
  6527. return _this;
  6528. }
  6529. SkipSubscriber.prototype._next = function (x) {
  6530. if (++this.count > this.total) {
  6531. this.destination.next(x);
  6532. }
  6533. };
  6534. return SkipSubscriber;
  6535. }(Subscriber));
  6536. function skipLast(count) {
  6537. return function (source) { return source.lift(new SkipLastOperator(count)); };
  6538. }
  6539. var SkipLastOperator = (function () {
  6540. function SkipLastOperator(_skipCount) {
  6541. this._skipCount = _skipCount;
  6542. if (this._skipCount < 0) {
  6543. throw new ArgumentOutOfRangeError;
  6544. }
  6545. }
  6546. SkipLastOperator.prototype.call = function (subscriber, source) {
  6547. if (this._skipCount === 0) {
  6548. return source.subscribe(new Subscriber(subscriber));
  6549. }
  6550. else {
  6551. return source.subscribe(new SkipLastSubscriber(subscriber, this._skipCount));
  6552. }
  6553. };
  6554. return SkipLastOperator;
  6555. }());
  6556. var SkipLastSubscriber = (function (_super) {
  6557. __extends(SkipLastSubscriber, _super);
  6558. function SkipLastSubscriber(destination, _skipCount) {
  6559. var _this = _super.call(this, destination) || this;
  6560. _this._skipCount = _skipCount;
  6561. _this._count = 0;
  6562. _this._ring = new Array(_skipCount);
  6563. return _this;
  6564. }
  6565. SkipLastSubscriber.prototype._next = function (value) {
  6566. var skipCount = this._skipCount;
  6567. var count = this._count++;
  6568. if (count < skipCount) {
  6569. this._ring[count] = value;
  6570. }
  6571. else {
  6572. var currentIndex = count % skipCount;
  6573. var ring = this._ring;
  6574. var oldValue = ring[currentIndex];
  6575. ring[currentIndex] = value;
  6576. this.destination.next(oldValue);
  6577. }
  6578. };
  6579. return SkipLastSubscriber;
  6580. }(Subscriber));
  6581. function skipUntil(notifier) {
  6582. return function (source) { return source.lift(new SkipUntilOperator(notifier)); };
  6583. }
  6584. var SkipUntilOperator = (function () {
  6585. function SkipUntilOperator(notifier) {
  6586. this.notifier = notifier;
  6587. }
  6588. SkipUntilOperator.prototype.call = function (destination, source) {
  6589. return source.subscribe(new SkipUntilSubscriber(destination, this.notifier));
  6590. };
  6591. return SkipUntilOperator;
  6592. }());
  6593. var SkipUntilSubscriber = (function (_super) {
  6594. __extends(SkipUntilSubscriber, _super);
  6595. function SkipUntilSubscriber(destination, notifier) {
  6596. var _this = _super.call(this, destination) || this;
  6597. _this.hasValue = false;
  6598. var innerSubscriber = new InnerSubscriber(_this, undefined, undefined);
  6599. _this.add(innerSubscriber);
  6600. _this.innerSubscription = innerSubscriber;
  6601. subscribeToResult(_this, notifier, undefined, undefined, innerSubscriber);
  6602. return _this;
  6603. }
  6604. SkipUntilSubscriber.prototype._next = function (value) {
  6605. if (this.hasValue) {
  6606. _super.prototype._next.call(this, value);
  6607. }
  6608. };
  6609. SkipUntilSubscriber.prototype.notifyNext = function (outerValue, innerValue, outerIndex, innerIndex, innerSub) {
  6610. this.hasValue = true;
  6611. if (this.innerSubscription) {
  6612. this.innerSubscription.unsubscribe();
  6613. }
  6614. };
  6615. SkipUntilSubscriber.prototype.notifyComplete = function () {
  6616. };
  6617. return SkipUntilSubscriber;
  6618. }(OuterSubscriber));
  6619. function skipWhile(predicate) {
  6620. return function (source) { return source.lift(new SkipWhileOperator(predicate)); };
  6621. }
  6622. var SkipWhileOperator = (function () {
  6623. function SkipWhileOperator(predicate) {
  6624. this.predicate = predicate;
  6625. }
  6626. SkipWhileOperator.prototype.call = function (subscriber, source) {
  6627. return source.subscribe(new SkipWhileSubscriber(subscriber, this.predicate));
  6628. };
  6629. return SkipWhileOperator;
  6630. }());
  6631. var SkipWhileSubscriber = (function (_super) {
  6632. __extends(SkipWhileSubscriber, _super);
  6633. function SkipWhileSubscriber(destination, predicate) {
  6634. var _this = _super.call(this, destination) || this;
  6635. _this.predicate = predicate;
  6636. _this.skipping = true;
  6637. _this.index = 0;
  6638. return _this;
  6639. }
  6640. SkipWhileSubscriber.prototype._next = function (value) {
  6641. var destination = this.destination;
  6642. if (this.skipping) {
  6643. this.tryCallPredicate(value);
  6644. }
  6645. if (!this.skipping) {
  6646. destination.next(value);
  6647. }
  6648. };
  6649. SkipWhileSubscriber.prototype.tryCallPredicate = function (value) {
  6650. try {
  6651. var result = this.predicate(value, this.index++);
  6652. this.skipping = Boolean(result);
  6653. }
  6654. catch (err) {
  6655. this.destination.error(err);
  6656. }
  6657. };
  6658. return SkipWhileSubscriber;
  6659. }(Subscriber));
  6660. function startWith() {
  6661. var array = [];
  6662. for (var _i = 0; _i < arguments.length; _i++) {
  6663. array[_i] = arguments[_i];
  6664. }
  6665. return function (source) {
  6666. var scheduler = array[array.length - 1];
  6667. if (isScheduler(scheduler)) {
  6668. array.pop();
  6669. }
  6670. else {
  6671. scheduler = null;
  6672. }
  6673. var len = array.length;
  6674. if (len === 1 && !scheduler) {
  6675. return concat(scalar(array[0]), source);
  6676. }
  6677. else if (len > 0) {
  6678. return concat(fromArray(array, scheduler), source);
  6679. }
  6680. else {
  6681. return concat(empty$1(scheduler), source);
  6682. }
  6683. };
  6684. }
  6685. var SubscribeOnObservable = (function (_super) {
  6686. __extends(SubscribeOnObservable, _super);
  6687. function SubscribeOnObservable(source, delayTime, scheduler) {
  6688. if (delayTime === void 0) { delayTime = 0; }
  6689. if (scheduler === void 0) { scheduler = asap; }
  6690. var _this = _super.call(this) || this;
  6691. _this.source = source;
  6692. _this.delayTime = delayTime;
  6693. _this.scheduler = scheduler;
  6694. if (!isNumeric(delayTime) || delayTime < 0) {
  6695. _this.delayTime = 0;
  6696. }
  6697. if (!scheduler || typeof scheduler.schedule !== 'function') {
  6698. _this.scheduler = asap;
  6699. }
  6700. return _this;
  6701. }
  6702. SubscribeOnObservable.create = function (source, delay, scheduler) {
  6703. if (delay === void 0) { delay = 0; }
  6704. if (scheduler === void 0) { scheduler = asap; }
  6705. return new SubscribeOnObservable(source, delay, scheduler);
  6706. };
  6707. SubscribeOnObservable.dispatch = function (arg) {
  6708. var source = arg.source, subscriber = arg.subscriber;
  6709. return this.add(source.subscribe(subscriber));
  6710. };
  6711. SubscribeOnObservable.prototype._subscribe = function (subscriber) {
  6712. var delay = this.delayTime;
  6713. var source = this.source;
  6714. var scheduler = this.scheduler;
  6715. return scheduler.schedule(SubscribeOnObservable.dispatch, delay, {
  6716. source: source, subscriber: subscriber
  6717. });
  6718. };
  6719. return SubscribeOnObservable;
  6720. }(Observable));
  6721. function subscribeOn(scheduler, delay) {
  6722. if (delay === void 0) { delay = 0; }
  6723. return function subscribeOnOperatorFunction(source) {
  6724. return source.lift(new SubscribeOnOperator(scheduler, delay));
  6725. };
  6726. }
  6727. var SubscribeOnOperator = (function () {
  6728. function SubscribeOnOperator(scheduler, delay) {
  6729. this.scheduler = scheduler;
  6730. this.delay = delay;
  6731. }
  6732. SubscribeOnOperator.prototype.call = function (subscriber, source) {
  6733. return new SubscribeOnObservable(source, this.delay, this.scheduler).subscribe(subscriber);
  6734. };
  6735. return SubscribeOnOperator;
  6736. }());
  6737. function switchMap(project, resultSelector) {
  6738. if (typeof resultSelector === 'function') {
  6739. return function (source) { return source.pipe(switchMap(function (a, i) { return from(project(a, i)).pipe(map(function (b, ii) { return resultSelector(a, b, i, ii); })); })); };
  6740. }
  6741. return function (source) { return source.lift(new SwitchMapOperator(project)); };
  6742. }
  6743. var SwitchMapOperator = (function () {
  6744. function SwitchMapOperator(project) {
  6745. this.project = project;
  6746. }
  6747. SwitchMapOperator.prototype.call = function (subscriber, source) {
  6748. return source.subscribe(new SwitchMapSubscriber(subscriber, this.project));
  6749. };
  6750. return SwitchMapOperator;
  6751. }());
  6752. var SwitchMapSubscriber = (function (_super) {
  6753. __extends(SwitchMapSubscriber, _super);
  6754. function SwitchMapSubscriber(destination, project) {
  6755. var _this = _super.call(this, destination) || this;
  6756. _this.project = project;
  6757. _this.index = 0;
  6758. return _this;
  6759. }
  6760. SwitchMapSubscriber.prototype._next = function (value) {
  6761. var result;
  6762. var index = this.index++;
  6763. try {
  6764. result = this.project(value, index);
  6765. }
  6766. catch (error) {
  6767. this.destination.error(error);
  6768. return;
  6769. }
  6770. this._innerSub(result, value, index);
  6771. };
  6772. SwitchMapSubscriber.prototype._innerSub = function (result, value, index) {
  6773. var innerSubscription = this.innerSubscription;
  6774. if (innerSubscription) {
  6775. innerSubscription.unsubscribe();
  6776. }
  6777. var innerSubscriber = new InnerSubscriber(this, undefined, undefined);
  6778. var destination = this.destination;
  6779. destination.add(innerSubscriber);
  6780. this.innerSubscription = subscribeToResult(this, result, value, index, innerSubscriber);
  6781. };
  6782. SwitchMapSubscriber.prototype._complete = function () {
  6783. var innerSubscription = this.innerSubscription;
  6784. if (!innerSubscription || innerSubscription.closed) {
  6785. _super.prototype._complete.call(this);
  6786. }
  6787. this.unsubscribe();
  6788. };
  6789. SwitchMapSubscriber.prototype._unsubscribe = function () {
  6790. this.innerSubscription = null;
  6791. };
  6792. SwitchMapSubscriber.prototype.notifyComplete = function (innerSub) {
  6793. var destination = this.destination;
  6794. destination.remove(innerSub);
  6795. this.innerSubscription = null;
  6796. if (this.isStopped) {
  6797. _super.prototype._complete.call(this);
  6798. }
  6799. };
  6800. SwitchMapSubscriber.prototype.notifyNext = function (outerValue, innerValue, outerIndex, innerIndex, innerSub) {
  6801. this.destination.next(innerValue);
  6802. };
  6803. return SwitchMapSubscriber;
  6804. }(OuterSubscriber));
  6805. function switchAll() {
  6806. return switchMap(identity);
  6807. }
  6808. function switchMapTo(innerObservable, resultSelector) {
  6809. return resultSelector ? switchMap(function () { return innerObservable; }, resultSelector) : switchMap(function () { return innerObservable; });
  6810. }
  6811. function takeUntil(notifier) {
  6812. return function (source) { return source.lift(new TakeUntilOperator(notifier)); };
  6813. }
  6814. var TakeUntilOperator = (function () {
  6815. function TakeUntilOperator(notifier) {
  6816. this.notifier = notifier;
  6817. }
  6818. TakeUntilOperator.prototype.call = function (subscriber, source) {
  6819. var takeUntilSubscriber = new TakeUntilSubscriber(subscriber);
  6820. var notifierSubscription = subscribeToResult(takeUntilSubscriber, this.notifier);
  6821. if (notifierSubscription && !takeUntilSubscriber.seenValue) {
  6822. takeUntilSubscriber.add(notifierSubscription);
  6823. return source.subscribe(takeUntilSubscriber);
  6824. }
  6825. return takeUntilSubscriber;
  6826. };
  6827. return TakeUntilOperator;
  6828. }());
  6829. var TakeUntilSubscriber = (function (_super) {
  6830. __extends(TakeUntilSubscriber, _super);
  6831. function TakeUntilSubscriber(destination) {
  6832. var _this = _super.call(this, destination) || this;
  6833. _this.seenValue = false;
  6834. return _this;
  6835. }
  6836. TakeUntilSubscriber.prototype.notifyNext = function (outerValue, innerValue, outerIndex, innerIndex, innerSub) {
  6837. this.seenValue = true;
  6838. this.complete();
  6839. };
  6840. TakeUntilSubscriber.prototype.notifyComplete = function () {
  6841. };
  6842. return TakeUntilSubscriber;
  6843. }(OuterSubscriber));
  6844. function takeWhile(predicate) {
  6845. return function (source) { return source.lift(new TakeWhileOperator(predicate)); };
  6846. }
  6847. var TakeWhileOperator = (function () {
  6848. function TakeWhileOperator(predicate) {
  6849. this.predicate = predicate;
  6850. }
  6851. TakeWhileOperator.prototype.call = function (subscriber, source) {
  6852. return source.subscribe(new TakeWhileSubscriber(subscriber, this.predicate));
  6853. };
  6854. return TakeWhileOperator;
  6855. }());
  6856. var TakeWhileSubscriber = (function (_super) {
  6857. __extends(TakeWhileSubscriber, _super);
  6858. function TakeWhileSubscriber(destination, predicate) {
  6859. var _this = _super.call(this, destination) || this;
  6860. _this.predicate = predicate;
  6861. _this.index = 0;
  6862. return _this;
  6863. }
  6864. TakeWhileSubscriber.prototype._next = function (value) {
  6865. var destination = this.destination;
  6866. var result;
  6867. try {
  6868. result = this.predicate(value, this.index++);
  6869. }
  6870. catch (err) {
  6871. destination.error(err);
  6872. return;
  6873. }
  6874. this.nextOrComplete(value, result);
  6875. };
  6876. TakeWhileSubscriber.prototype.nextOrComplete = function (value, predicateResult) {
  6877. var destination = this.destination;
  6878. if (Boolean(predicateResult)) {
  6879. destination.next(value);
  6880. }
  6881. else {
  6882. destination.complete();
  6883. }
  6884. };
  6885. return TakeWhileSubscriber;
  6886. }(Subscriber));
  6887. var defaultThrottleConfig = {
  6888. leading: true,
  6889. trailing: false
  6890. };
  6891. function throttle(durationSelector, config) {
  6892. if (config === void 0) { config = defaultThrottleConfig; }
  6893. return function (source) { return source.lift(new ThrottleOperator(durationSelector, config.leading, config.trailing)); };
  6894. }
  6895. var ThrottleOperator = (function () {
  6896. function ThrottleOperator(durationSelector, leading, trailing) {
  6897. this.durationSelector = durationSelector;
  6898. this.leading = leading;
  6899. this.trailing = trailing;
  6900. }
  6901. ThrottleOperator.prototype.call = function (subscriber, source) {
  6902. return source.subscribe(new ThrottleSubscriber(subscriber, this.durationSelector, this.leading, this.trailing));
  6903. };
  6904. return ThrottleOperator;
  6905. }());
  6906. var ThrottleSubscriber = (function (_super) {
  6907. __extends(ThrottleSubscriber, _super);
  6908. function ThrottleSubscriber(destination, durationSelector, _leading, _trailing) {
  6909. var _this = _super.call(this, destination) || this;
  6910. _this.destination = destination;
  6911. _this.durationSelector = durationSelector;
  6912. _this._leading = _leading;
  6913. _this._trailing = _trailing;
  6914. _this._hasValue = false;
  6915. return _this;
  6916. }
  6917. ThrottleSubscriber.prototype._next = function (value) {
  6918. this._hasValue = true;
  6919. this._sendValue = value;
  6920. if (!this._throttled) {
  6921. if (this._leading) {
  6922. this.send();
  6923. }
  6924. else {
  6925. this.throttle(value);
  6926. }
  6927. }
  6928. };
  6929. ThrottleSubscriber.prototype.send = function () {
  6930. var _a = this, _hasValue = _a._hasValue, _sendValue = _a._sendValue;
  6931. if (_hasValue) {
  6932. this.destination.next(_sendValue);
  6933. this.throttle(_sendValue);
  6934. }
  6935. this._hasValue = false;
  6936. this._sendValue = null;
  6937. };
  6938. ThrottleSubscriber.prototype.throttle = function (value) {
  6939. var duration = this.tryDurationSelector(value);
  6940. if (duration) {
  6941. this.add(this._throttled = subscribeToResult(this, duration));
  6942. }
  6943. };
  6944. ThrottleSubscriber.prototype.tryDurationSelector = function (value) {
  6945. try {
  6946. return this.durationSelector(value);
  6947. }
  6948. catch (err) {
  6949. this.destination.error(err);
  6950. return null;
  6951. }
  6952. };
  6953. ThrottleSubscriber.prototype.throttlingDone = function () {
  6954. var _a = this, _throttled = _a._throttled, _trailing = _a._trailing;
  6955. if (_throttled) {
  6956. _throttled.unsubscribe();
  6957. }
  6958. this._throttled = null;
  6959. if (_trailing) {
  6960. this.send();
  6961. }
  6962. };
  6963. ThrottleSubscriber.prototype.notifyNext = function (outerValue, innerValue, outerIndex, innerIndex, innerSub) {
  6964. this.throttlingDone();
  6965. };
  6966. ThrottleSubscriber.prototype.notifyComplete = function () {
  6967. this.throttlingDone();
  6968. };
  6969. return ThrottleSubscriber;
  6970. }(OuterSubscriber));
  6971. function throttleTime(duration, scheduler, config) {
  6972. if (scheduler === void 0) { scheduler = async; }
  6973. if (config === void 0) { config = defaultThrottleConfig; }
  6974. return function (source) { return source.lift(new ThrottleTimeOperator(duration, scheduler, config.leading, config.trailing)); };
  6975. }
  6976. var ThrottleTimeOperator = (function () {
  6977. function ThrottleTimeOperator(duration, scheduler, leading, trailing) {
  6978. this.duration = duration;
  6979. this.scheduler = scheduler;
  6980. this.leading = leading;
  6981. this.trailing = trailing;
  6982. }
  6983. ThrottleTimeOperator.prototype.call = function (subscriber, source) {
  6984. return source.subscribe(new ThrottleTimeSubscriber(subscriber, this.duration, this.scheduler, this.leading, this.trailing));
  6985. };
  6986. return ThrottleTimeOperator;
  6987. }());
  6988. var ThrottleTimeSubscriber = (function (_super) {
  6989. __extends(ThrottleTimeSubscriber, _super);
  6990. function ThrottleTimeSubscriber(destination, duration, scheduler, leading, trailing) {
  6991. var _this = _super.call(this, destination) || this;
  6992. _this.duration = duration;
  6993. _this.scheduler = scheduler;
  6994. _this.leading = leading;
  6995. _this.trailing = trailing;
  6996. _this._hasTrailingValue = false;
  6997. _this._trailingValue = null;
  6998. return _this;
  6999. }
  7000. ThrottleTimeSubscriber.prototype._next = function (value) {
  7001. if (this.throttled) {
  7002. if (this.trailing) {
  7003. this._trailingValue = value;
  7004. this._hasTrailingValue = true;
  7005. }
  7006. }
  7007. else {
  7008. this.add(this.throttled = this.scheduler.schedule(dispatchNext$3, this.duration, { subscriber: this }));
  7009. if (this.leading) {
  7010. this.destination.next(value);
  7011. }
  7012. }
  7013. };
  7014. ThrottleTimeSubscriber.prototype._complete = function () {
  7015. if (this._hasTrailingValue) {
  7016. this.destination.next(this._trailingValue);
  7017. this.destination.complete();
  7018. }
  7019. else {
  7020. this.destination.complete();
  7021. }
  7022. };
  7023. ThrottleTimeSubscriber.prototype.clearThrottle = function () {
  7024. var throttled = this.throttled;
  7025. if (throttled) {
  7026. if (this.trailing && this._hasTrailingValue) {
  7027. this.destination.next(this._trailingValue);
  7028. this._trailingValue = null;
  7029. this._hasTrailingValue = false;
  7030. }
  7031. throttled.unsubscribe();
  7032. this.remove(throttled);
  7033. this.throttled = null;
  7034. }
  7035. };
  7036. return ThrottleTimeSubscriber;
  7037. }(Subscriber));
  7038. function dispatchNext$3(arg) {
  7039. var subscriber = arg.subscriber;
  7040. subscriber.clearThrottle();
  7041. }
  7042. function timeInterval(scheduler) {
  7043. if (scheduler === void 0) { scheduler = async; }
  7044. return function (source) { return defer(function () {
  7045. return source.pipe(scan(function (_a, value) {
  7046. var current = _a.current;
  7047. return ({ value: value, current: scheduler.now(), last: current });
  7048. }, { current: scheduler.now(), value: undefined, last: undefined }), map(function (_a) {
  7049. var current = _a.current, last = _a.last, value = _a.value;
  7050. return new TimeInterval(value, current - last);
  7051. }));
  7052. }); };
  7053. }
  7054. var TimeInterval = (function () {
  7055. function TimeInterval(value, interval) {
  7056. this.value = value;
  7057. this.interval = interval;
  7058. }
  7059. return TimeInterval;
  7060. }());
  7061. function timeoutWith(due, withObservable, scheduler) {
  7062. if (scheduler === void 0) { scheduler = async; }
  7063. return function (source) {
  7064. var absoluteTimeout = isDate(due);
  7065. var waitFor = absoluteTimeout ? (+due - scheduler.now()) : Math.abs(due);
  7066. return source.lift(new TimeoutWithOperator(waitFor, absoluteTimeout, withObservable, scheduler));
  7067. };
  7068. }
  7069. var TimeoutWithOperator = (function () {
  7070. function TimeoutWithOperator(waitFor, absoluteTimeout, withObservable, scheduler) {
  7071. this.waitFor = waitFor;
  7072. this.absoluteTimeout = absoluteTimeout;
  7073. this.withObservable = withObservable;
  7074. this.scheduler = scheduler;
  7075. }
  7076. TimeoutWithOperator.prototype.call = function (subscriber, source) {
  7077. return source.subscribe(new TimeoutWithSubscriber(subscriber, this.absoluteTimeout, this.waitFor, this.withObservable, this.scheduler));
  7078. };
  7079. return TimeoutWithOperator;
  7080. }());
  7081. var TimeoutWithSubscriber = (function (_super) {
  7082. __extends(TimeoutWithSubscriber, _super);
  7083. function TimeoutWithSubscriber(destination, absoluteTimeout, waitFor, withObservable, scheduler) {
  7084. var _this = _super.call(this, destination) || this;
  7085. _this.absoluteTimeout = absoluteTimeout;
  7086. _this.waitFor = waitFor;
  7087. _this.withObservable = withObservable;
  7088. _this.scheduler = scheduler;
  7089. _this.action = null;
  7090. _this.scheduleTimeout();
  7091. return _this;
  7092. }
  7093. TimeoutWithSubscriber.dispatchTimeout = function (subscriber) {
  7094. var withObservable = subscriber.withObservable;
  7095. subscriber._unsubscribeAndRecycle();
  7096. subscriber.add(subscribeToResult(subscriber, withObservable));
  7097. };
  7098. TimeoutWithSubscriber.prototype.scheduleTimeout = function () {
  7099. var action = this.action;
  7100. if (action) {
  7101. this.action = action.schedule(this, this.waitFor);
  7102. }
  7103. else {
  7104. this.add(this.action = this.scheduler.schedule(TimeoutWithSubscriber.dispatchTimeout, this.waitFor, this));
  7105. }
  7106. };
  7107. TimeoutWithSubscriber.prototype._next = function (value) {
  7108. if (!this.absoluteTimeout) {
  7109. this.scheduleTimeout();
  7110. }
  7111. _super.prototype._next.call(this, value);
  7112. };
  7113. TimeoutWithSubscriber.prototype._unsubscribe = function () {
  7114. this.action = null;
  7115. this.scheduler = null;
  7116. this.withObservable = null;
  7117. };
  7118. return TimeoutWithSubscriber;
  7119. }(OuterSubscriber));
  7120. function timeout(due, scheduler) {
  7121. if (scheduler === void 0) { scheduler = async; }
  7122. return timeoutWith(due, throwError(new TimeoutError()), scheduler);
  7123. }
  7124. function timestamp(scheduler) {
  7125. if (scheduler === void 0) { scheduler = async; }
  7126. return map(function (value) { return new Timestamp(value, scheduler.now()); });
  7127. }
  7128. var Timestamp = (function () {
  7129. function Timestamp(value, timestamp) {
  7130. this.value = value;
  7131. this.timestamp = timestamp;
  7132. }
  7133. return Timestamp;
  7134. }());
  7135. function toArrayReducer(arr, item, index) {
  7136. if (index === 0) {
  7137. return [item];
  7138. }
  7139. arr.push(item);
  7140. return arr;
  7141. }
  7142. function toArray() {
  7143. return reduce(toArrayReducer, []);
  7144. }
  7145. function window$1(windowBoundaries) {
  7146. return function windowOperatorFunction(source) {
  7147. return source.lift(new WindowOperator(windowBoundaries));
  7148. };
  7149. }
  7150. var WindowOperator = (function () {
  7151. function WindowOperator(windowBoundaries) {
  7152. this.windowBoundaries = windowBoundaries;
  7153. }
  7154. WindowOperator.prototype.call = function (subscriber, source) {
  7155. var windowSubscriber = new WindowSubscriber(subscriber);
  7156. var sourceSubscription = source.subscribe(windowSubscriber);
  7157. if (!sourceSubscription.closed) {
  7158. windowSubscriber.add(subscribeToResult(windowSubscriber, this.windowBoundaries));
  7159. }
  7160. return sourceSubscription;
  7161. };
  7162. return WindowOperator;
  7163. }());
  7164. var WindowSubscriber = (function (_super) {
  7165. __extends(WindowSubscriber, _super);
  7166. function WindowSubscriber(destination) {
  7167. var _this = _super.call(this, destination) || this;
  7168. _this.window = new Subject();
  7169. destination.next(_this.window);
  7170. return _this;
  7171. }
  7172. WindowSubscriber.prototype.notifyNext = function (outerValue, innerValue, outerIndex, innerIndex, innerSub) {
  7173. this.openWindow();
  7174. };
  7175. WindowSubscriber.prototype.notifyError = function (error, innerSub) {
  7176. this._error(error);
  7177. };
  7178. WindowSubscriber.prototype.notifyComplete = function (innerSub) {
  7179. this._complete();
  7180. };
  7181. WindowSubscriber.prototype._next = function (value) {
  7182. this.window.next(value);
  7183. };
  7184. WindowSubscriber.prototype._error = function (err) {
  7185. this.window.error(err);
  7186. this.destination.error(err);
  7187. };
  7188. WindowSubscriber.prototype._complete = function () {
  7189. this.window.complete();
  7190. this.destination.complete();
  7191. };
  7192. WindowSubscriber.prototype._unsubscribe = function () {
  7193. this.window = null;
  7194. };
  7195. WindowSubscriber.prototype.openWindow = function () {
  7196. var prevWindow = this.window;
  7197. if (prevWindow) {
  7198. prevWindow.complete();
  7199. }
  7200. var destination = this.destination;
  7201. var newWindow = this.window = new Subject();
  7202. destination.next(newWindow);
  7203. };
  7204. return WindowSubscriber;
  7205. }(OuterSubscriber));
  7206. function windowCount(windowSize, startWindowEvery) {
  7207. if (startWindowEvery === void 0) { startWindowEvery = 0; }
  7208. return function windowCountOperatorFunction(source) {
  7209. return source.lift(new WindowCountOperator(windowSize, startWindowEvery));
  7210. };
  7211. }
  7212. var WindowCountOperator = (function () {
  7213. function WindowCountOperator(windowSize, startWindowEvery) {
  7214. this.windowSize = windowSize;
  7215. this.startWindowEvery = startWindowEvery;
  7216. }
  7217. WindowCountOperator.prototype.call = function (subscriber, source) {
  7218. return source.subscribe(new WindowCountSubscriber(subscriber, this.windowSize, this.startWindowEvery));
  7219. };
  7220. return WindowCountOperator;
  7221. }());
  7222. var WindowCountSubscriber = (function (_super) {
  7223. __extends(WindowCountSubscriber, _super);
  7224. function WindowCountSubscriber(destination, windowSize, startWindowEvery) {
  7225. var _this = _super.call(this, destination) || this;
  7226. _this.destination = destination;
  7227. _this.windowSize = windowSize;
  7228. _this.startWindowEvery = startWindowEvery;
  7229. _this.windows = [new Subject()];
  7230. _this.count = 0;
  7231. destination.next(_this.windows[0]);
  7232. return _this;
  7233. }
  7234. WindowCountSubscriber.prototype._next = function (value) {
  7235. var startWindowEvery = (this.startWindowEvery > 0) ? this.startWindowEvery : this.windowSize;
  7236. var destination = this.destination;
  7237. var windowSize = this.windowSize;
  7238. var windows = this.windows;
  7239. var len = windows.length;
  7240. for (var i = 0; i < len && !this.closed; i++) {
  7241. windows[i].next(value);
  7242. }
  7243. var c = this.count - windowSize + 1;
  7244. if (c >= 0 && c % startWindowEvery === 0 && !this.closed) {
  7245. windows.shift().complete();
  7246. }
  7247. if (++this.count % startWindowEvery === 0 && !this.closed) {
  7248. var window_1 = new Subject();
  7249. windows.push(window_1);
  7250. destination.next(window_1);
  7251. }
  7252. };
  7253. WindowCountSubscriber.prototype._error = function (err) {
  7254. var windows = this.windows;
  7255. if (windows) {
  7256. while (windows.length > 0 && !this.closed) {
  7257. windows.shift().error(err);
  7258. }
  7259. }
  7260. this.destination.error(err);
  7261. };
  7262. WindowCountSubscriber.prototype._complete = function () {
  7263. var windows = this.windows;
  7264. if (windows) {
  7265. while (windows.length > 0 && !this.closed) {
  7266. windows.shift().complete();
  7267. }
  7268. }
  7269. this.destination.complete();
  7270. };
  7271. WindowCountSubscriber.prototype._unsubscribe = function () {
  7272. this.count = 0;
  7273. this.windows = null;
  7274. };
  7275. return WindowCountSubscriber;
  7276. }(Subscriber));
  7277. function windowTime(windowTimeSpan) {
  7278. var scheduler = async;
  7279. var windowCreationInterval = null;
  7280. var maxWindowSize = Number.POSITIVE_INFINITY;
  7281. if (isScheduler(arguments[3])) {
  7282. scheduler = arguments[3];
  7283. }
  7284. if (isScheduler(arguments[2])) {
  7285. scheduler = arguments[2];
  7286. }
  7287. else if (isNumeric(arguments[2])) {
  7288. maxWindowSize = arguments[2];
  7289. }
  7290. if (isScheduler(arguments[1])) {
  7291. scheduler = arguments[1];
  7292. }
  7293. else if (isNumeric(arguments[1])) {
  7294. windowCreationInterval = arguments[1];
  7295. }
  7296. return function windowTimeOperatorFunction(source) {
  7297. return source.lift(new WindowTimeOperator(windowTimeSpan, windowCreationInterval, maxWindowSize, scheduler));
  7298. };
  7299. }
  7300. var WindowTimeOperator = (function () {
  7301. function WindowTimeOperator(windowTimeSpan, windowCreationInterval, maxWindowSize, scheduler) {
  7302. this.windowTimeSpan = windowTimeSpan;
  7303. this.windowCreationInterval = windowCreationInterval;
  7304. this.maxWindowSize = maxWindowSize;
  7305. this.scheduler = scheduler;
  7306. }
  7307. WindowTimeOperator.prototype.call = function (subscriber, source) {
  7308. return source.subscribe(new WindowTimeSubscriber(subscriber, this.windowTimeSpan, this.windowCreationInterval, this.maxWindowSize, this.scheduler));
  7309. };
  7310. return WindowTimeOperator;
  7311. }());
  7312. var CountedSubject = (function (_super) {
  7313. __extends(CountedSubject, _super);
  7314. function CountedSubject() {
  7315. var _this = _super !== null && _super.apply(this, arguments) || this;
  7316. _this._numberOfNextedValues = 0;
  7317. return _this;
  7318. }
  7319. CountedSubject.prototype.next = function (value) {
  7320. this._numberOfNextedValues++;
  7321. _super.prototype.next.call(this, value);
  7322. };
  7323. Object.defineProperty(CountedSubject.prototype, "numberOfNextedValues", {
  7324. get: function () {
  7325. return this._numberOfNextedValues;
  7326. },
  7327. enumerable: true,
  7328. configurable: true
  7329. });
  7330. return CountedSubject;
  7331. }(Subject));
  7332. var WindowTimeSubscriber = (function (_super) {
  7333. __extends(WindowTimeSubscriber, _super);
  7334. function WindowTimeSubscriber(destination, windowTimeSpan, windowCreationInterval, maxWindowSize, scheduler) {
  7335. var _this = _super.call(this, destination) || this;
  7336. _this.destination = destination;
  7337. _this.windowTimeSpan = windowTimeSpan;
  7338. _this.windowCreationInterval = windowCreationInterval;
  7339. _this.maxWindowSize = maxWindowSize;
  7340. _this.scheduler = scheduler;
  7341. _this.windows = [];
  7342. var window = _this.openWindow();
  7343. if (windowCreationInterval !== null && windowCreationInterval >= 0) {
  7344. var closeState = { subscriber: _this, window: window, context: null };
  7345. var creationState = { windowTimeSpan: windowTimeSpan, windowCreationInterval: windowCreationInterval, subscriber: _this, scheduler: scheduler };
  7346. _this.add(scheduler.schedule(dispatchWindowClose, windowTimeSpan, closeState));
  7347. _this.add(scheduler.schedule(dispatchWindowCreation, windowCreationInterval, creationState));
  7348. }
  7349. else {
  7350. var timeSpanOnlyState = { subscriber: _this, window: window, windowTimeSpan: windowTimeSpan };
  7351. _this.add(scheduler.schedule(dispatchWindowTimeSpanOnly, windowTimeSpan, timeSpanOnlyState));
  7352. }
  7353. return _this;
  7354. }
  7355. WindowTimeSubscriber.prototype._next = function (value) {
  7356. var windows = this.windows;
  7357. var len = windows.length;
  7358. for (var i = 0; i < len; i++) {
  7359. var window_1 = windows[i];
  7360. if (!window_1.closed) {
  7361. window_1.next(value);
  7362. if (window_1.numberOfNextedValues >= this.maxWindowSize) {
  7363. this.closeWindow(window_1);
  7364. }
  7365. }
  7366. }
  7367. };
  7368. WindowTimeSubscriber.prototype._error = function (err) {
  7369. var windows = this.windows;
  7370. while (windows.length > 0) {
  7371. windows.shift().error(err);
  7372. }
  7373. this.destination.error(err);
  7374. };
  7375. WindowTimeSubscriber.prototype._complete = function () {
  7376. var windows = this.windows;
  7377. while (windows.length > 0) {
  7378. var window_2 = windows.shift();
  7379. if (!window_2.closed) {
  7380. window_2.complete();
  7381. }
  7382. }
  7383. this.destination.complete();
  7384. };
  7385. WindowTimeSubscriber.prototype.openWindow = function () {
  7386. var window = new CountedSubject();
  7387. this.windows.push(window);
  7388. var destination = this.destination;
  7389. destination.next(window);
  7390. return window;
  7391. };
  7392. WindowTimeSubscriber.prototype.closeWindow = function (window) {
  7393. window.complete();
  7394. var windows = this.windows;
  7395. windows.splice(windows.indexOf(window), 1);
  7396. };
  7397. return WindowTimeSubscriber;
  7398. }(Subscriber));
  7399. function dispatchWindowTimeSpanOnly(state) {
  7400. var subscriber = state.subscriber, windowTimeSpan = state.windowTimeSpan, window = state.window;
  7401. if (window) {
  7402. subscriber.closeWindow(window);
  7403. }
  7404. state.window = subscriber.openWindow();
  7405. this.schedule(state, windowTimeSpan);
  7406. }
  7407. function dispatchWindowCreation(state) {
  7408. var windowTimeSpan = state.windowTimeSpan, subscriber = state.subscriber, scheduler = state.scheduler, windowCreationInterval = state.windowCreationInterval;
  7409. var window = subscriber.openWindow();
  7410. var action = this;
  7411. var context = { action: action, subscription: null };
  7412. var timeSpanState = { subscriber: subscriber, window: window, context: context };
  7413. context.subscription = scheduler.schedule(dispatchWindowClose, windowTimeSpan, timeSpanState);
  7414. action.add(context.subscription);
  7415. action.schedule(state, windowCreationInterval);
  7416. }
  7417. function dispatchWindowClose(state) {
  7418. var subscriber = state.subscriber, window = state.window, context = state.context;
  7419. if (context && context.action && context.subscription) {
  7420. context.action.remove(context.subscription);
  7421. }
  7422. subscriber.closeWindow(window);
  7423. }
  7424. function windowToggle(openings, closingSelector) {
  7425. return function (source) { return source.lift(new WindowToggleOperator(openings, closingSelector)); };
  7426. }
  7427. var WindowToggleOperator = (function () {
  7428. function WindowToggleOperator(openings, closingSelector) {
  7429. this.openings = openings;
  7430. this.closingSelector = closingSelector;
  7431. }
  7432. WindowToggleOperator.prototype.call = function (subscriber, source) {
  7433. return source.subscribe(new WindowToggleSubscriber(subscriber, this.openings, this.closingSelector));
  7434. };
  7435. return WindowToggleOperator;
  7436. }());
  7437. var WindowToggleSubscriber = (function (_super) {
  7438. __extends(WindowToggleSubscriber, _super);
  7439. function WindowToggleSubscriber(destination, openings, closingSelector) {
  7440. var _this = _super.call(this, destination) || this;
  7441. _this.openings = openings;
  7442. _this.closingSelector = closingSelector;
  7443. _this.contexts = [];
  7444. _this.add(_this.openSubscription = subscribeToResult(_this, openings, openings));
  7445. return _this;
  7446. }
  7447. WindowToggleSubscriber.prototype._next = function (value) {
  7448. var contexts = this.contexts;
  7449. if (contexts) {
  7450. var len = contexts.length;
  7451. for (var i = 0; i < len; i++) {
  7452. contexts[i].window.next(value);
  7453. }
  7454. }
  7455. };
  7456. WindowToggleSubscriber.prototype._error = function (err) {
  7457. var contexts = this.contexts;
  7458. this.contexts = null;
  7459. if (contexts) {
  7460. var len = contexts.length;
  7461. var index = -1;
  7462. while (++index < len) {
  7463. var context_1 = contexts[index];
  7464. context_1.window.error(err);
  7465. context_1.subscription.unsubscribe();
  7466. }
  7467. }
  7468. _super.prototype._error.call(this, err);
  7469. };
  7470. WindowToggleSubscriber.prototype._complete = function () {
  7471. var contexts = this.contexts;
  7472. this.contexts = null;
  7473. if (contexts) {
  7474. var len = contexts.length;
  7475. var index = -1;
  7476. while (++index < len) {
  7477. var context_2 = contexts[index];
  7478. context_2.window.complete();
  7479. context_2.subscription.unsubscribe();
  7480. }
  7481. }
  7482. _super.prototype._complete.call(this);
  7483. };
  7484. WindowToggleSubscriber.prototype._unsubscribe = function () {
  7485. var contexts = this.contexts;
  7486. this.contexts = null;
  7487. if (contexts) {
  7488. var len = contexts.length;
  7489. var index = -1;
  7490. while (++index < len) {
  7491. var context_3 = contexts[index];
  7492. context_3.window.unsubscribe();
  7493. context_3.subscription.unsubscribe();
  7494. }
  7495. }
  7496. };
  7497. WindowToggleSubscriber.prototype.notifyNext = function (outerValue, innerValue, outerIndex, innerIndex, innerSub) {
  7498. if (outerValue === this.openings) {
  7499. var closingSelector = this.closingSelector;
  7500. var closingNotifier = tryCatch(closingSelector)(innerValue);
  7501. if (closingNotifier === errorObject) {
  7502. return this.error(errorObject.e);
  7503. }
  7504. else {
  7505. var window_1 = new Subject();
  7506. var subscription = new Subscription();
  7507. var context_4 = { window: window_1, subscription: subscription };
  7508. this.contexts.push(context_4);
  7509. var innerSubscription = subscribeToResult(this, closingNotifier, context_4);
  7510. if (innerSubscription.closed) {
  7511. this.closeWindow(this.contexts.length - 1);
  7512. }
  7513. else {
  7514. innerSubscription.context = context_4;
  7515. subscription.add(innerSubscription);
  7516. }
  7517. this.destination.next(window_1);
  7518. }
  7519. }
  7520. else {
  7521. this.closeWindow(this.contexts.indexOf(outerValue));
  7522. }
  7523. };
  7524. WindowToggleSubscriber.prototype.notifyError = function (err) {
  7525. this.error(err);
  7526. };
  7527. WindowToggleSubscriber.prototype.notifyComplete = function (inner) {
  7528. if (inner !== this.openSubscription) {
  7529. this.closeWindow(this.contexts.indexOf(inner.context));
  7530. }
  7531. };
  7532. WindowToggleSubscriber.prototype.closeWindow = function (index) {
  7533. if (index === -1) {
  7534. return;
  7535. }
  7536. var contexts = this.contexts;
  7537. var context = contexts[index];
  7538. var window = context.window, subscription = context.subscription;
  7539. contexts.splice(index, 1);
  7540. window.complete();
  7541. subscription.unsubscribe();
  7542. };
  7543. return WindowToggleSubscriber;
  7544. }(OuterSubscriber));
  7545. function windowWhen(closingSelector) {
  7546. return function windowWhenOperatorFunction(source) {
  7547. return source.lift(new WindowOperator$1(closingSelector));
  7548. };
  7549. }
  7550. var WindowOperator$1 = (function () {
  7551. function WindowOperator(closingSelector) {
  7552. this.closingSelector = closingSelector;
  7553. }
  7554. WindowOperator.prototype.call = function (subscriber, source) {
  7555. return source.subscribe(new WindowSubscriber$1(subscriber, this.closingSelector));
  7556. };
  7557. return WindowOperator;
  7558. }());
  7559. var WindowSubscriber$1 = (function (_super) {
  7560. __extends(WindowSubscriber, _super);
  7561. function WindowSubscriber(destination, closingSelector) {
  7562. var _this = _super.call(this, destination) || this;
  7563. _this.destination = destination;
  7564. _this.closingSelector = closingSelector;
  7565. _this.openWindow();
  7566. return _this;
  7567. }
  7568. WindowSubscriber.prototype.notifyNext = function (outerValue, innerValue, outerIndex, innerIndex, innerSub) {
  7569. this.openWindow(innerSub);
  7570. };
  7571. WindowSubscriber.prototype.notifyError = function (error, innerSub) {
  7572. this._error(error);
  7573. };
  7574. WindowSubscriber.prototype.notifyComplete = function (innerSub) {
  7575. this.openWindow(innerSub);
  7576. };
  7577. WindowSubscriber.prototype._next = function (value) {
  7578. this.window.next(value);
  7579. };
  7580. WindowSubscriber.prototype._error = function (err) {
  7581. this.window.error(err);
  7582. this.destination.error(err);
  7583. this.unsubscribeClosingNotification();
  7584. };
  7585. WindowSubscriber.prototype._complete = function () {
  7586. this.window.complete();
  7587. this.destination.complete();
  7588. this.unsubscribeClosingNotification();
  7589. };
  7590. WindowSubscriber.prototype.unsubscribeClosingNotification = function () {
  7591. if (this.closingNotification) {
  7592. this.closingNotification.unsubscribe();
  7593. }
  7594. };
  7595. WindowSubscriber.prototype.openWindow = function (innerSub) {
  7596. if (innerSub === void 0) { innerSub = null; }
  7597. if (innerSub) {
  7598. this.remove(innerSub);
  7599. innerSub.unsubscribe();
  7600. }
  7601. var prevWindow = this.window;
  7602. if (prevWindow) {
  7603. prevWindow.complete();
  7604. }
  7605. var window = this.window = new Subject();
  7606. this.destination.next(window);
  7607. var closingNotifier = tryCatch(this.closingSelector)();
  7608. if (closingNotifier === errorObject) {
  7609. var err = errorObject.e;
  7610. this.destination.error(err);
  7611. this.window.error(err);
  7612. }
  7613. else {
  7614. this.add(this.closingNotification = subscribeToResult(this, closingNotifier));
  7615. }
  7616. };
  7617. return WindowSubscriber;
  7618. }(OuterSubscriber));
  7619. function withLatestFrom() {
  7620. var args = [];
  7621. for (var _i = 0; _i < arguments.length; _i++) {
  7622. args[_i] = arguments[_i];
  7623. }
  7624. return function (source) {
  7625. var project;
  7626. if (typeof args[args.length - 1] === 'function') {
  7627. project = args.pop();
  7628. }
  7629. var observables = args;
  7630. return source.lift(new WithLatestFromOperator(observables, project));
  7631. };
  7632. }
  7633. var WithLatestFromOperator = (function () {
  7634. function WithLatestFromOperator(observables, project) {
  7635. this.observables = observables;
  7636. this.project = project;
  7637. }
  7638. WithLatestFromOperator.prototype.call = function (subscriber, source) {
  7639. return source.subscribe(new WithLatestFromSubscriber(subscriber, this.observables, this.project));
  7640. };
  7641. return WithLatestFromOperator;
  7642. }());
  7643. var WithLatestFromSubscriber = (function (_super) {
  7644. __extends(WithLatestFromSubscriber, _super);
  7645. function WithLatestFromSubscriber(destination, observables, project) {
  7646. var _this = _super.call(this, destination) || this;
  7647. _this.observables = observables;
  7648. _this.project = project;
  7649. _this.toRespond = [];
  7650. var len = observables.length;
  7651. _this.values = new Array(len);
  7652. for (var i = 0; i < len; i++) {
  7653. _this.toRespond.push(i);
  7654. }
  7655. for (var i = 0; i < len; i++) {
  7656. var observable = observables[i];
  7657. _this.add(subscribeToResult(_this, observable, observable, i));
  7658. }
  7659. return _this;
  7660. }
  7661. WithLatestFromSubscriber.prototype.notifyNext = function (outerValue, innerValue, outerIndex, innerIndex, innerSub) {
  7662. this.values[outerIndex] = innerValue;
  7663. var toRespond = this.toRespond;
  7664. if (toRespond.length > 0) {
  7665. var found = toRespond.indexOf(outerIndex);
  7666. if (found !== -1) {
  7667. toRespond.splice(found, 1);
  7668. }
  7669. }
  7670. };
  7671. WithLatestFromSubscriber.prototype.notifyComplete = function () {
  7672. };
  7673. WithLatestFromSubscriber.prototype._next = function (value) {
  7674. if (this.toRespond.length === 0) {
  7675. var args = [value].concat(this.values);
  7676. if (this.project) {
  7677. this._tryProject(args);
  7678. }
  7679. else {
  7680. this.destination.next(args);
  7681. }
  7682. }
  7683. };
  7684. WithLatestFromSubscriber.prototype._tryProject = function (args) {
  7685. var result;
  7686. try {
  7687. result = this.project.apply(this, args);
  7688. }
  7689. catch (err) {
  7690. this.destination.error(err);
  7691. return;
  7692. }
  7693. this.destination.next(result);
  7694. };
  7695. return WithLatestFromSubscriber;
  7696. }(OuterSubscriber));
  7697. function zip$1() {
  7698. var observables = [];
  7699. for (var _i = 0; _i < arguments.length; _i++) {
  7700. observables[_i] = arguments[_i];
  7701. }
  7702. return function zipOperatorFunction(source) {
  7703. return source.lift.call(zip.apply(void 0, [source].concat(observables)));
  7704. };
  7705. }
  7706. function zipAll(project) {
  7707. return function (source) { return source.lift(new ZipOperator(project)); };
  7708. }
  7709. var _operators = Object.freeze({
  7710. audit: audit,
  7711. auditTime: auditTime,
  7712. buffer: buffer,
  7713. bufferCount: bufferCount,
  7714. bufferTime: bufferTime,
  7715. bufferToggle: bufferToggle,
  7716. bufferWhen: bufferWhen,
  7717. catchError: catchError,
  7718. combineAll: combineAll,
  7719. combineLatest: combineLatest$1,
  7720. concat: concat$1,
  7721. concatAll: concatAll,
  7722. concatMap: concatMap,
  7723. concatMapTo: concatMapTo,
  7724. count: count,
  7725. debounce: debounce,
  7726. debounceTime: debounceTime,
  7727. defaultIfEmpty: defaultIfEmpty,
  7728. delay: delay,
  7729. delayWhen: delayWhen,
  7730. dematerialize: dematerialize,
  7731. distinct: distinct,
  7732. distinctUntilChanged: distinctUntilChanged,
  7733. distinctUntilKeyChanged: distinctUntilKeyChanged,
  7734. elementAt: elementAt,
  7735. endWith: endWith,
  7736. every: every,
  7737. exhaust: exhaust,
  7738. exhaustMap: exhaustMap,
  7739. expand: expand,
  7740. filter: filter,
  7741. finalize: finalize,
  7742. find: find,
  7743. findIndex: findIndex,
  7744. first: first,
  7745. groupBy: groupBy,
  7746. ignoreElements: ignoreElements,
  7747. isEmpty: isEmpty,
  7748. last: last,
  7749. map: map,
  7750. mapTo: mapTo,
  7751. materialize: materialize,
  7752. max: max,
  7753. merge: merge$1,
  7754. mergeAll: mergeAll,
  7755. mergeMap: mergeMap,
  7756. flatMap: mergeMap,
  7757. mergeMapTo: mergeMapTo,
  7758. mergeScan: mergeScan,
  7759. min: min,
  7760. multicast: multicast,
  7761. observeOn: observeOn,
  7762. onErrorResumeNext: onErrorResumeNext$1,
  7763. pairwise: pairwise,
  7764. partition: partition,
  7765. pluck: pluck,
  7766. publish: publish,
  7767. publishBehavior: publishBehavior,
  7768. publishLast: publishLast,
  7769. publishReplay: publishReplay,
  7770. race: race$1,
  7771. reduce: reduce,
  7772. repeat: repeat,
  7773. repeatWhen: repeatWhen,
  7774. retry: retry,
  7775. retryWhen: retryWhen,
  7776. refCount: refCount,
  7777. sample: sample,
  7778. sampleTime: sampleTime,
  7779. scan: scan,
  7780. sequenceEqual: sequenceEqual,
  7781. share: share,
  7782. shareReplay: shareReplay,
  7783. single: single,
  7784. skip: skip,
  7785. skipLast: skipLast,
  7786. skipUntil: skipUntil,
  7787. skipWhile: skipWhile,
  7788. startWith: startWith,
  7789. subscribeOn: subscribeOn,
  7790. switchAll: switchAll,
  7791. switchMap: switchMap,
  7792. switchMapTo: switchMapTo,
  7793. take: take,
  7794. takeLast: takeLast,
  7795. takeUntil: takeUntil,
  7796. takeWhile: takeWhile,
  7797. tap: tap,
  7798. throttle: throttle,
  7799. throttleTime: throttleTime,
  7800. throwIfEmpty: throwIfEmpty,
  7801. timeInterval: timeInterval,
  7802. timeout: timeout,
  7803. timeoutWith: timeoutWith,
  7804. timestamp: timestamp,
  7805. toArray: toArray,
  7806. window: window$1,
  7807. windowCount: windowCount,
  7808. windowTime: windowTime,
  7809. windowToggle: windowToggle,
  7810. windowWhen: windowWhen,
  7811. withLatestFrom: withLatestFrom,
  7812. zip: zip$1,
  7813. zipAll: zipAll
  7814. });
  7815. var SubscriptionLog = (function () {
  7816. function SubscriptionLog(subscribedFrame, unsubscribedFrame) {
  7817. if (unsubscribedFrame === void 0) { unsubscribedFrame = Number.POSITIVE_INFINITY; }
  7818. this.subscribedFrame = subscribedFrame;
  7819. this.unsubscribedFrame = unsubscribedFrame;
  7820. }
  7821. return SubscriptionLog;
  7822. }());
  7823. var SubscriptionLoggable = (function () {
  7824. function SubscriptionLoggable() {
  7825. this.subscriptions = [];
  7826. }
  7827. SubscriptionLoggable.prototype.logSubscribedFrame = function () {
  7828. this.subscriptions.push(new SubscriptionLog(this.scheduler.now()));
  7829. return this.subscriptions.length - 1;
  7830. };
  7831. SubscriptionLoggable.prototype.logUnsubscribedFrame = function (index) {
  7832. var subscriptionLogs = this.subscriptions;
  7833. var oldSubscriptionLog = subscriptionLogs[index];
  7834. subscriptionLogs[index] = new SubscriptionLog(oldSubscriptionLog.subscribedFrame, this.scheduler.now());
  7835. };
  7836. return SubscriptionLoggable;
  7837. }());
  7838. function applyMixins(derivedCtor, baseCtors) {
  7839. for (var i = 0, len = baseCtors.length; i < len; i++) {
  7840. var baseCtor = baseCtors[i];
  7841. var propertyKeys = Object.getOwnPropertyNames(baseCtor.prototype);
  7842. for (var j = 0, len2 = propertyKeys.length; j < len2; j++) {
  7843. var name_1 = propertyKeys[j];
  7844. derivedCtor.prototype[name_1] = baseCtor.prototype[name_1];
  7845. }
  7846. }
  7847. }
  7848. var ColdObservable = (function (_super) {
  7849. __extends(ColdObservable, _super);
  7850. function ColdObservable(messages, scheduler) {
  7851. var _this = _super.call(this, function (subscriber) {
  7852. var observable = this;
  7853. var index = observable.logSubscribedFrame();
  7854. var subscription = new Subscription();
  7855. subscription.add(new Subscription(function () {
  7856. observable.logUnsubscribedFrame(index);
  7857. }));
  7858. observable.scheduleMessages(subscriber);
  7859. return subscription;
  7860. }) || this;
  7861. _this.messages = messages;
  7862. _this.subscriptions = [];
  7863. _this.scheduler = scheduler;
  7864. return _this;
  7865. }
  7866. ColdObservable.prototype.scheduleMessages = function (subscriber) {
  7867. var messagesLength = this.messages.length;
  7868. for (var i = 0; i < messagesLength; i++) {
  7869. var message = this.messages[i];
  7870. subscriber.add(this.scheduler.schedule(function (_a) {
  7871. var message = _a.message, subscriber = _a.subscriber;
  7872. message.notification.observe(subscriber);
  7873. }, message.frame, { message: message, subscriber: subscriber }));
  7874. }
  7875. };
  7876. return ColdObservable;
  7877. }(Observable));
  7878. applyMixins(ColdObservable, [SubscriptionLoggable]);
  7879. var HotObservable = (function (_super) {
  7880. __extends(HotObservable, _super);
  7881. function HotObservable(messages, scheduler) {
  7882. var _this = _super.call(this) || this;
  7883. _this.messages = messages;
  7884. _this.subscriptions = [];
  7885. _this.scheduler = scheduler;
  7886. return _this;
  7887. }
  7888. HotObservable.prototype._subscribe = function (subscriber) {
  7889. var subject = this;
  7890. var index = subject.logSubscribedFrame();
  7891. var subscription = new Subscription();
  7892. subscription.add(new Subscription(function () {
  7893. subject.logUnsubscribedFrame(index);
  7894. }));
  7895. subscription.add(_super.prototype._subscribe.call(this, subscriber));
  7896. return subscription;
  7897. };
  7898. HotObservable.prototype.setup = function () {
  7899. var subject = this;
  7900. var messagesLength = subject.messages.length;
  7901. for (var i = 0; i < messagesLength; i++) {
  7902. (function () {
  7903. var message = subject.messages[i];
  7904. subject.scheduler.schedule(function () { message.notification.observe(subject); }, message.frame);
  7905. })();
  7906. }
  7907. };
  7908. return HotObservable;
  7909. }(Subject));
  7910. applyMixins(HotObservable, [SubscriptionLoggable]);
  7911. var defaultMaxFrame = 750;
  7912. var TestScheduler = (function (_super) {
  7913. __extends(TestScheduler, _super);
  7914. function TestScheduler(assertDeepEqual) {
  7915. var _this = _super.call(this, VirtualAction, defaultMaxFrame) || this;
  7916. _this.assertDeepEqual = assertDeepEqual;
  7917. _this.hotObservables = [];
  7918. _this.coldObservables = [];
  7919. _this.flushTests = [];
  7920. _this.runMode = false;
  7921. return _this;
  7922. }
  7923. TestScheduler.prototype.createTime = function (marbles) {
  7924. var indexOf = marbles.indexOf('|');
  7925. if (indexOf === -1) {
  7926. throw new Error('marble diagram for time should have a completion marker "|"');
  7927. }
  7928. return indexOf * TestScheduler.frameTimeFactor;
  7929. };
  7930. TestScheduler.prototype.createColdObservable = function (marbles, values, error) {
  7931. if (marbles.indexOf('^') !== -1) {
  7932. throw new Error('cold observable cannot have subscription offset "^"');
  7933. }
  7934. if (marbles.indexOf('!') !== -1) {
  7935. throw new Error('cold observable cannot have unsubscription marker "!"');
  7936. }
  7937. var messages = TestScheduler.parseMarbles(marbles, values, error, undefined, this.runMode);
  7938. var cold = new ColdObservable(messages, this);
  7939. this.coldObservables.push(cold);
  7940. return cold;
  7941. };
  7942. TestScheduler.prototype.createHotObservable = function (marbles, values, error) {
  7943. if (marbles.indexOf('!') !== -1) {
  7944. throw new Error('hot observable cannot have unsubscription marker "!"');
  7945. }
  7946. var messages = TestScheduler.parseMarbles(marbles, values, error, undefined, this.runMode);
  7947. var subject = new HotObservable(messages, this);
  7948. this.hotObservables.push(subject);
  7949. return subject;
  7950. };
  7951. TestScheduler.prototype.materializeInnerObservable = function (observable, outerFrame) {
  7952. var _this = this;
  7953. var messages = [];
  7954. observable.subscribe(function (value) {
  7955. messages.push({ frame: _this.frame - outerFrame, notification: Notification.createNext(value) });
  7956. }, function (err) {
  7957. messages.push({ frame: _this.frame - outerFrame, notification: Notification.createError(err) });
  7958. }, function () {
  7959. messages.push({ frame: _this.frame - outerFrame, notification: Notification.createComplete() });
  7960. });
  7961. return messages;
  7962. };
  7963. TestScheduler.prototype.expectObservable = function (observable, subscriptionMarbles) {
  7964. var _this = this;
  7965. if (subscriptionMarbles === void 0) { subscriptionMarbles = null; }
  7966. var actual = [];
  7967. var flushTest = { actual: actual, ready: false };
  7968. var subscriptionParsed = TestScheduler.parseMarblesAsSubscriptions(subscriptionMarbles, this.runMode);
  7969. var subscriptionFrame = subscriptionParsed.subscribedFrame === Number.POSITIVE_INFINITY ?
  7970. 0 : subscriptionParsed.subscribedFrame;
  7971. var unsubscriptionFrame = subscriptionParsed.unsubscribedFrame;
  7972. var subscription;
  7973. this.schedule(function () {
  7974. subscription = observable.subscribe(function (x) {
  7975. var value = x;
  7976. if (x instanceof Observable) {
  7977. value = _this.materializeInnerObservable(value, _this.frame);
  7978. }
  7979. actual.push({ frame: _this.frame, notification: Notification.createNext(value) });
  7980. }, function (err) {
  7981. actual.push({ frame: _this.frame, notification: Notification.createError(err) });
  7982. }, function () {
  7983. actual.push({ frame: _this.frame, notification: Notification.createComplete() });
  7984. });
  7985. }, subscriptionFrame);
  7986. if (unsubscriptionFrame !== Number.POSITIVE_INFINITY) {
  7987. this.schedule(function () { return subscription.unsubscribe(); }, unsubscriptionFrame);
  7988. }
  7989. this.flushTests.push(flushTest);
  7990. var runMode = this.runMode;
  7991. return {
  7992. toBe: function (marbles, values, errorValue) {
  7993. flushTest.ready = true;
  7994. flushTest.expected = TestScheduler.parseMarbles(marbles, values, errorValue, true, runMode);
  7995. }
  7996. };
  7997. };
  7998. TestScheduler.prototype.expectSubscriptions = function (actualSubscriptionLogs) {
  7999. var flushTest = { actual: actualSubscriptionLogs, ready: false };
  8000. this.flushTests.push(flushTest);
  8001. var runMode = this.runMode;
  8002. return {
  8003. toBe: function (marbles) {
  8004. var marblesArray = (typeof marbles === 'string') ? [marbles] : marbles;
  8005. flushTest.ready = true;
  8006. flushTest.expected = marblesArray.map(function (marbles) {
  8007. return TestScheduler.parseMarblesAsSubscriptions(marbles, runMode);
  8008. });
  8009. }
  8010. };
  8011. };
  8012. TestScheduler.prototype.flush = function () {
  8013. var _this = this;
  8014. var hotObservables = this.hotObservables;
  8015. while (hotObservables.length > 0) {
  8016. hotObservables.shift().setup();
  8017. }
  8018. _super.prototype.flush.call(this);
  8019. this.flushTests = this.flushTests.filter(function (test) {
  8020. if (test.ready) {
  8021. _this.assertDeepEqual(test.actual, test.expected);
  8022. return false;
  8023. }
  8024. return true;
  8025. });
  8026. };
  8027. TestScheduler.parseMarblesAsSubscriptions = function (marbles, runMode) {
  8028. var _this = this;
  8029. if (runMode === void 0) { runMode = false; }
  8030. if (typeof marbles !== 'string') {
  8031. return new SubscriptionLog(Number.POSITIVE_INFINITY);
  8032. }
  8033. var len = marbles.length;
  8034. var groupStart = -1;
  8035. var subscriptionFrame = Number.POSITIVE_INFINITY;
  8036. var unsubscriptionFrame = Number.POSITIVE_INFINITY;
  8037. var frame = 0;
  8038. var _loop_1 = function (i) {
  8039. var nextFrame = frame;
  8040. var advanceFrameBy = function (count) {
  8041. nextFrame += count * _this.frameTimeFactor;
  8042. };
  8043. var c = marbles[i];
  8044. switch (c) {
  8045. case ' ':
  8046. if (!runMode) {
  8047. advanceFrameBy(1);
  8048. }
  8049. break;
  8050. case '-':
  8051. advanceFrameBy(1);
  8052. break;
  8053. case '(':
  8054. groupStart = frame;
  8055. advanceFrameBy(1);
  8056. break;
  8057. case ')':
  8058. groupStart = -1;
  8059. advanceFrameBy(1);
  8060. break;
  8061. case '^':
  8062. if (subscriptionFrame !== Number.POSITIVE_INFINITY) {
  8063. throw new Error('found a second subscription point \'^\' in a ' +
  8064. 'subscription marble diagram. There can only be one.');
  8065. }
  8066. subscriptionFrame = groupStart > -1 ? groupStart : frame;
  8067. advanceFrameBy(1);
  8068. break;
  8069. case '!':
  8070. if (unsubscriptionFrame !== Number.POSITIVE_INFINITY) {
  8071. throw new Error('found a second subscription point \'^\' in a ' +
  8072. 'subscription marble diagram. There can only be one.');
  8073. }
  8074. unsubscriptionFrame = groupStart > -1 ? groupStart : frame;
  8075. break;
  8076. default:
  8077. if (runMode && c.match(/^[0-9]$/)) {
  8078. if (i === 0 || marbles[i - 1] === ' ') {
  8079. var buffer = marbles.slice(i);
  8080. var match = buffer.match(/^([0-9]+(?:\.[0-9]+)?)(ms|s|m) /);
  8081. if (match) {
  8082. i += match[0].length - 1;
  8083. var duration = parseFloat(match[1]);
  8084. var unit = match[2];
  8085. var durationInMs = void 0;
  8086. switch (unit) {
  8087. case 'ms':
  8088. durationInMs = duration;
  8089. break;
  8090. case 's':
  8091. durationInMs = duration * 1000;
  8092. break;
  8093. case 'm':
  8094. durationInMs = duration * 1000 * 60;
  8095. break;
  8096. default:
  8097. break;
  8098. }
  8099. advanceFrameBy(durationInMs / this_1.frameTimeFactor);
  8100. break;
  8101. }
  8102. }
  8103. }
  8104. throw new Error('there can only be \'^\' and \'!\' markers in a ' +
  8105. 'subscription marble diagram. Found instead \'' + c + '\'.');
  8106. }
  8107. frame = nextFrame;
  8108. out_i_1 = i;
  8109. };
  8110. var this_1 = this, out_i_1;
  8111. for (var i = 0; i < len; i++) {
  8112. _loop_1(i);
  8113. i = out_i_1;
  8114. }
  8115. if (unsubscriptionFrame < 0) {
  8116. return new SubscriptionLog(subscriptionFrame);
  8117. }
  8118. else {
  8119. return new SubscriptionLog(subscriptionFrame, unsubscriptionFrame);
  8120. }
  8121. };
  8122. TestScheduler.parseMarbles = function (marbles, values, errorValue, materializeInnerObservables, runMode) {
  8123. var _this = this;
  8124. if (materializeInnerObservables === void 0) { materializeInnerObservables = false; }
  8125. if (runMode === void 0) { runMode = false; }
  8126. if (marbles.indexOf('!') !== -1) {
  8127. throw new Error('conventional marble diagrams cannot have the ' +
  8128. 'unsubscription marker "!"');
  8129. }
  8130. var len = marbles.length;
  8131. var testMessages = [];
  8132. var subIndex = runMode ? marbles.replace(/^[ ]+/, '').indexOf('^') : marbles.indexOf('^');
  8133. var frame = subIndex === -1 ? 0 : (subIndex * -this.frameTimeFactor);
  8134. var getValue = typeof values !== 'object' ?
  8135. function (x) { return x; } :
  8136. function (x) {
  8137. if (materializeInnerObservables && values[x] instanceof ColdObservable) {
  8138. return values[x].messages;
  8139. }
  8140. return values[x];
  8141. };
  8142. var groupStart = -1;
  8143. var _loop_2 = function (i) {
  8144. var nextFrame = frame;
  8145. var advanceFrameBy = function (count) {
  8146. nextFrame += count * _this.frameTimeFactor;
  8147. };
  8148. var notification = void 0;
  8149. var c = marbles[i];
  8150. switch (c) {
  8151. case ' ':
  8152. if (!runMode) {
  8153. advanceFrameBy(1);
  8154. }
  8155. break;
  8156. case '-':
  8157. advanceFrameBy(1);
  8158. break;
  8159. case '(':
  8160. groupStart = frame;
  8161. advanceFrameBy(1);
  8162. break;
  8163. case ')':
  8164. groupStart = -1;
  8165. advanceFrameBy(1);
  8166. break;
  8167. case '|':
  8168. notification = Notification.createComplete();
  8169. advanceFrameBy(1);
  8170. break;
  8171. case '^':
  8172. advanceFrameBy(1);
  8173. break;
  8174. case '#':
  8175. notification = Notification.createError(errorValue || 'error');
  8176. advanceFrameBy(1);
  8177. break;
  8178. default:
  8179. if (runMode && c.match(/^[0-9]$/)) {
  8180. if (i === 0 || marbles[i - 1] === ' ') {
  8181. var buffer = marbles.slice(i);
  8182. var match = buffer.match(/^([0-9]+(?:\.[0-9]+)?)(ms|s|m) /);
  8183. if (match) {
  8184. i += match[0].length - 1;
  8185. var duration = parseFloat(match[1]);
  8186. var unit = match[2];
  8187. var durationInMs = void 0;
  8188. switch (unit) {
  8189. case 'ms':
  8190. durationInMs = duration;
  8191. break;
  8192. case 's':
  8193. durationInMs = duration * 1000;
  8194. break;
  8195. case 'm':
  8196. durationInMs = duration * 1000 * 60;
  8197. break;
  8198. default:
  8199. break;
  8200. }
  8201. advanceFrameBy(durationInMs / this_2.frameTimeFactor);
  8202. break;
  8203. }
  8204. }
  8205. }
  8206. notification = Notification.createNext(getValue(c));
  8207. advanceFrameBy(1);
  8208. break;
  8209. }
  8210. if (notification) {
  8211. testMessages.push({ frame: groupStart > -1 ? groupStart : frame, notification: notification });
  8212. }
  8213. frame = nextFrame;
  8214. out_i_2 = i;
  8215. };
  8216. var this_2 = this, out_i_2;
  8217. for (var i = 0; i < len; i++) {
  8218. _loop_2(i);
  8219. i = out_i_2;
  8220. }
  8221. return testMessages;
  8222. };
  8223. TestScheduler.prototype.run = function (callback) {
  8224. var prevFrameTimeFactor = TestScheduler.frameTimeFactor;
  8225. var prevMaxFrames = this.maxFrames;
  8226. TestScheduler.frameTimeFactor = 1;
  8227. this.maxFrames = Number.POSITIVE_INFINITY;
  8228. this.runMode = true;
  8229. AsyncScheduler.delegate = this;
  8230. var helpers = {
  8231. cold: this.createColdObservable.bind(this),
  8232. hot: this.createHotObservable.bind(this),
  8233. flush: this.flush.bind(this),
  8234. expectObservable: this.expectObservable.bind(this),
  8235. expectSubscriptions: this.expectSubscriptions.bind(this),
  8236. };
  8237. try {
  8238. var ret = callback(helpers);
  8239. this.flush();
  8240. return ret;
  8241. }
  8242. finally {
  8243. TestScheduler.frameTimeFactor = prevFrameTimeFactor;
  8244. this.maxFrames = prevMaxFrames;
  8245. this.runMode = false;
  8246. AsyncScheduler.delegate = undefined;
  8247. }
  8248. };
  8249. return TestScheduler;
  8250. }(VirtualTimeScheduler));
  8251. var _testing = Object.freeze({
  8252. TestScheduler: TestScheduler
  8253. });
  8254. var __window = typeof window !== 'undefined' && window;
  8255. var __self = typeof self !== 'undefined' && typeof WorkerGlobalScope !== 'undefined' &&
  8256. self instanceof WorkerGlobalScope && self;
  8257. var __global = typeof global !== 'undefined' && global;
  8258. var _root = __window || __global || __self;
  8259. (function () {
  8260. if (!_root) {
  8261. throw new Error('RxJS could not find any global context (window, self, global)');
  8262. }
  8263. })();
  8264. function getCORSRequest() {
  8265. if (_root.XMLHttpRequest) {
  8266. return new _root.XMLHttpRequest();
  8267. }
  8268. else if (!!_root.XDomainRequest) {
  8269. return new _root.XDomainRequest();
  8270. }
  8271. else {
  8272. throw new Error('CORS is not supported by your browser');
  8273. }
  8274. }
  8275. function getXMLHttpRequest() {
  8276. if (_root.XMLHttpRequest) {
  8277. return new _root.XMLHttpRequest();
  8278. }
  8279. else {
  8280. var progId = void 0;
  8281. try {
  8282. var progIds = ['Msxml2.XMLHTTP', 'Microsoft.XMLHTTP', 'Msxml2.XMLHTTP.4.0'];
  8283. for (var i = 0; i < 3; i++) {
  8284. try {
  8285. progId = progIds[i];
  8286. if (new _root.ActiveXObject(progId)) {
  8287. break;
  8288. }
  8289. }
  8290. catch (e) {
  8291. }
  8292. }
  8293. return new _root.ActiveXObject(progId);
  8294. }
  8295. catch (e) {
  8296. throw new Error('XMLHttpRequest is not supported by your browser');
  8297. }
  8298. }
  8299. }
  8300. function ajaxGet(url, headers) {
  8301. if (headers === void 0) { headers = null; }
  8302. return new AjaxObservable({ method: 'GET', url: url, headers: headers });
  8303. }
  8304. function ajaxPost(url, body, headers) {
  8305. return new AjaxObservable({ method: 'POST', url: url, body: body, headers: headers });
  8306. }
  8307. function ajaxDelete(url, headers) {
  8308. return new AjaxObservable({ method: 'DELETE', url: url, headers: headers });
  8309. }
  8310. function ajaxPut(url, body, headers) {
  8311. return new AjaxObservable({ method: 'PUT', url: url, body: body, headers: headers });
  8312. }
  8313. function ajaxPatch(url, body, headers) {
  8314. return new AjaxObservable({ method: 'PATCH', url: url, body: body, headers: headers });
  8315. }
  8316. var mapResponse = map(function (x, index) { return x.response; });
  8317. function ajaxGetJSON(url, headers) {
  8318. return mapResponse(new AjaxObservable({
  8319. method: 'GET',
  8320. url: url,
  8321. responseType: 'json',
  8322. headers: headers
  8323. }));
  8324. }
  8325. var AjaxObservable = (function (_super) {
  8326. __extends(AjaxObservable, _super);
  8327. function AjaxObservable(urlOrRequest) {
  8328. var _this = _super.call(this) || this;
  8329. var request = {
  8330. async: true,
  8331. createXHR: function () {
  8332. return this.crossDomain ? getCORSRequest() : getXMLHttpRequest();
  8333. },
  8334. crossDomain: true,
  8335. withCredentials: false,
  8336. headers: {},
  8337. method: 'GET',
  8338. responseType: 'json',
  8339. timeout: 0
  8340. };
  8341. if (typeof urlOrRequest === 'string') {
  8342. request.url = urlOrRequest;
  8343. }
  8344. else {
  8345. for (var prop in urlOrRequest) {
  8346. if (urlOrRequest.hasOwnProperty(prop)) {
  8347. request[prop] = urlOrRequest[prop];
  8348. }
  8349. }
  8350. }
  8351. _this.request = request;
  8352. return _this;
  8353. }
  8354. AjaxObservable.prototype._subscribe = function (subscriber) {
  8355. return new AjaxSubscriber(subscriber, this.request);
  8356. };
  8357. AjaxObservable.create = (function () {
  8358. var create = function (urlOrRequest) {
  8359. return new AjaxObservable(urlOrRequest);
  8360. };
  8361. create.get = ajaxGet;
  8362. create.post = ajaxPost;
  8363. create.delete = ajaxDelete;
  8364. create.put = ajaxPut;
  8365. create.patch = ajaxPatch;
  8366. create.getJSON = ajaxGetJSON;
  8367. return create;
  8368. })();
  8369. return AjaxObservable;
  8370. }(Observable));
  8371. var AjaxSubscriber = (function (_super) {
  8372. __extends(AjaxSubscriber, _super);
  8373. function AjaxSubscriber(destination, request) {
  8374. var _this = _super.call(this, destination) || this;
  8375. _this.request = request;
  8376. _this.done = false;
  8377. var headers = request.headers = request.headers || {};
  8378. if (!request.crossDomain && !headers['X-Requested-With']) {
  8379. headers['X-Requested-With'] = 'XMLHttpRequest';
  8380. }
  8381. if (!('Content-Type' in headers) && !(_root.FormData && request.body instanceof _root.FormData) && typeof request.body !== 'undefined') {
  8382. headers['Content-Type'] = 'application/x-www-form-urlencoded; charset=UTF-8';
  8383. }
  8384. request.body = _this.serializeBody(request.body, request.headers['Content-Type']);
  8385. _this.send();
  8386. return _this;
  8387. }
  8388. AjaxSubscriber.prototype.next = function (e) {
  8389. this.done = true;
  8390. var _a = this, xhr = _a.xhr, request = _a.request, destination = _a.destination;
  8391. var response = new AjaxResponse(e, xhr, request);
  8392. if (response.response === errorObject) {
  8393. destination.error(errorObject.e);
  8394. }
  8395. else {
  8396. destination.next(response);
  8397. }
  8398. };
  8399. AjaxSubscriber.prototype.send = function () {
  8400. var _a = this, request = _a.request, _b = _a.request, user = _b.user, method = _b.method, url = _b.url, async = _b.async, password = _b.password, headers = _b.headers, body = _b.body;
  8401. var createXHR = request.createXHR;
  8402. var xhr = tryCatch(createXHR).call(request);
  8403. if (xhr === errorObject) {
  8404. this.error(errorObject.e);
  8405. }
  8406. else {
  8407. this.xhr = xhr;
  8408. this.setupEvents(xhr, request);
  8409. var result = void 0;
  8410. if (user) {
  8411. result = tryCatch(xhr.open).call(xhr, method, url, async, user, password);
  8412. }
  8413. else {
  8414. result = tryCatch(xhr.open).call(xhr, method, url, async);
  8415. }
  8416. if (result === errorObject) {
  8417. this.error(errorObject.e);
  8418. return null;
  8419. }
  8420. if (async) {
  8421. xhr.timeout = request.timeout;
  8422. xhr.responseType = request.responseType;
  8423. }
  8424. if ('withCredentials' in xhr) {
  8425. xhr.withCredentials = !!request.withCredentials;
  8426. }
  8427. this.setHeaders(xhr, headers);
  8428. result = body ? tryCatch(xhr.send).call(xhr, body) : tryCatch(xhr.send).call(xhr);
  8429. if (result === errorObject) {
  8430. this.error(errorObject.e);
  8431. return null;
  8432. }
  8433. }
  8434. return xhr;
  8435. };
  8436. AjaxSubscriber.prototype.serializeBody = function (body, contentType) {
  8437. if (!body || typeof body === 'string') {
  8438. return body;
  8439. }
  8440. else if (_root.FormData && body instanceof _root.FormData) {
  8441. return body;
  8442. }
  8443. if (contentType) {
  8444. var splitIndex = contentType.indexOf(';');
  8445. if (splitIndex !== -1) {
  8446. contentType = contentType.substring(0, splitIndex);
  8447. }
  8448. }
  8449. switch (contentType) {
  8450. case 'application/x-www-form-urlencoded':
  8451. return Object.keys(body).map(function (key) { return encodeURIComponent(key) + "=" + encodeURIComponent(body[key]); }).join('&');
  8452. case 'application/json':
  8453. return JSON.stringify(body);
  8454. default:
  8455. return body;
  8456. }
  8457. };
  8458. AjaxSubscriber.prototype.setHeaders = function (xhr, headers) {
  8459. for (var key in headers) {
  8460. if (headers.hasOwnProperty(key)) {
  8461. xhr.setRequestHeader(key, headers[key]);
  8462. }
  8463. }
  8464. };
  8465. AjaxSubscriber.prototype.setupEvents = function (xhr, request) {
  8466. var progressSubscriber = request.progressSubscriber;
  8467. function xhrTimeout(e) {
  8468. var _a = xhrTimeout, subscriber = _a.subscriber, progressSubscriber = _a.progressSubscriber, request = _a.request;
  8469. if (progressSubscriber) {
  8470. progressSubscriber.error(e);
  8471. }
  8472. var ajaxTimeoutError = new AjaxTimeoutError(this, request);
  8473. if (ajaxTimeoutError.response === errorObject) {
  8474. subscriber.error(errorObject.e);
  8475. }
  8476. else {
  8477. subscriber.error(ajaxTimeoutError);
  8478. }
  8479. }
  8480. xhr.ontimeout = xhrTimeout;
  8481. xhrTimeout.request = request;
  8482. xhrTimeout.subscriber = this;
  8483. xhrTimeout.progressSubscriber = progressSubscriber;
  8484. if (xhr.upload && 'withCredentials' in xhr) {
  8485. if (progressSubscriber) {
  8486. var xhrProgress_1;
  8487. xhrProgress_1 = function (e) {
  8488. var progressSubscriber = xhrProgress_1.progressSubscriber;
  8489. progressSubscriber.next(e);
  8490. };
  8491. if (_root.XDomainRequest) {
  8492. xhr.onprogress = xhrProgress_1;
  8493. }
  8494. else {
  8495. xhr.upload.onprogress = xhrProgress_1;
  8496. }
  8497. xhrProgress_1.progressSubscriber = progressSubscriber;
  8498. }
  8499. var xhrError_1;
  8500. xhrError_1 = function (e) {
  8501. var _a = xhrError_1, progressSubscriber = _a.progressSubscriber, subscriber = _a.subscriber, request = _a.request;
  8502. if (progressSubscriber) {
  8503. progressSubscriber.error(e);
  8504. }
  8505. var ajaxError = new AjaxError('ajax error', this, request);
  8506. if (ajaxError.response === errorObject) {
  8507. subscriber.error(errorObject.e);
  8508. }
  8509. else {
  8510. subscriber.error(ajaxError);
  8511. }
  8512. };
  8513. xhr.onerror = xhrError_1;
  8514. xhrError_1.request = request;
  8515. xhrError_1.subscriber = this;
  8516. xhrError_1.progressSubscriber = progressSubscriber;
  8517. }
  8518. function xhrReadyStateChange(e) {
  8519. return;
  8520. }
  8521. xhr.onreadystatechange = xhrReadyStateChange;
  8522. xhrReadyStateChange.subscriber = this;
  8523. xhrReadyStateChange.progressSubscriber = progressSubscriber;
  8524. xhrReadyStateChange.request = request;
  8525. function xhrLoad(e) {
  8526. var _a = xhrLoad, subscriber = _a.subscriber, progressSubscriber = _a.progressSubscriber, request = _a.request;
  8527. if (this.readyState === 4) {
  8528. var status_1 = this.status === 1223 ? 204 : this.status;
  8529. var response = (this.responseType === 'text' ? (this.response || this.responseText) : this.response);
  8530. if (status_1 === 0) {
  8531. status_1 = response ? 200 : 0;
  8532. }
  8533. if (status_1 < 400) {
  8534. if (progressSubscriber) {
  8535. progressSubscriber.complete();
  8536. }
  8537. subscriber.next(e);
  8538. subscriber.complete();
  8539. }
  8540. else {
  8541. if (progressSubscriber) {
  8542. progressSubscriber.error(e);
  8543. }
  8544. var ajaxError = new AjaxError('ajax error ' + status_1, this, request);
  8545. if (ajaxError.response === errorObject) {
  8546. subscriber.error(errorObject.e);
  8547. }
  8548. else {
  8549. subscriber.error(ajaxError);
  8550. }
  8551. }
  8552. }
  8553. }
  8554. xhr.onload = xhrLoad;
  8555. xhrLoad.subscriber = this;
  8556. xhrLoad.progressSubscriber = progressSubscriber;
  8557. xhrLoad.request = request;
  8558. };
  8559. AjaxSubscriber.prototype.unsubscribe = function () {
  8560. var _a = this, done = _a.done, xhr = _a.xhr;
  8561. if (!done && xhr && xhr.readyState !== 4 && typeof xhr.abort === 'function') {
  8562. xhr.abort();
  8563. }
  8564. _super.prototype.unsubscribe.call(this);
  8565. };
  8566. return AjaxSubscriber;
  8567. }(Subscriber));
  8568. var AjaxResponse = (function () {
  8569. function AjaxResponse(originalEvent, xhr, request) {
  8570. this.originalEvent = originalEvent;
  8571. this.xhr = xhr;
  8572. this.request = request;
  8573. this.status = xhr.status;
  8574. this.responseType = xhr.responseType || request.responseType;
  8575. this.response = parseXhrResponse(this.responseType, xhr);
  8576. }
  8577. return AjaxResponse;
  8578. }());
  8579. function AjaxErrorImpl(message, xhr, request) {
  8580. Error.call(this);
  8581. this.message = message;
  8582. this.name = 'AjaxError';
  8583. this.xhr = xhr;
  8584. this.request = request;
  8585. this.status = xhr.status;
  8586. this.responseType = xhr.responseType || request.responseType;
  8587. this.response = parseXhrResponse(this.responseType, xhr);
  8588. return this;
  8589. }
  8590. AjaxErrorImpl.prototype = Object.create(Error.prototype);
  8591. var AjaxError = AjaxErrorImpl;
  8592. function parseJson(xhr) {
  8593. if ('response' in xhr) {
  8594. return xhr.responseType ? xhr.response : JSON.parse(xhr.response || xhr.responseText || 'null');
  8595. }
  8596. else {
  8597. return JSON.parse(xhr.responseText || 'null');
  8598. }
  8599. }
  8600. function parseXhrResponse(responseType, xhr) {
  8601. switch (responseType) {
  8602. case 'json':
  8603. return tryCatch(parseJson)(xhr);
  8604. case 'xml':
  8605. return xhr.responseXML;
  8606. case 'text':
  8607. default:
  8608. return ('response' in xhr) ? xhr.response : xhr.responseText;
  8609. }
  8610. }
  8611. function AjaxTimeoutErrorImpl(xhr, request) {
  8612. AjaxError.call(this, 'ajax timeout', xhr, request);
  8613. this.name = 'AjaxTimeoutError';
  8614. return this;
  8615. }
  8616. var AjaxTimeoutError = AjaxTimeoutErrorImpl;
  8617. var ajax$1 = AjaxObservable.create;
  8618. var _ajax = Object.freeze({
  8619. ajax: ajax$1,
  8620. AjaxResponse: AjaxResponse,
  8621. AjaxError: AjaxError,
  8622. AjaxTimeoutError: AjaxTimeoutError
  8623. });
  8624. var DEFAULT_WEBSOCKET_CONFIG = {
  8625. url: '',
  8626. deserializer: function (e) { return JSON.parse(e.data); },
  8627. serializer: function (value) { return JSON.stringify(value); },
  8628. };
  8629. var WEBSOCKETSUBJECT_INVALID_ERROR_OBJECT = 'WebSocketSubject.error must be called with an object with an error code, and an optional reason: { code: number, reason: string }';
  8630. var WebSocketSubject = (function (_super) {
  8631. __extends(WebSocketSubject, _super);
  8632. function WebSocketSubject(urlConfigOrSource, destination) {
  8633. var _this = _super.call(this) || this;
  8634. if (urlConfigOrSource instanceof Observable) {
  8635. _this.destination = destination;
  8636. _this.source = urlConfigOrSource;
  8637. }
  8638. else {
  8639. var config = _this._config = __assign({}, DEFAULT_WEBSOCKET_CONFIG);
  8640. _this._output = new Subject();
  8641. if (typeof urlConfigOrSource === 'string') {
  8642. config.url = urlConfigOrSource;
  8643. }
  8644. else {
  8645. for (var key in urlConfigOrSource) {
  8646. if (urlConfigOrSource.hasOwnProperty(key)) {
  8647. config[key] = urlConfigOrSource[key];
  8648. }
  8649. }
  8650. }
  8651. if (!config.WebSocketCtor && WebSocket) {
  8652. config.WebSocketCtor = WebSocket;
  8653. }
  8654. else if (!config.WebSocketCtor) {
  8655. throw new Error('no WebSocket constructor can be found');
  8656. }
  8657. _this.destination = new ReplaySubject();
  8658. }
  8659. return _this;
  8660. }
  8661. WebSocketSubject.prototype.lift = function (operator) {
  8662. var sock = new WebSocketSubject(this._config, this.destination);
  8663. sock.operator = operator;
  8664. sock.source = this;
  8665. return sock;
  8666. };
  8667. WebSocketSubject.prototype._resetState = function () {
  8668. this._socket = null;
  8669. if (!this.source) {
  8670. this.destination = new ReplaySubject();
  8671. }
  8672. this._output = new Subject();
  8673. };
  8674. WebSocketSubject.prototype.multiplex = function (subMsg, unsubMsg, messageFilter) {
  8675. var self = this;
  8676. return new Observable(function (observer) {
  8677. var result = tryCatch(subMsg)();
  8678. if (result === errorObject) {
  8679. observer.error(errorObject.e);
  8680. }
  8681. else {
  8682. self.next(result);
  8683. }
  8684. var subscription = self.subscribe(function (x) {
  8685. var result = tryCatch(messageFilter)(x);
  8686. if (result === errorObject) {
  8687. observer.error(errorObject.e);
  8688. }
  8689. else if (result) {
  8690. observer.next(x);
  8691. }
  8692. }, function (err) { return observer.error(err); }, function () { return observer.complete(); });
  8693. return function () {
  8694. var result = tryCatch(unsubMsg)();
  8695. if (result === errorObject) {
  8696. observer.error(errorObject.e);
  8697. }
  8698. else {
  8699. self.next(result);
  8700. }
  8701. subscription.unsubscribe();
  8702. };
  8703. });
  8704. };
  8705. WebSocketSubject.prototype._connectSocket = function () {
  8706. var _this = this;
  8707. var _a = this._config, WebSocketCtor = _a.WebSocketCtor, protocol = _a.protocol, url = _a.url, binaryType = _a.binaryType;
  8708. var observer = this._output;
  8709. var socket = null;
  8710. try {
  8711. socket = protocol ?
  8712. new WebSocketCtor(url, protocol) :
  8713. new WebSocketCtor(url);
  8714. this._socket = socket;
  8715. if (binaryType) {
  8716. this._socket.binaryType = binaryType;
  8717. }
  8718. }
  8719. catch (e) {
  8720. observer.error(e);
  8721. return;
  8722. }
  8723. var subscription = new Subscription(function () {
  8724. _this._socket = null;
  8725. if (socket && socket.readyState === 1) {
  8726. socket.close();
  8727. }
  8728. });
  8729. socket.onopen = function (e) {
  8730. var openObserver = _this._config.openObserver;
  8731. if (openObserver) {
  8732. openObserver.next(e);
  8733. }
  8734. var queue = _this.destination;
  8735. _this.destination = Subscriber.create(function (x) {
  8736. if (socket.readyState === 1) {
  8737. var serializer = _this._config.serializer;
  8738. var msg = tryCatch(serializer)(x);
  8739. if (msg === errorObject) {
  8740. _this.destination.error(errorObject.e);
  8741. return;
  8742. }
  8743. socket.send(msg);
  8744. }
  8745. }, function (e) {
  8746. var closingObserver = _this._config.closingObserver;
  8747. if (closingObserver) {
  8748. closingObserver.next(undefined);
  8749. }
  8750. if (e && e.code) {
  8751. socket.close(e.code, e.reason);
  8752. }
  8753. else {
  8754. observer.error(new TypeError(WEBSOCKETSUBJECT_INVALID_ERROR_OBJECT));
  8755. }
  8756. _this._resetState();
  8757. }, function () {
  8758. var closingObserver = _this._config.closingObserver;
  8759. if (closingObserver) {
  8760. closingObserver.next(undefined);
  8761. }
  8762. socket.close();
  8763. _this._resetState();
  8764. });
  8765. if (queue && queue instanceof ReplaySubject) {
  8766. subscription.add(queue.subscribe(_this.destination));
  8767. }
  8768. };
  8769. socket.onerror = function (e) {
  8770. _this._resetState();
  8771. observer.error(e);
  8772. };
  8773. socket.onclose = function (e) {
  8774. _this._resetState();
  8775. var closeObserver = _this._config.closeObserver;
  8776. if (closeObserver) {
  8777. closeObserver.next(e);
  8778. }
  8779. if (e.wasClean) {
  8780. observer.complete();
  8781. }
  8782. else {
  8783. observer.error(e);
  8784. }
  8785. };
  8786. socket.onmessage = function (e) {
  8787. var deserializer = _this._config.deserializer;
  8788. var result = tryCatch(deserializer)(e);
  8789. if (result === errorObject) {
  8790. observer.error(errorObject.e);
  8791. }
  8792. else {
  8793. observer.next(result);
  8794. }
  8795. };
  8796. };
  8797. WebSocketSubject.prototype._subscribe = function (subscriber) {
  8798. var _this = this;
  8799. var source = this.source;
  8800. if (source) {
  8801. return source.subscribe(subscriber);
  8802. }
  8803. if (!this._socket) {
  8804. this._connectSocket();
  8805. }
  8806. this._output.subscribe(subscriber);
  8807. subscriber.add(function () {
  8808. var _socket = _this._socket;
  8809. if (_this._output.observers.length === 0) {
  8810. if (_socket && _socket.readyState === 1) {
  8811. _socket.close();
  8812. }
  8813. _this._resetState();
  8814. }
  8815. });
  8816. return subscriber;
  8817. };
  8818. WebSocketSubject.prototype.unsubscribe = function () {
  8819. var _a = this, source = _a.source, _socket = _a._socket;
  8820. if (_socket && _socket.readyState === 1) {
  8821. _socket.close();
  8822. this._resetState();
  8823. }
  8824. _super.prototype.unsubscribe.call(this);
  8825. if (!source) {
  8826. this.destination = new ReplaySubject();
  8827. }
  8828. };
  8829. return WebSocketSubject;
  8830. }(AnonymousSubject));
  8831. function webSocket$1(urlConfigOrSource) {
  8832. return new WebSocketSubject(urlConfigOrSource);
  8833. }
  8834. var _webSocket = Object.freeze({
  8835. webSocket: webSocket$1,
  8836. WebSocketSubject: WebSocketSubject
  8837. });
  8838. var operators = _operators;
  8839. var testing = _testing;
  8840. var ajax$$1 = _ajax;
  8841. var webSocket$$1 = _webSocket;
  8842. exports.operators = operators;
  8843. exports.testing = testing;
  8844. exports.ajax = ajax$$1;
  8845. exports.webSocket = webSocket$$1;
  8846. exports.Observable = Observable;
  8847. exports.ConnectableObservable = ConnectableObservable;
  8848. exports.GroupedObservable = GroupedObservable;
  8849. exports.observable = observable;
  8850. exports.Subject = Subject;
  8851. exports.BehaviorSubject = BehaviorSubject;
  8852. exports.ReplaySubject = ReplaySubject;
  8853. exports.AsyncSubject = AsyncSubject;
  8854. exports.asapScheduler = asap;
  8855. exports.asyncScheduler = async;
  8856. exports.queueScheduler = queue;
  8857. exports.animationFrameScheduler = animationFrame;
  8858. exports.VirtualTimeScheduler = VirtualTimeScheduler;
  8859. exports.VirtualAction = VirtualAction;
  8860. exports.Scheduler = Scheduler;
  8861. exports.Subscription = Subscription;
  8862. exports.Subscriber = Subscriber;
  8863. exports.Notification = Notification;
  8864. exports.pipe = pipe;
  8865. exports.noop = noop;
  8866. exports.identity = identity;
  8867. exports.isObservable = isObservable;
  8868. exports.ArgumentOutOfRangeError = ArgumentOutOfRangeError;
  8869. exports.EmptyError = EmptyError;
  8870. exports.ObjectUnsubscribedError = ObjectUnsubscribedError;
  8871. exports.UnsubscriptionError = UnsubscriptionError;
  8872. exports.TimeoutError = TimeoutError;
  8873. exports.bindCallback = bindCallback;
  8874. exports.bindNodeCallback = bindNodeCallback;
  8875. exports.combineLatest = combineLatest;
  8876. exports.concat = concat;
  8877. exports.defer = defer;
  8878. exports.empty = empty$1;
  8879. exports.forkJoin = forkJoin;
  8880. exports.from = from;
  8881. exports.fromEvent = fromEvent;
  8882. exports.fromEventPattern = fromEventPattern;
  8883. exports.generate = generate;
  8884. exports.iif = iif;
  8885. exports.interval = interval;
  8886. exports.merge = merge;
  8887. exports.never = never;
  8888. exports.of = of;
  8889. exports.onErrorResumeNext = onErrorResumeNext;
  8890. exports.pairs = pairs;
  8891. exports.race = race;
  8892. exports.range = range;
  8893. exports.throwError = throwError;
  8894. exports.timer = timer;
  8895. exports.using = using;
  8896. exports.zip = zip;
  8897. exports.EMPTY = EMPTY;
  8898. exports.NEVER = NEVER;
  8899. exports.config = config;
  8900. Object.defineProperty(exports, '__esModule', { value: true });
  8901. })));