rxjs.umd.js 365 KB

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